![ARTERY AT32F421 GPIO User Manual Download Page 15](http://html1.mh-extra.com/html/artery/at32f421-gpio/at32f421-gpio_user-manual_2977597015.webp)
AT32F421 GPIO user guide
2020.07.30
15
Rev.1.0.0
/* Connect PA9 to USART1_Tx */
GPIO_PinAFConfig(GPIOA, GPIO_PinsSource9, GPIO_AF_1);
/* Connect PA10 to USART1_Rx */
GPIO_PinAFConfig(GPIOA, GPIO_PinsSource10, GPIO_AF_1);
/* Configure USART2_Tx and USART2_Rx as alternate functions */
GPIO_InitStructure.GPIO_Pins = GPIO_Pins_9 | GPIO_Pins_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OutType = GPIO_OutType_PP;
GPIO_InitStructure.GPIO_Pull = GPIO_Pull_NOPULL;
GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
TMR I/O alternate function mode configuration
/* Enable AHB interface clock of GPIOA*/
RCC_AHBPeriphClockCmd(RCC_AHBPERIPH_GPIOA, ENABLE);
/* Connect PA6 to TMR1_BKIN */
GPIO_PinAFConfig(GPIOA, GPIO_PinsSource6, GPIO_AF_2);
/* Connect PA8 to TMR1_CH1 */
GPIO_PinAFConfig(GPIOA, GPIO_PinsSource8, GPIO_AF_2);
/* Connect PA12 to TMR1_ETR */
GPIO_PinAFConfig(GPIOA, GPIO_PinsSource12, GPIO_AF_2);
/* Configure TMR1 pins(PA6/PA8/PA12) as alternate functions */
GPIO_InitStructure.GPIO_Pins = GPIO_Pins_6 | GPIO_Pins_8 | GPIO_Pins_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OutType = GPIO_OutType_PP;
GPIO_InitStructure.GPIO_Pull = GPIO_Pull_NOPULL;
GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
I2C I/O alternate function mode configuration
/* Enable AHB interface clock of GPIOB */
RCC_AHBPeriphClockCmd(RCC_AHBPERIPH_GPIOB, ENABLE);