|
| 1 | +/*! |
| 2 | +* Copyright (c) 2015, Freescale Semiconductor, Inc. |
| 3 | +* Copyright 2016-2017 NXP |
| 4 | +* |
| 5 | +* \file |
| 6 | +* |
| 7 | +* This file holds type definitions that maps the standard c-types into types |
| 8 | +* with guaranteed sizes. The types are target/platform specific and must be edited |
| 9 | +* for each new target/platform. |
| 10 | +* The header file also provides definitions for TRUE, FALSE and NULL. |
| 11 | +* |
| 12 | +* Redistribution and use in source and binary forms, with or without modification, |
| 13 | +* are permitted provided that the following conditions are met: |
| 14 | +* |
| 15 | +* o Redistributions of source code must retain the above copyright notice, this list |
| 16 | +* of conditions and the following disclaimer. |
| 17 | +* |
| 18 | +* o Redistributions in binary form must reproduce the above copyright notice, this |
| 19 | +* list of conditions and the following disclaimer in the documentation and/or |
| 20 | +* other materials provided with the distribution. |
| 21 | +* |
| 22 | +* o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
| 23 | +* contributors may be used to endorse or promote products derived from this |
| 24 | +* software without specific prior written permission. |
| 25 | +* |
| 26 | +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 27 | +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 28 | +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 29 | +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| 30 | +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 31 | +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 32 | +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 33 | +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 34 | +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 35 | +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 | +*/ |
| 37 | + |
| 38 | +#ifndef _EMBEDDEDTYPES_H_ |
| 39 | +#define _EMBEDDEDTYPES_H_ |
| 40 | + |
| 41 | + |
| 42 | +/************************************************************************************ |
| 43 | +* |
| 44 | +* INCLUDES |
| 45 | +* |
| 46 | +************************************************************************************/ |
| 47 | + |
| 48 | +#include <stdint.h> |
| 49 | + |
| 50 | + |
| 51 | +/************************************************************************************ |
| 52 | +* |
| 53 | +* TYPE DEFINITIONS |
| 54 | +* |
| 55 | +************************************************************************************/ |
| 56 | + |
| 57 | +/* boolean types */ |
| 58 | +typedef uint8_t bool_t; |
| 59 | + |
| 60 | +typedef uint8_t index_t; |
| 61 | + |
| 62 | +/* TRUE/FALSE definition*/ |
| 63 | +#ifndef TRUE |
| 64 | +#define TRUE 1 |
| 65 | +#endif |
| 66 | + |
| 67 | +#ifndef FALSE |
| 68 | +#define FALSE 0 |
| 69 | +#endif |
| 70 | + |
| 71 | +/* null pointer definition*/ |
| 72 | +#ifndef NULL |
| 73 | +#define NULL (( void * )( 0x0UL )) |
| 74 | +#endif |
| 75 | + |
| 76 | +#if defined(__GNUC__) |
| 77 | +#define PACKED_STRUCT struct __attribute__ ((__packed__)) |
| 78 | +#define PACKED_UNION union __attribute__ ((__packed__)) |
| 79 | +#elif defined(__IAR_SYSTEMS_ICC__) |
| 80 | +#define PACKED_STRUCT __packed struct |
| 81 | +#define PACKED_UNION __packed union |
| 82 | +#else |
| 83 | +#define PACKED_STRUCT struct |
| 84 | +#define PACKED_UNION union |
| 85 | +#endif |
| 86 | + |
| 87 | +typedef unsigned char uintn8_t; |
| 88 | +typedef unsigned long uintn32_t; |
| 89 | + |
| 90 | +typedef unsigned char uchar_t; |
| 91 | + |
| 92 | +#if !defined(MIN) |
| 93 | +#define MIN(a,b) (((a) < (b))?(a):(b)) |
| 94 | +#endif |
| 95 | + |
| 96 | +#if !defined(MAX) |
| 97 | +#define MAX(a,b) (((a) > (b))?(a):(b)) |
| 98 | +#endif |
| 99 | + |
| 100 | +/* Compute the number of elements of an array */ |
| 101 | +#define NumberOfElements(x) (sizeof(x)/sizeof((x)[0])) |
| 102 | + |
| 103 | +/* Compute the size of a string initialized with quotation marks */ |
| 104 | +#define SizeOfString(string) (sizeof(string) - 1) |
| 105 | + |
| 106 | +#define GetRelAddr(strct, member) ((uint32_t)&(((strct*)(void *)0)->member)) |
| 107 | +#define GetSizeOfMember(strct, member) sizeof(((strct*)(void *)0)->member) |
| 108 | + |
| 109 | +/* Type definitions for link configuration of instantiable layers */ |
| 110 | +#define gInvalidInstanceId_c (instanceId_t)(-1) |
| 111 | +typedef uint32_t instanceId_t; |
| 112 | + |
| 113 | +/* Bit shift definitions */ |
| 114 | +#define BIT0 0x01 |
| 115 | +#define BIT1 0x02 |
| 116 | +#define BIT2 0x04 |
| 117 | +#define BIT3 0x08 |
| 118 | +#define BIT4 0x10 |
| 119 | +#define BIT5 0x20 |
| 120 | +#define BIT6 0x40 |
| 121 | +#define BIT7 0x80 |
| 122 | +#define BIT8 0x100 |
| 123 | +#define BIT9 0x200 |
| 124 | +#define BIT10 0x400 |
| 125 | +#define BIT11 0x800 |
| 126 | +#define BIT12 0x1000 |
| 127 | +#define BIT13 0x2000 |
| 128 | +#define BIT14 0x4000 |
| 129 | +#define BIT15 0x8000 |
| 130 | +#define BIT16 0x10000 |
| 131 | +#define BIT17 0x20000 |
| 132 | +#define BIT18 0x40000 |
| 133 | +#define BIT19 0x80000 |
| 134 | +#define BIT20 0x100000 |
| 135 | +#define BIT21 0x200000 |
| 136 | +#define BIT22 0x400000 |
| 137 | +#define BIT23 0x800000 |
| 138 | +#define BIT24 0x1000000 |
| 139 | +#define BIT25 0x2000000 |
| 140 | +#define BIT26 0x4000000 |
| 141 | +#define BIT27 0x8000000 |
| 142 | +#define BIT28 0x10000000 |
| 143 | +#define BIT29 0x20000000 |
| 144 | +#define BIT30 0x40000000 |
| 145 | +#define BIT31 0x80000000 |
| 146 | + |
| 147 | +/* Shift definitions */ |
| 148 | +#define SHIFT0 (0) |
| 149 | +#define SHIFT1 (1) |
| 150 | +#define SHIFT2 (2) |
| 151 | +#define SHIFT3 (3) |
| 152 | +#define SHIFT4 (4) |
| 153 | +#define SHIFT5 (5) |
| 154 | +#define SHIFT6 (6) |
| 155 | +#define SHIFT7 (7) |
| 156 | +#define SHIFT8 (8) |
| 157 | +#define SHIFT9 (9) |
| 158 | +#define SHIFT10 (10) |
| 159 | +#define SHIFT11 (11) |
| 160 | +#define SHIFT12 (12) |
| 161 | +#define SHIFT13 (13) |
| 162 | +#define SHIFT14 (14) |
| 163 | +#define SHIFT15 (15) |
| 164 | +#define SHIFT16 (16) |
| 165 | +#define SHIFT17 (17) |
| 166 | +#define SHIFT18 (18) |
| 167 | +#define SHIFT19 (19) |
| 168 | +#define SHIFT20 (20) |
| 169 | +#define SHIFT21 (21) |
| 170 | +#define SHIFT22 (22) |
| 171 | +#define SHIFT23 (23) |
| 172 | +#define SHIFT24 (24) |
| 173 | +#define SHIFT25 (25) |
| 174 | +#define SHIFT26 (26) |
| 175 | +#define SHIFT27 (27) |
| 176 | +#define SHIFT28 (28) |
| 177 | +#define SHIFT29 (29) |
| 178 | +#define SHIFT30 (30) |
| 179 | +#define SHIFT31 (31) |
| 180 | + |
| 181 | +#define SHIFT32 (32) |
| 182 | +#define SHIFT33 (33) |
| 183 | +#define SHIFT34 (34) |
| 184 | +#define SHIFT35 (35) |
| 185 | +#define SHIFT36 (36) |
| 186 | +#define SHIFT37 (37) |
| 187 | +#define SHIFT38 (38) |
| 188 | +#define SHIFT39 (39) |
| 189 | +#define SHIFT40 (40) |
| 190 | +#define SHIFT41 (41) |
| 191 | +#define SHIFT42 (42) |
| 192 | +#define SHIFT43 (43) |
| 193 | +#define SHIFT44 (44) |
| 194 | +#define SHIFT45 (45) |
| 195 | +#define SHIFT46 (46) |
| 196 | +#define SHIFT47 (47) |
| 197 | +#define SHIFT48 (48) |
| 198 | +#define SHIFT49 (49) |
| 199 | +#define SHIFT50 (50) |
| 200 | +#define SHIFT51 (51) |
| 201 | +#define SHIFT52 (52) |
| 202 | +#define SHIFT53 (53) |
| 203 | +#define SHIFT54 (54) |
| 204 | +#define SHIFT55 (55) |
| 205 | +#define SHIFT56 (56) |
| 206 | +#define SHIFT57 (57) |
| 207 | +#define SHIFT58 (58) |
| 208 | +#define SHIFT59 (59) |
| 209 | +#define SHIFT60 (60) |
| 210 | +#define SHIFT61 (61) |
| 211 | +#define SHIFT62 (62) |
| 212 | +#define SHIFT63 (63) |
| 213 | + |
| 214 | + |
| 215 | +#endif /* _EMBEDDEDTYPES_H_ */ |
0 commit comments