- stm_afr_set(&stm_gpiod, 5, STM_AFR_AF7);
- stm_afr_set(&stm_gpiod, 6, STM_AFR_AF7);
-#if USE_SERIAL_2_FLOW
-#error "Don't know how to set flowcontrol for serial 2 on PD"
-#endif
+ stm_gpio_conf(&stm_gpiod, 6,
+ STM_GPIO_CR_MODE_INPUT,
+ STM_GPIO_CR_CNF_INPUT_FLOATING);
+
+# if USE_SERIAL_2_FLOW
+# if USE_SERIAL_2_SW_FLOW
+ ao_serial_set_sw_rts_cts(&ao_stm_usart2,
+ ao_serial2_cts,
+ SERIAL_2_PORT_RTS,
+ SERIAL_2_PIN_RTS,
+ SERIAL_2_PORT_CTS,
+ SERIAL_2_PIN_CTS);
+# else
+ stm_gpio_conf(&stm_gpiod, 3, /* CTS */
+ STM_GPIO_CR_MODE_INPUT,
+ STM_GPIO_CR_CNF_INPUT_FLOATING);
+ stm_gpio_conf(&stm_gpiod, 4, /* RTS */
+ STM_GPIO_CR_MODE_OUTPUT_2MHZ,
+ STM_GPIO_CR_CNF_OUTPUT_AF_PUSH_PULL);
+
+# endif
+# endif
+ stm_set_afio_mapr(STM_AFIO_MAPR_USART2_REMAP,
+ STM_AFIO_MAPR_USART2_REMAP_PD3_PD4_PD5_PD6_PD7,
+ STM_AFIO_MAPR_USART2_REMAP_MASK);