Add peripheral-wide reset function for gpios
This commit is contained in:
parent
d9170ee902
commit
8dc58b6747
@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
//--local definitions-----------------------------------------------------------
|
//--local definitions-----------------------------------------------------------
|
||||||
|
|
||||||
|
//--local variables-------------------------------------------------------------
|
||||||
|
|
||||||
static volatile struct GPIO* regs = (struct GPIO*)GPIO_BASE_ADDRESS;
|
static volatile struct GPIO* regs = (struct GPIO*)GPIO_BASE_ADDRESS;
|
||||||
|
|
||||||
|
|
||||||
//--local variables-------------------------------------------------------------
|
|
||||||
|
|
||||||
//--public functions------------------------------------------------------------
|
//--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;
|
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-------------------------------------------------------------
|
//--local functions-------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
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_
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user