sf

motor.cpp

Committer:
floatlei
Date:
2016-09-27
Revision:
0:597047b3b728

File content as of revision 0:597047b3b728:


#include "motor.h"

    DigitalIn       motorguan(PB_12);
    DigitalIn       motorkai(PB_13);
    DigitalOut      motorzheng(PB_14);
    DigitalOut      motorfan(PB_15);
    
MotorCtl::MotorCtl()
{
    //motorguan.DigitalIn(PB_12);
    motorfan=0;     
    motorzheng=0;
}

unsigned short MotorCtl::open(void)
{
    unsigned short MotorTimeout=10;
    
    motorzheng=1;    //start open 

    while(MotorTimeout&&motorkai)
    {
        wait(1);
        MotorTimeout--;   
    }    
    if(motorkai==0)
            
    motorzheng=0; 

    if(MotorTimeout!=0)     
        MotorTimeout=1;       

    return MotorTimeout;   //Err   
}


unsigned short MotorCtl::close()
{
    unsigned short MotorTimeout=10;
    
    motorfan=1;

    while(MotorTimeout&&motorguan)
    {
        wait(1);
        MotorTimeout--;   
    }

    motorfan=0;
    if(motorguan==0)
    
    if(MotorTimeout!=0) //close done Err?
        MotorTimeout=1;       

    return MotorTimeout;   //Err
}