Contiki 2.6

isr_compat.h

00001 /*
00002  * Copyright (c) 2005 Steve Underwood
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  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS `AS IS'' AND
00015  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00017  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00018  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00019  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00020  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00021  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00022  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00023  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00024  * SUCH DAMAGE.
00025  *
00026  */
00027 
00028 #ifndef _ISR_COMPAT_H_
00029 #define _ISR_COMPAT_H_
00030 
00031 /* Cross compiler interrupt service routine compatibility definitions */
00032 /* This code currently allows for:
00033         MSPGCC - the GNU tools for the MSP430
00034         Quadravox AQ430
00035         IAR Version 1 (old syntax)
00036         IAR Versions 2, 3, 4, 5 (new syntax)
00037         Rowley Crossworks
00038         Code Composer Essentials
00039 
00040    These macros allow us to define interrupt routines for all
00041    compilers with a common syntax:
00042 
00043     ISR(<interrupt>, <routine name>)
00044     {
00045     }
00046 
00047    e.g.
00048 
00049     ISR(ADC12, adc_service_routine)
00050     {
00051         ADC12CTL0 &= ~ENC;
00052         ADC12CTL0 |= ENC;
00053     }
00054 */
00055 
00056 /* 2012-03-02: minor update to support IAR version 4 and 5 */
00057 
00058 /* A tricky #define to stringify _Pragma parameters */
00059 #define __PRAGMA__(x) _Pragma(#x)
00060 
00061 #if defined(__GNUC__)  &&  defined(__MSP430__)
00062     /* This is the MSPGCC compiler */
00063 #define ISR(a,b) interrupt(a ## _VECTOR) b(void)
00064 #elif defined(__AQCOMPILER__)
00065     /* This is the Quadravox compiler */
00066 #define ISR(a,b) void _INTERRUPT[a ## _VECTOR] b(void)
00067 #elif defined(__IAR_SYSTEMS_ICC__)  &&  (((__TID__ >> 8) & 0x7f) == 43)  &&  (__VER__ < 200)
00068     /* This is V1.xx of the IAR compiler. */
00069 #define ISR(a,b) interrupt[a ## _VECTOR] void b(void)
00070 #elif defined(__IAR_SYSTEMS_ICC__)  &&  (((__TID__ >> 8) & 0x7f) == 43)  &&  (__VER__ < 600)
00071     /* This is V2.xx, V3.xx, V4.xx, V5.xx of the IAR compiler. */
00072 #define ISR(a,b) \
00073 __PRAGMA__(vector=a ##_VECTOR) \
00074 __interrupt void b(void)
00075 #elif defined(__CROSSWORKS_MSP430)
00076     /* This is the Rowley Crossworks compiler */
00077 #define ISR(a,b) void b __interrupt[a ## _VECTOR](void)
00078 #elif defined(__TI_COMPILER_VERSION__)
00079     /* This is the Code Composer Essentials compiler. */
00080 #define ISR(a,b) __interrupt void b(void); \
00081 a ## _ISR(b) \
00082 __interrupt void b(void)
00083 #else
00084     #error Compiler not recognised.
00085 #endif
00086 
00087 #endif