Skip to content

Commit 9296cda

Browse files
committed
fix sa for imu
1 parent 4f91d9d commit 9296cda

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

components/icm42607/include/icm42607.hpp

+12-18
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
342342
/// @param power_mode The power mode
343343
/// @param ec The error code to set if an error occurs
344344
/// @return True if the power mode was set successfully, false otherwise
345-
bool set_accelerometer_power_mode(AccelerometerPowerMode power_mode, std::error_code &ec) {
345+
bool set_accelerometer_power_mode(const AccelerometerPowerMode &power_mode, std::error_code &ec) {
346346
uint8_t bitmask = 0x03;
347347
set_bits_in_register_by_mask(static_cast<uint8_t>(Register::PWR_MGMT0), bitmask,
348348
static_cast<uint8_t>(power_mode) & bitmask, ec);
@@ -353,7 +353,7 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
353353
/// @param power_mode The power mode
354354
/// @param ec The error code to set if an error occurs
355355
/// @return True if the power mode was set successfully, false otherwise
356-
bool set_gyroscope_power_mode(GyroscopePowerMode power_mode, std::error_code &ec) {
356+
bool set_gyroscope_power_mode(const GyroscopePowerMode &power_mode, std::error_code &ec) {
357357
uint8_t bitmask = 0x03;
358358
set_bits_in_register_by_mask(static_cast<uint8_t>(Register::PWR_MGMT0), bitmask << 2,
359359
(static_cast<uint8_t>(power_mode) & bitmask) << 2, ec);
@@ -364,7 +364,7 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
364364
/// @param bw The filter bandwidth
365365
/// @param ec The error code to set if an error occurs
366366
/// @return True if the filter bandwidth was set successfully, false otherwise
367-
bool set_accelerometer_filter(SensorFilterBandwidth bw, std::error_code &ec) {
367+
bool set_accelerometer_filter(const SensorFilterBandwidth &bw, std::error_code &ec) {
368368
// ACCEL_FILT_BW is bits 2-0 in ACCEL_CONFIG1
369369
uint8_t mask = 0x07;
370370
uint8_t data = static_cast<uint8_t>(bw) & mask;
@@ -376,7 +376,7 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
376376
/// @param bw The filter bandwidth
377377
/// @param ec The error code to set if an error occurs
378378
/// @return True if the filter bandwidth was set successfully, false otherwise
379-
bool set_gyroscope_filter(SensorFilterBandwidth bw, std::error_code &ec) {
379+
bool set_gyroscope_filter(const SensorFilterBandwidth &bw, std::error_code &ec) {
380380
// GYRO_FILT_BW is bits 2-0 in GYRO_CONFIG1
381381
uint8_t mask = 0x07;
382382
uint8_t data = static_cast<uint8_t>(bw) & mask;
@@ -412,7 +412,7 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
412412
/// @param ec The error code to set if an error occurs
413413
/// @return True if the DMP output data rate was set successfully, false
414414
/// otherwise
415-
bool set_dmp_odr(DmpODR odr, std::error_code &ec) {
415+
bool set_dmp_odr(const DmpODR &odr, std::error_code &ec) {
416416
// DMP ODR is bits 1-0 in APEX_CONFIG1
417417
uint8_t mask = 0x03;
418418
uint8_t data = static_cast<uint8_t>(odr) & mask;
@@ -504,7 +504,7 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
504504
/// @param bypassed True if the FIFO is bypassed, false otherwise
505505
/// @param ec The error code to set if an error occurs
506506
/// @return True if the FIFO buffer was configured successfully, false otherwise
507-
bool configure_fifo(FifoMode mode, bool bypassed, std::error_code &ec) {
507+
bool configure_fifo(const FifoMode &mode, bool bypassed, std::error_code &ec) {
508508
// FIFO_MODE is bit 1, FIFO_BYPASS is bit 0
509509
uint8_t data = (static_cast<uint8_t>(mode) << 1) | (bypassed ? 1 : 0);
510510
write_u8_to_register(static_cast<uint8_t>(Register::FIFO_CONFIG1), data, ec);
@@ -559,14 +559,8 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
559559
}
560560

561561
/// Get the FIFO data
562-
/// @param data The buffer to store the FIFO data
563-
/// @param size The size of the buffer
564562
/// @param ec The error code to set if an error occurs
565-
/// @return The number of bytes read
566-
size_t fifo_data(uint8_t *data, size_t size, std::error_code &ec) {
567-
return read(static_cast<uint8_t>(Register::FIFO_DATA), data, size, ec);
568-
}
569-
563+
/// @return The FIFO data
570564
std::vector<uint8_t> fifo_data(std::error_code &ec) {
571565
// get the count
572566
uint16_t count = fifo_count(ec);
@@ -578,7 +572,7 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
578572
std::vector<uint8_t> buffer(count);
579573

580574
// read the data
581-
size_t read_count = fifo_data(buffer.data(), count, ec);
575+
size_t read_count = read(static_cast<uint8_t>(Register::FIFO_DATA), buffer.data(), count, ec);
582576
if (ec) {
583577
return {};
584578
}
@@ -830,7 +824,7 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
830824
z_extension; ///< Z-axis extension data (accelz [3:0] high nibble + gyroz [3:0] low nibble)
831825
};
832826

833-
static float accelerometer_range_to_sensitivty(AccelerometerRange range) {
827+
static float accelerometer_range_to_sensitivty(const AccelerometerRange &range) {
834828
switch (range) {
835829
case AccelerometerRange::RANGE_16G:
836830
return ACCEL_FS_16G_SENS;
@@ -845,7 +839,7 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
845839
}
846840
}
847841

848-
static float gyroscope_range_to_sensitivty(GyroscopeRange range) {
842+
static float gyroscope_range_to_sensitivty(const GyroscopeRange &range) {
849843
switch (range) {
850844
case GyroscopeRange::RANGE_2000DPS:
851845
return GYRO_FS_2000_SENS;
@@ -881,8 +875,8 @@ class Icm42607 : public espp::BasePeripheral<uint8_t, Interface == icm42607::Int
881875
};
882876
}
883877

884-
ImuConfig imu_config_; ///< IMU configuration
885-
}; // class Icm42607
878+
ImuConfig imu_config_{}; ///< IMU configuration
879+
}; // class Icm42607
886880
} // namespace espp
887881

888882
// for libfmt printing of relevant imu types and structs

0 commit comments

Comments
 (0)