adc.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*****************************************************************************
  2. *
  3. * \file
  4. *
  5. * \brief ADC header for AVR UC3 UC3.
  6. *
  7. * This file defines a useful set of functions for ADC on AVR UC3 devices.
  8. *
  9. * Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries.
  10. *
  11. * \asf_license_start
  12. *
  13. * \page License
  14. *
  15. * Subject to your compliance with these terms, you may use Microchip
  16. * software and any derivatives exclusively with Microchip products.
  17. * It is your responsibility to comply with third party license terms applicable
  18. * to your use of third party software (including open source software) that
  19. * may accompany Microchip software.
  20. *
  21. * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
  22. * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
  23. * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
  24. * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
  25. * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
  26. * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
  27. * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
  28. * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
  29. * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
  30. * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
  31. * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
  32. *
  33. * \asf_license_stop
  34. *
  35. *****************************************************************************/
  36. /*
  37. * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
  38. */
  39. #ifndef _ADC_H_
  40. #define _ADC_H_
  41. /**
  42. * \defgroup group_avr32_drivers_adc ADC - Analog to Digital Converter
  43. *
  44. * Analog to Digital Converter is able to capture analog signals and transform
  45. * them
  46. * into digital format with 10-bit resolution.
  47. *
  48. * \{
  49. */
  50. #include <avr32/io.h>
  51. #include "compiler.h"
  52. /* if using 8 bits for ADC, define this flag in your compiler options */
  53. /** Max value for ADC resolution */
  54. #ifdef USE_ADC_8_BITS
  55. # define ADC_MAX_VALUE 0xFF
  56. #else
  57. # define ADC_MAX_VALUE 0x3FF
  58. #endif
  59. void adc_configure(volatile avr32_adc_t *adc);
  60. void adc_start(volatile avr32_adc_t *adc);
  61. void adc_enable(volatile avr32_adc_t *adc, uint16_t channel);
  62. void adc_disable(volatile avr32_adc_t *adc, uint16_t channel);
  63. bool adc_get_status(volatile avr32_adc_t *adc, uint16_t channel);
  64. bool adc_check_eoc(volatile avr32_adc_t *adc, uint16_t channel);
  65. bool adc_check_ovr(volatile avr32_adc_t *adc, uint16_t channel);
  66. uint32_t adc_get_value(volatile avr32_adc_t *adc,
  67. uint16_t channel);
  68. uint32_t adc_get_latest_value(volatile avr32_adc_t *adc);
  69. /**
  70. * \}
  71. */
  72. #endif /* _ADC_H_ */