1 /* 2 * Copyright (c) 2022 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_DRIVERS_SENSOR_ICM42688_SPI_H_ 8 #define ZEPHYR_DRIVERS_SENSOR_ICM42688_SPI_H_ 9 10 #include <zephyr/device.h> 11 #include <zephyr/drivers/spi.h> 12 13 /** 14 * @brief perform a single SPI write to a ICM42688 register 15 * 16 * this functions wraps all logic necessary to write to any of the ICM42688 registers, regardless 17 * of which memory bank the register belongs to. 18 * 19 * @param bus SPI bus pointer 20 * @param reg address of ICM42688 register to write to 21 * @param data data byte to write to register 22 * @return int 0 on success, negative error code otherwise 23 */ 24 int icm42688_spi_single_write(const struct spi_dt_spec *bus, uint16_t reg, uint8_t data); 25 26 /** 27 * @brief update a single ICM42688 register value 28 * 29 * this functions wraps all logic necessary to update any of the ICM42688 registers, regardless 30 * of which memory bank the register belongs to. 31 * 32 * @param bus SPI bus pointer 33 * @param reg address of ICM42688 register to update 34 * @param mask bitmask defining which bits of the register to update 35 * @param data new value to update register with, respecting the bitmask 36 * @return int 0 on success, negative error code otherwise 37 */ 38 int icm42688_spi_update_register(const struct spi_dt_spec *bus, uint16_t reg, uint8_t mask, 39 uint8_t data); 40 41 /** 42 * @brief read from one or more ICM42688 registers 43 * 44 * this functions wraps all logic necessary to read from any of the ICM42688 registers, regardless 45 * of which memory bank the register belongs to. 46 * 47 * @param bus SPI bus pointer 48 * @param reg start address of ICM42688 register(s) to read from 49 * @param data pointer to byte array to read register values to 50 * @param len number of bytes to read from the device 51 * @return int 0 on success, negative error code otherwise 52 */ 53 int icm42688_spi_read(const struct spi_dt_spec *bus, uint16_t reg, uint8_t *data, size_t len); 54 55 #endif /* ZEPHYR_DRIVERS_SENSOR_ICM42688_SPI_H_ */ 56