mirror of https://github.com/ARMmbed/mbed-os.git
[STM32F4] Introduce a function that sets gpio mode w/o changin pull mode
This function reads the pull mode from HW and can then be used to avoid over-writing the previously set pull-up / pull-down modes. This is done following reported issue: #2638pull/2920/head
parent
646cc89a62
commit
e516bddc66
|
@ -178,5 +178,20 @@ void pin_mode(PinName pin, PinMode mode)
|
|||
}
|
||||
gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2)));
|
||||
gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2));
|
||||
|
||||
}
|
||||
|
||||
/* Internal function for setting the gpiomode/function
|
||||
* without changing Pull mode
|
||||
*/
|
||||
void pin_function_gpiomode(PinName pin, uint32_t gpiomode) {
|
||||
|
||||
/* Read current pull state from HW to avoid over-write*/
|
||||
uint32_t port_index = STM_PORT(pin);
|
||||
uint32_t pin_index = STM_PIN(pin);
|
||||
GPIO_TypeDef *gpio = (GPIO_TypeDef *) Set_GPIO_Clock(port_index);
|
||||
uint32_t temp = gpio->PUPDR;
|
||||
uint32_t pull = (temp >> (pin_index * 2U)) & GPIO_PUPDR_PUPDR0;
|
||||
|
||||
/* Then re-use global function for updating the mode part*/
|
||||
pin_function(pin, STM_PIN_DATA(gpiomode, pull, 0));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue