| | |
| | | uint8_t group_id,enable_sleep_count; |
| | | uint32_t dev_id; |
| | | uint16_t disoffset; |
| | | uint16_t set_mk_time; |
| | | uint8_t flag_sleeptimer,flag_secondtask,secondtask_count; |
| | | float nomove_count; |
| | | // Default pool descriptor. |
| | |
| | | #else |
| | | |
| | | spi_init(); |
| | | // 模式判断脚和spi nrst脚初始化 |
| | | // // 模式判断脚和spi nrst脚初始化 |
| | | board_mode_pin_init(); |
| | | Program_Init(); |
| | | // board_led_on(BOARD_LED_1); |
| | | //board_led_on(BOARD_LED_1); |
| | | #endif |
| | | Board_LORA_NVIC_Init(Lora_irq_handler); |
| | | board_configure(); |
| | | // board_configure(); |
| | | } |
| | | |
| | | void app_process_handle(uint8_t msg_id, const void *param) |
| | |
| | | } |
| | | uint8_t bat_percent; |
| | | uint8_t stationary_flag; |
| | | extern uint8_t send_flag; |
| | | extern uint8_t txdone; |
| | | void mcu_deep_sleep(void) |
| | | { |
| | | uint32_t lock; |
| | | trace_flush(); |
| | | |
| | | lock = int_lock(); |
| | | LOG_INFO(TRACE_MODULE_APP, "进入休眠模式\r\n"); |
| | | sleep_timer_stop(); |
| | | power_enter_power_down_mode(1); |
| | | int_unlock(lock); |
| | |
| | | // Disable watchdog timer |
| | | wdt_close(WDT_ID0); |
| | | LOG_INFO(TRACE_MODULE_APP, "UCI FiRa example\r\n"); |
| | | delay_ms(300);//使log打印完毕 |
| | | |
| | | if(gpio_pin_get_val(SLEEP_PIN)) |
| | | { |
| | | if(gpio_pin_get_val(MODE_CHANGE_PIN))//记得改回来与正式的相反 |
| | |
| | | power_manage(); |
| | | if(!gpio_pin_get_val(SLEEP_PIN)) |
| | | { |
| | | gpio_pin_clr(LORA_NRST);//lora休眠 |
| | | LOG_INFO(TRACE_MODULE_APP, "进入休眠模式\r\n"); |
| | | mcu_deep_sleep(); |
| | | } |
| | | } |
| | | }else{ |
| | | }else{ |
| | | LOG_INFO(TRACE_MODULE_APP,"固件版本:MK_免布线模式 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); |
| | | uart0_Init_normal(); |
| | | Lora_1268_Init(); |
| | |
| | | sleep_timer_start(__MS_TO_32K_CNT(SLEEP_TIMER_NUM));//测试 |
| | | while (1) |
| | | { |
| | | if(send_flag) |
| | | { |
| | | LOG_INFO(TRACE_MODULE_APP,"发送数量%d. \r\n",txdone); |
| | | send_flag=0; |
| | | } |
| | | uwb_app_poll();//我们的测距逻辑 |
| | | if(flag_secondtask) |
| | | { |
| | |
| | | //Lora_Tx_Poll(); |
| | | } |
| | | Lora_Tx_Poll(); |
| | | if(!gpio_pin_get_val(SLEEP_PIN)) |
| | | { |
| | | mcu_deep_sleep(); |
| | | } |
| | | // if(!gpio_pin_get_val(SLEEP_PIN)) |
| | | // { |
| | | // //gpio_pin_clr(LORA_NRST);//lora休眠 |
| | | // LOG_INFO(TRACE_MODULE_APP, "进入休眠模式\r\n"); |
| | | // mcu_deep_sleep(); |
| | | // } |
| | | IdleTask(); |
| | | } |
| | | } |
| | | }else{ |
| | | |
| | | // while(1) |
| | | // { |
| | | // LOG_INFO(TRACE_MODULE_APP, "进入休眠模式\r\n"); |
| | | // } |
| | | //delay_ms(300); |
| | | LOG_INFO(TRACE_MODULE_APP, "进入休眠模式\r\n"); |
| | | //gpio_pin_clr(LORA_NRST);//lora休眠 |
| | | // spi_close(SPI_ID0); |
| | | lora_in_sleep(); |
| | | power_init(); |
| | | mcu_deep_sleep(); |
| | | mcu_deep_sleep(); |
| | | } |
| | | } |
| | | |