#include "generator.h" #include "utils.h" static constexpr unsigned W_TB = 8u; static constexpr double AMPL = 3000.0; static constexpr int ULEN = 1 << W_TB; static constexpr uint16_t u16_sin (const int x) { const double a = (double (x) * D_PI) / double (ULEN); const double s = AMPL * (1.0 + 0.96 * sincos (a, true)); return i_round (s); } static const TABLE sin_tab (u16_sin); extern void print_sinus_table (const TABLE & tab); Generator::Generator (const unsigned f) noexcept : OneWay(), freq (f), base(0u), incr (0u), ms_count (0u) { #ifdef __linux__ print_sinus_table(sin_tab); #endif } uint16_t Generator::step() { const uint16_t v = sin_tab [base >> 24]; base += incr; return v; } unsigned int Generator::Send(uint16_t * const ptr, const unsigned int len) { for (unsigned n=0u; n