btstack_tick.c 709 B

123456789101112131415161718192021222324252627282930313233
  1. #include "Includes.h"
  2. #define CORE_CLK 32000000ul /* Set Processor frequency */
  3. #define TICKS_PER_SEC 100ul /* Set the number of ticks in one second */
  4. #define TICK_PERIOD_IN_MS (1000ul/TICKS_PER_SEC)
  5. static void dummy_handler(void){};
  6. static void (*tick_handler)(void) = &dummy_handler;
  7. void hal_tick_init(void)
  8. {
  9. SysTick_Config(CORE_CLK/TICKS_PER_SEC);
  10. }
  11. int hal_tick_get_tick_period_in_ms(void){
  12. return TICK_PERIOD_IN_MS;
  13. }
  14. void hal_tick_set_handler(void (*handler)(void)){
  15. if (handler == 0){
  16. tick_handler = &dummy_handler;
  17. return;
  18. }
  19. tick_handler = handler;
  20. }
  21. void ble_tick_handler(void){
  22. (*tick_handler)();
  23. }