Audio Bitstream DAC (Digital to Analog Converter) provides functions to convert a sample value to a digital bitstream.
Data Structures | |
struct | abdac_config |
Configuration setting structure. More... | |
struct | abdac_dev_inst |
ABDAC driver software instance structure. More... | |
Macros | |
#define | ABDAC_BUSY_TIMEOUT 10000 |
Typedefs | |
typedef void(* | abdac_callback_t )(void) |
Interrupt callback function type for ABDAC. More... | |
typedef enum abdac_interrupt_source | abdac_interrupt_source_t |
Interrupt sources. More... | |
Enumerations | |
enum | abdac_data_format { ABDAC_DATE_32BIT = 0, ABDAC_DATE_20BIT, ABDAC_DATE_18BIT, ABDAC_DATE_16BIT, ABDAC_DATE_16BIT_COMPACT, ABDAC_DATE_8BIT, ABDAC_DATE_8BIT_COMPACT } |
Data format of the SDR register value. More... | |
enum | abdac_interrupt_source { ABDAC_INTERRUPT_TXRDY = 0, ABDAC_INTERRUPT_TXUR } |
Interrupt sources. More... | |
enum | abdac_sample_rate { ABDAC_SAMPLE_RATE_8000 = 0, ABDAC_SAMPLE_RATE_11025, ABDAC_SAMPLE_RATE_12000, ABDAC_SAMPLE_RATE_16000, ABDAC_SAMPLE_RATE_22050, ABDAC_SAMPLE_RATE_24000, ABDAC_SAMPLE_RATE_32000, ABDAC_SAMPLE_RATE_44100, ABDAC_SAMPLE_RATE_48000 } |
Supported sample rate. More... | |
Functions | |
void | abdac_clear_interrupt_flag (struct abdac_dev_inst *const dev_inst, abdac_interrupt_source_t source) |
Clear the interrupt status. More... | |
status_code_t | abdac_disable (struct abdac_dev_inst *const dev_inst) |
Disable the ABDAC module. More... | |
void | abdac_disable_interrupt (struct abdac_dev_inst *const dev_inst, abdac_interrupt_source_t source) |
Disable the interrupt. More... | |
status_code_t | abdac_enable (struct abdac_dev_inst *const dev_inst) |
Enable the ABDAC module. More... | |
void | abdac_enable_interrupt (struct abdac_dev_inst *const dev_inst, abdac_interrupt_source_t source) |
Enable the interrupt. More... | |
void | abdac_get_config_defaults (struct abdac_config *const cfg) |
Initialize a ABDAC configuration structure to defaults. More... | |
status_code_t | abdac_init (struct abdac_dev_inst *const dev_inst, Abdacb *const abdac, struct abdac_config *const cfg) |
Initialize the ABDAC module. More... | |
static bool | abdac_is_busy (struct abdac_dev_inst *const dev_inst) |
Check the busy status of ABDAC. More... | |
static bool | abdac_is_tx_ready (struct abdac_dev_inst *const dev_inst) |
Check the transmit ready status of ABDAC. More... | |
static bool | abdac_is_tx_underrun (struct abdac_dev_inst *const dev_inst) |
Check the transmit underrun status of ABDAC. More... | |
static uint32_t | abdac_read_interrupt_mask (struct abdac_dev_inst *const dev_inst) |
Return the ABDAC interrupts mask value. More... | |
void | abdac_set_callback (struct abdac_dev_inst *const dev_inst, abdac_interrupt_source_t source, abdac_callback_t callback, uint8_t irq_level) |
Set callback for ABDAC. More... | |
status_code_t | abdac_set_config (struct abdac_dev_inst *const dev_inst) |
Configure the ABDAC module. More... | |
void | abdac_set_volume0 (struct abdac_dev_inst *const dev_inst, bool mute, uint32_t volume) |
Set the volume of channel 0. More... | |
void | abdac_set_volume1 (struct abdac_dev_inst *const dev_inst, bool mute, uint32_t volume) |
Set the volume of channel 1. More... | |
status_code_t | abdac_sw_reset (struct abdac_dev_inst *const dev_inst) |
Software reset the ABDAC module. More... | |
status_code_t | abdac_swap_channels (struct abdac_dev_inst *const dev_inst) |
Swap the ABDAC channel output. More... | |
status_code_t | abdac_write_data0 (struct abdac_dev_inst *const dev_inst, uint32_t data) |
Writes the data to SDR0. More... | |
status_code_t | abdac_write_data1 (struct abdac_dev_inst *const dev_inst, uint32_t data) |
Writes the data to SDR1. More... | |
#define ABDAC_BUSY_TIMEOUT 10000 |
Referenced by abdac_disable(), abdac_enable(), abdac_set_config(), abdac_sw_reset(), abdac_swap_channels(), abdac_write_data0(), and abdac_write_data1().
typedef void(* abdac_callback_t)(void) |
Interrupt callback function type for ABDAC.
The interrupt handler can be configured to do a function callback, the callback function must match the abdac_callback_t type.
typedef enum abdac_interrupt_source abdac_interrupt_source_t |
Interrupt sources.
enum abdac_data_format |
enum abdac_sample_rate |
void abdac_clear_interrupt_flag | ( | struct abdac_dev_inst *const | dev_inst, |
abdac_interrupt_source_t | source | ||
) |
Clear the interrupt status.
dev_inst | Device structure pointer.. |
source | Interrupt status to be cleared |
References ABDAC_INTERRUPT_TXRDY, ABDAC_INTERRUPT_TXUR, and abdac_dev_inst::hw_dev.
Referenced by main().
status_code_t abdac_disable | ( | struct abdac_dev_inst *const | dev_inst | ) |
Disable the ABDAC module.
dev_inst | Device structure pointer.. |
References ABDAC_BUSY_TIMEOUT, abdac_is_busy(), ERR_TIMEOUT, abdac_dev_inst::hw_dev, SLEEPMGR_ACTIVE, sleepmgr_unlock_mode(), STATUS_OK, and sysclk_enable_peripheral_clock().
void abdac_disable_interrupt | ( | struct abdac_dev_inst *const | dev_inst, |
abdac_interrupt_source_t | source | ||
) |
Disable the interrupt.
dev_inst | Device structure pointer.. |
source | Interrupt to be disabled |
References ABDAC_INTERRUPT_TXRDY, ABDAC_INTERRUPT_TXUR, and abdac_dev_inst::hw_dev.
status_code_t abdac_enable | ( | struct abdac_dev_inst *const | dev_inst | ) |
Enable the ABDAC module.
dev_inst | Device structure pointer.. |
References ABDAC_BUSY_TIMEOUT, abdac_is_busy(), ERR_TIMEOUT, abdac_dev_inst::hw_dev, SLEEPMGR_ACTIVE, sleepmgr_lock_mode(), STATUS_OK, and sysclk_enable_peripheral_clock().
Referenced by main().
void abdac_enable_interrupt | ( | struct abdac_dev_inst *const | dev_inst, |
abdac_interrupt_source_t | source | ||
) |
Enable the interrupt.
dev_inst | Device structure pointer.. |
source | Interrupt to be enabled |
References ABDAC_INTERRUPT_TXRDY, ABDAC_INTERRUPT_TXUR, and abdac_dev_inst::hw_dev.
Referenced by abdac_set_callback().
void abdac_get_config_defaults | ( | struct abdac_config *const | cfg | ) |
Initialize a ABDAC configuration structure to defaults.
Initialize a given ABDAC configuration structure to a set of known default values. This function should be called on all new instances of these configuration structures before being modified by the user application.
The default configuration is as follows:
cfg | Configuration structure to initialize to default values. |
References ABDAC_DATE_16BIT, ABDAC_SAMPLE_RATE_8000, Assert, abdac_config::cmoc, abdac_config::data_word_format, abdac_config::mono, and abdac_config::sample_rate_hz.
Referenced by main().
status_code_t abdac_init | ( | struct abdac_dev_inst *const | dev_inst, |
Abdacb *const | abdac, | ||
struct abdac_config *const | cfg | ||
) |
Initialize the ABDAC module.
dev_inst | Device structure pointer. |
abdac | Base address of the ABDAC instance. |
cfg | Pointer to ABDAC configuration. |
References abdac_set_config(), Assert, abdac_dev_inst::cfg, abdac_dev_inst::hw_dev, sysclk_disable_peripheral_clock(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
inlinestatic |
Check the busy status of ABDAC.
dev_inst | Device structure pointer.. |
References abdac_dev_inst::hw_dev.
Referenced by abdac_disable(), abdac_enable(), abdac_set_config(), abdac_sw_reset(), abdac_swap_channels(), abdac_write_data0(), and abdac_write_data1().
|
inlinestatic |
Check the transmit ready status of ABDAC.
dev_inst | Device structure pointer.. |
References abdac_dev_inst::hw_dev.
Referenced by abdac_write_data0(), and abdac_write_data1().
|
inlinestatic |
Check the transmit underrun status of ABDAC.
dev_inst | Device structure pointer.. |
References abdac_dev_inst::hw_dev.
|
inlinestatic |
Return the ABDAC interrupts mask value.
dev_inst | Device structure pointer.. |
References abdac_dev_inst::hw_dev.
void abdac_set_callback | ( | struct abdac_dev_inst *const | dev_inst, |
abdac_interrupt_source_t | source, | ||
abdac_callback_t | callback, | ||
uint8_t | irq_level | ||
) |
Set callback for ABDAC.
dev_inst | Device structure pointer. |
source | Interrupt source. |
callback | callback function pointer. |
irq_level | interrupt level. |
References abdac_callback_pointer, abdac_enable_interrupt(), and irq_register_handler.
status_code_t abdac_set_config | ( | struct abdac_dev_inst *const | dev_inst | ) |
Configure the ABDAC module.
dev_inst | Device structure pointer.. |
References ABDAC_BUSY_TIMEOUT, abdac_is_busy(), ABDAC_SAMPLE_RATE_11025, ABDAC_SAMPLE_RATE_12000, ABDAC_SAMPLE_RATE_16000, ABDAC_SAMPLE_RATE_22050, ABDAC_SAMPLE_RATE_24000, ABDAC_SAMPLE_RATE_32000, ABDAC_SAMPLE_RATE_44100, ABDAC_SAMPLE_RATE_48000, ABDAC_SAMPLE_RATE_8000, BOARD_OSC0_HZ, abdac_dev_inst::cfg, abdac_config::cmoc, abdac_config::data_word_format, ERR_TIMEOUT, genclk_config_defaults(), genclk_config_set_divider(), genclk_config_set_source(), genclk_enable(), genclk_enable_source(), GENCLK_SRC_PLL0, abdac_dev_inst::hw_dev, abdac_config::mono, pll_config_init(), pll_enable(), PLL_SRC_OSC0, pll_wait_for_lock(), abdac_config::sample_rate_hz, and STATUS_OK.
Referenced by abdac_init().
void abdac_set_volume0 | ( | struct abdac_dev_inst *const | dev_inst, |
bool | mute, | ||
uint32_t | volume | ||
) |
Set the volume of channel 0.
dev_inst | Device structure pointer.. |
mute | Flag if set the channel mute |
volume | Value of volume |
References abdac_dev_inst::hw_dev.
Referenced by main().
void abdac_set_volume1 | ( | struct abdac_dev_inst *const | dev_inst, |
bool | mute, | ||
uint32_t | volume | ||
) |
Set the volume of channel 1.
dev_inst | Device structure pointer.. |
mute | Flag if set the channel mute |
volume | Value of volume |
References abdac_dev_inst::hw_dev.
Referenced by main().
status_code_t abdac_sw_reset | ( | struct abdac_dev_inst *const | dev_inst | ) |
Software reset the ABDAC module.
dev_inst | Device structure pointer.. |
References ABDAC_BUSY_TIMEOUT, abdac_is_busy(), ERR_TIMEOUT, abdac_dev_inst::hw_dev, and STATUS_OK.
status_code_t abdac_swap_channels | ( | struct abdac_dev_inst *const | dev_inst | ) |
Swap the ABDAC channel output.
dev_inst | Device structure pointer.. |
References ABDAC_BUSY_TIMEOUT, abdac_is_busy(), ERR_TIMEOUT, abdac_dev_inst::hw_dev, and STATUS_OK.
status_code_t abdac_write_data0 | ( | struct abdac_dev_inst *const | dev_inst, |
uint32_t | data | ||
) |
Writes the data to SDR0.
dev_inst | Device structure pointer.. |
data | Data value to write to SDR0. |
References ABDAC_BUSY_TIMEOUT, abdac_is_busy(), abdac_is_tx_ready(), ERR_TIMEOUT, abdac_dev_inst::hw_dev, and STATUS_OK.
status_code_t abdac_write_data1 | ( | struct abdac_dev_inst *const | dev_inst, |
uint32_t | data | ||
) |
Writes the data to SDR1.
dev_inst | Device structure pointer.. |
data | Data value to write to SDR1. |
References ABDAC_BUSY_TIMEOUT, abdac_is_busy(), abdac_is_tx_ready(), ERR_TIMEOUT, abdac_dev_inst::hw_dev, and STATUS_OK.