Cross compiler interrupt service routine compatibility definitions for MSP430 based platforms based on isr_compat.h by Steve Underwood.

This commit is contained in:
Niclas Finne 2012-03-07 01:14:54 +01:00
parent 7eac4393c2
commit 684c3edfa6
31 changed files with 157 additions and 182 deletions

View file

@ -31,6 +31,7 @@
#include "contiki.h"
#include "dev/button.h"
#include "isr_compat.h"
#define BUTTON_PORT 2
#define BUTTON_PIN 7
@ -57,8 +58,7 @@ button_init(struct process *proc)
P2IE &= ~BV(BUTTON_PIN);
}
interrupt(PORT2_VECTOR)
__button_interrupt(void)
ISR(PORT2, __button_interrupt)
{
static struct timer debouncetimer;

View file

@ -32,6 +32,7 @@
#include "contiki.h"
#include "dev/spi.h"
#include "dev/cc2420.h"
#include "isr_compat.h"
extern volatile uint8_t cc2420_sfd_counter;
extern volatile uint16_t cc2420_sfd_start_time;
@ -39,13 +40,7 @@ extern volatile uint16_t cc2420_sfd_end_time;
/*---------------------------------------------------------------------------*/
/* SFD interrupt for timestamping radio packets */
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=TIMERB1_VECTOR
__interrupt void
#else
interrupt(TIMERB1_VECTOR)
#endif
cc24240_timerb1_interrupt(void)
ISR(TIMERB1, cc2420_timerb1_interrupt)
{
int tbiv;
ENERGEST_ON(ENERGEST_TYPE_IRQ);

View file

@ -34,6 +34,7 @@
#include "dev/spi.h"
#include "dev/cc2420.h"
#include "isr_compat.h"
#ifdef CC2420_CONF_SFD_TIMESTAMPS
#define CONF_SFD_TIMESTAMPS CC2420_CONF_SFD_TIMESTAMPS
@ -48,14 +49,7 @@
#endif
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=CC2420_IRQ_VECTOR
__interrupt void
#else
interrupt(CC2420_IRQ_VECTOR)
#endif
cc24240_port1_interrupt(void)
ISR(CC2420_IRQ, cc2420_port1_interrupt)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);
@ -65,7 +59,6 @@ cc24240_port1_interrupt(void)
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
/*---------------------------------------------------------------------------*/
void
cc2420_arch_init(void)

View file

@ -30,6 +30,7 @@
#include "contiki.h"
#include "dev/spi.h"
#include "dev/cc2520.h"
#include "isr_compat.h"
extern volatile uint8_t cc2520_sfd_counter;
extern volatile uint16_t cc2520_sfd_start_time;
@ -37,13 +38,7 @@ extern volatile uint16_t cc2520_sfd_end_time;
/*---------------------------------------------------------------------------*/
/* SFD interrupt for timestamping radio packets */
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=TIMERB1_VECTOR
__interrupt void
#else
interrupt(TIMERB1_VECTOR)
#endif
cc2520_timerb1_interrupt(void)
ISR(TIMERB1, cc2520_timerb1_interrupt)
{
int tbiv;
ENERGEST_ON(ENERGEST_TYPE_IRQ);

View file

@ -32,6 +32,7 @@
#include "dev/spi.h"
#include "dev/cc2520.h"
#include "isr_compat.h"
#ifdef CC2520_CONF_SFD_TIMESTAMPS
#define CONF_SFD_TIMESTAMPS CC2520_CONF_SFD_TIMESTAMPS
@ -46,13 +47,7 @@
#endif
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=CC2520_IRQ_VECTOR
__interrupt void
#else
interrupt(CC2520_IRQ_VECTOR)
#endif
cc2520_port1_interrupt(void)
ISR(CC2520_IRQ, cc2520_port1_interrupt)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);

View file

@ -35,6 +35,7 @@
#include "sys/etimer.h"
#include "rtimer-arch.h"
#include "dev/watchdog.h"
#include "isr_compat.h"
#define INTERVAL (RTIMER_ARCH_SECOND / CLOCK_SECOND)
@ -46,13 +47,7 @@ static volatile clock_time_t count = 0;
/* last_tar is used for calculating clock_fine */
static volatile uint16_t last_tar = 0;
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=TIMERA1_VECTOR
__interrupt void
#else
interrupt(TIMERA1_VECTOR)
#endif
timera1 (void)
ISR(TIMERA1, timera1)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);

View file

@ -44,6 +44,7 @@
#include "sys/rtimer.h"
#include "sys/process.h"
#include "dev/watchdog.h"
#include "isr_compat.h"
#define DEBUG 0
#if DEBUG
@ -54,13 +55,7 @@
#endif
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=TIMERA0_VECTOR
__interrupt void
#else
interrupt(TIMERA0_VECTOR)
#endif
timera0 (void)
ISR(TIMERA0, timera0)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);

View file

@ -39,6 +39,7 @@
#include "dev/watchdog.h"
#include "sys/ctimer.h"
#include "lib/ringbuf.h"
#include "isr_compat.h"
static int (*uart1_input_handler)(unsigned char c);
static volatile uint8_t rx_in_progress;
@ -236,13 +237,7 @@ uart1_init(unsigned long ubr)
}
/*---------------------------------------------------------------------------*/
#if !RX_WITH_DMA
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=UART1RX_VECTOR
__interrupt void
#else
interrupt(UART1RX_VECTOR)
#endif
uart1_rx_interrupt(void)
ISR(UART1RX, uart1_rx_interrupt)
{
uint8_t c;
ENERGEST_ON(ENERGEST_TYPE_IRQ);
@ -273,13 +268,7 @@ uart1_rx_interrupt(void)
#endif /* !RX_WITH_DMA */
/*---------------------------------------------------------------------------*/
#if TX_WITH_INTERRUPT
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=UART1TX_VECTOR
__interrupt void
#else
interrupt(UART1TX_VECTOR)
#endif
uart1_tx_interrupt(void)
ISR(UART1TX, uart1_tx_interrupt)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);

View file

@ -41,6 +41,7 @@
#include "dev/watchdog.h"
#include "lib/ringbuf.h"
#include "dev/leds.h"
#include "isr_compat.h"
static int (*uart0_input_handler)(unsigned char c);
@ -138,14 +139,7 @@ uart0_init(unsigned long ubr)
#endif /* TX_WITH_INTERRUPT */
}
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=USCIAB0RX_VECTOR
__interrupt void
#else
interrupt(USCIAB0RX_VECTOR)
#endif
uart0_rx_interrupt(void)
ISR(USCIAB0RX, uart0_rx_interrupt)
{
uint8_t c;
@ -165,13 +159,7 @@ uart0_rx_interrupt(void)
}
/*---------------------------------------------------------------------------*/
#if TX_WITH_INTERRUPT
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=USCIAB0TX_VECTOR
__interrupt void
#else
interrupt(USCIAB0TX_VECTOR)
#endif
uart0_tx_interrupt(void)
ISR(USCIAB0TX, uart0_tx_interrupt)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if((IFG2 & UCA0TXIFG)){

View file

@ -37,8 +37,8 @@
#include "sys/energest.h"
#include "dev/uart1.h"
#include "dev/watchdog.h"
#include "lib/ringbuf.h"
#include "isr_compat.h"
static int (*uart1_input_handler)(unsigned char c);
@ -120,8 +120,7 @@ uart1_init(unsigned long ubr)
}
/*---------------------------------------------------------------------------*/
interrupt(USCIAB1RX_VECTOR)
uart1_rx_interrupt(void)
ISR(USCIAB1RX, uart1_rx_interrupt)
{
uint8_t c;
ENERGEST_ON(ENERGEST_TYPE_IRQ);
@ -141,8 +140,7 @@ uart1_rx_interrupt(void)
}
/*---------------------------------------------------------------------------*/
#if TX_WITH_INTERRUPT
interrupt(USCIAB1TX_VECTOR)
uart1_tx_interrupt(void)
ISR(USCIAB1TX, uart1_tx_interrupt)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if(IFG2 & UCA0TXIFG) {

View file

@ -35,6 +35,7 @@
#include "sys/etimer.h"
#include "rtimer-arch.h"
#include "dev/watchdog.h"
#include "isr_compat.h"
#define INTERVAL (RTIMER_ARCH_SECOND / CLOCK_SECOND)
@ -46,13 +47,7 @@ static volatile clock_time_t count = 0;
/* last_tar is used for calculating clock_fine, last_ccr might be better? */
static volatile uint16_t last_tar = 0;
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=TIMER1_A1_VECTOR
__interrupt void
#else
interrupt(TIMER1_A1_VECTOR)
#endif
timera1 (void)
ISR(TIMER1_A1, timera1)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);

View file

@ -41,6 +41,7 @@
#include "sys/rtimer.h"
#include "sys/process.h"
#include "dev/watchdog.h"
#include "isr_compat.h"
#define DEBUG 0
#if DEBUG
@ -51,13 +52,7 @@
#endif
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=TIMER1_A0_VECTOR
__interrupt void
#else
interrupt(TIMER1_A0_VECTOR)
#endif
timera0 (void)
ISR(TIMER1_A0, timera0)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);

View file

@ -38,6 +38,7 @@
#include "sys/energest.h"
#include "dev/uart0.h"
#include "dev/watchdog.h"
#include "isr_compat.h"
static int (*uart0_input_handler)(unsigned char c);
@ -98,18 +99,12 @@ uart0_init(unsigned long ubr)
UCA0IE |= UCRXIE; /* Enable UCA0 RX interrupt */
}
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=USCI_A0_VECTOR
__interrupt void
#else
interrupt(USCI_A0_VECTOR)
#endif
uart0_rx_interrupt(void)
ISR(USCI_A0, uart0_rx_interrupt)
{
uint8_t c;
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if (UCA0IV == 2) {
if(UCA0IV == 2) {
if(UCA0STAT & UCRXERR) {
c = UCA0RXBUF; /* Clear error flags by forcing a dummy read. */
} else {

View file

@ -38,6 +38,7 @@
#include "sys/energest.h"
#include "dev/uart1.h"
#include "dev/watchdog.h"
#include "isr_compat.h"
static int (*uart1_input_handler)(unsigned char c);
@ -103,13 +104,7 @@ uart1_init(unsigned long ubr)
UCA1IE |= UCRXIE; /* Enable UCA1 RX interrupt */
}
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=USCI_A1_VECTOR
__interrupt void
#else
interrupt(USCI_A1_VECTOR)
#endif
uart1_rx_interrupt(void)
ISR(USCI_A1, uart1_rx_interrupt)
{
uint8_t c;

87
cpu/msp430/isr_compat.h Normal file
View file

@ -0,0 +1,87 @@
/*
* Copyright (c) 2005 Steve Underwood
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS `AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef _ISR_COMPAT_H_
#define _ISR_COMPAT_H_
/* Cross compiler interrupt service routine compatibility definitions */
/* This code currently allows for:
MSPGCC - the GNU tools for the MSP430
Quadravox AQ430
IAR Version 1 (old syntax)
IAR Versions 2, 3, 4, 5 (new syntax)
Rowley Crossworks
Code Composer Essentials
These macros allow us to define interrupt routines for all
compilers with a common syntax:
ISR(<interrupt>, <routine name>)
{
}
e.g.
ISR(ADC12, adc_service_routine)
{
ADC12CTL0 &= ~ENC;
ADC12CTL0 |= ENC;
}
*/
/* 2012-03-02: minor update to support IAR version 4 and 5 */
/* A tricky #define to stringify _Pragma parameters */
#define __PRAGMA__(x) _Pragma(#x)
#if defined(__GNUC__) && defined(__MSP430__)
/* This is the MSPGCC compiler */
#define ISR(a,b) interrupt(a ## _VECTOR) b(void)
#elif defined(__AQCOMPILER__)
/* This is the Quadravox compiler */
#define ISR(a,b) void _INTERRUPT[a ## _VECTOR] b(void)
#elif defined(__IAR_SYSTEMS_ICC__) && (((__TID__ >> 8) & 0x7f) == 43) && (__VER__ < 200)
/* This is V1.xx of the IAR compiler. */
#define ISR(a,b) interrupt[a ## _VECTOR] void b(void)
#elif defined(__IAR_SYSTEMS_ICC__) && (((__TID__ >> 8) & 0x7f) == 43) && (__VER__ < 600)
/* This is V2.xx, V3.xx, V4.xx, V5.xx of the IAR compiler. */
#define ISR(a,b) \
__PRAGMA__(vector=a ##_VECTOR) \
__interrupt void b(void)
#elif defined(__CROSSWORKS_MSP430)
/* This is the Rowley Crossworks compiler */
#define ISR(a,b) void b __interrupt[a ## _VECTOR](void)
#elif defined(__TI_COMPILER_VERSION__)
/* This is the Code Composer Essentials compiler. */
#define ISR(a,b) __interrupt void b(void); \
a ## _ISR(b) \
__interrupt void b(void)
#else
#error Compiler not recognised.
#endif
#endif

View file

@ -33,6 +33,7 @@
#include "contiki.h"
#include "dev/watchdog.h"
#include "isr_compat.h"
static int counter = 0;
@ -70,13 +71,7 @@ printstring(char *s)
#endif /* CONTIKI_TARGET_SKY */
#endif /* PRINT_STACK_ON_REBOOT */
/*---------------------------------------------------------------------------*/
#ifdef __IAR_SYSTEMS_ICC__
#pragma vector=WDT_VECTOR
__interrupt void
#else
interrupt(WDT_VECTOR)
#endif
watchdog_interrupt(void)
ISR(WDT, watchdog_interrupt)
{
#ifdef CONTIKI_TARGET_SKY
#if PRINT_STACK_ON_REBOOT