infrared_protocol_rc5.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "infrared_protocol_rc5_i.h"
  2. const InfraredCommonProtocolSpec infrared_protocol_rc5 = {
  3. .timings =
  4. {
  5. .preamble_mark = 0,
  6. .preamble_space = 0,
  7. .bit1_mark = INFRARED_RC5_BIT,
  8. .preamble_tolerance = 0,
  9. .bit_tolerance = INFRARED_RC5_BIT_TOLERANCE,
  10. .silence_time = INFRARED_RC5_SILENCE,
  11. .min_split_time = INFRARED_RC5_MIN_SPLIT_TIME,
  12. },
  13. .databit_len[0] = 1 + 1 + 1 + 5 +
  14. 6, // start_bit + start_bit/command_bit + toggle_bit + 5 address + 6 command
  15. .manchester_start_from_space = true,
  16. .decode = infrared_common_decode_manchester,
  17. .encode = infrared_common_encode_manchester,
  18. .interpret = infrared_decoder_rc5_interpret,
  19. .decode_repeat = NULL,
  20. .encode_repeat = NULL,
  21. };
  22. static const InfraredProtocolVariant infrared_protocol_variant_rc5 = {
  23. .name = "RC5",
  24. .address_length = 5,
  25. .command_length = 6,
  26. .frequency = INFRARED_RC5_CARRIER_FREQUENCY,
  27. .duty_cycle = INFRARED_RC5_DUTY_CYCLE,
  28. .repeat_count = INFRARED_RC5_REPEAT_COUNT_MIN,
  29. };
  30. static const InfraredProtocolVariant infrared_protocol_variant_rc5x = {
  31. .name = "RC5X",
  32. .address_length = 5,
  33. .command_length = 7,
  34. .frequency = INFRARED_RC5_CARRIER_FREQUENCY,
  35. .duty_cycle = INFRARED_RC5_DUTY_CYCLE,
  36. .repeat_count = INFRARED_RC5_REPEAT_COUNT_MIN,
  37. };
  38. const InfraredProtocolVariant* infrared_protocol_rc5_get_variant(InfraredProtocol protocol) {
  39. if(protocol == InfraredProtocolRC5)
  40. return &infrared_protocol_variant_rc5;
  41. else if(protocol == InfraredProtocolRC5X)
  42. return &infrared_protocol_variant_rc5x;
  43. else
  44. return NULL;
  45. }