nu_adc.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**************************************************************************//**
  2. * @file adc.h
  3. * @version V1.00
  4. * $Revision: 6 $
  5. * $Date: 15/10/05 7:00p $
  6. * @brief NUC980 ADC driver header file
  7. *
  8. * @note
  9. * SPDX-License-Identifier: Apache-2.0
  10. * Copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
  11. *****************************************************************************/
  12. #ifndef __NU_ADC_H__
  13. #define __NU_ADC_H__
  14. #ifdef __cplusplus
  15. extern "C"
  16. {
  17. #endif
  18. /** @addtogroup Standard_Driver Standard Driver
  19. @{
  20. */
  21. /** @addtogroup ADC_Driver ADC Driver
  22. @{
  23. */
  24. /** @addtogroup ADC_EXPORTED_CONSTANTS ADC Exported Constants
  25. @{
  26. */
  27. #define ADC_ERR_ARGS 1 /*!< The arguments is wrong */
  28. #define ADC_ERR_CMD 2 /*!< The command is wrong */
  29. /// @cond HIDDEN_SYMBOLS
  30. typedef INT32(*ADC_CALLBACK)(UINT32 status, UINT32 userData);
  31. /// @endcond HIDDEN_SYMBOLS
  32. /*---------------------------------------------------------------------------------------------------------*/
  33. /* ADC_CTL constant definitions */
  34. /*---------------------------------------------------------------------------------------------------------*/
  35. #define ADC_CTL_ADEN 0x00000001 /*!< ADC Power Control */
  36. #define ADC_CTL_VBGEN 0x00000002 /*!< ADC Internal Bandgap Power Control */
  37. #define ADC_CTL_MST 0x00000100 /*!< Menu Start Conversion */
  38. /*---------------------------------------------------------------------------------------------------------*/
  39. /* ADC_CONF constant definitions */
  40. /*---------------------------------------------------------------------------------------------------------*/
  41. #define ADC_CONF_NACEN 0x00000004 /*!< Normal AD Conversion Enable */
  42. #define ADC_CONF_SELFTEN 0x00000400 /*!< Selft Test Enable */
  43. #define ADC_CONF_HSPEED (1<<22) /*!< High Speed Enable */
  44. #define ADC_CONF_CHSEL_Pos 12 /*!< Channel Selection Position */
  45. #define ADC_CONF_CHSEL_Msk (0xF<<ADC_CONF_CHSEL_Pos) /*!< Channel Selection Mask */
  46. #define ADC_CONF_REFSEL_Pos 6 /*!< Reference Selection Position */
  47. #define ADC_CONF_REFSEL_Msk (3<<6) /*!< Reference Selection Mask */
  48. #define ADC_CONF_REFSEL_VREF (0<<6) /*!< ADC reference select VREF input */
  49. #define ADC_CONF_REFSEL_AVDD33 (3<<6) /*!< ADC reference select AGND33 vs AVDD33 */
  50. /*---------------------------------------------------------------------------------------------------------*/
  51. /* ADC_IER constant definitions */
  52. /*---------------------------------------------------------------------------------------------------------*/
  53. #define ADC_IER_MIEN 0x00000001 /*!< Menu Interrupt Enable */
  54. /*---------------------------------------------------------------------------------------------------------*/
  55. /* ADC_ISR constant definitions */
  56. /*---------------------------------------------------------------------------------------------------------*/
  57. #define ADC_ISR_MF 0x00000001 /*!< Menu Complete Flag */
  58. #define ADC_ISR_NACF 0x00000400 /*!< Normal AD Conversion Finish */
  59. /** \brief Structure type of ADC_CMD
  60. */
  61. typedef enum
  62. {
  63. START_MST, /*!<Menu Start Conversion */
  64. VBPOWER_ON, /*!<Enable ADC Internal Bandgap Power */
  65. VBPOWER_OFF, /*!<Disable ADC Internal Bandgap Power */
  66. NAC_ON, /*!<Enable Normal AD Conversion */
  67. NAC_OFF, /*!<Disable Normal AD Conversion */
  68. SWITCH_CH, /*!<Switch Channel */
  69. } ADC_CMD;
  70. /*@}*/ /* end of group ADC_EXPORTED_CONSTANTS */
  71. /** @addtogroup ADC_EXPORTED_FUNCTIONS ADC Exported Functions
  72. @{
  73. */
  74. int adcOpen(void);
  75. int adcOpen2(uint32_t freq);
  76. int adcClose(void);
  77. int adcReadXY(short *bufX, short *bufY, int dataCnt);
  78. int adcReadZ(short *bufZ1, short *bufZ2, int dataCnt);
  79. int adcIoctl(ADC_CMD cmd, int arg1, int arg2);
  80. int adcChangeChannel(int channel);
  81. /*@}*/ /* end of group ADC_EXPORTED_FUNCTIONS */
  82. /*@}*/ /* end of group ADC_Driver */
  83. /*@}*/ /* end of group Standard_Driver */
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #endif //__NU_ADC_H__