Contiki 2.6

msp430def.h

00001 /*
00002  * Copyright (c) 2007, Swedish Institute of Computer Science
00003  * All rights reserved. 
00004  *
00005  * Redistribution and use in source and binary forms, with or without 
00006  * modification, are permitted provided that the following conditions 
00007  * are met: 
00008  * 1. Redistributions of source code must retain the above copyright 
00009  *    notice, this list of conditions and the following disclaimer. 
00010  * 2. Redistributions in binary form must reproduce the above copyright 
00011  *    notice, this list of conditions and the following disclaimer in the 
00012  *    documentation and/or other materials provided with the distribution. 
00013  * 3. Neither the name of the Institute nor the names of its contributors 
00014  *    may be used to endorse or promote products derived from this software 
00015  *    without specific prior written permission. 
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
00027  * SUCH DAMAGE. 
00028  */
00029 
00030 #ifndef MSP430DEF_H
00031 #define MSP430DEF_H
00032 
00033 #ifdef __IAR_SYSTEMS_ICC__
00034 #include <intrinsics.h>
00035 #include <in430.h>
00036 #include <msp430.h>
00037 #define dint() __disable_interrupt()
00038 #define eint() __enable_interrupt()
00039 #define __MSP430__ 1
00040 #define CC_CONF_INLINE
00041 
00042 #else /* __IAR_SYSTEMS_ICC__ */
00043 
00044 #ifdef __MSPGCC__
00045 #include <msp430.h>
00046 #include <legacymsp430.h>
00047 #else /* __MSPGCC__ */
00048 #include <io.h>
00049 #include <signal.h>
00050 #if !defined(MSP430_MEMCPY_WORKAROUND) && (__GNUC__ < 4)
00051 #define MSP430_MEMCPY_WORKAROUND 1
00052 #endif
00053 #endif /* __MSPGCC__ */
00054 
00055 #define CC_CONF_INLINE inline
00056 
00057 #endif /* __IAR_SYSTEMS_ICC__ */
00058 
00059 #ifndef BV
00060 #define BV(x) (1 << x)
00061 #endif
00062 
00063 #ifdef HAVE_STDINT_H
00064 #include <stdint.h>
00065 #else
00066 #ifndef uint8_t
00067 typedef unsigned char   uint8_t;
00068 typedef unsigned short uint16_t;
00069 typedef unsigned long  uint32_t;
00070 typedef   signed char    int8_t;
00071 typedef          short  int16_t;
00072 typedef          long   int32_t;
00073 #endif
00074 #endif /* !HAVE_STDINT_H */
00075 
00076 /* These names are deprecated, use C99 names. */
00077 typedef  uint8_t    u8_t;
00078 typedef uint16_t   u16_t;
00079 typedef uint32_t   u32_t;
00080 typedef  int32_t   s32_t;
00081 
00082 /* default DCOSYNCH Period is 30 seconds */
00083 #ifdef DCOSYNCH_CONF_PERIOD
00084 #define DCOSYNCH_PERIOD DCOSYNCH_CONF_PERIOD
00085 #else
00086 #define DCOSYNCH_PERIOD 30
00087 #endif
00088 
00089 void msp430_cpu_init(void);     /* Rename to cpu_init() later! */
00090 void msp430_sync_dco(void);
00091 
00092 
00093 #define cpu_init() msp430_cpu_init()
00094 
00095 void   *sbrk(int);
00096 
00097 typedef int spl_t;
00098 /* void    splx_(spl_t); */
00099 spl_t   splhigh_(void);
00100 
00101 #define splhigh() splhigh_()
00102 #ifdef __IAR_SYSTEMS_ICC__
00103 #define splx(sr) __bis_SR_register(sr)
00104 #else
00105 #define splx(sr) __asm__ __volatile__("bis %0, r2" : : "r" (sr))
00106 #endif
00107 
00108 /* Workaround for bug in msp430-gcc compiler */
00109 #if defined(__MSP430__) && defined(__GNUC__) && MSP430_MEMCPY_WORKAROUND
00110 #ifndef memcpy
00111 #include <string.h>
00112 
00113 void *w_memcpy(void *out, const void *in, size_t n);
00114 #define memcpy(dest, src, count) w_memcpy(dest, src, count)
00115 
00116 void *w_memset(void *out, int value, size_t n);
00117 #define memset(dest, value, count) w_memset(dest, value, count)
00118 
00119 #endif /* memcpy */
00120 #endif /* __GNUC__ &&  __MSP430__ && MSP430_MEMCPY_WORKAROUND */
00121 
00122 
00123 /* Moved from the msp430.h file with other msp430 related defines */
00124 
00125 #ifdef F_CPU
00126 #define MSP430_CPU_SPEED F_CPU
00127 #else
00128 #define MSP430_CPU_SPEED 2457600UL
00129 #endif
00130 
00131 #define MSP430_REQUIRE_CPUON 0
00132 #define MSP430_REQUIRE_LPM1 1
00133 #define MSP430_REQUIRE_LPM2 2
00134 #define MSP430_REQUIRE_LPM3 3
00135 
00136 void msp430_add_lpm_req(int req);
00137 void msp430_remove_lpm_req(int req);
00138 
00139 #endif /* MSP430DEF_H */