#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