See Quickstart guide for SAM AFEC driver.
Driver for the Analog-Front-End Controller. This driver provides access to the main features of the AFEC controller.
Macros | |
#define | AFEC_INTERRUPT_GAP2 (1UL) |
#define | AFEC_SEQ1_CHANNEL_NUM (8UL) |
#define | AFEC_TEMP_INT_SOURCE_NUM (15UL) |
#define | NUM_OF_AFEC (1UL) |
Functions | |
void | AFEC0_Handler (void) |
Interrupt handler for AFEC0. More... | |
void | AFEC1_Handler (void) |
Interrupt handler for AFEC1. More... | |
void | afec_ch_get_config_defaults (struct afec_ch_config *const cfg) |
Get the AFEC channel default configurations. 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... | |
void | afec_configure_sequence (Afec *const afec, const enum afec_channel_num ch_list[], 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 uint32_t | afec_find_inst_num (Afec *const afec) |
Get AFEC instance number. More... | |
static uint32_t | afec_find_pid (Afec *const afec) |
Get AFEC Peripheral ID. More... | |
void | afec_get_config_defaults (struct afec_config *const cfg) |
Get the AFEC default configurations. More... | |
enum status_code | afec_init (Afec *const afec, struct afec_config *config) |
Initialize the AFEC Module. More... | |
static void | afec_interrupt (uint8_t inst_num, enum afec_interrupt_source source) |
Common AFEC interrupt handler. More... | |
static void | afec_process_callback (Afec *const afec) |
Call the callback function if the corresponding interrupt is asserted. 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_config (Afec *const afec, struct afec_config *config) |
Configure the AFEC Module. More... | |
void | afec_set_power_mode (Afec *const afec, const enum afec_power_mode mode) |
Configure AFEC power mode. 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... | |
Variables | |
afec_callback_t | afec_callback_pointer [NUM_OF_AFEC][_AFEC_NUM_OF_INTERRUPT_SOURCE] |
#define AFEC_INTERRUPT_GAP2 (1UL) |
Referenced by afec_disable_interrupt(), afec_enable_interrupt(), and afec_process_callback().
#define AFEC_SEQ1_CHANNEL_NUM (8UL) |
Referenced by afec_configure_sequence().
#define AFEC_TEMP_INT_SOURCE_NUM (15UL) |
Referenced by afec_disable_interrupt(), afec_enable_interrupt(), and afec_process_callback().
#define NUM_OF_AFEC (1UL) |
void AFEC0_Handler | ( | void | ) |
Interrupt handler for AFEC0.
References afec_process_callback().
void AFEC1_Handler | ( | void | ) |
Interrupt handler for AFEC1.
References afec_process_callback().
void afec_ch_get_config_defaults | ( | struct afec_ch_config *const | cfg | ) |
Get the AFEC channel default configurations.
Use to initialize the configuration structure to known default values.
The default configuration is as follows:
cfg | Pointer to channel configuration structure to be initiated. |
References AFEC_GAINVALUE_1, Assert, afec_ch_config::diff, and afec_ch_config::gain.
Referenced by main().
void afec_ch_set_config | ( | Afec *const | afec, |
const enum afec_channel_num | channel, | ||
struct afec_ch_config * | config | ||
) |
Configure the AFEC channel.
afec | Base address of the AFEC |
channel | The channel number |
config | Configuration for the AFEC channel |
References afec_ch_sanity_check(), afec_ch_config::diff, and afec_ch_config::gain.
Referenced by main().
void afec_configure_sequence | ( | Afec *const | afec, |
const enum afec_channel_num | ch_list[], | ||
uint8_t | uc_num | ||
) |
Configure conversion sequence.
afec | Base address of the AFEC. |
ch_list | Channel sequence list. |
uc_num | Number of channels in the list. |
References AFEC_SEQ1_CHANNEL_NUM.
void afec_disable | ( | Afec *const | afec | ) |
Disable AFEC Module.
afec | Base address of the AFEC |
References afec_find_pid(), Assert, pmc_disable_periph_clk(), SLEEPMGR_SLEEP_WFI, and sleepmgr_unlock_mode().
void afec_disable_interrupt | ( | Afec *const | afec, |
enum afec_interrupt_source | interrupt_source | ||
) |
Disable AFEC interrupts.
afec | Base address of the AFEC. |
interrupt_source | Interrupts to be disabled. |
References AFEC_INTERRUPT_GAP2, and AFEC_TEMP_INT_SOURCE_NUM.
void afec_enable | ( | Afec *const | afec | ) |
Enable AFEC Module.
afec | Base address of the AFEC |
References afec_find_pid(), Assert, pmc_enable_periph_clk(), sleepmgr_lock_mode(), and SLEEPMGR_SLEEP_WFI.
Referenced by main().
void afec_enable_interrupt | ( | Afec *const | afec, |
enum afec_interrupt_source | interrupt_source | ||
) |
Enable AFEC interrupts.
afec | Base address of the AFEC. |
interrupt_source | Interrupts to be enabled. |
References AFEC_INTERRUPT_GAP2, and AFEC_TEMP_INT_SOURCE_NUM.
Referenced by afec_set_callback().
|
static |
Get AFEC instance number.
afec | Base address of the AFEC |
Referenced by afec_process_callback(), and afec_set_callback().
|
static |
Get AFEC Peripheral ID.
afec | Base address of the AFEC |
Referenced by afec_disable(), and afec_enable().
void afec_get_config_defaults | ( | struct afec_config *const | cfg | ) |
Get the AFEC default configurations.
Use to initialize the configuration structure to known default values. This function should be called at the start of any AFEC initiation.
The default configuration is as follows:
cfg | Pointer to configuration structure to be initiated. |
References AFEC_12_BITS, afec_config::afec_clock, AFEC_STARTUP_TIME_4, afec_config::anach, Assert, afec_config::ibctl, afec_config::mck, afec_config::resolution, afec_config::startup_time, afec_config::stm, sysclk_get_cpu_hz(), afec_config::tag, afec_config::tracktim, afec_config::transfer, and afec_config::useq.
Referenced by main().
enum status_code afec_init | ( | Afec *const | afec, |
struct afec_config * | config | ||
) |
Initialize the AFEC Module.
afec | Base address of the AFEC |
config | Configuration for the AFEC |
STATUS_OK | Initialization is finished. |
STATUS_ERR_BUSY | Initialization failed. |
References afec_callback_pointer, afec_get_interrupt_status(), afec_set_config(), Assert, STATUS_ERR_BUSY, and STATUS_OK.
Referenced by main().
|
static |
Common AFEC interrupt handler.
The optional callback used by the interrupt handler is set by the afec_set_callback() function.
inst_num | AFEC instance number to handle interrupt for |
source | Interrupt source number |
References afec_callback_pointer.
Referenced by afec_process_callback().
|
static |
Call the callback function if the corresponding interrupt is asserted.
afec | Base address of the AFEC. |
References afec_find_inst_num(), afec_get_interrupt_mask(), afec_get_interrupt_status(), afec_interrupt(), AFEC_INTERRUPT_GAP2, and AFEC_TEMP_INT_SOURCE_NUM.
Referenced by AFEC0_Handler(), and AFEC1_Handler().
void afec_set_callback | ( | Afec *const | afec, |
enum afec_interrupt_source | source, | ||
afec_callback_t | callback, | ||
uint8_t | irq_level | ||
) |
Set callback for AFEC.
afec | Base address of the AFEC |
source | Interrupt source |
callback | Callback function pointer |
irq_level | Interrupt level |
References afec_callback_pointer, afec_enable_interrupt(), afec_find_inst_num(), Assert, and irq_register_handler.
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.
afec | Base address of the AFEC. |
mode | Comparison mode. |
channel | Comparison Selected Channel. |
cmp_filter | Compare Event Filtering. |
References afec_ch_sanity_check().
|
static |
Configure the AFEC Module.
afec | Base address of the AFEC |
config | Configuration for the AFEC |
References afec_config::afec_clock, afec_config::anach, afec_config::ibctl, afec_config::mck, afec_config::resolution, SAME70, SAMS70, SAMV70, SAMV71, afec_config::startup_time, afec_config::stm, afec_config::tag, afec_config::tracktim, afec_config::transfer, and afec_config::useq.
Referenced by afec_init().
void afec_set_power_mode | ( | Afec *const | afec, |
const enum afec_power_mode | mode | ||
) |
Configure AFEC power mode.
afec | Base address of the AFEC. |
mode | AFEC power mode value. |
References AFEC_POWER_MODE_0, AFEC_POWER_MODE_1, and AFEC_POWER_MODE_2.
void afec_temp_sensor_get_config_defaults | ( | struct afec_temp_sensor_config *const | cfg | ) |
Get the AFEC Temperature Sensor default configurations.
Use to initialize the configuration structure to known default values.
The default configuration is as follows:
cfg | Pointer to temperature sensor configuration structure to be initiated. |
References AFEC_TEMP_CMP_MODE_2, Assert, afec_temp_sensor_config::high_threshold, afec_temp_sensor_config::low_threshold, afec_temp_sensor_config::mode, and afec_temp_sensor_config::rctc.
void afec_temp_sensor_set_config | ( | Afec *const | afec, |
struct afec_temp_sensor_config * | config | ||
) |
Configure the AFEC temperature sensor.
afec | Base address of the AFEC |
config | Configuration for the AFEC temperature sensor |
References Assert, afec_temp_sensor_config::high_threshold, afec_temp_sensor_config::low_threshold, afec_temp_sensor_config::mode, and afec_temp_sensor_config::rctc.
afec_callback_t afec_callback_pointer[NUM_OF_AFEC][_AFEC_NUM_OF_INTERRUPT_SOURCE] |
Referenced by afec_init(), afec_interrupt(), and afec_set_callback().