解决了掉电时反应慢的问题

This commit is contained in:
小马_666 2025-01-24 10:24:53 +08:00
parent f16d4ca934
commit a6c6a87e0d
4 changed files with 26 additions and 33 deletions

View File

@ -2,7 +2,7 @@
* @Author: mbw
* @Date: 2024-10-23 17:14:16
* @LastEditors: mbw && 1600520629@qq.com
* @LastEditTime: 2025-01-23 08:46:44
* @LastEditTime: 2025-01-24 10:04:53
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\applications\main.c
* @Descrt_thread_
*
@ -191,11 +191,6 @@ int main(void)
rt_err_t result = RT_EINVAL;
rt_uint32_t received_event;
// 等待系统初始化完成
BSP_ADC_Init();
rt_thread_mdelay(500);
// 等一下再读电压
if (Get_VIN_VoltageInt1000x() > 10000)
{
SYS_EventInit();
@ -246,8 +241,7 @@ int main(void)
NVIC_SystemReset(); // 直接重启系统
}
#if 1
BSP_VIN_Detection_Init();
// IWDG_Feed();
while (1)
{
@ -487,7 +481,6 @@ int main(void)
else
{
rt_thread_mdelay(1000);
// IWDG_Feed();
}
}
#endif

View File

@ -255,7 +255,6 @@ int BSP_SYS_Init(void)
{
BSP_WDG_Init();
BSP_RTC_Init();
BSP_Rng_Init();
BSP_LED_Init();
@ -265,8 +264,7 @@ int BSP_SYS_Init(void)
BSP_BUTTON_Init();
BSP_HR_Init();
BSP_Nt26k_Thread_Init();
BSP_VIN_Detection_Init();
return 0;
}
// INIT_ENV_EXPORT(BSP_SYS_Init);

View File

@ -124,11 +124,10 @@ int BSP_ADC_Init(void)
LOG_D("adc_calibrattion = %d", adc_calibrattion);
LOG_I("BSP_ADC_Init");
return 0;
}
#ifdef RT_USING_COMPONENTS_INIT
// INIT_BOARD_EXPORT(BSP_ADC_Init);
INIT_PREV_EXPORT(BSP_ADC_Init);
#endif
/**

View File

@ -2,7 +2,7 @@
* @Author: mbw
* @Date: 2024-10-09 08:42:14
* @LastEditors: mbw && 1600520629@qq.com
* @LastEditTime: 2025-01-24 09:59:17
* @LastEditTime: 2025-01-24 10:23:59
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_nt26k.c
* @Description:
*
@ -776,6 +776,7 @@ const Nt26kEventInfo nt26k_event_info[] = {
*/
int Nt26k_Process_Events(Nt26kEvent nt26k_recv_event, struct at_device *device, void *param)
{
rt_err_t ret = RT_EOK;
rt_uint8_t max_retry_count = (rt_uint8_t)Flash_Get_SysCfg(kIotRetryId);
LOG_D("max_retry_count:%d\n", max_retry_count);
struct Nt26k_Ops *nt26k_ops = (struct Nt26k_Ops *)param;
@ -810,6 +811,7 @@ int Nt26k_Process_Events(Nt26kEvent nt26k_recv_event, struct at_device *device,
if (result != RT_EOK)
{
LOG_E("nt26k send failed\n");
ret = RT_ERROR;
continue;
}
else
@ -818,29 +820,16 @@ int Nt26k_Process_Events(Nt26kEvent nt26k_recv_event, struct at_device *device,
{
LOG_D("收到回复\n");
nt26k_connect_sever_flag = 1;
return RT_EOK; // 函数执行完毕返回0
ret = RT_EOK; // 函数执行完毕返回0
break;
}
else
{
// 收不到说明在平台未注册,此时nt26k_connect_sever_flag 为0但nt26k_conncet_tcp_flag = 1此时不发起重连等待事件触发就行
nt26k_connect_sever_flag = 0;
continue;
ret = RT_ERROR;
}
}
if (rt_strcmp(event->event_name, "掉电事件") == RT_EOK)
{
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)
{
LOG_D("关闭模组");
nt26k_power_down_flag = 1;
return RT_EOK;
}
}
}
}
else
@ -851,12 +840,26 @@ int Nt26k_Process_Events(Nt26kEvent nt26k_recv_event, struct at_device *device,
rt_sem_release(nt26k_disconnect_sem);
}
LOG_D("断网,等待连接中......\n");
ret = RT_ERROR;
}
rt_thread_mdelay(3000);
}
}
return RT_ERROR;
if (rt_strcmp(event->event_name, "掉电事件") == RT_EOK)
{
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)
{
LOG_D("关闭模组");
nt26k_power_down_flag = 1;
ret = RT_EOK;
}
}
return ret;
}
// 比较帧头和帧尾