PWM based motor driver added from other project

This commit is contained in:
2024-11-16 20:04:38 +01:00
parent f6608075ff
commit 0181c72a9d
17 changed files with 1288 additions and 6 deletions
+95
View File
@@ -0,0 +1,95 @@
/**
* @file gpioPort.hpp
* @author Gustice
* @brief GPIO-Port classes
* @details C++ Wrapper for GPIO port
*
* @copyright Copyright (c) 2024
*/
#pragma once
#include "driver/gpio.h"
#include "portBase.hpp"
/**
* @brief Digital-Port BaseClass
*/
class GpioPort : public PortBase {
public:
enum PullResistor {
Floating = 0,
PullUp,
PullDown,
};
enum Logic {
Normal = 0, // Normal logic
Inverted, // Inverted logic -> Set low on active state
};
enum Interrupt {
PositiveEdge = gpio_int_type_t::GPIO_INTR_POSEDGE,
NegativeEdge = gpio_int_type_t::GPIO_INTR_NEGEDGE,
AnyEdge = gpio_int_type_t::GPIO_INTR_ANYEDGE
};
GpioPort(gpio_num_t port);
~GpioPort();
uint64_t GetReserved(void) { return _reservedPorts; }
protected:
const gpio_num_t _port;
private:
static uint64_t _reservedPorts;
};
/**
* @brief Input-Port
* @details Provides abstract reading functionality
*/
class InputPort : public GpioPort {
public:
InputPort(gpio_num_t port, GpioPort::PullResistor resistor = PullResistor::Floating);
void setLogic(GpioPort::Logic logic) {
_logic = logic;
}
~InputPort() = default;
bool read(void);
private:
GpioPort::Logic _logic = GpioPort::Logic::Normal;
};
/**
* @brief Output-Port
* @details Provides abstract setting functionality
*/
class OutputPort : public GpioPort {
public:
OutputPort(gpio_num_t port, GpioPort::Logic mode = Logic::Normal);
~OutputPort(){};
void write(int active);
private:
const GpioPort::Logic _mode = Normal;
};
/**
* @brief Interrupt-Port
*/
class TriggeredInput : public InputPort {
public:
TriggeredInput(gpio_num_t port,
GpioPort::PullResistor resistor = GpioPort::PullResistor::Floating,
TriggeredInput::Interrupt edge = TriggeredInput::Interrupt::AnyEdge);
~TriggeredInput(){};
void RegisterIsr(gpio_isr_t pIsrHandle);
private:
static bool _isrServiceInitiated;
};