Contiki 3.x
msp430def.h
1 /*
2  * Copyright (c) 2007, Swedish Institute of Computer Science
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #ifndef MSP430DEF_H
31 #define MSP430DEF_H
32 
33 #ifdef __IAR_SYSTEMS_ICC__
34 #include <intrinsics.h>
35 #include <in430.h>
36 #include <msp430.h>
37 #define dint() __disable_interrupt()
38 #define eint() __enable_interrupt()
39 #define __MSP430__ 1
40 #define CC_CONF_INLINE
41 
42 #else /* __IAR_SYSTEMS_ICC__ */
43 
44 #ifdef __MSPGCC__
45 #include <msp430.h>
46 #include <legacymsp430.h>
47 #else /* __MSPGCC__ */
48 #include <io.h>
49 #include <signal.h>
50 #if !defined(MSP430_MEMCPY_WORKAROUND) && (__GNUC__ < 4)
51 #define MSP430_MEMCPY_WORKAROUND 1
52 #endif
53 #endif /* __MSPGCC__ */
54 
55 #define CC_CONF_INLINE inline
56 
57 #endif /* __IAR_SYSTEMS_ICC__ */
58 
59 #ifndef BV
60 #define BV(x) (1 << x)
61 #endif
62 
63 #ifdef HAVE_STDINT_H
64 #include <stdint.h>
65 #else
66 #ifndef uint8_t
67 typedef unsigned char uint8_t;
68 typedef unsigned short uint16_t;
69 typedef unsigned long uint32_t;
70 typedef signed char int8_t;
71 typedef short int16_t;
72 typedef long int32_t;
73 #endif
74 #endif /* !HAVE_STDINT_H */
75 
76 /* These names are deprecated, use C99 names. */
77 typedef uint8_t u8_t;
78 typedef uint16_t u16_t;
79 typedef uint32_t u32_t;
80 typedef int32_t s32_t;
81 
82 /* default DCOSYNCH Period is 30 seconds */
83 #ifdef DCOSYNCH_CONF_PERIOD
84 #define DCOSYNCH_PERIOD DCOSYNCH_CONF_PERIOD
85 #else
86 #define DCOSYNCH_PERIOD 30
87 #endif
88 
89 void msp430_cpu_init(void); /* Rename to cpu_init() later! */
90 void msp430_sync_dco(void);
91 
92 
93 #define cpu_init() msp430_cpu_init()
94 
95 void *sbrk(int);
96 
97 typedef int spl_t;
98 /* void splx_(spl_t); */
99 spl_t splhigh_(void);
100 
101 #define splhigh() splhigh_()
102 #ifdef __IAR_SYSTEMS_ICC__
103 #define splx(sr) __bis_SR_register(sr)
104 #else
105 #define splx(sr) __asm__ __volatile__("bis %0, r2" : : "r" (sr))
106 #endif
107 
108 /* Workaround for bug in msp430-gcc compiler */
109 #if defined(__MSP430__) && defined(__GNUC__) && MSP430_MEMCPY_WORKAROUND
110 #ifndef memcpy
111 #include <string.h>
112 
113 void *w_memcpy(void *out, const void *in, size_t n);
114 #define memcpy(dest, src, count) w_memcpy(dest, src, count)
115 
116 void *w_memset(void *out, int value, size_t n);
117 #define memset(dest, value, count) w_memset(dest, value, count)
118 
119 #endif /* memcpy */
120 #endif /* __GNUC__ && __MSP430__ && MSP430_MEMCPY_WORKAROUND */
121 
122 
123 /* Moved from the msp430.h file with other msp430 related defines */
124 
125 #ifdef F_CPU
126 #define MSP430_CPU_SPEED F_CPU
127 #else
128 #define MSP430_CPU_SPEED 2457600UL
129 #endif
130 
131 #define MSP430_REQUIRE_CPUON 0
132 #define MSP430_REQUIRE_LPM1 1
133 #define MSP430_REQUIRE_LPM2 2
134 #define MSP430_REQUIRE_LPM3 3
135 
136 void msp430_add_lpm_req(int req);
137 void msp430_remove_lpm_req(int req);
138 
139 #endif /* MSP430DEF_H */