f_rtty.c 758 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "f_rtty.h"
  2. uint8_t start_bits;
  3. rttyStates send_rtty(char *buffer)
  4. {
  5. // Step through a supplied charater bit by bit (with each function call), and return
  6. // the current state (one, zero, end)
  7. static uint8_t nr_bit = 0;
  8. nr_bit++;
  9. //
  10. if (start_bits)
  11. {
  12. start_bits--;
  13. return rttyOne;
  14. }
  15. // Start bit.
  16. if (nr_bit == 1)
  17. return rttyZero;
  18. // Data bits
  19. if (nr_bit > 1 && nr_bit < (RTTY_7BIT ? 9 : 10))
  20. {
  21. if ((*(buffer) >> (nr_bit - 2)) & 0x01)
  22. return rttyOne;
  23. else
  24. return rttyZero;
  25. }
  26. #ifdef RTTY_7BIT
  27. nr_bit++;
  28. #endif
  29. // Stop Bit
  30. if (nr_bit == 10)
  31. return rttyOne;
  32. #ifdef RTTY_USE_2_STOP_BITS
  33. if (nr_bit == 11)
  34. return rttyOne;
  35. #endif
  36. nr_bit = 0;
  37. return rttyEnd;
  38. }