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
29 lines
1.1 KiB
#include "zapp_timer.h"
|
|
|
|
static void app_timer_timeout_handler(void* p_context) { //
|
|
zapp_timer_context* zcontext = (zapp_timer_context*)p_context;
|
|
ZASSERT(zcontext != NULL);
|
|
ZASSERT(zcontext->mark = 0xAABBCCDD);
|
|
|
|
if (zcontext->timeout_handler) zcontext->timeout_handler(zcontext->usrcontext);
|
|
}
|
|
|
|
ret_code_t zapp_timer_create(zapp_timer_context* context, //
|
|
app_timer_id_t* p_timer_id, app_timer_mode_t mode, app_timer_timeout_handler_t timeout_handler) {
|
|
context->timeout_handler = timeout_handler;
|
|
context->mark = 0xAABBCCDD;
|
|
ret_code_t ret = app_timer_create(p_timer_id, mode, app_timer_timeout_handler);
|
|
if (ret != NRF_SUCCESS) {
|
|
return ret;
|
|
}
|
|
(*p_timer_id)->p_context = context;
|
|
return ret;
|
|
}
|
|
|
|
ret_code_t zapp_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void* p_context) { //
|
|
zapp_timer_context* zcontext = (zapp_timer_context*)timer_id->p_context;
|
|
ZASSERT(zcontext != NULL);
|
|
ZASSERT(zcontext->mark = 0xAABBCCDD);
|
|
zcontext->usrcontext = p_context;
|
|
return app_timer_start(timer_id, timeout_ticks, zcontext);
|
|
}
|