AFBR-S50 API Reference Manual v1.5.6
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
Loading...
Searching...
No Matches

SCI Data Link Layer. More...

Collaboration diagram for SCI: Data Link Layer:

Macros

#define SCI_ALLOW_NEWLINE   1
 Whether to allow newline (
) in print / log messages.
 
#define SCI_CMD_IS_EXTENDED_CMD(cmd)   ((cmd) & 0x80)
 Checks whether the command byte is an extended command (= MSB set).
 

Functions

status_t SCI_DataLink_Init (void)
 Initialize the data link module.
 
status_t SCI_DataLink_CheckRxFrame (sci_frame_t *frame)
 Checks the CRC checksum for a RX frame.
 
void SCI_DataLink_ReleaseFrames (sci_frame_t *frame)
 Releases the frame queue.
 
void SCI_DataLink_ResetRxFrames (sci_frame_t *frame)
 Resets the frame read pointer to the very first byte (= command byte).
 
bool SCI_DataLink_IsTxBusy (void)
 Returns whether the TX line is currently busy and data is being sent.
 
status_t SCI_DataLink_SendTxFrame (sci_frame_t *frame, bool high_priority)
 Trigger the data transfer and releases the TX buffers.
 
sci_frame_tSCI_DataLink_RequestTxFrame (bool queueStartByte)
 Find an unused TX buffer from the queue and prepare it with a start byte.
 

Detailed Description

SCI Data Link Layer.


Implements the data link layer protocol for systems communication interface that connects to an external device. It takes care of sending and receiving data frames and thus byte stuffing and CRC check.

Remarks:

Macro Definition Documentation

◆ SCI_ALLOW_NEWLINE

#define SCI_ALLOW_NEWLINE   1

Whether to allow newline (
) in print / log messages.


◆ SCI_CMD_IS_EXTENDED_CMD

#define SCI_CMD_IS_EXTENDED_CMD (   cmd)    ((cmd) & 0x80)

Checks whether the command byte is an extended command (= MSB set).


Function Documentation

◆ SCI_DataLink_CheckRxFrame()

status_t SCI_DataLink_CheckRxFrame ( sci_frame_t frame)

Checks the CRC checksum for a RX frame.


Parameters
frameThe RX frame which requires CRC checking.
Returns
Returns the status:

◆ SCI_DataLink_Init()

status_t SCI_DataLink_Init ( void  )

Initialize the data link module.


Initialization implies the following steps:

  • Initialization of the SCI Hardware Layer, i.e. UART/LPSCI.
  • Starts to listen to incoming UART data and calls the frame received callback.
  • Initialization of the CRC module.
Returns
Returns the status (STATUS_OK on success).

◆ SCI_DataLink_IsTxBusy()

bool SCI_DataLink_IsTxBusy ( void  )

Returns whether the TX line is currently busy and data is being sent.


Returns
Returns true if the TX line is busy sending data.

◆ SCI_DataLink_ReleaseFrames()

void SCI_DataLink_ReleaseFrames ( sci_frame_t frame)

Releases the frame queue.


Parameters
frameThe frame queue to be released.

◆ SCI_DataLink_RequestTxFrame()

sci_frame_t * SCI_DataLink_RequestTxFrame ( bool  queueStartByte)

Find an unused TX buffer from the queue and prepare it with a start byte.


If sending data over the SCI, an new and empty TX frame needs to be claimed for usage of the command. This functions finds one and prepares it with an start byte. A pointer to the frame is returned if one is found. Otherwise null, so checking for null pointer is recommended!

Parameters
queueStartByteWhether to queue a start byte into the buffer.
Returns
Returns a pointer to an free TX frame, zero if no one is currently available.

◆ SCI_DataLink_ResetRxFrames()

void SCI_DataLink_ResetRxFrames ( sci_frame_t frame)

Resets the frame read pointer to the very first byte (= command byte).


Parameters
frameThe frame queue to reset.

◆ SCI_DataLink_SendTxFrame()

status_t SCI_DataLink_SendTxFrame ( sci_frame_t frame,
bool  high_priority 
)

Trigger the data transfer and releases the TX buffers.


Before the frame is transferred, a stop byte is added to the end of the data buffer.

Parameters
frameThe frame to be sent.
high_priorityIf set, the frame is queued right after the current frame. If not set, the frame is queued at the very end of the frame queue.
Returns
Returns the status (STATUS_OK on success).