?? uartintc.h
字號:
/*******************************************************************************
sioapi.h
********************************************************************************
Written by: Shaheen Mahomed
nSoft Developement.
********************************************************************************
0.00aA 17 Jun 04 SSM Began project
0.00aD 15 Sep 04 BDW Making build compatible with new Protocessors
0.00aI 11 Oct 04 BDW Increasing SIO buffer sizes
*******************************************************************************/
// Processor oerating parameters
#define UART_CLOCK_FREQ 10000000
#define DEFAULT_UART_BAUDRATE 9600
#define BRGH_VAL 1
// RS485 Config
#define ENABLE_SER1_RS485 'N'
#define ENABLE_SER2_RS485 'Y'
// Buffer sizes
#define TX_BUFFER_SIZE SIO_TX_BUFFER_SIZE
#define RX_BUFFER_SIZE SIO_RX_BUFFER_SIZE
#define TXSTA TXSTA1
#define RCSTA RCSTA1
#define TXSTAbits TXSTA1bits
#define RCSTAbits RCSTA1bits
#define TXREG TXREG1
#define RCREG RCREG1
#define SPBRG SPBRG1
#define PORTS 2
typedef struct
{
UINT UARTIntTxBufferFull :1;
UINT UARTIntTxBufferEmpty :1;
// variables representing status of transmission buffer and
// transmission buffer it self are declared below
BYTE vUARTIntTxBuffer[TX_BUFFER_SIZE];
BYTE vUARTIntTxBufDataCnt;
BYTE vUARTIntTxBufWrPtr;
BYTE vUARTIntTxBufRdPtr;
} tx_status ;
typedef struct
{
UINT UARTIntRxBufferFull :1;
UINT UARTIntRxBufferEmpty :1;
UINT UARTIntRxOverFlow :1;
UINT UARTIntRxError :1;
// variables referring the status of receive buffer.
BYTE vUARTIntRxBuffer[RX_BUFFER_SIZE];
BYTE vUARTIntRxBufDataCnt;
BYTE vUARTIntRxBufWrPtr;
BYTE vUARTIntRxBufRdPtr;
} rx_status ;
// functions offered by this module
// function returns a character from receive buffer
BYTE UARTIntGetChar(UINT);
// function returns the number of characters in receive buffer
BYTE UARTIntGetRxBufferDataSize(UINT);
// function to put a character in Transmit buffer
BYTE UARTIntPutChar(UINT, BYTE);
//function to put a hole string in the transmit buffer
BYTE UARTIntPutString(UINT, BYTE*,UINT);
// function returns size of the empty section of Transmit buffer
BYTE UARTIntGetTxBufferDataSize(UINT);
// Initialisation of the module
VOID UARTIntInit (UINT);
// Interrupt service routine supplied by the module.This need to be
// called from ISR of the main program.
VOID UARTIntISR (VOID);
//used to set baud rate, parity, no of data bits, and no of stop bits
BYTE mSetUARTPort (UINT, UINT, UINT);
//used to set and check the parity bit when parity has been selected
VOID addParityBit (UINT, BYTE);
BYTE checkParityBit (UINT, BYTE);
//used to disable and enable transmitter interrupts
VOID mDisableUARTTxInt (UINT);
VOID mEnableUARTTxInt (UINT);
//used to disable and enable receiver interrupts
VOID mDisableUARTRxInt (UINT);
VOID mEnableUARTRxInt (UINT);
//used to set the receiver interrupts to higher or lower priority
VOID mSetUARTRxIntHighPrior (UINT);
VOID mSetUARTRxIntLowPrior (UINT);
//used to set the transmitter interrupts to higher or lower priority
VOID mSetUARTTxIntHighPrior (UINT);
VOID mSetUARTTxIntLowPrior (UINT);
//used to set the UART baud rate to higher or lower speeds
VOID mSetUART_BRGHHigh (UINT);
VOID mSetUART_BRGHLow (UINT);
//used to drive the RTS line for the RS485 high or low
VOID mSetRS485_RTSHigh ( UINT iport) ;
VOID mSetRS485_RTSLow ( UINT iport) ;
//used to set the UART Baud rate
VOID mSetUARTBaud (UINT, UINT);
BYTE mCheckPortHandle (UINT);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -