客户侧能力:RTC、开机锁键与 BLE 协议收敛

1、新增 usr_periph RTC,DEVICEINFO 自动对时;对外精简为 get_time(sys_time*),开发板 RTC 时钟改用 LRC
2、iokey 开机锁键改为公开 start/stop 接口,板级宏 TCFG_IOKEY_BOOT_LOCK_ENABLE 可关闭
3、对齐模组 BLE 收发/组包与公开 API,更新 libusr_le_code.a;Release 包命名调整为 JBao_JL7016_SOC_SDK_Vx.x.x
This commit is contained in:
2026-08-19 15:26:35 +08:00
parent 3e9fb2cd06
commit aa724c6758
21 changed files with 1118 additions and 600 deletions
+79 -8
View File
@@ -157,7 +157,77 @@ __attribute__((weak)) u8 iokey_filter_hook(u8 io_state)
{
return 0;
}
u8 usr_first_power=0;
/* 开机锁键剩余确认次数;非 0 时扫描一律返回 NO_KEY */
static u8 s_boot_lock_cnt;
/**
* @brief 启动/关闭开机锁键
* @param release_cnt >0:松开后连续确认次数;0:关闭
*/
void iokey_boot_lock_start(u8 release_cnt)
{
#if TCFG_IOKEY_BOOT_LOCK_ENABLE
s_boot_lock_cnt = release_cnt;
#else
(void)release_cnt;
s_boot_lock_cnt = 0;
#endif
}
/**
* @brief 立即关闭开机锁键
*/
void iokey_boot_lock_stop(void)
{
s_boot_lock_cnt = 0;
}
/**
* @brief 扫描路径更新锁键:监视 port[0],松开则递减计数
* @return 1=仍锁定(应返回 NO_KEY),0=已解锁可正常扫描
*/
static u8 iokey_boot_lock_update(void)
{
#if !TCFG_IOKEY_BOOT_LOCK_ENABLE
return 0;
#else
u8 key_io;
u8 io_level;
u8 released;
if (!s_boot_lock_cnt)
{
return 0;
}
if (!__this || (__this->num == 0))
{
return 1;
}
key_io = __this->port[0].key_type.one_io.port;
io_level = gpio_read(key_io);
if (__this->port[0].connect_way == ONE_PORT_TO_LOW)
{
released = io_level; /* 上拉输入,松开为高 */
}
else
{
released = !io_level; /* 下拉输入,松开为低 */
}
if (released)
{
s_boot_lock_cnt--;
if (s_boot_lock_cnt == 0)
{
puts("iokey boot lock released\n");
}
}
return 1; /* 本拍仍屏蔽;计数到 0 后下一拍才开放 */
#endif
}
u8 io_get_key_value(void)
{
int i;
@@ -173,12 +243,7 @@ u8 io_get_key_value(void)
if (!__this->enable) {
return NO_KEY;
}
if(usr_first_power)
{
if(gpio_read(IO_PORTB_01))
{
usr_first_power--;
}
if (iokey_boot_lock_update()) {
return NO_KEY;
}
//先扫描单IO接按键方式
@@ -266,7 +331,7 @@ _iokey_get_value_end:
int iokey_init(const struct iokey_platform_data *iokey_data)
{
int i;
usr_first_power=10;
__this = iokey_data;
if (__this == NULL) {
return -EINVAL;
@@ -275,6 +340,12 @@ int iokey_init(const struct iokey_platform_data *iokey_data)
return KEY_NOT_SUPPORT;
}
/* 长按开机场景:等电源键(port[0])松开后再开放按键扫描 */
#if TCFG_IOKEY_BOOT_LOCK_ENABLE
iokey_boot_lock_start(IOKEY_BOOT_LOCK_DEFAULT_CNT);
#else
iokey_boot_lock_stop();
#endif
key_io_reset();
return 0;
@@ -57,6 +57,7 @@
#include "chgbox_box.h"
#endif
/* usr_le_code 库钩子:由静态库导出,供 RCSP BLE 栈回调,非应用层公开 API */
extern void usr_le_data_recieve(u8* data,u16 len);
extern void usr_ble_adv_init();
#if 1
@@ -526,19 +527,15 @@ static int att_write_callback(hci_con_handle_t connection_handle, uint16_t att_h
void usr_ble_send_data(u8* data,u16 len)
{
/* CCC 未写时 ATT 发数会失败(常见 app_send_fail:-93),等主机使能通知再发 */
if (get_ble_work_state() != BLE_ST_NOTIFY_IDICATE) {
log_info("ble send skip, wait CCC");
return;
}
if (app_send_user_data_check(len))
{
app_send_user_data(ATT_CHARACTERISTIC_15f1e601_a277_43fc_a484_dd39ef8a9100_01_VALUE_HANDLE, data, len, ATT_OP_AUTO_READ_CCC);
}
//printf("send rsp:");
// printf_buf(data,len);
printf("\n");
for(u8 i=0;i<len;i++)
{
printf("%c",data[i]);
}
printf("\n");
}
static int app_send_user_data(u16 handle, u8 *data, u16 len, u8 handle_type)
{
@@ -961,6 +958,16 @@ u16 usr_get_conn_service()
{
return con_handle;
}
/**
* @brief 主机是否已写 CCC,允许 GATT notify/indicate
* @return 1=可发数(BLE_ST_NOTIFY_IDICATE),0=还不行
*/
u8 usr_ble_is_notify_ready(void)
{
return (get_ble_work_state() == BLE_ST_NOTIFY_IDICATE) ? 1 : 0;
}
void ble_app_disconnect(void)
{
ble_disconnect(NULL);