From: klueska Date: Thu, 17 Apr 2008 22:38:34 +0000 (+0000) Subject: Update to centralize inside one module where all interrupt handlers are signaled... X-Git-Tag: release_tinyos_2_1_0_0~465 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=26d7f5a6239a0f8fbb76588b3562654823acd43f Update to centralize inside one module where all interrupt handlers are signaled from --- diff --git a/tos/chips/msp430/adc12/HplAdc12P.nc b/tos/chips/msp430/adc12/HplAdc12P.nc index aaee9ce5..6243739d 100644 --- a/tos/chips/msp430/adc12/HplAdc12P.nc +++ b/tos/chips/msp430/adc12/HplAdc12P.nc @@ -44,6 +44,7 @@ module HplAdc12P { provides interface HplAdc12; + uses interface HplMsp430InterruptSig as SIGNAL_ADC_VECTOR; } implementation { @@ -118,7 +119,7 @@ implementation async command bool HplAdc12.isBusy(){ return ADC12CTL1 & ADC12BUSY; } - TOSH_SIGNAL(ADC_VECTOR) { + inline async event void SIGNAL_ADC_VECTOR.fired() { signal HplAdc12.conversionDone(ADC12IV); } } diff --git a/tos/chips/msp430/adc12/Msp430Adc12P.nc b/tos/chips/msp430/adc12/Msp430Adc12P.nc index e662eea5..bd3c9465 100644 --- a/tos/chips/msp430/adc12/Msp430Adc12P.nc +++ b/tos/chips/msp430/adc12/Msp430Adc12P.nc @@ -77,5 +77,8 @@ configuration Msp430Adc12P Msp430Adc12ImplP.CompareA0 -> Msp430TimerC.CompareA0; Msp430Adc12ImplP.CompareA1 -> Msp430TimerC.CompareA1; #endif + + components HplMsp430InterruptSigP; + HplAdc12P.SIGNAL_ADC_VECTOR -> HplMsp430InterruptSigP.SIGNAL_ADC_VECTOR; } diff --git a/tos/chips/msp430/dma/HplMsp430DmaC.nc b/tos/chips/msp430/dma/HplMsp430DmaC.nc index 259d81a9..b6869f16 100644 --- a/tos/chips/msp430/dma/HplMsp430DmaC.nc +++ b/tos/chips/msp430/dma/HplMsp430DmaC.nc @@ -85,6 +85,9 @@ implementation { Dma0.Interrupt -> HplMsp430DmaP; Dma1.Interrupt -> HplMsp430DmaP; Dma2.Interrupt -> HplMsp430DmaP; + + components HplMsp430InterruptSigP; + HplMsp430DmaP.SIGNAL_DACDMA_VECTOR -> HplMsp430InterruptSigP.SIGNAL_DACDMA_VECTOR; } diff --git a/tos/chips/msp430/dma/HplMsp430DmaP.nc b/tos/chips/msp430/dma/HplMsp430DmaP.nc index 6b581606..4d8a6b6f 100644 --- a/tos/chips/msp430/dma/HplMsp430DmaP.nc +++ b/tos/chips/msp430/dma/HplMsp430DmaP.nc @@ -61,7 +61,7 @@ module HplMsp430DmaP { provides interface HplMsp430DmaControl as DmaControl; provides interface HplMsp430DmaInterrupt as Interrupt; - + uses interface HplMsp430InterruptSig as SIGNAL_DACDMA_VECTOR; } implementation { @@ -69,7 +69,7 @@ implementation { MSP430REG_NORACE( DMACTL0 ); MSP430REG_NORACE( DMACTL1 ); - TOSH_SIGNAL( DACDMA_VECTOR ) { + inline async event void SIGNAL_DACDMA_VECTOR.fired { signal Interrupt.fired(); } diff --git a/tos/chips/msp430/pins/HplMsp430InterruptC.nc b/tos/chips/msp430/pins/HplMsp430InterruptC.nc index 50ec746a..3cb8163e 100644 --- a/tos/chips/msp430/pins/HplMsp430InterruptC.nc +++ b/tos/chips/msp430/pins/HplMsp430InterruptC.nc @@ -51,6 +51,7 @@ configuration HplMsp430InterruptC implementation { components HplMsp430InterruptP as HplInterruptP; + components HplMsp430InterruptSigP; #ifdef __msp430_have_port1 Port10 = HplInterruptP.Port10; Port11 = HplInterruptP.Port11; @@ -60,6 +61,7 @@ implementation Port15 = HplInterruptP.Port15; Port16 = HplInterruptP.Port16; Port17 = HplInterruptP.Port17; + HplInterruptP.SIGNAL_PORT1_VECTOR -> HplMsp430InterruptSigP.SIGNAL_PORT1_VECTOR; #endif #ifdef __msp430_have_port2 Port20 = HplInterruptP.Port20; @@ -70,5 +72,6 @@ implementation Port25 = HplInterruptP.Port25; Port26 = HplInterruptP.Port26; Port27 = HplInterruptP.Port27; + HplInterruptP.SIGNAL_PORT2_VECTOR -> HplMsp430InterruptSigP.SIGNAL_PORT2_VECTOR; #endif } diff --git a/tos/chips/msp430/pins/HplMsp430InterruptNMIC.nc b/tos/chips/msp430/pins/HplMsp430InterruptNMIC.nc index 0acdbbb0..b4d71b6b 100644 --- a/tos/chips/msp430/pins/HplMsp430InterruptNMIC.nc +++ b/tos/chips/msp430/pins/HplMsp430InterruptNMIC.nc @@ -38,4 +38,7 @@ implementation NMI = HplInterruptP.NMI; OF = HplInterruptP.OF; ACCV = HplInterruptP.ACCV; + + components HplMsp430InterruptSigP; + HplInterruptP.SIGNAL_NMI_VECTOR -> HplMsp430InterruptSigP.SIGNAL_NMI_VECTOR; } diff --git a/tos/chips/msp430/pins/HplMsp430InterruptNMIP.nc b/tos/chips/msp430/pins/HplMsp430InterruptNMIP.nc index 1942ff24..97b945b2 100644 --- a/tos/chips/msp430/pins/HplMsp430InterruptNMIP.nc +++ b/tos/chips/msp430/pins/HplMsp430InterruptNMIP.nc @@ -27,10 +27,11 @@ module HplMsp430InterruptNMIP provides interface HplMsp430Interrupt as NMI; provides interface HplMsp430Interrupt as OF; provides interface HplMsp430Interrupt as ACCV; + uses interface HplMsp430InterruptSig as SIGNAL_NMI_VECTOR; } implementation { - TOSH_SIGNAL(NMI_VECTOR) + inline async event void SIGNAL_NMI_VECTOR.fired() { volatile int n = IFG1; if (n & NMIIFG) { signal NMI.fired(); return; } diff --git a/tos/chips/msp430/pins/HplMsp430InterruptP.nc b/tos/chips/msp430/pins/HplMsp430InterruptP.nc index 9b1b1f21..4c8d8990 100644 --- a/tos/chips/msp430/pins/HplMsp430InterruptP.nc +++ b/tos/chips/msp430/pins/HplMsp430InterruptP.nc @@ -33,6 +33,7 @@ module HplMsp430InterruptP provides interface HplMsp430Interrupt as Port15; provides interface HplMsp430Interrupt as Port16; provides interface HplMsp430Interrupt as Port17; + uses interface HplMsp430InterruptSig as SIGNAL_PORT1_VECTOR; #endif #ifdef __msp430_have_port2 provides interface HplMsp430Interrupt as Port20; @@ -43,6 +44,7 @@ module HplMsp430InterruptP provides interface HplMsp430Interrupt as Port25; provides interface HplMsp430Interrupt as Port26; provides interface HplMsp430Interrupt as Port27; + uses interface HplMsp430InterruptSig as SIGNAL_PORT2_VECTOR; #endif } @@ -50,7 +52,7 @@ implementation { #ifdef __msp430_have_port1 - TOSH_SIGNAL(PORT1_VECTOR) + inline async event void SIGNAL_PORT1_VECTOR.fired() { volatile int n = P1IFG & P1IE; @@ -155,7 +157,7 @@ implementation #endif #ifdef __msp430_have_port2 - TOSH_SIGNAL(PORT2_VECTOR) + inline async event void SIGNAL_PORT2_VECTOR.fired() { volatile int n = P2IFG & P2IE; diff --git a/tos/chips/msp430/pins/HplMsp430InterruptSig.nc b/tos/chips/msp430/pins/HplMsp430InterruptSig.nc new file mode 100644 index 00000000..e9c29fb2 --- /dev/null +++ b/tos/chips/msp430/pins/HplMsp430InterruptSig.nc @@ -0,0 +1,44 @@ +/// $Id$ + +/* + * Copyright (c) 2004-2005 Crossbow Technology, Inc. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written + * agreement is hereby granted, provided that the above copyright + * notice, the (updated) modification history and the author appear in + * all copies of this source code. + * + * Permission is also granted to distribute this software under the + * standard BSD license as contained in the TinyOS distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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. + */ + +/** + * Interface to an Msp430 external interrupt pin that exposes just the + * interrupt vector routine for easy linking to generic components (see + * Msp430InterruptSigP for the full interface). + * + * @author Martin Turon + * @author Kevin Klues + * @see Msp430InterruptSigP + */ +interface HplMsp430InterruptSig +{ + /** + * Signalled when an interrupt occurs on a pin + */ + inline async event void fired(); +} + diff --git a/tos/chips/msp430/pins/HplMsp430InterruptSigP.nc b/tos/chips/msp430/pins/HplMsp430InterruptSigP.nc new file mode 100644 index 00000000..408ab9bd --- /dev/null +++ b/tos/chips/msp430/pins/HplMsp430InterruptSigP.nc @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2008 Stanford University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. + */ + +/** + * @author Kevin Klues + */ + +module HplMsp430InterruptSigP +{ + provides { + interface HplMsp430InterruptSig as SIGNAL_ADC_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_DACDMA_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_NMI_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_PORT1_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_PORT2_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_TIMERA0_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_TIMERA1_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_TIMERB0_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_TIMERB1_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_UART0RX_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_UART0TX_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_UART1RX_VECTOR; + interface HplMsp430InterruptSig as SIGNAL_UART1TX_VECTOR; + } +} +implementation { + #define MSP430_INTERRUPT_HANDLER(NAME) \ + default async event void SIGNAL_##NAME.fired() {} \ + TOSH_SIGNAL(NAME) { \ + signal SIGNAL_##NAME.fired(); \ + } + + MSP430_INTERRUPT_HANDLER(ADC_VECTOR) + MSP430_INTERRUPT_HANDLER(DACDMA_VECTOR) + MSP430_INTERRUPT_HANDLER(NMI_VECTOR) + MSP430_INTERRUPT_HANDLER(PORT1_VECTOR) + MSP430_INTERRUPT_HANDLER(PORT2_VECTOR) + MSP430_INTERRUPT_HANDLER(TIMERA0_VECTOR) + MSP430_INTERRUPT_HANDLER(TIMERA1_VECTOR) + MSP430_INTERRUPT_HANDLER(TIMERB0_VECTOR) + MSP430_INTERRUPT_HANDLER(TIMERB1_VECTOR) + MSP430_INTERRUPT_HANDLER(UART0RX_VECTOR) + MSP430_INTERRUPT_HANDLER(UART0TX_VECTOR) + MSP430_INTERRUPT_HANDLER(UART1RX_VECTOR) + MSP430_INTERRUPT_HANDLER(UART1TX_VECTOR) +} diff --git a/tos/chips/msp430/timer/Msp430TimerC.nc b/tos/chips/msp430/timer/Msp430TimerC.nc index 65b23cd8..e1d6a23f 100644 --- a/tos/chips/msp430/timer/Msp430TimerC.nc +++ b/tos/chips/msp430/timer/Msp430TimerC.nc @@ -159,5 +159,11 @@ implementation CaptureB6 = Msp430TimerB6.Capture; Msp430TimerB6.Timer -> Msp430TimerB.Timer; Msp430TimerB6.Event -> Msp430TimerB.Event[6]; + + components HplMsp430InterruptSigP; + Common.SIGNAL_TIMERA0_VECTOR -> HplMsp430InterruptSigP.SIGNAL_TIMERA0_VECTOR; + Common.SIGNAL_TIMERA1_VECTOR -> HplMsp430InterruptSigP.SIGNAL_TIMERA1_VECTOR; + Common.SIGNAL_TIMERB0_VECTOR -> HplMsp430InterruptSigP.SIGNAL_TIMERB0_VECTOR; + Common.SIGNAL_TIMERB1_VECTOR -> HplMsp430InterruptSigP.SIGNAL_TIMERB1_VECTOR; } diff --git a/tos/chips/msp430/timer/Msp430TimerCommonP.nc b/tos/chips/msp430/timer/Msp430TimerCommonP.nc index 64c27704..707ca7db 100644 --- a/tos/chips/msp430/timer/Msp430TimerCommonP.nc +++ b/tos/chips/msp430/timer/Msp430TimerCommonP.nc @@ -1,16 +1,44 @@ +/* "Copyright (c) 2000-2003 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement + * is hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY + * OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + */ + +/** + * @author Cory Sharp + */ + module Msp430TimerCommonP { provides interface Msp430TimerEvent as VectorTimerA0; provides interface Msp430TimerEvent as VectorTimerA1; provides interface Msp430TimerEvent as VectorTimerB0; provides interface Msp430TimerEvent as VectorTimerB1; + uses interface HplMsp430InterruptSig as SIGNAL_TIMERA0_VECTOR; + uses interface HplMsp430InterruptSig as SIGNAL_TIMERA1_VECTOR; + uses interface HplMsp430InterruptSig as SIGNAL_TIMERB0_VECTOR; + uses interface HplMsp430InterruptSig as SIGNAL_TIMERB1_VECTOR; } implementation { - TOSH_SIGNAL(TIMERA0_VECTOR) { signal VectorTimerA0.fired(); } - TOSH_SIGNAL(TIMERA1_VECTOR) { signal VectorTimerA1.fired(); } - TOSH_SIGNAL(TIMERB0_VECTOR) { signal VectorTimerB0.fired(); } - TOSH_SIGNAL(TIMERB1_VECTOR) { signal VectorTimerB1.fired(); } + inline async event void SIGNAL_TIMERA0_VECTOR.fired() { signal VectorTimerA0.fired(); } + inline async event void SIGNAL_TIMERA1_VECTOR.fired() { signal VectorTimerA1.fired(); } + inline async event void SIGNAL_TIMERB0_VECTOR.fired() { signal VectorTimerB0.fired(); } + inline async event void SIGNAL_TIMERB1_VECTOR.fired() { signal VectorTimerB1.fired(); } } diff --git a/tos/chips/msp430/usart/HplMsp430Usart0C.nc b/tos/chips/msp430/usart/HplMsp430Usart0C.nc index c1060df2..8c87accc 100644 --- a/tos/chips/msp430/usart/HplMsp430Usart0C.nc +++ b/tos/chips/msp430/usart/HplMsp430Usart0C.nc @@ -85,4 +85,7 @@ implementation { HplUsartP.URXD -> GIO.URXD0; HplUsartP.UTXD -> GIO.UTXD0; + components HplMsp430InterruptSigP; + HplUsartP.SIGNAL_UART0RX_VECTOR -> HplMsp430InterruptSigP.SIGNAL_UART0RX_VECTOR; + HplUsartP.SIGNAL_UART0TX_VECTOR -> HplMsp430InterruptSigP.SIGNAL_UART0TX_VECTOR; } diff --git a/tos/chips/msp430/usart/HplMsp430Usart0P.nc b/tos/chips/msp430/usart/HplMsp430Usart0P.nc index cf618bfb..228e2b14 100644 --- a/tos/chips/msp430/usart/HplMsp430Usart0P.nc +++ b/tos/chips/msp430/usart/HplMsp430Usart0P.nc @@ -82,6 +82,8 @@ module HplMsp430Usart0P { uses interface HplMsp430GeneralIO as UCLK; uses interface HplMsp430GeneralIO as URXD; uses interface HplMsp430GeneralIO as UTXD; + uses interface HplMsp430InterruptSig as SIGNAL_UART0RX_VECTOR; + uses interface HplMsp430InterruptSig as SIGNAL_UART0TX_VECTOR; } implementation @@ -93,12 +95,12 @@ implementation MSP430REG_NORACE(U0RCTL); MSP430REG_NORACE(U0TXBUF); - TOSH_SIGNAL(UART0RX_VECTOR) { + inline async event void SIGNAL_UART0RX_VECTOR.fired() { uint8_t temp = U0RXBUF; signal Interrupts.rxDone(temp); } - TOSH_SIGNAL(UART0TX_VECTOR) { + inline async event void SIGNAL_UART0TX_VECTOR.fired() { if ( call HplI2C.isI2C() ) signal I2CInterrupts.fired(); else diff --git a/tos/chips/msp430/usart/HplMsp430Usart1C.nc b/tos/chips/msp430/usart/HplMsp430Usart1C.nc index 78b93232..aefd47f7 100644 --- a/tos/chips/msp430/usart/HplMsp430Usart1C.nc +++ b/tos/chips/msp430/usart/HplMsp430Usart1C.nc @@ -85,5 +85,8 @@ implementation { HplUsartP.UCLK -> GIO.UCLK1; HplUsartP.URXD -> GIO.URXD1; HplUsartP.UTXD -> GIO.UTXD1; - + + components HplMsp430InterruptSigP; + HplUsartP.SIGNAL_UART1RX_VECTOR -> HplMsp430InterruptSigP.SIGNAL_UART1RX_VECTOR; + HplUsartP.SIGNAL_UART1TX_VECTOR -> HplMsp430InterruptSigP.SIGNAL_UART1TX_VECTOR; } diff --git a/tos/chips/msp430/usart/HplMsp430Usart1P.nc b/tos/chips/msp430/usart/HplMsp430Usart1P.nc index d5a8a268..d35e9f50 100644 --- a/tos/chips/msp430/usart/HplMsp430Usart1P.nc +++ b/tos/chips/msp430/usart/HplMsp430Usart1P.nc @@ -80,6 +80,8 @@ module HplMsp430Usart1P { uses interface HplMsp430GeneralIO as UCLK; uses interface HplMsp430GeneralIO as URXD; uses interface HplMsp430GeneralIO as UTXD; + uses interface HplMsp430InterruptSig as SIGNAL_UART1RX_VECTOR; + uses interface HplMsp430InterruptSig as SIGNAL_UART1TX_VECTOR; } implementation @@ -91,14 +93,12 @@ implementation MSP430REG_NORACE(U1RCTL); MSP430REG_NORACE(U1TXBUF); - - - TOSH_SIGNAL(UART1RX_VECTOR) { + inline async event void SIGNAL_UART1RX_VECTOR.fired() { uint8_t temp = U1RXBUF; signal Interrupts.rxDone(temp); } - TOSH_SIGNAL(UART1TX_VECTOR) { + inline async event void SIGNAL_UART1TX_VECTOR.fired() { signal Interrupts.txDone(); }