From ee1775e283a17728cc35544c687fbb9baad53f2c Mon Sep 17 00:00:00 2001 From: smckown Date: Thu, 11 Sep 2008 02:34:55 +0000 Subject: [PATCH] The AT25DF part is not compatible with the AT45DB nor the STM25P, apparently. It is quite close to the STM25P, but mapping the chip to that code failed to get good results using the tests/storage/Block application. However, the part does work correctly with a test application written directly to its SPI API. --- tos/chips/msp430/pins/NoMsp430GpioC.nc | 44 ++++++++++++ tos/chips/msp430/usci/Msp430SpiA0C.nc | 94 ++++++++++++++++++++++++++ tos/chips/msp430/usci/Msp430SpiB0C.nc | 94 ++++++++++++++++++++++++++ tos/platforms/tmicore/.platform | 1 - 4 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 tos/chips/msp430/pins/NoMsp430GpioC.nc create mode 100644 tos/chips/msp430/usci/Msp430SpiA0C.nc create mode 100644 tos/chips/msp430/usci/Msp430SpiB0C.nc diff --git a/tos/chips/msp430/pins/NoMsp430GpioC.nc b/tos/chips/msp430/pins/NoMsp430GpioC.nc new file mode 100644 index 00000000..2b9cc174 --- /dev/null +++ b/tos/chips/msp430/pins/NoMsp430GpioC.nc @@ -0,0 +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." + */ + +/** + * A noop version of Msp430GpioC. + * + * @author Joe Polastre + * @see Please refer to TEP 117 for more information about this component and its + * intended use. + */ + +generic module NoMsp430GpioC() @safe() { + provides interface GeneralIO; +} +implementation { + + async command void GeneralIO.set() {} + async command void GeneralIO.clr() {} + async command void GeneralIO.toggle() {} + async command bool GeneralIO.get() { return FALSE; } + async command void GeneralIO.makeInput() {} + async command bool GeneralIO.isInput() { return TRUE; } + async command void GeneralIO.makeOutput() {} + async command bool GeneralIO.isOutput() { return FALSE; } + +} diff --git a/tos/chips/msp430/usci/Msp430SpiA0C.nc b/tos/chips/msp430/usci/Msp430SpiA0C.nc new file mode 100644 index 00000000..546c81ae --- /dev/null +++ b/tos/chips/msp430/usci/Msp430SpiA0C.nc @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2008, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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 COPYRIGHT + * OWNER 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 configuration provides the interface for using USCI_A0 in its SPI + * mode. + * + * The instantiator should set the blockSize, which represents the maximum + * number of bytes the underlying SPI stack will transmit or receive in a + * single interrupt service. Increasing the block size decreases SPI + * communications time at the expense of reducing system responsiveness to + * other events. + * + * The blockSize is best set by considering the maximum time the SPI stack + * should be able to delay other events. A rule of thumb formula would be: + * + * block_time = block_size / (spi_bitclock/8) + * + * For example, using a 500KHZ SPI bitclock, a block size of 64 bytes + * equates to a block time of 1 ms. Note that this calculation is rough + * because it does not take into account ISR overhead and other factors. + * + * The implementation will use a default blockSize if set to 0 here. + * + * @author R. Steve McKown + */ + +#if !defined(__MSP430_HAS_USCI_AB0__) +#error "Target does not have a USCI_A0 peripheral (SPI)" +#endif + +#include "Msp430Usci.h" + +generic configuration Msp430SpiA0C(uint16_t blockSize) { + provides { + interface Resource; + interface ResourceRequested; + interface SpiByte; + interface SpiPacket; + interface ArbiterInfo; /* ??? */ + } + uses interface AsyncConfigure as Configure; +} +implementation { + enum { + CLIENT_ID = unique(MSP430_USCIA0_RESOURCE) + }; + + components new Msp430SpiP(blockSize) as SpiP; + SpiByte = SpiP; + SpiPacket = SpiP; + Configure = SpiP; + + components Msp430UsciA0C as UsciC; + Resource = UsciC.Resource[CLIENT_ID]; + ResourceRequested = UsciC.ResourceRequested[CLIENT_ID]; + ArbiterInfo = UsciC.ArbiterInfo; + SpiP -> UsciC.Registers; + SpiP -> UsciC.Interrupts[CLIENT_ID]; + SpiP -> UsciC.ArbiterInfo; + UsciC.ResourceConfigure[CLIENT_ID] -> SpiP; + + components HplMsp430GeneralIOC as IOC; + SpiP.STE -> IOC.UCA0STE; + SpiP.SIMO -> IOC.UCA0SIMO; + SpiP.SOMI -> IOC.UCA0SOMI; + SpiP.CLK -> IOC.UCA0CLK; +} diff --git a/tos/chips/msp430/usci/Msp430SpiB0C.nc b/tos/chips/msp430/usci/Msp430SpiB0C.nc new file mode 100644 index 00000000..533a1ef3 --- /dev/null +++ b/tos/chips/msp430/usci/Msp430SpiB0C.nc @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2008, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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 COPYRIGHT + * OWNER 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 configuration provides the interface for using USCI_B0 in its SPI + * mode. + * + * The instantiator should set the blockSize, which represents the maximum + * number of bytes the underlying SPI stack will transmit or receive in a + * single interrupt service. Increasing the block size decreases SPI + * communications time at the expense of reducing system responsiveness to + * other events. + * + * The blockSize is best set by considering the maximum time the SPI stack + * should be able to delay other events. A rule of thumb formula would be: + * + * block_time = block_size / (spi_bitclock/8) + * + * For example, using a 500KHZ SPI bitclock, a block size of 64 bytes + * equates to a block time of 1 ms. Note that this calculation is rough + * because it does not take into account ISR overhead and other factors. + * + * The implementation will use a default blockSize if set to 0 here. + * + * @author R. Steve McKown + */ + +#if !defined(__MSP430_HAS_USCI_AB0__) +#error "Target does not have a USCI_B0 peripheral (SPI)" +#endif + +#include "Msp430Usci.h" + +generic configuration Msp430SpiB0C(uint16_t blockSize) { + provides { + interface Resource; + interface ResourceRequested; + interface SpiByte; + interface SpiPacket; + interface ArbiterInfo; /* ??? */ + } + uses interface AsyncConfigure as Configure; +} +implementation { + enum { + CLIENT_ID = unique(MSP430_USCIB0_RESOURCE) + }; + + components new Msp430SpiP(blockSize) as SpiP; + SpiByte = SpiP; + SpiPacket = SpiP; + Configure = SpiP; + + components Msp430UsciB0C as UsciC; + Resource = UsciC.Resource[CLIENT_ID]; + ResourceRequested = UsciC.ResourceRequested[CLIENT_ID]; + ArbiterInfo = UsciC.ArbiterInfo; + SpiP -> UsciC.Registers; + SpiP -> UsciC.Interrupts[CLIENT_ID]; + SpiP -> UsciC.ArbiterInfo; + UsciC.ResourceConfigure[CLIENT_ID] -> SpiP; + + components HplMsp430GeneralIOC as IOC; + SpiP.STE -> IOC.UCB0STE; + SpiP.SIMO -> IOC.UCB0SIMO; + SpiP.SOMI -> IOC.UCB0SOMI; + SpiP.CLK -> IOC.UCB0CLK; +} diff --git a/tos/platforms/tmicore/.platform b/tos/platforms/tmicore/.platform index 3e8fdb1b..f80694a5 100755 --- a/tos/platforms/tmicore/.platform +++ b/tos/platforms/tmicore/.platform @@ -15,7 +15,6 @@ push( @includes, qw( %T/chips/msp430/timer %T/chips/msp430/usci %T/chips/msp430/sensors - %T/chips/at45db %T/chips/bq2403x %T/chips/cp210x %T/lib/timer -- 2.39.2