![]() |
BLDC control on ATAVRMC303 with ATxMega128A1
|
XMEGA ADC driver source file. More...
#include "adc_driver.h"
Go to the source code of this file.
Functions | |
| void | ADC_CalibrationValues_Set (ADC_t *adc) |
| This function get the calibration data from the production calibration. More... | |
| uint8_t | ADC_Offset_Get (ADC_t *adc) |
| This function get the offset of the ADC. More... | |
| uint8_t | ADC_ResultCh_GetHighByte (ADC_CH_t *adc_ch) |
| This function clears the interrupt flag and returns the high byte of the coversion result. More... | |
| uint8_t | ADC_ResultCh_GetLowByte (ADC_CH_t *adc_ch, uint8_t offset) |
| This function clears the interrupt flag and returns the low byte of the coversion result. More... | |
| uint16_t | ADC_ResultCh_GetWord (ADC_CH_t *adc_ch, uint8_t offset) |
| This function clears the interrupt flag and returns the coversion result. More... | |
| void | ADC_Wait_32MHz (ADC_t *adc) |
| This function waits until the adc common mode is settled. More... | |
| void | ADC_Wait_8MHz (ADC_t *adc) |
| This function waits until the adc common mode is settled. More... | |
XMEGA ADC driver source file.
This file contains the function implementations the XMEGA ADC driver.
The driver is not intended for size and/or speed critical code, since most functions are just a few lines of code, and the function call overhead would decrease code performance. The driver is intended for rapid prototyping and documentation purposes for getting started with the XMEGA ADC module.
For size and/or speed critical code, it is recommended to copy the function contents directly into your application instead of making a function call.
Several functions use the following construct: "some_register = ... | (some_parameter ? SOME_BIT_bm : 0) | ..." Although the use of the ternary operator ( if ? then : else ) is discouraged, in some occasions the operator makes it possible to write pretty clean and neat code. In this driver, the construct is used to set or not set a configuration bit based on a boolean input parameter, such as the "some_parameter" in the example above.
Copyright (c) 2008, Atmel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file adc_driver.c.
| void ADC_CalibrationValues_Set | ( | ADC_t * | adc | ) |
This function get the calibration data from the production calibration.
The calibration data is loaded from flash and stored in the calibration register. The calibration data reduces the gain error in the adc.
| adc | Pointer to ADC module register section. |
Definition at line 77 of file adc_driver.c.
References SP_ReadCalibrationByte().
Referenced by ADC_Init().

| uint8_t ADC_Offset_Get | ( | ADC_t * | adc | ) |
This function get the offset of the ADC.
This function make an internal coupling to the same pin and calculate the internal offset in the ADC.
| adc | Pointer to the ADC to calculate offset from. |
Definition at line 241 of file adc_driver.c.
References ADC_Ch_Conversion_Complete, ADC_Ch_Conversion_Start, ADC_Ch_InputMode_and_Gain_Config, ADC_Ch_InputMux_Config, ADC_ConvMode_and_Resolution_Config, ADC_Disable, ADC_Enable, ADC_Prescaler_Config, ADC_Referance_Config, ADC_ResultCh_GetLowByte(), ADC_Wait_32MHz(), offset, and SP_ReadCalibrationByte().
Referenced by ADC_Init().

| uint8_t ADC_ResultCh_GetHighByte | ( | ADC_CH_t * | adc_ch | ) |
This function clears the interrupt flag and returns the high byte of the coversion result.
This funtion should be used together with the ADC_ResultCh_ConversionComplete. When the conversion result is ready this funciton reads out the result.
| adc_ch | Pointer to ADC channel register section. |
Definition at line 160 of file adc_driver.c.
| uint8_t ADC_ResultCh_GetLowByte | ( | ADC_CH_t * | adc_ch, |
| uint8_t | offset | ||
| ) |
This function clears the interrupt flag and returns the low byte of the coversion result.
This funtion should be used together with the ADC_Ch_Conversion_Complete. When the conversion result is ready this funciton reads out the result.
| adc_ch | Pointer to ADC channel register section. |
| offset | Compansation offset value. |
Definition at line 131 of file adc_driver.c.
References offset.
Referenced by ADC_Offset_Get().
| uint16_t ADC_ResultCh_GetWord | ( | ADC_CH_t * | adc_ch, |
| uint8_t | offset | ||
| ) |
This function clears the interrupt flag and returns the coversion result.
This function should be used together with the ADC_Ch_Conversion_Complete. When the conversion result is ready this funciton reads out the result.
| adc_ch | Pointer to ADC channel register section. |
| offset | Offset value that is compansated for. |
Definition at line 98 of file adc_driver.c.
Referenced by mc_ADC_Scheduler().
| void ADC_Wait_32MHz | ( | ADC_t * | adc | ) |
This function waits until the adc common mode is settled.
After the ADC clock has been turned on, the common mode voltage in the ADC need some time to settle. The time it takes equals one dummy conversion. Instead of doing a dummy conversion this function waits until the common mode is settled.
| adc | Pointer to ADC module register section. |
Definition at line 214 of file adc_driver.c.
References COMMEN_MODE_CYCLES.
Referenced by ADC_Offset_Get().
| void ADC_Wait_8MHz | ( | ADC_t * | adc | ) |
This function waits until the adc common mode is settled.
After the ADC clock has been turned on, the common mode voltage in the ADC need some time to settle. The time it takes equals one dummy conversion. Instead of doing a dummy conversion this function waits until the common mode is settled.
| adc | Pointer to ADC module register section. |
Definition at line 182 of file adc_driver.c.
References COMMEN_MODE_CYCLES.
Referenced by ADC_Init().