FreeHIL
Loading...
Searching...
No Matches
FH_UART_GSD16_C.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>, <b>Cmd</b> (Command), <b>GSD16</b>, <b>GSD16_C</b> (Get Shared Data 16 Call)\n
6 * Functions in this file, Call 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
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
33/* Includes ------------------------------------------------------------------*/
34#include "../../../../../../../FH_Embedded/FH_Root/FH_Perif/FH_UART/Cmd/GSD16/GSD16_C/FH_UART_GSD16_C.h"
35
36#include "../../../../../../../FH_Embedded/FH_Root/FH_General/FH_GeneralFunctions/FH_GeneralFunctions.h"
38
39#if FH_UART_MaxPeripheralNumber > 0 // It is configurable in FH_DevicePeripherals.h
40
41/**
42 * @brief This function calls 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
43 *
44 * @param fh_RFCommunication_Message
45 * The message frame set by <b>RobotFramework</b>
46 * @param SharedDataLength
47 * *SharedDataLength will be set with the length of the related SharedDataBuf
48 * @param SharedData
49 * *SharedData will be set with the related SharedDataBuf
50 * @param fH_UART_GSD16_FuncPtr
51 * The array of function pointers
52 *
53 * @verbatim
54 ==============================================================================
55 ##### RobotFramework Example #####
56 ==============================================================================
57 @{MessageData} = Create List ${UART01}
58 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_UART} Command=${UART_Commands_GSD16} Data=@{MessageData}
59 ${Result} SendMessage &{Message}
60
61 Comments:
62
63 UART01 => It indicates the UART 01
64 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
65 Function_UART => It is the function in the message frame
66 UART_Commands_GSD16 => It is the command of the function in the message frame
67 @endverbatim
68 *
69 * @return FH_ErrorInfo is returned
70 *
71
72*/
73FH_ErrorInfo FH_UART_GSD16_C (FH_RFCommunication_Message* fh_RFCommunication_Message, uint8_t* SharedDataLength, uint8_t* SharedData, FH_UART_GSD16_FuncPtrModel *fH_UART_GSD16_FuncPtr)
74{
75 FH_ErrorInfo fh_ErrorInfo; // Error Information
76 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
77
78 for (uint8_t i = 1; i <= FH_UART_MaxPeripheralNumber; i++) // Iteration through all defined peripherals
79 {
80 if (i == fh_RFCommunication_Message -> Data[UART_GSD16_PeripheralNumber]) // If the PeripheralNumber in the message frame is met
81 {
82 if (fH_UART_GSD16_FuncPtr[i-1] != NULL_PTR) // If the address of the function is truly assigned
83 {
84 fh_ErrorInfo = fH_UART_GSD16_FuncPtr[i-1](fh_RFCommunication_Message, SharedDataLength, SharedData); // Call the related function
85 }
86 else
87 {
88 fh_ErrorInfo.error_code = FH_ERROR_Root; // There is Root error
89 }
90 return fh_ErrorInfo;
91 }
92 }
93 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
94 return fh_ErrorInfo;
95}
96
97#endif