eive-obsw/linux/devices/SusPolling.h

53 lines
1.7 KiB
C++

#ifndef LINUX_DEVICES_SUSPOLLING_H_
#define LINUX_DEVICES_SUSPOLLING_H_
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/tasks/SemaphoreIF.h>
#include <fsfw_hal/linux/spi/SpiComIF.h>
#include "devices/addresses.h"
#include "mission/devices/devicedefinitions/acsPolling.h"
class SusPolling : public SystemObject, public ExecutableObjectIF, public DeviceCommunicationIF {
public:
SusPolling(object_id_t objectId, SpiComIF& spiComIF, GpioIF& gpioIF);
ReturnValue_t performOperation(uint8_t operationCode) override;
ReturnValue_t initialize() override;
private:
enum class InternalState { IDLE, IS_BUSY } state = InternalState::IDLE;
struct SusDev {
SpiCookie* cookie = nullptr;
bool performStartup = false;
acs::SimpleSensorMode mode = acs::SimpleSensorMode::OFF;
ReturnValue_t replyResult = returnvalue::OK;
acs::SusReply ownReply{};
acs::SusReply readerReply{};
};
MutexIF* ipcLock;
SemaphoreIF* semaphore;
uint8_t* rawReply = nullptr;
size_t dummy = 0;
SpiComIF& spiComIF;
GpioIF& gpioIF;
std::array<SusDev, 12> susDevs;
std::array<uint8_t, 32> cmdBuf;
ReturnValue_t initializeInterface(CookieIF* cookie) override;
ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override;
ReturnValue_t getSendSuccess(CookieIF* cookie) override;
ReturnValue_t requestReceiveMessage(CookieIF* cookie, size_t requestLen) override;
ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override;
ReturnValue_t handleSusPolling();
static int addressToIndex(address_t addr);
};
#endif /* LINUX_DEVICES_SUSPOLLING_H_ */