changed for STM32F4

Fork of FastPWM by Erik -

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FastPWM_LPC1768.cpp Source File

FastPWM_LPC1768.cpp

00001 #ifdef TARGET_LPC1768
00002 
00003 #include "FastPWM.h"
00004 
00005 void FastPWM::initFastPWM( void ) {
00006     //Set clock source
00007     LPC_SC->PCLKSEL0|=1<<12;
00008     bits = 32;
00009 }
00010 
00011 void FastPWM::pulsewidth_ticks( uint32_t ticks ) {
00012     *(_pwm.MR) = ticks;
00013     LPC_PWM1->LER |= 1 << _pwm.pwm;
00014 }
00015 
00016 void FastPWM::period_ticks( uint32_t ticks ) {
00017     LPC_PWM1->MR0 = ticks;
00018     LPC_PWM1->LER |= 1 << 0;
00019 }
00020 
00021 uint32_t FastPWM::getPeriod( void ) {
00022     return LPC_PWM1->MR0;
00023 }
00024 
00025 //Maybe implemented later, but needing to change the prescaler for a 32-bit
00026 //timer used in PWM mode is kinda unlikely.
00027 //If you really need to do it, rejoice, you can make it run so slow a period is over 40,000 year
00028 uint32_t FastPWM::setPrescaler(uint32_t reqScale) {
00029     //Disable dynamic prescaling
00030     dynamicPrescaler = false;
00031     
00032     return 1;
00033 }
00034 #endif