RISC-V/V203/pwm/generator.cpp
2024-05-07 15:50:51 +02:00

13 lines
319 B
C++

#include "generator.h"
extern "C" const int16_t sin_tab[0x100];
int16_t Generator::step() {
const int16_t v = sin_tab [base >> 24];
base += freq;
return v;
}
unsigned int Generator::Send(uint16_t * const ptr, const unsigned int len) {
for (unsigned n=0u; n<len; n++) ptr [n] = 3000u + step();
return len;
}