Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

UserRevisionLine numberNew 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 : RTSL
lypinator 0:bb348c97df44 17 * File : cb_types.h
lypinator 0:bb348c97df44 18 *
lypinator 0:bb348c97df44 19 * Description : Common type definitions
lypinator 0:bb348c97df44 20 *-------------------------------------------------------------------------*/
lypinator 0:bb348c97df44 21
lypinator 0:bb348c97df44 22 /**
lypinator 0:bb348c97df44 23 * @file cb_types.h Defines type required for the entire driver.
lypinator 0:bb348c97df44 24 * The defines in this file will have to be adapted for the platform.
lypinator 0:bb348c97df44 25 * @ingroup platform
lypinator 0:bb348c97df44 26 */
lypinator 0:bb348c97df44 27
lypinator 0:bb348c97df44 28 #ifndef _CB_TYPES_H_
lypinator 0:bb348c97df44 29 #define _CB_TYPES_H_
lypinator 0:bb348c97df44 30
lypinator 0:bb348c97df44 31 #include "cb_port_types.h"
lypinator 0:bb348c97df44 32
lypinator 0:bb348c97df44 33 /*===========================================================================
lypinator 0:bb348c97df44 34 * TYPES
lypinator 0:bb348c97df44 35 *=========================================================================*/
lypinator 0:bb348c97df44 36
lypinator 0:bb348c97df44 37 /*===========================================================================
lypinator 0:bb348c97df44 38 * COMMON SYSTEM DEFINES
lypinator 0:bb348c97df44 39 *=========================================================================*/
lypinator 0:bb348c97df44 40
lypinator 0:bb348c97df44 41 #ifndef FALSE
lypinator 0:bb348c97df44 42 # define FALSE (0)
lypinator 0:bb348c97df44 43 #endif
lypinator 0:bb348c97df44 44 #ifndef TRUE
lypinator 0:bb348c97df44 45 # define TRUE (!FALSE)
lypinator 0:bb348c97df44 46 #endif
lypinator 0:bb348c97df44 47
lypinator 0:bb348c97df44 48 #ifndef NULL
lypinator 0:bb348c97df44 49 # define NULL ((void *) 0)
lypinator 0:bb348c97df44 50 #endif
lypinator 0:bb348c97df44 51
lypinator 0:bb348c97df44 52 /**
lypinator 0:bb348c97df44 53 * Returns the maximum value of the two parameters.
lypinator 0:bb348c97df44 54 */
lypinator 0:bb348c97df44 55 #ifndef cb_MAX
lypinator 0:bb348c97df44 56 # define cb_MAX(x , y) (((x) > (y)) ? (x) : (y))
lypinator 0:bb348c97df44 57 #endif
lypinator 0:bb348c97df44 58 /**
lypinator 0:bb348c97df44 59 * Returns the minimum value of the two parameters.
lypinator 0:bb348c97df44 60 */
lypinator 0:bb348c97df44 61 #ifndef cb_MIN
lypinator 0:bb348c97df44 62 # define cb_MIN(x , y) (((x) < (y)) ? (x) : (y))
lypinator 0:bb348c97df44 63 #endif
lypinator 0:bb348c97df44 64
lypinator 0:bb348c97df44 65 #ifndef ELEMENTS_OF
lypinator 0:bb348c97df44 66 # define ELEMENTS_OF(_array) (sizeof((_array)) / sizeof((_array)[0]))
lypinator 0:bb348c97df44 67 #endif
lypinator 0:bb348c97df44 68
lypinator 0:bb348c97df44 69 #define cbWM_ARRAY_SIZE(a) ELEMENTS_OF(a)
lypinator 0:bb348c97df44 70
lypinator 0:bb348c97df44 71 /**
lypinator 0:bb348c97df44 72 * Used when declaring an empty array that does not take up space in a struct.
lypinator 0:bb348c97df44 73 * Example: struct { cb_uint8 payload[cb_EMPTY_ARRAY]; }
lypinator 0:bb348c97df44 74 * In some compilers this is empty i.e. payload[]. While in some it requires a zero.
lypinator 0:bb348c97df44 75 * I.e. payload[0];
lypinator 0:bb348c97df44 76 * Use this define to get it working for your system.
lypinator 0:bb348c97df44 77 */
lypinator 0:bb348c97df44 78 #ifndef cb_EMPTY_ARRAY
lypinator 0:bb348c97df44 79 # define cb_EMPTY_ARRAY (0)
lypinator 0:bb348c97df44 80 #endif
lypinator 0:bb348c97df44 81
lypinator 0:bb348c97df44 82 /*===========================================================================
lypinator 0:bb348c97df44 83 * DEFINES
lypinator 0:bb348c97df44 84 *=========================================================================*/
lypinator 0:bb348c97df44 85 /**
lypinator 0:bb348c97df44 86 * Used in function definitions to declare an inparameter unused to avoid warnings.
lypinator 0:bb348c97df44 87 */
lypinator 0:bb348c97df44 88 #ifndef cb_UNUSED
lypinator 0:bb348c97df44 89 # define cb_UNUSED(x) x
lypinator 0:bb348c97df44 90 #endif
lypinator 0:bb348c97df44 91
lypinator 0:bb348c97df44 92 #ifndef cb_ASSERT
lypinator 0:bb348c97df44 93 # error "No port definition for ASSERT!"
lypinator 0:bb348c97df44 94 #endif
lypinator 0:bb348c97df44 95
lypinator 0:bb348c97df44 96 #ifndef cb_ARG_POINTER_CHECK
lypinator 0:bb348c97df44 97 # define cb_ARG_POINTER_CHECK(ptr) if((ptr) == NULL) {cb_ASSERT(FALSE); return;}
lypinator 0:bb348c97df44 98 #endif
lypinator 0:bb348c97df44 99 #ifndef cb_ARG_POINTER_CHECK_RETURN
lypinator 0:bb348c97df44 100 # define cb_ARG_POINTER_CHECK_RETURN(ptr, returnValue) if((ptr) == NULL) {cb_ASSERT(FALSE); return (returnValue);}
lypinator 0:bb348c97df44 101 #endif
lypinator 0:bb348c97df44 102
lypinator 0:bb348c97df44 103 #ifndef cb_BIT_0
lypinator 0:bb348c97df44 104 #define cb_BIT_0 (1ul)
lypinator 0:bb348c97df44 105 #endif
lypinator 0:bb348c97df44 106 #ifndef cb_BIT_1
lypinator 0:bb348c97df44 107 #define cb_BIT_1 (1ul << 1)
lypinator 0:bb348c97df44 108 #endif
lypinator 0:bb348c97df44 109 #ifndef cb_BIT_2
lypinator 0:bb348c97df44 110 #define cb_BIT_2 (1ul << 2)
lypinator 0:bb348c97df44 111 #endif
lypinator 0:bb348c97df44 112 #ifndef cb_BIT_3
lypinator 0:bb348c97df44 113 #define cb_BIT_3 (1ul << 3)
lypinator 0:bb348c97df44 114 #endif
lypinator 0:bb348c97df44 115 #ifndef cb_BIT_4
lypinator 0:bb348c97df44 116 #define cb_BIT_4 (1ul << 4)
lypinator 0:bb348c97df44 117 #endif
lypinator 0:bb348c97df44 118 #ifndef cb_BIT_5
lypinator 0:bb348c97df44 119 #define cb_BIT_5 (1ul << 5)
lypinator 0:bb348c97df44 120 #endif
lypinator 0:bb348c97df44 121 #ifndef cb_BIT_6
lypinator 0:bb348c97df44 122 #define cb_BIT_6 (1ul << 6)
lypinator 0:bb348c97df44 123 #endif
lypinator 0:bb348c97df44 124 #ifndef cb_BIT_7
lypinator 0:bb348c97df44 125 #define cb_BIT_7 (1ul << 7)
lypinator 0:bb348c97df44 126 #endif
lypinator 0:bb348c97df44 127 #ifndef cb_BIT_8
lypinator 0:bb348c97df44 128 #define cb_BIT_8 (1ul << 8)
lypinator 0:bb348c97df44 129 #endif
lypinator 0:bb348c97df44 130 #ifndef cb_BIT_9
lypinator 0:bb348c97df44 131 #define cb_BIT_9 (1ul << 9)
lypinator 0:bb348c97df44 132 #endif
lypinator 0:bb348c97df44 133 #ifndef cb_BIT_10
lypinator 0:bb348c97df44 134 #define cb_BIT_10 (1ul << 10)
lypinator 0:bb348c97df44 135 #endif
lypinator 0:bb348c97df44 136 #ifndef cb_BIT_11
lypinator 0:bb348c97df44 137 #define cb_BIT_11 (1ul << 11)
lypinator 0:bb348c97df44 138 #endif
lypinator 0:bb348c97df44 139 #ifndef cb_BIT_12
lypinator 0:bb348c97df44 140 #define cb_BIT_12 (1ul << 12)
lypinator 0:bb348c97df44 141 #endif
lypinator 0:bb348c97df44 142 #ifndef cb_BIT_13
lypinator 0:bb348c97df44 143 #define cb_BIT_13 (1ul << 13)
lypinator 0:bb348c97df44 144 #endif
lypinator 0:bb348c97df44 145 #ifndef cb_BIT_14
lypinator 0:bb348c97df44 146 #define cb_BIT_14 (1ul << 14)
lypinator 0:bb348c97df44 147 #endif
lypinator 0:bb348c97df44 148 #ifndef cb_BIT_15
lypinator 0:bb348c97df44 149 #define cb_BIT_15 (1ul << 15)
lypinator 0:bb348c97df44 150 #endif
lypinator 0:bb348c97df44 151 #ifndef cb_BIT_16
lypinator 0:bb348c97df44 152 #define cb_BIT_16 (1ul << 16)
lypinator 0:bb348c97df44 153 #endif
lypinator 0:bb348c97df44 154 #ifndef cb_BIT_17
lypinator 0:bb348c97df44 155 #define cb_BIT_17 (1ul << 17)
lypinator 0:bb348c97df44 156 #endif
lypinator 0:bb348c97df44 157 #ifndef cb_BIT_18
lypinator 0:bb348c97df44 158 #define cb_BIT_18 (1ul << 18)
lypinator 0:bb348c97df44 159 #endif
lypinator 0:bb348c97df44 160 #ifndef cb_BIT_19
lypinator 0:bb348c97df44 161 #define cb_BIT_19 (1ul << 19)
lypinator 0:bb348c97df44 162 #endif
lypinator 0:bb348c97df44 163 #ifndef cb_BIT_20
lypinator 0:bb348c97df44 164 #define cb_BIT_20 (1ul << 20)
lypinator 0:bb348c97df44 165 #endif
lypinator 0:bb348c97df44 166 #ifndef cb_BIT_21
lypinator 0:bb348c97df44 167 #define cb_BIT_21 (1ul << 21)
lypinator 0:bb348c97df44 168 #endif
lypinator 0:bb348c97df44 169 #ifndef cb_BIT_22
lypinator 0:bb348c97df44 170 #define cb_BIT_22 (1ul << 22)
lypinator 0:bb348c97df44 171 #endif
lypinator 0:bb348c97df44 172 #ifndef cb_BIT_23
lypinator 0:bb348c97df44 173 #define cb_BIT_23 (1ul << 23)
lypinator 0:bb348c97df44 174 #endif
lypinator 0:bb348c97df44 175 #ifndef cb_BIT_24
lypinator 0:bb348c97df44 176 #define cb_BIT_24 (1ul << 24)
lypinator 0:bb348c97df44 177 #endif
lypinator 0:bb348c97df44 178 #ifndef cb_BIT_25
lypinator 0:bb348c97df44 179 #define cb_BIT_25 (1ul << 25)
lypinator 0:bb348c97df44 180 #endif
lypinator 0:bb348c97df44 181 #ifndef cb_BIT_26
lypinator 0:bb348c97df44 182 #define cb_BIT_26 (1ul << 26)
lypinator 0:bb348c97df44 183 #endif
lypinator 0:bb348c97df44 184 #ifndef cb_BIT_27
lypinator 0:bb348c97df44 185 #define cb_BIT_27 (1ul << 27)
lypinator 0:bb348c97df44 186 #endif
lypinator 0:bb348c97df44 187 #ifndef cb_BIT_28
lypinator 0:bb348c97df44 188 #define cb_BIT_28 (1ul << 28)
lypinator 0:bb348c97df44 189 #endif
lypinator 0:bb348c97df44 190 #ifndef cb_BIT_29
lypinator 0:bb348c97df44 191 #define cb_BIT_29 (1ul << 29)
lypinator 0:bb348c97df44 192 #endif
lypinator 0:bb348c97df44 193 #ifndef cb_BIT_30
lypinator 0:bb348c97df44 194 #define cb_BIT_30 (1ul << 30)
lypinator 0:bb348c97df44 195 #endif
lypinator 0:bb348c97df44 196 #ifndef cb_BIT_31
lypinator 0:bb348c97df44 197 #define cb_BIT_31 (1ul << 31)
lypinator 0:bb348c97df44 198 #endif
lypinator 0:bb348c97df44 199
lypinator 0:bb348c97df44 200 #ifndef cb_UINT8_MAX
lypinator 0:bb348c97df44 201 #define cb_UINT8_MAX ((cb_uint8)0xff)
lypinator 0:bb348c97df44 202 #endif
lypinator 0:bb348c97df44 203 #ifndef cb_UINT16_MAX
lypinator 0:bb348c97df44 204 #define cb_UINT16_MAX ((cb_uint16)0xffff)
lypinator 0:bb348c97df44 205 #endif
lypinator 0:bb348c97df44 206 #ifndef cb_UINT32_MAX
lypinator 0:bb348c97df44 207 #define cb_UINT32_MAX ((cb_uint32)0xffffffff)
lypinator 0:bb348c97df44 208 #endif
lypinator 0:bb348c97df44 209 #ifndef cb_INT8_MAX
lypinator 0:bb348c97df44 210 #define cb_INT8_MAX ((cb_uint8)0x7f)
lypinator 0:bb348c97df44 211 #endif
lypinator 0:bb348c97df44 212 #ifndef cb_INT16_MAX
lypinator 0:bb348c97df44 213 #define cb_INT16_MAX ((cb_uint16)0x7fff)
lypinator 0:bb348c97df44 214 #endif
lypinator 0:bb348c97df44 215 #ifndef cb_INT32_MAX
lypinator 0:bb348c97df44 216 #define cb_INT32_MAX ((cb_uint32)0x7fffffff)
lypinator 0:bb348c97df44 217 #endif
lypinator 0:bb348c97df44 218 #ifndef cb_INT8_MIN
lypinator 0:bb348c97df44 219 #define cb_INT8_MIN ((cb_uint8)0x80)
lypinator 0:bb348c97df44 220 #endif
lypinator 0:bb348c97df44 221 #ifndef cb_INT16_MIN
lypinator 0:bb348c97df44 222 #define cb_INT16_MIN ((cb_uint16)0x8000)
lypinator 0:bb348c97df44 223 #endif
lypinator 0:bb348c97df44 224 #ifndef cb_INT32_MIN
lypinator 0:bb348c97df44 225 #define cb_INT32_MIN ((cb_uint32)0x80000000)
lypinator 0:bb348c97df44 226 #endif
lypinator 0:bb348c97df44 227
lypinator 0:bb348c97df44 228 /**
lypinator 0:bb348c97df44 229 * Clears (set to zero) a bit or bits in a variable.
lypinator 0:bb348c97df44 230 * @param variable The variable.
lypinator 0:bb348c97df44 231 * @param bit The bit or bits to clear
lypinator 0:bb348c97df44 232 */
lypinator 0:bb348c97df44 233 #ifndef cb_CLEAR_BIT
lypinator 0:bb348c97df44 234 # define cb_CLEAR_BIT(variable,bit) ((variable) &= ~((bit)))
lypinator 0:bb348c97df44 235 #endif
lypinator 0:bb348c97df44 236
lypinator 0:bb348c97df44 237 /**
lypinator 0:bb348c97df44 238 * Gets a bit i.e. checks if it is set in a variable.
lypinator 0:bb348c97df44 239 *
lypinator 0:bb348c97df44 240 * Also works to see if any of several bits are set.
lypinator 0:bb348c97df44 241 *
lypinator 0:bb348c97df44 242 * @param variable The variable.
lypinator 0:bb348c97df44 243 * @param bit The bit to check if it set.
lypinator 0:bb348c97df44 244 * @return @ref TRUE if any of the bits are set, @ref FALSE otherwise.
lypinator 0:bb348c97df44 245 */
lypinator 0:bb348c97df44 246 #ifndef cb_GET_BIT
lypinator 0:bb348c97df44 247 # define cb_GET_BIT(variable,bit) (((variable) & ((bit))) ? TRUE : FALSE)
lypinator 0:bb348c97df44 248 #endif
lypinator 0:bb348c97df44 249
lypinator 0:bb348c97df44 250 /**
lypinator 0:bb348c97df44 251 * Sets (set to 1) a bit or bits in a variable.
lypinator 0:bb348c97df44 252 *
lypinator 0:bb348c97df44 253 * @param variable The variable.
lypinator 0:bb348c97df44 254 * @param bit The bit or bits to set in the variable.
lypinator 0:bb348c97df44 255 */
lypinator 0:bb348c97df44 256 #ifndef cb_SET_BIT
lypinator 0:bb348c97df44 257 # define cb_SET_BIT(variable,bit) ((variable) |= (bit))
lypinator 0:bb348c97df44 258 #endif
lypinator 0:bb348c97df44 259
lypinator 0:bb348c97df44 260
lypinator 0:bb348c97df44 261 /*Packed struct defines*/
lypinator 0:bb348c97df44 262 #ifndef cb_PACKED_STRUCT_ATTR_INLINE_POST
lypinator 0:bb348c97df44 263 # define cb_PACKED_STRUCT_ATTR_INLINE_POST
lypinator 0:bb348c97df44 264 #endif
lypinator 0:bb348c97df44 265 #ifndef cb_PACKED_STRUCT_ATTR_INLINE_PRE
lypinator 0:bb348c97df44 266 # define cb_PACKED_STRUCT_ATTR_INLINE_PRE
lypinator 0:bb348c97df44 267 #endif
lypinator 0:bb348c97df44 268 #ifndef cb_PACKED_STRUCT_ATTR_PRE
lypinator 0:bb348c97df44 269 # define cb_PACKED_STRUCT_ATTR_PRE
lypinator 0:bb348c97df44 270 #endif
lypinator 0:bb348c97df44 271 #ifndef cb_PACKED_STRUCT_ATTR_POST
lypinator 0:bb348c97df44 272 # define cb_PACKED_STRUCT_ATTR_POST
lypinator 0:bb348c97df44 273 #endif
lypinator 0:bb348c97df44 274
lypinator 0:bb348c97df44 275 #ifndef cb_PACKED_STRUCT_BEGIN
lypinator 0:bb348c97df44 276 # define cb_PACKED_STRUCT_BEGIN(name) \
lypinator 0:bb348c97df44 277 cb_PACKED_STRUCT_ATTR_PRE \
lypinator 0:bb348c97df44 278 typedef cb_PACKED_STRUCT_ATTR_INLINE_PRE struct name
lypinator 0:bb348c97df44 279 #endif
lypinator 0:bb348c97df44 280
lypinator 0:bb348c97df44 281 #ifndef cb_PACKED_STRUCT_END
lypinator 0:bb348c97df44 282 # define cb_PACKED_STRUCT_END(name) \
lypinator 0:bb348c97df44 283 cb_PACKED_STRUCT_ATTR_INLINE_POST name; \
lypinator 0:bb348c97df44 284 cb_PACKED_STRUCT_ATTR_POST
lypinator 0:bb348c97df44 285 #endif
lypinator 0:bb348c97df44 286
lypinator 0:bb348c97df44 287 #endif /* _CB_TYPES_H_ */