X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fscp1000%2FScp1000P.nc;h=a3b4bdb7444cfdfbf5dbde541d06360129659f4d;hb=be862ab07d080085823951d18dcb27a28a310ace;hp=670d3d8e5a661de4118419329938de5db78c0a26;hpb=86e1f38f71efaa4ef35d676dde514fb9884f124e;p=tinyos-2.x.git diff --git a/tos/chips/scp1000/Scp1000P.nc b/tos/chips/scp1000/Scp1000P.nc index 670d3d8e..a3b4bdb7 100644 --- a/tos/chips/scp1000/Scp1000P.nc +++ b/tos/chips/scp1000/Scp1000P.nc @@ -10,7 +10,7 @@ * - 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 + * - Neither the name of the Titanium Mirror, Inc. nor the names * of its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -26,26 +26,22 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + /** * scp1000 implementation. - * + * * @author R. Steve McKown */ #include "Scp1000.h" - + generic module Scp1000P() @safe() { - provides { - interface Init; - interface ReadRef; - } + provides interface ReadRef; uses { - /* TODO: too platform specific, but need for disableRen() */ - interface HplMsp430GeneralIO as CSn; - interface HplMsp430GeneralIO as PD; - interface HplMsp430GeneralIO as DRDY; + interface GeneralIO as CSn; + interface GeneralIO as PD; + interface GeneralIO as DRDY; interface GpioInterrupt as IntDRDY; interface Resource; interface SpiByte; @@ -113,39 +109,12 @@ implementation { scp1000_t* tmp = m_ptr; - call DRDY.enableRen(); call PD.set(); call Resource.release(); m_ptr = 0; signal ReadRef.readDone(error, tmp); } - command error_t Init.init() - { - /* TODO: tmicore MotePlatformC sets the pins we use up in a way that isn't - * ideal for our use, but changing them requires that we use platform - * dependent code. Find a way to fix this. - * - * When the part is 'soldered' onto the board, aka tmirws, then - * MotePlatform can set it and be done, mostly. However, DRDY will use - * extra energy since with the scp1000 on it pulls DRDY low most of the - * time, causing current through the enabled pull-up. Best to turn it - * off after PD is enabled and on before PD is disabled. - */ - call CSn.selectIOFunc(); - call CSn.disableRen(); - call CSn.set(); - call CSn.makeOutput(); - call PD.selectIOFunc(); - call PD.disableRen(); - call PD.set(); - call PD.makeOutput(); - call DRDY.selectIOFunc(); - call DRDY.enableRen(); - call DRDY.makeInput(); - return SUCCESS; - } - command error_t ReadRef.read(scp1000_t* ptr) { if (m_ptr || !ptr) @@ -184,6 +153,15 @@ implementation return; } + /* We could use the low noise configuration by also doing: + * writeByte(0x2d, 0x03); + * wait_ms(100); + * writeByte(OPERATION, 0); + * wait_ms(10); + * writeByte(OPERATION, 0x0a); -- 0x0a is high resolution mode + * wait_ms(100); + */ + /* Initiate a reading. DRDY will assert when done, ~ 500ms from now */ tstate = TIMER_DRDY; call Timer.startOneShot(1024); @@ -202,9 +180,9 @@ implementation task void results() { call Timer.stop(); - m_ptr->temp = readWord(TEMPOUT); + m_ptr->temp = readWord(TEMPOUT); /* 20ths of a degree C */ m_ptr->pressure = (uint32_t)readByte(DATARD8) << 16; - m_ptr->pressure += readWord(DATARD16); + m_ptr->pressure += readWord(DATARD16); /* 4ths of a Pa? */ signalDone(SUCCESS); return; } @@ -216,7 +194,6 @@ implementation tstate = TIMER_NONE; switch (tmp) { case TIMER_POWER: - call DRDY.disableRen(); counter = 0; post check(); break;