Audio Sample Rate Converter.
More...
|
| file | hw_src.h |
| | Definition of the API for the Audio Unit SRC Low Level Driver.
|
| |
|
| #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...
|
| |
|
| 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...
|
| |
|
| __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...
|
| |
Audio Sample Rate Converter.
◆ HW_SRC1
| #define HW_SRC1 ((void *)SRC1_BASE) |
◆ 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] | id | identifies SRC1, SRC2 |
| [in] | base | identifies APU, SRC1, SRC2 bases |
| [in] | reg | is the register to access |
| [in] | field | is 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;
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;
...
◆ 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] | id | identifies SRC1, SRC2 |
| [in] | base | identifies APU, SRC1, SRC2 bases |
| [in] | reg | is the register to access |
| [in] | field | is 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] | id | identifies SRC1, SRC2 |
| [in] | base | identifies APU, SRC1, SRC2 bases |
| [in] | reg | is the register to access |
| [in] | field | is 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;
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] | id | identifies SRC1, SRC2 |
| [in] | base | identifies APU, SRC1, SRC2 bases |
| [in] | reg | is the register to access |
| [in] | field | is the register field to write |
| [in] | val | is the value to write |
◆ 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
|
◆ hw_src_disable()
| __STATIC_INLINE void hw_src_disable |
( |
HW_SRC_ID |
id | ) |
|
Disable SRC.
- Parameters
-
| [in] | id | identifies 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] | id | identifies SRC1, SRC2 |
◆ hw_src_enable()
| __STATIC_INLINE void hw_src_enable |
( |
HW_SRC_ID |
id | ) |
|
Enable SRC.
- Parameters
-
| [in] | id | identifies 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] | id | identifies SRC1, SRC2 |
| [in] | direction | The 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()
Check if SRC flow errors have occurred and clear the indication.
- Parameters
-
| [in] | id | identifies SRC1, SRC2 |
| [in] | direction | Input/Output direction |
- Returns
- The flow status
◆ hw_src_init()
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] | id | identifies SRC1, SRC2 |
| [out] | config | configuration 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] | id | identifies SRC1, SRC2 |
| [in] | direction | Input/Output direction of data flow allowed values: HW_SRC_IN, HW_SRC_OUT |
- Returns
- mode
- Return values
-
| 0 | for manual mode |
| 1 | for automatic mode |
◆ hw_src_is_enabled()
| __STATIC_INLINE bool hw_src_is_enabled |
( |
HW_SRC_ID |
id | ) |
|
Check if SRC is enabled.
- Parameters
-
| [in] | id | identifies SRC1, SRC2 |
- Returns
- Return values
-
| True | if it is enabled |
| False | if 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] | id | identifies SRC1, SRC2 |
- Returns
- Return values
-
| True | if it is enabled |
| False | if 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] | id | identifies SRC1, SRC2 |
| [in] | stream | The output stream (1 or 2) |
- Returns
- The data read
◆ hw_src_select_input()
Select the SRC input.
- Note
- call this function once SRC interface initialization is done
- Parameters
-
| [in] | input | the SRC input |
| [in,out] | config | the 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] | id | identifies SRC1, SRC2 |
| [in] | direction | Input/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] | id | identifies SRC1, SRC2 |
| [in] | direction | Input/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] | id | identifies SRC1, SRC2 |
| [in] | stream | The input stream (1 or 2) |
| [in] | value | The data to be written |
#define HW_SRC_REG_GET_FIELD(base, reg, field, var)
Access register field value.
Definition: hw_src.h:127
#define HW_SRC_REG_SET_FIELD(base, reg, field, var, val)
Set SRC register field value.
Definition: hw_src.h:108
#define HW_SRC_REG_CLR_FIELD(base, reg, field, var)
Clear register field value.
Definition: hw_src.h:144