loliruyu
Diff: vnh_2sp30.cpp
- Revision:
- 0:d7f40a9a9020
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vnh_2sp30.cpp Wed Mar 28 16:18:22 2018 +0000 @@ -0,0 +1,30 @@ +#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); + } \ No newline at end of file