AFBR-S50 API Reference Manual  v1.6.5
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
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  *****************************************************************************/
66 int32_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  *****************************************************************************/
76 uint8_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  *****************************************************************************/
87 uint32_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  *****************************************************************************/
98 void 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  *****************************************************************************/
105 void 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  *****************************************************************************/
114 void 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  *****************************************************************************/
123 void 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  *****************************************************************************/
133 void 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  *****************************************************************************/
142 void 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  *****************************************************************************/
155 void 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  *****************************************************************************/
165 void 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  *****************************************************************************/
174 void 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  *****************************************************************************/
184 void 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  *****************************************************************************/
193 void 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  *****************************************************************************/
200 int8_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  *****************************************************************************/
207 int16_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  *****************************************************************************/
214 int32_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  *****************************************************************************/
221 int32_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  *****************************************************************************/
228 uint8_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  *****************************************************************************/
235 uint16_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  *****************************************************************************/
242 uint32_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  *****************************************************************************/
249 uint32_t SCI_Frame_Dequeue32u(sci_frame_t * frame);
250 
252 #endif /* SCI_FRAME_H */
SCI_Frame_Queue16s
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
SCI_Frame_IsStartFrame
uint8_t SCI_Frame_IsStartFrame(sci_frame_t const *frame)
Determines whether the frame is a start frame.
Definition: sci_frame.c:75
SCI_Frame_SetByte
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
SCI_Frame_BytesToRead
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
SCI_Frame_Dequeue24s
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
SCI_Frame_Dequeue08u
uint8_t SCI_Frame_Dequeue08u(sci_frame_t *frame)
Takes a unsigned byte (8-bit) from the RX buffer.
Definition: sci_frame.c:221
SCI_Frame_PutChar
void SCI_Frame_PutChar(char c, void *frame)
Inserts a char into the TX buffer.
Definition: sci_frame.c:250
SCI_Frame_Dequeue32s
int32_t SCI_Frame_Dequeue32s(sci_frame_t *frame)
Takes a signed word (32-bit) from the RX buffer.
Definition: sci_frame.c:212
SCI_Frame_Queue32u
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
sci_internal_types.h
SCI: The internal type definitions.
SCI_Frame_Dequeue08s
int8_t SCI_Frame_Dequeue08s(sci_frame_t *frame)
Takes a signed byte (8-bit) from the RX buffer.
Definition: sci_frame.c:193
SCI_Frame_Queue24s
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
SCI_Frame_Queue08u
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
time.h
This file is part of the AFBR-S50 API.
sci_frame_t
Data buffer for outgoing frames.
Definition: sci_internal_types.h:109
SCI_Frame_Queue08s
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
ltc_t
A data structure to represent current time.
Definition: time.h:69
SCI_Frame_Queue_Time
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_Frame_TotalFrameLength
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
SCI_Frame_Dequeue16s
int16_t SCI_Frame_Dequeue16s(sci_frame_t *frame)
Takes a signed halfword (16-bit) from the RX buffer.
Definition: sci_frame.c:197
SCI_Frame_Dequeue32u
uint32_t SCI_Frame_Dequeue32u(sci_frame_t *frame)
Takes a unsigned word (32-bit) from the RX buffer.
Definition: sci_frame.c:240
SCI_Frame_Queue32s
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
SCI_Frame_Queue16u
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
SCI_Frame_Queue24u
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
SCI_Frame_Dequeue16u
uint16_t SCI_Frame_Dequeue16u(sci_frame_t *frame)
Takes a unsigned halfword (16-bit) from the RX buffer.
Definition: sci_frame.c:225
SCI_Frame_Dequeue24u
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