Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Seeed_Motor_Shield_HelloWorld Official_MedusaIcon Seeed_Motor_Shield adrobo
SoftwarePWM.cpp
00001 #include "SoftwarePWM.h" 00002 #include "mbed.h" 00003 00004 SoftwarePWM::SoftwarePWM(PinName Pin) : SoftwarePWMPin(Pin) {} 00005 00006 void SoftwarePWM::SetPosition(int Pos) { 00007 Position = Pos; 00008 } 00009 00010 void SoftwarePWM::StartPulse() { 00011 if(Position <= 0) { 00012 SoftwarePWMPin = 0 ; 00013 } else { 00014 SoftwarePWMPin = 1; 00015 PulseStop.attach_us(this, &SoftwarePWM::EndPulse, Position); 00016 } 00017 } 00018 00019 void SoftwarePWM::EndPulse() { 00020 SoftwarePWMPin = 0; 00021 } 00022 00023 void SoftwarePWM::Enable(int StartPos, int Period) { 00024 Position = StartPos; 00025 Pulse.attach_us(this, &SoftwarePWM::StartPulse, Period); 00026 } 00027 00028 void SoftwarePWM::Disable() { 00029 Pulse.detach(); 00030 }
Generated on Tue Jul 12 2022 21:20:52 by
1.7.2