This commit is contained in:
parent
5a984bd554
commit
63fb71a9de
|
@ -5,7 +5,7 @@
|
||||||
"type": "mrs-debugger",
|
"type": "mrs-debugger",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "BLE_TYQ_CH584M",
|
"name": "BLE_TYQ_CH584M",
|
||||||
"cwd": "c:\\Users\\16586\\Desktop\\BLE_TYQ_CH584M",
|
"cwd": "f:\\BaiduSyncdisk\\SXDT\\BLE_TYQ\\Firmware\\BLE_TYQ_CH584M",
|
||||||
"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": "c:\\Users\\16586\\Desktop\\BLE_TYQ_CH584M\\obj\\BLE_TYQ_CH584M.elf",
|
"executableFile": "f:\\BaiduSyncdisk\\SXDT\\BLE_TYQ\\Firmware\\BLE_TYQ_CH584M\\obj\\BLE_TYQ_CH584M.elf",
|
||||||
"symbolFile": "c:\\Users\\16586\\Desktop\\BLE_TYQ_CH584M\\obj\\BLE_TYQ_CH584M.elf",
|
"symbolFile": "f:\\BaiduSyncdisk\\SXDT\\BLE_TYQ\\Firmware\\BLE_TYQ_CH584M\\obj\\BLE_TYQ_CH584M.elf",
|
||||||
"executableFileOffset": 0,
|
"executableFileOffset": 0,
|
||||||
"symbolFileOffset": 0
|
"symbolFileOffset": 0
|
||||||
},
|
},
|
||||||
|
|
|
@ -67,6 +67,7 @@ void app_task_handler(TeAppEvtType app_evt_type)
|
||||||
DelayMs(5);
|
DelayMs(5);
|
||||||
// ShowLed();
|
// ShowLed();
|
||||||
// 电压过低就关阀
|
// 电压过低就关阀
|
||||||
|
// if (gValveData.bat <= LOW_VABAT_ALARM_VALUE)
|
||||||
if (gValveData.bat <= LOW_VABAT_ALARM_VALUE)
|
if (gValveData.bat <= LOW_VABAT_ALARM_VALUE)
|
||||||
{
|
{
|
||||||
LED_ALL_OFF_DEINIT;
|
LED_ALL_OFF_DEINIT;
|
||||||
|
@ -244,7 +245,7 @@ int main(void)
|
||||||
// 改成 4000000 波特率了
|
// 改成 4000000 波特率了
|
||||||
BSP_UART1_Init(4000000);
|
BSP_UART1_Init(4000000);
|
||||||
#endif
|
#endif
|
||||||
DelayMs(1000 * 1);
|
DelayMs(1000 * 2);
|
||||||
|
|
||||||
ShowRestartReason();
|
ShowRestartReason();
|
||||||
|
|
||||||
|
@ -272,27 +273,24 @@ int main(void)
|
||||||
GXHTC3C_Init();
|
GXHTC3C_Init();
|
||||||
BSP_ADC_Init();
|
BSP_ADC_Init();
|
||||||
|
|
||||||
// DelayMs(2000 * 1);
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
BOOST_EN;
|
|
||||||
DelayMs(8);
|
|
||||||
|
|
||||||
BOOST_OFF_DEINIT;
|
|
||||||
DelayMs(2);
|
|
||||||
}
|
|
||||||
BSP_BlockSleep();
|
|
||||||
BSP_RequestBoost();
|
|
||||||
|
|
||||||
DelayMs(100);
|
|
||||||
|
|
||||||
BSP_VAVLE_Init();
|
BSP_VAVLE_Init();
|
||||||
|
|
||||||
ShowLed();
|
// DelayMs(2000 * 1);
|
||||||
BEEP_ON;
|
BSP_BlockSleep();
|
||||||
DelayMs(500);
|
BSP_RequestBoost();
|
||||||
|
DelayMs(100);
|
||||||
|
|
||||||
|
// 如果电压低就都不亮灯、蜂鸣器
|
||||||
|
if (bat_mv <= LOW_VABAT_CLOSE_MV)
|
||||||
|
{
|
||||||
|
tmos_set_event(vavle_task_id, VAVLE_CLOSE_START_EVT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowLed();
|
||||||
|
BEEP_ON;
|
||||||
|
DelayMs(500);
|
||||||
|
}
|
||||||
LED_ALL_OFF_DEINIT;
|
LED_ALL_OFF_DEINIT;
|
||||||
BEEP_OFF_DEINIT;
|
BEEP_OFF_DEINIT;
|
||||||
BSP_NoNeedBoost();
|
BSP_NoNeedBoost();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Author : stark1898y 1658608470@qq.com
|
* @Author : stark1898y 1658608470@qq.com
|
||||||
* @Date : 2024-12-12 15:55:38
|
* @Date : 2024-12-12 15:55:38
|
||||||
* @LastEditors : stark1898y 1658608470@qq.com
|
* @LastEditors : stark1898y 1658608470@qq.com
|
||||||
* @LastEditTime : 2025-04-22 16:12:07
|
* @LastEditTime : 2025-05-28 13:38:08
|
||||||
* @FilePath : \BLE_TYQ_CH584M\BSP\inc\bsp_valve.h
|
* @FilePath : \BLE_TYQ_CH584M\BSP\inc\bsp_valve.h
|
||||||
* @Description :
|
* @Description :
|
||||||
*
|
*
|
||||||
|
@ -44,9 +44,12 @@ extern tmosTaskID vavle_task_id;
|
||||||
#define CHARGE_TIME_MS (1500)
|
#define CHARGE_TIME_MS (1500)
|
||||||
|
|
||||||
// 2.2V
|
// 2.2V
|
||||||
#define LOW_VABAT_ALARM_VALUE 22
|
#define LOW_VABAT_ALARM_VALUE 23
|
||||||
|
|
||||||
|
#define LOW_VABAT_CLOSE_VALUE 23
|
||||||
|
|
||||||
|
#define LOW_VABAT_CLOSE_MV 2350
|
||||||
|
|
||||||
#define LOW_VABAT_CLOSE_VALUE 20
|
|
||||||
|
|
||||||
|
|
||||||
#define FRAME_HEADER 0xAA
|
#define FRAME_HEADER 0xAA
|
||||||
|
@ -110,12 +113,13 @@ typedef struct __attribute__((packed))
|
||||||
uint32_t in_pressure; // 4B 阀门入口压力 Pa
|
uint32_t in_pressure; // 4B 阀门入口压力 Pa
|
||||||
uint32_t out_pressure; // 4B 阀门出口压力 Pa
|
uint32_t out_pressure; // 4B 阀门出口压力 Pa
|
||||||
uint32_t atm_pressure; // 4B 阀门大气压力 Pa
|
uint32_t atm_pressure; // 4B 阀门大气压力 Pa
|
||||||
uint8_t type; // 阀门类型
|
|
||||||
uint8_t bat; // 1B 电池电压 30=3V,18=1.8V
|
uint8_t bat; // 1B 电池电压 30=3V,18=1.8V
|
||||||
|
uint8_t type; // 阀门类型
|
||||||
uint8_t humi; // 1B 阀门湿度 %RH
|
uint8_t humi; // 1B 阀门湿度 %RH
|
||||||
int8_t rssi;
|
int8_t rssi;
|
||||||
} TsValveData;
|
} TsValveData;
|
||||||
extern TsValveData gValveData;
|
extern TsValveData gValveData;
|
||||||
|
extern uint16_t bat_mv;
|
||||||
|
|
||||||
void LDect_Deinit(void);
|
void LDect_Deinit(void);
|
||||||
void LDect_Init(void);
|
void LDect_Init(void);
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include "bsp_uart.h"
|
#include "bsp_uart.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
#include "bsp_valve.h"
|
||||||
|
|
||||||
#undef LOG_ENABLE
|
#undef LOG_ENABLE
|
||||||
#define LOG_ENABLE 1
|
#define LOG_ENABLE 1
|
||||||
|
|
||||||
|
@ -67,6 +69,8 @@ uint8_t BSP_ReadVbat(void)
|
||||||
uint8_t vbat = (uint8_t)((CountBat + 50) / 100);
|
uint8_t vbat = (uint8_t)((CountBat + 50) / 100);
|
||||||
logDebug("AverageCountBat = %dmV, vbat = %d(100mV)", CountBat, vbat);
|
logDebug("AverageCountBat = %dmV, vbat = %d(100mV)", CountBat, vbat);
|
||||||
|
|
||||||
|
bat_mv = CountBat;
|
||||||
|
|
||||||
//缩小到100mV
|
//缩小到100mV
|
||||||
return vbat;
|
return vbat;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Author : stark1898y 1658608470@qq.com
|
* @Author : stark1898y 1658608470@qq.com
|
||||||
* @Date : 2024-12-15 15:01:15
|
* @Date : 2024-12-15 15:01:15
|
||||||
* @LastEditors : stark1898y 1658608470@qq.com
|
* @LastEditors : stark1898y 1658608470@qq.com
|
||||||
* @LastEditTime : 2025-05-22 11:08:37
|
* @LastEditTime : 2025-05-28 09:03:24
|
||||||
* @FilePath : \BLE_TYQ_CH584M\BSP\src\bsp_valve.c
|
* @FilePath : \BLE_TYQ_CH584M\BSP\src\bsp_valve.c
|
||||||
* @Description :
|
* @Description :
|
||||||
*
|
*
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
#define LOG_TAG "BSP_VALVE"
|
#define LOG_TAG "BSP_VALVE"
|
||||||
|
|
||||||
TsValveData gValveData = {0};
|
TsValveData gValveData = {0};
|
||||||
|
uint16_t bat_mv;
|
||||||
|
|
||||||
TsRawFrameData RelyData;
|
TsRawFrameData RelyData;
|
||||||
|
|
||||||
|
@ -542,15 +543,16 @@ static uint16_t VAVLE_Task_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||||
gValveData.bat = BSP_ReadVbat();
|
gValveData.bat = BSP_ReadVbat();
|
||||||
|
|
||||||
// 电压过低就关阀
|
// 电压过低就关阀
|
||||||
if (gValveData.bat <= LOW_VABAT_CLOSE_VALUE)
|
// if (gValveData.bat <= LOW_VABAT_CLOSE_VALUE)
|
||||||
|
if (bat_mv <= LOW_VABAT_CLOSE_MV)
|
||||||
{
|
{
|
||||||
gValveData.switch_status = kClosed;
|
gValveData.switch_status = kClosed;
|
||||||
tmos_set_event(vavle_task_id, VAVLE_CLOSE_START_EVT);
|
tmos_set_event(vavle_task_id, VAVLE_CLOSE_START_EVT);
|
||||||
}
|
}
|
||||||
else if (gValveData.bat <= LOW_VABAT_ALARM_VALUE)
|
// else if (gValveData.bat <= LOW_VABAT_ALARM_VALUE)
|
||||||
{
|
// {
|
||||||
tmos_set_event(vavle_task_id, VAVLE_LOW_VBAT_ALARM_EVT);
|
// tmos_set_event(vavle_task_id, VAVLE_LOW_VBAT_ALARM_EVT);
|
||||||
}
|
// }
|
||||||
tmos_start_task(vavle_task_id, VAVLE_LOOP_DECT_EVT, MS1_TO_SYSTEM_TIME(VALVE_DECT_PERIOD_MS));
|
tmos_start_task(vavle_task_id, VAVLE_LOOP_DECT_EVT, MS1_TO_SYSTEM_TIME(VALVE_DECT_PERIOD_MS));
|
||||||
|
|
||||||
return (events ^ VAVLE_LOOP_DECT_EVT);
|
return (events ^ VAVLE_LOOP_DECT_EVT);
|
||||||
|
@ -648,7 +650,7 @@ void BSP_VAVLE_Init(void)
|
||||||
gValveData.type = kTyq;
|
gValveData.type = kTyq;
|
||||||
gValveData.bat = BSP_ReadVbat();
|
gValveData.bat = BSP_ReadVbat();
|
||||||
|
|
||||||
tmos_start_task(vavle_task_id, VAVLE_LOOP_DECT_EVT, MS1_TO_SYSTEM_TIME(VALVE_DECT_PERIOD_MS));
|
tmos_start_task(vavle_task_id, VAVLE_LOOP_DECT_EVT, MS1_TO_SYSTEM_TIME(1000));
|
||||||
|
|
||||||
// GPIOA_ResetBits(GPIO_Pin_2);
|
// GPIOA_ResetBits(GPIO_Pin_2);
|
||||||
// GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeIN_PU);
|
// GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeIN_PU);
|
||||||
|
|
Loading…
Reference in New Issue