Library for working with the HYCON HY3116/8 24-bit weigh-scales ADC series.
Diff: HY3116.cpp
- Revision:
- 3:535ed9a0ce59
- Parent:
- 2:2da9fbab02b7
- Child:
- 4:1571244a8486
--- a/HY3116.cpp Mon Jun 13 00:43:19 2016 +0000 +++ b/HY3116.cpp Tue Jun 28 13:27:09 2016 +0000 @@ -1,7 +1,29 @@ #include "HY3116.h" // Define I2C pins (SDA,SCL) -static I2C i2c(p6,p5); // nRF51-DK +//static I2C i2c(p6,p5); // nRF51-DK +//static I2C i2c(p7,p20); // nRF51-DK +//static I2C i2c(p22,p21); // nRF51-DK + +/** + * Constructor. + * Prepares the output pins. + */ +HY3116::HY3116(PinName sda, + PinName scl) +{ + i2c(sda, scl); + // Set the I2C clock frequency + i2c.frequency(100000); +} // End constructor + +/** + * Destructor. + */ +HY3116::~HY3116() +{ + +} // Single-byte write helper function void HY3116::writeByte(uint8_t address, uint8_t subAddress, uint8_t data) @@ -78,8 +100,6 @@ // void HY3116::init() { - // Set the I2C clock frequency - i2c.frequency(100000); // Set-up the SYS register writeByte(HY3116_ADDRESS, SYS, 0b00011100); // Enable the ADC & LDO