mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c
- Revision:
- 80:66393a7b209d
- Parent:
- 76:aeb1df146756
- Child:
- 84:f54042cbc282
diff -r 6fdc4ea80ae0 -r 66393a7b209d targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c --- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c Thu Jan 30 09:45:05 2014 +0000 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c Thu Jan 30 12:15:05 2014 +0000 @@ -90,20 +90,21 @@ // Enable GPIO clock uint32_t gpio_add = Set_GPIO_Clock(port_index); gpio = (GPIO_TypeDef *)gpio_add; - + // Enable AFIO clock RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); + + // Configure Alternate Function + // Warning: Must be done before the GPIO is initialized + if (afnum > 0) { + GPIO_PinRemapConfig(AF_mapping[afnum], ENABLE); + } // Configure GPIO GPIO_InitStructure.GPIO_Pin = (uint16_t)(1 << pin_index); GPIO_InitStructure.GPIO_Mode = (GPIOMode_TypeDef)mode; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(gpio, &GPIO_InitStructure); - - // Configure Alternate Function - if (afnum > 0) { - GPIO_PinRemapConfig(AF_mapping[afnum], ENABLE); - } // Disconnect JTAG-DP + SW-DP signals. // Warning: Need to reconnect under reset