Files | |
file | uart.c |
UART implementation. | |
file | uart.h |
UART interface. | |
Macros | |
#define | UART_RX_BUF_SIZE 32 |
UART RX buffer size. | |
#define | UART_TX_BUF_SIZE 128 |
UART TX buffer size. | |
Functions | |
void | uart_init () |
UART initialization. More... | |
UInt16 | uart_proccess () |
UART process. More... | |
UInt8 | uart_startFrame (UInt8 len, UInt8 cmd0, UInt8 cmd1) |
Start frame. More... | |
void | uart_endFrame () |
End frame. More... | |
UInt8 | uart_snd (UInt8 len, void *pBuf) |
Send. More... | |
void | USCIA0RX_ISR () |
USCIA0 RX ISR. More... | |
void | USCIA0TX_ISR () |
USCIA0 TX ISR. More... | |
void | uart_sndnextchar () |
Send next char. More... | |
UInt8 | uart_txBufFree () |
TX buffer free. More... | |
UInt8 | uart_sndInt64 (int64_t *p) |
Send Int64. More... | |
UInt8 | uart_sndUInt64 (uint64_t *p) |
Send UInt64. More... | |
UInt8 | uart_sndUInt48 (uint64_t *p) |
Send UInt48. More... | |
UInt8 | uart_sndUInt32 (UInt32 *p) |
Send UInt32. More... | |
UInt8 | uart_sndUInt16 (UInt16 v) |
Send UInt16. More... | |
UInt8 | uart_sndUInt8 (UInt8 v) |
Send UInt8. More... | |
UInt8 | uart_forwardCmd (char *pBuf) |
Forward command. More... | |
void uart_endFrame | ( | ) |
End frame.
This function sends the FCS, that must be the end of a frame.
Definition at line 165 of file uart.c.
References im_enable_interrupt(), uart_currentFCS, and uart_snd().
Referenced by main(), ptp_process(), rep_endFrame(), rep_hello(), uart_forwardCmd(), and uart_proccessCmd().
UInt8 uart_forwardCmd | ( | char * | pBuf | ) |
Forward command.
This function forwards the received or sent command to UART. On the coordinator this is used to collect the data, that can be stored or shown to an operator.
Definition at line 741 of file uart.c.
References uart_endFrame(), uart_snd(), and uart_startFrame().
Referenced by nwk_allow_bindConfirm(), nwk_bind_deviceConfirm(), nwk_rcv(), spi_process_message(), and spi_reqEnd().
void uart_init | ( | ) |
UART initialization.
This function initializes the UART variables.
Definition at line 106 of file uart.c.
References uart_currentFCS, uart_rxBufRead, uart_rxBufWrite, uart_txBufRead, and uart_txBufWrite.
Referenced by main().
UInt16 uart_proccess | ( | ) |
UART process.
This function processes the tasks of the UART.
Definition at line 123 of file uart.c.
References uart_proccessCmd().
Referenced by main().
UInt8 uart_snd | ( | UInt8 | len, |
void * | pBuf | ||
) |
Send.
This function puts len characters from *pBuf onto uart_txBuf.
[in] | len | Amount of data to copy. |
[in] | pBuf | Pointer to the data to copy. |
Definition at line 182 of file uart.c.
References uart_currentFCS, UART_TX_BUF_SIZE, uart_txBuf, uart_txBufFreeReal(), and uart_txBufWrite.
Referenced by main(), rep_hello(), rep_snd(), uart_endFrame(), uart_forwardCmd(), uart_proccessCmd(), uart_sndInt64(), uart_sndUInt16(), uart_sndUInt32(), uart_sndUInt48(), uart_sndUInt64(), uart_sndUInt8(), and uart_startFrame().
UInt8 uart_sndInt64 | ( | int64_t * | p | ) |
Send Int64.
Sends a 64 bits integer to the buffer.
[in] | p | Pointer to the value to send |
Definition at line 336 of file uart.c.
References uart_snd().
Referenced by rep_sndInt64().
void uart_sndnextchar | ( | ) |
Send next char.
If TX buffer not empty and UART ready, send next char in buffer over serial.
Definition at line 271 of file uart.c.
References UART_TX_BUF_SIZE, uart_txBuf, uart_txBufRead, and uart_txBufWrite.
Referenced by USCIA0TX_ISR().
UInt8 uart_sndUInt16 | ( | UInt16 | v | ) |
Send UInt16.
Sends a 16 bits unsigned integer to the buffer.
[in] | v | Value to send |
Definition at line 396 of file uart.c.
References uart_snd().
Referenced by ptp_process(), rep_sndUInt16(), and rep_sndUInt48sc().
UInt8 uart_sndUInt32 | ( | UInt32 * | p | ) |
Send UInt32.
Sends a 32 bits unsigned integer to the buffer.
[in] | p | Pointer to the value to send |
Definition at line 381 of file uart.c.
References uart_snd().
Referenced by ptp_process(), rep_sndUInt32(), and rep_sndUInt48sc().
UInt8 uart_sndUInt48 | ( | uint64_t * | p | ) |
Send UInt48.
Sends the 48 LSB from a 64 bits unsigned integer to the buffer.
[in] | p | Pointer to the value to send |
Definition at line 366 of file uart.c.
References uart_snd().
Referenced by rep_sndUInt48().
UInt8 uart_sndUInt64 | ( | uint64_t * | p | ) |
Send UInt64.
Sends a 64 bits unsigned integer to the buffer.
[in] | p | Pointer to the value to send |
Definition at line 351 of file uart.c.
References uart_snd().
Referenced by rep_sndUInt64().
UInt8 uart_sndUInt8 | ( | UInt8 | v | ) |
Send UInt8.
Sends a 8 bits unsigned integer to the buffer.
[in] | v | Value to send |
Definition at line 411 of file uart.c.
References uart_snd().
Referenced by rep_sndUInt8(), and uart_proccessCmd().
UInt8 uart_startFrame | ( | UInt8 | len, |
UInt8 | cmd0, | ||
UInt8 | cmd1 | ||
) |
Start frame.
This function verify needed space, start a frame and initialize FCS
[in] | len | Size of the data field of the frame |
[in] | cmd0 | Byte 0 of command to send |
[in] | cmd1 | Byte 1 of command to send |
Definition at line 141 of file uart.c.
References im_disable_interrupt(), uart_currentFCS, uart_snd(), and uart_txBufFree().
Referenced by main(), ptp_process(), rep_hello(), rep_startFrame(), uart_forwardCmd(), and uart_proccessCmd().
UInt8 uart_txBufFree | ( | ) |
TX buffer free.
Returns max payload size to a new message.
Definition at line 294 of file uart.c.
References uart_txBufFreeReal().
Referenced by rep_hello(), uart_proccessCmd(), and uart_startFrame().
void USCIA0RX_ISR | ( | ) |
USCIA0 RX ISR.
UART RX Interrupt Service Request.
Definition at line 238 of file uart.c.
References UART_RX_BUF_SIZE, uart_rxBuf, uart_rxBufRead, and uart_rxBufWrite.
void USCIA0TX_ISR | ( | ) |
USCIA0 TX ISR.
UART TX Interrupt Service Request.
Definition at line 260 of file uart.c.
References uart_sndnextchar().