添加了标定部分程序
This commit is contained in:
parent
b2c5011701
commit
ee85ee6813
|
@ -197,5 +197,5 @@
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||||
|
<storageModule moduleId="refreshScope"/>
|
||||||
</cproject>
|
</cproject>
|
||||||
|
|
|
@ -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: 2024-12-01 13:04:55
|
* @LastEditTime: 2024-12-01 14:44:58
|
||||||
* @FilePath: \ble_bjq_ch303rct6_ml307\applications\main.c
|
* @FilePath: \ble_bjq_ch303rct6_ml307\applications\main.c
|
||||||
* @Descrt_thread_
|
* @Descrt_thread_
|
||||||
*
|
*
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
#include "bsp_flash.h"
|
#include "bsp_flash.h"
|
||||||
#include "bsp_hr.h"
|
#include "bsp_hr.h"
|
||||||
#include "bsp_mq.h"
|
#include "bsp_mq.h"
|
||||||
#include "bsp_button.h"
|
#include "bsp_button.h"
|
||||||
#include "bsp_mb26.h"
|
#include "bsp_mb26.h"
|
||||||
#include "bsp_vin_detection.h"
|
#include "bsp_vin_detection.h"
|
||||||
#include "user_sys.h"
|
#include "user_sys.h"
|
||||||
|
@ -41,6 +41,7 @@ TsSysControl SysControl;
|
||||||
struct rt_timer work_cnt_timer;
|
struct rt_timer work_cnt_timer;
|
||||||
void Send_Laser_Alarm_Event(AlarmEvent event_type);
|
void Send_Laser_Alarm_Event(AlarmEvent event_type);
|
||||||
|
|
||||||
|
TeCalibrationStatus g_Calibration_status = kNotCalibrated;
|
||||||
static void Set_Event(AlarmEvent event_type)
|
static void Set_Event(AlarmEvent event_type)
|
||||||
{
|
{
|
||||||
if (event_type < kMaxEventcnt)
|
if (event_type < kMaxEventcnt)
|
||||||
|
@ -139,261 +140,299 @@ void Work_Cnt_Timer_Callback(void *parameter)
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// 定义超时时间,单位为毫秒
|
// 定义超时时间,单位为毫秒
|
||||||
#define TIMEOUT_MS 10000
|
#define TIMEOUT_MS 3 * 60 * 1000
|
||||||
#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;
|
||||||
rt_uint32_t received_event;
|
rt_uint32_t received_event;
|
||||||
|
|
||||||
rt_kprintf("JT-DT-YD4N02A Software version: %02X", (uint8_t)Flash_Get_SysCfg(kSwVerId));
|
rt_kprintf("JT-DT-YD4N02A Software version: %02X\r\n", (uint8_t)Flash_Get_SysCfg(kSwVerId));
|
||||||
// 读取历史记录总数
|
// 读取历史记录总数
|
||||||
Flash_GetTotalRecord(&TotalRecords);
|
Flash_GetTotalRecord(&TotalRecords);
|
||||||
|
g_Calibration_status = Flash_Get_Calibration_State();
|
||||||
SYS_EventInit();
|
if (g_Calibration_status == kNotCalibrated)//没标定
|
||||||
work_duration = Flash_Get_WorkDuration();
|
|
||||||
rt_timer_init(&work_cnt_timer,
|
|
||||||
"work_cnt_timer",
|
|
||||||
Work_Cnt_Timer_Callback,
|
|
||||||
RT_NULL,
|
|
||||||
WORK_TIMER_CNT,
|
|
||||||
RT_TIMER_FLAG_PERIODIC);
|
|
||||||
rt_timer_start(&work_cnt_timer);
|
|
||||||
if (Get_VIN_VoltageInt1000x() > 10000)
|
|
||||||
{
|
{
|
||||||
// 检测上电/掉电复位标志
|
LED_STOP(r);
|
||||||
if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) // TODO:这块超级电容会造成掉电重启,并且标志是上电复位,只能通过其超级电容造成复位时事件创建失败进行判断,不治本
|
LED_STOP(y);
|
||||||
|
LED_CTRL(g, "1000,500", -1);
|
||||||
|
LED_START(g);
|
||||||
|
|
||||||
|
uint16_t ticks = 0, gas_calibration_voltage;
|
||||||
|
while (1)
|
||||||
{
|
{
|
||||||
Send_Laser_Alarm_Event(kPowerOnEvent);
|
gas_calibration_voltage = Get_Gas_VoltageInt1000x();
|
||||||
TotalRecords.power_on++;
|
LOG_D("ticks[%d] gas_calibration_voltage = %d", ticks++, gas_calibration_voltage);
|
||||||
RCC_ClearFlag();
|
|
||||||
}
|
if (g_Calibration_status == kNotCalibrated)//没标定
|
||||||
else
|
{
|
||||||
{
|
if (ticks > TIMEOUT_MS)
|
||||||
Send_Laser_Alarm_Event(kPreheatingEvent); // 这一句的作用是设备不是掉电重启的情况,直接进入预热模式
|
{
|
||||||
|
if(gas_calibration_voltage > (MQ_VOLTAGE_ALARM_DEFAULT - 500)
|
||||||
|
&& gas_calibration_voltage < (MQ_VOLTAGE_ALARM_DEFAULT + 500))
|
||||||
|
{
|
||||||
|
uint8_t calibration_buf[2] = {0};
|
||||||
|
calibration_buf[0] = gas_calibration_voltage << 8;// 低字节
|
||||||
|
calibration_buf[1] = gas_calibration_voltage >> 8;//高字节
|
||||||
|
LOG_D("calibration_buf[0] = %X calibration_buf[1] = %X", calibration_buf[0], calibration_buf[1]);
|
||||||
|
Flash_Sys_Cfg(kAlarmLValueId, calibration_buf, 2);
|
||||||
|
// 标定完成打开绿灯常亮,蜂鸣器叫一下
|
||||||
|
BEEP_CALIBRATION_OK;
|
||||||
|
LED_STOP(g);
|
||||||
|
LED_ON(g);
|
||||||
|
Flash_Set_Calibration_State(kSysGasCalibStatus);
|
||||||
|
g_Calibration_status = kSysGasCalibStatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_D("欠压复位\r\n");
|
SYS_EventInit();
|
||||||
}
|
work_duration = Flash_Get_WorkDuration();
|
||||||
|
rt_timer_init(&work_cnt_timer,
|
||||||
while (1)
|
"work_cnt_timer",
|
||||||
{
|
Work_Cnt_Timer_Callback,
|
||||||
result = rt_event_recv(&alarm_event,
|
RT_NULL,
|
||||||
Get_Sys_Event_Flag(kPowerOnEvent) | // 上电
|
WORK_TIMER_CNT,
|
||||||
Get_Sys_Event_Flag(kPowerDownEvent) | // 掉电
|
RT_TIMER_FLAG_PERIODIC);
|
||||||
Get_Sys_Event_Flag(kPreheatingEvent) | // 预热
|
rt_timer_start(&work_cnt_timer);
|
||||||
Get_Sys_Event_Flag(kNormalDetectionEvents) | // 正常检测
|
if (Get_VIN_VoltageInt1000x() > 10000)
|
||||||
Get_Sys_Event_Flag(kAlarmExceptionEvent) | // 寿命到期
|
|
||||||
Get_Sys_Event_Flag(kAlarmEvent) | // 报警
|
|
||||||
Get_Sys_Event_Flag(kAlarmRcyEvent) | // 报警恢复
|
|
||||||
Get_Sys_Event_Flag(kSelfCheckEvent) | // 自检
|
|
||||||
Get_Sys_Event_Flag(kFaultEvent) | // 故障模式
|
|
||||||
Get_Sys_Event_Flag(kFaultRcyEvent) | // 故障恢复
|
|
||||||
Get_Sys_Event_Flag(KMuteEvent), // 消音
|
|
||||||
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
|
|
||||||
RT_WAITING_FOREVER, &received_event);
|
|
||||||
if (result == RT_EOK)
|
|
||||||
{
|
{
|
||||||
if (is_event_initialized == RT_TRUE)
|
// 检测上电/掉电复位标志
|
||||||
|
if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) // TODO:这块超级电容会造成掉电重启,并且标志是上电复位,只能通过其超级电容造成复位时事件创建失败进行判断,不治本
|
||||||
{
|
{
|
||||||
if (received_event & Get_Sys_Event_Flag(kPowerOnEvent)) // 上电
|
Send_Laser_Alarm_Event(kPowerOnEvent);
|
||||||
|
TotalRecords.power_on++;
|
||||||
|
RCC_ClearFlag();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Send_Laser_Alarm_Event(kPreheatingEvent); // 这一句的作用是设备不是掉电重启的情况,直接进入预热模式
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_D("欠压复位\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
result = rt_event_recv(&alarm_event,
|
||||||
|
Get_Sys_Event_Flag(kPowerOnEvent) | // 上电
|
||||||
|
Get_Sys_Event_Flag(kPowerDownEvent) | // 掉电
|
||||||
|
Get_Sys_Event_Flag(kPreheatingEvent) | // 预热
|
||||||
|
Get_Sys_Event_Flag(kNormalDetectionEvents) | // 正常检测
|
||||||
|
Get_Sys_Event_Flag(kAlarmExceptionEvent) | // 寿命到期
|
||||||
|
Get_Sys_Event_Flag(kAlarmEvent) | // 报警
|
||||||
|
Get_Sys_Event_Flag(kAlarmRcyEvent) | // 报警恢复
|
||||||
|
Get_Sys_Event_Flag(kSelfCheckEvent) | // 自检
|
||||||
|
Get_Sys_Event_Flag(kFaultEvent) | // 故障模式
|
||||||
|
Get_Sys_Event_Flag(kFaultRcyEvent) | // 故障恢复
|
||||||
|
Get_Sys_Event_Flag(KMuteEvent), // 消音
|
||||||
|
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
|
||||||
|
RT_WAITING_FOREVER, &received_event);
|
||||||
|
if (result == RT_EOK)
|
||||||
|
{
|
||||||
|
if (is_event_initialized == RT_TRUE)
|
||||||
{
|
{
|
||||||
LOG_D("上电模式");
|
if (received_event & Get_Sys_Event_Flag(kPowerOnEvent)) // 上电
|
||||||
LOG_D("is_event_initialized :%d", is_event_initialized);
|
|
||||||
SysControl.status = kPowerOnEvent;
|
|
||||||
|
|
||||||
Flash_Write_Record(kRecordPowerOn);
|
|
||||||
Send_Laser_Alarm_Event(kPreheatingEvent);
|
|
||||||
}
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(kPreheatingEvent)) // 预热
|
|
||||||
{
|
|
||||||
LOG_D("预热模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
SysControl.status = kPreheatingEvent;
|
|
||||||
|
|
||||||
LED_STOP(r);
|
|
||||||
LED_STOP(g);
|
|
||||||
LED_STOP(y);
|
|
||||||
LED_CTRL(g, "500,2500", -1);
|
|
||||||
LED_START(g);
|
|
||||||
rt_thread_mdelay(1000);
|
|
||||||
LED_CTRL(y, "500,2500", -1);
|
|
||||||
LED_START(y);
|
|
||||||
rt_thread_mdelay(1000);
|
|
||||||
LED_CTRL(r, "500,2500", -1);
|
|
||||||
LED_START(r);
|
|
||||||
rt_thread_mdelay(1000);
|
|
||||||
|
|
||||||
BEEP_PREAT_OK;
|
|
||||||
LED_STOP(r);
|
|
||||||
LED_STOP(g);
|
|
||||||
LED_STOP(y);
|
|
||||||
LOG_D("预热完成");
|
|
||||||
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(kNormalDetectionEvents)) // 正常检测
|
|
||||||
{
|
|
||||||
LOG_D("正常检测模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
SysControl.status = kNormalDetectionEvents;
|
|
||||||
#if (NB_MODULE_SWITCH == 1)
|
|
||||||
if (mb26_conncet_tcp_flag)
|
|
||||||
{
|
{
|
||||||
LED_G_INTERNET;
|
LOG_D("上电模式");
|
||||||
|
LOG_D("is_event_initialized :%d", is_event_initialized);
|
||||||
|
SysControl.status = kPowerOnEvent;
|
||||||
|
|
||||||
|
Flash_Write_Record(kRecordPowerOn);
|
||||||
|
Send_Laser_Alarm_Event(kPreheatingEvent);
|
||||||
}
|
}
|
||||||
else
|
else if (received_event & Get_Sys_Event_Flag(kPreheatingEvent)) // 预热
|
||||||
{
|
{
|
||||||
#endif
|
LOG_D("预热模式");
|
||||||
LED_G_NORMAL;
|
|
||||||
#if (NB_MODULE_SWITCH == 1)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
rt_thread_mdelay(10);
|
|
||||||
LOG_D("LED_G_NORMAL");
|
|
||||||
}
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(kAlarmExceptionEvent)) // 浓度异常
|
|
||||||
{
|
|
||||||
LOG_D("浓度异常模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
SysControl.last_status = SysControl.status;
|
||||||
SysControl.status = kAlarmExceptionEvent;
|
SysControl.status = kPreheatingEvent;
|
||||||
|
|
||||||
LED_R_ALARM;
|
LED_STOP(r);
|
||||||
LOG_D("LED_R_ALARM");
|
LED_STOP(g);
|
||||||
}
|
LED_STOP(y);
|
||||||
else if (received_event & Get_Sys_Event_Flag(kAlarmEvent)) // 报警
|
LED_CTRL(g, "500,2500", -1);
|
||||||
{
|
LED_START(g);
|
||||||
LOG_D("报警模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
SysControl.status = kAlarmEvent;
|
|
||||||
|
|
||||||
Flash_Write_Record(kRecordAlarm); // 写入flash报警信息
|
|
||||||
|
|
||||||
LED_R_ALARM;
|
|
||||||
BEEP_ALARM;
|
|
||||||
|
|
||||||
#if (NB_MODULE_SWITCH == 1)
|
|
||||||
Mb26_Send_Event(kMb26AlarmEvent);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(kAlarmRcyEvent)) // 报警恢复
|
|
||||||
{
|
|
||||||
LOG_D("报警恢复模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
SysControl.status = kAlarmRcyEvent;
|
|
||||||
|
|
||||||
Flash_Write_Record(kRecordAlarmRcy);
|
|
||||||
|
|
||||||
BEEP_STOP;
|
|
||||||
|
|
||||||
#if (NB_MODULE_SWITCH == 1)
|
|
||||||
Mb26_Send_Event(kMb26AlarmRcyEvent);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
|
||||||
}
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(kFaultEvent)) // 故障
|
|
||||||
{
|
|
||||||
LOG_D("故障模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
SysControl.status = kFaultEvent;
|
|
||||||
|
|
||||||
Flash_Write_Record(kRecordFault);
|
|
||||||
|
|
||||||
LED_Y_FAULT;
|
|
||||||
BEEP_FAULT;
|
|
||||||
|
|
||||||
#if (NB_MODULE_SWITCH == 1)
|
|
||||||
Mb26_Send_Event(kMb26FaultEvent);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(kFaultRcyEvent)) // 故障恢复
|
|
||||||
{
|
|
||||||
LOG_D("故障恢复模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
SysControl.status = kFaultRcyEvent;
|
|
||||||
|
|
||||||
Flash_Write_Record(kRecordFaultRcy);
|
|
||||||
|
|
||||||
BEEP_STOP;
|
|
||||||
|
|
||||||
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
|
||||||
#if (NB_MODULE_SWITCH == 1)
|
|
||||||
Mb26_Send_Event(kMb26FaultRcyEvent);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(KMuteEvent)) // 消音
|
|
||||||
{
|
|
||||||
LOG_D("消音模式");
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
SysControl.status = KMuteEvent;
|
|
||||||
|
|
||||||
#if (NB_MODULE_SWITCH == 1)
|
|
||||||
Mb26_Send_Event(kMb26SilenceEvent);
|
|
||||||
#endif
|
|
||||||
BEEP_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(kPowerDownEvent)) // 掉电
|
|
||||||
{
|
|
||||||
LOG_D("掉电模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
SysControl.status = kPowerDownEvent;
|
|
||||||
|
|
||||||
// 写入掉电记录
|
|
||||||
Flash_Write_Record(kRecordPowerDown);
|
|
||||||
|
|
||||||
Flash_Set_WorkDuration(work_duration); // 写入工作时长
|
|
||||||
#if (NB_MODULE_SWITCH == 1)
|
|
||||||
Mb26_Send_Event(kMb26PowerDownEvent);
|
|
||||||
#endif
|
|
||||||
LOG_D("Enter AnalogWatchdog Interrupt");
|
|
||||||
|
|
||||||
Flash_Set_WorkDuration(work_duration); // 重启前保存参数
|
|
||||||
// 等待180s,要是还没断电就重启
|
|
||||||
for (uint8_t i = 0; i < 180; i++)
|
|
||||||
{
|
|
||||||
rt_thread_mdelay(1000);
|
rt_thread_mdelay(1000);
|
||||||
LOG_D(" %d s", i);
|
LED_CTRL(y, "500,2500", -1);
|
||||||
|
LED_START(y);
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
|
LED_CTRL(r, "500,2500", -1);
|
||||||
|
LED_START(r);
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
|
|
||||||
|
BEEP_PREAT_OK;
|
||||||
|
LED_STOP(r);
|
||||||
|
LED_STOP(g);
|
||||||
|
LED_STOP(y);
|
||||||
|
LOG_D("预热完成");
|
||||||
|
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
||||||
}
|
}
|
||||||
NVIC_SystemReset(); // 直接重启系统
|
else if (received_event & Get_Sys_Event_Flag(kNormalDetectionEvents)) // 正常检测
|
||||||
}
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(kSelfCheckEvent)) // 自检
|
|
||||||
{
|
|
||||||
LOG_D("自检模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
LOG_D("Self Check Mode SysControl.last_status:%d", SysControl.last_status);
|
|
||||||
SysControl.status = kSelfCheckEvent;
|
|
||||||
|
|
||||||
_Self_Check_Mode();
|
|
||||||
Send_Laser_Alarm_Event(SysControl.last_status);
|
|
||||||
#if (NB_MODULE_SWITCH == 1)
|
|
||||||
Mb26_Send_Event(kMb26SelfCheckEvent);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (received_event & Get_Sys_Event_Flag(kSensorFailureEvent)) // 失效
|
|
||||||
{
|
|
||||||
LOG_D("传感器失效模式");
|
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
|
||||||
SysControl.status = kSensorFailureEvent;
|
|
||||||
|
|
||||||
if (Flash_GetNum_Records(kRecordSensoEndOfLife) == 0)
|
|
||||||
{
|
{
|
||||||
Flash_Write_Record(kRecordSensoEndOfLife);
|
LOG_D("正常检测模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kNormalDetectionEvents;
|
||||||
|
#if (NB_MODULE_SWITCH == 1)
|
||||||
|
if (mb26_conncet_tcp_flag)
|
||||||
|
{
|
||||||
|
LED_G_INTERNET;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
LED_G_NORMAL;
|
||||||
|
#if (NB_MODULE_SWITCH == 1)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
rt_thread_mdelay(10);
|
||||||
|
LOG_D("LED_G_NORMAL");
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kAlarmExceptionEvent)) // 浓度异常
|
||||||
|
{
|
||||||
|
LOG_D("浓度异常模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kAlarmExceptionEvent;
|
||||||
|
|
||||||
|
LED_R_ALARM;
|
||||||
|
LOG_D("LED_R_ALARM");
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kAlarmEvent)) // 报警
|
||||||
|
{
|
||||||
|
LOG_D("报警模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kAlarmEvent;
|
||||||
|
|
||||||
|
Flash_Write_Record(kRecordAlarm); // 写入flash报警信息
|
||||||
|
|
||||||
|
LED_R_ALARM;
|
||||||
|
BEEP_ALARM;
|
||||||
|
|
||||||
|
#if (NB_MODULE_SWITCH == 1)
|
||||||
|
Mb26_Send_Event(kMb26AlarmEvent);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kAlarmRcyEvent)) // 报警恢复
|
||||||
|
{
|
||||||
|
LOG_D("报警恢复模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kAlarmRcyEvent;
|
||||||
|
|
||||||
|
Flash_Write_Record(kRecordAlarmRcy);
|
||||||
|
|
||||||
|
BEEP_STOP;
|
||||||
|
|
||||||
|
#if (NB_MODULE_SWITCH == 1)
|
||||||
|
Mb26_Send_Event(kMb26AlarmRcyEvent);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kFaultEvent)) // 故障
|
||||||
|
{
|
||||||
|
LOG_D("故障模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kFaultEvent;
|
||||||
|
|
||||||
|
Flash_Write_Record(kRecordFault);
|
||||||
|
|
||||||
|
LED_Y_FAULT;
|
||||||
|
BEEP_FAULT;
|
||||||
|
|
||||||
|
#if (NB_MODULE_SWITCH == 1)
|
||||||
|
Mb26_Send_Event(kMb26FaultEvent);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kFaultRcyEvent)) // 故障恢复
|
||||||
|
{
|
||||||
|
LOG_D("故障恢复模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kFaultRcyEvent;
|
||||||
|
|
||||||
|
Flash_Write_Record(kRecordFaultRcy);
|
||||||
|
|
||||||
|
BEEP_STOP;
|
||||||
|
|
||||||
|
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
||||||
|
#if (NB_MODULE_SWITCH == 1)
|
||||||
|
Mb26_Send_Event(kMb26FaultRcyEvent);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(KMuteEvent)) // 消音
|
||||||
|
{
|
||||||
|
LOG_D("消音模式");
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = KMuteEvent;
|
||||||
|
|
||||||
|
#if (NB_MODULE_SWITCH == 1)
|
||||||
|
Mb26_Send_Event(kMb26SilenceEvent);
|
||||||
|
#endif
|
||||||
|
BEEP_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kPowerDownEvent)) // 掉电
|
||||||
|
{
|
||||||
|
LOG_D("掉电模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kPowerDownEvent;
|
||||||
|
|
||||||
|
// 写入掉电记录
|
||||||
|
Flash_Write_Record(kRecordPowerDown);
|
||||||
|
|
||||||
|
Flash_Set_WorkDuration(work_duration); // 写入工作时长
|
||||||
|
#if (NB_MODULE_SWITCH == 1)
|
||||||
|
Mb26_Send_Event(kMb26PowerDownEvent);
|
||||||
|
#endif
|
||||||
|
LOG_D("Enter AnalogWatchdog Interrupt");
|
||||||
|
|
||||||
|
Flash_Set_WorkDuration(work_duration); // 重启前保存参数
|
||||||
|
// 等待180s,要是还没断电就重启
|
||||||
|
for (uint8_t i = 0; i < 180; i++)
|
||||||
|
{
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
|
LOG_D(" %d s", i);
|
||||||
|
}
|
||||||
|
NVIC_SystemReset(); // 直接重启系统
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kSelfCheckEvent)) // 自检
|
||||||
|
{
|
||||||
|
LOG_D("自检模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
LOG_D("Self Check Mode SysControl.last_status:%d", SysControl.last_status);
|
||||||
|
SysControl.status = kSelfCheckEvent;
|
||||||
|
|
||||||
|
_Self_Check_Mode();
|
||||||
|
Send_Laser_Alarm_Event(SysControl.last_status);
|
||||||
|
#if (NB_MODULE_SWITCH == 1)
|
||||||
|
Mb26_Send_Event(kMb26SelfCheckEvent);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kSensorFailureEvent)) // 失效
|
||||||
|
{
|
||||||
|
LOG_D("传感器失效模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kSensorFailureEvent;
|
||||||
|
|
||||||
|
if (Flash_GetNum_Records(kRecordSensoEndOfLife) == 0)
|
||||||
|
{
|
||||||
|
Flash_Write_Record(kRecordSensoEndOfLife);
|
||||||
|
}
|
||||||
|
BEEP_END_OF_LIFE;
|
||||||
|
LED_Y_END_OF_LIFE;
|
||||||
}
|
}
|
||||||
BEEP_END_OF_LIFE;
|
|
||||||
LED_Y_END_OF_LIFE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "ctype.h"
|
#include "ctype.h"
|
||||||
#include "rtthread.h"
|
#include "rtthread.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
#include "bsp_flash.h"
|
||||||
|
|
||||||
volatile rt_uint16_t work_duration = 1; // 工作时长
|
volatile rt_uint16_t work_duration = 1; // 工作时长
|
||||||
volatile rt_uint8_t device_life_check = 0;
|
volatile rt_uint8_t device_life_check = 0;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* @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: 2024-11-12 14:19:50
|
* @LastEditTime: 2024-12-01 14:18:19
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS\applications\user_sys.h
|
* @FilePath: \ble_bjq_ch303rct6_ml307\applications\user_sys.h
|
||||||
* @Description:
|
* @Description:
|
||||||
* @
|
* @
|
||||||
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
||||||
|
@ -12,7 +12,6 @@
|
||||||
#define __USER_SYS_H__
|
#define __USER_SYS_H__
|
||||||
|
|
||||||
#include "rtdef.h"
|
#include "rtdef.h"
|
||||||
#include "bsp_flash.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define SYS_PREHEAT_TIME_S (10U)
|
#define SYS_PREHEAT_TIME_S (10U)
|
||||||
|
@ -37,13 +36,20 @@ typedef enum
|
||||||
kMaxEventcnt,
|
kMaxEventcnt,
|
||||||
} AlarmEvent;
|
} AlarmEvent;
|
||||||
|
|
||||||
|
// 定义系统状态枚举类型
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
kNotCalibrated = 0, // 未标定
|
||||||
|
kSysGasCalibStatus, // 已经标定
|
||||||
|
|
||||||
|
}TeCalibrationStatus;
|
||||||
// 定义开关状态枚举类型
|
// 定义开关状态枚举类型
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
kStatusOff = 0, // 关闭状态
|
kStatusOff = 0, // 关闭状态
|
||||||
kStatusOn // 打开状态
|
kStatusOn // 打开状态
|
||||||
} TeStatus;
|
} TeStatus;
|
||||||
|
|
||||||
// 定义系统标志位结构体
|
// 定义系统标志位结构体
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -51,31 +57,6 @@ typedef struct
|
||||||
TeStatus relay_status; // 继电器状态
|
TeStatus relay_status; // 继电器状态
|
||||||
} TsDeviceStatus;
|
} TsDeviceStatus;
|
||||||
|
|
||||||
|
|
||||||
// 定义系统状态枚举类型
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
kSysToBeCalibStatus = 0, // 系统待校准状态
|
|
||||||
kSysGasCalibStatus, // 气体校准状态
|
|
||||||
KSysTestStatus, // 测试状态
|
|
||||||
|
|
||||||
kSysSelfCheckingStatus, // 自检状态
|
|
||||||
|
|
||||||
kSysPowerUpStatus, // 上电状态
|
|
||||||
kSysPowerDownStatus, // 下电状态
|
|
||||||
|
|
||||||
kSysStartupPreheatingStatus, // 启动预热状态
|
|
||||||
kSysRuningStatus, // 运行中状态
|
|
||||||
|
|
||||||
kSysAlarmStatus, // 报警状态
|
|
||||||
kSysMuteStatus, // 消音状态
|
|
||||||
|
|
||||||
kSysFaultStatus, // 故障状态
|
|
||||||
kSysSensorEndOfLifeStatus, // 传感器寿命结束状态
|
|
||||||
|
|
||||||
kSysRestoreFactoryStatus, // 恢复出厂设置状态
|
|
||||||
}TeSysStatus;
|
|
||||||
|
|
||||||
// 定义系统控制结构体
|
// 定义系统控制结构体
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -85,19 +66,24 @@ typedef struct
|
||||||
|
|
||||||
extern volatile rt_uint16_t work_duration;//工作天数
|
extern volatile rt_uint16_t work_duration;//工作天数
|
||||||
extern volatile rt_uint8_t device_state_flag;
|
extern volatile rt_uint8_t device_state_flag;
|
||||||
|
extern TeCalibrationStatus g_Calibration_status;
|
||||||
extern struct rt_event alarm_event;
|
extern struct rt_event alarm_event;
|
||||||
extern TsSysControl SysControl;
|
extern TsSysControl SysControl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Send_Laser_Alarm_Event(AlarmEvent event);
|
void Send_Laser_Alarm_Event(AlarmEvent event);
|
||||||
|
|
||||||
|
|
||||||
unsigned short crc1021(const char *data, unsigned int length);
|
unsigned short crc1021(const char *data, unsigned int length);
|
||||||
void HexStrToBytes(const char *hexString, unsigned char *byteArray, size_t byteCount);
|
void HexStrToBytes(const char *hexString, unsigned char *byteArray, size_t byteCount);
|
||||||
void String2Hex(char *hex_arry, char *str);
|
void String2Hex(char *hex_arry, char *str);
|
||||||
unsigned int VerToHex(const char *version);
|
unsigned int VerToHex(const char *version);
|
||||||
int Extract_Value(const char *str, const char *key);
|
int Extract_Value(const char *str, const char *key);
|
||||||
int _Self_Check_Mode(void);
|
int _Self_Check_Mode(void);
|
||||||
int Convert_To_Hex(const struct flash_sever_info *sever_info, uint8_t *hex_array);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //!__USER_SYS_H__
|
#endif //!__USER_SYS_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,13 @@ extern agile_led_t *beep;
|
||||||
} while (0U)
|
} while (0U)
|
||||||
|
|
||||||
/************************预设的一些鸣叫模式**************/
|
/************************预设的一些鸣叫模式**************/
|
||||||
|
#define BEEP_CALIBRATION_OK \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
BEEP_CTRL("1000,100", 1); \
|
||||||
|
BEEP_START; \
|
||||||
|
} while (0U)
|
||||||
|
|
||||||
#define BEEP_PREAT_OK \
|
#define BEEP_PREAT_OK \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "rtdef.h"
|
#include "rtdef.h"
|
||||||
#include "bsp_hr.h"
|
#include "bsp_hr.h"
|
||||||
|
#include "user_sys.h"
|
||||||
|
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE (256U)
|
#define FLASH_PAGE_SIZE (256U)
|
||||||
#define FLASH_PAGE_HR_RECORD_NUM (25U)
|
#define FLASH_PAGE_HR_RECORD_NUM (25U)
|
||||||
|
@ -122,7 +124,9 @@
|
||||||
#define FLASH_SERVER_ADDR_ADDR (FLASH_WORK_TIME_ADDR + FLASH_WORK_TIME_LEN)
|
#define FLASH_SERVER_ADDR_ADDR (FLASH_WORK_TIME_ADDR + FLASH_WORK_TIME_LEN)
|
||||||
#define FLASH_SERVER_LEN (6) //FF.FF.FF.FF:FFFF
|
#define FLASH_SERVER_LEN (6) //FF.FF.FF.FF:FFFF
|
||||||
|
|
||||||
|
/*标定状态*/
|
||||||
|
#define FLASH_CALIBRATION_STATUS_ADDR (FLASH_SERVER_ADDR_ADDR + FLASH_SERVER_LEN)
|
||||||
|
#define FLASH_CALIBRATION_STATUS_LEN (1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,8 +240,8 @@ typedef struct __attribute__((packed))
|
||||||
{
|
{
|
||||||
rt_uint8_t hw_ver; // 硬件版本号
|
rt_uint8_t hw_ver; // 硬件版本号
|
||||||
rt_uint8_t sw_ver; // 软件版本号
|
rt_uint8_t sw_ver; // 软件版本号
|
||||||
rt_uint8_t alarm_l_value; // 报警低阈值
|
rt_uint16_t alarm_l_value; // 报警低阈值
|
||||||
rt_uint8_t alarm_h_value; // 报警高阈值
|
rt_uint16_t alarm_h_value; // 报警高阈值
|
||||||
rt_uint8_t temp_alarm_threshold;//温度报警阈值
|
rt_uint8_t temp_alarm_threshold;//温度报警阈值
|
||||||
rt_uint16_t nb_upload_cycle; // NB上传周期
|
rt_uint16_t nb_upload_cycle; // NB上传周期
|
||||||
rt_uint8_t nb_retry; // 重试次数
|
rt_uint8_t nb_retry; // 重试次数
|
||||||
|
@ -253,7 +257,9 @@ struct flash_sever_info
|
||||||
char server_url[64];
|
char server_url[64];
|
||||||
char server_port[8];
|
char server_port[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct flash_sever_info sever_info;
|
extern struct flash_sever_info sever_info;
|
||||||
|
|
||||||
void Flash_Write_Record(TeRecord record);
|
void Flash_Write_Record(TeRecord record);
|
||||||
int Get_Nb_Imei(char *buf, rt_size_t len);
|
int Get_Nb_Imei(char *buf, rt_size_t len);
|
||||||
int Get_Nb_Imsi(char *buf, rt_size_t len);
|
int Get_Nb_Imsi(char *buf, rt_size_t len);
|
||||||
|
@ -295,8 +301,23 @@ int Flash_Set_Sever_Data(rt_uint8_t *data);
|
||||||
rt_uint16_t Flash_Get_WorkDuration(void);
|
rt_uint16_t Flash_Get_WorkDuration(void);
|
||||||
int Flash_Set_WorkDuration(rt_uint16_t value);
|
int Flash_Set_WorkDuration(rt_uint16_t value);
|
||||||
|
|
||||||
|
TeCalibrationStatus Flash_Get_Calibration_State(void);
|
||||||
|
int Flash_Set_Calibration_State(TeCalibrationStatus status);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //!@__BSP_FLASH_H__
|
#endif //!@__BSP_FLASH_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
#include "bsp_flash.h"
|
#include "bsp_flash.h"
|
||||||
#include "lwutil.h"
|
#include "lwutil.h"
|
||||||
#include "bsp_rtc.h"
|
#include "bsp_rtc.h"
|
||||||
// #include "bsp_wdg.h"
|
|
||||||
#include "bsp_hr.h"
|
#include "bsp_hr.h"
|
||||||
#include "at_device_mb26.h"
|
#include "at_device_mb26.h"
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <rthw.h>
|
#include <rthw.h>
|
||||||
#include "user_sys.h"
|
|
||||||
|
|
||||||
#define LOG_TAG "bsp_flash"
|
#define LOG_TAG "bsp_flash"
|
||||||
#define LOG_LVL LOG_LVL_DBG
|
#define LOG_LVL LOG_LVL_DBG
|
||||||
|
@ -14,6 +12,7 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
extern int Convert_To_Hex(const struct flash_sever_info *sever_info, uint8_t *hex_array);
|
||||||
#define GETATTR(info, id) ((id) == kHwVerId ? (&(info)->hw_ver) \
|
#define GETATTR(info, id) ((id) == kHwVerId ? (&(info)->hw_ver) \
|
||||||
: (id) == kSwVerId ? (&(info)->sw_ver) \
|
: (id) == kSwVerId ? (&(info)->sw_ver) \
|
||||||
: (id) == kAlarmLValueId ? (&(info)->alarm_l_value) \
|
: (id) == kAlarmLValueId ? (&(info)->alarm_l_value) \
|
||||||
|
@ -85,11 +84,12 @@ rt_uint8_t sys_sw_ver = 0x11;
|
||||||
rt_uint8_t sys_nb_retry = 0x03; // 重试次数3次
|
rt_uint8_t sys_nb_retry = 0x03; // 重试次数3次
|
||||||
rt_uint16_t sys_nb_upload_cycle = 0x7800; // 120分钟一次 ,低位在前,高为在后,为了和服务器下发时保持一致,有利于读取
|
rt_uint16_t sys_nb_upload_cycle = 0x7800; // 120分钟一次 ,低位在前,高为在后,为了和服务器下发时保持一致,有利于读取
|
||||||
rt_uint16_t sys_alarm_h_value = 0x0032; // 50
|
rt_uint16_t sys_alarm_h_value = 0x0032; // 50
|
||||||
rt_uint16_t sys_alarm_l_value = 0x000A; // 10
|
rt_uint16_t sys_alarm_l_value = 0x09C4; // 10
|
||||||
rt_uint8_t sys_temp_alarm_threshold = 0x32;
|
rt_uint8_t sys_temp_alarm_threshold = 0x32;
|
||||||
rt_uint8_t sys_emagnetic_switch = 0x04; // 具备阀门功能
|
rt_uint8_t sys_emagnetic_switch = 0x04; // 具备阀门功能
|
||||||
rt_uint8_t sys_relay_switch = 0x04; // 具备继电器功能
|
rt_uint8_t sys_relay_switch = 0x04; // 具备继电器功能
|
||||||
struct flash_sever_info sever_info =
|
|
||||||
|
struct flash_sever_info sever_info =
|
||||||
{
|
{
|
||||||
.server_url = "47.94.169.135",
|
.server_url = "47.94.169.135",
|
||||||
.server_port = "7150",
|
.server_port = "7150",
|
||||||
|
@ -322,6 +322,26 @@ int Flash_Set_Sever_Data(rt_uint8_t *data)
|
||||||
return Flash_Write_ConfigInfo(page_buf);
|
return Flash_Write_ConfigInfo(page_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TeCalibrationStatus Flash_Get_Calibration_State(void)
|
||||||
|
{
|
||||||
|
return *(rt_uint8_t *)FLASH_CALIBRATION_STATUS_ADDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Flash_Set_Calibration_State(TeCalibrationStatus status)
|
||||||
|
{
|
||||||
|
rt_uint8_t page_buf[FLASH_PAGE_SIZE] = {0};
|
||||||
|
rt_uint8_t in_page_offset = (FLASH_CALIBRATION_STATUS_ADDR - FLASH_CONFIG_INFO_START_ADDR);
|
||||||
|
|
||||||
|
Flash_ErasePage_ReadConfigInfo(page_buf);
|
||||||
|
//*将传入的数据写到flash地址中
|
||||||
|
|
||||||
|
page_buf[in_page_offset] = status;
|
||||||
|
|
||||||
|
return Flash_Write_ConfigInfo(page_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Flash Erase Page
|
* @description: Flash Erase Page
|
||||||
* @param {TeRecord} record
|
* @param {TeRecord} record
|
||||||
|
@ -730,8 +750,19 @@ rt_uint8_t Flash_Sys_Cfg(TeFlashCfgInfoId id, rt_uint8_t *buf, rt_size_t len)
|
||||||
size_t Flash_Get_SysCfg(TeFlashCfgInfoId id)
|
size_t Flash_Get_SysCfg(TeFlashCfgInfoId id)
|
||||||
{
|
{
|
||||||
size_t value = 0;
|
size_t value = 0;
|
||||||
rt_memcpy(&value, (void *)hr_sys_cfg_info_addr[id], hr_sys_cfg_info_len[id]);
|
if (hr_sys_cfg_info_len[id] == 1)
|
||||||
|
{
|
||||||
|
return *(rt_uint8_t *)hr_sys_cfg_info_addr[id];
|
||||||
|
}
|
||||||
|
else if (hr_sys_cfg_info_len[id] == 2)
|
||||||
|
{
|
||||||
|
rt_uint8_t buf[2] = {0};
|
||||||
|
|
||||||
|
rt_memcpy(&buf, (rt_uint8_t *)hr_sys_cfg_info_addr[id], hr_sys_cfg_info_len[id]);
|
||||||
|
value = buf[0] | (buf[1] << 8);
|
||||||
|
|
||||||
|
LOG_D("buf[0]= %u, buf[1]: %u", buf[0], buf[1]);
|
||||||
|
}
|
||||||
LOG_D("value: %u", value);
|
LOG_D("value: %u", value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -844,6 +875,7 @@ int BSP_Flash_Init(void)
|
||||||
{
|
{
|
||||||
LOG_D("Flash_Set_Sever_Data error!");
|
LOG_D("Flash_Set_Sever_Data error!");
|
||||||
}
|
}
|
||||||
|
Flash_Set_Calibration_State(kNotCalibrated);//未标定状态
|
||||||
|
|
||||||
Flash_Write(FLASH_HW_VER_ADDR, (rt_uint8_t *)&sci,
|
Flash_Write(FLASH_HW_VER_ADDR, (rt_uint8_t *)&sci,
|
||||||
(sizeof(sys_config_info) - 50));
|
(sizeof(sys_config_info) - 50));
|
||||||
|
|
|
@ -8,26 +8,6 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
* @Author: mbw
|
|
||||||
* @Date: 2024-10-09 08:42:14
|
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
|
||||||
* @LastEditTime: 2024-11-29 14:38:14
|
|
||||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS\bsp\src\bsp_mb26.c
|
|
||||||
* @Description:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2019-12-13 qiyongzhong first version
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <at_device_mb26.h>
|
#include <at_device_mb26.h>
|
||||||
#include "drv_gpio.h"
|
#include "drv_gpio.h"
|
||||||
#include "bsp_mb26.h"
|
#include "bsp_mb26.h"
|
||||||
|
|
|
@ -172,6 +172,7 @@ static void Sensor_detection_thread_entry(void *param)
|
||||||
int BSP_MQ_Init(void)
|
int BSP_MQ_Init(void)
|
||||||
{
|
{
|
||||||
Sensor_device.alarm_value = Flash_Get_SysCfg(kAlarmLValueId);
|
Sensor_device.alarm_value = Flash_Get_SysCfg(kAlarmLValueId);
|
||||||
|
LOG_D("报警阈值为:%d", Sensor_device.alarm_value);
|
||||||
rt_thread_init(&Sensor_Thread, //可以用定时器做,没必要线程
|
rt_thread_init(&Sensor_Thread, //可以用定时器做,没必要线程
|
||||||
"sensor_thread",
|
"sensor_thread",
|
||||||
Sensor_detection_thread_entry,
|
Sensor_detection_thread_entry,
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#endif /* RT_USING_LIBC */
|
#endif /* RT_USING_LIBC */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Reference in New Issue