Skip to content

Commit

Permalink
update byte timeout name
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-goddard committed Jan 9, 2025
1 parent 4897370 commit d7b848a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lis3dh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ bool LIS3DH::read_accel(float *x, float *y, float *z) {
// MSB of 1 indicates register auto-increment
uint8_t reg = LIS3DH_REG_OUT_X_L | 0x80;

if (i2c_write_timeout_us(i2c, LIS3DH_ADDR, &reg, 1, true, BYTE_TIMEOUT_US) < 1) {
if (i2c_write_timeout_us(i2c, LIS3DH_ADDR, &reg, 1, true, LIS3DH_BYTE_TIMEOUT_US) < 1) {
return false;
}
if (i2c_read_timeout_us(i2c, LIS3DH_ADDR, raw, 6, false, BYTE_TIMEOUT_US) < 1) {
if (i2c_read_timeout_us(i2c, LIS3DH_ADDR, raw, 6, false, 6 * LIS3DH_BYTE_TIMEOUT_US) < 1) {
return false;
}

Expand All @@ -81,8 +81,8 @@ uint8_t LIS3DH::get_id() {
uint8_t val;
uint8_t reg = LIS3DH_REG_WHO_AM_I;

i2c_write_timeout_us(i2c, LIS3DH_ADDR, &reg, 1, true, BYTE_TIMEOUT_US);
i2c_read_timeout_us(i2c, LIS3DH_ADDR, &val, 1, false, BYTE_TIMEOUT_US);
i2c_write_timeout_us(i2c, LIS3DH_ADDR, &reg, 1, true, LIS3DH_BYTE_TIMEOUT_US);
i2c_read_timeout_us(i2c, LIS3DH_ADDR, &val, 1, false, LIS3DH_BYTE_TIMEOUT_US);

return val;
}
Expand All @@ -92,7 +92,7 @@ bool LIS3DH::write_register(const uint8_t reg, const uint8_t val) {
buf[0] = reg;
buf[1] = val;

if (i2c_write_timeout_us(i2c, LIS3DH_ADDR, buf, 2, false, BYTE_TIMEOUT_US) < 1) {
if (i2c_write_timeout_us(i2c, LIS3DH_ADDR, buf, 2, false, 2 * LIS3DH_BYTE_TIMEOUT_US) < 1) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lis3dh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define LIS3DH_REG_WHO_AM_I (0x0F)
#define LI3DH_WHO_AM_I (0x33)

#define BYTE_TIMEOUT_US (1000)
#define LIS3DH_BYTE_TIMEOUT_US (1000)

/**
* Representation of the LIS3DH sensor
Expand Down

0 comments on commit d7b848a

Please sign in to comment.