FreeHIL
Loading...
Searching...
No Matches
FH_PWMO05.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_PWMO</b> (PWM Output), Peripheral <b>FH_PWMO05</b> (PWM Output 05)\n
6 * (The <b>PWMO05 (PWM Output 05)</b> could be any interested PWM 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>PWM Output 05</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>PWM Output 05</b>\n
12 * The declaration of the set function of the <b>PWM Output 05</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_PWMO05 // It is configurable in FH_PWMO_Configs.h
46
47#if FH_PWMO_MaxPeripheralNumber > 0 // It is configurable in FH_DevicePeripherals.h
48
49/* Secondary Includes ------------------------------------------------------------------*/
53
54/**
55 * @brief This function initializes the <b>PWM Output 05</b>\n
56 * The <b>PWM Output 05</b> could be any interested PWM 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 PWM 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 ${PWMO05}
71 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_PWMO} Command=${PWMO_Commands_Init} Data=@{MessageData}
72 ${Result} SendMessage &{Message}
73
74 Comments:
75
76 PWMO05 => It indicates the PWM Output 05
77 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
78 Function_PWMO => It is the function in the message frame
79 PWMO_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>PWM Output 05</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_PWMO_SetStatus_PWMO05</b> function from <b>RobotFramework</b>, this function shall be invoked in order to initialize the PWM 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 PWM Output 05 here)
95
96 // YourInitializationFunctionName ();
97
98 //
99
100 return fh_ErrorInfo;
101}
102
103/**
104 * @brief This function sets the <b>PWM Output 05</b>\n
105 * The <b>PWM Output 05</b> could be any interested PWM 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 PWM 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 ${PWMO05} 00 00 00 F0 32
122 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_PWMO} Command=${PWMO_Commands_SetStatus} Data=@{MessageData}
123 ${Result} SendMessage &{Message}
124
125 Comments:
126
127 PWMO05 => It indicates the PWM Output 05
128 00 00 00 F0 => Example data as PWM frequency (0x000000F0) to be set through the <b>PWM Output 05</b>\n
129 32 => Example data as PWM duty cycle (0x32 => as 50% duty cycle) to be set through the <b>PWM Output 05</b>\n
130 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
131 Function_PWMO => It is the function in the message frame
132 PWMO_Commands_SetStatus => It is the command of the function in the message frame
133 @endverbatim
134 *
135 *
136 * @warning
137 * To be able to set the <b>PWM Output 05</b> of the micro-controller on which <b>FH</b> source code is ported, the <b>FH_PWMO_Init_PWMO05</b> function shall be invoked once by <b>RobotFramework</b> firstly\n
138 * In other words, before invoking <b>FH_PWMO_SetStatus_PWMO05</b> function from <b>RobotFramework</b>, <b>FH_PWMO_Init_PWMO05</b> function shall be invoked in order to initialize the PWM Output
139 *
140
141*/
143{
144 FH_ErrorInfo fh_ErrorInfo; // Error Information
145 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
146
147 // Attention 3: FH user defined code (call the set function of the PWM Output 05 here with fh_RFCommunication_Message -> Data[...] as argument)
148 // Hint: The prototype of the set function should be something like YourSetFunctionName(uint32_t Frequency, uint8_t DutyCycle);
149
150 //YourSetFunctionName (FH_ConvertUint8ToUint32(&fh_RFCommunication_Message -> Data[PWMO_SetStatus_FrequencyByte4]), // One 4 bytes PWM data out of four 1 byte data is sent as frequency argument
151 // fh_RFCommunication_Message -> Data[PWMO_SetStatus_DutyCycle]); // One byte as duty cycle argument
152
153 //
154
155 return fh_ErrorInfo;
156}
157
158#endif
159
160#endif