mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 01:40:14 +01:00
ports: Move definitions of ATOMIC_SECTION macros to mphalport.h.
Also move MICROPY_PY_PENDSV_ENTER/REENTER/EXIT to mphalport.h, for ports where these are not already there. This helps separate the hardware implementation of these macros from the MicroPython configuration (eg for renesas-ra and stm32, the IRQ static inline helper functions can now be moved to irq.h). Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -177,18 +177,6 @@
|
||||
#endif // !defined(MICROPY_HW_MCUFLASH) ....
|
||||
|
||||
// Miscellaneous settings
|
||||
__attribute__((always_inline)) static inline void enable_irq(uint32_t state) {
|
||||
__set_PRIMASK(state);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline uint32_t disable_irq(void) {
|
||||
uint32_t state = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
return state;
|
||||
}
|
||||
|
||||
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
|
||||
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
|
||||
|
||||
#define MICROPY_EVENT_POLL_HOOK \
|
||||
do { \
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
#include "hpl_time_measure.h"
|
||||
#include "sam.h"
|
||||
|
||||
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
|
||||
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
|
||||
|
||||
#define MICROPY_PY_PENDSV_ENTER uint32_t atomic_state = raise_irq_pri(IRQ_PRI_PENDSV)
|
||||
#define MICROPY_PY_PENDSV_EXIT restore_irq_pri(atomic_state)
|
||||
|
||||
@@ -46,6 +49,16 @@ uint64_t mp_hal_ticks_us_64(void);
|
||||
|
||||
void mp_hal_set_interrupt_char(int c);
|
||||
|
||||
__attribute__((always_inline)) static inline void enable_irq(uint32_t state) {
|
||||
__set_PRIMASK(state);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline uint32_t disable_irq(void) {
|
||||
uint32_t state = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
return state;
|
||||
}
|
||||
|
||||
#define mp_hal_delay_us_fast mp_hal_delay_us
|
||||
|
||||
static inline uint64_t mp_hal_ticks_ms_64(void) {
|
||||
|
||||
Reference in New Issue
Block a user