📄 uartfax.h
字号:
//==================================================================================
#ifndef __UARTFAX_H__
#define __UARTFAX_H__
#include "faxdata.h"
#include "uartfax.h"
/*
* In UAF_Init, a constant is used to identify the UART.
*/
#define FALSE 0
#define TRUE 1
typedef unsigned char UBYTE;
typedef UBYTE BOOL;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
typedef unsigned int UINT;
/*
* 3 HISR are used to avoid to execute operations from the LISR.
*/
#define RX_HISR_PRIORITY (1)
#define RX_HISR_STACK_SIZE ( 4096 ) /* Bytes. */
#define TX_HISR_PRIORITY (2)
#define TX_HISR_STACK_SIZE (4096) /* Bytes. */
#define V24_HISR_PRIORITY (2)
#define V24_HISR_STACK_SIZE (4096) /* Bytes. */
#define FIFO_SIZE (64) /* In bytes. */
#define MINIMAL_BREAK_LENGTH (2)
#define BREAK_HISR_PRIORITY (2)
#define BREAK_HISR_STACK_SIZE (512) /* Bytes. */
#define USB_UAF_ID 1
/*******************************************************************************
*
* UAF_Init
*
* Purpose : Initializes the UART hardware and installs interrupt handlers.
* The parameters are set to the default values:
* - 19200 baud,
* - 8 bits / character,
* - no parity,
* - 1 stop bit,
* - no flow control.
* All functionalities of the UART driver are disabled.
*
* Arguments: In : uartNo: Used UART.
* Out: none
*
* Returns : FD_OK : Successful operation.
* FD_NOT_SUPPORTED: Wrong UART number.
* FD_INTERNAL_ERR : Internal problem.
*
******************************************************************************/
T_FDRET UAF_Init (T_tr_UartId uartNo);
/*******************************************************************************
*
* UAF_Enable
*
* Purpose : The functionalities of the UART driver are disabled or enabled.
* In the deactivated state, all information about the communication
* parameters should be stored and recalled if the driver is again
* enabled. When the driver is enabled the RX and TX buffers are
* cleared.
*
* Arguments: In : uartNo: Used UART.
* : enable: 1: enable the driver
* 0: disable the driver
* Out: none
*
* Returns : FD_OK : Successful operation.
* FD_NOT_SUPPORTED: Wrong UART number.
* FD_INTERNAL_ERR : Internal problem with the hardware.
*
******************************************************************************/
T_FDRET UAF_Enable (T_tr_UartId uartNo,
SYS_BOOL enable);
/*******************************************************************************
*
* UAF_SetComPar
*
* Purpose : Sets up the communication parameters: baud rate, bits per
* character, number of stop bits, parity.
*
* Arguments: In : uartNo : Used UART.
* baudrate: Used baud rate.
* bpc : Used bits per character.
* sb : Used stop bits.
* parity : Used parity.
* Out: none
*
* Returns : FD_OK : Successful operation.
* FD_NOT_SUPPORTED: The specified parameters don't fit to the
* capabilities of the UART or wrong UART number.
* FD_INTERNAL_ERR : Internal problem with the hardware.
*
******************************************************************************/
T_FDRET UAF_SetComPar (T_tr_UartId uartNo,
T_baudrate baudrate,
T_bitsPerCharacter bpc,
T_stopBits sb,
T_parity parity);
/*******************************************************************************
*
* UAF_SetBuffer
*
* Purpose : Sets up the size of the circular buffers to be used in the UART
* driver. This function may be called only if the UART is disabled
* with UAF_Enable.
*
* Arguments: In : uartNo : Used UART.
* bufSize : Specifies the size of the circular buffer.
* rxThreshold: Amount of received bytes that leads to a call
* to suspended read-out function which is passed
* to the function UAF_ReadData.
* txThreshold: Amount of bytes in the TX buffer to call the
* suspended write-in function which is passed to
* the function UAF_WriteData
* Out: none
*
* Returns : FD_OK : Successful operation.
* FD_NOT_SUPPORTED: bufSize exceeds the maximal possible
* capabilities of the driver or the threshold
* values don't correspond to the bufSize or
* wrong UART number.
* FD_INTERNAL_ERR : Internal problem with the hardware or the
* function has been called while the UART is
* enabled.
*
******************************************************************************/
T_FDRET UAF_SetBuffer (T_tr_UartId uartNo,
SYS_UWORD16 bufSize,
SYS_UWORD16 rxThreshold,
SYS_UWORD16 txThreshold);
/*******************************************************************************
*
* UAF_SetFlowCtrl
*
* Purpose : Changes the flow control mode of the UART driver.
* If a flow control is activated, DTR is activated or XOFF is sent
* if the RX buffer is not able to store the received characters else
* DTR is deactivated or XON is sent.
*
* Arguments: In : uartNo: Used UART.
* fcMode: flow control mode (none, DTR/DSR, RTS/CTS, XON/XOFF).
* XON : ASCII code of the XON character.
* XOFF : ASCII code of the XOFF character.
* Out: none
*
* Returns : FD_OK : Successful operation.
* FD_NOT_SUPPORTED: The flow control mode is not supported or wrong
* UART number.
* FD_INTERNAL_ERR : Internal problem with the hardware.
*
******************************************************************************/
T_FDRET UAF_SetFlowCtrl (T_tr_UartId uartNo,
T_flowCtrlMode fcMode,
SYS_UWORD8 XON,
SYS_UWORD8 XOFF);
/*******************************************************************************
*
* UAF_SetEscape
*
* Purpose : To return to the command mode at the ACI while a data connection
* is established, an escape sequence has to be detected.
* To distinguish between user data and the escape sequence a
* defined guard period is necessary before and after this sequence.
*
* Arguments: In: uartNo : Used UART.
* escChar : ASCII character which could appear three times
* as an escape sequence.
* guardPeriod: Denotes the minimal duration of the rest before
* the first and after the last character of the
* escape sequence, and the maximal receiving
* duration of the whole escape string. This value
* is expressed in ms.
* Out: none
*
* Returns : FD_OK : Successful operation.
* FD_NOT_SUPPORTED: Wrong UART number.
* FD_INTERNAL_ERR : Internal problem with the hardware.
*
******************************************************************************/
T_FDRET UAF_SetEscape (T_tr_UartId uartNo,
SYS_UWORD8 escChar,
SYS_UWORD16 guardPeriod);
/*******************************************************************************
*
* UAF_InpAvail
*
* Purpose : Returns the number of characters available in the RX buffer of the
* driver. If the driver is disabled the function returns 0.
*
* Arguments: In : uartNo: Used UART.
* Out: none
*
* Returns : >= 0 : The returned value is the amount of data in the
* RX buffer.
* FD_NOT_SUPPORTED: Wrong UART number.
* FD_NOT_READY : The function is called while the callback of the
* readOutFunc function is activated and still not
* terminated.
* FD_INTERNAL_ERR : Internal problem with the hardware.
*
******************************************************************************/
T_FDRET UAF_InpAvail (T_tr_UartId uartNo);
/*******************************************************************************
*
* UAF_OutpAvail
*
* Purpose : Returns the number of free characters in TX buffer of the driver.
* If the driver is disabled the function returns 0.
*
* Arguments: In : uartNo: Used UART.
* Out: none
*
* Returns : >= 0 : The returned value is the amount of data in the
* TX buffer.
* FD_NOT_SUPPORTED: Wrong UART number.
* FD_NOT_READY : The function is called while the callback of the
* writeInFunc function is activated and still not
* terminated.
* FD_INTERNAL_ERR : Internal problem with the hardware.
*
******************************************************************************/
T_FDRET UAF_OutpAvail (T_tr_UartId uartNo);
/*******************************************************************************
*
* UAF_EnterSleep
*
* Purpose : Checks if UART is ready to enter Deep Sleep. If ready, enables
* wake-up interrupt.
*
* Arguments: In : uartNo: Used UART.
* Out: none
*
* Returns : 0 : Deep Sleep is not possible.
* >= 1 : Deep Sleep is possible.
* FD_NOT_SUPPORTED: Wrong UART number.
*
* Warning: Parameters are not verified.
*
******************************************************************************/
T_FDRET UAF_EnterSleep (T_tr_UartId uartNo);
/*******************************************************************************
*
* UAF_WakeUp
*
* Purpose : Wakes up UART after Deep Sleep.
*
* Arguments: In : uartNo: Used UART.
* Out: none
*
* Returns : FD_OK : Successful operation.
* FD_NOT_SUPPORTED: Wrong UART number.
*
* Warning: Parameters are not verified.
*
******************************************************************************/
T_FDRET UAF_WakeUp (T_tr_UartId uartNo);
/*******************************************************************************
*
* UAF_ReadData
*
* Purpose : To read the received characters out of the RX buffer the address
* of a function is passed. If characters are available, the driver
* calls this function and pass the address and the amount of
* readable characters. Because the RX buffer is circular, the
* callback function may be called with more than one address of
* buffer fragment.
* The readOutFunc function modifies the contents of the size array
* to return the driver the number of processed characters. Each
* array entry is decremented by the number of bytes read in the
* fragment.
* If the UAF_ReadData is called while the RX buffer is empty, it
* depends on the suspend parameter to suspend the call-back or to
* leave without any operation. In the case of suspension, the
* return value of UAF_ReadData is UAF_SUSPENDED. A delayed call-back
* will be performed if:
* - the RX buffer reachs the adjusted threshold (rxThreshold of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -