not an ideal solution but works for now

This commit is contained in:
Robin Müller 2021-07-16 12:22:14 +02:00
parent aafccd191e
commit a65a184083
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
9 changed files with 70 additions and 10 deletions

View File

@ -3,10 +3,10 @@
#include "spiDefinitions.h" #include "spiDefinitions.h"
#include "returnvalues/classIds.h" #include "returnvalues/classIds.h"
#include "../../common/gpio/GpioIF.h" #include "fsfw/hal/common/gpio/GpioIF.h"
#include <fsfw/devicehandlers/DeviceCommunicationIF.h> #include "fsfw/devicehandlers/DeviceCommunicationIF.h"
#include <fsfw/objectmanager/SystemObject.h> #include "fsfw/objectmanager/SystemObject.h"
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>

View File

@ -5,7 +5,6 @@
#include "fsfw/devicehandlers/DeviceCommunicationIF.h" #include "fsfw/devicehandlers/DeviceCommunicationIF.h"
#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/osal/freertos/BinarySemaphore.h"
#include "fsfw/hal/stm32h7/spi/spiDefinitions.h" #include "fsfw/hal/stm32h7/spi/spiDefinitions.h"
#include "stm32h7xx_hal_spi.h" #include "stm32h7xx_hal_spi.h"
#include "stm32h743xx.h" #include "stm32h743xx.h"
@ -14,6 +13,7 @@
#include <map> #include <map>
class SpiCookie; class SpiCookie;
class BinarySemaphore;
/** /**
* @brief This communication interface allows using generic device handlers with using * @brief This communication interface allows using generic device handlers with using

View File

@ -9,7 +9,6 @@
#include "fsfw/tasks/TaskFactory.h" #include "fsfw/tasks/TaskFactory.h"
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
#include "stm32h7xx_nucleo.h"
#include "stm32h7xx_hal_spi.h" #include "stm32h7xx_hal_spi.h"
#include "stm32h7xx_hal_rcc.h" #include "stm32h7xx_hal_rcc.h"

View File

@ -2,12 +2,21 @@
#include "fsfw/hal/stm32h7/spi/SpiCookie.h" #include "fsfw/hal/stm32h7/spi/SpiCookie.h"
#include "fsfw/tasks/SemaphoreFactory.h" #include "fsfw/tasks/SemaphoreFactory.h"
#include "fsfw/osal/freertos/TaskManagement.h"
#include "fsfw/hal/stm32h7/spi/spiCore.h" #include "fsfw/hal/stm32h7/spi/spiCore.h"
#include "fsfw/hal/stm32h7/spi/spiInterrupts.h" #include "fsfw/hal/stm32h7/spi/spiInterrupts.h"
#include "fsfw/hal/stm32h7/spi/mspInit.h" #include "fsfw/hal/stm32h7/spi/mspInit.h"
#include "fsfw/hal/stm32h7/gpio/gpio.h" #include "fsfw/hal/stm32h7/gpio/gpio.h"
// FreeRTOS required special Semaphore handling from an ISR. Therefore, we use the concrete
// instance here, because RTEMS and FreeRTOS are the only relevant OSALs currently
// and it is not trivial to add a releaseFromISR to the SemaphoreIF
#if defined FSFW_OSAL_RTEMS
#include "fsfw/osal/rtems/BinarySemaphore.h"
#elif defined FSFW_OSAL_FREERTOS
#include "fsfw/osal/freertos/TaskManagement.h"
#include "fsfw/osal/freertos/BinarySemaphore.h"
#endif
#include "stm32h7xx_hal_gpio.h" #include "stm32h7xx_hal_gpio.h"
SpiComIF::SpiComIF(object_id_t objectId): SystemObject(objectId) { SpiComIF::SpiComIF(object_id_t objectId): SystemObject(objectId) {
@ -421,10 +430,14 @@ void SpiComIF::genericIrqHandler(void *irqArgsVoid, spi::TransferStates targetSt
HAL_GPIO_WritePin(spiCookie->getChipSelectGpioPort(), spiCookie->getChipSelectGpioPin(), HAL_GPIO_WritePin(spiCookie->getChipSelectGpioPort(), spiCookie->getChipSelectGpioPin(),
GPIO_PIN_SET); GPIO_PIN_SET);
#if defined FSFW_OSAL_FREERTOS
// Release the task semaphore // Release the task semaphore
BaseType_t taskWoken = pdFALSE; BaseType_t taskWoken = pdFALSE;
ReturnValue_t result = BinarySemaphore::releaseFromISR(comIF->spiSemaphore->getSemaphore(), ReturnValue_t result = BinarySemaphore::releaseFromISR(comIF->spiSemaphore->getSemaphore(),
&taskWoken); &taskWoken);
#elif defined FSFW_OSAL_RTEMS
ReturnValue_t result = comIF->spiSemaphore->release();
#endif
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
// Configuration error // Configuration error
printf("SpiComIF::genericIrqHandler: Failure releasing Semaphore!\n"); printf("SpiComIF::genericIrqHandler: Failure releasing Semaphore!\n");
@ -436,11 +449,13 @@ void SpiComIF::genericIrqHandler(void *irqArgsVoid, spi::TransferStates targetSt
SCB_InvalidateDCache_by_Addr ((uint32_t *) comIF->currentRecvPtr, SCB_InvalidateDCache_by_Addr ((uint32_t *) comIF->currentRecvPtr,
comIF->currentRecvBuffSize); comIF->currentRecvBuffSize);
} }
#if defined FSFW_OSAL_FREERTOS
/* Request a context switch if the SPI ComIF task was woken up and has a higher priority /* Request a context switch if the SPI ComIF task was woken up and has a higher priority
than the currently running task */ than the currently running task */
if(taskWoken == pdTRUE) { if(taskWoken == pdTRUE) {
TaskManagement::requestContextSwitch(CallContext::ISR); TaskManagement::requestContextSwitch(CallContext::ISR);
} }
#endif
} }
void SpiComIF::printCfgError(const char *const type) { void SpiComIF::printCfgError(const char *const type) {

View File

@ -98,7 +98,7 @@ public:
* already available. * already available.
*/ */
static ReturnValue_t releaseFromISR(SemaphoreHandle_t semaphore, static ReturnValue_t releaseFromISR(SemaphoreHandle_t semaphore,
BaseType_t * higherPriorityTaskWoken); BaseType_t * higherPriorityTaskWoken) override;
protected: protected:
SemaphoreHandle_t handle; SemaphoreHandle_t handle;

View File

@ -0,0 +1,21 @@
#ifndef FSFW_INC_FSFW_OSAL_RTEMS_BINARYSEMAPHORE_H_
#define FSFW_INC_FSFW_OSAL_RTEMS_BINARYSEMAPHORE_H_
#include "fsfw/tasks/SemaphoreIF.h"
class BinarySemaphore: public SemaphoreIF {
public:
BinarySemaphore();
virtual ~BinarySemaphore();
// Interface implementation
ReturnValue_t acquire(TimeoutType timeoutType =
TimeoutType::BLOCKING, uint32_t timeoutMs = 0) override;
ReturnValue_t release() override;
uint8_t getSemaphoreCounter() const override;
private:
};
#endif /* FSFW_INC_FSFW_OSAL_RTEMS_BINARYSEMAPHORE_H_ */

View File

@ -1,9 +1,9 @@
#ifndef FSFW_OSAL_RTEMS_MESSAGEQUEUE_H_ #ifndef FSFW_OSAL_RTEMS_MESSAGEQUEUE_H_
#define FSFW_OSAL_RTEMS_MESSAGEQUEUE_H_ #define FSFW_OSAL_RTEMS_MESSAGEQUEUE_H_
#include "../../internalError/InternalErrorReporterIF.h" #include "fsfw/internalerror/InternalErrorReporterIF.h"
#include "../../ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueIF.h"
#include "../../ipc/MessageQueueMessage.h" #include "fsfw/ipc/MessageQueueMessage.h"
#include "RtemsBasic.h" #include "RtemsBasic.h"
/** /**

View File

@ -0,0 +1,24 @@
#include "fsfw/osal/rtems/BinarySemaphore.h"
#include <rtems/rtems/sem.h>
BinarySemaphore::BinarySemaphore() {
}
BinarySemaphore::~BinarySemaphore() {
}
// Interface implementation
ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, uint32_t timeoutMs) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t BinarySemaphore::release() {
return HasReturnvaluesIF::RETURN_OK;
}
uint8_t BinarySemaphore::getSemaphoreCounter() const {
return 0;
}

View File

@ -13,6 +13,7 @@ target_sources(${LIB_FSFW_NAME}
RtemsBasic.cpp RtemsBasic.cpp
RTEMSTaskBase.cpp RTEMSTaskBase.cpp
TaskFactory.cpp TaskFactory.cpp
BinarySemaphore.cpp
) )