c语言求上升沿次数,[求助]上升沿信号在C语言中怎么写啊
把下面程序拷貝到頭文件中,就可以在C中調(diào)用此函數(shù)了.
#ifndef __EDGE_H__
#define __EDGE_H__
/*****************************************************************************************/
/* EDGEPOS return 1 at positive transition of signal, in all other cases 0 is returned */
/*****************************************************************************************/
#define EDGEPOS(variable,__buffer) \
({plcbit result; \
if (variable && !__buffer) \
{ \
result=1; \
} \
else \
{ \
result=0; \
} \
__buffer=variable; \
result; \
})
/*****************************************************************************************/
/* EDGENEG return 1 at negative transition of signal, in all other cases 0 is returned */
/*****************************************************************************************/
#define EDGENEG(variable,__buffer) \
({plcbit result; \
if (!variable && __buffer) \
{ \
result=1; \
} \
else \
{ \
result=0; \
} \
__buffer=variable; \
result; \
})
/**************************************************************************************************/
/* EDGE return 1 at positive and negative transition of signal, in all other cases 0 is returned */
/**************************************************************************************************/
#define EDGE(variable,__buffer) \
({plcbit result; \
if (variable != __buffer) \
{ \
result=1; \
} \
else \
{ \
result=0; \
} \
__buffer=variable; \
result; \
})
#endif /*__EDGE_H__*/
總結(jié)
以上是生活随笔為你收集整理的c语言求上升沿次数,[求助]上升沿信号在C语言中怎么写啊的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言字符5,C语言编程(练习5:字符串
- 下一篇: 乳石牙龋齿怎么治