c语言求上升沿次数,[求助]上升沿信号在C语言中怎么写啊
把下面程序拷贝到头文件中,就可以在C中调用此函数了.
#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__*/
总结
以上是生活随笔为你收集整理的c语言求上升沿次数,[求助]上升沿信号在C语言中怎么写啊的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: C语言字符5,C语言编程(练习5:字符串
- 下一篇: c语言printf右移,C语言print