ritimer_001.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * @brief Repetitive Interrupt Timer registers and control functions
  3. *
  4. * @note
  5. * Copyright(C) NXP Semiconductors, 2012
  6. * All rights reserved.
  7. *
  8. * @par
  9. * Software that is described herein is for illustrative purposes only
  10. * which provides customers with programming information regarding the
  11. * LPC products. This software is supplied "AS IS" without any warranties of
  12. * any kind, and NXP Semiconductors and its licensor disclaim any and
  13. * all warranties, express or implied, including all implied warranties of
  14. * merchantability, fitness for a particular purpose and non-infringement of
  15. * intellectual property rights. NXP Semiconductors assumes no responsibility
  16. * or liability for the use of the software, conveys no license or rights under any
  17. * patent, copyright, mask work right, or any other intellectual property rights in
  18. * or to any products. NXP Semiconductors reserves the right to make changes
  19. * in the software without notification. NXP Semiconductors also makes no
  20. * representation or warranty that such application will be suitable for the
  21. * specified use without further testing or modification.
  22. *
  23. * @par
  24. * Permission to use, copy, modify, and distribute this software and its
  25. * documentation is hereby granted, under NXP Semiconductors' and its
  26. * licensor's relevant copyrights in the software, without fee, provided that it
  27. * is used in conjunction with NXP Semiconductors microcontrollers. This
  28. * copyright, permission, and disclaimer notice must appear in all copies of
  29. * this code.
  30. */
  31. #ifndef __RITIMER_001_H_
  32. #define __RITIMER_001_H_
  33. #include "sys_config.h"
  34. #include "cmsis.h"
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /** @defgroup IP_RITIMER_001 IP: RITimer register block and driver
  39. * @ingroup IP_Drivers
  40. * Repetitive Interrupt Timer
  41. * @{
  42. */
  43. /**
  44. * @brief Repetitive Interrupt Timer register block structure
  45. */
  46. typedef struct { /*!< RITIMER Structure */
  47. __IO uint32_t COMPVAL; /*!< Compare register */
  48. __IO uint32_t MASK; /*!< Mask register. This register holds the 32-bit mask value. A 1 written to any bit will force a compare on the corresponding bit of the counter and compare register. */
  49. __IO uint32_t CTRL; /*!< Control register. */
  50. __IO uint32_t COUNTER; /*!< 32-bit counter */
  51. } IP_RITIMER_001_Type;
  52. /**
  53. * @brief RITIMER register support bitfields and mask
  54. */
  55. /*
  56. * RIT control register
  57. */
  58. /** Set by H/W when the counter value equals the masked compare value */
  59. #define RIT_CTRL_INT ((uint32_t) (1))
  60. /** Set timer enable clear to 0 when the counter value equals the masked compare value */
  61. #define RIT_CTRL_ENCLR ((uint32_t) _BIT(1))
  62. /** Set timer enable on debug */
  63. #define RIT_CTRL_ENBR ((uint32_t) _BIT(2))
  64. /** Set timer enable */
  65. #define RIT_CTRL_TEN ((uint32_t) _BIT(3))
  66. /**
  67. * @brief Initialize the RIT
  68. * @param RITx : RIT peripheral selected
  69. * @return None
  70. */
  71. void IP_RIT_Init(IP_RITIMER_001_Type *RITx);
  72. /**
  73. * @brief DeInitialize the RIT
  74. * @param RITx : RIT peripheral selected
  75. * @return None
  76. */
  77. void IP_RIT_DeInit(IP_RITIMER_001_Type *RITx);
  78. /**
  79. * @brief Enable/Disable Timer
  80. * @param RITx : RIT peripheral selected
  81. * @param NewState : ENABLE to enable RITimer, DISABLE to disable
  82. * @return None
  83. */
  84. void IP_RIT_Enable(IP_RITIMER_001_Type *RITx, FunctionalState NewState);
  85. /**
  86. * @brief Timer Enable/Disable on debug
  87. * @param RITx : RIT peripheral selected
  88. * @param NewState : ENABLE to halt timer whenever a hardware break condition occurs
  89. * @return None
  90. */
  91. void IP_RIT_TimerDebugCmd(IP_RITIMER_001_Type *RITx, FunctionalState NewState);
  92. /**
  93. * @brief Check whether interrupt flag is set or not
  94. * @param RITx : RIT peripheral selected
  95. * @return Current interrupt status, could be SET or UNSET
  96. */
  97. IntStatus IP_RIT_GetIntStatus(IP_RITIMER_001_Type *RITx);
  98. /**
  99. * @brief Set a tick value for the interrupt to time out
  100. * @param RITx : RIT peripheral selected
  101. * @param val : value (in ticks) of the interrupt to be set
  102. * @return None
  103. */
  104. STATIC INLINE void IP_RIT_SetCOMPVAL(IP_RITIMER_001_Type *RITx, uint32_t val)
  105. {
  106. RITx->COMPVAL = val;
  107. }
  108. /**
  109. * @brief Enables or clears the RIT or interrupt
  110. * @param RITx : RIT peripheral selected
  111. * @param val : RIT to be set, one or more RIT_CTRL_* values
  112. * @return None
  113. */
  114. STATIC INLINE void IP_RIT_EnableCTRL(IP_RITIMER_001_Type *RITx, uint32_t val)
  115. {
  116. RITx->CTRL |= val;
  117. }
  118. /**
  119. * @brief Get the RIT Counter value
  120. * @param RITx : RIT peripheral selected
  121. * @return the counter value
  122. */
  123. STATIC INLINE uint32_t IP_RIT_GetCounter(IP_RITIMER_001_Type *RITx)
  124. {
  125. return RITx->COUNTER;
  126. }
  127. /**
  128. * @}
  129. */
  130. #ifdef __cplusplus
  131. }
  132. #endif
  133. #endif /* __RITIMER_001_H_ */