Keyscan adopts manual scanning mode and the scanning will be completed in one time.?To realize matrix keyboard scanning, first send key message event
to app_task by key interrupt.When a message event is detected by app_task, it will be parsed at app layer and app_task will execute user program. In the meantime, key information will be printed on DebugAnalyser tool.
路径:src/sample/io_sample/KEYSCAN/Keyscan/ble_peripheral
typedef struct
{
? ? uint32_t length;
? ? struct
? ? {
? ? ? ? uint16_t column: 5; ? /**< keyscan column buffer data ? */
? ? ? ? uint16_t row: 4; ? ? ?/**< keyscan raw buffer data ? ? ?*/
? ? } key[26];
} KeyScan_Data_TypeDef;
global_data_keyscan_init?
作用:初始化按键变量中的值。?
/**
? * @brief ?Initialization of pinmux settings and pad settings.
? * @param ?No parameter.
? * @return Void
? */
void board_keyboard_init(void)
{
? ? /* Keypad pad config */
? ? Pad_Config(KEYBOARD_ROW_0, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE,
? ? ? ? ? ? ? ?PAD_OUT_LOW);
? ? Pad_Config(KEYBOARD_ROW_1, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE,
? ? ? ? ? ? ? ?PAD_OUT_LOW);
? ? Pad_Config(KEYBOARD_COLUMN_0, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_NONE, PAD_OUT_ENABLE,
? ? ? ? ? ? ? ?PAD_OUT_LOW);
? ? Pad_Config(KEYBOARD_COLUMN_1, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_NONE, PAD_OUT_ENABLE,
? ? ? ? ? ? ? ?PAD_OUT_LOW);? ? /* keypad pinmux config */
? ? Pinmux_Config(KEYBOARD_ROW_0, KEY_ROW_0);
? ? Pinmux_Config(KEYBOARD_ROW_1, KEY_ROW_1);
? ? Pinmux_Config(KEYBOARD_COLUMN_0, KEY_COL_0);
? ? Pinmux_Config(KEYBOARD_COLUMN_1, KEY_COL_1);
}
NOTE:PAD初始化,?PINMUX初始化,设置PAD功能。