t
Fork of mbed-dev by
Diff: targets/TARGET_NORDIC/TARGET_MCU_NRF51822/analogin_api.c
- Revision:
- 178:c26431f84b0d
- Parent:
- 151:5eaa88a5bcc7
--- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/analogin_api.c Tue Feb 28 17:13:35 2017 +0000 +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/analogin_api.c Thu Nov 09 22:14:37 2017 +0000 @@ -36,6 +36,7 @@ {NC, NC, 0} }; + void analogin_init(analogin_t *obj, PinName pin) { int analogInputPin = 0; @@ -71,7 +72,8 @@ while (!NRF_ADC->EVENTS_END) { } - return (uint16_t)NRF_ADC->RESULT; // 10 bit + uint16_t value = NRF_ADC->RESULT; + return (value << 6) | ((value >> 4) & 0x003F); // 10 bit } float analogin_read(analogin_t *obj)