correction lib

Fork of TLE5206_lib by nicolas Atienza

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TLE5206_lib.cpp Source File

TLE5206_lib.cpp

00001 #include "mbed.h"
00002 #include "TLE5206_lib.h"
00003 
00004 TLE5206::TLE5206(PinName IN1,PinName IN2):pwmIN1(IN1),pwmIN2(IN2){};
00005 
00006 void TLE5206::setup(int periode_us){
00007     this->pwmIN1.period_us(periode_us);
00008     this->pwmIN2.period_us(periode_us);    
00009 }
00010 
00011 void TLE5206::write(float duty_cycle){
00012     if (duty_cycle < -TLE5206_SAT_HIGH){
00013         this->pwmIN1 = TLE5206_SAT_HIGH;
00014         this->pwmIN2 = 0.0;
00015     }else if (duty_cycle < -TLE5206_SAT_LOW){
00016         this->pwmIN1 = -duty_cycle;
00017         this->pwmIN2 = 0.0;
00018     }else if (duty_cycle < TLE5206_NO_SAT_LOW){
00019         this->pwmIN1 = TLE5206_SAT_LOW;
00020         this->pwmIN2 = 0.0;
00021     }else if (duty_cycle < 0){
00022         this->pwmIN1 = -TLE5206_SAT_LOW/TLE5206_NO_SAT_LOW*duty_cycle;
00023         this->pwmIN2 = 0.0;
00024     }else if (duty_cycle < TLE5206_NO_SAT_LOW){
00025         this->pwmIN1 = 0.0;
00026         this->pwmIN2 = TLE5206_SAT_LOW/TLE5206_NO_SAT_LOW*duty_cycle;
00027     }else if (duty_cycle < TLE5206_SAT_LOW){
00028         this->pwmIN1 = 0.0;
00029         this->pwmIN2 = TLE5206_SAT_LOW;
00030     }else if (duty_cycle < TLE5206_SAT_HIGH){
00031         this->pwmIN1 = 0.0;
00032         this->pwmIN2 = duty_cycle;
00033     }else {
00034         this->pwmIN1 = 0.0;
00035         this->pwmIN2 = TLE5206_SAT_HIGH;
00036     }
00037 }