rc5_decode.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*!
  2. \file rc5_decode.h
  3. \brief the header file of rc5 infrared decoding
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-06-06, V1.0.0, firmware for GD32F3x0
  8. */
  9. #ifndef RC5_DECODE_H
  10. #define RC5_DECODE_H
  11. #include "gd32f3x0.h"
  12. /* rc5 frame structure */
  13. typedef struct
  14. {
  15. __IO uint8_t field_bit; /*!< field bit */
  16. __IO uint8_t toggle_bit; /*!< toggle bit field */
  17. __IO uint8_t address; /*!< address field */
  18. __IO uint8_t command; /*!< command field */
  19. } rc5_frame_struct;
  20. /* rc5 packet structure */
  21. typedef struct
  22. {
  23. __IO uint16_t data; /*!< rc5 data */
  24. __IO uint8_t status; /*!< rc5 status */
  25. __IO uint8_t last_bit; /*!< rc5 last bit */
  26. __IO uint8_t bit_count; /*!< rc5 bit count */
  27. } trc5_packet_struct;
  28. /* rc5 last bit type enum */
  29. enum rc5_last_bit_type
  30. {
  31. RC5_ZER,
  32. RC5_ONE,
  33. RC5_NAN,
  34. RC5_INV
  35. };
  36. typedef enum rc5_last_bit_type trc5_last_bit_type;
  37. #define RC5_1T_TIME 0x00
  38. #define RC5_2T_TIME 0x01
  39. #define RC5_WRONG_TIME 0xFF
  40. #define RC5_TIME_OUT_US 3600
  41. /* half bit period */
  42. #define RC5_T_US 900
  43. /* tolerance time */
  44. #define RC5_T_TOLERANCE_US 270
  45. #define RC5_NUMBER_OF_VALID_PULSE_LENGTH 2
  46. /* total bits */
  47. #define RC5_PACKET_BIT_COUNT 13
  48. /* packet struct for reception */
  49. #define RC5_PACKET_STATUS_EMPTY (uint16_t)(1<<0)
  50. void menu_rc5decode_func(void);
  51. void rc5_decode_deinit(void);
  52. void rc5_decode_init(void);
  53. void rc5_decode(rc5_frame_struct *rc5_frame);
  54. void rc5_reset_packet(void);
  55. void rc5_data_sampling(uint16_t raw_pulse_length, uint8_t edge);
  56. #endif /* RC5_DECODE_H */