diff --git a/libs/miosix-kernel b/libs/miosix-kernel index 66206b16188210c32212bc915b99fae2c43628fd..d63a8905149e04e1db2fb813ec2f1e3e46f3734e 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 0eacca533d0abb6d48371c9986869ac1655ebcef..ad3f18e9690164daf45c85c9288e56ff2495508c 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 b1d90fe4164575243a57d0d1939a47ef55d220cb..0eb65db1488357178ae8058de54e209b6c59eb3c 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 2d47dd8db80eb5f97512763b07ae803d8ed8f2a0..a81f6e2b84bd21f252e0ef0b1ae720a89ba44528 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. *