我正在尝试对 N2HET 进行编程以输出脉冲脚本。 该脚本将是80位开启或关闭的序列。 请注意、奇数位始终为零、并且它们不会显示在下面的脚本中。 将有四个脚本。 默认情况是空闲状态、不需要发送脚本。 应用将需要发送其所需操作的 NHET。
脚本1:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1.
脚本2:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1
脚本3:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1.
脚本2:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 1 1
如果我要用 C 语言编写此代码、我可能会编写如下内容:
typedef enum send_pulse_script
{
SEND_PULSE_script_none=0、
SEND_PULSE_script_1、
SEND_PULSE_script_2、
SEND_PULSE_script_3、
SEND_PULSE_script_4
}send_pulse_script_t;
静态 send_pulse_script_t pulse_script = send_pulse_script_none;
静态 int nCounter = 0;
空 NHET_Loop (空)
{
if (pulate_script =send_pulse_script_none)
{
返回;
}
//奇数计数始终为零
if (nCounter %2 ==1) gioSetBit (hetPORT1、18、0);
//前导码
否则、如果(nCounter <= 48) gioSetBit (hetPORT1、18、0);
否则、如果(nCounter = 50) gioSetBit (hetPORT1、18、1);
否则、如果(nCounter = 52) gioSetBit (hetPORT1、18、1);
否则、如果(nCounter = 54) gioSetBit (hetPORT1、18、0);
//地址
否则、如果(nCounter = 56 || nCounter = 58 || nCounter = 60)
{
if (pulate_script =send_pulse_script_1 || pulse_script =send_pulse_script_2 )
{
gioSetBit (hetPORT1、18、0);
}
else // pulse_script =send_pulse_script_3 || pulse_script =send_pulse_script_4
{
gioSetBit (hetPORT1、18、1);
}
}
//命令
否则、如果(nCounter = 62) gioSetBit (hetPORT1、18、0);
否则、如果(nCounter = 64) gioSetBit (hetPORT1、18、0);
如果(nCounter = 66)则为其他值
{
if (pulate_script =send_pulse_script_1 || pulse_script =send_pulse_script_3 )
{
gioSetBit (hetPORT1、18、1);
}
else // pulse_script =send_pulse_script_2 || pulse_script =send_pulse_script_4
{
gioSetBit (hetPORT1、18、0);
}
}
否则、如果(nCounter = 68) gioSetBit (hetPORT1、18、1);
//结束
否则、如果(nCounter = 70) gioSetBit (hetPORT1、18、1);
否则、如果(nCounter = 72) gioSetBit (hetPORT1、18、1);
否则、如果(nCounter = 74) gioSetBit (hetPORT1、18、1);
否则、如果(nCounter = 76) gioSetBit (hetPORT1、18、1);
否则、如果(nCounter = 78) gioSetBit (hetPORT1、18、1);
IF (nCounter >= 80)
{
//脚本完成,重新初始化下一条消息
gioSetBit (hetPORT1、18、1);
PULSE_script = SEND_PULSE_STEFLE_NONE;
nCounter = 0;
}
其他
{
nCounter++;
}
}
void SetPulseScript (send_pulse_script_t 脚本)
{
PULSE_script =脚本;
}
SEND_PULSE_script_t GetPulseScript (void)
{
返回 PULSE_script;
}
我将如何在 HET 指令中写入此内容?
感谢您的帮助!
Ken