Started with a blank main file
- Added GPIO handling - Added a logger class with additional static debug log handling Tested, functional
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file gpio.h
|
||||
/// \brief File description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MAIN_HAL_INC_GPIO_H_
|
||||
#define MAIN_HAL_INC_GPIO_H_
|
||||
|
||||
/**
|
||||
* gpio implementation
|
||||
* \defgroup gpio
|
||||
* \brief {group_description}
|
||||
* \addtogroup {Layer}
|
||||
*
|
||||
* Detailed description
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Include files
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// CompilerIncludes
|
||||
// All include files that are provided by the compiler directly
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
// ProjectIncludes
|
||||
// All include files that are provided by the project
|
||||
#include "FunctionStatus.h" //!< Include to use the generic function status enumeration type
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class gpio
|
||||
{
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public Section
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
public:
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_DIRECTION_INPUT = 0,
|
||||
GPIO_DIRECTION_OUTPUT = 1
|
||||
} Direction_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_VALUE_LOW = 0,
|
||||
GPIO_VALUE_HIGH = 1
|
||||
} Value_t;
|
||||
|
||||
/** -------------------------------------------------------------------------------------------------------------
|
||||
* GPIO
|
||||
* \brief Constructs a new instance of GPIO
|
||||
*
|
||||
*
|
||||
* @param number The IO instance given in as its unique GPIO number
|
||||
* @param direction Direction of the GPIO.
|
||||
* Default value: @arg GPIO_DIRECTION_INPUT
|
||||
* @arg GPIO_DIRECTION_INPUT for incoming signal
|
||||
* @arg GPIO_DIRECTION_OUTPUT for outgoing signal
|
||||
* @param initialValue The initial value for this GPIO. For outputs the given value will be
|
||||
* applied immediately after initialization. For inputs this value is only
|
||||
* initial and is not the real representation of the input.
|
||||
* Default value: @arg GPIO_VALUE_LOW
|
||||
* @arg GPIO_VALUE_LOW the signal at the GPIO is equal to GND
|
||||
* @arg GPIO_VALUE_HIGH the signal at the GPIO is equal to VCC
|
||||
* --------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
gpio(uint32_t number, Direction_t direction = GPIO_DIRECTION_INPUT, Value_t initialValue = GPIO_VALUE_LOW);
|
||||
|
||||
FunctionStatus set(Value_t value);
|
||||
FunctionStatus get(Value_t* const value);
|
||||
FunctionStatus toogle();
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Protected Section
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
protected:
|
||||
uint32_t number;
|
||||
Direction_t direction;
|
||||
Value_t currentState;
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Private Section
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#endif /* MAIN_HAL_INC_GPIO_H_ */
|
||||
Reference in New Issue
Block a user