irda_protocol_defs_i.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include "irda.h"
  5. /***************************************************************************************************
  6. * NEC protocol description
  7. * https://radioparty.ru/manuals/encyclopedia/213-ircontrol?start=1
  8. ****************************************************************************************************
  9. * Preamble Preamble Pulse Distance/Width Pause Preamble Preamble Stop
  10. * mark space Modulation repeat repeat bit
  11. * mark space
  12. *
  13. * 9000 4500 32 bit + stop bit 40000/100000 9000 2250
  14. * __________ _ _ _ _ _ _ _ _ _ _ _ _ _ ___________ _
  15. * ____ __________ _ _ _ __ __ __ _ _ __ __ _ _ ________________ ____________ ___
  16. *
  17. ***************************************************************************************************/
  18. #define IRDA_NEC_PREAMBULE_MARK 9000
  19. #define IRDA_NEC_PREAMBULE_SPACE 4500
  20. #define IRDA_NEC_BIT1_MARK 560
  21. #define IRDA_NEC_BIT1_SPACE 1600
  22. #define IRDA_NEC_BIT0_MARK 560
  23. #define IRDA_NEC_BIT0_SPACE 560
  24. #define IRDA_NEC_REPEAT_PAUSE_MIN 30000
  25. #define IRDA_NEC_REPEAT_PAUSE 40000
  26. #define IRDA_NEC_REPEAT_PAUSE_MAX 150000
  27. #define IRDA_NEC_REPEAT_MARK 9000
  28. #define IRDA_NEC_REPEAT_SPACE 2250
  29. #define IRDA_NEC_CARRIER_FREQUENCY 38000
  30. #define IRDA_NEC_DUTY_CYCLE 0.33
  31. #define IRDA_NEC_PREAMBLE_TOLERANCE 0.07 // percents
  32. #define IRDA_NEC_BIT_TOLERANCE 120 // us
  33. void* irda_decoder_nec_alloc(void);
  34. void irda_encoder_nec_encode(uint32_t address, uint32_t command, bool repeat);
  35. void irda_decoder_nec_free(void* decoder);
  36. IrdaMessage* irda_decoder_nec_decode(void* decoder, bool level, uint32_t duration);
  37. /***************************************************************************************************
  38. * SAMSUNG32 protocol description
  39. * https://www.mikrocontroller.net/articles/IRMP_-_english#SAMSUNG
  40. ****************************************************************************************************
  41. * Preamble Preamble Pulse Distance/Width Pause Preamble Preamble Bit1 Stop
  42. * mark space Modulation repeat repeat bit
  43. * mark space
  44. *
  45. * 4500 4500 32 bit + stop bit 40000/100000 4500 4500
  46. * __________ _ _ _ _ _ _ _ _ _ _ _ ___________ _ _
  47. * _ __________ __ _ __ __ __ _ _ __ __ _ ________________ ____________ ____ ___
  48. *
  49. ***************************************************************************************************/
  50. #define IRDA_SAMSUNG_PREAMBULE_MARK 4500
  51. #define IRDA_SAMSUNG_PREAMBULE_SPACE 4500
  52. #define IRDA_SAMSUNG_BIT1_MARK 550
  53. #define IRDA_SAMSUNG_BIT1_SPACE 1650
  54. #define IRDA_SAMSUNG_BIT0_MARK 550
  55. #define IRDA_SAMSUNG_BIT0_SPACE 550
  56. #define IRDA_SAMSUNG_REPEAT_PAUSE_MIN 30000
  57. #define IRDA_SAMSUNG_REPEAT_PAUSE 47000
  58. #define IRDA_SAMSUNG_REPEAT_PAUSE_MAX 150000
  59. #define IRDA_SAMSUNG_REPEAT_MARK 4500
  60. #define IRDA_SAMSUNG_REPEAT_SPACE 4500
  61. #define IRDA_SAMSUNG_CARRIER_FREQUENCY 38000
  62. #define IRDA_SAMSUNG_DUTY_CYCLE 0.33
  63. #define IRDA_SAMSUNG_PREAMBLE_TOLERANCE 0.07 // percents
  64. #define IRDA_SAMSUNG_BIT_TOLERANCE 120 // us
  65. void* irda_decoder_samsung32_alloc(void);
  66. void irda_encoder_samsung32_encode(uint32_t address, uint32_t command, bool repeat);
  67. void irda_decoder_samsung32_free(void* decoder);
  68. IrdaMessage* irda_decoder_samsung32_decode(void* decoder, bool level, uint32_t duration);