47 #include PLATFORM_HEADER
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) {
123 for (j = 50; j > 0; j--)
138 while(
clock_time() - start < (clock_time_t)i);
144 return current_seconds;
147 void sleep_seconds(
int seconds)
149 uint32_t quarter_seconds = seconds * 4;
154 radio_on = stm32w_radio_is_on();
155 stm32w_radio_driver.
off();
165 current_seconds += seconds - quarter_seconds / 4 ;
179 stm32w_radio_driver.init();
181 stm32w_radio_driver.
on();
void SysTick_SetReload(uint32_t Reload)
Sets SysTick Reload value.
void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
Configures the SysTick clock source.
void uart1_init(unsigned long ubr)
Initalize the RS232 port.
void rtimer_init(void)
Initialize the real-time scheduler.
void halPowerUp(void)
Powers up microcontroller peripherals and board peripherals.
STM32W radio driver header file
StStatus halSleepForQsWithOptions(uint32_t *duration, uint32_t gpioWakeBitMask)
Uses the system timer to enter ::SLEEPMODE_WAKETIMER for approximately the specified amount of time (...
void halPowerDown(void)
Powers down microcontroller peripherals and board peripherals.
void clock_init(void)
Initialize the clock library.
uint32_t halGetWakeInfo(void)
Obtains the events that caused the last wake from sleep.
CCIF clock_time_t clock_time(void)
Get the current clock time.
void SysTick_ITConfig(FunctionalState NewState)
Enables or disables the SysTick Interrupt.
void SysTick_CounterCmd(uint32_t SysTick_Counter)
Enables or disables the SysTick counter.
int(* on)(void)
Turn the radio on.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
CCIF unsigned long clock_seconds(void)
Get the current value of the platform seconds.
int etimer_pending(void)
Check if there are any non-expired event timers.
Generic set of HAL includes for all platforms.
Return codes for API functions and module definitions.
void clock_delay(unsigned int delay)
Obsolete delay function but we implement it here since some code still uses it.
A set of debugging macros.
#define ATOMIC(blah)
A block of code may be made atomic by wrapping it with this macro.
void clock_wait(clock_time_t t)
Wait for a given number of ticks.
int(* off)(void)
Turn the radio off.
#define CLOCK_SECOND
A second, measured in system clock time.