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:
Matthias Mitscherlich
2024-03-11 15:45:48 +01:00
parent 4b31b6c618
commit a0d13f08c1
10 changed files with 1067 additions and 4 deletions
+103
View File
@@ -0,0 +1,103 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file ISerialBus.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_HAL_INC_ISERIALBUS_H_
#define MAIN_HAL_INC_ISERIALBUS_H_
/**
* ISerialBus implementation
* \defgroup ISerialBus
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "FunctionStatus.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
template<typename T>
class ISerialBus
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Virtual Class Destructor (required for absolute virtual classes)
virtual ~ISerialBus() {}
FunctionStatus open() {status = OPEN; return FUNCTION_STATUS_OK;}
FunctionStatus close() {status = CLOSED; return FUNCTION_STATUS_OK;}
virtual FunctionStatus read(T* buffer, uint32_t length, uint32_t* actualLength) = 0;
virtual FunctionStatus write(T* buffer, uint32_t length) = 0;
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
typedef enum
{
CLOSED = 0,
OPEN
} Status_t;
// The current open/close status of the interface
Status_t status;
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_HAL_INC_ISERIALBUS_H_ */
+122
View File
@@ -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_ */
+91
View File
@@ -0,0 +1,91 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file uart.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_HAL_INC_UART_H_
#define MAIN_HAL_INC_UART_H_
/**
* uart implementation
* \defgroup uart
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "ISerialBus.h"
#include "driver/uart.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class uart : public ISerialBus<uint8_t>
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Class Constructor
uart(uart_port_t* uartPort);
~uart();
FunctionStatus read(uint8_t* buffer, uint32_t length, uint32_t* actualLength);
FunctionStatus write(uint8_t* buffer, uint32_t length);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
uart_port_t* port;
};
/** @} */
#endif /* MAIN_HAL_INC_UART_H_ */