Example #1
0
void serial_init(void)
{
    Timer2_Stop();

    // S1_USE_P30P31(); // Use the MCU RXD/TXD programmer port for UART1
    S1_USE_P36P37();    // Use the WIFI RXD1/TXD1 port for UART1
    S1_8bit();
    S1_RX_Enable();
    S1_BRT_UseTimer2();

    Timer2_Load(Timer2_Reload);
    Timer2_AsTimer();
    Timer2_1T();

    PS = 1; // Defines the serial port interrupt priority level.
    
    RI = 0;
    TI = 0;
    
    stx_index_in = srx_index_in = stx_index_out = srx_index_out = 0;
    rx_serial_buffer_empty = tx_serial_buffer_empty = 1;
    work_flag_buffer_transfered = 0;
    work_flag_byte_arrived = 0;

    ES=1; // Enable serial port interrupt.

    Timer2_Run();
}
Example #2
0
void Bk8000l_Init() {

    memset(TX1_Buffer, 0, COM_TX1_Lenth);
    USART_Init(&COM1);

    S1_8bit();
    S1_BRT_UseTimer2();     // S1 BRT Use Timer2;

    S1_Int_Enable();        // 允许中断
    S1_RX_Enable();         // Rx 接收允许
    S1_USE_P30P31();
    S1_TXD_RXD_OPEN();

    USART_Share_Timer2();
}