valve.c
来自「基于avr单片机的氢气测控系统源代码」· C语言 代码 · 共 30 行
C
30 行
#include <avr/io.h>
#include "valve.h"
#include "global.h"
void initValve()
{
//NOTE VERY IMPORTANT.
//For the initialize we set the PORTD register.
//But we mustn't open all the valve at the beginning.
//What will happen if we do so?
//All the chemical material flows into the garbage can!!!
PORTD = 0x00;
DDRD = 0xff;
//OK, shut up all valves!!!
setValveState(0, VALVE1_OFF | VALVE2_OFF | VALVE3_OFF | VALVE4_OFF);
}
void setValveState(unsigned char on, unsigned char mask)
{
if(on == 1)
{
PORTD &= mask;
}
else if(on == 0)
{
PORTD |= mask;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?