mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #11287 from MichelRottleuthner/pr_stm32f103_fix_gpiob4_remapping
cpu/stm32f103: make gpio B4 usable as output pin
This commit is contained in:
commit
1ef525340c
@ -88,6 +88,16 @@ int gpio_init(gpio_t pin, gpio_mode_t mode)
|
||||
/* enable the clock for the selected port */
|
||||
periph_clk_en(APB2, (RCC_APB2ENR_IOPAEN << _port_num(pin)));
|
||||
|
||||
#ifdef BOARD_NUCLEO_F103RB
|
||||
/* disable the default SWJ RST mode to allow using the pin as IO
|
||||
this may also work on other f103 based boards but it was only tested on
|
||||
nucleo-f103rb */
|
||||
if ((pin_num == 4) && _port_num(pin)) {
|
||||
RCC->APB2ENR |= RCC_APB2ENR_AFIOEN;
|
||||
AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_NOJNTRST;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* set pin mode */
|
||||
port->CR[pin_num >> 3] &= ~(0xf << ((pin_num & 0x7) * 4));
|
||||
port->CR[pin_num >> 3] |= ((mode & MODE_MASK) << ((pin_num & 0x7) * 4));
|
||||
|
Loading…
Reference in New Issue
Block a user