47 #include PLATFORM_HEADER
48 #include "hal/error.h"
50 #include "dev/stm32w_systick.h"
52 #include "sys/clock.h"
54 #include "dev/button-sensor.h"
59 #define DEBUG DEBUG_NONE
63 #define RELOAD_VALUE 24000-1 // 1 ms with a 24 MHz clock
65 static volatile clock_time_t count;
66 static volatile unsigned long current_seconds = 0;
70 void SysTick_Handler(
void)
75 if(button_sensor.status(SENSORS_READY)){
76 button_sensor.value(0);
83 if (--second_countdown == 0) {
100 SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
101 SysTick_SetReload(RELOAD_VALUE);
102 SysTick_ITConfig(ENABLE);
103 SysTick_CounterCmd(SysTick_Counter_Enable);
123 for (j = 50; j > 0; j--)
138 while(
clock_time() - start < (clock_time_t)i);
142 unsigned long clock_seconds(
void)
144 return current_seconds;
147 void sleep_seconds(
int seconds)
149 int32u quarter_seconds = seconds * 4;
154 radio_on = stm32w_radio_is_on();
155 stm32w_radio_driver.
off();
165 current_seconds += seconds - quarter_seconds / 4 ;
172 SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
173 SysTick_SetReload(RELOAD_VALUE);
174 SysTick_ITConfig(ENABLE);
175 SysTick_CounterCmd(SysTick_Counter_Enable);
179 stm32w_radio_driver.init();
181 stm32w_radio_driver.
on();