generic module Scp1000P() @safe()
{
- provides {
- interface Init;
- interface ReadRef<scp1000_t>;
- }
+ provides interface ReadRef<scp1000_t>;
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;
{
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)
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);
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;
}
tstate = TIMER_NONE;
switch (tmp) {
case TIMER_POWER:
- call DRDY.disableRen();
counter = 0;
post check();
break;