mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

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:
548:1abac31e188e
Parent:
544:1af5f1c39e80
Child:
554:edd95c0879f8
--- a/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/pwmout_api.c	Fri May 22 09:45:08 2015 +0100
+++ b/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/pwmout_api.c	Fri May 22 10:45:46 2015 +0100
@@ -33,22 +33,23 @@
 static int pwm_clockfreq;
 static int pwm_prescaler_div;
 
-uint32_t pwmout_get_channel_route(pwmout_t *obj) {
-	MBED_ASSERT(obj->channel != (PWMName) NC);
+uint32_t pwmout_get_channel_route(pwmout_t *obj)
+{
+    MBED_ASSERT(obj->channel != (PWMName) NC);
 
-	switch (obj->channel) {
-		case PWM_CH0:
-			return TIMER_ROUTE_CC0PEN;
-			break;
-		case PWM_CH1:
-			return TIMER_ROUTE_CC1PEN;
-			break;
-		case PWM_CH2:
-			return TIMER_ROUTE_CC2PEN;
-			break;
-		default:
-			return 0;
-	}
+    switch (obj->channel) {
+        case PWM_CH0:
+            return TIMER_ROUTE_CC0PEN;
+            break;
+        case PWM_CH1:
+            return TIMER_ROUTE_CC1PEN;
+            break;
+        case PWM_CH2:
+            return TIMER_ROUTE_CC2PEN;
+            break;
+        default:
+            return 0;
+    }
 }
 
 void pwmout_enable_pins(pwmout_t *obj, uint8_t enable)
@@ -63,8 +64,8 @@
 
 void pwmout_enable(pwmout_t *obj, uint8_t enable)
 {
-	/* Start with default CC (Compare/Capture) channel parameters */
-	TIMER_InitCC_TypeDef timerCCInit = TIMER_INITCC_DEFAULT;
+    /* Start with default CC (Compare/Capture) channel parameters */
+    TIMER_InitCC_TypeDef timerCCInit = TIMER_INITCC_DEFAULT;
     if (enable) {
         /* Set mode to PWM */
         timerCCInit.mode = timerCCModePWM;
@@ -76,33 +77,33 @@
 
 void pwmout_init(pwmout_t *obj, PinName pin)
 {
-	obj->channel = (PWMName) pinmap_peripheral(pin, PinMap_PWM);
-	obj->pin = pin;
-	MBED_ASSERT(obj->channel != (PWMName) NC);
+    obj->channel = (PWMName) pinmap_peripheral(pin, PinMap_PWM);
+    obj->pin = pin;
+    MBED_ASSERT(obj->channel != (PWMName) NC);
 
-	/* Turn on clock */
-	CMU_ClockEnable(PWM_TIMER_CLOCK, true);
+    /* Turn on clock */
+    CMU_ClockEnable(PWM_TIMER_CLOCK, true);
 
-	/* Turn on timer */
-	if(!(PWM_TIMER->STATUS & TIMER_STATUS_RUNNING)) {
-		TIMER_Init_TypeDef timerInit = TIMER_INIT_DEFAULT;
-		TIMER_Init(PWM_TIMER, &timerInit);
-	}
+    /* Turn on timer */
+    if(!(PWM_TIMER->STATUS & TIMER_STATUS_RUNNING)) {
+        TIMER_Init_TypeDef timerInit = TIMER_INIT_DEFAULT;
+        TIMER_Init(PWM_TIMER, &timerInit);
+    }
 
     /* Enable correct channel */
-	uint32_t routeloc = pwmout_get_channel_route(obj);
-	if(PWM_TIMER->ROUTE & routeloc) {
-		//This channel was already in use
-		//TODO: gracefully handle this case
-	} else {
-		//This channel was unused up to now
-		PWM_TIMER->ROUTE |= routeloc;
-		blockSleepMode(EM1);
+    uint32_t routeloc = pwmout_get_channel_route(obj);
+    if(PWM_TIMER->ROUTE & routeloc) {
+        //This channel was already in use
+        //TODO: gracefully handle this case
+    } else {
+        //This channel was unused up to now
+        PWM_TIMER->ROUTE |= routeloc;
+        blockSleepMode(EM1);
 
-		//TODO: check if any channel was up already, then don't re-init timer
-		pwmout_enable(obj, true);
-		pwmout_enable_pins(obj, true);
-	}
+        //TODO: check if any channel was up already, then don't re-init timer
+        pwmout_enable(obj, true);
+        pwmout_enable_pins(obj, true);
+    }
 
     /* Route correct channel to location 1 */
     PWM_TIMER->ROUTE &= ~_TIMER_ROUTE_LOCATION_MASK;
@@ -115,18 +116,19 @@
     pwmout_period(obj, 0.02);
 }
 
-void pwmout_free(pwmout_t *obj) {
-	uint32_t routeloc = pwmout_get_channel_route(obj);
-	if(PWM_TIMER->ROUTE & routeloc) {
-		//This channel was in use, so disable
-		PWM_TIMER->ROUTE &= ~routeloc;
-		pwmout_enable_pins(obj, false);
-		unblockSleepMode(EM1);
+void pwmout_free(pwmout_t *obj)
+{
+    uint32_t routeloc = pwmout_get_channel_route(obj);
+    if(PWM_TIMER->ROUTE & routeloc) {
+        //This channel was in use, so disable
+        PWM_TIMER->ROUTE &= ~routeloc;
+        pwmout_enable_pins(obj, false);
+        unblockSleepMode(EM1);
 
-		//TODO: check if all channels are down, then switch off timer
-	} else {
-		//This channel was disabled already
-	}
+        //TODO: check if all channels are down, then switch off timer
+    } else {
+        //This channel was disabled already
+    }
 }
 
 void pwmout_write(pwmout_t *obj, float value)