FreeHIL
Loading...
Searching...
No Matches
FH_AI45.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_AI</b> (Analog Input), Peripheral <b>FH_AI45</b> (Analog Input 45)\n
6 * (The <b>AI45 (Analog Input 45)</b> could be any interested Analog Input 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 read functions of the <b>Analog Input 45</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 Input 45</b>\n
12 * The declaration of the read function of the <b>Analog Input 45</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_AI45 // It is configurable in FH_AI_Configs.h
46
47#if FH_AI_MaxPeripheralNumber > 0 // It is configurable in FH_DevicePeripherals.h
48
49/* Secondary Includes ------------------------------------------------------------------*/
53
54/**
55 * @brief This function initializes the <b>Analog Input 45</b>\n
56 * The <b>Analog Input 45</b> could be any interested Analog Input 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 Input 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 ${AI45}
71 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_AI} Command=${AI_Commands_Init} Data=@{MessageData}
72 ${Result} SendMessage &{Message}
73
74 Comments:
75
76 AI45 => It indicates the Analog Input 45
77 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
78 Function_AI => It is the function in the message frame
79 AI_Commands_Init => It is the command of the function in the message frame
80 @endverbatim
81 *
82 *
83 * @warning
84 * To be able to read the <b>Analog Input 45</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_AI_GetStatus_AI45</b> function from <b>RobotFramework</b>, this function shall be invoked in order to initialize the Analog Input
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 Input 45 here)
95
96 // YourInitializationFunctionName ();
97
98 //
99
100 return fh_ErrorInfo;
101}
102
103/**
104 * @brief This function reads the <b>Analog Input 45</b>\n
105 * The <b>Analog Input 45</b> could be any interested Analog Input of the micro-controller on which <b>FH</b> source code is ported\n
106 * <b>FH</b> user should call the read function of the interested Analog Input here
107 *
108 * @param Data
109 * *Data will be set with the value of <b>Analog Input 45</b>\n
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 ${AI45}
122 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_AI} Command=${AI_Commands_GetStatus} Data=@{MessageData}
123 ${Result} SendMessage &{Message}
124
125 Comments:
126
127 AI45 => It indicates the Analog Input 45
128 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
129 Function_AI => It is the function in the message frame
130 AI_Commands_GetStatus => It is the command of the function in the message frame
131 @endverbatim
132 *
133 *
134 * @warning
135 * To be able to read the <b>Analog Input 45</b> of the micro-controller on which <b>FH</b> source code is ported, the <b>FH_AI_Init_AI45</b> function shall be invoked once by <b>RobotFramework</b> firstly\n
136 * In other words, before invoking <b>FH_AI_GetStatus_AI45</b> function from <b>RobotFramework</b>, <b>FH_AI_Init_AI45</b> function shall be invoked in order to initialize the Analog Input
137 *
138
139*/
141{
142 FH_ErrorInfo fh_ErrorInfo; // Error Information
143 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
144 uint32_t readData = 0; // Read data of the Analog Input 45
145
146 // Attention 3: FH user defined code (call the read function the Analog Input 45 here)
147
148 // readData = YourReadFunctionName();
149
150 //
151
152 *Data = readData;
153
154 return fh_ErrorInfo;
155}
156
157#endif
158
159#endif