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.
Diff: ADS1100.cpp
- Revision:
- 0:b211ff96822b
- Child:
- 1:ccf2f06f72d0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ADS1100.cpp Thu May 31 04:28:43 2018 +0000 @@ -0,0 +1,42 @@ +//********************** +// ADS1100.cpp for mbed +// +// +// +// (C)Copyright 2018 All rights reserved by K.Hongu +//********************** + +#include "mbed.h" +#include "ADS1100.h" + +ADS1100::ADS1100 (PinName sda, PinName scl, uint8_t addr) : _i2c(sda, scl) { + init(addr); +} +ADS1100::ADS1100 (I2C& p_i2c, uint8_t addr) : _i2c(p_i2c) { + init(addr); +} + +void init(uint8_t addr) { + address = ADS1100_ADDR << 3 + addr // make address + + config.bit.ST=0; // must be 0 + config.bit.RE=0; // must be 0 + config.bit.SC=0; // continuous mode + config.bit.DR=3; // 8SPS + config.bit.PGA=0; // No GAIN + + buf[0] = config.UC; + + _i2c.write(address, buf, 1); +} + +uint16_t ADS1100::get() +{ + + _i2c.read(address , buf, 3); + + result.byte.UB=buf[0]; + result.byte.LB=buf[1]; + config.UC=buf[2]; + return result.S; // 16bit +} \ No newline at end of file