test
Fork of mbed-dev by
Diff: targets/TARGET_ONSEMI/TARGET_NCS36510/analogin_api.c
- Revision:
- 153:fa9ff456f731
- Parent:
- 149:156823d33999
- Child:
- 161:2cc1468da177
--- a/targets/TARGET_ONSEMI/TARGET_NCS36510/analogin_api.c Thu Dec 15 11:48:27 2016 +0000 +++ b/targets/TARGET_ONSEMI/TARGET_NCS36510/analogin_api.c Tue Dec 20 17:27:56 2016 +0000 @@ -64,7 +64,8 @@ obj->adcReg = (AdcReg_pt)adc; obj->pin = pin; obj->pinFlag = 1; - + obj->ADC_Offset_Value = TRIMREG->ADC_OFFSET_TRIM; + switch (pin) { case A0: adc_pin=0; @@ -183,7 +184,14 @@ while((uint32_t)(obj->adcReg->STATUS)!=(uint32_t)1) { } adcData =(uint16_t)(obj->adcReg->DATA); - CLOCK_DISABLE(CLOCK_ADC); + + /* Offset the ADC data with trim value */ + if (obj->ADC_Offset_Value != 0xFFFFFFFF) { + + if(adcData >= obj->ADC_Offset_Value) { + adcData -= obj->ADC_Offset_Value; + } + } return(adcData); }