RISC-V/V003/pwm/generator.cpp

14 lines
314 B
C++
Raw Permalink Normal View History

2024-03-01 17:32:22 +01:00
#include "generator.h"
extern "C" const uint16_t sin_tab[0x100];
uint16_t Generator::step() {
const uint16_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] = step();
return len;
}