2024-03-01 14:14:21 +01:00
|
|
|
#ifndef PWMCLASS_H
|
|
|
|
#define PWMCLASS_H
|
|
|
|
#include "oneway.h"
|
|
|
|
static constexpr unsigned HALF_LEN = 64u;
|
2024-03-01 17:32:22 +01:00
|
|
|
static constexpr unsigned FULL_LEN = 2u * HALF_LEN;
|
|
|
|
static constexpr unsigned MAXPWM = 2048u;
|
|
|
|
/* Používá TIM1, PWM kanál 1, DMA1 kanál 5, přerušení DMA1_Channel5_IRQHandler */
|
2024-03-01 14:14:21 +01:00
|
|
|
class PwmClass {
|
|
|
|
uint16_t * const pL;
|
|
|
|
uint16_t * const pH;
|
|
|
|
uint16_t buffer [FULL_LEN];
|
|
|
|
OneWay * src;
|
|
|
|
public:
|
|
|
|
explicit PwmClass () noexcept;
|
|
|
|
void attach (OneWay & s) { src = & s; }
|
|
|
|
void send (const bool b) {
|
|
|
|
if (!src) return;
|
|
|
|
if (b) src->Send (pH, HALF_LEN);
|
|
|
|
else src->Send (pL, HALF_LEN);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PWMCLASS_H
|