rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board

This is the driver for the UART0/2/3. More...

Enumerations

enum  rflpc_uart_t {
  RFLPC_UART0 = 0,
  RFLPC_UART2 = 2,
  RFLPC_UART3 = 3
}
 Constants that represents the UART port you want to use in uart driver functions. More...
 

Functions

int rflpc_uart_init (rflpc_uart_t uart_num)
 Inits the UART e, using 11520 baud, 8 bits data, no parity and 1 stop bit. More...
 
int rflpc_uart_init_ex (rflpc_uart_t uart_num, int dll, int dlm, int divadd, int mulval)
 Inits the UART e, using 8 bits data, no parity and 1 stop bit. More...
 
void rflpc_uart_putchar (rflpc_uart_t uart_num, char c)
 Sends a byte to the uart. More...
 
int rflpc_uart_byte_available (rflpc_uart_t uart_num)
 Test the reception FIFO. More...
 
char rflpc_uart_getchar (rflpc_uart_t uart_num)
 Gets a character from the uart. More...
 
void rflpc_uart_set_rx_callback (rflpc_uart_t uart_num, rflpc_irq_handler_t callback)
 Sets the uart rx callback. More...
 

Detailed Description

This is the driver for the UART0/2/3.

At the moment, this driver is only usable when the CPU is clocked at 96Mhz and the UART mode is set to

Enumeration Type Documentation

Constants that represents the UART port you want to use in uart driver functions.

Enumerator
RFLPC_UART0 

Use UART0.

RFLPC_UART2 

Use UART2.

RFLPC_UART3 

Use UART3.

Definition at line 45 of file uart.h.

Function Documentation

int rflpc_uart_byte_available ( rflpc_uart_t  uart_num)

Test the reception FIFO.

Parameters
uart_numthe uart to use
Returns
true if a byte is available
char rflpc_uart_getchar ( rflpc_uart_t  uart_num)

Gets a character from the uart.

Parameters
uart_numthe uart to use
Returns
the character read.
Warning
This function loops while no data is available!
int rflpc_uart_init ( rflpc_uart_t  uart_num)

Inits the UART e, using 11520 baud, 8 bits data, no parity and 1 stop bit.

Returns
0 if init is successful, -1 otherwise
Note
at the moment, -1 is returned if the CPU is not clocked at 96Mhz
int rflpc_uart_init_ex ( rflpc_uart_t  uart_num,
int  dll,
int  dlm,
int  divadd,
int  mulval 
)

Inits the UART e, using 8 bits data, no parity and 1 stop bit.

The baud rate is computed from dll, dlm, divadd and mulval. you can use the baud_rate_calc.pl script in the tools folder to generate the values for the desired baud rate

Returns
0 if init is successful, -1 otherwise
Note
at the moment, -1 is returned if the CPU is not clocked at 96Mhz
void rflpc_uart_putchar ( rflpc_uart_t  uart_num,
char  c 
)

Sends a byte to the uart.

Parameters
uart_numthe uart to use
ccharacter to send
void rflpc_uart_set_rx_callback ( rflpc_uart_t  uart_num,
rflpc_irq_handler_t  callback 
)

Sets the uart rx callback.

This enables the uart0 interrupt and set the handler accordingly

Parameters
uart_numthe uart to use
callbacka pointer to a rflpc_irq_handler_t function