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.
Dependents: AMS_CCS811_gas_sensor AMS_CCS811_gas_sensor
Diff: AMS_ENS210.cpp
- Revision:
- 5:22b8ef3a65e1
- Parent:
- 4:31fbbf39d935
- Child:
- 6:475b764b720d
diff -r 31fbbf39d935 -r 22b8ef3a65e1 AMS_ENS210.cpp
--- a/AMS_ENS210.cpp Thu Jan 19 11:55:39 2017 +0000
+++ b/AMS_ENS210.cpp Fri Jan 20 14:33:17 2017 +0000
@@ -91,12 +91,12 @@
bool AMS_ENS210::start(bool temp, bool humid) {
char cmd[1] = {0 | temp | (humid << 1)};
- return i2c_write(SENS_START, cmd, 1) == 1; //_i2c->write(SLAVE_ADDR, cmd, 2) == 2;
+ return i2c_write(SENS_START, cmd, 1) == 1; //_i2c->write(ENS210_ENS210_ENS210_ENS210_ENS210_ENS210_ENS210_SLAVE_ADDR, cmd, 2) == 2;
}
bool AMS_ENS210::stop(bool temp, bool humid) {
char cmd[1] = {0 | temp | (humid << 1)};
- return i2c_write(SENS_STOP, cmd, 1) == 1; //_i2c->write(SLAVE_ADDR, cmd, 2) == 2;
+ return i2c_write(SENS_STOP, cmd, 1) == 1; //_i2c->write(ENS210_ENS210_ENS210_ENS210_ENS210_ENS210_ENS210_SLAVE_ADDR, cmd, 2) == 2;
}
bool AMS_ENS210::temp_is_measuring() {
@@ -197,12 +197,12 @@
if (system) {
cmd[0] = 0 | _power_mode | _reset << 7; // bit 0 of SYS_CTRL is power mode, bit 7 is reset
- w_bytes += i2c_write(SYS_CONFIG, cmd, 1); //_i2c->write(SLAVE_ADDR, cmd, 2);
+ w_bytes += i2c_write(SYS_CONFIG, cmd, 1); //_i2c->write(ENS210_ENS210_ENS210_ENS210_ENS210_ENS210_ENS210_SLAVE_ADDR, cmd, 2);
}
if (sensor) {
cmd[0] = 0 | _temp_mode | (_humid_mode << 1); // bit 0 is temp mode, bit 1 is humid mode
- w_bytes += i2c_write(SENS_OP_MODE, cmd, 1); //_i2c->write(SLAVE_ADDR, cmd, 2);
+ w_bytes += i2c_write(SENS_OP_MODE, cmd, 1); //_i2c->write(ENS210_ENS210_ENS210_ENS210_ENS210_ENS210_ENS210_SLAVE_ADDR, cmd, 2);
}
return w_bytes == (system + sensor);
@@ -227,10 +227,10 @@
int read_count = 0;
_i2c->start(); // send start condition for write
- if(_i2c->write(SLAVE_ADDR_W) == 1) { // write slave address with write bit
+ if(_i2c->write(ENS210_SLAVE_ADDR_W) == 1) { // write slave address with write bit
if(_i2c->write(reg_addr) == 1) { // write register address
_i2c->start(); // send another start condition for read
- if(_i2c->write(SLAVE_ADDR_R) == 1) { // write slave address with read bit
+ if(_i2c->write(ENS210_SLAVE_ADDR_R) == 1) { // write slave address with read bit
for (int i = 0; i < len; i++) { // read len bytes
output[i] = _i2c->read(i < len-1 ? 1 : 0); // ack all reads aside from the final one (i == len-1)
read_count++;
@@ -248,7 +248,7 @@
int write_count = 0;
_i2c->start(); // send start condition for write
- if(_i2c->write(SLAVE_ADDR_W) == 1) { // write slave address
+ if(_i2c->write(ENS210_SLAVE_ADDR_W) == 1) { // write slave address
if(_i2c->write(reg_addr) == 1) { // write register address
for (int i = 0; i < len; i++) { // write len bytes
if(_i2c->write(input[i]) == 1) write_count++; // write each byte, if successful increment count