#define UART_RX_BUFFER_SIZE 32 /* 1,2,4,8,16,32,64,128 or 256 bytes */
#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1 ) //127
#define UART_TX_BUFFER_SIZE 32 /* 1,2,4,8,16,32,64,128 or 256 bytes */
#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1 ) //127
PIC_Uart.UART_TxBuf[PICUart_TxHead] =0x68;
struct StructUart{
unsigned char UART_RxBuf[UART_RX_BUFFER_SIZE];
unsigned char UART_RxHead;
unsigned char UART_RxTail;
unsigned char UART_TxBuf[UART_TX_BUFFER_SIZE];
unsigned char UART_TxHead;
unsigned char UART_TxTail;
};
void DATApack_senddata(unsigned char Pdata[],unsigned char con_word,unsigned char num)
{
unsigned char i;
PIC_Uart.UART_TxBuf[PICUart_TxHead] =0x68;
PIC_Uart.UART_TxBuf[PICUart_TxHead] =0x00;
PIC_Uart.UART_TxBuf[PICUart_TxHead] =Dever_ID;
PIC_Uart.UART_TxBuf[PICUart_TxHead] =con_word;
PIC_Uart.UART_TxBuf[PICUart_TxHead]=num;
for(i=0;i<num;i++)
PIC_Uart.UART_TxBuf[PICUart_TxHead]=Pdata[i];
PIC_Uart.UART_TxBuf[PICUart_TxHead]=Parity_bit(PIC_Uart.UART_TxBuf+1,4+num);
PIC_Uart.UART_TxBuf[PICUart_TxHead]=0x16;
TXEN=1;//发送使能位
}
|