FreeHIL
Loading...
Searching...
No Matches
FH_UART.c
Go to the documentation of this file.
1/**
2 * @file
3 * @brief
4 * <b>File Map:</b>\n
5 * <b>FH_Root</b>, Section <b>FH_Perif</b>, <b>FH_UART</b>\n
6 * Functions in this file, handle RFCommunication (<b>RobotFramework</b> <b>C</b>ommunication) for all commands related to <b>UART</b>
7 *
8 * @attention <b>FH</b> user could left this file intact
9 *
10 *******************************************************************************
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Copyright 2026 Vahid Hasirchi
14 *
15 * Licensed under the Apache License, Version 2.0 (the "License");
16 * you may not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
18 *
19 * http://www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
26 ********************************************************************************
27
28 *
29 * <b>For more information refer to FreeHIL.com</b>
30 *
31*/
32/* Primary Includes ------------------------------------------------------------------*/
34
35#include "stdio.h"
36
37#if FH_UART_MaxPeripheralNumber > 0 // It is configurable in FH_DevicePeripherals.h
38
39/* Secondary Includes ------------------------------------------------------------------*/
76
77/**
78 * @brief This function is the basic function of handling RFCommunication (<b>RobotFramework</b> <b>C</b>ommunication) for all the <b>Commands</b> related to the <b>Function</b> <b>UART</b>\n
79 * This function is called from <b>FH_RFCommunication()</b>
80 *
81 * @param fh_RFCommunication_Message
82 * The message frame set by <b>RobotFramework</b>
83 *
84 * @return FH_ErrorInfo is returned
85 *
86
87*/
89{
90 FH_ErrorInfo fh_ErrorInfo; // Error Information
91 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
92
93 uint8_t FH_DataSize; // It temporarily stores the received data size
94 uint8_t TemporaryCollectDataBuffer [FH_RFCommunication_SendBufLength]; // It temporarily stores the received data
95 uint8_t* FH_DataSize_Ptr = &FH_DataSize; // Pointer with &FH_DataSize address
96 uint8_t* FH_DataBuffer_Ptr = &TemporaryCollectDataBuffer[0]; // Pointer with &TemporaryCollectDataBuffer[0] address
97
98 switch (fh_RFCommunication_Message -> Command) // Check different commands
99 {
100 case FH_UART_Commands_Init: // If the command is FH_UART_Commands_Init
101 fh_ErrorInfo = FH_UART_ProcessCommand_Init (fh_RFCommunication_Message); // Handle FH_UART_Commands_Init command
102 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|Init|%02x|\n",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code); // set FH_RFCommunication_SendBuf buffer
103 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
104 break;
105 case FH_UART_Commands_Send: // If the command is FH_UART_Commands_Send
106 fh_ErrorInfo = FH_UART_ProcessCommand_Send (fh_RFCommunication_Message); // Handle FH_UART_Commands_Send command
107 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|Send|%02x|\n",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code); // set FH_RFCommunication_SendBuf buffer
108 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
109 break;
110 case FH_UART_Commands_Receive: // If the command is FH_UART_Commands_Receive
111 fh_ErrorInfo = FH_UART_ProcessCommand_Receive (fh_RFCommunication_Message, FH_DataBuffer_Ptr, FH_DataSize_Ptr); // Handle FH_UART_Commands_Receive command
112
113 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|Receive|%02x|%02x|",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code,FH_DataSize); // set FH_RFCommunication_SendBuf buffer
114 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
115
116 for (uint8_t i = 0; i < FH_DataSize ; i++) // Iteration within the length of the FH_DataSize
117 {
118 sprintf(FH_RFCommunication_SendBuf,"%02x",TemporaryCollectDataBuffer[i]); // set FH_RFCommunication_SendBuf buffer
119 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
120 }
121
122 sprintf(FH_RFCommunication_SendBuf,"|\n"); // set FH_RFCommunication_SendBuf buffer
123 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
124 break;
125 case FH_UART_Commands_ReceiveW: // If the command is FH_UART_Commands_ReceiveW
126 fh_ErrorInfo = FH_UART_ProcessCommand_ReceiveW (fh_RFCommunication_Message, FH_DataBuffer_Ptr, FH_DataSize_Ptr); // Handle FH_UART_Commands_ReceiveW command
127
128 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|ReceiveW|%02x|%02x|",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code,FH_DataSize); // set FH_RFCommunication_SendBuf buffer
129 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
130
131 for (uint8_t i = 0; i < FH_DataSize ; i++) // Iteration within the length of the FH_DataSize
132 {
133 sprintf(FH_RFCommunication_SendBuf,"%02x",TemporaryCollectDataBuffer[i]); // set FH_RFCommunication_SendBuf buffer
134 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
135 }
136
137 sprintf(FH_RFCommunication_SendBuf,"|\n"); // set FH_RFCommunication_SendBuf buffer
138 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
139 break;
140 case FH_UART_Commands_ResetRB: // If the command is FH_UART_Commands_ResetRB
141 fh_ErrorInfo = FH_UART_ProcessCommand_ResetRB (fh_RFCommunication_Message); // Handle FH_UART_Commands_ResetRB command
142 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|ResetRB|%02x|\n",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code); // set FH_RFCommunication_SendBuf buffer
143 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
144 break;
145 case FH_UART_Commands_SSD8: // If the command is FH_UART_Commands_SSD8
146 fh_ErrorInfo = FH_UART_ProcessCommand_SSD8 (fh_RFCommunication_Message); // Handle FH_UART_Commands_SSD8 command
147 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|SSD8|%02x|\n",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code); // set FH_RFCommunication_SendBuf buffer
148 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
149 break;
150 case FH_UART_Commands_SSD16: // If the command is FH_UART_Commands_SSD16
151 fh_ErrorInfo = FH_UART_ProcessCommand_SSD16 (fh_RFCommunication_Message); // Handle FH_UART_Commands_SSD16 command
152 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|SSD16|%02x|\n",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code); // set FH_RFCommunication_SendBuf buffer
153 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
154 break;
155 case FH_UART_Commands_SSD32: // If the command is FH_UART_Commands_SSD32
156 fh_ErrorInfo = FH_UART_ProcessCommand_SSD32 (fh_RFCommunication_Message); // Handle FH_UART_Commands_SSD32 command
157 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|SSD32|%02x|\n",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code); // set FH_RFCommunication_SendBuf buffer
158 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
159 break;
160 case FH_UART_Commands_GSD8: // If the command is FH_UART_Commands_GSD8
161 fh_ErrorInfo = FH_UART_ProcessCommand_GSD8 (fh_RFCommunication_Message, FH_DataSize_Ptr, FH_DataBuffer_Ptr); // Handle FH_UART_Commands_GSD8 command
162
163 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|GSD8|%02x|%02x|",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code,FH_DataSize); // set FH_RFCommunication_SendBuf buffer
164 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
165
166 for (uint8_t i = 0; i < FH_DataSize ; i++) // Iteration within the length of the FH_DataSize
167 {
168 sprintf(FH_RFCommunication_SendBuf,"%02x",TemporaryCollectDataBuffer[i]); // set FH_RFCommunication_SendBuf buffer
169 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
170 }
171
172 sprintf(FH_RFCommunication_SendBuf,"|\n"); // set FH_RFCommunication_SendBuf buffer
173 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
174 break;
175 case FH_UART_Commands_GSD16: // If the command is FH_UART_Commands_GSD16
176 fh_ErrorInfo = FH_UART_ProcessCommand_GSD16 (fh_RFCommunication_Message, FH_DataSize_Ptr, FH_DataBuffer_Ptr); // Handle FH_UART_Commands_GSD16 command
177
178 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|GSD16|%02x|%02x|",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code,FH_DataSize); // set FH_RFCommunication_SendBuf buffer
179 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
180
181 for (uint8_t i = 0; i < FH_DataSize ; i++) // Iteration within the length of the FH_DataSize
182 {
183 sprintf(FH_RFCommunication_SendBuf,"%02x",TemporaryCollectDataBuffer[i]); // set FH_RFCommunication_SendBuf buffer
184 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
185 }
186
187 sprintf(FH_RFCommunication_SendBuf,"|\n"); // set FH_RFCommunication_SendBuf buffer
188 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
189 break;
190 case FH_UART_Commands_GSD32: // If the command is FH_UART_Commands_GSD32
191 fh_ErrorInfo = FH_UART_ProcessCommand_GSD32 (fh_RFCommunication_Message, FH_DataSize_Ptr, FH_DataBuffer_Ptr); // Handle FH_UART_Commands_GSD32 command
192
193 sprintf(FH_RFCommunication_SendBuf,"%02x|UART|GSD32|%02x|%02x|",FH_RFCommunication_DeviceAddress,fh_ErrorInfo.error_code,FH_DataSize); // set FH_RFCommunication_SendBuf buffer
194 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
195
196 for (uint8_t i = 0; i < FH_DataSize ; i++) // Iteration within the length of the FH_DataSize
197 {
198 sprintf(FH_RFCommunication_SendBuf,"%02x",TemporaryCollectDataBuffer[i]); // set FH_RFCommunication_SendBuf buffer
199 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
200 }
201
202 sprintf(FH_RFCommunication_SendBuf,"|\n"); // set FH_RFCommunication_SendBuf buffer
203 FH_RFCommunication_Send(FH_RFCommunication_SendBuf); // Send the result back to the Robot Framework
204 break;
205 default:
206 break;
207 }
208 return fh_ErrorInfo;
209}
210
211/**
212 * @brief This function handles <b>FH_UART_Commands_Init</b> command\n
213 * There are 3 main items handled in this function as following:\n
214 * 1 - Verifying the health of the received message\n
215 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
216 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
217 *
218 * @param fh_RFCommunication_Message
219 * The message frame set by <b>RobotFramework</b>
220 *
221 * @verbatim
222 ==============================================================================
223 ##### RobotFramework Example #####
224 ==============================================================================
225 @{MessageData} = Create List ${UART01}
226 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_Init} Data=@{MessageData}
227 ${Result} SendMessage &{Message}
228
229 Comments:
230
231 UART01 => It indicates the UART 01
232 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
233 Function_UART => It is the function in the message frame
234 UART_Commands_Init => It is the command of the function in the message frame
235 @endverbatim
236 *
237 * @return FH_ErrorInfo is returned
238 *
239
240*/
242{
243 FH_ErrorInfo fh_ErrorInfo; // Error Information
244 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
245
246 // 1 - Verifying the health of the received message
247 fh_ErrorInfo = FH_UART_Init_H(fh_RFCommunication_Message);
248 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
249 {
250 return fh_ErrorInfo; // Return the error
251 }
252
253 // 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer
254 FH_UART_Init_FuncPtrModel FH_UART_Init_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_Init_FuncPtrModel
255 FH_UART_Init_S(FH_UART_Init_FuncPtr); // Setting the address of the functions
256
257 // 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
258 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
259 fh_ErrorInfo = FH_UART_Init_C(fh_RFCommunication_Message, FH_UART_Init_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
260 return fh_ErrorInfo;
261}
262
263/**
264 * @brief This function handles <b>FH_UART_Commands_Send</b> command\n
265 * There are 3 main items handled in this function as following:\n
266 * 1 - Verifying the health of the received message\n
267 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
268 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
269 * (The next parameters after the first one, resemble the data to be sent)
270 *
271 * @param fh_RFCommunication_Message
272 * The message frame set by <b>RobotFramework</b>
273 *
274 * @verbatim
275 ==============================================================================
276 ##### RobotFramework Example #####
277 ==============================================================================
278 @{MessageData} = Create List ${UART01} 02 B1 FF
279 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_Send} Data=@{MessageData}
280 ${Result} SendMessage &{Message}
281
282 Comments:
283
284 UART01 => It indicates the UART 01
285 02 => Example length of the data to be sent
286 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 01</b>\n
287 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
288 Function_UART => It is the function in the message frame
289 UART_Commands_Send => It is the command of the function in the message frame
290 @endverbatim
291 *
292 * @return FH_ErrorInfo is returned
293 *
294
295*/
297{
298 FH_ErrorInfo fh_ErrorInfo; // Error Information
299 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
300
301 // 1 - Verifying the health of the received message
302 fh_ErrorInfo = FH_UART_Send_H(fh_RFCommunication_Message);
303 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
304 {
305 return fh_ErrorInfo; // Return the error
306 }
307
308 // 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer
309 FH_UART_Send_FuncPtrModel FH_UART_Send_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_Send_FuncPtrModel
310 FH_UART_Send_S(FH_UART_Send_FuncPtr); // Setting the address of the functions
311
312 // 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
313 // (The next parameters after the first one, resemble the data to be sent)
314 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
315 fh_ErrorInfo = FH_UART_Send_C(fh_RFCommunication_Message, FH_UART_Send_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
316 return fh_ErrorInfo;
317}
318
319/**
320 * @brief This function handles <b>FH_UART_Commands_Receive</b> command\n
321 * There are 3 main items handled in this function as following:\n
322 * 1 - Verifying the health of the received message\n
323 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
324 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
325 *
326 * @param fh_RFCommunication_Message
327 * The message frame set by <b>RobotFramework</b>
328 *
329 * @verbatim
330 ==============================================================================
331 ##### RobotFramework Example #####
332 ==============================================================================
333 @{MessageData} = Create List ${UART01}
334 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_Receive} Data=@{MessageData}
335 ${Result} SendMessage &{Message}
336
337 Comments:
338
339 UART01 => It indicates the UART 01
340 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
341 Function_UART => It is the function in the message frame
342 UART_Commands_Receive => It is the command of the function in the message frame
343 @endverbatim
344 *
345 * @return FH_ErrorInfo is returned
346 *
347
348*/
350{
351 FH_ErrorInfo fh_ErrorInfo; // Error Information
352 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
353
354 // 1 - Verifying the health of the received message
355 fh_ErrorInfo = FH_UART_Receive_H(fh_RFCommunication_Message);
356 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
357 {
358 return fh_ErrorInfo; // Return the error
359 }
360
361 // 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer
362 FH_UART_Receive_FuncPtrModel FH_UART_Receive_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_Receive_FuncPtrModel
363 FH_UART_Receive_S(FH_UART_Receive_FuncPtr); // Setting the address of the functions
364
365 // 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
366 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
367 fh_ErrorInfo = FH_UART_Receive_C(fh_RFCommunication_Message, FH_UART_ReceiveData,FH_UART_DataSize,FH_UART_Receive_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
368
369 return fh_ErrorInfo;
370}
371
372/**
373 * @brief This function handles <b>FH_UART_Commands_ReceiveW</b> command\n
374 * There are 3 main items handled in this function as following:\n
375 * 1 - Verifying the health of the received message\n
376 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
377 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame\n
378 * (The 2nd parameter after the first one, resembles the expected number of bytes of data to be received)\n
379 * (The next 4 parameters, resemble the timeout of receiving the expected number of bytes)
380 *
381 * @param fh_RFCommunication_Message
382 * The message frame set by <b>RobotFramework</b>
383 *
384 * @verbatim
385 ==============================================================================
386 ##### RobotFramework Example #####
387 ==============================================================================
388 @{MessageData} = Create List ${UART01} 05 00 00 0B B8
389 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_ReceiveW} Data=@{MessageData}
390 ${Result} SendMessage &{Message}
391
392 Comments:
393
394 UART01 => It indicates the UART 01
395 05 => The expected number of bytes of data to be received through the <b>ISR</b> (Interrupt Service Routine) receive buffer (FH_UART01_ReceiveBuf) of the <b>UART 01</b>
396 00 00 0B B8 => Example data (0x00000BB8 mili-seconds) as timeout of receiving the expected number of bytes
397 FH_GlobalTimeCounter which is a global variable is utilized to calculate the timeout
398 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
399 For this to happen, <b>FH_GlobalTimerCount.h</b> shall be included in the interested timer <b>ISR</b> (Interrupt Service Routine) file
400 If the expected number of bytes are received, the function does not wait anymore for the remaining time of the timeout
401 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
402 Function_UART => It is the function in the message frame
403 UART_Commands_ReceiveW => It is the command of the function in the message frame
404 @endverbatim
405 *
406 * @return FH_ErrorInfo is returned
407 *
408
409*/
411{
412 FH_ErrorInfo fh_ErrorInfo; // Error Information
413 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
414
415 // 1 - Verifying the health of the received message
416 fh_ErrorInfo = FH_UART_ReceiveW_H(fh_RFCommunication_Message);
417 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
418 {
419 return fh_ErrorInfo; // Return the error
420 }
421
422 // 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
423 FH_UART_ReceiveW_FuncPtrModel FH_UART_ReceiveW_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_ReceiveW_FuncPtrModel
424 FH_UART_ReceiveW_S(FH_UART_ReceiveW_FuncPtr); // Setting the address of the functions
425
426 // 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame\n
427 // (The 2nd parameter after the first one, resembles the expected number of bytes of data to be received)\n
428 // (The next 4 parameters, resemble the timeout of receiving the expected number of bytes)
429 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
430 fh_ErrorInfo = FH_UART_ReceiveW_C(fh_RFCommunication_Message, FH_UART_ReceiveData, FH_UART_DataSize, FH_UART_ReceiveW_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
431
432 return fh_ErrorInfo;
433}
434
435/**
436 * @brief This function handles <b>FH_UART_Commands_ResetRB</b> command\n
437 * There are 3 main items handled in this function as following:\n
438 * 1 - Verifying the health of the received message\n
439 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
440 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
441 *
442 * @param fh_RFCommunication_Message
443 * The message frame set by <b>RobotFramework</b>
444 *
445 * @verbatim
446 ==============================================================================
447 ##### RobotFramework Example #####
448 ==============================================================================
449 @{MessageData} = Create List ${UART01}
450 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_ResetRB} Data=@{MessageData}
451 ${Result} SendMessage &{Message}
452
453 Comments:
454
455 UART01 => It indicates the UART 01
456 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
457 Function_UART => It is the function in the message frame
458 UART_Commands_ResetRB => It is the command of the function in the message frame
459 @endverbatim
460 *
461 * @return FH_ErrorInfo is returned
462 *
463
464*/
466{
467 FH_ErrorInfo fh_ErrorInfo; // Error Information
468 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
469
470 // 1 - Verifying the health of the received message
471 fh_ErrorInfo = FH_UART_ResetRB_H(fh_RFCommunication_Message);
472 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
473 {
474 return fh_ErrorInfo; // Return the error
475 }
476
477 // 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer
478 FH_UART_ResetRB_FuncPtrModel FH_UART_ResetRB_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_ResetRB_FuncPtrModel
479 FH_UART_ResetRB_S (FH_UART_ResetRB_FuncPtr); // Setting the address of the functions
480
481 // 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
482 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
483 fh_ErrorInfo = FH_UART_ResetRB_C(fh_RFCommunication_Message,FH_UART_ResetRB_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
484
485 return fh_ErrorInfo;
486}
487
488/**
489 * @brief This function handles <b>FH_UART_Commands_SSD8</b> command\n
490 * There are 3 main items handled in this function as following:\n
491 * 1 - Verifying the health of the received message\n
492 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
493 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame\n
494 * (The 2nd parameter after the first one, resembles the interested length of the 8 bit data to be set)\n
495 * (The next parameters, resemble the data to be set in <b>FH_UART01_SharedDataBuf_8Bits</b>)
496 *
497 * @param fh_RFCommunication_Message
498 * The message frame set by <b>RobotFramework</b>
499 *
500 * @verbatim
501 ==============================================================================
502 ##### RobotFramework Example #####
503 ==============================================================================
504 @{MessageData} = Create List ${UART01} 04 AA BB CC DD
505 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_SSD8} Data=@{MessageData}
506 ${Result} SendMessage &{Message}
507
508 Comments:
509
510 UART01 => It indicates the UART 01
511 04 => Example interested length of the 8 bit data to be set
512 AA BB CC DD => Example data (0xAA, 0xBB, 0xCC, 0xDD) to be set in <b>FH_UART01_SharedDataBuf_8Bits</b>
513 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
514 Function_UART => It is the function in the message frame
515 UART_Commands_SSD8 => It is the command of the function in the message frame
516 @endverbatim
517 *
518 * @return FH_ErrorInfo is returned
519 *
520
521*/
523{
524 FH_ErrorInfo fh_ErrorInfo; // Error Information
525 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
526
527 fh_ErrorInfo = FH_UART_SSD8_H(fh_RFCommunication_Message);
528 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
529 {
530 return fh_ErrorInfo; // Return the error
531 }
532
533 FH_UART_SSD8_FuncPtrModel FH_UART_SSD8_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_SSD8_FuncPtrModel
534 FH_UART_SSD8_S (FH_UART_SSD8_FuncPtr); // Setting the address of the functions
535
536 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
537 fh_ErrorInfo = FH_UART_SSD8_C(fh_RFCommunication_Message, FH_UART_SSD8_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
538
539 return fh_ErrorInfo;
540}
541
542/**
543 * @brief This function handles <b>FH_UART_Commands_SSD16</b> command\n
544 * There are 3 main items handled in this function as following:\n
545 * 1 - Verifying the health of the received message\n
546 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
547 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame\n
548 * (The 2nd parameter after the first one, resembles the interested length of the 16 bit data to be set)\n
549 * (The next parameters, resemble the data to be set in <b>FH_UART01_SharedDataBuf_16Bits</b>)
550 *
551 * @param fh_RFCommunication_Message
552 * The message frame set by <b>RobotFramework</b>
553 *
554 * @verbatim
555 ==============================================================================
556 ##### RobotFramework Example #####
557 ==============================================================================
558 @{MessageData} = Create List ${UART01} 02 AA BB CC DD
559 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_SSD16} Data=@{MessageData}
560 ${Result} SendMessage &{Message}
561
562 Comments:
563
564 UART01 => It indicates the UART 01
565 02 => Example interested length of the 16 bit data to be set
566 AA BB CC DD => Example data (0xAABB and 0xCCDD) to be set in <b>FH_UART01_SharedDataBuf_16Bits</b>
567 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
568 Function_UART => It is the function in the message frame
569 UART_Commands_SSD16 => It is the command of the function in the message frame
570 @endverbatim
571 *
572 * @return FH_ErrorInfo is returned
573 *
574
575*/
577{
578 FH_ErrorInfo fh_ErrorInfo; // Error Information
579 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
580
581 fh_ErrorInfo = FH_UART_SSD16_H(fh_RFCommunication_Message);
582 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
583 {
584 return fh_ErrorInfo; // Return the error
585 }
586
587 FH_UART_SSD16_FuncPtrModel FH_UART_SSD16_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_SSD16_FuncPtrModel
588 FH_UART_SSD16_S(FH_UART_SSD16_FuncPtr); // Setting the address of the functions
589
590 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
591 fh_ErrorInfo = FH_UART_SSD16_C(fh_RFCommunication_Message, FH_UART_SSD16_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
592
593 return fh_ErrorInfo;
594}
595
596/**
597 * @brief This function handles <b>FH_UART_Commands_SSD32</b> command\n
598 * There are 3 main items handled in this function as following:\n
599 * 1 - Verifying the health of the received message\n
600 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
601 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame\n
602 * (The 2nd parameter after the first one, resembles the interested length of the 32 bit data to be set)\n
603 * (The next parameters, resemble the data to be set in <b>FH_UART01_SharedDataBuf_32Bits</b>)
604 *
605 * @param fh_RFCommunication_Message
606 * The message frame set by <b>RobotFramework</b>
607 *
608 * @verbatim
609 ==============================================================================
610 ##### RobotFramework Example #####
611 ==============================================================================
612 @{MessageData} = Create List ${UART01} 02 AA BB CC DD 01 02 03 04
613 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_SSD32} Data=@{MessageData}
614 ${Result} SendMessage &{Message}
615
616 Comments:
617
618 UART01 => It indicates the UART 01
619 02 => Example interested length of the 32 bit data to be set
620 AA BB CC DD 01 02 03 04 => Example data (0xAABBCCDD and 0x01020304) to be set in <b>FH_UART01_SharedDataBuf_32Bits</b>
621 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
622 Function_UART => It is the function in the message frame
623 UART_Commands_SSD32 => It is the command of the function in the message frame
624 @endverbatim
625 *
626 * @return FH_ErrorInfo is returned
627 *
628
629*/
631{
632 FH_ErrorInfo fh_ErrorInfo; // Error Information
633 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
634
635 fh_ErrorInfo = FH_UART_SSD32_H(fh_RFCommunication_Message);
636 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
637 {
638 return fh_ErrorInfo; // Return the error
639 }
640
641 FH_UART_SSD32_FuncPtrModel FH_UART_SSD32_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_SSD32_FuncPtrModel
642 FH_UART_SSD32_S(FH_UART_SSD32_FuncPtr); // Setting the address of the functions
643
644 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
645 fh_ErrorInfo = FH_UART_SSD32_C(fh_RFCommunication_Message, FH_UART_SSD32_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
646
647 return fh_ErrorInfo;
648}
649
650/**
651 * @brief This function handles <b>FH_UART_Commands_GSD8</b> command\n
652 * There are 3 main items handled in this function as following:\n
653 * 1 - Verifying the health of the received message\n
654 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
655 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
656 *
657 * @param fh_RFCommunication_Message
658 * The message frame set by <b>RobotFramework</b>
659 *
660 * @verbatim
661 ==============================================================================
662 ##### RobotFramework Example #####
663 ==============================================================================
664 @{MessageData} = Create List ${UART01}
665 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_GSD8} Data=@{MessageData}
666 ${Result} SendMessage &{Message}
667
668 Comments:
669
670 UART01 => It indicates the UART 01
671 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
672 Function_UART => It is the function in the message frame
673 UART_Commands_GSD8 => It is the command of the function in the message frame
674 @endverbatim
675 *
676 * @return FH_ErrorInfo is returned
677 *
678
679*/
680FH_ErrorInfo FH_UART_ProcessCommand_GSD8(FH_RFCommunication_Message* fh_RFCommunication_Message, uint8_t* FH_UART_DataLength, uint8_t* FH_UART_FH_UART_Data)
681{
682 FH_ErrorInfo fh_ErrorInfo; // Error Information
683 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
684
685 // 1 - Verifying the health of the received message\n
686 fh_ErrorInfo = FH_UART_GSD8_H(fh_RFCommunication_Message);
687 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
688 {
689 return fh_ErrorInfo; // Return the error
690 }
691
692 // 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer
693 FH_UART_GSD8_FuncPtrModel FH_UART_GSD8_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_GSD8_FuncPtrModel
694 FH_UART_GSD8_S(FH_UART_GSD8_FuncPtr); // Setting the address of the functions
695
696 // 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
697 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
698 fh_ErrorInfo = FH_UART_GSD8_C(fh_RFCommunication_Message, FH_UART_DataLength, FH_UART_FH_UART_Data, FH_UART_GSD8_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
699
700 return fh_ErrorInfo;
701}
702
703/**
704 * @brief This function handles <b>FH_UART_Commands_GSD16</b> command\n
705 * There are 3 main items handled in this function as following:\n
706 * 1 - Verifying the health of the received message\n
707 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
708 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
709 *
710 * @param fh_RFCommunication_Message
711 * The message frame set by <b>RobotFramework</b>
712 *
713 * @verbatim
714 ==============================================================================
715 ##### RobotFramework Example #####
716 ==============================================================================
717 @{MessageData} = Create List ${UART01}
718 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_GSD16} Data=@{MessageData}
719 ${Result} SendMessage &{Message}
720
721 Comments:
722
723 UART01 => It indicates the UART 01
724 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
725 Function_UART => It is the function in the message frame
726 UART_Commands_GSD16 => It is the command of the function in the message frame
727 @endverbatim
728 *
729 * @return FH_ErrorInfo is returned
730 *
731
732*/
733FH_ErrorInfo FH_UART_ProcessCommand_GSD16(FH_RFCommunication_Message* fh_RFCommunication_Message, uint8_t* FH_UART_DataLength, uint8_t* FH_UART_FH_UART_Data)
734{
735 FH_ErrorInfo fh_ErrorInfo; // Error Information
736 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
737
738 // 1 - Verifying the health of the received message
739 fh_ErrorInfo = FH_UART_GSD16_H(fh_RFCommunication_Message);
740 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
741 {
742 return fh_ErrorInfo; // Return the error
743 }
744
745 // 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer
746 FH_UART_GSD16_FuncPtrModel FH_UART_GSD16_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_GSD16_FuncPtrModel
747 FH_UART_GSD16_S(FH_UART_GSD16_FuncPtr); // Setting the address of the functions
748
749 // 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
750 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
751 fh_ErrorInfo = FH_UART_GSD16_C(fh_RFCommunication_Message, FH_UART_DataLength, FH_UART_FH_UART_Data, FH_UART_GSD16_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
752
753 return fh_ErrorInfo;
754}
755
756/**
757 * @brief This function handles <b>FH_UART_Commands_GSD32</b> command\n
758 * There are 3 main items handled in this function as following:\n
759 * 1 - Verifying the health of the received message\n
760 * 2 - Setting the addresses of the functions in <b>FH_Functions</b>, Section <b>FH_UART</b> to an array of function pointer\n
761 * 3 - Calling the related function in <b>FH_Functions</b>, Section <b>FH_UART</b> according to the first parameter of the Data in the message frame
762 *
763 * @param fh_RFCommunication_Message
764 * The message frame set by <b>RobotFramework</b>
765 *
766 * @verbatim
767 ==============================================================================
768 ##### RobotFramework Example #####
769 ==============================================================================
770 @{MessageData} = Create List ${UART01}
771 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_GSD32} Data=@{MessageData}
772 ${Result} SendMessage &{Message}
773
774 Comments:
775
776 UART01 => It indicates the UART 01
777 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
778 Function_UART => It is the function in the message frame
779 UART_Commands_GSD32 => It is the command of the function in the message frame
780 @endverbatim
781 *
782 * @return FH_ErrorInfo is returned
783 *
784
785*/
786FH_ErrorInfo FH_UART_ProcessCommand_GSD32(FH_RFCommunication_Message* fh_RFCommunication_Message, uint8_t* FH_UART_DataLength, uint8_t* FH_UART_FH_UART_Data)
787{
788 FH_ErrorInfo fh_ErrorInfo; // Error Information
789 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
790
791 fh_ErrorInfo = FH_UART_GSD32_H(fh_RFCommunication_Message);
792 if (fh_ErrorInfo.error_code != FH_ERROR_OK) // Check if the message is healthy or not
793 {
794 return fh_ErrorInfo; // Return the error
795 }
796
797 FH_UART_GSD32_FuncPtrModel FH_UART_GSD32_FuncPtr[FH_UART_MaxPeripheralNumber]; // An array of function pointer FH_UART_GSD32_FuncPtrModel
798 FH_UART_GSD32_S(FH_UART_GSD32_FuncPtr); // Setting the address of the functions
799
800 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
801 fh_ErrorInfo = FH_UART_GSD32_C(fh_RFCommunication_Message, FH_UART_DataLength, FH_UART_FH_UART_Data, FH_UART_GSD32_FuncPtr); // Calling the related function according to the first parameter of the Data in the message frame
802
803 return fh_ErrorInfo;
804}
805
806#endif