Library for working with the HYCON HY3116/8 24-bit weigh-scales ADC series.

Revision:
8:530aad60c490
Parent:
7:c9a0ce000a18
diff -r c9a0ce000a18 -r 530aad60c490 HY3116.h
--- a/HY3116.h	Mon Jul 25 21:23:56 2016 +0000
+++ b/HY3116.h	Tue Jul 26 16:26:35 2016 +0000
@@ -1,29 +1,40 @@
 #include "main.h"
 #include "mbed.h"
 
+/**
+ * Define I2C addresses for the device
+ */
 #define HY3116_ADDRESS 0xA0
+#define RESET_ADDRESS  0x00
 
-#define SYS 0x00
-#define ADC1 0x01
-#define ADC2 0x02
-#define ADC3 0x03
-#define ADC4 0x04
-#define ADO 0x05
-#define RESET 0x06
+/**
+ * Define settings & I2C command registers
+ */
+#define SYS     0x00
+#define ADC1    0x01
+#define ADC2    0x02
+#define ADC3    0x03
+#define ADC4    0x04
+#define ADO     0x05
+#define RESET   0x06
 
-/* Function Prototypes */
+/**
+ * HY3116 class definition
+ */
 class HY3116 
 {
 public:
-//    HY3116(PinName sda, PinName scl);
-//    ~HY3116();
-    int writeByte(uint8_t address, uint8_t subAddress, uint8_t data);
-    int resetChip();
-    int readBytes(uint8_t address, uint8_t subAddress, uint8_t byteNum, uint8_t* dest, bool alreadyRead);
+    HY3116();
+    HY3116(PinName sda, PinName scl);
+    HY3116(PinName sda, PinName scl, int freq);
+    ~HY3116();
     uint8_t readAdc(int32_t *_adcReading);
     bool init();
     
 private:
-//    I2C i2c;
+    I2C i2c;
     
+    int writeRegister(uint8_t regAddress, uint8_t data);
+    int readRegister(uint8_t regAddress, uint8_t byteNum, uint8_t* dest);
+    int resetChip();
 };