关于Assert断言产生的死循环,导致程序未执行的问题

XGpioPs_SetDirection(Gpio,0x7,0x01);

I am designed to write XGpioPs_SetDirectionPin(Gpio,0x07,0x01) but make a mistake !

The driver api will check the validity of parameters:

Xil_AssertVoid(InstancePtr != NULL);

    Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);

    Xil_AssertVoid(Pin < XGPIOPS_DEVICE_MAX_PIN_NUM);

    Xil_AssertVoid((Direction == 0) || (Direction == 1));

Go into sentence: Xil_AssertVoid(Pin < XGPIOPS_DEVICE_MAX_PIN_NUM);

if (Expression) { \

Xil_AssertStatus = XIL_ASSERT_NONE; \

} else { \

Xil_Assert(__FILE__, __LINE__); \

Xil_AssertStatus = XIL_ASSERT_OCCURRED; \

return; \

}

Once the parameters occur false and the following 2 sentences will be executed:

Xil_Assert(__FILE__, __LINE__);

Xil_AssertStatus = XIL_ASSERT_OCCURRED;

It just set the Xil_AssertStatus flag and transform the error location information to the specified routes.

void Xil_Assert(const char *File, int Line)

{

    /* if the callback has been set then invoke it */

    if (Xil_AssertCallbackRoutine != 0) {

        (*Xil_AssertCallbackRoutine)(File, Line);

    }

 

    /* if specified, wait indefinitely such that the assert will show up

     * in testing

     */

    while (Xil_AssertWait) {

    }

}

Once the routes equal 0, that's no route being set, just run endless loop.

So if you application seems go away but no error message has been output or the specified flow has not been executed, just to think about the

ASSERT loop.

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/dragen/archive/2013/06/13/3134095.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值