infrared_protocol_sirc.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "infrared_protocol_sirc_i.h"
  2. const InfraredCommonProtocolSpec infrared_protocol_sirc = {
  3. .timings =
  4. {
  5. .preamble_mark = INFRARED_SIRC_PREAMBLE_MARK,
  6. .preamble_space = INFRARED_SIRC_PREAMBLE_SPACE,
  7. .bit1_mark = INFRARED_SIRC_BIT1_MARK,
  8. .bit1_space = INFRARED_SIRC_BIT1_SPACE,
  9. .bit0_mark = INFRARED_SIRC_BIT0_MARK,
  10. .bit0_space = INFRARED_SIRC_BIT0_SPACE,
  11. .preamble_tolerance = INFRARED_SIRC_PREAMBLE_TOLERANCE,
  12. .bit_tolerance = INFRARED_SIRC_BIT_TOLERANCE,
  13. .silence_time = INFRARED_SIRC_SILENCE,
  14. .min_split_time = INFRARED_SIRC_MIN_SPLIT_TIME,
  15. },
  16. .databit_len[0] = 20,
  17. .databit_len[1] = 15,
  18. .databit_len[2] = 12,
  19. .no_stop_bit = true,
  20. .decode = infrared_common_decode_pdwm,
  21. .encode = infrared_common_encode_pdwm,
  22. .interpret = infrared_decoder_sirc_interpret,
  23. .decode_repeat = NULL,
  24. .encode_repeat = infrared_encoder_sirc_encode_repeat,
  25. };
  26. static const InfraredProtocolVariant infrared_protocol_variant_sirc = {
  27. .name = "SIRC",
  28. .address_length = 5,
  29. .command_length = 7,
  30. .frequency = INFRARED_SIRC_CARRIER_FREQUENCY,
  31. .duty_cycle = INFRARED_SIRC_DUTY_CYCLE,
  32. .repeat_count = INFRARED_SIRC_REPEAT_COUNT_MIN,
  33. };
  34. static const InfraredProtocolVariant infrared_protocol_variant_sirc15 = {
  35. .name = "SIRC15",
  36. .address_length = 8,
  37. .command_length = 7,
  38. .frequency = INFRARED_SIRC_CARRIER_FREQUENCY,
  39. .duty_cycle = INFRARED_SIRC_DUTY_CYCLE,
  40. .repeat_count = INFRARED_SIRC_REPEAT_COUNT_MIN,
  41. };
  42. static const InfraredProtocolVariant infrared_protocol_variant_sirc20 = {
  43. .name = "SIRC20",
  44. .address_length = 13,
  45. .command_length = 7,
  46. .frequency = INFRARED_SIRC_CARRIER_FREQUENCY,
  47. .duty_cycle = INFRARED_SIRC_DUTY_CYCLE,
  48. .repeat_count = INFRARED_SIRC_REPEAT_COUNT_MIN,
  49. };
  50. const InfraredProtocolVariant* infrared_protocol_sirc_get_variant(InfraredProtocol protocol) {
  51. if(protocol == InfraredProtocolSIRC)
  52. return &infrared_protocol_variant_sirc;
  53. else if(protocol == InfraredProtocolSIRC15)
  54. return &infrared_protocol_variant_sirc15;
  55. else if(protocol == InfraredProtocolSIRC20)
  56. return &infrared_protocol_variant_sirc20;
  57. else
  58. return NULL;
  59. }