Skip to content

Commit 10e30b5

Browse files
committed
Fixed error handling and cleanup
1 parent d4e5206 commit 10e30b5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX/analogin_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ void analogin_init(analogin_t *obj, PinName pin) {
4444
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
4545
if (obj->adc == (uint32_t)NC) {
4646
error("ADC pin mapping failed");
47+
return;
4748
}
4849

4950
// Power up ADC
50-
LPC_SYSCON->PDRUNCFG &= ~ (1 << 4);
51+
LPC_SYSCON->PDRUNCFG &= ~(1 << 4);
5152
LPC_SYSCON->SYSAHBCLKCTRL |= ((uint32_t)1 << 13);
5253

53-
uint32_t offset = (uint32_t)pin & 0xff;
54-
__IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + offset);
54+
__IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + (pin & 0xff));
5555

5656
// set pin to ADC mode
5757
*reg &= ~(1 << 7); // set ADMODE = 0 (analog mode)

0 commit comments

Comments
 (0)