Analog-Front-End Controller driver for SAM.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | afec_ch_config |
AFEC channel configuration structure. More... | |
struct | afec_config |
Analog-Front-End Controller configuration structure. More... | |
struct | afec_temp_sensor_config |
AFEC Temperature Sensor configuration structure. More... | |
Typedefs | |
typedef void(* | afec_callback_t )(void) |
Enumerations | |
enum | afec_cmp_mode { AFEC_CMP_MODE_0 = AFEC_EMR_CMPMODE_LOW, AFEC_CMP_MODE_1 = AFEC_EMR_CMPMODE_HIGH, AFEC_CMP_MODE_2 = AFEC_EMR_CMPMODE_IN, AFEC_CMP_MODE_3 = AFEC_EMR_CMPMODE_OUT } |
Definitions for Comparison Mode. More... | |
enum | afec_gainvalue { AFEC_GAINVALUE_0 = 0, AFEC_GAINVALUE_1 = 1, AFEC_GAINVALUE_2 = 2, AFEC_GAINVALUE_3 = 3 } |
Definitions for AFEC gain value. More... | |
enum | afec_power_mode { AFEC_POWER_MODE_0 = 0, AFEC_POWER_MODE_1, AFEC_POWER_MODE_2 } |
Definitions for AFEC power mode. More... | |
enum | afec_resolution { AFEC_10_BITS = AFEC_EMR_RES_LOW_RES, AFEC_12_BITS = AFEC_EMR_RES_NO_AVERAGE, AFEC_13_BITS = AFEC_EMR_RES_OSR4, AFEC_14_BITS = AFEC_EMR_RES_OSR16, AFEC_15_BITS = AFEC_EMR_RES_OSR64, AFEC_16_BITS = AFEC_EMR_RES_OSR256 } |
Definitions for AFEC resolution. More... | |
enum | afec_startup_time { AFEC_STARTUP_TIME_0 = AFEC_MR_STARTUP_SUT0, AFEC_STARTUP_TIME_1 = AFEC_MR_STARTUP_SUT8, AFEC_STARTUP_TIME_2 = AFEC_MR_STARTUP_SUT16, AFEC_STARTUP_TIME_3 = AFEC_MR_STARTUP_SUT24, AFEC_STARTUP_TIME_4 = AFEC_MR_STARTUP_SUT64, AFEC_STARTUP_TIME_5 = AFEC_MR_STARTUP_SUT80, AFEC_STARTUP_TIME_6 = AFEC_MR_STARTUP_SUT96, AFEC_STARTUP_TIME_7 = AFEC_MR_STARTUP_SUT112, AFEC_STARTUP_TIME_8 = AFEC_MR_STARTUP_SUT512, AFEC_STARTUP_TIME_9 = AFEC_MR_STARTUP_SUT576, AFEC_STARTUP_TIME_10 = AFEC_MR_STARTUP_SUT640, AFEC_STARTUP_TIME_11 = AFEC_MR_STARTUP_SUT704, AFEC_STARTUP_TIME_12 = AFEC_MR_STARTUP_SUT768, AFEC_STARTUP_TIME_13 = AFEC_MR_STARTUP_SUT832, AFEC_STARTUP_TIME_14 = AFEC_MR_STARTUP_SUT896, AFEC_STARTUP_TIME_15 = AFEC_MR_STARTUP_SUT960 } |
Definitions for AFEC Start Up Time. More... | |
enum | afec_temp_cmp_mode { AFEC_TEMP_CMP_MODE_0 = AFEC_TEMPMR_TEMPCMPMOD_LOW, AFEC_TEMP_CMP_MODE_1 = AFEC_TEMPMR_TEMPCMPMOD_HIGH, AFEC_TEMP_CMP_MODE_2 = AFEC_TEMPMR_TEMPCMPMOD_IN, AFEC_TEMP_CMP_MODE_3 = AFEC_TEMPMR_TEMPCMPMOD_OUT } |
Definitions for Temperature Comparison Mode. More... | |
enum | afec_trigger { AFEC_TRIG_SW = AFEC_MR_TRGEN_DIS, AFEC_TRIG_EXT = AFEC_MR_TRGSEL_AFEC_TRIG0 | AFEC_MR_TRGEN, AFEC_TRIG_TIO_CH_0 = AFEC_MR_TRGSEL_AFEC_TRIG1 | AFEC_MR_TRGEN, AFEC_TRIG_TIO_CH_1 = AFEC_MR_TRGSEL_AFEC_TRIG2 | AFEC_MR_TRGEN, AFEC_TRIG_TIO_CH_2 = AFEC_MR_TRGSEL_AFEC_TRIG3 | AFEC_MR_TRGEN, AFEC_TRIG_PWM_EVENT_LINE_0 = AFEC_MR_TRGSEL_AFEC_TRIG4 | AFEC_MR_TRGEN, AFEC_TRIG_PWM_EVENT_LINE_1 = AFEC_MR_TRGSEL_AFEC_TRIG5 | AFEC_MR_TRGEN, AFEC_TRIG_FREERUN = 0xFF } |
Definitions for AFEC trigger. More... | |
Functions | |
void | afec_ch_get_config_defaults (struct afec_ch_config *const cfg) |
Get the AFEC channel default configurations. More... | |
static void | afec_ch_sanity_check (Afec *const afec, const enum afec_channel_num channel) |
AFEC channel sanity check. More... | |
void | afec_ch_set_config (Afec *const afec, const enum afec_channel_num channel, struct afec_ch_config *config) |
Configure the AFEC channel. More... | |
static void | afec_channel_disable (Afec *const afec, const enum afec_channel_num afec_ch) |
Disable the specified AFEC channel. More... | |
static void | afec_channel_enable (Afec *const afec, const enum afec_channel_num afec_ch) |
Enable the specified AFEC channel. More... | |
static uint32_t | afec_channel_get_status (Afec *const afec, const enum afec_channel_num afec_ch) |
Get the AFEC channel status. More... | |
static uint32_t | afec_channel_get_value (Afec *const afec, enum afec_channel_num afec_ch) |
Read the Converted Data of the selected channel. More... | |
static void | afec_channel_set_analog_offset (Afec *const afec, enum afec_channel_num afec_ch, uint16_t aoffset) |
Set analog offset to be used for channel CSEL. More... | |
void | afec_configure_sequence (Afec *const afec, const enum afec_channel_num ch_list[], const uint8_t uc_num) |
Configure conversion sequence. More... | |
void | afec_disable (Afec *const afec) |
Disable AFEC Module. More... | |
void | afec_disable_interrupt (Afec *const afec, enum afec_interrupt_source interrupt_source) |
Disable AFEC interrupts. More... | |
void | afec_enable (Afec *const afec) |
Enable AFEC Module. More... | |
void | afec_enable_interrupt (Afec *const afec, enum afec_interrupt_source interrupt_source) |
Enable AFEC interrupts. More... | |
static enum afec_cmp_mode | afec_get_comparison_mode (Afec *const afec) |
Get comparison mode. More... | |
void | afec_get_config_defaults (struct afec_config *const cfg) |
Get the AFEC default configurations. More... | |
static uint32_t | afec_get_interrupt_mask (Afec *const afec) |
Get AFEC interrupt mask. More... | |
static uint32_t | afec_get_interrupt_status (Afec *const afec) |
Get AFEC interrupt status. More... | |
static uint32_t | afec_get_latest_chan_num (Afec *const afec) |
Get the Last Converted Channel Number. More... | |
static uint32_t | afec_get_latest_value (Afec *const afec) |
Get the Last Data Converted. More... | |
static uint32_t | afec_get_overrun_status (Afec *const afec) |
Get AFEC overrun error status. More... | |
static uint32_t | afec_get_writeprotect_status (Afec *const afec) |
Indicate write protect status. More... | |
enum status_code | afec_init (Afec *const afec, struct afec_config *const config) |
Initialize the AFEC Module. More... | |
void | afec_set_callback (Afec *const afec, enum afec_interrupt_source source, afec_callback_t callback, uint8_t irq_level) |
Set callback for AFEC. More... | |
void | afec_set_comparison_mode (Afec *const afec, const enum afec_cmp_mode mode, const enum afec_channel_num channel, uint8_t cmp_filter) |
Configure comparison mode. More... | |
static void | afec_set_comparison_window (Afec *const afec, const uint16_t us_low_threshold, const uint16_t us_high_threshold) |
Configure AFEC compare window. More... | |
void | afec_set_power_mode (Afec *const afec, const enum afec_power_mode mode) |
Configure AFEC power mode. More... | |
static void | afec_set_resolution (Afec *const afec, const enum afec_resolution res) |
Configure conversion resolution. More... | |
static void | afec_set_trigger (Afec *const afec, const enum afec_trigger trigger) |
Configure conversion trigger and free run mode. More... | |
static void | afec_set_writeprotect (Afec *const afec, const bool is_enable) |
Enable or disable write protection of AFEC registers. More... | |
static void | afec_start_software_conversion (Afec *const afec) |
Start analog-to-digital conversion. More... | |
void | afec_temp_sensor_get_config_defaults (struct afec_temp_sensor_config *const cfg) |
Get the AFEC Temperature Sensor default configurations. More... | |
void | afec_temp_sensor_set_config (Afec *const afec, struct afec_temp_sensor_config *config) |
Configure the AFEC temperature sensor. More... | |
typedef void(* afec_callback_t)(void) |
enum afec_cmp_mode |
enum afec_gainvalue |
enum afec_power_mode |
enum afec_resolution |
enum afec_startup_time |
Definitions for AFEC Start Up Time.
enum afec_temp_cmp_mode |
enum afec_trigger |
|
inlinestatic |
AFEC channel sanity check.
afec | Base address of the AFEC. |
channel | AFEC channel number. |
References Assert, and UNUSED.
Referenced by afec_ch_set_config(), afec_channel_disable(), afec_channel_enable(), afec_channel_get_status(), afec_channel_get_value(), afec_channel_set_analog_offset(), and afec_set_comparison_mode().
|
inlinestatic |
Disable the specified AFEC channel.
afec | Base address of the AFEC. |
afec_ch | AFEC channel number. |
References afec_ch_sanity_check().
|
inlinestatic |
Enable the specified AFEC channel.
afec | Base address of the AFEC. |
afec_ch | AFEC channel number. |
References afec_ch_sanity_check().
Referenced by main().
|
inlinestatic |
Get the AFEC channel status.
afec | Base address of the AFEC. |
afec_ch | AFEC channel number. |
1 | if channel is enabled. |
0 | if channel is disabled. |
References afec_ch_sanity_check().
|
inlinestatic |
Read the Converted Data of the selected channel.
afec | Base address of the AFEC. |
afec_ch | AFEC channel number. |
References afec_ch_sanity_check().
Referenced by afec_print_comp_result(), afec_temp_sensor_end_conversion(), and main().
|
inlinestatic |
Set analog offset to be used for channel CSEL.
afec | Base address of the AFEC. |
afec_ch | AFEC channel number. |
aoffset | Analog offset value. |
References afec_ch_sanity_check().
Referenced by main().
|
inlinestatic |
Get comparison mode.
afec | Base address of the AFEC. |
Compare | mode value. |
|
inlinestatic |
Get AFEC interrupt mask.
afec | Base address of the AFEC. |
Referenced by afec_process_callback().
|
inlinestatic |
Get AFEC interrupt status.
afec | Base address of the AFEC. |
Referenced by afec_init(), afec_process_callback(), and main().
|
inlinestatic |
Get the Last Converted Channel Number.
afec | Base address of the AFEC. |
|
inlinestatic |
Get the Last Data Converted.
afec | Base address of the AFEC. |
|
inlinestatic |
Get AFEC overrun error status.
afec | Base address of the AFEC. |
|
inlinestatic |
Indicate write protect status.
afec | Base address of the AFEC. |
|
inlinestatic |
Configure AFEC compare window.
afec | Base address of the AFEC. |
us_low_threshold | Low threshold of compare window. |
us_high_threshold | High threshold of compare window. |
Referenced by main(), and run_afec_comp_test().
|
inlinestatic |
Configure conversion resolution.
afec | Base address of the AFEC. |
res | Conversion resolution. |
|
inlinestatic |
Configure conversion trigger and free run mode.
afec | Base address of the AFEC. |
trigger | Conversion trigger. |
References AFEC_TRIG_FREERUN.
Referenced by configure_tc_trigger(), main(), and run_afec_comp_test().
|
inlinestatic |
Enable or disable write protection of AFEC registers.
afec | Base address of the AFEC. |
is_enable | 1 to enable, 0 to disable. |
|
inlinestatic |
Start analog-to-digital conversion.
afec | Base address of the AFEC. |
Referenced by main(), and run_afec_comp_test().