diff --git a/drivers/CoreIMU/include/CoreIMU.hpp b/drivers/CoreIMU/include/CoreIMU.hpp index ed0f03a8e..ec796a9b9 100644 --- a/drivers/CoreIMU/include/CoreIMU.hpp +++ b/drivers/CoreIMU/include/CoreIMU.hpp @@ -28,7 +28,6 @@ class CoreIMU : public interface::IMU, public interface::DeepSleepEnabled void registerOnWakeUpCallback(std::function const &callback) final; void enableOnWakeUpInterrupt() final; - void disableOnWakeUpInterrupt() final; void setPowerMode(PowerMode mode) final; @@ -64,7 +63,6 @@ class CoreIMU : public interface::IMU, public interface::DeepSleepEnabled std::array _rx_buffer {}; std::function _on_wake_up_callback {}; - std::function _on_wake_up_wrapper_callback {}; }; } // namespace leka diff --git a/drivers/CoreIMU/source/CoreIMU.cpp b/drivers/CoreIMU/source/CoreIMU.cpp index 8933243e5..1f07ae3df 100644 --- a/drivers/CoreIMU/source/CoreIMU.cpp +++ b/drivers/CoreIMU/source/CoreIMU.cpp @@ -162,7 +162,7 @@ void CoreIMU::enableOnWakeUpInterrupt() }; lsm6dsox_pin_int1_route_set(&_register_io_function, lsm6dsox_int1); - _on_wake_up_wrapper_callback = [this] { + auto on_wake_up_wrapper_callback = [this] { _event_queue.call([this] { lsm6dsox_all_sources_t all_source; lsm6dsox_all_sources_get(&_register_io_function, &all_source); @@ -173,17 +173,7 @@ void CoreIMU::enableOnWakeUpInterrupt() }); }; - setDataReadyInterruptCallback(_on_wake_up_wrapper_callback); -} - -void CoreIMU::disableOnWakeUpInterrupt() -{ - lsm6dsox_pin_int1_route_t lsm6dsox_int1 { - .sleep_change = PROPERTY_DISABLE, - }; - lsm6dsox_pin_int1_route_set(&_register_io_function, lsm6dsox_int1); - - setDataReadyInterruptCallback({}); + setDataReadyInterruptCallback(on_wake_up_wrapper_callback); } auto CoreIMU::read(uint8_t register_address, uint16_t number_bytes_to_read, uint8_t *p_buffer) -> int32_t diff --git a/drivers/CoreIMU/tests/CoreIMU_test.cpp b/drivers/CoreIMU/tests/CoreIMU_test.cpp index 3bddb561a..4f1a3a643 100644 --- a/drivers/CoreIMU/tests/CoreIMU_test.cpp +++ b/drivers/CoreIMU/tests/CoreIMU_test.cpp @@ -152,14 +152,6 @@ TEST_F(CoreIMUTest, enableOnWakeUpInterrupt) coreimu.enableOnWakeUpInterrupt(); } -TEST_F(CoreIMUTest, disableOnWakeUpInterrupt) -{ - EXPECT_CALL(mocki2c, write).Times(AtLeast(1)); - EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); - - coreimu.disableOnWakeUpInterrupt(); -} - TEST_F(CoreIMUTest, switchCallbacks) { auto mock_data_available_callback = MockFunction {}; @@ -182,28 +174,19 @@ TEST_F(CoreIMUTest, switchCallbacks) } { - // Enable Wake Up + // Disable Data Available EXPECT_CALL(mock_data_available_callback, Call).Times(0); - EXPECT_CALL(mock_wake_up_callback, Call).Times(AnyNumber()); - coreimu.enableOnWakeUpInterrupt(); - on_rise_callback = spy_InterruptIn_getRiseCallback(); - on_rise_callback(); - } - - { - // Enable Data Available - EXPECT_CALL(mock_data_available_callback, Call).Times(1); EXPECT_CALL(mock_wake_up_callback, Call).Times(0); - coreimu.enableOnDataReadyInterrupt(); + coreimu.disableOnDataReadyInterrupt(); on_rise_callback = spy_InterruptIn_getRiseCallback(); on_rise_callback(); } { - // Disable Data Available + // Enable Wake Up EXPECT_CALL(mock_data_available_callback, Call).Times(0); - EXPECT_CALL(mock_wake_up_callback, Call).Times(0); - coreimu.disableOnDataReadyInterrupt(); + EXPECT_CALL(mock_wake_up_callback, Call).Times(AnyNumber()); + coreimu.enableOnWakeUpInterrupt(); on_rise_callback = spy_InterruptIn_getRiseCallback(); on_rise_callback(); } diff --git a/include/interface/drivers/IMU.hpp b/include/interface/drivers/IMU.hpp index b255cb2ba..2aaa72495 100644 --- a/include/interface/drivers/IMU.hpp +++ b/include/interface/drivers/IMU.hpp @@ -56,7 +56,6 @@ class IMU virtual void registerOnWakeUpCallback(std::function const &callback) = 0; virtual void enableOnWakeUpInterrupt() = 0; - virtual void disableOnWakeUpInterrupt() = 0; virtual void setPowerMode(PowerMode) = 0; }; diff --git a/tests/unit/mocks/mocks/leka/IMU.h b/tests/unit/mocks/mocks/leka/IMU.h index e29f4442c..d131b0b26 100644 --- a/tests/unit/mocks/mocks/leka/IMU.h +++ b/tests/unit/mocks/mocks/leka/IMU.h @@ -21,7 +21,6 @@ class IMU : public interface::IMU void registerOnWakeUpCallback(std::function const &cb) override { wake_up_callback = cb; } MOCK_METHOD(void, enableOnWakeUpInterrupt, (), (override)); - MOCK_METHOD(void, disableOnWakeUpInterrupt, (), (override)); void call_data_ready_callback(const SensorData &data) { data_ready_callback(data); } void call_wake_up_callback() { wake_up_callback(); }