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.
ADS1100.cpp
- Committer:
- hongu
- Date:
- 2018-06-20
- Revision:
- 2:7ee26d7e2997
- Parent:
- 1:ccf2f06f72d0
- Child:
- 3:7c8d1aa80a9d
File content as of revision 2:7ee26d7e2997:
//********************** // 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, char addr) : _i2c(sda, scl) { init(addr); } ADS1100::ADS1100 (I2C& p_i2c, char addr) : _i2c(p_i2c) { init(addr); } void ADS1100::init(char 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 }