Skip to content

Commit

Permalink
feat: add keyscan code to keyboard demo
Browse files Browse the repository at this point in the history
Here we demonstrate the basic functions of a 65% keyboard, however
it is totally not all and we plan to add more features in it.
  • Loading branch information
metro94 committed Aug 22, 2021
1 parent 6c5156a commit 8fc7651
Show file tree
Hide file tree
Showing 17 changed files with 1,402 additions and 31 deletions.
36 changes: 18 additions & 18 deletions firmware/bl_mcu_sdk/bsp/board/bl702/sipeed_keyboard/pinmux_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@

// <q> GPIO0 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio0 function
#define CONFIG_GPIO0_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO0_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO1 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio1 function
#define CONFIG_GPIO1_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO1_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO2 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio2 function
#define CONFIG_GPIO2_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO2_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_QDEC]
// <i> config gpio3 function
#define CONFIG_GPIO3_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO3_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
// <i> config gpio4 function
#define CONFIG_GPIO4_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO4_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_QDEC]
// <i> config gpio5 function
#define CONFIG_GPIO5_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO5_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_QDEC]
// <i> config gpio6 function
#define CONFIG_GPIO6_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO6_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ADC//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio7 function
Expand Down Expand Up @@ -107,50 +107,50 @@

// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ADC//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio20 function
#define CONFIG_GPIO20_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO20_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ADC//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio21 function
#define CONFIG_GPIO21_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO21_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio22 function
#define CONFIG_GPIO22_FUNC GPIO_FUN_PWM
#define CONFIG_GPIO22_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
// <i> config gpio23 function
#define CONFIG_GPIO23_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO23_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio24 function
#define CONFIG_GPIO24_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO24_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio25 function
#define CONFIG_GPIO25_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO25_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio26 function
#define CONFIG_GPIO26_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO26_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio27 function
#define CONFIG_GPIO27_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO27_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
// <i> config gpio28 function
#define CONFIG_GPIO28_FUNC GPIO_FUN_UNUSED

// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
// <i> config gpio29 function
#define CONFIG_GPIO29_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO29_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
// <i> config gpio30 function
#define CONFIG_GPIO30_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO30_FUNC GPIO_FUN_GPIO_INPUT_UP

// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
// <i> config gpio31 function
#define CONFIG_GPIO31_FUNC GPIO_FUN_UNUSED
#define CONFIG_GPIO31_FUNC GPIO_FUN_GPIO_INPUT_UP

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ set(TARGET_REQUIRED_SRCS ${CMAKE_CURRENT_LIST_DIR}/ble_peripheral_tp_server.c
${CMAKE_CURRENT_LIST_DIR}/smk_hid.c
${CMAKE_CURRENT_LIST_DIR}/smk_cdc.c
${CMAKE_CURRENT_LIST_DIR}/smk_msc.c
${CMAKE_CURRENT_LIST_DIR}/smk_keyscan.c
${CMAKE_CURRENT_LIST_DIR}/smk_shell.c
${CMAKE_CURRENT_LIST_DIR}/smk_spirgb.c
${CMAKE_CURRENT_LIST_DIR}/keyboard/smk_keyscan.c
${CMAKE_CURRENT_LIST_DIR}/keyboard/smk_keymap.c
${CMAKE_CURRENT_LIST_DIR}/keyboard/smk_debounce_defer_g.c
${CMAKE_CURRENT_LIST_DIR}/config/sipeed_mechanical_keyboard.c
${BSP_COMMON_DIR}/usb/usb_dc.c
${BSP_COMMON_DIR}/usb/uart_interface.c
${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*=========================================================================================================================
.-------. .-------. .-------. .-------. .-------. .-------. .-------. .-------. .-------. .-------.
/ SIP / `\/ EED / `\/ / `\/ MECH / `\/ ANI / `\/ CAL / `\/ / `\/ KEY / `\/ BO / `\/ ARD / `\
`------'` /`------'` /`------'` /`------'` /`------'` /`------'` /`------'` /`------'` /`------'` /`------'` /
V V / V V / V V / V metro V / V 94@ V / V Git V / V Hub V / V V / V V / V V /
`------' `------' `------' `------' `------' `------' `------' `------' `------' `------'
=========================================================================================================================*/

#define USE_KEYCODE_SHORT_NAME

#include "keyboard/smk_keyboard.h"
#include "keyboard/smk_debounce.h"

#include "hal_gpio.h"
#include "glb_reg.h"

#define MATRIX_COLS 11
#define MATRIX_ROWS 7
#define LAYOUT_COLS 15
#define LAYOUT_ROWS 5
#define LAYERS 3

static const smk_keycode_type smk_default_matrix_keymaps[LAYERS][LAYOUT_ROWS][LAYOUT_COLS] = {
{
/*< .-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.---------------.-------. >*/
{ ESC , NUM1 , NUM2 , NUM3 , NUM4 , NUM5 , NUM6 , NUM7 , NUM8 , NUM9 , NUM0 , MINUS , EQUAL , BACKSPACE , GRAVE }, \
/*< /======='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.===========/`======/`. / >*/
{ TAB , Q , W , E , R , T , Y , U , I , O , P , LBRKT , RBRKT , BSLASH , DEL }, \
/*< /==========='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`==========/`======/`. / >*/
{ CAPS , A , S , D , F , G , H , J , K , L , SCOLN , QUOTE , ENTER , PGUP }, \
/*< /============='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`========.=======/`======/`. / >*/
{ LSHIFT , Z , X , C , V , B , N , M , COMMA , DOT , SLASH , RSFT , UP , PGDN }, \
/*< /=========.======='`.====='`==.==='`======'`======'`======'`======'`======'`====.='`====.='`====.='`====.=======/`======/`======/`. / >*/
{ LCTRL , LGUI , LALT , SPACE , RALT , MO(2) , RCTRL , LEFT , DOWN , RIGHT } \
/*< `---------'`--------'`--------'`------------------------------------------------'`------'`------'`------'`------'`------'`------'`. / >*/
/*< V V V V Layer 0 V V V V V V V / >*/
/*< `----------'`--------'`--------'`------------------------------------------------'`------'`------'`------'`------'`------'`------' >*/
}, {
/*< .-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.---------------.-------. >*/
{ ESC , NUM1 , NUM2 , NUM3 , NUM4 , NUM5 , NUM6 , NUM7 , NUM8 , NUM9 , NUM0 , MINUS , EQUAL , BACKSPACE , GRAVE }, \
/*< /======='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.===========/`======/`. / >*/
{ TAB , Q , W , E , R , T , Y , U , I , O , P , LBRKT , RBRKT , BSLASH , DEL }, \
/*< /==========='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`==========/`======/`. / >*/
{ CAPS , A , S , D , F , G , H , J , K , L , SCOLN , QUOTE , ENTER , PGUP }, \
/*< /============='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`========.=======/`======/`. / >*/
{ LSHIFT , Z , X , C , V , B , N , M , COMMA , DOT , SLASH , RSFT , UP , PGDN }, \
/*< /=========.======='`.====='`==.==='`======'`======'`======'`======'`======'`====.='`====.='`====.='`====.=======/`======/`======/`. / >*/
{ LCTRL , LOPT , LCMD , SPACE , RCMD , MO(2) , RCTRL , LEFT , DOWN , RIGHT } \
/*< `---------'`--------'`--------'`------------------------------------------------'`------'`------'`------'`------'`------'`------'`. / >*/
/*< V V V V Layer 1 V V V V V V V / >*/
/*< `----------'`--------'`--------'`------------------------------------------------'`------'`------'`------'`------'`------'`------' >*/
}, {
/*< .-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.-------.---------------.-------. >*/
{ _____ , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 , F10 , F11 , F12 , _____ , PRTSC }, \
/*< /======='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.===========/`======/`. / >*/
{ _____ , XXXXX , XXXXX , XXXXX , XXXXX , XXXXX , XXXXX , NUMLK , P7 , P8 , P9 , PSLSH , PAST , PMINUS , INS }, \
/*< /==========='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`.====='`==========/`======/`. / >*/
{ _____ , DF(0) , DF(1) , XXXXX , XXXXX , XXXXX , XXXXX , XXXXX , P4 , P5 , P6 , PPLUS , PENTER , HOME }, \
/*< /============='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`==.==='`========.=======/`======/`. / >*/
{ _____ , XXXXX , XXXXX , XXXXX , XXXXX , XXXXX , XXXXX , XXXXX , P1 , P2 , P3 , XXXXX , _____ , END }, \
/*< /=========.======='`.====='`==.==='`======'`======'`======'`======'`======'`====.='`====.='`====.='`====.=======/`======/`======/`. / >*/
{ _____ , _____ , _____ , _____ , P0 , _____ , PDOT , _____ , _____ , _____ } \
/*< `---------'`--------'`--------'`------------------------------------------------'`------'`------'`------'`------'`------'`------'`. / >*/
/*< V V V V Layer 2 V V V V V V V / >*/
/*< `----------'`--------'`--------'`------------------------------------------------'`------'`------'`------'`------'`------'`------' >*/
}
};

const smk_keyboard_hardware_type * smk_keyboard_get_hardware(void)
{
static const uint8_t matrix_col_pins[MATRIX_COLS] = { 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31 };
static const uint8_t matrix_row_pins[MATRIX_ROWS] = { 0, 1, 2, 3, 4, 5, 6 };

static const uint8_t matrix_to_layout[MATRIX_COLS][MATRIX_ROWS] = {
{ 0, 15, 30, 45, 60, -1, -1 },
{ 1, 16, 31, 46, 61, 68, 69 },
{ 2, 17, 32, 47, 62, 66, 67 },
{ 3, 18, 33, 48, -1, 57, 58 },
{ 4, 19, 34, 49, -1, 56, -1 },
{ 5, 20, 35, 50, 63, -1, 43 },
{ 6, 21, 36, 51, -1, 41, 42 },
{ 7, 22, 37, 52, -1, 28, 29 },
{ 8, 23, 38, 53, -1, 26, 27 },
{ 9, 24, 39, 54, 64, 13, 14 },
{ 10, 25, 40, 55, 65, 11, 12 }
};

static const smk_keyboard_hardware_type hardware = {
.matrix = {
.total_cnt = MATRIX_COLS * MATRIX_ROWS,
.col_cnt = MATRIX_COLS,
.row_cnt = MATRIX_ROWS,
.col_pins = matrix_col_pins,
.row_pins = matrix_row_pins,
.layout_from = (const uint8_t *)matrix_to_layout
},
.layout = {
.total_cnt = LAYOUT_COLS * LAYOUT_ROWS,
.col_cnt = LAYOUT_COLS,
.row_cnt = LAYOUT_ROWS
},
.scan = {
.scan_period_ms = 2,
.max_jitter_ms = 10,
.debounce_algo = SMK_KEYBOARD_DEBOUNCE_ALGO_DEFER_G
},
.map = {
.layer_cnt = LAYERS,
.keymaps = (const smk_keycode_type *)smk_default_matrix_keymaps
}
};

return &hardware;
}

int smk_keyscan_init_gpio(const smk_keyboard_hardware_type *hardware)
{
for (uint8_t col = 0; col < hardware->matrix.col_cnt; ++col) {
uint8_t pin = hardware->matrix.col_pins[col];
gpio_set_mode(pin, GPIO_INPUT_PP_MODE);
}

for (uint8_t row = 0; row < hardware->matrix.row_cnt; ++row) {
uint8_t pin = hardware->matrix.row_pins[row];
gpio_set_mode(pin, GPIO_INPUT_PP_MODE);
}

return 0;
}

void smk_keyscan_select_col(const smk_keyboard_hardware_type *hardware, uint32_t col)
{
uint8_t pin = hardware->matrix.col_pins[col];
gpio_write(pin, 0U);
gpio_set_mode(pin, GPIO_OUTPUT_MODE);
}

void smk_keyscan_unselect_col(const smk_keyboard_hardware_type *hardware, uint32_t col)
{
uint8_t pin = hardware->matrix.col_pins[col];
gpio_set_mode(pin, GPIO_INPUT_PP_MODE);
}

void smk_keyscan_select_col_delay(const smk_keyboard_hardware_type *hardware)
{
bflb_platform_delay_us(0);
}

void smk_keyscan_unselect_col_delay(const smk_keyboard_hardware_type *hardware)
{
bflb_platform_delay_us(5);
}

uint32_t smk_keyscan_read_entire_row(const smk_keyboard_hardware_type *hardware)
{
// Here we read GPIO0-GPIO6 in one-time register read
return ~*(uint32_t *)(GLB_BASE + GLB_GPIO_INPUT_OFFSET) & 0x7FU;
}

// uint32_t smk_keyscan_read_row_gpio(const smk_keyboard_hardware_type *hardware, uint32_t row)
// {
// uint8_t pin = hardware->matrix.row_pins[row];
// return (uint32_t)gpio_read(pin);
// }
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef __SMK_DEBOUNCE_H
#define __SMK_DEBOUNCE_H

#include "smk_keyboard.h"

typedef enum {
SMK_KEYBOARD_DEBOUNCE_ALGO_DEFER_G,
SMK_KEYBOARD_DEBOUNCE_ALGO_COUNT
} smk_keyboard_debounce_algo_type;

int smk_keyscan_init_debounce_defer_g(smk_keyboard_scan_type *scan);
uint32_t smk_keyscan_debounce_defer_g(smk_keyboard_scan_type *scan);

typedef int (*smk_keyscan_init_debounce_type)(smk_keyboard_scan_type *);

static const smk_keyscan_init_debounce_type smk_keyscan_init_debounce_func[SMK_KEYBOARD_DEBOUNCE_ALGO_COUNT] = {
[SMK_KEYBOARD_DEBOUNCE_ALGO_DEFER_G] = smk_keyscan_init_debounce_defer_g
};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef __SMK_EVENT_H
#define __SMK_EVENT_H

#include <stdint.h>
#include "FreeRTOS.h"

typedef enum {
SMK_EVENT_NONE,
SMK_EVENT_KEYPOS,
SMK_EVENT_KEYCODE,
SMK_EVENT_COUNT
} smk_event_class_type;

typedef enum {
SMK_EVENT_KEYPOS_SCAN_END,
SMK_EVENT_KEYPOS_PRESS,
SMK_EVENT_KEYPOS_RELEASE,
SMK_EVENT_KEYPOS_MAX
} smk_event_keypress_subclass_type;

typedef enum {
SMK_EVENT_KEYCODE_COMMIT,
SMK_EVENT_KEYCODE_ADD,
SMK_EVENT_KEYCODE_REMOVE,
SMK_EVENT_KEYCODE_MAX
} smk_event_keycode_subclass_type;

typedef uint16_t smk_event_data_type;

typedef struct {
uint8_t class;
uint8_t subclass;
smk_event_data_type data;
TickType_t timestamp;
} smk_event_type;

#endif
Loading

0 comments on commit 8fc7651

Please sign in to comment.