Battery Status Workaround for Workbench 3.1
응답
17. 11. 15 오전 8:08

Hello,

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,

Christopher Koch

0 (0 투표)
RE: Battery Status Workaround for Workbench 3.1
응답
17. 11. 15 오후 2:28 as a reply to BCDS Tester.

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:

#ifndef SDK_XDK110_PLATFORM_ESSENTIALS_INCLUDE_BSP_BCDS_BSP_CHARGER_BQ2405X_H_
#define SDK_XDK110_PLATFORM_ESSENTIALS_INCLUDE_BSP_BCDS_BSP_CHARGER_BQ2405X_H_

Retcode_T BSP_Charger_BQ2405X_Connect(void);
int32_t BSP_Charger_BQ2405X_MeasureSignal(uint32_t);
Retcode_T BSP_Charger_BQ2405X_Enable(uint32_t);
Retcode_T BSP_Charger_BQ2405X_Disable(void);
uint32_t BSP_Charger_BQ2405X_GetStatus(void);
Retcode_T BSP_Charger_BQ2405X_Disconnect(void);

#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.
 

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

0 (0 투표)
RE: Battery Status Workaround for Workbench 3.1
응답
18. 6. 19 오전 1:16 as a reply to Franjo Stjepandic.

Hello

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.

0 (0 투표)
RE: Battery Status Workaround for Workbench 3.1
응답
18. 6. 19 오전 11:36 as a reply to jang.
Hello jang,

I answered your questions in your other thread Battery Status .
Please take a look at it.

Kind regards,
Franjo
0 (0 투표)