dp: rx: Added timer functionality.
Signed-off-by: Andrei-Liviu Simion <andrei.simion@xilinx.com>
This commit is contained in:
parent
b3a492d02a
commit
bd16c255da
4 changed files with 95 additions and 6 deletions
|
@ -49,6 +49,11 @@
|
|||
|
||||
#include "xdprx.h"
|
||||
#include "xstatus.h"
|
||||
#if defined(__arm__)
|
||||
#include "sleep.h"
|
||||
#elif defined(__MICROBLAZE__)
|
||||
#include "microblaze_sleep.h"
|
||||
#endif
|
||||
|
||||
/**************************** Function Definitions ****************************/
|
||||
|
||||
|
@ -106,3 +111,77 @@ void XDprx_CfgInitialize(XDprx *InstancePtr, XDp_Config *ConfigPtr,
|
|||
|
||||
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* This function installs a custom delay/sleep function to be used by the XDprx
|
||||
* driver.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDprx instance.
|
||||
* @param CallbackFunc is the address to the callback function.
|
||||
* @param CallbackRef is the user data item (microseconds to delay) that
|
||||
* will be passed to the custom sleep/delay function when it is
|
||||
* invoked.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*******************************************************************************/
|
||||
void XDprx_SetUserTimerHandler(XDprx *InstancePtr,
|
||||
XDp_TimerHandler CallbackFunc, void *CallbackRef)
|
||||
{
|
||||
/* Verify arguments. */
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(CallbackFunc != NULL);
|
||||
Xil_AssertVoid(CallbackRef != NULL);
|
||||
|
||||
InstancePtr->UserTimerWaitUs = CallbackFunc;
|
||||
InstancePtr->UserTimerPtr = CallbackRef;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* This function is the delay/sleep function for the XDprx driver. For the Zynq
|
||||
* family, there exists native sleep functionality. For MicroBlaze however,
|
||||
* there does not exist such functionality. In the MicroBlaze case, the default
|
||||
* method for delaying is to use a predetermined amount of loop iterations. This
|
||||
* method is prone to inaccuracy and dependent on system configuration; for
|
||||
* greater accuracy, the user may supply their own delay/sleep handler, pointed
|
||||
* to by InstancePtr->UserTimerWaitUs, which may have better accuracy if a
|
||||
* hardware timer is used.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDprx instance.
|
||||
* @param MicroSeconds is the number of microseconds to delay/sleep for.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*******************************************************************************/
|
||||
void XDprx_WaitUs(XDprx *InstancePtr, u32 MicroSeconds)
|
||||
{
|
||||
/* Verify arguments. */
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
if (MicroSeconds == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(__MICROBLAZE__)
|
||||
if (InstancePtr->UserTimerWaitUs != NULL) {
|
||||
/* Use the timer handler specified by the user for better
|
||||
* accuracy. */
|
||||
InstancePtr->UserTimerWaitUs(InstancePtr, MicroSeconds);
|
||||
}
|
||||
else {
|
||||
/* MicroBlaze sleep only has millisecond accuracy. Round up. */
|
||||
u32 MilliSeconds = (MicroSeconds + 999) / 1000;
|
||||
MB_Sleep(MilliSeconds);
|
||||
}
|
||||
#elif defined(__arm__)
|
||||
/* Wait the requested amount of time. */
|
||||
usleep(MicroSeconds);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -76,12 +76,22 @@ typedef struct {
|
|||
ready. */
|
||||
XDprx_LinkConfig LinkConfig; /**< Configuration structure for
|
||||
the main link. */
|
||||
XDp_TimerHandler UserTimerWaitUs; /**< Custom user function for
|
||||
delay/sleep. */
|
||||
void *UserTimerPtr; /**< Pointer to a timer instance
|
||||
used by the custom user
|
||||
delay/sleep function. */
|
||||
} XDprx;
|
||||
|
||||
/**************************** Function Prototypes *****************************/
|
||||
|
||||
/* xdptx.c: Setup and initialization functions. */
|
||||
/* xdprx.c: Setup and initialization functions. */
|
||||
void XDprx_CfgInitialize(XDprx *InstancePtr, XDp_Config *ConfigPtr,
|
||||
u32 EffectiveAddr);
|
||||
|
||||
/* xdprx.c: General usage functions. */
|
||||
void XDprx_SetUserTimerHandler(XDprx *InstancePtr,
|
||||
XDp_TimerHandler CallbackFunc, void *CallbackRef);
|
||||
void XDprx_WaitUs(XDprx *InstancePtr, u32 MicroSeconds);
|
||||
|
||||
#endif /* XDPRX_H_ */
|
||||
|
|
|
@ -59,10 +59,10 @@
|
|||
|
||||
#include "xdptx.h"
|
||||
#include "xstatus.h"
|
||||
#if defined(__MICROBLAZE__)
|
||||
#include "microblaze_sleep.h"
|
||||
#elif defined(__arm__)
|
||||
#if defined(__arm__)
|
||||
#include "sleep.h"
|
||||
#elif defined(__MICROBLAZE__)
|
||||
#include "microblaze_sleep.h"
|
||||
#endif
|
||||
#include "xenv.h"
|
||||
|
||||
|
@ -1332,7 +1332,7 @@ void XDptx_ResetPhy(XDptx *InstancePtr, u32 Reset)
|
|||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* This function installs a custom delay/sleep function to be used by the XDdptx
|
||||
* This function installs a custom delay/sleep function to be used by the XDptx
|
||||
* driver.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDptx instance.
|
||||
|
|
|
@ -604,9 +604,9 @@ u32 XDptx_IsConnected(XDptx *InstancePtr);
|
|||
void XDptx_EnableMainLink(XDptx *InstancePtr);
|
||||
void XDptx_DisableMainLink(XDptx *InstancePtr);
|
||||
void XDptx_ResetPhy(XDptx *InstancePtr, u32 Reset);
|
||||
void XDptx_WaitUs(XDptx *InstancePtr, u32 MicroSeconds);
|
||||
void XDptx_SetUserTimerHandler(XDptx *InstancePtr,
|
||||
XDp_TimerHandler CallbackFunc, void *CallbackRef);
|
||||
void XDptx_WaitUs(XDptx *InstancePtr, u32 MicroSeconds);
|
||||
|
||||
/* xdptx_spm.c: Stream policy maker functions. */
|
||||
void XDptx_CfgMsaRecalculate(XDptx *InstancePtr, u8 Stream);
|
||||
|
|
Loading…
Add table
Reference in a new issue