atimer_001.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * @brief Alarm 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 __ATIMER_001_H_
  32. #define __ATIMER_001_H_
  33. #include "sys_config.h"
  34. #include "cmsis.h"
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /** @defgroup IP_ATIMER_001 IP: ATimer register block and driver
  39. * @ingroup IP_Drivers
  40. * Alarm timer
  41. * @{
  42. */
  43. /**
  44. * @brief Alarm Timer register block structure
  45. */
  46. typedef struct { /*!< ATIMER Structure */
  47. __IO uint32_t DOWNCOUNTER; /*!< Downcounter register */
  48. __IO uint32_t PRESET; /*!< Preset value register */
  49. __I uint32_t RESERVED0[1012];
  50. __O uint32_t CLR_EN; /*!< Interrupt clear enable register */
  51. __O uint32_t SET_EN; /*!< Interrupt set enable register */
  52. __I uint32_t STATUS; /*!< Status register */
  53. __I uint32_t ENABLE; /*!< Enable register */
  54. __O uint32_t CLR_STAT; /*!< Clear register */
  55. __O uint32_t SET_STAT; /*!< Set register */
  56. } IP_ATIMER_001_Type;
  57. /**
  58. * @brief Close ATIMER device
  59. * @param pATimer : Pointer to timer device
  60. * @return None
  61. * Important: 32KHz clock must be enabled in CREG prior to this call. See
  62. * the User Manual for more information.
  63. */
  64. void IP_ATIMER_DeInit(IP_ATIMER_001_Type *pATimer);
  65. /**
  66. * @brief Clear ATIMER Interrupt Status
  67. * @param pATimer : Pointer to timer device
  68. * @return None
  69. */
  70. STATIC INLINE void IP_ATIMER_ClearIntStatus(IP_ATIMER_001_Type *pATimer)
  71. {
  72. pATimer->CLR_STAT = 1;
  73. }
  74. /**
  75. * @brief Set ATIMER Interrupt Status
  76. * @param pATimer : Pointer to timer device
  77. * @return None
  78. */
  79. STATIC INLINE void IP_ATIMER_SetIntStatus(IP_ATIMER_001_Type *pATimer)
  80. {
  81. pATimer->SET_STAT = 1;
  82. }
  83. /**
  84. * @brief Enable ATIMER Interrupt
  85. * @param pATimer : Pointer to timer device
  86. * @return None
  87. */
  88. STATIC INLINE void IP_ATIMER_IntEnable(IP_ATIMER_001_Type *pATimer)
  89. {
  90. pATimer->SET_EN = 1;
  91. }
  92. /**
  93. * @brief Disable ATIMER Interrupt
  94. * @param pATimer : Pointer to timer device
  95. * @return None
  96. */
  97. STATIC INLINE void IP_ATIMER_IntDisable(IP_ATIMER_001_Type *pATimer)
  98. {
  99. pATimer->CLR_EN = 1;
  100. }
  101. /**
  102. * @brief Update Preset value
  103. * @param pATimer : Pointer to timer device
  104. * @param PresetValue updated preset value
  105. * @return Nothing
  106. */
  107. STATIC INLINE void IP_ATIMER_UpdatePresetValue(IP_ATIMER_001_Type *pATimer, uint32_t PresetValue)
  108. {
  109. pATimer->PRESET = PresetValue;
  110. }
  111. /**
  112. * @brief Read value of preset register
  113. * @param pATimer : Pointer to timer/counter device
  114. * @return Value of capture register
  115. */
  116. STATIC INLINE uint32_t IP_ATIMER_GetPresetValue(IP_ATIMER_001_Type *pATimer)
  117. {
  118. return pATimer->PRESET;
  119. }
  120. /**
  121. * @brief Returns enable state of ATimer interrupt
  122. * @param pATimer : Pointer to timer/counter device
  123. * @return !0 if the ATimer interrupt is enabled, otherwise 0
  124. */
  125. STATIC INLINE uint32_t IP_ATIMER_GetIntEnableState(IP_ATIMER_001_Type *pATimer)
  126. {
  127. return pATimer->ENABLE;
  128. }
  129. /**
  130. * @brief Returns current pending state of ATimer interrupt
  131. * @param pATimer : Pointer to timer/counter device
  132. * @return !0 if the ATimer interrupt is asserted, otherwise 0
  133. */
  134. STATIC INLINE uint32_t IP_ATIMER_GetIntPendingState(IP_ATIMER_001_Type *pATimer)
  135. {
  136. return pATimer->STATUS;
  137. }
  138. /**
  139. * @}
  140. */
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif /* __ATIMER_001_H_ */