irda-decoder-nec.h 761 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include "irda-decoder-types.h"
  5. typedef enum {
  6. WAIT_PREAMBULA_HIGH,
  7. WAIT_PREAMBULA_LOW,
  8. WAIT_RETRY_HIGH,
  9. WAIT_BIT_HIGH,
  10. WAIT_BIT_LOW,
  11. WAIT_BIT_STOP_HIGH,
  12. } IrDANecDecoderState;
  13. typedef struct {
  14. uint8_t addr2;
  15. uint8_t addr1;
  16. uint8_t cmd_inverse;
  17. uint8_t cmd;
  18. } IrDANecData;
  19. typedef uint32_t IrDANecDataType;
  20. typedef struct {
  21. union {
  22. IrDANecData simple;
  23. IrDANecDataType data;
  24. } data;
  25. uint8_t current_data_index;
  26. IrDANecDecoderState state;
  27. } IrDANecDecoder;
  28. bool process_decoder_nec(
  29. IrDANecDecoder* decoder,
  30. bool polarity,
  31. uint32_t time,
  32. IrDADecoderOutputData* out);
  33. void reset_decoder_nec(IrDANecDecoder* decoder);