FreeHIL
Loading...
Searching...
No Matches
FH_AO50.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_AO</b> (Analog Output), Peripheral <b>FH_AO50</b> (Analog Output 50)\n
6 * (The <b>AO50 (Analog Output 50)</b> could be any interested Analog Output 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 set function of the <b>Analog Output 50</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>Analog Output 50</b>\n
12 * The declaration of the set function of the <b>Analog Output 50</b>
13 *
14 * @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
15 * Other parts could be left intact
16 *
17 *******************************************************************************
18 * SPDX-License-Identifier: Apache-2.0
19 *
20 * Copyright 2026 Vahid Hasirchi
21 *
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
25 *
26 * http://www.apache.org/licenses/LICENSE-2.0
27 *
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
33 ********************************************************************************
34
35 *
36 * <b>For more information refer to FreeHIL.com</b>
37 *
38*/
39/* Primary Includes ------------------------------------------------------------------*/
40// Attention 1: FH user defined code (include the mentioned header file here)
41
42//
44
45#ifdef FH_AO50 // It is configurable in FH_AO_Configs.h
46
47#if FH_AO_MaxPeripheralNumber > 0 // It is configurable in FH_DevicePeripherals.h
48
49/* Secondary Includes ------------------------------------------------------------------*/
53
54/**
55 * @brief This function initializes the <b>Analog Output 50</b>\n
56 * The <b>Analog Output 50</b> could be any interested Analog Output of the micro-controller on which <b>FH</b> source code is ported\n
57 * <b>FH</b> user should call the initialization function of the interested Analog Output here
58 *
59 * @param None
60 * @return FH_ErrorInfo is returned
61 *
62 * @note
63 * To have a clean code, just include the related header file\n
64 * Then just call the function here
65 *
66 * @verbatim
67 ==============================================================================
68 ##### RobotFramework Example #####
69 ==============================================================================
70 @{MessageData} = Create List ${AO50}
71 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_AO} Command=${AO_Commands_Init} Data=@{MessageData}
72 ${Result} SendMessage &{Message}
73
74 Comments:
75
76 AO50 => It indicates the Analog Output 50
77 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
78 Function_AO => It is the function in the message frame
79 AO_Commands_Init => It is the command of the function in the message frame
80 @endverbatim
81 *
82 *
83 * @warning
84 * To be able to set or reset the <b>Analog Output 50</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
85 * In other words, before invoking <b>FH_AO_SetStatus_AO50</b> function from <b>RobotFramework</b>, this function shall be invoked in order to initialize the Analog Output
86 *
87
88*/
90{
91 FH_ErrorInfo fh_ErrorInfo; // Error Information
92 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
93
94 // Attention 2: FH user defined code (call the initialization function of the Analog Output 50 here)
95
96 // YourInitializationFunctionName ();
97
98 //
99
100 return fh_ErrorInfo;
101}
102
103/**
104 * @brief This function sets the <b>Analog Output 50</b>\n
105 * The <b>Analog Output 50</b> could be any interested Analog Output of the micro-controller on which <b>FH</b> source code is ported\n
106 * <b>FH</b> user should call the set function of the interested Analog Output here
107 *
108 * @param fh_RFCommunication_Message
109 * The message frame set by <b>RobotFramework</b>
110 *
111 * @return FH_ErrorInfo is returned
112 *
113 * @note
114 * To have a clean code, just include the related header file\n
115 * Then just call the function here
116 *
117 * @verbatim
118 ==============================================================================
119 ##### RobotFramework Example #####
120 ==============================================================================
121 @{MessageData} = Create List ${AO50} F1 C2 01 08
122 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_AO} Command=${AO_Commands_SetStatus} Data=@{MessageData}
123 ${Result} SendMessage &{Message}
124
125 Comments:
126
127 AO50 => It indicates the Analog Output 50
128 F1 C2 01 08 => Example data as analog value (0xF1C20108) to be set through the <b>Analog Output 50</b>\n
129 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
130 Function_AO => It is the function in the message frame
131 AO_Commands_SetStatus => It is the command of the function in the message frame
132 @endverbatim
133 *
134 *
135 * @warning
136 * To be able to set the <b>Analog Output 50</b> of the micro-controller on which <b>FH</b> source code is ported, the <b>FH_AO_Init_AO50</b> function shall be invoked once by <b>RobotFramework</b> firstly\n
137 * In other words, before invoking <b>FH_AO_SetStatus_AO50</b> function from <b>RobotFramework</b>, <b>FH_AO_Init_AO50</b> function shall be invoked in order to initialize the Analog Output
138 *
139
140*/
142{
143 FH_ErrorInfo fh_ErrorInfo; // Error Information
144 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
145
146 // Attention 3: FH user defined code (call the set function the Analog Output 50 here with fh_RFCommunication_Message -> Data[...] as argument)
147 // Hint: The prototype of the set function should be something like YourSetFunctionName(uint32_t Data);
148
149 // YourSetFunctionName (FH_ConvertUint8ToUint32(&fh_RFCommunication_Message -> Data[AO_SetStatus_StatusByte4])); // One 4 bytes analog data out of four 1 byte data is sent as argument
150
151 //
152
153 return fh_ErrorInfo;
154}
155
156#endif
157
158#endif