We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d4e5206 commit 10e30b5Copy full SHA for 10e30b5
libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX/analogin_api.c
@@ -44,14 +44,14 @@ void analogin_init(analogin_t *obj, PinName pin) {
44
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
45
if (obj->adc == (uint32_t)NC) {
46
error("ADC pin mapping failed");
47
+ return;
48
}
49
50
// Power up ADC
- LPC_SYSCON->PDRUNCFG &= ~ (1 << 4);
51
+ LPC_SYSCON->PDRUNCFG &= ~(1 << 4);
52
LPC_SYSCON->SYSAHBCLKCTRL |= ((uint32_t)1 << 13);
53
- uint32_t offset = (uint32_t)pin & 0xff;
54
- __IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + offset);
+ __IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + (pin & 0xff));
55
56
// set pin to ADC mode
57
*reg &= ~(1 << 7); // set ADMODE = 0 (analog mode)
0 commit comments