manchester-encoder.h 700 B

1234567891011121314151617181920212223242526272829303132
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct {
  8. bool prev_bit;
  9. uint8_t step;
  10. } ManchesterEncoderState;
  11. typedef enum {
  12. ManchesterEncoderResultShortLow = 0b00,
  13. ManchesterEncoderResultLongLow = 0b01,
  14. ManchesterEncoderResultLongHigh = 0b10,
  15. ManchesterEncoderResultShortHigh = 0b11,
  16. } ManchesterEncoderResult;
  17. void manchester_encoder_reset(ManchesterEncoderState* state);
  18. bool manchester_encoder_advance(
  19. ManchesterEncoderState* state,
  20. const bool curr_bit,
  21. ManchesterEncoderResult* result);
  22. ManchesterEncoderResult manchester_encoder_finish(ManchesterEncoderState* state);
  23. #ifdef __cplusplus
  24. }
  25. #endif