diff --git a/drivers/CoreBufferedSerial/source/CoreBufferedSerial.cpp b/drivers/CoreBufferedSerial/source/CoreBufferedSerial.cpp index 54991257b5..32d7d290ab 100644 --- a/drivers/CoreBufferedSerial/source/CoreBufferedSerial.cpp +++ b/drivers/CoreBufferedSerial/source/CoreBufferedSerial.cpp @@ -24,6 +24,10 @@ auto CoreBufferedSerial::readable() -> bool void CoreBufferedSerial::disableDeepSleep() { _serial.enable_input(true); + + if (_sigio_callback != nullptr) { + _serial.sigio(mbed::Callback {[this] { _sigio_callback(); }}); + } } void CoreBufferedSerial::enableDeepSleep() diff --git a/drivers/CoreBufferedSerial/tests/CoreBufferedSerial_test.cpp b/drivers/CoreBufferedSerial/tests/CoreBufferedSerial_test.cpp index f3160d0b09..30189e4a55 100644 --- a/drivers/CoreBufferedSerial/tests/CoreBufferedSerial_test.cpp +++ b/drivers/CoreBufferedSerial/tests/CoreBufferedSerial_test.cpp @@ -81,3 +81,21 @@ TEST_F(CoreBufferedSerialTest, disableDeepSleep) coreserial.disableDeepSleep(); ASSERT_TRUE(spy_BufferedSerial_getEnableInput()); } + +TEST_F(CoreBufferedSerialTest, sigioAfterDisableDeepSleep) +{ + auto mock_function = MockFunction {}; + + coreserial.sigio(mock_function.AsStdFunction()); + + EXPECT_CALL(mock_function, Call); + auto on_sigio_callback = spy_BufferedSerial_getSigioCallback(); + on_sigio_callback(); + + coreserial.enableDeepSleep(); + coreserial.disableDeepSleep(); + + EXPECT_CALL(mock_function, Call); + on_sigio_callback = spy_BufferedSerial_getSigioCallback(); + on_sigio_callback(); +}