PWM based motor driver added from other project
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @file pwmPort.hpp
|
||||
* @author Gustice
|
||||
* @brief C++ Wrapper for PWM-output
|
||||
*
|
||||
* @copyright Copyright (c) 2024
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/ledc.h"
|
||||
#include "portBase.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @brief PWM-Class
|
||||
* @details Provides Write to PWM-Port
|
||||
*/
|
||||
class PwmPort : public PortBase {
|
||||
public:
|
||||
PwmPort(ledc_timer_t timer, ledc_channel_t channel, gpio_num_t output, ledc_timer_bit_t resolution, uint32_t frequency);
|
||||
~PwmPort() = default;
|
||||
|
||||
void write(float duty);
|
||||
void writeRaw(uint16_t duty);
|
||||
|
||||
protected:
|
||||
const uint32_t FullScale;
|
||||
const ledc_timer_t _timer;
|
||||
const ledc_channel_t _channel;
|
||||
const gpio_num_t _port;
|
||||
|
||||
private:
|
||||
};
|
||||
Reference in New Issue
Block a user