Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed_blinky-bmd-200 bmd-200_accel_demo firstRig
Fork of mbed-src by
Revision 547:9dba91c44009, committed 2015-05-20
- Comitter:
- mbed_official
- Date:
- Wed May 20 08:45:07 2015 +0100
- Parent:
- 546:6693aa6d3ba3
- Child:
- 548:1af5f1c39e80
- Commit message:
- Synchronized with git revision 1f6ad3fbb3fb13007f636ded30764bc5a1d4d362
Full URL: https://github.com/mbedmicro/mbed/commit/1f6ad3fbb3fb13007f636ded30764bc5a1d4d362/
[Silicon Labs] Fix missing clock enable in ADC/DAC
Changed in this revision
--- 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)
--- a/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/analogout_api.c Tue May 19 08:00:08 2015 +0100
+++ b/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/analogout_api.c Wed May 20 08:45:07 2015 +0100
@@ -23,6 +23,7 @@
#include "pinmap.h"
#include "pinmap_function.h"
#include "PeripheralPins.h"
+#include "clocking.h"
#include "em_dac.h"
#include "em_cmu.h"
@@ -42,30 +43,34 @@
}
void analogout_init(dac_t *obj, PinName pin) {
- static uint8_t initialized = 0;
+ static uint8_t dac_initialized = 0;
- if (!initialized) {
+ /* init in-memory structure */
+ analogout_preinit(obj, pin);
+
+ if (!dac_initialized) {
/* Initialize the DAC. Will disable both DAC channels, so should only be done once */
/* Use default settings */
+ CMU_ClockEnable(cmuClock_DAC0, true);
+
DAC_Init_TypeDef init = DAC_INIT_DEFAULT;
/* Calculate the DAC clock prescaler value that will result in a DAC clock
* close to 500kHz. Second parameter is zero. This uses the current HFPERCLK
* frequency instead of setting a new one. */
- init.prescale = DAC_PrescaleCalc(500000, 0);
+ init.prescale = DAC_PrescaleCalc(500000, REFERENCE_FREQUENCY);
/* Set reference voltage to VDD */
init.reference = dacRefVDD;
DAC_Init(obj->dac, &init);
- initialized = 1;
+ dac_initialized = 1;
}
/* Use default channel settings */
DAC_InitChannel_TypeDef initChannel = DAC_INITCHANNEL_DEFAULT;
DAC_InitChannel(obj->dac, &initChannel, obj->channel);
- /* init pins */
- analogout_preinit(obj, pin);
+
}
void analogout_enable(dac_t *obj, uint8_t enable)
