Driver for the ADCIFB (Analog-to-Digital Converter Interface B).
Provides functions for configuration of conversion parameters (up to 12-bit signed with 16x interpolation at 6 MHz), enabling channels (max. 32, see device datasheet for details) and conversion triggering. Resistive touch screen mode is not supported by this driver.
Data Structures | |
struct | adcifb_opt_t |
Macros | |
#define | ADCIFB_POLL_TIMEOUT 10000 |
Functions | |
static void | adcifb_channels_disable (volatile avr32_adcifb_t *adcifb, uint32_t channels_mask) |
Disable one or several channels. More... | |
static void | adcifb_channels_enable (volatile avr32_adcifb_t *adcifb, uint32_t channels_mask) |
Enable one or several channels. More... | |
static void | adcifb_clear_all_interrupt_flags (volatile avr32_adcifb_t *adcifb) |
Clear all ADCIFB interrupt flags. More... | |
static void | adcifb_clear_busy_interrupt_flag (volatile avr32_adcifb_t *adcifb) |
Clear ADCIFB Busy Interrupt flag. More... | |
static void | adcifb_clear_compare_else_interrupt_flag (volatile avr32_adcifb_t *adcifb) |
Clear ADCIFB Compare Else interrupt flag. More... | |
static void | adcifb_clear_compare_gt_interrupt_flag (volatile avr32_adcifb_t *adcifb) |
Clear ADCIFB Compare Greater than interrupt flag. More... | |
static void | adcifb_clear_compare_lt_interrupt_flag (volatile avr32_adcifb_t *adcifb) |
Clear ADCIFB Compare Less than interrupt flag. More... | |
static void | adcifb_clear_data_ready_interrupt_flag (volatile avr32_adcifb_t *adcifb) |
Clear ADCIFB Data Ready Interrupt flag. More... | |
static void | adcifb_clear_interrupt_flag (volatile avr32_adcifb_t *adcifb, uint32_t interrupt_mask) |
Clear ADCIFB interrupt flags. More... | |
static void | adcifb_clear_no_contact_interrupt_flag (volatile avr32_adcifb_t *adcifb) |
Clear ADCIFB No Contact Interrupt flag. More... | |
static void | adcifb_clear_overrun_error_interrupt_flag (volatile avr32_adcifb_t *adcifb) |
Clear ADCIFB Overrun Error Interrupt flag. More... | |
static void | adcifb_clear_pen_contact_interrupt_flag (volatile avr32_adcifb_t *adcifb) |
Clear ADCIFB Pen Contact Interrupt flag. More... | |
static void | adcifb_clear_ready_interrupt_flag (volatile avr32_adcifb_t *adcifb) |
Clear ADCIFB Ready Interrupt flag. More... | |
int32_t | adcifb_configure (volatile avr32_adcifb_t *adcifb, const adcifb_opt_t *p_adcifb_opt) |
Initialize the ADCIFB module (enable and configure). More... | |
int32_t | adcifb_configure_trigger (volatile avr32_adcifb_t *adcifb, uint8_t trgmod, uint32_t trgper) |
Configure the ADCIFB trigger mode. More... | |
int32_t | adcifb_disable (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB. More... | |
static void | adcifb_disable_all_interrupts (volatile avr32_adcifb_t *adcifb) |
Disable all ADCIFB interrupts. More... | |
static void | adcifb_disable_busy_interrupt (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB Busy Interrupt. More... | |
static void | adcifb_disable_compare_else_interrupt (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB Compare Else interrupt. More... | |
static void | adcifb_disable_compare_gt_interrupt (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB Compare Greater than interrupt. More... | |
static void | adcifb_disable_compare_lt_interrupt (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB Compare Less than interrupt. More... | |
static void | adcifb_disable_data_ready_interrupt (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB Data Ready Interrupt. More... | |
static void | adcifb_disable_interrupt (volatile avr32_adcifb_t *adcifb, uint32_t interrupt_mask) |
Disable ADCIFB interrupts. More... | |
static void | adcifb_disable_no_contact_interrupt (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB No Contact Interrupt. More... | |
static void | adcifb_disable_overrun_error_interrupt (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB Overrun Error Interrupt. More... | |
static void | adcifb_disable_pen_contact_interrupt (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB Pen Contact Interrupt. More... | |
static void | adcifb_disable_ready_interrupt (volatile avr32_adcifb_t *adcifb) |
Disable ADCIFB Ready Interrupt. More... | |
static void | adcifb_enable_analog_compare_mode (volatile avr32_adcifb_t *adcifb) |
Enable Analog Compare mode in ADCIFB. More... | |
static void | adcifb_enable_analog_pin_output (volatile avr32_adcifb_t *adcifb) |
Enable Analog Pin output when using touch screen mode in ADCIFB. More... | |
static void | adcifb_enable_busy_interrupt (volatile avr32_adcifb_t *adcifb) |
Enable ADCIFB Busy Interrupt. More... | |
static void | adcifb_enable_compare_else_interrupt (volatile avr32_adcifb_t *adcifb) |
Enable ADCIFB Compare Else interrupt. More... | |
static void | adcifb_enable_compare_gt_interrupt (volatile avr32_adcifb_t *adcifb) |
Enable ADCIFB Compare Greater than interrupt. More... | |
static void | adcifb_enable_compare_lt_interrupt (volatile avr32_adcifb_t *adcifb) |
Enable ADCIFB Compare Less than interrupt. More... | |
static void | adcifb_enable_data_ready_interrupt (volatile avr32_adcifb_t *adcifb) |
Enable ADCIFB Data Ready Interrupt. More... | |
static void | adcifb_enable_interrupt (volatile avr32_adcifb_t *adcifb, uint32_t interrupt_mask) |
Enable ADCIFB interrupts. More... | |
static void | adcifb_enable_no_contact_interrupt (volatile avr32_adcifb_t *adcifb) |
Enable ADCIFB No Contact Interrupt. More... | |
static void | adcifb_enable_overrun_error_interrupt (volatile avr32_adcifb_t *adcifb) |
Enable ADCIFB Overrun Error Interrupt. More... | |
static void | adcifb_enable_pen_contact_interrupt (volatile avr32_adcifb_t *adcifb) |
Enable ADCIFB Pen Contact Interrupt. More... | |
void | adcifb_enable_pen_detect_mode (volatile avr32_adcifb_t *adcifb, uint8_t pen_dbc_period) |
Enable Pen Detect mode in ADCIFB. More... | |
static void | adcifb_enable_ready_interrupt (volatile avr32_adcifb_t *adcifb) |
Enable ADCIFB Ready Interrupt. More... | |
void | adcifb_enable_touch_screen_mode (volatile avr32_adcifb_t *adcifb, uint8_t touch_screen_pin_offset, bool analog_pin_output_enable) |
Enable Touch Screen mode in ADCIFB. More... | |
uint32_t | adcifb_get_last_data (volatile avr32_adcifb_t *adcifb) |
Get Last Converted data. More... | |
bool | adcifb_is_busy (volatile avr32_adcifb_t *adcifb) |
Check if the ADCIFB is busy. More... | |
bool | adcifb_is_drdy (volatile avr32_adcifb_t *adcifb) |
Check if one or more data has been converted since the start of conversion and is available. More... | |
bool | adcifb_is_ovre (volatile avr32_adcifb_t *adcifb) |
Check if one or more Overrun Error has occurred since the start of conversion. More... | |
bool | adcifb_is_ready (volatile avr32_adcifb_t *adcifb) |
Check if the ADCIFB is ready to perform a conversion sequence. More... | |
static void | adcifb_reset (volatile avr32_adcifb_t *adcifb) |
Resets the ADCIFB module(software reset) More... | |
static void | adcifb_set_high_compare_value (volatile avr32_adcifb_t *adcifb, uint32_t compare_value) |
Set the ADCIFB Compare High Value Register. More... | |
static void | adcifb_set_low_compare_value (volatile avr32_adcifb_t *adcifb, uint32_t compare_value) |
Set the ADCIFB Compare Low Value Register. More... | |
static void | adcifb_set_pen_debouncing_period (volatile avr32_adcifb_t *adcifb, uint8_t pen_dbc_period) |
Set the ADCIFB Pen Detect Debouncing Period. More... | |
static void | adcifb_set_touch_screen_pin_offset (volatile avr32_adcifb_t *adcifb, uint8_t touch_screen_pin_offset) |
Set the ADCIFB Touch Screen Pin Offset value. More... | |
int32_t | adcifb_sr_statushigh_wait (volatile avr32_adcifb_t *adcifb, uint32_t statusMask) |
Wait for a status high in the ADCIFB SR status register. More... | |
static void | adcifb_start_conversion_sequence (volatile avr32_adcifb_t *adcifb) |
Start an ADC conversion sequence (Software trigger) More... | |
#define ADCIFB_POLL_TIMEOUT 10000 |
The timeguard used for polling.
Referenced by adcifb_disable(), and adcifb_sr_statushigh_wait().
|
inlinestatic |
Disable one or several channels.
*adcifb | Base address of the ADCIFB module |
channels_mask | Bitmask of channels to disable |
|
inlinestatic |
Enable one or several channels.
*adcifb | Base address of the ADCIFB module |
channels_mask | Bitmask of channels to enable |
Referenced by main().
|
inlinestatic |
Clear all ADCIFB interrupt flags.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Clear ADCIFB Busy Interrupt flag.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Clear ADCIFB Compare Else interrupt flag.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Clear ADCIFB Compare Greater than interrupt flag.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Clear ADCIFB Compare Less than interrupt flag.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Clear ADCIFB Data Ready Interrupt flag.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Clear ADCIFB interrupt flags.
*adcifb | Base address of the ADCIFB module |
interrupt_mask | Bitmask of interrupts to clear |
|
inlinestatic |
Clear ADCIFB No Contact Interrupt flag.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Clear ADCIFB Overrun Error Interrupt flag.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Clear ADCIFB Pen Contact Interrupt flag.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Clear ADCIFB Ready Interrupt flag.
*adcifb | Base address of the ADCIFB module |
int32_t adcifb_configure | ( | volatile avr32_adcifb_t * | adcifb, |
const adcifb_opt_t * | p_adcifb_opt | ||
) |
Initialize the ADCIFB module (enable and configure).
Mandatory to call.
*adcifb | Base address of the ADCIFB module |
p_adcifb_opt | Structure for the ADCIFB module configuration |
0 | ADCIFB successfully enabled and configured |
<0 | ADCIFB initialization failed. |
References adcifb_sr_statushigh_wait(), adcifb_opt_t::ratio_clkadcifb_clkadc, adcifb_opt_t::resolution, adcifb_opt_t::shtim, adcifb_opt_t::sleep_mode_enable, and adcifb_opt_t::startup.
Referenced by main().
int32_t adcifb_configure_trigger | ( | volatile avr32_adcifb_t * | adcifb, |
uint8_t | trgmod, | ||
uint32_t | trgper | ||
) |
Configure the ADCIFB trigger mode.
*adcifb | Base address of the ADCIFB module |
trgmod | Trigger mode, one of AVR32_ADCIFB_TRGR_TRGMOD_* defines (cf adcifb_xxx.h part header file) |
trgper | Defines the Trigger period where Trigger Period = trgper *Tclk_adc (effective only if trigger_mode==AVR32_ADCIFB_TRGMOD_PT) |
0 | ADCIFB trigger mode successfully configured |
<0 | ADCIFB trigger mode configuration failed. |
References PASS.
Referenced by main().
int32_t adcifb_disable | ( | volatile avr32_adcifb_t * | adcifb | ) |
Disable ADCIFB.
*adcifb | Base address of the ADCIFB module |
0 | ADCIFB successfully disabled |
<0 | ADCIFB configuration failed. |
References adcifb_is_busy(), ADCIFB_POLL_TIMEOUT, and PASS.
|
inlinestatic |
Disable all ADCIFB interrupts.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Disable ADCIFB Busy Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Disable ADCIFB Compare Else interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Disable ADCIFB Compare Greater than interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Disable ADCIFB Compare Less than interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Disable ADCIFB Data Ready Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Disable ADCIFB interrupts.
*adcifb | Base address of the ADCIFB module |
interrupt_mask | Bitmask of interrupts to disable |
|
inlinestatic |
Disable ADCIFB No Contact Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Disable ADCIFB Overrun Error Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Disable ADCIFB Pen Contact Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Disable ADCIFB Ready Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Enable Analog Compare mode in ADCIFB.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Enable Analog Pin output when using touch screen mode in ADCIFB.
*adcifb | Base address of the ADCIFB module |
Referenced by adcifb_enable_touch_screen_mode().
|
inlinestatic |
Enable ADCIFB Busy Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Enable ADCIFB Compare Else interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Enable ADCIFB Compare Greater than interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Enable ADCIFB Compare Less than interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Enable ADCIFB Data Ready Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Enable ADCIFB interrupts.
*adcifb | Base address of the ADCIFB module |
interrupt_mask | Bitmask of interrupts to enable |
|
inlinestatic |
Enable ADCIFB No Contact Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Enable ADCIFB Overrun Error Interrupt.
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Enable ADCIFB Pen Contact Interrupt.
*adcifb | Base address of the ADCIFB module |
void adcifb_enable_pen_detect_mode | ( | volatile avr32_adcifb_t * | adcifb, |
uint8_t | pen_dbc_period | ||
) |
Enable Pen Detect mode in ADCIFB.
*adcifb | Base address of the ADCIFB module |
pen_dbc_period | Pen Detect Debouncing Period |
References adcifb_set_pen_debouncing_period().
|
inlinestatic |
Enable ADCIFB Ready Interrupt.
*adcifb | Base address of the ADCIFB module |
void adcifb_enable_touch_screen_mode | ( | volatile avr32_adcifb_t * | adcifb, |
uint8_t | touch_screen_pin_offset, | ||
bool | analog_pin_output_enable | ||
) |
Enable Touch Screen mode in ADCIFB.
*adcifb | Base address of the ADCIFB module |
touch_screen_pin_offset | The Touch Screen Pin Offset field is used to indicate which AD pins are connected to the resistive touch screen film edges. |
analog_pin_output_enable | Enable Analog Pin Output in ADCIFB |
References adcifb_enable_analog_pin_output(), and adcifb_set_touch_screen_pin_offset().
uint32_t adcifb_get_last_data | ( | volatile avr32_adcifb_t * | adcifb | ) |
Get Last Converted data.
*adcifb | Base address of the ADCIFB module |
Referenced by main().
bool adcifb_is_busy | ( | volatile avr32_adcifb_t * | adcifb | ) |
Check if the ADCIFB is busy.
*adcifb | Base address of the ADCIFB module |
Referenced by adcifb_disable().
bool adcifb_is_drdy | ( | volatile avr32_adcifb_t * | adcifb | ) |
Check if one or more data has been converted since the start of conversion and is available.
*adcifb | Base address of the ADCIFB module |
Referenced by main().
bool adcifb_is_ovre | ( | volatile avr32_adcifb_t * | adcifb | ) |
Check if one or more Overrun Error has occurred since the start of conversion.
*adcifb | Base address of the ADCIFB module |
bool adcifb_is_ready | ( | volatile avr32_adcifb_t * | adcifb | ) |
Check if the ADCIFB is ready to perform a conversion sequence.
*adcifb | Base address of the ADCIFB module |
Referenced by main().
|
inlinestatic |
Resets the ADCIFB module(software reset)
*adcifb | Base address of the ADCIFB module |
|
inlinestatic |
Set the ADCIFB Compare High Value Register.
*adcifb | Base address of the ADCIFB module |
compare_value | Value to be compared |
|
inlinestatic |
Set the ADCIFB Compare Low Value Register.
*adcifb | Base address of the ADCIFB module |
compare_value | Value to be compared |
|
inlinestatic |
Set the ADCIFB Pen Detect Debouncing Period.
*adcifb | Base address of the ADCIFB module |
pen_dbc_period | Debouncing period |
Referenced by adcifb_enable_pen_detect_mode().
|
inlinestatic |
Set the ADCIFB Touch Screen Pin Offset value.
*adcifb | Base address of the ADCIFB module |
touch_screen_pin_offset | Offset value |
Referenced by adcifb_enable_touch_screen_mode().
int32_t adcifb_sr_statushigh_wait | ( | volatile avr32_adcifb_t * | adcifb, |
uint32_t | statusMask | ||
) |
Wait for a status high in the ADCIFB SR status register.
*adcifb | Base address of the ADCIFB module |
statusMask | Mask field of the status to poll |
0 | Status is high. |
<0 | ADCIFB_POLL_TIMEOUT Timeout expired before the status was high |
References ADCIFB_POLL_TIMEOUT, and PASS.
Referenced by adcifb_configure().
|
inlinestatic |
Start an ADC conversion sequence (Software trigger)
*adcifb | Base address of the ADCIFB module |
Referenced by main().