common_cir.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * ===========================================================================================
  3. *
  4. * Filename: common_cir.h
  5. *
  6. * Description: IR HAL definition.
  7. *
  8. * Version: Melis3.0
  9. * Create: 2021-01-15 11:11:56
  10. * Revision: none
  11. * Compiler: GCC:version 9.2.1
  12. *
  13. * Author: luruixiang@allwinnertech.com
  14. * Organization: SWC-BPD
  15. * Last Modified: 2021-01-15 16:02:11
  16. *
  17. * ===========================================================================================
  18. */
  19. #ifndef _CIRCOMMON_H_
  20. #define _CIRCOMMON_H_
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. /* Registers */
  26. #define CIR_CTRL (0x00) /* IR Control */
  27. #define CIR_RXCTRL (0x10) /* Rx Config */
  28. #define CIR_RXFIFO (0x20) /* Rx Data */
  29. #define CIR_RXINT (0x2C) /* Rx Interrupt Enable */
  30. #define CIR_RXSTA (0x30) /* Rx Interrupt Status */
  31. #define CIR_CONFIG (0x34) /* IR Sample Config */
  32. /*CIR_CTRL*/
  33. #define GEN_OFFSET 0
  34. #define RXEN_OFFSET 1
  35. #define CIR_ENABLE_OFFSET 4
  36. #define CIR_MODE_OFFSET 6
  37. /*global enable*/
  38. #define GEN (0x01 << GEN_OFFSET)
  39. /*receiver block enable*/
  40. #define RXEN (0x01 << RXEN_OFFSET)
  41. /*cir enable*/
  42. #define CIR_ENABLE (0x03 << CIR_ENABLE_OFFSET)
  43. /*active pulse accept mode*/
  44. #define CIR_MODE (0x03 << CIR_MODE_OFFSET)
  45. /*CIR_RXCTRL*/
  46. #define RPPI_OFFSET 2
  47. #define RPPI (0x01 << RPPI_OFFSET) /*receiver pulse polarity invert*/
  48. /*CIR_RXINT*/
  49. #define ROI_EN_OFFSET 0
  50. #define PREI_EN_OFFSET 1
  51. #define RAI_EN_OFFSET 4
  52. #define DRQ_EN_OFFSET 5
  53. #define RAL_OFFSET 8
  54. /*receiver fifo overrun interrupt enable*/
  55. #define ROI_EN (0x01 << ROI_EN_OFFSET)
  56. /*receiver packet end interrupt enable*/
  57. #define PREI_EN (0x01 << PREI_EN_OFFSET)
  58. /*rx fifo available interrupt enable*/
  59. #define RAI_EN (0x01 << RAI_EN_OFFSET)
  60. /*rx fifo dma enable*/
  61. #define DRQ_EN (0x01 << DRQ_EN_OFFSET)
  62. /*rx fifo available received byte level*/
  63. #define RAL (0x3f << RAL_OFFSET)
  64. #define IRQ_MASK (0x3f)
  65. /*CIR_RXSTA*/
  66. #define ROI_OFFSET 0
  67. #define RPE_OFFSET 1
  68. #define RA_OFFSET 4
  69. #define STAT_OFFSET 7
  70. #define RAC_OFFSET 8
  71. #define ROI (0x01 << ROI_OFFSET) /*receiver fifo overrun*/
  72. #define RPE (0x01 << RPE_OFFSET) /*receiver packet end reg*/
  73. #define RA (0x01 << RA_OFFSET) /*rx fifo available*/
  74. #define STAT (0x01 << STAT_OFFSET) /*status of cir, 0:idle, 1:busy*/
  75. #define RAC (0x7f << RAC_OFFSET) /*rx fifo available counter*/
  76. /*CIR_CONFIG*/
  77. #define SCS_OFFSET 0
  78. #define NTHR_OFFSET 2
  79. #define ITHR_OFFSET 8
  80. #define ATHR_OFFSET 16
  81. #define ATHC_OFFSET 23
  82. #define SCS2_OFFSET 24
  83. #define SCS (0x03 << SCS_OFFSET) /*sample clk select for cir*/
  84. #define NTHR (0x3f << NTHR_OFFSET) /*noise threshold for cir*/
  85. #define ITHR (0xff << ITHR_OFFSET) /*idle threshold for cir*/
  86. #define ATHR (0x7f << ATHR_OFFSET) /*active threshold for cir*/
  87. #define ATHC (0x01 << ATHC_OFFSET) /*active threshold control for cir*/
  88. #define SCS2 (0x01 << SCS2_OFFSET) /*bit2 of sample clock select for cir*/
  89. #define CIR_NOISE_THR_NEC 32
  90. #define CIR_NOISE_THR_RC5 22
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif