not an ideal solution but works for now
This commit is contained in:
parent
aafccd191e
commit
a65a184083
@ -3,10 +3,10 @@
|
||||
|
||||
#include "spiDefinitions.h"
|
||||
#include "returnvalues/classIds.h"
|
||||
#include "../../common/gpio/GpioIF.h"
|
||||
#include "fsfw/hal/common/gpio/GpioIF.h"
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include "fsfw/devicehandlers/DeviceCommunicationIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "fsfw/devicehandlers/DeviceCommunicationIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
|
||||
#include "fsfw/osal/freertos/BinarySemaphore.h"
|
||||
#include "fsfw/hal/stm32h7/spi/spiDefinitions.h"
|
||||
#include "stm32h7xx_hal_spi.h"
|
||||
#include "stm32h743xx.h"
|
||||
@ -14,6 +13,7 @@
|
||||
#include <map>
|
||||
|
||||
class SpiCookie;
|
||||
class BinarySemaphore;
|
||||
|
||||
/**
|
||||
* @brief This communication interface allows using generic device handlers with using
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include "stm32h7xx_nucleo.h"
|
||||
#include "stm32h7xx_hal_spi.h"
|
||||
#include "stm32h7xx_hal_rcc.h"
|
||||
|
||||
|
@ -2,12 +2,21 @@
|
||||
#include "fsfw/hal/stm32h7/spi/SpiCookie.h"
|
||||
|
||||
#include "fsfw/tasks/SemaphoreFactory.h"
|
||||
#include "fsfw/osal/freertos/TaskManagement.h"
|
||||
#include "fsfw/hal/stm32h7/spi/spiCore.h"
|
||||
#include "fsfw/hal/stm32h7/spi/spiInterrupts.h"
|
||||
#include "fsfw/hal/stm32h7/spi/mspInit.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"
|
||||
|
||||
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(),
|
||||
GPIO_PIN_SET);
|
||||
|
||||
#if defined FSFW_OSAL_FREERTOS
|
||||
// Release the task semaphore
|
||||
BaseType_t taskWoken = pdFALSE;
|
||||
ReturnValue_t result = BinarySemaphore::releaseFromISR(comIF->spiSemaphore->getSemaphore(),
|
||||
&taskWoken);
|
||||
#elif defined FSFW_OSAL_RTEMS
|
||||
ReturnValue_t result = comIF->spiSemaphore->release();
|
||||
#endif
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
// Configuration error
|
||||
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,
|
||||
comIF->currentRecvBuffSize);
|
||||
}
|
||||
#if defined FSFW_OSAL_FREERTOS
|
||||
/* Request a context switch if the SPI ComIF task was woken up and has a higher priority
|
||||
than the currently running task */
|
||||
if(taskWoken == pdTRUE) {
|
||||
TaskManagement::requestContextSwitch(CallContext::ISR);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SpiComIF::printCfgError(const char *const type) {
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
* already available.
|
||||
*/
|
||||
static ReturnValue_t releaseFromISR(SemaphoreHandle_t semaphore,
|
||||
BaseType_t * higherPriorityTaskWoken);
|
||||
BaseType_t * higherPriorityTaskWoken) override;
|
||||
|
||||
protected:
|
||||
SemaphoreHandle_t handle;
|
||||
|
21
inc/fsfw/osal/rtems/BinarySemaphore.h
Normal file
21
inc/fsfw/osal/rtems/BinarySemaphore.h
Normal 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_ */
|
@ -1,9 +1,9 @@
|
||||
#ifndef FSFW_OSAL_RTEMS_MESSAGEQUEUE_H_
|
||||
#define FSFW_OSAL_RTEMS_MESSAGEQUEUE_H_
|
||||
|
||||
#include "../../internalError/InternalErrorReporterIF.h"
|
||||
#include "../../ipc/MessageQueueIF.h"
|
||||
#include "../../ipc/MessageQueueMessage.h"
|
||||
#include "fsfw/internalerror/InternalErrorReporterIF.h"
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||
#include "RtemsBasic.h"
|
||||
|
||||
/**
|
||||
|
24
src/osal/rtems/BinarySemaphore.cpp
Normal file
24
src/osal/rtems/BinarySemaphore.cpp
Normal 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;
|
||||
}
|
@ -13,6 +13,7 @@ target_sources(${LIB_FSFW_NAME}
|
||||
RtemsBasic.cpp
|
||||
RTEMSTaskBase.cpp
|
||||
TaskFactory.cpp
|
||||
BinarySemaphore.cpp
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user