[低功耗连接方案(BLE&WIFI)]

系统定时函数问题

[复制链接]
944|1
手机看帖
扫描二维码
随时随地手机跟帖
Li高岗|  楼主 | 2019-11-26 13:47 | 显示全部楼层 |阅读模式
我使用的是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);
                                }
                }
}

使用特权

评论回复

相关帖子

aoyi| | 2019-12-4 08:31 | 显示全部楼层
跳出来了吗

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝