Initial commit
mbed-dev-master/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_MODULE_UBLOX_ODIN_W2/sdk/ublox-odin-w2-drivers/cb_comdefs.h@0:bb348c97df44, 2020-09-16 (annotated)
- Committer:
- lypinator
- Date:
- Wed Sep 16 01:11:49 2020 +0000
- Revision:
- 0:bb348c97df44
Added PWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lypinator | 0:bb348c97df44 | 1 | /*--------------------------------------------------------------------------- |
lypinator | 0:bb348c97df44 | 2 | * Copyright (c) 2016, u-blox Malmö, All Rights Reserved |
lypinator | 0:bb348c97df44 | 3 | * SPDX-License-Identifier: LicenseRef-PBL |
lypinator | 0:bb348c97df44 | 4 | * |
lypinator | 0:bb348c97df44 | 5 | * This file and the related binary are licensed under the |
lypinator | 0:bb348c97df44 | 6 | * Permissive Binary License, Version 1.0 (the "License"); |
lypinator | 0:bb348c97df44 | 7 | * you may not use these files except in compliance with the License. |
lypinator | 0:bb348c97df44 | 8 | * |
lypinator | 0:bb348c97df44 | 9 | * You may obtain a copy of the License here: |
lypinator | 0:bb348c97df44 | 10 | * LICENSE-permissive-binary-license-1.0.txt and at |
lypinator | 0:bb348c97df44 | 11 | * https://www.mbed.com/licenses/PBL-1.0 |
lypinator | 0:bb348c97df44 | 12 | * |
lypinator | 0:bb348c97df44 | 13 | * See the License for the specific language governing permissions and |
lypinator | 0:bb348c97df44 | 14 | * limitations under the License. |
lypinator | 0:bb348c97df44 | 15 | * |
lypinator | 0:bb348c97df44 | 16 | * Component : Common Definitions |
lypinator | 0:bb348c97df44 | 17 | * File : cb_comdefs.h |
lypinator | 0:bb348c97df44 | 18 | * |
lypinator | 0:bb348c97df44 | 19 | * Description : Common definitions. |
lypinator | 0:bb348c97df44 | 20 | *-------------------------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 21 | |
lypinator | 0:bb348c97df44 | 22 | #ifndef _CB_COMDEFS_H_ |
lypinator | 0:bb348c97df44 | 23 | #define _CB_COMDEFS_H_ |
lypinator | 0:bb348c97df44 | 24 | |
lypinator | 0:bb348c97df44 | 25 | #include "cb_platform_basic_types.h" |
lypinator | 0:bb348c97df44 | 26 | |
lypinator | 0:bb348c97df44 | 27 | /*=========================================================================== |
lypinator | 0:bb348c97df44 | 28 | * DEFINES |
lypinator | 0:bb348c97df44 | 29 | *=========================================================================*/ |
lypinator | 0:bb348c97df44 | 30 | |
lypinator | 0:bb348c97df44 | 31 | #ifndef FALSE |
lypinator | 0:bb348c97df44 | 32 | # define FALSE (0) |
lypinator | 0:bb348c97df44 | 33 | #endif |
lypinator | 0:bb348c97df44 | 34 | |
lypinator | 0:bb348c97df44 | 35 | #ifndef TRUE |
lypinator | 0:bb348c97df44 | 36 | # define TRUE (!FALSE) |
lypinator | 0:bb348c97df44 | 37 | #endif |
lypinator | 0:bb348c97df44 | 38 | |
lypinator | 0:bb348c97df44 | 39 | #ifndef NULL |
lypinator | 0:bb348c97df44 | 40 | # define NULL ((void*)0) |
lypinator | 0:bb348c97df44 | 41 | #endif |
lypinator | 0:bb348c97df44 | 42 | |
lypinator | 0:bb348c97df44 | 43 | /** |
lypinator | 0:bb348c97df44 | 44 | * Returns the maximum value of the two parameters. |
lypinator | 0:bb348c97df44 | 45 | */ |
lypinator | 0:bb348c97df44 | 46 | #define cb_MAX(a,b) (((a) > (b)) ? (a) : (b)) |
lypinator | 0:bb348c97df44 | 47 | |
lypinator | 0:bb348c97df44 | 48 | /** |
lypinator | 0:bb348c97df44 | 49 | * Returns the minimum value of the two parameters. |
lypinator | 0:bb348c97df44 | 50 | */ |
lypinator | 0:bb348c97df44 | 51 | #define cb_MIN(a,b) (((a) < (b)) ? (a) : (b)) |
lypinator | 0:bb348c97df44 | 52 | |
lypinator | 0:bb348c97df44 | 53 | /** |
lypinator | 0:bb348c97df44 | 54 | * Used in function definitions to declare an input parameter unused to avoid warnings. |
lypinator | 0:bb348c97df44 | 55 | */ |
lypinator | 0:bb348c97df44 | 56 | #ifndef cb_UNUSED |
lypinator | 0:bb348c97df44 | 57 | # define cb_UNUSED(x) x |
lypinator | 0:bb348c97df44 | 58 | #endif |
lypinator | 0:bb348c97df44 | 59 | |
lypinator | 0:bb348c97df44 | 60 | |
lypinator | 0:bb348c97df44 | 61 | #ifndef cb_ASSERT |
lypinator | 0:bb348c97df44 | 62 | # error "No platform definition for ASSERT!" |
lypinator | 0:bb348c97df44 | 63 | #endif |
lypinator | 0:bb348c97df44 | 64 | |
lypinator | 0:bb348c97df44 | 65 | /** |
lypinator | 0:bb348c97df44 | 66 | * Used when declaring an empty array that does not take up space in a struct. |
lypinator | 0:bb348c97df44 | 67 | * Example: struct { cb_uint8 payload[cb_EMPTY_ARRAY]; } |
lypinator | 0:bb348c97df44 | 68 | * In some compilers this is empty i.e. payload[]. While in some it requires a zero. |
lypinator | 0:bb348c97df44 | 69 | * I.e. payload[0]; |
lypinator | 0:bb348c97df44 | 70 | * Use this define to get it working for your system. |
lypinator | 0:bb348c97df44 | 71 | */ |
lypinator | 0:bb348c97df44 | 72 | #ifndef cb_EMPTY_ARRAY |
lypinator | 0:bb348c97df44 | 73 | # define cb_EMPTY_ARRAY (0) |
lypinator | 0:bb348c97df44 | 74 | #endif |
lypinator | 0:bb348c97df44 | 75 | |
lypinator | 0:bb348c97df44 | 76 | |
lypinator | 0:bb348c97df44 | 77 | #define cb_BIT_0 (1ul) |
lypinator | 0:bb348c97df44 | 78 | #define cb_BIT_1 (1ul << 1) |
lypinator | 0:bb348c97df44 | 79 | #define cb_BIT_2 (1ul << 2) |
lypinator | 0:bb348c97df44 | 80 | #define cb_BIT_3 (1ul << 3) |
lypinator | 0:bb348c97df44 | 81 | #define cb_BIT_4 (1ul << 4) |
lypinator | 0:bb348c97df44 | 82 | #define cb_BIT_5 (1ul << 5) |
lypinator | 0:bb348c97df44 | 83 | #define cb_BIT_6 (1ul << 6) |
lypinator | 0:bb348c97df44 | 84 | #define cb_BIT_7 (1ul << 7) |
lypinator | 0:bb348c97df44 | 85 | #define cb_BIT_8 (1ul << 8) |
lypinator | 0:bb348c97df44 | 86 | #define cb_BIT_9 (1ul << 9) |
lypinator | 0:bb348c97df44 | 87 | #define cb_BIT_10 (1ul << 10) |
lypinator | 0:bb348c97df44 | 88 | #define cb_BIT_11 (1ul << 11) |
lypinator | 0:bb348c97df44 | 89 | #define cb_BIT_12 (1ul << 12) |
lypinator | 0:bb348c97df44 | 90 | #define cb_BIT_13 (1ul << 13) |
lypinator | 0:bb348c97df44 | 91 | #define cb_BIT_14 (1ul << 14) |
lypinator | 0:bb348c97df44 | 92 | #define cb_BIT_15 (1ul << 15) |
lypinator | 0:bb348c97df44 | 93 | #define cb_BIT_16 (1ul << 16) |
lypinator | 0:bb348c97df44 | 94 | #define cb_BIT_17 (1ul << 17) |
lypinator | 0:bb348c97df44 | 95 | #define cb_BIT_18 (1ul << 18) |
lypinator | 0:bb348c97df44 | 96 | #define cb_BIT_19 (1ul << 19) |
lypinator | 0:bb348c97df44 | 97 | #define cb_BIT_20 (1ul << 20) |
lypinator | 0:bb348c97df44 | 98 | #define cb_BIT_21 (1ul << 21) |
lypinator | 0:bb348c97df44 | 99 | #define cb_BIT_22 (1ul << 22) |
lypinator | 0:bb348c97df44 | 100 | #define cb_BIT_23 (1ul << 23) |
lypinator | 0:bb348c97df44 | 101 | #define cb_BIT_24 (1ul << 24) |
lypinator | 0:bb348c97df44 | 102 | #define cb_BIT_25 (1ul << 25) |
lypinator | 0:bb348c97df44 | 103 | #define cb_BIT_26 (1ul << 26) |
lypinator | 0:bb348c97df44 | 104 | #define cb_BIT_27 (1ul << 27) |
lypinator | 0:bb348c97df44 | 105 | #define cb_BIT_28 (1ul << 28) |
lypinator | 0:bb348c97df44 | 106 | #define cb_BIT_29 (1ul << 29) |
lypinator | 0:bb348c97df44 | 107 | #define cb_BIT_30 (1ul << 30) |
lypinator | 0:bb348c97df44 | 108 | #define cb_BIT_31 (1ul << 31) |
lypinator | 0:bb348c97df44 | 109 | |
lypinator | 0:bb348c97df44 | 110 | /** |
lypinator | 0:bb348c97df44 | 111 | * Clears (set to zero) a bit or bits in a variable. |
lypinator | 0:bb348c97df44 | 112 | * @param variable The variable. |
lypinator | 0:bb348c97df44 | 113 | * @param bit The bit or bits to clear |
lypinator | 0:bb348c97df44 | 114 | */ |
lypinator | 0:bb348c97df44 | 115 | #define cb_CLEAR_BIT(variable,bit) ((variable) &= ~((bit))) |
lypinator | 0:bb348c97df44 | 116 | |
lypinator | 0:bb348c97df44 | 117 | /** |
lypinator | 0:bb348c97df44 | 118 | * Gets a bit i.e. checks if it is set in a variable. |
lypinator | 0:bb348c97df44 | 119 | * |
lypinator | 0:bb348c97df44 | 120 | * Also works to see if any of several bits are set. |
lypinator | 0:bb348c97df44 | 121 | * |
lypinator | 0:bb348c97df44 | 122 | * @param variable The variable. |
lypinator | 0:bb348c97df44 | 123 | * @param bit The bit to check if it set. |
lypinator | 0:bb348c97df44 | 124 | * @return @ref TRUE if any of the bits are set, @ref FALSE otherwise. |
lypinator | 0:bb348c97df44 | 125 | */ |
lypinator | 0:bb348c97df44 | 126 | #define cb_GET_BIT(variable,bit) (((variable) & ((bit))) ? TRUE : FALSE) |
lypinator | 0:bb348c97df44 | 127 | |
lypinator | 0:bb348c97df44 | 128 | /** |
lypinator | 0:bb348c97df44 | 129 | * Calculate the number of elements in an array. |
lypinator | 0:bb348c97df44 | 130 | * |
lypinator | 0:bb348c97df44 | 131 | * @note Won't work on pointer to array as the sizeof(pointer) is 4. |
lypinator | 0:bb348c97df44 | 132 | * |
lypinator | 0:bb348c97df44 | 133 | * @param _array The array. |
lypinator | 0:bb348c97df44 | 134 | * @return Number of elements in array. |
lypinator | 0:bb348c97df44 | 135 | */ |
lypinator | 0:bb348c97df44 | 136 | #define ELEMENTS_OF(_array) (sizeof((_array)) / sizeof((_array)[0])) |
lypinator | 0:bb348c97df44 | 137 | |
lypinator | 0:bb348c97df44 | 138 | /** |
lypinator | 0:bb348c97df44 | 139 | * Sets (set to 1) a bit or bits in a variable. |
lypinator | 0:bb348c97df44 | 140 | * |
lypinator | 0:bb348c97df44 | 141 | * @param variable The variable. |
lypinator | 0:bb348c97df44 | 142 | * @param bit The bit or bits to set in the variable. |
lypinator | 0:bb348c97df44 | 143 | */ |
lypinator | 0:bb348c97df44 | 144 | #define cb_SET_BIT(variable,bit) ((variable) |= (bit)) |
lypinator | 0:bb348c97df44 | 145 | |
lypinator | 0:bb348c97df44 | 146 | #define cb_UINT8_MAX ((cb_uint8)0xff) |
lypinator | 0:bb348c97df44 | 147 | #define cb_UINT16_MAX ((cb_uint16)0xffff) |
lypinator | 0:bb348c97df44 | 148 | #define cb_UINT32_MAX ((cb_uint32)0xffffffff) |
lypinator | 0:bb348c97df44 | 149 | #define cb_INT8_MAX ((cb_int8)0x7f) |
lypinator | 0:bb348c97df44 | 150 | #define cb_INT16_MAX ((cb_int16)0x7fff) |
lypinator | 0:bb348c97df44 | 151 | #define cb_INT32_MAX ((cb_int32)0x7fffffff) |
lypinator | 0:bb348c97df44 | 152 | #define cb_INT8_MIN ((cb_int8)0x80) |
lypinator | 0:bb348c97df44 | 153 | #define cb_INT16_MIN ((cb_int16)0x8000) |
lypinator | 0:bb348c97df44 | 154 | #define cb_INT32_MIN ((cb_int32)0x80000000) |
lypinator | 0:bb348c97df44 | 155 | |
lypinator | 0:bb348c97df44 | 156 | /* Packed struct default defines */ |
lypinator | 0:bb348c97df44 | 157 | #ifndef cb_PACKED_STRUCT_ATTR_INLINE_POST |
lypinator | 0:bb348c97df44 | 158 | # define cb_PACKED_STRUCT_ATTR_INLINE_POST |
lypinator | 0:bb348c97df44 | 159 | #endif |
lypinator | 0:bb348c97df44 | 160 | #ifndef cb_PACKED_STRUCT_ATTR_INLINE_PRE |
lypinator | 0:bb348c97df44 | 161 | # define cb_PACKED_STRUCT_ATTR_INLINE_PRE |
lypinator | 0:bb348c97df44 | 162 | #endif |
lypinator | 0:bb348c97df44 | 163 | #ifndef cb_PACKED_STRUCT_ATTR_PRE |
lypinator | 0:bb348c97df44 | 164 | # define cb_PACKED_STRUCT_ATTR_PRE |
lypinator | 0:bb348c97df44 | 165 | #endif |
lypinator | 0:bb348c97df44 | 166 | #ifndef cb_PACKED_STRUCT_ATTR_POST |
lypinator | 0:bb348c97df44 | 167 | # define cb_PACKED_STRUCT_ATTR_POST |
lypinator | 0:bb348c97df44 | 168 | #endif |
lypinator | 0:bb348c97df44 | 169 | |
lypinator | 0:bb348c97df44 | 170 | #define cb_PACKED_STRUCT_BEGIN(name) \ |
lypinator | 0:bb348c97df44 | 171 | cb_PACKED_STRUCT_ATTR_PRE \ |
lypinator | 0:bb348c97df44 | 172 | typedef cb_PACKED_STRUCT_ATTR_INLINE_PRE struct name##_t |
lypinator | 0:bb348c97df44 | 173 | |
lypinator | 0:bb348c97df44 | 174 | #define cb_PACKED_STRUCT_END(name) \ |
lypinator | 0:bb348c97df44 | 175 | cb_PACKED_STRUCT_ATTR_INLINE_POST name; \ |
lypinator | 0:bb348c97df44 | 176 | cb_PACKED_STRUCT_ATTR_POST |
lypinator | 0:bb348c97df44 | 177 | |
lypinator | 0:bb348c97df44 | 178 | #ifdef __GNUC__ |
lypinator | 0:bb348c97df44 | 179 | # define DO_PRAGMA(x) _Pragma (#x) |
lypinator | 0:bb348c97df44 | 180 | # define TODO(x) DO_PRAGMA(message ("TODO - " #x)) |
lypinator | 0:bb348c97df44 | 181 | #else |
lypinator | 0:bb348c97df44 | 182 | # define TODO(x) |
lypinator | 0:bb348c97df44 | 183 | #endif |
lypinator | 0:bb348c97df44 | 184 | |
lypinator | 0:bb348c97df44 | 185 | /*=========================================================================== |
lypinator | 0:bb348c97df44 | 186 | * TYPES |
lypinator | 0:bb348c97df44 | 187 | *=========================================================================*/ |
lypinator | 0:bb348c97df44 | 188 | |
lypinator | 0:bb348c97df44 | 189 | #endif /* _cb_COMDEFS_H_ */ |
lypinator | 0:bb348c97df44 | 190 |