Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add skip_reset bmi270_init, preventing soft reset during init #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bmi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,11 @@ static int8_t validate_foc_accel_axis(int16_t avg_foc_data, struct bmi2_dev *dev
* chip-id of the sensor.
*/
int8_t bmi2_sec_init(struct bmi2_dev *dev)
{
return bmi2_sec_init_with_opt(dev, 0);
}

int8_t bmi2_sec_init_with_opt(struct bmi2_dev *dev, uint8_t skip_reset)
{
/* Variable to define error */
int8_t rslt;
Expand Down Expand Up @@ -1928,6 +1933,8 @@ int8_t bmi2_sec_init(struct bmi2_dev *dev)
*/
dev->remap = axes_remap;

if (skip_reset) return BMI2_OK;

/* Perform soft-reset to bring all register values to their
* default values
*/
Expand Down
2 changes: 2 additions & 0 deletions bmi2.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ extern "C" {
*/
int8_t bmi2_sec_init(struct bmi2_dev *dev);

int8_t bmi2_sec_init_with_opt(struct bmi2_dev *dev, uint8_t skip_reset);

/*!
* \ingroup bmi2ApiInit
* \page bmi2_api_bmi2_set_spi_en bmi2_set_spi_en
Expand Down
4 changes: 2 additions & 2 deletions bmi270.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ static int8_t disable_sensor_features(uint64_t sensor_sel, struct bmi2_dev *dev)
* 4) Updates the feature offset parameters in the device structure.
* 5) Updates the maximum number of pages, in the device structure.
*/
int8_t bmi270_init(struct bmi2_dev *dev)
int8_t bmi270_init(struct bmi2_dev *dev, uint8_t skip_reset)
{
/* Variable to define error */
int8_t rslt;
Expand Down Expand Up @@ -1389,7 +1389,7 @@ int8_t bmi270_init(struct bmi2_dev *dev)
}

/* Initialize BMI2 sensor */
rslt = bmi2_sec_init(dev);
rslt = bmi2_sec_init_with_opt(dev, skip_reset);
if (rslt == BMI2_OK)
{
/* Assign the offsets of the feature input
Expand Down
2 changes: 1 addition & 1 deletion bmi270.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ extern "C" {
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_init(struct bmi2_dev *dev);
int8_t bmi270_init(struct bmi2_dev *dev, uint8_t skip_reset);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO you shouldn't modify the API, it will break all examples, and also all applications already using it, and just updating the driver.

Instead add a new API, bmi270_init_opt or smth else then:

int8_t bmi270_init(struct bmi2_dev *dev)
{
 return bmi270_init_opt(dev, false);
}

int8_t bmi270_init_opt(struct bmi2_dev *dev, uint8_t skip_reset) {
....
}


/**
* \ingroup bmi270
Expand Down