void usart_init(void)
{
/* Enable USART2 APB clock */
RCC_APB2PeriphClock_Enable(RCC_APB2PERIPH_USART1, ENABLE);
/* USART1 Pins configuration **************************************************/
{
/* Configure the GPIO ports */
GPIO_InitPara GPIO_InitStructure;
/* Connect pin to Periph */
GPIO_PinAFConfig(GPIOA , GPIO_PINSOURCE9, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA , GPIO_PINSOURCE10, GPIO_AF_1);
/* Configure pins as AF pushpull */
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_9 | GPIO_PIN_10;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_50MHZ;
GPIO_InitStructure.GPIO_OType = GPIO_OTYPE_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PUPD_NOPULL;
GPIO_Init(GPIOA , &GPIO_InitStructure);
} //GPIO setting
{
USART_InitPara USART_InitStructure;
USART_DeInit(USART1);
USART_InitStructure.USART_BRR =9600;
USART_InitStructure.USART_WL
GD32芯片的USART1初始化代码
最新推荐文章于 2024-05-14 17:13:21 发布