relay.c
来自「制袋机程序.rar」· C语言 代码 · 共 74 行
C
74 行
/***************************************
* 文件名:Relay.c
* 描述:
* 最后修改时间:2010.4.15
****************************************/
#include "INCLUDES.H"
//====================================================================================
//函数名称:void SetRealyStatus(uchar index, bool bClosed)
//函数功能:设置继电器状态
//入口参数:index[in]:继电器编号(1~16),bClosed[in]:true触点闭合,false触点打开
//出口参数:无
//====================================================================================
void SetRealyStatus(uchar index, bool bClosed)
{
if(index <= 8)
{
if(bClosed)
{
g_Status.Relay_Status1 &= ~(1<<(index-1));
g_Status.Relay_Status1 |= (1<<(index-1));
}
else
{
g_Status.Relay_Status1 &= ~(1<<(index-1));
g_Status.Relay_Status1 |= (0<<(index-1));
}
RELAYOUT1 = g_Status.Relay_Status1;
}
else if(index <= 16)
{
if(bClosed)
{
g_Status.Relay_Status2 &= ~(1<<(index-9));
g_Status.Relay_Status2 |= (1<<(index-9));
}
else
{
g_Status.Relay_Status2 &= ~(1<<(index-9));
g_Status.Relay_Status2 |= (0<<(index-9));
}
RELAYOUT2 = g_Status.Relay_Status2;
}
else
{
//do nothing
}
}
bool GetRealyStatus(uchar index)
{
if(index <= 8)
{
if(g_Status.Relay_Status1 & (1<<(index-1)))
return true;
else
return false;
}
else if(index <= 16)
{
if(g_Status.Relay_Status1 & (1<<(index-9)))
return true;
else
return false;
}
else
{
//do nothing
return false;
}
return false;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?