| 【USART初始化】 
 根据以上配置对USART进行初始化。
 
 函数原型:   void UsartInt( void )
 
 功能说明:   USART初始化
 
 输入参数:   无
 
 输出参数:   无
 
 特殊备注:   需配合Usart.h中的配置
 
 void UsartInt( void )
 
{
 
    uint32_t u32Fcg1Periph = PWC_FCG1_PERIPH_USART1 | PWC_FCG1_PERIPH_USART2 | \ PWC_FCG1_PERIPH_USART3 | PWC_FCG1_PERIPH_USART4;
 
    const stc_usart_uart_init_t stcInitCfg = {
 
        UsartIntClkCkNoOutput,
 
        UsartClkDiv_1,
 
        UsartDataBits8,
 
        UsartDataLsbFirst,
 
        UsartOneStopBit,
 
        UsartParityNone,
 
        UsartSampleBit8,
 
        UsartStartBitFallEdge,
 
        UsartRtsEnable,
 
    };
 
    /* Enable peripheral clock */
 
    PWC_Fcg1PeriphClockCmd(u32Fcg1Periph, Enable);
 
#if (USART1_EN == 1 )
 
    /* Initialize USART IO */
 
    PORT_SetFunc( ( en_port_t )USART1_PORT, ( en_pin_t )RX1_PIN, Func_Usart1_Rx, Disable);
 
    PORT_SetFunc( ( en_port_t )USART1_PORT, ( en_pin_t )TX1_PIN, Func_Usart1_Tx, Disable);
 
    /* Initialize UART */
 
    USART_UART_Init(USART1, &stcInitCfg);
 
    /* Set baudrate */
 
    USART_SetBaudrate(USART1, USART1_BAUD);
 
    /*Enable RX && TX function*/
 
    USART_FuncCmd(USART1, UsartRx, Enable);
 
    USART_FuncCmd(USART1, UsartTx, Enable);
 
#endif
 
#if (USART2_EN == 1 )
 
………………………………………
 
#endif
 
#if (USART3_EN == 1 )
 
………………………………………
 
#endif
 
#if (USART4_EN == 1 )
 
………………………………………
 
#endif
 
}
 |