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-08-03
- Revision:
- 5:687975ef50d2
- Parent:
- 4:25de15d742ba
- Child:
- 6:160ba0125b18
File content as of revision 5:687975ef50d2:
//********************** // 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 + (addr << 1); // 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; // 1倍 GAIN buf[0] = config.UC; _i2c.write(address, buf, 1); } void ADS1100::init() { 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; // 1倍 GAIN buf[0] = config.UC; _i2c.write(address, buf, 1); } short ADS1100::get() { _i2c.read(address , buf, 3); result.byte.UB=buf[1]; result.byte.LB=buf[0]; config.UC=buf[2]; if (config.UC == 0b10001100) { init(); } return result.S; // 16bit } //char ADS1100::get() { // _i2c.read(address , buf, 3); // // result.byte.UB=buf[1]; // result.byte.LB=buf[0]; // config.UC=buf[2]; // // return config.UC; //}