Skip to content

Commit 0b6b2a0

Browse files
committed
feat: add BMI270 for component
1 parent 4f0b699 commit 0b6b2a0

File tree

21 files changed

+3673
-305
lines changed

21 files changed

+3673
-305
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Push components to Espressif Component Service
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
upload_components:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@master
13+
with:
14+
submodules: 'recursive'
15+
- name: Upload components to component service
16+
uses: espressif/upload-components-ci-action@v1
17+
with:
18+
name: "BMI270"
19+
namespace: "espressif2022"
20+
api_token: ${{secrets.IDF_COMPONENT_API_TOKEN}}

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# vscode
2+
.vscode/
3+
4+
# build
5+
**/build
6+
**/sdkconfig.old
7+
8+
# managed_components
9+
**/managed_components
10+
11+
# docs build files
12+
docs/__pycache__
13+
docs/_build
14+
15+
# dependencies.lock
16+
**/dependencies.lock

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# ChangeLog
2+
3+
## v1.0.1~1 Initial Version
4+
5+
* Added sensor bmi_270.

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
idf_component_register(
2+
SRC_DIRS "." "./bmi270_examples/common/"
3+
INCLUDE_DIRS "." "./bmi270_examples/"
4+
REQUIRES "driver"
5+
)
6+
7+
include(package_manager)
8+
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})

Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
menu "IMU Sensor Selection"
2+
3+
choice
4+
prompt "Select sensor type"
5+
default SENSOR_BMI270
6+
7+
config SENSOR_BMI220
8+
bool "BMI220 support"
9+
10+
config SENSOR_BMI270
11+
bool "BMI270 support"
12+
13+
endchoice
14+
15+
endmenu

bmi2.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ int8_t bmi2_soft_reset(struct bmi2_dev *dev)
20972097
{
20982098
/* Reset bmi2 device */
20992099
rslt = bmi2_set_regs(BMI2_CMD_REG_ADDR, &data, 1, dev);
2100-
dev->delay_us(2000, dev->intf_ptr);
2100+
dev->delay_us(20 * 1000, dev->intf_ptr);
21012101

21022102
/* Set APS flag as after soft reset the sensor is on advance power save mode */
21032103
dev->aps_status = BMI2_ENABLE;
@@ -5635,11 +5635,11 @@ static int8_t write_config_file(struct bmi2_dev *dev)
56355635
/* Enable loading of the configuration */
56365636
rslt = set_config_load(BMI2_ENABLE, dev);
56375637

5638-
if (rslt == BMI2_OK)
5639-
{
5640-
/* Enable advanced power save mode */
5641-
rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
5642-
}
5638+
// if (rslt == BMI2_OK)
5639+
// {
5640+
// /* Enable advanced power save mode */
5641+
// rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
5642+
// }
56435643
}
56445644
}
56455645
}

bmi2.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ extern "C" {
5959
/*! Header files
6060
****************************************************************************/
6161
#include "bmi2_defs.h"
62+
#include "freertos/FreeRTOS.h"
63+
#include "freertos/task.h"
64+
#include "esp_log.h"
65+
#include "esp_check.h"
6266

67+
#include "driver/i2c.h"
6368
/***************************************************************************/
6469

6570
/*! BMI2XY User Interface function prototypes

bmi270.c

Lines changed: 734 additions & 0 deletions
Large diffs are not rendered by default.

bmi270.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ extern "C" {
6262
****************************************************************************/
6363

6464
/*! @name BMI270 Chip identifier */
65+
#if CONFIG_SENSOR_BMI220
66+
#define BMI270_CHIP_ID UINT8_C(0x26)
67+
#elif CONFIG_SENSOR_BMI270
6568
#define BMI270_CHIP_ID UINT8_C(0x24)
69+
#else
70+
#error "Invalid sensor selected"
71+
#endif
72+
73+
#define BMI270_I2C_ADDRESS UINT8_C(0x68)
6674

6775
/*! @name BMI270 feature input start addresses */
6876
#define BMI270_CONFIG_ID_STRT_ADDR UINT8_C(0x00)
@@ -125,6 +133,55 @@ extern "C" {
125133
/*! BMI270 User Interface function prototypes
126134
****************************************************************************/
127135

136+
/**
137+
* @brief BMI270 I2C configuration structure
138+
*
139+
* This structure contains the configuration parameters for communicating with
140+
* the BMI270 sensor over I2C. It specifies the I2C port and the I2C address of
141+
* the BMI270 device.
142+
*/
143+
typedef struct {
144+
i2c_port_t i2c_port; /*!< I2C port used to connect to the BMI270 device */
145+
uint8_t i2c_addr; /*!< I2C address of the BMI270 device, can be 0x38 or 0x39 depending on the A0 pin */
146+
} bmi270_i2c_config_t;
147+
148+
/**
149+
* @brief Handle type for BMI270 sensor
150+
*
151+
* This is a pointer to a structure representing the BMI270 device. It is used
152+
* as a handle for interacting with the sensor.
153+
*/
154+
typedef struct bmi2_dev * bmi270_handle_t;
155+
156+
/**
157+
* @brief Create and initialize a BMI270 sensor object
158+
*
159+
* This function initializes the BMI270 sensor and prepares it for use.
160+
* It configures the I2C interface and creates a handle for further communication.
161+
*
162+
* @param[in] i2c_conf Pointer to the I2C configuration structure
163+
* @param[out] handle_ret Pointer to a variable that will hold the created sensor handle
164+
* @return
165+
* - ESP_OK: Successfully created the sensor object
166+
* - ESP_ERR_INVALID_ARG: Invalid arguments were provided
167+
* - ESP_FAIL: Failed to initialize the sensor
168+
*/
169+
esp_err_t bmi270_sensor_create(const bmi270_i2c_config_t *i2c_conf, bmi270_handle_t *handle_ret);
170+
171+
/**
172+
* @brief Delete and release a BMI270 sensor object
173+
*
174+
* This function releases the resources allocated for the BMI270 sensor.
175+
* It should be called when the sensor is no longer needed.
176+
*
177+
* @param[in] handle Handle of the BMI270 sensor object
178+
* @return
179+
* - ESP_OK: Successfully deleted the sensor object
180+
* - ESP_ERR_INVALID_ARG: Invalid handle was provided
181+
* - ESP_FAIL: Failed to delete the sensor object
182+
*/
183+
esp_err_t bmi270_sensor_del(bmi270_handle_t handle);
184+
128185
/**
129186
* \ingroup bmi270
130187
* \defgroup bmi270ApiInit Initialization

0 commit comments

Comments
 (0)