提交 | 用户 | age
|
8b51c7
|
1 |
|
Q |
2 |
/** |
|
3 |
****************************************************************************** |
|
4 |
* @file : main.c |
|
5 |
* @brief : Main program body |
|
6 |
****************************************************************************** |
|
7 |
** This notice applies to any and all portions of this file |
|
8 |
* that are not between comment pairs USER CODE BEGIN and |
|
9 |
* USER CODE END. Other portions of this file, whether |
|
10 |
* inserted by the user or by software development tools |
|
11 |
* are owned by their respective copyright owners. |
|
12 |
* |
|
13 |
* COPYRIGHT(c) 2018 STMicroelectronics |
|
14 |
* |
|
15 |
* Redistribution and use in source and binary forms, with or without modification, |
|
16 |
* are permitted provided that the following conditions are met: |
|
17 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
18 |
* this list of conditions and the following disclaimer. |
|
19 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
20 |
* this list of conditions and the following disclaimer in the documentation |
|
21 |
* and/or other materials provided with the distribution. |
|
22 |
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
|
23 |
* may be used to endorse or promote products derived from this software |
|
24 |
* without specific prior written permission. |
|
25 |
* |
|
26 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
27 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
28 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
29 |
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
|
30 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
31 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
32 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
33 |
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
34 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
35 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
36 |
* |
|
37 |
****************************************************************************** |
|
38 |
*/ |
|
39 |
/* Includes ------------------------------------------------------------------*/ |
|
40 |
#include "main.h" |
|
41 |
#include "stm32f0xx_hal.h" |
|
42 |
|
|
43 |
/* USER CODE BEGIN Includes */ |
|
44 |
#include "Globaldef.h" |
|
45 |
#include "debug.h" |
|
46 |
#include "Functions.h" |
|
47 |
#include "string.h" |
|
48 |
#include "BSP.h" |
842bb6
|
49 |
#include "stm32f0xx_ll_flash.h" |
8b51c7
|
50 |
|
Q |
51 |
/* USER CODE END Includes */ |
|
52 |
|
|
53 |
/* Private variables ---------------------------------------------------------*/ |
|
54 |
|
|
55 |
/* USER CODE BEGIN PV */ |
|
56 |
/* Private variables ---------------------------------------------------------*/ |
|
57 |
|
|
58 |
unsigned char SlowFlicker=0; |
|
59 |
unsigned char FastFlicker=0; |
|
60 |
|
842bb6
|
61 |
|
Q |
62 |
typedef struct tagInfoBlockHdr { |
|
63 |
unsigned short nBlkSign; // 开始标志 |
|
64 |
unsigned short nBlkTypeVer; // 类型和版本 |
|
65 |
unsigned short nBlkSize; // Block 大小, 包括开始和结束标志 |
|
66 |
unsigned short Pad1; |
|
67 |
}stInfoBlockHdr; |
|
68 |
|
|
69 |
typedef struct tagInfoBlockTail { |
|
70 |
|
|
71 |
unsigned short CRC16; |
|
72 |
unsigned short EndSign; |
|
73 |
}stInfoBlockTail; |
|
74 |
|
|
75 |
typedef struct tagBtLdrInfoBlock { |
|
76 |
stInfoBlockHdr Hdr; |
|
77 |
unsigned short nBtldrVer; |
|
78 |
unsigned short nBtldrDevice; |
|
79 |
unsigned short nBtldrSize; // 设计大小 |
|
80 |
unsigned short nBtldrDataSize; //代码大小 |
|
81 |
unsigned int nBtldr_AppAddr; |
|
82 |
unsigned int nBtldr_NewAppInfoAddr; |
|
83 |
unsigned int nBtldr_NewAppAddr; |
|
84 |
stInfoBlockTail tail; |
|
85 |
}stBtLdrInfoBlock; |
|
86 |
// /* |
|
87 |
typedef struct { |
|
88 |
uint32_t addr_Code_RO_Data_limit; |
|
89 |
|
|
90 |
}addr_data_def; |
|
91 |
// */ |
|
92 |
extern int Region$$Table$$Base; |
|
93 |
addr_data_def const * paddr = (addr_data_def *)&Region$$Table$$Base; |
|
94 |
|
|
95 |
const stBtLdrInfoBlock theBtldrInfoBlock __attribute__((at(0x08000100))) = { |
|
96 |
0xAA55, // StartSign |
|
97 |
0x0101, // BlockType |
|
98 |
sizeof(stBtLdrInfoBlock), //BlockSize |
|
99 |
0, // Pad, |
|
100 |
0x0100, //BtLdrVer |
|
101 |
0x0100, //BtLdrDevice; |
|
102 |
0x1000, //BtLdrSize; |
|
103 |
0x0C00, //BtLdrDataSize; |
|
104 |
0x08001000, //nBtldr_AppAddr |
|
105 |
(int)&Region$$Table$$Base, //nBtldr_NewAppInfoAddr |
|
106 |
0x08009000, //nBtldr_NewAppAddr |
|
107 |
0xEEEE, //crc16; |
|
108 |
0xAA55 //EndSign; |
|
109 |
}; |
|
110 |
|
|
111 |
// const int END_SIGN __attribute__((at(0x08000FD8))); // = 0x55aa; |
8b51c7
|
112 |
|
Q |
113 |
uint32_t us1,us2,us3,us4,us5,us6; |
|
114 |
|
|
115 |
/* USER CODE END PV */ |
|
116 |
|
|
117 |
/* Private function prototypes -----------------------------------------------*/ |
|
118 |
|
|
119 |
|
|
120 |
/* USER CODE BEGIN PFP */ |
|
121 |
/* Private function prototypes -----------------------------------------------*/ |
|
122 |
|
|
123 |
/* USER CODE END PFP */ |
|
124 |
|
|
125 |
/* USER CODE BEGIN 0 */ |
|
126 |
|
5dd1b7
|
127 |
/* Table of CRC values for high-order byte */ |
842bb6
|
128 |
/* |
5dd1b7
|
129 |
const uint8_t crctablehi[] = { |
Q |
130 |
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, |
|
131 |
0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, |
|
132 |
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, |
|
133 |
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, |
|
134 |
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, |
|
135 |
0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, |
|
136 |
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, |
|
137 |
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, |
|
138 |
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, |
|
139 |
0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, |
|
140 |
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, |
|
141 |
0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, |
|
142 |
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, |
|
143 |
0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, |
|
144 |
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, |
|
145 |
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, |
|
146 |
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, |
|
147 |
0x40 |
|
148 |
}; |
842bb6
|
149 |
*/ |
5dd1b7
|
150 |
/* Table of CRC values for low-order byte */ |
842bb6
|
151 |
/* |
5dd1b7
|
152 |
const uint8_t crctablelo[] = { |
Q |
153 |
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, |
|
154 |
0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, |
|
155 |
0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, |
|
156 |
0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, |
|
157 |
0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7, |
|
158 |
0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, |
|
159 |
0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, |
|
160 |
0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, |
|
161 |
0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, |
|
162 |
0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, |
|
163 |
0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, |
|
164 |
0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, |
|
165 |
0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90, 0x91, |
|
166 |
0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, |
|
167 |
0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, |
|
168 |
0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, |
|
169 |
0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, |
|
170 |
0x40 |
|
171 |
}; |
842bb6
|
172 |
*/ |
Q |
173 |
/* |
5dd1b7
|
174 |
uint16_t crc16table(const uint8_t *ptr, uint16_t len) |
Q |
175 |
{ |
|
176 |
uint8_t crchi = 0xff; |
|
177 |
uint8_t crclo = 0xff; |
|
178 |
uint16_t index; |
|
179 |
while (len--) |
|
180 |
{ |
|
181 |
index = crclo ^ *ptr++; |
|
182 |
crclo = crchi ^ crctablehi[index]; |
|
183 |
crchi = crctablelo[index]; |
|
184 |
} |
|
185 |
return (crchi << 8 | crclo); |
|
186 |
} |
842bb6
|
187 |
*/ |
5dd1b7
|
188 |
|
8b51c7
|
189 |
void HAL_SYSTICK_Callback(void) |
Q |
190 |
{ |
|
191 |
static int Count=0; |
|
192 |
Count++; |
|
193 |
if (Count>=10000) |
|
194 |
{ |
|
195 |
Count=0; |
|
196 |
} |
|
197 |
|
|
198 |
return; |
|
199 |
} |
|
200 |
|
|
201 |
#define ApplicationAddress 0x08001000 //应用程序首地址定义 |
842bb6
|
202 |
#define NEW_APP_INFOBLOCK_ADDR 0x08008000 // 存储的新应用程序信息块的地址 |
Q |
203 |
#define NEW_APP_ADDR 0x08009000 // 存储的新应用程序的地址 |
5dd1b7
|
204 |
|
Q |
205 |
typedef struct tagNewAppInfoBlock |
|
206 |
{ |
|
207 |
unsigned short Sign; |
|
208 |
unsigned short Version; |
|
209 |
unsigned int Length; |
|
210 |
unsigned int nCRC; |
|
211 |
|
|
212 |
}stNewAppInfoBlock,*pNewAppInfoBlock; |
8b51c7
|
213 |
|
Q |
214 |
typedef void (*pFunction)(void); //定义跳转函数指针类型 |
|
215 |
|
|
216 |
|
|
217 |
/*跳转到应用程序处理函数*/ |
|
218 |
static void JumpToApplication(void) |
|
219 |
{ |
5dd1b7
|
220 |
uint32_t AppStackAddr; //应用程序栈地址 |
Q |
221 |
uint32_t AppResetVector; //应用程序中断向量表的地址 |
8b51c7
|
222 |
|
Q |
223 |
pFunction JumpToApp; //定义跳转函数指针 |
|
224 |
|
|
225 |
__set_PRIMASK(1); //关闭全局中断 |
|
226 |
|
5dd1b7
|
227 |
AppStackAddr = *(__IO uint32_t*)ApplicationAddress; //0x08001000; |
Q |
228 |
AppResetVector = *(__IO uint32_t*)(ApplicationAddress + 4); //0x08001004; |
8b51c7
|
229 |
|
5dd1b7
|
230 |
if((AppStackAddr&0x2FFC0000)==0x20000000) //检查栈顶地址是否合法. |
8b51c7
|
231 |
{ |
Q |
232 |
__disable_irq(); |
|
233 |
memcpy((void *)0x20000000,(void *)ApplicationAddress,0xc0); |
|
234 |
|
5dd1b7
|
235 |
__set_MSP(AppStackAddr); //初始化应用程序栈指针 |
8b51c7
|
236 |
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_SYSCFG); |
Q |
237 |
LL_SYSCFG_SetRemapMemory(LL_SYSCFG_REMAP_SRAM); |
|
238 |
// SYSCFG |
5dd1b7
|
239 |
JumpToApp = (pFunction)AppResetVector; |
8b51c7
|
240 |
JumpToApp(); |
Q |
241 |
} |
5dd1b7
|
242 |
} |
Q |
243 |
|
|
244 |
int EraseFlashMem(void * pAddrFlash, unsigned int Pages) |
|
245 |
{ |
842bb6
|
246 |
ErrorStatus res; |
Q |
247 |
res = LL_Flash_Unlock(); |
|
248 |
// uint32_t ErrNo; |
|
249 |
res = LL_Flash_PageErase(pAddrFlash,Pages); |
|
250 |
LL_FLASH_Lock(FLASH); |
5dd1b7
|
251 |
return res; |
Q |
252 |
} |
|
253 |
|
|
254 |
int EraseAndWriteToFlashMem(void * pBuf, void * pAddrFlash, unsigned int nByteSize) |
|
255 |
{ |
|
256 |
|
842bb6
|
257 |
ErrorStatus res; |
Q |
258 |
res = LL_Flash_Unlock(); |
|
259 |
// __disable_irq(); |
|
260 |
int NbPages = (nByteSize-1) / FLASH_PAGE_SIZE + 1; |
|
261 |
res = LL_Flash_PageErase(pAddrFlash,NbPages); |
5dd1b7
|
262 |
for (int i=0;i<(nByteSize+1)/2;i++) |
Q |
263 |
{ |
842bb6
|
264 |
unsigned short value = ((uint8_t *)pBuf)[i*2] + (((uint8_t *)pBuf)[i*2 +1] << 8); |
Q |
265 |
res = LL_FLASH_Program(ProgaraType_DATA16, (uint32_t)pAddrFlash + i*2, value); |
|
266 |
if (res == ERROR) break; |
5dd1b7
|
267 |
} |
Q |
268 |
|
842bb6
|
269 |
// __enable_irq(); |
Q |
270 |
LL_FLASH_Lock(FLASH); |
|
271 |
if (res == ERROR) return 1; |
5dd1b7
|
272 |
|
Q |
273 |
return res; |
8b51c7
|
274 |
} |
Q |
275 |
|
|
276 |
/* USER CODE END 0 */ |
|
277 |
|
|
278 |
/** |
|
279 |
* @brief The application entry point. |
|
280 |
* |
|
281 |
* @retval None |
|
282 |
*/ |
|
283 |
int main(void) |
|
284 |
{ |
|
285 |
/* USER CODE BEGIN 1 */ |
|
286 |
|
|
287 |
// InitUartstat(&Uart1Stat,Uart1RxBuf,sizeof(Uart1RxBuf),Uart1TxBuf,sizeof(Uart1TxBuf)); |
|
288 |
// InitUartstat(&Uart2Stat,Uart2RxBuf,sizeof(Uart2RxBuf),Uart2TxBuf,sizeof(Uart2TxBuf)); |
|
289 |
/* USER CODE END 1 */ |
|
290 |
|
|
291 |
/* MCU Configuration----------------------------------------------------------*/ |
|
292 |
|
|
293 |
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ |
|
294 |
// HAL_Init(); |
|
295 |
|
|
296 |
/* USER CODE BEGIN Init */ |
|
297 |
|
|
298 |
/* USER CODE END Init */ |
|
299 |
|
|
300 |
/* Configure the system clock */ |
|
301 |
|
|
302 |
/* USER CODE BEGIN SysInit */ |
|
303 |
// HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/TickFreq); //重新定义SysTick的频率 |
|
304 |
LL_Init1msTick(8000000); |
|
305 |
MX_GPIO_Init(); |
|
306 |
|
|
307 |
/* USER CODE END SysInit */ |
|
308 |
|
|
309 |
|
|
310 |
/* USER CODE BEGIN 2 */ |
|
311 |
|
|
312 |
//LL_USART_EnableIT_TXE(USART1); |
|
313 |
/* USER CODE END 2 */ |
|
314 |
|
|
315 |
/* Infinite loop */ |
|
316 |
/* USER CODE BEGIN WHILE */ |
|
317 |
|
|
318 |
SetRunLed(1); //Turn On Run Led |
|
319 |
SetErrLed(0); //Turn Off Err Led |
5dd1b7
|
320 |
// check for app update |
Q |
321 |
///* |
842bb6
|
322 |
int FlashSize = *(unsigned short *)FLASHSIZE_BASE; |
Q |
323 |
int NewAppAddress ; |
|
324 |
int NewAppInfoBlockAddress ; |
|
325 |
if (FlashSize == 64) { |
|
326 |
NewAppInfoBlockAddress = 0x08008000; |
|
327 |
NewAppAddress = 0x08009000U; |
|
328 |
}else if (FlashSize == 256) { |
|
329 |
NewAppInfoBlockAddress = 0x08020000; |
|
330 |
NewAppAddress = 0x08021000U; |
|
331 |
} |
|
332 |
|
5dd1b7
|
333 |
pNewAppInfoBlock ptheNewAppInfoBlock = (pNewAppInfoBlock) NewAppInfoBlockAddress; |
Q |
334 |
if (ptheNewAppInfoBlock->Sign == 0x55AA) |
|
335 |
{ |
|
336 |
//check length and CRC; |
|
337 |
int length = ptheNewAppInfoBlock->Length; |
842bb6
|
338 |
int nCRC; // = crc16table((uint8_t *)NewAppAddress,length); |
Q |
339 |
nCRC = crc16bitbybit((uint8_t *)NewAppAddress,length); |
5dd1b7
|
340 |
if (nCRC == ptheNewAppInfoBlock->nCRC) |
Q |
341 |
{ |
|
342 |
// copy program |
|
343 |
EraseAndWriteToFlashMem((void *)NewAppAddress,(void*)ApplicationAddress,length); |
|
344 |
|
|
345 |
// verify copyed program |
|
346 |
//int nCRC2 = CalCRC((void *)NewAppAddress,length); |
|
347 |
|
|
348 |
|
|
349 |
//erease infoBlock |
|
350 |
EraseFlashMem((void *)NewAppInfoBlockAddress,1); |
|
351 |
} |
|
352 |
} |
|
353 |
// */ |
8b51c7
|
354 |
int nCount=0; |
Q |
355 |
while (1) |
|
356 |
{ |
|
357 |
|
|
358 |
SlowFlicker=0; |
|
359 |
FastFlicker=1; |
|
360 |
us1=GetuS(); |
|
361 |
LL_mDelay(100); |
|
362 |
|
|
363 |
// ToggleRunLed(); |
842bb6
|
364 |
ToggleErrLed(); |
8b51c7
|
365 |
ToggleErr2Led(); |
Q |
366 |
|
|
367 |
// LL_IWDG_ReloadCounter(IWDG); |
|
368 |
nCount++; |
|
369 |
if (nCount>2) {JumpToApplication(); LL_mDelay(1000);} |
|
370 |
|
|
371 |
} //while (1) ; |
|
372 |
/* USER CODE END WHILE */ |
|
373 |
|
|
374 |
/* USER CODE BEGIN 3 */ |
|
375 |
|
|
376 |
/* USER CODE END 3 */ |
|
377 |
} |
|
378 |
/* USER CODE BEGIN 4 */ |
|
379 |
|
|
380 |
/* USER CODE END 4 */ |
|
381 |
|
|
382 |
/** |
|
383 |
* @brief This function is executed in case of error occurrence. |
|
384 |
* @param file: The file name as string. |
|
385 |
* @param line: The line in file as a number. |
|
386 |
* @retval None |
|
387 |
*/ |
|
388 |
void _Error_Handler(char *file, int line) |
|
389 |
{ |
|
390 |
/* USER CODE BEGIN Error_Handler_Debug */ |
|
391 |
/* User can add his own implementation to report the HAL error return state */ |
|
392 |
while(1) |
|
393 |
{ |
|
394 |
} |
|
395 |
/* USER CODE END Error_Handler_Debug */ |
|
396 |
} |
|
397 |
|
|
398 |
#ifdef USE_FULL_ASSERT |
|
399 |
/** |
|
400 |
* @brief Reports the name of the source file and the source line number |
|
401 |
* where the assert_param error has occurred. |
|
402 |
* @param file: pointer to the source file name |
|
403 |
* @param line: assert_param error line source number |
|
404 |
* @retval None |
|
405 |
*/ |
|
406 |
void assert_failed(uint8_t* file, uint32_t line) |
|
407 |
{ |
|
408 |
/* USER CODE BEGIN 6 */ |
|
409 |
/* User can add his own implementation to report the file name and line number, |
|
410 |
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
|
411 |
/* USER CODE END 6 */ |
|
412 |
} |
|
413 |
#endif /* USE_FULL_ASSERT */ |
|
414 |
|
|
415 |
/** |
|
416 |
* @} |
|
417 |
*/ |
|
418 |
|
|
419 |
/** |
|
420 |
* @} |
|
421 |
*/ |
|
422 |
|
|
423 |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |