loliruyu

vnh_2sp30.cpp

Committer:
Osgoth
Date:
2018-03-28
Revision:
0:d7f40a9a9020

File content as of revision 0:d7f40a9a9020:

#include <vnh_2sp30.h>
#include <vnh_2sp30_conf.h>
#include <mbed.h>

vnh_2sp30::vnh_2sp30(){
    ENA = new digitalOut(ENA_PIN);
    ENB = new digitalOut(ENB_PIN);
    PWM = new PwmOut (PWM_PIN);
    CS = new analogIn (CS_PIN);
    t = new Ticker (&update, 1/freq);
    
    }
    vnh_2sp30::set_vel(float vel){
        this.vel = vel;
        }
    vnh_2sp30::set_dir(int dir){
        this.dir = dir;
        }
    vnh_2sp30::set_acc(float acc){
        this.acc = acc;
        }
    vnh_2sp30::update(){
        if(dir == 0x1){
             ENA = 0; ENB = 1;
             }
        if(dir == 0x0){
            ENA = 1; ENB = 0;
            }
            PWM.period (PWM_PERIOD);
        }