#
# FILE: micaz/.platform
-#
+#
# Includes that should take precedence come first. Platforms come before
# chips because they may override files. These must be specified as
# @includes instead of -I's to @opts, otherwise the %T won't be processed
-# by ncc.
+# by ncc.
#
# $Id$
#
%T/platforms/iris/chips/rf230
%T/chips/rf230
%T/chips/cc2420 # for IEEE802154.h
+ %T/platforms/iris/chips/at45db
%T/platforms/mica2/chips/at45db
%T/platforms/mica/chips/at45db
%T/chips/at45db
- %T/chips/atm1281
+ %T/chips/atm1281
%T/chips/atm1281/adc
- %T/chips/atm1281/timer
+ %T/chips/atm1281/timer
%T/chips/atm128
%T/chips/atm128/adc
%T/chips/atm128/pins
--- /dev/null
+// $Id$
+/*
+ * Copyright (c) 2005-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.
+ */
+/*
+ * Copyright (c) 2007, Vanderbilt University
+ * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ */
+
+
+/**
+ * Low-level access functions for the AT45DB flash on the mica2 and micaz.
+ *
+ * @author David Gay
+ * @author Janos Sallai <janos.sallai@vanderbilt.edu>
+ */
+
+configuration HplAt45dbIOC {
+ provides {
+ interface Resource;
+ interface SpiByte as FlashSpi;
+ interface HplAt45dbByte;
+ }
+}
+implementation {
+ // Wire up byte I/O to At45db
+ components HplAt45dbIOP, HplAtm128GeneralIOC as Pins, PlatformC;
+ components BusyWaitMicroC;
+ components new NoArbiterC();
+
+ Resource = NoArbiterC;
+ FlashSpi = HplAt45dbIOP;
+ HplAt45dbByte = HplAt45dbIOP;
+
+ PlatformC.SubInit -> HplAt45dbIOP;
+ HplAt45dbIOP.Select -> Pins.PortA3;
+ HplAt45dbIOP.Clk -> Pins.PortD5;
+ HplAt45dbIOP.In -> Pins.PortD2;
+ HplAt45dbIOP.Out -> Pins.PortD3;
+ HplAt45dbIOP.BusyWait -> BusyWaitMicroC;
+}
--- /dev/null
+// $Id$
+
+/* tab:4
+ * "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."
+ *
+ * Copyright (c) 2002-2003 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.
+ */
+/*
+ * Copyright (c) 2007, Vanderbilt University
+ * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ */
+
+/**
+ * Low level hardware access to the onboard AT45DB flash chip.
+ * <p>
+ * Note: This component includes optimised bit-banging SPI code with the
+ * pins hardwired. Don't copy it to some other platform without
+ * understanding it (see txByte).
+ *
+ * @author Jason Hill
+ * @author David Gay
+ * @author Philip Levis
+ * @author Janos Sallai <janos.sallai@vanderbilt.edu>
+ */
+
+#include "Timer.h"
+
+module HplAt45dbIOP {
+ provides {
+ interface Init;
+ interface SpiByte as FlashSpi;
+ interface HplAt45dbByte;
+ }
+ uses {
+ interface GeneralIO as Select;
+ interface GeneralIO as Clk;
+ interface GeneralIO as Out;
+ interface GeneralIO as In;
+ interface BusyWait<TMicro, uint16_t>;
+ }
+}
+implementation
+{
+ // We use SPI mode 0 (clock low at select time)
+
+ command error_t Init.init() {
+ call Select.makeOutput();
+ call Select.set();
+ call Clk.clr();
+ call Clk.makeOutput();
+ call Out.set();
+ call Out.makeOutput();
+ call In.clr();
+ call In.makeInput();
+ return SUCCESS;
+ }
+
+ command void HplAt45dbByte.select() {
+ call Clk.clr(); // ensure SPI mode 0
+ call Select.clr();
+ }
+
+ command void HplAt45dbByte.deselect() {
+ call Select.set();
+ }
+
+#define BITINIT \
+ uint8_t clrClkAndData = PORTD & ~0x28
+
+#define BIT(n) \
+ PORTD = clrClkAndData; \
+ asm __volatile__ \
+ ( "sbrc %2," #n "\n" \
+ "\tsbi 11,3\n" \
+ "\tsbi 11,5\n" \
+ "\tsbic 9,2\n" \
+ "\tori %0,1<<" #n "\n" \
+ : "=d" (spiIn) : "0" (spiIn), "r" (spiOut))
+
+ async command uint8_t FlashSpi.write(uint8_t spiOut) {
+ uint8_t spiIn = 0;
+
+ // This atomic ensures integrity at the hardware level...
+ atomic
+ {
+ BITINIT;
+
+ BIT(7);
+ BIT(6);
+ BIT(5);
+ BIT(4);
+ BIT(3);
+ BIT(2);
+ BIT(1);
+ BIT(0);
+ }
+
+ return spiIn;
+ }
+
+ task void avail() {
+ signal HplAt45dbByte.idle();
+ }
+
+ command void HplAt45dbByte.waitIdle() {
+ // at45db041 rev d fix by handsomezhu hongsong at ios.cn
+ // http://mail.millennium.berkeley.edu/pipermail/tinyos-help/2008-January/030255.html
+ int i;
+ call Clk.clr();
+ call BusyWait.wait(2);
+ while( ! call In.get() ) {
+ for( i=0; i < 8; i ++ ) {
+ call Clk.set();
+ call Clk.clr();
+ call BusyWait.wait(2);
+ }
+ }
+ post avail();
+ }
+
+ command bool HplAt45dbByte.getCompareStatus() {
+ call Clk.set();
+ call Clk.clr();
+ // Wait for compare value to propagate
+ asm volatile("nop");
+ asm volatile("nop");
+ return !call In.get();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2005-2006 Arch Rock Corporation
+ * 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 Arch Rock Corporation 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 THE
+ * ARCHED ROCK 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
+ */
+
+/**
+ * An abstraction to map volume addresses to physical addresses.
+ *
+ * @author Jonathan Hui <jhui@archrock.com>
+ * @version $Revision$ $Date$
+ */
+#include "at45db.h"
+
+interface StorageMap {
+
+ /**
+ * Get the physical address of a volume address.
+ *
+ * @param addr the volume addres.
+ * @return the physical address.
+ */
+ command storage_addr_t getPhysicalAddress( storage_addr_t addr );
+
+}