ADC Reset Conflict Fixed

ADC Reset conflict with already configured ADC pins is fixed
pull/4974/head
Ganesh Ramachandran 2017-08-07 17:27:51 +05:30 committed by adbridge
parent e445e081d2
commit 6b6d07245e
1 changed files with 6 additions and 2 deletions

View File

@ -18,6 +18,7 @@
#include "pinmap.h" #include "pinmap.h"
#include "mbed_wait_api.h" #include "mbed_wait_api.h"
static uint8_t adc_reset_init = 0; // Is ADC Reset happened yet?
#define ADC_10BIT_RANGE 0x3FF #define ADC_10BIT_RANGE 0x3FF
static const PinMap PinMap_ADC[] = { static const PinMap PinMap_ADC[] = {
@ -43,8 +44,11 @@ void analogin_init(analogin_t *obj, PinName pin)
CG_SetADCClkSupply(ENABLE); CG_SetADCClkSupply(ENABLE);
// Set pin function as ADC // Set pin function as ADC
pinmap_pinout(pin, PinMap_ADC); pinmap_pinout(pin, PinMap_ADC);
if (!adc_reset_init) {
// Software reset ADC // Software reset ADC
ADC_SWReset(); ADC_SWReset();
adc_reset_init = 1;
}
// Set sample hold time and pre-scale clock // Set sample hold time and pre-scale clock
ADC_SetClk(ADC_CONVERSION_81_CLOCK, ADC_FC_DIVIDE_LEVEL_8); ADC_SetClk(ADC_CONVERSION_81_CLOCK, ADC_FC_DIVIDE_LEVEL_8);
// Set input channel // Set input channel