Re-examine the Xilins Driver API: Assert

xiaoxiao2021-03-06  44

I have never seen a more embarrassing ASSERT function than Xilinx's Assert, which is the hardware related to humans (in fact, I only have me) ... sweat!

#define xcomponent_is_ready 0x11111111 / * Component Has Been Initialized * / # define XComponent_is_Started 0x22222222 / * Component Has Been Started * /

#define xtest_parassed 0 # define Xtest_failed 1

#define XASSERT_NONE 0 # Define XASSERT_OCCURRED 1

Unsigned int XASSERTSTATUS; Extern Void XASSERT (CHAR *, INT); XBoolean Xwaitinassert = Xtrue; / * If this value is set to true, the XASSERT function will enter an infinite loop * /

/ * Xilinx Processor IP Reference Guide is this THE XASSERT FUNCTION CALLS A User Defined Function and Then Enters An endless. * /

TypedEf void (* xassertcallback) (int LineNumber); static xassertcallback xassertcallbackroutine = (XassertCallback) xnull;

Void Xassert (Char * file, int line) {/ * if the callback Has been set the invoke it * / if (XassertCallbackRoutine! = xnull) {(* xassertcallbackroutine) (file, line)

/ * if specified, Wait INDEFINITELY Such That The assert Will show up * in Testing * / while (xwaitinassert) {}}

/ * This macro does not return a value. It is used with Xwaitinassert, and you can fail when it is tested, and you can make the implementation continue * /

#define XASSERT_VOID (Expression) / {/ if (expression) / {/ XASSERTSTATUS = XASSERT_NONE; /} / else / {/ xassert (__ file__, __line__); / xassertstatus = XASSERT_OCCURRED; / RETURN; /} /} / * This macro return value. It is used with Xwaitinassert, and you can fail when it is tested, and you can make the implementation continue * /

#define XASSERT_NONVOID (Expression) / {/ if (expression) / {/ xassertstatus = XASSERT_NONE; /} / else / {/ xassert (__ file__, __line__); / xassertstatus = XASSERT_OCCURRED; / RETURN 0; /} /}

/ * This macro does not return a value. Place that will happen in Assert (still do not understand what to use) * /

#define XASSERT_VOID_ALWAYS () / {/ XASSERT (__ file__, __line__); / xassertstatus = XASSERT_OCCURRED; / RETURN; /}

/ * This macro is returned. Place that will happen in Assert (still do not understand what to use) * /

转载请注明原文地址:https://www.9cbs.com/read-51093.html

New Post(0)