SmartSnippets DA1459x SDK
Files | Data Structures | Macros | Enumerations | Functions
Audio Processing Unit - Sample Rate Converter

Audio Sample Rate Converter. More...

Files

file  hw_src.h
 Definition of the API for the Audio Unit SRC Low Level Driver.
 

Data Structures

struct  hw_src_config_t
 SRC configuration structure definition. More...
 

Macros

#define HW_SRC1   ((void *)SRC1_BASE)
 SRC id. More...
 
#define HW_SRC_REG_GETF(id, base, reg, field)   ((SRCBA(id)->SRC1_##reg & (base##_SRC1_##reg##_##field##_Msk)) >> (base##_SRC1_##reg##_##field##_Pos))
 Get the value of a field of a SRC register. More...
 
#define HW_SRC_REG_SETF(id, base, reg, field, val)
 Set the value of a field of a SRC register. More...
 
#define HW_SRC_REG_SET_FIELD(base, reg, field, var, val)
 Set SRC register field value. More...
 
#define HW_SRC_REG_GET_FIELD(base, reg, field, var)
 Access register field value. More...
 
#define HW_SRC_REG_CLR_FIELD(base, reg, field, var)   var &= ~(base##_SRC1_##reg##_##field##_Msk)
 Clear register field value. More...
 
#define HW_SRC_REG_SET_BIT(id, base, reg, field)
 Set a bit of a SRC register. More...
 
#define HW_SRC_REG_CLR_BIT(id, base, reg, field)
 Clear a bit of a SRC register. More...
 

Enumerations

enum  HW_SRC_DIRECTION { HW_SRC_IN, HW_SRC_OUT }
 Input/Output direction. More...
 
enum  HW_SRC_FLOW_STATUS { HW_SRC_FLOW_OK = 0, HW_SRC_FLOW_OVER, HW_SRC_FLOW_UNDER, HW_SRC_FLOW_OVER_UNDER }
 Flow status. More...
 
enum  HW_SRC_SELECTION { HW_SRC_PCM = 1, HW_SRC_PDM, HW_SRC_REGS }
 Input/Output selection. More...
 
enum  HW_SRCx_MUX_IN { HW_SRC_INPUT_MUX_OFF, HW_SRC_INPUT_MUX_PCM_OUT_REG, HW_SRC_INPUT_MUX_SRCx_IN_REG, HW_SRC_INPUT_MUX_SDADC_OUT }
 SRCx input multiplexer. More...
 
enum  HW_PDM1_MUX_IN { HW_PDM_INPUT_MUX_SRCx_MUX_IN, HW_PDM_INPUT_MUX_PDM_INPUT }
 PDM input multiplexer. More...
 

Functions

__STATIC_INLINE void hw_src_enable (HW_SRC_ID id)
 Enable SRC. More...
 
__STATIC_INLINE void hw_src_disable (HW_SRC_ID id)
 Disable SRC. More...
 
__STATIC_INLINE bool hw_src_is_enabled (HW_SRC_ID id)
 Check if SRC is enabled. More...
 
__STATIC_INLINE void hw_src_enable_fifo (HW_SRC_ID id, HW_SRC_DIRECTION direction)
 Enable SRC FIFO. FIFO is used to store samples from/to SRC. More...
 
__STATIC_INLINE void hw_src_disable_fifo (HW_SRC_ID id)
 Disable SRC FIFO. On each SRC request, one sample is serviced. More...
 
__STATIC_INLINE bool hw_src_is_fifo_enabled (HW_SRC_ID id)
 Check if SRC FIFO is enabled. FIFO is used to store samples from/to SRC. More...
 
__STATIC_INLINE void hw_src_set_automode (HW_SRC_ID id, HW_SRC_DIRECTION direction)
 Set Automatic Conversion mode. More...
 
__STATIC_INLINE void hw_src_set_manual_mode (HW_SRC_ID id, HW_SRC_DIRECTION direction)
 Clear Automatic Conversion mode. Use manual mode. More...
 
__STATIC_INLINE void hw_src_select_input (HW_SRC_SELECTION input, hw_src_config_t *config)
 Select the SRC input. More...
 
__STATIC_INLINE void hw_src_write_input (HW_SRC_ID id, uint8_t stream, uint32_t value)
 Write data to an input SRC register. More...
 
__STATIC_INLINE bool hw_src_is_auto_mode (HW_SRC_ID id, HW_SRC_DIRECTION direction)
 Get the mode. More...
 
__STATIC_INLINE uint32_t hw_src_read_output (HW_SRC_ID id, uint8_t stream)
 Read data from an output SRC register. More...
 
HW_SRC_FLOW_STATUS hw_src_get_flow_status (HW_SRC_ID id, HW_SRC_DIRECTION direction)
 Check if SRC flow errors have occurred and clear the indication. More...
 
void hw_src_init (HW_SRC_ID id, hw_src_config_t *config)
 Initialize the SRC. More...
 

Detailed Description

Audio Sample Rate Converter.

Macro Definition Documentation

◆ HW_SRC1

#define HW_SRC1   ((void *)SRC1_BASE)

SRC id.

◆ HW_SRC_REG_CLR_BIT

#define HW_SRC_REG_CLR_BIT (   id,
  base,
  reg,
  field 
)
Value:
do { \
SRCBA(id)->SRC1_##reg &= ~(base##_SRC1_##reg##_##field##_Msk); \
} while (0)

Clear a bit of a SRC register.

Parameters
[in]ididentifies SRC1, SRC2
[in]baseidentifies APU, SRC1, SRC2 bases
[in]regis the register to access
[in]fieldis the register field to write

◆ HW_SRC_REG_CLR_FIELD

#define HW_SRC_REG_CLR_FIELD (   base,
  reg,
  field,
  var 
)    var &= ~(base##_SRC1_##reg##_##field##_Msk)

Clear register field value.

Clears a register field value (aimed to be used with local variables). e.g.

uint16_t tmp;
tmp = SRC1->SRC1_MUX_REG;
HW_SRC_REG_CLR_FIELD(SRC1, SRC1_MUX_REG, PDM1_MUX_IN, tmp);
SRC1->SRC1_MUX_REG = tmp;
...

◆ HW_SRC_REG_GET_FIELD

#define HW_SRC_REG_GET_FIELD (   base,
  reg,
  field,
  var 
)
Value:
((var & (base##_SRC1_##reg##_##field##_Msk)) >> \
(base##_SRC1_##reg##_##field##_Pos))

Access register field value.

Returns a register field value (aimed to be used with local variables). e.g.

uint16_t tmp;
int val;
tmp = SRC1->SRC1_MUX_REG;
val = HW_SRC_REG_GET_FIELD(SRC1, SRC1_MUX_REG, PDM1_MUX_IN, tmp);
...

◆ HW_SRC_REG_GETF

#define HW_SRC_REG_GETF (   id,
  base,
  reg,
  field 
)    ((SRCBA(id)->SRC1_##reg & (base##_SRC1_##reg##_##field##_Msk)) >> (base##_SRC1_##reg##_##field##_Pos))

Get the value of a field of a SRC register.

Parameters
[in]ididentifies SRC1, SRC2
[in]baseidentifies APU, SRC1, SRC2 bases
[in]regis the register to access
[in]fieldis the register field to read
Returns
the value of the register field

◆ HW_SRC_REG_SET_BIT

#define HW_SRC_REG_SET_BIT (   id,
  base,
  reg,
  field 
)
Value:
do { \
SRCBA(id)->SRC1_##reg |= (1 << (base##_SRC1_##reg##_##field##_Pos)); \
} while (0)

Set a bit of a SRC register.

Parameters
[in]ididentifies SRC1, SRC2
[in]baseidentifies APU, SRC1, SRC2 bases
[in]regis the register to access
[in]fieldis the register field to write

◆ HW_SRC_REG_SET_FIELD

#define HW_SRC_REG_SET_FIELD (   base,
  reg,
  field,
  var,
  val 
)
Value:
var = (((var & ~(base##_SRC1_##reg##_##field##_Msk))) | \
(((val) << (base##_SRC1_##reg##_##field##_Pos)) & \
(base##_SRC1_##reg##_##field##_Msk)))

Set SRC register field value.

Sets a register field value (aimed to be used with local variables). e.g.

uint32_t val;
val = SRCBA(config->id)->CTRL_REG;
HW_SRC_REG_SET_FIELD(SRC1, SRC1_CTRL_REG, SRC_IN_DS, val, iir_setting);
SRCBA(config->id)->CTRL_REG = val;
...

◆ HW_SRC_REG_SETF

#define HW_SRC_REG_SETF (   id,
  base,
  reg,
  field,
  val 
)
Value:
SRCBA(id)->SRC1_##reg = ((SRCBA(id)->SRC1_##reg & ~(base##_SRC1_##reg##_##field##_Msk)) | \
((base##_SRC1_##reg##_##field##_Msk) & ((val) << (base##_SRC1_##reg##_##field##_Pos))))

Set the value of a field of a SRC register.

Parameters
[in]ididentifies SRC1, SRC2
[in]baseidentifies APU, SRC1, SRC2 bases
[in]regis the register to access
[in]fieldis the register field to write
[in]valis the value to write

Enumeration Type Documentation

◆ HW_PDM1_MUX_IN

PDM input multiplexer.

Enumerator
HW_PDM_INPUT_MUX_SRCx_MUX_IN 

PDM input is SRCx_MUX_IN

HW_PDM_INPUT_MUX_PDM_INPUT 

PDM input is PDM

◆ HW_SRC_DIRECTION

Input/Output direction.

Enumerator
HW_SRC_IN 

SRC input

HW_SRC_OUT 

SRC output

◆ HW_SRC_FLOW_STATUS

Flow status.

Enumerator
HW_SRC_FLOW_OK 

No flow errors

HW_SRC_FLOW_OVER 

Overflow errors

HW_SRC_FLOW_UNDER 

Underflow errors

HW_SRC_FLOW_OVER_UNDER 

Both overflow and underflow errors

◆ HW_SRC_SELECTION

Input/Output selection.

Enumerator
HW_SRC_PCM 

PCM interface

HW_SRC_PDM 

PDM interface

HW_SRC_REGS 

SRC registers

◆ HW_SRCx_MUX_IN

SRCx input multiplexer.

Enumerator
HW_SRC_INPUT_MUX_OFF 

PCM input is off

HW_SRC_INPUT_MUX_PCM_OUT_REG 

PCM input set to PCM_OUT_REG

HW_SRC_INPUT_MUX_SRCx_IN_REG 

PCM input set to SRCx_OUT_REG

HW_SRC_INPUT_MUX_SDADC_OUT 

PCM input set to SDADC

Function Documentation

◆ hw_src_disable()

__STATIC_INLINE void hw_src_disable ( HW_SRC_ID  id)

Disable SRC.

Parameters
[in]ididentifies SRC1, SRC2

◆ hw_src_disable_fifo()

__STATIC_INLINE void hw_src_disable_fifo ( HW_SRC_ID  id)

Disable SRC FIFO. On each SRC request, one sample is serviced.

Parameters
[in]ididentifies SRC1, SRC2

◆ hw_src_enable()

__STATIC_INLINE void hw_src_enable ( HW_SRC_ID  id)

Enable SRC.

Parameters
[in]ididentifies SRC1, SRC2

◆ hw_src_enable_fifo()

__STATIC_INLINE void hw_src_enable_fifo ( HW_SRC_ID  id,
HW_SRC_DIRECTION  direction 
)

Enable SRC FIFO. FIFO is used to store samples from/to SRC.

Parameters
[in]ididentifies SRC1, SRC2
[in]directionThe SRC FIFO direction. HW_SRC_IN - FIFO is used to store samples from memory to SRC HW_SRC_OUT - FIFO is used to store samples from SRC to memory

◆ hw_src_get_flow_status()

HW_SRC_FLOW_STATUS hw_src_get_flow_status ( HW_SRC_ID  id,
HW_SRC_DIRECTION  direction 
)

Check if SRC flow errors have occurred and clear the indication.

Parameters
[in]ididentifies SRC1, SRC2
[in]directionInput/Output direction
Returns
The flow status

◆ hw_src_init()

void hw_src_init ( HW_SRC_ID  id,
hw_src_config_t config 
)

Initialize the SRC.

Configure the SRC sampling frequencies, the input down-sampler and output up-sampler IIR filters, the conversion modes, the divider of the internally generated clock and enable the clock

Note
call hw_src_enable() once SRC interface initialization is done
Parameters
[in]ididentifies SRC1, SRC2
[out]configconfiguration structure of SRC

◆ hw_src_is_auto_mode()

__STATIC_INLINE bool hw_src_is_auto_mode ( HW_SRC_ID  id,
HW_SRC_DIRECTION  direction 
)

Get the mode.

Parameters
[in]ididentifies SRC1, SRC2
[in]directionInput/Output direction of data flow allowed values: HW_SRC_IN, HW_SRC_OUT
Returns
mode
Return values
0for manual mode
1for automatic mode

◆ hw_src_is_enabled()

__STATIC_INLINE bool hw_src_is_enabled ( HW_SRC_ID  id)

Check if SRC is enabled.

Parameters
[in]ididentifies SRC1, SRC2
Returns
Return values
Trueif it is enabled
Falseif it is disabled

◆ hw_src_is_fifo_enabled()

__STATIC_INLINE bool hw_src_is_fifo_enabled ( HW_SRC_ID  id)

Check if SRC FIFO is enabled. FIFO is used to store samples from/to SRC.

Parameters
[in]ididentifies SRC1, SRC2
Returns
Return values
Trueif it is enabled
Falseif it is disabled

◆ hw_src_read_output()

__STATIC_INLINE uint32_t hw_src_read_output ( HW_SRC_ID  id,
uint8_t  stream 
)

Read data from an output SRC register.

Parameters
[in]ididentifies SRC1, SRC2
[in]streamThe output stream (1 or 2)
Returns
The data read

◆ hw_src_select_input()

__STATIC_INLINE void hw_src_select_input ( HW_SRC_SELECTION  input,
hw_src_config_t config 
)

Select the SRC input.

Note
call this function once SRC interface initialization is done
Parameters
[in]inputthe SRC input
[in,out]configthe configuration structure of SRC

◆ hw_src_set_automode()

__STATIC_INLINE void hw_src_set_automode ( HW_SRC_ID  id,
HW_SRC_DIRECTION  direction 
)

Set Automatic Conversion mode.

Parameters
[in]ididentifies SRC1, SRC2
[in]directionInput/Output direction of data flow allowed values: HW_SRC_IN, HW_SRC_OUT

◆ hw_src_set_manual_mode()

__STATIC_INLINE void hw_src_set_manual_mode ( HW_SRC_ID  id,
HW_SRC_DIRECTION  direction 
)

Clear Automatic Conversion mode. Use manual mode.

Parameters
[in]ididentifies SRC1, SRC2
[in]directionInput/Output direction of data flow allowed values: HW_SRC_IN, HW_SRC_OUT

◆ hw_src_write_input()

__STATIC_INLINE void hw_src_write_input ( HW_SRC_ID  id,
uint8_t  stream,
uint32_t  value 
)

Write data to an input SRC register.

Parameters
[in]ididentifies SRC1, SRC2
[in]streamThe input stream (1 or 2)
[in]valueThe data to be written
HW_SRC_REG_GET_FIELD
#define HW_SRC_REG_GET_FIELD(base, reg, field, var)
Access register field value.
Definition: hw_src.h:127
HW_SRC_REG_SET_FIELD
#define HW_SRC_REG_SET_FIELD(base, reg, field, var, val)
Set SRC register field value.
Definition: hw_src.h:108
HW_SRC_REG_CLR_FIELD
#define HW_SRC_REG_CLR_FIELD(base, reg, field, var)
Clear register field value.
Definition: hw_src.h:144