From a6c6a87e0dd2b564070576ee9b415e2c28398b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A9=AC=5F666?= <13089258+pony-six-hundred-and-sixty-six@user.noreply.gitee.com> Date: Fri, 24 Jan 2025 10:24:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=86=E6=8E=89=E7=94=B5?= =?UTF-8?q?=E6=97=B6=E5=8F=8D=E5=BA=94=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/main.c | 11 ++--------- applications/user_sys.c | 4 +--- bsp/src/bsp_adc.c | 3 +-- bsp/src/bsp_nt26k.c | 41 ++++++++++++++++++++++------------------- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/applications/main.c b/applications/main.c index ede30e5..90b5481 100644 --- a/applications/main.c +++ b/applications/main.c @@ -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 diff --git a/applications/user_sys.c b/applications/user_sys.c index 493b697..4e2e951 100644 --- a/applications/user_sys.c +++ b/applications/user_sys.c @@ -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); diff --git a/bsp/src/bsp_adc.c b/bsp/src/bsp_adc.c index c82f62b..b109cfd 100644 --- a/bsp/src/bsp_adc.c +++ b/bsp/src/bsp_adc.c @@ -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 /** diff --git a/bsp/src/bsp_nt26k.c b/bsp/src/bsp_nt26k.c index e378e68..066b11e 100644 --- a/bsp/src/bsp_nt26k.c +++ b/bsp/src/bsp_nt26k.c @@ -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; } // 比较帧头和帧尾