Replaced LED with more generic class GPIO

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@233 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-04 14:18:33 +00:00
parent 8b315602e9
commit cf0435c273
9 changed files with 172 additions and 93 deletions

View File

@@ -1,6 +1,5 @@
// -----------------------------------------------------------------------------
/// @file led.h
/// @file gpio.h
/// @brief File description
// -----------------------------------------------------------------------------
// Micro-Key bv
@@ -15,28 +14,26 @@
/// $Revision$
/// $Author$
/// $Date$
// (c) 2017 Micro-Key bv
// (c) 2015 Micro-Key bv
// -----------------------------------------------------------------------------
/// @defgroup {group_name} {group_description}
/// Description
/// @file led.h
/// @file gpio.h
/// @ingroup {group_name}
#ifndef LED_INC_LED_H_
#define LED_INC_LED_H_
#ifndef INC_GPIO_H_
#define INC_GPIO_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include <stdbool.h>
#include "platform.h"
#include "IODevice.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
@@ -44,13 +41,20 @@
// -----------------------------------------------------------------------------
// Type definitions.
// Type definitions.
// -----------------------------------------------------------------------------
struct Led
typedef enum
{
INPUT = 0,
OUTPUT = !INPUT
}GpioDirection;
struct Gpio
{
struct IODevice device;
T_PL_GPIO ledGpio;
T_PL_GPIO gpio;
GpioDirection direction;
bool status;
};
@@ -59,34 +63,57 @@ struct Led
// -----------------------------------------------------------------------------
ErrorStatus LED_construct (struct Led* self);
/** ----------------------------------------------------------------------------
* LED_turnOn
* Turns on the LED identified with the ID
* GPIO_construct
* Constructs a GPIO as IODevice
*
* @param ledID Unique identifier of the LED
* @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 init was successful
* @return ErrorStatus SUCCESS if construction was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus LED_turnOn(struct Led* led);
extern ErrorStatus GPIO_construct(struct Gpio* self, GpioDirection direction, T_PL_GPIO io);
/** ----------------------------------------------------------------------------
* LED_turnOff
* Turns off the LED identified with the ID
* GPIO_setValue
* Sets value to GPIO self
*
* @param ledID Unique identifier of the LED
* @param self The GPIO instance
* @param value the value to use
* 0 => Output LOW
* 1 => Output HIGH
*
* @return ErrorStatus SUCCESS if init was successful
* @return ErrorStatus SUCCESS if construction was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus LED_turnOff(struct Led* led);
extern ErrorStatus GPIO_setValue(struct Gpio* self, bool value);
#endif /* LED_INC_LED_H_ */
/** ----------------------------------------------------------------------------
* 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_ */

View File

@@ -64,8 +64,8 @@ typedef struct
extern struct Pcba* pcba;
// Export of LEDs
extern struct Led* const ledGreen;
extern struct Led* const ledOrange;
extern struct Gpio* const ledGreen;
extern struct Gpio* const ledOrange;
// Export of ADCs
extern struct Adc* const adc1;
// Export of the rtc