Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DACIFB - DAC Interface B

Driver for the Digital to Analog Converter (DAC) Interface B.

It provides functions for configuring and using the DAC and its channels.

Modules

 

Data Structures

struct  dacifb_channel_opt_t
 Parameters for the configuration of the channel. More...
 
struct  dacifb_opt_t
 Parameters for the DACIFB. More...
 

Macros

#define DACIFB_CHI_MIN_VALUE   500000
 CHI Min Value of 2us. More...
 
#define DACIFB_CHRx_MAX_VALUE   33333
 CHRx Max Value of 35us. More...
 
#define DACIFB_CHRx_MIN_VALUE   40000
 CHRx Min Value of 25us. More...
 

Functions

bool dacifb_check_eoc (volatile avr32_dacifb_t *dacifb, uint8_t channel)
 Check channel conversion status. More...
 
bool dacifb_configure (volatile avr32_dacifb_t *dacifb, dacifb_opt_t *p_dacifb_opt, uint32_t pb_hz)
 Configure DACIFB. More...
 
bool dacifb_configure_channel (volatile avr32_dacifb_t *dacifb, uint8_t channel, dacifb_channel_opt_t *p_dacifb_channel_opt, uint32_t prescaler_clock_hz)
 Configure DACIFB specific channel. More...
 
void dacifb_get_calibration_data (volatile avr32_dacifb_t *dacifb, dacifb_opt_t *p_dacifb_opt, uint8_t instance)
 Get DACIFB Calibration Data. More...
 
void dacifb_reload_timer (volatile avr32_dacifb_t *dacifb, uint8_t channel, uint8_t timer_us, uint32_t prescaler_clock_hz)
 Reload Timer for Automatic Trigger on DAC. More...
 
void dacifb_set_value (volatile avr32_dacifb_t *dacifb, uint8_t channel, bool dual, uint32_t value)
 Set channel value. More...
 
void dacifb_start_channel (volatile avr32_dacifb_t *dacifb, uint8_t channel, uint32_t cpu_hz)
 Start analog to digital conversion. More...
 

Channel Selection used by the DAC

#define DACIFB_CHANNEL_SELECTION_NONE   0x0
 
#define DACIFB_CHANNEL_SELECTION_A   0x1
 
#define DACIFB_CHANNEL_SELECTION_B   0x2
 
#define DACIFB_CHANNEL_SELECTION_AB   0x3
 

Reference used by the DAC

#define DACIFB_REFERENCE_EXT   0x0
 
#define DACIFB_REFERENCE_VDDANA   0x1
 

Trigger Mode used by the DAC

#define DACIFB_TRIGGER_MODE_MANUAL   0x0
 
#define DACIFB_TRIGGER_MODE_TIMER   0x1
 
#define DACIFB_TRIGGER_MODE_EVENT   0x2
 

#define DACIFB_CHANNEL_SELECTION_A   0x1
#define DACIFB_CHANNEL_SELECTION_AB   0x3
#define DACIFB_CHANNEL_SELECTION_B   0x2
#define DACIFB_CHANNEL_SELECTION_NONE   0x0
#define DACIFB_CHI_MIN_VALUE   500000

CHI Min Value of 2us.

Referenced by dacifb_configure().

#define DACIFB_CHRx_MAX_VALUE   33333

CHRx Max Value of 35us.

Referenced by dacifb_configure_channel().

#define DACIFB_CHRx_MIN_VALUE   40000

CHRx Min Value of 25us.

Referenced by dacifb_configure_channel().

#define DACIFB_REFERENCE_EXT   0x0
#define DACIFB_REFERENCE_VDDANA   0x1
#define DACIFB_TRIGGER_MODE_EVENT   0x2
#define DACIFB_TRIGGER_MODE_MANUAL   0x0
#define DACIFB_TRIGGER_MODE_TIMER   0x1

bool dacifb_check_eoc ( volatile avr32_dacifb_t *  dacifb,
uint8_t  channel 
)

Check channel conversion status.

Parameters
*dacifbBase address of the DACIFB
channelchannel to check (0 to 1)
Returns
Boolean true if conversion not running, false if conversion running.

References Assert, and NULL.

bool dacifb_configure ( volatile avr32_dacifb_t *  dacifb,
dacifb_opt_t p_dacifb_opt,
uint32_t  pb_hz 
)

Configure DACIFB.

Mandatory to call. If not called, DACIFB channels will have side effects.

Parameters
*dacifbBase address of the DACIFB
*p_dacifb_optStructure for the DACIFB core configuration
pb_hzPeripheral Bus frequency
Returns
Boolean true if the module was configured, false otherwise

References Assert, dacifb_opt_t::channel_selection, clz, DACIFB_CHI_MIN_VALUE, dacifb_opt_t::dual, dacifb_opt_t::gain_calibration_value, dacifb_opt_t::low_power, NULL, dacifb_opt_t::offset_calibration_value, dacifb_opt_t::prescaler_clock_hz, and dacifb_opt_t::reference.

Referenced by dac_task_init(), and main().

bool dacifb_configure_channel ( volatile avr32_dacifb_t *  dacifb,
uint8_t  channel,
dacifb_channel_opt_t p_dacifb_channel_opt,
uint32_t  prescaler_clock_hz 
)

Configure DACIFB specific channel.

Sets channel Adjustment, Refresh_time and Trigger Mode settings.

Parameters
*dacifbBase address of the ADCIFA
channelDACIFB_CHANNEL_SELECTION_NONE / DACIFB_CHANNEL_SELECTION_A / DACIFB_CHANNEL_SELECTION_B / DACIFB_CHANNEL_SELECTION_AB
p_dacifb_channel_optStructure for the sequencer configuration
prescaler_clock_hzPrescaler Clock in Hertz (should be > 500000Hz)
Returns
Boolean true if the channel was configured, false otherwise

References Assert, dacifb_channel_opt_t::auto_refresh_mode, clz, DACIFB_CHANNEL_SELECTION_A, DACIFB_CHANNEL_SELECTION_AB, DACIFB_CHANNEL_SELECTION_B, DACIFB_CHRx_MAX_VALUE, DACIFB_CHRx_MIN_VALUE, DACIFB_TRIGGER_MODE_EVENT, DACIFB_TRIGGER_MODE_MANUAL, DACIFB_TRIGGER_MODE_TIMER, dacifb_channel_opt_t::data_round_enable, dacifb_channel_opt_t::data_shift, dacifb_channel_opt_t::left_adjustment, NULL, and dacifb_channel_opt_t::trigger_mode.

Referenced by dac_task_init(), and main().

void dacifb_get_calibration_data ( volatile avr32_dacifb_t *  dacifb,
dacifb_opt_t p_dacifb_opt,
uint8_t  instance 
)

Get DACIFB Calibration Data.

Mandatory to call if factory calibration data are wanted to be used. If not called, Calibration Data should be set by the application.

Parameters
*dacifbBase address of the DACIFB
*p_dacifb_optStructure for the DACIFB core configuration
instanceDACIFB core instance 0 for DACIFB0 or 1 for DACIFB1

References dacifb_opt_t::gain_calibration_value, and dacifb_opt_t::offset_calibration_value.

Referenced by dac_task_init(), and main().

void dacifb_reload_timer ( volatile avr32_dacifb_t *  dacifb,
uint8_t  channel,
uint8_t  timer_us,
uint32_t  prescaler_clock_hz 
)

Reload Timer for Automatic Trigger on DAC.

Parameters
*dacifbBase address of the DACIFB
channelDACIFB_CHANNEL_SELECTION_NONE / DACIFB_CHANNEL_SELECTION_A / DACIFB_CHANNEL_SELECTION_B / DACIFB_CHANNEL_SELECTION_AB
timer_usTimer Value in Microseconds
prescaler_clock_hzPrescaler Clock in Hertz (should be > 500000Hz)

References Assert, DACIFB_CHANNEL_SELECTION_A, DACIFB_CHANNEL_SELECTION_AB, DACIFB_CHANNEL_SELECTION_B, and NULL.

Referenced by main().

void dacifb_set_value ( volatile avr32_dacifb_t *  dacifb,
uint8_t  channel,
bool  dual,
uint32_t  value 
)

Set channel value.

Parameters
*dacifbBase address of the DACIFB
channelchannel to handle (0 to 1)
dualDual Mode Selection
valueValue to be converted

References Assert, DACIFB_CHANNEL_SELECTION_A, DACIFB_CHANNEL_SELECTION_AB, DACIFB_CHANNEL_SELECTION_B, and NULL.

void dacifb_start_channel ( volatile avr32_dacifb_t *  dacifb,
uint8_t  channel,
uint32_t  cpu_hz 
)

Start analog to digital conversion.

Parameters
*dacifbBase address of the DACIFB
channelDACIFB_CHANNEL_SELECTION_NONE / DACIFB_CHANNEL_SELECTION_A / DACIFB_CHANNEL_SELECTION_B / DACIFB_CHANNEL_SELECTION_AB
cpu_hzCPU Clock frequency

References Assert, DACIFB_CHANNEL_SELECTION_A, DACIFB_CHANNEL_SELECTION_AB, DACIFB_CHANNEL_SELECTION_B, delay_us, and NULL.

Referenced by dac_task_init(), and main().