Skip to content
Merged
Changes from 4 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
14 changes: 11 additions & 3 deletions components/bmi270/include/bmi270.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ 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 0 (uses full config file size of 8192 bytes).
* Decrease this if you encounter stack overflow (e.g., 128 for ESP32-C3).
*/
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 +100,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 @@ -565,9 +572,9 @@ 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
// - burst write init data to INIT_DATA, using configurable chunk size (defaults to 8 kB)
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 +713,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