Skip to content

Commit 38f9519

Browse files
author
Cruz Monrreal
authored
Merge pull request #6949 from OpenNuvoton/nuvoton_m23_bootloader
Support mbed_start_application for Cortex-M23
2 parents bacf6a9 + 23dcd82 commit 38f9519

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

platform/mbed_application.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,21 @@ static void powerdown_nvic()
4848
int i;
4949
int j;
5050

51+
#if defined(__CORTEX_M23)
52+
// M23 doesn't support ICTR and supports up to 240 external interrupts.
53+
isr_groups_32 = 8;
54+
#else
5155
isr_groups_32 = ((SCnSCB->ICTR & SCnSCB_ICTR_INTLINESNUM_Msk) >> SCnSCB_ICTR_INTLINESNUM_Pos) + 1;
56+
#endif
5257
for (i = 0; i < isr_groups_32; i++) {
5358
NVIC->ICER[i] = 0xFFFFFFFF;
5459
NVIC->ICPR[i] = 0xFFFFFFFF;
5560
for (j = 0; j < 8; j++) {
61+
#if defined(__CORTEX_M23)
62+
NVIC->IPR[i * 8 + j] = 0x00000000;
63+
#else
5664
NVIC->IP[i * 8 + j] = 0x00000000;
65+
#endif
5766
}
5867
}
5968
}
@@ -68,18 +77,27 @@ static void powerdown_scb(uint32_t vtor)
6877
SCB->AIRCR = 0x05FA | 0x0000;
6978
SCB->SCR = 0x00000000;
7079
// SCB->CCR - Implementation defined value
80+
#if defined(__CORTEX_M23)
81+
for (i = 0; i < 2; i++) {
82+
SCB->SHPR[i] = 0x00;
83+
}
84+
#else
7185
for (i = 0; i < 12; i++) {
7286
#if defined(__CORTEX_M7)
7387
SCB->SHPR[i] = 0x00;
7488
#else
7589
SCB->SHP[i] = 0x00;
7690
#endif
7791
}
92+
#endif
7893
SCB->SHCSR = 0x00000000;
94+
#if defined(__CORTEX_M23)
95+
#else
7996
SCB->CFSR = 0xFFFFFFFF;
8097
SCB->HFSR = SCB_HFSR_DEBUGEVT_Msk | SCB_HFSR_FORCED_Msk | SCB_HFSR_VECTTBL_Msk;
8198
SCB->DFSR = SCB_DFSR_EXTERNAL_Msk | SCB_DFSR_VCATCH_Msk |
8299
SCB_DFSR_DWTTRAP_Msk | SCB_DFSR_BKPT_Msk | SCB_DFSR_HALTED_Msk;
100+
#endif
83101
// SCB->MMFAR - Implementation defined value
84102
// SCB->BFAR - Implementation defined value
85103
// SCB->AFSR - Implementation defined value
@@ -107,7 +125,9 @@ __asm static void start_new_application(void *sp, void *pc)
107125
void start_new_application(void *sp, void *pc)
108126
{
109127
__asm volatile (
110-
"mov r2, #0 \n"
128+
"movw r2, #0 \n" // Fail to compile "mov r2, #0" with ARMC6. Replace with MOVW.
129+
// We needn't "movt r2, #0" immediately following because MOVW
130+
// will zero-extend the 16-bit immediate.
111131
"msr control, r2 \n" // Switch to main stack
112132
"mov sp, %0 \n"
113133
"msr primask, r2 \n" // Enable interrupts

platform/mbed_application.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
#include<stdint.h>
2121

22-
#if defined(__CORTEX_M3) || defined(__CORTEX_M4) || defined(__CORTEX_M7)
22+
#if defined(__CORTEX_M3) || defined(__CORTEX_M4) || defined(__CORTEX_M7)\
23+
|| defined(__CORTEX_M23)
2324
#define MBED_APPLICATION_SUPPORT 1
2425
#else
2526
#define MBED_APPLICATION_SUPPORT 0

0 commit comments

Comments
 (0)