暂存一下
This commit is contained in:
parent
d74da25a2c
commit
0ef073439e
|
@ -5,7 +5,7 @@
|
||||||
"type": "mrs-debugger",
|
"type": "mrs-debugger",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "JT-DT-YD4N02A_RTT_MRS-4G",
|
"name": "JT-DT-YD4N02A_RTT_MRS-4G",
|
||||||
"cwd": "d:\\SXDT\\Project\\CH32\\JT-DT-YD4N02A_RTT_MRS-4G",
|
"cwd": "d:\\SXDT\\Project\\CH32\\JT-DT-YD4N02A_RTT_MRS-NT26K",
|
||||||
"openOCDCfg": {
|
"openOCDCfg": {
|
||||||
"useLocalOpenOCD": true,
|
"useLocalOpenOCD": true,
|
||||||
"executable": "c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/openocd.exe",
|
"executable": "c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/openocd.exe",
|
||||||
|
@ -39,8 +39,8 @@
|
||||||
"additionalCommands": []
|
"additionalCommands": []
|
||||||
},
|
},
|
||||||
"loadedFiles": {
|
"loadedFiles": {
|
||||||
"executableFile": "d:\\SXDT\\Project\\CH32\\JT-DT-YD4N02A_RTT_MRS-4G\\obj\\JT-DT-YD4N02A_RTT_MRS-4G.elf",
|
"executableFile": "d:\\SXDT\\Project\\CH32\\JT-DT-YD4N02A_RTT_MRS-NT26K\\obj\\JT-DT-YD4N02A_RTT_MRS-4G.elf",
|
||||||
"symbolFile": "d:\\SXDT\\Project\\CH32\\JT-DT-YD4N02A_RTT_MRS-4G\\obj\\JT-DT-YD4N02A_RTT_MRS-4G.elf",
|
"symbolFile": "d:\\SXDT\\Project\\CH32\\JT-DT-YD4N02A_RTT_MRS-NT26K\\obj\\JT-DT-YD4N02A_RTT_MRS-4G.elf",
|
||||||
"executableFileOffset": 0,
|
"executableFileOffset": 0,
|
||||||
"symbolFileOffset": 0
|
"symbolFileOffset": 0
|
||||||
},
|
},
|
||||||
|
|
|
@ -773,7 +773,7 @@
|
||||||
"address": "0x08000000",
|
"address": "0x08000000",
|
||||||
"target_path": "obj\\JT-DT-YD4N02A_RTT_MRS-4G.hex",
|
"target_path": "obj\\JT-DT-YD4N02A_RTT_MRS-4G.hex",
|
||||||
"clkSpeed": "High",
|
"clkSpeed": "High",
|
||||||
"debug_interface_mode": "1-wire serial",
|
"debug_interface_mode": "",
|
||||||
"erase": true,
|
"erase": true,
|
||||||
"program": true,
|
"program": true,
|
||||||
"verify": true,
|
"verify": true,
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* @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-08 10:21:25
|
* @LastEditTime: 2025-01-09 14:50:14
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-4G\applications\main.c
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\applications\main.c
|
||||||
* @Descrt_thread_
|
* @Descrt_thread_
|
||||||
*
|
*
|
||||||
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
||||||
|
@ -184,7 +184,6 @@ void Work_Cnt_Timer_Callback(void *parameter)
|
||||||
}
|
}
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
#define WORK_TIMER_CNT (1000 * 60 * 60 * 24)
|
#define WORK_TIMER_CNT (1000 * 60 * 60 * 24)
|
||||||
|
|
||||||
rt_err_t result = RT_EINVAL;
|
rt_err_t result = RT_EINVAL;
|
||||||
|
@ -201,6 +200,7 @@ int main(void)
|
||||||
Flash_GetTotalRecord(&TotalRecords);
|
Flash_GetTotalRecord(&TotalRecords);
|
||||||
|
|
||||||
work_duration = Flash_Get_WorkDuration();
|
work_duration = Flash_Get_WorkDuration();
|
||||||
|
LOG_D("工作天数:%d", work_duration);
|
||||||
rt_timer_init(&work_cnt_timer,
|
rt_timer_init(&work_cnt_timer,
|
||||||
"work_cnt_timer",
|
"work_cnt_timer",
|
||||||
Work_Cnt_Timer_Callback,
|
Work_Cnt_Timer_Callback,
|
||||||
|
@ -225,7 +225,6 @@ int main(void)
|
||||||
LOG_D("欠压复位\r\n");
|
LOG_D("欠压复位\r\n");
|
||||||
RCC_ClearFlag();
|
RCC_ClearFlag();
|
||||||
NVIC_SystemReset(); // 直接重启系统
|
NVIC_SystemReset(); // 直接重启系统
|
||||||
|
|
||||||
}
|
}
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -291,10 +290,6 @@ int main(void)
|
||||||
rt_thread_mdelay(500);
|
rt_thread_mdelay(500);
|
||||||
Send_Laser_Alarm_Event(kAlarmEvent);
|
Send_Laser_Alarm_Event(kAlarmEvent);
|
||||||
}
|
}
|
||||||
if (H308.end_of_life == 1)
|
|
||||||
{
|
|
||||||
Send_Laser_Alarm_Event(kSensorFailureEvent);
|
|
||||||
}
|
|
||||||
else if (H308.detection_flag == kH308Fault)
|
else if (H308.detection_flag == kH308Fault)
|
||||||
{
|
{
|
||||||
LED_G_NORMAL;
|
LED_G_NORMAL;
|
||||||
|
@ -344,7 +339,6 @@ int main(void)
|
||||||
|
|
||||||
relay_state_flag = 0;
|
relay_state_flag = 0;
|
||||||
BEEP_STOP;
|
BEEP_STOP;
|
||||||
|
|
||||||
#if (IOT_MODULE_SWITCH == 1)
|
#if (IOT_MODULE_SWITCH == 1)
|
||||||
Nt26k_Send_Event(kNt26kAlarmRcyEvent);
|
Nt26k_Send_Event(kNt26kAlarmRcyEvent);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#define SYS_HW_VERSION 0X10
|
#define SYS_HW_VERSION 0X10
|
||||||
#define SYS_SW_VERSION 0X13
|
#define SYS_SW_VERSION 0X13
|
||||||
#define SYS_IOT_UPLOAD_CYCLE_MIN (0X0A00) // 高位在前,低位在后
|
#define SYS_IOT_UPLOAD_CYCLE_MIN (0X3C00) // 高位在前,低位在后
|
||||||
#define SYS_ALARM_VALVE 0X0A
|
#define SYS_ALARM_VALVE 0X0A
|
||||||
#define SYS_IOT_URL "8.130.117.149"
|
#define SYS_IOT_URL "8.130.117.149"
|
||||||
#define SYS_IOT_PORT "7137"
|
#define SYS_IOT_PORT "7137"
|
||||||
|
|
|
@ -204,6 +204,7 @@ extern struct Nt26k_Ops nt26k_ops;
|
||||||
extern rt_sem_t nt26k_recv_sem;
|
extern rt_sem_t nt26k_recv_sem;
|
||||||
extern rt_sem_t nt26k_disconnect_sem;
|
extern rt_sem_t nt26k_disconnect_sem;
|
||||||
extern rt_uint8_t nt26k_conncet_tcp_flag;
|
extern rt_uint8_t nt26k_conncet_tcp_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;
|
||||||
int nt26k_device_register(void);
|
int nt26k_device_register(void);
|
||||||
int BSP_Nt26k_Thread_Init(void);
|
int BSP_Nt26k_Thread_Init(void);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -277,19 +277,14 @@ int Flash_Set_WorkDuration(rt_uint16_t value)
|
||||||
|
|
||||||
Flash_ErasePage_ReadConfigInfo(page_buf);
|
Flash_ErasePage_ReadConfigInfo(page_buf);
|
||||||
|
|
||||||
*(rt_uint16_t *)(page_buf + in_page_offset) = value;
|
rt_memcpy(page_buf + in_page_offset, &value, FLASH_WORK_TIME_LEN);
|
||||||
return Flash_Write_ConfigInfo(page_buf);
|
return Flash_Write_ConfigInfo(page_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Flash_Get_Sever_Data(struct flash_sever_info *sever_info)
|
int Flash_Get_Sever_Data(struct flash_sever_info *sever_info)
|
||||||
{
|
{
|
||||||
rt_uint8_t data[FLASH_SERVER_LEN];
|
rt_uint8_t data[FLASH_SERVER_LEN] = {0};
|
||||||
rt_memcpy(data, (rt_uint8_t *)FLASH_SERVER_ADDR_ADDR, FLASH_SERVER_LEN);
|
rt_memcpy(data, (rt_uint8_t *)FLASH_SERVER_ADDR_ADDR, FLASH_SERVER_LEN);
|
||||||
if (data == RT_NULL)
|
|
||||||
{
|
|
||||||
LOG_E("Flash_Get_Sever_Data failed");
|
|
||||||
return -RT_ERROR;
|
|
||||||
}
|
|
||||||
LOG_D("data[%d] = %x data[%d] = %x data[%d] = %x data[%d] = %x data[%d] = %x data[%d] = %x", 0, data[0], 1, data[1], 2, data[2], 3, data[3], 4, data[4], 5, data[5]);
|
LOG_D("data[%d] = %x data[%d] = %x data[%d] = %x data[%d] = %x data[%d] = %x data[%d] = %x", 0, data[0], 1, data[1], 2, data[2], 3, data[3], 4, data[4], 5, data[5]);
|
||||||
rt_snprintf(sever_info->server_url, sizeof(sever_info->server_url), "%d.%d.%d.%d",
|
rt_snprintf(sever_info->server_url, sizeof(sever_info->server_url), "%d.%d.%d.%d",
|
||||||
data[3], data[2], data[1], data[0]);
|
data[3], data[2], data[1], data[0]);
|
||||||
|
@ -584,8 +579,9 @@ void Flash_ErasePage_ConfigInfo(void)
|
||||||
void Flash_ErasePage_ReadConfigInfo(rt_uint8_t *page_buf)
|
void Flash_ErasePage_ReadConfigInfo(rt_uint8_t *page_buf)
|
||||||
{
|
{
|
||||||
Flash_Read(FLASH_CONFIG_INFO_START_ADDR, page_buf, FLASH_PAGE_SIZE);
|
Flash_Read(FLASH_CONFIG_INFO_START_ADDR, page_buf, FLASH_PAGE_SIZE);
|
||||||
|
rt_thread_mdelay(10);
|
||||||
Flash_ErasePage_ConfigInfo();
|
Flash_ErasePage_ConfigInfo();
|
||||||
|
rt_thread_mdelay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Flash_Write_ConfigInfo(rt_uint8_t *page_buf)
|
int Flash_Write_ConfigInfo(rt_uint8_t *page_buf)
|
||||||
|
@ -839,7 +835,7 @@ int BSP_Flash_Init(void)
|
||||||
sci.emagnetic_switch = sys_emagnetic_switch;
|
sci.emagnetic_switch = sys_emagnetic_switch;
|
||||||
sci.relay_switch = sys_relay_switch;
|
sci.relay_switch = sys_relay_switch;
|
||||||
|
|
||||||
Flash_Set_WorkDuration(work_duration);
|
Flash_Set_WorkDuration(0);
|
||||||
LOG_D("work_duration:%d", Flash_Get_WorkDuration());
|
LOG_D("work_duration:%d", Flash_Get_WorkDuration());
|
||||||
|
|
||||||
Convert_To_Hex(&sever_info, sever_data);
|
Convert_To_Hex(&sever_info, sever_data);
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-11-14 10:21:04
|
* @Date: 2024-11-14 10:21:04
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-01-08 11:27:49
|
* @LastEditTime: 2025-01-09 15:25:27
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-4G\bsp\src\bsp_h308.c
|
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_h308.c
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
||||||
|
@ -260,11 +260,11 @@ static void h308_thread_entry(void *param)
|
||||||
|
|
||||||
if (Flash_GetNum_Records(kRecordSensoEndOfLife) == 1)
|
if (Flash_GetNum_Records(kRecordSensoEndOfLife) == 1)
|
||||||
{
|
{
|
||||||
H308.end_of_life = 1;
|
|
||||||
|
|
||||||
LOG_W("寿命已到期");
|
LOG_W("寿命已到期");
|
||||||
TotalRecords.sensor_failure++;
|
H308.end_of_life = 1;
|
||||||
}
|
}
|
||||||
|
//这里应该等下iot模组更新网络,不然可能不准确,但如果从未更新时,截至日期小于1天才会有影响,所以可不等待
|
||||||
|
rt_thread_mdelay(5000);//这里等的原因是,等待4G更新网络,其二是传感器需要10s的启动时间
|
||||||
// 寿命到期检测
|
// 寿命到期检测
|
||||||
if (IS_H308_EndOfLife())
|
if (IS_H308_EndOfLife())
|
||||||
{
|
{
|
||||||
|
@ -272,6 +272,7 @@ static void h308_thread_entry(void *param)
|
||||||
{
|
{
|
||||||
Flash_Write_Record(kRecordSensoEndOfLife);
|
Flash_Write_Record(kRecordSensoEndOfLife);
|
||||||
}
|
}
|
||||||
|
Send_Laser_Alarm_Event(kSensorFailureEvent);
|
||||||
}
|
}
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -285,7 +286,7 @@ static void h308_thread_entry(void *param)
|
||||||
if (len >= 44)
|
if (len >= 44)
|
||||||
{
|
{
|
||||||
ret = H308_GetFrameData(str, len, &H308.Data);
|
ret = H308_GetFrameData(str, len, &H308.Data);
|
||||||
// LOG_I("str:[%s]", str);
|
LOG_I("str:[%s]", str);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
H308_CheckData();
|
H308_CheckData();
|
||||||
|
@ -301,7 +302,6 @@ static void h308_thread_entry(void *param)
|
||||||
LOG_E("(len = %d) < 44, error data:[%s]", len, str);
|
LOG_E("(len = %d) < 44, error data:[%s]", len, str);
|
||||||
if (h308_err_cnt >= 5)
|
if (h308_err_cnt >= 5)
|
||||||
{
|
{
|
||||||
// LOG_E("h308_err_cnt:%d", h308_err_cnt);
|
|
||||||
H308_RST_ON;
|
H308_RST_ON;
|
||||||
rt_thread_mdelay(100);
|
rt_thread_mdelay(100);
|
||||||
H308_RST_OFF;
|
H308_RST_OFF;
|
||||||
|
@ -309,7 +309,7 @@ static void h308_thread_entry(void *param)
|
||||||
h308_err_cnt = 0;
|
h308_err_cnt = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(str, 0, len);
|
rt_memset(str, 0, len);
|
||||||
|
|
||||||
if (h308_rx_timout_cnt)
|
if (h308_rx_timout_cnt)
|
||||||
{
|
{
|
||||||
|
@ -386,7 +386,7 @@ int BSP_H308_Init(void)
|
||||||
rt_pin_mode(H308_RST_PIN, PIN_MODE_OUTPUT);
|
rt_pin_mode(H308_RST_PIN, PIN_MODE_OUTPUT);
|
||||||
H308_PWR_OFF;
|
H308_PWR_OFF;
|
||||||
H308_RST_OFF;
|
H308_RST_OFF;
|
||||||
// h308_mutex = rt_mutex_create("h308_mutex", RT_IPC_FLAG_PRIO);
|
|
||||||
uart4_rx_ok_sem = rt_sem_create("uart4_rx", 0, RT_IPC_FLAG_FIFO);
|
uart4_rx_ok_sem = rt_sem_create("uart4_rx", 0, RT_IPC_FLAG_FIFO);
|
||||||
if (uart4_rx_ok_sem == RT_NULL)
|
if (uart4_rx_ok_sem == RT_NULL)
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -287,8 +287,8 @@ static uint8_t RTC_FirstInit(void)
|
||||||
RTC_SetPrescaler(32767);
|
RTC_SetPrescaler(32767);
|
||||||
RTC_WaitForLastTask();
|
RTC_WaitForLastTask();
|
||||||
|
|
||||||
// RTC_SetTime(2024, 9, 5, 0, 0, 0); //设置出厂日期
|
RTC_SetTime(2025, 1, 8, 12, 0, 0); //设置出厂日期
|
||||||
// RTC_WaitForLastTask();
|
RTC_WaitForLastTask();
|
||||||
//
|
//
|
||||||
// RTC_SetAlarm(20 + RTC_GetCounter()); //闹钟值设定为当前时间的10秒后
|
// RTC_SetAlarm(20 + RTC_GetCounter()); //闹钟值设定为当前时间的10秒后
|
||||||
// RTC_WaitForLastTask();
|
// RTC_WaitForLastTask();
|
||||||
|
@ -324,7 +324,6 @@ int BSP_RTC_Init(void)
|
||||||
/* Is it the first configuration */
|
/* Is it the first configuration */
|
||||||
if (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET || BKP_ReadBackupRegister(BKP_DR1) != RTC_FIRST_INIT_VALUE)
|
if (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET || BKP_ReadBackupRegister(BKP_DR1) != RTC_FIRST_INIT_VALUE)
|
||||||
{
|
{
|
||||||
LOG_W("RTC hasn't been configured, please use [RTC_Cfg_Time] to config.");
|
|
||||||
RTC_FirstInit();
|
RTC_FirstInit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue