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  * @(#)$Id: msp430def.h,v 1.5 2010/03/19 14:50:07 joxe Exp $
00030  */
00031 
00032 #ifndef MSP430DEF_H
00033 #define MSP430DEF_H
00034 
00035 #ifdef HAVE_STDINT_H
00036 #include <stdint.h>
00037 #else
00038 typedef unsigned char   uint8_t;
00039 typedef unsigned short uint16_t;
00040 typedef unsigned long  uint32_t;
00041 typedef   signed char    int8_t;
00042 typedef          short  int16_t;
00043 typedef          long   int32_t;
00044 #endif /* !HAVE_STDINT_H */
00045 
00046 /* These names are deprecated, use C99 names. */
00047 typedef  uint8_t    u8_t;
00048 typedef uint16_t   u16_t;
00049 typedef uint32_t   u32_t;
00050 typedef  int32_t   s32_t;
00051 
00052 /* default DCOSYNCH Period is 30 seconds */
00053 #ifdef DCOSYNCH_CONF_PERIOD
00054 #define DCOSYNCH_PERIOD DCOSYNCH_CONF_PERIOD
00055 #else
00056 #define DCOSYNCH_PERIOD 30
00057 #endif
00058 
00059 void msp430_cpu_init(void);     /* Rename to cpu_init() later! */
00060 void msp430_sync_dco(void);
00061 
00062 
00063 #define cpu_init() msp430_cpu_init()
00064 
00065 void   *sbrk(int);
00066 
00067 typedef int spl_t;
00068 void    splx_(spl_t);
00069 spl_t   splhigh_(void);
00070 
00071 #define splhigh() splhigh_()
00072 #ifdef __IAR_SYSTEMS_ICC__
00073 #define splx(sr) sr = __get_SR_register()
00074 #else
00075 #define splx(sr) __asm__ __volatile__("bis %0, r2" : : "r" (sr))
00076 #endif
00077 
00078 /* Workaround for bug in msp430-gcc compiler */
00079 #if defined(__MSP430__) && defined(__GNUC__) && MSP430_MEMCPY_WORKAROUND
00080 #ifndef memcpy
00081 #include <string.h>
00082 
00083 void *w_memcpy(void *out, const void *in, size_t n);
00084 #define memcpy(dest, src, count) w_memcpy(dest, src, count)
00085 
00086 /* #define memcpy(dest, src, count) do {                    \ */
00087 /*   if(count == 2) {                                       \ */
00088 /*     *((uint8_t *)dest) = *((uint8_t *)src);              \ */
00089 /*     *((uint8_t *)dest + 1) = *((uint8_t *)src + 1);      \ */
00090 /*   } else {                                               \ */
00091 /*     memcpy(dest, src, count);                            \ */
00092 /*   }                                                      \ */
00093 /* } while(0) */
00094 
00095 void *w_memset(void *out, int value, size_t n);
00096 #define memset(dest, value, count) w_memset(dest, value, count)
00097 
00098 /* #define memset(dest, value, count) do {                  \ */
00099 /*   if(count == 2) {                                       \ */
00100 /*     *((uint8_t *)dest) = (uint8_t)value;                 \ */
00101 /*     *((uint8_t *)dest + 1) = (uint8_t)value;             \ */
00102 /*   } else {                                               \ */
00103 /*     memset(dest, value, count);                          \ */
00104 /*   }                                                      \ */
00105 /* } while(0) */
00106 #endif /* memcpy */
00107 #endif /* __GNUC__ &&  __MSP430__ && MSP430_MEMCPY_WORKAROUND */
00108 
00109 #endif /* MSP430DEF_H */

Generated on Mon Apr 11 14:23:39 2011 for Contiki 2.5 by  doxygen 1.6.1