osc_fsk.h 744 B

123456789101112131415161718192021222324252627282930
  1. #pragma once
  2. #include <stdint.h>
  3. /**
  4. * This code tries to fit the periods into a given number of cycles (phases) by taking cycles from the next cycle of periods.
  5. */
  6. class OscFSK {
  7. public:
  8. /**
  9. * Get next period
  10. * @param bit bit value
  11. * @param period return period
  12. * @return bool whether to advance to the next bit
  13. */
  14. bool next(bool bit, uint16_t* period);
  15. /**
  16. * FSK ocillator constructor
  17. *
  18. * @param freq_low bit 0 freq
  19. * @param freq_hi bit 1 freq
  20. * @param osc_phase_max max oscillator phase
  21. */
  22. OscFSK(uint16_t freq_low, uint16_t freq_hi, uint16_t osc_phase_max);
  23. private:
  24. const uint16_t freq[2];
  25. const uint16_t osc_phase_max;
  26. int32_t osc_phase_current;
  27. };