]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
pretty code, minor improvements
authorr-studio <r-studio>
Wed, 28 Oct 2009 07:22:10 +0000 (07:22 +0000)
committerr-studio <r-studio>
Wed, 28 Oct 2009 07:22:10 +0000 (07:22 +0000)
tos/platforms/mulle/chips/ds2745/DS2745InternalC.nc [new file with mode: 0644]
tos/platforms/mulle/chips/ds2745/DS2745InternalP.nc [new file with mode: 0644]
tos/platforms/mulle/chips/m16c62p/M16c62pAdcPlatformC.nc
tos/platforms/mulle/chips/m16c62p/M16c62pAdcPlatformP.nc [new file with mode: 0644]
tos/platforms/mulle/chips/rf230/RF230SplitControlP.nc
tos/platforms/mulle/chips/rf230/RadioConfig.h
tos/platforms/mulle/chips/rv8564/RV8564.nc
tos/platforms/mulle/chips/rv8564/RV8564C.nc
tos/platforms/mulle/chips/rv8564/RV8564P.nc
tos/platforms/mulle/chips/rv8564/rv8564.h
tos/platforms/mulle/softwarei2c/SoftI2CBusP.nc

diff --git a/tos/platforms/mulle/chips/ds2745/DS2745InternalC.nc b/tos/platforms/mulle/chips/ds2745/DS2745InternalC.nc
new file mode 100644 (file)
index 0000000..673f890
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * The DS2745 works well to be used with the DS2782 chip on the Mulle.
+ * 
+ * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
+ */
+
+// TODO(henrik) Clean and comment this code better. Also Make the chip request
+//              access to the I2C bus instead of how its now that the program
+//              needs to request it.
+configuration DS2745InternalC {
+  provides interface SplitControl;
+  provides interface Resource;
+  provides interface HplDS2745;
+}
+
+implementation {
+  components MainC;
+  
+  components new SoftI2CBatteryMonitorRTCC() as I2C;
+  Resource = I2C;
+  
+  components new HplDS2745LogicP(0x68) as Logic;
+  MainC.SoftwareInit -> Logic;
+  Logic.I2CPacket -> I2C;
+  HplDS2745 = Logic;
+
+  SplitControl = Logic;
+
+}
diff --git a/tos/platforms/mulle/chips/ds2745/DS2745InternalP.nc b/tos/platforms/mulle/chips/ds2745/DS2745InternalP.nc
new file mode 100644 (file)
index 0000000..e4845f4
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * 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 Arched 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
+ */
+
+/**
+ * 
+ * @author Phil Buonadonna <pbuonadonna@archrock.com>
+ * @version $Revision$ $Date$
+ */
+
+module DS2745InternalP {
+  provides interface HplDS2745[uint8_t id];
+  uses interface HplDS2745 as ToHPLC;
+}
+
+implementation {
+  uint8_t currentId;
+  
+  command error_t HplDS2745.setConfig[uint8_t id](uint8_t val) {
+    currentId = id;
+    return call ToHPLC.setConfig(val);
+  }
+  command error_t HplDS2745.measureTemperature[uint8_t id]() {
+    currentId = id;
+    return call ToHPLC.measureTemperature();
+  }
+  command error_t HplDS2745.measureVoltage[uint8_t id]() {
+    currentId = id;
+    return call ToHPLC.measureVoltage();
+  }
+  command error_t HplDS2745.measureCurrent[uint8_t id]() {
+    currentId = id;
+    return call ToHPLC.measureCurrent();
+  }
+  command error_t HplDS2745.measureAccCurrent[uint8_t id]() {
+    currentId = id;
+    return call ToHPLC.measureAccCurrent();
+  }
+  command error_t HplDS2745.setOffsetBias[uint8_t id](int8_t val) {
+    currentId = id;
+    return call ToHPLC.setOffsetBias(val);
+  }
+  command error_t HplDS2745.setAccOffsetBias[uint8_t id](int8_t val) {
+    currentId = id;
+    return call ToHPLC.setAccOffsetBias(val);
+  }
+  
+  async event void ToHPLC.setConfigDone(error_t error) {
+    signal HplDS2745.setConfigDone[currentId](error);
+  }
+  async event void ToHPLC.measureTemperatureDone(error_t result, uint16_t val) {
+    signal HplDS2745.measureTemperatureDone[currentId](result, val);
+  }
+  async event void ToHPLC.measureVoltageDone(error_t result, uint16_t val) {
+    signal HplDS2745.measureVoltageDone[currentId](result, val);
+  }
+  async event void ToHPLC.measureCurrentDone(error_t result, uint16_t val) {
+    signal HplDS2745.measureCurrentDone[currentId](result, val);
+  }
+  async event void ToHPLC.measureAccCurrentDone(error_t result, uint16_t val) {
+    signal HplDS2745.measureAccCurrentDone[currentId](result, val);
+  }
+  async event void ToHPLC.setOffsetBiasDone(error_t error) {
+    signal HplDS2745.setOffsetBiasDone[currentId](error);
+  }
+  async event void ToHPLC.setAccOffsetBiasDone(error_t error) {
+    signal HplDS2745.setAccOffsetBiasDone[currentId](error);
+  }
+
+  default async event void HplDS2745.setConfigDone[uint8_t id]( error_t error ){ return; }
+  default async event void HplDS2745.measureTemperatureDone[uint8_t id]( error_t error, uint16_t val ){ return; }
+  default async event void HplDS2745.measureVoltageDone[uint8_t id]( error_t error, uint16_t val ){ return; }
+  default async event void HplDS2745.measureCurrentDone[uint8_t id]( error_t error, uint16_t val ){ return; }
+  default async event void HplDS2745.measureAccCurrentDone[uint8_t id]( error_t error, uint16_t val ){ return; }
+  default async event void HplDS2745.setOffsetBiasDone[uint8_t id]( error_t error ){ return; }
+  default async event void HplDS2745.setAccOffsetBiasDone[uint8_t id](error_t error){ return; }
+
+}
+
+
index a22f485999957a51bcc3f607ab3ed28b99cb34cc..5765fbe2d9b12ca6058966ee4f5b8bcf6c955fe8 100644 (file)
@@ -1,28 +1,52 @@
-module M16c62pAdcPlatformC
+/*
+ * 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.
+ */
+
+/**
+ * Mulle specific implementation of the M16c62pAdcPlatform interface.
+ * 
+ * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
+ */
+configuration M16c62pAdcPlatformC
 {
   provides interface M16c62pAdcPlatform;
 }
 implementation
 {
-  async command void M16c62pAdcPlatform.adcOn()
-  {
-    // turn on AVcc 
-    PD7.BIT.PD7_6 = 1;
-    P7.BIT.P7_6 = 1;
-               
-    // turn on AVref 
-    PD3.BIT.PD3_1 = 1;
-    P3.BIT.P3_1 = 1;
-  }
-  
-  async command void M16c62pAdcPlatform.adcOff()
-  {
-//    // turn off AVcc 
-//    PD7.BIT.PD7_6 = 0;
-//    P7.BIT.P7_6 = 0;
-//             
-//    // turn off AVref 
-//    PD3.BIT.PD3_1 = 0;
-//    P3.BIT.P3_1 = 0;
-  }
-}
\ No newline at end of file
+  components M16c62pAdcPlatformP, HplM16c62pGeneralIOC as IOs;
+
+  M16c62pAdcPlatform = M16c62pAdcPlatformP;
+  M16c62pAdcPlatformP -> IOs.PortP76;
+}
diff --git a/tos/platforms/mulle/chips/m16c62p/M16c62pAdcPlatformP.nc b/tos/platforms/mulle/chips/m16c62p/M16c62pAdcPlatformP.nc
new file mode 100644 (file)
index 0000000..02e7b62
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+/**
+ * Mulle specific implementation of the M16c62pAdcPlatform interface.
+ * 
+ * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
+ */
+module M16c62pAdcPlatformP
+{
+  provides interface M16c62pAdcPlatform;
+  uses interface GeneralIO VRef;
+}
+implementation
+{
+  async command void M16c62pAdcPlatform.adcOn()
+  {
+    call VRef.makeOutput();
+    call VRef.set();
+  }
+  
+  async command void M16c62pAdcPlatform.adcOff()
+  {
+    call VRef.clr();
+  }
+}
index bd87661de98064bf52c4ba44df696c44ecaf7b51..2f30cadf511caabec36b629ddb35199a574f3543 100644 (file)
@@ -50,16 +50,20 @@ implementation
 {
   command error_t SplitControl.start()
   {
+#ifndef RF230_SLOW_SPI
     call SystemClockControl.minSpeed(M16C62P_PLL_CLOCK);
+#endif
     return call SplitControlOrig.start();
   }
 
   event void SplitControlOrig.startDone(error_t error)
   {
+#ifndef RF230_SLOW_SPI
     if (error != SUCCESS)
     {
       call SystemClockControl.minSpeed(M16C62P_DONT_CARE);
     }
+#endif
     signal SplitControl.startDone(error);
   }
 
@@ -70,10 +74,12 @@ implementation
 
   event void SplitControlOrig.stopDone(error_t error)
   {
+#ifndef RF230_SLOW_SPI
     if (error == SUCCESS)
     {
       call SystemClockControl.minSpeed(M16C62P_DONT_CARE);
     }
+#endif
     signal SplitControl.stopDone(error);
   }
 }
index 5ba89494059c2726dec5a3f138a0baccb6346b05..b3835f7cf1a2315666db677e9a0275b475036f7e 100644 (file)
@@ -64,7 +64,7 @@
 #define __RADIOCONFIG_H__
 
 #include <RF230DriverLayer.h>
-
+#include "Timer.h"
 
 enum
 {
index 16b492cd58dd9f275b17ccb50a78f188b53c0d76..3004be353e3e136a86bfcd5e75ac0c624d16b06b 100755 (executable)
@@ -44,27 +44,27 @@ interface RV8564
   /**
    * Turns the chip on.
    */
-  async command void on();
+  command error_t on();
 
   /**
    * Turns the chip off.
    */
-  async command void off();
+  command error_t off();
 
   /**
    * Checks if the chip is on.
    *
    * @return true if on.
    */
-  async command bool isOn();
+  command bool isOn();
 
   /**
    * Enables/disables the interrupts generated by the CLKOUT.
    */
   // TODO(henrik) This needs to be changed because there are different type of 
   //              interrupts generated by the chip.
-  async command void enableInterrupt();
-  async command void disableInterrupt();
+  command void enableInterrupt();
+  command void disableInterrupt();
 
   /**
    * Reads from a register.
@@ -72,7 +72,7 @@ interface RV8564
    * @param reg The register to be read.
    * @return The value of the register.
    */
-  async command uint8_t readRegister(uint16_t reg);
+  command error_t readRegister(uint8_t reg);
 
   /**
    * Writes to a register.
@@ -80,10 +80,30 @@ interface RV8564
    * @param reg The register that is written to.
    * @param value The value that is written to the register.
    */
-  async command void writeRegister(uint16_t reg, uint8_t value);
-  
+  command error_t writeRegister(uint8_t reg, uint8_t value);
+
+  /**
+   * Signals when a register read finished.
+   *
+   * @param val The value read from the register.
+   * @param reg The register the value was read from.
+   */
+  async event void readRegisterDone(uint8_t val, uint8_t reg);
+
+  /**
+   * Signals when a register write finished.
+   *
+   * @param reg The register the value was written to.
+   */
+  async event void writeRegisterDone(uint8_t reg);
+
   /**
    * Signal when an interrupt occurs.
    */
   async event void fired();
+  
+  /**
+   * Enables CLKOUT from the RTC.
+   */
+  command void enableCLKOUT();
 }
index 861b0535885167434a92da28b534cabc277703cc..1f484f9e95d1273a9a6265ffc266619ac69a448b 100755 (executable)
@@ -55,7 +55,8 @@ implementation
   Irq.HplM16c62pInterrupt -> Irqs.Int0;
 
   RTC = RTCP;
-  RTCP -> IOs.PortP47;
+  RTCP.CLKOE -> IOs.PortP47;
+  RTCP.CLKOUT -> IOs.PortP92;
   RTCP.GpioInterrupt -> Irq;
   RTCP.I2C -> I2C;
   RTCP.I2CResource -> I2C;
index 77e594cb924d1c8b66dc13636f354e235d8bedbd..9dcf0c2bbc47ccbb8f1778d06eab442815af9fd8 100755 (executable)
 
 #include "rv8564.h"
 #include "I2C.h"
-// TODO(henrik) The request to the I2C is done throuh a immediateRequest, this perhaps needs to be changed because
-//              its bad if the battery monitor has hold of the I2C bus.
 module RV8564P
 {
   provides interface RV8564 as RTC;
   // TODO(henrik) Exactly how is the RTC connected to mulle, what is the functionallity of GeneralIO?
   //              Maybe there is only a init needed because the chip is always on?
+  uses interface GeneralIO as CLKOE;
+  uses interface GeneralIO as CLKOUT;
   uses interface GeneralIO;
   uses interface GpioInterrupt;
   uses interface I2CPacket<TI2CBasicAddr> as I2C;
@@ -56,72 +56,139 @@ module RV8564P
 }
 implementation
 {
-  async command void RTC.on()
+
+  enum
+  {
+    OFF,
+    IDLE,
+    READING,
+    WRITING
+  };
+  norace uint8_t state = OFF;
+  norace uint8_t read_register;
+  uint8_t read_register_value;
+  uint8_t write_buffer[2];
+
+  command error_t RTC.on()
   {
-    call GeneralIO.makeOutput();
-    call GeneralIO.set();
+    if (state != OFF)
+    {
+      return SUCCESS;
+    }
+    state = IDLE;
+    return SUCCESS;
   }
 
-  async command void RTC.off()
+  command error_t RTC.off()
   {
-    call GeneralIO.clr();
-    call GeneralIO.makeInput();
+    if  (state == OFF)
+    {
+      return SUCCESS;
+    }
+    else if (state != IDLE)
+    {
+      return FAIL;
+    }
+    call CLKOE.clr();
+    call CLKOUT.clr();
+    return SUCCESS;
   }
 
-  async command bool RTC.isOn()
+  command bool RTC.isOn()
   {
-    return (call GeneralIO.get() && call GeneralIO.isOutput());
+    return ((state != OFF) ? true : false);
   }
 
-  async command void RTC.enableInterrupt()
+  command void RTC.enableCLKOUT()
+  {
+       call CLKOUT.makeInput();
+       call CLKOUT.clr();
+       call CLKOE.makeOutput();
+       call CLKOE.set();
+  }
+  command void RTC.enableInterrupt()
   {
     call GpioInterrupt.enableFallingEdge();
   }
 
-  async command void RTC.disableInterrupt()
+  command void RTC.disableInterrupt()
   {
     call GpioInterrupt.disable();
   }
-  
-  async command uint8_t RTC.readRegister(uint16_t reg)
+
+  command error_t RTC.readRegister(uint8_t reg)
   {
     uint8_t val;
-    atomic
+    if (state != IDLE)
+    {  
+      return FAIL;
+    }
+    state = READING;
+    read_register = reg;
+    call I2CResource.request();
+    return SUCCESS;
+  }
+
+  command error_t RTC.writeRegister(uint8_t reg, uint8_t value)
+  { 
+    if (state != IDLE)
     {
-      if (call I2CResource.immediateRequest() == SUCCESS)
+      return FAIL;
+    }
+    state = WRITING;
+    write_buffer[0] = reg;
+    write_buffer[1] = value;
+    call I2CResource.request();
+    return SUCCESS;
+  }
+
+  event void I2CResource.granted()
+  {
+    atomic {
+      if (state == READING)
       {
-        call I2C.write(I2C_START, RV8564_WR_ADDR, 1, (uint8_t*)&reg);
-        call I2C.read(I2C_START | I2C_STOP, RV8564_RD_ADDR, 1, &val);
-        call I2CResource.release();
+        call I2C.write(I2C_START, RV8564_ADDR, 1, &read_register);
       }
-    }
-    return val;
+      else if (state == WRITING)
+      {
+        call I2C.write(I2C_START | I2C_STOP, RV8564_ADDR, 2, write_buffer);    
+      }
+    }  
   }
 
-  async command void RTC.writeRegister(uint16_t reg, uint8_t value)
+  async event void GpioInterrupt.fired()
+  {
+    signal RTC.fired();
+  }
+
+  async event void I2C.readDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
   {
-    uint8_t wr[2] = {reg, value};
     atomic
     {
-      if (call I2CResource.immediateRequest() == SUCCESS)
+      if (state == READING && data == &read_register_value)
       {
-        call I2C.write(I2C_START | I2C_STOP, RV8564_WR_ADDR, 2, wr);
+        state = IDLE;
         call I2CResource.release();
-      }
+        signal RTC.readRegisterDone(read_register_value, read_register);
+      }        
     }
   }
 
-  event void I2CResource.granted()
+  async event void I2C.writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
   {
-    // TODO(henrik) Insert communication code here.
-  }
-  
-  async event void GpioInterrupt.fired()
-  {
-    signal RTC.fired();
+    if (state == READING)
+    {
+      call I2C.read(I2C_START | I2C_STOP, RV8564_ADDR, 1, &read_register_value);
+    }
+    else if (state == WRITING)
+    {
+      state = IDLE;
+      call I2CResource.release();
+      signal RTC.writeRegisterDone(write_buffer[0]);
+    }
   }
-  default async event void RTC.fired() { }
 
-  async event void I2C.readDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data) {}
-  async event void I2C.writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data) {}
+  default async event void RTC.readRegisterDone(uint8_t val, uint8_t reg) {}
+  default async event void RTC.writeRegisterDone(uint8_t reg) {}
+  default async event void RTC.fired() { }
 }
index 48195ab7df17fb9a0410002f427eddb612a5c33b..e3563aebb1697d411ac6827aa3109b6330bce00b 100755 (executable)
@@ -45,8 +45,7 @@
 #define __RV8564_H__
 
 /* constants */
-#define RV8564_WR_ADDR 0xa2  //slave address write 0xa2 or read 0xa3   
-#define RV8564_RD_ADDR 0xa3 
+#define RV8564_ADDR    0xa2  //slave address   
 
 
 #define RV8564_CS1    0x00
index 0460da4c4175b650b60060521a89aa56fc915b01..db5543b300ef81765d9b1f4395c0f23f3d8349f1 100755 (executable)
@@ -180,8 +180,14 @@ implementation
       }
 
       call I2CClk.clr();
-      if (ack) call I2C.masterAck();
-      else     call I2C.masterNack();
+      if (ack) 
+      {
+        call I2C.masterAck();
+      }
+      else
+      {
+        call I2C.masterNack();
+      }
     }
     return retChar;
   }
@@ -219,13 +225,6 @@ implementation
       transition();
       call I2CClk.clr();
 
-      // ...Check the ACK from the receiver....  
-
-      //  if(SDA2==1){ACK=0;} /* ACK received£¿*/    
-      //  else  ACK= 1;
-
-      //  SCL2 = LOW;
-      //  transition();
       idle(); 
     }
   }
@@ -234,6 +233,7 @@ implementation
   {
     atomic
     {
+      call I2CData.makeOutput();
       call I2CClk.clr();
       call I2CData.clr(); // Low for ack
       transition();
@@ -249,6 +249,7 @@ implementation
   {
     atomic 
     {
+      call I2CData.makeOutput();
       call I2CClk.clr();
 
       call I2CData.set(); // High for nack