This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the conversion of digital values to analog voltage.
The following driver API modes are covered by this manual:
The following peripheral is used by this module:
The following devices can use this module:
The outline of this documentation is as follows:
There are no prerequisites for this module.
The Digital-to-Analog converter converts a digital value to an analog voltage. The DAC Controller can operate as two independent DACs or as a single DAC in differential mode. Each DAC has a 12-bit resolution and it is capable of converting up to 1M samples per second (Msps).
A common use of DAC is to generate audio signals by connecting the DAC output to a speaker, or to generate a reference voltage; either for an external circuit or an internal peripheral such as the Analog Comparator.
After being set up, the DAC will convert new digital values written to the conversion data register (DATA0 or DATA1) to an analog value either on the DAC output (VOUT0 or VOUT1) pin of the device, or internally for use as an input to the AC, ADC, and other analog modules.
Writing the DATA register will start a new conversion. It is also possible to trigger the conversion from the event system.
A simplified block diagram of the DAC can be seen in the figure below.
The conversion range is between GND and the selected voltage reference. Available voltage references are:
The output voltage from a DAC channel is given as:
\[ V_{OUTx} = \frac{DATAx}{0x3FF} \times VREF \]
The differential output voltage is given as:
\[ V_{OUT} = \frac{DATA0}{0x1FF} \times VREF = (V_{OUT0}-V_{OUT1}) \]
The conversion digital value written to the DATA register will be converted to an analog value. Writing the DATA register will start a new conversion. It is also possible to write the conversion value to the DATABUF register, the writing of the DATA register can then be triggered from the event system, which will load the value from DATABUF to DATA.
The analog output value can be output to the VOUTx converted by DACx, and each data conversion can be started independently.
In differential mode, DAC0 and DAC1 are operating synchronously to convert value. VOUT0 is the positive output and VOUT1 the negative output.
VOUT0 signal is internally connected so that it can be used as input for AC, ADC, or OPAMP modules when DAC0 is enabled.
Events generation and event actions are configurable in the DAC. The DAC has one event line input and one event output: Start Conversion and Data Buffer Empty.
If the Start Conversion input event is enabled in the module configuration, an incoming event will load data from the data buffer to the data register and start a new conversion. This method synchronizes conversions with external events (such as those from a timer module) and ensures regular and fixed conversion intervals.
If the Data Buffer Empty output event is enabled in the module configuration, events will be generated when the DAC data buffer register becomes empty and new data can be loaded to the buffer.
The 12-bit input value to the DAC is contained in a 16-bit register. This can be configured to be either left or right adjusted. In the figure below both options are shown, and the position of the most (MSB) and the least (LSB) significant bits are indicated. The unused bits should always be written to zero.
The clock for the DAC interface (CLK_DAC) is generated by the Power Manager. This clock is turned on by default, and can be enabled and disabled in the Power Manager.
Additionally, an asynchronous clock source (GCLK_DAC) is required. These clocks are normally disabled by default. The selected clock source must be enabled in the Power Manager before it can be used by the DAC. The DAC core operates asynchronously from the user interface and peripheral bus. As a consequence, the DAC needs two clock cycles of both CLK_DAC and GCLK_DAC to synchronize the values written to some of the control and data registers. The oscillator source for the GCLK_DAC clock is selected in the Supply Control Interface (SUPC).
The DAC can do conversions in Active or Idle modes, and will continue the conversions in standby sleep mode if the RUNSTDBY bit in the DACCTRLx register is set. Otherwise, the DACx will stop conversions.
If DACx conversion is stopped in standby sleep mode, DACx is disabled to reduce power consumption. When exiting standby sleep mode, DACx is enabled therefore startup time is required before starting a new conversion.
DAC conversion time is approximately 2.85µs. The user must ensure that new data is not written to the DAC before the last conversion is complete. Conversions should be triggered by a periodic event from a Timer/Counter or another peripheral.
For extra information, see Extra Information for DAC Driver. This includes:
For a list of examples related to this driver, see Examples for DAC Driver.
Data Structures | |
struct | dac_chan_config |
DAC channel configuration structure. More... | |
struct | dac_config |
DAC configuration structure. More... | |
struct | dac_events |
DAC event enable/disable structure. More... | |
struct | dac_module |
DAC software device instance structure. More... | |
Macros | |
#define | DAC_TIMEOUT 0xFFFF |
Define DAC features set according to different device families. More... | |
Typedefs | |
typedef void(* | dac_callback_t )(uint8_t channel) |
Type definition for a DAC module callback function. More... | |
Enumerations | |
enum | dac_callback { DAC_CALLBACK_DATA_EMPTY, DAC_CALLBACK_DATA_UNDERRUN, DAC_CALLBACK_TRANSFER_COMPLETE } |
Enum for the possible callback types for the DAC module. More... | |
enum | dac_channel { DAC_CHANNEL_0, DAC_CHANNEL_1 } |
DAC channel selection enum. More... | |
enum | dac_current_ctrl { DAC_CURRENT_100K = DAC_DACCTRL_CCTRL(0), DAC_CURRENT_1M = DAC_DACCTRL_CCTRL(1), DAC_CURRENT_12M = DAC_DACCTRL_CCTRL(2), DAC_CURRENT_RESERVED = DAC_DACCTRL_CCTRL(3) } |
DAC current control enum. More... | |
enum | dac_reference { DAC_REFERENCE_VREFPU = DAC_CTRLB_REFSEL(0), DAC_REFERENCE_VDDANA = DAC_CTRLB_REFSEL(1), DAC_REFERENCE_VREFPB = DAC_CTRLB_REFSEL(2), DAC_REFERENCE_INTREF = DAC_CTRLB_REFSEL(3) } |
DAC reference voltage enum. More... | |
Configuration and Initialization | |
bool | dac_is_syncing (struct dac_module *const dev_inst) |
Determines if the hardware module(s) are currently synchronizing to the bus. More... | |
void | dac_get_config_defaults (struct dac_config *const config) |
Initializes a DAC configuration structure to defaults. More... | |
enum status_code | dac_init (struct dac_module *const dev_inst, Dac *const module, struct dac_config *const config) |
Initialize the DAC device struct. More... | |
void | dac_reset (struct dac_module *const dev_inst) |
Resets the DAC module. More... | |
void | dac_enable (struct dac_module *const dev_inst) |
Enable the DAC module. More... | |
void | dac_disable (struct dac_module *const dev_inst) |
Disable the DAC module. More... | |
void | dac_enable_events (struct dac_module *const module_inst, struct dac_events *const events) |
Enables a DAC event input or output. More... | |
void | dac_disable_events (struct dac_module *const module_inst, struct dac_events *const events) |
Disables a DAC event input or output. More... | |
Configuration and Initialization (Channel) | |
void | dac_chan_get_config_defaults (struct dac_chan_config *const config) |
void | dac_chan_set_config (struct dac_module *const dev_inst, const enum dac_channel channel, struct dac_chan_config *const config) |
Writes a DAC channel configuration to the hardware module. More... | |
void | dac_chan_enable (struct dac_module *const dev_inst, enum dac_channel channel) |
Enable a DAC channel. More... | |
void | dac_chan_disable (struct dac_module *const dev_inst, enum dac_channel channel) |
Disable a DAC channel. More... | |
Channel Data Management | |
enum status_code | dac_chan_write (struct dac_module *const dev_inst, enum dac_channel channel, const uint16_t data) |
Write to the DAC. More... | |
enum status_code | dac_chan_write_buffer_wait (struct dac_module *const module_inst, enum dac_channel channel, uint16_t *buffer, uint32_t length) |
Write to the DAC. More... | |
Status Management | |
uint32_t | dac_get_status (struct dac_module *const module_inst) |
Retrieves the current module status. More... | |
void | dac_clear_status (struct dac_module *const module_inst, uint32_t status_flags) |
Clears a module status flag. More... | |
Callback Configuration and Initialization | |
enum status_code | dac_chan_write_buffer_job (struct dac_module *const module_inst, const enum dac_channel channel, uint16_t *buffer, uint32_t buffer_size) |
Convert a specific number digital data to analog through DAC. More... | |
enum status_code | dac_chan_write_job (struct dac_module *const module_inst, const enum dac_channel channel, uint16_t data) |
Convert one digital data job. More... | |
enum status_code | dac_register_callback (struct dac_module *const module, const enum dac_channel channel, const dac_callback_t callback, const enum dac_callback type) |
Registers an asynchronous callback function with the driver. More... | |
enum status_code | dac_unregister_callback (struct dac_module *const module, const enum dac_channel channel, const enum dac_callback type) |
Unregisters an asynchronous callback function with the driver. More... | |
Callback Enabling and Disabling (Channel) | |
enum status_code | dac_chan_enable_callback (struct dac_module *const module, const enum dac_channel channel, const enum dac_callback type) |
Enables asynchronous callback generation for a given channel and type. More... | |
enum status_code | dac_chan_disable_callback (struct dac_module *const module, const enum dac_channel channel, const enum dac_callback type) |
Disables asynchronous callback generation for a given channel and type. More... | |
enum status_code | dac_chan_get_job_status (struct dac_module *module_inst, const enum dac_channel channel) |
Gets the status of a job. More... | |
void | dac_chan_abort_job (struct dac_module *module_inst, const enum dac_channel channel) |
Aborts an ongoing job. More... | |
DAC Status Flags | |
DAC status flags, returned by dac_get_status() and cleared by dac_clear_status(). | |
#define | DAC_STATUS_CHANNEL_0_EMPTY (1UL << 0) |
Data Buffer Empty Channel 0 - Set when data is transferred from DATABUF to DATA by a start conversion event and DATABUF is ready for new data. More... | |
#define | DAC_STATUS_CHANNEL_1_EMPTY (1UL << 1) |
Data Buffer Empty Channel 1 - Set when data is transferred from DATABUF to DATA by a start conversion event and DATABUF is ready for new data. More... | |
#define | DAC_STATUS_CHANNEL_0_UNDERRUN (1UL << 2) |
Underrun Channel 0 - Set when a start conversion event occurs when DATABUF is empty. More... | |
#define | DAC_STATUS_CHANNEL_1_UNDERRUN (1UL << 3) |
Underrun Channel 1 - Set when a start conversion event occurs when DATABUF is empty. More... | |
Status Management (Channel) | |
bool | dac_chan_is_end_of_conversion (struct dac_module *const module_inst, enum dac_channel channel) |
Retrieves the status of DAC channel end of conversion. More... | |
#define DAC_STATUS_CHANNEL_0_EMPTY (1UL << 0) |
Data Buffer Empty Channel 0 - Set when data is transferred from DATABUF to DATA by a start conversion event and DATABUF is ready for new data.
Referenced by dac_clear_status(), and dac_get_status().
#define DAC_STATUS_CHANNEL_0_UNDERRUN (1UL << 2) |
Underrun Channel 0 - Set when a start conversion event occurs when DATABUF is empty.
Referenced by dac_clear_status(), and dac_get_status().
#define DAC_STATUS_CHANNEL_1_EMPTY (1UL << 1) |
Data Buffer Empty Channel 1 - Set when data is transferred from DATABUF to DATA by a start conversion event and DATABUF is ready for new data.
Referenced by dac_clear_status(), and dac_get_status().
#define DAC_STATUS_CHANNEL_1_UNDERRUN (1UL << 3) |
Underrun Channel 1 - Set when a start conversion event occurs when DATABUF is empty.
Referenced by dac_clear_status(), and dac_get_status().
#define DAC_TIMEOUT 0xFFFF |
Define DAC features set according to different device families.
Referenced by dac_chan_write_buffer_wait().
typedef void(* dac_callback_t)(uint8_t channel) |
Type definition for a DAC module callback function.
enum dac_callback |
Enum for the possible callback types for the DAC module.
enum dac_channel |
enum dac_current_ctrl |
enum dac_reference |
DAC reference voltage enum.
Enum for the possible reference voltages for the DAC.
void dac_chan_abort_job | ( | struct dac_module * | module_inst, |
const enum dac_channel | channel | ||
) |
Aborts an ongoing job.
Aborts an ongoing job.
[in] | module_inst | Pointer to the DAC software instance struct |
[in] | channel | Logical channel to enable callback function |
References Assert, DAC_CHANNEL_0, DAC_CHANNEL_1, and STATUS_ABORTED.
void dac_chan_disable | ( | struct dac_module *const | module_inst, |
enum dac_channel | channel | ||
) |
Disable a DAC channel.
Disables the selected DAC channel.
[in] | module_inst | Pointer to the DAC software instance struct |
[in] | channel | Channel to disable |
References Assert.
enum status_code dac_chan_disable_callback | ( | struct dac_module *const | module_inst, |
const enum dac_channel | channel, | ||
const enum dac_callback | type | ||
) |
Disables asynchronous callback generation for a given channel and type.
Disables asynchronous callbacks for a given logical DAC channel and type.
[in,out] | dac_module | Pointer to the DAC software instance struct |
[in] | channel | Logical channel to disable callback function |
[in] | type | Type of callback function callbacks to disable |
STATUS_OK | The callback was disabled successfully |
STATUS_ERR_UNSUPPORTED_DEV | If a callback that requires event driven mode was specified with a DAC instance configured in non-event mode |
References Assert, STATUS_ERR_UNSUPPORTED_DEV, STATUS_OK, and UNUSED.
void dac_chan_enable | ( | struct dac_module *const | module_inst, |
enum dac_channel | channel | ||
) |
Enable a DAC channel.
Enables the selected DAC channel.
[in] | module_inst | Pointer to the DAC software instance struct |
[in] | channel | Channel to enable |
References Assert.
Referenced by test_dac_init().
enum status_code dac_chan_enable_callback | ( | struct dac_module *const | module_inst, |
const enum dac_channel | channel, | ||
const enum dac_callback | type | ||
) |
Enables asynchronous callback generation for a given channel and type.
Enables asynchronous callbacks for a given logical DAC channel and type. This must be called before a DAC channel will generate callback events.
[in,out] | dac_module | Pointer to the DAC software instance struct |
[in] | channel | Logical channel to enable callback function |
[in] | type | Type of callback function callbacks to enable |
STATUS_OK | The callback was enabled successfully |
STATUS_ERR_UNSUPPORTED_DEV | If a callback that requires event driven mode was specified with a DAC instance configured in non-event mode |
References Assert, STATUS_ERR_UNSUPPORTED_DEV, and STATUS_OK.
void dac_chan_get_config_defaults | ( | struct dac_chan_config *const | config | ) |
enum status_code dac_chan_get_job_status | ( | struct dac_module * | module_inst, |
const enum dac_channel | channel | ||
) |
Gets the status of a job.
Gets the status of an ongoing or the last job.
[in] | module_inst | Pointer to the DAC software instance struct |
[in] | channel | Logical channel to enable callback function |
References Assert.
bool dac_chan_is_end_of_conversion | ( | struct dac_module *const | module_inst, |
enum dac_channel | channel | ||
) |
Retrieves the status of DAC channel end of conversion.
Checks if the conversion is completed or not and returns boolean flag of status.
[in] | module_inst | Pointer to the DAC software instance struct |
[in] | channel | Channel to disable |
true | Conversion is complete, VOUT is stable |
false | No conversion completed since last load of DATA |
References Assert.
void dac_chan_set_config | ( | struct dac_module *const | module_inst, |
const enum dac_channel | channel, | ||
struct dac_chan_config *const | config | ||
) |
Writes a DAC channel configuration to the hardware module.
Writes out a given channel configuration to the hardware module.
[in] | module_inst | Pointer to the DAC software instance struct |
[in] | channel | Channel to configure |
[in] | config | Pointer to the configuration struct |
References Assert, dac_chan_config::current, DAC_CHANNEL_0, DAC_CHANNEL_1, system_pinmux_config::direction, dac_chan_config::dither_mode, system_pinmux_config::input_pull, dac_chan_config::left_adjust, system_pinmux_config::mux_position, dac_chan_config::refresh_period, dac_chan_config::run_in_standby, system_pinmux_get_config_defaults(), SYSTEM_PINMUX_PIN_DIR_INPUT, SYSTEM_PINMUX_PIN_PULL_NONE, and system_pinmux_pin_set_config().
Referenced by test_dac_init().
enum status_code dac_chan_write | ( | struct dac_module *const | module_inst, |
enum dac_channel | channel, | ||
const uint16_t | data | ||
) |
Write to the DAC.
This function writes to the DATA or DATABUF register. If the conversion is not event-triggered, the data will be written to the DATA register and the conversion will start. If the conversion is event-triggered, the data will be written to DATABUF and transferred to the DATA register and converted when a Start Conversion Event is issued. Conversion data must be right or left adjusted according to configuration settings.
[in] | module_inst | Pointer to the DAC software device struct |
[in] | channel | DAC channel to write to |
[in] | data | Conversion data |
STATUS_OK | If the data was written |
References Assert, dac_is_syncing(), and STATUS_OK.
Referenced by dac_chan_write_buffer_wait(), run_adc_average_mode_test(), run_adc_callback_mode_test(), run_adc_polled_mode_test(), run_adc_window_mode_test(), and setup_adc_window_mode_test().
enum status_code dac_chan_write_buffer_job | ( | struct dac_module *const | module_inst, |
const enum dac_channel | channel, | ||
uint16_t * | buffer, | ||
uint32_t | length | ||
) |
Convert a specific number digital data to analog through DAC.
This function will perform a conversion of specific number of digital data. The conversion should be event-triggered, the data will be written to DATABUF and transferred to the DATA register and converted when a Start Conversion Event is issued. Conversion data must be right or left adjusted according to configuration settings.
[in] | module_inst | Pointer to the DAC software device struct |
[in] | channel | DAC channel to write to |
[in] | buffer | Pointer to the digital data write buffer to be converted |
[in] | length | Size of the write buffer |
STATUS_OK | If the data was written |
STATUS_ERR_UNSUPPORTED_DEV | If a callback that requires event driven mode was specified with a DAC instance configured in non-event mode |
STATUS_BUSY | The DAC is busy and can not accept a new job |
References Assert, DAC_CHANNEL_0, DAC_CHANNEL_1, dac_is_syncing(), STATUS_BUSY, STATUS_ERR_UNSUPPORTED_DEV, STATUS_OK, system_interrupt_enable(), and SYSTEM_INTERRUPT_MODULE_DAC.
Referenced by dac_chan_write_job().
enum status_code dac_chan_write_buffer_wait | ( | struct dac_module *const | module_inst, |
enum dac_channel | channel, | ||
uint16_t * | buffer, | ||
uint32_t | length | ||
) |
Write to the DAC.
This function converts a specific number of digital data. The conversion should be event-triggered, the data will be written to DATABUF and transferred to the DATA register and converted when a Start Conversion Event is issued. Conversion data must be right or left adjusted according to configuration settings.
[in] | module_inst | Pointer to the DAC software device struct |
[in] | channel | DAC channel to write to |
[in] | buffer | Pointer to the digital data write buffer to be converted |
[in] | length | Length of the write buffer |
STATUS_OK | If the data was written or no data conversion required |
STATUS_ERR_UNSUPPORTED_DEV | The DAC is not configured as using event trigger |
STATUS_BUSY | The DAC is busy and can not do the conversion |
References Assert, dac_chan_write(), DAC_CHANNEL_0, DAC_CHANNEL_1, dac_is_syncing(), DAC_TIMEOUT, STATUS_BUSY, STATUS_ERR_TIMEOUT, STATUS_ERR_UNSUPPORTED_DEV, and STATUS_OK.
enum status_code dac_chan_write_job | ( | struct dac_module *const | module_inst, |
const enum dac_channel | channel, | ||
uint16_t | data | ||
) |
Convert one digital data job.
This function will perform a conversion of specfic number of digital data. The conversion is event-triggered, the data will be written to DATABUF and transferred to the DATA register and converted when a Start Conversion Event is issued. Conversion data must be right or left adjusted according to configuration settings.
[in] | module_inst | Pointer to the DAC software device struct |
[in] | channel | DAC channel to write to |
[in] | data | Digital data to be converted |
STATUS_OK | If the data was written |
STATUS_ERR_UNSUPPORTED_DEV | If a callback that requires event driven mode was specified with a DAC instance configured in non-event mode |
STATUS_BUSY | The DAC is busy and can not accept a new job |
References Assert, dac_chan_write_buffer_job(), STATUS_BUSY, STATUS_ERR_UNSUPPORTED_DEV, and STATUS_OK.
void dac_clear_status | ( | struct dac_module *const | module_inst, |
uint32_t | status_flags | ||
) |
Clears a module status flag.
Clears the given status flag of the module.
[in] | module_inst | Pointer to the DAC software device struct |
[in] | status_flags | Bit mask of status flags to clear |
References Assert, DAC_STATUS_CHANNEL_0_EMPTY, DAC_STATUS_CHANNEL_0_UNDERRUN, DAC_STATUS_CHANNEL_1_EMPTY, and DAC_STATUS_CHANNEL_1_UNDERRUN.
void dac_disable | ( | struct dac_module *const | module_inst | ) |
Disable the DAC module.
Disables the DAC interface and the output buffer.
[in] | module_inst | Pointer to the DAC software instance struct |
References Assert, and dac_is_syncing().
void dac_disable_events | ( | struct dac_module *const | module_inst, |
struct dac_events *const | events | ||
) |
Disables a DAC event input or output.
Disables one or more input or output events to or from the DAC module. See Struct dac_events for a list of events this module supports.
[in] | module_inst | Software instance for the DAC peripheral |
[in] | events | Struct containing flags of events to disable |
References Assert, DAC_CHANNEL_0, DAC_CHANNEL_1, dac_events::generate_event_on_chan0_buffer_empty, dac_events::on_event_chan0_start_conversion, and dac_events::on_event_chan1_start_conversion.
void dac_enable | ( | struct dac_module *const | module_inst | ) |
Enable the DAC module.
Enables the DAC interface and the selected output. If any internal reference is selected it will be enabled.
[in] | module_inst | Pointer to the DAC software instance struct |
References Assert, DAC_CHANNEL_0, DAC_CHANNEL_1, dac_is_syncing(), DAC_REFERENCE_INTREF, system_voltage_reference_enable(), and SYSTEM_VOLTAGE_REFERENCE_OUTPUT.
Referenced by test_dac_init().
void dac_enable_events | ( | struct dac_module *const | module_inst, |
struct dac_events *const | events | ||
) |
Enables a DAC event input or output.
Enables one or more input or output events to or from the DAC module. See Struct dac_events for a list of events this module supports.
[in] | module_inst | Software instance for the DAC peripheral |
[in] | events | Struct containing flags of events to enable |
References Assert, DAC_CHANNEL_0, DAC_CHANNEL_1, dac_events::generate_event_on_chan0_buffer_empty, dac_events::generate_event_on_chan0_falling_edge, dac_events::generate_event_on_chan1_buffer_empty, dac_events::generate_event_on_chan1_falling_edge, dac_events::on_event_chan0_start_conversion, and dac_events::on_event_chan1_start_conversion.
void dac_get_config_defaults | ( | struct dac_config *const | config | ) |
Initializes a DAC configuration structure to defaults.
Initializes a given DAC configuration structure to a set of known default values. This function should be called on any new instance of the configuration structures before being modified by the user application.
The default configuration is as follows:
[out] | config | Configuration structure to initialize to default values |
References Assert, dac_config::clock_source, DAC_REFERENCE_INTREF, dac_config::differential_mode, GCLK_GENERATOR_0, and dac_config::reference.
Referenced by test_dac_init().
uint32_t dac_get_status | ( | struct dac_module *const | module_inst | ) |
Retrieves the current module status.
Checks the status of the module and returns it as a bitmask of status flags.
[in] | module_inst | Pointer to the DAC software device struct |
DAC_STATUS_CHANNEL_0_EMPTY | Data has been transferred from DATABUF to DATA by a start conversion event and DATABUF is ready for new data |
DAC_STATUS_CHANNEL_0_UNDERRUN | A start conversion event has occurred when DATABUF is empty |
References Assert, DAC_STATUS_CHANNEL_0_EMPTY, DAC_STATUS_CHANNEL_0_UNDERRUN, DAC_STATUS_CHANNEL_1_EMPTY, and DAC_STATUS_CHANNEL_1_UNDERRUN.
enum status_code dac_init | ( | struct dac_module *const | module_inst, |
Dac *const | module, | ||
struct dac_config *const | config | ||
) |
Initialize the DAC device struct.
Use this function to initialize the Digital to Analog Converter. Resets the underlying hardware module and configures it.
[out] | module_inst | Pointer to the DAC software instance struct |
[in] | module | Pointer to the DAC module instance |
[in] | config | Pointer to the config struct, created by the user application |
STATUS_OK | Module initiated correctly |
STATUS_ERR_DENIED | If module is enabled |
STATUS_BUSY | If module is busy resetting |
References _dac_instances, _dac_set_config(), Assert, dac_config::clock_source, dac_config::reference, system_gclk_chan_config::source_generator, STATUS_BUSY, STATUS_ERR_DENIED, STATUS_OK, system_apb_clock_set_mask(), SYSTEM_CLOCK_APB_APBC, system_gclk_chan_enable(), system_gclk_chan_get_config_defaults(), and system_gclk_chan_set_config().
Referenced by test_dac_init().
bool dac_is_syncing | ( | struct dac_module *const | dev_inst | ) |
Determines if the hardware module(s) are currently synchronizing to the bus.
Checks to see if the underlying hardware peripheral module(s) are currently synchronizing across multiple clock domains to the hardware bus. This function can be used to delay further operations on a module until such time that it is ready, to prevent blocking delays for synchronization in the user application.
[in] | dev_inst | Pointer to the DAC software instance struct |
true | If the module synchronization is ongoing |
false | If the module has completed synchronization |
References Assert.
Referenced by dac_chan_write(), dac_chan_write_buffer_job(), dac_chan_write_buffer_wait(), dac_disable(), dac_enable(), and dac_reset().
enum status_code dac_register_callback | ( | struct dac_module *const | module_inst, |
const enum dac_channel | channel, | ||
const dac_callback_t | callback, | ||
const enum dac_callback | type | ||
) |
Registers an asynchronous callback function with the driver.
Registers an asynchronous callback with the DAC driver, fired when a callback condition occurs.
[in,out] | module_inst | Pointer to the DAC software instance struct |
[in] | callback | Pointer to the callback function to register |
[in] | channel | Logical channel to register callback function |
[in] | type | Type of callback function to register |
STATUS_OK | The callback was registered successfully |
STATUS_ERR_INVALID_ARG | If an invalid callback type was supplied |
STATUS_ERR_UNSUPPORTED_DEV | If a callback that requires event driven mode was specified with a DAC instance configured in non-event mode |
References Assert, STATUS_ERR_INVALID_ARG, STATUS_ERR_UNSUPPORTED_DEV, and STATUS_OK.
void dac_reset | ( | struct dac_module *const | module_inst | ) |
Resets the DAC module.
This function will reset the DAC module to its power on default values and disable it.
[in] | module_inst | Pointer to the DAC software instance struct |
References Assert, and dac_is_syncing().
enum status_code dac_unregister_callback | ( | struct dac_module *const | module_inst, |
const enum dac_channel | channel, | ||
const enum dac_callback | type | ||
) |
Unregisters an asynchronous callback function with the driver.
Unregisters an asynchronous callback with the DAC driver, removing it from the internal callback registration table.
[in,out] | module_inst | Pointer to the DAC software instance struct |
[in] | channel | Logical channel to unregister callback function |
[in] | type | Type of callback function to unregister |
STATUS_OK | The callback was unregistered successfully |
STATUS_ERR_INVALID_ARG | If an invalid callback type was supplied |
STATUS_ERR_UNSUPPORTED_DEV | If a callback that requires event driven mode was specified with a DAC instance configured in non-event mode |
References Assert, STATUS_ERR_INVALID_ARG, STATUS_ERR_UNSUPPORTED_DEV, and STATUS_OK.