// ----------------------------------------------------------------------------- /// @file gpio.h /// @brief File description // ----------------------------------------------------------------------------- // Micro-Key bv // Industrieweg 28, 9804 TG Noordhorn // Postbus 92, 9800 AB Zuidhorn // The Netherlands // Tel: +31 594 503020 // Fax: +31 594 505825 // Email: support@microkey.nl // Web: www.microkey.nl // ----------------------------------------------------------------------------- /// $Revision$ /// $Author$ /// $Date$ // (c) 2015 Micro-Key bv // ----------------------------------------------------------------------------- /** * %GPIO implementation * \defgroup GPIO Package GPIO * \ingroup Platform * @{ */ #ifndef INC_GPIO_H_ #define INC_GPIO_H_ // ----------------------------------------------------------------------------- // Include files // ----------------------------------------------------------------------------- #include #include "platform.h" #include "IODevice.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Type definitions. // ----------------------------------------------------------------------------- typedef enum { INPUT = 0, OUTPUT = !INPUT } GpioDirection; /** * \class Gpio * \extends IODevice */ struct Gpio { struct IODevice device; //!< \private T_PL_GPIO gpio; GpioDirection direction; bool status; bool initialized; }; // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- /** ---------------------------------------------------------------------------- * GPIO_construct * Constructs a GPIO as IODevice * * @param self The GPIO instance * @param direction Direction of the GPIO * - INPUT or OUTPUT * @param io The Input/Output to use * * @return ErrorStatus SUCCESS if construction was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus GPIO_construct(struct Gpio* self, GpioDirection direction, T_PL_GPIO io); /** ---------------------------------------------------------------------------- * GPIO_setValue * Sets value to GPIO self * * @param self The GPIO instance * @param value the value to use * 0 => Output LOW * 1 => Output HIGH * * @return ErrorStatus SUCCESS if construction was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus GPIO_setValue(struct Gpio* self, bool value); /** ---------------------------------------------------------------------------- * GPIO_getValue * Gets value from GPIO self * * @param self The GPIO instance * @param value the value that has been read * 0 => Output LOW * 1 => Output HIGH * * @return ErrorStatus SUCCESS if construction was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus GPIO_getValue(struct Gpio* self, bool* value); #endif /* INC_GPIO_H_ */ /** @} */