AFBR-S50 API Reference Manual v1.5.6
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
|
#include "sci_cmd.h"
#include "sci_datalink.h"
#include "sci_byte_stuffing.h"
#include "sci_crc8.h"
#include "sci_handshaking.h"
#include "driver/irq.h"
#include "debug.h"
#include "driver/uart.h"
#include <stddef.h>
#include <assert.h>
#include "utility/time.h"
Macros | |
#define | AFBR_SCI_USB 0 |
SCI Layer 2: Data Link and Data Frame Module. | |
Functions | |
static void | RaiseError (status_t error) |
static void | RxCallback (uint8_t const *data, uint32_t size) |
static void | TxCallback (status_t status, sci_frame_t *frame) |
static sci_frame_t * | SCI_DataLink_RequestFrame (sci_frame_queue_t *queue) |
static status_t | SCI_DataLink_SendFrame (sci_frame_t *frame) |
static void | SCI_DataLink_ReleaseFrame (sci_frame_t *frame) |
static uint8_t | SCI_DataLink_GetCRC (sci_frame_t const *frame) |
static uint8_t | SCI_DataLink_CalcCRC (sci_frame_t const *frame) |
static void | SCI_Frame_QueueCRC (sci_frame_t *frame) |
Inserts a checksum into the Tx frame;. | |
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). | |
sci_frame_t * | SCI_DataLink_RequestTxFrame (bool queueStartByte) |
Find an unused TX buffer from the queue and prepare it with a start 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. | |
Variables | |
static uint8_t | SCI_DataBuffer [SCI_FRAME_SIZE *SCI_FRAME_BUF_CT] = { 0 } |
static sci_frame_t | SCI_FrameBuffer [SCI_FRAME_BUF_CT] |
static sci_frame_queue_t | SCI_RxFrameQueue |
static sci_frame_queue_t | SCI_TxFrameQueue |
sci_rx_cmd_cb_t | SCI_RxCallback = 0 |
sci_error_cb_t | SCI_ErrorCallback = 0 |
static volatile sci_frame_t * | SCI_CurrentTxFrame = 0 |
#define AFBR_SCI_USB 0 |
SCI Layer 2: Data Link and Data Frame Module.
This file provides a data link layer for the systems communication interface. It also contains the implementation of the data frame interface.
Copyright (c) 2023, Broadcom Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Preprocessor flag to choose between USB and non-USB (UART) connection.
|
inlinestatic |
|
static |
< Flag for byte stuffing
< the current buffer in the queue.
< the first buffer in the queue.
|
static |
|
static |
|
inlinestatic |
|
static |
|
inlinestatic |
|
static |
Inserts a checksum into the Tx frame;.
Given a Tx frame with data filled, this function calculates and appends the CRC to the frame buffer. It assumes that the first byte in the TX buffer is start byte which is usually ensured by the SCI_DataLink_RequestTxFrame function.
frame | The frame for which a checksum is calculated. |
|
static |
|
static |
A pointer to the frame that is currently sent. It is used to enqueue more frames if the UART is busy.
|
static |
The data buffer for rx and tx frames.
sci_error_cb_t SCI_ErrorCallback = 0 |
Callback function pointer for error event.
|
static |
The frame buffer for rx and tx frames.
sci_rx_cmd_cb_t SCI_RxCallback = 0 |
Callback function pointer for received frame event.
|
static |
The data frame queue for rx frames.
|
static |
The data frame queue for tx frames.