Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

driver: sensor: adxl367: Fix for conversion and SPI #80617

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions drivers/sensor/adi/adxl367/adxl367.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,9 @@
enum adxl367_range range)
#endif /*CONFIG_SENSOR_ASYNC_API*/
{
int64_t micro_ms2 = value * (SENSOR_G * 250 / 10000 *
int64_t micro_ms2 = value * (SENSOR_G * 250 / 1000 *
adxl367_scale_mul[range] / 1000);

Check notice on line 895 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:895 - int64_t micro_ms2 = value * (SENSOR_G * 250 / 1000 * - adxl367_scale_mul[range] / 1000); + int64_t micro_ms2 = value * (SENSOR_G * 250 / 1000 * adxl367_scale_mul[range] / 1000);
val->val1 = micro_ms2 / 1000000;
val->val2 = micro_ms2 % 1000000;
}
Expand All @@ -903,10 +903,10 @@
static void adxl367_temp_convert(struct sensor_value *val, int16_t value)
#endif /*CONFIG_SENSOR_ASYNC_API*/
{
int64_t temp_data = (value + ADXL367_TEMP_OFFSET) * ADXL367_TEMP_SCALE;
int64_t temp_data = (value - ADXL367_TEMP_25C);

val->val1 = temp_data / ADXL367_TEMP_SCALE_DIV;
val->val2 = temp_data % ADXL367_TEMP_SCALE_DIV;
val->val1 = temp_data / 54 /*temp sensitivity LSB/C*/ + 25/*bias test conditions*/;
val->val2 = temp_data % 54 * 10000;

Check notice on line 909 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:909 - val->val1 = temp_data / 54 /*temp sensitivity LSB/C*/ + 25/*bias test conditions*/; + val->val1 = temp_data / 54 /*temp sensitivity LSB/C*/ + 25 /*bias test conditions*/;
}

static int adxl367_channel_get(const struct device *dev,
Expand All @@ -932,6 +932,7 @@
break;
case SENSOR_CHAN_DIE_TEMP:
adxl367_temp_convert(val, data->temp_val);
break;
default:
return -ENOTSUP;
}
Expand Down
17 changes: 8 additions & 9 deletions drivers/sensor/adi/adxl367/adxl367_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@

addr_reg = ADXL367_TO_REG(reg);

const struct spi_buf buf[3] = {
uint8_t access[2] = {rw_reg, addr_reg};

const struct spi_buf buf[2] = {
{
.buf = &rw_reg,
.len = 1
}, {
.buf = &addr_reg,
.len = 1
.buf = access,
.len = 2
}, {
.buf = data,
.len = length
Expand All @@ -52,15 +51,15 @@
if ((reg & ADXL367_READ) != 0) {
const struct spi_buf_set rx = {
.buffers = buf,
.count = 3
.count = 2
};

Check notice on line 56 in drivers/sensor/adi/adxl367/adxl367_spi.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367_spi.c:56 - const struct spi_buf buf[2] = { - { - .buf = access, - .len = 2 - }, { - .buf = data, - .len = length - } - }; + const struct spi_buf buf[2] = {{.buf = access, .len = 2}, {.buf = data, .len = length}}; struct spi_buf_set tx = { .buffers = buf, }; if ((reg & ADXL367_READ) != 0) { - const struct spi_buf_set rx = { - .buffers = buf, - .count = 2 - }; + const struct spi_buf_set rx = {.buffers = buf, .count = 2};
tx.count = 2;
tx.count = 1;

return spi_transceive_dt(&config->spi, &tx, &rx);
}

tx.count = 3;
tx.count = 2;

return spi_write_dt(&config->spi, &tx);
}
Expand Down
Loading