fsk_osc.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct FSKOsc FSKOsc;
  8. /**
  9. * @brief Allocate a new FSKOsc instance
  10. * FSKOsc is a oscillator that can provide FSK encoding
  11. *
  12. * @param freq_low
  13. * @param freq_hi
  14. * @param osc_phase_max
  15. * @return FSKOsc*
  16. */
  17. FSKOsc* fsk_osc_alloc(uint32_t freq_low, uint32_t freq_hi, uint32_t osc_phase_max);
  18. /**
  19. * @brief Free a FSKOsc instance
  20. *
  21. * @param osc
  22. */
  23. void fsk_osc_free(FSKOsc* osc);
  24. /**
  25. * @brief Reset ocillator
  26. *
  27. * @param osc
  28. */
  29. void fsk_osc_reset(FSKOsc* osc);
  30. /**
  31. * @brief Get next duration sample from oscillator
  32. *
  33. * @param osc
  34. * @param bit
  35. * @param period
  36. * @return bool
  37. */
  38. bool fsk_osc_next(FSKOsc* osc, bool bit, uint32_t* period);
  39. /**
  40. * @brief Get next half of sample from oscillator
  41. * Useful when encoding high and low levels separately.
  42. *
  43. * @param osc
  44. * @param bit
  45. * @param level
  46. * @param duration
  47. * @return bool
  48. */
  49. bool fsk_osc_next_half(FSKOsc* osc, bool bit, bool* level, uint32_t* duration);
  50. #ifdef __cplusplus
  51. }
  52. #endif