請先看『使用說明』
Battery Develop Utility under Windows
From LEXWiKi
(→How to use DLL) |
(→How to use DLL) |
||
Line 45: | Line 45: | ||
== How to use DLL == | == How to use DLL == | ||
- | '''*Step1.''' Unzip DLL zip file and put files to your | + | '''*Step1.''' Unzip DLL zip file and put files to your program.<br /> |
Line 72: | Line 72: | ||
- | '''*Step3.''' | + | '''*Step3.''' If power board module initialize succeed, you could call PW_CheckPWModuleExist() to check device is still exist or not.<br /> |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||
Line 86: | Line 86: | ||
- | '''*Step4.''' If you | + | '''*Step4.''' If power board module initialize succeed, you could call PW_GetBatteryAllInfo() to get based battery information at the power board.<br /> |
- | + | '''BATTERY_INFO_ST''' structure content please refer to '''PWUtilityDll DLL Function Guide'''<br /> | |
- | + | ||
- | + | typedef struct _BATTERY_INFO_ST | |
- | + | { | |
+ | int nBtExist; | ||
+ | TCHAR tcBatteryName[32]; | ||
+ | int nPwModule; | ||
+ | int nChargeStatus; | ||
+ | LONGLONG llTimestampSec; | ||
+ | float fTemperature; //Unit: Kelvin | ||
+ | float fCurrent; | ||
+ | float fVoltage; | ||
+ | float fOutputVoltage; | ||
+ | int nChargePercent; | ||
+ | long lBtLeftMins; | ||
+ | long lWarnBits; | ||
+ | int nCycleCount; | ||
+ | int nIsShutdown; | ||
+ | long lBatteryStatus; | ||
+ | long lSafetyStatus; | ||
+ | long lSafetyAlert; | ||
+ | long lGaugingStatus; | ||
+ | long lOperationStatus; | ||
+ | long lPFStatus; | ||
+ | long lPFAlert; | ||
+ | } BATTERY_INFO_ST; | ||
- | //-------------------------------------------------------------------------- | + | //------------------------------------------------------------------------------ |
- | // Name : | + | // Name : PW_GetBatteryAllInfo |
- | // Description : | + | // Description : Get All of battery information |
// Arguments : | // Arguments : | ||
- | // nModule [in] : | + | // nModule [in] : PW module |
- | // | + | // pValStruct [out] : Battery information structure. (BATTERY_INFO_ST) |
- | + | ||
// Return : | // Return : | ||
// TRUE : Success | // TRUE : Success | ||
// FALSE : Failed | // FALSE : Failed | ||
- | //-------------------------------------------------------------------------- | + | //------------------------------------------------------------------------------ |
- | + | PWUTILITYDLL_API int PW_GetBatteryAllInfo(int nModule, void* pValStruct); | |
- | '''*Step5.''' If you want | + | '''*Step5.''' If you want to get single piece of information.<br /> |
- | If digital input pin trigger, bit is 1; Else bit is 0. Digital output pin bit is always 1.<br /> | ||
- | (DI-0 is bit0, DI-1 is bit1, DI-2 is bit2 and DI-3 is bit3). | ||
- | |||
- | Ex: Receive bDIVal = 0xFF. If DI/DO is 0xF0 (OOOO IIII), then DI-0、DI-1、DI-2、DI-3 are triggered.<br /> | ||
- | Ex: Receive bDIVal = 0xF9. If DI/DO is 0xF0 (OOOO IIII), then DI-0、DI-3 are triggered.<br /> | ||
- | |||
- | //-------------------------------------------------------------------------- | ||
- | // Name : GPIODLL_GetDIValueFromControlModule | ||
- | // Description : Get digital in value from GPIO device module | ||
- | // Arguments : | ||
- | // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. | ||
- | // nSwPort [in] : Enum of GPIO_CIO_PORT_E | ||
- | // bDIVal [out] : Digital in value | ||
- | // Return : | ||
- | // TRUE : Success | ||
- | // FALSE : Failed | ||
- | //-------------------------------------------------------------------------- | ||
- | GPIOUTILITYDLL_API int GPIODLL_GetDIValueFromControlModule(int nModule, int nSwPort, BYTE &bDIVal); | ||
Revision as of 19:08, 10 February 2025
Contents |
Introduction
Power Board Develop Utility can help you to develop tool to control LEX power board device.
Support power board module
PW405、PW407、PW601.
The binary file you can download from
DLL files descreption
PWUtilityDll.dll: Contains code and data about PWUtilityDll function.
PWUtilityDll.h: Header about PWUtilityDll function.
PWUtilityDll.lib: Import library that link to PWUtilityDll.dll.
LexIo64.dll、LexIo64.sys: Based on WinIO that provids DLL to read hardware data. For x64.
How to use DLL
*Step1. Unzip DLL zip file and put files to your program.
*Step2. Initialize power board module resource.
PW_MODULE_E defined in PWUtilityDll.h
enum PW_MODULE_E { PW_MODULE_PW405 = 0, PW_MODULE_PW407, PW_MODULE_PW601, PW_MODULE_NUM, //Used to record the number of modules };
//------------------------------------------------------------------------------ // Name : PW_InstallPwModule // Description : Initial PW module resource // Arguments : // nModule [in] : PW module. Enum of PW_MODULE_E. // Return : // TRUE : Success // FALSE : Failed //------------------------------------------------------------------------------ PWUTILITYDLL_API int PW_InstallPwModule(int nModule);
*Step3. If power board module initialize succeed, you could call PW_CheckPWModuleExist() to check device is still exist or not.
//------------------------------------------------------------------------------ // Name : PW_CheckPWModuleExist // Description : Check specific PW module exist or not. // Arguments : // nModule [in] : PW module. Enum of PW_MODULE_E. // Return : // TRUE : PW module exist // FALSE : PW module does not exist //------------------------------------------------------------------------------ PWUTILITYDLL_API int PW_CheckPWModuleExist(int nModule);
*Step4. If power board module initialize succeed, you could call PW_GetBatteryAllInfo() to get based battery information at the power board.
BATTERY_INFO_ST structure content please refer to PWUtilityDll DLL Function Guide
typedef struct _BATTERY_INFO_ST { int nBtExist; TCHAR tcBatteryName[32]; int nPwModule; int nChargeStatus; LONGLONG llTimestampSec; float fTemperature; //Unit: Kelvin float fCurrent; float fVoltage; float fOutputVoltage; int nChargePercent; long lBtLeftMins; long lWarnBits; int nCycleCount; int nIsShutdown; long lBatteryStatus; long lSafetyStatus; long lSafetyAlert; long lGaugingStatus; long lOperationStatus; long lPFStatus; long lPFAlert; } BATTERY_INFO_ST;
//------------------------------------------------------------------------------ // Name : PW_GetBatteryAllInfo // Description : Get All of battery information // Arguments : // nModule [in] : PW module // pValStruct [out] : Battery information structure. (BATTERY_INFO_ST) // Return : // TRUE : Success // FALSE : Failed //------------------------------------------------------------------------------ PWUTILITYDLL_API int PW_GetBatteryAllInfo(int nModule, void* pValStruct);
*Step5. If you want to get single piece of information.
*Step6. If you want enable WDT coutdown function and trigger shutdone after few seconds later.
You could update the trigger time by calling GPIODLL_StartWatchDogTimer() repeatedly.\n");
//-------------------------------------------------------------------------- // Name : GPIODLL_StartWatchDogTimer // Description : Start running watch dog timer in device module. // Arguments : // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. // nUnit [in] : Time unit (0: 1sec, 1: 60 sec) // nCount [in] : Watch dog timer range.(0~255) // Return : // TRUE : Success // FALSE : Failed //-------------------------------------------------------------------------- GPIOUTILITYDLL_API int GPIODLL_StartWatchDogTimer(int nModule, int nUnit, int nCount);
*Step7. If you want to know WDT countdown remaining seconds.
//-------------------------------------------------------------------------- // Name : GPIODLL_GetWatchDogCountdownSeconds // Description : Get watch dog timer countdown time in device module. // Arguments : // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. // nTimerSec [out] : Countdown time seconds.(0~255) // Return : // TRUE : Success // FALSE : Failed //-------------------------------------------------------------------------- GPIOUTILITYDLL_API int GPIODLL_GetWatchDogCountdownSeconds(int nModule, int& nTimerSec);
*Step8. If you want disable WDT coutdown function.
//-------------------------------------------------------------------------- // Name : GPIODLL_StopWatchDogTimer // Description : Stop watch dog timer in device module. // Arguments : // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. // Return : // TRUE : Success // FALSE : Failed //-------------------------------------------------------------------------- GPIOUTILITYDLL_API int GPIODLL_StopWatchDogTimer(int nModule);
*Final Step. Release GPIO resource before leaving your program.
//------------------------------------------------------------------------------ // Name : GPIODLL_FreeControlModule // Description : Free DLL supported GPIO device module. // Arguments : // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. // Return : // TRUE : Success // FALSE : Failed //------------------------------------------------------------------------------ GPIOUTILITYDLL_API int GPIODLL_FreeControlModule(int nModule);