SoftwarePWM.cpp
Go to the documentation of this file.
00001 #include "SoftwarePWM.h"
00002 #include "mbed.h"
00003 
00004 SoftwarePWM::SoftwarePWM(PinName Pin) : SoftwarePWMPin(Pin) {}
00005 
00006 void SoftwarePWM::SetPosition(int Pos)
00007 {
00008   Position = Pos;
00009 }
00010 
00011 void SoftwarePWM::StartPulse()
00012 {
00013   if (Position <= 0)
00014   {
00015     SoftwarePWMPin = 0 ;
00016   }
00017   else
00018   {
00019     SoftwarePWMPin = 1;
00020     PulseStop.attach_us(this, &SoftwarePWM::EndPulse, Position);
00021   }
00022 }
00023 
00024 void SoftwarePWM::EndPulse()
00025 {
00026   SoftwarePWMPin = 0;
00027 }
00028 
00029 void SoftwarePWM::Enable(int StartPos, int Period)
00030 {
00031   Position = StartPos;
00032   Pulse.attach_us(this, &SoftwarePWM::StartPulse, Period);
00033 }
00034 
00035 void SoftwarePWM::Disable()
00036 {
00037   Pulse.detach();
00038 }


rosserial_mbed
Author(s): Gary Servin
autogenerated on Sat Oct 7 2017 03:08:46