You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.1 KiB

1 year ago
  1. #include "zapp_timer.h"
  2. static void app_timer_timeout_handler(void* p_context) { //
  3. zapp_timer_context* zcontext = (zapp_timer_context*)p_context;
  4. ZASSERT(zcontext != NULL);
  5. ZASSERT(zcontext->mark = 0xAABBCCDD);
  6. if (zcontext->timeout_handler) zcontext->timeout_handler(zcontext->usrcontext);
  7. }
  8. ret_code_t zapp_timer_create(zapp_timer_context* context, //
  9. app_timer_id_t* p_timer_id, app_timer_mode_t mode, app_timer_timeout_handler_t timeout_handler) {
  10. context->timeout_handler = timeout_handler;
  11. context->mark = 0xAABBCCDD;
  12. ret_code_t ret = app_timer_create(p_timer_id, mode, app_timer_timeout_handler);
  13. if (ret != NRF_SUCCESS) {
  14. return ret;
  15. }
  16. (*p_timer_id)->p_context = context;
  17. return ret;
  18. }
  19. ret_code_t zapp_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void* p_context) { //
  20. zapp_timer_context* zcontext = (zapp_timer_context*)timer_id->p_context;
  21. ZASSERT(zcontext != NULL);
  22. ZASSERT(zcontext->mark = 0xAABBCCDD);
  23. zcontext->usrcontext = p_context;
  24. return app_timer_start(timer_id, timeout_ticks, zcontext);
  25. }