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:
543:9dba91c44009
Parent:
525:c320967f86b9
Child:
548:1abac31e188e
--- a/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/analogin_api.c	Tue May 19 08:00:08 2015 +0100
+++ b/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/analogin_api.c	Wed May 20 08:45:07 2015 +0100
@@ -43,22 +43,33 @@
 
 void analogin_init(analogin_t *obj, PinName pin)
 {
-    // TODO_LP only once - module in C++ ?
-    /* Init with default settings */
-    ADC_Init_TypeDef init = ADC_INIT_DEFAULT;
-    ADC_Init(obj->adc, &init);
+    static uint8_t adc_initialized = 0;
 
-    ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
+    /* Init structure */
+    analogin_preinit(obj, pin);
 
-    /* Init for single conversion use, measure input channel with Vdd reference. */
-    singleInit.reference = adcRefVDD;
-    singleInit.resolution = adcRes12Bit;
-    singleInit.acqTime = adcAcqTime32;
+    /* Only initialize the ADC once */
+    if (!adc_initialized) {
+        /* Turn on the clock */
+        CMU_ClockEnable(cmuClock_ADC0, true);
+        
+        /* Init with default settings */
+        ADC_Init_TypeDef init = ADC_INIT_DEFAULT;
+        init.prescale = 4;
+        ADC_Init(obj->adc, &init);
+        
+        /* Init for single conversion use */
+        ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
 
-    ADC_InitSingle(obj->adc, &singleInit);
+        /* Measure input channel with Vdd reference. */
+        singleInit.reference = adcRefVDD;
+        singleInit.resolution = adcRes12Bit;
+        singleInit.acqTime = adcAcqTime32;
 
-    /* Init pins */
-    analogin_preinit(obj, pin);
+        ADC_InitSingle(obj->adc, &singleInit);
+        
+        adc_initialized = 1;
+    }
 }
 
 void analogin_enable(analogin_t *obj, uint8_t enable)