-
Notifications
You must be signed in to change notification settings - Fork 0
/
arm_inlines_temperature.h
86 lines (68 loc) · 1.93 KB
/
arm_inlines_temperature.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*!\file arm_inlines_temperature.h
** \author SMFSW
** \copyright MIT (c) 2017-2024, SMFSW
** \brief Temperature conversion inlines
*/
/****************************************************************/
#ifndef ARM_INLINES_TEMPERATURE_H_
#define ARM_INLINES_TEMPERATURE_H_
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************/
#define M_5_9 (5.0 / 9.0) //!< 5/9 constant approximation
#define M_9_5 (9.0 / 5.0) //!< 9/5 constant approximation
/*!\brief Convert degrees Celsius to Kelvin
** \param[in] cel - Celsius degrees value
** \return Kelvin degrees
**/
__INLINE float celsius2kelvin(const float cel)
{
return (cel + 273.15f);
}
/*!\brief Convert degrees Kelvin to Celsius
** \param[in] kel - Kelvin degrees value
** \return Kelvin degrees
**/
__INLINE float kelvin2celsius(const float kel)
{
return (kel - 273.15f);
}
/*!\brief Convert degrees Celsius to Fahrenheit
** \param[in] cel - Celsius degrees value
** \return Fahrenheit degrees
**/
__INLINE float celsius2fahrenheit(const float cel)
{
return (cel * M_9_5) + 32.0f;
}
/*!\brief Convert degrees Fahrenheit to Celsius
** \param[in] fah - Fahrenheit degrees value
** \return Celsius degrees
**/
__INLINE float fahrenheit2celsius(const float fah)
{
return ((fah - 32.0f) * M_5_9);
}
/*!\brief Convert degrees Fahrenheit to Kelvin
** \param[in] fah - Fahrenheit degrees value
** \return Kelvin degrees
**/
__INLINE float fahrenheit2kelvin(const float fah)
{
return (celsius2kelvin(fahrenheit2celsius(fah)));
}
/*!\brief Convert degrees Kelvin to Fahrenheit
** \param[in] kel - Kelvin degrees value
** \return Fahrenheit degrees
**/
__INLINE float kelvin2fahrenheit(const float kel)
{
return (celsius2fahrenheit(kelvin2celsius(kel)));
}
/****************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* ARM_INLINES_TEMPERATURE_H_ */
/****************************************************************/