for sophomore

Fork of VNH5019 by aigamozu

Committer:
m5171135
Date:
Wed May 28 11:54:04 2014 +0000
Revision:
1:656efbc86da4
Parent:
0:83e00dc8eb92
???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
m5171135 0:83e00dc8eb92 1 #include "VNH5019.h"
m5171135 0:83e00dc8eb92 2
m5171135 0:83e00dc8eb92 3 #include "mbed.h"
m5171135 0:83e00dc8eb92 4 #include <stdint.h>
m5171135 0:83e00dc8eb92 5 #include <math.h>
m5171135 0:83e00dc8eb92 6 #include <ctype.h>
m5171135 0:83e00dc8eb92 7
m5171135 0:83e00dc8eb92 8 //PinSetting
m5171135 0:83e00dc8eb92 9 VNH5019::VNH5019(PinName m1na,PinName m1nb,PinName m1pwm,PinName m2na,PinName m2nb,PinName m2pwm)
m5171135 0:83e00dc8eb92 10 : _m1na(m1na),_m1nb(m1nb),_m1pwm(m1pwm),_m2na(m2na),_m2nb(m2nb),_m2pwm(m2pwm){
m5171135 1:656efbc86da4 11 _m1pwm.period_us(50);
m5171135 1:656efbc86da4 12 _m2pwm.period_us(50);
m5171135 0:83e00dc8eb92 13 }
m5171135 0:83e00dc8eb92 14
m5171135 0:83e00dc8eb92 15 void VNH5019::changeSpeed(uint8_t L_state,uint8_t L_pwm,uint8_t R_state,uint8_t R_pwm){
m5171135 0:83e00dc8eb92 16
m5171135 0:83e00dc8eb92 17 switch(L_state){
m5171135 0:83e00dc8eb92 18 case 0:
m5171135 0:83e00dc8eb92 19 _m1na = 0;
m5171135 0:83e00dc8eb92 20 _m1nb = 0;
m5171135 0:83e00dc8eb92 21 break;
m5171135 0:83e00dc8eb92 22
m5171135 0:83e00dc8eb92 23 case 1:
m5171135 0:83e00dc8eb92 24 _m1na = 1;
m5171135 0:83e00dc8eb92 25 _m1nb = 0;
m5171135 0:83e00dc8eb92 26 break;
m5171135 0:83e00dc8eb92 27
m5171135 0:83e00dc8eb92 28 case 2:
m5171135 0:83e00dc8eb92 29 _m1na = 0;
m5171135 0:83e00dc8eb92 30 _m1nb = 1;
m5171135 0:83e00dc8eb92 31 break;
m5171135 0:83e00dc8eb92 32
m5171135 0:83e00dc8eb92 33 default:
m5171135 0:83e00dc8eb92 34 _m1na = 0;
m5171135 0:83e00dc8eb92 35 _m1nb = 0;
m5171135 0:83e00dc8eb92 36 break;
m5171135 0:83e00dc8eb92 37 }
m5171135 0:83e00dc8eb92 38
m5171135 0:83e00dc8eb92 39 _m1pwm = (float)L_pwm/256.0;
m5171135 0:83e00dc8eb92 40
m5171135 0:83e00dc8eb92 41 switch(R_state){
m5171135 0:83e00dc8eb92 42 case 0:
m5171135 0:83e00dc8eb92 43 _m2na = 0;
m5171135 0:83e00dc8eb92 44 _m2nb = 0;
m5171135 0:83e00dc8eb92 45 break;
m5171135 0:83e00dc8eb92 46
m5171135 0:83e00dc8eb92 47 case 1:
m5171135 0:83e00dc8eb92 48 _m2na = 1;
m5171135 0:83e00dc8eb92 49 _m2nb = 0;
m5171135 0:83e00dc8eb92 50 break;
m5171135 0:83e00dc8eb92 51
m5171135 0:83e00dc8eb92 52 case 2:
m5171135 0:83e00dc8eb92 53 _m2na = 0;
m5171135 0:83e00dc8eb92 54 _m2nb = 1;
m5171135 0:83e00dc8eb92 55 break;
m5171135 0:83e00dc8eb92 56
m5171135 0:83e00dc8eb92 57 default:
m5171135 0:83e00dc8eb92 58 _m2na = 0;
m5171135 0:83e00dc8eb92 59 _m2nb = 0;
m5171135 0:83e00dc8eb92 60 break;
m5171135 0:83e00dc8eb92 61 }
m5171135 0:83e00dc8eb92 62
m5171135 0:83e00dc8eb92 63
m5171135 0:83e00dc8eb92 64 _m2pwm = (float)R_pwm/256.0;
m5171135 0:83e00dc8eb92 65
m5171135 0:83e00dc8eb92 66 }