Disclaimer: The code and project was tested with the following versions of the sw:
- Xtensa Xplorer 9.0.20
- Xtensa OCD 15.03
- Core Configuration: hifi3z_lark_RI_2022_10
- Xtensa Build Tools: RI 2022_10
- Lark SDK 3.3.1
The code below configures an easy ADC --> DAC audio path using the ADAU1860SDK. Look at the attachment for a complete code.
int32_t err;
adi_lark_device_t device =
{
.cp_mode = API_LARK_CP_NATIVE
};
/* disable cache */
xthal_set_region_attribute((void *)0x40000000, 0x20000000, XCHAL_CA_BYPASS, XTHAL_CAFLAG_EXACT);
/* set REG_DAC_AUTO_MUTE_CTRL_ADDR to disable DAC auto-mute for easy debug */
err = adi_lark_hal_reg_write(&device, 0x4000C054, 0xFF);
LARK_ERROR_RETURN(err);
/* power up device and audio block */
err = adi_lark_pmu_set_chip_power_mode(&device, API_LARK_PWR_MODE_ACTIVE);
LARK_ERROR_RETURN(err);
err = adi_lark_pmu_enable_master_block(&device, 1);
LARK_ERROR_RETURN(err);
/* set bus clock */
err = adi_lark_clk_set_mclk_freq(&device, API_LARK_MCLK_FREQ_24P576, true);
LARK_ERROR_RETURN(err);
/* power on all modules */
err = adi_lark_pmu_enable_master_block(&device, true);
LARK_ERROR_RETURN(err);
/* ADC0: 96KHz, differential input */
err = adi_lark_adc_set_sample_rate(&device, 0, API_LARK_ADC_SAMPLE_RATE_96KHz);
LARK_ERROR_RETURN(err);
err = adi_lark_adc_set_input_mode(&device, 0, false);
LARK_ERROR_RETURN(err);
/* DAC: 96KHz, from ADC0 */
err = adi_lark_dac_set_sample_rate(&device, API_LARK_DAC_SAMPLE_RATE_96KHz);
LARK_ERROR_RETURN(err);
err = adi_lark_dac_select_input_route(&device, API_LARK_DAC_ROUTE_ADC0);
LARK_ERROR_RETURN(err);
/* HPAMP: headphone mode*/
err = adi_lark_hpamp_set_output_mode(&device, API_LARK_HPAMP_HEADPHONE);
LARK_ERROR_RETURN(err);
/* Power on ADC0 and DAC */
err = adi_lark_adc_enable_power_on(&device, 0, true);
LARK_ERROR_RETURN(err);
err = adi_lark_dac_enable_power_on(&device, true);
LARK_ERROR_RETURN(err);
err = adi_lark_dac_enable_mute(&device, false);
LARK_ERROR_RETURN(err);
err = adi_lark_dac_set_volume(&device, 0x40);
LARK_ERROR_RETURN(err);
while(1)
{
asm("WAITI 0");
}