15
15
*/
16
16
#include <stddef.h>
17
17
#include "ticker_api.h"
18
- #include "cmsis .h"
18
+ #include "critical .h"
19
19
20
20
void ticker_set_handler (const ticker_data_t * const data , ticker_event_handler handler ) {
21
21
data -> interface -> init ();
@@ -55,7 +55,7 @@ void ticker_irq_handler(const ticker_data_t *const data) {
55
55
56
56
void ticker_insert_event (const ticker_data_t * const data , ticker_event_t * obj , timestamp_t timestamp , uint32_t id ) {
57
57
/* disable interrupts for the duration of the function */
58
- __disable_irq ();
58
+ core_util_critical_section_enter ();
59
59
60
60
// initialise our data
61
61
obj -> timestamp = timestamp ;
@@ -84,11 +84,11 @@ void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, t
84
84
/* if we're at the end p will be NULL, which is correct */
85
85
obj -> next = p ;
86
86
87
- __enable_irq ();
87
+ core_util_critical_section_exit ();
88
88
}
89
89
90
90
void ticker_remove_event (const ticker_data_t * const data , ticker_event_t * obj ) {
91
- __disable_irq ();
91
+ core_util_critical_section_enter ();
92
92
93
93
// remove this object from the list
94
94
if (data -> queue -> head == obj ) {
@@ -111,7 +111,7 @@ void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj) {
111
111
}
112
112
}
113
113
114
- __enable_irq ();
114
+ core_util_critical_section_exit ();
115
115
}
116
116
117
117
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
124
124
int ret = 0 ;
125
125
126
126
/* if head is NULL, there are no pending events */
127
- __disable_irq ();
127
+ core_util_critical_section_enter ();
128
128
if (data -> queue -> head != NULL ) {
129
129
* timestamp = data -> queue -> head -> timestamp ;
130
130
ret = 1 ;
131
131
}
132
- __enable_irq ();
132
+ core_util_critical_section_exit ();
133
133
134
134
return ret ;
135
135
}
0 commit comments