Add peripheral-wide reset function for gpios

This commit is contained in:
Steins7 2023-05-13 13:21:26 +02:00
parent d9170ee902
commit 8dc58b6747
2 changed files with 16 additions and 3 deletions

View File

@ -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-------------------------------------------------------------

View File

@ -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_