請先看『使用說明』
GPIO Develop Utility under Windows
From LEXWiKi
(New page: Category:AllowPages == Introduction == GPIO Develop Utility can help you to develop tool to control GPIO device.<br /> == The binary file you can download from == <Google Drive> ...) |
(→How to use DLL) |
||
(10 intermediate revisions not shown.) | |||
Line 11: | Line 11: | ||
<Google Drive> | <Google Drive> | ||
- | DLL file(64 bit): [https://drive.google.com/file/d/ | + | DLL file(64 bit): [https://drive.google.com/file/d/1_4gumHIt2wbTG65l79O03aUnl48RjFz3/view?usp=sharing GPIOUtilityDll_v1.7.18.25_x64] |
- | Sample file(64 bit): [https://drive.google.com/file/d/ | + | Sample binary file(64 bit): [https://drive.google.com/file/d/1C8pfA5wB1D_T-v6lb7jLrxfPCvxVc4fn/view?usp=sharing GPIO_DLL_SAMPLE_Bin_v1.0.3.5_x64] |
- | Sample code: [https://drive.google.com/ | + | Sample source code: [https://drive.google.com/file/d/1nsCzM8L1nCRP6WzidRQU9Z0OcFt28S4k/view?usp=sharing GPIO_DLL_SAMPLE_Src_v1.0.3.5] |
<!-- | <!-- | ||
Line 36: | Line 36: | ||
'''LexIo64.dll、LexIo64.sys''': Based on WinIO that provids DLL to read hardware data. For x64.<br /> | '''LexIo64.dll、LexIo64.sys''': Based on WinIO that provids DLL to read hardware data. For x64.<br /> | ||
+ | |||
+ | |||
+ | == Support GPIO module == | ||
+ | |||
+ | '''F75111(Onboard)、F75111 EXT(CIO series)、F75113 SMBUS、F75113 LPC、F81966 LPC.'''<br /> | ||
+ | |||
== How to use DLL == | == How to use DLL == | ||
- | '''*Step1.''' Unzip | + | '''*Step1.''' Unzip DLL zip file and put files to your programe.<br /> |
+ | |||
+ | |||
+ | '''*Step2.''' Initialize GPIO module resource.<br /> | ||
+ | |||
+ | '''MODULE_GPIO_LIST_E''' defined in '''GPIOUtilityDll.h'''<br /> | ||
+ | |||
+ | enum MODULE_GPIO_LIST_E | ||
+ | { | ||
+ | /* GPIO */ | ||
+ | MODULE_GPIO_F75111 = 0, | ||
+ | MODULE_GPIO_F75111_EXT, | ||
+ | MODULE_GPIO_F75113, | ||
+ | MODULE_GPIO_F75113_LPC, | ||
+ | MODULE_GPIO_F81966_LPC, | ||
+ | }; | ||
+ | |||
+ | //------------------------------------------------------------------------------ | ||
+ | // Name : GPIODLL_InstallControlModule | ||
+ | // Description : Initial DLL supported GPIO device module. | ||
+ | // Arguments : | ||
+ | // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. | ||
+ | // Return : Enum of GPIO_ERR_CODE_E. Defined in "ModuleBase.h". | ||
+ | // GPIO_ERR_OK = 1, | ||
+ | // GPIO_ERR_UNKNOW_FAILED = 0, | ||
+ | // GPIO_ERR_SMBUS_FAILED = -1, | ||
+ | // GPIO_ERR_DEVICE_NOT_EXIST = -2, | ||
+ | // GPIO_ERR_WRITE_DATA_FAILED = -3, | ||
+ | //------------------------------------------------------------------------------ | ||
+ | GPIOUTILITYDLL_API int GPIODLL_InstallControlModule(int nModule); | ||
+ | |||
+ | |||
+ | '''*Step3.''' If you want control GPIO pin, setup DI pin and DO pin in CIO port.<br /> | ||
+ | |||
+ | '''GPIO_CIO_PORT_E''' defined in '''GPIOUtilityDll.h'''<br /> | ||
+ | Setup DI pin and DO pin. Use 1 byte to indicate the status of the Pins.<br /> | ||
+ | Digital output pin bit is 1; Digital input pin bit is 0.<br /> | ||
+ | (DI-0 is bit0, DI-1 is bit1, DI-2 is bit2 and DI-3 is bit3).<br /> | ||
+ | (DO-0 is bit4, DO-1 is bit5, DO-3 is bit6 and DO-3 is bit7).<br /> | ||
+ | |||
+ | Ex: Setup CIO is 4I/4O. bDIOBits = 0xF0 (1111 0000) => (OOOO IIII).<br /> | ||
+ | Ex: Setup CIO is 2I/2O. bDIOBits = 0x30 (0011 0000) => (OOII IIII).<br /> | ||
+ | |||
+ | enum GPIO_CIO_PORT_E | ||
+ | { | ||
+ | GPIO_CIO_1 = 1, | ||
+ | GPIO_CIO_2, | ||
+ | GPIO_CIO_3, | ||
+ | GPIO_CIO_4, | ||
+ | }; | ||
+ | |||
+ | //-------------------------------------------------------------------------- | ||
+ | // Name : GPIODLL_AddControlModuleToWatchList | ||
+ | // Description : Add GPIO device module to watch dog list. | ||
+ | // Arguments : | ||
+ | // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. | ||
+ | // nSwPort [in] : Enum of GPIO_CIO_PORT_E | ||
+ | // bDIOBits [in] : DI/DO bits. (Output bit is 1; Input bit is 0) | ||
+ | // nFilterDO [in] : Filter DO signal from GPIO module (default: TRUE) | ||
+ | // Return : | ||
+ | // TRUE : Success | ||
+ | // FALSE : Failed | ||
+ | //-------------------------------------------------------------------------- | ||
+ | GPIOUTILITYDLL_API int GPIODLL_AddControlModuleToWatchList(int nModule, int nSwPort, BYTE bDIOBits, int nFilterDO = TRUE); | ||
+ | |||
+ | |||
+ | '''*Step4.''' If you want Send DO signal once. Use 1 byte to indicate the digital output pins to be triggered.<br /> | ||
+ | |||
+ | Digital output pin bit is 1; Digital input pin bit is 0.<br /> | ||
+ | (DO-0 is bit4, DO-1 is bit5, DO-3 is bit6 and DO-3 is bit7).<br /> | ||
+ | |||
+ | Ex: Send CIO DO-0、DO-1、DO-2、DO-3 DO signal. bDOVal = 0xF0 (1111 0000) => (OOOO xxxx).<br /> | ||
+ | Ex: Send CIO DO-0、DO-3 DO signal. bDOVal = 0x90 (1001 0000) => (OxxO xxxx).<br /> | ||
+ | |||
+ | //-------------------------------------------------------------------------- | ||
+ | // Name : GPIODLL_SendDOValueToControlModule | ||
+ | // Description : Send digital out value to GPIO device module | ||
+ | // Arguments : | ||
+ | // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. | ||
+ | // nSwPort [in] : Enum of GPIO_CIO_PORT_E | ||
+ | // bDOVal [in] : Digital out value | ||
+ | // Return : | ||
+ | // TRUE : Success | ||
+ | // FALSE : Failed | ||
+ | //-------------------------------------------------------------------------- | ||
+ | GPIOUTILITYDLL_API int GPIODLL_SendDOValueToControlModule(int nModule, int nSwPort, BYTE bDOVal); | ||
+ | |||
+ | |||
+ | '''*Step5.''' If you want receive DI signal once. Use 1 byte to indicate the digital input pins status.<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); | ||
+ | |||
+ | |||
+ | '''*Step6.''' If you want enable WDT coutdown function and trigger shutdone after few seconds later.<br /> | ||
+ | |||
+ | 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.<br /> | |
- | + | //-------------------------------------------------------------------------- | |
+ | // 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); | ||
- | '''*Step2.''' Initialize PW601 resource.<br /> | ||
- | + | '''*Step8.''' If you want disable WDT coutdown function.<br /> | |
- | + | //-------------------------------------------------------------------------- | |
+ | // 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); | ||
- | [[Image:Use_DLL_2.png]] <br/> | ||
- | '''*Final Step.''' Release | + | '''*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); |
Current revision
Contents |
Introduction
GPIO Develop Utility can help you to develop tool to control GPIO device.
The binary file you can download from
<Google Drive>
DLL file(64 bit): GPIOUtilityDll_v1.7.18.25_x64
Sample binary file(64 bit): GPIO_DLL_SAMPLE_Bin_v1.0.3.5_x64
Sample source code: GPIO_DLL_SAMPLE_Src_v1.0.3.5
DLL files descreption
GPIOUtilityDll.dll: Contains code and data about GPIODLL function.
GPIOUtilityDll.h: Header about GPIODLL function.
GPIOUtilityDll.lib: Import library that link to GPIOUtilityDll.dll.
LexIo64.dll、LexIo64.sys: Based on WinIO that provids DLL to read hardware data. For x64.
Support GPIO module
F75111(Onboard)、F75111 EXT(CIO series)、F75113 SMBUS、F75113 LPC、F81966 LPC.
How to use DLL
*Step1. Unzip DLL zip file and put files to your programe.
*Step2. Initialize GPIO module resource.
MODULE_GPIO_LIST_E defined in GPIOUtilityDll.h
enum MODULE_GPIO_LIST_E { /* GPIO */ MODULE_GPIO_F75111 = 0, MODULE_GPIO_F75111_EXT, MODULE_GPIO_F75113, MODULE_GPIO_F75113_LPC, MODULE_GPIO_F81966_LPC, };
//------------------------------------------------------------------------------ // Name : GPIODLL_InstallControlModule // Description : Initial DLL supported GPIO device module. // Arguments : // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. // Return : Enum of GPIO_ERR_CODE_E. Defined in "ModuleBase.h". // GPIO_ERR_OK = 1, // GPIO_ERR_UNKNOW_FAILED = 0, // GPIO_ERR_SMBUS_FAILED = -1, // GPIO_ERR_DEVICE_NOT_EXIST = -2, // GPIO_ERR_WRITE_DATA_FAILED = -3, //------------------------------------------------------------------------------ GPIOUTILITYDLL_API int GPIODLL_InstallControlModule(int nModule);
*Step3. If you want control GPIO pin, setup DI pin and DO pin in CIO port.
GPIO_CIO_PORT_E defined in GPIOUtilityDll.h
Setup DI pin and DO pin. Use 1 byte to indicate the status of the Pins.
Digital output pin bit is 1; Digital input pin bit is 0.
(DI-0 is bit0, DI-1 is bit1, DI-2 is bit2 and DI-3 is bit3).
(DO-0 is bit4, DO-1 is bit5, DO-3 is bit6 and DO-3 is bit7).
Ex: Setup CIO is 4I/4O. bDIOBits = 0xF0 (1111 0000) => (OOOO IIII).
Ex: Setup CIO is 2I/2O. bDIOBits = 0x30 (0011 0000) => (OOII IIII).
enum GPIO_CIO_PORT_E { GPIO_CIO_1 = 1, GPIO_CIO_2, GPIO_CIO_3, GPIO_CIO_4, };
//-------------------------------------------------------------------------- // Name : GPIODLL_AddControlModuleToWatchList // Description : Add GPIO device module to watch dog list. // Arguments : // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. // nSwPort [in] : Enum of GPIO_CIO_PORT_E // bDIOBits [in] : DI/DO bits. (Output bit is 1; Input bit is 0) // nFilterDO [in] : Filter DO signal from GPIO module (default: TRUE) // Return : // TRUE : Success // FALSE : Failed //-------------------------------------------------------------------------- GPIOUTILITYDLL_API int GPIODLL_AddControlModuleToWatchList(int nModule, int nSwPort, BYTE bDIOBits, int nFilterDO = TRUE);
*Step4. If you want Send DO signal once. Use 1 byte to indicate the digital output pins to be triggered.
Digital output pin bit is 1; Digital input pin bit is 0.
(DO-0 is bit4, DO-1 is bit5, DO-3 is bit6 and DO-3 is bit7).
Ex: Send CIO DO-0、DO-1、DO-2、DO-3 DO signal. bDOVal = 0xF0 (1111 0000) => (OOOO xxxx).
Ex: Send CIO DO-0、DO-3 DO signal. bDOVal = 0x90 (1001 0000) => (OxxO xxxx).
//-------------------------------------------------------------------------- // Name : GPIODLL_SendDOValueToControlModule // Description : Send digital out value to GPIO device module // Arguments : // nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E. // nSwPort [in] : Enum of GPIO_CIO_PORT_E // bDOVal [in] : Digital out value // Return : // TRUE : Success // FALSE : Failed //-------------------------------------------------------------------------- GPIOUTILITYDLL_API int GPIODLL_SendDOValueToControlModule(int nModule, int nSwPort, BYTE bDOVal);
*Step5. If you want receive DI signal once. Use 1 byte to indicate the digital input pins status.
If digital input pin trigger, bit is 1; Else bit is 0. Digital output pin bit is always 1.
(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.
Ex: Receive bDIVal = 0xF9. If DI/DO is 0xF0 (OOOO IIII), then DI-0、DI-3 are triggered.
//-------------------------------------------------------------------------- // 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);
*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);