Public fork of mbed-src to add generic stm32f030k6 target

Fork of mbed-src by mbed official

Revision:
499:d0e9408fd176
Parent:
363:12a245e5c745
--- a/targets/hal/TARGET_Freescale/TARGET_KLXX/sleep.c	Fri Mar 27 16:00:09 2015 +0000
+++ b/targets/hal/TARGET_Freescale/TARGET_KLXX/sleep.c	Sat Mar 28 08:15:07 2015 +0000
@@ -30,6 +30,15 @@
 //Very low-power stop mode
 void deepsleep(void)
 {
+    //Check if ADC is enabled and HS mode is set, if yes disable it (lowers power consumption by 60uA)
+    uint8_t ADC_HSC = 0;
+    if (SIM->SCGC6 & SIM_SCGC6_ADC0_MASK) {
+        if (ADC0->CFG2 & ADC_CFG2_ADHSC_MASK) {
+            ADC_HSC = 1;
+            ADC0->CFG2 &= ~(ADC_CFG2_ADHSC_MASK);
+        }
+    }
+    
 #if ! defined(TARGET_KL43Z)
     //Check if PLL/FLL is enabled:
     uint32_t PLL_FLL_en = (MCG->C1 & MCG_C1_CLKS_MASK) == MCG_C1_CLKS(0);
@@ -54,4 +63,8 @@
         MCG->C1 &= ~MCG_C1_CLKS_MASK;
     }
 #endif 
+
+    if (ADC_HSC) {
+        ADC0->CFG2 |= (ADC_CFG2_ADHSC_MASK);
+    }
 }