Library for working with the HYCON HY3116/8 24-bit weigh-scales ADC series.
HY3116.h@8:530aad60c490, 2016-07-26 (annotated)
- Committer:
- seajayshore
- Date:
- Tue Jul 26 16:26:35 2016 +0000
- Revision:
- 8:530aad60c490
- Parent:
- 7:c9a0ce000a18
Refactoring & re-organisation with true C++ constructors.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
seajayshore | 6:435b50250491 | 1 | #include "main.h" |
seajayshore | 0:80768ca5d5ff | 2 | #include "mbed.h" |
seajayshore | 0:80768ca5d5ff | 3 | |
seajayshore | 8:530aad60c490 | 4 | /** |
seajayshore | 8:530aad60c490 | 5 | * Define I2C addresses for the device |
seajayshore | 8:530aad60c490 | 6 | */ |
seajayshore | 0:80768ca5d5ff | 7 | #define HY3116_ADDRESS 0xA0 |
seajayshore | 8:530aad60c490 | 8 | #define RESET_ADDRESS 0x00 |
seajayshore | 0:80768ca5d5ff | 9 | |
seajayshore | 8:530aad60c490 | 10 | /** |
seajayshore | 8:530aad60c490 | 11 | * Define settings & I2C command registers |
seajayshore | 8:530aad60c490 | 12 | */ |
seajayshore | 8:530aad60c490 | 13 | #define SYS 0x00 |
seajayshore | 8:530aad60c490 | 14 | #define ADC1 0x01 |
seajayshore | 8:530aad60c490 | 15 | #define ADC2 0x02 |
seajayshore | 8:530aad60c490 | 16 | #define ADC3 0x03 |
seajayshore | 8:530aad60c490 | 17 | #define ADC4 0x04 |
seajayshore | 8:530aad60c490 | 18 | #define ADO 0x05 |
seajayshore | 8:530aad60c490 | 19 | #define RESET 0x06 |
seajayshore | 0:80768ca5d5ff | 20 | |
seajayshore | 8:530aad60c490 | 21 | /** |
seajayshore | 8:530aad60c490 | 22 | * HY3116 class definition |
seajayshore | 8:530aad60c490 | 23 | */ |
seajayshore | 0:80768ca5d5ff | 24 | class HY3116 |
seajayshore | 0:80768ca5d5ff | 25 | { |
seajayshore | 2:2da9fbab02b7 | 26 | public: |
seajayshore | 8:530aad60c490 | 27 | HY3116(); |
seajayshore | 8:530aad60c490 | 28 | HY3116(PinName sda, PinName scl); |
seajayshore | 8:530aad60c490 | 29 | HY3116(PinName sda, PinName scl, int freq); |
seajayshore | 8:530aad60c490 | 30 | ~HY3116(); |
seajayshore | 7:c9a0ce000a18 | 31 | uint8_t readAdc(int32_t *_adcReading); |
seajayshore | 7:c9a0ce000a18 | 32 | bool init(); |
seajayshore | 0:80768ca5d5ff | 33 | |
seajayshore | 3:535ed9a0ce59 | 34 | private: |
seajayshore | 8:530aad60c490 | 35 | I2C i2c; |
seajayshore | 3:535ed9a0ce59 | 36 | |
seajayshore | 8:530aad60c490 | 37 | int writeRegister(uint8_t regAddress, uint8_t data); |
seajayshore | 8:530aad60c490 | 38 | int readRegister(uint8_t regAddress, uint8_t byteNum, uint8_t* dest); |
seajayshore | 8:530aad60c490 | 39 | int resetChip(); |
seajayshore | 7:c9a0ce000a18 | 40 | }; |