Forked from anonymous/gist:b72e2737f1b58a0dd24eb8bffacdc616
Last active
February 22, 2020 07:27
-
-
Save brysonreece/be998a0a1b38b2e839e1aa8508b007fc to your computer and use it in GitHub Desktop.
Particle Boron getSystemStatus() Tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Particle leaves it to the datasheet to explain. | |
| * | |
| * http://www.ti.com/lit/ds/symlink/bq24195.pdf | |
| * page 32. | |
| */ | |
| int vbus_status(systemStatus) | |
| { | |
| vbus = (systemStatus >> 6) & 3; | |
| if(vbus == 0) | |
| { | |
| return UNKNOWN; | |
| } | |
| else if(vbus == 1) | |
| { | |
| return USB_HOST; | |
| } | |
| else if(vbus == 2) | |
| { | |
| return ADAPTER_PORT; | |
| } | |
| else if(vbus == 3) | |
| { | |
| return OTG; | |
| } | |
| } | |
| int charging_status(systemStatus) | |
| { | |
| charging = (systemStatus >> 4) & 3; | |
| if(charging == 0) | |
| { | |
| return NOT_CHARGING; | |
| } | |
| else if(charging == 1) | |
| { | |
| return PRE_CHARGE; | |
| } | |
| else if(charging == 2) | |
| { | |
| return FAST_CHARGING; | |
| } | |
| else if(charging == 3) | |
| { | |
| return CHARGE_TERMINATION_DONE; | |
| } | |
| } | |
| int dpm_status(systemStatus) | |
| { | |
| dpm = (systemStatus >> 3) & 1; | |
| if(dpm == 1) | |
| { | |
| return VINDPM_OR_IINDPM; | |
| } | |
| else if(dpm == 0) | |
| { | |
| return Not_DPM; | |
| } | |
| } | |
| int power_good_status(systemStatus) | |
| { | |
| power_good = (systemStatus >> 2) & 1; | |
| if(power_good == 1) | |
| { | |
| return POWER_GOOD; | |
| } | |
| else if(power_good == 0) | |
| { | |
| return NOT_POWER_GOOD; | |
| } | |
| } | |
| int thermal_status(systemStatus) | |
| { | |
| therm = (systemStatus >> 1) & 1; | |
| if(therm == 1) | |
| { | |
| return IN_THERMAL_REGULATION; | |
| } | |
| else if(therm == 0) | |
| { | |
| return NORMAL; | |
| } | |
| } | |
| int vsys_status(systemStatus) | |
| { | |
| vsys = systemStatus & 1; | |
| if(vsys == 1) | |
| { | |
| return IN_VSYSMIN_REGULATION; | |
| } | |
| else if(vsys == 0) | |
| { | |
| return NOT_IN_VSYSMIN_REGULATION; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment