This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the device's Analog Comparator Interface Controller functionality.
The Analog Comparator Interface controls eight Analog Comparators (AC) with identical behavior. Each Analog Comparator compares two voltages, yielding an output that depends on the result of the comparison.
Devices from the following series can use this module:
The outline of this documentation is as follows:
There are no prerequisites for this module.
The Analog Comparator Interface (ACIFC) controls a number of Analog Comparators (AC) with identical behavior. Each Analog Comparator compares two voltages and gives a compare output depending on the results of this comparison.
The ACIFC module can be configured in normal mode, in which each comparator is used independently, or in window mode, which uses defined comparator pairs. The comparators do not all have to be in the same mode; some comparators may be in normal mode, while others are in window mode. There are, however, restrictions on which ACs can be grouped together in window mode.
The ACIFC pins are multiplexed with other peripherals. The user application must therefore configure the GPIO Controller, to give the ACIFC module control of the associated pins.
The ACIFC stops functioning when the system enters a sleep mode that disables its clock. However, the ACIFC module can resume its operation if the system enters the SleepWalking mode and the ACIFC clock is started by the Peripheral Event System. During this time, if the ACIFC module generates an interrupt, the system will wake-up from sleep mode and normal system operation resumes.
The clock for ACIFC (CLK_ACIFC) is generated by the Power Manager (PM). It can be manually disabled, through the Power Manager, or may be automatically disabled when the system enters a sleep mode that disables the clocks to the peripheral bus modules.
The ACIFC interrupt request line is connected to the Nested Vectored Interrupt Controller (NVIC). Using the ACIFC interrupt requires that the NVIC be configured beforehand.
The ACIFC peripheral events are connected via the Peripheral Event System.
When an external debugger forces the CPU into debug mode, the ACIFC module continues normal operation. If the ACIFC module is configured in a way that requires it to be periodically serviced by the CPU through interrupts (or similar), debugging may result in improper operation or data loss.
For extra information, see Extra Information for Analog Comparator Interface Driver. This includes:
For a list of examples related to this driver, see Examples for Analog Comparator Interface.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the SAM4L Analog Comparator Interface Controller (ACIFC) Driver. | |
Data Structures | |
struct | ac_ch_config |
ACIFC channel configuration structure. More... | |
struct | ac_config |
ACIFC module configuration structure. More... | |
struct | ac_dev_inst |
ACIFC driver structure. More... | |
struct | ac_win_config |
ACIFC window configuration structure. More... | |
Typedefs | |
typedef void(* | ac_callback_t )(void) |
ACIFC interrupt callback type. More... | |
typedef enum ac_interrupt_source | ac_interrupt_source_t |
ACIFC interrupt configuration type. More... | |
Functions | |
static void | ac_ch_get_config_defaults (struct ac_ch_config *const cfg) |
Initializes an ACIFC channel configuration structure to default values. More... | |
void | ac_ch_set_config (struct ac_dev_inst *const dev_inst, uint32_t channel, struct ac_ch_config *cfg) |
Configure the specified ACIFC channel. More... | |
static void | ac_clear_interrupt_status (struct ac_dev_inst *const dev_inst, uint32_t status) |
Write to the ACIFC interrupt status. More... | |
void | ac_disable (struct ac_dev_inst *const dev_inst) |
Disable the ACIFC Module. More... | |
void | ac_disable_interrupt (struct ac_dev_inst *const dev_inst, ac_interrupt_source_t source) |
Disable the specified ACIFC interrupt source. More... | |
void | ac_enable (struct ac_dev_inst *const dev_inst) |
Enable the ACIFC module. More... | |
void | ac_enable_interrupt (struct ac_dev_inst *const dev_inst, ac_interrupt_source_t source) |
Enable the specified ACIFC interrupt source. More... | |
static void | ac_get_config_defaults (struct ac_config *const cfg) |
Initialize an ACIFC configuration structure to default values. More... | |
static uint32_t | ac_get_interrupt_mask (struct ac_dev_inst *const dev_inst) |
Get the ACIFC interrupt mask. More... | |
static uint32_t | ac_get_interrupt_status (struct ac_dev_inst *const dev_inst) |
Get the ACIFC interrupt status. More... | |
static uint32_t | ac_get_status (struct ac_dev_inst *const dev_inst) |
Get the ACIFC status. More... | |
enum status_code | ac_init (struct ac_dev_inst *const dev_inst, Acifc *const ac, struct ac_config *const cfg) |
Initialize the ACIFC module. More... | |
static bool | ac_is_comparison_done (struct ac_dev_inst *const dev_inst) |
Check if the ACIFC comparison is done. More... | |
void | ac_set_callback (struct ac_dev_inst *const dev_inst, ac_interrupt_source_t source, ac_callback_t callback, uint8_t irq_level) |
Set the ACIFC interrupt callback. More... | |
static void | ac_user_trigger_single_comparison (struct ac_dev_inst *const dev_inst) |
Start a single ACIFC comparison. More... | |
static void | ac_win_get_config_defaults (struct ac_win_config *const cfg) |
Initializes an ACIFC window configuration structure to default values. More... | |
void | ac_win_set_config (struct ac_dev_inst *const dev_inst, uint32_t window, struct ac_win_config *cfg) |
Configure the specified ACIFC window. More... | |
typedef void(* ac_callback_t)(void) |
ACIFC interrupt callback type.
typedef enum ac_interrupt_source ac_interrupt_source_t |
ACIFC interrupt configuration type.
enum ac_comparator_mode |
enum ac_interrupt_source |
ACIFC interrupt configuration type.
enum ac_negative_input |
enum ac_win_event_source |
ACIFC window event output configuration.
ACIFC window interrupt settings.
|
inlinestatic |
Initializes an ACIFC channel configuration structure to default values.
The default configuration is as follows:
[out] | cfg | ACIFC channel configuration structure pointer |
References AC_CH_IS_COMP_DONE, AC_COMPARATOR_USER_TRIGGERED, AC_HYSTERESIS_0_MV, AC_NEGTIVE_INPUT_EXTERNAL, ac_ch_config::always_on, Assert, ac_ch_config::comparator_mode, ac_ch_config::event_negative, ac_ch_config::event_positive, ac_ch_config::fast_mode, ac_ch_config::hysteresis_voltage, ac_ch_config::interrupt_setting, and ac_ch_config::negative_input.
Referenced by main(), and run_ac_test().
void ac_ch_set_config | ( | struct ac_dev_inst *const | dev_inst, |
uint32_t | channel, | ||
struct ac_ch_config * | cfg | ||
) |
Configure the specified ACIFC channel.
[in] | dev_inst | Driver structure pointer |
[in] | channel | ACIFC channel number (range 0 to 7 inclusive) |
[in] | cfg | ACIFC channel configuration structure pointer |
References ac_ch_config::always_on, Assert, ac_ch_config::comparator_mode, ac_ch_config::event_negative, ac_ch_config::event_positive, ac_ch_config::fast_mode, ac_dev_inst::hw_dev, ac_ch_config::hysteresis_voltage, ac_ch_config::interrupt_setting, and ac_ch_config::negative_input.
Referenced by main(), and run_ac_test().
|
inlinestatic |
Write to the ACIFC interrupt status.
[in] | dev_inst | Driver structure pointer |
[in] | status | Interrupt status to be clear |
References ac_dev_inst::hw_dev, and status.
Referenced by compare_result_output(), and set_int_flag().
void ac_disable | ( | struct ac_dev_inst *const | dev_inst | ) |
Disable the ACIFC Module.
[in] | dev_inst | Driver structure pointer |
References ac_dev_inst::hw_dev, SLEEPMGR_BACKUP, and sleepmgr_unlock_mode().
void ac_disable_interrupt | ( | struct ac_dev_inst *const | dev_inst, |
ac_interrupt_source_t | source | ||
) |
Disable the specified ACIFC interrupt source.
[in] | dev_inst | Driver structure pointer |
[in] | source | Interrupt source to disable |
References AC_INTERRUPT_CONVERSION_COMPLETED_0, AC_INTERRUPT_CONVERSION_COMPLETED_1, AC_INTERRUPT_CONVERSION_COMPLETED_2, AC_INTERRUPT_CONVERSION_COMPLETED_3, AC_INTERRUPT_CONVERSION_COMPLETED_4, AC_INTERRUPT_CONVERSION_COMPLETED_5, AC_INTERRUPT_CONVERSION_COMPLETED_6, AC_INTERRUPT_CONVERSION_COMPLETED_7, AC_INTERRUPT_STARTUP_TIME_ELAPSED_0, AC_INTERRUPT_STARTUP_TIME_ELAPSED_1, AC_INTERRUPT_STARTUP_TIME_ELAPSED_2, AC_INTERRUPT_STARTUP_TIME_ELAPSED_3, AC_INTERRUPT_STARTUP_TIME_ELAPSED_4, AC_INTERRUPT_STARTUP_TIME_ELAPSED_5, AC_INTERRUPT_STARTUP_TIME_ELAPSED_6, AC_INTERRUPT_STARTUP_TIME_ELAPSED_7, AC_INTERRUPT_WINDOW_0, AC_INTERRUPT_WINDOW_1, AC_INTERRUPT_WINDOW_2, AC_INTERRUPT_WINDOW_3, Assert, and ac_dev_inst::hw_dev.
void ac_enable | ( | struct ac_dev_inst *const | dev_inst | ) |
Enable the ACIFC module.
[in] | dev_inst | Driver structure pointer |
References ac_dev_inst::hw_dev, SLEEPMGR_BACKUP, and sleepmgr_lock_mode().
Referenced by main(), and run_ac_test().
void ac_enable_interrupt | ( | struct ac_dev_inst *const | dev_inst, |
ac_interrupt_source_t | source | ||
) |
Enable the specified ACIFC interrupt source.
[out] | dev_inst | Driver structure pointer |
[in] | source | Interrupt source to enable |
References AC_INTERRUPT_CONVERSION_COMPLETED_0, AC_INTERRUPT_CONVERSION_COMPLETED_1, AC_INTERRUPT_CONVERSION_COMPLETED_2, AC_INTERRUPT_CONVERSION_COMPLETED_3, AC_INTERRUPT_CONVERSION_COMPLETED_4, AC_INTERRUPT_CONVERSION_COMPLETED_5, AC_INTERRUPT_CONVERSION_COMPLETED_6, AC_INTERRUPT_CONVERSION_COMPLETED_7, AC_INTERRUPT_STARTUP_TIME_ELAPSED_0, AC_INTERRUPT_STARTUP_TIME_ELAPSED_1, AC_INTERRUPT_STARTUP_TIME_ELAPSED_2, AC_INTERRUPT_STARTUP_TIME_ELAPSED_3, AC_INTERRUPT_STARTUP_TIME_ELAPSED_4, AC_INTERRUPT_STARTUP_TIME_ELAPSED_5, AC_INTERRUPT_STARTUP_TIME_ELAPSED_6, AC_INTERRUPT_STARTUP_TIME_ELAPSED_7, AC_INTERRUPT_WINDOW_0, AC_INTERRUPT_WINDOW_1, AC_INTERRUPT_WINDOW_2, AC_INTERRUPT_WINDOW_3, Assert, and ac_dev_inst::hw_dev.
Referenced by ac_set_callback().
|
inlinestatic |
Initialize an ACIFC configuration structure to default values.
The default configuration is as follows:
[out] | cfg | ACIFC configuration structure pointer |
References Assert, and ac_config::event_trigger.
Referenced by main(), and run_ac_test().
|
inlinestatic |
Get the ACIFC interrupt mask.
[in] | dev_inst | Driver structure pointer |
References ac_dev_inst::hw_dev.
Referenced by ac_interrupt_handler().
|
inlinestatic |
Get the ACIFC interrupt status.
[in] | dev_inst | Driver structure pointer |
References ac_dev_inst::hw_dev.
Referenced by ac_interrupt_handler().
|
inlinestatic |
Get the ACIFC status.
[in] | dev_inst | Driver structure pointer |
References ac_dev_inst::hw_dev.
Referenced by compare_result_output().
enum status_code ac_init | ( | struct ac_dev_inst *const | dev_inst, |
Acifc *const | ac, | ||
struct ac_config *const | cfg | ||
) |
Initialize the ACIFC module.
[out] | dev_inst | Driver structure pointer |
[in] | ac | Module hardware register base address pointer |
[in] | cfg | Module configuration structure pointer |
STATUS_OK | Module initiated correctly |
STATUS_ERR_DENIED | Module has already been enabled |
STATUS_ERR_BUSY | Module is busy performing a comparison |
References _ac_set_config(), Assert, ac_dev_inst::hw_dev, STATUS_ERR_BUSY, STATUS_ERR_DENIED, STATUS_OK, and sysclk_enable_peripheral_clock().
Referenced by main(), and run_ac_test().
|
inlinestatic |
Check if the ACIFC comparison is done.
[in] | dev_inst | Driver structure pointer |
false | ACIFC comparison has not completed |
true | ACIFC comparison has completed |
References ac_dev_inst::hw_dev.
void ac_set_callback | ( | struct ac_dev_inst *const | dev_inst, |
ac_interrupt_source_t | source, | ||
ac_callback_t | callback, | ||
uint8_t | irq_level | ||
) |
Set the ACIFC interrupt callback.
[in] | dev_inst | Driver structure pointer |
[in] | source | ACIFC interrupt source |
[in] | callback | Interrupt callback function pointer |
[in] | irq_level | Interrupt priority level |
References ac_enable_interrupt(), callback, and irq_register_handler.
Referenced by main(), and run_ac_test().
|
inlinestatic |
Start a single ACIFC comparison.
[in] | dev_inst | Driver structure pointer |
References ac_dev_inst::hw_dev.
Referenced by main(), and run_ac_test().
|
inlinestatic |
Initializes an ACIFC window configuration structure to default values.
The default configuration is as follows:
[out] | cfg | ACIFC window configuration structure pointer |
References AC_WIN_EVENT_MEASURE_DONE, AC_WIN_IS_WINDOW_COMP_DONE, Assert, ac_win_config::enable, ac_win_config::event_enable, ac_win_config::event_source, and ac_win_config::interrupt_setting.
void ac_win_set_config | ( | struct ac_dev_inst *const | dev_inst, |
uint32_t | window, | ||
struct ac_win_config * | cfg | ||
) |
Configure the specified ACIFC window.
[in] | dev_inst | Driver structure pointer |
[in] | window | ACIFC window number (range 0 to 3 inclusive) |
[in] | cfg | ACIFC window configuration structure |
References Assert, ac_win_config::enable, ac_win_config::event_enable, ac_win_config::event_source, ac_dev_inst::hw_dev, and ac_win_config::interrupt_setting.