13#include "fsl_common.h"
26#define FSL_SPDIF_DRIVER_VERSION (MAKE_VERSION(2, 0, 6))
156#define SPDIF_XFER_QUEUE_SIZE (4U)
189#if defined(__cplusplus)
253static inline void SPDIF_TxFIFOReset(
SPDIF_Type *base)
255 base->SCR |= SPDIF_SCR_RXFIFO_RST_MASK;
265static inline void SPDIF_RxFIFOReset(
SPDIF_Type *base)
267 base->SCR |= SPDIF_SCR_RXFIFO_RST_MASK;
284static inline void SPDIF_RxEnable(
SPDIF_Type *base,
bool enable)
289 base->SCR &= ~(SPDIF_SCR_RXFIFO_CTRL_MASK | SPDIF_SCR_RXFIFO_OFF_ON_MASK);
293 base->SCR |= SPDIF_SCR_RXFIFO_OFF_ON_MASK;
310static inline uint32_t SPDIF_GetStatusFlag(
SPDIF_Type *base)
326static inline void SPDIF_ClearStatusFlags(
SPDIF_Type *base, uint32_t mask)
350static inline void SPDIF_EnableInterrupts(
SPDIF_Type *base, uint32_t mask)
367static inline void SPDIF_DisableInterrupts(
SPDIF_Type *base, uint32_t mask)
387static inline void SPDIF_EnableDMA(
SPDIF_Type *base, uint32_t mask,
bool enable)
407static inline uint32_t SPDIF_TxGetLeftDataRegisterAddress(
SPDIF_Type *base)
409 return (uint32_t)(&(base->STL));
420static inline uint32_t SPDIF_TxGetRightDataRegisterAddress(
SPDIF_Type *base)
422 return (uint32_t)(&(base->STR));
433static inline uint32_t SPDIF_RxGetLeftDataRegisterAddress(
SPDIF_Type *base)
435 return (uint32_t)(&(base->SRL));
446static inline uint32_t SPDIF_RxGetRightDataRegisterAddress(
SPDIF_Type *base)
448 return (uint32_t)(&(base->SRR));
497static inline void SPDIF_WriteLeftData(
SPDIF_Type *base, uint32_t data)
508static inline void SPDIF_WriteRightData(
SPDIF_Type *base, uint32_t data)
519static inline void SPDIF_WriteChannelStatusHigh(
SPDIF_Type *base, uint32_t data)
530static inline void SPDIF_WriteChannelStatusLow(
SPDIF_Type *base, uint32_t data)
552static inline uint32_t SPDIF_ReadLeftData(
SPDIF_Type *base)
563static inline uint32_t SPDIF_ReadRightData(
SPDIF_Type *base)
574static inline uint32_t SPDIF_ReadChannelStatusHigh(
SPDIF_Type *base)
585static inline uint32_t SPDIF_ReadChannelStatusLow(
SPDIF_Type *base)
596static inline uint32_t SPDIF_ReadQChannel(
SPDIF_Type *base)
607static inline uint32_t SPDIF_ReadUChannel(
SPDIF_Type *base)
747#if defined(__cplusplus)
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
Definition: fsl_common.h:47
@ kStatusGroup_SPDIF
Definition: fsl_common.h:147
void SPDIF_TransferAbortSend(SPDIF_Type *base, spdif_handle_t *handle)
Aborts the current send.
Definition: fsl_spdif.c:599
status_t SPDIF_TransferReceiveNonBlocking(SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_t *xfer)
Performs an interrupt non-blocking receive transfer on SPDIF.
Definition: fsl_spdif.c:492
enum _spdif_uchannel_source spdif_uchannel_source_t
SPDIF U channel source.
void SPDIF_GetDefaultConfig(spdif_config_t *config)
Sets the SPDIF configuration structure to default values.
Definition: fsl_spdif.c:156
void SPDIF_TransferTxHandleIRQ(SPDIF_Type *base, spdif_handle_t *handle)
Tx interrupt handler.
Definition: fsl_spdif.c:646
status_t SPDIF_TransferSendNonBlocking(SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_t *xfer)
Performs an interrupt non-blocking send transfer on SPDIF.
Definition: fsl_spdif.c:449
_spdif_validity_config
SPDIF tx data source.
Definition: fsl_spdif.h:98
void SPDIF_Deinit(SPDIF_Type *base)
De-initializes the SPDIF peripheral.
Definition: fsl_spdif.c:133
void SPDIF_TransferTxCreateHandle(SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_callback_t callback, void *userData)
Initializes the SPDIF Tx handle.
Definition: fsl_spdif.c:375
void SPDIF_ReadBlocking(SPDIF_Type *base, uint8_t *buffer, uint32_t size)
Receives data using a blocking method.
Definition: fsl_spdif.c:330
#define SPDIF_XFER_QUEUE_SIZE
SPDIF transfer queue size, user can refine it according to use case.
Definition: fsl_spdif.h:156
status_t SPDIF_TransferGetSendCount(SPDIF_Type *base, spdif_handle_t *handle, size_t *count)
Gets a set byte count.
Definition: fsl_spdif.c:543
void SPDIF_TxEnable(SPDIF_Type *base, bool enable)
Enables/disables the SPDIF Tx.
Definition: fsl_spdif.c:179
void SPDIF_TransferAbortReceive(SPDIF_Type *base, spdif_handle_t *handle)
Aborts the current IRQ receive.
Definition: fsl_spdif.c:623
_spdif_gain_select
SPDIF clock gain.
Definition: fsl_spdif.h:79
void SPDIF_Init(SPDIF_Type *base, const spdif_config_t *config)
Initializes the SPDIF peripheral.
Definition: fsl_spdif.c:90
_spdif_uchannel_source
SPDIF U channel source.
Definition: fsl_spdif.h:71
void(* spdif_transfer_callback_t)(SPDIF_Type *base, spdif_handle_t *handle, status_t status, void *userData)
SPDIF transfer callback prototype.
Definition: fsl_spdif.h:170
enum _spdif_gain_select spdif_gain_select_t
SPDIF clock gain.
_spdif_txempty_select
SPDIF tx FIFO EMPTY falg select, it decides when assert the tx empty flag.
Definition: fsl_spdif.h:62
void SPDIF_TransferRxHandleIRQ(SPDIF_Type *base, spdif_handle_t *handle)
Tx interrupt handler.
Definition: fsl_spdif.c:709
status_t SPDIF_TransferGetReceiveCount(SPDIF_Type *base, spdif_handle_t *handle, size_t *count)
Gets a received byte count.
Definition: fsl_spdif.c:571
void SPDIF_WriteBlocking(SPDIF_Type *base, uint8_t *buffer, uint32_t size)
Sends data using a blocking method.
Definition: fsl_spdif.c:286
enum _spdif_rxfull_select spdif_rxfull_select_t
SPDIF Rx FIFO full falg select, it decides when assert the rx full flag.
void SPDIF_TransferRxCreateHandle(SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_callback_t callback, void *userData)
Initializes the SPDIF Rx handle.
Definition: fsl_spdif.c:410
enum _spdif_tx_source spdif_tx_source_t
SPDIF tx data source.
uint32_t SPDIF_GetInstance(SPDIF_Type *base)
Get the instance number for SPDIF.
Definition: fsl_spdif.c:58
enum _spdif_validity_config spdif_validity_config_t
SPDIF tx data source.
void SPDIF_TxSetSampleRate(SPDIF_Type *base, uint32_t sampleRate_Hz, uint32_t sourceClockFreq_Hz)
Configures the SPDIF Tx sample rate.
Definition: fsl_spdif.c:209
struct _spdif_config spdif_config_t
SPDIF user configuration structure.
_spdif_tx_source
SPDIF tx data source.
Definition: fsl_spdif.h:91
struct _spdif_transfer spdif_transfer_t
SPDIF transfer structure.
_spdif_rxfull_select
SPDIF Rx FIFO full falg select, it decides when assert the rx full flag.
Definition: fsl_spdif.h:53
uint32_t SPDIF_GetRxSampleRate(SPDIF_Type *base, uint32_t clockSourceFreq_Hz)
Configures the SPDIF Rx audio format.
Definition: fsl_spdif.c:256
enum _spdif_txempty_select spdif_txempty_select_t
SPDIF tx FIFO EMPTY falg select, it decides when assert the tx empty flag.
@ kSPDIF_validityFlagAlwaysClear
Definition: fsl_spdif.h:100
@ kSPDIF_validityFlagAlwaysSet
Definition: fsl_spdif.h:99
@ kSPDIF_RxDMAEnable
Definition: fsl_spdif.h:136
@ kSPDIF_TxDMAEnable
Definition: fsl_spdif.h:137
@ kSPDIF_GAIN_3
Definition: fsl_spdif.h:86
@ kSPDIF_GAIN_6
Definition: fsl_spdif.h:84
@ kSPDIF_GAIN_4
Definition: fsl_spdif.h:85
@ kSPDIF_GAIN_16
Definition: fsl_spdif.h:81
@ kSPDIF_GAIN_8
Definition: fsl_spdif.h:83
@ kSPDIF_GAIN_24
Definition: fsl_spdif.h:80
@ kSPDIF_GAIN_12
Definition: fsl_spdif.h:82
@ kSPDIF_RxParityBitError
Definition: fsl_spdif.h:112
@ kSPDIF_RxFIFOError
Definition: fsl_spdif.h:119
@ kSPDIF_LockLoss
Definition: fsl_spdif.h:121
@ kSPDIF_UChannelReceiveRegisterOverrun
Definition: fsl_spdif.h:114
@ kSPDIF_RxControlChannelChange
Definition: fsl_spdif.h:109
@ kSPDIF_QChannelReceiveRegisterOverrun
Definition: fsl_spdif.h:116
@ kSPDIF_UQChannelSync
Definition: fsl_spdif.h:117
@ kSPDIF_TxFIFOError
Definition: fsl_spdif.h:107
@ kSPDIF_ValidityFlagNoGood
Definition: fsl_spdif.h:110
@ kSPDIF_QChannelReceiveRegisterFull
Definition: fsl_spdif.h:115
@ kSPDIF_TxFIFOEmpty
Definition: fsl_spdif.h:122
@ kSPDIF_RxFIFOFull
Definition: fsl_spdif.h:123
@ kSPDIF_RxIllegalSymbol
Definition: fsl_spdif.h:111
@ kSPDIF_RxDPLLLocked
Definition: fsl_spdif.h:106
@ kSPDIF_UQChannelFrameError
Definition: fsl_spdif.h:118
@ kSPDIF_UChannelReceiveRegisterFull
Definition: fsl_spdif.h:113
@ kSPDIF_RxFIFOResync
Definition: fsl_spdif.h:120
@ kSPDIF_TxFIFOResync
Definition: fsl_spdif.h:108
@ kSPDIF_AllInterrupt
Definition: fsl_spdif.h:124
@ kSPDIF_UChannelFromTx
Definition: fsl_spdif.h:74
@ kSPDIF_UChannelFromRx
Definition: fsl_spdif.h:73
@ kSPDIF_NoUChannel
Definition: fsl_spdif.h:72
@ kSPDIF_TxEmpty4Samples
Definition: fsl_spdif.h:64
@ kSPDIF_TxEmpty0Sample
Definition: fsl_spdif.h:63
@ kSPDIF_TxEmpty12Samples
Definition: fsl_spdif.h:66
@ kSPDIF_TxEmpty8Samples
Definition: fsl_spdif.h:65
@ kStatus_SPDIF_UChannelOverrun
Definition: fsl_spdif.h:39
@ kStatus_SPDIF_RxDPLLLocked
Definition: fsl_spdif.h:32
@ kStatus_SPDIF_TxFIFOResync
Definition: fsl_spdif.h:34
@ kStatus_SPDIF_QChannelOverrun
Definition: fsl_spdif.h:40
@ kStatus_SPDIF_RxFIFOError
Definition: fsl_spdif.h:43
@ kStatus_SPDIF_RxCnew
Definition: fsl_spdif.h:35
@ kStatus_SPDIF_TxFIFOError
Definition: fsl_spdif.h:33
@ kStatus_SPDIF_RxIllegalSymbol
Definition: fsl_spdif.h:37
@ kStatus_SPDIF_UQChannelSync
Definition: fsl_spdif.h:41
@ kStatus_SPDIF_TxIdle
Definition: fsl_spdif.h:46
@ kStatus_SPDIF_ValidatyNoGood
Definition: fsl_spdif.h:36
@ kStatus_SPDIF_QueueFull
Definition: fsl_spdif.h:48
@ kStatus_SPDIF_LockLoss
Definition: fsl_spdif.h:45
@ kStatus_SPDIF_RxFIFOResync
Definition: fsl_spdif.h:44
@ kStatus_SPDIF_RxIdle
Definition: fsl_spdif.h:47
@ kStatus_SPDIF_UQChannelFrameError
Definition: fsl_spdif.h:42
@ kStatus_SPDIF_RxParityBitError
Definition: fsl_spdif.h:38
@ kSPDIF_txNormal
Definition: fsl_spdif.h:93
@ kSPDIF_txFromReceiver
Definition: fsl_spdif.h:92
@ kSPDIF_RxFull8Samples
Definition: fsl_spdif.h:56
@ kSPDIF_RxFull4Samples
Definition: fsl_spdif.h:55
@ kSPDIF_RxFull16Samples
Definition: fsl_spdif.h:57
@ kSPDIF_RxFull1Sample
Definition: fsl_spdif.h:54
Definition: MIMXRT1052.h:42276
SPDIF user configuration structure.
Definition: fsl_spdif.h:142
uint8_t txClkSource
Definition: fsl_spdif.h:146
uint8_t DPLLClkSource
Definition: fsl_spdif.h:145
spdif_gain_select_t gain
Definition: fsl_spdif.h:152
bool isRxAutoSync
Definition: fsl_spdif.h:144
spdif_tx_source_t txSource
Definition: fsl_spdif.h:150
spdif_validity_config_t validityConfig
Definition: fsl_spdif.h:151
spdif_txempty_select_t txFullSelect
Definition: fsl_spdif.h:148
bool isTxAutoSync
Definition: fsl_spdif.h:143
spdif_rxfull_select_t rxFullSelect
Definition: fsl_spdif.h:147
spdif_uchannel_source_t uChannelSrc
Definition: fsl_spdif.h:149
SPDIF handle structure.
Definition: fsl_spdif.h:174
uint8_t watermark
Definition: fsl_spdif.h:182
size_t transferSize[SPDIF_XFER_QUEUE_SIZE]
Definition: fsl_spdif.h:179
uint32_t state
Definition: fsl_spdif.h:175
volatile uint8_t queueUser
Definition: fsl_spdif.h:180
spdif_transfer_callback_t callback
Definition: fsl_spdif.h:176
void * userData
Definition: fsl_spdif.h:177
volatile uint8_t queueDriver
Definition: fsl_spdif.h:181
spdif_transfer_t spdifQueue[SPDIF_XFER_QUEUE_SIZE]
Definition: fsl_spdif.h:178
SPDIF transfer structure.
Definition: fsl_spdif.h:160
size_t dataSize
Definition: fsl_spdif.h:164
uint8_t * udata
Definition: fsl_spdif.h:163
uint8_t * qdata
Definition: fsl_spdif.h:162
uint8_t * data
Definition: fsl_spdif.h:161
Definition: deflate.c:114
unsigned size
Definition: tte.h:1