Used with KL25Z Freescale board to access the Avnet Wi-Go Battery charger
Dependents: Wi-Go_IOT_Demo IoT_World_Hackathon_WiGo_NSP_Demo Wi-Go_IOT_Demo_MKII
Fork of WiGo_BattCharger by
Modified BattCharger from https://mbed.org/users/monpjc/code/WiGo_BattCharger/ - removed LED pins and added raw read.
Revision 3:fb966ae74766, committed 2013-09-06
- Comitter:
- frankvnk
- Date:
- Fri Sep 06 09:06:39 2013 +0000
- Parent:
- 2:f52adda183d2
- Commit message:
- Temp modif - removed LED pins - added raw read
Changed in this revision
WiGo_BattCharger.cpp | Show annotated file Show diff for this revision Revisions of this file |
WiGo_BattCharger.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r f52adda183d2 -r fb966ae74766 WiGo_BattCharger.cpp --- a/WiGo_BattCharger.cpp Fri May 17 20:13:01 2013 +0000 +++ b/WiGo_BattCharger.cpp Fri Sep 06 09:06:39 2013 +0000 @@ -1,11 +1,11 @@ #include "WiGo_BattCharger.h" #include "mbed.h" -WiGo_BattCharger::WiGo_BattCharger( PinName battlow, PinName battmed, PinName battfull, PinName en1, PinName en2, PinName snsen, PinName sense, PinName supplystate, PinName chargestate ) : _battlow(battlow), _battmed(battmed), _battfull(battfull), _en1(en1), _en2(en2), _snsen(snsen), _sense(sense), _supplystate(supplystate), _chargestate(chargestate) +WiGo_BattCharger::WiGo_BattCharger( PinName en1, PinName en2, PinName snsen, PinName sense, + PinName supplystate, PinName chargestate ) + : _en1(en1), _en2(en2), _snsen(snsen), _sense(sense), + _supplystate(supplystate), _chargestate(chargestate) { - _battlow = BATT_LED_OFF; //Default State - _battmed = BATT_LED_OFF; - _battfull = BATT_LED_OFF; _en1 = 0; //100mA Charge _en2 = 0; _snsen = 1; //Off @@ -45,6 +45,11 @@ _snsen = 0; } +unsigned short WiGo_BattCharger::readRaw( void ) +{ + return _sense.read_u16(); +} + float WiGo_BattCharger::read( void ) { return _sense; @@ -60,42 +65,6 @@ return _supplystate; } -void WiGo_BattCharger::LEDupdate( int n ) -{ - float batt_level; - - if( n == 1 ) { - sense_en(1); - batt_level = read(); - if( batt_level <= BATT_0 ) { - _battlow = BATT_LED_OFF; - _battmed = BATT_LED_OFF; - _battfull = BATT_LED_OFF; - } - if( batt_level > BATT_0 && batt_level <= 0.605 ) { - _battlow = BATT_LED_ON; - _battmed = BATT_LED_OFF; - _battfull = BATT_LED_OFF; - } - if( batt_level > 0.605 && batt_level <= BATT_100 ) { - _battlow = BATT_LED_ON; - _battmed = BATT_LED_ON; - _battfull = BATT_LED_OFF; - } - if( batt_level > BATT_100 ) { - _battlow = BATT_LED_ON; - _battmed = BATT_LED_ON; - _battfull = BATT_LED_ON; - } - } - else - { - _battlow = BATT_LED_OFF; - _battmed = BATT_LED_OFF; - _battfull = BATT_LED_OFF; - } -} - int WiGo_BattCharger::level( void ) { float returnValue = 0; @@ -111,3 +80,5 @@ return (int)returnValue; } + +
diff -r f52adda183d2 -r fb966ae74766 WiGo_BattCharger.h --- a/WiGo_BattCharger.h Fri May 17 20:13:01 2013 +0000 +++ b/WiGo_BattCharger.h Fri Sep 06 09:06:39 2013 +0000 @@ -4,9 +4,6 @@ #include "mbed.h" //Battery Circuit for Avnet PCB -#define BATT_FULL PTB10 -#define BATT_MED PTB9 -#define BATT_LOW PTB8 #define CHRG_EN1 PTB2 #define CHRG_EN2 PTB3 #define CHRG_SNS_EN PTC2 @@ -28,34 +25,30 @@ { public: - WiGo_BattCharger( PinName battlow, PinName battmed, PinName battfull, - PinName en1, PinName en2, PinName snsen, PinName sense, + WiGo_BattCharger( PinName en1, PinName en2, PinName snsen, PinName sense, PinName supplystate, PinName chargestate ); void init( int n ); void sense_en( int n); + unsigned short readRaw( void ); + float read( void ); int charging( void ); int supply( void ); - void LEDupdate( int n ); - int level( void ); protected: - DigitalOut _battfull; - DigitalOut _battmed; - DigitalOut _battlow; DigitalOut _en1; DigitalOut _en2; DigitalOut _snsen; + AnalogIn _sense; DigitalIn _supplystate; DigitalIn _chargestate; - AnalogIn _sense; }; #endif