From 4daddc4f4c6f35643c6ba9ccd94d93fcfc176d3f Mon Sep 17 00:00:00 2001 From: Alberto Nidasio <alberto.nidasio@skywarder.eu> Date: Thu, 21 Jul 2022 12:39:40 +0000 Subject: [PATCH] [PinObserver] Removed unregisterPinCallback function --- libs/miosix-kernel | 2 +- src/shared/sensors/LIS331HH/LIS331HH.cpp | 19 ++++--------------- src/shared/utils/PinObserver/PinObserver.cpp | 14 ++++++-------- src/shared/utils/PinObserver/PinObserver.h | 9 --------- 4 files changed, 11 insertions(+), 33 deletions(-) diff --git a/libs/miosix-kernel b/libs/miosix-kernel index 66206b161..d63a89051 160000 --- a/libs/miosix-kernel +++ b/libs/miosix-kernel @@ -1 +1 @@ -Subproject commit 66206b16188210c32212bc915b99fae2c43628fd +Subproject commit d63a8905149e04e1db2fb813ec2f1e3e46f3734e diff --git a/src/shared/sensors/LIS331HH/LIS331HH.cpp b/src/shared/sensors/LIS331HH/LIS331HH.cpp index 0eacca533..ad3f18e96 100644 --- a/src/shared/sensors/LIS331HH/LIS331HH.cpp +++ b/src/shared/sensors/LIS331HH/LIS331HH.cpp @@ -33,15 +33,7 @@ LIS331HH::LIS331HH(SPIBusInterface& bus, miosix::GpioPin cs, { } -bool LIS331HH::init() -{ - SPITransaction spi(slave); - - spi.writeRegister(CTRL_REG1, 0x20); - printf("CTRL_REG1: %X\n", spi.readRegister(CTRL_REG1)); - - return true; -} +bool LIS331HH::init() { return true; } bool LIS331HH::selfTest() { return true; } @@ -57,19 +49,16 @@ LIS331HHData LIS331HH::sampleImpl() val = spi.readRegister(OUT_X_L); val |= spi.readRegister(OUT_X_H) << 8; data.accelerationX = 6.0 / 65536.0 * val; - printf("%X\t", val); val = spi.readRegister(OUT_Y_L); val |= spi.readRegister(OUT_Y_H) << 8; - data.accelerationX = 6.0 / 65536.0 * val; - printf("%X\t", val); + data.accelerationY = 6.0 / 65536.0 * val; val = spi.readRegister(OUT_Z_L); val |= spi.readRegister(OUT_Z_H) << 8; - data.accelerationX = 6.0 / 65536.0 * val; - printf("%X\t", val); + data.accelerationZ = 6.0 / 65536.0 * val; return data; } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/utils/PinObserver/PinObserver.cpp b/src/shared/utils/PinObserver/PinObserver.cpp index b1d90fe41..0eb65db14 100644 --- a/src/shared/utils/PinObserver/PinObserver.cpp +++ b/src/shared/utils/PinObserver/PinObserver.cpp @@ -39,19 +39,17 @@ bool PinObserver::registerPinCallback(miosix::GpioPin pin, PinCallback callback, // Check if the insertion took place if (result.second) { - return scheduler.addTask( - std::bind(&PinObserver::periodicPinValueCheck, this, pin), - SAMPLE_PERIOD, TaskScheduler::Policy::SKIP); + if (scheduler.addTask( + std::bind(&PinObserver::periodicPinValueCheck, this, pin), + SAMPLE_PERIOD, TaskScheduler::Policy::SKIP)) + return true; + else + callbacks.erase(pin); } return false; } -bool PinObserver::unregisterPinCallback(miosix::GpioPin pin) -{ - return callbacks.erase(pin) != 0; -} - bool PinObserver::start() { return scheduler.start(); } void PinObserver::stop() { scheduler.stop(); } diff --git a/src/shared/utils/PinObserver/PinObserver.h b/src/shared/utils/PinObserver/PinObserver.h index 2d47dd8db..a81f6e2b8 100644 --- a/src/shared/utils/PinObserver/PinObserver.h +++ b/src/shared/utils/PinObserver/PinObserver.h @@ -86,15 +86,6 @@ public: bool registerPinCallback(miosix::GpioPin pin, PinCallback callback, uint32_t detectionThreshold = 1); - /** - * @brief Unregisters the callback associated with the specified pin, if - * any. - * - * @param pin Pin whose callback function is to be removed. - * @return True if a callback was present and removed for the given pin. - */ - bool unregisterPinCallback(miosix::GpioPin pin); - /** * @brief Starts the PinObserver's task scheduler. * -- GitLab