123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- #ifndef HAL_UART_H
- #define HAL_UART_H
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #include "hal_board.h"
- #define HAL_UART_BR_9600 0x00
- #define HAL_UART_BR_19200 0x01
- #define HAL_UART_BR_38400 0x02
- #define HAL_UART_BR_57600 0x03
- #define HAL_UART_BR_115200 0x04
- #define HAL_UART_ONE_STOP_BIT 0x00
- #define HAL_UART_TWO_STOP_BITS 0x01
- #define HAL_UART_NO_PARITY 0x00
- #define HAL_UART_EVEN_PARITY 0x01
- #define HAL_UART_ODD_PARITY 0x02
- #define HAL_UART_8_BITS_PER_CHAR 0x00
- #define HAL_UART_9_BITS_PER_CHAR 0x01
- #define HAL_UART_FLOW_OFF 0x00
- #define HAL_UART_FLOW_ON 0x01
- #define HAL_UART_PORT_0 0x00
- #define HAL_UART_PORT_1 0x01
- #define HAL_UART_PORT_MAX 0x02
- #define HAL_UART_SUCCESS 0x00
- #define HAL_UART_UNCONFIGURED 0x01
- #define HAL_UART_NOT_SUPPORTED 0x02
- #define HAL_UART_MEM_FAIL 0x03
- #define HAL_UART_BAUDRATE_ERROR 0x04
- #define HAL_UART_RX_FULL 0x01
- #define HAL_UART_RX_ABOUT_FULL 0x02
- #define HAL_UART_RX_TIMEOUT 0x04
- #define HAL_UART_TX_FULL 0x08
- #define HAL_UART_TX_EMPTY 0x10
- typedef void (*halUARTCBack_t) (uint8 port, uint8 event);
- typedef struct
- {
-
- volatile uint16 bufferHead;
- volatile uint16 bufferTail;
- uint16 maxBufSize;
- uint8 *pBuffer;
- } halUARTBufControl_t;
- typedef struct
- {
- bool configured;
- uint8 baudRate;
- bool flowControl;
- uint16 flowControlThreshold;
- uint8 idleTimeout;
- halUARTBufControl_t rx;
- halUARTBufControl_t tx;
- bool intEnable;
- uint32 rxChRvdTime;
- halUARTCBack_t callBackFunc;
- }halUARTCfg_t;
- typedef union
- {
- bool paramCTS;
- bool paramRTS;
- bool paramDSR;
- bool paramDTR;
- bool paramCD;
- bool paramRI;
- uint16 baudRate;
- bool flowControl;
- bool flushControl;
- }halUARTIoctl_t;
- extern void HalUARTInit ( void );
- extern uint8 HalUARTOpen ( uint8 port, halUARTCfg_t *config );
- extern void HalUARTClose ( uint8 port );
- extern uint16 HalUARTRead ( uint8 port, uint8 *pBuffer, uint16 length );
- extern uint16 HalUARTWrite ( uint8 port, uint8 *pBuffer, uint16 length );
- extern uint8 HalUARTIoctl ( uint8 port, uint8 cmd, halUARTIoctl_t *pIoctl );
- extern void HalUARTPoll( void );
- extern uint16 Hal_UART_RxBufLen ( uint8 port );
- extern uint16 Hal_UART_TxBufLen ( uint8 port );
- extern void Hal_UART_FlowControlSet ( uint8 port, bool status );
- extern uint8 HalUART_HW_Init(uint8 port);
- extern void HalUARTSuspend(void);
- extern void HalUARTResume(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|