Library for TI's DRV2667

Revision:
1:a57042b30965
Parent:
0:faa5d89e9dac
Child:
2:101901b3f05e
diff -r faa5d89e9dac -r a57042b30965 DRV2667.h
--- a/DRV2667.h	Wed Feb 07 09:20:34 2018 +0000
+++ b/DRV2667.h	Thu Feb 08 02:12:16 2018 +0000
@@ -1,34 +1,26 @@
-/*
-    Taku Hachisu 06/02/2018
-
-    Library for the TI DRV2667
-
-    References:
-    http://www.ti.com/product/DRV2667/description
-    http://www.tij.co.jp/jp/lit/ds/symlink/drv2667.pdf (Datasheet)
-*/
-
 #ifndef DRV2667_H
 #define DRV2667_H
 
 #include "mbed.h"
 
-/******************************************************************************
-***** DRV2667 Addresses
-******************************************************************************/
-#define SLAVE_ADDR_7_BIT 0x59 // 7-bit slave address 
+// DRV2667 Slave Address
+#define SLAVE_ADDR_7_BIT 0x59
+
+/** Library for the TI DRV2667
+ *
+ */
 
 class DRV2667
 {
 
 public:
-    //// Selects the source to be played in register 0x01, bit 2
+    // Selects the source to be played in register 0x01, bit 2
     enum InputMux {
         Digital = 0,    // Digital input source
         Analog = 0x04,  // Analog input source
     };
 
-    //// Selects the gain for the amplifier in register 0x01, bits [1:0]
+    // Selects the gain for the amplifier in register 0x01, bits [1:0]
     enum Gain {
         GNx1,    // 0x00:  50 Vpp - 28.8 dB
         GNx2,    // 0x01: 100 Vpp - 34.8 dB
@@ -36,9 +28,9 @@
         GNx4,    // 0x03: 200 Vpp - 40.7 dB
     };
 
-    //// Time period when the FIFO runs empty and the device goes into idle
-    //// mode, powering down the boost converter and amplifier in register
-    //// 0x02, bits [3:2]
+    // Time period when the FIFO runs empty and the device goes into idle
+    // mode, powering down the boost converter and amplifier in register
+    // 0x02, bits [3:2]
     enum Timeout {
         TOx1 = 0,    // 5 msec
         TOx2 = 0x04,    // 10 msec
@@ -47,10 +39,10 @@
     };
 
     /**
-    * Create a DRV2605 object
+    * Create a DRV2667 object
     *
     * @param &i2c pointer of I2C object
-    * @param isDigital true: digital input source, false: analog input source
+    * @param im DRV2667::Digital or DRV2667::Analog
     * @param gn gain for the amplifier
     * @param to timeout for FIFO interface (digital input only)
     */
@@ -68,7 +60,7 @@
         @param reg  The device register to read
         @return     The result
     */
-    uint8_t i2cReadByte(char reg);
+    char i2cReadByte(char reg);
 
     /**
         Starts waveform playback
@@ -88,26 +80,27 @@
     */
     void setWaveform(char* id, char setNum);
 
-    /**
-        Entry point for FIFO data read out automatically at an 8-kHz sampling rate
-        @param data     signed 8-bit data
-    */
-    void loadFIFO(signed char data, char size);
+    ///**
+    //    Entry point for FIFO data read out automatically at an 8-kHz sampling rate
+    //
+    //    @param data signed 8-bit data
+    //    @param size size of waveform
+    //    To be implemented
+    //*/
+    //void loadFIFO(signed char* data, char size);
 
     /**
         Set internal wavefrom storage for the Waveform Synthesis Playback mode
-        @param data array of parameters of sinusoid, which are:
-                    0: Peak voltage = amp / 255  x Gain / 2
-                    1: Sinusoidal frequency in Herz
-                    2: Number of cycles to be played
-                    3: The envelope setting:
-                    bits [7:4] sets ramp-up rate
-                    bits [3:0] sets ramp-down rate
-                    0x00 NoEnvelope; 0x01 32ms; 0x02 64ms; 0x03 96ms; 0x04 128ms;
-                    0x05 160ms; 0x06 192ms; 0x07 224ms; 0x08 256ms; 0x09 512ms;
-                    0x0A 768ms; 0x0B 1024ms; 0xC 1280ms; 0x0D 1536ms; 0x0E 1792ms;
-                    0x0F 2048ms;
-        @param waveNum  the number of waveform
+        @param data[][0] Peak voltage = amp / 255  x Gain / 2
+        @param data[][1] Sinusoidal frequency
+        @param data[][2] Number of cycles to be played
+        @param data[][3] The envelope setting: bits [7:4] sets ramp-up rate; 
+                         bits [3:0] sets ramp-down rate. 0x00 NoEnvelope; 0x01 
+                         32ms; 0x02 64ms; 0x03 96ms; 0x04 128ms; 0x05 160ms; 
+                         0x06 192ms; 0x07 224ms; 0x08 256ms; 0x09 512ms; 0x0A
+                         768ms; 0x0B 1024ms; 0xC 1280ms; 0x0D 1536ms; 0x0E
+                         1792ms; 0x0F 2048ms.
+        @param waveNum the number of waveform
     */
     void setWSP(char data[][4], char waveNum);