1
0
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:
Martine Lenders 2019-03-27 00:09:21 +01:00 committed by GitHub
commit 1ef525340c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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