Skip to content

Commit 9e40582

Browse files
committed
Remove M453 and uvisor. Replace __disable_irq() with critical_section API
1. Remove M453. It is not to support in this commit. 2. Remove uvisor. It is incomplete and not to support in this commit. 3. Replace __disable_irq() with critical_section APIs.
1 parent 872d60f commit 9e40582

File tree

6 files changed

+17
-36
lines changed

6 files changed

+17
-36
lines changed

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/gpio_irq_api.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "cmsis.h"
2323
#include "pinmap.h"
2424
#include "PeripheralPins.h"
25-
//#include "uvisor-lib/uvisor-lib.h"
2625
#include "nu_bitutil.h"
2726

2827
#define NU_MAX_PIN_PER_PORT 16

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "nu_modutil.h"
2525
#include "nu_miscutil.h"
2626
#include "nu_bitutil.h"
27-
//#include "uvisor-lib/uvisor-lib.h"
27+
#include "critical.h"
2828

2929
#define NU_I2C_DEBUG 0
3030

@@ -309,42 +309,39 @@ static void i2c_enable_int(i2c_t *obj)
309309
I2C_T *i2c_base = (I2C_T *) NU_MODBASE(obj->i2c.i2c);
310310
const struct nu_modinit_s *modinit = get_modinit(obj->i2c.i2c, i2c_modinit_tab);
311311

312-
uint32_t _state = __get_PRIMASK();
313-
__disable_irq();
312+
core_util_critical_section_enter();
314313

315314
// Enable I2C interrupt
316315
NVIC_EnableIRQ(modinit->irq_n);
317316
obj->i2c.inten = 1;
318317

319-
__set_PRIMASK(_state);
318+
core_util_critical_section_exit();
320319
}
321320

322321
static void i2c_disable_int(i2c_t *obj)
323322
{
324323
I2C_T *i2c_base = (I2C_T *) NU_MODBASE(obj->i2c.i2c);
325324
const struct nu_modinit_s *modinit = get_modinit(obj->i2c.i2c, i2c_modinit_tab);
326325

327-
uint32_t _state = __get_PRIMASK();
328-
__disable_irq();
326+
core_util_critical_section_enter();
329327

330328
// Disable I2C interrupt
331329
NVIC_DisableIRQ(modinit->irq_n);
332330
obj->i2c.inten = 0;
333331

334-
__set_PRIMASK(_state);
332+
core_util_critical_section_exit();
335333
}
336334

337335
static int i2c_set_int(i2c_t *obj, int inten)
338336
{
339337
I2C_T *i2c_base = (I2C_T *) NU_MODBASE(obj->i2c.i2c);
340338
int inten_back;
341339

342-
uint32_t _state = __get_PRIMASK();
343-
__disable_irq();
340+
core_util_critical_section_enter();
344341

345342
inten_back = obj->i2c.inten;
346343

347-
__set_PRIMASK(_state);
344+
core_util_critical_section_exit();
348345

349346
if (inten) {
350347
i2c_enable_int(obj);

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "sleep_api.h"
2222
#include "nu_modutil.h"
2323
#include "nu_miscutil.h"
24-
//#include "uvisor-lib/uvisor-lib.h"
24+
#include "critical.h"
2525

2626
// lp_ticker tick = us = timestamp
2727
// clock of timer peripheral = ms
@@ -118,8 +118,7 @@ timestamp_t lp_ticker_read()
118118
// NOTE: As TIMER_CNT = TIMER_CMP and counter_major has increased by one, TIMER_CNT doesn't change to 0 for one tick time.
119119
// NOTE: As TIMER_CNT = TIMER_CMP or TIMER_CNT = 0, counter_major (ISR) may not sync with TIMER_CNT. So skip and fetch stable one at the cost of 1 clock delay on this read.
120120
do {
121-
uint32_t _state = __get_PRIMASK();
122-
__disable_irq();
121+
core_util_critical_section_enter();
123122

124123
// NOTE: Order of reading minor_us/carry here is significant.
125124
minor_ms = TIMER_GetCounter(timer2_base) * MS_PER_TMR2_CLK;
@@ -132,7 +131,7 @@ timestamp_t lp_ticker_read()
132131
major_minor_ms = (counter_major + carry) * MS_PER_TMR2_INT + minor_ms;
133132
}
134133

135-
__set_PRIMASK(_state);
134+
core_util_critical_section_exit();
136135
}
137136
while (minor_ms == 0 || minor_ms == MS_PER_TMR2_INT);
138137

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sleep.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "sleep_api.h"
1818
#include "serial_api.h"
1919
#include "lp_ticker_api.h"
20-
//#include "uvisor-lib/uvisor-lib.h"
2120

2221
#if DEVICE_SLEEP
2322

@@ -89,23 +88,13 @@ static void mbed_enter_sleep(struct sleep_s *obj)
8988

9089
if (obj->powerdown) { // Power-down mode (HIRC/HXT disabled, LIRC/LXT enabled)
9190
SYS_UnlockReg();
92-
#if YOTTA_CFG_UVISOR_PRESENT == 1
93-
uvisor_write32(&SCB->SCR, uvisor_read32(&(SCB->SCR)) | SCB_SCR_SLEEPDEEP_Msk);
94-
CLK->PWRCTL |= (CLK_PWRCTL_PDEN_Msk | CLK_PWRCTL_PDWKDLY_Msk);
95-
__WFI();
96-
#else
9791
CLK_PowerDown();
98-
#endif
9992
SYS_LockReg();
10093
}
10194
else { // CPU halt mode (HIRC/HXT enabled, LIRC/LXT enabled)
10295
// NOTE: NUC472's CLK_Idle() will also disable HIRC/HXT.
10396
SYS_UnlockReg();
104-
#if YOTTA_CFG_UVISOR_PRESENT == 1
105-
uvisor_write32(&SCB->SCR, uvisor_read32(&(SCB->SCR)) & ~SCB_SCR_SLEEPDEEP_Msk);
106-
#else
10797
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
108-
#endif
10998
CLK->PWRCTL &= ~CLK_PWRCTL_PDEN_Msk;
11099
__WFI();
111100
SYS_LockReg();

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/spi_api.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "nu_modutil.h"
2525
#include "nu_miscutil.h"
2626
#include "nu_bitutil.h"
27-
//#include "uvisor-lib/uvisor-lib.h"
2827

2928
#if DEVICE_SPI_ASYNCH
3029
#include "dma_api.h"

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/us_ticker.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "mbed_assert.h"
2020
#include "nu_modutil.h"
2121
#include "nu_miscutil.h"
22+
#include "critical.h"
2223

2324
#define US_PER_TICK 1
2425

@@ -119,8 +120,7 @@ uint32_t us_ticker_read()
119120
// NOTE: As TIMER_CNT = TIMER_CMP and counter_major has increased by one, TIMER_CNT doesn't change to 0 for one tick time.
120121
// NOTE: As TIMER_CNT = TIMER_CMP or TIMER_CNT = 0, counter_major (ISR) may not sync with TIMER_CNT. So skip and fetch stable one at the cost of 1 clock delay on this read.
121122
do {
122-
uint32_t _state = __get_PRIMASK();
123-
__disable_irq();
123+
core_util_critical_section_enter();
124124

125125
// NOTE: Order of reading minor_us/carry here is significant.
126126
minor_us = TIMER_GetCounter(timer0_base) * US_PER_TMR0HIRES_CLK;
@@ -133,7 +133,7 @@ uint32_t us_ticker_read()
133133
major_minor_us = (counter_major + carry) * US_PER_TMR0HIRES_INT + minor_us;
134134
}
135135

136-
__set_PRIMASK(_state);
136+
core_util_critical_section_exit();
137137
}
138138
while (minor_us == 0 || minor_us == US_PER_TMR0HIRES_INT);
139139

@@ -171,22 +171,20 @@ void us_ticker_prepare_sleep(struct sleep_s *obj)
171171
obj->powerdown = ! cd_hires_tmr_armed;
172172
}
173173

174-
uint32_t _state = __get_PRIMASK();
175-
__disable_irq();
174+
core_util_critical_section_enter();
176175

177176
if (obj->powerdown) {
178177
// NOTE: On entering power-down mode, HIRC/HXT will be disabled in normal mode, but not in ICE mode. This may cause confusion in development.
179178
// To not be inconsistent due to above, always disable clock source of normal counter, and then re-enable it and make compensation on wakeup from power-down.
180179
CLK_DisableModuleClock(timer0hires_modinit.clkidx);
181180
}
182181

183-
__set_PRIMASK(_state);
182+
core_util_critical_section_exit();
184183
}
185184

186185
void us_ticker_wakeup_from_sleep(struct sleep_s *obj)
187186
{
188-
uint32_t _state = __get_PRIMASK();
189-
__disable_irq();
187+
core_util_critical_section_enter();
190188

191189
if (obj->powerdown) {
192190
// Calculate power-down compensation
@@ -195,7 +193,7 @@ void us_ticker_wakeup_from_sleep(struct sleep_s *obj)
195193
CLK_EnableModuleClock(timer0hires_modinit.clkidx);
196194
}
197195

198-
__set_PRIMASK(_state);
196+
core_util_critical_section_exit();
199197
}
200198

201199
static void tmr0_vec(void)

0 commit comments

Comments
 (0)