mirror of https://github.com/ARMmbed/mbed-os.git
lpc546xx: fix adc Resolve #5304
parent
f8a4c07570
commit
44d45d4023
|
@ -38,6 +38,14 @@ void analogin_init(analogin_t *obj, PinName pin)
|
||||||
|
|
||||||
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
|
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
|
||||||
adc_config_t adc_config;
|
adc_config_t adc_config;
|
||||||
|
uint32_t reg;
|
||||||
|
uint32_t pin_number = pin & 0x1F;
|
||||||
|
uint8_t port_number = pin / 32;
|
||||||
|
|
||||||
|
/* Clear the PDEN_ADC0 bit in the PDRUNCFG0 */
|
||||||
|
reg = IOCON->PIO[port_number][pin_number] & ~IOCON_PIO_DIGIMODE_MASK;
|
||||||
|
reg &= ~(1UL << SYSCON_PDRUNCFG_PDEN_ADC0_SHIFT);
|
||||||
|
IOCON->PIO[port_number][pin_number] = reg;
|
||||||
|
|
||||||
ADC_ClockPower_Configuration();
|
ADC_ClockPower_Configuration();
|
||||||
|
|
||||||
|
@ -69,6 +77,7 @@ uint16_t analogin_read_u16(analogin_t *obj)
|
||||||
adcConvSeqConfigStruct.interruptMode = kADC_InterruptForEachSequence;
|
adcConvSeqConfigStruct.interruptMode = kADC_InterruptForEachSequence;
|
||||||
|
|
||||||
ADC_SetConvSeqAConfig(adc_addrs[instance], &adcConvSeqConfigStruct);
|
ADC_SetConvSeqAConfig(adc_addrs[instance], &adcConvSeqConfigStruct);
|
||||||
|
ADC_EnableConvSeqA(adc_addrs[instance], true);
|
||||||
ADC_DoSoftwareTriggerConvSeqA(adc_addrs[instance]);
|
ADC_DoSoftwareTriggerConvSeqA(adc_addrs[instance]);
|
||||||
|
|
||||||
/* Wait for the converter to be done. */
|
/* Wait for the converter to be done. */
|
||||||
|
|
Loading…
Reference in New Issue