AVR XMEGA analog comparator example.
Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
Functions | |
static void | example_ac_update_single_leds (uint8_t channel, enum ac_status_t status) |
Update LEDs used for feedback from analog comparator channel in single trigger level mode. More... | |
static void | example_ac_update_window_leds (enum ac_status_t status) |
Update LEDs used for feedback from analog comparator in window mode. More... | |
static void | example_aca_interrupt_callback (AC_t *ac, uint8_t channel, enum ac_status_t status) |
Analog comparator A interrupt callback function. More... | |
static void | example_acb_interrupt_callback (AC_t *ac, uint8_t channel, enum ac_status_t status) |
Analog comparator B interrupt callback function. More... | |
int | main (void) |
Main function. More... | |
static void | mdelay (uint16_t ms) |
delay for ms milliseconds More... | |
Variables | |
static struct ac_config | aca0_config |
Analog comparator A channel 0 configuration. More... | |
static struct ac_config | aca1_config |
Analog comparator A channel 1 configuration. More... | |
static struct ac_config | acb_config |
Analog comparator B window configuration. More... | |
|
static |
Update LEDs used for feedback from analog comparator channel in single trigger level mode.
This function will set the LEDs appropriately for the channel that caused the interrupt. See the Description of the example section for additional details.
channel | The analog comparator channel to update status for |
status | Analog comparator channel status given by a ac_status_t value |
References AC_STATUS_ABOVE, gpio_set_pin_high, gpio_set_pin_low, LED4_GPIO, LED5_GPIO, LED6_GPIO, and LED7_GPIO.
Referenced by example_aca_interrupt_callback(), and main().
|
static |
Update LEDs used for feedback from analog comparator in window mode.
This function will set the LEDs appropriately status of the window. See the Description of the example section for additional details.
status | Analog comparator window status given by a ac_status_t value |
References AC_STATUS_ABOVE, AC_STATUS_INSIDE, gpio_set_pin_high, gpio_set_pin_low, LED0_GPIO, LED1_GPIO, LED2_GPIO, and LED3_GPIO.
Referenced by example_acb_interrupt_callback(), and main().
|
static |
Analog comparator A interrupt callback function.
This function is called when an interrupt has occurred on a channel in analog comparator A.
ac | Pointer to the analog comparator (AC) base address which caused the interrupt |
channel | The analog comparator channel that caused the interrupt |
status | Analog comparator channel status given by a ac_status_t value |
References example_ac_update_single_leds().
Referenced by main().
|
static |
Analog comparator B interrupt callback function.
This function is called when an interrupt has occurred on a channel in analog comparator B.
ac | Pointer to the analog comparator (AC) base address which caused the interrupt |
channel | The analog comparator channel that caused the interrupt |
status | Analog comparator window status given by a ac_status_t value |
References ac_disable(), ac_enable(), AC_INT_MODE_INSIDE_WINDOW, AC_INT_MODE_OUTSIDE_WINDOW, ac_set_interrupt_mode(), AC_STATUS_INSIDE, ac_write_config(), acb_config, and example_ac_update_window_leds().
Referenced by main().
int main | ( | void | ) |
Main function.
References ac_enable(), ac_get_status(), AC_INT_LVL_MED, AC_INT_MODE_INSIDE_WINDOW, AC_MODE_WINDOW, ac_read_config(), ac_set_hysteresis(), ac_set_interrupt_callback(), ac_set_interrupt_level(), ac_set_interrupt_mode(), ac_set_mode(), ac_set_negative_reference(), ac_set_positive_reference(), ac_set_voltage_scaler(), ac_write_config(), acb_config, board_init(), cpu_irq_enable, example_ac_update_single_leds(), example_ac_update_window_leds(), example_aca_interrupt_callback(), example_acb_interrupt_callback(), mdelay(), pmic_init(), sleepmgr_enter_sleep(), sleepmgr_init(), and sysclk_init().
|
static |
delay for ms milliseconds
ms | number of milliseconds to busy wait |
References sysclk_get_cpu_hz().
Referenced by main().
|
static |
Analog comparator A channel 0 configuration.
This struct is intentionally just defined, not declared. The example code will use the helper functions to setup the channel configuration.
|
static |
Analog comparator A channel 1 configuration.
This struct configures the an analog comparator channel with the following settings:
|
static |
Analog comparator B window configuration.
This struct is intentionally just defined, not declared. The example code will use the helper functions to setup the analog comparator in window mode.
Referenced by example_acb_interrupt_callback(), and main().