]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
nativ tos PrintF support, demosensors based on accelerometer, better low power
authorr-studio <r-studio>
Thu, 5 Nov 2009 12:02:07 +0000 (12:02 +0000)
committerr-studio <r-studio>
Thu, 5 Nov 2009 12:02:07 +0000 (12:02 +0000)
12 files changed:
tos/chips/m16c62p/pins/HplM16c62pGeneralIOPinPRC2P.nc [new file with mode: 0755]
tos/lib/net/Deluge/extra/m16c62p/HplM16c62pFlashC.nc
tos/lib/printf/PrintfP.nc
tos/platforms/mulle/.platform
tos/platforms/mulle/DemoSensorC.nc
tos/platforms/mulle/DemoSensorNowC.nc [new file with mode: 0644]
tos/platforms/mulle/DemoSensorP.nc [new file with mode: 0644]
tos/platforms/mulle/DemoSensorStreamC.nc [new file with mode: 0644]
tos/platforms/mulle/PlatformP.nc
tos/platforms/mulle/PlatformSerialC.nc
tos/platforms/mulle/PlatformSerialP.nc [new file with mode: 0644]
tos/platforms/mulle/timers/AlarmMicro16C.nc

diff --git a/tos/chips/m16c62p/pins/HplM16c62pGeneralIOPinPRC2P.nc b/tos/chips/m16c62p/pins/HplM16c62pGeneralIOPinPRC2P.nc
new file mode 100755 (executable)
index 0000000..bea643e
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2009 Communication Group and Eislab at
+ * Lulea University of Technology
+ *
+ * Contact: Laurynas Riliskis, LTU
+ * Mail: laurynas.riliskis@ltu.se
+ * 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 Communication Group at Lulea University of Technology
+ *   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.
+ */
+  
+/**
+ * Generic pin access for pins on the P9 port. The PD9 register
+ * is locked by the PRC2 bit in the PRCR register so it needs
+ * to be unlocked before each access.
+ *
+ * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
+ */
+
+generic module HplM16c62pGeneralIOPinPRC2P()
+{
+  provides interface GeneralIO as IO;
+  uses interface GeneralIO as Wrap;
+}
+implementation
+{
+
+  inline async command bool IO.get()        { return call Wrap.get(); }
+  inline async command void IO.set()        { call Wrap.set(); }
+  inline async command void IO.clr()        { call Wrap.clr(); }
+  inline async command void IO.toggle()     { call Wrap.toggle(); }
+    
+  inline async command void IO.makeInput() 
+  {
+    atomic
+    {
+         PRCR.BYTE = BIT2;
+         call Wrap.makeInput();
+    }
+  }
+  
+  inline async command bool IO.isInput()    { return call Wrap.isInput(); }
+  inline async command void IO.makeOutput()
+  {
+    atomic
+    {
+      PRCR.BYTE = BIT2;
+         call Wrap.makeOutput();
+    }
+  }
+  
+  inline async command bool IO.isOutput()   { return call Wrap.isOutput(); }
+}
+
index 49d6ffd58f7e50769cbc43a3ae7646d11845cac5..bc8255d0f47ae9c49d3ae90203de241247894f9b 100644 (file)
@@ -187,14 +187,14 @@ command uint8_t HplM16c62pFlash.FlashWrite( unsigned long flash_addr,
         "mov.w %[low], a0\n\t"
         "mov.w %[high], a1\n\t"
 
-        "mov.w #0x0040, r0\n\t" // Send write command
-        "ste.w r0, [a1a0]\n\t"
+        "mov.w #0x0040, r1\n\t" // Send write command
+        "ste.w r1, [a1a0]\n\t"
 
-        "mov.w %[data], r0\n\t" // Write data
-        "ste.w r0, [a1a0]\n\t"
+        "mov.w %[data], r1\n\t" // Write data
+        "ste.w r1, [a1a0]\n\t"
         :
         :[low] "r" (low), [high] "r" (high), [data] "r" (*buffer_addr)
-        : "memory", "r0", "a1", "a0");
+        : "memory", "a1", "a0", "r1");
 
     // Note: In EW1 Mode, the MCU is suspended until the operation completed
 
@@ -238,4 +238,4 @@ command uint8_t HplM16c62pFlash.FlashRead(unsigned long address) {
                 : "memory", "a0", "a1");
   return data;
 }
-}
\ No newline at end of file
+}
index 01219e074ab03729faa63ce96a3f856c0c7ef663..2ebed371187999f4bc5b6c3e5c411c56d157e139 100644 (file)
@@ -169,6 +169,9 @@ implementation {
 #endif
 #ifdef _H_atmega128hardware_H
   int uart_putchar(char c, FILE *stream) __attribute__((noinline)) @C() @spontaneous() {
+#endif
+#ifdef __M16C62PHARDWARE_H__
+  int lowlevel_putc(int c) __attribute__((noinline)) @C() @spontaneous() {
 #endif
     if((state == S_STARTED) && (call Queue.size() >= ((PRINTF_BUFFER_SIZE)/2))) {
       state = S_FLUSHING;
index 932d67faec18500b953d667dfe6b38d1fe902ff2..0ecae8e16276c7f1b06efa3ba0bcd87ab09266bc 100755 (executable)
@@ -5,13 +5,14 @@ push( @includes, qw(
   %T/chips/rf2xx/layers
   %T/chips/rf2xx/util
   %T/chips/at45db
+  %T/platforms/mulle/button
   %T/platforms/mulle/softwarei2c
   %T/platforms/mulle/softwarespi
   %T/platforms/mulle/chips/rv8564
   %T/platforms/mulle/chips/at45db
   %T/platforms/mulle/chips/m16c62p
   %T/platforms/mulle/chips/mma7261qt
-  %T/platforms/mulle/debug
+  %T/platforms/mulle/chips/ds2745
   %T/platforms/mulle/system
   %T/platforms/mulle/timers
   %T/platforms/mulle/timers/stop
@@ -23,6 +24,7 @@ push( @includes, qw(
   %T/chips/m16c62p/pins
   %T/chips/m16c62p/timer
   %T/chips/m16c62p/uart
+  %T/chips/m16c62p/printf
   %T/chips/mma7261qt
   %T/chips/ds2745
   %T/lib/power
index 568bb9ed79ef082289d4daab317e479c28d79e9c..3c88114e9381dec329b6d9e209c124c310e7b9ed 100755 (executable)
  */
 
 /**
- * A dumb demo sensor used for testing.
+ * Demo sensor that connects to the AN0 channel on the MCU. This can
+ * easily be used together with the potentiometer on the Mulle
+ * expansionboard.
  *
  * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
  */
-generic module DemoSensorC()
+generic configuration DemoSensorC()
 {
   provides interface Read<uint16_t>;
 }
 implementation
 {
-  uint8_t counter = 0;
-  
-  task void signalReadDone()
-  {
-    atomic uint8_t tmp = counter;
-    atomic counter++;
-    
-    signal Read.readDone(SUCCESS, tmp);
-  } 
-    
-  command error_t Read.read()
-  {
-    return SUCCESS;
-  }
-  default event void Read.readDone( error_t result, uint16_t val ) {}
+  components new AdcReadClientC(), DemoSensorP,
+             HplM16c62pGeneralIOC as IOs,
+             RealMainP;
+
+  DemoSensorP.Pin -> IOs.PortP100;
+  DemoSensorP.AVcc -> IOs.PortP76;
+
+  Read = AdcReadClientC;
+
+  AdcReadClientC.M16c62pAdcConfig -> DemoSensorP;
+
+  RealMainP.PlatformInit -> DemoSensorP;
 }
diff --git a/tos/platforms/mulle/DemoSensorNowC.nc b/tos/platforms/mulle/DemoSensorNowC.nc
new file mode 100644 (file)
index 0000000..22b60e3
--- /dev/null
@@ -0,0 +1,27 @@
+/**
+ * Demo sensor for the mica2 platform.
+ *
+ * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
+ */
+
+generic configuration DemoSensorNowC()
+{
+  provides interface Resource;
+  provides interface ReadNow<uint16_t>;
+}
+implementation {
+  components new AdcReadNowClientC(),
+             DemoSensorP,
+             HplM16c62pGeneralIOC as IOs,
+             RealMainP;
+
+  DemoSensorP.Pin -> IOs.PortP100;
+  DemoSensorP.AVcc -> IOs.PortP76;
+
+  ReadNow = AdcReadNowClientC;
+  Resource = AdcReadNowClientC;
+
+  AdcReadNowClientC.M16c62pAdcConfig -> DemoSensorP;
+
+  RealMainP.PlatformInit -> DemoSensorP;
+}
diff --git a/tos/platforms/mulle/DemoSensorP.nc b/tos/platforms/mulle/DemoSensorP.nc
new file mode 100644 (file)
index 0000000..d3242d7
--- /dev/null
@@ -0,0 +1,36 @@
+module DemoSensorP
+{
+  provides interface M16c62pAdcConfig;
+  provides interface Init;
+
+  uses interface GeneralIO as Pin;
+  uses interface GeneralIO as AVcc;
+}
+implementation
+{
+  command error_t Init.init()
+  {
+    call Pin.makeInput();
+    // TODO(henrik) This Vref should be turned on in connection to the A/D
+    // converter code and not here.
+    // Turn on the Vref
+    call AVcc.makeOutput();
+    call AVcc.set();
+  }
+
+  async command uint8_t M16c62pAdcConfig.getChannel()
+  {
+    // select the AN0 = P10_0 to potentiometer on the expansion board.
+    return M16c62p_ADC_CHL_AN0;
+  }
+
+  async command uint8_t M16c62pAdcConfig.getPrecision()
+  {
+    return M16c62p_ADC_PRECISION_10BIT;
+  }
+
+  async command uint8_t M16c62pAdcConfig.getPrescaler()
+  {
+    return M16c62p_ADC_PRESCALE_4;
+  }
+}
diff --git a/tos/platforms/mulle/DemoSensorStreamC.nc b/tos/platforms/mulle/DemoSensorStreamC.nc
new file mode 100644 (file)
index 0000000..43c50ea
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Id$
+ * Copyright (c) 2006 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE     
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+/**
+ * Demo sensor for the mica2 platform.
+ *
+ * @author David Gay
+ */
+
+generic configuration DemoSensorStreamC()
+{
+  provides interface ReadStream<uint16_t>;
+}
+implementation {
+  components new AdcReadStreamClientC(),
+             DemoSensorP,
+             HplM16c62pGeneralIOC as IOs,
+             RealMainP;
+
+  DemoSensorP.Pin -> IOs.PortP100;
+  DemoSensorP.AVcc -> IOs.PortP76;
+
+  ReadStream = AdcReadStreamClientC;
+
+  AdcReadStreamClientC.M16c62pAdcConfig -> DemoSensorP;
+
+  RealMainP.PlatformInit -> DemoSensorP;
+}
index c4025efbacc3a96614aff201167638a1076a0947..733d112f452dfd66688a9972f2f37b5e11e00f08 100755 (executable)
@@ -65,6 +65,7 @@ implementation
     call StopModeControl.allowStopMode(true);
     // Activate the RTC and set it to output 1024 tics on the CLKOUT pin.
     call RTC.on();
+    call RTC.enableCLKOUT();
     call RTC.writeRegister(RV8564_CLKF, 0x81);
 #else
     call StopModeControl.allowStopMode(false);
@@ -79,5 +80,7 @@ implementation
   }
 #ifdef ENABLE_STOP_MODE
   async event void RTC.fired() {}
+  async event void RTC.readRegisterDone(uint8_t val, uint8_t reg) {}
+  async event void RTC.writeRegisterDone(uint8_t reg) {}
 #endif
 }
index 452c272e429188f3d502bae56afb5bfa3269ffb3..2b3cf7c65acc12f169575ac61044cbcea9ece5c5 100755 (executable)
@@ -50,12 +50,17 @@ configuration PlatformSerialC {
 implementation {
 
   components M16c62pUartC as Uart,
-      CounterMicro16C;
+      PlatformSerialP, CounterMicro16C;
       
-  StdControl = Uart.StdControl1;
+  StdControl = PlatformSerialP;
+  PlatformSerialP -> Uart.Uart1Control;
   UartStream = Uart.Uart1Stream;
   UartByte = Uart.Uart1Byte;
   
   Uart.Counter -> CounterMicro16C;
   
+  components MainC;
+  
+  MainC.SoftwareInit -> PlatformSerialP;
+  
 }
diff --git a/tos/platforms/mulle/PlatformSerialP.nc b/tos/platforms/mulle/PlatformSerialP.nc
new file mode 100644 (file)
index 0000000..81c8e11
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2009 Communication Group and Eislab at
+ * Lulea University of Technology
+ *
+ * Contact: Laurynas Riliskis, LTU
+ * Mail: laurynas.riliskis@ltu.se
+ * 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 Communication Group at Lulea University of Technology
+ *   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.
+ */
+
+/**
+ * Initialization of the PlatformSerial uart and a StdControl implementation
+ * for it.
+ * 
+ * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
+ */
+
+module PlatformSerialP
+{
+  provides interface StdControl;
+  provides interface Init;
+  
+  uses interface UartControl;
+}
+implementation
+{
+  command error_t Init.init() {
+    call UartControl.setParity(TOS_UART_PARITY_NONE);
+    call UartControl.setNoStop();
+    call UartControl.setSpeed(TOS_UART_57600);
+    return SUCCESS;
+  }
+  
+  
+  command error_t StdControl.start()
+  {
+    call UartControl.setDuplexMode(TOS_UART_DUPLEX);
+    return SUCCESS;
+  }
+
+  command error_t StdControl.stop()
+  {
+    call UartControl.setDuplexMode(TOS_UART_OFF);
+    return SUCCESS;
+  }
+}
index 4a6cd8a1a6b735425a7edd86accdc2c57a2d3b07..bf62fad27f527f9ec40a6af501d1d2f6a0d67196 100755 (executable)
@@ -53,7 +53,6 @@ implementation
 {
   components new M16c62pAlarm16C(TMicro) as AlarmFrom;
   components new M16c62pTimerAInitC(TMR_COUNTER_MODE, M16C_TMRA_TES_TA_PREV, 0, false, false, false) as AlarmInit;
-  components McuSleepC;
 
   components HplM16c62pTimerC as Timers,
       CounterMicro16C,
@@ -61,7 +60,6 @@ implementation
 
   AlarmFrom -> Timers.ALARM_MICRO16;
   AlarmFrom.Counter -> CounterMicro16C;
-  AlarmFrom.McuPowerState -> McuSleepC;
 
   AlarmInit -> Timers.ALARM_MICRO16;
   AlarmInit -> Timers.ALARM_MICRO16_CTRL;