如何创建一个新的定时器中断功能on in DSPS host example?

2 posts / 0 new
Last post
fn654
Offline
Last seen:1 year 10 months ago
加入:2016-06-14 13:27
如何创建一个新的定时器中断功能on in DSPS host example?

I have seen a function named app_easy_timer() described as follow .I call app_easy_timer() at user_on_init() function and return 1.but never go into the function I set .what wrong with it?
thanks.
/**
****************************************************************************************
* @brief Create a new timer. Activate the ble if required.
* @param[in] delay The amount of timer slots (10 ms) to wait.
* @param[in] fn The callback to be called when timer expires.
* @return The handler of the timer for future reference. If there are not timers available
* EASY_TIMER_INVALID_TIMER will be returned.
****************************************************************************************
*/
timer_hnd app_easy_timer(const uint16_t delay, void (*fn) (void))
{
timer_hnd timer_id=app_easy_timer_set_callback(fn);
if (timer_id==EASY_TIMER_INVALID_TIMER)
return (EASY_TIMER_INVALID_TIMER); //No timers available

if (app_check_BLE_active())
ke_timer_set(APP_EASY_TIMER_HND_TO_MSG_ID(timer_id), TASK_APP, delay);
else
{
arch_ble_force_wakeup(); //wake_up BLE
//send a message to wait for BLE to be woken up before executing the
struct create_new_timer_struct *req = KE_MSG_ALLOC(APP_CREATE_NEW_TIMER, TASK_APP, TASK_APP,
create_new_timer_struct);

req->delay=delay;
req->timer_id=timer_id;
ke_msg_send(req);
}
return (timer_id);
}

Device:
MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi fn654,

Hi fn654,

If you call the timer from the app_user_on_init() the timer will never trigger, since after that function is invoked, a GAPM_RESET command is invoked and the stack gets re-initialized, so any set timers are cancelled. Try to set the timer later in your code, for example when you start to advertise or upon database completetion for example.

Thanks MT_dialog