22 #include PLATFORM_HEADER
28 #pragma language=extended
31 __root __no_init
const HalFixedAddressTableType halFixedAddressTable @ __FAT__;
33 extern const HalVectorTableType __vector_table[];
36 #define IAP_BOOTLOADER_APP_SWITCH_SIGNATURE 0xb001204d
37 #define IAP_BOOTLOADER_MODE_UART 0
39 __interwork
int __low_level_init(
void);
41 static void setStackPointer(uint32_t address)
46 static const uint16_t blOffset[] = {
47 0x0715 - 0x03ad - 0x68,
48 0x0719 - 0x03ad - 0x6C
52 __interwork
int __low_level_init(
void)
72 DEBUG_EMCR &= ~DEBUG_EMCR_VC_CORERESET;
76 FLASH_ACCESS = (FLASH_ACCESS_PREFETCH_EN |
77 (1<<FLASH_ACCESS_CODE_LATENCY_BIT));
82 SCS_VTOR = (uint32_t)__vector_table;
91 SCS_AIRCR = (0x05FA0000 | (4 <<SCS_AIRCR_PRIGROUP_BIT));
103 #define CRITICAL (0 <<3)
107 #define NONE (31 <<3)
117 SCS_SHPR_7to4 = ((CRITICAL <<SCS_SHPR_7to4_PRI_4_BIT) |
118 (CRITICAL <<SCS_SHPR_7to4_PRI_5_BIT) |
119 (CRITICAL <<SCS_SHPR_7to4_PRI_6_BIT) |
120 (NONE <<SCS_SHPR_7to4_PRI_7_BIT));
121 SCS_SHPR_11to8 = ((NONE <<SCS_SHPR_11to8_PRI_8_BIT) |
122 (NONE <<SCS_SHPR_11to8_PRI_9_BIT) |
123 (NONE <<SCS_SHPR_11to8_PRI_10_BIT) |
124 (HIGH <<SCS_SHPR_11to8_PRI_11_BIT));
125 SCS_SHPR_15to12 = ((MED <<SCS_SHPR_15to12_PRI_12_BIT) |
126 (NONE <<SCS_SHPR_15to12_PRI_13_BIT) |
127 (HIGH <<SCS_SHPR_15to12_PRI_14_BIT) |
128 (MED <<SCS_SHPR_15to12_PRI_15_BIT));
129 NVIC_IPR_3to0 = ((MED <<NVIC_IPR_3to0_PRI_0_BIT) |
130 (MED <<NVIC_IPR_3to0_PRI_1_BIT) |
131 (HIGH <<NVIC_IPR_3to0_PRI_2_BIT) |
132 (MED <<NVIC_IPR_3to0_PRI_3_BIT));
133 NVIC_IPR_7to4 = ((MED <<NVIC_IPR_7to4_PRI_4_BIT) |
134 (MED <<NVIC_IPR_7to4_PRI_5_BIT) |
135 (MED <<NVIC_IPR_7to4_PRI_6_BIT) |
136 (MED <<NVIC_IPR_7to4_PRI_7_BIT));
137 NVIC_IPR_11to8 = ((MED <<NVIC_IPR_11to8_PRI_8_BIT) |
138 (MED <<NVIC_IPR_11to8_PRI_9_BIT) |
139 (MED <<NVIC_IPR_11to8_PRI_10_BIT) |
140 (MED <<NVIC_IPR_11to8_PRI_11_BIT));
141 NVIC_IPR_15to12 = ((MED <<NVIC_IPR_15to12_PRI_12_BIT) |
142 (MED <<NVIC_IPR_15to12_PRI_13_BIT) |
143 (MED <<NVIC_IPR_15to12_PRI_14_BIT) |
144 (MED <<NVIC_IPR_15to12_PRI_15_BIT));
145 NVIC_IPR_19to16 = ((LOW <<NVIC_IPR_19to16_PRI_16_BIT));
151 SCS_CCR = SCS_CCR_DIV_0_TRP_MASK;
152 SCS_SHCSR = ( SCS_SHCSR_USGFAULTENA_MASK
153 | SCS_SHCSR_BUSFAULTENA_MASK
154 | SCS_SHCSR_MEMFAULTENA_MASK );
157 if((RESET_EVENT&RESET_DSLEEP) == RESET_DSLEEP) {
162 void halTriggerContextRestore(
void);
163 extern volatile boolean halPendSvSaveContext;
164 halPendSvSaveContext = 0;
165 SCS_ICSR |= SCS_ICSR_PENDSVSET;
166 halTriggerContextRestore();
173 uint8_t cut = *(
volatile uint8_t *) 0x08040798;
175 typedef void (*EntryPoint)(void);
176 offset = (halFixedAddressTable.baseTable.version == 3) ? blOffset[cut - 2] : 0;
177 *((uint32_t *)RAM_BOTTOM) = 0;
181 EntryPoint entryPoint = (EntryPoint)(*(uint32_t *)(FIB_BOTTOM+4) - offset);
182 setStackPointer(*(uint32_t *)FIB_BOTTOM);
198 #pragma language=default
STM32W108 series memory map definitions used by the full hal.
void halInternalSwitchToXtal(void)
Switches to running off of the 24MHz crystal, including changing the CPU to be 24MHz (FCLK sourced fr...
#define INTERRUPTS_OFF()
Disable global interrupts without regard to the current or previous state.
#define IAP_BOOTLOADER_MODE_UART
IAP bootloader uart mode.
#define IAP_BOOTLOADER_APP_SWITCH_SIGNATURE
Signature used for switch to application.