diff --git a/hal/common/rtc_time.c b/hal/common/rtc_time.c index 98227974696..45499379158 100644 --- a/hal/common/rtc_time.c +++ b/hal/common/rtc_time.c @@ -16,6 +16,7 @@ #include "rtc_api.h" #include +#include "critical.h" #include "rtc_time.h" #include "us_ticker_api.h" @@ -74,12 +75,12 @@ clock_t clock() { } void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void)) { - __disable_irq(); + core_util_critical_section_enter(); _rtc_read = read_rtc; _rtc_write = write_rtc; _rtc_init = init_rtc; _rtc_isenabled = isenabled_rtc; - __enable_irq(); + core_util_critical_section_exit(); } diff --git a/hal/common/ticker_api.c b/hal/common/ticker_api.c index 52b48888f6c..e4bf86dcd0c 100644 --- a/hal/common/ticker_api.c +++ b/hal/common/ticker_api.c @@ -15,7 +15,7 @@ */ #include #include "ticker_api.h" -#include "cmsis.h" +#include "critical.h" void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler) { data->interface->init(); @@ -55,7 +55,7 @@ void ticker_irq_handler(const ticker_data_t *const data) { void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, timestamp_t timestamp, uint32_t id) { /* disable interrupts for the duration of the function */ - __disable_irq(); + core_util_critical_section_enter(); // initialise our data obj->timestamp = timestamp; @@ -84,11 +84,11 @@ void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, t /* if we're at the end p will be NULL, which is correct */ obj->next = p; - __enable_irq(); + core_util_critical_section_exit(); } void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj) { - __disable_irq(); + core_util_critical_section_enter(); // remove this object from the list if (data->queue->head == obj) { @@ -111,7 +111,7 @@ void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj) { } } - __enable_irq(); + core_util_critical_section_exit(); } timestamp_t ticker_read(const ticker_data_t *const data) @@ -124,12 +124,12 @@ int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *time int ret = 0; /* if head is NULL, there are no pending events */ - __disable_irq(); + core_util_critical_section_enter(); if (data->queue->head != NULL) { *timestamp = data->queue->head->timestamp; ret = 1; } - __enable_irq(); + core_util_critical_section_exit(); return ret; }