MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SPDIF: Sony/Philips Digital Interface

Overview

The MCUXpresso SDK provides a peripheral driver for the Sony/Philips Digital Interface (SPDIF) module of MCUXpresso SDK devices.

SPDIF driver includes functional APIs and transactional APIs.

Functional APIs target low-level APIs. Functional APIs can be used for SPDIF initialization/configuration/operation for optimization/customization purpose. Using the functional API requires the knowledge of the SPDIF peripheral and how to organize functional APIs to meet the application requirements. All functional API use the peripheral base address as the first parameter. SPDIF functional operation groups provide the functional API set.

Transactional APIs target high-level APIs. Transactional APIs can be used to enable the peripheral and in the application if the code size and performance of transactional APIs satisfy the requirements. If the code size and performance are a critical requirement, see the transactional API implementation and write a custom code. All transactional APIs use the spdif_handle_t as the first parameter. Initialize the handle by calling the SPDIF_TransferTxCreateHandle() or SPDIF_TransferRxCreateHandle() API.

Transactional APIs support asynchronous transfer. This means that the functions SPDIF_TransferSendNonBlocking() and SPDIF_TransferReceiveNonBlocking() set up the interrupt for data transfer. When the transfer completes, the upper layer is notified through a callback function with the kStatus_SPDIF_TxIdle and kStatus_SPDIF_RxIdle status.

Typical use case

SPDIF Send/receive using an interrupt method

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/spdif

SPDIF Send/receive using a DMA method

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/spdif

Modules

 SPDIF eDMA Driver
 

Data Structures

struct  spdif_config_t
 SPDIF user configuration structure. More...
 
struct  spdif_transfer_t
 SPDIF transfer structure. More...
 
struct  spdif_handle_t
 SPDIF handle structure. More...
 

Macros

#define SPDIF_XFER_QUEUE_SIZE   (4U)
 SPDIF transfer queue size, user can refine it according to use case. More...
 

Typedefs

typedef void(* spdif_transfer_callback_t )(SPDIF_Type *base, spdif_handle_t *handle, status_t status, void *userData)
 SPDIF transfer callback prototype.
 

Enumerations

enum  {
  kStatus_SPDIF_RxDPLLLocked = MAKE_STATUS(kStatusGroup_SPDIF, 0),
  kStatus_SPDIF_TxFIFOError = MAKE_STATUS(kStatusGroup_SPDIF, 1),
  kStatus_SPDIF_TxFIFOResync = MAKE_STATUS(kStatusGroup_SPDIF, 2),
  kStatus_SPDIF_RxCnew = MAKE_STATUS(kStatusGroup_SPDIF, 3),
  kStatus_SPDIF_ValidatyNoGood = MAKE_STATUS(kStatusGroup_SPDIF, 4),
  kStatus_SPDIF_RxIllegalSymbol = MAKE_STATUS(kStatusGroup_SPDIF, 5),
  kStatus_SPDIF_RxParityBitError = MAKE_STATUS(kStatusGroup_SPDIF, 6),
  kStatus_SPDIF_UChannelOverrun = MAKE_STATUS(kStatusGroup_SPDIF, 7),
  kStatus_SPDIF_QChannelOverrun = MAKE_STATUS(kStatusGroup_SPDIF, 8),
  kStatus_SPDIF_UQChannelSync = MAKE_STATUS(kStatusGroup_SPDIF, 9),
  kStatus_SPDIF_UQChannelFrameError = MAKE_STATUS(kStatusGroup_SPDIF, 10),
  kStatus_SPDIF_RxFIFOError = MAKE_STATUS(kStatusGroup_SPDIF, 11),
  kStatus_SPDIF_RxFIFOResync = MAKE_STATUS(kStatusGroup_SPDIF, 12),
  kStatus_SPDIF_LockLoss = MAKE_STATUS(kStatusGroup_SPDIF, 13),
  kStatus_SPDIF_TxIdle = MAKE_STATUS(kStatusGroup_SPDIF, 14),
  kStatus_SPDIF_RxIdle = MAKE_STATUS(kStatusGroup_SPDIF, 15),
  kStatus_SPDIF_QueueFull = MAKE_STATUS(kStatusGroup_SPDIF, 16)
}
 SPDIF return status. More...
 
enum  spdif_rxfull_select_t {
  kSPDIF_RxFull1Sample = 0x0u,
  kSPDIF_RxFull4Samples,
  kSPDIF_RxFull8Samples,
  kSPDIF_RxFull16Samples
}
 SPDIF Rx FIFO full falg select, it decides when assert the rx full flag. More...
 
enum  spdif_txempty_select_t {
  kSPDIF_TxEmpty0Sample = 0x0u,
  kSPDIF_TxEmpty4Samples,
  kSPDIF_TxEmpty8Samples,
  kSPDIF_TxEmpty12Samples
}
 SPDIF tx FIFO EMPTY falg select, it decides when assert the tx empty flag. More...
 
enum  spdif_uchannel_source_t {
  kSPDIF_NoUChannel = 0x0U,
  kSPDIF_UChannelFromRx = 0x1U,
  kSPDIF_UChannelFromTx = 0x3U
}
 SPDIF U channel source. More...
 
enum  spdif_gain_select_t {
  kSPDIF_GAIN_24 = 0x0U,
  kSPDIF_GAIN_16,
  kSPDIF_GAIN_12,
  kSPDIF_GAIN_8,
  kSPDIF_GAIN_6,
  kSPDIF_GAIN_4,
  kSPDIF_GAIN_3
}
 SPDIF clock gain. More...
 
enum  spdif_tx_source_t {
  kSPDIF_txFromReceiver = 0x1U,
  kSPDIF_txNormal = 0x5U
}
 SPDIF tx data source. More...
 
enum  spdif_validity_config_t {
  kSPDIF_validityFlagAlwaysSet = 0x0U,
  kSPDIF_validityFlagAlwaysClear
}
 SPDIF tx data source. More...
 
enum  {
  kSPDIF_RxDPLLLocked = SPDIF_SIE_LOCK_MASK,
  kSPDIF_TxFIFOError = SPDIF_SIE_TXUNOV_MASK,
  kSPDIF_TxFIFOResync = SPDIF_SIE_TXRESYN_MASK,
  kSPDIF_RxControlChannelChange = SPDIF_SIE_CNEW_MASK,
  kSPDIF_ValidityFlagNoGood = SPDIF_SIE_VALNOGOOD_MASK,
  kSPDIF_RxIllegalSymbol = SPDIF_SIE_SYMERR_MASK,
  kSPDIF_RxParityBitError = SPDIF_SIE_BITERR_MASK,
  kSPDIF_UChannelReceiveRegisterFull = SPDIF_SIE_URXFUL_MASK,
  kSPDIF_UChannelReceiveRegisterOverrun = SPDIF_SIE_URXOV_MASK,
  kSPDIF_QChannelReceiveRegisterFull = SPDIF_SIE_QRXFUL_MASK,
  kSPDIF_QChannelReceiveRegisterOverrun = SPDIF_SIE_QRXOV_MASK,
  kSPDIF_UQChannelSync = SPDIF_SIE_UQSYNC_MASK,
  kSPDIF_UQChannelFrameError = SPDIF_SIE_UQERR_MASK,
  kSPDIF_RxFIFOError = SPDIF_SIE_RXFIFOUNOV_MASK,
  kSPDIF_RxFIFOResync = SPDIF_SIE_RXFIFORESYN_MASK,
  kSPDIF_LockLoss = SPDIF_SIE_LOCKLOSS_MASK,
  kSPDIF_TxFIFOEmpty = SPDIF_SIE_TXEM_MASK,
  kSPDIF_RxFIFOFull = SPDIF_SIE_RXFIFOFUL_MASK
}
 The SPDIF interrupt enable flag. More...
 
enum  {
  kSPDIF_RxDMAEnable = SPDIF_SCR_DMA_RX_EN_MASK,
  kSPDIF_TxDMAEnable = SPDIF_SCR_DMA_TX_EN_MASK
}
 The DMA request sources. More...
 

Driver version

#define FSL_SPDIF_DRIVER_VERSION   (MAKE_VERSION(2, 0, 3))
 Version 2.0.3.
 

Initialization and deinitialization

void SPDIF_Init (SPDIF_Type *base, const spdif_config_t *config)
 Initializes the SPDIF peripheral. More...
 
void SPDIF_GetDefaultConfig (spdif_config_t *config)
 Sets the SPDIF configuration structure to default values. More...
 
void SPDIF_Deinit (SPDIF_Type *base)
 De-initializes the SPDIF peripheral. More...
 
uint32_t SPDIF_GetInstance (SPDIF_Type *base)
 Get the instance number for SPDIF. More...
 
static void SPDIF_TxFIFOReset (SPDIF_Type *base)
 Resets the SPDIF Tx. More...
 
static void SPDIF_RxFIFOReset (SPDIF_Type *base)
 Resets the SPDIF Rx. More...
 
void SPDIF_TxEnable (SPDIF_Type *base, bool enable)
 Enables/disables the SPDIF Tx. More...
 
static void SPDIF_RxEnable (SPDIF_Type *base, bool enable)
 Enables/disables the SPDIF Rx. More...
 

Status

static uint32_t SPDIF_GetStatusFlag (SPDIF_Type *base)
 Gets the SPDIF status flag state. More...
 
static void SPDIF_ClearStatusFlags (SPDIF_Type *base, uint32_t mask)
 Clears the SPDIF status flag state. More...
 

Interrupts

static void SPDIF_EnableInterrupts (SPDIF_Type *base, uint32_t mask)
 Enables the SPDIF Tx interrupt requests. More...
 
static void SPDIF_DisableInterrupts (SPDIF_Type *base, uint32_t mask)
 Disables the SPDIF Tx interrupt requests. More...
 

DMA Control

static void SPDIF_EnableDMA (SPDIF_Type *base, uint32_t mask, bool enable)
 Enables/disables the SPDIF DMA requests. More...
 
static uint32_t SPDIF_TxGetLeftDataRegisterAddress (SPDIF_Type *base)
 Gets the SPDIF Tx left data register address. More...
 
static uint32_t SPDIF_TxGetRightDataRegisterAddress (SPDIF_Type *base)
 Gets the SPDIF Tx right data register address. More...
 
static uint32_t SPDIF_RxGetLeftDataRegisterAddress (SPDIF_Type *base)
 Gets the SPDIF Rx left data register address. More...
 
static uint32_t SPDIF_RxGetRightDataRegisterAddress (SPDIF_Type *base)
 Gets the SPDIF Rx right data register address. More...
 

Bus Operations

void SPDIF_TxSetSampleRate (SPDIF_Type *base, uint32_t sampleRate_Hz, uint32_t sourceClockFreq_Hz)
 Configures the SPDIF Tx sample rate. More...
 
uint32_t SPDIF_GetRxSampleRate (SPDIF_Type *base, uint32_t clockSourceFreq_Hz)
 Configures the SPDIF Rx audio format. More...
 
void SPDIF_WriteBlocking (SPDIF_Type *base, uint8_t *buffer, uint32_t size)
 Sends data using a blocking method. More...
 
static void SPDIF_WriteLeftData (SPDIF_Type *base, uint32_t data)
 Writes data into SPDIF FIFO. More...
 
static void SPDIF_WriteRightData (SPDIF_Type *base, uint32_t data)
 Writes data into SPDIF FIFO. More...
 
static void SPDIF_WriteChannelStatusHigh (SPDIF_Type *base, uint32_t data)
 Writes data into SPDIF FIFO. More...
 
static void SPDIF_WriteChannelStatusLow (SPDIF_Type *base, uint32_t data)
 Writes data into SPDIF FIFO. More...
 
void SPDIF_ReadBlocking (SPDIF_Type *base, uint8_t *buffer, uint32_t size)
 Receives data using a blocking method. More...
 
static uint32_t SPDIF_ReadLeftData (SPDIF_Type *base)
 Reads data from the SPDIF FIFO. More...
 
static uint32_t SPDIF_ReadRightData (SPDIF_Type *base)
 Reads data from the SPDIF FIFO. More...
 
static uint32_t SPDIF_ReadChannelStatusHigh (SPDIF_Type *base)
 Reads data from the SPDIF FIFO. More...
 
static uint32_t SPDIF_ReadChannelStatusLow (SPDIF_Type *base)
 Reads data from the SPDIF FIFO. More...
 
static uint32_t SPDIF_ReadQChannel (SPDIF_Type *base)
 Reads data from the SPDIF FIFO. More...
 
static uint32_t SPDIF_ReadUChannel (SPDIF_Type *base)
 Reads data from the SPDIF FIFO. More...
 

Transactional

void SPDIF_TransferTxCreateHandle (SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_callback_t callback, void *userData)
 Initializes the SPDIF Tx handle. More...
 
void SPDIF_TransferRxCreateHandle (SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_callback_t callback, void *userData)
 Initializes the SPDIF Rx handle. More...
 
status_t SPDIF_TransferSendNonBlocking (SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_t *xfer)
 Performs an interrupt non-blocking send transfer on SPDIF. More...
 
status_t SPDIF_TransferReceiveNonBlocking (SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_t *xfer)
 Performs an interrupt non-blocking receive transfer on SPDIF. More...
 
status_t SPDIF_TransferGetSendCount (SPDIF_Type *base, spdif_handle_t *handle, size_t *count)
 Gets a set byte count. More...
 
status_t SPDIF_TransferGetReceiveCount (SPDIF_Type *base, spdif_handle_t *handle, size_t *count)
 Gets a received byte count. More...
 
void SPDIF_TransferAbortSend (SPDIF_Type *base, spdif_handle_t *handle)
 Aborts the current send. More...
 
void SPDIF_TransferAbortReceive (SPDIF_Type *base, spdif_handle_t *handle)
 Aborts the current IRQ receive. More...
 
void SPDIF_TransferTxHandleIRQ (SPDIF_Type *base, spdif_handle_t *handle)
 Tx interrupt handler. More...
 
void SPDIF_TransferRxHandleIRQ (SPDIF_Type *base, spdif_handle_t *handle)
 Tx interrupt handler. More...
 

Data Structure Documentation

struct spdif_config_t

Data Fields

bool isTxAutoSync
 If auto sync mechanism open.
 
bool isRxAutoSync
 If auto sync mechanism open.
 
uint8_t DPLLClkSource
 SPDIF DPLL clock source, range from 0~15, meaning is chip-specific.
 
uint8_t txClkSource
 SPDIF tx clock source, range from 0~7, meaning is chip-specific.
 
spdif_rxfull_select_t rxFullSelect
 SPDIF rx buffer full select.
 
spdif_txempty_select_t txFullSelect
 SPDIF tx buffer empty select.
 
spdif_uchannel_source_t uChannelSrc
 U channel source.
 
spdif_tx_source_t txSource
 SPDIF tx data source.
 
spdif_validity_config_t validityConfig
 Validity flag config.
 
spdif_gain_select_t gain
 Rx receive clock measure gain parameter. More...
 

Field Documentation

spdif_gain_select_t spdif_config_t::gain
struct spdif_transfer_t

Data Fields

uint8_t * data
 Data start address to transfer. More...
 
uint8_t * qdata
 Data buffer for Q channel.
 
uint8_t * udata
 Data buffer for C channel.
 
size_t dataSize
 Transfer size. More...
 

Field Documentation

uint8_t* spdif_transfer_t::data
size_t spdif_transfer_t::dataSize
struct _spdif_handle

Data Fields

uint32_t state
 Transfer status.
 
spdif_transfer_callback_t callback
 Callback function called at transfer event.
 
void * userData
 Callback parameter passed to callback function.
 
spdif_transfer_t spdifQueue [SPDIF_XFER_QUEUE_SIZE]
 Transfer queue storing queued transfer.
 
size_t transferSize [SPDIF_XFER_QUEUE_SIZE]
 Data bytes need to transfer.
 
volatile uint8_t queueUser
 Index for user to queue transfer.
 
volatile uint8_t queueDriver
 Index for driver to get the transfer data and size.
 
uint8_t watermark
 Watermark value.
 

Macro Definition Documentation

#define SPDIF_XFER_QUEUE_SIZE   (4U)

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_SPDIF_RxDPLLLocked 

SPDIF Rx PLL locked.

kStatus_SPDIF_TxFIFOError 

SPDIF Tx FIFO error.

kStatus_SPDIF_TxFIFOResync 

SPDIF Tx left and right FIFO resync.

kStatus_SPDIF_RxCnew 

SPDIF Rx status channel value updated.

kStatus_SPDIF_ValidatyNoGood 

SPDIF validaty flag not good.

kStatus_SPDIF_RxIllegalSymbol 

SPDIF Rx receive illegal symbol.

kStatus_SPDIF_RxParityBitError 

SPDIF Rx parity bit error.

kStatus_SPDIF_UChannelOverrun 

SPDIF receive U channel overrun.

kStatus_SPDIF_QChannelOverrun 

SPDIF receive Q channel overrun.

kStatus_SPDIF_UQChannelSync 

SPDIF U/Q channel sync found.

kStatus_SPDIF_UQChannelFrameError 

SPDIF U/Q channel frame error.

kStatus_SPDIF_RxFIFOError 

SPDIF Rx FIFO error.

kStatus_SPDIF_RxFIFOResync 

SPDIF Rx left and right FIFO resync.

kStatus_SPDIF_LockLoss 

SPDIF Rx PLL clock lock loss.

kStatus_SPDIF_TxIdle 

SPDIF Tx is idle.

kStatus_SPDIF_RxIdle 

SPDIF Rx is idle.

kStatus_SPDIF_QueueFull 

SPDIF queue full.

Enumerator
kSPDIF_RxFull1Sample 

Rx full at least 1 sample in left and right FIFO.

kSPDIF_RxFull4Samples 

Rx full at least 4 sample in left and right FIFO.

kSPDIF_RxFull8Samples 

Rx full at least 8 sample in left and right FIFO.

kSPDIF_RxFull16Samples 

Rx full at least 16 sample in left and right FIFO.

Enumerator
kSPDIF_TxEmpty0Sample 

Tx empty at most 0 sample in left and right FIFO.

kSPDIF_TxEmpty4Samples 

Tx empty at most 4 sample in left and right FIFO.

kSPDIF_TxEmpty8Samples 

Tx empty at most 8 sample in left and right FIFO.

kSPDIF_TxEmpty12Samples 

Tx empty at most 12 sample in left and right FIFO.

Enumerator
kSPDIF_NoUChannel 

No embedded U channel.

kSPDIF_UChannelFromRx 

U channel from receiver, it is CD mode.

kSPDIF_UChannelFromTx 

U channel from on chip tx.

Enumerator
kSPDIF_GAIN_24 

Gain select is 24.

kSPDIF_GAIN_16 

Gain select is 16.

kSPDIF_GAIN_12 

Gain select is 12.

kSPDIF_GAIN_8 

Gain select is 8.

kSPDIF_GAIN_6 

Gain select is 6.

kSPDIF_GAIN_4 

Gain select is 4.

kSPDIF_GAIN_3 

Gain select is 3.

Enumerator
kSPDIF_txFromReceiver 

Tx data directly through SPDIF receiver.

kSPDIF_txNormal 

Normal operation, data from processor.

Enumerator
kSPDIF_validityFlagAlwaysSet 

Outgoing validity flags always set.

kSPDIF_validityFlagAlwaysClear 

Outgoing validity flags always clear.

anonymous enum
Enumerator
kSPDIF_RxDPLLLocked 

SPDIF DPLL locked.

kSPDIF_TxFIFOError 

Tx FIFO underrun or overrun.

kSPDIF_TxFIFOResync 

Tx FIFO left and right channel resync.

kSPDIF_RxControlChannelChange 

SPDIF Rx control channel value changed.

kSPDIF_ValidityFlagNoGood 

SPDIF validity flag no good.

kSPDIF_RxIllegalSymbol 

SPDIF receiver found illegal symbol.

kSPDIF_RxParityBitError 

SPDIF receiver found parity bit error.

kSPDIF_UChannelReceiveRegisterFull 

SPDIF U channel revceive register full.

kSPDIF_UChannelReceiveRegisterOverrun 

SPDIF U channel receive register overrun.

kSPDIF_QChannelReceiveRegisterFull 

SPDIF Q channel receive reigster full.

kSPDIF_QChannelReceiveRegisterOverrun 

SPDIF Q channel receive register overrun.

kSPDIF_UQChannelSync 

SPDIF U/Q channel sync found.

kSPDIF_UQChannelFrameError 

SPDIF U/Q channel frame error.

kSPDIF_RxFIFOError 

SPDIF Rx FIFO underrun/overrun.

kSPDIF_RxFIFOResync 

SPDIF Rx left and right FIFO resync.

kSPDIF_LockLoss 

SPDIF receiver loss of lock.

kSPDIF_TxFIFOEmpty 

SPDIF Tx FIFO empty.

kSPDIF_RxFIFOFull 

SPDIF Rx FIFO full.

anonymous enum
Enumerator
kSPDIF_RxDMAEnable 

Rx FIFO full.

kSPDIF_TxDMAEnable 

Tx FIFO empty.

Function Documentation

void SPDIF_Init ( SPDIF_Type *  base,
const spdif_config_t config 
)

Ungates the SPDIF clock, resets the module, and configures SPDIF with a configuration structure. The configuration structure can be custom filled or set with default values by SPDIF_GetDefaultConfig().

Note
This API should be called at the beginning of the application to use the SPDIF driver. Otherwise, accessing the SPDIF module can cause a hard fault because the clock is not enabled.
Parameters
baseSPDIF base pointer
configSPDIF configuration structure.
void SPDIF_GetDefaultConfig ( spdif_config_t config)

This API initializes the configuration structure for use in SPDIF_Init. The initialized structure can remain unchanged in SPDIF_Init, or it can be modified before calling SPDIF_Init. This is an example.

Parameters
configpointer to master configuration structure
void SPDIF_Deinit ( SPDIF_Type *  base)

This API gates the SPDIF clock. The SPDIF module can't operate unless SPDIF_Init is called to enable the clock.

Parameters
baseSPDIF base pointer
uint32_t SPDIF_GetInstance ( SPDIF_Type *  base)
Parameters
baseSPDIF base pointer.
static void SPDIF_TxFIFOReset ( SPDIF_Type *  base)
inlinestatic

This function makes Tx FIFO in reset mode.

Parameters
baseSPDIF base pointer
static void SPDIF_RxFIFOReset ( SPDIF_Type *  base)
inlinestatic

This function enables the software reset and FIFO reset of SPDIF Rx. After reset, clear the reset bit.

Parameters
baseSPDIF base pointer
void SPDIF_TxEnable ( SPDIF_Type *  base,
bool  enable 
)
Parameters
baseSPDIF base pointer
enableTrue means enable SPDIF Tx, false means disable.
static void SPDIF_RxEnable ( SPDIF_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseSPDIF base pointer
enableTrue means enable SPDIF Rx, false means disable.
static uint32_t SPDIF_GetStatusFlag ( SPDIF_Type *  base)
inlinestatic
Parameters
baseSPDIF base pointer
Returns
SPDIF status flag value. Use the _spdif_interrupt_enable_t to get the status value needed.
static void SPDIF_ClearStatusFlags ( SPDIF_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseSPDIF base pointer
maskState mask. It can be a combination of the _spdif_interrupt_enable_t member. Notice these members cannot be included, as these flags cannot be cleared by writing 1 to these bits:
  • kSPDIF_UChannelReceiveRegisterFull
  • kSPDIF_QChannelReceiveRegisterFull
  • kSPDIF_TxFIFOEmpty
  • kSPDIF_RxFIFOFull
static void SPDIF_EnableInterrupts ( SPDIF_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseSPDIF base pointer
maskinterrupt source The parameter can be a combination of the following sources if defined.
  • kSPDIF_WordStartInterruptEnable
  • kSPDIF_SyncErrorInterruptEnable
  • kSPDIF_FIFOWarningInterruptEnable
  • kSPDIF_FIFORequestInterruptEnable
  • kSPDIF_FIFOErrorInterruptEnable
static void SPDIF_DisableInterrupts ( SPDIF_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseSPDIF base pointer
maskinterrupt source The parameter can be a combination of the following sources if defined.
  • kSPDIF_WordStartInterruptEnable
  • kSPDIF_SyncErrorInterruptEnable
  • kSPDIF_FIFOWarningInterruptEnable
  • kSPDIF_FIFORequestInterruptEnable
  • kSPDIF_FIFOErrorInterruptEnable
static void SPDIF_EnableDMA ( SPDIF_Type *  base,
uint32_t  mask,
bool  enable 
)
inlinestatic
Parameters
baseSPDIF base pointer
maskSPDIF DMA enable mask, The parameter can be a combination of the following sources if defined
  • kSPDIF_RxDMAEnable
  • kSPDIF_TxDMAEnable
enableTrue means enable DMA, false means disable DMA.
static uint32_t SPDIF_TxGetLeftDataRegisterAddress ( SPDIF_Type *  base)
inlinestatic

This API is used to provide a transfer address for the SPDIF DMA transfer configuration.

Parameters
baseSPDIF base pointer.
Returns
data register address.
static uint32_t SPDIF_TxGetRightDataRegisterAddress ( SPDIF_Type *  base)
inlinestatic

This API is used to provide a transfer address for the SPDIF DMA transfer configuration.

Parameters
baseSPDIF base pointer.
Returns
data register address.
static uint32_t SPDIF_RxGetLeftDataRegisterAddress ( SPDIF_Type *  base)
inlinestatic

This API is used to provide a transfer address for the SPDIF DMA transfer configuration.

Parameters
baseSPDIF base pointer.
Returns
data register address.
static uint32_t SPDIF_RxGetRightDataRegisterAddress ( SPDIF_Type *  base)
inlinestatic

This API is used to provide a transfer address for the SPDIF DMA transfer configuration.

Parameters
baseSPDIF base pointer.
Returns
data register address.
void SPDIF_TxSetSampleRate ( SPDIF_Type *  base,
uint32_t  sampleRate_Hz,
uint32_t  sourceClockFreq_Hz 
)

The audio format can be changed at run-time. This function configures the sample rate.

Parameters
baseSPDIF base pointer.
sampleRate_HzSPDIF sample rate frequency in Hz.
sourceClockFreq_HzSPDIF tx clock source frequency in Hz.
uint32_t SPDIF_GetRxSampleRate ( SPDIF_Type *  base,
uint32_t  clockSourceFreq_Hz 
)

The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.

Parameters
baseSPDIF base pointer.
clockSourceFreq_HzSPDIF system clock frequency in hz.
void SPDIF_WriteBlocking ( SPDIF_Type *  base,
uint8_t *  buffer,
uint32_t  size 
)
Note
This function blocks by polling until data is ready to be sent.
Parameters
baseSPDIF base pointer.
bufferPointer to the data to be written.
sizeBytes to be written.
static void SPDIF_WriteLeftData ( SPDIF_Type *  base,
uint32_t  data 
)
inlinestatic
Parameters
baseSPDIF base pointer.
dataData needs to be written.
static void SPDIF_WriteRightData ( SPDIF_Type *  base,
uint32_t  data 
)
inlinestatic
Parameters
baseSPDIF base pointer.
dataData needs to be written.
static void SPDIF_WriteChannelStatusHigh ( SPDIF_Type *  base,
uint32_t  data 
)
inlinestatic
Parameters
baseSPDIF base pointer.
dataData needs to be written.
static void SPDIF_WriteChannelStatusLow ( SPDIF_Type *  base,
uint32_t  data 
)
inlinestatic
Parameters
baseSPDIF base pointer.
dataData needs to be written.
void SPDIF_ReadBlocking ( SPDIF_Type *  base,
uint8_t *  buffer,
uint32_t  size 
)
Note
This function blocks by polling until data is ready to be sent.
Parameters
baseSPDIF base pointer.
bufferPointer to the data to be read.
sizeBytes to be read.
static uint32_t SPDIF_ReadLeftData ( SPDIF_Type *  base)
inlinestatic
Parameters
baseSPDIF base pointer.
Returns
Data in SPDIF FIFO.
static uint32_t SPDIF_ReadRightData ( SPDIF_Type *  base)
inlinestatic
Parameters
baseSPDIF base pointer.
Returns
Data in SPDIF FIFO.
static uint32_t SPDIF_ReadChannelStatusHigh ( SPDIF_Type *  base)
inlinestatic
Parameters
baseSPDIF base pointer.
Returns
Data in SPDIF FIFO.
static uint32_t SPDIF_ReadChannelStatusLow ( SPDIF_Type *  base)
inlinestatic
Parameters
baseSPDIF base pointer.
Returns
Data in SPDIF FIFO.
static uint32_t SPDIF_ReadQChannel ( SPDIF_Type *  base)
inlinestatic
Parameters
baseSPDIF base pointer.
Returns
Data in SPDIF FIFO.
static uint32_t SPDIF_ReadUChannel ( SPDIF_Type *  base)
inlinestatic
Parameters
baseSPDIF base pointer.
Returns
Data in SPDIF FIFO.
void SPDIF_TransferTxCreateHandle ( SPDIF_Type *  base,
spdif_handle_t *  handle,
spdif_transfer_callback_t  callback,
void *  userData 
)

This function initializes the Tx handle for the SPDIF Tx transactional APIs. Call this function once to get the handle initialized.

Parameters
baseSPDIF base pointer
handleSPDIF handle pointer.
callbackPointer to the user callback function.
userDataUser parameter passed to the callback function
void SPDIF_TransferRxCreateHandle ( SPDIF_Type *  base,
spdif_handle_t *  handle,
spdif_transfer_callback_t  callback,
void *  userData 
)

This function initializes the Rx handle for the SPDIF Rx transactional APIs. Call this function once to get the handle initialized.

Parameters
baseSPDIF base pointer.
handleSPDIF handle pointer.
callbackPointer to the user callback function.
userDataUser parameter passed to the callback function.
status_t SPDIF_TransferSendNonBlocking ( SPDIF_Type *  base,
spdif_handle_t *  handle,
spdif_transfer_t xfer 
)
Note
This API returns immediately after the transfer initiates. Call the SPDIF_TxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_SPDIF_Busy, the transfer is finished.
Parameters
baseSPDIF base pointer.
handlePointer to the spdif_handle_t structure which stores the transfer state.
xferPointer to the spdif_transfer_t structure.
Return values
kStatus_SuccessSuccessfully started the data receive.
kStatus_SPDIF_TxBusyPrevious receive still not finished.
kStatus_InvalidArgumentThe input parameter is invalid.
status_t SPDIF_TransferReceiveNonBlocking ( SPDIF_Type *  base,
spdif_handle_t *  handle,
spdif_transfer_t xfer 
)
Note
This API returns immediately after the transfer initiates. Call the SPDIF_RxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_SPDIF_Busy, the transfer is finished.
Parameters
baseSPDIF base pointer
handlePointer to the spdif_handle_t structure which stores the transfer state.
xferPointer to the spdif_transfer_t structure.
Return values
kStatus_SuccessSuccessfully started the data receive.
kStatus_SPDIF_RxBusyPrevious receive still not finished.
kStatus_InvalidArgumentThe input parameter is invalid.
status_t SPDIF_TransferGetSendCount ( SPDIF_Type *  base,
spdif_handle_t *  handle,
size_t *  count 
)
Parameters
baseSPDIF base pointer.
handlePointer to the spdif_handle_t structure which stores the transfer state.
countBytes count sent.
Return values
kStatus_SuccessSucceed get the transfer count.
kStatus_NoTransferInProgressThere is not a non-blocking transaction currently in progress.
status_t SPDIF_TransferGetReceiveCount ( SPDIF_Type *  base,
spdif_handle_t *  handle,
size_t *  count 
)
Parameters
baseSPDIF base pointer.
handlePointer to the spdif_handle_t structure which stores the transfer state.
countBytes count received.
Return values
kStatus_SuccessSucceed get the transfer count.
kStatus_NoTransferInProgressThere is not a non-blocking transaction currently in progress.
void SPDIF_TransferAbortSend ( SPDIF_Type *  base,
spdif_handle_t *  handle 
)
Note
This API can be called any time when an interrupt non-blocking transfer initiates to abort the transfer early.
Parameters
baseSPDIF base pointer.
handlePointer to the spdif_handle_t structure which stores the transfer state.
void SPDIF_TransferAbortReceive ( SPDIF_Type *  base,
spdif_handle_t *  handle 
)
Note
This API can be called when an interrupt non-blocking transfer initiates to abort the transfer early.
Parameters
baseSPDIF base pointer
handlePointer to the spdif_handle_t structure which stores the transfer state.
void SPDIF_TransferTxHandleIRQ ( SPDIF_Type *  base,
spdif_handle_t *  handle 
)
Parameters
baseSPDIF base pointer.
handlePointer to the spdif_handle_t structure.
void SPDIF_TransferRxHandleIRQ ( SPDIF_Type *  base,
spdif_handle_t *  handle 
)
Parameters
baseSPDIF base pointer.
handlePointer to the spdif_handle_t structure.