2020-09-19 15:44:10 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
2022-06-29 11:39:50 -07:00
|
|
|
/* for PWMConfig */
|
|
|
|
#include "hal.h"
|
|
|
|
|
2020-09-19 15:44:10 -07:00
|
|
|
struct PWMDriver;
|
|
|
|
|
|
|
|
class Pwm
|
|
|
|
{
|
|
|
|
public:
|
2022-06-29 11:39:50 -07:00
|
|
|
Pwm(PWMDriver& driver);
|
2020-09-19 15:44:10 -07:00
|
|
|
|
2022-12-01 15:51:01 -08:00
|
|
|
void Start(const PWMConfig& config);
|
2022-06-29 11:39:50 -07:00
|
|
|
void SetDuty(int channel, float duty);
|
2022-08-29 17:19:30 -07:00
|
|
|
float GetLastDuty(int channel);
|
2022-01-26 10:56:58 -08:00
|
|
|
|
2020-09-19 15:44:10 -07:00
|
|
|
private:
|
|
|
|
PWMDriver* const m_driver;
|
2022-08-29 17:19:30 -07:00
|
|
|
//const uint8_t m_channel;
|
2022-06-29 11:39:50 -07:00
|
|
|
/* const */ uint32_t m_counterFrequency;
|
|
|
|
/* const */ uint16_t m_counterPeriod;
|
2022-08-29 17:19:30 -07:00
|
|
|
float m_dutyFloat[4];
|
2020-09-19 15:44:10 -07:00
|
|
|
};
|