sf
Revision 0:597047b3b728, committed 2016-09-27
- Comitter:
- floatlei
- Date:
- Tue Sep 27 09:41:43 2016 +0000
- Commit message:
- sf
Changed in this revision
motor.cpp | Show annotated file Show diff for this revision Revisions of this file |
motor.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 597047b3b728 motor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motor.cpp Tue Sep 27 09:41:43 2016 +0000 @@ -0,0 +1,57 @@ + +#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 +}
diff -r 000000000000 -r 597047b3b728 motor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motor.h Tue Sep 27 09:41:43 2016 +0000 @@ -0,0 +1,46 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mbed.h" + +#ifndef SANFAN_MOTOR_H +#define SANFAN_MOTOR_H + +#include "platform.h" + +class MotorCtl { + +public: + MotorCtl(); + + unsigned short open(void); + unsigned short close(void); + + +/* +private: + + + */ +protected: + +}; + +#endif + + + +