Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lpc546xx: fix adc #5516

Merged
merged 3 commits into from Nov 22, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/api/analogin_api.c
Expand Up @@ -38,6 +38,14 @@ void analogin_init(analogin_t *obj, PinName pin)

uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
adc_config_t adc_config;
uint32_t reg;
uint32_t pin_number = pin & 0x1F;
uint8_t port_number = pin / 32;

/* Clear the DIGIMODE bit */
reg = IOCON->PIO[port_number][pin_number] & ~IOCON_PIO_DIGIMODE_MASK;
reg &= ~(1UL << IOCON_PIO_DIGIMODE_SHIFT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this line as the previous line has already cleared the bit.

IOCON->PIO[port_number][pin_number] = reg;

ADC_ClockPower_Configuration();

Expand Down Expand Up @@ -69,6 +77,7 @@ uint16_t analogin_read_u16(analogin_t *obj)
adcConvSeqConfigStruct.interruptMode = kADC_InterruptForEachSequence;

ADC_SetConvSeqAConfig(adc_addrs[instance], &adcConvSeqConfigStruct);
ADC_EnableConvSeqA(adc_addrs[instance], true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this, apologies for missing this line.

ADC_DoSoftwareTriggerConvSeqA(adc_addrs[instance]);

/* Wait for the converter to be done. */
Expand Down