test

Fork of mbed-dev by mbed official

Revision:
153:fa9ff456f731
Parent:
149:156823d33999
Child:
161:2cc1468da177
diff -r 9a67f0b066fc -r fa9ff456f731 targets/TARGET_ONSEMI/TARGET_NCS36510/analogin_api.c
--- 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);
 }