|
COX Serial Peripheral Interface
Version: 1.00 - 13. June 2010
Contents
Overview
A serial port (UART) is a serial communication physical interface used by computers and electronic modules to send and receive control information and data. It has two signals, one for sending and one for receiving.
Interface Definition
Serial Interface Definition : COX serial Interface is a structure variable of COX_SERIAL_PI type, it contains a list of pointers to the functions that implement the standard functions specified by COX. Use different variables to access different serial peripherals.
| Serial Interface |
typedef struct {
COX_Status (*Init) (uint32_t baudrate);
uint32_t (*Write) (const void* wbuf, uint32_t wlen);
uint32_t (*Read) (void *rbuf, uint32_t rlen);
COX_Status (*Cfg) (uint8_t index, uint32_t arg, uint32_t *pre_arg);
} COX_SERIAL_PI_Def;
typedef const COX_SERIAL_PI_Def COX_SERIAL_PI; |
| Member |
COX_Status (*Init)(uint32_t baudrate);
/* Initialize the Serial peripheral */
uint32_t (*Write) (const void* wbuf, uint32_t wlen);
/* Send a block of data */
uint32_t (*Read) (void *rbuf, uint32_t rlen);
/* Receive a block of data */
COX_Status (*Cfg) (uint8_t index, uint32_t arg, uint32_t *pre_arg);
/* Configure the peripheral */ |
Global Define
| Name |
Description |
| COX_SERIAL_CFG_RATE |
Baudrate |
| COX_SERIAL_CFG_BITS |
Number of data bits |
| COX_SERIAL_CFG_STOP_BITS |
Number of stop bits |
| COX_SERIAL_CFG_PARITY |
Parity selection |
Standard Function
| Name |
Description |
| Init |
Initialize the Serial peripheral |
| Write |
Send a block of data |
| Read |
Receive a block of data |
| Cfg |
Configure the peripheral |
| COX_Status Init (uint32_t baudrate) |
| Description |
Initialize the Serial peripheral |
| Parameter |
rate : Baudrate |
| Return Code |
COX_SUCCESS or COX_ERROR |
| uint32_t Write (const void* wbuf, uint32_t wlen) |
| Description |
Send a block of data |
| Parameter |
wbuf : Pointer to transmit buffer
wlen : Length of transmit buffer |
| Return Code |
Number of data sent |
| uint32_t Read (void *rbuf, uint32_t rlen) : |
| Description |
Receive a block of data |
| Parameter |
rbuf : Pointer to receive buffer
rlen : Length of receive buffer |
| Return Code |
Number of bytes received |
| COX_Status Cfg (uint8_t index, uint32_t arg, uint32_t *pre_arg) |
| Description |
Configure the peripheral |
| Parameter |
index : Configuration index, it should be :
- COX_SERIAL_CFG_RATE : Set baudrate
- COX_SERIAL_CFG_BITS : Set bumber of data bits
- COX_SERIAL_CFG_STOP_BITS : Set bumber of stop bits, arg should be :
- COX_SERIAL_STOPBIT_1 : 1 Stop Bits Select
- COX_SERIAL_STOPBIT_1_5 : 1.5 Stop Bits Select
- COX_SERIAL_STOPBIT_2 : 2 Stop Bits Select
- COX_SERIAL_CFG_PARITY : Parity selection, arg should be :
- COX_SERIAL_PARITY_NONE : No parity
- COX_SERIAL_PARITY_ODD : Odd parity
- COX_SERIAL_PARITY_EVEN : Even parity
- COX_SERIAL_PARITY_SP_1 : Forced "1" stick parity
- COX_SERIAL_PARITY_SP_0 : Forced "0" stick parity
arg : Configuration argument
pre_arg : Return previous configuration argument |
| Return Code |
COX_SUCCESS or COX_ERROR |
Available Interface
| Vendor |
Chip |
Interface |
Description |
| NXP |
LPC17xx Series |
pi_serial0 |
Serial Interface based on UART0 |
| pi_serial1 |
Serial Interface based on UART1 |
| pi_serial2 |
Serial Interface based on UART2 |
| pi_serial3 |
Serial Interface based on UART3 |
|
|