mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-26 03:32:17 +00:00
bdk: gpio: add debounce set function
The debounce time is not per pin but per bank. So software should manage proper time for sibling pins
This commit is contained in:
parent
1edb6583ac
commit
107fbd1d24
2 changed files with 21 additions and 0 deletions
|
@ -110,6 +110,26 @@ int gpio_read(u32 port, u32 pins)
|
||||||
return (GPIO(port_offset) & pins) ? 1 : 0;
|
return (GPIO(port_offset) & pins) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gpio_set_debounce(u32 port, u32 pins, u32 ms)
|
||||||
|
{
|
||||||
|
const u32 db_ctrl_offset = GPIO_DB_CTRL_OFFSET(port);
|
||||||
|
const u32 db_cnt_offset = GPIO_DB_CNT_OFFSET(port);
|
||||||
|
|
||||||
|
if (ms)
|
||||||
|
{
|
||||||
|
if (ms > 255)
|
||||||
|
ms = 255;
|
||||||
|
|
||||||
|
// Debounce time affects all pins of the same port.
|
||||||
|
GPIO(db_cnt_offset) = ms;
|
||||||
|
GPIO(db_ctrl_offset) = (pins << 8) | pins;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
GPIO(db_ctrl_offset) = (pins << 8) | 0;
|
||||||
|
|
||||||
|
(void)GPIO(db_ctrl_offset); // Commit the write.
|
||||||
|
}
|
||||||
|
|
||||||
static void _gpio_interrupt_clear(u32 port, u32 pins)
|
static void _gpio_interrupt_clear(u32 port, u32 pins)
|
||||||
{
|
{
|
||||||
const u32 port_offset = GPIO_INT_CLR_OFFSET(port);
|
const u32 port_offset = GPIO_INT_CLR_OFFSET(port);
|
||||||
|
|
|
@ -89,6 +89,7 @@ void gpio_direction_input(u32 port, u32 pins);
|
||||||
void gpio_direction_output(u32 port, u32 pins, int high);
|
void gpio_direction_output(u32 port, u32 pins, int high);
|
||||||
void gpio_write(u32 port, u32 pins, int high);
|
void gpio_write(u32 port, u32 pins, int high);
|
||||||
int gpio_read(u32 port, u32 pins);
|
int gpio_read(u32 port, u32 pins);
|
||||||
|
void gpio_set_debounce(u32 port, u32 pins, u32 ms);
|
||||||
int gpio_interrupt_status(u32 port, u32 pins);
|
int gpio_interrupt_status(u32 port, u32 pins);
|
||||||
void gpio_interrupt_enable(u32 port, u32 pins, int enable);
|
void gpio_interrupt_enable(u32 port, u32 pins, int enable);
|
||||||
void gpio_interrupt_level(u32 port, u32 pins, int high, int edge, int delta);
|
void gpio_interrupt_level(u32 port, u32 pins, int high, int edge, int delta);
|
||||||
|
|
Loading…
Reference in a new issue