Added pin descriptions for NUCLEO-F303RE. Tested

Fork of FastPWM by Erik -

Files at this revision

API Documentation at this revision

Comitter:
jocis
Date:
Sat Oct 04 13:14:44 2014 +0000
Parent:
16:ec208b5ec0bb
Child:
18:d91c0629e4e6
Commit message:
Added NUCLEO F103RB; adapted t 32/16 bit pwm struct for NUCLEO

Changed in this revision

Device/FastPWM_STM_TIM.cpp Show annotated file Show diff for this revision Revisions of this file
Device/FastPWM_STM_TIM_PinOut.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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;
 }
 
--- a/Device/FastPWM_STM_TIM_PinOut.cpp	Thu Oct 02 08:09:52 2014 +0000
+++ b/Device/FastPWM_STM_TIM_PinOut.cpp	Sat Oct 04 13:14:44 2014 +0000
@@ -47,23 +47,23 @@
 #endif
 
 #if defined TARGET_NUCLEO_F103RB
-__IO uint32_t* getChannel(TIM_TypeDef* pwm, PinName pin) {
+__IO uint16_t* getChannel(TIM_TypeDef* pwm, PinName pin) {
     switch (pin) {
         // Channels 1 : PWMx/1
         case PA_6: case PA_8: case PA_15: case PB_4: case PC_6: case PB_13:
-            return (uint32_t*)&pwm->CCR1;
+            return &pwm->CCR1;
         
         // Channels 2 : PWMx/2
         case PA_1: case PA_7: case PA_9: case PB_3: case PB_5: case PC_7: case PB_14:
-            return (uint32_t*)&pwm->CCR2;
+            return &pwm->CCR2;
             
         // Channels 3 : PWMx/3
         case PA_2: case PA_10: case PB_0: case PB_10: case PC_8: case PB_15:
-            return (uint32_t*)&pwm->CCR3;
+            return &pwm->CCR3;
  
         // Channels 4 : PWMx/4
         case PA_3: case PA_11: case PB_1: case PB_11: case PC_9: 
-            return (uint32_t*)&pwm->CCR4;
+            return &pwm->CCR4;
     }
     return NULL;
 }