]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
added D/A converdet interface and clean implementation
authorr-studio <r-studio>
Tue, 15 Dec 2009 08:48:39 +0000 (08:48 +0000)
committerr-studio <r-studio>
Tue, 15 Dec 2009 08:48:39 +0000 (08:48 +0000)
tos/chips/m16c62p/dac/HplM16c62pDac.nc [new file with mode: 0755]
tos/chips/m16c62p/dac/HplM16c62pDacC.nc [new file with mode: 0755]
tos/chips/m16c62p/dac/HplM16c62pDacP.nc [new file with mode: 0755]
tos/platforms/mulle/.platform

diff --git a/tos/chips/m16c62p/dac/HplM16c62pDac.nc b/tos/chips/m16c62p/dac/HplM16c62pDac.nc
new file mode 100755 (executable)
index 0000000..02a9e0a
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * HPL interface to the M16c62p D/A converers. 
+ *
+ * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
+ */
+
+interface HplM16c62pDac {
+  /**
+   * Sets the D/A value.
+   * @param value The new D/A value
+   */
+  async command void setValue(uint8_t value);
+  
+  /**
+   * Reads the current D/A value.
+   * @return D/A value
+   */
+  async command uint8_t getValue();
+
+  /**
+   * Enables the D/A converter.
+   */
+  async command void enable();
+
+  /**
+   * Disables the D/A converter.
+   */
+  async command void disable();
+
+  /**
+   * Checks the state of the D/A converter.
+   * @return TRUE if the D/A converter is enabled.
+   */
+  async command bool isEnabled();
+}
diff --git a/tos/chips/m16c62p/dac/HplM16c62pDacC.nc b/tos/chips/m16c62p/dac/HplM16c62pDacC.nc
new file mode 100755 (executable)
index 0000000..31b3961
--- /dev/null
@@ -0,0 +1,17 @@
+/**
+ * HPL for the M16c62p D/A conversion susbsystem.
+ *
+ * @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
+ */
+
+configuration HplM16c62pDacC {
+  provides interface HplM16c62pDac as Dac0;
+  provides interface HplM16c62pDac as Dac1;
+}
+implementation {
+  components new HplM16c62pDacP(&DA0, 0) as Dac0_, 
+             new HplM16c62pDacP(&DA1, 1) as Dac1_;
+
+  Dac0 = Dac0_;
+  Dac1 = Dac1_;
+}
diff --git a/tos/chips/m16c62p/dac/HplM16c62pDacP.nc b/tos/chips/m16c62p/dac/HplM16c62pDacP.nc
new file mode 100755 (executable)
index 0000000..c99b110
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ * HPL for the M16c62p A/D conversion susbsystem.
+ *
+ * @author Fan Zhang <fanzha@ltu.se>
+ *
+ */
+
+generic module HplM16c62pDacP(uint16_t da_addr,
+                              uint8_t da_num)
+{
+  provides interface HplM16c62pDac;
+}
+implementation
+{
+#define da (*TCAST(volatile uint8_t* ONE, da_addr))
+
+  async command void HplM16c62pDac.setValue(uint8_t value)
+  {
+    da = value;
+  }
+  
+  async command uint8_t HplM16c62pDac.getValue()
+  {
+    return da;
+  }
+
+  async command void HplM16c62pDac.enable()
+  {
+    SET_BIT(DACON.BYTE, da_num);
+  }
+
+  async command void HplM16c62pDac.disable()
+  {
+    CLR_BIT(DACON.BYTE, da_num);
+  }
+
+  async command bool HplM16c62pDac.isEnabled()
+  {
+    return (READ_BIT(DACON.BYTE, da_num) ? true : false);
+  }
+}
index f8aba77e23af1f58e854e6b89e5fdb90f4145632..b912ac0cbef6840e7394b18cc1abda3f37c117b7 100755 (executable)
@@ -21,6 +21,7 @@ push( @includes, qw(
   %T/chips/m16c62p
   %T/chips/m16c62p/control
   %T/chips/m16c62p/adc
+  %T/chips/m16c62p/dac
   %T/chips/m16c62p/pins
   %T/chips/m16c62p/timer
   %T/chips/m16c62p/uart