FreeHIL
Loading...
Searching...
No Matches
FH_UART08.c
Go to the documentation of this file.
1/**
2 * @file
3 * @brief
4 * <b>File Map:</b>\n
5 * <b>FH_Functions</b>, Section <b>FH_UART</b>, Peripheral <b>FH_UART08</b> (UART 08)\n
6 * (The <b>UART08 (UART 08)</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported)\n
7 *
8 * @note To have a clean code, <b>FH</b> user should have the implementation of the initialization and send functions of the <b>UART 08</b> in a separate c file\n
9 * Then <b>FH</b> user should include the header file <b>(.h)</b> of the related source file <b>(.c)</b> here\n
10 * This header file shall include the following items:\n
11 * The declaration of the initialization function of the <b>UART 08</b>\n
12 * The declaration of the send function of the <b>UART 08</b>\n\n
13 *
14 * <b>FH</b> user shall use <b>FH_UART08_ReceiveBuf</b> and <b>FH_UART08_ReceiveBufIndex</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file\n
15 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there\n
16 * In other word, <b>FH_UART08_ReceiveBuf</b> array shall receive every byte of the received data there with <b>FH_UART08_ReceiveBufIndex</b> as index of the array
17 *
18 * <b>FH_UART08_SharedDataBuf_8Bits</b>, <b>FH_UART08_SharedDataBuf_16Bits</b> and <b>FH_UART08_SharedDataBuf_32Bits</b> are optional and could be left intact\n
19 * They could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> , ...\n
20 * They are controllable with some commands (described in this file) through <b>RobotFramework</b>\n
21 *
22 * @attention There are a total number of <b>3 attentions</b> (<b>FH</b> user defined code) in this file where <b>FH</b> user shall insert some code\n
23 * Other parts could be left intact
24 *
25 *******************************************************************************
26 * SPDX-License-Identifier: Apache-2.0
27 *
28 * Copyright 2026 Vahid Hasirchi
29 *
30 * Licensed under the Apache License, Version 2.0 (the "License");
31 * you may not use this file except in compliance with the License.
32 * You may obtain a copy of the License at
33 *
34 * http://www.apache.org/licenses/LICENSE-2.0
35 *
36 * Unless required by applicable law or agreed to in writing, software
37 * distributed under the License is distributed on an "AS IS" BASIS,
38 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39 * See the License for the specific language governing permissions and
40 * limitations under the License.
41 ********************************************************************************
42
43 *
44 * <b>For more information refer to FreeHIL.com</b>
45 *
46*/
47/* Primary Includes ------------------------------------------------------------------*/
48// Attention 1: FH user defined code (include the mentioned header file here)
49
50//
52
53#ifdef FH_UART08 // It is configurable in FH_UART_Configs.h
54
55#if FH_UART_MaxPeripheralNumber > 0 // It is configurable in FH_DevicePeripherals.h
56
57/* Secondary Includes ------------------------------------------------------------------*/
63
64/*!
65 <b>FH</b> user shall use <b>FH_UART08_ReceiveBuf</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file\n
66 For this to happen, FH user shall just include FH_UART08_GlobalVariables.h there\n
67 In other word, <b>FH_UART08_ReceiveBuf</b> array shall receive every byte of the received data there\n
68 It is configurable in FH_UART08_Configs.h
69*/
71
72/*!
73 <b>FH_UART08_ReceiveBufIndex</b> is the index of <b>FH_UART08_ReceiveBuf</b>
74*/
75volatile uint16_t FH_UART08_ReceiveBufIndex = 0;
76
77/*!
78 <b>FH_UART08_SharedDataBuf_8Bits</b> is optional and could be left intact\n
79 It could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> , ...
80 It are controllable with some commands (described in this file) through <b>RobotFramework</b>\n
81 It is configurable in FH_UART08_Configs.h
82*/
84
85/*!
86 <b>FH_UART08_SharedDataBuf_16Bits</b> is optional and could be left intact\n
87 It could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> , ...
88 It are controllable with some commands (described in this file) through <b>RobotFramework</b>\n
89 It is configurable in FH_UART08_Configs.h
90*/
92/*!
93 <b>FH_UART08_SharedDataBuf_32Bits</b> is optional and could be left intact\n
94 It could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> , ...
95 It are controllable with some commands (described in this file) through <b>RobotFramework</b>\n
96 It is configurable in FH_UART08_Configs.h
97*/
99
100/**
101 * @brief This function initializes the <b>UART 08</b>\n
102 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
103 * <b>FH</b> user should call the initialization function of the interested UART here
104 *
105 * @param fh_RFCommunication_Message
106 * The message frame set by <b>RobotFramework</b>
107 *
108 * @return FH_ErrorInfo is returned
109 *
110 * @note
111 * To have a clean code, just include the related header file\n
112 * Then just call the function here
113 *
114 * @verbatim
115 ==============================================================================
116 ##### RobotFramework Example #####
117 ==============================================================================
118 @{MessageData} = Create List ${UART08}
119 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_Init} Data=@{MessageData}
120 ${Result} SendMessage &{Message}
121
122 Comments:
123
124 UART08 => It indicates the UART 08
125 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
126 Function_UART => It is the function in the message frame
127 UART_Commands_Init => It is the command of the function in the message frame
128 @endverbatim
129 *
130 *
131 * @warning
132 * To be able to send or receive data through the <b>UART 08</b> of the micro-controller on which <b>FH</b> source code is ported, this function shall be invoked once by <b>RobotFramework</b> firstly\n
133 * In other words, before invoking for example <b>FH_UART_Send_UART08</b> or <b>FH_UART_Receive_UART08</b> functions or ... from <b>RobotFramework</b>, this function shall be invoked in order to initialize the UART
134 *
135
136*/
138{
139 FH_ErrorInfo fh_ErrorInfo; // Error Information
140 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
141
142 // Attention 2: FH user defined code (call the initialization function of the UART 08 here)
143
144 // YourInitializationFunctionName ();
145
146 //
147
148 return fh_ErrorInfo;
149}
150
151/**
152 * @brief This function sends data through the <b>UART 08</b>\n
153 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
154 * <b>FH</b> user should call the send function of the interested UART here
155 *
156 * @param fh_RFCommunication_Message
157 * The message frame set by <b>RobotFramework</b>
158 *
159 * @return FH_ErrorInfo is returned
160 *
161 * @note
162 * To have a clean code, just include the related header file\n
163 * Then just call the function here
164 *
165 * @verbatim
166 ==============================================================================
167 ##### RobotFramework Example #####
168 ==============================================================================
169 @{MessageData} = Create List ${UART08} 02 B1 FF
170 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_Send} Data=@{MessageData}
171 ${Result} SendMessage &{Message}
172
173 Comments:
174
175 UART08 => It indicates the UART 08
176 02 => Example length of the data to be sent
177 B1 FF => Example data (0xB1, 0xFF) to be sent (or apart from the data to be sent, it may include some other data like ID, Filter, ... to be processed too, if need be) through the <b>UART 08</b>\n
178 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
179 Function_UART => It is the function in the message frame
180 UART_Commands_Send => It is the command of the function in the message frame
181 @endverbatim
182 *
183 *
184 * @warning
185 * To be able to send data through the <b>UART 08</b> of the micro-controller on which <b>FH</b> source code is ported, the <b>FH_UART_Init_UART08</b> function shall be invoked once by <b>RobotFramework</b> firstly\n
186 * In other words, before invoking <b>FH_UART_Send_UART08</b> function from <b>RobotFramework</b>, <b>FH_UART_Init_UART08</b> function shall be invoked in order to initialize the UART
187 *
188
189*/
191{
192 FH_ErrorInfo fh_ErrorInfo; // Error Information
193 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
194
195 // **** Option 1 (just one of the 2 options here shall be selected) ****
196 // If the data is supposed to be directly sent (without the need to be processed), the following code could be simply utilized:
197
199 {
200 // Attention 3: FH user defined code (call the send function of the UART 08 here with fh_RFCommunication_Message -> Data[i] as argument)
201
202 // YourSendFunctionName (fh_RFCommunication_Message -> Data[i]);
203
204 //
205 }
206
207 // **** Option 2 (just one of the 2 options here shall be selected) ****
208 // If the data is supposed to be processed, an extra process function shall be developed by FH user and the following code could be utilized:
209
210 // Attention 3: FH user defined code (call the send process function of the UART 08 here with &fh_RFCommunication_Message -> Data[UART_Send_Data] and fh_RFCommunication_Message -> Data[UART_Send_DataLength] as argument)
211 // Hint: The prototype of the send process function should be something like YourSendProcessFunctionName(uint8_t* Data, uint8_t DataLength);
212
213 // YourSendProcessFunctionName (&fh_RFCommunication_Message -> Data[UART_Send_Data], fh_RFCommunication_Message -> Data[UART_Send_DataLength]);
214
215 //
216
217 return fh_ErrorInfo;
218}
219
220/**
221 * @brief This function retrieves the <b>ISR</b> (Interrupt Service Routine) receive buffer (<b>FH_UART08_ReceiveBuf</b>) of the <b>UART 08</b>\n
222 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
223 * <b>FH</b> user could left the present source code here intact
224 *
225 * @param fh_RFCommunication_Message
226 * The message frame set by <b>RobotFramework</b>
227 * @param DataSize
228 * *DataSize will be set to the <b>ISR</b> (Interrupt Service Routine) receive buffer index (<b>FH_UART08_ReceiveBufIndex</b>) of the <b>UART 08</b>
229 * @param Data
230 * *Data will be set to the <b>ISR</b> (Interrupt Service Routine) receive buffer (<b>FH_UART08_ReceiveBuf</b>) of the <b>UART 08</b>
231 *
232 * @return FH_ErrorInfo is returned
233 *
234 * @note
235 * <b>FH</b> user shall use <b>FH_UART08_ReceiveBuf</b> and <b>FH_UART08_ReceiveBufIndex</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file\n
236 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there\n
237 * In other word, <b>FH_UART08_ReceiveBuf</b> array shall receive every byte of the received data there with <b>FH_UART08_ReceiveBufIndex</b> as index of the array
238 *
239 * @verbatim
240 ==============================================================================
241 ##### RobotFramework Example #####
242 ==============================================================================
243 @{MessageData} = Create List ${UART08}
244 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_Receive} Data=@{MessageData}
245 ${Result} SendMessage &{Message}
246
247 Comments:
248
249 UART08 => It indicates the UART 08
250 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
251 Function_UART => It is the function in the message frame
252 UART_Commands_Receive => It is the command of the function in the message frame
253 @endverbatim
254 *
255 *
256 * @warning
257 * To be able to receive data through the <b>UART 08</b> of the micro-controller on which <b>FH</b> source code is ported, the <b>FH_UART_Init_UART08</b> function shall be invoked once by <b>RobotFramework</b> firstly\n
258 * In other words, before invoking <b>FH_UART_Receive_UART08</b> function from <b>RobotFramework</b>, <b>FH_UART_Init_UART08</b> function shall be invoked in order to initialize the UART
259 *
260 * @note
261 * The only solution for resetting the receive buffer index (<b>FH_UART08_ReceiveBufIndex</b>) is using <b>FH_UART_ResetRB_UART08</b> function\n
262 * In other words, <b>FH_UART08_ReceiveBufIndex</b> may have been already increased if any data has been already received\n
263 * So it is normally required to invoke <b>FH_UART_ResetRB_UART08</b> through <b>RobotFramework</b> to reset the receive buffer index (<b>FH_UART08_ReceiveBufIndex</b>) before invoking <b>FH_UART_Receive_UART08</b>
264 *
265
266*/
268{
269 FH_ErrorInfo fh_ErrorInfo; // Error Information
270 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
271
272 if (FH_UART08_ReceiveBufIndex > 0) // If there is at least one byte of data received in the ISR (Interrupt Service Routine) of the UART 08
273 {
274 *DataSize = FH_UART08_ReceiveBufIndex; // The number of the received bytes in the ISR (Interrupt Service Routine) of the UART 08
275 for (uint8_t i = 0; i < FH_UART08_ReceiveBufIndex; i++)
276 {
277 *(Data + i) = FH_UART08_ReceiveBuf[i]; // The data received in the ISR (Interrupt Service Routine) of the UART 08
278 }
279 }
280 *DataSize = FH_UART08_ReceiveBufIndex; // The number of the received bytes in the ISR (Interrupt Service Routine) of the UART 08
281
282 return fh_ErrorInfo;
283}
284
285/**
286 * @brief This function waits to receive the specified number of bytes of data through the <b>ISR</b> (Interrupt Service Routine) receive buffer (<b>FH_UART08_ReceiveBuf</b>) of the <b>UART 08</b>\n
287 * A maximum timeout is specified too\n
288 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
289 * <b>FH</b> user could left the present source code here intact
290 *
291 * @param fh_RFCommunication_Message
292 * The message frame set by <b>RobotFramework</b>
293 * @param DataSize
294 * *DataSize will be set to the <b>ISR</b> (Interrupt Service Routine) receive buffer index (<b>FH_UART08_ReceiveBufIndex</b>) of the <b>UART 08</b>
295 * @param Data
296 * *Data will be set to the <b>ISR</b> (Interrupt Service Routine) receive buffer (<b>FH_UART08_ReceiveBuf</b>) of the <b>UART 08</b>
297 *
298 * @return FH_ErrorInfo is returned
299 *
300 * @note
301 * <b>FH</b> user shall use <b>FH_UART08_ReceiveBuf</b> and <b>FH_UART08_ReceiveBufIndex</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file\n
302 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there\n
303 * In other word, <b>FH_UART08_ReceiveBuf</b> array shall receive every byte of the received data there with <b>FH_UART08_ReceiveBufIndex</b> as index of the array
304 *
305 * @verbatim
306 ==============================================================================
307 ##### RobotFramework Example #####
308 ==============================================================================
309 @{MessageData} = Create List ${UART08} 05 00 00 0B B8
310 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_ReceiveW} Data=@{MessageData}
311 ${Result} SendMessage &{Message}
312
313 Comments:
314
315 UART08 => It indicates the UART 08
316 05 => The expected number of bytes of data to be received through the <b>ISR</b> (Interrupt Service Routine) receive buffer (FH_UART08_ReceiveBuf) of the <b>UART 08</b>
317 00 00 0B B8 => Example data (0x00000BB8 mili-seconds) as timeout of receiving the expected number of bytes
318 FH_GlobalTimeCounter which is a global variable is utilized to calculate the timeout
319 FH_GlobalTimeCounter shall be incremented every <b>1 mili-second</b> in an interested timer <b>ISR</b> (Interrupt Service Routine) by <b>FH</b> user
320 For this to happen, <b>FH_GlobalTimerCount.h</b> shall be included in the interested timer <b>ISR</b> (Interrupt Service Routine) file
321 If the expected number of bytes are received, the function does not wait anymore for the remaining time of the timeout
322 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
323 Function_UART => It is the function in the message frame
324 UART_Commands_ReceiveW => It is the command of the function in the message frame
325 @endverbatim
326 *
327 * @warning
328 * To be able to receive data through the <b>UART 08</b> of the micro-controller on which <b>FH</b> source code is ported, the <b>FH_UART_Init_UART08</b> function shall be invoked once by <b>RobotFramework</b> firstly\n
329 * In other words, before invoking <b>FH_UART_ReceiveW_UART08</b> function from <b>RobotFramework</b>, <b>FH_UART_Init_UART08</b> function shall be invoked in order to initialize the UART
330 *
331 * @note
332 * The only solution for resetting the receive buffer index (<b>FH_UART08_ReceiveBufIndex</b>) is using <b>FH_UART_ResetRB_UART08</b> function\n
333 * In other words, <b>FH_UART08_ReceiveBufIndex</b> may have been already increased if any data has been already received\n
334 * So it is normally required to invoke <b>FH_UART_ResetRB_UART08</b> through <b>RobotFramework</b> to reset the receive buffer index (<b>FH_UART08_ReceiveBufIndex</b>) before invoking <b>FH_UART_ReceiveW_UART08</b>
335 *
336
337*/
339{
340 FH_ErrorInfo fh_ErrorInfo; // Error Information
341 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
342
343 uint8_t ExpectedDataLength;
344 ExpectedDataLength = fh_RFCommunication_Message -> Data[UART_ReceiveW_ExpectedDataLength]; // The expected number of bytes to be received through the ISR (Interrupt Service Routine) receive buffer (FH_UART08_ReceiveBuf) of the UART 08
345
346 uint32_t MaxTimerCount = FH_ConvertUint8ToUint32(&fh_RFCommunication_Message -> Data[UART_ReceiveW_MaxTimerCount]); // The timeout of receiving the expected number of bytes
347
348 FH_GlobalTimeCounter = 0; // The global variable is utilized to calculate the timeout
349 // Wait till the expected number of bytes are received or timeout happens
350 while (FH_UART08_ReceiveBufIndex < ExpectedDataLength && FH_GlobalTimeCounter < MaxTimerCount)
351 {
352 }
353
354 if (FH_UART08_ReceiveBufIndex > 0) // If there is at least one byte of data received in the ISR (Interrupt Service Routine) of the UART 08
355 {
356 *DataSize = FH_UART08_ReceiveBufIndex;
357 for (uint8_t i = 0; i < FH_UART08_ReceiveBufIndex; i++)
358 {
359 *(Data + i) = FH_UART08_ReceiveBuf[i];
360 }
361 }
362 *DataSize = FH_UART08_ReceiveBufIndex; // The number of the received bytes in the ISR (Interrupt Service Routine) of the UART 08
363
364 return fh_ErrorInfo;
365}
366
367/**
368 * @brief This function resets the <b>ISR</b> (Interrupt Service Routine) receive buffer index (<b>FH_UART08_ReceiveBufIndex</b>) of the <b>UART 08</b>\n
369 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
370 * <b>FH</b> user could left the present source code here intact
371 *
372 * @param fh_RFCommunication_Message
373 * The message frame set by <b>RobotFramework</b>
374 *
375 * @return FH_ErrorInfo is returned
376 *
377 * @note
378 * <b>FH</b> user shall use <b>FH_UART08_ReceiveBuf</b> and <b>FH_UART08_ReceiveBufIndex</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file\n
379 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there\n
380 * In other word, <b>FH_UART08_ReceiveBuf</b> array shall receive every byte of the received data there with <b>FH_UART08_ReceiveBufIndex</b> as index of the array
381 *
382 * @verbatim
383 ==============================================================================
384 ##### RobotFramework Example #####
385 ==============================================================================
386 @{MessageData} = Create List ${UART08}
387 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_ResetRB} Data=@{MessageData}
388 ${Result} SendMessage &{Message}
389
390 Comments:
391
392 UART08 => It indicates the UART 08
393 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
394 Function_UART => It is the function in the message frame
395 UART_Commands_ResetRB => It is the command of the function in the message frame
396 @endverbatim
397 *
398 * @warning
399 * The only solution for resetting the receive buffer index (<b>FH_UART08_ReceiveBufIndex</b>) is using <b>FH_UART_ResetRB_UART08</b> function\n
400 * In other words, <b>FH_UART08_ReceiveBufIndex</b> may have been already increased if any data has been already received\n
401 * So it is normally required to invoke <b>FH_UART_ResetRB_UART08</b> through <b>RobotFramework</b> to reset the receive buffer index (<b>FH_UART08_ReceiveBufIndex</b>) before invoking <b>FH_UART_Receive_UART08</b> or <b>FH_UART_ReceiveW_UART08</b> or ...
402 *
403
404*/
406{
407 FH_ErrorInfo fh_ErrorInfo; // Error Information
408 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
409
410 FH_UART08_ReceiveBufIndex = 0; // The receive buffer index of the ISR (Interrupt Service Routine) of the UART 08
411
412 return fh_ErrorInfo;
413}
414
415/**
416 * @brief This function sets the shared data buffer (<b>FH_UART08_SharedDataBuf_8Bits</b>) of the <b>UART 08</b>\n
417 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
418 * <b>FH_UART08_SharedDataBuf_8Bits</b> is a shared global 8 bit array which is a data bridge between <b>RobotFramework</b> and <b>FH</b> user code\n
419 * <b>FH_UART08_SharedDataBuf_8Bits</b> is optional\n
420 * It could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> or ...
421 *
422 * <b>FH</b> user could left the present source code here intact
423 *
424 * @param fh_RFCommunication_Message
425 * The message frame set by <b>RobotFramework</b>
426 *
427 * @return FH_ErrorInfo is returned
428 *
429 * @note
430 * <b>FH</b> user could use <b>FH_UART08_SharedDataBuf_8Bits</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file or anywhere else interested\n
431 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there
432 *
433 * @verbatim
434 ==============================================================================
435 ##### RobotFramework Example #####
436 ==============================================================================
437 @{MessageData} = Create List ${UART08} 04 AA BB CC DD
438 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_SSD8} Data=@{MessageData}
439 ${Result} SendMessage &{Message}
440
441 Comments:
442
443 UART08 => It indicates the UART 08
444 04 => Example interested length of the 8 bit data to be set
445 AA BB CC DD => Example data (0xAA, 0xBB, 0xCC, 0xDD) to be set in <b>FH_UART08_SharedDataBuf_8Bits</b>
446 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
447 Function_UART => It is the function in the message frame
448 UART_Commands_SSD8 => It is the command of the function in the message frame
449 @endverbatim
450 *
451
452*/
454{
455 FH_ErrorInfo fh_ErrorInfo; // Error Information
456 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
457
458 if (fh_RFCommunication_Message -> Data[UART_SSD8_SharedDataLength] > FH_UART08_SharedDataBufLength_8Bits) // The length of the 8 bit data to be set
459 {
460 fh_ErrorInfo.error_code = FH_ERROR_Functions; // FH User Defined Function Error
461 return fh_ErrorInfo;
462 }
463
464 for (uint8_t i = 0; i < fh_RFCommunication_Message -> Data[UART_SSD8_SharedDataLength] ; i++)
465 {
466 FH_UART08_SharedDataBuf_8Bits[i] = fh_RFCommunication_Message -> Data[UART_SSD8_SharedData+i]; // Set data to FH_UART08_SharedDataBuf_8Bits
467 }
468 fh_ErrorInfo.error_code = FH_ERROR_OK; // There is no Error
469
470 return fh_ErrorInfo;
471}
472
473/**
474 * @brief This function sets the shared data buffer (<b>FH_UART08_SharedDataBuf_16Bits</b>) of the <b>UART 08</b>\n
475 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
476 * <b>FH_UART08_SharedDataBuf_16Bits</b> is a shared global 8 bit array which is a data bridge between <b>RobotFramework</b> and <b>FH</b> user code\n
477 * <b>FH_UART08_SharedDataBuf_16Bits</b> is optional\n
478 * It could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> or ...
479 *
480 * <b>FH</b> user could left the present source code here intact
481 *
482 * @param fh_RFCommunication_Message
483 * The message frame set by <b>RobotFramework</b>
484 *
485 * @return FH_ErrorInfo is returned
486 *
487 * @note
488 * <b>FH</b> user could use <b>FH_UART08_SharedDataBuf_16Bits</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file or anywhere else interested\n
489 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there
490 *
491 * @verbatim
492 ==============================================================================
493 ##### RobotFramework Example #####
494 ==============================================================================
495 @{MessageData} = Create List ${UART08} 02 AA BB CC DD
496 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_SSD16} Data=@{MessageData}
497 ${Result} SendMessage &{Message}
498
499 Comments:
500
501 UART08 => It indicates the UART 08
502 02 => Example interested length of the 16 bit data to be set
503 AA BB CC DD => Example data (0xAABB and 0xCCDD) to be set in <b>FH_UART08_SharedDataBuf_16Bits</b>
504 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
505 Function_UART => It is the function in the message frame
506 UART_Commands_SSD16 => It is the command of the function in the message frame
507 @endverbatim
508 *
509
510*/
512{
513 FH_ErrorInfo fh_ErrorInfo; // Error Information
514 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
515
516 if (fh_RFCommunication_Message -> Data[UART_SSD16_SharedDataLength] > (FH_UART08_SharedDataBufLength_16Bits * 2)) // The length of the 16 bit data to be set
517 {
518 fh_ErrorInfo.error_code = FH_ERROR_Functions; // FH User Defined Function Error
519 return fh_ErrorInfo;
520 }
521
522 uint8_t i = 0;
523 uint8_t SharedDataIndex = UART_SSD16_SharedData; // Shared Data Index in FH_UART_Commandelements_SSD16
524 do
525 {
526 FH_UART08_SharedDataBuf_16Bits[i] = FH_ConvertUint8ToUint16(&fh_RFCommunication_Message -> Data[SharedDataIndex]); // Set data to FH_UART08_SharedDataBuf_16Bits
527 SharedDataIndex = SharedDataIndex + 2;
528 i = i + 1;
529 }while (i < fh_RFCommunication_Message -> Data[UART_SSD16_SharedDataLength]); // The length of the 16 bit data to be set
530 fh_ErrorInfo.error_code = FH_ERROR_OK; // There is no Error
531
532 return fh_ErrorInfo;
533}
534
535/**
536 * @brief This function sets the shared data buffer (<b>FH_UART08_SharedDataBuf_32Bits</b>) of the <b>UART 08</b>\n
537 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
538 * <b>FH_UART08_SharedDataBuf_32Bits</b> is a shared global 8 bit array which is a data bridge between <b>RobotFramework</b> and <b>FH</b> user code\n
539 * <b>FH_UART08_SharedDataBuf_32Bits</b> is optional\n
540 * It could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> or ...
541 *
542 * <b>FH</b> user could left the present source code here intact
543 *
544 * @param fh_RFCommunication_Message
545 * The message frame set by <b>RobotFramework</b>
546 *
547 * @return FH_ErrorInfo is returned
548 *
549 * @note
550 * <b>FH</b> user could use <b>FH_UART08_SharedDataBuf_32Bits</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file or anywhere else interested\n
551 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there
552 *
553 * @verbatim
554 ==============================================================================
555 ##### RobotFramework Example #####
556 ==============================================================================
557 @{MessageData} = Create List ${UART08} 02 AA BB CC DD 01 02 03 04
558 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_SSD32} Data=@{MessageData}
559 ${Result} SendMessage &{Message}
560
561 Comments:
562
563 UART08 => It indicates the UART 08
564 02 => Example interested length of the 32 bit data to be set
565 AA BB CC DD 01 02 03 04 => Example data (0xAABBCCDD and 0x01020304) to be set in <b>FH_UART08_SharedDataBuf_32Bits</b>
566 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
567 Function_UART => It is the function in the message frame
568 UART_Commands_SSD32 => It is the command of the function in the message frame
569 @endverbatim
570 *
571
572*/
574{
575 FH_ErrorInfo fh_ErrorInfo; // Error Information
576 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
577
578 if (fh_RFCommunication_Message -> Data[UART_SSD32_SharedDataLength] > (FH_UART08_SharedDataBufLength_32Bits * 4)) // The length of the 32 bit data to be set
579 {
580 fh_ErrorInfo.error_code = FH_ERROR_Functions; // FH User Defined Function Error
581 return fh_ErrorInfo;
582 }
583
584 uint8_t i = 0;
585 uint8_t SharedDataIndex = UART_SSD32_SharedData; // Shared Data Index in FH_UART_Commandelements_SSD32
586 do
587 {
588 FH_UART08_SharedDataBuf_32Bits[i] = FH_ConvertUint8ToUint32(&fh_RFCommunication_Message -> Data[SharedDataIndex]); // Set data to FH_UART08_SharedDataBuf_32Bits
589 SharedDataIndex = SharedDataIndex + 4;
590 i = i + 1;
591 }while (i < fh_RFCommunication_Message -> Data[UART_SSD32_SharedDataLength]); // The length of the 32 bit data to be set
592
593 fh_ErrorInfo.error_code = FH_ERROR_OK; // There is no Error
594
595 return fh_ErrorInfo;
596}
597
598/**
599 * @brief This function gets the shared data buffer (<b>FH_UART08_SharedDataBuf_8Bits</b>) of the <b>UART 08</b>\n
600 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
601 * <b>FH_UART08_SharedDataBuf_8Bits</b> is a shared global 8 bit array which is a data bridge between <b>RobotFramework</b> and <b>FH</b> user code\n
602 * <b>FH_UART08_SharedDataBuf_8Bits</b> is optional\n
603 * It could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> or ...
604 *
605 * <b>FH</b> user could left the present source code here intact
606 *
607 * @param fh_RFCommunication_Message
608 * The message frame set by <b>RobotFramework</b>
609 * @param SharedDataLength
610 * *SharedDataLength will be set to <b>FH_UART08_SharedDataBufLength_8Bits</b>
611 * @param SharedData
612 * *SharedData will be set to <b>FH_UART08_SharedDataBuf_8Bits</b>
613 *
614 * @return FH_ErrorInfo is returned
615 *
616 * @note
617 * <b>FH</b> user could use <b>FH_UART08_SharedDataBuf_8Bits</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file or anywhere else interested\n
618 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there
619 *
620 * @verbatim
621 ==============================================================================
622 ##### RobotFramework Example #####
623 ==============================================================================
624 @{MessageData} = Create List ${UART08}
625 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_GSD8} Data=@{MessageData}
626 ${Result} SendMessage &{Message}
627
628 Comments:
629
630 UART08 => It indicates the UART 08
631 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
632 Function_UART => It is the function in the message frame
633 UART_Commands_GSD8 => It is the command of the function in the message frame
634 @endverbatim
635 *
636
637*/
639{
640 FH_ErrorInfo fh_ErrorInfo; // Error Information
641 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
642
643 for (uint8_t i = 0; i < FH_UART08_SharedDataBufLength_8Bits; i++)
644 {
645 *(SharedData + i) = FH_UART08_SharedDataBuf_8Bits[i];
646 }
647 *SharedDataLength = FH_UART08_SharedDataBufLength_8Bits; // The length of the 8 bit data to be set
648 fh_ErrorInfo.error_code = FH_ERROR_OK; // There is no Error
649
650 return fh_ErrorInfo;
651}
652
653/**
654 * @brief This function gets the shared data buffer (<b>FH_UART08_SharedDataBuf_16Bits</b>) of the <b>UART 08</b>\n
655 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
656 * <b>FH_UART08_SharedDataBuf_16Bits</b> is a shared global 16 bit array which is a data bridge between <b>RobotFramework</b> and <b>FH</b> user code\n
657 * <b>FH_UART08_SharedDataBuf_16Bits</b> is optional\n
658 * It could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> or ...
659 *
660 * <b>FH</b> user could left the present source code here intact
661 *
662 * @param fh_RFCommunication_Message
663 * The message frame set by <b>RobotFramework</b>
664 * @param SharedDataLength
665 * *SharedDataLength will be set to <b>FH_UART08_SharedDataBufLength_16Bits</b>
666 * @param SharedData
667 * *SharedData will be set to <b>FH_UART08_SharedDataBuf_16Bits</b>
668 *
669 * @return FH_ErrorInfo is returned
670 *
671 * @note
672 * <b>FH</b> user could use <b>FH_UART08_SharedDataBuf_16Bits</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file or anywhere else interested\n
673 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there
674 *
675 * @verbatim
676 ==============================================================================
677 ##### RobotFramework Example #####
678 ==============================================================================
679 @{MessageData} = Create List ${UART08}
680 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_GSD16} Data=@{MessageData}
681 ${Result} SendMessage &{Message}
682
683 Comments:
684
685 UART08 => It indicates the UART 08
686 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
687 Function_UART => It is the function in the message frame
688 UART_Commands_GSD16 => It is the command of the function in the message frame
689 @endverbatim
690 *
691
692*/
694{
695 FH_ErrorInfo fh_ErrorInfo; // Error Information
696 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
697
698 FH_Uint8Uint16 fh_Uint8Uint16; // Union to access 4 uint8_t out of 1 uint16_t
699 uint8_t SharedDataIndex = 0;
700 for (uint8_t i = 0; i < FH_UART08_SharedDataBufLength_16Bits; i++)
701 {
702 fh_Uint8Uint16.value = FH_UART08_SharedDataBuf_16Bits[i];
703 *(SharedData + SharedDataIndex++) = fh_Uint8Uint16.bytes[1];
704 *(SharedData + SharedDataIndex++) = fh_Uint8Uint16.bytes[0];
705 }
706 *SharedDataLength = FH_UART08_SharedDataBufLength_16Bits; // The length of the 16 bit data to be set
707 fh_ErrorInfo.error_code = FH_ERROR_OK; // There is no Error
708
709 return fh_ErrorInfo;
710}
711
712/**
713 * @brief This function gets the shared data buffer (<b>FH_UART08_SharedDataBuf_32Bits</b>) of the <b>UART 08</b>\n
714 * The <b>UART 08</b> could be any interested UART of the micro-controller on which <b>FH</b> source code is ported\n
715 * <b>FH_UART08_SharedDataBuf_32Bits</b> is a shared global 32 bit array which is a data bridge between <b>RobotFramework</b> and <b>FH</b> user code\n
716 * <b>FH_UART08_SharedDataBuf_32Bits</b> is optional\n
717 * It could be used by <b>FH</b> user to set some special data like receive filters on <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> or ...
718 *
719 * <b>FH</b> user could left the present source code here intact
720 *
721 * @param fh_RFCommunication_Message
722 * The message frame set by <b>RobotFramework</b>
723 * @param SharedDataLength
724 * *SharedDataLength will be set to <b>FH_UART08_SharedDataBufLength_32Bits</b>
725 * @param SharedData
726 * *SharedData will be set to <b>FH_UART08_SharedDataBuf_32Bits</b>
727 *
728 * @return FH_ErrorInfo is returned
729 *
730 * @note
731 * <b>FH</b> user could use <b>FH_UART08_SharedDataBuf_32Bits</b> in the receive <b>ISR</b> (Interrupt Service Routine) of the <b>UART 08</b> in a separate c file or anywhere else interested\n
732 * For this to happen, <b>FH</b> user shall just include <b>FH_UART08_GlobalVariables.h</b> there
733 *
734 * @verbatim
735 ==============================================================================
736 ##### RobotFramework Example #####
737 ==============================================================================
738 @{MessageData} = Create List ${UART08}
739 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_GSD32} Data=@{MessageData}
740 ${Result} SendMessage &{Message}
741
742 Comments:
743
744 UART08 => It indicates the UART 08
745 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
746 Function_UART => It is the function in the message frame
747 UART_Commands_GSD32 => It is the command of the function in the message frame
748 @endverbatim
749 *
750
751*/
753{
754 FH_ErrorInfo fh_ErrorInfo; // Error Information
755 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
756
757 FH_Uint8Uint32 fh_Uint8Uint32; // Union to access 4 uint8_t out of 1 uint32_t
758 uint8_t SharedDataIndex = 0;
759 for (uint8_t i = 0; i < FH_UART08_SharedDataBufLength_32Bits; i++)
760 {
761 fh_Uint8Uint32.value = FH_UART08_SharedDataBuf_32Bits[i];
762 *(SharedData + SharedDataIndex++) = fh_Uint8Uint32.bytes[3];
763 *(SharedData + SharedDataIndex++) = fh_Uint8Uint32.bytes[2];
764 *(SharedData + SharedDataIndex++) = fh_Uint8Uint32.bytes[1];
765 *(SharedData + SharedDataIndex++) = fh_Uint8Uint32.bytes[0];
766 }
767 *SharedDataLength = FH_UART08_SharedDataBufLength_32Bits; // The length of the 32 bit data to be set
768
769 fh_ErrorInfo.error_code = FH_ERROR_OK; // There is no Error
770 return fh_ErrorInfo;
771}
772
773#endif
774
775#endif