Skip to content

Commit a5f9629

Browse files
author
Deepika
committed
Use Cortex M23 specific header files and interrupts
1. Update use of correct header files 2. Added missing entry of M2351 device in IAR defines. 3. Removed support of ARM toolchain in targets.json
1 parent 71faea2 commit a5f9629

File tree

4 files changed

+9
-290
lines changed

4 files changed

+9
-290
lines changed

targets/TARGET_NUVOTON/TARGET_M2351/device/M2351.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,8 @@ typedef enum IRQn
188188
/*@}*/ /* end of group CMSIS */
189189

190190

191-
//#include "core_armv8mbl.h" /* Processor and core peripherals */
192-
#include "core_cm0plus.h" /* Regard M2351 as M0+ for early mbed test */
193-
#include "system_M2351.h" /* System Header */
194-
191+
#include "core_armv8mbl.h" /* Processor and core peripherals */
192+
#include "system_M2351.h" /* System Header */
195193

196194

197195
/**

targets/TARGET_NUVOTON/TARGET_M2351/device/cmsis_nvic.h

Lines changed: 1 addition & 282 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
#ifndef MBED_CMSIS_NVIC_H
1818
#define MBED_CMSIS_NVIC_H
1919

20-
#include "cmsis.h"
21-
22-
#define NVIC_USER_IRQ_OFFSET 16
23-
#define NVIC_USER_IRQ_NUMBER 102
24-
#define NVIC_NUM_VECTORS (NVIC_USER_IRQ_OFFSET + NVIC_USER_IRQ_NUMBER)
20+
#define NVIC_NUM_VECTORS (16 + 102)
2521

2622
#if defined(__CC_ARM)
2723
# define NVIC_RAM_VECTOR_ADDRESS ((uint32_t) &Image$$ER_IRAMVEC$$ZI$$Base)
@@ -32,281 +28,4 @@
3228
# define NVIC_RAM_VECTOR_ADDRESS ((uint32_t) &__start_vector_table__)
3329
#endif
3430

35-
36-
#ifdef __cplusplus
37-
extern "C" {
38-
#endif
39-
40-
/* Interrupt Priorities are WORD accessible only under ARMv6M */
41-
/* The following MACROS handle generation of the register offset and byte masks */
42-
#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
43-
#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
44-
#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
45-
46-
47-
/**
48-
\brief Enable Interrupt
49-
\details Enables a device specific interrupt in the NVIC interrupt controller.
50-
\param [in] IRQn Device specific interrupt number.
51-
\note IRQn must not be negative.
52-
*/
53-
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
54-
{
55-
if ((int32_t)(IRQn) >= 0)
56-
{
57-
NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
58-
}
59-
}
60-
61-
62-
/**
63-
\brief Get Interrupt Enable status
64-
\details Returns a device specific interrupt enable status from the NVIC interrupt controller.
65-
\param [in] IRQn Device specific interrupt number.
66-
\return 0 Interrupt is not enabled.
67-
\return 1 Interrupt is enabled.
68-
\note IRQn must not be negative.
69-
*/
70-
__STATIC_INLINE uint32_t NVIC_GetEnableIRQ(IRQn_Type IRQn)
71-
{
72-
if ((int32_t)(IRQn) >= 0)
73-
{
74-
return((uint32_t)(((NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
75-
}
76-
else
77-
{
78-
return(0U);
79-
}
80-
}
81-
82-
83-
/**
84-
\brief Disable Interrupt
85-
\details Disables a device specific interrupt in the NVIC interrupt controller.
86-
\param [in] IRQn Device specific interrupt number.
87-
\note IRQn must not be negative.
88-
*/
89-
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
90-
{
91-
if ((int32_t)(IRQn) >= 0)
92-
{
93-
NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
94-
__DSB();
95-
__ISB();
96-
}
97-
}
98-
99-
100-
/**
101-
\brief Get Pending Interrupt
102-
\details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt.
103-
\param [in] IRQn Device specific interrupt number.
104-
\return 0 Interrupt status is not pending.
105-
\return 1 Interrupt status is pending.
106-
\note IRQn must not be negative.
107-
*/
108-
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
109-
{
110-
if ((int32_t)(IRQn) >= 0)
111-
{
112-
return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
113-
}
114-
else
115-
{
116-
return(0U);
117-
}
118-
}
119-
120-
121-
/**
122-
\brief Set Pending Interrupt
123-
\details Sets the pending bit of a device specific interrupt in the NVIC pending register.
124-
\param [in] IRQn Device specific interrupt number.
125-
\note IRQn must not be negative.
126-
*/
127-
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
128-
{
129-
if ((int32_t)(IRQn) >= 0)
130-
{
131-
NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
132-
}
133-
}
134-
135-
136-
137-
/**
138-
\brief Clear Pending Interrupt
139-
\details Clears the pending bit of a device specific interrupt in the NVIC pending register.
140-
\param [in] IRQn Device specific interrupt number.
141-
\note IRQn must not be negative.
142-
*/
143-
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
144-
{
145-
if ((int32_t)(IRQn) >= 0)
146-
{
147-
NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
148-
}
149-
}
150-
151-
152-
/**
153-
\brief Get Active Interrupt
154-
\details Reads the active register in the NVIC and returns the active bit for the device specific interrupt.
155-
\param [in] IRQn Device specific interrupt number.
156-
\return 0 Interrupt status is not active.
157-
\return 1 Interrupt status is active.
158-
\note IRQn must not be negative.
159-
*/
160-
#ifdef ARM_V8M
161-
__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
162-
{
163-
if ((int32_t)(IRQn) >= 0)
164-
{
165-
return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
166-
}
167-
else
168-
{
169-
return(0U);
170-
}
171-
}
172-
#endif
173-
174-
/**
175-
\brief Set Interrupt Priority
176-
\details Sets the priority of a device specific interrupt or a processor exception.
177-
The interrupt number can be positive to specify a device specific interrupt,
178-
or negative to specify a processor exception.
179-
\param [in] IRQn Interrupt number.
180-
\param [in] priority Priority to set.
181-
\note The priority cannot be set for every processor exception.
182-
*/
183-
#ifdef ARM_V8M
184-
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
185-
{
186-
if ((int32_t)(IRQn) >= 0)
187-
{
188-
NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
189-
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
190-
}
191-
else
192-
{
193-
SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
194-
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
195-
}
196-
}
197-
#else
198-
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
199-
{
200-
if ((int32_t)(IRQn) >= 0)
201-
{
202-
NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
203-
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
204-
}
205-
else
206-
{
207-
SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
208-
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
209-
}
210-
}
211-
#endif
212-
213-
/**
214-
\brief Get Interrupt Priority
215-
\details Reads the priority of a device specific interrupt or a processor exception.
216-
The interrupt number can be positive to specify a device specific interrupt,
217-
or negative to specify a processor exception.
218-
\param [in] IRQn Interrupt number.
219-
\return Interrupt Priority.
220-
Value is aligned automatically to the implemented priority bits of the microcontroller.
221-
*/
222-
#ifdef ARM_V8M
223-
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
224-
{
225-
226-
if ((int32_t)(IRQn) >= 0)
227-
{
228-
return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
229-
}
230-
else
231-
{
232-
return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
233-
}
234-
}
235-
#else
236-
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
237-
{
238-
239-
if ((int32_t)(IRQn) >= 0)
240-
{
241-
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
242-
}
243-
else
244-
{
245-
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
246-
}
247-
}
248-
#endif
249-
/**
250-
\brief Set Interrupt Vector
251-
\details Sets an interrupt vector in SRAM based interrupt vector table.
252-
The interrupt number can be positive to specify a device specific interrupt,
253-
or negative to specify a processor exception.
254-
VTOR must been relocated to SRAM before.
255-
If VTOR is not present address 0 must be mapped to SRAM.
256-
\param [in] IRQn Interrupt number
257-
\param [in] vector Address of interrupt handler function
258-
*/
259-
__STATIC_INLINE void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
260-
{
261-
#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
262-
uint32_t *vectors = (uint32_t *)SCB->VTOR;
263-
#else
264-
uint32_t *vectors = (uint32_t *)0x0U;
265-
#endif
266-
vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector;
267-
}
268-
269-
270-
/**
271-
\brief Get Interrupt Vector
272-
\details Reads an interrupt vector from interrupt vector table.
273-
The interrupt number can be positive to specify a device specific interrupt,
274-
or negative to specify a processor exception.
275-
\param [in] IRQn Interrupt number.
276-
\return Address of interrupt handler function
277-
*/
278-
__STATIC_INLINE uint32_t NVIC_GetVector(IRQn_Type IRQn)
279-
{
280-
#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
281-
uint32_t *vectors = (uint32_t *)SCB->VTOR;
282-
#else
283-
uint32_t *vectors = (uint32_t *)0x0U;
284-
#endif
285-
return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET];
286-
}
287-
288-
289-
/**
290-
\brief System Reset
291-
\details Initiates a system reset request to reset the MCU.
292-
*/
293-
__STATIC_INLINE void NVIC_SystemReset(void)
294-
{
295-
__DSB(); /* Ensure all outstanding memory accesses included
296-
buffered write are completed before reset */
297-
SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
298-
SCB_AIRCR_SYSRESETREQ_Msk);
299-
__DSB(); /* Ensure completion of memory access */
300-
301-
for(;;) /* wait until reset */
302-
{
303-
__NOP();
304-
}
305-
}
306-
307-
#ifdef __cplusplus
308-
}
309-
#endif
310-
311-
31231
#endif

targets/targets.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3350,13 +3350,12 @@
33503350
"bootloader_supported": true
33513351
},
33523352
"NUMAKER_PFM_M2351": {
3353-
"core": "Cortex-M0+",
3354-
"default_toolchain": "ARM",
3353+
"core": "Cortex-M23",
3354+
"default_toolchain": "GCC_ARM",
33553355
"extra_labels": ["NUVOTON", "M2351", "M2351K1AAEES"],
33563356
"is_disk_virtual": true,
3357-
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"],
3357+
"supported_toolchains": ["GCC_ARM", "IAR"],
33583358
"inherits": ["Target"],
3359-
"macros": ["CMSIS_NVIC_VIRTUAL", "CMSIS_NVIC_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\"", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""],
33603359
"device_has": ["LOWPOWERTIMER", "RTC", "INTERRUPTIN","PORTIN", "PORTINOUT", "PORTOUT", "SERIAL","SERIAL_ASYNCH", "SERIAL_FC", "STDIO_MESSAGES", "SLEEP"],
33613360
"release_versions": ["5"],
33623361
"device_name": "M2351K1AAEES"

tools/export/iar/iar_definitions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,5 +228,8 @@
228228
"CExtraOptionsCheck": 1,
229229
"CExtraOptions": "--drv_vector_table_base=0x0",
230230
"CMSISDAPJtagSpeedList": 10
231+
},
232+
"M2351K1AAEES": {
233+
"OGChipSelectEditMenu": "M2351 series\tNuvoton M2351 series"
231234
}
232235
}

0 commit comments

Comments
 (0)