git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@426 05563f52-14a8-4384-a975-3d1654cca0fa
130 lines
4.0 KiB
C
130 lines
4.0 KiB
C
// -----------------------------------------------------------------------------
|
|
/// @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 <stdbool.h>
|
|
#include "platform.h"
|
|
#include "IODevice.h"
|
|
// -----------------------------------------------------------------------------
|
|
// Constant and macro definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Type definitions.
|
|
// -----------------------------------------------------------------------------
|
|
|
|
typedef enum
|
|
{
|
|
INPUT = 0,
|
|
OUTPUT = !INPUT
|
|
} GpioDirection;
|
|
|
|
/**
|
|
* \class Gpio
|
|
* \extends IODevice
|
|
* The Gpio struct that can be used as an object
|
|
*/
|
|
|
|
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_ */
|
|
|
|
/** @} */
|