TER Atienza Pongnot 2019 / TLE5206_lib

Fork of TLE5206_lib by nicolas Atienza

TLE5206_lib.cpp

Committer:
natienza
Date:
2019-03-13
Revision:
1:1117196d767b
Parent:
0:03a724b7421c
Child:
2:610e4177e391

File content as of revision 1:1117196d767b:

#include "mbed.h"
#include "TLE5206_lib.h"

TLE5206::TLE5206(PinName IN1,PinName IN2):pwmIN1(IN1),pwmIN2(IN2){};

void TLE5206::setup(int periode_us){
    this->pwmIN1.period_us(periode_us);
    this->pwmIN2.period_us(periode_us);    
}

void TLE5206::write(float duty_cycle){
    if (duty_cycle < -1){
        this->pwmIN1 = 0.99;
        this->pwmIN2 = 0.0;
    }else if (duty_cycle < 0){
        this->pwmIN1 = -duty_cycle;
        this->pwmIN2 = 0.0;
    }else if (duty_cycle < 1){
        this->pwmIN1 = 0.0;
        this->pwmIN2 = duty_cycle;
    }else {
        this->pwmIN1 = 0.0;
        this->pwmIN2 = 0.99;    
    }    
}