Skip to content
Merged
Changes from 2 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
11 changes: 9 additions & 2 deletions components/bmi270/include/bmi270.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ class Bmi270 : public espp::BasePeripheral<uint8_t, Interface == bmi270::Interfa
nullptr; ///< Read function
ImuConfig imu_config; ///< IMU configuration
filter_fn orientation_filter = nullptr; ///< Filter function for orientation
/**
* @brief Maximum number of bytes to write in a single burst during config upload.
* Default is 128 bytes. Decrease this if you encounter stack overflow.
*/
uint16_t burst_write_size = 0;
bool auto_init{true}; ///< Automatically initialize the BMI270
Logger::Verbosity log_level{Logger::Verbosity::WARN}; ///< Log level
};
Expand All @@ -94,7 +99,8 @@ class Bmi270 : public espp::BasePeripheral<uint8_t, Interface == bmi270::Interfa
explicit Bmi270(const Config &config)
: BasePeripheral<uint8_t, Interface == bmi270::Interface::I2C>({}, "Bmi270", config.log_level)
, orientation_filter_(config.orientation_filter)
, imu_config_(config.imu_config) {
, imu_config_(config.imu_config)
, burst_write_size_(config.burst_write_size == 0 ? config_file_size : config.burst_write_size) {
if constexpr (Interface == bmi270::Interface::I2C) {
set_address(config.device_address);
}
Expand Down Expand Up @@ -567,7 +573,7 @@ class Bmi270 : public espp::BasePeripheral<uint8_t, Interface == bmi270::Interfa
// upload config file:
// - burst write 8 kB init data to INIT_DATA, using 128-byte writes
const uint8_t *config_data = config_file;
size_t burst_size = config_file_size;
size_t burst_size = burst_write_size_;
size_t config_size = config_file_size;
size_t offset = 0;
while (offset < config_size) {
Expand Down Expand Up @@ -706,6 +712,7 @@ class Bmi270 : public espp::BasePeripheral<uint8_t, Interface == bmi270::Interfa
// Member variables
filter_fn orientation_filter_{nullptr};
ImuConfig imu_config_{};
uint16_t burst_write_size_{0};
Value accel_values_{};
Value gyro_values_{};
float temperature_{0.0f};
Expand Down