|
|
typedef struct Uartx_Define{
u8 id;
u16 Tx_Read;
u16 Tx_Write;
u8 Tx_Busy;
u16 Rx_Read;
u16 Rx_Write;
u8 Rx_Busy;
u8 Rx_Flag;
u8 Rx_Buffer[Uart2_Rx_Lenth];
u8 Tx_Buffer[Uart2_Tx_Lenth];
} *P_S_UART;
void Uart2_Init(u32 baud_rate){
u16 i;
Uart2.id = 2;
Uart2.Tx_Read = 0;
Uart2.Tx_Write = 0;
Uart2.Tx_Busy = 0;
Uart2.Rx_Read = 0;
Uart2.Rx_Write = 0;
Uart2.Rx_Busy = 0;
Uart2.Rx_Flag = Uart_Rev_Pre;
for(i = 0; i < Uart2_Tx_Lenth; i++) Uart2.Tx_Buffer[ i] = 0;[ i]
for(i = 0; i < Uart2_Rx_Lenth; i++) Uart2.Rx_Buffer[ i] = 0;[ i]
i=1024-FOSC/64/baud_rate;
MUX_SEL |= 0x40;
P0MDOUT &= 0xCF;
P0MDOUT |= 0x10;
ADCON = 0x80;
SCON0 = 0x50;
SREL0H = (u8)(i>>8); /
SREL0L = (u8)i; // S_2/115200=224=0X03E4 1024-206438400/(64*115200)=0X03E4
ES0 = 1;
EA=1;
}
代碼復(fù)制例程。
請(qǐng)問 *P_S_UART; 怎么定義,怎么操作Uart2里成員?
|
|