From 00931bdf9d09d60d68c91e4734f2a41de8ed27d0 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Thu, 15 Mar 2007 21:57:06 +0000 Subject: [PATCH] Moved to msp430/cpu/dev/ --- platform/esb/dev/irq.c | 183 ----------------------------------------- platform/esb/dev/irq.h | 44 ---------- 2 files changed, 227 deletions(-) delete mode 100644 platform/esb/dev/irq.c delete mode 100644 platform/esb/dev/irq.h diff --git a/platform/esb/dev/irq.c b/platform/esb/dev/irq.c deleted file mode 100644 index 721ebb2f4..000000000 --- a/platform/esb/dev/irq.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * 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. - * 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. - * - * This file is part of the Contiki operating system. - * - * @(#)$Id: irq.c,v 1.2 2006/08/30 07:45:56 nifi Exp $ - */ -#include "contiki-esb.h" -#include - -#define ADC12MCTL_NO(adcno) ((unsigned char *) ADC12MCTL0_)[adcno] - -static unsigned char adcflags; - -/*---------------------------------------------------------------------------*/ -interrupt(PORT1_VECTOR) - irq_p1(void) -{ - if(sensors_handle_irq(IRQ_PORT1)) { - LPM_AWAKE(); - } - P1IFG = 0x00; -} -/*---------------------------------------------------------------------------*/ -interrupt(PORT2_VECTOR) - irq_p2(void) -{ - if(sensors_handle_irq(IRQ_PORT2)) { - LPM_AWAKE(); - } - P2IFG = 0x00; -} -/*---------------------------------------------------------------------------*/ -interrupt (ADC_VECTOR) - irq_adc(void) -{ - if(sensors_handle_irq(IRQ_ADC)) { - LPM_AWAKE(); - } -} -/*---------------------------------------------------------------------------*/ -void -irq_init(void) -{ - adcflags = 0; - - /* Setup ADC12, ref., sampling time */ - ADC12CTL0 = REF2_5V | SHT0_10 | SHT1_10 | MSC; - - /* Use sampling timer, repeat-sequence-of-channels */ -/* ADC12CTL1 = SHP | CONSEQ_3 | ADC12DIV_3; */ - ADC12CTL1 = SHP | CONSEQ_3; -} -/*---------------------------------------------------------------------------*/ -/* Set lowest ADC to be start in sequence and highest to be interrupt - enabled and set end-of-sequence on the highest active ADC */ -static void -sethilo(void) -{ - int c; - - /* Clear start of sequence */ - ADC12CTL1 &= ~(CSTARTADD_15); - - /* Set new start of sequence to lowest active memory holder */ - for(c = 0; c < 8; c++) { - if(adcflags & (1 << c)) { - ADC12CTL1 |= (c * CSTARTADD_1); - break; - } - } - - /* Clear all interrupts and end-of-sequences */ - ADC12IE = 0; - for(c = 0; c < 8; c++) { - ADC12MCTL_NO(c) &= ~EOS; - } - - /* Set highest interrupt and end-of-sequence. This will generate one - interrupt for each sequence of conversions. */ - for(c = 0; c < 8; c++) { - if(adcflags & (128 >> c)) { - ADC12IE |= 128 >> c; - ADC12MCTL_NO(7 - c) |= EOS; - break; - } - } -} -/*---------------------------------------------------------------------------*/ -void -irq_adc12_activate(const struct sensors_sensor *sensor, - unsigned char adcno, unsigned char config) -{ - /* stop converting */ - ADC12CTL0 &= ~ENC; - /* wait for conversion to stop */ - while(ADC12CTL0 & ADC12BUSY); - ADC12CTL0 &= ~(ADC12ON | REFON); - ADC12IE = 0; - - /* clear any pending interrupts */ - ADC12IFG = 0; - - adcflags |= (1 << adcno); - - ADC12MCTL_NO(adcno) = config; - - sethilo(); - - ADC12CTL0 |= ADC12ON | REFON; - - sensors_add_irq(sensor, IRQ_ADC); - - /* Delay */ - clock_delay(20000); - - ADC12CTL0 |= ENC | ADC12SC; -} -/*---------------------------------------------------------------------------*/ -void -irq_adc12_deactivate(const struct sensors_sensor *sensor, unsigned char adcno) -{ - /* stop converting */ - ADC12CTL0 &= ~ENC; - /* wait for conversion to stop */ - while(ADC12CTL0 & ADC12BUSY); - ADC12CTL0 &= ~(ADC12ON | REFON); - ADC12IE = 0; - - /* clear any pending interrupts */ - ADC12IFG = 0; - - adcflags &= ~(1 << adcno); - - ADC12MCTL_NO(adcno) = 0; - - sethilo(); - - sensors_remove_irq(sensor, IRQ_ADC); - - if(adcflags) { - /* Turn on the ADC12 */ - ADC12CTL0 |= (ADC12ON | REFON); - - /* Delay */ - clock_delay(20000); - - /* Still active. Turn on the conversion. */ - ADC12CTL0 |= ENC | ADC12SC; - } -} -/*---------------------------------------------------------------------------*/ -int -irq_adc12_active(unsigned char adcno) -{ - return adcflags & (1 << adcno) ? 1 : 0; -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/esb/dev/irq.h b/platform/esb/dev/irq.h deleted file mode 100644 index efa46e1d3..000000000 --- a/platform/esb/dev/irq.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * 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. - * 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. - * - * This file is part of the Contiki operating system. - * - * @(#)$Id: irq.h,v 1.1 2006/06/18 07:49:33 adamdunkels Exp $ - */ -#ifndef __IRQ_H__ -#define __IRQ_H__ - -void irq_adc12_activate(const struct sensors_sensor *sensor, - unsigned char adcno, unsigned char config); - -void irq_adc12_deactivate(const struct sensors_sensor *sensor, - unsigned char adcno); - -int irq_adc12_active(unsigned char adcno); - -#endif /* __IRQ_H__ */