@@ -89,16 +89,19 @@ void mbed_start_application(uintptr_t address)
89
89
90
90
static void powerdown_nvic ()
91
91
{
92
- int isr_groups_32 ;
93
92
int i ;
94
93
int j ;
94
+ int isr_groups_32 ;
95
95
96
96
#if defined(__CORTEX_M23 )
97
97
// M23 doesn't support ICTR and supports up to 240 external interrupts.
98
98
isr_groups_32 = 8 ;
99
+ #elif defined(__CORTEX_M0PLUS )
100
+ isr_groups_32 = 1 ;
99
101
#else
100
102
isr_groups_32 = ((SCnSCB -> ICTR & SCnSCB_ICTR_INTLINESNUM_Msk ) >> SCnSCB_ICTR_INTLINESNUM_Pos ) + 1 ;
101
103
#endif
104
+
102
105
for (i = 0 ; i < isr_groups_32 ; i ++ ) {
103
106
NVIC -> ICER [i ] = 0xFFFFFFFF ;
104
107
NVIC -> ICPR [i ] = 0xFFFFFFFF ;
@@ -122,21 +125,21 @@ static void powerdown_scb(uint32_t vtor)
122
125
SCB -> AIRCR = 0x05FA | 0x0000 ;
123
126
SCB -> SCR = 0x00000000 ;
124
127
// SCB->CCR - Implementation defined value
125
- #if defined(__CORTEX_M23 )
126
- for (i = 0 ; i < 2 ; i ++ ) {
127
- SCB -> SHPR [i ] = 0x00 ;
128
- }
128
+ int num_pri_reg ; // Number of priority registers
129
+ #if defined(__CORTEX_M0PLUS ) || defined(__CORTEX_M23 )
130
+ num_pri_reg = 2 ;
129
131
#else
130
- for (i = 0 ; i < 12 ; i ++ ) {
131
- #if defined(__CORTEX_M7 )
132
+ num_pri_reg = 12 ;
133
+ #endif
134
+ for (i = 0 ; i < num_pri_reg ; i ++ ) {
135
+ #if defined(__CORTEX_M7 ) || defined(__CORTEX_M23 )
132
136
SCB -> SHPR [i ] = 0x00 ;
133
137
#else
134
138
SCB -> SHP [i ] = 0x00 ;
135
139
#endif
136
140
}
137
- #endif
138
141
SCB -> SHCSR = 0x00000000 ;
139
- #if defined(__CORTEX_M23 )
142
+ #if defined(__CORTEX_M23 ) || defined( __CORTEX_M0PLUS )
140
143
#else
141
144
SCB -> CFSR = 0xFFFFFFFF ;
142
145
SCB -> HFSR = SCB_HFSR_DEBUGEVT_Msk | SCB_HFSR_FORCED_Msk | SCB_HFSR_VECTTBL_Msk ;
@@ -158,7 +161,7 @@ static void powerdown_scb(uint32_t vtor)
158
161
159
162
__asm static void start_new_application (void * sp , void * pc )
160
163
{
161
- MOV R2 , #0
164
+ MOVS R2 , #0
162
165
MSR CONTROL , R2 // Switch to main stack
163
166
MOV SP , R0
164
167
MSR PRIMASK , R2 // Enable interrupts
@@ -170,9 +173,7 @@ __asm static void start_new_application(void *sp, void *pc)
170
173
void start_new_application (void * sp , void * pc )
171
174
{
172
175
__asm volatile (
173
- "movw r2, #0 \n" // Fail to compile "mov r2, #0" with ARMC6. Replace with MOVW.
174
- // We needn't "movt r2, #0" immediately following because MOVW
175
- // will zero-extend the 16-bit immediate.
176
+ "movs r2, #0 \n"
176
177
"msr control, r2 \n" // Switch to main stack
177
178
"mov sp, %0 \n"
178
179
"msr primask, r2 \n" // Enable interrupts
0 commit comments