⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uartintc.h

📁 build a modbus client/server for use on the Protocessor (from FieldServer Technologies) Tools Req
💻 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);


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -