Community news, upcoming events and general discussions
Threads: 36 Posts: 88
Get technical support from the community
Threads: 1427 Posts: 7608
Threads: 18 Posts: 64
Tell us how to make XDK better!
Threads: 36 Posts: 119
Share and discuss community member projects
Threads: 81 Posts: 350
It has come to my attention that the battery status API has been de-activated for XDK Workbench version 3.0 through 3.1 (at least). Is there a workaround that users can implement to still get this functionality? Some people cannot fully migrate there code without this.
Thank you for your help,
Hello Chris, the only thing I found in the SDK regarding Battery Status are the Charger modules. Those function as Battery Status monitors, allowing to read the current voltage and determining the current battery status. The main issue is that there are two charger modules. One for BQ24050, one for BQ24070. Not knowing which battery is actually installed on the XDK, since I am lacking these informations currently, I tried out the BQ24050 module. To use the module BSP_Charger_BQ2405X, you have to make two changes to the SDK. Firstly, the modules does not have a header-file yet. You would have to create a header-file in the SDK at:
SDK > xdk110 > Platform > Essentials > include > bsp > BCDS_BSP_Charger_BQ2405X.h
With the following content:
#endif /* SDK_XDK110_PLATFORM_ESSENTIALS_INCLUDE_BSP_BCDS_BSP_CHARGER_BQ2405X_H_ */
This header-file will be included in the implementation file of the charger-module. But, to build the module and be able to use it, you have to change a #define at:
SDK > xdk110 > Common > config > Essentials > BCDS_HALConfig.h
Change line 66 #define BCDS_FEATURE_BSP_CHARGER_BQ2405X from 0 to 1. This should enable everything related to the
Additionally, I would make the following two changes in the implementation file located at
SDK > xdk 110 > Platform > BSP > source > BSP_Charger_BQ2405X.c
The first change is in BSP_Charger_BQ2405X_MeasureSignal(). For some reason, the developer decided to return the voltage as voltage = (2 * sample * 2500) / 4096, since the sample should already be the correct value in millivolt. Simply returning sample seems valid enough to me.
voltage = (2 * sample * 2500) / 4096
The second change would be in the function BSP_Charger_BQ2405X_getStatus(). In the last else-branch, an assert(0) is called. I would replace this with anything else that might be useful for troubleshooting. Such as status = -1. Keep in mind that these two changes are purely a recommendation, and not a must. Although getStatus will most likely assert, since MeasureSignal in its original implementation will (at least in my case) return voltages that are above the maximal voltage accepted by getStatus . Please tell me if this was helpful, and do not hesitate to ask further questions. Kind regards, Franjo
status = -1
I tried it
#define BCDS_FEATURE_BSP_CHARGER_BQ2407X is not declared in BCDS_HALConfig.h, so I added it by declaring it. The function type of the .h file you gave and the BSP_Charger_BQ2407X.c file are different. BSP_Charger_BQ2407X.c says uint32_t BSP_Charger_BQ2407X_GetStatus (void) The .h file that you gave contains Retcode_T BSP_Charger_BQ2407X_GetStatus (BSP_ChargeState_T * state); .
I used the following syntax. BSP_Charger_BQ2407X_Connect (); BSP_Charger_BQ2407X_Enable (0); int32_t BatteryStatus = BSP_Charger_BQ2407X_GetStatus (); printf ("% ld", BatteryStatus); But Asserted at Filename source / BSP_Charger_BQ2407X.c, line no 162 Such an error occurs. I changed the type to match the C file, Battery status and voltage value can not be obtained in%. i need your help.