sensors: stmemsc: add I3C access functions

This adds I3C access functions so that STM sensors connected
on I3C bus can utilize I3C.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2022-06-13 10:51:16 -07:00 committed by Anas Nashif
parent 4b26bd3349
commit eb9cd9242c
3 changed files with 35 additions and 0 deletions

View file

@ -7,4 +7,5 @@
zephyr_library()
zephyr_library_sources_ifdef(CONFIG_I2C stmemsc_i2c.c)
zephyr_library_sources_ifdef(CONFIG_I3C stmemsc_i3c.c)
zephyr_library_sources_ifdef(CONFIG_SPI stmemsc_spi.c)

View file

@ -11,6 +11,7 @@
#define ZEPHYR_DRIVERS_SENSOR_STMEMSC_STMEMSC_H_
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i3c.h>
#include <zephyr/drivers/spi.h>
#ifdef CONFIG_I2C
@ -20,6 +21,13 @@ int stmemsc_i2c_write(const struct i2c_dt_spec *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len);
#endif
#ifdef CONFIG_I3C
int stmemsc_i3c_read(void *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len);
int stmemsc_i3c_write(void *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len);
#endif
#ifdef CONFIG_SPI
int stmemsc_spi_read(const struct spi_dt_spec *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len);

View file

@ -0,0 +1,26 @@
/* ST Microelectronics STMEMS hal i/f
*
* Copyright (c) 2021 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*
* zephyrproject-rtos/modules/hal/st/sensor/stmemsc/
*/
#include "stmemsc.h"
int stmemsc_i3c_read(void *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len)
{
struct i3c_device_desc *target = **(struct i3c_device_desc ***)stmemsc;
return i3c_burst_read(target, reg_addr, value, len);
}
int stmemsc_i3c_write(void *stmemsc,
uint8_t reg_addr, uint8_t *value, uint8_t len)
{
struct i3c_device_desc *target = **(struct i3c_device_desc ***)stmemsc;
return i3c_burst_write(target, reg_addr, value, len);
}