FastPWM clone

Revision:
28:3c8a0d977bc3
Parent:
24:1f451660d8c0
Child:
32:e880dcb178f4
--- a/Device/FastPWM_STM_TIM.cpp	Thu Feb 11 06:33:59 2016 +0000
+++ b/Device/FastPWM_STM_TIM.cpp	Mon Feb 29 19:18:42 2016 +0000
@@ -9,11 +9,18 @@
 #define PWM_CHANNEL     (**(CHANNEL_P_T*)fast_obj)
 #define PWM_TIMER       ((TIM_TypeDef*)_pwm.pwm)
 
-extern CHANNEL_P_T getChannel(TIM_TypeDef* pwm, PinName pin);
+#if defined(TARGET_STM32F0) || defined (TARGET_STM32F1) || defined (TARGET_STM32L1)
+extern __IO uint32_t* getChannel(TIM_TypeDef* pwm, PinName pin);
+#endif
 
 void FastPWM::initFastPWM( void ) {
     fast_obj = new (CHANNEL_P_T);
+    
+    #if defined(TARGET_STM32F0) || defined (TARGET_STM32F1) || defined (TARGET_STM32L1)
     *(CHANNEL_P_T*)fast_obj = getChannel(PWM_TIMER, _pwm.pin);
+    #else
+    *(CHANNEL_P_T*)fast_obj = &PWM_TIMER->CCR1 + _pwm.channel - 1; 
+    #endif
     
     //Enable PWM period syncing for glitch free result
     PWM_TIMER->CR1 |= TIM_CR1_ARPE;