Explorar o código

Data Recv Confirm Check Jum API not excute

PYJ %!s(int64=5) %!d(string=hai) anos
pai
achega
0606068465

+ 80 - 0
.code_review_properties

@@ -0,0 +1,80 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<Property>
3
+  <Review id="DEFAULT">
4
+    <Description>property.default.description</Description>
5
+    <Author/>
6
+    <CreationDate format="yyyy-MM-dd :: HH:mm:ss:SSS z">1970-01-01 :: 00:00:00:000 GMT-10:00</CreationDate>
7
+    <Directory>review</Directory>
8
+    <Reviewers/>
9
+    <Files/>
10
+    <FieldItems>
11
+      <FieldItem id="Type" default="item.label.unset">
12
+        <Entry name="item.label.unset" />        
13
+        <Entry name="item.type.label.codingStandards" />
14
+        <Entry name="item.type.label.programLogic" />
15
+        <Entry name="item.type.label.optimization" />
16
+        <Entry name="item.type.label.usability" />
17
+        <Entry name="item.type.label.clarity" />
18
+        <Entry name="item.type.label.missing" />
19
+        <Entry name="item.type.label.irrelevant" />
20
+        <Entry name="item.type.label.suggestion" />
21
+        <Entry name="item.type.label.other" />
22
+      </FieldItem>
23
+      <FieldItem id="Severity" default="item.label.unset">
24
+        <Entry name="item.label.unset" />
25
+        <Entry name="item.severity.label.critical" />
26
+        <Entry name="item.severity.label.major" />
27
+        <Entry name="item.severity.label.normal" />
28
+        <Entry name="item.severity.label.minor" />
29
+        <Entry name="item.severity.label.trivial" />
30
+      </FieldItem>
31
+      <FieldItem id="Resolution" default="item.label.unset">
32
+        <Entry name="item.label.unset" />
33
+        <Entry name="item.resolution.label.validNeedsfixing" />
34
+        <Entry name="item.resolution.label.validFixlater" />
35
+        <Entry name="item.resolution.label.validDuplicate" />
36
+        <Entry name="item.resolution.label.validWontfix" />
37
+        <Entry name="item.resolution.label.invalidWontfix" />
38
+        <Entry name="item.resolution.label.unsureValidity" />
39
+      </FieldItem>
40
+      <FieldItem id="Status" default="item.status.label.open">
41
+        <Entry name="item.status.label.open" />
42
+        <Entry name="item.status.label.resolved" />
43
+        <Entry name="item.status.label.closed" />
44
+        <Entry name="item.status.label.reopened" />        
45
+      </FieldItem>
46
+    </FieldItems>
47
+    <Filters>
48
+      <Phase name="phase.individual" enabled="true">
49
+        <Filter name="Interval" value="7" enabled="false" />
50
+        <Filter name="Reviewer" value="item.reviewer.label.automatic" enabled="true" />
51
+        <Filter name="Type" value="item.label.unset" enabled="false" />
52
+        <Filter name="Severity" value="item.label.unset" enabled="false" />
53
+        <Filter name="AssignedTo" value="" enabled="false" />
54
+        <Filter name="Resolution" value="item.label.unset" enabled="false" />
55
+        <Filter name="Status" value="item.status.label.open" enabled="false" />
56
+        <Filter name="File" value="" enabled="false" />
57
+      </Phase>
58
+      <Phase name="phase.team" enabled="true">
59
+        <Filter name="Interval" value="7" enabled="false" />
60
+        <Filter name="Reviewer" value="" enabled="false" />
61
+        <Filter name="Type" value="item.label.unset" enabled="false" />
62
+        <Filter name="Severity" value="item.label.unset" enabled="false" />
63
+        <Filter name="AssignedTo" value="" enabled="false" />
64
+        <Filter name="Resolution" value="item.label.unset" enabled="true" />
65
+        <Filter name="Status" value="item.status.label.open" enabled="false" />
66
+        <Filter name="File" value="" enabled="false" />
67
+      </Phase>
68
+      <Phase name="phase.rework" enabled="true">
69
+        <Filter name="Interval" value="7" enabled="false" />
70
+        <Filter name="Reviewer" value="" enabled="false" />
71
+        <Filter name="Type" value="item.label.unset" enabled="false" />
72
+        <Filter name="Severity" value="item.label.unset" enabled="false" />
73
+        <Filter name="AssignedTo" value="item.reviewer.label.automatic" enabled="true" />
74
+        <Filter name="Resolution" value="item.label.unset" enabled="false" />
75
+        <Filter name="Status" value="item.status.label.open" enabled="true" />
76
+        <Filter name="File" value="" enabled="false" />
77
+      </Phase>
78
+    </Filters>
79
+  </Review>
80
+</Property>

+ 2 - 2
.settings/language.settings.xml

@@ -4,7 +4,7 @@
4 4
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
5 5
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
6 6
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
7
-			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1681877287601945682" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
7
+			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="800489075853895203" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
8 8
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
9 9
 				<language-scope id="org.eclipse.cdt.core.g++"/>
10 10
 			</provider>
@@ -14,7 +14,7 @@
14 14
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
15 15
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
16 16
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
17
-			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1681877287601945682" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
17
+			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="800489075853895203" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
18 18
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
19 19
 				<language-scope id="org.eclipse.cdt.core.g++"/>
20 20
 			</provider>

BIN=BIN
Debug/STM32F103_ATTEN_PLL_Zig.elf


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 877 - 819
Debug/STM32F103_ATTEN_PLL_Zig.hex


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 5438 - 4951
Debug/STM32F103_ATTEN_PLL_Zig.list


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 572 - 557
Debug/STM32F103_ATTEN_PLL_Zig.map


+ 5 - 5
Debug/Src/main.su

@@ -1,5 +1,5 @@
1
-main.c:74:6:HAL_TIM_PeriodElapsedCallback	0	static
2
-main.c:83:5:_write	8	static
3
-main.c:161:6:SystemClock_Config	72	static
4
-main.c:99:5:main	40	static
5
-main.c:362:6:Error_Handler	0	static
1
+main.c:77:6:HAL_TIM_PeriodElapsedCallback	0	static
2
+main.c:86:5:_write	8	static
3
+main.c:166:6:SystemClock_Config	72	static
4
+main.c:102:5:main	40	static
5
+main.c:406:6:Error_Handler	0	static

BIN=BIN
Debug/Src/stm32f1xx_hal_msp.o


+ 7 - 7
Debug/Src/stm32f1xx_hal_msp.su

@@ -1,7 +1,7 @@
1
-stm32f1xx_hal_msp.c:67:6:HAL_MspInit	8	static
2
-stm32f1xx_hal_msp.c:93:6:HAL_I2C_MspInit	32	static
3
-stm32f1xx_hal_msp.c:127:6:HAL_I2C_MspDeInit	0	static
4
-stm32f1xx_hal_msp.c:156:6:HAL_TIM_Base_MspInit	8	static
5
-stm32f1xx_hal_msp.c:178:6:HAL_TIM_Base_MspDeInit	0	static
6
-stm32f1xx_hal_msp.c:203:6:HAL_UART_MspInit	40	static
7
-stm32f1xx_hal_msp.c:275:6:HAL_UART_MspDeInit	8	static
1
+stm32f1xx_hal_msp.c:69:6:HAL_MspInit	8	static
2
+stm32f1xx_hal_msp.c:95:6:HAL_I2C_MspInit	32	static
3
+stm32f1xx_hal_msp.c:129:6:HAL_I2C_MspDeInit	0	static
4
+stm32f1xx_hal_msp.c:158:6:HAL_TIM_Base_MspInit	8	static
5
+stm32f1xx_hal_msp.c:180:6:HAL_TIM_Base_MspDeInit	0	static
6
+stm32f1xx_hal_msp.c:205:6:HAL_UART_MspInit	48	static
7
+stm32f1xx_hal_msp.c:321:6:HAL_UART_MspDeInit	8	static

BIN=BIN
Debug/Src/stm32f1xx_it.o


+ 15 - 13
Debug/Src/stm32f1xx_it.su

@@ -1,13 +1,15 @@
1
-stm32f1xx_it.c:73:6:NMI_Handler	0	static
2
-stm32f1xx_it.c:86:6:HardFault_Handler	0	static
3
-stm32f1xx_it.c:101:6:MemManage_Handler	0	static
4
-stm32f1xx_it.c:116:6:BusFault_Handler	0	static
5
-stm32f1xx_it.c:131:6:UsageFault_Handler	0	static
6
-stm32f1xx_it.c:146:6:SVC_Handler	0	static
7
-stm32f1xx_it.c:159:6:DebugMon_Handler	0	static
8
-stm32f1xx_it.c:172:6:PendSV_Handler	0	static
9
-stm32f1xx_it.c:185:6:SysTick_Handler	0	static
10
-stm32f1xx_it.c:206:6:DMA1_Channel4_IRQHandler	0	static
11
-stm32f1xx_it.c:220:6:DMA1_Channel5_IRQHandler	0	static
12
-stm32f1xx_it.c:234:6:USART1_IRQHandler	0	static
13
-stm32f1xx_it.c:248:6:TIM6_IRQHandler	0	static
1
+stm32f1xx_it.c:75:6:NMI_Handler	0	static
2
+stm32f1xx_it.c:88:6:HardFault_Handler	0	static
3
+stm32f1xx_it.c:103:6:MemManage_Handler	0	static
4
+stm32f1xx_it.c:118:6:BusFault_Handler	0	static
5
+stm32f1xx_it.c:133:6:UsageFault_Handler	0	static
6
+stm32f1xx_it.c:148:6:SVC_Handler	0	static
7
+stm32f1xx_it.c:161:6:DebugMon_Handler	0	static
8
+stm32f1xx_it.c:174:6:PendSV_Handler	0	static
9
+stm32f1xx_it.c:187:6:SysTick_Handler	0	static
10
+stm32f1xx_it.c:208:6:DMA1_Channel4_IRQHandler	0	static
11
+stm32f1xx_it.c:222:6:DMA1_Channel5_IRQHandler	0	static
12
+stm32f1xx_it.c:236:6:DMA1_Channel6_IRQHandler	0	static
13
+stm32f1xx_it.c:250:6:USART1_IRQHandler	0	static
14
+stm32f1xx_it.c:264:6:USART2_IRQHandler	0	static
15
+stm32f1xx_it.c:278:6:TIM6_IRQHandler	0	static

+ 1 - 1
Inc/Bootloader.h

@@ -23,7 +23,7 @@ typedef enum updateseqok
23 23
     UpdateStartOK,
24 24
     UpdateSendingOK,
25 25
     UpdateEndOK,
26
-};
26
+}bluecell_update_t;
27 27
 typedef enum{
28 28
     bluecell_stx = 0,
29 29
     bluecell_type = 1,

+ 2 - 0
Inc/stm32f1xx_it.h

@@ -58,7 +58,9 @@ void PendSV_Handler(void);
58 58
 void SysTick_Handler(void);
59 59
 void DMA1_Channel4_IRQHandler(void);
60 60
 void DMA1_Channel5_IRQHandler(void);
61
+void DMA1_Channel6_IRQHandler(void);
61 62
 void USART1_IRQHandler(void);
63
+void USART2_IRQHandler(void);
62 64
 void TIM6_IRQHandler(void);
63 65
 /* USER CODE BEGIN EFP */
64 66
 

+ 1 - 1
STM32F103ZE_FLASH.ld

@@ -41,7 +41,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
41 41
 MEMORY
42 42
 {
43 43
 RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 64K
44
-FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 20K
44
+FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 512K
45 45
 }
46 46
 
47 47
 /* Define output sections */

+ 2 - 2
STM32F103_ATTEN_PLL_Zig.elf.launch

@@ -43,7 +43,7 @@
43 43
 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
44 44
 <listEntry value="4"/>
45 45
 </listAttribute>
46
-<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;&#13;&#10;"/>
46
+<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536873172&quot; label=&quot;data&quot;/&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536873172&quot; label=&quot;data&quot;/&gt;&#13;&#10;&lt;/memoryBlockExpressionList&gt;&#13;&#10;"/>
47 47
 <stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
48
-<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="update_data_buf,data"/>
48
+<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="update_data_buf,data,uart_buf"/>
49 49
 </launchConfiguration>

+ 33 - 12
STM32F103_ATTEN_PLL_Zig.ioc

@@ -1,7 +1,8 @@
1 1
 #MicroXplorer Configuration settings - do not modify
2 2
 Dma.Request0=USART1_RX
3 3
 Dma.Request1=USART1_TX
4
-Dma.RequestsNb=2
4
+Dma.Request2=USART2_RX
5
+Dma.RequestsNb=3
5 6
 Dma.USART1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
6 7
 Dma.USART1_RX.0.Instance=DMA1_Channel5
7 8
 Dma.USART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
@@ -20,6 +21,15 @@ Dma.USART1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
20 21
 Dma.USART1_TX.1.PeriphInc=DMA_PINC_DISABLE
21 22
 Dma.USART1_TX.1.Priority=DMA_PRIORITY_LOW
22 23
 Dma.USART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
24
+Dma.USART2_RX.2.Direction=DMA_PERIPH_TO_MEMORY
25
+Dma.USART2_RX.2.Instance=DMA1_Channel6
26
+Dma.USART2_RX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE
27
+Dma.USART2_RX.2.MemInc=DMA_MINC_ENABLE
28
+Dma.USART2_RX.2.Mode=DMA_NORMAL
29
+Dma.USART2_RX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
30
+Dma.USART2_RX.2.PeriphInc=DMA_PINC_DISABLE
31
+Dma.USART2_RX.2.Priority=DMA_PRIORITY_LOW
32
+Dma.USART2_RX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
23 33
 File.Version=6
24 34
 GPIO.groupedBy=Group By Peripherals
25 35
 I2C2.I2C_Mode=I2C_Fast
@@ -33,19 +43,22 @@ Mcu.IP3=RCC
33 43
 Mcu.IP4=SYS
34 44
 Mcu.IP5=TIM6
35 45
 Mcu.IP6=USART1
36
-Mcu.IPNb=7
46
+Mcu.IP7=USART2
47
+Mcu.IPNb=8
37 48
 Mcu.Name=STM32F103Z(C-D-E)Tx
38 49
 Mcu.Package=LQFP144
39 50
 Mcu.Pin0=PC15-OSC32_OUT
40
-Mcu.Pin1=PB10
41
-Mcu.Pin2=PB11
42
-Mcu.Pin3=PA9
43
-Mcu.Pin4=PA10
44
-Mcu.Pin5=PA13
45
-Mcu.Pin6=PA14
46
-Mcu.Pin7=VP_SYS_VS_Systick
47
-Mcu.Pin8=VP_TIM6_VS_ClockSourceINT
48
-Mcu.PinsNb=9
51
+Mcu.Pin1=PA2
52
+Mcu.Pin10=VP_TIM6_VS_ClockSourceINT
53
+Mcu.Pin2=PA3
54
+Mcu.Pin3=PB10
55
+Mcu.Pin4=PB11
56
+Mcu.Pin5=PA9
57
+Mcu.Pin6=PA10
58
+Mcu.Pin7=PA13
59
+Mcu.Pin8=PA14
60
+Mcu.Pin9=VP_SYS_VS_Systick
61
+Mcu.PinsNb=11
49 62
 Mcu.ThirdPartyNb=0
50 63
 Mcu.UserConstants=
51 64
 Mcu.UserName=STM32F103ZETx
@@ -54,6 +67,7 @@ MxDb.Version=DB.5.0.21
54 67
 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
55 68
 NVIC.DMA1_Channel4_IRQn=true\:0\:0\:false\:true\:true\:4\:false\:true
56 69
 NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:true\:true\:1\:false\:true
70
+NVIC.DMA1_Channel6_IRQn=true\:0\:0\:false\:true\:true\:5\:false\:true
57 71
 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
58 72
 NVIC.ForceEnableDMAVector=true
59 73
 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
@@ -65,6 +79,7 @@ NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
65 79
 NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
66 80
 NVIC.TIM6_IRQn=true\:0\:0\:false\:true\:true\:3\:true\:true
67 81
 NVIC.USART1_IRQn=true\:0\:0\:false\:true\:true\:2\:true\:true
82
+NVIC.USART2_IRQn=true\:0\:0\:false\:true\:true\:6\:true\:true
68 83
 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
69 84
 PA10.Mode=Asynchronous
70 85
 PA10.Signal=USART1_RX
@@ -72,6 +87,10 @@ PA13.Mode=Serial_Wire
72 87
 PA13.Signal=SYS_JTMS-SWDIO
73 88
 PA14.Mode=Serial_Wire
74 89
 PA14.Signal=SYS_JTCK-SWCLK
90
+PA2.Mode=Asynchronous
91
+PA2.Signal=USART2_TX
92
+PA3.Mode=Asynchronous
93
+PA3.Signal=USART2_RX
75 94
 PA9.Mode=Asynchronous
76 95
 PA9.Signal=USART1_TX
77 96
 PB10.GPIOParameters=GPIO_Label
@@ -87,7 +106,7 @@ PC15-OSC32_OUT.GPIO_Label=BOOT_LED
87 106
 PC15-OSC32_OUT.Locked=true
88 107
 PC15-OSC32_OUT.Signal=GPIO_Output
89 108
 PinOutPanel.RotationAngle=0
90
-ProjectManager.AskForMigrate=false
109
+ProjectManager.AskForMigrate=true
91 110
 ProjectManager.BackupPrevious=false
92 111
 ProjectManager.CompilerOptimize=6
93 112
 ProjectManager.ComputerToolchain=false
@@ -145,6 +164,8 @@ TIM6.Period=10 - 1
145 164
 TIM6.Prescaler=5600 - 1
146 165
 USART1.IPParameters=VirtualMode
147 166
 USART1.VirtualMode=VM_ASYNC
167
+USART2.IPParameters=VirtualMode
168
+USART2.VirtualMode=VM_ASYNC
148 169
 VP_SYS_VS_Systick.Mode=SysTick
149 170
 VP_SYS_VS_Systick.Signal=SYS_VS_Systick
150 171
 VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer

+ 5 - 0
Src/Bootloader.c

@@ -5,7 +5,12 @@
5 5
  *      Author: parkyj
6 6
  */
7 7
 #include "Bootloader.h"
8
+#include "CRC16.h"
9
+#include "flash.h"
8 10
 //Blueprotocol_t * UpdateFiledata;
11
+extern uint8_t Flash_write(uint8_t* data); // ?占쏙옙湲고븿?占쏙옙
12
+extern etError STH30_CheckCrc(uint8_t *data, uint8_t nbrOfBytes, uint8_t checksum);
13
+
9 14
 uint16_t updatecnt = 0;
10 15
 /***
11 16
  * Header Check Function

+ 44 - 11
Src/MBIC_Bootloader.c

@@ -164,7 +164,7 @@ uint8_t* MBIC_HeaderMergeFunction(uint8_t* data,uint16_t Length )
164 164
 
165 165
         
166 166
 
167
-    ret[MBIC_LENGTH_0] = (Length & 0xFF00) << 8;
167
+    ret[MBIC_LENGTH_0] = (Length & 0xFF00) >>8;
168 168
     ret[MBIC_LENGTH_1] = Length & 0x00FF;
169 169
 
170 170
     ret[MBIC_HEADERCHECKSUM_0] = Chksum_Create(ret);
@@ -203,8 +203,9 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
203 203
     static uint32_t Curr_Download_DataIndex = 0;
204 204
     static uint32_t Prev_Download_DataIndex = 0;    
205 205
     uint32_t TotalFrame = 0;
206
-    uint32_t CurrFrame = 0;
207
-    
206
+   // uint32_t CurrFrame = 0;
207
+    uint16_t DeviceCrc16 = 0;
208
+    uint16_t FileCrc16 = 0;    
208 209
     uint32_t i = 0 ;
209 210
 #if 0 // PYJ.2020.06.04_BEGIN -- 
210 211
     uint8_t dataTest[1024] = {
@@ -274,27 +275,59 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
274 275
             data[MBIC_PAYLOADSTART + index++] = 0;
275 276
             data[MBIC_PAYLOADSTART + index++] = 0;
276 277
             data[MBIC_PAYLOADSTART + index++] = 0;
277
-            for(i = 0; i < Curr_Download_DataIndex - Prev_Download_DataIndex; i++){
278
+#if 0 // PYJ.2020.06.16_BEGIN -- 
279
+            if(Curr_Download_DataIndex != 1023){
280
+                for(i = 0; i <= Curr_Download_DataIndex - Prev_Download_DataIndex; i++){
281
+                        MBIC_DownLoadData[i] = data[MBIC_PAYLOADSTART + 12 +i];
282
+                        printf("%02x ",MBIC_DownLoadData[i]);
283
+                }
284
+            }else{
285
+                Curr_Download_DataIndex = 1024;
286
+                for(i = 0; i < Curr_Download_DataIndex; i++){
287
+                        MBIC_DownLoadData[i] = data[MBIC_PAYLOADSTART + 12 +i];
288
+                        printf("%02x ",MBIC_DownLoadData[i]);
289
+                }
290
+            }
291
+#else
292
+            for(i = 0; i <= Curr_Download_DataIndex - Prev_Download_DataIndex; i++){
278 293
                     MBIC_DownLoadData[i] = data[MBIC_PAYLOADSTART + 12 +i];
279 294
                     printf("%02x ",MBIC_DownLoadData[i]);
280 295
             }
296
+
297
+#endif // PYJ.2020.06.16_END -- 
281 298
 //            printf("Data End\r\n");
282
-//            Bank_Flash_write(data,FLASH_USER_TEMPBANK_START_ADDR);
283
-//            HAL_Delay(100);
284
-            Prev_Download_DataIndex  = Curr_Download_DataIndex;
299
+            Bank_Flash_write(data,FLASH_USER_START_ADDR);
300
+//            HAL_Delay(5);
301
+            Prev_Download_DataIndex  = Curr_Download_DataIndex + 1;
285 302
             break;
286 303
         case MBIC_Download_Confirm_REQ:
287 304
             cmd = MBIC_Download_Confirm_RSP;
305
+            TotalFrame = data[MBIC_PAYLOADSTART + 0] << 24
306
+                        |data[MBIC_PAYLOADSTART + 1] << 16
307
+                        |data[MBIC_PAYLOADSTART + 2] << 8
308
+                        |data[MBIC_PAYLOADSTART + 3] << 0;
309
+            
288 310
             /*TOTAL FRAME NUMBER*/
311
+            if(Curr_Download_DataIndex != TotalFrame){
312
+                printf("Device Total : %d\r\n     File   Total : %d\r\n    ",Curr_Download_DataIndex,TotalFrame);
313
+            }
314
+
315
+    
316
+
289 317
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 0];
290 318
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 1];        
291 319
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 2];
292 320
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 3];        
293
-            /*DOWNLOAD OPTION*/        
321
+            /*DOWNLOAD CRC CHECK*/    
294 322
             data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 4];
295
-            Download_Option = data[MBIC_PAYLOADSTART + 4];
296
-            /*DOWNLOAD DELAY REQUEST*/
297
-            data[MBIC_PAYLOADSTART + index++] = 3;
323
+            data[MBIC_PAYLOADSTART + index++] = data[MBIC_PAYLOADSTART + 5];
324
+            FileCrc16 = data[MBIC_PAYLOADSTART + 4] << 8;
325
+            FileCrc16 += data[MBIC_PAYLOADSTART + 5];
326
+         //   DeviceCrc16 = CRC16_Generate();
327
+            
328
+            if(FileCrc16 != DeviceCrc16){
329
+                printf("Device Total : %d\r\n    File   Total : %d\r\n    ",Curr_Download_DataIndex,TotalFrame);
330
+            }            
298 331
             /*DOWNLOAD Reserve*/
299 332
             data[MBIC_PAYLOADSTART + index++] = 0;
300 333
             data[MBIC_PAYLOADSTART + index++] = 0;

+ 88 - 35
Src/flash.c

@@ -39,10 +39,12 @@ void FLASH_If_Init(void)
39 39
 
40 40
 void Flash_InitRead(void) // ?占쏙옙湲고븿?占쏙옙
41 41
 {
42
+
42 43
     uint32_t  Address = 0;
43 44
     Address = FLASH_USER_START_ADDR;
44
-    for(uint32_t i = 0; i < 16; i++ ){
45
-        printf("%08x : %02X \n",Address ,*(uint8_t*)Address);
45
+    for(uint32_t i = 0; i < 0xC9BC; i++ ){
46
+//        printf("%08x : %02X \n",Address ,*(uint8_t*)Address);
47
+	printf("%02X ",*(uint8_t*)Address);
46 48
         Address++;
47 49
     }
48 50
 #if 0 // PYJ.2019.03.27_BEGIN -- 
@@ -77,9 +79,14 @@ uint8_t Flash_RGB_Data_Write(uint8_t* data){
77 79
     }
78 80
     return ret;
79 81
 }
82
+/*
83
+
84
+
85
+*/
80 86
 uint8_t Flash_Data_Write(uint8_t* data){
81 87
     uint16_t Firmdata = 0;
82 88
     uint8_t ret = 0;
89
+    HAL_StatusTypeDef HAL_Ret = HAL_ERROR;
83 90
     static uint32_t Curr_Download_DataIndex = 0;
84 91
     static uint32_t Prev_Download_DataIndex = 0;  
85 92
     
@@ -88,17 +95,62 @@ uint8_t Flash_Data_Write(uint8_t* data){
88 95
     Curr_Download_DataIndex += data[MBIC_PAYLOADSTART + 6] << 8;            
89 96
     Curr_Download_DataIndex += data[MBIC_PAYLOADSTART + 7];      
90 97
 
98
+
99
+#if 1 // PYJ.2020.06.16_BEGIN -- 
100
+    for(int i = 0; i <= Curr_Download_DataIndex - Prev_Download_DataIndex; i += 2){
101
+            Firmdata  = ((data[MBIC_PAYLOADSTART + 12 +i]) & 0x00FF);
102
+            Firmdata  += ((data[MBIC_PAYLOADSTART + 12 +i + 1] << 8) & 0xFF00);
103
+            HAL_Ret = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,UserAddress ,   (uint16_t)Firmdata);
104
+            if(HAL_Ret != HAL_OK){
105
+                switch(ret) {
106
+                    case HAL_OK:
107
+                        break;
108
+                    case HAL_TIMEOUT:
109
+                        printf("HAL_FLASH_Program() timeout!\n");
110
+                        break;
111
+                    case HAL_ERROR:
112
+                        printf("HAL_FLASH_Program() error 0x%08x, see *hal_flash.h for bit definitions\n", HAL_FLASH_GetError());
113
+                        break;
114
+                    default:
115
+                        printf("HAL_FLASH_Program() returned unknown status %lu\n", ret);
116
+                }
117
+
118
+                ret = 1;
119
+            }
120
+            UserAddress += 2;
121
+
122
+    }
123
+#else
124
+
125
+#endif // PYJ.2020.06.16_END -- 
126
+
91 127
 //    data[MBIC_PAYLOADSTART + 12 +i];
92
-    for(int i= 0; i <= Curr_Download_DataIndex - Prev_Download_DataIndex+1; i+=2){
93
-        Firmdata  = ((data[MBIC_PAYLOADSTART + 12 +i]) & 0x00FF);
94
-        Firmdata  += ((data[MBIC_PAYLOADSTART + 12 +i + 1] << 8) & 0xFF00);
95
-        if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,UserAddress ,   (uint16_t)Firmdata) != HAL_OK){
96
-            printf("HAL NOT OK \n");
97
-            ret = 1;
128
+#if 0 // PYJ.2020.06.16_BEGIN -- 
129
+    if(Curr_Download_DataIndex != 1023){
130
+        for(int i= 0; i <= Curr_Download_DataIndex - Prev_Download_DataIndex+1; i+=2){
131
+            Firmdata  = ((data[MBIC_PAYLOADSTART + 12 +i]) & 0x00FF);
132
+            Firmdata  += ((data[MBIC_PAYLOADSTART + 12 +i + 1] << 8) & 0xFF00);
133
+            if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,UserAddress ,   (uint16_t)Firmdata) != HAL_OK){
134
+                printf("HAL NOT OK \n");
135
+                ret = 1;
136
+            }
137
+            UserAddress += 2;
138
+
139
+        }
140
+    }else{/*(Curr_Download_DataIndex == 1023)*/
141
+        for(int i= 0; i <= 1024; i+=2){
142
+            Firmdata  = ((data[MBIC_PAYLOADSTART + 12 +i]) & 0x00FF);
143
+            Firmdata  += ((data[MBIC_PAYLOADSTART + 12 +i + 1] << 8) & 0xFF00);
144
+            if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,UserAddress ,   (uint16_t)Firmdata) != HAL_OK){
145
+                printf("HAL NOT OK \n");
146
+                ret = 1;
147
+            }
148
+            UserAddress += 2;
98 149
         }
99
-        UserAddress += 2;
100 150
     }
101
-    Prev_Download_DataIndex = Curr_Download_DataIndex;
151
+#endif // PYJ.2020.06.16_END -- 
152
+//    HAL_Delay(1);
153
+    Prev_Download_DataIndex =  Curr_Download_DataIndex + 1;
102 154
     return ret;
103 155
 }
104 156
 
@@ -236,35 +288,36 @@ uint8_t Bank_Flash_write(uint8_t* data,uint32_t StartBankAddress) // ?占쏙옙
236 288
     static FLASH_EraseInitTypeDef EraseInitStruct;
237 289
     static uint32_t PAGEError = 0;
238 290
     uint8_t ret = 0;
239
-    /* Fill EraseInit structure*/
240
-    switch(StartBankAddress){
241
-        case FLASH_USER_START_ADDR:
242
-            EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
243
-            EraseInitStruct.PageAddress = FLASH_USER_START_ADDR;
244
-            EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_START_ADDR) / FLASH_PAGE_SIZE;
245
-        break;
246
-        case FLASH_USER_BANK1_START_ADDR:
247
-            EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
248
-            EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
249
-            EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE;
250
-
251
-        break;
252
-        case FLASH_USER_BANK2_START_ADDR:
253
-            EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
254
-            EraseInitStruct.PageAddress = FLASH_USER_BANK2_START_ADDR;
255
-            EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_BANK2_START_ADDR) / FLASH_PAGE_SIZE;
256
-
257
-        break;
258
-        case FLASH_USER_TEMPBANK_START_ADDR:
259
-            EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
260
-            EraseInitStruct.PageAddress = FLASH_USER_TEMPBANK_START_ADDR;
261
-            EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_TEMPBANK_START_ADDR) / FLASH_PAGE_SIZE;
262
-        break;
263 291
 
264
-    }
265 292
 
266 293
     HAL_FLASH_Unlock(); // lock ??占�?
267 294
     if(flashinit == 0){
295
+        /* Fill EraseInit structure*/
296
+        switch(StartBankAddress){
297
+            case FLASH_USER_START_ADDR:
298
+                EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
299
+                EraseInitStruct.PageAddress = FLASH_USER_START_ADDR;
300
+                EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_START_ADDR) / FLASH_PAGE_SIZE;
301
+            break;
302
+            case FLASH_USER_BANK1_START_ADDR:
303
+                EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
304
+                EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
305
+                EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE;
306
+
307
+            break;
308
+            case FLASH_USER_BANK2_START_ADDR:
309
+                EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
310
+                EraseInitStruct.PageAddress = FLASH_USER_BANK2_START_ADDR;
311
+                EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_BANK2_START_ADDR) / FLASH_PAGE_SIZE;
312
+
313
+            break;
314
+            case FLASH_USER_TEMPBANK_START_ADDR:
315
+                EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
316
+                EraseInitStruct.PageAddress = FLASH_USER_TEMPBANK_START_ADDR;
317
+                EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_TEMPBANK_START_ADDR) / FLASH_PAGE_SIZE;
318
+            break;
319
+
320
+        }        
268 321
         flashinit= 1;
269 322
         UserAddress = EraseInitStruct.PageAddress;
270 323
         //FLASH_PageErase(StartAddr);

+ 47 - 3
Src/main.c

@@ -47,8 +47,10 @@ I2C_HandleTypeDef hi2c2;
47 47
 TIM_HandleTypeDef htim6;
48 48
 
49 49
 UART_HandleTypeDef huart1;
50
+UART_HandleTypeDef huart2;
50 51
 DMA_HandleTypeDef hdma_usart1_rx;
51 52
 DMA_HandleTypeDef hdma_usart1_tx;
53
+DMA_HandleTypeDef hdma_usart2_rx;
52 54
 
53 55
 /* USER CODE BEGIN PV */
54 56
 
@@ -64,6 +66,7 @@ static void MX_DMA_Init(void);
64 66
 static void MX_USART1_UART_Init(void);
65 67
 static void MX_I2C2_Init(void);
66 68
 static void MX_TIM6_Init(void);
69
+static void MX_USART2_UART_Init(void);
67 70
 static void MX_NVIC_Init(void);
68 71
 /* USER CODE BEGIN PFP */
69 72
 
@@ -99,7 +102,7 @@ extern UARTQUEUE TerminalQueue;
99 102
 int main(void)
100 103
 {
101 104
   /* USER CODE BEGIN 1 */
102
-	uint8_t tempdata[] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A};
105
+//	uint8_t tempdata[] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A};
103 106
   /* USER CODE END 1 */
104 107
   
105 108
 
@@ -125,6 +128,7 @@ int main(void)
125 128
   MX_USART1_UART_Init();
126 129
   MX_I2C2_Init();
127 130
   MX_TIM6_Init();
131
+  MX_USART2_UART_Init();
128 132
 
129 133
   /* Initialize interrupts */
130 134
   MX_NVIC_Init();
@@ -135,6 +139,7 @@ int main(void)
135 139
   printf("Crc generate %x \r\n",CRC16_Generate(tempdata,11));*/
136 140
   Firmware_BootStart_Signal();
137 141
   InitUartQueue(&TerminalQueue);
142
+  //Flash_InitRead();
138 143
   /* USER CODE END 2 */
139 144
 
140 145
   /* Infinite loop */
@@ -144,7 +149,7 @@ int main(void)
144 149
 	 // printf("Uart Start \r\n");
145 150
 	  if(LedTimerCnt > 500){HAL_GPIO_TogglePin(BOOT_LED_GPIO_Port,BOOT_LED_Pin);LedTimerCnt = 0;}
146 151
 	  while (TerminalQueue.data > 0 && UartTimerCnt > 30) GetDataFromUartQueue(&hTerminal);
147
-	 // while(FirmwareTimerCnt > 3000)  Jump_App();
152
+	 while(FirmwareTimerCnt > 3000)  Jump_App();
148 153
 
149 154
 	  //HAL_Delay(500);
150 155
     /* USER CODE END WHILE */
@@ -208,6 +213,12 @@ static void MX_NVIC_Init(void)
208 213
   /* DMA1_Channel4_IRQn interrupt configuration */
209 214
   HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 0, 0);
210 215
   HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn);
216
+  /* DMA1_Channel6_IRQn interrupt configuration */
217
+  HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0);
218
+  HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
219
+  /* USART2_IRQn interrupt configuration */
220
+  HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
221
+  HAL_NVIC_EnableIRQ(USART2_IRQn);
211 222
 }
212 223
 
213 224
 /**
@@ -315,6 +326,39 @@ static void MX_USART1_UART_Init(void)
315 326
 
316 327
 }
317 328
 
329
+/**
330
+  * @brief USART2 Initialization Function
331
+  * @param None
332
+  * @retval None
333
+  */
334
+static void MX_USART2_UART_Init(void)
335
+{
336
+
337
+  /* USER CODE BEGIN USART2_Init 0 */
338
+
339
+  /* USER CODE END USART2_Init 0 */
340
+
341
+  /* USER CODE BEGIN USART2_Init 1 */
342
+
343
+  /* USER CODE END USART2_Init 1 */
344
+  huart2.Instance = USART2;
345
+  huart2.Init.BaudRate = 115200;
346
+  huart2.Init.WordLength = UART_WORDLENGTH_8B;
347
+  huart2.Init.StopBits = UART_STOPBITS_1;
348
+  huart2.Init.Parity = UART_PARITY_NONE;
349
+  huart2.Init.Mode = UART_MODE_TX_RX;
350
+  huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
351
+  huart2.Init.OverSampling = UART_OVERSAMPLING_16;
352
+  if (HAL_UART_Init(&huart2) != HAL_OK)
353
+  {
354
+    Error_Handler();
355
+  }
356
+  /* USER CODE BEGIN USART2_Init 2 */
357
+
358
+  /* USER CODE END USART2_Init 2 */
359
+
360
+}
361
+
318 362
 /** 
319 363
   * Enable DMA controller clock
320 364
   */
@@ -336,8 +380,8 @@ static void MX_GPIO_Init(void)
336 380
 
337 381
   /* GPIO Ports Clock Enable */
338 382
   __HAL_RCC_GPIOC_CLK_ENABLE();
339
-  __HAL_RCC_GPIOB_CLK_ENABLE();
340 383
   __HAL_RCC_GPIOA_CLK_ENABLE();
384
+  __HAL_RCC_GPIOB_CLK_ENABLE();
341 385
 
342 386
   /*Configure GPIO pin Output Level */
343 387
   HAL_GPIO_WritePin(BOOT_LED_GPIO_Port, BOOT_LED_Pin, GPIO_PIN_RESET);

+ 69 - 0
Src/stm32f1xx_hal_msp.c

@@ -28,6 +28,8 @@ extern DMA_HandleTypeDef hdma_usart1_rx;
28 28
 
29 29
 extern DMA_HandleTypeDef hdma_usart1_tx;
30 30
 
31
+extern DMA_HandleTypeDef hdma_usart2_rx;
32
+
31 33
 /* Private typedef -----------------------------------------------------------*/
32 34
 /* USER CODE BEGIN TD */
33 35
 
@@ -263,6 +265,50 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
263 265
 
264 266
   /* USER CODE END USART1_MspInit 1 */
265 267
   }
268
+  else if(huart->Instance==USART2)
269
+  {
270
+  /* USER CODE BEGIN USART2_MspInit 0 */
271
+
272
+  /* USER CODE END USART2_MspInit 0 */
273
+    /* Peripheral clock enable */
274
+    __HAL_RCC_USART2_CLK_ENABLE();
275
+  
276
+    __HAL_RCC_GPIOA_CLK_ENABLE();
277
+    /**USART2 GPIO Configuration    
278
+    PA2     ------> USART2_TX
279
+    PA3     ------> USART2_RX 
280
+    */
281
+    GPIO_InitStruct.Pin = GPIO_PIN_2;
282
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
283
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
284
+    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
285
+
286
+    GPIO_InitStruct.Pin = GPIO_PIN_3;
287
+    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
288
+    GPIO_InitStruct.Pull = GPIO_NOPULL;
289
+    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
290
+
291
+    /* USART2 DMA Init */
292
+    /* USART2_RX Init */
293
+    hdma_usart2_rx.Instance = DMA1_Channel6;
294
+    hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
295
+    hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
296
+    hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE;
297
+    hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
298
+    hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
299
+    hdma_usart2_rx.Init.Mode = DMA_NORMAL;
300
+    hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW;
301
+    if (HAL_DMA_Init(&hdma_usart2_rx) != HAL_OK)
302
+    {
303
+      Error_Handler();
304
+    }
305
+
306
+    __HAL_LINKDMA(huart,hdmarx,hdma_usart2_rx);
307
+
308
+  /* USER CODE BEGIN USART2_MspInit 1 */
309
+
310
+  /* USER CODE END USART2_MspInit 1 */
311
+  }
266 312
 
267 313
 }
268 314
 
@@ -298,6 +344,29 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
298 344
 
299 345
   /* USER CODE END USART1_MspDeInit 1 */
300 346
   }
347
+  else if(huart->Instance==USART2)
348
+  {
349
+  /* USER CODE BEGIN USART2_MspDeInit 0 */
350
+
351
+  /* USER CODE END USART2_MspDeInit 0 */
352
+    /* Peripheral clock disable */
353
+    __HAL_RCC_USART2_CLK_DISABLE();
354
+  
355
+    /**USART2 GPIO Configuration    
356
+    PA2     ------> USART2_TX
357
+    PA3     ------> USART2_RX 
358
+    */
359
+    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
360
+
361
+    /* USART2 DMA DeInit */
362
+    HAL_DMA_DeInit(huart->hdmarx);
363
+
364
+    /* USART2 interrupt DeInit */
365
+    HAL_NVIC_DisableIRQ(USART2_IRQn);
366
+  /* USER CODE BEGIN USART2_MspDeInit 1 */
367
+
368
+  /* USER CODE END USART2_MspDeInit 1 */
369
+  }
301 370
 
302 371
 }
303 372
 

+ 30 - 0
Src/stm32f1xx_it.c

@@ -59,7 +59,9 @@
59 59
 extern TIM_HandleTypeDef htim6;
60 60
 extern DMA_HandleTypeDef hdma_usart1_rx;
61 61
 extern DMA_HandleTypeDef hdma_usart1_tx;
62
+extern DMA_HandleTypeDef hdma_usart2_rx;
62 63
 extern UART_HandleTypeDef huart1;
64
+extern UART_HandleTypeDef huart2;
63 65
 /* USER CODE BEGIN EV */
64 66
 
65 67
 /* USER CODE END EV */
@@ -228,6 +230,20 @@ void DMA1_Channel5_IRQHandler(void)
228 230
   /* USER CODE END DMA1_Channel5_IRQn 1 */
229 231
 }
230 232
 
233
+/**
234
+  * @brief This function handles DMA1 channel6 global interrupt.
235
+  */
236
+void DMA1_Channel6_IRQHandler(void)
237
+{
238
+  /* USER CODE BEGIN DMA1_Channel6_IRQn 0 */
239
+
240
+  /* USER CODE END DMA1_Channel6_IRQn 0 */
241
+  HAL_DMA_IRQHandler(&hdma_usart2_rx);
242
+  /* USER CODE BEGIN DMA1_Channel6_IRQn 1 */
243
+
244
+  /* USER CODE END DMA1_Channel6_IRQn 1 */
245
+}
246
+
231 247
 /**
232 248
   * @brief This function handles USART1 global interrupt.
233 249
   */
@@ -242,6 +258,20 @@ void USART1_IRQHandler(void)
242 258
   /* USER CODE END USART1_IRQn 1 */
243 259
 }
244 260
 
261
+/**
262
+  * @brief This function handles USART2 global interrupt.
263
+  */
264
+void USART2_IRQHandler(void)
265
+{
266
+  /* USER CODE BEGIN USART2_IRQn 0 */
267
+
268
+  /* USER CODE END USART2_IRQn 0 */
269
+  HAL_UART_IRQHandler(&huart2);
270
+  /* USER CODE BEGIN USART2_IRQn 1 */
271
+
272
+  /* USER CODE END USART2_IRQn 1 */
273
+}
274
+
245 275
 /**
246 276
   * @brief This function handles TIM6 global interrupt.
247 277
   */

+ 11 - 4
Src/uart.c

@@ -10,6 +10,8 @@
10 10
 #include "MBIC_Bootloader.h"
11 11
 UARTQUEUE TerminalQueue;
12 12
 UARTQUEUE WifiQueue;
13
+extern void FirmwareUpdateStart(uint8_t* data);
14
+extern void MBIC_Bootloader_FirmwareUpdate(uint8_t* data);
13 15
 
14 16
 void InitUartQueue(pUARTQUEUE pQueue)
15 17
 {
@@ -56,7 +58,7 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
56 58
     volatile static int cnt;
57 59
     uint16_t Length = 0;
58 60
     uint16_t CrcChk = 0;
59
-    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);
61
+   // UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);
60 62
 //    UART_HandleTypeDef *dst = &hTerminal;
61 63
     pUARTQUEUE pQueue = &TerminalQueue;
62 64
 //    if (HAL_UART_Transmit(dst, pQueue->Buffer + pQueue->tail, 1, 3000) != HAL_OK)
@@ -72,8 +74,8 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
72 74
     if(pQueue->data == 0){
73 75
         //HAL_UART_Transmit_DMA(dst, &temp_buf[BLUECELL_HEADER00], 11);
74 76
 #if 0 // PYJ.2019.07.15_BEGIN -- 
75
-            for(int i = 0; i < 128; i++){
76
-                printf("%02x",update_data_buf[i]);
77
+            for(int i = 0; i < pQueue->tail; i++){
78
+                printf("%02x ",update_data_buf[i]);
77 79
             }
78 80
 #endif // PYJ.2019.07.15_END -- 
79 81
         cnt = 0;
@@ -110,8 +112,13 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
110 112
 void Uart1_Data_Send(uint8_t* data,uint16_t size){
111 113
 //    printf("size : %d \r\n",size);
112 114
     HAL_UART_Transmit (&huart1, data, size, 0xFFFF);
115
+//  static uint8_t  testdata[10] = {0x16,0x16,};
116
+
117
+ //   HAL_UART_Transmit_DMA(&huart1, &data[0], size);
118
+   // HAL_UART_Transmit_DMA(&huart1, &data[1], size);
119
+
113 120
 //    for(int i = 0; i < size; i++)
114
-//    if(HAL_UART_Transmit_DMA(&huart1, data, size) != HAL_OK){
121
+ //   if(HAL_UART_Transmit_DMA(&huart1, data, size) != HAL_OK){
115 122
 //        printf("ERROR \r\n");
116 123
 //    }
117 124
 //        printf("data : %x \r\n",data[i]);