spdif
Xilinx SDK Drivers API Documentation
Xspdif_v1_0

Data Structures

struct  XSpdif_Config
 This typedef contains configuration information for the XSpdif. More...
 
struct  XSpdif
 The XSpdif driver instance data. More...
 

Typedefs

typedef void(* XSpdif_Callback )(void *CallbackRef)
 Callback function data type for handling interrupt requests from the XSpdif peripheral. More...
 

Functions

XSpdif_ConfigXSpdif_LookupConfig (u16 DeviceId)
 This function returns a reference to an XSpdif_Config structure based on the core id, DeviceId. More...
 
int XSpdif_Initialize (XSpdif *InstancePtr, u16 DeviceId)
 Initializes a specific Xspdif instance such that the driver is ready to use. More...
 
int XSpdif_CfgInitialize (XSpdif *InstancePtr, XSpdif_Config *CfgPtr, UINTPTR EffectiveAddr)
 This function initializes the XSpdif. More...
 
void XSpdif_Enable (XSpdif *InstancePtr, u8 Enable)
 This function enables/disables the XSpdif. More...
 
void XSpdif_SetClkConfig (XSpdif *InstancePtr, u8 Clk_DivNum)
 This function sets the clock configuration bits. More...
 
u32 XSpdif_GetFs (XSpdif *InstancePtr, u32 AudClk)
 This function calculates the Sampling Frequency (Fs) and returns it's value. More...
 
void XSpdif_SoftReset (XSpdif *InstancePtr)
 This function is used to soft reset the interrupt registers. More...
 
void XSpdif_ResetFifo (XSpdif *InstancePtr)
 This function resets the Fifo. More...
 
void XSpdif_IntrHandler (void *InstancePtr)
 This function is the interrupt handler for the XSpdif driver. More...
 
int XSpdif_SetHandler (XSpdif *InstancePtr, XSpdif_HandlerType HandlerType, XSpdif_Callback FuncPtr, void *CallbackRef)
 This function installs an asynchronous callback function for the given HandlerType: More...
 
void XSpdif_Rx_GetChStat (XSpdif *InstancePtr, u8 *ChStatBuf)
 This function reads all the Channel Status registers and writes to a buffer. More...
 
void XSpdif_Rx_GetChA_UserData (XSpdif *InstancePtr, u8 *ChA_UserDataBuf)
 This function reads the Channel A user data and writes to a buffer. More...
 
void XSpdif_Rx_GetChB_UserData (XSpdif *InstancePtr, u8 *ChB_UserDataBuf)
 This function reads the Channel B user data and writes to a buffer. More...
 

Handler Types

enum  XSpdif_HandlerType {
  XSPDIF_HANDLER_TX_OR_RX_FIFO_FULL = 0, XSPDIF_HANDLER_TX_OR_RX_FIFO_EMPTY, XSPDIF_HANDLER_START_OF_BLOCK, XSPDIF_HANDLER_BMC_ERROR,
  XSPDIF_HANDLER_PREAMBLE_ERROR, XSPDIF_NUM_HANDLERS
}
 These constants specify different types of handlers and is used to differentiate interrupt requests from the XSpdif peripheral. More...
 

Typedef Documentation

typedef void(* XSpdif_Callback)(void *CallbackRef)

Callback function data type for handling interrupt requests from the XSpdif peripheral.

The application using this driver is expected to define a handler of this type to support interrupt driven mode. The handler is called in an interrupt context such that minimal processing should be performed.

Parameters
CallBackRefis a callback reference passed in by the upper layer when setting the callback functions, and passed back to the upper layer when the callback is invoked.
Returns
None
Note
None

Enumeration Type Documentation

These constants specify different types of handlers and is used to differentiate interrupt requests from the XSpdif peripheral.

Enumerator
XSPDIF_HANDLER_TX_OR_RX_FIFO_FULL 

Transmitter or Receiver FIFO Full Handler.

XSPDIF_HANDLER_TX_OR_RX_FIFO_EMPTY 

Transmitter or Receiver FIFO Empty Handler.

XSPDIF_HANDLER_START_OF_BLOCK 

Start of Block Handler.

XSPDIF_HANDLER_BMC_ERROR 

BMC error.

XSPDIF_HANDLER_PREAMBLE_ERROR 

Preamble error.

XSPDIF_NUM_HANDLERS 

Number of handler types.

Function Documentation

int XSpdif_CfgInitialize ( XSpdif InstancePtr,
XSpdif_Config CfgPtr,
UINTPTR  EffectiveAddr 
)

This function initializes the XSpdif.

This function must be called prior to using the core. Initialization of the XSpdif includes setting up the instance data, and ensuring the hardware is in a quiescent state.

Parameters
InstancePtris a pointer to the XSpdif instance.
CfgPtrpoints to the configuration structure associated with the XSpdif.
EffectiveAddris the base address of the device. If address translation is being used, then this parameter must reflect the virtual base address. Otherwise, the physical address should be used.
Returns
  • XST_SUCCESS : if successful.
  • XST_FAILURE : if version mismatched.
Note
None.

References XSpdif_Config::BaseAddress, XSpdif::Config, XSpdif::IsReady, and XSpdif_Enable().

Referenced by SpdifSelfTestExample(), and XSpdif_Initialize().

void XSpdif_Enable ( XSpdif InstancePtr,
u8  Enable 
)

This function enables/disables the XSpdif.

Parameters
InstancePtris a pointer to the XSpdif instance.
Enablespecifies TRUE/FALSE value to either enable or disable the XSpdif.
Returns
None.

References XSpdif_Config::BaseAddress, XSpdif::Config, XSpdif::IsStarted, XSPDIF_CONTROL_REGISTER_OFFSET, XSPDIF_CORE_ENABLE_MASK, XSpdif_ReadReg, and XSpdif_WriteReg.

Referenced by XSpdif_CfgInitialize().

u32 XSpdif_GetFs ( XSpdif InstancePtr,
u32  AudClk 
)

This function calculates the Sampling Frequency (Fs) and returns it's value.

Parameters
InstancePtris a pointer to the XSpdif instance.
AudClkis the audio clock frequency value in Hz.
Returns
- Returns the sampling frequency value in Hz.

References XSpdif_Config::BaseAddress, XSpdif::Config, XSpdif_ReadReg, XSPDIF_SAMPLE_CLOCK_COUNT_MASK, and XSPDIF_STATUS_REGISTER_OFFSET.

int XSpdif_Initialize ( XSpdif InstancePtr,
u16  DeviceId 
)

Initializes a specific Xspdif instance such that the driver is ready to use.

Parameters
InstancePtris a pointer to the XSpdif instance to be worked on.
DeviceIdis the unique id of the device controlled by this XSpdif instance. Passing in a device id associates the generic XSpdif instance to a specific device, as chosen by the caller or application developer.
Returns
  • XST_SUCCESS if successful.
  • XST_DEVICE_NOT_FOUND if the device was not found in the configuration such that initialization could not be accomplished.
  • XST_FAILURE if version mismatched

References XSpdif_Config::BaseAddress, XSpdif_CfgInitialize(), and XSpdif_LookupConfig().

void XSpdif_IntrHandler ( void *  InstancePtr)
XSpdif_Config* XSpdif_LookupConfig ( u16  DeviceId)

This function returns a reference to an XSpdif_Config structure based on the core id, DeviceId.

The return value will refer to an entry in the device configuration table defined in the xspdif_g.c file.

Parameters
DeviceIdis the unique core ID of the XSpdif core for the lookup operation.
Returns
returns a reference to a config record in the configuration table corresponding to DeviceId, or NULL if no match is found.
Note
None.

Referenced by SpdifSelfTestExample(), and XSpdif_Initialize().

void XSpdif_ResetFifo ( XSpdif InstancePtr)

This function resets the Fifo.

Parameters
InstancePtris a pointer to the XSpdif instance.
Returns
None.

References XSpdif_Config::BaseAddress, XSpdif::Config, XSPDIF_CONTROL_REGISTER_OFFSET, XSPDIF_CORE_ENABLE_MASK, XSpdif_ReadReg, and XSpdif_WriteReg.

void XSpdif_Rx_GetChA_UserData ( XSpdif InstancePtr,
u8 *  ChA_UserDataBuf 
)

This function reads the Channel A user data and writes to a buffer.

Parameters
InstancePtris a pointer to the XSPDIF instance.
ChA_UserDataBufis a pointer to a buffer.
Returns
None.

References XSpdif_Config::BaseAddress, XSpdif::Config, XSPDIF_CHANNEL_A_USER_DATA_REGISTER0_OFFSET, and XSpdif_ReadReg.

void XSpdif_Rx_GetChB_UserData ( XSpdif InstancePtr,
u8 *  ChB_UserDataBuf 
)

This function reads the Channel B user data and writes to a buffer.

Parameters
InstancePtris a pointer to the XSPDIF instance.
ChB_UserDataBufis a pointer to a buffer.
Returns
None.

References XSpdif_Config::BaseAddress, XSpdif::Config, XSPDIF_CHANNEL_B_USER_DATA_REGISTER0_OFFSET, and XSpdif_ReadReg.

void XSpdif_Rx_GetChStat ( XSpdif InstancePtr,
u8 *  ChStatBuf 
)

This function reads all the Channel Status registers and writes to a buffer.

Parameters
InstancePtris a pointer to the XSpdif instance.
ChStatBufis a pointer to a buffer.
Returns
None.

References XSpdif_Config::BaseAddress, XSpdif::Config, XSPDIF_CHANNEL_STATUS_REGISTER0_OFFSET, and XSpdif_ReadReg.

void XSpdif_SetClkConfig ( XSpdif InstancePtr,
u8  Clk_DivNum 
)

This function sets the clock configuration bits.

Parameters
InstancePtris a pointer to the Spdif instance.
Clk_DivNumis the clock division number. Clk_DivNum value can be only 4,8,16,24,32,48,or 64.
Returns
-none

References XSpdif_Config::BaseAddress, XSpdif::Config, XSPDIF_CLK_16, XSPDIF_CLK_24, XSPDIF_CLK_32, XSPDIF_CLK_4, XSPDIF_CLK_48, XSPDIF_CLK_64, XSPDIF_CLK_8, XSPDIF_CLOCK_CONFIG_BITS_MASK, XSPDIF_CLOCK_CONFIG_BITS_SHIFT, XSPDIF_CONTROL_REGISTER_OFFSET, XSpdif_ReadReg, and XSpdif_WriteReg.

int XSpdif_SetHandler ( XSpdif InstancePtr,
XSpdif_HandlerType  HandlerType,
XSpdif_Callback  FuncPtr,
void *  CallbackRef 
)

This function installs an asynchronous callback function for the given HandlerType:

HandlerType                              Callback Function
--------------------------------         ----------------------------------
(XSPDIF_HANDLER_START_OF_BLOCK)          StartOfBlockHandler
(XSPDIF_HANDLE_PREAMBLE_ERROR)           PreambleErrHandler
(XSPDIF_HANDLE_BMC_ERROR)                   BmcErrHandler
(XSPDIF_HANDLER_TX_OR_RX_FIFO_EMPTY)     TxOrRxFifoEmptyHandler
(XSPDIF_HANDLER_TX_OR_RX_FIFO_FULL)         TxOrRxFifoFullHandler
Parameters
InstancePtris a pointer to the XSpdif core instance.
HandlerTypespecifies the type of handler.
FuncPtris a pointer to the callback function.
CallbackRefis a reference pointer passed on actual calling of the callback function.
Returns
  • XST_SUCCESS if callback function installed successfully.
  • XST_INVALID_PARAM when HandlerType is invalid.
Note
Invoking this function for a handler that already has been installed replaces it with the new handler.

References XSpdif::BmcErrHandler, XSpdif::BmcErrHandlerRef, XSpdif::PreambleErrHandler, XSpdif::PreambleErrHandlerRef, XSpdif::StartOfBlockHandler, XSpdif::StartOfBlockHandlerRef, XSpdif::TxOrRxFifoEmptyHandler, XSpdif::TxOrRxFifoEmptyHandlerRef, XSpdif::TxOrRxFifoFullHandler, XSpdif::TxOrRxFifoFullHandlerRef, XSPDIF_HANDLER_BMC_ERROR, XSPDIF_HANDLER_PREAMBLE_ERROR, XSPDIF_HANDLER_START_OF_BLOCK, XSPDIF_HANDLER_TX_OR_RX_FIFO_EMPTY, XSPDIF_HANDLER_TX_OR_RX_FIFO_FULL, and XSPDIF_NUM_HANDLERS.

void XSpdif_SoftReset ( XSpdif InstancePtr)

This function is used to soft reset the interrupt registers.

Parameters
InstancePtris a pointer to the XSPDIF instance.
Returns
None.

References XSpdif_Config::BaseAddress, XSpdif::Config, XSPDIF_SOFT_RESET_REGISTER_OFFSET, XSPDIF_SOFT_RESET_REGISTER_VALUE, and XSpdif_WriteReg.