FASTPWM

Dependents:   OV7670_make

Revision:
17:8378bc456f0d
Parent:
13:cdefd9d75b64
Child:
22:db9c0cf445e2
diff -r ec208b5ec0bb -r 8378bc456f0d Device/FastPWM_STM_TIM.cpp
--- a/Device/FastPWM_STM_TIM.cpp	Thu Oct 02 08:09:52 2014 +0000
+++ b/Device/FastPWM_STM_TIM.cpp	Sat Oct 04 13:14:44 2014 +0000
@@ -4,14 +4,21 @@
 
 #include "FastPWM.h"
 
-#define PWM_CHANNEL     (**(__IO uint32_t**)fast_obj)
+#if defined TARGET_NUCLEO_F103RB
+typedef __IO uint16_t* CHANNEL_P_T;
+#else
+typedef __IO uint32_t* CHANNEL_P_T;
+#endif
+
+#define PWM_CHANNEL     (**(CHANNEL_P_T*)fast_obj)
 #define PWM_TIMER       ((TIM_TypeDef*)_pwm.pwm)
 
-extern __IO uint32_t* getChannel(TIM_TypeDef* pwm, PinName pin);
+extern CHANNEL_P_T getChannel(TIM_TypeDef* pwm, PinName pin);
 
 void FastPWM::initFastPWM( void ) {
-    fast_obj = new (__IO uint32_t*);
-    *(__IO uint32_t**)fast_obj = getChannel(PWM_TIMER, _pwm.pin);
+    fast_obj = new (CHANNEL_P_T);
+    *(CHANNEL_P_T*)fast_obj = getChannel(PWM_TIMER, _pwm.pin);
+    
     bits = 16;
 }