我使用的是14580,sdk是5.0.4/projects/target_apps/ble_examples/ble_app_all_in_one.
现在我在使用定时函数app_easy_timer()时,遇到了一个问题。
我调用这个函数之后,只要加入app_easy_timer_cancel()函数,那么下面的函数只会循环一次。
请求帮助!!
大概代码如下:
uint16_t receyle_read_timer_hnd = EASY_TIMER_INVALID_TIMER;
void read_body_sensor_mag_reset(void)
{
arch_printf("nice");
open_flag = 0;
if(person_in == false)
{
if(GPIO_GetPinStatus(GPIO_BODY_PORT,GPIO_BODY_PIN))//人感检测到有人
{
arch_printf("有人\r\n");
init_judege(&magx_init,&magy_init,&magz_init);//地磁数据更新
person_in = true;
cycle_counter=0;
last_state = person_in;
time_flag = 0;
stop_flag = 0;
reset_flag = 0;
body_time = 0;
send_data[6] = 6;
toilet_indicate_data(send_data,20);
send_data[6] = 0;
if(receyle_read_timer_hnd != EASY_TIMER_INVALID_TIMER)
{
app_easy_timer_cancel(receyle_read_timer_hnd);
receyle_read_timer_hnd = 0;
}
}
else if(cycle_counter > 5)
{
open_flag = 4;
cycle_counter = 0;
time_flag = 0;
stop_flag = 0;
reset_flag = 0;
body_time = 0;
if(receyle_read_timer_hnd != EASY_TIMER_INVALID_TIMER)
{
app_easy_timer_cancel(receyle_read_timer_hnd);
receyle_read_timer_hnd = 0;
}
}
if(cycle_counter<6)
{
cycle_counter++;
receyle_read_timer_hnd = app_easy_timer(265,read_body_sensor_mag_reset);
}
}
} |