17
17
#include " fhss_api.h"
18
18
#include " fhss_config.h"
19
19
#include " mbed_trace.h"
20
+ #include " platform/SingletonPtr.h"
20
21
#include " platform/arm_hal_interrupt.h"
21
22
#include < Timer.h>
22
23
#include " equeue.h"
32
33
using namespace mbed ;
33
34
using namespace events ;
34
35
35
- static Timer timer;
36
+ static SingletonPtr< Timer> timer;
36
37
static bool timer_initialized = false ;
37
38
static const fhss_api_t *fhss_active_handle = NULL ;
38
39
#if !MBED_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT
@@ -44,14 +45,14 @@ struct fhss_timeout_s {
44
45
uint32_t start_time;
45
46
uint32_t stop_time;
46
47
bool active;
47
- Timeout timeout;
48
+ SingletonPtr< Timeout> timeout;
48
49
};
49
50
50
51
fhss_timeout_s fhss_timeout[NUMBER_OF_SIMULTANEOUS_TIMEOUTS];
51
52
52
53
static uint32_t read_current_time (void )
53
54
{
54
- return timer. read_us ();
55
+ return timer-> read_us ();
55
56
}
56
57
57
58
static fhss_timeout_s *find_timeout (void (*callback)(const fhss_api_t *api, uint16_t ))
@@ -103,7 +104,7 @@ static int platform_fhss_timer_start(uint32_t slots, void (*callback)(const fhss
103
104
equeue = mbed_highprio_event_queue ();
104
105
MBED_ASSERT (equeue != NULL );
105
106
#endif
106
- timer. start ();
107
+ timer-> start ();
107
108
timer_initialized = true ;
108
109
}
109
110
fhss_timeout_s *fhss_tim = find_timeout (callback);
@@ -119,7 +120,7 @@ static int platform_fhss_timer_start(uint32_t slots, void (*callback)(const fhss
119
120
fhss_tim->start_time = read_current_time ();
120
121
fhss_tim->stop_time = fhss_tim->start_time + slots;
121
122
fhss_tim->active = true ;
122
- fhss_tim->timeout . attach_us (timer_callback, slots);
123
+ fhss_tim->timeout -> attach_us (timer_callback, slots);
123
124
fhss_active_handle = callback_param;
124
125
ret_val = 0 ;
125
126
platform_exit_critical ();
@@ -135,7 +136,7 @@ static int platform_fhss_timer_stop(void (*callback)(const fhss_api_t *api, uint
135
136
platform_exit_critical ();
136
137
return -1 ;
137
138
}
138
- fhss_tim->timeout . detach ();
139
+ fhss_tim->timeout -> detach ();
139
140
fhss_tim->active = false ;
140
141
platform_exit_critical ();
141
142
return 0 ;
0 commit comments