diff --git a/bsp_z7/objects/ObjectFactory.cpp b/bsp_z7/objects/ObjectFactory.cpp index 33c1339..0e408bc 100644 --- a/bsp_z7/objects/ObjectFactory.cpp +++ b/bsp_z7/objects/ObjectFactory.cpp @@ -8,6 +8,8 @@ #include #include +#include +#include #include "fsfw/events/EventManager.h" #include "fsfw/health/HealthTable.h" @@ -66,6 +68,7 @@ void ObjectFactory::produce(void *args) { new PrintController(123); new BlinkController(124); - new LightHandler(125, new ComIF(), *CookieIF); + static GpioIF gpioIF = new GpioIF(220); + new LightHandler(124, gpioIF); } diff --git a/bsp_z7/objects/communication/CMakeLists.txt b/bsp_z7/objects/communication/CMakeLists.txt index 591690d..79c4cac 100644 --- a/bsp_z7/objects/communication/CMakeLists.txt +++ b/bsp_z7/objects/communication/CMakeLists.txt @@ -1,4 +1,6 @@ target_sources( ${TARGET_NAME} PRIVATE ServoCommInterface.cpp - SerialTCPCookie.cpp) \ No newline at end of file + SerialTCPCookie.cpp + GpioCommIF.cpp + GpioCookie.cpp) \ No newline at end of file diff --git a/bsp_z7/objects/communication/GpioCommIF.h b/bsp_z7/objects/communication/GpioCommIF.h new file mode 100644 index 0000000..d2a2bc7 --- /dev/null +++ b/bsp_z7/objects/communication/GpioCommIF.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +#include "GpioCookie.h" + +class GpioCommIF : public DeviceCommunicationIF, public SystemObject { + public: + GpioCommIF(object_id_t setObjectId); + + virtual ~GpioCommIF() {} + + 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; + + private: + ReturnValue_t initializeInterface(GpioCookie *cookie); + ReturnValue_t sendMessage(GpioCookie *cookie, const uint8_t *sendData, size_t sendLen); + ReturnValue_t readReceivedMessage(GpioCookie *cookie, uint8_t **buffer, size_t *size); +}; \ No newline at end of file diff --git a/bsp_z7/objects/communication/GpioCookie.cpp b/bsp_z7/objects/communication/GpioCookie.cpp new file mode 100644 index 0000000..f2c694a --- /dev/null +++ b/bsp_z7/objects/communication/GpioCookie.cpp @@ -0,0 +1,7 @@ +#include "GpioCookie.h" + +GpioCookie::GpioCookie(uint32_t pinAddress, uint32_t bitOffsetMask) + : pinAddress(pinAddress), bitOffsetMask(bitOffsetMask) { +} + +GpioCookie::~GpioCookie() {} \ No newline at end of file diff --git a/bsp_z7/objects/communication/GpioCookie.h b/bsp_z7/objects/communication/GpioCookie.h new file mode 100644 index 0000000..c962c68 --- /dev/null +++ b/bsp_z7/objects/communication/GpioCookie.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +class GpioCookie : public CookieIF { + /** + * @brief A Cookie containing the Pin and bit offset mask + * + * @param bitOffsetMask Since we can only address each word (32-bit), but a GPIO is represented by a single bit for efficiency-reasons, we need a mask to AND-out all bits we do not want to write to. All bits should zero except the one of the GPIO- If there are multiple GPIOs to set at the same time, this should also be possible, as long as there is no validation fo rthe bitmask + * + */ + public: + GpioCookie(uint32_t pinAddress, uint32_t bitOffsetMask); + virtual ~GpioCookie(); + + const uint32_t pin; + const uint32_t bitOffsetMask; + int socket; +}; \ No newline at end of file