app_timer_appsh.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. #include "app_timer_appsh.h"
  13. #include "app_scheduler.h"
  14. static void app_timer_evt_get(void * p_event_data, uint16_t event_size)
  15. {
  16. app_timer_event_t * p_timer_event = (app_timer_event_t *)p_event_data;
  17. APP_ERROR_CHECK_BOOL(event_size == sizeof(app_timer_event_t));
  18. p_timer_event->timeout_handler(p_timer_event->p_context);
  19. }
  20. uint32_t app_timer_evt_schedule(app_timer_timeout_handler_t timeout_handler,
  21. void * p_context)
  22. {
  23. app_timer_event_t timer_event;
  24. timer_event.timeout_handler = timeout_handler;
  25. timer_event.p_context = p_context;
  26. return app_sched_event_put(&timer_event, sizeof(timer_event), app_timer_evt_get);
  27. }