62 lines
2.0 KiB
C++
62 lines
2.0 KiB
C++
#ifndef BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_
|
|
#define BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_
|
|
|
|
#include <bsp_q7s/gpio/GpioIF.h>
|
|
#include <fsfwconfig/returnvalues/classIds.h>
|
|
#include <bsp_q7s/gpio/cookies/GpioCookie.h>
|
|
#include <fsfw/objectmanager/SystemObject.h>
|
|
|
|
/**
|
|
* @brief This class implements the GpioIF for a linux based system. The
|
|
* implementation is based on the libgpiod lib which requires linux 4.8
|
|
* or higher.
|
|
* @note The Petalinux SDK from Xilinx supports libgpiod since Petalinux
|
|
* 2019.1.
|
|
*/
|
|
class LinuxLibgpioIF : public GpioIF, public SystemObject {
|
|
public:
|
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::LINUX_LIBGPIO_IF;
|
|
|
|
static const ReturnValue_t CONFIGURATION_FAILURE = MAKE_RETURN_CODE(0x1);
|
|
static const ReturnValue_t OPEN_CHIP_FAILURE = MAKE_RETURN_CODE(0x2);
|
|
static const ReturnValue_t OPEN_LINE_FAILURE = MAKE_RETURN_CODE(0x3);
|
|
static const ReturnValue_t REQUEST_LINE_FAILURE = MAKE_RETURN_CODE(0x4);
|
|
static const ReturnValue_t PULLING_HIGH_FAILURE = MAKE_RETURN_CODE(0x5);
|
|
|
|
LinuxLibgpioIF(object_id_t objectId);
|
|
virtual ~LinuxLibgpioIF();
|
|
|
|
ReturnValue_t initialize(CookieIF * cookie) override;
|
|
ReturnValue_t pullHigh(gpioId_t gpioId) override;
|
|
ReturnValue_t pullLow(gpioId_t gpioId) override;
|
|
|
|
private:
|
|
|
|
/*Holds the information and configuration of all used GPIOs */
|
|
GpioMap gpioMap;
|
|
GpioMapIter gpioMapIter;
|
|
|
|
/**
|
|
* @brief This functions drives line of a GPIO specified by the GPIO ID.
|
|
*
|
|
* @param gpioId The GPIO ID of the GPIO to drive.
|
|
* @param logiclevel The logic level to set. O or 1.
|
|
*/
|
|
ReturnValue_t driveGpio(gpioId_t gpioId,
|
|
unsigned int logiclevel);
|
|
|
|
/**
|
|
* @brief This function checks if GPIOs are already registered and whether
|
|
* there exists a conflict in the GPIO configuration. E.g. the
|
|
* direction.
|
|
*
|
|
* @param mapToAdd The GPIOs which shall be added to the gpioMap.
|
|
*
|
|
* @return RETURN_OK if successful, otherwise RETURN_FAILED
|
|
*/
|
|
ReturnValue_t checkForConflicts(GpioMap mapToAdd);
|
|
};
|
|
|
|
#endif /* BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_ */
|