User manual
Page | 108
IOCTL Code
Descriptions
IOCTL_GPIO_SETBIT
The GPIO pin will be set as 1
IOCTL_GPIO_CLRBIT
The GPIO pin will be cleared
IOCTL_GPIO_GETBIT
Read the GPIO pin status
IOCTL_GPIO_SETMODE
Set the working mode of the GPIO pin
IOCTL_GPIO_GETMODE
Read the working mode of the GPIO pin
IOCTL_GPIO_GETIRQ
Read the corresponding IRQ number of the
GPIO pin
The tables below contain examples of GPIO applications;
1. Enable the GPIO device;
HANDLE hFile = CreateFile(_T("GIO1:"),
(GENERIC_READ|GENERIC_WRITE),
(FILE_SHARE_READ|FILE_SHARE_WRITE), 0, OPEN_EXISTING, 0, 0);
2. Set the working mode as reading GPIO;
DWORD id = 0, mode = 0;
3. Set the working mode of the GPIO;
DWORD pInBuffer[2];
pInBuffer[0] = id;
pInBuffer[1] = mode;
DeviceIoControl(hFile, IOCTL_GPIO_SETMODE, pInBuffer,
sizeof(pInBuffer), NULL, 0, NULL, NULL);
4. Read the working mode of the GPIO;
DeviceIoControl(hFile, IOCTL_GPIO_GETMODE, &id,
sizeof(DWORD), &mode, sizeof(DWORD), NULL, NULL);