lpc_adc.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef _ARCH_CM3_NXP_MACH_LPC_ADC_H_
  2. #define _ARCH_CM3_NXP_MACH_LPC_ADC_H_
  3. /*
  4. * Copyright 2011 by egnite GmbH
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*!
  35. * \file arch/cm3/nxp/mach/lpc_adc.h
  36. * \brief LPC ADC definitions
  37. *
  38. * \verbatim
  39. * $Id$
  40. * \endverbatim
  41. */
  42. /*!
  43. * \addtogroup xgNutArchArmv7mLpcAdc
  44. */
  45. /*@{*/
  46. /*! \name ADC Control Register */
  47. /*@{*/
  48. #define ADC_CR_OFF 0x00000000
  49. #define ADC_CR_CH_SEL(x) _BV(x)
  50. #define ADC_CR_CLKDIV(d) ((n) << 8)
  51. #define ADC_CR_BURST _BV(16)
  52. #define ADC_CR_PDN _BV(21)
  53. #define ADC_CR_START_MODE_SEL(x) ((x) << 24)
  54. #define ADC_CR_START_MASK ADC_CR_START_MODE_SEL(7)
  55. #define ADC_CR_START_NOW (1UL<<24))
  56. #define ADC_CR_START_EINT0 (2 << 24)
  57. #define ADC_CR_START_CAP01 (3 << 24)
  58. #define ADC_CR_START_MAT01 (4 << 24)
  59. #define ADC_CR_START_MAT03 (5 << 24)
  60. #define ADC_CR_START_MAT10 (6 << 24)
  61. #define ADC_CR_START_MAT11 (7 << 24)
  62. #define ADC_CR_EDGE _BV(27)
  63. /*@}*/
  64. /*! \name ADC Global Data Register */
  65. /*@{*/
  66. #define ADC_GDR_OFF 0x00000004
  67. #define ADC_GDR_RESULT(x) (((x) >> 4) & 0xFFF)
  68. #define ADC_GDR_CH(x) (((x) >> 24) & 7)
  69. #define ADC_GDR_CH_MASK (7 << 24)
  70. #define ADC_GDR_OVERRUN_FLAG _BV(30)
  71. #define ADC_GDR_DONE_FLAG _BV(31)
  72. /*@}*/
  73. /*! \name ADC Interrupt Register */
  74. /*@{*/
  75. #define ADC_INTEN_OFF 0x0000000C
  76. #define ADC_INTEN_CH(x) _BV(x)
  77. #define ADC_INTEN_GLOBAL _BV(8)
  78. /*@}*/
  79. /*! \name ADC Data Registers */
  80. /*@{*/
  81. #define ADC_DR_OFF(x) ((x) * 4 + 0x00000010)
  82. #define ADC_DR_OVERRUN_FLAG _BV(30)
  83. #define ADC_DR_DONE_FLAG _BV(31)
  84. /*@}*/
  85. /*! \name ADC Status Register */
  86. /*@{*/
  87. #define ADC_STAT_OFF 0x00000030
  88. #define ADC_STAT_CH_DONE_FLAG(x) _BV(x)
  89. #define ADC_STAT_CH_OVERRUN_FLAG(x) _BV((x) + 8)
  90. #define ADC_STAT_INT_FLAG _BV(16)
  91. /*@}*/
  92. /*! \name ADC Trim Register */
  93. /*@{*/
  94. #define ADC_TRIM_OFF 0x00000034
  95. /*@}*/
  96. #if defined(LPC_ADC_BASE)
  97. #define AD0CR (LPC_ADC_BASE + ADC_CR_OFF)
  98. #define AD0GDR (LPC_ADC_BASE + ADC_GDR_OFF)
  99. #define AD0INTEN (LPC_ADC_BASE + ADC_INTEN_OFF)
  100. #define AD0DR(x) (LPC_ADC_BASE + ADC_DR_OFF(x))
  101. #define AD0STAT (LPC_ADC_BASE + ADC_STAT_OFF)
  102. #define AD0TRIM (LPC_ADC_BASE + ADC_TRIM_OFF)
  103. #endif
  104. /*@}*/
  105. #endif