Time Division Multiplexed Audio Interface (TDM) peripheral driver.
More...
|
| #define | NRFX_TDM_DEFAULT_CONFIG(_sck_pin, _fsync_pin, _mck_pin, _sdout_pin, _sdin_pin) |
| | TDM driver default configuration.
|
| |
|
#define | NRFX_TDM_NUM_OF_CHANNELS (TDM_CONFIG_CHANNEL_NUM_NUM_Max + 1) |
| | Maximum number of TDM channels.
|
| |
| #define | NRFX_TDM_MIN_TRANSFER_SIZE TDM_MIN_TRANSFER_SIZE |
| | Minimal transfer size of TDM buffer in 32-bit words.
|
| |
| #define | NRFX_TDM_MIN_TRANSFER_SIZE TDM_MIN_TRANSFER_SIZE |
| | Minimal transfer size of TDM buffer in 32-bit words.
|
| |
|
#define | NRFX_TDM_STATUS_NEXT_BUFFERS_NEEDED (1UL << 0) |
| | TDM status flag indicating that the application must provide buffers that are to be used in the next part of the transfer. A call to nrfx_tdm_next_buffers_set must be done before the currently used buffers are completely processed (that is, the time remaining for supplying the next buffers depends on the used size of the buffers).
|
| |
|
#define | NRFX_TDM_STATUS_TRANSFER_STOPPED (1UL << 1) |
| | TDM status flag indicating that The peripheral has been stopped and all buffers that were passed to the driver have been released.
|
| |
| #define | NRFX_TDM_INSTANCE(reg) |
| | Macro for creating a TDM driver instance.
|
| |
Time Division Multiplexed Audio Interface (TDM) peripheral driver.
◆ NRFX_TDM_DEFAULT_CONFIG
| #define NRFX_TDM_DEFAULT_CONFIG |
( |
| _sck_pin, |
|
|
| _fsync_pin, |
|
|
| _mck_pin, |
|
|
| _sdout_pin, |
|
|
| _sdin_pin ) |
Value:{ \
.sck_pin = _sck_pin, \
.fsync_pin = _fsync_pin, \
.mck_pin = _mck_pin, \
.sdout_pin = _sdout_pin, \
.sdin_pin = _sdin_pin, \
.irq_priority = NRFX_TDM_DEFAULT_CONFIG_IRQ_PRIORITY, \
.channel_number = 2, \
.fsync_duration = NRFX_TDM_DEFAULT_FSYNC_DURATION, \
.ors = 0, \
.prescalers = \
{ \
}, \
}
@ NRF_TDM_SRC_PCLK32M
32MHz peripheral clock.
Definition nrf_tdm.h:205
@ NRF_TDM_POLARITY_POSEDGE
Synchronization at rising edge of the reference signal.
Definition nrf_tdm.h:277
@ NRF_TDM_POLARITY_NEGEDGE
Synchronization at falling edge of the reference signal.
Definition nrf_tdm.h:278
@ NRF_TDM_MODE_MASTER
Master mode.
Definition nrf_tdm.h:143
@ NRF_TDM_SWIDTH_16BIT
16 bit.
Definition nrf_tdm.h:216
@ NRF_TDM_ALIGN_LEFT
Left-aligned.
Definition nrf_tdm.h:228
@ NRF_TDM_CHANNEL_DELAY_1CK
1 clock pulse delay. Used with original TDM format.
Definition nrf_tdm.h:270
@ NRF_TDM_CHANNEL_RX0_MASK
Enable RX channel 0 data.
Definition nrf_tdm.h:235
@ NRF_TDM_CHANNEL_TX0_MASK
Enable TX channel 0 data.
Definition nrf_tdm.h:243
@ NRF_TDM_MCK_DIV_8
MCK divided by 8.
Definition nrf_tdm.h:163
@ NRF_TDM_SCK_DIV_8
SCK divided by 8.
Definition nrf_tdm.h:186
TDM driver default configuration.
This configuration sets up TDM with the following options:
- Master mode
- Left alignment
- 16 bit sample width
- One RX channel enabled
- One TX channel enabled
- Delay of one clock pulse
- TX on the falling edge of SCK, RX on the rising edge of SCK
- Frame starts at falling edge of FSYNC.
- Zeros sent as over-read
- PCLK32M clock source
- MCK frequency divider equal to 8
- SCK frequency divider equal to 8
- Parameters
-
| [in] | _sck_pin | Serial clock pin number. |
| [in] | _fsync_pin | Frame Synchronization pin number. |
| [in] | _mck_pin | Master clock pin number. |
| [in] | _sdout_pin | Serial Data Output pin number. |
| [in] | _sdin_pin | Serial Data Input pin number. |
◆ NRFX_TDM_INSTANCE
| #define NRFX_TDM_INSTANCE |
( |
| reg | ) |
|
Value:{ \
.p_reg = (NRF_TDM_Type *)reg, \
.cb = {0}, \
}
Macro for creating a TDM driver instance.
◆ NRFX_TDM_MIN_TRANSFER_SIZE [1/2]
| #define NRFX_TDM_MIN_TRANSFER_SIZE TDM_MIN_TRANSFER_SIZE |
Minimal transfer size of TDM buffer in 32-bit words.
Minimum TDM transfer size in bytes.
◆ NRFX_TDM_MIN_TRANSFER_SIZE [2/2]
| #define NRFX_TDM_MIN_TRANSFER_SIZE TDM_MIN_TRANSFER_SIZE |
Minimal transfer size of TDM buffer in 32-bit words.
Minimum TDM transfer size in bytes.
◆ nrfx_tdm_data_handler_t
| typedef void(* nrfx_tdm_data_handler_t) (nrfx_tdm_buffers_t const *p_released, uint32_t status) |
TDM driver data handler type.
A data handling function of this type must be specified during the initialization of the driver. The driver will call this function when it finishes transfer using buffers passed to it by the application, and when it needs to be provided with buffers for the next part of the transfer.
- Note
- The
p_released pointer passed to this function is temporary and will be invalid after the function returns, hence it cannot be stored and used later. If needed, the pointed content (that is, buffers pointers) must be copied instead.
- Parameters
-
| [in] | p_released | Pointer to a structure with pointers to buffers passed previously to the driver that will no longer be accessed by it (they can be now safely released or used for another purpose, in particular for a next part of the transfer). This pointer will be NULL if the application did not supply the buffers for the next part of the transfer (via a call to nrfx_tdm_next_buffers_set) since the previous time the data handler signaled such need. This means that data corruption occurred (the previous buffers are used for the second time) and no buffers can be released at the moment. Both pointers in this structure are NULL when the handler is called for the first time after a transfer is started, because no data has been transferred yet at this point. In all successive calls, the pointers specify what has been sent (TX) and what has been received (RX) in the part of the transfer that has just been completed (provided that a given direction is enabled, see nrfx_tdm_start). |
- Note
- Since the peripheral is stopped asynchronously, buffers that are released after the call to nrfx_tdm_stop are not used entirely. In this case, only a part (if any) of the TX buffer has been actually transmitted and only a part (if any) of the RX buffer is filled with received data.
- Parameters
-
| [in] | status | Bit field describing the current status of the transfer. It can be 0 or a combination of the following flags:
|
◆ nrfx_tdm_init()
Function for initializing the TDM driver.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_config | Pointer to the structure with the initial configuration. |
| [in] | handler | Data handler provided by the user. |
- Return values
-
| 0 | Initialization was successful. |
| -EALREADY | The driver is already initialized. |
| -EINVAL | The requested combination of configuration options is not allowed by the TDM peripheral. |
◆ nrfx_tdm_init_check()
| bool nrfx_tdm_init_check |
( |
nrfx_tdm_t const * | p_instance | ) |
|
Function for checking if the TDM driver instance is initialized.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
- Return values
-
| true | Instance is already initialized. |
| false | Instance is not initialized. |
◆ nrfx_tdm_irq_handler()
| void nrfx_tdm_irq_handler |
( |
nrfx_tdm_t * | p_instance | ) |
|
Driver interrupt handler.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
◆ nrfx_tdm_next_buffers_set()
Function for supplying the buffers to be used in the next part of the transfer.
The application must call this function when the data handler receives NRFX_TDM_STATUS_NEXT_BUFFERS_NEEDED in the status parameter. The call can be done immediately from the data handler function or later, but it has to be done before the TDM peripheral finishes processing the buffers supplied previously. Otherwise, data corruption will occur.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_buffers | Pointer to a structure specifying the buffers to be used in the upcoming part of the transfer. |
- Return values
-
| 0 | If the operation was successful. |
| -EINPROGRESS | If the buffers were already supplied or the peripheral is currently being stopped. |
| -EINVAL | Required buffers were not provided or the provided transfer length is too short. |
| -EACCES | The provided buffers are not placed in the Data RAM region. |
◆ nrfx_tdm_prescalers_calc()
Function for calculating TDM clock prescaler values.
Call this function to find suitable value for prescalers in nrfx_tdm_config_t structure.
If prescaler calculation for a specific clock is to be skipped, its desired frequency should be set to 0.
Application must ensure that requested clock frequency can be achieved using its base clock frequency.
- Parameters
-
| [in] | clk_params | Parameters used to describe clock prescaling. |
| [out] | prescalers | Prescaler structure pointer to be filled with prescaler values. |
- Return values
-
| 0 | Suitable prescaler values were found for both clocks. |
| -EINVAL | No suitable prescaler values were found for either of the clocks. |
◆ nrfx_tdm_reconfigure()
Function for reconfiguring the TDM driver.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_config | Pointer to the structure with the configuration. |
- Return values
-
| 0 | Reconfiguration was successful. |
| -EINPROGRESS | The driver is uninitialized. |
| -EINVAL | The requested combination of configuration options is not allowed by the TDM peripheral. |
◆ nrfx_tdm_start()
Function for starting the continuous TDM transfer.
The TDM data transfer can be performed in one of three modes: RX (reception) only, TX (transmission) only, or in both directions simultaneously. The mode is selected by specifying a proper buffer for a given direction in the call to this function or by passing NULL instead if this direction is to be disabled.
The length of the buffer (which is a common value for RX and TX if both directions are enabled) is specified in 32-bit words. One 32-bit memory word can either contain four 8-bit samples, two 16-bit samples, or one right-aligned 24-bit sample sign-extended to a 32-bit value. For a detailed memory mapping for different supported configurations, see the Product Specification.
- Note
- Peripherals using EasyDMA (including TDM) require the transfer buffers to be placed in the Data RAM region. If this condition is not met, this function will fail with the error code -EACCES.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_initial_buffers | Pointer to a structure specifying the buffers to be used in the initial part of the transfer (buffers for all consecutive parts are provided through the data handler). |
- Return values
-
| 0 | The operation was successful. |
| -EINPROGRESS | The driver has not been initialized. |
| -EALREADY | Transfer has already been already started. |
| -EINVAL | No buffers were provided or the provided transfer length is too short. |
| -EACCES | The provided buffers are not placed in the Data RAM region. |
◆ nrfx_tdm_stop()
| void nrfx_tdm_stop |
( |
nrfx_tdm_t * | p_instance, |
|
|
bool | abort ) |
Function for stopping the TDM transfer.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | abort | True if transfer is to be stopped immediately, false if transfer is to be stopped only after currently processed buffers are filled. |
◆ nrfx_tdm_uninit()
Function for uninitializing the TDM driver.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |