machine: Rewrite most of the GPIO functionality

Split across device types (nrf, dummy) and use registers directly
instead of the HAL.
This commit is contained in:
Ayke van Laethem
2018-05-05 20:02:00 +02:00
parent 16489c0df6
commit c4f0dc90dd
5 changed files with 77 additions and 38 deletions
-14
View File
@@ -48,20 +48,6 @@ void RTC0_IRQHandler() {
rtc_wakeup = true;
}
void gpio_cfg(uint32_t pin, gpio_mode_t mode) {
nrf_gpio_cfg(
pin,
mode == GPIO_INPUT ? NRF_GPIO_PIN_DIR_INPUT : NRF_GPIO_PIN_DIR_OUTPUT,
mode == GPIO_INPUT ? NRF_GPIO_PIN_INPUT_CONNECT : NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL,
NRF_GPIO_PIN_S0S1,
NRF_GPIO_PIN_NOSENSE);
}
void gpio_set(uint32_t pin, bool high) {
nrf_gpio_pin_write(pin, high);
}
void _start() {
main();
}
-8
View File
@@ -9,11 +9,3 @@ void uart_send(uint8_t c);
void rtc_init();
void rtc_sleep(uint32_t ticks);
typedef enum {
GPIO_INPUT,
GPIO_OUTPUT,
} gpio_mode_t;
void gpio_cfg(uint32_t pin, gpio_mode_t mode);
void gpio_set(uint32_t pin, bool high);