Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: TPL0102.cpp
- Revision:
- 0:54d71ce98029
diff -r 000000000000 -r 54d71ce98029 TPL0102.cpp
--- /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);
+}