HEPTA-Sat Training 2017~2018 / HeptaBattery

Dependencies:   PowerControl

Dependents:   Lab9-01_All_transmit Lab9-03_Thermal_chamber 3daf572bcae1 Team ... more

Fork of HeptaBattery by CLTP 8

Files at this revision

API Documentation at this revision

Comitter:
HEPTA
Date:
Wed Aug 08 10:50:17 2018 +0000
Parent:
7:b701e9cd2108
Child:
10:e6d9db9a4802
Child:
11:65c3076b5c24
Commit message:
HeptaBattery library

Changed in this revision

HeptaBattery.cpp Show annotated file Show diff for this revision Revisions of this file
HeptaBattery.h Show annotated file Show diff for this revision Revisions of this file
--- a/HeptaBattery.cpp	Fri Nov 17 02:08:19 2017 +0000
+++ b/HeptaBattery.cpp	Wed Aug 08 10:50:17 2018 +0000
@@ -4,12 +4,12 @@
 HeptaBattery::HeptaBattery(PinName bat, PinName bat_ct) : _bat(bat),_bat_ct(bat_ct)
 {
     _bat_ct = 1;
-    PHY_PowerDown();//Ethernet PHYchip停止
+    PHY_PowerDown();//stop Ethernet PHYchip
 }
 
 void HeptaBattery::vol(float* bt)
 {
-    *bt = (_bat.read()*1.431*3.3);//バッテリー電圧読み出し
+    *bt = (_bat.read()*1.431*3.3);//read the battery voltage
 }
 
 void HeptaBattery::shut_down_regulator()
@@ -36,27 +36,29 @@
     //*dsize = 4;
 }
 
-void HeptaBattery::power_saving_mode()
+void HeptaBattery::power_saving_mode(int *flag,float* Bat)
 {
-    float Bat;
-    Bat = _bat.read()*1.431*3.3;
-    //4.2以上
-    if(Bat>=4.2) {
+    *Bat = _bat.read()*1.431*3.3;
+    //Above 4.2 or more
+    if(*Bat>=4.2) {
         _bat_ct = 1;
         LPC_SC->CCLKCFG = 2;
         SystemCoreClockUpdate();
+        *flag = 0;
     }
     //3.7 < Voltage < 4.1
-    else if(Bat<=4.1 && Bat>=3.7) {
+    else if(*Bat<=4.1 && *Bat>=3.7) {
         _bat_ct = 1;
         LPC_SC->CCLKCFG = 2;
         SystemCoreClockUpdate();
+        *flag = 0;
     }
-    //3.5V以下
-    else if(Bat<=3.5) {
+    //3.5V or less
+    else if(*Bat<=3.5) {
         _bat_ct = 0;
         LPC_SC->CCLKCFG = 5;
         SystemCoreClockUpdate();
+        *flag = 1;
     }
 
 }
\ No newline at end of file
--- a/HeptaBattery.h	Fri Nov 17 02:08:19 2017 +0000
+++ b/HeptaBattery.h	Wed Aug 08 10:50:17 2018 +0000
@@ -14,7 +14,7 @@
     void shut_down_regulator();//3.3V供給停止
     void turn_on_regulator();//3.3V供給
     void vol_u16(char* bt_u16);//Battery電圧監視(16進数)
-    void power_saving_mode(void);//省電力モード
+    void power_saving_mode(int *flag,float* Bat);//省電力モード
   
 private:  
     DigitalOut _bat_ct;