drivers/sensor: stmemsc: make use of i2c/spi dt APIs

Make use of the i2c and spi DT APIs introduced in
2946a535 and c894ad12 that get i2c_dt_spec and spi_dt_spec
as input arguments.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
Armando Visconti 2021-12-10 17:49:30 +01:00 committed by Maureen Helm
parent 9407add27c
commit 13bf2e5e48
2 changed files with 4 additions and 8 deletions

View file

@ -12,13 +12,11 @@
int stmemsc_i2c_read(const struct i2c_dt_spec *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len)
{
return i2c_burst_read(stmemsc->bus, stmemsc->addr,
reg_addr, value, len);
return i2c_burst_read_dt(stmemsc, reg_addr, value, len);
}
int stmemsc_i2c_write(const struct i2c_dt_spec *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len)
{
return i2c_burst_write(stmemsc->bus, stmemsc->addr,
reg_addr, value, len);
return i2c_burst_write_dt(stmemsc, reg_addr, value, len);
}

View file

@ -17,7 +17,6 @@
int stmemsc_spi_read(const struct spi_dt_spec *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len)
{
const struct spi_config *spi_cfg = &stmemsc->config;
uint8_t buffer_tx[2] = { reg_addr | SPI_READ, 0 };
/* write 1 byte with reg addr (msb at 1) + 1 dummy byte */
@ -34,7 +33,7 @@ int stmemsc_spi_read(const struct spi_dt_spec *stmemsc,
};
const struct spi_buf_set rx = { .buffers = rx_buf, .count = 2 };
return spi_transceive(stmemsc->bus, spi_cfg, &tx, &rx);
return spi_transceive_dt(stmemsc, &tx, &rx);
}
/*
@ -43,7 +42,6 @@ int stmemsc_spi_read(const struct spi_dt_spec *stmemsc,
int stmemsc_spi_write(const struct spi_dt_spec *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len)
{
const struct spi_config *spi_cfg = &stmemsc->config;
uint8_t buffer_tx[1] = { reg_addr & ~SPI_READ };
/*
@ -56,5 +54,5 @@ int stmemsc_spi_write(const struct spi_dt_spec *stmemsc,
};
const struct spi_buf_set tx = { .buffers = tx_buf, .count = 2 };
return spi_write(stmemsc->bus, spi_cfg, &tx);
return spi_write_dt(stmemsc, &tx);
}