Contiki 3.x
8051def.h
1 /*
2  * \file
3  * This file contains a set of configuration for using SDCC as a compiler.
4  * This is based on the cc2430 file (which in turn is based on the z80 one)
5  *
6  * \author
7  * Takahide Matsutsuka <markn@markn.org> (Original)
8  * George Oikonomou - <oikonomou@users.sourceforge.net>
9  * (updates for the cc2530 ports)
10  */
11 
12 #ifndef E051_DEF_H_
13 #define E051_DEF_H_
14 
15 #include <stdint.h>
16 
17 /* In watchdog mode, our WDT can't be stopped once started
18  * Include watchdog_stop()'s declaration and then trash it */
19 #include "dev/watchdog.h"
20 #define watchdog_stop() watchdog_periodic()
21 
22 /* This port no longer implements the legacy clock_delay. Hack its usages
23  * outta the way till it gets phased out completely
24  * NB: This also overwrites the prototype so delay_usec() is declared twice */
25 #define clock_delay(t) clock_delay_usec(t)
26 
27 /*
28  * lint - style defines to help syntax parsers with sdcc-specific 8051 code
29  * They don't interfere with actual compilation
30  */
31 #if !defined(__SDCC_mcs51) && !defined(SDCC_mcs51)
32 #define __data
33 #define __xdata
34 #define __code
35 #define __bit bool
36 #define __sfr volatile unsigned char
37 #define __sbit volatile bool
38 #define __critical
39 #define __at(x)
40 #define __using(x)
41 #define __interrupt(x)
42 #define __naked
43 #endif
44 
45 #define CC_CONF_FUNCTION_POINTER_ARGS 1
46 #define CC_CONF_FASTCALL
47 #define CC_CONF_VA_ARGS 1
48 #define CC_CONF_UNSIGNED_CHAR_BUGS 0
49 #define CC_CONF_REGISTER_ARGS 0
50 #define CC_CONF_FUNCTION_POINTER_KEYWORD __reentrant
51 #define CC_CONF_NON_BANKED_OPTIMIZATION 1
52 
53 #if (defined(__SDCC_mcs51) || defined(SDCC_mcs51)) && CC_CONF_NON_BANKED_OPTIMIZATION
54 #define CC_NON_BANKED __nonbanked
55 #else
56 #define CC_NON_BANKED
57 #endif
58 
59 /*
60  * Max Stack Depth manipulation. It is possible to get up to 247 bytes
61  * allocated for the stack if:
62  * - You set this to 1 and
63  * - You have a patched toolchain and
64  * - You don't use __bit variables
65  * - You do not link libraries using BIT registers (e.g. printf_large)
66  * Enabling this will mean ISRs will NOT push bits (#pragma exclude bits) so
67  * make sure you know what you're doing
68  *
69  * More information on the wiki
70  */
71 #define CC_CONF_OPTIMIZE_STACK_SIZE 0
72 
73 #if CC_CONF_OPTIMIZE_STACK_SIZE
74 #define CC_AT_DATA
75 #else
76 #define CC_AT_DATA __data
77 #endif
78 
79 /* Generic types. */
80 typedef unsigned short uip_stats_t;
81 
82 /* Time type. */
83 typedef unsigned short clock_time_t;
84 #define MAX_TICKS (~((clock_time_t)0) / 2)
85 /* Defines tick counts for a second. */
86 #define CLOCK_CONF_SECOND 128
87 
88 /* Compiler configurations */
89 #define CCIF
90 #define CLIF
91 
92 /* Single asm instruction without messing up syntax highlighting */
93 #if defined(__SDCC_mcs51) || defined(SDCC_mcs51)
94 #define ASM(x) __asm \
95  x \
96  __endasm
97 #else
98 #define ASM(x)
99 #endif
100 
101 /* Critical section management */
102 #define DISABLE_INTERRUPTS() do {EA = 0;} while(0)
103 #define ENABLE_INTERRUPTS() do {EA = 1;} while(0)
104 
105 /* Macro for a soft reset. */
106 #define SOFT_RESET() do {((void (__code *) (void)) 0x0000) ();} while(0)
107 
108 /* We don't provide architecture-specific checksum calculations */
109 #define UIP_ARCH_ADD32 0
110 #define UIP_ARCH_CHKSUM 0
111 
112 #define CC_CONF_ASSIGN_AGGREGATE(dest, src) \
113  memcpy(dest, src, sizeof(*dest))
114 
115 #define uip_ipaddr_copy(dest, src) \
116  memcpy(dest, src, sizeof(*dest))
117 
118 #endif /* E051_DEF_H_ */