30
|
1 ///////////////////////////////////////////////////////////////////////////////
|
|
2 /// -*- coding: UTF-8 -*-
|
|
3 ///
|
|
4 /// \file BootLoader/Src/base_bootlader.c
|
|
5 /// \brief he beginning of it all. main() is part of this.
|
|
6 /// \author heinrichs/weikamp, Christian Weikamp
|
|
7 /// \date 26-February-2014
|
|
8 ///
|
|
9 /// $Id$
|
|
10 ///////////////////////////////////////////////////////////////////////////////
|
|
11 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
|
|
12 ///
|
|
13 /// This program is free software: you can redistribute it and/or modify
|
|
14 /// it under the terms of the GNU General Public License as published by
|
|
15 /// the Free Software Foundation, either version 3 of the License, or
|
|
16 /// (at your option) any later version.
|
|
17 ///
|
|
18 /// This program is distributed in the hope that it will be useful,
|
|
19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 /// GNU General Public License for more details.
|
|
22 ///
|
|
23 /// You should have received a copy of the GNU General Public License
|
|
24 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
25 //////////////////////////////////////////////////////////////////////////////
|
|
26 /**
|
|
27 * @detail The beginning of it all. main() is part of this.
|
|
28 * + Do the inits for hardware
|
|
29 * + check for button press or update process reset trigger
|
|
30 * + Do the inits for sub-systems like menu, dive screen etc.
|
|
31 * + Start IRQs
|
|
32 * + Start MainTasks not in IRQs
|
|
33 * @bug
|
|
34 * @warning
|
|
35 @verbatim
|
|
36
|
|
37 ==============================================================================
|
|
38 ##### bootloader specific #####
|
|
39 ==============================================================================
|
|
40
|
|
41 151130 chsw sleep on button3
|
|
42 (MX_tell_reset_logik_alles_ok() + DataEX_call() in endlos loop)
|
|
43
|
|
44 ==============================================================================
|
|
45 ##### bootloader specific #####
|
|
46 ==============================================================================
|
|
47
|
|
48 Bootloader info is set right here in this file.
|
|
49 The location is 0x0800A000 instead of 0x08050000 (firmware)
|
|
50
|
|
51 on system reset (Menu Start Bootloader in firmware) the update process
|
|
52 is started automatically if no button is pressed
|
|
53
|
|
54 if the right button is pressed the bootloader menu is started
|
|
55
|
|
56 after update process (with update or empty) cleaning of EEPROM is started
|
|
57 afterwards the watchdog reset starts without activating the update process
|
|
58
|
|
59 bluetooth chip is started in tComm on start of the mini bootloader firmware
|
|
60
|
|
61 SMALLCPU_CSB_PIN must be re-set to 0 to communicate with small CPU / CPU2 / RTE
|
|
62
|
|
63 for RealTerm to send file / firmware, Delays has to be increased to 0
|
|
64
|
|
65 RTE update / SPI1 with DMA gave IBUSERR, now it is working fine :-) 150828
|
|
66 ==============================================================================
|
|
67 from standard firmware, parts might be invalid here:
|
|
68 ==============================================================================
|
|
69 ##### IRQs #####
|
|
70 ==============================================================================
|
|
71 [..] The IRQs are very important and most functions should only run there.
|
|
72
|
|
73 PreemptPriority are as follows
|
|
74 (#) 2 (low) sprintf _only_ here. Don't use in maintask or anywhere else.
|
|
75 Called by Buttons und Timer3
|
|
76 Timer3 is 1/10 second
|
|
77 (#) 1 (mid) anything that should work while in IRQ2 like HalDelay(), VSYNC
|
|
78 and DMA2D Transfer Complete for housekeepingFrame();
|
|
79 (#) 0 (high) _very very short_ interrupts like The HAL hardware part for
|
|
80 spi, uart, i2c.
|
|
81
|
|
82 SubPriority within PreemptPriority give the order to execute.
|
|
83 Introduced 30.Oct.14 as it used by several HAL examples.
|
|
84 Three levelAmbients are available (2 low,1 mid,0 high)
|
|
85
|
|
86 The STM32F4 has 4bits for IRQ levelAmbients, divided 2/2 in this code
|
|
87 with the NVIC_PRIORITYGROUP_2 setting.
|
|
88
|
|
89 ==============================================================================
|
|
90 ##### MainTask #####
|
|
91 ==============================================================================
|
|
92 [..] For everthing slow without importance to be 'in time'.
|
|
93 Like VPM and Buehlmann.
|
|
94 No sprintf and probably no GFX_SetFramesTopBottom() stuff neither.
|
|
95 If sprintf is called while sprintf is executed it blows up everything.
|
|
96
|
|
97 ==============================================================================
|
|
98 ##### Frames / the external SDRAM #####
|
|
99 ==============================================================================
|
|
100 [..] The SDRAM is handled by getFrame() and releaseFrame().
|
|
101 Each frame with 800*480*2 Bytes.
|
|
102 Be carefull to release every frame
|
|
103 otherwise there will be a memory leakage over time.
|
|
104 housekeepingFrame() in the MainTask takes care of cleaning the frames.
|
|
105 All frames are filled with 0x00. This will be transparent with color of
|
|
106 CLUT_Font020 (is CLUT 0) if the alpha is set for a 16bit pair.
|
|
107 housekeepingFrame() delays the cleaning of frames still used as screen
|
|
108 buffer to prevent flickering.
|
|
109
|
|
110 ==============================================================================
|
|
111 ##### Display #####
|
|
112 ==============================================================================
|
|
113 [..] There is a Top layer, Bottom layer and background color.
|
|
114 All are perfectly alpha-blended by hardware.
|
|
115
|
|
116 (#) top layer has 800x480 option function calls only
|
|
117 as it is not used for cursors here
|
|
118 (#) bottom layer has free size and start option to be used
|
|
119 for cursors (or sprites in the future ;-)
|
|
120 (#) background only black in the moment.
|
|
121 ToDo: Could be anything else for warnings etc.
|
|
122 if needed
|
|
123
|
|
124 [..] Frame updates, switching and cursors is done with
|
|
125
|
|
126 (#) GFX_SetFramesTopBottom() and the subset
|
|
127 GFX_SetFrameTop() + GFX_SetFrameBottom()
|
|
128 Those do not change anything on the display but give commands to..
|
|
129 (#) GFX_change_LTDC() The only place that changes the pointer.
|
|
130 This prevents erratic behaviour if several changes
|
|
131 are made within one refresh rate of the screen.
|
|
132 Is called in IRQ by PD4 and HAL_GPIO_EXTI_IRQHandler
|
|
133 from VSYNC signal.
|
|
134
|
|
135 [..] Content
|
|
136
|
|
137 (#) Colors by LookupTable only. This could be modified by
|
|
138 system settings in the future. (gfx_color.h/.c)
|
|
139
|
|
140 (#) Text by text_multilinguage.h/.c with one char
|
|
141 necessary only starting from '\x80'
|
|
142 with automatic language switch by
|
|
143 selected_language in SSettings
|
|
144 see openEdit_Language() in tMenuEditSystem.c
|
|
145 Therefore there are differnent functions
|
|
146 for example:
|
|
147 write_label_fix() for single char multilanguage
|
|
148 write_label_var() for strings that could include
|
|
149 multilanguage as well
|
|
150 see GFX_write_string() to get an overview of the controls
|
|
151 as well as the command list in gfx_engine.h
|
|
152 There is no clear before writing, text overlay is always on.
|
|
153 Many options to have LargeFont.SmallFont for numbers etc.
|
|
154
|
|
155 ==============================================================================
|
|
156 ##### Update, DualBoot and build-in FLASH memory usage #####
|
|
157 ==============================================================================
|
|
158 [..] Boot0 pin, Boot1/PB2 pin and BFB2 software bit control the behaviour.
|
|
159 PB2 should be tied to GND.
|
|
160 Boot0 == VDD -> bootloader on start, otherwise boot from Bank1 or Bank2
|
|
161 depending on BFB2.
|
|
162 Bank2 contains the Fonts and should contain a proper test code in future
|
|
163 Bank1 is the main code (Bank1 is 1 MB too, usage as of Oct. 14 is 200 KB)
|
|
164 [..] Bootloader should be either UART or USB (on FS pins _only_)
|
|
165 USB HS to FS like on the Eval board does not work.
|
|
166 [..] Bootloader for the smaller CPU2 is implemented via the SPI used for DMA copy.
|
|
167
|
|
168 ==============================================================================
|
|
169 ##### Connection to CPU2 (STM32F411 as of Oct.14 #####
|
|
170 ==============================================================================
|
|
171 [..] Connected via SPI and DMA for every purpose.
|
|
172 two entire arrays are transfered for data security reasons
|
|
173 with respect to master (STM32F429) might interrupt internal
|
|
174 data copy in CPU2 (like hi byte, low byte, etc.).
|
|
175 [..] The entire life data is calculated in CPU2. Like tissues, CNS,...
|
|
176 Therefore the main unit is _not_ necessarily a Real Time system.
|
|
177 Simulation on the main unit can be executed without disrupting life data.
|
|
178 [..] SPI is triggered and timed by calling DataEX_call() in data_exchange_main.c
|
|
179 DataEX_copy_to_LifeData() does the transfer from buffer to variables used.
|
|
180
|
|
181 ==============================================================================
|
|
182 ##### Menu, MenuEdit, Info #####
|
|
183 ==============================================================================
|
|
184 [..] tMenu.c, tMenuEdit.c and tInfo.c is the system used.
|
|
185 logbook is part of Info not Menu.
|
|
186 The Info Menu is accessed by button 'Back'
|
|
187 The regular Menu is accessed by button 'Enter'
|
|
188 [..] Menu content is kept in frame memory for fast access.
|
|
189 There is no need to build pages if the 'Enter' button is pressed.
|
|
190 This is in contrast to MenuEdit pages.
|
|
191 [..] Button control for new pages (and pages in general) have to implemented
|
|
192 in tMenu.c, tMenuEdit.c or tInfo.c
|
|
193
|
|
194 [..] ToDo (Oct. 14) Timeout for menus via Timer3 / IRQ 2
|
|
195
|
|
196 ==============================================================================
|
|
197 ##### specials #####
|
|
198 ==============================================================================
|
|
199 [..] There was code for vector graphics from great demos
|
|
200 (peridiummmm and jupiter) that can be fitted again
|
|
201
|
|
202 @endverbatim
|
|
203 ******************************************************************************
|
|
204 */
|
|
205
|
|
206 /* Includes ------------------------------------------------------------------*/
|
|
207 #include "base_bootloader.h"
|
|
208
|
|
209 // From Bootloader/Inc:
|
|
210 #include "tInfoBootloader.h"
|
|
211
|
|
212 // ?
|
|
213 #include "externLogbookFlash.h"
|
|
214 #include "firmwareEraseProgram.h"
|
|
215 #include "firmwareJumpToApplication.h"
|
|
216
|
|
217 // From Common/Inc:
|
|
218 #include "FirmwareData.h"
|
|
219
|
|
220 // From Common/Drivers:
|
|
221 #include "stm32f4xx_hal.h"
|
|
222 #include "stm32f4xx_hal_rcc.h"
|
|
223 #include "stm32f4xx_hal_flash_ex.h"
|
|
224 #include "stm32f4xx_hal_wwdg.h"
|
|
225
|
|
226 // From Discovery/Inc (shall be shared...)
|
|
227 #include "data_exchange_main.h"
|
|
228 #include "display.h"
|
|
229 #include "gfx_engine.h"
|
|
230 #include "ostc.h"
|
|
231 #include "tComm.h"
|
|
232 #include "tStructure.h"
|
|
233
|
|
234 // From AC6 support:
|
|
235 #include <stdio.h>
|
|
236 #include <string.h> // for memcopy
|
|
237
|
|
238 /* Private define ------------------------------------------------------------*/
|
|
239 #define BUFFER_SIZE ((uint32_t)0x00177000)
|
|
240 #define WRITE_READ_ADDR ((uint32_t)0x0000)
|
|
241 #define REFRESH_COUNT ((uint32_t)0x0569) /* SDRAM refresh counter (90Mhz SD clock) */
|
|
242
|
|
243 /* Private macro -------------------------------------------------------------*/
|
|
244 /* Private variables ---------------------------------------------------------*/
|
|
245 uint8_t returnFromCommCleanUpRequest = 0;
|
|
246
|
|
247 const SFirmwareData bootloader_FirmwareData __attribute__(( section(".bootloader_firmware_data") )) =
|
|
248 {
|
|
249 .versionFirst = 1,
|
|
250 .versionSecond = 0,
|
|
251 .versionThird = 1,
|
|
252 .versionBeta = 1,
|
|
253
|
|
254 /* 4 bytes with trailing 0 */
|
|
255 .signature = "cw",
|
|
256
|
|
257 .release_year = 16,
|
|
258 .release_month = 4,
|
|
259 .release_day = 8,
|
|
260 .release_sub = 0,
|
|
261
|
|
262 /* max 48 with trailing 0 */
|
|
263 .release_info ="tComm with all",
|
|
264
|
|
265 /* for safety reasons and coming functions*/
|
|
266 .magic[0] = FIRMWARE_MAGIC_FIRST,
|
|
267 .magic[1] = FIRMWARE_MAGIC_SECOND,
|
|
268 .magic[2] = FIRMWARE_MAGIC_FIRMWARE, /* the magic byte */
|
|
269 .magic[3] = FIRMWARE_MAGIC_END
|
|
270 };
|
|
271
|
|
272
|
|
273 const SHardwareData HardwareData __attribute__((at(HARDWAREDATA_ADDRESS))) = {
|
|
274
|
|
275 // first 52 bytes
|
|
276 .primarySerial = 0xFFFF,
|
|
277 .primaryLicence = 0xFF,
|
|
278 .revision8bit = 0xFF,
|
|
279 .production_year = 0xFF,
|
|
280 .production_month = 0xFF,
|
|
281 .production_day = 0xFF,
|
|
282 .production_bluetooth_name_set = 0xFF,
|
|
283
|
|
284 .production_info = {
|
|
285 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
|
286 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
|
287 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
|
288 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
|
|
289
|
|
290 // other 12 bytes (64 in total)
|
|
291 .secondarySerial = 0xFFFF,
|
|
292 .secondaryLicence = 0xFF,
|
|
293 .secondaryReason8bit = 0xFF,
|
|
294 .secondary_year = 0xFF,
|
|
295 .secondary_month = 0xFF,
|
|
296 .secondary_day = 0xFF,
|
|
297 .secondary_bluetooth_name_set = 0xFF,
|
|
298 .secondary_info = {0xFF,0xFF,0xFF,0xFF}
|
|
299 };
|
|
300
|
|
301
|
|
302 RTC_HandleTypeDef RtcHandle;
|
|
303 TIM_HandleTypeDef TimHandle; /* used in stm32f4xx_it.c too */
|
|
304 TIM_HandleTypeDef TimBacklightHandle; /* used in stm32f4xx_it.c too */
|
|
305
|
|
306 uint32_t time_before;
|
|
307 uint32_t time_between;
|
|
308 uint32_t time_after;
|
|
309
|
|
310 /* SDRAM handler declaration */
|
|
311 SDRAM_HandleTypeDef hsdram;
|
|
312 FMC_SDRAM_TimingTypeDef SDRAM_Timing;
|
|
313 FMC_SDRAM_CommandTypeDef command;
|
|
314
|
|
315 FLASH_OBProgramInitTypeDef OBInit;
|
|
316 FLASH_AdvOBProgramInitTypeDef AdvOBInit;
|
|
317
|
|
318
|
|
319 /* Private variables with external access ------------------------------------*/
|
|
320
|
|
321 uint32_t globalStateID = 0;
|
|
322 uint8_t globalModeID = SURFMODE;
|
|
323 uint32_t time_without_button_pressed_deciseconds = 0;
|
|
324 uint8_t bootToBootloader = 0;
|
|
325
|
|
326 /* Private function prototypes -----------------------------------------------*/
|
|
327
|
|
328 //static void LCD_ToggleFramebuffer(GFX_DrawCfgTypeDef *hconfig);
|
|
329 //static void LCD_Config(GFX_DrawCfgTypeDef *hconfig);
|
|
330 static void SystemClock_Config(void);
|
|
331 static void Error_Handler(void);
|
|
332
|
|
333 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command);
|
|
334 static void SDRAM_Config(void);
|
|
335 //static void DualBoot(void);
|
|
336 static void EXTILine_Buttons_Config(void);
|
|
337 //static void RTC_init(void);
|
|
338 static void TIM_init(void);
|
|
339 static void TIM_BACKLIGHT_init(void);
|
|
340 //static void TIM_BACKLIGHT_adjust(void);
|
|
341 static void gotoSleep(void);
|
|
342 uint8_t checkResetForFirmwareUpdate(void);
|
|
343 void DeleteResetToFirmwareUpdateRegister(void);
|
|
344 void reset_to_firmware_using_Watchdog(void);
|
|
345 void reset_to_update_using_system_reset(void);
|
|
346
|
|
347 //static void DualBootToBootloader(void);
|
|
348
|
|
349 /* ITM Trace-------- ---------------------------------------------------------*/
|
|
350 /*
|
|
351 #define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n)))
|
|
352 #define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n)))
|
|
353 #define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n)))
|
|
354
|
|
355 #define DEMCR (*((volatile unsigned long *)(0xE000EDFC)))
|
|
356 #define TRCENA 0x01000000
|
|
357
|
|
358 struct __FILE { int handle; };
|
|
359 FILE __stdout;
|
|
360 FILE __stdin;
|
|
361
|
|
362 int fputc(int ch, FILE *f) {
|
|
363 if (DEMCR & TRCENA) {
|
|
364 while (ITM_Port32(0) == 0);
|
|
365 ITM_Port8(0) = ch;
|
|
366 }
|
|
367 return(ch);
|
|
368 }
|
|
369 */
|
|
370
|
|
371 /* Private functions ---------------------------------------------------------*/
|
|
372
|
|
373 /**
|
|
374 * @brief Main program
|
|
375 * @param None
|
|
376 * @retval None
|
|
377 */
|
|
378
|
|
379 void GPIO_test_I2C_lines(void)
|
|
380 {
|
|
381 GPIO_InitTypeDef GPIO_InitStructure;
|
|
382 __GPIOA_CLK_ENABLE();
|
|
383 __GPIOG_CLK_ENABLE();
|
|
384 GPIO_InitStructure.Pin = GPIO_PIN_7;
|
|
385 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
|
386 GPIO_InitStructure.Pull = GPIO_PULLUP;
|
|
387 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
|
388 HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
|
|
389 GPIO_InitStructure.Pin = GPIO_PIN_3;
|
|
390 HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
|
|
391
|
|
392 while(1)
|
|
393 {
|
|
394 HAL_GPIO_WritePin(GPIOG,GPIO_PIN_7,GPIO_PIN_SET);
|
|
395 HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3,GPIO_PIN_RESET);
|
|
396 HAL_Delay(10);
|
|
397 HAL_GPIO_WritePin(GPIOG,GPIO_PIN_7,GPIO_PIN_RESET);
|
|
398 HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3,GPIO_PIN_SET);
|
|
399 HAL_Delay(10);
|
|
400 }
|
|
401 }
|
|
402
|
|
403
|
|
404 int main(void)
|
|
405 {
|
|
406
|
|
407 /*
|
|
408 HAL_Init();
|
|
409 SystemClock_Config();
|
|
410 GPIO_test_I2C_lines();
|
|
411 */
|
|
412 uint32_t pLayerInvisible;
|
|
413 uint32_t firmware_load_result;
|
|
414 uint8_t magicbyte = 0;
|
|
415 uint8_t callForUpdate;
|
|
416 uint8_t status = 0;
|
|
417 char textVersion[32];
|
|
418 uint8_t ptr;
|
|
419 uint32_t pOffset;
|
|
420
|
|
421 set_globalState(StBoot0);
|
|
422
|
|
423 HAL_Init();
|
|
424 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2);
|
|
425
|
|
426 /* feedback for the user
|
|
427 * aber sehr unsch�n beim Warmstart
|
|
428 * da das letzte Bild noch lange nachleuchtet */
|
|
429 // MX_GPIO_Backlight_max_static_only_Init();
|
|
430
|
|
431
|
|
432 /* button press is only 40 to 50 us low */
|
|
433 MX_GPIO_One_Button_only_Init();
|
|
434
|
|
435 uint32_t i = 500000;
|
|
436
|
|
437 callForUpdate = __HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST);
|
|
438
|
|
439 if(callForUpdate)
|
|
440 {
|
|
441 i = 0;
|
|
442 }
|
|
443 else
|
|
444 if( (firmware_MainCodeIsProgammed() == 0)
|
|
445 || (hardwareDataGetPointer()->primarySerial == 0xFFFF)
|
|
446 || (hardwareDataGetPointer()->production_bluetooth_name_set == 0xFF))
|
|
447 {
|
|
448 i = 1;
|
|
449 }
|
|
450 else
|
|
451 {
|
|
452 while(MX_GPIO_Read_The_One_Button() && i)
|
|
453 {
|
|
454 i--;
|
|
455 __NOP();
|
|
456 }
|
|
457 if(i)
|
|
458 {
|
|
459 i = 200000;
|
|
460 while(!MX_GPIO_Read_The_One_Button() && i)
|
|
461 {
|
|
462 i--;
|
|
463 __NOP();
|
|
464 }
|
|
465 if(i)
|
|
466 {
|
|
467 i = 200000;
|
|
468 while(MX_GPIO_Read_The_One_Button() && i)
|
|
469 {
|
|
470 i--;
|
|
471 __NOP();
|
|
472 }
|
|
473 if(i)
|
|
474 {
|
|
475 i = 200000;
|
|
476 while(!MX_GPIO_Read_The_One_Button() && i)
|
|
477 {
|
|
478 i--;
|
|
479 __NOP();
|
|
480 }
|
|
481 if(i)
|
|
482 {
|
|
483 i = 200000;
|
|
484 while(MX_GPIO_Read_The_One_Button() && i)
|
|
485 {
|
|
486 i--;
|
|
487 __NOP();
|
|
488 }
|
|
489 }
|
|
490 }
|
|
491 }
|
|
492 }
|
|
493 }
|
|
494
|
|
495 if((i == 0) && (callForUpdate == 0))
|
|
496 firmware_JumpTo_Application();
|
|
497
|
|
498 SystemClock_Config();
|
|
499
|
|
500 MX_GPIO_Init();
|
|
501 MX_Bluetooth_PowerOn();
|
|
502 MX_SPI_Init();
|
|
503 SDRAM_Config();
|
|
504 HAL_Delay(100);
|
|
505
|
|
506 GFX_init1_no_DMA(&pLayerInvisible, 2);
|
|
507
|
|
508 TIM_BACKLIGHT_init();
|
|
509
|
|
510 // -----------------------------
|
|
511
|
|
512 display_power_on__1_of_2__pre_RGB();
|
|
513 GFX_LTDC_Init();
|
|
514 GFX_LTDC_LayerDefaultInit(TOP_LAYER, pLayerInvisible);
|
|
515 GFX_LTDC_LayerDefaultInit(BACKGRD_LAYER, pLayerInvisible);
|
|
516 GFX_SetFramesTopBottom(pLayerInvisible,pLayerInvisible,480);
|
|
517 HAL_Delay(20);
|
|
518 display_power_on__2_of_2__post_RGB();
|
|
519
|
|
520 // -----------------------------
|
|
521 GFX_change_LTDC();
|
|
522 GFX_hwBackgroundOn();
|
|
523 GFX_change_LTDC();
|
|
524 // -----------------------------
|
|
525 tInfoBootloader_init();
|
|
526 // -----------------------------
|
|
527 if(i == 0)
|
|
528 {
|
|
529 tInfo_newpage("load firmware data");
|
|
530 uint8_t* pBuffer = (uint8_t*)((uint32_t)0xD0000000); /* blocked via GFX_init1_no_DMA */
|
|
531 firmware_load_result = ext_flash_read_firmware(pBuffer,768000, &magicbyte);
|
|
532
|
|
533 if((firmware_load_result > 0) && (firmware_load_result < 768000) && (magicbyte == 0xEE))
|
|
534 {
|
|
535 ptr = ext_flash_read_firmware_version(textVersion);
|
|
536 textVersion[ptr++] = 'f';
|
|
537 textVersion[ptr++] = 'o';
|
|
538 textVersion[ptr++] = 'u';
|
|
539 textVersion[ptr++] = 'n';
|
|
540 textVersion[ptr++] = 'd';
|
|
541 textVersion[ptr] = 0;
|
|
542
|
|
543 tInfo_newpage(textVersion);
|
|
544 tInfo_write("erase flash");
|
|
545 status = firmware_eraseFlashMemory();
|
|
546 if(status != HAL_OK)
|
|
547 {
|
|
548 tInfo_newpage("error. try again.");
|
|
549 status = firmware_eraseFlashMemory();
|
|
550 if(status != HAL_OK)
|
|
551 {
|
|
552 tInfo_newpage("error. skip update.");
|
|
553 HAL_Delay(1000);
|
|
554 }
|
|
555 }
|
|
556 if(status == HAL_OK)
|
|
557 {
|
|
558 tInfo_write("programm flash");
|
|
559 status = firmware_programFlashMemory(pBuffer,firmware_load_result);
|
|
560 if(status != HAL_OK)
|
|
561 {
|
|
562 tInfo_newpage("error. try again.");
|
|
563 status = firmware_programFlashMemory(pBuffer,firmware_load_result);
|
|
564 if(status != HAL_OK)
|
|
565 {
|
|
566 tInfo_newpage("error. skip update.");
|
|
567 HAL_Delay(1000);
|
|
568 }
|
|
569 }
|
|
570 }
|
|
571 }
|
|
572 }
|
|
573
|
|
574 /* here comes the variable upper firmware loader */
|
|
575 if((i == 0) && (status == HAL_OK))
|
|
576 {
|
|
577 tInfo_newpage("load firmware2 data");
|
|
578 uint8_t* pBuffer = (uint8_t*)((uint32_t)0xD0000000); /* blocked via GFX_init1_no_DMA */
|
|
579 firmware_load_result = ext_flash_read_firmware2(&pOffset, pBuffer,768000*2,0,0);
|
|
580
|
|
581 if((firmware_load_result > 0) && (firmware_load_result + pOffset <= 1024000))
|
|
582 {
|
|
583 ptr = 0;
|
|
584 ptr += gfx_number_to_string(7,0,&textVersion[ptr],firmware_load_result);
|
|
585 textVersion[ptr++] = ' ';
|
|
586 textVersion[ptr++] = 'b';
|
|
587 textVersion[ptr++] = 'y';
|
|
588 textVersion[ptr++] = 't';
|
|
589 textVersion[ptr++] = 'e';
|
|
590 textVersion[ptr++] = 's';
|
|
591 textVersion[ptr++] = ' ';
|
|
592 textVersion[ptr++] = 'w';
|
|
593 textVersion[ptr++] = 'i';
|
|
594 textVersion[ptr++] = 't';
|
|
595 textVersion[ptr++] = 'h';
|
|
596 textVersion[ptr++] = ' ';
|
|
597 ptr += gfx_number_to_string(7,0,&textVersion[ptr],pOffset);
|
|
598 textVersion[ptr++] = ' ';
|
|
599 textVersion[ptr++] = 'o';
|
|
600 textVersion[ptr++] = 'f';
|
|
601 textVersion[ptr++] = 'f';
|
|
602 textVersion[ptr++] = 's';
|
|
603 textVersion[ptr++] = 'e';
|
|
604 textVersion[ptr++] = 't';
|
|
605 textVersion[ptr] = 0;
|
|
606 tInfo_newpage(textVersion);
|
|
607
|
|
608 ptr = 0;
|
|
609 textVersion[ptr++] = 'f';
|
|
610 textVersion[ptr++] = 'o';
|
|
611 textVersion[ptr++] = 'u';
|
|
612 textVersion[ptr++] = 'n';
|
|
613 textVersion[ptr++] = 'd';
|
|
614 textVersion[ptr] = 0;
|
|
615
|
|
616 tInfo_write(textVersion);
|
|
617 tInfo_write("erase flash");
|
|
618 status = firmware2_variable_upperpart_eraseFlashMemory(firmware_load_result,pOffset);
|
|
619 if(status != HAL_OK)
|
|
620 {
|
|
621 tInfo_newpage("error. try again.");
|
|
622 status = firmware2_variable_upperpart_eraseFlashMemory(firmware_load_result,pOffset);
|
|
623 if(status != HAL_OK)
|
|
624 {
|
|
625 tInfo_newpage("error. skip update.");
|
|
626 HAL_Delay(1000);
|
|
627 }
|
|
628 }
|
|
629 if(status == HAL_OK)
|
|
630 {
|
|
631 tInfo_write("programm flash");
|
|
632 status = firmware2_variable_upperpart_programFlashMemory(firmware_load_result,pOffset,pBuffer,firmware_load_result,0);
|
|
633 if(status != HAL_OK)
|
|
634 {
|
|
635 tInfo_newpage("error. try again.");
|
|
636 status = firmware2_variable_upperpart_programFlashMemory(firmware_load_result,pOffset,pBuffer,firmware_load_result,0);
|
|
637 if(status != HAL_OK)
|
|
638 {
|
|
639 tInfo_newpage("error. skip update.");
|
|
640 HAL_Delay(1000);
|
|
641 }
|
|
642 }
|
|
643 }
|
|
644 }
|
|
645 }
|
|
646
|
|
647 if((i == 0) && (status == HAL_OK))
|
|
648 {
|
|
649 tInfo_newpage("Done.");
|
|
650 tInfo_write("Cleaning.");
|
|
651 ext_flash_erase_firmware_if_not_empty();
|
|
652 ext_flash_erase_firmware2_if_not_empty();
|
|
653 tInfo_write("Reset device.");
|
|
654 reset_to_firmware_using_Watchdog();
|
|
655 }
|
|
656
|
|
657 ptr = 0;
|
|
658 textVersion[ptr++] = '\021';
|
|
659 textVersion[ptr++] = 's';
|
|
660 textVersion[ptr++] = 'e';
|
|
661 textVersion[ptr++] = 'r';
|
|
662 textVersion[ptr++] = 'i';
|
|
663 textVersion[ptr++] = 'a';
|
|
664 textVersion[ptr++] = 'l';
|
|
665 textVersion[ptr++] = ' ';
|
|
666 if(HardwareData.primarySerial == 0xFFFF)
|
|
667 {
|
|
668 textVersion[ptr++] = 'n';
|
|
669 textVersion[ptr++] = 'o';
|
|
670 textVersion[ptr++] = 't';
|
|
671 textVersion[ptr++] = ' ';
|
|
672 textVersion[ptr++] = 's';
|
|
673 textVersion[ptr++] = 'e';
|
|
674 textVersion[ptr++] = 't';
|
|
675 }
|
|
676 else if(HardwareData.secondarySerial == 0xFFFF)
|
|
677 {
|
|
678 textVersion[ptr++] = '#';
|
|
679 ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData.primarySerial);
|
|
680 }
|
|
681 else
|
|
682 {
|
|
683 textVersion[ptr++] = '#';
|
|
684 ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData.secondarySerial);
|
|
685 textVersion[ptr++] = ' ';
|
|
686 textVersion[ptr++] = '(';
|
|
687 ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData.primarySerial);
|
|
688 textVersion[ptr++] = ')';
|
|
689 }
|
|
690 textVersion[ptr++] = '\020';
|
|
691 textVersion[ptr] = 0;
|
|
692
|
|
693 tInfo_button_text("Exit","","Sleep");
|
|
694 tInfo_newpage("Bootloader 160602");
|
|
695 tInfo_write("start bluetooth");
|
|
696 tInfo_write("");
|
|
697 tInfo_write(textVersion);
|
|
698 tInfo_write("");
|
|
699
|
|
700 TIM_init();
|
|
701 MX_UART_Init();
|
|
702 MX_Bluetooth_PowerOn();
|
|
703 tComm_Set_Bluetooth_Name(0);
|
|
704
|
|
705 tComm_init();
|
|
706 set_globalState_Base();
|
|
707
|
|
708 GFX_start_VSYNC_IRQ();
|
|
709
|
|
710 EXTILine_Buttons_Config();
|
|
711 /*
|
|
712 uint8_t* pBuffer1 = (uint8_t*)getFrame(20);
|
|
713 firmware_load_result = ext_flash_read_firmware(pBuffer1,768000);
|
|
714
|
|
715 if((firmware_load_result > 0) && (firmware_load_result < 768000))
|
|
716 {
|
|
717 firmware_eraseFlashMemory();
|
|
718 firmware_programFlashMemory(pBuffer1,firmware_load_result);
|
|
719 // not for testing
|
|
720 //ext_flash_erase_firmware_if_not_empty();
|
|
721 reset_to_firmware_using_Watchdog();
|
|
722 }
|
|
723 */
|
|
724 while(1)
|
|
725 {
|
|
726 // if(bootToBootloader)
|
|
727 // DualBootToBootloader();
|
|
728
|
|
729 if(bootToBootloader)
|
|
730 reset_to_update_using_system_reset();
|
|
731
|
|
732 tComm_control(); // will stop while loop if tComm Mode started until exit from UART
|
|
733 };
|
|
734 }
|
|
735
|
|
736
|
|
737 void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|
738 {
|
|
739
|
|
740 SStateList status;
|
|
741
|
|
742 get_globalStateList(&status);
|
|
743
|
|
744 switch(status.base)
|
|
745 {
|
|
746 default:
|
|
747 // TIM_BACKLIGHT_adjust();
|
|
748 break;
|
|
749 }
|
|
750
|
|
751 if(returnFromCommCleanUpRequest)
|
|
752 {
|
|
753 tComm_exit();
|
|
754 returnFromCommCleanUpRequest = 0;
|
|
755 GFX_hwBackgroundOn();
|
|
756 tInfo_button_text("Exit","","Sleep");
|
|
757 tInfo_newpage("bluetooth disonnected");
|
|
758 tInfo_write("");
|
|
759 tInfo_write("");
|
|
760 tInfo_write("");
|
|
761 tInfo_write("");
|
|
762 }
|
|
763
|
|
764 get_globalStateList(&status);
|
|
765
|
|
766 switch(status.base)
|
|
767 {
|
|
768 case BaseComm:
|
|
769 if(get_globalState() == StUART_STANDARD)
|
|
770 tComm_refresh();
|
|
771 break;
|
|
772 default:
|
|
773 break;
|
|
774 }
|
|
775 }
|
|
776
|
|
777 void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|
778 {
|
|
779 uint8_t action;
|
|
780 SStateList status;
|
|
781 static uint8_t counterToPreventSleep = 0;
|
|
782 if(GPIO_Pin == VSYNC_IRQ_PIN) // rechts, unten
|
|
783 {
|
|
784 GFX_change_LTDC();
|
|
785 housekeepingFrame();
|
|
786 if(counterToPreventSleep < 250)
|
|
787 counterToPreventSleep++;
|
|
788 else
|
|
789 if(counterToPreventSleep != 255)
|
|
790 {
|
|
791 counterToPreventSleep = 255;
|
|
792 }
|
|
793
|
|
794 return;
|
|
795 }
|
|
796
|
|
797 time_without_button_pressed_deciseconds = 0;
|
|
798
|
|
799 if(GFX_logoStatus() != 0)
|
|
800 return;
|
|
801
|
|
802 if(GPIO_Pin == BUTTON_BACK_PIN) // links
|
|
803 action = ACTION_BUTTON_BACK;
|
|
804 else
|
|
805 if(GPIO_Pin == BUTTON_ENTER_PIN) // mitte
|
|
806 action = ACTION_BUTTON_ENTER;
|
|
807 else
|
|
808 if(GPIO_Pin == BUTTON_NEXT_PIN) // rechts
|
|
809 action = ACTION_BUTTON_NEXT;
|
|
810 #ifdef BUTTON_CUSTOM_PIN
|
|
811 else
|
|
812 if(GPIO_Pin == BUTTON_CUSTOM_PIN) // extra
|
|
813 action = ACTION_BUTTON_CUSTOM;
|
|
814 #endif
|
|
815 else
|
|
816 action = 0;
|
|
817 get_globalStateList(&status);
|
|
818
|
|
819 switch(status.base)
|
|
820 {
|
|
821 case BaseComm:
|
|
822 if(action == ACTION_BUTTON_BACK)
|
|
823 {
|
|
824 reset_to_firmware_using_Watchdog();
|
|
825 }
|
|
826 break;
|
|
827
|
|
828 default:
|
|
829 if((action == ACTION_BUTTON_NEXT) && (counterToPreventSleep == 255) && (get_globalState() == StS))
|
|
830 {
|
|
831 while(1)
|
|
832 {
|
|
833 MX_tell_reset_logik_alles_ok();
|
|
834 DataEX_call();
|
|
835 HAL_Delay(100);
|
|
836 }
|
|
837 }
|
|
838 else
|
|
839 if(action == ACTION_BUTTON_BACK)
|
|
840 {
|
|
841 reset_to_firmware_using_Watchdog();
|
|
842 }
|
|
843 else
|
|
844 if(action == ACTION_BUTTON_CUSTOM)
|
|
845 {
|
|
846 if(get_globalState() == StS)
|
|
847 gotoSleep();
|
|
848 }
|
|
849 else
|
|
850 if(action == ACTION_BUTTON_ENTER)
|
|
851 {
|
|
852 reset_to_update_using_system_reset();
|
|
853 }
|
|
854 break;
|
|
855 }
|
|
856 }
|
|
857
|
|
858
|
|
859 void gotoSleep(void)
|
|
860 {
|
|
861 ext_flash_erase_firmware_if_not_empty();
|
|
862 set_globalState(StStop);
|
|
863 }
|
|
864
|
|
865 // -----------------------------
|
|
866
|
|
867
|
|
868 void MainBootLoaderInit(void)
|
|
869 {
|
|
870 void (*SysMemBootJump)(void);
|
|
871 SysMemBootJump=(void (*)(void)) (*((uint32_t *) 0x1fff0004));
|
|
872
|
|
873 // DMA, SPI, UART, TIM, ExtIRQ, graphics DMA, LTDC
|
|
874
|
|
875 HAL_RCC_DeInit();
|
|
876 SysTick->CTRL = 0;
|
|
877 SysTick->LOAD = 0;
|
|
878 SysTick->VAL = 0;
|
|
879
|
|
880 __set_PRIMASK(1);
|
|
881
|
|
882 __set_MSP(0x20002318);
|
|
883 SysMemBootJump();
|
|
884 }
|
|
885
|
|
886 uint32_t get_globalState(void)
|
|
887 {
|
|
888 return globalStateID;
|
|
889 }
|
|
890
|
|
891 void get_globalStateList(SStateList *output)
|
|
892 {
|
|
893 output->base = (uint8_t)((globalStateID >> 28) & 0x0F);
|
|
894 output->page = (uint8_t)((globalStateID >> 24) & 0x0F);
|
|
895 output->line = (uint8_t)((globalStateID >> 16) & 0xFF);
|
|
896 output->field = (uint8_t)((globalStateID >> 8) & 0xFF);
|
|
897 output->mode = (uint8_t)((globalStateID ) & 0xFF);
|
|
898 }
|
|
899
|
|
900 void get_idSpecificStateList(uint32_t id, SStateList *output)
|
|
901 {
|
|
902 output->base = (uint8_t)((id >> 28) & 0x0F);
|
|
903 output->page = (uint8_t)((id >> 24) & 0x0F);
|
|
904 output->line = (uint8_t)((id >> 16) & 0xFF);
|
|
905 output->field = (uint8_t)((id >> 8) & 0xFF);
|
|
906 output->mode = (uint8_t)((id ) & 0xFF);
|
|
907 }
|
|
908
|
|
909 void set_globalState_Base(void)
|
|
910 {
|
|
911 set_globalState(StS);
|
|
912 }
|
|
913
|
|
914 void set_globalState_Menu_Page(uint8_t page)
|
|
915 {
|
|
916 globalStateID = ((BaseMenu << 28) + (page << 24));
|
|
917 }
|
|
918
|
|
919 void set_globalState_Log_Page(uint8_t pageIsLine)
|
|
920 {
|
|
921 globalStateID = StILOGLIST + (pageIsLine << 16);
|
|
922 }
|
|
923
|
|
924
|
|
925 void set_globalState_Menu_Line(uint8_t line)
|
|
926 {
|
|
927 globalStateID = ((globalStateID & MaskLineFieldDigit) + (line << 16));
|
|
928 }
|
|
929
|
|
930
|
|
931 void set_globalState(uint32_t newID)
|
|
932 {
|
|
933 globalStateID = newID;
|
|
934 }
|
|
935
|
|
936
|
|
937
|
|
938 void delayMicros(uint32_t micros)
|
|
939 {
|
|
940 micros = micros * (168/4) - 10;
|
|
941 while(micros--);
|
|
942 }
|
|
943
|
|
944
|
|
945 void get_RTC_DateTime(RTC_DateTypeDef * sdatestructureget, RTC_TimeTypeDef * stimestructureget)
|
|
946 {
|
|
947 /* Get the RTC current Time */
|
|
948 if(sdatestructureget)
|
|
949 HAL_RTC_GetTime(&RtcHandle, stimestructureget, FORMAT_BIN);
|
|
950 /* Get the RTC current Date */
|
|
951 if(stimestructureget)
|
|
952 HAL_RTC_GetDate(&RtcHandle, sdatestructureget, FORMAT_BIN);
|
|
953 }
|
|
954
|
|
955
|
|
956 void set_RTC_DateTime(RTC_DateTypeDef * sdatestructure, RTC_TimeTypeDef * stimestructure)
|
|
957 {
|
|
958 if(sdatestructure)
|
|
959 if(HAL_RTC_SetDate(&RtcHandle,sdatestructure,FORMAT_BCD) != HAL_OK)
|
|
960 {
|
|
961 /* Initialization Error */
|
|
962 Error_Handler();
|
|
963 }
|
|
964
|
|
965 if(stimestructure)
|
|
966 if(HAL_RTC_SetTime(&RtcHandle,stimestructure,FORMAT_BCD) != HAL_OK)
|
|
967 {
|
|
968 /* Initialization Error */
|
|
969 Error_Handler();
|
|
970 }
|
|
971 }
|
|
972
|
|
973 static void TIM_init(void)
|
|
974 {
|
|
975 uint16_t uwPrescalerValue = 0;
|
|
976
|
|
977 uwPrescalerValue = (uint32_t) ((SystemCoreClock /2) / 10000) - 1;
|
|
978
|
|
979 /* Set TIMx instance */
|
|
980 TimHandle.Instance = TIMx;
|
|
981
|
|
982 /* Initialize TIM3 peripheral as follows:
|
|
983 + Period = 10000 - 1
|
|
984 + Prescaler = ((SystemCoreClock/2)/10000) - 1
|
|
985 + ClockDivision = 0
|
|
986 + Counter direction = Up
|
|
987 */
|
|
988 TimHandle.Init.Period = 1000 - 1;
|
|
989 TimHandle.Init.Prescaler = uwPrescalerValue;
|
|
990 TimHandle.Init.ClockDivision = 0;
|
|
991 TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
|
992 if(HAL_TIM_Base_Init(&TimHandle) != HAL_OK)
|
|
993 {
|
|
994 /* Initialization Error */
|
|
995 Error_Handler();
|
|
996 }
|
|
997
|
|
998 /*##-2- Start the TIM Base generation in interrupt mode ####################*/
|
|
999 /* Start Channel1 */
|
|
1000 if(HAL_TIM_Base_Start_IT(&TimHandle) != HAL_OK)
|
|
1001 {
|
|
1002 /* Starting Error */
|
|
1003 Error_Handler();
|
|
1004 }
|
|
1005 }
|
|
1006
|
|
1007 #ifndef TIM_BACKLIGHT
|
|
1008 /*
|
|
1009 static void TIM_BACKLIGHT_adjust(void)
|
|
1010 {
|
|
1011 }
|
|
1012 */
|
|
1013 static void TIM_BACKLIGHT_init(void)
|
|
1014 {
|
|
1015 }
|
|
1016 #else
|
|
1017 /*
|
|
1018 static void TIM_BACKLIGHT_adjust(void)
|
|
1019 {
|
|
1020
|
|
1021 TIM_OC_InitTypeDef sConfig;
|
|
1022 sConfig.OCMode = TIM_OCMODE_PWM1;
|
|
1023 sConfig.OCPolarity = TIM_OCPOLARITY_HIGH;
|
|
1024 sConfig.OCFastMode = TIM_OCFAST_DISABLE;
|
|
1025 sConfig.Pulse = 600;
|
|
1026
|
|
1027 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL);
|
|
1028 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL);
|
|
1029 }
|
|
1030 */
|
|
1031 static void TIM_BACKLIGHT_init(void)
|
|
1032 {
|
|
1033 uint32_t uwPrescalerValue = 0;
|
|
1034 TIM_OC_InitTypeDef sConfig;
|
|
1035
|
|
1036 uwPrescalerValue = (uint32_t) ((SystemCoreClock /2) / 18000000) - 1;
|
|
1037
|
|
1038 TimBacklightHandle.Instance = TIM_BACKLIGHT;
|
|
1039
|
|
1040 // Initialize TIM3 peripheral as follows: 30 kHz
|
|
1041
|
|
1042 TimBacklightHandle.Init.Period = 600 - 1;
|
|
1043 TimBacklightHandle.Init.Prescaler = uwPrescalerValue;
|
|
1044 TimBacklightHandle.Init.ClockDivision = 0;
|
|
1045 TimBacklightHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
|
1046 HAL_TIM_PWM_Init(&TimBacklightHandle);
|
|
1047
|
|
1048 sConfig.OCMode = TIM_OCMODE_PWM1;
|
|
1049 sConfig.OCPolarity = TIM_OCPOLARITY_HIGH;
|
|
1050 sConfig.OCFastMode = TIM_OCFAST_DISABLE;
|
|
1051 sConfig.Pulse = 50 * 6;
|
|
1052
|
|
1053 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL);
|
|
1054 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL);
|
|
1055 }
|
|
1056 #endif
|
|
1057
|
|
1058 /* Configure RTC prescaler and RTC data registers */
|
|
1059 /* RTC configured as follow:
|
|
1060 - Hour Format = Format 24
|
|
1061 - Asynch Prediv = Value according to source clock
|
|
1062 - Synch Prediv = Value according to source clock
|
|
1063 - OutPut = Output Disable
|
|
1064 - OutPutPolarity = High Polarity
|
|
1065 - OutPutType = Open Drain */
|
|
1066 /*#define RTC_ASYNCH_PREDIV 0x7F LSE as RTC clock */
|
|
1067 /*LSE: #define RTC_SYNCH_PREDIV 0x00FF LSE as RTC clock */
|
|
1068 /*LSI: #define RTC_SYNCH_PREDIV 0x0130 LSI as RTC clock */
|
|
1069 /*
|
|
1070 static void RTC_init(void)
|
|
1071 {
|
|
1072 RtcHandle.Instance = RTC;
|
|
1073
|
|
1074
|
|
1075 RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24;
|
|
1076 RtcHandle.Init.AsynchPrediv = 0x7F;
|
|
1077 RtcHandle.Init.SynchPrediv = 0x0130;
|
|
1078 RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
|
|
1079 RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
|
|
1080 RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
|
|
1081
|
|
1082 if(HAL_RTC_Init(&RtcHandle) != HAL_OK)
|
|
1083 {
|
|
1084 Error_Handler();
|
|
1085 }
|
|
1086 }
|
|
1087 */
|
|
1088
|
|
1089 static void EXTILine_Buttons_Config(void)
|
|
1090 {
|
|
1091 GPIO_InitTypeDef GPIO_InitStructure;
|
|
1092
|
|
1093 BUTTON_ENTER_GPIO_ENABLE();
|
|
1094 BUTTON_NEXT_GPIO_ENABLE();
|
|
1095 BUTTON_BACK_GPIO_ENABLE();
|
|
1096
|
|
1097 /* Configure pin as weak PULLUP input */
|
|
1098 /* buttons */
|
|
1099 GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING;
|
|
1100 GPIO_InitStructure.Pull = GPIO_NOPULL;
|
|
1101 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
|
1102
|
|
1103 GPIO_InitStructure.Pin = BUTTON_ENTER_PIN;
|
|
1104 HAL_GPIO_Init(BUTTON_ENTER_GPIO_PORT, &GPIO_InitStructure);
|
|
1105
|
|
1106 GPIO_InitStructure.Pin = BUTTON_NEXT_PIN;
|
|
1107 HAL_GPIO_Init(BUTTON_NEXT_GPIO_PORT, &GPIO_InitStructure);
|
|
1108
|
|
1109 GPIO_InitStructure.Pin = BUTTON_BACK_PIN;
|
|
1110 HAL_GPIO_Init(BUTTON_BACK_GPIO_PORT, &GPIO_InitStructure);
|
|
1111
|
|
1112 /* Enable and set EXTI Line0 Interrupt to the lowest priority */
|
|
1113 HAL_NVIC_SetPriority(BUTTON_ENTER_EXTI_IRQn, 2, 0);
|
|
1114 HAL_NVIC_SetPriority(BUTTON_NEXT_EXTI_IRQn, 2, 0);
|
|
1115 HAL_NVIC_SetPriority(BUTTON_BACK_EXTI_IRQn, 2, 0);
|
|
1116 HAL_NVIC_EnableIRQ(BUTTON_ENTER_EXTI_IRQn);
|
|
1117 HAL_NVIC_EnableIRQ(BUTTON_NEXT_EXTI_IRQn);
|
|
1118 HAL_NVIC_EnableIRQ(BUTTON_BACK_EXTI_IRQn);
|
|
1119
|
|
1120 #ifdef BUTTON_CUSTOM_PIN
|
|
1121 BUTTON_CUSTOM_GPIO_ENABLE();
|
|
1122 GPIO_InitStructure.Pin = BUTTON_CUSTOM_PIN;
|
|
1123 HAL_GPIO_Init(BUTTON_CUSTOM_GPIO_PORT, &GPIO_InitStructure);
|
|
1124 HAL_NVIC_SetPriority(BUTTON_CUSTOM_EXTI_IRQn, 2, 0);
|
|
1125 HAL_NVIC_EnableIRQ(BUTTON_CUSTOM_EXTI_IRQn);
|
|
1126 #endif
|
|
1127 }
|
|
1128
|
|
1129
|
|
1130 /**
|
|
1131 * @brief System Clock Configuration
|
|
1132 * The system Clock is configured as follow :
|
|
1133 * System Clock source = PLL (HSE)
|
|
1134 * SYSCLK(Hz) = 180000000
|
|
1135 * HCLK(Hz) = 180000000
|
|
1136 * AHB Prescaler = 1
|
|
1137 * APB1 Prescaler = 4
|
|
1138 * APB2 Prescaler = 2
|
|
1139 * HSE Frequency(Hz) = 8000000
|
|
1140 * PLL_M = 8
|
|
1141 * PLL_N = 360
|
|
1142 * PLL_P = 2
|
|
1143 * PLL_Q = 7
|
|
1144 * VDD(V) = 3.3
|
|
1145 * Main regulator output voltage = Scale1 mode
|
|
1146 * Flash Latency(WS) = 5
|
|
1147 * The LTDC Clock is configured as follow :
|
|
1148 * PLLSAIN = 192
|
|
1149 * PLLSAIR = 4
|
|
1150 * PLLSAIDivR = 8
|
|
1151 * @param None
|
|
1152 * @retval None
|
|
1153 */
|
|
1154 static void SystemClock_Config(void)
|
|
1155 {
|
|
1156 RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
|
1157 RCC_OscInitTypeDef RCC_OscInitStruct;
|
|
1158 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
|
|
1159
|
|
1160 /* Enable Power Control clock */
|
|
1161 __PWR_CLK_ENABLE();
|
|
1162
|
|
1163 /* The voltage scaling allows optimizing the power consumption when the device is
|
|
1164 clocked below the maximum system frequency, to update the voltage scaling value
|
|
1165 regarding system frequency refer to product datasheet. */
|
|
1166 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
|
1167
|
|
1168 /*##-1- System Clock Configuration #########################################*/
|
|
1169 /* Enable HSE Oscillator and activate PLL with HSE as source */
|
|
1170 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
|
1171 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
|
1172 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
|
1173 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
|
1174 RCC_OscInitStruct.PLL.PLLM = 8;
|
|
1175 RCC_OscInitStruct.PLL.PLLN = 336;//360;
|
|
1176 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
|
1177 RCC_OscInitStruct.PLL.PLLQ = 7;
|
|
1178 HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
|
1179
|
|
1180 // HAL_PWREx_ActivateOverDrive();
|
|
1181 HAL_PWREx_DeactivateOverDrive();
|
|
1182 /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
|
|
1183 clocks dividers */
|
|
1184 RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
|
1185 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
|
1186 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
|
1187 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
|
1188 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
|
1189 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_8);//FLASH_LATENCY_5);
|
|
1190
|
|
1191 /*##-2- LTDC Clock Configuration ###########################################*/
|
|
1192 /* LCD clock configuration */
|
|
1193 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
|
|
1194 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
|
|
1195 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */
|
|
1196 /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDIVR_8 = 48/8 = 6 Mhz */
|
|
1197
|
|
1198 /* neu: 8MHz/8*300/5/8 = 7,5 MHz = 19,5 Hz bei 800 x 480 */
|
|
1199 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
|
|
1200 PeriphClkInitStruct.PLLSAI.PLLSAIN = 300;//192;
|
|
1201 PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;//4;
|
|
1202 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;//RCC_PLLSAIDIVR_4;// RCC_PLLSAIDIVR_2; // RCC_PLLSAIDIVR_8
|
|
1203 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
|
|
1204 }
|
|
1205
|
|
1206
|
|
1207 /**
|
|
1208 * @brief This function is executed in case of error occurrence.
|
|
1209 * @param None
|
|
1210 * @retval None
|
|
1211 */
|
|
1212 static void Error_Handler(void)
|
|
1213 {
|
|
1214 /* Turn LED3 on */
|
|
1215 // BSP_LED_On(LED3);
|
|
1216 while(1)
|
|
1217 {
|
|
1218 }
|
|
1219 }
|
|
1220
|
|
1221 /**
|
|
1222 * @brief Perform the SDRAM exernal memory inialization sequence
|
|
1223 * @param hsdram: SDRAM handle
|
|
1224 * @param Command: Pointer to SDRAM command structure
|
|
1225 * @retval None
|
|
1226 */
|
|
1227 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command)
|
|
1228 {
|
|
1229 __IO uint32_t tmpmrd =0;
|
|
1230 /* Step 3: Configure a clock configuration enable command */
|
|
1231 Command->CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
|
|
1232 Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
|
|
1233 Command->AutoRefreshNumber = 1;
|
|
1234 Command->ModeRegisterDefinition = 0;
|
|
1235
|
|
1236 /* Send the command */
|
|
1237 HAL_SDRAM_SendCommand(hsdram, Command, 0x1000);
|
|
1238
|
|
1239 /* Step 4: Insert 100 ms delay */
|
|
1240 HAL_Delay(100);
|
|
1241
|
|
1242 /* Step 5: Configure a PALL (precharge all) command */
|
|
1243 Command->CommandMode = FMC_SDRAM_CMD_PALL;
|
|
1244 Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
|
|
1245 Command->AutoRefreshNumber = 1;
|
|
1246 Command->ModeRegisterDefinition = 0;
|
|
1247
|
|
1248 /* Send the command */
|
|
1249 HAL_SDRAM_SendCommand(hsdram, Command, 0x1000);
|
|
1250
|
|
1251 /* Step 6 : Configure a Auto-Refresh command */
|
|
1252 Command->CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
|
|
1253 Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
|
|
1254 Command->AutoRefreshNumber = 4;
|
|
1255 Command->ModeRegisterDefinition = 0;
|
|
1256
|
|
1257 /* Send the command */
|
|
1258 HAL_SDRAM_SendCommand(hsdram, Command, 0x1000);
|
|
1259
|
|
1260 /* Step 7: Program the external memory mode register */
|
|
1261 tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_2 |
|
|
1262 SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |
|
|
1263 SDRAM_MODEREG_CAS_LATENCY_3 |
|
|
1264 SDRAM_MODEREG_OPERATING_MODE_STANDARD |
|
|
1265 SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;
|
|
1266
|
|
1267 Command->CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
|
|
1268 Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
|
|
1269 Command->AutoRefreshNumber = 1;
|
|
1270 Command->ModeRegisterDefinition = tmpmrd;
|
|
1271
|
|
1272 /* Send the command */
|
|
1273 HAL_SDRAM_SendCommand(hsdram, Command, 0x1000);
|
|
1274
|
|
1275 /* Step 8: Set the refresh rate counter */
|
|
1276 /* (15.62 us x Freq) - 20 */
|
|
1277 /* neu: (8 us x Freq) - 20 */
|
|
1278 /* Set the device refresh counter */
|
|
1279 HAL_SDRAM_ProgramRefreshRate(hsdram, REFRESH_COUNT);
|
|
1280 }
|
|
1281
|
|
1282 /*
|
|
1283 static void DualBoot(void)
|
|
1284 {
|
|
1285 // Set BFB2 bit to enable boot from Flash Bank2
|
|
1286 // Allow Access to Flash control registers and user Falsh
|
|
1287 HAL_FLASH_Unlock();
|
|
1288
|
|
1289 // Allow Access to option bytes sector
|
|
1290 HAL_FLASH_OB_Unlock();
|
|
1291
|
|
1292 // Get the Dual boot configuration status
|
|
1293 AdvOBInit.OptionType = OBEX_BOOTCONFIG;
|
|
1294 HAL_FLASHEx_AdvOBGetConfig(&AdvOBInit);
|
|
1295
|
|
1296 // Enable/Disable dual boot feature
|
|
1297 if (((AdvOBInit.BootConfig) & (FLASH_OPTCR_BFB2)) == FLASH_OPTCR_BFB2)
|
|
1298 {
|
|
1299 AdvOBInit.BootConfig = OB_DUAL_BOOT_DISABLE;
|
|
1300 HAL_FLASHEx_AdvOBProgram (&AdvOBInit);
|
|
1301 }
|
|
1302 else
|
|
1303 {
|
|
1304 AdvOBInit.BootConfig = OB_DUAL_BOOT_ENABLE;
|
|
1305 HAL_FLASHEx_AdvOBProgram (&AdvOBInit);
|
|
1306 }
|
|
1307
|
|
1308 // Start the Option Bytes programming process
|
|
1309 if (HAL_FLASH_OB_Launch() != HAL_OK)
|
|
1310 {
|
|
1311 // User can add here some code to deal with this error
|
|
1312 while (1)
|
|
1313 {
|
|
1314 }
|
|
1315 }
|
|
1316 // Prevent Access to option bytes sector
|
|
1317 HAL_FLASH_OB_Lock();
|
|
1318
|
|
1319 // Disable the Flash option control register access (recommended to protect
|
|
1320 // the option Bytes against possible unwanted operations)
|
|
1321 HAL_FLASH_Lock();
|
|
1322
|
|
1323 // Initiates a system reset request to reset the MCU
|
|
1324 reset_to_firmware_using_Watchdog();
|
|
1325 }
|
|
1326 */
|
|
1327 /**
|
|
1328 ******************************************************************************
|
|
1329 ******************************************************************************
|
|
1330 ******************************************************************************
|
|
1331 */
|
|
1332
|
|
1333
|
|
1334 /**
|
|
1335 * @brief DMA2D configuration.
|
|
1336 * @note This function Configure tha DMA2D peripheral :
|
|
1337 * 1) Configure the transfer mode : memory to memory W/ pixel format conversion
|
|
1338 * 2) Configure the output color mode as ARGB4444
|
|
1339 * 3) Configure the output memory address at SRAM memory
|
|
1340 * 4) Configure the data size : 320x120 (pixels)
|
|
1341 * 5) Configure the input color mode as ARGB8888
|
|
1342 * 6) Configure the input memory address at FLASH memory
|
|
1343 * @retval
|
|
1344 * None
|
|
1345 */
|
|
1346
|
|
1347 static void SDRAM_Config(void)
|
|
1348 {
|
|
1349 /*##-1- Configure the SDRAM device #########################################*/
|
|
1350 /* SDRAM device configuration */
|
|
1351 hsdram.Instance = FMC_SDRAM_DEVICE;
|
|
1352
|
|
1353 /* Timing configuration for 90 Mhz of SD clock frequency (180Mhz/2) */
|
|
1354 /* TMRD: 2 Clock cycles */
|
|
1355 SDRAM_Timing.LoadToActiveDelay = 2;
|
|
1356 /* TXSR: min=70ns (6x11.90ns) */
|
|
1357 SDRAM_Timing.ExitSelfRefreshDelay = 7;
|
|
1358 /* TRAS: min=42ns (4x11.90ns) max=120k (ns) */
|
|
1359 SDRAM_Timing.SelfRefreshTime = 4;
|
|
1360 /* TRC: min=63 (6x11.90ns) */
|
|
1361 SDRAM_Timing.RowCycleDelay = 7;
|
|
1362 /* TWR: 2 Clock cycles */
|
|
1363 SDRAM_Timing.WriteRecoveryTime = 2;
|
|
1364 /* TRP: 15ns => 2x11.90ns */
|
|
1365 SDRAM_Timing.RPDelay = 2;
|
|
1366 /* TRCD: 15ns => 2x11.90ns */
|
|
1367 SDRAM_Timing.RCDDelay = 2;
|
|
1368
|
|
1369 hsdram.Init.SDBank = FMC_SDRAM_BANK2;
|
|
1370 hsdram.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9;
|
|
1371 hsdram.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13;
|
|
1372 hsdram.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH;
|
|
1373 hsdram.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
|
|
1374 hsdram.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;
|
|
1375 hsdram.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
|
|
1376 hsdram.Init.SDClockPeriod = SDCLOCK_PERIOD;
|
|
1377 hsdram.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE;
|
|
1378 hsdram.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_1;
|
|
1379
|
|
1380 /* Initialize the SDRAM controller */
|
|
1381 if(HAL_SDRAM_Init(&hsdram, &SDRAM_Timing) != HAL_OK)
|
|
1382 {
|
|
1383 /* Initialization Error */
|
|
1384 Error_Handler();
|
|
1385 }
|
|
1386
|
|
1387 /* Program the SDRAM external device */
|
|
1388 SDRAM_Initialization_Sequence(&hsdram, &command);
|
|
1389 }
|
|
1390
|
|
1391
|
|
1392 uint8_t checkResetForFirmwareUpdate(void)
|
|
1393 {
|
|
1394 uint32_t backupRegisterContent;
|
|
1395
|
|
1396 RTC_HandleTypeDef RtcHandle;
|
|
1397 RtcHandle.Instance = RTC;
|
|
1398 backupRegisterContent = HAL_RTCEx_BKUPRead(&RtcHandle,RTC_BKP_DR0);
|
|
1399
|
|
1400 if(backupRegisterContent == 0x12345678)
|
|
1401 return 1;
|
|
1402 else
|
|
1403 return 0;
|
|
1404 }
|
|
1405
|
|
1406 void DeleteResetToFirmwareUpdateRegister(void)
|
|
1407 {
|
|
1408 RTC_HandleTypeDef RtcHandle;
|
|
1409 RtcHandle.Instance = RTC;
|
|
1410 __HAL_RTC_WRITEPROTECTION_DISABLE(&RtcHandle);
|
|
1411 HAL_RTCEx_BKUPWrite(&RtcHandle,RTC_BKP_DR0,0x00);
|
|
1412 __HAL_RTC_WRITEPROTECTION_ENABLE(&RtcHandle);
|
|
1413 }
|
|
1414
|
|
1415 #ifdef USE_FULL_ASSERT
|
|
1416
|
|
1417 /**
|
|
1418 * @brief Reports the name of the source file and the source line number
|
|
1419 * where the assert_param error has occurred.
|
|
1420 * @param file: pointer to the source file name
|
|
1421 * @param line: assert_param error line source number
|
|
1422 * @retval None
|
|
1423 */
|
|
1424 void assert_failed(uint8_t* file, uint32_t line)
|
|
1425 {
|
|
1426 /* User can add his own implementation to report the file name and line number,
|
|
1427 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
|
1428
|
|
1429 /* Infinite loop */
|
|
1430 while (1)
|
|
1431 {
|
|
1432 }
|
|
1433 }
|
|
1434 #endif
|
|
1435
|
|
1436 /*
|
|
1437 static void DualBootToBootloader(void)
|
|
1438 {
|
|
1439 // Set BFB2 bit to enable boot from Flash Bank2
|
|
1440 // Allow Access to Flash control registers and user Falsh
|
|
1441 HAL_FLASH_Unlock();
|
|
1442
|
|
1443 // Allow Access to option bytes sector
|
|
1444 HAL_FLASH_OB_Unlock();
|
|
1445
|
|
1446 // Get the Dual boot configuration status
|
|
1447 AdvOBInit.OptionType = OPTIONBYTE_BOOTCONFIG;
|
|
1448 HAL_FLASHEx_AdvOBGetConfig(&AdvOBInit);
|
|
1449
|
|
1450 // Enable/Disable dual boot feature
|
|
1451 if (((AdvOBInit.BootConfig) & (FLASH_OPTCR_BFB2)) == FLASH_OPTCR_BFB2)
|
|
1452 {
|
|
1453 AdvOBInit.BootConfig = OB_DUAL_BOOT_DISABLE;
|
|
1454 HAL_FLASHEx_AdvOBProgram (&AdvOBInit);
|
|
1455 if (HAL_FLASH_OB_Launch() != HAL_OK)
|
|
1456 {
|
|
1457 while (1)
|
|
1458 {
|
|
1459 }
|
|
1460 }
|
|
1461 }
|
|
1462 else
|
|
1463 {
|
|
1464
|
|
1465 AdvOBInit.BootConfig = OB_DUAL_BOOT_ENABLE;
|
|
1466 HAL_FLASHEx_AdvOBProgram (&AdvOBInit);
|
|
1467 if (HAL_FLASH_OB_Launch() != HAL_OK)
|
|
1468 {
|
|
1469 while (1)
|
|
1470 {
|
|
1471 }
|
|
1472 }
|
|
1473 }
|
|
1474
|
|
1475 // Prevent Access to option bytes sector
|
|
1476 HAL_FLASH_OB_Lock();
|
|
1477
|
|
1478 / Disable the Flash option control register access (recommended to protect
|
|
1479 // the option Bytes against possible unwanted operations)
|
|
1480 HAL_FLASH_Lock();
|
|
1481
|
|
1482 // Initiates a system reset request to reset the MCU
|
|
1483 reset_to_firmware_using_Watchdog();
|
|
1484 }
|
|
1485 */
|
|
1486
|
|
1487 void reset_to_update_using_system_reset(void)
|
|
1488 {
|
|
1489 __HAL_RCC_CLEAR_RESET_FLAGS();
|
|
1490 HAL_NVIC_SystemReset();
|
|
1491 }
|
|
1492
|
|
1493 void reset_to_firmware_using_Watchdog(void)
|
|
1494 {
|
|
1495 __HAL_RCC_CLEAR_RESET_FLAGS();
|
|
1496 __HAL_RCC_WWDG_CLK_ENABLE();
|
|
1497
|
|
1498 WWDG_HandleTypeDef WwdgHandle;
|
|
1499 WwdgHandle.Instance = WWDG;
|
|
1500
|
|
1501 WwdgHandle.Init.Prescaler = WWDG_PRESCALER_8;
|
|
1502 WwdgHandle.Init.Window = 80;
|
|
1503 WwdgHandle.Init.Counter = 127;
|
|
1504
|
|
1505 HAL_WWDG_Init(&WwdgHandle);
|
|
1506 HAL_WWDG_Start(&WwdgHandle);
|
|
1507 while(1);
|
|
1508 }
|
|
1509
|
|
1510
|
|
1511 void set_returnFromComm(void)
|
|
1512 {
|
|
1513 returnFromCommCleanUpRequest = 1;
|
|
1514 }
|
|
1515
|
|
1516 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
|