Fix mbed_start_application on Cortex-M23

1. M23 doesn't support ICTR and supports up to 240 external interrupts.
2. Fix reset of SHPR
3. Fix inline assembly compile error with ARMC6
pull/7228/head
ccli8 2018-05-28 11:43:27 +08:00 committed by adbridge
parent 4f9de80311
commit a77e4072b2
1 changed files with 10 additions and 7 deletions

View File

@ -49,7 +49,8 @@ static void powerdown_nvic()
int j; int j;
#if defined(__CORTEX_M23) #if defined(__CORTEX_M23)
isr_groups_32 = 16; // M23 doesn't support ICTR and supports up to 240 external interrupts.
isr_groups_32 = 8;
#else #else
isr_groups_32 = ((SCnSCB->ICTR & SCnSCB_ICTR_INTLINESNUM_Msk) >> SCnSCB_ICTR_INTLINESNUM_Pos) + 1; isr_groups_32 = ((SCnSCB->ICTR & SCnSCB_ICTR_INTLINESNUM_Msk) >> SCnSCB_ICTR_INTLINESNUM_Pos) + 1;
#endif #endif
@ -76,13 +77,19 @@ static void powerdown_scb(uint32_t vtor)
SCB->AIRCR = 0x05FA | 0x0000; SCB->AIRCR = 0x05FA | 0x0000;
SCB->SCR = 0x00000000; SCB->SCR = 0x00000000;
// SCB->CCR - Implementation defined value // SCB->CCR - Implementation defined value
#if defined(__CORTEX_M23)
for (i = 0; i < 2; i++) {
SCB->SHPR[i] = 0x00;
}
#else
for (i = 0; i < 12; i++) { for (i = 0; i < 12; i++) {
#if defined(__CORTEX_M7) || defined(__CORTEX_M23) #if defined(__CORTEX_M7)
SCB->SHPR[i] = 0x00; SCB->SHPR[i] = 0x00;
#else #else
SCB->SHP[i] = 0x00; SCB->SHP[i] = 0x00;
#endif #endif
} }
#endif
SCB->SHCSR = 0x00000000; SCB->SHCSR = 0x00000000;
#if defined(__CORTEX_M23) #if defined(__CORTEX_M23)
#else #else
@ -118,12 +125,8 @@ __asm static void start_new_application(void *sp, void *pc)
void start_new_application(void *sp, void *pc) void start_new_application(void *sp, void *pc)
{ {
__asm volatile ( __asm volatile (
#if defined(__CORTEX_M23) "movw r2, #0 \n" // Fail to compile "mov r2, #0" with ARMC6. Replace with movw/movt.
"movw r2, #0 \n"
"movt r2, #0 \n" "movt r2, #0 \n"
#else
"mov r2, #0 \n"
#endif
"msr control, r2 \n" // Switch to main stack "msr control, r2 \n" // Switch to main stack
"mov sp, %0 \n" "mov sp, %0 \n"
"msr primask, r2 \n" // Enable interrupts "msr primask, r2 \n" // Enable interrupts