driver: sensor: adxl367: Fix for SPI
Fix for SPI communication when RTIO is used in SPI driver. When in adxl367_bus_access, const struct spi_buf buf[3] is used, spi_rtio_copy function won't set correct buffers and length for buf[2] and that will cause exception when that buffer is processed. Signed-off-by: Vladislav Pejic <vladislav.pejic@orioninc.com>
This commit is contained in:
parent
1a4085ad0f
commit
eb15f306b6
1 changed files with 8 additions and 9 deletions
|
@ -32,13 +32,12 @@ static int adxl367_bus_access(const struct device *dev, uint8_t reg,
|
|||
|
||||
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
|
||||
|
@ -52,15 +51,15 @@ static int adxl367_bus_access(const struct device *dev, uint8_t reg,
|
|||
if ((reg & ADXL367_READ) != 0) {
|
||||
const struct spi_buf_set rx = {
|
||||
.buffers = buf,
|
||||
.count = 3
|
||||
.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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue