InPlay API
Audio Profile

HAL AUDIO. More...

Enumerations

enum  audio_status_t {
  AUDIO_ERR_OK = 0, AUDIO_ERR_NOT_INIT = 1, AUDIO_ERR_ALREADY_INIT = 2, AUDIO_ERR_DEV_BAD_STATE = 3,
  AUDIO_ERR_INVALID_PARA = 4, AUDIO_ERR_OP_BLOCKED = 5, AUDIO_ERR_NO_AUDIO_CONFIG = 6, AUDIO_ERR_BAD_HW_GPIO_CONFIG = 7,
  AUDIO_ERR_AUDIO_HW_INTR = 8
}
 Audio function status return. More...
 

Functions

int hal_audio_enc_open (void)
 Initialize encode functionality. More...
 
int hal_audio_dec_open (void)
 Initialize decode functionality. More...
 
int hal_audio_resample_open (void)
 Initialize resample functionality. More...
 
int hal_audio_enc_close (void)
 Clean-up encode functionality. More...
 
int hal_audio_dec_close (void)
 Clean-up decode functionality. More...
 
int hal_audio_resample_close (void)
 Clean-up resample functionality. More...
 
int hal_audio_enc_set_pdm_mic_inp (int pdm_l_core, int pdm_r_core, int wss_l_low)
 Configure PDM mic input control. More...
 
int hal_audio_enc_set_predict_endianness (int is_little_end)
 Configure encode frame header endianness. More...
 
int hal_audio_dec_set_predict_endianness (int is_little_end)
 Configure decode frame header endianness. More...
 
int hal_audio_enc_set_config (int is_pdm, int is_I2S_master, float in_rate, float out_rate, int is_stereo, int bytes_per_frame, int gain)
 Configure audio_control encode function settings. More...
 
int hal_audio_dec_set_config (int is_i2s, int is_I2S_master, float in_rate, float out_rate, uint8_t out_clk_src, float out_clk_rate, int is_stereo, int bytes_per_frame, int gain)
 Configure audio_control decode function settings. More...
 
int hal_audio_resample_set_config (float in_rate, float out_rate, int is_stereo, int gain)
 Configure audio_control resample function settings. More...
 
int hal_audio_enc_pdm_dc_offset_cal (int bytes_per_frame, int is_stereo, int num_frames_skip, int num_frames_samp)
 Calibrate PDM Encoder DC Offset. Must be called after hal_audio_enc_set_config. Once called, user must execute function again to re-calibrate. More...
 
int hal_audio_encode_start (void *pv, void(*enc_lmt_callback)(void *))
 Begin encode audio functionality based on current configuration. More...
 
int hal_audio_encode_process (uint8_t *out_buf, uint32_t buf_sz, uint16_t *in_size)
 Request encoded data. More...
 
int hal_audio_decode_start (uint8_t *in_buf, uint16_t buf_size, uint16_t *in_size, void *pv, void(*dec_lmt_callback)(void *pv))
 Begin decode audio functionality based on current configuration and input data. More...
 
int hal_audio_decode_process (uint8_t *in_buf, uint16_t buf_size, uint16_t *in_size)
 Provide audio hardware with additional encoded data to be decoded. More...
 
int hal_audio_resample_process (uint32_t *in_buf, uint16_t *in_size, uint32_t *out_buf)
 Execute resample audio functionality based on current configuration and input data. More...
 
int hal_audio_encode_stop (void)
 Stop encode audio functionality. More...
 
int hal_audio_decode_stop (void)
 Stop decode audio functionality. More...
 
int hal_audio_resample_stop (void)
 Stop resample audio functionality. More...
 

Detailed Description

HAL AUDIO.

Enumeration Type Documentation

◆ audio_status_t

Audio function status return.

Enumerator
AUDIO_ERR_OK 

No error. Good status.

AUDIO_ERR_NOT_INIT 

Error, AUDIO driver not initialized.

AUDIO_ERR_ALREADY_INIT 

Error, AUDIO driver already initialized.

AUDIO_ERR_DEV_BAD_STATE 

Error, AUDIO bad state.

AUDIO_ERR_INVALID_PARA 

Error, invalid AUDIO parameter.

AUDIO_ERR_OP_BLOCKED 

Error, current operation block.

AUDIO_ERR_NO_AUDIO_CONFIG 

Error, configuration not initialized.

AUDIO_ERR_BAD_HW_GPIO_CONFIG 

Error, HW GPIO configuration error.

AUDIO_ERR_AUDIO_HW_INTR 

Error, Audio interrupt trigger.

Function Documentation

◆ hal_audio_dec_close()

int hal_audio_dec_close ( void  )

Clean-up decode functionality.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_dec_open()

int hal_audio_dec_open ( void  )

Initialize decode functionality.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_dec_set_config()

int hal_audio_dec_set_config ( int  is_i2s,
int  is_I2S_master,
float  in_rate,
float  out_rate,
uint8_t  out_clk_src,
float  out_clk_rate,
int  is_stereo,
int  bytes_per_frame,
int  gain 
)

Configure audio_control decode function settings.

Parameters
[in]is_i2s1 if audio decode output is i2s output path, 0 if output is sigma delta output path.
[in]is_I2S_master1 if audio decode output is I2S connected to I2S master core, 0 if output is I2S connected to I2S slave core, otherwise don't care.
[in]in_rateAudio input encoded data rate in float format.
[in]is_stereo1 if audio sample format is stereo, 0 if format is mono.
[in]out_rateAudio decode output decoded data rate in float format.
[in]out_clk_srcAudio decode clock rate source. 0 if source is I2S Master, 1 if source is I2S Slave, 2 if source is PDM clock. If clock source is PDM, hardware will internally configure clock. If clock source is I2S Master or I2S Slave, user must generate and/or supply clock signal.
[in]out_clk_rateAudio decode clock rate used to generate audio decode out rate in float format.
[in]bytes_per_frameNumber of total bytes per decoded audio frame. Max 512 bytes.
[in]gainLeft/Right gain setting.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_dec_set_predict_endianness()

int hal_audio_dec_set_predict_endianness ( int  is_little_end)

Configure decode frame header endianness.

Parameters
[in]is_little_end1 if frame header predict bytes in little-endian format, 0 if big-endian format.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_decode_process()

int hal_audio_decode_process ( uint8_t *  in_buf,
uint16_t  buf_size,
uint16_t *  in_size 
)

Provide audio hardware with additional encoded data to be decoded.

Parameters
[in]in_bufPointer to the input encoded data to be decoded.
[in]buf_sizeBuffer size
[out]in_sizereturn with actual number of bytes inserted into audio hardware.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_decode_start()

int hal_audio_decode_start ( uint8_t *  in_buf,
uint16_t  buf_size,
uint16_t *  in_size,
void *  pv,
void(*)(void *pv)  dec_lmt_callback 
)

Begin decode audio functionality based on current configuration and input data.

Parameters
[in]in_bufPointer to the input location of encoded data to be decoded.
[in]buf_sizeBuffer size
[out]in_sizereturn with actual number of bytes inserted into audio hardware.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_decode_stop()

int hal_audio_decode_stop ( void  )

Stop decode audio functionality.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_enc_close()

int hal_audio_enc_close ( void  )

Clean-up encode functionality.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_enc_open()

int hal_audio_enc_open ( void  )

Initialize encode functionality.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_enc_pdm_dc_offset_cal()

int hal_audio_enc_pdm_dc_offset_cal ( int  bytes_per_frame,
int  is_stereo,
int  num_frames_skip,
int  num_frames_samp 
)

Calibrate PDM Encoder DC Offset. Must be called after hal_audio_enc_set_config. Once called, user must execute function again to re-calibrate.

Parameters
[in]bytes_per_frameNumber of total bytes per encoded audio frame. Max 512 bytes.
[in]is_stereo1 if audio sample format is stereo, 0 if format is mono.
[in]num_frames_skipNumber of initial frames to skip when sampling dc offset
[in]num_frames_sampNumber of frames to measure when sampling dc offset
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_enc_set_config()

int hal_audio_enc_set_config ( int  is_pdm,
int  is_I2S_master,
float  in_rate,
float  out_rate,
int  is_stereo,
int  bytes_per_frame,
int  gain 
)

Configure audio_control encode function settings.

Parameters
[in]is_pdm1 if audio encode input is PDM mic, 0 if input is I2S mic.
[in]is_I2S_master1 if audio encode input is I2S mic connected to I2S master core, 0 if input is I2S mic connected to I2S slave core, otherwise don't care.
[in]in_rateAudio encode microphone input sampling rate in float format.
[in]is_stereo1 if audio sample format is stereo, 0 if format is mono.
[in]out_rateAudio encode output encoded data rate in float format.
[in]bytes_per_frameNumber of total bytes per encoded audio frame. Max 512 bytes.
[in]gainLeft/Right gain setting.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_enc_set_pdm_mic_inp()

int hal_audio_enc_set_pdm_mic_inp ( int  pdm_l_core,
int  pdm_r_core,
int  wss_l_low 
)

Configure PDM mic input control.

Parameters
[in]pdm_l_core0 if pdm left input is connected to pin pdm data 0, 1 if connected to pin pdm data 1.
[in]pdm_r_core0 if pdm right input is connected to pin pdm data 0, 1 if connected to pin pdm data 1.
[in]wss_l_low0 if pdm left input is set during word select signal low, 1 if set during signal high.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_enc_set_predict_endianness()

int hal_audio_enc_set_predict_endianness ( int  is_little_end)

Configure encode frame header endianness.

Parameters
[in]is_little_end1 if frame header predict bytes in little-endian format, 0 if big-endian format.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_encode_process()

int hal_audio_encode_process ( uint8_t *  out_buf,
uint32_t  buf_sz,
uint16_t *  in_size 
)

Request encoded data.

Parameters
[in]out_bufPointer to the output location where encoded data is to be written.
[in]buf_szBuffer size.
[out]in_sizePointer to the requested number of encoded bytes of data. Location will be updated upon return with actual number of bytes written to output buffer.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_encode_start()

int hal_audio_encode_start ( void *  pv,
void(*)(void *)  enc_lmt_callback 
)

Begin encode audio functionality based on current configuration.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_encode_stop()

int hal_audio_encode_stop ( void  )

Stop encode audio functionality.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_resample_close()

int hal_audio_resample_close ( void  )

Clean-up resample functionality.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_resample_open()

int hal_audio_resample_open ( void  )

Initialize resample functionality.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_resample_process()

int hal_audio_resample_process ( uint32_t *  in_buf,
uint16_t *  in_size,
uint32_t *  out_buf 
)

Execute resample audio functionality based on current configuration and input data.

Parameters
[in]in_bufPointer to the input audio data to be resampled.
[in]in_sizePointer to the requested number of bytes of data to be resampled.
[out]out_bufPointer to the output location where resampled data will be written.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_resample_set_config()

int hal_audio_resample_set_config ( float  in_rate,
float  out_rate,
int  is_stereo,
int  gain 
)

Configure audio_control resample function settings.

Parameters
[in]in_rateAudio resample input sampling rate in float format.
[in]is_stereo1 if audio sample format is stereo, 0 if format is mono.
[in]out_rateAudio resample output sampling rate in float format.
[in]gainLeft/Right gain setting.
Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.

◆ hal_audio_resample_stop()

int hal_audio_resample_stop ( void  )

Stop resample audio functionality.

Returns
AUDIO_ERR_OK if successful, error otherwise.
See also
enum audio_status_t.