irda_i.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "irda.h"
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. typedef struct {
  6. uint32_t min_split_time;
  7. uint32_t silence_time;
  8. uint16_t preamble_mark;
  9. uint16_t preamble_space;
  10. uint16_t bit1_mark;
  11. uint16_t bit1_space;
  12. uint16_t bit0_mark;
  13. uint16_t bit0_space;
  14. uint32_t preamble_tolerance;
  15. uint32_t bit_tolerance;
  16. } IrdaTimings;
  17. typedef struct {
  18. const char* name;
  19. uint8_t address_length;
  20. uint8_t command_length;
  21. uint32_t frequency;
  22. float duty_cycle;
  23. } IrdaProtocolSpecification;
  24. typedef const IrdaProtocolSpecification* (*IrdaGetProtocolSpec) (IrdaProtocol protocol);
  25. typedef void* (*IrdaAlloc) (void);
  26. typedef void (*IrdaFree) (void*);
  27. typedef void (*IrdaDecoderReset) (void*);
  28. typedef IrdaMessage* (*IrdaDecode) (void* ctx, bool level, uint32_t duration);
  29. typedef IrdaMessage* (*IrdaDecoderCheckReady) (void*);
  30. typedef void (*IrdaEncoderReset)(void* encoder, const IrdaMessage* message);
  31. typedef IrdaStatus (*IrdaEncode)(void* encoder, uint32_t* out, bool* polarity);
  32. static inline uint8_t reverse(uint8_t value) {
  33. uint8_t reverse_value = 0;
  34. for (int i = 0; i < 8; ++i) {
  35. reverse_value |= (value & (0x01 << i)) ? 1 << (7 - i) : 0;
  36. }
  37. return reverse_value;
  38. }