diff --git a/.cproject b/.cproject
index ad4ad56..976b44e 100644
--- a/.cproject
+++ b/.cproject
@@ -1,181 +1,597 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.project b/.project
index ec429be..f22289c 100644
--- a/.project
+++ b/.project
@@ -1,37 +1,34 @@
- BLE_TYQ_CH584M
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- 1602468250279
-
- 22
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.wvproj
-
-
-
-
+ BLE_TYQ_CH584M
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
+
+
+
+ 6
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-name-matches-false-false-*.wvproj
+
+
+
+
\ No newline at end of file
diff --git a/.template b/.template
index e69de29..9298c60 100644
--- a/.template
+++ b/.template
@@ -0,0 +1,23 @@
+Vendor=WCH
+Toolchain=RISC-V
+Series=CH585
+RTOS=NoneOS
+MCU=CH584M
+Link=WCH-Link
+PeripheralVersion=1.0
+Description=
+Mcu Type=CH584/5
+Address=0x00000000
+Target Path=
+Exe Path=
+Exe Arguments=
+CLKSpeed=1
+DebugInterfaceMode=0
+Erase All=false
+Program=false
+Verify=false
+Reset=false
+SDIPrintf=false
+Disable Power Output=false
+Clear CodeFlash=false
+Disable Code-Protect=false
\ No newline at end of file
diff --git a/APP/peripheral.c b/APP/peripheral.c
index 7fa91a2..4c9a9f9 100644
--- a/APP/peripheral.c
+++ b/APP/peripheral.c
@@ -723,6 +723,7 @@ static void peripheralStateNotificationCB(gapRole_States_t newState, gapRoleEven
*/
static void performPeriodicTask(void)
{
+
gValveData.bat = BSP_ReadVbat();
BSP_BlockSleep();
@@ -759,10 +760,11 @@ static void performPeriodicTask(void)
logError("Read TempHumi Err");
return;
}
+ #if 0
logDebug("switch_status:%d Temp:%d Bat:%d Humi:%d%% RSSI: %d"
, gValveData.switch_status, gValveData.temp, gValveData.bat, gValveData.humi, gValveData.rssi);
-
+ #endif
TsRawFrameData RawData;
BSP_VALVE_Generate_UploadData(&RawData);
@@ -782,6 +784,7 @@ static void performPeriodicTask(void)
*/
static void peripheralChar4Notify(uint8_t *pValue, uint16_t len)
{
+ #if 1
attHandleValueNoti_t noti;
if (len > (peripheralMTU - 3))
{
@@ -803,6 +806,7 @@ static void peripheralChar4Notify(uint8_t *pValue, uint16_t len)
logDebug("Noti Success");
}
}
+ #endif
}
/*********************************************************************
diff --git a/APP/peripheral_main.c b/APP/peripheral_main.c
index b4f6302..134e858 100644
--- a/APP/peripheral_main.c
+++ b/APP/peripheral_main.c
@@ -129,50 +129,80 @@ void app_task_handler(TeAppEvtType app_evt_type)
// BSP_BlockSleep();
BSP_RequestBoost();
- switch (app_evt_type)
+ switch(app_evt_type)
{
- case kKeyShort:
- logDebug("button short press");
- BSP_RequestBoost();
- LED_R_ON;
-
- break;
-
- case kKeyLong:
- logDebug("button long press");
- logDebug("kOpened-->kClosed");
- gValveData.switch_status = kClosed;
- tmos_set_event(vavle_task_id, VAVLE_CLOSE_START_EVT);
-
+ case kKeyShort:
+ logDebug("button short press");
+ key_press_cnt++;
+ logDebug("key_press_cnt = %d", key_press_cnt);
+ if (key_press_cnt == 1)
+ {
+ logDebug("LED显示状态");
// tmos_set_event(led_task_id, LED_SHOW_START_EVT);
BSP_BlockSleep();
BSP_RequestBoost();
DelayMs(1);
ShowLed();
+ // tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT);
+ // tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000);
+ }
+ else if (key_press_cnt == 2)
+ {
+ if (gValveData.switch_status == kClosed)
+ {
+ logDebug("kClosed-->kOpened");
+ // tmos_set_event(led_task_id, LED_SHOW_START_EVT);
+ gValveData.switch_status = kOpened;
+ BSP_BlockSleep();
+ BSP_RequestBoost();
+ DelayMs(1);
+ ShowLed();
+ // tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT);
+ // tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000);
+ }
+ else if (gValveData.switch_status != kClosed)
+ {
+ logDebug("kOpened-->kClosed");
+ gValveData.switch_status = kClosed;
+ tmos_set_event(vavle_task_id, VAVLE_CLOSE_START_EVT);
- break;
- case kKeyRelease:
- // BSP_KEY_EnterLowpower();
- // DelayMs(10);
- key_press_cnt = 0;
- // BSP_RequestSleep();
- // tmos_set_event(led_task_id, LED_SHOW_END_EVT);
+ // tmos_set_event(led_task_id, LED_SHOW_START_EVT);
+ BSP_BlockSleep();
+ BSP_RequestBoost();
+ DelayMs(1);
+ ShowLed();
+ // tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT);
+ // tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000);
+ }
+ }
+ break;
- LED_ALL_OFF_DEINIT;
- BEEP_OFF_DEINIT;
+ case kKeyLong:
+ logDebug("button long press");
- BSP_NoNeedBoost();
- BSP_RequestSleep();
+ break;
+ case kKeyRelease:
+ // BSP_KEY_EnterLowpower();
+ // DelayMs(10);
+ key_press_cnt = 0;
+ // BSP_RequestSleep();
+ // tmos_set_event(led_task_id, LED_SHOW_END_EVT);
- logDebug("gpio relase;BSP_RequestSleep");
- break;
- default:
- break;
+ LED_ALL_OFF_DEINIT;
+ BEEP_OFF_DEINIT;
+
+ BSP_NoNeedBoost();
+ BSP_RequestSleep();
+
+ logDebug("gpio relase;BSP_RequestSleep");
+
+ break;
+ default:
+ break;
}
}
#endif
-
/*********************************************************************
* @fn Main_Circulation
*
@@ -241,13 +271,14 @@ int main(void)
logDebug("Start @ChipID=%02X\n", R8_CHIP_ID);
logError("中文测试 %2.2f", 123.456);
#endif
+
+ CH58x_BLEInit();
+
LED_R_ON;
DelayMs(500);
BSP_BEEP_LED_EMV_Init();
- CH58x_BLEInit();
-
logDebug("%s\n", VER_LIB);
uint8_t MacAddr[6];
GetMACAddress(MacAddr);
@@ -283,7 +314,7 @@ int main(void)
BSP_RequestBoost();
DelayMs(1);
ShowLed();
- // BEEP_ON;
+ BEEP_ON;
DelayMs(1000 * 1);
diff --git a/BLE_TYQ_CH584M.launch b/BLE_TYQ_CH584M.launch
new file mode 100644
index 0000000..42aa22a
--- /dev/null
+++ b/BLE_TYQ_CH584M.launch
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BLE_TYQ_CH584M.wvproj b/BLE_TYQ_CH584M.wvproj
index 02d84e6..f89e9e9 100644
Binary files a/BLE_TYQ_CH584M.wvproj and b/BLE_TYQ_CH584M.wvproj differ
diff --git a/BSP/inc/bsp_beep_led_emv.h b/BSP/inc/bsp_beep_led_emv.h
index d338d7e..0f1c1f8 100644
--- a/BSP/inc/bsp_beep_led_emv.h
+++ b/BSP/inc/bsp_beep_led_emv.h
@@ -2,7 +2,7 @@
* @Author : stark1898y 1658608470@qq.com
* @Date : 2024-12-09 09:50:56
* @LastEditors : stark1898y 1658608470@qq.com
- * @LastEditTime : 2024-12-30 10:46:06
+ * @LastEditTime : 2025-02-21 18:19:03
* @FilePath : \BLE_TYQ_CH584M\BSP\inc\bsp_beep_led_emv.h
* @Description :
*
@@ -26,34 +26,34 @@ extern tmosTaskID led_task_id;
#define HIGH_TEMP_EVT (0x0001 << 5)
-/**********************BOOST 12V_EN PB15************************ */
+/**********************BOOST 12V_EN PA1************************ */
#define BOOST_EN \
do \
{ \
- GPIOB_SetBits(GPIO_Pin_15); \
- GPIOB_ModeCfg(GPIO_Pin_15, GPIO_ModeOut_PP_5mA); \
+ GPIOA_SetBits(GPIO_Pin_1); \
+ GPIOA_ModeCfg(GPIO_Pin_1, GPIO_ModeOut_PP_5mA); \
} while (0);
#define BOOST_OFF_DEINIT \
do \
{ \
- GPIOB_ResetBits(GPIO_Pin_15); \
- GPIOB_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PD); \
+ GPIOA_ResetBits(GPIO_Pin_1); \
+ GPIOA_ModeCfg(GPIO_Pin_1, GPIO_ModeIN_PD); \
} while (0);
-/***********************BEEP PB1************************ */
+/***********************BEEP PA0************************ */
#define BEEP_ON \
do \
{ \
- GPIOB_SetBits(GPIO_Pin_1); \
- GPIOB_ModeCfg(GPIO_Pin_1, GPIO_ModeOut_PP_5mA);\
+ GPIOA_SetBits(GPIO_Pin_0); \
+ GPIOA_ModeCfg(GPIO_Pin_0, GPIO_ModeOut_PP_5mA);\
} while (0);
#define BEEP_OFF_DEINIT \
do \
{ \
- GPIOB_ResetBits(GPIO_Pin_1); \
- GPIOB_ModeCfg(GPIO_Pin_1, GPIO_ModeIN_Floating); \
+ GPIOA_ResetBits(GPIO_Pin_0); \
+ GPIOA_ModeCfg(GPIO_Pin_0, GPIO_ModeIN_Floating); \
} while (0);
/***********************LED************************ */
diff --git a/BSP/inc/bsp_key.h b/BSP/inc/bsp_key.h
index da05697..f5380e2 100644
--- a/BSP/inc/bsp_key.h
+++ b/BSP/inc/bsp_key.h
@@ -1,7 +1,7 @@
#ifndef __BSP_KEY_H__
#define __BSP_KEY_H__
-#include "CONFIG.h"
+// #include "CONFIG.h"
#include
#include
@@ -15,8 +15,9 @@
#define KEY_RELEASE_EVT (0x0001 << 2)
#define KEY_IDLE_TIMEOUT_EVT (0x0001 << 3)
-// KEY_B_PIN at PB0,low->active
+// KEY_B_PIN at PB0, low->active
#define KEY_B_PIN GPIO_Pin_0
+// #define KEY_B_PIN GPIO_Pin_0
#define IS_KEY_Vaild() ((GPIOB_ReadPortPin(KEY_B_PIN) ? 0 : 1))
diff --git a/BSP/src/bsp_adc.c b/BSP/src/bsp_adc.c
index fb7c1b9..44f7a7a 100644
--- a/BSP/src/bsp_adc.c
+++ b/BSP/src/bsp_adc.c
@@ -63,7 +63,7 @@ void BSP_ADC_Init(void)
#endif
logDebug("ADC init");
-#if 1
+#if 0
// ±10C,没啥参考价值
/* 温度采样并输出 */
logDebug("\n1.Temperature sampling...");
@@ -80,7 +80,7 @@ void BSP_ADC_Init(void)
}
#endif
-#if 1
+#if 0
// PA1
// 默认情况下,ADC 引脚和所在 GPIO 引脚的数字功能是同时存在的
diff --git a/BSP/src/bsp_key.c b/BSP/src/bsp_key.c
index d237351..c6c3baa 100644
--- a/BSP/src/bsp_key.c
+++ b/BSP/src/bsp_key.c
@@ -1,6 +1,6 @@
#include "bsp_key.h"
-#include "bsp_uart.h"
+// #include "bsp_uart.h"
#include "log.h"
#include "SLEEP.h"
@@ -116,14 +116,13 @@ void BSP_KEY_EnterLowpower(void)
// 开启GPIO的睡眠唤醒,如果需要的话
// PWR_PeriphWakeUpCfg(ENABLE, RB_SLP_GPIO_WAKE, Long_Delay);
- PWR_PeriphWakeUpCfg(ENABLE, RB_SLP_GPIO_WAKE, Long_Delay);
+ PWR_PeriphWakeUpCfg(ENABLE, RB_GPIO_WAKE_MODE | RB_SLP_GPIO_WAKE, Long_Delay);
// 开启GPIOB中断
PFIC_EnableIRQ(GPIO_B_IRQn);
BSP_RequestSleep();
#endif
-
}
__HIGH_CODE
@@ -134,7 +133,8 @@ void BSP_KEY_ExitLowpower(void)
// 关闭GPIOB中断
PFIC_DisableIRQ(GPIO_B_IRQn);
- PWR_PeriphWakeUpCfg(DISABLE, RB_SLP_GPIO_WAKE, Long_Delay);
+ PWR_PeriphWakeUpCfg(DISABLE, RB_GPIO_WAKE_MODE | RB_SLP_GPIO_WAKE, Long_Delay);
+ // PWR_PeriphWakeUpCfg(DISABLE, RB_SLP_GPIO_WAKE, Long_Delay);
#endif
}
@@ -244,23 +244,35 @@ void BSP_KEY_Init(app_task_evt_handler_t handler)
p_handler = handler;
key_task_id = TMOS_ProcessEventRegister(KEY_Task_ProcessEvent);
+ // // https://www.wch.cn/bbs/thread-98540-1.html
+ // R16_PIN_ALTERNATE |= RB_PIN_INTX;
+
// 由外部上拉电阻了
// 设置为浮空输入模式
- // GPIOB_SetBits(KEY_B_PIN);
- GPIOB_ModeCfg(KEY_B_PIN, GPIO_ModeIN_PU);
+
+ GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeIN_PU);
+
+ GPIOB_ModeCfg(GPIO_Pin_0, GPIO_ModeIN_Floating);
+ // GPIOB_ModeCfg(GPIO_Pin_1, GPIO_ModeIN_Floating);
+
#if 1
// 下降沿触发
- GPIOB_ITModeCfg(KEY_B_PIN, GPIO_ITMode_FallEdge);
+ GPIOB_ITModeCfg(GPIO_Pin_0, GPIO_ITMode_FallEdge);
+ // GPIOB_ITModeCfg(GPIO_Pin_1, GPIO_ITMode_FallEdge);
// 开启GPIO的睡眠唤醒,如果需要的话
// PWR_PeriphWakeUpCfg(ENABLE, RB_SLP_GPIO_WAKE, Long_Delay);
- PWR_PeriphWakeUpCfg(ENABLE, RB_SLP_GPIO_WAKE, Long_Delay);
+ PWR_PeriphWakeUpCfg(ENABLE, RB_GPIO_WAKE_MODE | RB_SLP_GPIO_WAKE, Long_Delay);
// 开启GPIOB中断
PFIC_EnableIRQ(GPIO_B_IRQn);
tmos_start_task(key_task_id, KEY_SCAN_EVT, MS1_TO_SYSTEM_TIME(KEY_SACN_MS));
#endif
+ DelayMs(2);
+ logDebug("BSP_KEY_Init=%d", IS_KEY_Vaild());
+ DelayMs(2);
+ logDebug("BSP_KEY_Init=%d", IS_KEY_Vaild());
}
__HIGH_CODE
@@ -296,7 +308,9 @@ void GPIOB_IRQHandler(void)
// PRINT("KEY IRQ\n");
- GPIOB_ClearITFlagBit(KEY_B_PIN);
+ // GPIOB_ClearITFlagBit(KEY_B_PIN);
+ GPIOB_ClearITFlagBit(GPIO_Pin_0);
+ // GPIOB_ClearITFlagBit(GPIO_Pin_1);
// tmos_set_event(key_task_id, KEY_SCAN_EVT);
// logDebug("KEY_ProcessLoop");
diff --git a/BSP/src/bsp_valve.c b/BSP/src/bsp_valve.c
index 2e19fd1..5b548c0 100644
--- a/BSP/src/bsp_valve.c
+++ b/BSP/src/bsp_valve.c
@@ -2,7 +2,7 @@
* @Author : stark1898y 1658608470@qq.com
* @Date : 2024-12-15 15:01:15
* @LastEditors : stark1898y 1658608470@qq.com
- * @LastEditTime : 2024-12-24 11:17:00
+ * @LastEditTime : 2025-02-22 17:20:22
* @FilePath : \BLE_TYQ_CH584M\BSP\src\bsp_valve.c
* @Description :
*
@@ -359,34 +359,35 @@ static uint16_t VAVLE_Task_ProcessEvent(uint8_t task_id, uint16_t events)
BSP_BlockSleep();
BSP_RequestBoost();
logDebug("VAVLE_CLOSE_ACTION_EVT");
- // 关阀动作,一定要先关充电的,防止其他12V用电
- // EMV_CHARGE_OFF_DEINIT;
- logDebug("EMV_CHARGE_OFF_DEINIT");
BOOST_EN;
- EMV_CHARGE_EN;
+ // EMV_CHARGE_EN;
+ // 关阀动作,一定要先关充电的,防止其他12V用电
+ EMV_CHARGE_OFF_DEINIT;
- DelayMs(10);
+ BEEP_ON;
- // BEEP_ON;
+ logDebug("EMV_CHARGE_OFF_DEINIT");
+
+ // DelayMs(10);
// EMV_CTRL
EMV_ON;
- DelayMs(50);
+ // DelayMs(50);
- {BEEP_OFF_DEINIT;
+ // {BEEP_OFF_DEINIT;
- EMV_CHARGE_OFF_DEINIT;
- EMV_OFF_DEINIT;
+ // EMV_CHARGE_OFF_DEINIT;
+ // EMV_OFF_DEINIT;
- BSP_NoNeedBoost();
+ // BSP_NoNeedBoost();
- gValveData.switch_status = kClosed;
+ // gValveData.switch_status = kClosed;
- tmos_memset(&RelyData, 0, sizeof(RelyData));
- BSP_VALVE_Generate_ValveResponse(&RelyData, kCmdCloseVavle, 1);
+ // tmos_memset(&RelyData, 0, sizeof(RelyData));
+ // BSP_VALVE_Generate_ValveResponse(&RelyData, kCmdCloseVavle, 1);
- tmos_set_event(Peripheral_TaskID, SBP_REPLY_CMD_EVT);}
+ // tmos_set_event(Peripheral_TaskID, SBP_REPLY_CMD_EVT);}
logDebug("EMV_ON");
tmos_start_task(vavle_task_id, VAVLE_CLOSE_END_EVT, MS1_TO_SYSTEM_TIME(100));
@@ -400,6 +401,8 @@ static uint16_t VAVLE_Task_ProcessEvent(uint8_t task_id, uint16_t events)
EMV_CHARGE_OFF_DEINIT;
EMV_OFF_DEINIT;
+ LED_ALL_OFF_DEINIT;
+
BSP_NoNeedBoost();
gValveData.switch_status = kClosed;
@@ -449,7 +452,6 @@ static uint16_t VAVLE_Task_ProcessEvent(uint8_t task_id, uint16_t events)
void BSP_VAVLE_Init(void)
{
- GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeIN_Floating);
vavle_task_id = TMOS_ProcessEventRegister(VAVLE_Task_ProcessEvent);
tmos_memset(&gValveData, 0, sizeof(gValveData));
diff --git a/HAL/include/CONFIG.h b/HAL/include/CONFIG.h
index 937b0b7..d8c42d8 100644
--- a/HAL/include/CONFIG.h
+++ b/HAL/include/CONFIG.h
@@ -80,7 +80,7 @@
#define DCDC_ENABLE TRUE
#endif
#ifndef HAL_SLEEP
-#define HAL_SLEEP FALSE
+#define HAL_SLEEP TRUE
#endif
#ifndef SLEEP_RTC_MIN_TIME
#define SLEEP_RTC_MIN_TIME US_TO_RTC(1000)
diff --git a/LIB/CH58xBLE_LIB.h b/LIB/CH58xBLE_LIB.h
index 4760ba3..e2c3535 100644
--- a/LIB/CH58xBLE_LIB.h
+++ b/LIB/CH58xBLE_LIB.h
@@ -5,7 +5,7 @@
* Date : 2024/04/10
* Description : head file(ch585/ch584)
* Copyright (c) 2023 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.
*******************************************************************************/
@@ -419,7 +419,7 @@ extern const uint8_t VER_LIB[]; // LIB version
#define NAV_UUID 0x2A68 // Navigation
#define POS_QUALITY_UUID 0x2A69 // Position Quality
#define LN_FEATURE_UUID 0x2A6A // LN Feature
-#define LN_CTRL_PT_UUID 0x2A6B // LN Control Point
+#define LN_CTRL_PT_UUID 0x2A6B // LN Control Point
#define ELE_UUID 0x2A6C // Elevation
#define PRESSURE_UUID 0x2A6D // Pressure
#define TEMP_UUID 0x2A6E // Temperature
@@ -526,7 +526,7 @@ extern const uint8_t VER_LIB[]; // LIB version
/************************************ATT***************************************/
#define ATT_MTU_SIZE 23 //!< Minimum ATT MTU size
#define ATT_MAX_MTU_SIZE 512 //!< Maximum ATT MTU size
-// ATT Methods
+// ATT Methods
#define ATT_ERROR_RSP 0x01 //!< ATT Error Response
#define ATT_EXCHANGE_MTU_REQ 0x02 //!< ATT Exchange MTU Request
#define ATT_EXCHANGE_MTU_RSP 0x03 //!< ATT Exchange MTU Response
@@ -1523,7 +1523,7 @@ typedef struct
* All subsequent ATT Requests and Indications received by the local ATT Server
* and Client respectively will be dropped.
*
- * This message is to inform the app (that has registered with GAP by calling
+ * This message is to inform the app (that has registered with GAP by calling
* GAP_RegisterForMsgs()) in case it wants to drop the connection.
*/
typedef struct
@@ -1537,7 +1537,7 @@ typedef struct
* by the local ATT Server or Client when the ATT MTU size is updated for a
* connection. The default ATT MTU size is 23 octets.
*
- * This message is to inform the app (that has registered with GAP by calling
+ * This message is to inform the app (that has registered with GAP by calling
* GAP_RegisterForMsgs()) about the new ATT MTU size negotiated for a connection.
*/
typedef struct
@@ -1730,8 +1730,8 @@ typedef struct
* - Read Request: ATT_READ_REQ
* - Read Blob Request: ATT_READ_BLOB_REQ
*
- * @note If blePending is returned then it's the responsibility of the application to respond to
- * ATT_READ_REQ and ATT_READ_BLOB_REQ message with ATT_READ_RSP and ATT_READ_BLOB_RSP
+ * @note If blePending is returned then it's the responsibility of the application to respond to
+ * ATT_READ_REQ and ATT_READ_BLOB_REQ message with ATT_READ_RSP and ATT_READ_BLOB_RSP
* message respectively.
*
* @note Payload 'pValue' used with ATT_READ_RSP and ATT_READ_BLOB_RSP must be allocated using GATT_bm_alloc().
@@ -1750,7 +1750,7 @@ typedef struct
*/
typedef uint8_t (*pfnGATTReadAttrCB_t)( uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue,
uint16_t *pLen, uint16_t offset, uint16_t maxLen, uint8_t method );
-
+
/**
* @brief Callback function prototype to write an attribute value.
*
@@ -1761,7 +1761,7 @@ typedef uint8_t (*pfnGATTReadAttrCB_t)( uint16_t connHandle, gattAttribute_t *pA
* - Write Long: ATT_EXECUTE_WRITE_REQ
* - Reliable Writes: Multiple ATT_PREPARE_WRITE_REQ followed by one final ATT_EXECUTE_WRITE_REQ
*
- * @note If blePending is returned then it's the responsibility of the application to 1) respond to
+ * @note If blePending is returned then it's the responsibility of the application to 1) respond to
* ATT_WRITE_REQ and ATT_EXECUTE_WRITE_REQ message with ATT_WRITE_RSP and ATT_EXECUTE_WRITE_RSP
* message respectively, and 2) free each request payload 'pValue' using BM_free().
*
@@ -1780,7 +1780,7 @@ typedef uint8_t (*pfnGATTReadAttrCB_t)( uint16_t connHandle, gattAttribute_t *pA
*/
typedef uint8_t (*pfnGATTWriteAttrCB_t)( uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue,
uint16_t len, uint16_t offset, uint8_t method );
-
+
/**
* @brief Callback function prototype to authorize a Read or Write operation
* on a given attribute.
@@ -2632,7 +2632,7 @@ typedef struct
#define TX_MODE_TX_TIMEOUT TX_MODE_TX_FAIL //!< time of data transmission
#define TX_MODE_RX_DATA 0x02 //!< auto tx mode receive data(ack) and enter idle state
#define TX_MODE_RX_TIMEOUT 0x12 //!< auto tx mode receive timeout and enter idle state
-#define TX_MODE_HOP_SHUT 0x22
+#define TX_MODE_HOP_SHUT 0x22
// RX_MODE call RF_Rx
#define RX_MODE_RX_DATA 0x03 //!< basic or auto rx mode receive data
@@ -2642,7 +2642,7 @@ typedef struct
#define RX_MODE_TX_FINISH 0x04 //!< auto rx mode sends data(ack) successfully and enters idle state
#define RX_MODE_TX_FAIL 0x14 //!< auto rx mode fail to send data and enter idle state
#define RX_MODE_TX_TIMEOUT RX_MODE_TX_FAIL //!< time of data transmission
-#define RX_MODE_HOP_SHUT 0x24
+#define RX_MODE_HOP_SHUT 0x24
// LLE_MODE_TYPE
#define LLE_MODE_BASIC (0) //!< basic mode, enter idle state after sending or receive
@@ -2963,7 +2963,7 @@ extern bStatus_t LL_Decrypt( uint8_t *key, uint8_t *plaintextData, uint8_t *decr
*
* @param handle - connect handle
*
- * @return 0xFFFFFFFF-handle error,number of packets not receiving ack
+ * @return 0xFFFFFFFF-handle error,number of packets not receiving ack
*/
extern uint32_t LL_GetNumberOfUnAckPacket( uint16_t handle );
@@ -3015,7 +3015,7 @@ extern int16_t BLE_ReadCfo( void );
/**
* @brief pa control init
- *
+ *
* @note Can't be called until role Init
*
* @param paControl - pa control parameters(global variable)
@@ -3025,9 +3025,9 @@ extern int16_t BLE_ReadCfo( void );
extern void BLE_PAControlInit( blePaControlConfig_t *paControl );
/**
- * @brief ble register reset and rf calibration
+ * @brief ble register reset and rf calibration
*
- * @param None
+ * @param None
*
* @return None
*/
@@ -3067,7 +3067,7 @@ extern void LLE_IRQLibHandler( void );
*
* @return access address
* the Access Address meets the following requirements:
- * It shall have no more than six consecutive zeros or ones.
+ * It shall have no more than six consecutive zeros or ones.
* It shall not be t he advertising channel packets Access Address.
* It shall not be a sequence that differ s from the advertising channel packets' Access Address by only one bit.
* It shall not have all four octets equal.
@@ -3084,7 +3084,7 @@ extern uint8_t linkDB_Register( pfnLinkDBCB_t pFunc );
/*
* linkDB_State - Check to see if a physical link is in a specific state.
- *
+ *
* returns TRUE is the link is in state. FALSE, otherwise.
*/
extern uint8_t linkDB_State( uint16_t connectionHandle, uint8_t state );
@@ -3151,13 +3151,13 @@ extern void GATT_RegisterForInd( uint8_t taskId );
*
* @param handle - handle to look for
* @param pHandle - handle of owner of attribute (to be returned)
- *
+ *
* @return Pointer to attribute record. NULL, otherwise.
*/
extern gattAttribute_t *GATT_FindHandle( uint16_t handle, uint16_t *pHandle );
/**
- * @brief This sub-procedure is used when a server is configured to
+ * @brief This sub-procedure is used when a server is configured to
* indicate a characteristic value to a client and expects an
* attribute protocol layer acknowledgement that the indication
* was successfully received.
@@ -3186,9 +3186,9 @@ extern gattAttribute_t *GATT_FindHandle( uint16_t handle, uint16_t *pHandle );
*/
extern bStatus_t GATT_Indication( uint16_t connHandle, attHandleValueInd_t *pInd, uint8_t authenticated, uint8_t taskId );
/**
- * @brief This sub-procedure is used when a server is configured to
+ * @brief This sub-procedure is used when a server is configured to
* notify a characteristic value to a client without expecting
- * any attribute protocol layer acknowledgement that the
+ * any attribute protocol layer acknowledgement that the
* notification was successfully received.
*
* The ATT Handle Value Notification is used in this sub-procedure.
@@ -3243,7 +3243,7 @@ extern bStatus_t GATT_Notification( uint16_t connHandle, attHandleValueNoti_t *p
extern bStatus_t GATT_ExchangeMTU( uint16_t connHandle, attExchangeMTUReq_t *pReq, uint8_t taskId );
/**
- * @brief This sub-procedure is used by a client to discover all
+ * @brief This sub-procedure is used by a client to discover all
* the primary services on a server.
*
* The ATT Read By Group Type Request is used with the Attribute
@@ -3276,7 +3276,7 @@ extern bStatus_t GATT_DiscAllPrimaryServices( uint16_t connHandle, uint8_t taskI
/**
* @brief This sub-procedure is used by a client to discover a specific
* primary service on a server when only the Service UUID is
- * known. The primary specific service may exist multiple times
+ * known. The primary specific service may exist multiple times
* on a server. The primary service being discovered is identified
* by the service UUID.
*
@@ -3312,7 +3312,7 @@ extern bStatus_t GATT_DiscPrimaryServiceByUUID( uint16_t connHandle, uint8_t *pU
/**
* @brief This sub-procedure is used by a client to find include
- * service declarations within a service definition on a
+ * service declarations within a service definition on a
* server. The service specified is identified by the service
* handle range.
*
@@ -3347,7 +3347,7 @@ extern bStatus_t GATT_DiscPrimaryServiceByUUID( uint16_t connHandle, uint8_t *pU
extern bStatus_t GATT_FindIncludedServices( uint16_t connHandle, uint16_t startHandle, uint16_t endHandle, uint8_t taskId );
/**
- * @brief This sub-procedure is used by a client to find all the
+ * @brief This sub-procedure is used by a client to find all the
* characteristic declarations within a service definition on
* a server when only the service handle range is known. The
* service specified is identified by the service handle range.
@@ -3383,11 +3383,11 @@ extern bStatus_t GATT_FindIncludedServices( uint16_t connHandle, uint16_t startH
extern bStatus_t GATT_DiscAllChars( uint16_t connHandle, uint16_t startHandle, uint16_t endHandle, uint8_t taskId );
/**
- * @brief This sub-procedure is used by a client to discover service
- * characteristics on a server when only the service handle
- * ranges are known and the characteristic UUID is known.
+ * @brief This sub-procedure is used by a client to discover service
+ * characteristics on a server when only the service handle
+ * ranges are known and the characteristic UUID is known.
* The specific service may exist multiple times on a server.
- * The characteristic being discovered is identified by the
+ * The characteristic being discovered is identified by the
* characteristic UUID.
*
* The ATT Read By Type Request is used with the Attribute Type
@@ -3419,10 +3419,10 @@ extern bStatus_t GATT_DiscAllChars( uint16_t connHandle, uint16_t startHandle, u
extern bStatus_t GATT_DiscCharsByUUID( uint16_t connHandle, attReadByTypeReq_t *pReq, uint8_t taskId );
/**
- * @brief This sub-procedure is used by a client to find all the
+ * @brief This sub-procedure is used by a client to find all the
* characteristic descriptors Attribute Handles and Attribute
- * Types within a characteristic definition when only the
- * characteristic handle range is known. The characteristic
+ * Types within a characteristic definition when only the
+ * characteristic handle range is known. The characteristic
* specified is identified by the characteristic handle range.
*
* The ATT Find Information Request is used with the Starting
@@ -3458,12 +3458,12 @@ extern bStatus_t GATT_DiscAllCharDescs( uint16_t connHandle, uint16_t startHandl
* @brief This sub-procedure is used to read a Characteristic Value
* from a server when the client knows the Characteristic Value
* Handle. The ATT Read Request is used with the Attribute Handle
- * parameter set to the Characteristic Value Handle. The Read
+ * parameter set to the Characteristic Value Handle. The Read
* Response returns the Characteristic Value in the Attribute
* Value parameter.
*
* The Read Response only contains a Characteristic Value that
- * is less than or equal to (ATT_MTU ?1) octets in length. If
+ * is less than or equal to (ATT_MTU ?1) octets in length. If
* the Characteristic Value is greater than (ATT_MTU - 1) octets
* in length, the Read Long Characteristic Value procedure may
* be used if the rest of the Characteristic Value is required.
@@ -3500,7 +3500,7 @@ extern bStatus_t GATT_ReadCharValue( uint16_t connHandle, attReadReq_t *pReq, ui
* The Attribute Type is set to the known characteristic UUID and
* the Starting Handle and Ending Handle parameters shall be set
* to the range over which this read is to be performed. This is
- * typically the handle range for the service in which the
+ * typically the handle range for the service in which the
* characteristic belongs.
*
* If the return status from this function is SUCCESS, the calling
@@ -3529,7 +3529,7 @@ extern bStatus_t GATT_ReadUsingCharUUID( uint16_t connHandle, attReadByTypeReq_t
/**
* @brief This sub-procedure is used to read a Characteristic Value from
* a server when the client knows the Characteristic Value Handle
- * and the length of the Characteristic Value is longer than can
+ * and the length of the Characteristic Value is longer than can
* be sent in a single Read Response Attribute Protocol message.
*
* The ATT Read Blob Request is used in this sub-procedure.
@@ -3559,8 +3559,8 @@ extern bStatus_t GATT_ReadLongCharValue( uint16_t connHandle, attReadBlobReq_t *
/**
* @brief This sub-procedure is used to read multiple Characteristic Values
- * from a server when the client knows the Characteristic Value
- * Handles. The Attribute Protocol Read Multiple Requests is used
+ * from a server when the client knows the Characteristic Value
+ * Handles. The Attribute Protocol Read Multiple Requests is used
* with the Set Of Handles parameter set to the Characteristic Value
* Handles. The Read Multiple Response returns the Characteristic
* Values in the Set Of Values parameter.
@@ -3599,16 +3599,16 @@ extern bStatus_t GATT_ReadMultiCharValues( uint16_t connHandle, attReadMultiReq_
* Value. This sub-procedure can not be used to write a long
* characteristic; instead the Write Long Characteristic Values
* sub-procedure should be used.
- *
+ *
* The ATT Write Command is used for this sub-procedure. The
* Attribute Handle parameter shall be set to the Characteristic
* Value Handle. The Attribute Value parameter shall be set to
* the new Characteristic Value.
*
* No response will be sent to the calling application task for this
- * sub-procedure. If the Characteristic Value write request is the
- * wrong size, or has an invalid value as defined by the profile,
- * then the write will not succeed and no error will be generated
+ * sub-procedure. If the Characteristic Value write request is the
+ * wrong size, or has an invalid value as defined by the profile,
+ * then the write will not succeed and no error will be generated
* by the server.
*
* @param connHandle - connection to use
@@ -3625,25 +3625,25 @@ extern bStatus_t GATT_WriteNoRsp( uint16_t connHandle, attWriteReq_t *pReq );
/**
* @brief This sub-procedure is used to write a Characteristic Value
- * to a server when the client knows the Characteristic Value
+ * to a server when the client knows the Characteristic Value
* Handle and the ATT Bearer is not encrypted. This sub-procedure
* shall only be used if the Characteristic Properties authenticated
* bit is enabled and the client and server device share a bond as
* defined in the GAP.
*
* This sub-procedure only writes the first (ATT_MTU ?15) octets
- * of an Attribute Value. This sub-procedure cannot be used to
+ * of an Attribute Value. This sub-procedure cannot be used to
* write a long Attribute.
*
* The ATT Write Command is used for this sub-procedure. The
* Attribute Handle parameter shall be set to the Characteristic
- * Value Handle. The Attribute Value parameter shall be set to
+ * Value Handle. The Attribute Value parameter shall be set to
* the new Characteristic Value authenticated by signing the
* value, as defined in the Security Manager.
*
* No response will be sent to the calling application task for this
- * sub-procedure. If the authenticated Characteristic Value that is
- * written is the wrong size, or has an invalid value as defined by
+ * sub-procedure. If the authenticated Characteristic Value that is
+ * written is the wrong size, or has an invalid value as defined by
* the profile, or the signed value does not authenticate the client,
* then the write will not succeed and no error will be generated by
* the server.
@@ -3666,10 +3666,10 @@ extern bStatus_t GATT_SignedWriteNoRsp( uint16_t connHandle, attWriteReq_t *pReq
* to a server when the client knows the characteristic value
* handle. This sub-procedure only writes the first (ATT_MTU-3)
* octets of a characteristic value. This sub-procedure can not
- * be used to write a long attribute; instead the Write Long
+ * be used to write a long attribute; instead the Write Long
* Characteristic Values sub-procedure should be used.
*
- * The ATT Write Request is used in this sub-procedure. The
+ * The ATT Write Request is used in this sub-procedure. The
* Attribute Handle parameter shall be set to the Characteristic
* Value Handle. The Attribute Value parameter shall be set to
* the new characteristic.
@@ -3700,7 +3700,7 @@ extern bStatus_t GATT_WriteCharValue( uint16_t connHandle, attWriteReq_t *pReq,
/**
* @brief This sub-procedure is used to write a Characteristic Value to
* a server when the client knows the Characteristic Value Handle
- * but the length of the Characteristic Value is longer than can
+ * but the length of the Characteristic Value is longer than can
* be sent in a single Write Request Attribute Protocol message.
*
* The ATT Prepare Write Request and Execute Write Request are
@@ -3739,11 +3739,11 @@ extern bStatus_t GATT_WriteLongCharValue( uint16_t connHandle, attPrepareWriteRe
* and assurance is required that the correct Characteristic Value
* is going to be written by transferring the Characteristic Value
* to be written in both directions before the write is performed.
- * This sub-procedure can also be used when multiple values must
+ * This sub-procedure can also be used when multiple values must
* be written, in order, in a single operation.
*
* The sub-procedure has two phases, the first phase prepares the
- * characteristic values to be written. Once this is complete,
+ * characteristic values to be written. Once this is complete,
* the second phase performs the execution of all of the prepared
* characteristic value writes on the server from this client.
*
@@ -3787,7 +3787,7 @@ extern bStatus_t GATT_ReliableWrites( uint16_t connHandle, attPrepareWriteReq_t
* declaration's Attribute handle.
*
* The ATT Read Request is used for this sub-procedure. The Read
- * Request is used with the Attribute Handle parameter set to the
+ * Request is used with the Attribute Handle parameter set to the
* characteristic descriptor handle. The Read Response returns the
* characteristic descriptor value in the Attribute Value parameter.
*
@@ -3885,7 +3885,7 @@ extern bStatus_t GATT_WriteCharDesc( uint16_t connHandle, attWriteReq_t *pReq, u
/**
* @brief This sub-procedure is used to write a Characteristic Value to
* a server when the client knows the Characteristic Value Handle
- * but the length of the Characteristic Value is longer than can
+ * but the length of the Characteristic Value is longer than can
* be sent in a single Write Request Attribute Protocol message.
*
* The ATT Prepare Write Request and Execute Write Request are
@@ -4297,7 +4297,7 @@ extern bStatus_t GAPRole_TerminateLink( uint16_t connHandle );
* @param connHandle - connection handle
*
* @return bStatus_t: HCI Error Code.
- *
+ *
*/
extern bStatus_t GAPRole_ReadRssiCmd( uint16_t connHandle );
@@ -4773,7 +4773,7 @@ extern bStatus_t RF_SetFrequency( uint32_t frequency, uint8_t ch );
extern void RF_FrequencyHoppingShut( void );
/**
- * @brief
+ * @brief
*
* @param resendCount - Maximum count of sending HOP_TX pdu,0 = unlimited.
*
@@ -4782,7 +4782,7 @@ extern void RF_FrequencyHoppingShut( void );
extern uint8_t RF_FrequencyHoppingTx( uint8_t resendCount );
/**
- * @brief
+ * @brief
*
* @param timeoutMS - Maximum time to wait for receiving HOP_TX pdu(Time = n * 1mSec),0 = unlimited.
*