FreeHIL
Loading...
Searching...
No Matches
FH_GeneralFunctions.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_General</b>, <b>FH_GeneralFunctions</b> \n
6 * All different possible general functions utilized in different parts of the code, go here\n
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/* Includes ------------------------------------------------------------------*/
34
35/**
36 * @brief This function converts two 8 bits data (uint8_t) to one 16 bits data (uint16_t)
37 *
38 * @param fh_Uint8
39 * Pointer to the two 8 bits data (uint8_t)
40 *
41 * @return The one 16 bits data (uint16_t)
42 *
43 * @note
44 * For this to happen, FH_Uint8Uint16 enumeration defined in <b>FH_GeneralFunctions.h</b> is utilized \n
45 *
46
47*/
48uint16_t FH_ConvertUint8ToUint16(uint8_t* fh_Uint8)
49{
50 FH_Uint8Uint16 fh_Uint8Uint16; // FH_Uint8Uint16 enumeration
51 fh_Uint8Uint16.bytes[1] = fh_Uint8[0];
52 fh_Uint8Uint16.bytes[0] = fh_Uint8[1];
53 return fh_Uint8Uint16.value;
54}
55
56/**
57 * @brief This function converts four 8 bits data (uint8_t) to one 32 bits data (uint32_t)
58 *
59 * @param fh_Uint8
60 * Pointer to the four 8 bits data (uint8_t)
61 *
62 * @return The one 32 bits data (uint32_t)
63 *
64 * @note
65 * For this to happen, FH_Uint8Uint32 enumeration defined in <b>FH_GeneralFunctions.h</b> is utilized \n
66 *
67
68*/
69uint32_t FH_ConvertUint8ToUint32(uint8_t* fh_Uint8)
70{
71 FH_Uint8Uint32 fh_Uint8Uint32; // FH_Uint8Uint32 enumeration
72 fh_Uint8Uint32.bytes[3] = fh_Uint8[0];
73 fh_Uint8Uint32.bytes[2] = fh_Uint8[1];
74 fh_Uint8Uint32.bytes[1] = fh_Uint8[2];
75 fh_Uint8Uint32.bytes[0] = fh_Uint8[3];
76 return fh_Uint8Uint32.value;
77}