TER Atienza Pongnot 2019 / TLE5206_lib

Fork of TLE5206_lib by nicolas Atienza

Committer:
gpongnot
Date:
Tue Jan 29 15:32:12 2019 +0000
Revision:
0:03a724b7421c
Child:
1:1117196d767b
bibli hacheur

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gpongnot 0:03a724b7421c 1 #include "mbed.h"
gpongnot 0:03a724b7421c 2 #include "TLE5206_lib.h"
gpongnot 0:03a724b7421c 3
gpongnot 0:03a724b7421c 4 TLE5206::TLE5206(PinName IN1,PinName IN2):pwmIN1(IN1),pwmIN2(IN2){};
gpongnot 0:03a724b7421c 5
gpongnot 0:03a724b7421c 6 void TLE5206::setup(int periode_us){
gpongnot 0:03a724b7421c 7 this->pwmIN1.period_us(periode_us);
gpongnot 0:03a724b7421c 8 this->pwmIN2.period_us(periode_us);
gpongnot 0:03a724b7421c 9 }
gpongnot 0:03a724b7421c 10
gpongnot 0:03a724b7421c 11 void TLE5206::write(float duty_cycle){
gpongnot 0:03a724b7421c 12 if (duty_cycle < -1){
gpongnot 0:03a724b7421c 13 this->pwmIN1 = 1.0;
gpongnot 0:03a724b7421c 14 this->pwmIN2 = 0.0;
gpongnot 0:03a724b7421c 15 }else if (duty_cycle < 0){
gpongnot 0:03a724b7421c 16 this->pwmIN1 = -duty_cycle;
gpongnot 0:03a724b7421c 17 this->pwmIN2 = 0.0;
gpongnot 0:03a724b7421c 18 }else if (duty_cycle < 1){
gpongnot 0:03a724b7421c 19 this->pwmIN1 = 0.0;
gpongnot 0:03a724b7421c 20 this->pwmIN2 = duty_cycle;
gpongnot 0:03a724b7421c 21 }else {
gpongnot 0:03a724b7421c 22 this->pwmIN1 = 0.0;
gpongnot 0:03a724b7421c 23 this->pwmIN2 = 1.0;
gpongnot 0:03a724b7421c 24 }
gpongnot 0:03a724b7421c 25 }