irda_protocol_defs_i.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_decoder_necext_alloc(void);
  35. void irda_encoder_nec_encode(uint32_t address, uint32_t command, bool repeat);
  36. void irda_encoder_necext_encode(uint32_t address, uint32_t command, bool repeat);
  37. void irda_decoder_nec_reset(void* decoder);
  38. void irda_decoder_nec_free(void* decoder);
  39. IrdaMessage* irda_decoder_nec_decode(void* decoder, bool level, uint32_t duration);
  40. /***************************************************************************************************
  41. * SAMSUNG32 protocol description
  42. * https://www.mikrocontroller.net/articles/IRMP_-_english#SAMSUNG
  43. ****************************************************************************************************
  44. * Preamble Preamble Pulse Distance/Width Pause Preamble Preamble Bit1 Stop
  45. * mark space Modulation repeat repeat bit
  46. * mark space
  47. *
  48. * 4500 4500 32 bit + stop bit 40000/100000 4500 4500
  49. * __________ _ _ _ _ _ _ _ _ _ _ _ ___________ _ _
  50. * _ __________ __ _ __ __ __ _ _ __ __ _ ________________ ____________ ____ ___
  51. *
  52. ***************************************************************************************************/
  53. #define IRDA_SAMSUNG_PREAMBULE_MARK 4500
  54. #define IRDA_SAMSUNG_PREAMBULE_SPACE 4500
  55. #define IRDA_SAMSUNG_BIT1_MARK 550
  56. #define IRDA_SAMSUNG_BIT1_SPACE 1650
  57. #define IRDA_SAMSUNG_BIT0_MARK 550
  58. #define IRDA_SAMSUNG_BIT0_SPACE 550
  59. #define IRDA_SAMSUNG_REPEAT_PAUSE_MIN 30000
  60. #define IRDA_SAMSUNG_REPEAT_PAUSE 47000
  61. #define IRDA_SAMSUNG_REPEAT_PAUSE_MAX 150000
  62. #define IRDA_SAMSUNG_REPEAT_MARK 4500
  63. #define IRDA_SAMSUNG_REPEAT_SPACE 4500
  64. #define IRDA_SAMSUNG_CARRIER_FREQUENCY 38000
  65. #define IRDA_SAMSUNG_DUTY_CYCLE 0.33
  66. #define IRDA_SAMSUNG_PREAMBLE_TOLERANCE 0.07 // percents
  67. #define IRDA_SAMSUNG_BIT_TOLERANCE 120 // us
  68. void* irda_decoder_samsung32_alloc(void);
  69. void irda_encoder_samsung32_encode(uint32_t address, uint32_t command, bool repeat);
  70. void irda_decoder_samsung32_reset(void* decoder);
  71. void irda_decoder_samsung32_free(void* decoder);
  72. IrdaMessage* irda_decoder_samsung32_decode(void* decoder, bool level, uint32_t duration);