FastLED 3.10.6
Loading...
Searching...
No Matches
AutoResearchStartupHook.cpp
Go to the documentation of this file.
2
3#if defined(FL_IS_TEENSY_4X) && defined(__IMXRT1062__)
4
5#include <Arduino.h>
6
7// Disable the iMXRT1062 RTWDOG before the Arduino runtime starts.
8//
9// WDOG3 can already be armed when this sketch boots, and a short prior timeout
10// can reset the chip before USB enumeration or setup() runs. Teensyduino exposes
11// startup_early_hook as a weak symbol specifically for this kind of early reset
12// recovery. Keep the override in this .cpp file: Arduino prototype generation
13// can give .ino prototypes C++ linkage, which conflicts with the C-linkage weak
14// symbol and breaks fbuild deploy.
15extern "C" FLASHMEM void startup_early_hook(void) {
16 CCM_CCGR5 |= CCM_CCGR5_WDOG3(3);
17 __asm__ volatile ("dsb" ::: "memory");
18 __asm__ volatile ("isb" ::: "memory");
19
20 WDOG3_CNT = 0xD928C520u;
21
22 {
23 volatile uint32_t spin = 0;
24 while (!(WDOG3_CS & WDOG_CS_ULK)) {
25 if (++spin > 200000u) {
26 break;
27 }
28 }
29 }
30
31 WDOG3_TOVAL = 0xFFFFu;
32 WDOG3_WIN = 0;
33 WDOG3_CS = WDOG_CS_CMD32EN | WDOG_CS_UPDATE | WDOG_CS_CLK(1);
34
35 {
36 volatile uint32_t spin = 0;
37 while (!(WDOG3_CS & WDOG_CS_RCS)) {
38 if (++spin > 200000u) {
39 break;
40 }
41 }
42 }
43}
44
45#endif
fl::u32 uint32_t
Definition stdint.h:218