加了掉电后上电的快速恢复逻辑,以及加了nt26定时器溢出防护机制
This commit is contained in:
parent
bf398932c6
commit
e7ec172555
|
@ -2,7 +2,7 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-10-23 17:14:16
|
* @Date: 2024-10-23 17:14:16
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-01-15 10:36:40
|
* @LastEditTime: 2025-01-18 11:21:57
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\applications\main.c
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\applications\main.c
|
||||||
* @Descrt_thread_
|
* @Descrt_thread_
|
||||||
*
|
*
|
||||||
|
@ -420,13 +420,27 @@ int main (void)
|
||||||
#if (IOT_MODULE_SWITCH == 1)
|
#if (IOT_MODULE_SWITCH == 1)
|
||||||
Nt26k_Send_Event (kNt26kPowerDownEvent);
|
Nt26k_Send_Event (kNt26kPowerDownEvent);
|
||||||
#endif
|
#endif
|
||||||
// 等待20s,要是还没断电就重启
|
rt_uint8_t cnt = 0;
|
||||||
for (uint8_t i = 0; i < 20; i++)
|
while ((device_power_down_flag == 0)&&(cnt < 60))//等待接收到掉电事件响应
|
||||||
{
|
{
|
||||||
rt_thread_mdelay (1000);
|
rt_thread_mdelay(500);
|
||||||
LOG_D (" %d s", i);
|
}
|
||||||
|
cnt = 0;
|
||||||
|
while ((nt26k_power_down_flag == 0)&&(cnt < 60))//等待接收到物联网模组关机完成
|
||||||
|
{
|
||||||
|
rt_thread_mdelay(500);
|
||||||
|
}
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if (Get_VIN_VoltageInt1000x() > 10000)
|
||||||
|
{
|
||||||
|
NVIC_SystemReset(); // 直接重启系统
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_thread_mdelay(500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NVIC_SystemReset(); // 直接重启系统
|
|
||||||
}
|
}
|
||||||
else if (received_event & Get_Sys_Event_Flag (kSelfCheckEvent)) // 自检
|
else if (received_event & Get_Sys_Event_Flag (kSelfCheckEvent)) // 自检
|
||||||
{
|
{
|
||||||
|
|
|
@ -208,5 +208,8 @@ extern rt_uint8_t nt26k_conncet_tcp_flag;
|
||||||
extern rt_uint8_t nt26k_connect_sever_flag;
|
extern rt_uint8_t nt26k_connect_sever_flag;
|
||||||
extern rt_uint8_t nt26k_disconnect_pdp_flag;
|
extern rt_uint8_t nt26k_disconnect_pdp_flag;
|
||||||
extern rt_uint8_t power_on_send_flag;
|
extern rt_uint8_t power_on_send_flag;
|
||||||
|
extern rt_uint8_t device_power_down_flag;
|
||||||
|
extern rt_uint8_t nt26k_power_down_flag;
|
||||||
|
|
||||||
int BSP_Nt26k_Thread_Init(void);
|
int BSP_Nt26k_Thread_Init(void);
|
||||||
void Nt26k_Send_Event(Nt26kEvent event_type);
|
void Nt26k_Send_Event(Nt26kEvent event_type);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-10-09 08:42:14
|
* @Date: 2024-10-09 08:42:14
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-01-17 15:04:55
|
* @LastEditTime: 2025-01-18 11:16:47
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_nt26k.c
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_nt26k.c
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
|
@ -67,6 +67,8 @@ static rt_timer_t nt26k_timer; // 上报心跳
|
||||||
static rt_timer_t nt26k_upload_timer; // 更新本地时间定时器
|
static rt_timer_t nt26k_upload_timer; // 更新本地时间定时器
|
||||||
static rt_timer_t nt26k_power_error_timer; // 上电失败情况下启动定时器
|
static rt_timer_t nt26k_power_error_timer; // 上电失败情况下启动定时器
|
||||||
|
|
||||||
|
rt_uint8_t device_power_down_flag;
|
||||||
|
rt_uint8_t nt26k_power_down_flag;
|
||||||
rt_uint8_t nt26k_connect_sever_flag;
|
rt_uint8_t nt26k_connect_sever_flag;
|
||||||
rt_uint8_t nt26k_conncet_tcp_flag;
|
rt_uint8_t nt26k_conncet_tcp_flag;
|
||||||
rt_uint8_t nt26k_disconnect_pdp_flag; // PDP断开连接标志
|
rt_uint8_t nt26k_disconnect_pdp_flag; // PDP断开连接标志
|
||||||
|
@ -830,10 +832,15 @@ int Nt26k_Process_Events(Nt26kEvent nt26k_recv_event, struct at_device *device,
|
||||||
}
|
}
|
||||||
else if (rt_strcmp(event->event_name, "掉电事件") == RT_EOK)
|
else if (rt_strcmp(event->event_name, "掉电事件") == RT_EOK)
|
||||||
{
|
{
|
||||||
rt_thread_mdelay(5000);
|
rt_uint8_t cnt = 0;
|
||||||
|
while ((device_power_down_flag == 0)&&(cnt < 10))
|
||||||
|
{
|
||||||
|
rt_thread_mdelay(500);
|
||||||
|
}
|
||||||
if (device->class->device_ops->control(device, AT_DEVICE_CTRL_POWER_OFF, RT_NULL) == RT_EOK)
|
if (device->class->device_ops->control(device, AT_DEVICE_CTRL_POWER_OFF, RT_NULL) == RT_EOK)
|
||||||
{
|
{
|
||||||
LOG_D("关闭模组");
|
LOG_D("关闭模组");
|
||||||
|
nt26k_power_down_flag = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -899,6 +906,10 @@ void Handle_Server_Reply(struct Nt26k_Ops *ops)
|
||||||
{
|
{
|
||||||
LOG_D("nt26k send data success\n");
|
LOG_D("nt26k send data success\n");
|
||||||
}
|
}
|
||||||
|
else if (ops->recv->recv_data.event_type == EVENT_TYPE_DEVICE_FAILURE)//是掉电事件回应
|
||||||
|
{
|
||||||
|
device_power_down_flag = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle_Self_Check(struct Nt26k_Ops *ops)
|
void Handle_Self_Check(struct Nt26k_Ops *ops)
|
||||||
|
|
Loading…
Reference in New Issue