DECS_Tubee / Mbed 2 deprecated TPL0102_Potentiometer

Dependencies:   mbed

Revision:
0:54d71ce98029
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TPL0102.cpp	Wed Jan 23 06:56:03 2019 +0000
@@ -0,0 +1,29 @@
+#include "TPL0102.h"
+
+TPL0102::TPL0102(PinName SDA, 
+                 PinName SCL) : i2c_(SDA, SCL)
+{
+    i2c_.frequency(100000);
+//    i2c_.start();
+    wait_us(500);
+}
+
+int TPL0102::SlaveSelect(char address, char settings)
+{
+    return oneByteWrite(address, settings);
+}
+
+int TPL0102::AccessControlRegister(char settings)
+{
+    int tx=TPL0102_ACR;
+    return oneByteWrite(tx, settings);
+}
+
+int TPL0102::oneByteWrite(char address, char data)
+{
+   int ack = 0;
+   char tx[2];
+   tx[0] = address;
+   tx[1] = data;
+   return   ack | i2c_.write( TPL0102_Potentiometer_Address << 1 & 0xFE , tx, 2);  
+}