Files
JBao_JL7016_SOC_SDK/include_lib/system/device/iokey.h
T
wuchuyuan aa724c6758 客户侧能力: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
2026-08-19 15:26:35 +08:00

71 lines
1.8 KiB
C

#ifndef DEVICE_IOKEY_H
#define DEVICE_IOKEY_H
#include "typedef.h"
#include "device/device.h"
// enum key_connect_way {
// ONE_PORT_TO_LOW, //按键一个端口接低电平, 另一个端口接IO
// ONE_PORT_TO_HIGH, //按键一个端口接高电平, 另一个端口接IO
// DOUBLE_PORT_TO_IO, //按键两个端口接IO
// };
#define ONE_PORT_TO_LOW 0 //按键一个端口接低电平, 另一个端口接IO
#define ONE_PORT_TO_HIGH 1 //按键一个端口接高电平, 另一个端口接IO
#define DOUBLE_PORT_TO_IO 2 //按键两个端口接IO
#define CUST_DOUBLE_PORT_TO_IO 3
struct one_io_key {
u8 port;
};
struct two_io_key {
u8 in_port;
u8 out_port;
};
union key_type {
struct one_io_key one_io;
struct two_io_key two_io;
};
struct iokey_port {
union key_type key_type;
u8 connect_way;
u8 key_value;
};
struct iokey_platform_data {
u8 enable;
u8 num;
const struct iokey_port *port;
};
//IOKEY API:
extern int iokey_init(const struct iokey_platform_data *iokey_data);
extern u8 io_get_key_value(void);
/* 开机锁键:长按开机不松手时屏蔽全部按键,避免误触长按关机。
* 默认监视 port[0](请把电源键配成第 0 个)。
* 松开并连续确认 release_cnt 次扫描后解锁(扫描约 10ms 一次,默认 10 ≈ 100ms)。
*
* 关闭方式:
* 1) 编译关闭:在 board/app_config 里 #define TCFG_IOKEY_BOOT_LOCK_ENABLE 0
* 2) 运行关闭:iokey_boot_lock_stop() 或 iokey_boot_lock_start(0)
*/
#ifndef TCFG_IOKEY_BOOT_LOCK_ENABLE
#define TCFG_IOKEY_BOOT_LOCK_ENABLE 1
#endif
#ifndef IOKEY_BOOT_LOCK_DEFAULT_CNT
#define IOKEY_BOOT_LOCK_DEFAULT_CNT 10
#endif
void iokey_boot_lock_start(u8 release_cnt); /* >0 启动;0=关闭 */
void iokey_boot_lock_stop(void); /* 立即关闭锁键 */
#endif