Skip to content

Commit

Permalink
Sensor: ADXL345: Fix ADXL345 driver
Browse files Browse the repository at this point in the history
Fixes problems with ADXL345 3-axis I2C accelerometer
reported in zephyrproject-rtos#23577, zephyrproject-rtos#23581 and zephyrproject-rtos#23584.

Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
  • Loading branch information
kamilrakoczy authored and mateusz-holenko committed Apr 22, 2020
1 parent 47fa55c commit 6886137
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/sensor/adxl345/adxl345.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int adxl345_sample_fetch(struct device *dev, enum sensor_channel chan)
return rc;
}

__ASSERT_NO_MSG(samples_count < ADXL345_MAX_FIFO_SIZE);
__ASSERT_NO_MSG(samples_count <= ARRAY_SIZE(data->bufx));

for (u8_t s = 0; s < samples_count; s++) {
rc = adxl345_read_sample(dev, &sample);
Expand All @@ -93,7 +93,7 @@ static int adxl345_channel_get(struct device *dev,
{
struct adxl345_dev_data *data = dev->driver_data;

if (data->sample_number > 32) {
if (data->sample_number >= ARRAY_SIZE(data->bufx)) {
data->sample_number = 0;
}

Expand Down

0 comments on commit 6886137

Please sign in to comment.