| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cc.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 * OF SUCH DAMAGE.
26 *
27 * This file is part of the lwIP TCP/IP stack.
28 *
29 * Author: Adam Dunkels <adam@sics.se>
30 *
31 */
32 #ifndef __CC_H__
33 #define __CC_H__
34
35 #include <stdint.h>
36 #include <stdio.h>
37
42 /* Types based on stdint.h */
43 typedef uint8_t u8_t;
44 typedef int8_t s8_t;
45 typedef uint16_t u16_t;
46 typedef int16_t s16_t;
47 typedef uint32_t u32_t;
48 typedef int32_t s32_t;
49 typedef uintptr_t mem_ptr_t;
50
51 /* Define (sn)printf formatters for these lwIP types */
52 #define U16_F "hu"
53 #define S16_F "hd"
54 #define X16_F "hx"
55 #define U32_F "lu"
56 #define S32_F "ld"
57 #define X32_F "lx"
58 #define SZT_F "uz"
59
60 /* ARM/LPC17xx is little endian only */
61 #define BYTE_ORDER LITTLE_ENDIAN
62
63 /* Use LWIP error codes */
64 #define LWIP_PROVIDE_ERRNO
65
66 #if defined(__arm__) && defined(__ARMCC_VERSION)
67 /* Keil uVision4 tools */
68 #define PACK_STRUCT_BEGIN __packed
69 #define PACK_STRUCT_STRUCT
70 #define PACK_STRUCT_END
71 #define PACK_STRUCT_FIELD(fld) fld
72 #define ALIGNED(n) __align(n)
73 #elif defined (__IAR_SYSTEMS_ICC__)
74 /* IAR Embedded Workbench tools */
75 #define PACK_STRUCT_BEGIN __packed
76 #define PACK_STRUCT_STRUCT
77 #define PACK_STRUCT_END
78 #define PACK_STRUCT_FIELD(fld) fld
79 // #define PACK_STRUCT_USE_INCLUDES
80 #define ALIGNEDX(x) _Pragma(#x)
81 #define ALIGNEDXX(x) ALIGNEDX(data_alignment=x)
82 #define ALIGNED(x) ALIGNEDXX(x)
83 #else
84 /* GCC tools (CodeSourcery) */
85 #define PACK_STRUCT_BEGIN
86 #define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
87 #define PACK_STRUCT_END
88 #define PACK_STRUCT_FIELD(fld) fld
89 #define ALIGNED(n) __attribute__((aligned (n)))
90 // #define ALIGNED(n) __align(n)
91 #endif
92
93 /* Used with IP headers only */
94 #define LWIP_CHKSUM_ALGORITHM 1
95
96 #ifdef LWIP_DEBUG
97
106 void assert_printf(char *msg, int line, char *file);
107
108 /* Plaform specific diagnostic output */
109 #define LWIP_PLATFORM_DIAG(vars) printf vars
110 #define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); }
111 #else
112
117 void assert_loop(void);
118 #define LWIP_PLATFORM_DIAG(msg) { ; }
119 #define LWIP_PLATFORM_ASSERT(flag) { assert_loop(); }
120 #endif
121
126 #endif /* __CC_H__ */