acc.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /**
  2. * \file
  3. *
  4. * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
  5. *
  6. * \asf_license_start
  7. *
  8. * \page License
  9. *
  10. * Subject to your compliance with these terms, you may use Microchip
  11. * software and any derivatives exclusively with Microchip products.
  12. * It is your responsibility to comply with third party license terms applicable
  13. * to your use of third party software (including open source software) that
  14. * may accompany Microchip software.
  15. *
  16. * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
  17. * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
  18. * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
  19. * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
  20. * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
  21. * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
  22. * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
  23. * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
  24. * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
  25. * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
  26. * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
  27. *
  28. * \asf_license_stop
  29. *
  30. */
  31. /*
  32. * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
  33. */
  34. #ifndef _SAME70_ACC_COMPONENT_
  35. #define _SAME70_ACC_COMPONENT_
  36. /* ============================================================================= */
  37. /** SOFTWARE API DEFINITION FOR Analog Comparator Controller */
  38. /* ============================================================================= */
  39. /** \addtogroup SAME70_ACC Analog Comparator Controller */
  40. /*@{*/
  41. #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
  42. /** \brief Acc hardware registers */
  43. typedef struct {
  44. __O uint32_t ACC_CR; /**< \brief (Acc Offset: 0x00) Control Register */
  45. __IO uint32_t ACC_MR; /**< \brief (Acc Offset: 0x04) Mode Register */
  46. __I uint32_t Reserved1[7];
  47. __O uint32_t ACC_IER; /**< \brief (Acc Offset: 0x24) Interrupt Enable Register */
  48. __O uint32_t ACC_IDR; /**< \brief (Acc Offset: 0x28) Interrupt Disable Register */
  49. __I uint32_t ACC_IMR; /**< \brief (Acc Offset: 0x2C) Interrupt Mask Register */
  50. __I uint32_t ACC_ISR; /**< \brief (Acc Offset: 0x30) Interrupt Status Register */
  51. __I uint32_t Reserved2[24];
  52. __IO uint32_t ACC_ACR; /**< \brief (Acc Offset: 0x94) Analog Control Register */
  53. __I uint32_t Reserved3[19];
  54. __IO uint32_t ACC_WPMR; /**< \brief (Acc Offset: 0xE4) Write Protection Mode Register */
  55. __I uint32_t ACC_WPSR; /**< \brief (Acc Offset: 0xE8) Write Protection Status Register */
  56. __I uint32_t Reserved4[4];
  57. __I uint32_t ACC_VER; /**< \brief (Acc Offset: 0xFC) Version Register */
  58. } Acc;
  59. #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
  60. /* -------- ACC_CR : (ACC Offset: 0x00) Control Register -------- */
  61. #define ACC_CR_SWRST (0x1u << 0) /**< \brief (ACC_CR) Software Reset */
  62. /* -------- ACC_MR : (ACC Offset: 0x04) Mode Register -------- */
  63. #define ACC_MR_SELMINUS_Pos 0
  64. #define ACC_MR_SELMINUS_Msk (0x7u << ACC_MR_SELMINUS_Pos) /**< \brief (ACC_MR) Selection for Minus Comparator Input */
  65. #define ACC_MR_SELMINUS(value) ((ACC_MR_SELMINUS_Msk & ((value) << ACC_MR_SELMINUS_Pos)))
  66. #define ACC_MR_SELMINUS_TS (0x0u << 0) /**< \brief (ACC_MR) Select TS */
  67. #define ACC_MR_SELMINUS_ADVREFP (0x1u << 0) /**< \brief (ACC_MR) Select ADVREFP */
  68. #define ACC_MR_SELMINUS_VREFP (0x1u << 0) /**< \brief (ACC_MR) Select VREFP */
  69. #define ACC_MR_SELMINUS_DAC0 (0x2u << 0) /**< \brief (ACC_MR) Select DAC0 */
  70. #define ACC_MR_SELMINUS_DAC1 (0x3u << 0) /**< \brief (ACC_MR) Select DAC1 */
  71. #define ACC_MR_SELMINUS_AFE0_AD0 (0x4u << 0) /**< \brief (ACC_MR) Select AFE0_AD0 */
  72. #define ACC_MR_SELMINUS_AFE0_AD1 (0x5u << 0) /**< \brief (ACC_MR) Select AFE0_AD1 */
  73. #define ACC_MR_SELMINUS_AFE0_AD2 (0x6u << 0) /**< \brief (ACC_MR) Select AFE0_AD2 */
  74. #define ACC_MR_SELMINUS_AFE0_AD3 (0x7u << 0) /**< \brief (ACC_MR) Select AFE0_AD3 */
  75. #define ACC_MR_SELPLUS_Pos 4
  76. #define ACC_MR_SELPLUS_Msk (0x7u << ACC_MR_SELPLUS_Pos) /**< \brief (ACC_MR) Selection For Plus Comparator Input */
  77. #define ACC_MR_SELPLUS(value) ((ACC_MR_SELPLUS_Msk & ((value) << ACC_MR_SELPLUS_Pos)))
  78. #define ACC_MR_SELPLUS_AFE0_AD0 (0x0u << 4) /**< \brief (ACC_MR) Select AFE0_AD0 */
  79. #define ACC_MR_SELPLUS_AFE0_AD1 (0x1u << 4) /**< \brief (ACC_MR) Select AFE0_AD1 */
  80. #define ACC_MR_SELPLUS_AFE0_AD2 (0x2u << 4) /**< \brief (ACC_MR) Select AFE0_AD2 */
  81. #define ACC_MR_SELPLUS_AFE0_AD3 (0x3u << 4) /**< \brief (ACC_MR) Select AFE0_AD3 */
  82. #define ACC_MR_SELPLUS_AFE0_AD4 (0x4u << 4) /**< \brief (ACC_MR) Select AFE0_AD4 */
  83. #define ACC_MR_SELPLUS_AFE0_AD5 (0x5u << 4) /**< \brief (ACC_MR) Select AFE0_AD5 */
  84. #define ACC_MR_SELPLUS_AFE1_AD0 (0x6u << 4) /**< \brief (ACC_MR) Select AFE1_AD0 */
  85. #define ACC_MR_SELPLUS_AFE1_AD1 (0x7u << 4) /**< \brief (ACC_MR) Select AFE1_AD1 */
  86. #define ACC_MR_ACEN (0x1u << 8) /**< \brief (ACC_MR) Analog Comparator Enable */
  87. #define ACC_MR_ACEN_DIS (0x0u << 8) /**< \brief (ACC_MR) Analog comparator disabled. */
  88. #define ACC_MR_ACEN_EN (0x1u << 8) /**< \brief (ACC_MR) Analog comparator enabled. */
  89. #define ACC_MR_EDGETYP_Pos 9
  90. #define ACC_MR_EDGETYP_Msk (0x3u << ACC_MR_EDGETYP_Pos) /**< \brief (ACC_MR) Edge Type */
  91. #define ACC_MR_EDGETYP(value) ((ACC_MR_EDGETYP_Msk & ((value) << ACC_MR_EDGETYP_Pos)))
  92. #define ACC_MR_EDGETYP_RISING (0x0u << 9) /**< \brief (ACC_MR) Only rising edge of comparator output */
  93. #define ACC_MR_EDGETYP_FALLING (0x1u << 9) /**< \brief (ACC_MR) Falling edge of comparator output */
  94. #define ACC_MR_EDGETYP_ANY (0x2u << 9) /**< \brief (ACC_MR) Any edge of comparator output */
  95. #define ACC_MR_INV (0x1u << 12) /**< \brief (ACC_MR) Invert Comparator Output */
  96. #define ACC_MR_INV_DIS (0x0u << 12) /**< \brief (ACC_MR) Analog comparator output is directly processed. */
  97. #define ACC_MR_INV_EN (0x1u << 12) /**< \brief (ACC_MR) Analog comparator output is inverted prior to being processed. */
  98. #define ACC_MR_SELFS (0x1u << 13) /**< \brief (ACC_MR) Selection Of Fault Source */
  99. #define ACC_MR_SELFS_CE (0x0u << 13) /**< \brief (ACC_MR) The CE flag is used to drive the FAULT output. */
  100. #define ACC_MR_SELFS_OUTPUT (0x1u << 13) /**< \brief (ACC_MR) The output of the analog comparator flag is used to drive the FAULT output. */
  101. #define ACC_MR_FE (0x1u << 14) /**< \brief (ACC_MR) Fault Enable */
  102. #define ACC_MR_FE_DIS (0x0u << 14) /**< \brief (ACC_MR) The FAULT output is tied to 0. */
  103. #define ACC_MR_FE_EN (0x1u << 14) /**< \brief (ACC_MR) The FAULT output is driven by the signal defined by SELFS. */
  104. /* -------- ACC_IER : (ACC Offset: 0x24) Interrupt Enable Register -------- */
  105. #define ACC_IER_CE (0x1u << 0) /**< \brief (ACC_IER) Comparison Edge */
  106. /* -------- ACC_IDR : (ACC Offset: 0x28) Interrupt Disable Register -------- */
  107. #define ACC_IDR_CE (0x1u << 0) /**< \brief (ACC_IDR) Comparison Edge */
  108. /* -------- ACC_IMR : (ACC Offset: 0x2C) Interrupt Mask Register -------- */
  109. #define ACC_IMR_CE (0x1u << 0) /**< \brief (ACC_IMR) Comparison Edge */
  110. /* -------- ACC_ISR : (ACC Offset: 0x30) Interrupt Status Register -------- */
  111. #define ACC_ISR_CE (0x1u << 0) /**< \brief (ACC_ISR) Comparison Edge (cleared on read) */
  112. #define ACC_ISR_SCO (0x1u << 1) /**< \brief (ACC_ISR) Synchronized Comparator Output */
  113. #define ACC_ISR_MASK (0x1u << 31) /**< \brief (ACC_ISR) Flag Mask */
  114. /* -------- ACC_ACR : (ACC Offset: 0x94) Analog Control Register -------- */
  115. #define ACC_ACR_ISEL (0x1u << 0) /**< \brief (ACC_ACR) Current Selection */
  116. #define ACC_ACR_ISEL_LOPW (0x0u << 0) /**< \brief (ACC_ACR) Low-power option. */
  117. #define ACC_ACR_ISEL_HISP (0x1u << 0) /**< \brief (ACC_ACR) High-speed option. */
  118. #define ACC_ACR_HYST_Pos 1
  119. #define ACC_ACR_HYST_Msk (0x3u << ACC_ACR_HYST_Pos) /**< \brief (ACC_ACR) Hysteresis Selection */
  120. #define ACC_ACR_HYST(value) ((ACC_ACR_HYST_Msk & ((value) << ACC_ACR_HYST_Pos)))
  121. /* -------- ACC_WPMR : (ACC Offset: 0xE4) Write Protection Mode Register -------- */
  122. #define ACC_WPMR_WPEN (0x1u << 0) /**< \brief (ACC_WPMR) Write Protection Enable */
  123. #define ACC_WPMR_WPKEY_Pos 8
  124. #define ACC_WPMR_WPKEY_Msk (0xffffffu << ACC_WPMR_WPKEY_Pos) /**< \brief (ACC_WPMR) Write Protection Key */
  125. #define ACC_WPMR_WPKEY(value) ((ACC_WPMR_WPKEY_Msk & ((value) << ACC_WPMR_WPKEY_Pos)))
  126. #define ACC_WPMR_WPKEY_PASSWD (0x414343u << 8) /**< \brief (ACC_WPMR) Writing any other value in this field aborts the write operation of the WPEN bit.Always reads as 0. */
  127. /* -------- ACC_WPSR : (ACC Offset: 0xE8) Write Protection Status Register -------- */
  128. #define ACC_WPSR_WPVS (0x1u << 0) /**< \brief (ACC_WPSR) Write Protection Violation Status */
  129. /* -------- ACC_VER : (ACC Offset: 0xFC) Version Register -------- */
  130. #define ACC_VER_VERSION_Pos 0
  131. #define ACC_VER_VERSION_Msk (0xfffu << ACC_VER_VERSION_Pos) /**< \brief (ACC_VER) Version of the Hardware Module */
  132. #define ACC_VER_MFN_Pos 16
  133. #define ACC_VER_MFN_Msk (0x7u << ACC_VER_MFN_Pos) /**< \brief (ACC_VER) Metal Fix Number */
  134. /*@}*/
  135. #endif /* _SAME70_ACC_COMPONENT_ */