AFBR-S50 API Reference Manual v1.5.6
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
Loading...
Searching...
No Matches
sci_frame.h
Go to the documentation of this file.
1/*************************************************************************/
38#ifndef SCI_FRAME_H
39#define SCI_FRAME_H
40
41#include "sci_internal_types.h"
42#include "utility/time.h"
43
44/*!***************************************************************************
45 * @defgroup sci_frame SCI: Data Frames
46 * @ingroup sci
47 * @brief SCI Data Frames
48 * @details The SCI Data Frame Interface. Contains functionality to
49 * enqueue/dequeue different data types to/from an specified
50 * #sci_frame_t object. This is mainly used to define the SCI
51 * commands and implement the data serialization.
52 *
53 * @addtogroup sci_frame
54 * @{
55 *****************************************************************************/
56
57
58/*!***************************************************************************
59 * @brief Returns the total number of bytes within a specified frame.
60 * @details Does calculate the total number of bytes that have been written
61 * into the buffer. Especially it does not heed the byte stuffing and
62 * counts escape bytes as well as normal bytes.
63 * @param frame The frame to count the data bytes.
64 * @return The number of bytes to read.
65 *****************************************************************************/
66int32_t SCI_Frame_TotalFrameLength (sci_frame_t const * frame);
67
68/*!***************************************************************************
69 * @brief Determines whether the frame is a start frame.
70 * @details If the specified frame is a start frame, i.e. the first frame of a
71 * sequence of multiple frames that starts with a start byte, the
72 * function returns true. False elsewise.
73 * @param frame The frame to check for the start byte.
74 * @return True if the frame is a start frame.
75 *****************************************************************************/
76uint8_t SCI_Frame_IsStartFrame(sci_frame_t const * frame);
77
78/*!***************************************************************************
79 * @brief Returns the bytes that have been written from the buffer and not
80 * read yet.
81 * @details Does calculate the total number of bytes to be read in the buffer.
82 * Especially it does not heed the byte stuffing and counts escape
83 * bytes as well as normal bytes.
84 * @param frame The frame to count the data bytes.
85 * @return The number of bytes to read.
86 *****************************************************************************/
87uint32_t SCI_Frame_BytesToRead(sci_frame_t const * frame);
88
89/*!***************************************************************************
90 * @brief Inserts a char into the TX buffer.
91 * @details The char is checked for byte stuffing and thus it might
92 * additionally add an escape byte to the buffer.
93 * @note No new line / carriage return chars are added to the buffer. They
94 * will be removed/ignored.
95 * @param c The char to append.
96 * @param frame The frame to put the data.
97 *****************************************************************************/
98void SCI_Frame_PutChar(char c, void * frame);
99
100/*!***************************************************************************
101 * @brief Function for inserting a byte in a SCI frame.
102 * @param frame The frame to insert the byte.
103 * @param byte The byte to insert.
104 *****************************************************************************/
105void SCI_Frame_SetByte(sci_frame_t * frame, uint8_t byte);
106
107/*!***************************************************************************
108 * @brief Inserts a signed byte (8-bit) into the TX buffer.
109 * @details The byte is checked for byte stuffing and thus it might additionally
110 * add an escape byte to the buffer.
111 * @param frame The frame to put the data.
112 * @param data The byte to append.
113 *****************************************************************************/
114void SCI_Frame_Queue08s(sci_frame_t * frame, int8_t data);
115
116/*!***************************************************************************
117 * @brief Inserts a signed halfword (16-bit) into the TX buffer.
118 * @details The two bytes are checked for byte stuffing and thus it might
119 * additionally add escape bytes to the buffer.
120 * @param frame The frame to put the data.
121 * @param data The data to append.
122 *****************************************************************************/
123void SCI_Frame_Queue16s(sci_frame_t * frame, int16_t data);
124
125/*!***************************************************************************
126 * @brief Inserts a signed 3/4-word (24-bit) into the TX buffer.
127 * @details The three least significant bytes are added to the buffer. They are
128 * checked for byte stuffing and thus it might additionally add escape
129 * bytes to the buffer.
130 * @param frame The frame to put the data.
131 * @param data The data to append.
132 *****************************************************************************/
133void SCI_Frame_Queue24s(sci_frame_t * frame, int32_t data);
134
135/*!***************************************************************************
136 * @brief Inserts a signed word (32-bit) into the TX buffer.
137 * @details The four bytes are checked for byte stuffing and thus it might
138 * additionally add escape bytes to the buffer.
139 * @param frame The frame to put the data.
140 * @param data The data to append.
141 *****************************************************************************/
142void SCI_Frame_Queue32s(sci_frame_t * frame, int32_t data);
143
144/*!***************************************************************************
145 * @brief Inserts a #ltc_t time stamp type into the TX buffer.
146 * @details The time stamp is added as 6 byte wide value, i.e.
147 * 1. The seconds are added as uint32_t
148 * 2. The microseconds / 16 are added as uint16_t
149 * .
150 * The four bytes are checked for byte stuffing and thus it might
151 * additionally add escape bytes to the buffer.
152 * @param frame The frame to put the data.
153 * @param t The time stamp data to append.
154 *****************************************************************************/
155void SCI_Frame_Queue_Time(sci_frame_t * frame, ltc_t const * t);
156
157
158/*!***************************************************************************
159 * @brief Inserts a unsigned byte (8-bit) into the TX buffer.
160 * @details The byte is checked for byte stuffing and thus it might additionally
161 * add an escape byte to the buffer.
162 * @param frame The frame to put the data.
163 * @param data The byte to append.
164 *****************************************************************************/
165void SCI_Frame_Queue08u(sci_frame_t * frame, uint8_t data);
166
167/*!***************************************************************************
168 * @brief Inserts a unsigned halfword (16-bit) into the TX buffer.
169 * @details The two bytes are checked for byte stuffing and thus it might
170 * additionally add escape bytes to the buffer.
171 * @param frame The frame to put the data.
172 * @param data The data to append.
173 *****************************************************************************/
174void SCI_Frame_Queue16u(sci_frame_t * frame, uint16_t data);
175
176/*!***************************************************************************
177 * @brief Inserts a unsigned 3/4-word (24-bit) into the TX buffer.
178 * @details The three least significant bytes are added to the buffer. They are
179 * checked for byte stuffing and thus it might additionally add escape
180 * bytes to the buffer.
181 * @param frame The frame to put the data.
182 * @param data The data to append.
183 *****************************************************************************/
184void SCI_Frame_Queue24u(sci_frame_t * frame, uint32_t data);
185
186/*!***************************************************************************
187 * @brief Inserts a unsigned word (32-bit) into the TX buffer.
188 * @details The four bytes are checked for byte stuffing and thus it might
189 * additionally add escape bytes to the buffer.
190 * @param frame The frame to put the data.
191 * @param data The data to append.
192 *****************************************************************************/
193void SCI_Frame_Queue32u(sci_frame_t * frame, uint32_t data);
194
195/*!***************************************************************************
196 * @brief Takes a signed byte (8-bit) from the RX buffer.
197 * @param frame The frame to take the data from.
198 * @return Signed byte.
199 *****************************************************************************/
200int8_t SCI_Frame_Dequeue08s(sci_frame_t * frame);
201
202/*!***************************************************************************
203 * @brief Takes a signed halfword (16-bit) from the RX buffer.
204 * @param frame The frame to take the data from.
205 * @return Signed 32-bit halfword.
206 *****************************************************************************/
207int16_t SCI_Frame_Dequeue16s(sci_frame_t * frame);
208
209/*!***************************************************************************
210 * @brief Takes a signed 3/4-word (24-bit) from the RX buffer.
211 * @param frame The frame to take the data from.
212 * @return Signed 24-bit data.
213 *****************************************************************************/
214int32_t SCI_Frame_Dequeue24s(sci_frame_t * frame);
215
216/*!***************************************************************************
217 * @brief Takes a signed word (32-bit) from the RX buffer.
218 * @param frame The frame to take the data from.
219 * @return Signed 32-bit word.
220 *****************************************************************************/
221int32_t SCI_Frame_Dequeue32s(sci_frame_t * frame);
222
223/*!***************************************************************************
224 * @brief Takes a unsigned byte (8-bit) from the RX buffer.
225 * @param frame The frame to take the data from.
226 * @return Unsigned byte.
227 *****************************************************************************/
228uint8_t SCI_Frame_Dequeue08u(sci_frame_t * frame);
229
230/*!***************************************************************************
231 * @brief Takes a unsigned halfword (16-bit) from the RX buffer.
232 * @param frame The frame to take the data from.
233 * @return Unsigned 16-bit halfword.
234 *****************************************************************************/
235uint16_t SCI_Frame_Dequeue16u(sci_frame_t * frame);
236
237/*!***************************************************************************
238 * @brief Takes a unsigned 3/4-word (24-bit) from the RX buffer.
239 * @param frame The frame to take the data from.
240 * @return Unsigned 24-bit 3/4-word.
241 *****************************************************************************/
242uint32_t SCI_Frame_Dequeue24u(sci_frame_t * frame);
243
244/*!***************************************************************************
245 * @brief Takes a unsigned word (32-bit) from the RX buffer.
246 * @param frame The frame to take the data from.
247 * @return Unsigned 32-bit word.
248 *****************************************************************************/
249uint32_t SCI_Frame_Dequeue32u(sci_frame_t * frame);
250
252#endif /* SCI_FRAME_H */
uint32_t SCI_Frame_Dequeue24u(sci_frame_t *frame)
Takes a unsigned 3/4-word (24-bit) from the RX buffer.
Definition sci_frame.c:232
uint8_t SCI_Frame_Dequeue08u(sci_frame_t *frame)
Takes a unsigned byte (8-bit) from the RX buffer.
Definition sci_frame.c:221
int32_t SCI_Frame_TotalFrameLength(sci_frame_t const *frame)
Returns the total number of bytes within a specified frame.
Definition sci_frame.c:50
void SCI_Frame_Queue08u(sci_frame_t *frame, uint8_t data)
Inserts a unsigned byte (8-bit) into the TX buffer.
Definition sci_frame.c:108
void SCI_Frame_Queue24s(sci_frame_t *frame, int32_t data)
Inserts a signed 3/4-word (24-bit) into the TX buffer.
Definition sci_frame.c:156
uint16_t SCI_Frame_Dequeue16u(sci_frame_t *frame)
Takes a unsigned halfword (16-bit) from the RX buffer.
Definition sci_frame.c:225
void SCI_Frame_Queue32u(sci_frame_t *frame, uint32_t data)
Inserts a unsigned word (32-bit) into the TX buffer.
Definition sci_frame.c:132
void SCI_Frame_Queue32s(sci_frame_t *frame, int32_t data)
Inserts a signed word (32-bit) into the TX buffer.
Definition sci_frame.c:162
void SCI_Frame_SetByte(sci_frame_t *frame, uint8_t byte)
Function for inserting a byte in a SCI frame.
Definition sci_frame.c:81
int8_t SCI_Frame_Dequeue08s(sci_frame_t *frame)
Takes a signed byte (8-bit) from the RX buffer.
Definition sci_frame.c:193
int32_t SCI_Frame_Dequeue24s(sci_frame_t *frame)
Takes a signed 3/4-word (24-bit) from the RX buffer.
Definition sci_frame.c:204
void SCI_Frame_Queue08s(sci_frame_t *frame, int8_t data)
Inserts a signed byte (8-bit) into the TX buffer.
Definition sci_frame.c:139
uint32_t SCI_Frame_BytesToRead(sci_frame_t const *frame)
Returns the bytes that have been written from the buffer and not read yet.
Definition sci_frame.c:64
void SCI_Frame_Queue16s(sci_frame_t *frame, int16_t data)
Inserts a signed halfword (16-bit) into the TX buffer.
Definition sci_frame.c:151
void SCI_Frame_PutChar(char c, void *frame)
Inserts a char into the TX buffer.
Definition sci_frame.c:250
void SCI_Frame_Queue16u(sci_frame_t *frame, uint16_t data)
Inserts a unsigned halfword (16-bit) into the TX buffer.
Definition sci_frame.c:120
int16_t SCI_Frame_Dequeue16s(sci_frame_t *frame)
Takes a signed halfword (16-bit) from the RX buffer.
Definition sci_frame.c:197
int32_t SCI_Frame_Dequeue32s(sci_frame_t *frame)
Takes a signed word (32-bit) from the RX buffer.
Definition sci_frame.c:212
uint32_t SCI_Frame_Dequeue32u(sci_frame_t *frame)
Takes a unsigned word (32-bit) from the RX buffer.
Definition sci_frame.c:240
uint8_t SCI_Frame_IsStartFrame(sci_frame_t const *frame)
Determines whether the frame is a start frame.
Definition sci_frame.c:75
void SCI_Frame_Queue24u(sci_frame_t *frame, uint32_t data)
Inserts a unsigned 3/4-word (24-bit) into the TX buffer.
Definition sci_frame.c:125
void SCI_Frame_Queue_Time(sci_frame_t *frame, ltc_t const *t)
Inserts a ltc_t time stamp type into the TX buffer.
Definition sci_frame.c:170
SCI: The internal type definitions.
A data structure to represent current time.
Definition time.h:70
Data buffer for outgoing frames.
Definition sci_internal_types.h:110
This file is part of the AFBR-S50 API.