--- /dev/null
+/*
+ * 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(); }
+}
+
"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
: "memory", "a0", "a1");
return data;
}
-}
\ No newline at end of file
+}
#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;
%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
%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
*/
/**
- * 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;
}
--- /dev/null
+/**
+ * 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;
+}
--- /dev/null
+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;
+ }
+}
--- /dev/null
+/* $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;
+}
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);
}
#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
}
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;
+
}
--- /dev/null
+/*
+ * 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;
+ }
+}
{
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,
AlarmFrom -> Timers.ALARM_MICRO16;
AlarmFrom.Counter -> CounterMicro16C;
- AlarmFrom.McuPowerState -> McuSleepC;
AlarmInit -> Timers.ALARM_MICRO16;
AlarmInit -> Timers.ALARM_MICRO16_CTRL;