From 24203bbc2d258d7dc2fb37698c0171dfb05edd14 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Fri, 2 Feb 2024 18:21:07 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(BufferedSerial):=20Register=20s?= =?UTF-8?q?igio=20again=20after=20disableDeepSleep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/CoreBufferedSerial.cpp | 4 ++++ .../tests/CoreBufferedSerial_test.cpp | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) 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(); +}