Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kscan): Add config to control int trigger #2699

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/module/drivers/kscan/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,34 @@ config ZMK_KSCAN_MATRIX_WAIT_BETWEEN_OUTPUTS
scenario, set this value to a positive value to configure the number of
ticks to wait after reading each column of keys.

choice ZMK_KSCAN_GPIO_MATRIX_INTERRUPT_TYPE
prompt "Matrix interrupt type for key press detection"

config ZMK_KSCAN_GPIO_MATRIX_INTERRUPT_TYPE_LEVEL
bool "Level active"

config ZMK_KSCAN_GPIO_MATRIX_INTERRUPT_TYPE_EDGE
bool "Edge to active"

endchoice

endif # ZMK_KSCAN_GPIO_MATRIX

if ZMK_KSCAN_GPIO_DIRECT

choice ZMK_KSCAN_GPIO_DIRECT_INTERRUPT_TYPE
prompt "Direct interrupt type for key press detection"

config ZMK_KSCAN_GPIO_DIRECT_INTERRUPT_TYPE_LEVEL
bool "Level active"

config ZMK_KSCAN_GPIO_DIRECT_INTERRUPT_TYPE_EDGE
bool "Edge to active"

endchoice

endif

if ZMK_KSCAN_GPIO_CHARLIEPLEX

config ZMK_KSCAN_CHARLIEPLEX_WAIT_BEFORE_INPUTS
Expand Down
4 changes: 3 additions & 1 deletion app/module/drivers/kscan/kscan_gpio_direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ static int kscan_direct_interrupt_configure(const struct device *dev, const gpio

#if USE_INTERRUPTS
static int kscan_direct_interrupt_enable(const struct device *dev) {
return kscan_direct_interrupt_configure(dev, GPIO_INT_LEVEL_ACTIVE);
return kscan_direct_interrupt_configure(
dev, COND_CODE_1(IS_ENABLED(CONFIG_ZMK_KSCAN_GPIO_DIRECT_INTERRUPT_TYPE_EDGE),
(GPIO_INT_EDGE_TO_ACTIVE), (GPIO_INT_LEVEL_ACTIVE)));
}
#endif

Expand Down
4 changes: 3 additions & 1 deletion app/module/drivers/kscan/kscan_gpio_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ static int kscan_matrix_interrupt_configure(const struct device *dev, const gpio

#if USE_INTERRUPTS
static int kscan_matrix_interrupt_enable(const struct device *dev) {
int err = kscan_matrix_interrupt_configure(dev, GPIO_INT_LEVEL_ACTIVE);
int err = kscan_matrix_interrupt_configure(
dev, COND_CODE_1(IS_ENABLED(CONFIG_ZMK_KSCAN_GPIO_MATRIX_INTERRUPT_TYPE_EDGE),
(GPIO_INT_EDGE_TO_ACTIVE), (GPIO_INT_LEVEL_ACTIVE)));
if (err) {
return err;
}
Expand Down
20 changes: 12 additions & 8 deletions docs/docs/config/kscan.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ Keyboard scan driver where each key has a dedicated GPIO.

Definition file: [zmk/app/module/drivers/kscan/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/module/drivers/kscan/Kconfig)

| Config | Type | Description | Default |
| --------------------------------- | ---- | ------------------------------------------------ | ------- |
| `CONFIG_ZMK_KSCAN_DIRECT_POLLING` | bool | Poll for key presses instead of using interrupts | n |
| Config | Type | Description | Default |
| --------------------------------------------------- | ---- | ------------------------------------------------ | ------- |
| `CONFIG_ZMK_KSCAN_DIRECT_POLLING` | bool | Poll for key presses instead of using interrupts | n |
| `CONFIG_ZMK_KSCAN_GPIO_DIRECT_INTERRUPT_TYPE_LEVEL` | bool | Use level active interrupts to detect presses | y |
| `CONFIG_ZMK_KSCAN_GPIO_DIRECT_INTERRUPT_TYPE_EDGE` | bool | Use edge to active interrupts to detect presses | n |

### Devicetree

Expand Down Expand Up @@ -121,11 +123,13 @@ Keyboard scan driver where keys are arranged on a matrix with one GPIO per row a

Definition file: [zmk/app/module/drivers/kscan/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/module/drivers/kscan/Kconfig)

| Config | Type | Description | Default |
| ---------------------------------------------- | ----------- | ------------------------------------------------------------------------- | ------- |
| `CONFIG_ZMK_KSCAN_MATRIX_POLLING` | bool | Poll for key presses instead of using interrupts | n |
| `CONFIG_ZMK_KSCAN_MATRIX_WAIT_BEFORE_INPUTS` | int (ticks) | How long to wait before reading input pins after setting output active | 0 |
| `CONFIG_ZMK_KSCAN_MATRIX_WAIT_BETWEEN_OUTPUTS` | int (ticks) | How long to wait between each output to allow previous output to "settle" | 0 |
| Config | Type | Description | Default |
| --------------------------------------------------- | ----------- | ------------------------------------------------------------------------- | ------- |
| `CONFIG_ZMK_KSCAN_MATRIX_POLLING` | bool | Poll for key presses instead of using interrupts | n |
| `CONFIG_ZMK_KSCAN_MATRIX_WAIT_BEFORE_INPUTS` | int (ticks) | How long to wait before reading input pins after setting output active | 0 |
| `CONFIG_ZMK_KSCAN_MATRIX_WAIT_BETWEEN_OUTPUTS` | int (ticks) | How long to wait between each output to allow previous output to "settle" | 0 |
| `CONFIG_ZMK_KSCAN_GPIO_MATRIX_INTERRUPT_TYPE_LEVEL` | bool | Use level active interrupts to detect presses | y |
| `CONFIG_ZMK_KSCAN_GPIO_MATRIX_INTERRUPT_TYPE_EDGE` | bool | Use edge to active interrupts to detect presses | n |

### Devicetree

Expand Down
Loading