Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ABDAC - Audio Bitstream DAC

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

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.

Interrupt sources.

Data format of the SDR register value.

Enumerator
ABDAC_DATE_32BIT 
ABDAC_DATE_20BIT 
ABDAC_DATE_18BIT 
ABDAC_DATE_16BIT 
ABDAC_DATE_16BIT_COMPACT 
ABDAC_DATE_8BIT 
ABDAC_DATE_8BIT_COMPACT 

Interrupt sources.

Enumerator
ABDAC_INTERRUPT_TXRDY 
ABDAC_INTERRUPT_TXUR 

Supported sample rate.

Enumerator
ABDAC_SAMPLE_RATE_8000 
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 

void abdac_clear_interrupt_flag ( struct abdac_dev_inst *const  dev_inst,
abdac_interrupt_source_t  source 
)

Clear the interrupt status.

Parameters
dev_instDevice structure pointer..
sourceInterrupt status to be cleared

References ABDAC_INTERRUPT_TXRDY, ABDAC_INTERRUPT_TXUR, and abdac_dev_inst::hw_dev.

Referenced by run_abdac_init_test().

status_code_t abdac_disable ( struct abdac_dev_inst *const  dev_inst)

Disable the ABDAC module.

Parameters
dev_instDevice structure pointer..
Returns
Status code.

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.

Parameters
dev_instDevice structure pointer..
sourceInterrupt to be disabled

References ABDAC_INTERRUPT_TXRDY, ABDAC_INTERRUPT_TXUR, and abdac_dev_inst::hw_dev.

Referenced by abdac_callback().

status_code_t abdac_enable ( struct abdac_dev_inst *const  dev_inst)

Enable the ABDAC module.

Parameters
dev_instDevice structure pointer..
Returns
Status code.

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

void abdac_enable_interrupt ( struct abdac_dev_inst *const  dev_inst,
abdac_interrupt_source_t  source 
)

Enable the interrupt.

Parameters
dev_instDevice structure pointer..
sourceInterrupt 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:

  • sample rate with 8000hz.
  • 16 bit data format.
  • stereo mode.
  • Common mode adjustment is disabled.
Parameters
cfgConfiguration 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 run_abdac_init_test().

status_code_t abdac_init ( struct abdac_dev_inst *const  dev_inst,
Abdacb *const  abdac,
struct abdac_config *const  cfg 
)

Initialize the ABDAC module.

Parameters
dev_instDevice structure pointer.
abdacBase address of the ABDAC instance.
cfgPointer to ABDAC configuration.
Returns
Status code.

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

static bool abdac_is_busy ( struct abdac_dev_inst *const  dev_inst)
inlinestatic

Check the busy status of ABDAC.

Parameters
dev_instDevice structure pointer..
Returns
true if ABDAC is busy, else it will return false.

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

static bool abdac_is_tx_ready ( struct abdac_dev_inst *const  dev_inst)
inlinestatic

Check the transmit ready status of ABDAC.

Parameters
dev_instDevice structure pointer..
Returns
true if ABDAC is ready to receive a new data in SDR, else it will return false.

References abdac_dev_inst::hw_dev.

Referenced by abdac_write_data0(), and abdac_write_data1().

static bool abdac_is_tx_underrun ( struct abdac_dev_inst *const  dev_inst)
inlinestatic

Check the transmit underrun status of ABDAC.

Parameters
dev_instDevice structure pointer..
Returns
true if at least one underrun has occurred since the last time this bit was cleared, else it will return false.

References abdac_dev_inst::hw_dev.

static uint32_t abdac_read_interrupt_mask ( struct abdac_dev_inst *const  dev_inst)
inlinestatic

Return the ABDAC interrupts mask value.

Parameters
dev_instDevice structure pointer..
Returns
Interrupt mask value

References abdac_dev_inst::hw_dev.

Referenced by abdac_callback().

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.

Parameters
dev_instDevice structure pointer.
sourceInterrupt source.
callbackcallback function pointer.
irq_levelinterrupt level.

References abdac_callback_pointer, abdac_enable_interrupt(), and irq_register_handler.

Referenced by run_abdac_interrupt_test().

void abdac_set_volume0 ( struct abdac_dev_inst *const  dev_inst,
bool  mute,
uint32_t  volume 
)

Set the volume of channel 0.

Parameters
dev_instDevice structure pointer..
muteFlag if set the channel mute
volumeValue of volume
Returns
Status code.

References abdac_dev_inst::hw_dev.

void abdac_set_volume1 ( struct abdac_dev_inst *const  dev_inst,
bool  mute,
uint32_t  volume 
)

Set the volume of channel 1.

Parameters
dev_instDevice structure pointer..
muteFlag if set the channel mute
volumeValue of volume
Returns
Status code.

References abdac_dev_inst::hw_dev.

status_code_t abdac_sw_reset ( struct abdac_dev_inst *const  dev_inst)

Software reset the ABDAC module.

Parameters
dev_instDevice structure pointer..
Returns
Status code.

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.

Parameters
dev_instDevice structure pointer..
Returns
Status code.

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.

Parameters
dev_instDevice structure pointer..
dataData value to write to SDR0.
Returns
Status code.

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.

Parameters
dev_instDevice structure pointer..
dataData 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.