]> git.sur5r.net Git - armstart-ibdap/blobdiff - inc/lpc_types.h
initial commit
[armstart-ibdap] / inc / lpc_types.h
diff --git a/inc/lpc_types.h b/inc/lpc_types.h
new file mode 100644 (file)
index 0000000..772143e
--- /dev/null
@@ -0,0 +1,216 @@
+/*\r
+ * @brief Common types used in LPC functions\r
+ *\r
+ * @note\r
+ * Copyright(C) NXP Semiconductors, 2012\r
+ * All rights reserved.\r
+ *\r
+ * @par\r
+ * Software that is described herein is for illustrative purposes only\r
+ * which provides customers with programming information regarding the\r
+ * LPC products.  This software is supplied "AS IS" without any warranties of\r
+ * any kind, and NXP Semiconductors and its licensor disclaim any and\r
+ * all warranties, express or implied, including all implied warranties of\r
+ * merchantability, fitness for a particular purpose and non-infringement of\r
+ * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
+ * or liability for the use of the software, conveys no license or rights under any\r
+ * patent, copyright, mask work right, or any other intellectual property rights in\r
+ * or to any products. NXP Semiconductors reserves the right to make changes\r
+ * in the software without notification. NXP Semiconductors also makes no\r
+ * representation or warranty that such application will be suitable for the\r
+ * specified use without further testing or modification.\r
+ *\r
+ * @par\r
+ * Permission to use, copy, modify, and distribute this software and its\r
+ * documentation is hereby granted, under NXP Semiconductors' and its\r
+ * licensor's relevant copyrights in the software, without fee, provided that it\r
+ * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
+ * copyright, permission, and disclaimer notice must appear in all copies of\r
+ * this code.\r
+ */\r
+\r
+#ifndef __LPC_TYPES_H_\r
+#define __LPC_TYPES_H_\r
+\r
+#include <stdint.h>\r
+#include <stdbool.h>\r
+\r
+/** @defgroup LPC_Types CHIP: LPC Common Types\r
+ * @ingroup CHIP_Common\r
+ * @{\r
+ */\r
+\r
+/** @defgroup LPC_Types_Public_Types LPC Public Types\r
+ * @{\r
+ */\r
+\r
+/**\r
+ * @brief Boolean Type definition\r
+ */\r
+typedef enum {FALSE = 0, TRUE = !FALSE} Bool;\r
+\r
+/**\r
+ * @brief Boolean Type definition\r
+ */\r
+#if !defined(__cplusplus)\r
+// typedef enum {false = 0, true = !false} bool;\r
+#endif\r
+\r
+/**\r
+ * @brief Flag Status and Interrupt Flag Status type definition\r
+ */\r
+typedef enum {RESET = 0, SET = !RESET} FlagStatus, IntStatus, SetState;\r
+#define PARAM_SETSTATE(State) ((State == RESET) || (State == SET))\r
+\r
+/**\r
+ * @brief Functional State Definition\r
+ */\r
+typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;\r
+#define PARAM_FUNCTIONALSTATE(State) ((State == DISABLE) || (State == ENABLE))\r
+\r
+/**\r
+ * @ Status type definition\r
+ */\r
+typedef enum {ERROR = 0, SUCCESS = !ERROR} Status;\r
+\r
+/**\r
+ * Read/Write transfer type mode (Block or non-block)\r
+ */\r
+typedef enum {\r
+       NONE_BLOCKING = 0,              /**< None Blocking type */\r
+       BLOCKING,                               /**< Blocking type */\r
+} TRANSFER_BLOCK_T;\r
+\r
+/** Pointer to Function returning Void (any number of parameters) */\r
+typedef void (*PFV)();\r
+\r
+/** Pointer to Function returning int32_t (any number of parameters) */\r
+typedef int32_t (*PFI)();\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/** @defgroup LPC_Types_Public_Macros  LPC Public Macros\r
+ * @{\r
+ */\r
+\r
+/* _BIT(n) sets the bit at position "n"\r
+ * _BIT(n) is intended to be used in "OR" and "AND" expressions:\r
+ * e.g., "(_BIT(3) | _BIT(7))".\r
+ */\r
+#undef _BIT\r
+/* Set bit macro */\r
+#define _BIT(n) (1 << (n))\r
+\r
+/* _SBF(f,v) sets the bit field starting at position "f" to value "v".\r
+ * _SBF(f,v) is intended to be used in "OR" and "AND" expressions:\r
+ * e.g., "((_SBF(5,7) | _SBF(12,0xF)) & 0xFFFF)"\r
+ */\r
+#undef _SBF\r
+/* Set bit field macro */\r
+#define _SBF(f, v) ((v) << (f))\r
+\r
+/* _BITMASK constructs a symbol with 'field_width' least significant\r
+ * bits set.\r
+ * e.g., _BITMASK(5) constructs '0x1F', _BITMASK(16) == 0xFFFF\r
+ * The symbol is intended to be used to limit the bit field width\r
+ * thusly:\r
+ * <a_register> = (any_expression) & _BITMASK(x), where 0 < x <= 32.\r
+ * If "any_expression" results in a value that is larger than can be\r
+ * contained in 'x' bits, the bits above 'x - 1' are masked off.  When\r
+ * used with the _SBF example above, the example would be written:\r
+ * a_reg = ((_SBF(5,7) | _SBF(12,0xF)) & _BITMASK(16))\r
+ * This ensures that the value written to a_reg is no wider than\r
+ * 16 bits, and makes the code easier to read and understand.\r
+ */\r
+#undef _BITMASK\r
+/* Bitmask creation macro */\r
+#define _BITMASK(field_width) ( _BIT(field_width) - 1)\r
+\r
+/* NULL pointer */\r
+#ifndef NULL\r
+#define NULL ((void *) 0)\r
+#endif\r
+\r
+/* Number of elements in an array */\r
+#define NELEMENTS(array)  (sizeof(array) / sizeof(array[0]))\r
+\r
+/* Static data/function define */\r
+#define STATIC static\r
+/* External data/function define */\r
+#define EXTERN extern\r
+\r
+#if !defined(MAX)\r
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))\r
+#endif\r
+#if !defined(MIN)\r
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))\r
+#endif\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/* Old Type Definition compatibility */\r
+/** @addtogroup LPC_Types_Public_Types\r
+ * @{\r
+ */\r
+\r
+/** LPC type for character type */\r
+typedef char CHAR;\r
+\r
+/** LPC type for 8 bit unsigned value */\r
+typedef uint8_t UNS_8;\r
+\r
+/** LPC type for 8 bit signed value */\r
+typedef int8_t INT_8;\r
+\r
+/** LPC type for 16 bit unsigned value */\r
+typedef uint16_t UNS_16;\r
+\r
+/** LPC type for 16 bit signed value */\r
+typedef int16_t INT_16;\r
+\r
+/** LPC type for 32 bit unsigned value */\r
+typedef uint32_t UNS_32;\r
+\r
+/** LPC type for 32 bit signed value */\r
+typedef int32_t INT_32;\r
+\r
+/** LPC type for 64 bit signed value */\r
+typedef int64_t INT_64;\r
+\r
+/** LPC type for 64 bit unsigned value */\r
+typedef uint64_t UNS_64;\r
+\r
+#ifdef __CODE_RED\r
+#define BOOL_32 bool\r
+#define BOOL_16 bool\r
+#define BOOL_8  bool\r
+#else\r
+/** 32 bit boolean type */\r
+typedef bool BOOL_32;\r
+\r
+/** 16 bit boolean type */\r
+typedef bool BOOL_16;\r
+\r
+/** 8 bit boolean type */\r
+typedef bool BOOL_8;\r
+#endif\r
+\r
+#ifdef __CC_ARM\r
+#define INLINE  __inline\r
+#else\r
+#define INLINE inline\r
+#endif\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+#endif /* __LPC_TYPES_H_ */\r