1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-22 18:06:40 +00:00

bdk: gpio: add simple gpio direction functions

This commit is contained in:
CTCaer 2023-02-11 22:55:22 +02:00
parent 4e15e034b8
commit 05b5e4f297
2 changed files with 15 additions and 0 deletions

View file

@ -86,6 +86,19 @@ void gpio_write(u32 port, u32 pins, int high)
(void)GPIO(port_offset); // Commit the write.
}
void gpio_direction_input(u32 port, u32 pins)
{
gpio_config(port, pins, GPIO_MODE_GPIO);
gpio_output_enable(port, pins, GPIO_OUTPUT_DISABLE);
}
void gpio_direction_output(u32 port, u32 pins, int high)
{
gpio_config(port, pins, GPIO_MODE_GPIO);
gpio_output_enable(port, pins, GPIO_OUTPUT_ENABLE);
gpio_write(port, pins, high);
}
int gpio_read(u32 port, u32 pins)
{
u32 port_offset = GPIO_IN_OFFSET(port);

View file

@ -85,6 +85,8 @@
void gpio_config(u32 port, u32 pins, int mode);
void gpio_output_enable(u32 port, u32 pins, int enable);
void gpio_direction_input(u32 port, u32 pins);
void gpio_direction_output(u32 port, u32 pins, int high);
void gpio_write(u32 port, u32 pins, int high);
int gpio_read(u32 port, u32 pins);
int gpio_interrupt_status(u32 port, u32 pins);