diff --git a/drivers/gpio.c b/drivers/gpio.c index 5ef4cd1..d1a7922 100644 --- a/drivers/gpio.c +++ b/drivers/gpio.c @@ -15,11 +15,11 @@ //--local definitions----------------------------------------------------------- +//--local variables------------------------------------------------------------- + static volatile struct GPIO* regs = (struct GPIO*)GPIO_BASE_ADDRESS; -//--local variables------------------------------------------------------------- - //--public functions------------------------------------------------------------ /** @@ -83,6 +83,13 @@ bool gpio_read(enum GpioPort port, enum GpioPin pin_mask) return (regs->PORTS[port].IDR.word & pin_mask) == pin_mask; } +void gpio_reset_peripheral(void) +{ + rcc_disable(RCC_AHB_NONE, RCC_APB1_NONE, RCC_APB2_IOPA | RCC_APB2_IOPB + | RCC_APB2_IOPC | RCC_APB2_IOPD | RCC_APB2_IOPE | RCC_APB2_IOPF + | RCC_APB2_IOPG); +} + //--local functions------------------------------------------------------------- diff --git a/drivers/gpio.h b/drivers/gpio.h index 7a12484..6453764 100644 --- a/drivers/gpio.h +++ b/drivers/gpio.h @@ -114,6 +114,12 @@ void gpio_write(enum GpioPort port, enum GpioPin pin_mask, bool value); */ bool gpio_read(enum GpioPort port, enum GpioPin pin_mask); +/** + * Resets all gpios and disable all ports. The gpio peripherals are returned to + * their reset configuration and their respective clocks disabled + */ +void gpio_reset_peripheral(void); -#endif //_RCC_H_ + +#endif //_GPIO_H_