Data Structures

struct  KUARTConf
 Uart configuration structure. More...
 
struct  KUART
 Uart interface data structure. More...
 

Enumerations

enum  KUARTNum {
  K_UART1 = 0, K_UART2, K_UART3, K_UART4,
  K_UART5, K_UART6
}
 Available uart interfaces. More...
 
enum  KWordLen { K_WORD_LEN_7BIT = 0, K_WORD_LEN_8BIT, K_WORD_LEN_9BIT }
 Word length. More...
 
enum  KStopBits { K_STOP_BITS_1 = 0, K_STOP_BITS_2 }
 Number of stop bits. More...
 
enum  KParity { K_PARITY_NONE = 0, K_PARITY_EVEN, K_PARITY_ODD }
 Parity setting. More...
 
enum  KUARTStatus { UART_OK, UART_ERROR, UART_ERROR_NULL_HANDLE, UART_ERROR_CONFIG }
 Uart status values. More...
 

Functions

KUARTConf k_uart_conf_defaults (void)
 Generate KUARTConf with default uart values. More...
 
KUARTStatus k_uart_init (KUARTNum uart, KUARTConf *conf)
 Setup and enable uart interface. More...
 
void k_uart_terminate (KUARTNum uart)
 Terminates uart interface. More...
 
void k_uart_console_init (void)
 Setup and enable console uart interface. More...
 
int k_uart_read (KUARTNum uart, char *ptr, int len)
 Interrupt driven function for reading data from a uart interface. More...
 
int k_uart_write (KUARTNum uart, char *ptr, int len)
 Interrupt driven function for writing data to a uart interface. More...
 
KUARTStatus k_uart_write_immediate (KUARTNum uart, char c)
 Write data directly to a uart interface. More...
 
KUARTStatus k_uart_write_immediate_str (KUARTNum uart, uint8_t *ptr, uint8_t len)
 Write data directly to a uart interface. More...
 
int k_uart_rx_queue_len (KUARTNum uart)
 Returns the number of characters currently in the uart rx queue. More...
 
void k_uart_rx_queue_push (KUARTNum uart, char c, void *task_woken)
 Pushes a character into the uart rx queue. More...
 
int k_uart_rx_pin (KUARTNum uart)
 Returns rx pin for specified uart interface. More...
 
int k_uart_tx_pin (KUARTNum uart)
 Returns tx pin for specified uart interface. More...
 
KUARTkprv_uart_get (KUARTNum uart)
 Returns uart data structure for specified interface. More...
 
KUARTStatus kprv_uart_dev_init (KUARTNum uart)
 Performs low level uart hardware initialization. More...
 
void kprv_uart_dev_terminate (KUARTNum uart)
 
void kprv_uart_enable_tx_int (KUARTNum uart)
 Enables uart transmit interrupt. More...
 

Enumeration Type Documentation

enum KParity

Parity setting.

Enumerator
K_PARITY_NONE 
K_PARITY_EVEN 
K_PARITY_ODD 
enum KStopBits

Number of stop bits.

Enumerator
K_STOP_BITS_1 
K_STOP_BITS_2 
enum KUARTNum

Available uart interfaces.

Enumerator
K_UART1 
K_UART2 
K_UART3 
K_UART4 
K_UART5 
K_UART6 

Uart status values.

Enumerator
UART_OK 
UART_ERROR 
UART_ERROR_NULL_HANDLE 
UART_ERROR_CONFIG 
enum KWordLen

Word length.

Note
MSP430F5 does not support 9-bit mode
Enumerator
K_WORD_LEN_7BIT 
K_WORD_LEN_8BIT 
K_WORD_LEN_9BIT 

Function Documentation

KUARTConf k_uart_conf_defaults ( void  )

Generate KUARTConf with default uart values.

Returns
KUARTConf
void k_uart_console_init ( void  )

Setup and enable console uart interface.

KUARTStatus k_uart_init ( KUARTNum  uart,
KUARTConf conf 
)

Setup and enable uart interface.

Parameters
uartuart interface to initialize
confconfig values to initialize with
Returns
KUARTStatus UART_OK if OK, failure otherwise
int k_uart_read ( KUARTNum  uart,
char *  ptr,
int  len 
)

Interrupt driven function for reading data from a uart interface.

This function reads from a queue which is filled up via the uart interrupt handler.

Parameters
uartuart interface to read from
ptrbuffer to read data into
lenlength of data to read
Returns
int number of characters read or -1 to indicate a null uart handle
int k_uart_rx_pin ( KUARTNum  uart)

Returns rx pin for specified uart interface.

Parameters
uartuart interface number
Returns
int rx pin
int k_uart_rx_queue_len ( KUARTNum  uart)

Returns the number of characters currently in the uart rx queue.

Parameters
uartuart interface number or -1 to indicate a null uart handle or -2 to indicate a null rx queue pointer
void k_uart_rx_queue_push ( KUARTNum  uart,
char  c,
void *  task_woken 
)

Pushes a character into the uart rx queue.

Parameters
uartuart interface number
ccharacter to push
task_wokenused by FreeRTOS to determine task blocking
void k_uart_terminate ( KUARTNum  uart)

Terminates uart interface.

Parameters
uartuart interface to terminate
int k_uart_tx_pin ( KUARTNum  uart)

Returns tx pin for specified uart interface.

Parameters
uartuart interface number
Returns
int tx pin
int k_uart_write ( KUARTNum  uart,
char *  ptr,
int  len 
)

Interrupt driven function for writing data to a uart interface.

This function writes data into a queue which is then written out in the interrupt handler.

Parameters
uartuart interface to write to
ptrbuffer to write data from
lenlength of data to write
Returns
int number of characters written or -1 to indicate a null uart handle
KUARTStatus k_uart_write_immediate ( KUARTNum  uart,
char  c 
)

Write data directly to a uart interface.

Parameters
uartuart interface to write to
ccharacter to write
Returns
KUARTStatus UART_OK if success, otherwise failure
KUARTStatus k_uart_write_immediate_str ( KUARTNum  uart,
uint8_t *  ptr,
uint8_t  len 
)

Write data directly to a uart interface.

Parameters
uartuart interface to write to
ptrbuffer to write data from
lenlength of data to write
Returns
KUARTStatus UART_OK if success, otherwise failure
KUARTStatus kprv_uart_dev_init ( KUARTNum  uart)

Performs low level uart hardware initialization.

Parameters
uartuart interface to initialize
Returns
KUARTStatus UART_OK if OK, failure otherwise
void kprv_uart_dev_terminate ( KUARTNum  uart)
void kprv_uart_enable_tx_int ( KUARTNum  uart)

Enables uart transmit interrupt.

Parameters
uartuart interface number
KUART* kprv_uart_get ( KUARTNum  uart)

Returns uart data structure for specified interface.

Parameters
uartuart interface number
Returns
KUART* pointer to uart data structure