ciu32f003_std_irtim(2).h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /************************************************************************************************/
  2. /**
  3. * @file ciu32f003_std_irtim.h
  4. * @author MCU Ecosystem Development Team
  5. * @brief IRTIM STD库驱动头文件。
  6. * 提供IRTIM相关的STD库操作函数声明、数据类型以及常量的定义。
  7. *
  8. *
  9. **************************************************************************************************
  10. * @attention
  11. * Copyright (c) CEC Huada Electronic Design Co.,Ltd. All rights reserved.
  12. *
  13. **************************************************************************************************
  14. */
  15. /* 避免头文件重复引用 */
  16. #ifndef CIU32F003_STD_IRTIM_H
  17. #define CIU32F003_STD_IRTIM_H
  18. /************************************************************************************************/
  19. /**
  20. * @addtogroup CIU32F003_STD_Driver
  21. * @{
  22. */
  23. /**
  24. * @defgroup IRTIM IRTIM
  25. * @brief 红外控制模块的STD库驱动
  26. * @{
  27. */
  28. /************************************************************************************************/
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /*------------------------------------------includes--------------------------------------------*/
  33. #include "ciu32f003_std_common.h"
  34. /*--------------------------------------------define--------------------------------------------*/
  35. /************************************************************************************************/
  36. /**
  37. * @defgroup IRTIM_Constants IRTIM Constants
  38. * @brief IRTIM常量定义及宏定义
  39. * @{
  40. *
  41. */
  42. /************************************************************************************************/
  43. /* IRTIM 调制信号源选择 */
  44. #define ITRIM_SIGNAL_SOURCE_TIM3_OC1 IRTIM_CR_IR_MODE_TIM3_OC1 /**< 调制信号源于TIM3_OC1 */
  45. #define ITRIM_SIGNAL_SOURCE_UART1_TX IRTIM_CR_IR_MODE_UART1_TX /**< 调制信号源于UART1_TX */
  46. #define ITRIM_SIGNAL_SOURCE_UART2_TX IRTIM_CR_IR_MODE_UART2_TX /**< 调制信号源于UART2_TX */
  47. /* IRTIM 输出信号极性选择 */
  48. #define IRTIM_POLARITY_DIRECT (0x00000000U) /**< IRTIM 输出信号未反相 */
  49. #define IRTIM_POLARITY_INVERSE IRTIM_CR_IR_POL /**< IRTIM 输出信号反相 */
  50. /**
  51. * @}
  52. */
  53. /*-------------------------------------------functions------------------------------------------*/
  54. /************************************************************************************************/
  55. /**
  56. * @defgroup IRTIM_External_Functions IRTIM External Functions
  57. * @brief IRTIM对外函数
  58. * @{
  59. *
  60. */
  61. /************************************************************************************************/
  62. /**
  63. * @brief 配置IRTIM调制信号源
  64. * @param source 调制信号源选择
  65. * @arg ITRIM_SIGNAL_SOURCE_TIM3_OC1: 调制信号源为TIM3的OC1
  66. * @arg ITRIM_SIGNAL_SOURCE_UART1_TX: 调制信号源为UART1
  67. * @arg ITRIM_SIGNAL_SOURCE_UART2_TX: 调制信号源为UART2
  68. * @retval 无
  69. */
  70. __STATIC_INLINE void std_irtim_set_signal_source(uint32_t source)
  71. {
  72. MODIFY_REG(IRTIM->CR, IRTIM_CR_IR_MODE, source);
  73. }
  74. /**
  75. * @brief 获取IRTIM调制信号源
  76. * @retval uint32_t 调制信号源
  77. * @arg ITRIM_SIGNAL_SOURCE_TIM3_OC1: 调制信号源为TIM3的OC1
  78. * @arg ITRIM_SIGNAL_SOURCE_UART1_TX: 调制信号源为UART1
  79. * @arg ITRIM_SIGNAL_SOURCE_UART2_TX: 调制信号源为UART2
  80. */
  81. __STATIC_INLINE uint32_t std_irtim_get_signal_source(void)
  82. {
  83. return(IRTIM->CR & IRTIM_CR_IR_MODE);
  84. }
  85. /**
  86. * @brief IR_OUT输出信号极性选择
  87. * @param polarity 输出信号极性
  88. * @arg IRTIM_POLARITY_DIRECT: 输出信号未反相
  89. * @arg IRTIM_POLARITY_INVERSE: 输出信号反相
  90. * @retval 无
  91. */
  92. __STATIC_INLINE void std_irtim_set_polarity(uint32_t polarity)
  93. {
  94. MODIFY_REG(IRTIM->CR, IRTIM_CR_IR_POL, polarity);
  95. }
  96. /**
  97. * @brief 获取IR_OUT输出信号极性状态
  98. * @retval uint32_t 返回逻辑表达式的判断结果
  99. * @arg 非0: 表示IRTIM输出信号反相
  100. * @arg 0: 表示IRTIM输出信号未相反
  101. */
  102. __STATIC_INLINE uint32_t std_irtim_get_polarity(void)
  103. {
  104. return(IRTIM->CR & IRTIM_CR_IR_POL);
  105. }
  106. /**
  107. * @}
  108. */
  109. #ifdef __cplusplus
  110. }
  111. #endif
  112. /**
  113. * @}
  114. */
  115. /**
  116. * @}
  117. */
  118. #endif /* CIU32F003_STD_IRTIM_H */