Skip to content

Commit d5dbdb6

Browse files
committed
fix HardwareSerial::begin by doing gpio_set_af_mode AF8 when devices are UART4 or UART5
1 parent 17edc37 commit d5dbdb6

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

STM32F4/cores/maple/libmaple/HardwareSerial.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,14 @@ void HardwareSerial::begin(uint32 baud) {
9494
const stm32_pin_info *rxi = &PIN_MAP[rx_pin];
9595
#ifdef STM32F2
9696
// int af = 7<<8;
97-
gpio_set_af_mode(txi->gpio_device, txi->gpio_bit, 7);
98-
gpio_set_af_mode(rxi->gpio_device, rxi->gpio_bit, 7);
97+
if (usart_device == UART4 || usart_device == UART5) {
98+
gpio_set_af_mode(txi->gpio_device, txi->gpio_bit, 8);
99+
gpio_set_af_mode(rxi->gpio_device, rxi->gpio_bit, 8);
100+
}
101+
else {
102+
gpio_set_af_mode(txi->gpio_device, txi->gpio_bit, 7);
103+
gpio_set_af_mode(rxi->gpio_device, rxi->gpio_bit, 7);
104+
}
99105
gpio_set_mode(txi->gpio_device, txi->gpio_bit, (gpio_pin_mode)(GPIO_AF_OUTPUT_PP | GPIO_PUPD_INPUT_PU | 0x700));
100106
gpio_set_mode(rxi->gpio_device, rxi->gpio_bit, (gpio_pin_mode)(GPIO_MODE_AF | GPIO_PUPD_INPUT_PU | 0x700));
101107
//gpio_set_mode(txi->gpio_device, txi->gpio_bit, (gpio_pin_mode)(GPIO_PUPD_INPUT_PU));

0 commit comments

Comments
 (0)