@@ -85,6 +85,12 @@ class Bmi270 : public espp::BasePeripheral<uint8_t, Interface == bmi270::Interfa
8585 nullptr ; // /< Read function
8686 ImuConfig imu_config; // /< IMU configuration
8787 filter_fn orientation_filter = nullptr ; // /< Filter function for orientation
88+ /* *
89+ * @brief Maximum number of bytes to write in a single burst during config upload. If 0 will use full config file size of 8192 bytes.
90+ * Default is 0 (uses full config file size of 8192 bytes).
91+ * Set this to a small non-zero value (e.g., 128) if you encounter stack overflow or want to decrease memory usage.
92+ */
93+ uint16_t burst_write_size = 0 ;
8894 bool auto_init{true }; // /< Automatically initialize the BMI270
8995 Logger::Verbosity log_level{Logger::Verbosity::WARN}; // /< Log level
9096 };
@@ -94,7 +100,8 @@ class Bmi270 : public espp::BasePeripheral<uint8_t, Interface == bmi270::Interfa
94100 explicit Bmi270 (const Config &config)
95101 : BasePeripheral<uint8_t, Interface == bmi270::Interface::I2C>({}, " Bmi270" , config.log_level)
96102 , orientation_filter_(config.orientation_filter)
97- , imu_config_(config.imu_config) {
103+ , imu_config_(config.imu_config)
104+ , burst_write_size_(config.burst_write_size == 0 ? config_file_size : config.burst_write_size) {
98105 if constexpr (Interface == bmi270::Interface::I2C) {
99106 set_address (config.device_address );
100107 }
@@ -565,9 +572,9 @@ class Bmi270 : public espp::BasePeripheral<uint8_t, Interface == bmi270::Interfa
565572 }
566573
567574 // upload config file:
568- // - burst write 8 kB init data to INIT_DATA, using 128-byte writes
575+ // - burst write init data to INIT_DATA, using configurable chunk size (defaults to 8 kB)
569576 const uint8_t *config_data = config_file;
570- size_t burst_size = config_file_size ;
577+ size_t burst_size = burst_write_size_ ;
571578 size_t config_size = config_file_size;
572579 size_t offset = 0 ;
573580 while (offset < config_size) {
@@ -706,6 +713,7 @@ class Bmi270 : public espp::BasePeripheral<uint8_t, Interface == bmi270::Interfa
706713 // Member variables
707714 filter_fn orientation_filter_{nullptr };
708715 ImuConfig imu_config_{};
716+ uint16_t burst_write_size_{0 };
709717 Value accel_values_{};
710718 Value gyro_values_{};
711719 float temperature_{0 .0f };
0 commit comments