OS  v7.3.3
Documentation
Loading...
Searching...
No Matches
qflm.h
1
8#ifndef QFLM_H
9 #define QFLM_H
10
11 #include "qtypes.h"
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
28 #define qFLM_BitsSet( dst, xBits ) (dst) |= (xBits)
29
36 #define qFLM_BitsClear( dst, xBits ) (dst) &= ~(xBits)
37
45 #define qFLM_BitSet( dst, xBit, xType ) \
46 (dst) |= (xType)( (xType)1U << (xBit) ) \
47
55 #define qFLM_BitClear( dst, xBit, xType ) \
56 (dst) &= (xType)( ~( (xType)1U << (xBit) ) ) \
57
65 #define qFLM_BitRead( dst, xBit ) \
66 ( ( qFalse == ( (dst) & ( 1 << (xBit) ) ) ) ? qFalse : qTrue ) \
67
75 #define qFLM_BitToggle( dst, xBit ) ( (dst) ^= ( 1 << (xBit) ) )
76
84 #define qFLM_BitWrite( dst, xBit, xVal ) \
85 ( (xVal) ? qFLM_BitSet( (dst), (xBit) ) \
86 : qFLM_BitClear( (dst),(xBit) ) ) \
87
93 #define qFLM_BitMakeByte( b7, b6, b5, b4, b3, b2, b1, b0 ) \
94 (qUINT8_t)( \
95 ( (b7) << 7 ) + \
96 ( (b6) << 6 ) + \
97 ( (b5) << 5 ) + \
98 ( (b4) << 4 ) + \
99 ( (b3) << 3 ) + \
100 ( (b2) << 2 ) + \
101 ( (b1) << 1 ) + \
102 ( (b0) << 0 ) \
103 ) \
104
110 #define qFLM_ByteHighNibble( dst ) ( (qUINT8_t)( (dst) >> 4 ) )
111
117 #define qFLM_ByteLowNibble( dst ) ( (qUINT8_t)( (dst) & 0x0F ) )
118
125 #define qFLM_ByteMergeNibbles( H, L ) \
126 ( (qUINT8_t)( ( (H) << 4 ) | ( 0x0F & (L) ) ) ) \
127
133 #define qFLM_WordHighByte( dst ) ( (qUINT8_t)( (dst) >> 8 ) )
134
140 #define qFLM_WordLowByte( dst ) ( (qUINT8_t)( (dst) & 0x00FF ) )
141
148 #define qFLM_WordMergeBytes( H, L ) \
149 ( (qUINT16_t) ( ( (H) << 8 ) | (L) ) ) \
150
156 #define qFLM_DWordHighWord( dst ) ( (qUINT16_t)( (dst) >> 16 ) )
157
163 #define qFLM_DWordLowWord( dst ) ( (qUINT16_t)( (dst) & 0xFFFF ) )
164
171 #define qFLM_DWordMergeWords( H, L ) \
172 ( (qUINT32_t)( ( (qUINT32_t)(H) << 16 ) | (L) ) ) \
173
182 #define qFLM_Clip( X, Min, Max ) \
183 ( ( (X) < (Min) ) ? (Min) : ( ( (X) > (Max) ) ? (Max) : (X) ) ) \
184
191 #define qFLM_ClipUpper( X, Max ) ( ( (X) > (Max) ) ? (Max) : (X) )
192
199 #define qFLM_ClipLower( X, Min ) ( ( (X) < (Min) ) ? (Min) : (X) )
200
210 #define qFLM_IsBetween( X, Low, High ) \
211 ( ( (X) >= (Low) ) && ( (X) <= (High) ) ) \
212
219 #define qFLM_Min( a, b ) ( ( (a) < (b) ) ? (a) : (b) )
220
227 #define qFLM_Max( a, b ) ( ( (a) > (b) ) ? (a) : (b) )
228
234 #define qFLM_ArraySize( x ) ( sizeof((x))/sizeof((x)[ 0 ]) )
235
238 #ifdef __cplusplus
239 }
240 #endif
241
242#endif