sensors: Move SCU-specific bmi160 sensor into spresense board

Move SCU-specific bmi160 sensor into spresense board layer.
This commit is contained in:
SPRESENSE 2023-08-24 16:09:12 +09:00 committed by Xiang Xiao
parent 795dcee521
commit ffcea1da4f
3 changed files with 80 additions and 22 deletions

View file

@ -31,6 +31,7 @@
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
#include <nuttx/sensors/bmi160.h>
#include <arch/board/cxd56_bmi160.h>
#include <arch/chip/scu.h>
#if defined(CONFIG_SENSORS_BMI160_SCU_SPI)

View file

@ -60,6 +60,83 @@ extern "C"
int board_bmi160_initialize(int bus);
#ifdef CONFIG_SENSORS_BMI160_SCU
/****************************************************************************
* Name: bmi160_init
*
* Description:
* Initialize BMI160 accelerometer/gyro device
*
* Input Parameters:
* dev - An instance of the SPI or I2C interface to use to communicate
* with BMI160
* port - I2C port number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_SENSORS_BMI160_I2C
int bmi160_init(FAR struct i2c_master_s *dev, int port);
#else /* CONFIG_SENSORS_BMI160_SPI */
int bmi160_init(struct spi_dev_s *dev);
#endif
/****************************************************************************
* Name: bmi160gyro_register
*
* Description:
* Register the BMI160 gyro character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/gyro"
* minor - The number of sequencer
* dev - An instance of the SPI or I2C interface to use to communicate
* with BMI160
* port - I2C port number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_SENSORS_BMI160_I2C
int bmi160gyro_register(const char *devpath, int minor,
struct i2c_master_s *dev, int port);
#else /* CONFIG_SENSORS_BMI160_SPI */
int bmi160gyro_register(const char *devpath, int minor,
struct spi_dev_s *dev);
#endif
/****************************************************************************
* Name: bmi160accel_register
*
* Description:
* Register the BMI160 accelerometer character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/accel"
* minor - The number of sequencer
* dev - An instance of the SPI or I2C interface to use to communicate
* with BMI160
* port - I2C port number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_SENSORS_BMI160_I2C
int bmi160accel_register(const char *devpath, int minor,
struct i2c_master_s *dev, int port);
#else /* CONFIG_SENSORS_BMI160_SPI */
int bmi160accel_register(const char *devpath, int minor,
struct spi_dev_s *dev);
#endif
#endif /* CONFIG_SENSORS_BMI160_SCU */
#undef EXTERN
#if defined(__cplusplus)
}

View file

@ -131,30 +131,10 @@ extern "C"
*
****************************************************************************/
#ifndef CONFIG_SENSORS_BMI160_SCU
# ifdef CONFIG_SENSORS_BMI160_I2C
#ifdef CONFIG_SENSORS_BMI160_I2C
int bmi160_register(FAR const char *devpath, FAR struct i2c_master_s *dev);
# else /* CONFIG_BMI160_SPI */
#else /* CONFIG_BMI160_SPI */
int bmi160_register(FAR const char *devpath, FAR struct spi_dev_s *dev);
# endif
#else /* CONFIG_SENSORS_BMI160_SCU */
# ifdef CONFIG_SENSORS_BMI160_I2C
int bmi160_init(FAR struct i2c_master_s *dev, int port);
int bmi160gyro_register(FAR const char *devpath, int minor,
FAR struct i2c_master_s *dev, int port);
int bmi160accel_register(FAR const char *devpath, int minor,
FAR struct i2c_master_s *dev, int port);
# else /* CONFIG_SENSORS_BMI160_SPI */
int bmi160_init(FAR struct spi_dev_s *dev);
int bmi160gyro_register(FAR const char *devpath, int minor,
FAR struct spi_dev_s *dev);
int bmi160accel_register(FAR const char *devpath, int minor,
FAR struct spi_dev_s *dev);
# endif
#endif
#undef EXTERN