[fix][keyscan] fix keyscan default clk setting and array index warning

This commit is contained in:
jzlv 2021-07-13 13:57:26 +08:00
parent ca5416824b
commit 411776be3f
7 changed files with 24 additions and 8 deletions

View file

@ -73,7 +73,7 @@
#define BSP_CAM_CLOCK_DIV 3
#endif
#if defined(BSP_USING_QDEC) || defined(BSP_USING_KEYSCAN)
#define BSP_QDEC_KEYSCAN_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
#define BSP_QDEC_KEYSCAN_CLOCK_SOURCE ROOT_CLOCK_SOURCE_32K_CLK
#define BSP_QDEC_KEYSCAN_CLOCK_DIV 0
#endif

View file

@ -64,7 +64,7 @@
#define BSP_CAM_CLOCK_DIV 3
#endif
#if defined(BSP_USING_QDEC) || defined(BSP_USING_KEYSCAN)
#define BSP_QDEC_KEYSCAN_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
#define BSP_QDEC_KEYSCAN_CLOCK_SOURCE ROOT_CLOCK_SOURCE_32K_CLK
#define BSP_QDEC_KEYSCAN_CLOCK_DIV 0
#endif

View file

@ -24,14 +24,16 @@
#include "kys_reg.h"
#include "bl702_glb.h"
#ifdef BSP_USING_KEYSCAN
static void KeyScan_IRQ(void);
#endif
static keyscan_device_t keyscan_device[KEYSCAN_MAX_INDEX] = {
#ifdef BSP_USING_KEYSCAN
KEYSCAN_CONFIG
#endif
};
static void KeyScan_IRQ(void);
/**
* @brief
*
@ -79,7 +81,9 @@ int keyscan_control(struct device *dev, int cmd, void *args)
{
switch (cmd) {
case DEVICE_CTRL_SET_INT /* constant-expression */:
#ifdef BSP_USING_KEYSCAN
Interrupt_Handler_Register(KYS_IRQn, KeyScan_IRQ);
#endif
BL_WR_REG(KYS_BASE, KYS_KS_INT_EN, 1);
NVIC_EnableIRQ(KYS_IRQn);
break;
@ -144,11 +148,13 @@ int keyscan_register(enum keyscan_index_type index, const char *name)
return device_register(dev, name, 0);
}
#if defined(BSP_USING_KEYSCAN)
static void KeyScan_IRQ(void)
{
if (keyscan_device[0].parent.callback) {
keyscan_device[0].parent.callback(&keyscan_device[0].parent, (void *)(BL_RD_REG(KYS_BASE, KYS_KEYCODE_VALUE)), 0, KEYSCAN_EVENT_TRIG);
if (keyscan_device[KEYSCAN_INDEX].parent.callback) {
keyscan_device[KEYSCAN_INDEX].parent.callback(&keyscan_device[KEYSCAN_INDEX].parent, (void *)(BL_RD_REG(KYS_BASE, KYS_KEYCODE_VALUE)), 0, KEYSCAN_EVENT_TRIG);
}
BL_WR_REG(KYS_BASE, KYS_KEYCODE_CLR, 0xf);
}
#endif

View file

@ -42,7 +42,7 @@ int main(void)
if (keyscan) {
KEYSCAN_DEV(keyscan)->col_num = COL_NUM_4;
KEYSCAN_DEV(keyscan)->row_num = ROW_NUM_4;
device_open(keyscan, 0); //current scan latency is 32M/1/8 = 4Khz
device_open(keyscan, 0); //current scan latency is 32K/1/8 = 4Khz
device_set_callback(keyscan, keyscan_irq_callback);
device_control(keyscan, DEVICE_CTRL_SET_INT, NULL);
device_control(keyscan, DEVICE_CTRL_RESUME, NULL);

View file

@ -1,3 +1,8 @@
**board/bl706_iot/clock_config.h** 中,
**BSP_QDEC_KEYSCAN_CLOCK_SOURCE** 设置成 **ROOT_CLOCK_SOURCE_32K_CLK**
**BSP_QDEC_KEYSCAN_CLOCK_DIV** 设置成 **0**
**board/bl706_iot/pinmux_config.h** 中, 以下宏设置成 **GPIO_FUN_KEY_SCAN_ROW**
- **CONFIG_GPIO16_FUNC**

View file

@ -33,7 +33,7 @@ int main(void)
if (keyscan) {
KEYSCAN_DEV(keyscan)->col_num = COL_NUM_4;
KEYSCAN_DEV(keyscan)->row_num = ROW_NUM_4;
device_open(keyscan, 0); //current scan latency is 32M/1/8 = 4Khz
device_open(keyscan, 0); //current scan latency is 32K/1/8 = 4Khz
device_control(keyscan, DEVICE_CTRL_RESUME, NULL);
MSG("keyscan found\n");
}

View file

@ -1,3 +1,8 @@
**board/bl706_iot/clock_config.h** 中,
**BSP_QDEC_KEYSCAN_CLOCK_SOURCE** 设置成 **ROOT_CLOCK_SOURCE_32K_CLK**
**BSP_QDEC_KEYSCAN_CLOCK_DIV** 设置成 **0**
**board/bl706_iot/pinmux_config.h** 中, 以下宏设置成 **GPIO_FUN_KEY_SCAN_ROW**
- **CONFIG_GPIO16_FUNC**