SZSPTP ez430-RF2480 1.0

ZigBee Sensor Network with synchronized time and time-stamped measurements.
UART

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...
 

Detailed Description

Function Documentation

void uart_endFrame ( )

End frame.

This function sends the FCS, that must be the end of a frame.

Returns
1 on success; 0 on fail because of not buffer.

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Returns
1 on success, 0 on fail because of full UART buffer.

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

+ Here is the caller graph for this function:

UInt16 uart_proccess ( )

UART process.

This function processes the tasks of the UART.

Returns
Time to run again (ms); 0 means 65536ms

Definition at line 123 of file uart.c.

References uart_proccessCmd().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt8 uart_snd ( UInt8  len,
void *  pBuf 
)

Send.

This function puts len characters from *pBuf onto uart_txBuf.

Parameters
[in]lenAmount of data to copy.
[in]pBufPointer to the data to copy.
Returns
0 if not enough room to the requested size nothing is done, else 1.

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt8 uart_sndInt64 ( int64_t *  p)

Send Int64.

Sends a 64 bits integer to the buffer.

Parameters
[in]pPointer to the value to send
Returns
1 on success, 0 on fail because no room in buffer

Definition at line 336 of file uart.c.

References uart_snd().

Referenced by rep_sndInt64().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

+ Here is the caller graph for this function:

UInt8 uart_sndUInt16 ( UInt16  v)

Send UInt16.

Sends a 16 bits unsigned integer to the buffer.

Parameters
[in]vValue to send
Returns
1 on success, 0 on fail because no room in buffer

Definition at line 396 of file uart.c.

References uart_snd().

Referenced by ptp_process(), rep_sndUInt16(), and rep_sndUInt48sc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt8 uart_sndUInt32 ( UInt32 *  p)

Send UInt32.

Sends a 32 bits unsigned integer to the buffer.

Parameters
[in]pPointer to the value to send
Returns
1 on success, 0 on fail because no room in buffer

Definition at line 381 of file uart.c.

References uart_snd().

Referenced by ptp_process(), rep_sndUInt32(), and rep_sndUInt48sc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt8 uart_sndUInt48 ( uint64_t *  p)

Send UInt48.

Sends the 48 LSB from a 64 bits unsigned integer to the buffer.

Parameters
[in]pPointer to the value to send
Returns
1 on success, 0 on fail because no room in buffer

Definition at line 366 of file uart.c.

References uart_snd().

Referenced by rep_sndUInt48().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt8 uart_sndUInt64 ( uint64_t *  p)

Send UInt64.

Sends a 64 bits unsigned integer to the buffer.

Parameters
[in]pPointer to the value to send
Returns
1 on success, 0 on fail because no room in buffer

Definition at line 351 of file uart.c.

References uart_snd().

Referenced by rep_sndUInt64().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt8 uart_sndUInt8 ( UInt8  v)

Send UInt8.

Sends a 8 bits unsigned integer to the buffer.

Parameters
[in]vValue to send
Returns
1 on success, 0 on fail because no room in buffer

Definition at line 411 of file uart.c.

References uart_snd().

Referenced by rep_sndUInt8(), and uart_proccessCmd().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt8 uart_startFrame ( UInt8  len,
UInt8  cmd0,
UInt8  cmd1 
)

Start frame.

This function verify needed space, start a frame and initialize FCS

Parameters
[in]lenSize of the data field of the frame
[in]cmd0Byte 0 of command to send
[in]cmd1Byte 1 of command to send
Returns
1 on success; 0 on fail because of not buffer

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt8 uart_txBufFree ( )

TX buffer free.

Returns max payload size to a new message.

Returns
Free bytes on TX buffer

Definition at line 294 of file uart.c.

References uart_txBufFreeReal().

Referenced by rep_hello(), uart_proccessCmd(), and uart_startFrame().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void USCIA0RX_ISR ( )

USCIA0 RX ISR.

  • This function is not being used, but is left here as an example

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().

+ Here is the call graph for this function: