⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 valve.c

📁 基于avr单片机的氢气测控系统源代码
💻 C
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -