From a8680dd5b5bbefa1da239bc8fca5591afe2d6c48 Mon Sep 17 00:00:00 2001 From: Matthias Mitscherlich Date: Thu, 12 Jan 2023 20:48:45 +0100 Subject: [PATCH] Added first code parts --- code/main/inc/gpio.h | 37 +++++++++++++++++++++++++++---------- code/main/src/gpio.cpp | 11 ++++++++++- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/code/main/inc/gpio.h b/code/main/inc/gpio.h index cf08fde..cc5341d 100644 --- a/code/main/inc/gpio.h +++ b/code/main/inc/gpio.h @@ -16,16 +16,6 @@ #ifndef MAIN_INC_GPIO_H_ #define MAIN_INC_GPIO_H_ -/** - * gpio implementation - * \defgroup gpio - * \brief {group_description} - * \addtogroup {Layer} - * - * Detailed description - * @{ - */ - // -------------------------------------------------------------------------------------------------------------------- @@ -50,13 +40,40 @@ // Type definitions. // -------------------------------------------------------------------------------------------------------------------- +typedef enum +{ + GPIO_DIRECTION_INPUT = 0, + GPIO_DIRECTION_OUTPUT = 1 +} GPIO_Direction_t; +typedef enum +{ + GPIO_VALUE_LOW = 0, + GPIO_VALUE_HIGH = 1 +} GPIO_Value_t; // -------------------------------------------------------------------------------------------------------------------- // Function declarations // -------------------------------------------------------------------------------------------------------------------- +class GPIO +{ + public: + bool GPIO(int number, GPIO_Direction_t direction); + + bool GPIO_setOutput(GPIO_Value_t value); + + GPIO_Value_t GPIO_getInput(void); + + private: + + int number; + + GPIO_Direction_t direction; + + GPIO_Value_t value; +}; /** @} */ diff --git a/code/main/src/gpio.cpp b/code/main/src/gpio.cpp index 182c00b..154f343 100644 --- a/code/main/src/gpio.cpp +++ b/code/main/src/gpio.cpp @@ -17,8 +17,11 @@ // Include files // -------------------------------------------------------------------------------------------------------------------- +#include "driver/gpio.h" + #include "gpio.h" + // -------------------------------------------------------------------------------------------------------------------- // Constant and macro definitions // -------------------------------------------------------------------------------------------------------------------- @@ -47,7 +50,13 @@ // -------------------------------------------------------------------------------------------------------------------- - +bool GPIO::GPIO(int number, GPIO_Direction_t direction) +{ + this->number = number; + this->direction = direction; + + return true; +}