Código de estrellas

/ ************************************************* ****************************** 
* Nombre de la función: USART1_Init 
* Función de la función: función de inicialización de USART1 
* Entrada: límite: Velocidad de transmisión 
* Salida: Ninguna 
************************************************ ********************************* / 
void USART1_Init (u32 enlazado) 
{ 
   // Configuración del puerto GPIO 
    GPIO_InitTypeDef GPIO_InitStructure; 
    USART_InitTypeDef USART_InitStructure; 
    NVIC_InitTypeDef NVIC_InitStructure; 
    
    RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOA, ENABLE); // Habilitar reloj 
    GPIOA RCC_APB2PeriphClockCmd (RCC_APB2Periph_US)
  
    / / /
    GPIO_PinAFConfig (GPIOA, GPIO_PinSource9, GPIO_AF_USART1) ; // GPIOA9 multiplexa en el USART1 
    GPIO_PinAFConfig (con GPIOA, GPIO_PinSource10, GPIO_AF_USART1); // GPIOA10 multiplexados en el USART1 
    
    // la configuración del puerto USART1 
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; // GPIOA9 con GPIOA10 
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; // función de multiplexación con 
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // velocidad 50MHz 
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // salida push-pull multiplexación 
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; // tirón
    GPIO_Init (GPIOA, & GPIO_InitStructure); // Inicializar PA9, PA10 
    
 
   // el USART1 Inicializar configuraciones
    USART_InitStructure.USART_BaudRate = encuadernado; // Configuración de la tasa de baudios 
    USART_InitStructure.USART_WordLength = USART_WordLength_8b; // La longitud de la palabra es de 8 bits 
    . bit 
    USART_InitStructure.USART_Parity = USART_Parity_No; // sin paridad 
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // control de flujo sin necesidad de hardware 
    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; // modo de transceptor 
    USART_Init (USART1, y USART_InitStructure); // inicializar el puerto serie 1
    
    USART_Cmd (USART1, ENABLE); // Habilitar puerto serie 1 
    
    
    USART_ClearFlag (USART1, USART_FLAG_TC); 
        
    USART_ITConfig (USART1, USART_IT_RXNE, ENABLE); // Habilitar interrupciones relacionadas 

    // Usart1 NVIC configuración 
    NVIC_InitStructure.NVIC_ARTQ1hannel = USVART_ART1Channel = USVART_ART1Channel = USVART_ARTQ1hannel Channel 
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; // Prioridad de 
    preajuste 3 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; // Sub-prioridad 3 
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; // 
    IRQItitIn_It_InIC_It_InIC_It_InIC está habilitado para NVIC_InIC. registrarse     

}

 

 

Supongo que te gusta

Origin www.cnblogs.com/4nianlaoqun/p/12702309.html
Recomendado
Clasificación