Classes | Typedefs | Enumerations | Functions
drivers/afec/afec.h File Reference

Analog-Front-End Controller driver for SAM. More...

#include "compiler.h"
#include "status_codes.h"
Include dependency graph for drivers/afec/afec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  afec_ch_config
 
struct  afec_config
 Analog-Front-End Controller configuration structure. More...
 
struct  afec_temp_sensor_config
 

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 }
 
enum  afec_gainvalue { AFEC_GAINVALUE_0 = 0, AFEC_GAINVALUE_1 = 1, AFEC_GAINVALUE_2 = 2, AFEC_GAINVALUE_3 = 3 }
 
enum  afec_power_mode { AFEC_POWER_MODE_0 = 0, AFEC_POWER_MODE_1, AFEC_POWER_MODE_2 }
 
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
}
 
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
}
 
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 }
 
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
}
 

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)
 
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...
 

Detailed Description

Analog-Front-End Controller driver for SAM.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

Definition in file drivers/afec/afec.h.

Typedef Documentation

◆ afec_callback_t

typedef void(* afec_callback_t) (void)

Definition at line 344 of file drivers/afec/afec.h.

Enumeration Type Documentation

◆ afec_cmp_mode

Definitions for Comparison Mode

Enumerator
AFEC_CMP_MODE_0 
AFEC_CMP_MODE_1 
AFEC_CMP_MODE_2 
AFEC_CMP_MODE_3 

Definition at line 200 of file drivers/afec/afec.h.

◆ afec_gainvalue

Definitions for AFEC gain value

Enumerator
AFEC_GAINVALUE_0 
AFEC_GAINVALUE_1 
AFEC_GAINVALUE_2 
AFEC_GAINVALUE_3 

Definition at line 162 of file drivers/afec/afec.h.

◆ afec_power_mode

Definitions for AFEC power mode

Enumerator
AFEC_POWER_MODE_0 
AFEC_POWER_MODE_1 
AFEC_POWER_MODE_2 

Definition at line 64 of file drivers/afec/afec.h.

◆ afec_resolution

Definitions for AFEC resolution

Enumerator
AFEC_10_BITS 
AFEC_12_BITS 
AFEC_13_BITS 
AFEC_14_BITS 
AFEC_15_BITS 
AFEC_16_BITS 

Definition at line 54 of file drivers/afec/afec.h.

◆ afec_startup_time

Definitions for AFEC Start Up Time

Enumerator
AFEC_STARTUP_TIME_0 
AFEC_STARTUP_TIME_1 
AFEC_STARTUP_TIME_2 
AFEC_STARTUP_TIME_3 
AFEC_STARTUP_TIME_4 
AFEC_STARTUP_TIME_5 
AFEC_STARTUP_TIME_6 
AFEC_STARTUP_TIME_7 
AFEC_STARTUP_TIME_8 
AFEC_STARTUP_TIME_9 
AFEC_STARTUP_TIME_10 
AFEC_STARTUP_TIME_11 
AFEC_STARTUP_TIME_12 
AFEC_STARTUP_TIME_13 
AFEC_STARTUP_TIME_14 
AFEC_STARTUP_TIME_15 

Definition at line 170 of file drivers/afec/afec.h.

◆ afec_temp_cmp_mode

Definitions for Temperature Comparison Mode

Enumerator
AFEC_TEMP_CMP_MODE_0 
AFEC_TEMP_CMP_MODE_1 
AFEC_TEMP_CMP_MODE_2 
AFEC_TEMP_CMP_MODE_3 

Definition at line 208 of file drivers/afec/afec.h.

◆ afec_trigger

Definitions for AFEC trigger

Enumerator
AFEC_TRIG_SW 
AFEC_TRIG_EXT 
AFEC_TRIG_TIO_CH_0 
AFEC_TRIG_TIO_CH_1 
AFEC_TRIG_TIO_CH_2 
AFEC_TRIG_PWM_EVENT_LINE_0 
AFEC_TRIG_PWM_EVENT_LINE_1 
AFEC_TRIG_FREERUN 

Definition at line 74 of file drivers/afec/afec.h.

Function Documentation

◆ afec_ch_sanity_check()

static void afec_ch_sanity_check ( Afec *const  afec,
const enum afec_channel_num  channel 
)
inlinestatic

Definition at line 380 of file drivers/afec/afec.h.

◆ afec_channel_disable()

static void afec_channel_disable ( Afec *const  afec,
const enum afec_channel_num  afec_ch 
)
inlinestatic

Disable the specified AFEC channel.

Parameters
afecBase address of the AFEC.
afec_chAFEC channel number.

Definition at line 558 of file drivers/afec/afec.h.

◆ afec_channel_enable()

static void afec_channel_enable ( Afec *const  afec,
const enum afec_channel_num  afec_ch 
)
inlinestatic

Enable the specified AFEC channel.

Parameters
afecBase address of the AFEC.
afec_chAFEC channel number.

Definition at line 541 of file drivers/afec/afec.h.

◆ afec_channel_get_status()

static uint32_t afec_channel_get_status ( Afec *const  afec,
const enum afec_channel_num  afec_ch 
)
inlinestatic

Get the AFEC channel status.

Parameters
afecBase address of the AFEC.
afec_chAFEC channel number.
Return values
1if channel is enabled.
0if channel is disabled.

Definition at line 578 of file drivers/afec/afec.h.

◆ afec_channel_get_value()

static uint32_t afec_channel_get_value ( Afec *const  afec,
enum afec_channel_num  afec_ch 
)
inlinestatic

Read the Converted Data of the selected channel.

Parameters
afecBase address of the AFEC.
afec_chAFEC channel number.
Returns
AFEC converted value of the selected channel.

Definition at line 594 of file drivers/afec/afec.h.

◆ afec_channel_set_analog_offset()

static void afec_channel_set_analog_offset ( Afec *const  afec,
enum afec_channel_num  afec_ch,
uint16_t  aoffset 
)
inlinestatic

Set analog offset to be used for channel CSEL.

Parameters
afecBase address of the AFEC.
afec_chAFEC channel number.
aoffsetAnalog offset value.

Definition at line 610 of file drivers/afec/afec.h.

◆ afec_get_comparison_mode()

static enum afec_cmp_mode afec_get_comparison_mode ( Afec *const  afec)
inlinestatic

Get comparison mode.

Parameters
afecBase address of the AFEC.
Return values
Comparemode value.

Definition at line 452 of file drivers/afec/afec.h.

◆ afec_get_interrupt_mask()

static uint32_t afec_get_interrupt_mask ( Afec *const  afec)
inlinestatic

Get AFEC interrupt mask.

Parameters
afecBase address of the AFEC.
Returns
The interrupt mask value.

Definition at line 668 of file drivers/afec/afec.h.

◆ afec_get_interrupt_status()

static uint32_t afec_get_interrupt_status ( Afec *const  afec)
inlinestatic

Get AFEC interrupt status.

Parameters
afecBase address of the AFEC.
Returns
The interrupt status value.

Definition at line 656 of file drivers/afec/afec.h.

◆ afec_get_latest_chan_num()

static uint32_t afec_get_latest_chan_num ( Afec *const  afec)
inlinestatic

Get the Last Converted Channel Number.

Parameters
afecBase address of the AFEC.
Returns
AFEC Last Converted Channel Number.

Definition at line 638 of file drivers/afec/afec.h.

◆ afec_get_latest_value()

static uint32_t afec_get_latest_value ( Afec *const  afec)
inlinestatic

Get the Last Data Converted.

Parameters
afecBase address of the AFEC.
Returns
AFEC latest converted value.

Definition at line 626 of file drivers/afec/afec.h.

◆ afec_get_overrun_status()

static uint32_t afec_get_overrun_status ( Afec *const  afec)
inlinestatic

Get AFEC overrun error status.

Parameters
afecBase address of the AFEC.
Returns
AFEC overrun error status.

Definition at line 514 of file drivers/afec/afec.h.

◆ afec_get_writeprotect_status()

static uint32_t afec_get_writeprotect_status ( Afec *const  afec)
inlinestatic

Indicate write protect status.

Parameters
afecBase address of the AFEC.
Returns
0 if no write protect violation occurred, or 16-bit write protect violation source.

Definition at line 495 of file drivers/afec/afec.h.

◆ afec_set_comparison_window()

static void afec_set_comparison_window ( Afec *const  afec,
const uint16_t  us_low_threshold,
const uint16_t  us_high_threshold 
)
inlinestatic

Configure AFEC compare window.

Parameters
afecBase address of the AFEC.
us_low_thresholdLow threshold of compare window.
us_high_thresholdHigh threshold of compare window.

Definition at line 464 of file drivers/afec/afec.h.

◆ afec_set_resolution()

static void afec_set_resolution ( Afec *const  afec,
const enum afec_resolution  res 
)
inlinestatic

Configure conversion resolution.

Parameters
afecBase address of the AFEC.
resConversion resolution.

Definition at line 428 of file drivers/afec/afec.h.

◆ afec_set_trigger()

static void afec_set_trigger ( Afec *const  afec,
const enum afec_trigger  trigger 
)
inlinestatic

Configure conversion trigger and free run mode.

Parameters
afecBase address of the AFEC.
triggerConversion trigger.

Definition at line 404 of file drivers/afec/afec.h.

◆ afec_set_writeprotect()

static void afec_set_writeprotect ( Afec *const  afec,
const bool  is_enable 
)
inlinestatic

Enable or disable write protection of AFEC registers.

Parameters
afecBase address of the AFEC.
is_enable1 to enable, 0 to disable.

Definition at line 477 of file drivers/afec/afec.h.

◆ afec_start_software_conversion()

static void afec_start_software_conversion ( Afec *const  afec)
inlinestatic

Start analog-to-digital conversion.

Note
If one of the hardware event is selected as AFEC trigger, this function can NOT start analog to digital conversion.
Parameters
afecBase address of the AFEC.

Definition at line 527 of file drivers/afec/afec.h.



inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:58