This commit is contained in:
parent
5889762ed0
commit
a3a95c5d0c
|
@ -1,6 +1,8 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//APP/peripheral_main.c=UTF-8
|
||||
encoding//BSP/inc/bsp_valve.h=UTF-8
|
||||
encoding//BSP/src/bsp_adc.c=UTF-8
|
||||
encoding//BSP/src/bsp_i2c.c=UTF-8
|
||||
encoding//BSP/src/bsp_key.c=UTF-8
|
||||
encoding//BSP/src/bsp_valve.c=UTF-8
|
||||
encoding//common/letter-shell/extensions/log/log.h=UTF-8
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
"atomic": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"stdarg.h": "c"
|
||||
"stdarg.h": "c",
|
||||
"bsp_flash.h": "c",
|
||||
"bsp_valve.h": "c",
|
||||
"log.h": "c"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
|
@ -32,6 +32,12 @@ extern "C" {
|
|||
#define SBP_PARAM_UPDATE_EVT 0x0008
|
||||
#define SBP_PHY_UPDATE_EVT 0x0010
|
||||
|
||||
#define SBP_REPLY_CMD_EVT 0x0020
|
||||
|
||||
extern uint8_t Peripheral_TaskID;
|
||||
|
||||
// #define VAVLE_CLOSE_
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
@ -57,6 +63,10 @@ extern void Peripheral_Init(void);
|
|||
*/
|
||||
extern uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events);
|
||||
|
||||
|
||||
void BSP_NeeedReplyCMdFirst(void);
|
||||
void BSP_NoNeeedReplyCMd(void);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
|
|
217
APP/peripheral.c
217
APP/peripheral.c
|
@ -33,18 +33,22 @@
|
|||
#undef LOG_TAG
|
||||
#define LOG_TAG "peripheral"
|
||||
|
||||
volatile uint8_t mtu_flag = 0;
|
||||
volatile uint8_t mtu_flag = 0;
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
static volatile bool periodic_upload_block_flag = false;
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
void BSP_NeeedReplyCMdFirst(void)
|
||||
{
|
||||
periodic_upload_block_flag = true;
|
||||
}
|
||||
|
||||
void BSP_NoNeeedReplyCMd(void)
|
||||
{
|
||||
periodic_upload_block_flag = false;
|
||||
}
|
||||
|
||||
// How often to perform periodic event
|
||||
#define SBP_PERIODIC_EVT_PERIOD (160 * 10 * 1) // (160 = 100ms)
|
||||
#define SBP_PERIODIC_EVT_PERIOD (160 * 10 * 5) // (160 = 100ms)
|
||||
|
||||
// How often to perform read rssi event
|
||||
#define SBP_READ_RSSI_EVT_PERIOD (1600 * 3) // (160 = 100ms)
|
||||
|
@ -56,23 +60,23 @@
|
|||
#define SBP_PHY_UPDATE_DELAY (1600 * 2)
|
||||
|
||||
// What is the advertising interval when device is discoverable (units of 625us, 80=50ms)
|
||||
#define DEFAULT_ADVERTISING_INTERVAL (160 * 10)
|
||||
#define DEFAULT_ADVERTISING_INTERVAL (160 * 8)
|
||||
|
||||
// Limited discoverable mode advertises for 30.72s, and then stops
|
||||
// General discoverable mode advertises indefinitely
|
||||
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL
|
||||
|
||||
// Minimum connection interval (units of 1.25ms, 6=7.5ms)
|
||||
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL (80 * 9) // (80 = 100ms)
|
||||
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL (80 * 4) // (80 = 100ms)
|
||||
|
||||
// Maximum connection interval (units of 1.25ms, 100=125ms)
|
||||
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL (80 * 10)
|
||||
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL (80 * 5)
|
||||
|
||||
// Slave latency to use parameter update
|
||||
#define DEFAULT_DESIRED_SLAVE_LATENCY 3
|
||||
#define DEFAULT_DESIRED_SLAVE_LATENCY 0
|
||||
|
||||
// Supervision timeout value (units of 10ms, 100=1s)
|
||||
#define DEFAULT_DESIRED_CONN_TIMEOUT (100 * 5)
|
||||
#define DEFAULT_DESIRED_CONN_TIMEOUT (100 * 2)
|
||||
|
||||
// Company Identifier: WCH
|
||||
#define WCH_COMPANY_ID 0x07D7
|
||||
|
@ -81,7 +85,7 @@
|
|||
// TYQ-93:B4:8F:10:53:5C
|
||||
#define MAC_NAME_LEN 22
|
||||
|
||||
static uint8_t Peripheral_TaskID = INVALID_TASK_ID; // Task ID for internal task/event processing
|
||||
uint8_t Peripheral_TaskID = INVALID_TASK_ID; // Task ID for internal task/event processing
|
||||
|
||||
// 蓝牙广播包的最大长度是37个字节,其中设备地址占用了6个字节,只有31个字节是可用的。
|
||||
// TODO:响应体,名称加上MAC地址
|
||||
|
@ -351,16 +355,30 @@ uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events)
|
|||
|
||||
return (events ^ SBP_START_DEVICE_EVT);
|
||||
}
|
||||
if (events & SBP_REPLY_CMD_EVT)
|
||||
{
|
||||
logDebug("SBP_REPLY_CMD_EVT");
|
||||
|
||||
peripheralChar4Notify((uint8_t *)&RelyData.buf[0], RelyData.len);
|
||||
|
||||
BSP_NoNeeedReplyCMd();
|
||||
return (events ^ SBP_REPLY_CMD_EVT);
|
||||
}
|
||||
if (events & SBP_PERIODIC_EVT)
|
||||
{
|
||||
// Restart timer
|
||||
if (SBP_PERIODIC_EVT_PERIOD)
|
||||
// 防止主机下发指令,从机回复响应的时候,先传的是状态数据
|
||||
if (periodic_upload_block_flag == false && mtu_flag == 1)
|
||||
{
|
||||
// Perform periodic application task
|
||||
performPeriodicTask();
|
||||
// Restart timer
|
||||
tmos_start_task(Peripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD);
|
||||
}
|
||||
// Perform periodic application task
|
||||
performPeriodicTask();
|
||||
else
|
||||
{
|
||||
// 需要等先回复了下发的指令,1s 之后再尝试回复状态数据
|
||||
tmos_start_task(Peripheral_TaskID, SBP_PERIODIC_EVT, 1600 * 1);
|
||||
}
|
||||
return (events ^ SBP_PERIODIC_EVT);
|
||||
}
|
||||
|
||||
|
@ -456,7 +474,7 @@ static void Peripheral_ProcessTMOSMsg(tmos_event_hdr_t *pMsg)
|
|||
if (pMsgEvent->method == ATT_MTU_UPDATED_EVENT)
|
||||
{
|
||||
peripheralMTU = pMsgEvent->msg.exchangeMTUReq.clientRxMTU;
|
||||
mtu_flag = 1;
|
||||
mtu_flag = 1;
|
||||
logDebug("****mtu exchange: %d****", pMsgEvent->msg.exchangeMTUReq.clientRxMTU);
|
||||
}
|
||||
break;
|
||||
|
@ -563,7 +581,8 @@ static void Peripheral_LinkTerminated(gapRoleEvent_t *pEvent)
|
|||
*/
|
||||
static void peripheralRssiCB(uint16_t connHandle, int8_t rssi)
|
||||
{
|
||||
logDebug("RSSI -%d dB Conn %x ", -rssi, connHandle);
|
||||
gValveData.rssi = rssi;
|
||||
logDebug("RSSI %d dB Conn %x ", gValveData.rssi, connHandle);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -587,8 +606,7 @@ static void peripheralParamUpdateCB(uint16_t connHandle, uint16_t connInterval,
|
|||
peripheralConnList.connSlaveLatency = connSlaveLatency;
|
||||
peripheralConnList.connTimeout = connTimeout;
|
||||
|
||||
logDebug("ParamUpdateCB (Handle)%x - (connInt 0x%x=%.1fms) - (connSlaveLatency) %x - (connTimeout 0x%x=%dms) "
|
||||
, connHandle, connInterval, connInterval * 1.25, connSlaveLatency, connTimeout * 10, connTimeout * 10);
|
||||
logDebug("ParamUpdateCB (Handle)%x - (connInt 0x%x=%.1fms) - (connSlaveLatency) %x - (connTimeout 0x%x=%dms) ", connHandle, connInterval, connInterval * 1.25, connSlaveLatency, connTimeout * 10, connTimeout * 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -634,7 +652,9 @@ static void peripheralStateNotificationCB(gapRole_States_t newState, gapRoleEven
|
|||
|
||||
// 在蓝牙建立连接之后,调用 GATT ExchangeMTU 来修改 MTU 的值
|
||||
// Update MTU
|
||||
attExchangeMTUReq_t req = {.clientRxMTU = BLE_BUFF_MAX_LEN - 4,};
|
||||
attExchangeMTUReq_t req = {
|
||||
.clientRxMTU = BLE_BUFF_MAX_LEN - 4,
|
||||
};
|
||||
GATT_ExchangeMTU(peripheralConnList.connHandle, &req, Peripheral_TaskID);
|
||||
// Peripheral_SetMacName();
|
||||
}
|
||||
|
@ -699,65 +719,28 @@ static void peripheralStateNotificationCB(gapRole_States_t newState, gapRoleEven
|
|||
*/
|
||||
static void performPeriodicTask(void)
|
||||
{
|
||||
if (mtu_flag)
|
||||
gValveData.bat = BSP_ReadVbat();
|
||||
|
||||
float _humi, _temp;
|
||||
if (BSP_ReadTempHumi(&_humi, &_temp) == 0)
|
||||
{
|
||||
// 温度
|
||||
uint32_t countadc = 0;
|
||||
// VBAT
|
||||
uint32_t CountBat = 0;
|
||||
uint16_t adcBuff[40];
|
||||
uint8_t i = 0;
|
||||
// uint32_t countadc = 0;
|
||||
uint16_t min_number = 0;
|
||||
uint16_t max_number = 0;
|
||||
|
||||
ADC_InterBATSampInit();
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
adcBuff[i] = ADC_ExcutSingleConver(); // 连续采样20次
|
||||
}
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
CountBat += adcBuff[i];
|
||||
if (i == 0)
|
||||
{
|
||||
min_number = adcBuff[i];
|
||||
max_number = adcBuff[i];
|
||||
}
|
||||
min_number = ((min_number > adcBuff[i]) ? adcBuff[i] : min_number); // 软件滤波
|
||||
max_number = ((max_number < adcBuff[i]) ? adcBuff[i] : max_number);
|
||||
}
|
||||
logDebug("min_number = %d, max_number = %d", min_number, max_number);
|
||||
CountBat = (CountBat - min_number - max_number) / 18; // 删除最小与最大值
|
||||
logDebug("AverageCountBat = %d", CountBat);
|
||||
|
||||
|
||||
int ret;
|
||||
|
||||
GXHTC3C_Wakeup();
|
||||
DelayMs(20);
|
||||
|
||||
GXHTC3C_GetStart();
|
||||
DelayMs(20);
|
||||
float humi, temp;
|
||||
ret = GXHTC3C_GetTempHumi(&humi, &temp);
|
||||
if (ret == 0)
|
||||
{
|
||||
logDebug("humi %.2f %, temp %.2f C", humi, temp);
|
||||
}
|
||||
|
||||
GXHTC3C_Sleep();
|
||||
|
||||
TsRawFrameData RawData;
|
||||
// static uint8_t humi;
|
||||
// humi++;
|
||||
BSP_VALVE_Generate_Data(&RawData, 0, CountBat / 100, temp, humi);
|
||||
// if (humi > 99)
|
||||
// {
|
||||
// humi = 0;
|
||||
// }
|
||||
peripheralChar4Notify(&RawData.buf[0], RawData.len);
|
||||
gValveData.temp = (int8_t)_temp;
|
||||
gValveData.humi = (uint8_t)_humi;
|
||||
}
|
||||
else
|
||||
{
|
||||
logError("Read TempHumi Err");
|
||||
return;
|
||||
}
|
||||
logDebug("switch_status:%d Temp:%d Bat:%d Humi:%d%% RSSI: %d"
|
||||
, gValveData.switch_status, gValveData.temp, gValveData.bat, gValveData.humi, gValveData.rssi);
|
||||
|
||||
|
||||
TsRawFrameData RawData;
|
||||
|
||||
BSP_VALVE_Generate_UploadData(&RawData);
|
||||
|
||||
peripheralChar4Notify(&RawData.buf[0], RawData.len);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -809,7 +792,10 @@ static void peripheralChar4Notify(uint8_t *pValue, uint16_t len)
|
|||
static void simpleProfileChangeCB(uint8_t paramID, uint8_t *pValue, uint16_t len)
|
||||
{
|
||||
// tmos_event_hdr_t *test_message;
|
||||
TsRawFrameData RawData;
|
||||
// TsRawFrameData RawData;
|
||||
|
||||
BSP_NeeedReplyCMdFirst();
|
||||
|
||||
switch (paramID)
|
||||
{
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
|
@ -820,28 +806,48 @@ static void simpleProfileChangeCB(uint8_t paramID, uint8_t *pValue, uint16_t len
|
|||
for (uint8_t i = 0; i < len; i++)
|
||||
{
|
||||
logDebug("%02x ", newValue[i]);
|
||||
BSP_UART1_TxLoop();
|
||||
// BSP_UART1_TxLoop();
|
||||
}
|
||||
logDebug("\n profile ChangeCB CHAR1.. End");
|
||||
|
||||
// test_message =(tmos_event_hdr_t*) tmos_msg_allocate(sizeof(tmos_event_hdr_t));
|
||||
BSP_UART1_TxLoop();
|
||||
// BSP_UART1_TxLoop();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
{
|
||||
uint8_t newValue[SIMPLEPROFILE_CHAR3_LEN];
|
||||
tmos_memset(newValue, 0, sizeof(newValue));
|
||||
tmos_memcpy(newValue, pValue, len);
|
||||
// uint8_t newValue[SIMPLEPROFILE_CHAR3_LEN];
|
||||
// tmos_memset(newValue, 0, sizeof(newValue));
|
||||
// tmos_memcpy(newValue, pValue, len);
|
||||
logDebug("CHAR3 Start");
|
||||
logHexDumpAll(newValue, len);
|
||||
// for (uint8_t i = 0; i < len; i++)
|
||||
// {
|
||||
// logDebug("%02x ", newValue[i]);
|
||||
// }
|
||||
#if 1
|
||||
// logHexDumpAll(newValue, len);
|
||||
// TODO:发送rev数据
|
||||
uint8_t *p_rev_msg;
|
||||
// TsValveMsg *ValveMsg;
|
||||
// ValveMsg = tmos_msg_allocate(len);
|
||||
// ValveMsg.data = tmos_msg_allocate(len);
|
||||
p_rev_msg = tmos_msg_allocate(len + 1);
|
||||
if ( p_rev_msg )
|
||||
{
|
||||
p_rev_msg[0] = len;
|
||||
tmos_memcpy(&p_rev_msg[1], pValue, len);
|
||||
int ret = tmos_msg_send(vavle_task_id, p_rev_msg);
|
||||
if (ret == SUCCESS)
|
||||
{
|
||||
logDebug("p_rev_msg send ret = %d", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
logError("p_rev_msg send ret = %d", ret);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logError("内存不足");
|
||||
}
|
||||
#if 0
|
||||
TsFrameData *HostFrameData = BSP_VAVLE_GetFrameData(newValue, len);
|
||||
if (HostFrameData != NULL)
|
||||
{
|
||||
|
@ -858,15 +864,28 @@ static void simpleProfileChangeCB(uint8_t paramID, uint8_t *pValue, uint16_t len
|
|||
break;
|
||||
case kCmdCloseVavle:
|
||||
logDebug("kCmdCloseVavle");
|
||||
BSP_VALVE_Generate_ValveResponse(&RawData, kCmdCloseVavle, 1);
|
||||
peripheralChar4Notify((uint8_t *)&RawData.buf[0], RawData.len);
|
||||
BSP_UART1_TxLoop();
|
||||
|
||||
// TODO:注意这里
|
||||
BSP_NeeedReplyCMdFirst();
|
||||
|
||||
// EMV_CHARGE
|
||||
EMV_CHARGE_EN;
|
||||
logDebug("EMV_CHARGE_EN");
|
||||
|
||||
// 开始一个定时event,1s后产生,当前语句只会产生一次event
|
||||
// 可以在event产生后去开启event,可以是别的task的,也可以是当前task的event
|
||||
tmos_start_task(vavle_task_id, VAVLE_CLOSE_ACTION_EVT, MS1_TO_SYSTEM_TIME(CHARGE_TIME_MS));
|
||||
|
||||
// BSP_VALVE_Generate_ValveResponse(&RawData, kCmdCloseVavle, 1);
|
||||
// // TODO: 关阀动作
|
||||
// peripheralChar4Notify((uint8_t *)&RawData.buf[0], RawData.len);
|
||||
break;
|
||||
|
||||
case kCmdOpenVavle:
|
||||
logDebug("kCmdOpenVavle");
|
||||
BSP_VALVE_Generate_ValveResponse(&RawData, kCmdOpenVavle, 1);
|
||||
peripheralChar4Notify((uint8_t *)&RawData.buf[0], RawData.len);
|
||||
BSP_UART1_TxLoop();
|
||||
// BSP_UART1_TxLoop();
|
||||
break;
|
||||
default:
|
||||
logError("无效的命令");
|
||||
|
@ -891,9 +910,6 @@ static void simpleProfileChangeCB(uint8_t paramID, uint8_t *pValue, uint16_t len
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
|
@ -908,9 +924,6 @@ void Peripheral_UpdateAdvertData(uint8_t adType, uint8_t dataLen, uint8_t *pAdve
|
|||
GAP_UpdateAdvertisingData(Peripheral_TaskID, adType, dataLen, pAdvertData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdarg.h"
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "bsp_iwdg.h"
|
||||
#include "bsp_flash.h"
|
||||
|
||||
#include "bsp_valve.h"
|
||||
|
||||
|
||||
#undef LOG_ENABLE
|
||||
#define LOG_ENABLE 1
|
||||
|
@ -39,14 +41,31 @@
|
|||
|
||||
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
|
||||
|
||||
static uint8_t key_cnt = 0;
|
||||
void app_task_handler(TeAppEvtType app_evt_type)
|
||||
{
|
||||
switch(app_evt_type)
|
||||
{
|
||||
case kKeyShort:{
|
||||
case kKeyShort:
|
||||
logDebug("button short press");
|
||||
key_cnt++;
|
||||
if (key_cnt == 1)
|
||||
{
|
||||
// TODO:LED显示状态
|
||||
}
|
||||
else if (key_cnt == 2)
|
||||
{
|
||||
if (gValveData.switch_status == kClosed)
|
||||
{
|
||||
gValveData.switch_status = kOpened;
|
||||
}
|
||||
else if (gValveData.switch_status == kOpened)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kKeyLong:
|
||||
logDebug("button long press");
|
||||
|
||||
|
@ -54,6 +73,7 @@ void app_task_handler(TeAppEvtType app_evt_type)
|
|||
case kKeyRelease:
|
||||
// BSP_KEY_EnterLowpower();
|
||||
// DelayMs(10);
|
||||
key_cnt = 0;
|
||||
BSP_RequestSleep();
|
||||
logDebug("gpio relase;BSP_RequestSleep");
|
||||
|
||||
|
@ -199,7 +219,7 @@ int main(void)
|
|||
EMV_CHARGE_OFF_DEINIT;
|
||||
EMV_OFF_DEINIT;
|
||||
|
||||
BSP_ADC_Init();
|
||||
// BSP_ADC_Init();
|
||||
CH59x_BLEInit();
|
||||
|
||||
logDebug("%s\n", VER_LIB);
|
||||
|
@ -231,6 +251,8 @@ int main(void)
|
|||
|
||||
// IWDG_Init(1500);
|
||||
|
||||
BSP_VAVLE_Init();
|
||||
|
||||
Main_Circulation();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "CONFIG.h"
|
||||
|
||||
uint8_t BSP_ReadVbat(void);
|
||||
|
||||
void BSP_ADC_Init(void);
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* @Author : stark1898y 1658608470@qq.com
|
||||
* @Date : 2024-12-15 15:42:00
|
||||
* @LastEditors : stark1898y 1658608470@qq.com
|
||||
* @LastEditTime : 2024-12-15 15:42:00
|
||||
* @FilePath : \BLE_TYQ_CH592F - 副本\BSP\inc\bsp_i2c.h
|
||||
* @LastEditTime : 2024-12-16 20:50:17
|
||||
* @FilePath : \BLE_TYQ_CH592F\BSP\inc\bsp_i2c.h
|
||||
* @Description :
|
||||
*
|
||||
* Copyright (c) 2024 by yzy, All Rights Reserved.
|
||||
|
@ -138,6 +138,7 @@ void BSP_I2C_DeInit(void);
|
|||
|
||||
void GXHTC3C_Init(void);
|
||||
|
||||
int BSP_ReadTempHumi(float *humi, float *temp);
|
||||
|
||||
#endif // !__BSP_I2C_H__
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @Author : stark1898y 1658608470@qq.com
|
||||
* @Date : 2024-12-12 15:55:38
|
||||
* @LastEditors : stark1898y 1658608470@qq.com
|
||||
* @LastEditTime : 2024-12-15 10:40:07
|
||||
* @LastEditTime : 2024-12-16 21:00:37
|
||||
* @FilePath : \BLE_TYQ_CH592F\BSP\inc\bsp_valve.h
|
||||
* @Description :
|
||||
*
|
||||
|
@ -13,11 +13,16 @@
|
|||
|
||||
#include "CONFIG.h"
|
||||
|
||||
extern tmosTaskID vavle_task_id;
|
||||
|
||||
|
||||
#define VAVLE_RX_DATA_EVT (0x0001 << 0)
|
||||
#define VAVLE_TX_DATA_EVT (0x0001 << 1)
|
||||
|
||||
#define VAVLE_CLOSE_START_EVT (0x0001 << 2) // 关阀,开始充电
|
||||
#define VAVLE_CLOSE_END_EVT (0x0001 << 2) // 关阀,开始充电
|
||||
#define VAVLE_CLOSE_ACTION_EVT (0x0001 << 3) // 关阀,动作
|
||||
#define VAVLE_CLOSE_END_EVT (0x0001 << 4) // 关阀结束
|
||||
|
||||
|
||||
#define CHARGE_TIME_MS 1000
|
||||
|
||||
|
@ -35,11 +40,6 @@ typedef enum
|
|||
kCmdData,
|
||||
} TeFrameCmd;
|
||||
|
||||
// typedef enum
|
||||
// {
|
||||
|
||||
// } TeCmdIndex;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
TeFrameCmd cmd; // CMD/DATA
|
||||
|
@ -51,9 +51,11 @@ typedef struct __attribute__((packed))
|
|||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t len;
|
||||
uint8_t buf[128];
|
||||
uint8_t buf[64];
|
||||
} TsRawFrameData;
|
||||
|
||||
extern TsRawFrameData RelyData;
|
||||
|
||||
// 阀门类型
|
||||
typedef enum
|
||||
{
|
||||
|
@ -62,31 +64,41 @@ typedef enum
|
|||
kDcf,
|
||||
} TeVavleType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kUnknown = 0,
|
||||
kClosed,
|
||||
kOpened,
|
||||
} TeValveSwitchStatus;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// uint8_t status; // 1B 阀门工作状态 超欠压、过流
|
||||
// uint8_t connct_status; // 1B 阀门连接状态 (电磁阀BLE控制盒) 0=未连接 1=已连接
|
||||
uint8_t switch_status; // 1B 阀门开关状态 0=未知 1=关闭 2=关闭过,未按按键恢复 3=关闭过,按下了恢复键 4=打开
|
||||
uint8_t switch_status; // 1B 阀门开关状态 0=未知 1=关闭=关闭过,未按按键恢复 2=关闭过,按下了恢复键 = 打开
|
||||
int8_t temp; // 1B 阀门温度 有符号整数 25 ℃
|
||||
|
||||
uint32_t in_pressure; // 4B 阀门入口压力 Pa
|
||||
uint32_t out_pressure; // 4B 阀门出口压力 Pa
|
||||
uint32_t atm_pressure; // 4B 阀门大气压力 Pa
|
||||
uint8_t type; // 阀门类型
|
||||
uint8_t type; // 阀门类型
|
||||
uint8_t bat; // 1B 电池电压 30=3V,18=1.8V
|
||||
uint8_t hum; // 1B 阀门湿度 %RH
|
||||
uint8_t rssi;
|
||||
uint8_t humi; // 1B 阀门湿度 %RH
|
||||
int8_t rssi;
|
||||
} TsValveData;
|
||||
extern TsValveData gValveData;
|
||||
|
||||
uint8_t CheckSum(const uint8_t *data, size_t len);
|
||||
|
||||
void BSP_VAVLE_Init(void);
|
||||
|
||||
TsFrameData* BSP_VAVLE_GetFrameData(uint8_t *data, uint16_t len);
|
||||
TsFrameData* BSP_VAVLE_GetFrameData(uint8_t *data, uint8_t len);
|
||||
|
||||
uint8_t GenerateRawFrame(TsRawFrameData *pRawData, uint8_t cmd, const uint8_t *p_src, uint8_t src_len);
|
||||
|
||||
void BSP_VALVE_Generate_Data(TsRawFrameData *pRawData, uint8_t switch_status, uint8_t bat, int8_t temp, uint8_t hum);
|
||||
void BSP_VALVE_Generate_Data(TsRawFrameData *pRawData, uint8_t switch_status, uint8_t bat, int8_t temp, uint8_t humi);
|
||||
void BSP_VALVE_Generate_ValveResponse(TsRawFrameData *pRawData, TeFrameCmd cmd, uint8_t status);
|
||||
|
||||
void BSP_VALVE_Generate_UploadData(TsRawFrameData *pRawData);
|
||||
|
||||
#endif // ! __BSP_VALVE_H__
|
||||
|
|
|
@ -25,28 +25,9 @@ uint16_t min_number = 0;
|
|||
uint16_t max_number = 0;
|
||||
double voltage = 0;
|
||||
|
||||
void BSP_ADC_Init(void)
|
||||
uint8_t BSP_ReadVbat(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
#if 0
|
||||
// ±10C,没啥参考价值
|
||||
/* 温度采样并输出 */
|
||||
logDebug("\n1.Temperature sampling...\n");
|
||||
ADC_InterTSSampInit();
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
adcBuff[i] = ADC_ExcutSingleConver(); // 连续采样20次
|
||||
}
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
uint32_t C25 = 0;
|
||||
C25 = (*((PUINT32)ROM_CFG_TMP_25C));
|
||||
logDebug("%d %d %d \n", adc_to_temperature_celsius(adcBuff[i]), adcBuff[i], C25);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
// VBAT
|
||||
uint32_t CountBat = 0;
|
||||
ADC_InterBATSampInit();
|
||||
|
@ -67,8 +48,38 @@ void BSP_ADC_Init(void)
|
|||
}
|
||||
logDebug("min_number = %d, max_number = %d", min_number, max_number);
|
||||
CountBat = (CountBat - min_number - max_number) / 18; // 删除最小与最大值
|
||||
logDebug("AverageCountBat = %d", CountBat);
|
||||
uint8_t vbat = (uint8_t)(CountBat / 100);
|
||||
logDebug("AverageCountBat = %dmV, vbat = %d(100mV)", CountBat, vbat);
|
||||
|
||||
//缩小到100mV
|
||||
return vbat;
|
||||
}
|
||||
|
||||
void BSP_ADC_Init(void)
|
||||
{
|
||||
#if 1
|
||||
// logDebug();
|
||||
#endif
|
||||
logDebug("ADC init");
|
||||
|
||||
#if 0
|
||||
// ±10C,没啥参考价值
|
||||
/* 温度采样并输出 */
|
||||
logDebug("\n1.Temperature sampling...\n");
|
||||
ADC_InterTSSampInit();
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
adcBuff[i] = ADC_ExcutSingleConver(); // 连续采样20次
|
||||
}
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
uint32_t C25 = 0;
|
||||
C25 = (*((PUINT32)ROM_CFG_TMP_25C));
|
||||
logDebug("%d %d %d \n", adc_to_temperature_celsius(adcBuff[i]), adcBuff[i], C25);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
// 默认情况下,ADC 引脚和所在 GPIO 引脚的数字功能是同时存在的
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "bsp_uart.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "bsp_valve.h"
|
||||
|
||||
#undef LOG_ENABLE
|
||||
#define LOG_ENABLE 1
|
||||
|
||||
|
@ -380,6 +382,7 @@ uint8_t GXHTC3C_GetTempHumi(float *humi, float *temp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void GXHTC3C_Read(void)
|
||||
{
|
||||
int ret;
|
||||
|
@ -399,6 +402,31 @@ void GXHTC3C_Read(void)
|
|||
|
||||
GXHTC3C_Sleep();
|
||||
}
|
||||
#endif
|
||||
|
||||
int BSP_ReadTempHumi(float *humi, float *temp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
GXHTC3C_Wakeup();
|
||||
DelayMs(1);
|
||||
|
||||
GXHTC3C_GetStart();
|
||||
DelayMs(3);
|
||||
float _humi, _temp;
|
||||
ret = GXHTC3C_GetTempHumi(&_humi, &_temp);
|
||||
if (ret == 0)
|
||||
{
|
||||
*humi = _humi;
|
||||
*temp = _temp;
|
||||
// gValveData.temp = (int8_t)temp;
|
||||
// gValveData.humi = (uint8_t)humi;
|
||||
logDebug("humi %.2f %, temp %.2f C", *humi, *temp);
|
||||
}
|
||||
GXHTC3C_Sleep();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void GXHTC3C_Init(void)
|
||||
{
|
||||
|
@ -407,26 +435,9 @@ void GXHTC3C_Init(void)
|
|||
int ret;
|
||||
|
||||
GXHTC3C_Sleep();
|
||||
DelayMs(100);
|
||||
|
||||
GXHTC3C_Wakeup();
|
||||
DelayMs(20);
|
||||
|
||||
GXHTC3C_GetStart();
|
||||
DelayMs(20);
|
||||
float humi, temp;
|
||||
ret = GXHTC3C_GetTempHumi(&humi, &temp);
|
||||
if (ret == 0)
|
||||
{
|
||||
// logDebug("humi %.2f %, temp %.2f C", humi, temp);
|
||||
}
|
||||
|
||||
GXHTC3C_Sleep();
|
||||
|
||||
for (uint8_t i = 0; i < 3; i++)
|
||||
{
|
||||
GXHTC3C_Read();
|
||||
}
|
||||
float _humi, _temp;
|
||||
BSP_ReadTempHumi(&_humi, &_temp);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -2,22 +2,12 @@
|
|||
* @Author : stark1898y 1658608470@qq.com
|
||||
* @Date : 2024-12-15 15:01:15
|
||||
* @LastEditors : stark1898y 1658608470@qq.com
|
||||
* @LastEditTime : 2024-12-15 16:31:46
|
||||
* @FilePath : \BLE_TYQ_CH592F - 副本\BSP\src\bsp_valve.c
|
||||
* @LastEditTime : 2024-12-16 21:11:32
|
||||
* @FilePath : \BLE_TYQ_CH592F\BSP\src\bsp_valve.c
|
||||
* @Description :
|
||||
*
|
||||
* Copyright (c) 2024 by yzy, All Rights Reserved.
|
||||
*/
|
||||
/*
|
||||
* @Author: mbw
|
||||
* @Date: 2024-12-09 11:40:10
|
||||
* @LastEditors: mbw && 1600520629@qq.com
|
||||
* @LastEditTime: 2024-12-11 15:43:47
|
||||
* @FilePath: \ble_-tyq_-bjq_-ch584-m\bsp\src\bsp_valve.c
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
||||
*/
|
||||
#include "bsp_valve.h"
|
||||
#include "bsp_flash.h"
|
||||
|
||||
|
@ -27,15 +17,20 @@
|
|||
#include "bsp_uart.h"
|
||||
#include "log.h"
|
||||
|
||||
#undef LOG_ENABLE
|
||||
#define LOG_ENABLE 0
|
||||
#include "peripheral.h"
|
||||
|
||||
#undef LOG_ENABLE
|
||||
#define LOG_ENABLE 1
|
||||
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "BSP_VALVE"
|
||||
|
||||
//存储 当前task id 的全局变量
|
||||
tmosTaskID vavle_task_id = INVALID_TASK_ID;
|
||||
TsValveData gValveData = {0};
|
||||
|
||||
TsRawFrameData RelyData;
|
||||
|
||||
// 存储 当前task id 的全局变量
|
||||
tmosTaskID vavle_task_id = INVALID_TASK_ID;
|
||||
|
||||
/**
|
||||
* @description: 从帧起始符开始到校验码之前所有字节的和的模256,即各字节不计超过255的溢出值的二进制算术和。
|
||||
|
@ -110,10 +105,10 @@ TsFrameData *HR_GetFrameData(const uint8_t *p_src, const uint8_t src_len)
|
|||
}
|
||||
#endif
|
||||
|
||||
TsFrameData* BSP_VAVLE_GetFrameData(uint8_t *data, uint16_t len)
|
||||
TsFrameData *BSP_VAVLE_GetFrameData(uint8_t *data, uint8_t len)
|
||||
{
|
||||
int ret = 0;
|
||||
uint16_t index = 0;
|
||||
int ret = 0;
|
||||
uint16_t index = 0;
|
||||
|
||||
TsFrameData *get_buffer = NULL;
|
||||
// 解析接收到的数据帧,先寻找AA开头,然后再找AA下一个字节,其代表了数据长度,然后找到代表长度的值的长度的下一位,其为校验码,校验码后为结束码0x55,
|
||||
|
@ -145,8 +140,8 @@ TsFrameData* BSP_VAVLE_GetFrameData(uint8_t *data, uint16_t len)
|
|||
// return 3;
|
||||
}
|
||||
|
||||
uint8_t check_sum = data[index + 3 + data_len]; // 读取校验码
|
||||
uint8_t calculated_sum = CheckSum(&data[index], data_len + 3); // 计算校验码
|
||||
uint8_t check_sum = data[index + 3 + data_len]; // 读取校验码
|
||||
uint8_t calculated_sum = CheckSum(&data[index], data_len + 3); // 计算校验码
|
||||
if (check_sum != calculated_sum)
|
||||
{
|
||||
logError("数据帧校验码错误 check_sum = %02X, calculated_sum = %02X", check_sum, calculated_sum);
|
||||
|
@ -170,9 +165,9 @@ TsFrameData* BSP_VAVLE_GetFrameData(uint8_t *data, uint16_t len)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
get_buffer->cmd = data[index + 1];
|
||||
get_buffer->cmd = data[index + 1];
|
||||
get_buffer->len = data_len;
|
||||
// get_buffer->data = data;
|
||||
// get_buffer->data = data;
|
||||
|
||||
if (data_len > 0)
|
||||
{
|
||||
|
@ -216,73 +211,111 @@ uint8_t GenerateRawFrame(TsRawFrameData *pRawData, uint8_t cmd, const uint8_t *p
|
|||
return 0;
|
||||
}
|
||||
|
||||
void BSP_VALVE_Generate_Data(TsRawFrameData *pRawData, uint8_t switch_status, uint8_t bat, int8_t temp, uint8_t hum)
|
||||
void BSP_VALVE_Generate_UploadData(TsRawFrameData *pRawData)
|
||||
{
|
||||
GenerateRawFrame(pRawData, kCmdData, (uint8_t *)&gValveData, sizeof(gValveData));
|
||||
// logHexDumpAll(&pRawData->buf[0], pRawData->len);
|
||||
}
|
||||
|
||||
void BSP_VALVE_Generate_Data(TsRawFrameData *pRawData, uint8_t switch_status, uint8_t bat, int8_t temp, uint8_t humi)
|
||||
{
|
||||
TsValveData ValveData;
|
||||
|
||||
ValveData.switch_status = 0;
|
||||
ValveData.temp = temp; // 阀门温度 有符号整数 25 ℃
|
||||
ValveData.temp = temp; // 阀门温度 有符号整数 25 ℃
|
||||
|
||||
ValveData.in_pressure = 1.6 * 1000000;
|
||||
ValveData.out_pressure = 3000;
|
||||
ValveData.atm_pressure = 96000;
|
||||
ValveData.in_pressure = 0;
|
||||
ValveData.out_pressure = 0;
|
||||
ValveData.atm_pressure = 0;
|
||||
|
||||
ValveData.type = kTyq; // 阀门类型
|
||||
ValveData.bat = bat; // 电池电压 30=3V,18=1.8V
|
||||
ValveData.hum = hum; // 阀门湿度 %RH
|
||||
ValveData.type = kTyq; // 阀门类型
|
||||
ValveData.bat = bat; // 电池电压 30=3V,18=1.8V
|
||||
ValveData.humi = humi; // 阀门湿度 %RH
|
||||
|
||||
ValveData.rssi = 0;
|
||||
|
||||
GenerateRawFrame(pRawData, kCmdData, (uint8_t*)&ValveData, sizeof(ValveData));
|
||||
GenerateRawFrame(pRawData, kCmdData, (uint8_t *)&ValveData, sizeof(ValveData));
|
||||
// logHexDumpAll(&pRawData->buf[0], pRawData->len);
|
||||
}
|
||||
|
||||
void BSP_VALVE_Generate_ValveResponse(TsRawFrameData *pRawData, TeFrameCmd cmd, uint8_t status)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
data = status;
|
||||
data = status;
|
||||
GenerateRawFrame(pRawData, cmd, &data, 1);
|
||||
// logHexDumpAll(&pRawData->buf[0], pRawData->len);
|
||||
}
|
||||
|
||||
void BSP_CloseValve(void)
|
||||
{
|
||||
// EMV_CHARGE
|
||||
EMV_CHARGE_EN;
|
||||
logDebug("EMV_CHARGE_EN");
|
||||
|
||||
DelayMs(1000);
|
||||
|
||||
EMV_CHARGE_OFF_DEINIT;
|
||||
logDebug("EMV_CHARGE_OFF_DEINIT 500 ms");
|
||||
|
||||
// EMV_CTRL
|
||||
EMV_ON;
|
||||
logDebug("EMV_ON\n");
|
||||
DelayMs(100);
|
||||
}
|
||||
|
||||
static void VAVLE_Task_ProcessTmosMsg(tmos_event_hdr_t *pMsg)
|
||||
static void VAVLE_Task_ProcessTmosMsg(uint8_t *p_rev_msg)
|
||||
{
|
||||
switch (pMsg->event)
|
||||
if (p_rev_msg)
|
||||
{
|
||||
default:
|
||||
logDebug("pMsg->event %04x", pMsg->event);
|
||||
break;
|
||||
#if 1
|
||||
TsFrameData *HostFrameData = BSP_VAVLE_GetFrameData(&p_rev_msg[1], p_rev_msg[0]);
|
||||
if (HostFrameData != NULL)
|
||||
{
|
||||
// logHexDumpAll(&HostFrameData->data[0], HostFrameData->len); // 数据段
|
||||
switch (HostFrameData->cmd)
|
||||
{
|
||||
case kCmdCfg:
|
||||
// uint8_t data_buf[64] = {0};
|
||||
// tmos_memset(data_buf, 0, sizeof(data_buf));
|
||||
// 处理数据帧
|
||||
logDebug("kCmdCfg");
|
||||
break;
|
||||
case kCmdCloseVavle:
|
||||
logDebug("kCmdCloseVavle");
|
||||
tmos_set_event(vavle_task_id, VAVLE_CLOSE_START_EVT);
|
||||
|
||||
// TODO:注意这里
|
||||
|
||||
// tmos_set_event(vavle_task_id, VAVLE_CLOSE_START_EVT);
|
||||
// // TODO: 关阀动作
|
||||
// peripheralChar4Notify((uint8_t *)&RawData.buf[0], RawData.len);
|
||||
break;
|
||||
|
||||
case kCmdOpenVavle:
|
||||
logDebug("kCmdOpenVavle");
|
||||
|
||||
// BSP_UART1_TxLoop();
|
||||
break;
|
||||
default:
|
||||
logError("无效的命令");
|
||||
// logHexDumpAll(data, len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logError("数据帧解析失败");
|
||||
}
|
||||
tmos_msg_deallocate((uint8_t *)HostFrameData);
|
||||
HostFrameData = NULL;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
logError("pMsg is NULL");
|
||||
}
|
||||
}
|
||||
|
||||
//task的event处理回调函数,需要在注册task时候,传进去
|
||||
static uint16_t VAVLE_Task_ProcessEvent( uint8_t task_id, uint16_t events )
|
||||
// task的event处理回调函数,需要在注册task时候,传进去
|
||||
static uint16_t VAVLE_Task_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||
{
|
||||
if (events & SYS_EVENT_MSG)
|
||||
{
|
||||
uint8_t *pMsg;
|
||||
if ((pMsg = tmos_msg_receive(vavle_task_id)) != NULL)
|
||||
uint8_t *p_rev_msg;
|
||||
if ((p_rev_msg = tmos_msg_receive(vavle_task_id)) != NULL)
|
||||
{
|
||||
VAVLE_Task_ProcessTmosMsg((tmos_event_hdr_t *)pMsg);
|
||||
VAVLE_Task_ProcessTmosMsg(p_rev_msg);
|
||||
// Release the TMOS message
|
||||
tmos_msg_deallocate(pMsg);
|
||||
tmos_msg_deallocate(p_rev_msg);
|
||||
}
|
||||
// return unprocessed events
|
||||
return (events ^ SYS_EVENT_MSG);
|
||||
|
@ -303,15 +336,48 @@ static uint16_t VAVLE_Task_ProcessEvent( uint8_t task_id, uint16_t events )
|
|||
{
|
||||
logDebug("VAVLE_CLOSE_START_EVT");
|
||||
|
||||
//开始一个定时event,1s后产生,当前语句只会产生一次event
|
||||
//可以在event产生后去开启event,可以是别的task的,也可以是当前task的event
|
||||
tmos_start_task(vavle_task_id, VAVLE_CLOSE_END_EVT, MS1_TO_SYSTEM_TIME(CHARGE_TIME_MS));
|
||||
BOOST_EN;
|
||||
DelayMs(1);
|
||||
|
||||
// EMV_CHARGE
|
||||
EMV_CHARGE_EN;
|
||||
logDebug("EMV_CHARGE_EN");
|
||||
|
||||
// 开始一个定时event,1s后产生,当前语句只会产生一次event
|
||||
// 可以在event产生后去开启event,可以是别的task的,也可以是当前task的event
|
||||
tmos_start_task(vavle_task_id, VAVLE_CLOSE_ACTION_EVT, MS1_TO_SYSTEM_TIME(CHARGE_TIME_MS));
|
||||
|
||||
return (events ^ VAVLE_CLOSE_START_EVT);
|
||||
}
|
||||
if (events & VAVLE_CLOSE_ACTION_EVT)
|
||||
{
|
||||
logDebug("VAVLE_CLOSE_ACTION_EVT");
|
||||
// 关阀动作
|
||||
EMV_CHARGE_OFF_DEINIT;
|
||||
logDebug("EMV_CHARGE_OFF_DEINIT");
|
||||
|
||||
// EMV_CTRL
|
||||
EMV_ON;
|
||||
logDebug("EMV_ON");
|
||||
tmos_start_task(vavle_task_id, VAVLE_CLOSE_END_EVT, MS1_TO_SYSTEM_TIME(100));
|
||||
|
||||
return (events ^ VAVLE_CLOSE_ACTION_EVT);
|
||||
}
|
||||
if (events & VAVLE_CLOSE_END_EVT)
|
||||
{
|
||||
gValveData.switch_status = kClosed;
|
||||
|
||||
tmos_memset(&RelyData, 0, sizeof(RelyData));
|
||||
BSP_VALVE_Generate_ValveResponse(&RelyData, kCmdCloseVavle, 1);
|
||||
|
||||
|
||||
|
||||
tmos_set_event(Peripheral_TaskID, SBP_REPLY_CMD_EVT);
|
||||
|
||||
logDebug("VAVLE_CLOSE_END_EVT");
|
||||
return (events ^ VAVLE_CLOSE_END_EVT);
|
||||
}
|
||||
|
||||
// Discard unknown events
|
||||
return 0;
|
||||
}
|
||||
|
@ -320,6 +386,17 @@ void BSP_VAVLE_Init(void)
|
|||
{
|
||||
vavle_task_id = TMOS_ProcessEventRegister(VAVLE_Task_ProcessEvent);
|
||||
|
||||
tmos_memset(&gValveData, 0, sizeof(gValveData));
|
||||
|
||||
gValveData.switch_status = kUnknown;
|
||||
gValveData.temp = -100;
|
||||
gValveData.in_pressure = 0;
|
||||
gValveData.out_pressure = 0;
|
||||
gValveData.atm_pressure = 0;
|
||||
|
||||
gValveData.type = kTyq;
|
||||
gValveData.bat = 0;
|
||||
|
||||
// //立即开始一个event
|
||||
// tmos_set_event(vavle_task_id, VAVLE_RX_DATA_EVT);
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
# [BLE_TYQ_CH592F](https://gitee.com/SXDT-Embedded/ble_-tyq_-ch592-f)
|
||||
|
||||
基于“CH592EVT_V1-4”
|
||||
|
||||
|
||||

|
||||
|
||||

|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
Loading…
Reference in New Issue