From 32f420c4f0abb9294b6fd178bfd48edb7402de12 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 7 Mar 2022 16:13:04 +0100 Subject: [PATCH 1/2] SPI HAL improvement - Initialize line state --- hal/src/fsfw_hal/linux/spi/SpiComIF.cpp | 8 ++++++++ hal/src/fsfw_hal/linux/spi/SpiComIF.h | 1 + 2 files changed, 9 insertions(+) diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp index d95232c1..dcf92b5d 100644 --- a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp +++ b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp @@ -401,4 +401,12 @@ void SpiComIF::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) if (retval != 0) { utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Setting SPI speed failed"); } + // This updates the SPI clock default polarity. Only setting the mode does not update + // the line state, which can be an issue on mode switches because the clock line will + // switch the state after the chip select is pulled low + clockUpdateTransfer.len = 0; + retval = ioctl(spiFd, SPI_IOC_MESSAGE(1), &clockUpdateTransfer); + if (retval != 0) { + utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Updating SPI default clock failed"); + } } diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.h b/hal/src/fsfw_hal/linux/spi/SpiComIF.h index 1f825d52..357afa2f 100644 --- a/hal/src/fsfw_hal/linux/spi/SpiComIF.h +++ b/hal/src/fsfw_hal/linux/spi/SpiComIF.h @@ -74,6 +74,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject { MutexIF* spiMutex = nullptr; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t timeoutMs = 20; + spi_ioc_transfer clockUpdateTransfer = {}; using SpiDeviceMap = std::unordered_map; using SpiDeviceMapIter = SpiDeviceMap::iterator; From 983fa346b30441e98081992f8abebeb16aa24483 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 7 Mar 2022 16:17:33 +0100 Subject: [PATCH 2/2] update CHANGELOG --- CHANGELOG.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa59651f..717932c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,17 +12,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes -- HAL Devicehandlers: Periodic printout is run-time configurable now -- `oneShotAction` flag in the `TestTask` class is not static anymore +- HAL Linux SPI: Set the Clock Default State when setting new SPI speed + and mode + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/573 +- HAL Devicehandlers: Periodic printout is run-time configurable now. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/561 +- `oneShotAction` flag in the `TestTask` class is not static anymore. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/560 ## Removed - Removed the `HkSwitchHelper`. This module should not be needed anymore, now that the local - datapools have been implemented + datapools have been implemented. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/557 ## Additions - Linux HAL: Add wiretapping option for I2C. Enabled with `FSFW_HAL_I2C_WIRETAPPING` defined to 1 + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/559 # [v4.0.0]