drivers/sensors: add BMI270 IMU support
This commit is contained in:
parent
0ed9842180
commit
e1ffacfc33
@ -182,6 +182,35 @@ config BMI160_I2C_ADDR_69
|
|||||||
endchoice
|
endchoice
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
config SENSORS_BMI270
|
||||||
|
bool "Bosch BMI270 Inertial Measurement Sensor support"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Enable driver support for the Bosch BMI270 Inertial
|
||||||
|
Measurement sensor
|
||||||
|
|
||||||
|
if SENSORS_BMI270
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "BMI270 Interface"
|
||||||
|
default SENSORS_BMI270_SPI
|
||||||
|
|
||||||
|
config SENSORS_BMI270_I2C
|
||||||
|
bool "BMI270 I2C Interface"
|
||||||
|
select I2C
|
||||||
|
---help---
|
||||||
|
Enables support for the I2C interface
|
||||||
|
|
||||||
|
config SENSORS_BMI270_SPI
|
||||||
|
bool "BMI270 SPI Interface"
|
||||||
|
select SPI
|
||||||
|
---help---
|
||||||
|
Enables support for the SPI interface
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
config SENSORS_BMP180
|
config SENSORS_BMP180
|
||||||
bool "Bosch BMP180 Barometer Sensor support"
|
bool "Bosch BMP180 Barometer Sensor support"
|
||||||
default n
|
default n
|
||||||
|
@ -132,6 +132,10 @@ ifeq ($(CONFIG_SENSORS_BMI160),y)
|
|||||||
CSRCS += bmi160.c
|
CSRCS += bmi160.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SENSORS_BMI270),y)
|
||||||
|
CSRCS += bmi270.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_BMP180),y)
|
ifeq ($(CONFIG_SENSORS_BMP180),y)
|
||||||
CSRCS += bmp180.c
|
CSRCS += bmp180.c
|
||||||
endif
|
endif
|
||||||
|
1483
drivers/sensors/bmi270.c
Normal file
1483
drivers/sensors/bmi270.c
Normal file
File diff suppressed because it is too large
Load Diff
103
include/nuttx/sensors/bmi270.h
Normal file
103
include/nuttx/sensors/bmi270.h
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/sensors/bmi270.h
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_SENSORS_BMI270_H
|
||||||
|
#define __INCLUDE_NUTTX_SENSORS_BMI270_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/compiler.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* struct 6-axis data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct accel_t
|
||||||
|
{
|
||||||
|
int16_t x;
|
||||||
|
int16_t y;
|
||||||
|
int16_t z;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct gyro_t
|
||||||
|
{
|
||||||
|
int16_t x;
|
||||||
|
int16_t y;
|
||||||
|
int16_t z;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct accel_gyro_st_s
|
||||||
|
{
|
||||||
|
struct gyro_t gyro;
|
||||||
|
struct accel_t accel;
|
||||||
|
uint32_t sensor_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: bmi270_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register the BMI270 character device as 'devpath'
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* devpath - The full path to the driver to register. E.g., "/dev/accel0"
|
||||||
|
* dev - An instance of the SPI or I2C interface to use to communicate
|
||||||
|
* with BMI270
|
||||||
|
* addr - (I2C only) I2C address
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_BMI270_I2C
|
||||||
|
struct i2c_master_s;
|
||||||
|
int bmi270_register(FAR const char *devpath, FAR struct i2c_master_s *dev,
|
||||||
|
uint8_t addr);
|
||||||
|
#else /* CONFIG_BMI270_SPI */
|
||||||
|
struct spi_dev_s;
|
||||||
|
int bmi270_register(FAR const char *devpath, FAR struct spi_dev_s *dev);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_SENSORS_BMI270_H */
|
@ -475,6 +475,7 @@
|
|||||||
#define SPIDEV_LPWAN(n) SPIDEV_ID(SPIDEVTYPE_LPWAN, (n))
|
#define SPIDEV_LPWAN(n) SPIDEV_ID(SPIDEVTYPE_LPWAN, (n))
|
||||||
#define SPIDEV_ADC(n) SPIDEV_ID(SPIDEVTYPE_ADC, (n))
|
#define SPIDEV_ADC(n) SPIDEV_ID(SPIDEVTYPE_ADC, (n))
|
||||||
#define SPIDEV_MOTOR(n) SPIDEV_ID(SPIDEVTYPE_MOTOR, (n))
|
#define SPIDEV_MOTOR(n) SPIDEV_ID(SPIDEVTYPE_MOTOR, (n))
|
||||||
|
#define SPIDEV_IMU(n) SPIDEV_ID(SPIDEVTYPE_IMU, (n))
|
||||||
#define SPIDEV_USER(n) SPIDEV_ID(SPIDEVTYPE_USER, (n))
|
#define SPIDEV_USER(n) SPIDEV_ID(SPIDEVTYPE_USER, (n))
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -515,6 +516,7 @@ enum spi_devtype_e
|
|||||||
SPIDEVTYPE_LPWAN, /* Select SPI LPWAN controller over SPI */
|
SPIDEVTYPE_LPWAN, /* Select SPI LPWAN controller over SPI */
|
||||||
SPIDEVTYPE_ADC, /* Select SPI ADC device */
|
SPIDEVTYPE_ADC, /* Select SPI ADC device */
|
||||||
SPIDEVTYPE_MOTOR, /* Select SPI motor device */
|
SPIDEVTYPE_MOTOR, /* Select SPI motor device */
|
||||||
|
SPIDEVTYPE_IMU, /* Select SPI IMU device */
|
||||||
SPIDEVTYPE_USER /* Board-specific values start here
|
SPIDEVTYPE_USER /* Board-specific values start here
|
||||||
* This must always be the last definition. */
|
* This must always be the last definition. */
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user