mbed SDK library sources

Fork of mbed-src by mbed official

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Revision:
84:f54042cbc282
Parent:
70:c1fbde68b492
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pwmout_api.c	Fri Jan 31 10:15:06 2014 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pwmout_api.c	Mon Feb 03 09:30:05 2014 +0000
@@ -33,21 +33,13 @@
 #include "pinmap.h"
 #include "error.h"
 
-// Only TIM2 and TIM3 can be used (TIM1 and TIM4 are used by the us_ticker)
 static const PinMap PinMap_PWM[] = {
-    // TIM2 default
-    //{PA_2,  PWM_2, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, // TIM2_CH3 - ARDUINO D1
-    //{PA_3,  PWM_2, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, // TIM2_CH4 - ARDUINO D0
     // TIM2 full remap
     {PB_3,  PWM_2, STM_PIN_DATA(GPIO_Mode_AF_PP, 5)}, // TIM2fr_CH2 - ARDUINO D3
-    //{PB_10, PWM_2, STM_PIN_DATA(GPIO_Mode_AF_PP, 5)}, // TIM2fr_CH3 - ARDUINO D6
-    // TIM3 default
-    //{PA_6,  PWM_3, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, // TIM3_CH1 - ARDUINO D12
-    //{PA_7,  PWM_3, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, // TIM3_CH2 - ARDUINO D11
-    // TIM3 full remap
-    //{PC_7,  PWM_3, STM_PIN_DATA(GPIO_Mode_AF_PP, 6)}, // TIM3fr_CH2 - ARDUINO D9
     // TIM3 partial remap
     {PB_4,  PWM_3, STM_PIN_DATA(GPIO_Mode_AF_PP, 7)}, // TIM3pr_CH1 - ARDUINO D5
+    // TIM4 default
+    {PB_6,  PWM_4, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, // TIM4_CH1 - ARDUINO D10    
     {NC,    NC,    0}
 };
 
@@ -62,7 +54,8 @@
     // Enable TIM clock
     if (obj->pwm == PWM_2) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
     if (obj->pwm == PWM_3) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
- 
+    if (obj->pwm == PWM_4) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
+    
     // Configure GPIO
     pinmap_pinout(pin, PinMap_PWM);
     
@@ -87,10 +80,7 @@
     } else if (value > 1.0) {
         value = 1.0;
     }
-
-    //while(TIM_GetFlagStatus(tim, TIM_FLAG_Update) == RESET);
-    //TIM_ClearFlag(tim, TIM_FLAG_Update);
-    
+   
     obj->pulse = (uint32_t)((float)obj->period * value);
     
     TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
@@ -99,7 +89,7 @@
     TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
 
     // Configure channel 1
-    if (obj->pin == PB_4) {
+    if ((obj->pin == PB_4) || (obj->pin == PB_6)) {
         TIM_OC1PreloadConfig(tim, TIM_OCPreload_Enable);
         TIM_OC1Init(tim, &TIM_OCInitStructure);
     }
@@ -109,18 +99,6 @@
         TIM_OC2PreloadConfig(tim, TIM_OCPreload_Enable);
         TIM_OC2Init(tim, &TIM_OCInitStructure);
     }
-
-    // Configure channel 3
-    //if (obj->pin == PB_10) {
-    //    TIM_OC3PreloadConfig(tim, TIM_OCPreload_Enable);
-    //    TIM_OC3Init(tim, &TIM_OCInitStructure);
-    //}
-
-    // Configure channel 4
-    //if (obj->pin == PA_3) {
-    //    TIM_OC4PreloadConfig(tim, TIM_OCPreload_Enable);
-    //    TIM_OC4Init(tim, &TIM_OCInitStructure);
-    //}
 }
 
 float pwmout_read(pwmout_t* obj) {