GPIO driver development

Write a driver for a general-purpose I/O (GPIO) controller or for a peripheral device that connects to GPIO pins on that controller.

A GPIO controller driver handles I/O requests to read or write to groups of GPIO pins. Typically, these pins are used to communicate with peripheral devices that are attached to computer motherboards or that are embedded in mobile devices, such as smart phones.

A peripheral device that transfers data over a serial or parallel bus might, in addition, connect to GPIO pins that receive interrupt requests from the device or that send data to or from the device.

Support in Windows versions

  • Starting with Windows 10, the driver programming interfaces are part of OneCoreUAP-based editions of Windows. By using that common set, you can write a drivers for GPIO controllers and for GPIO-connected peripheral devices. Those drivers will run on both Windows 10 for desktop editions (Home, Pro, Enterprise, and Education) and Windows 10 Mobile, as well as other Windows 10 versions.

  • Windows 8 introduced driver support for GPIO.

Microsoft-provided binaries for GPIO

Windows includes GPIO driver support through these in-box binaries.

Note  These binaries are included in OneCoreUAP-based editions of Windows.
 
  • GPIO framework extension (GpioClx) driver, Msgpioclx.sys. This extension driver simplifies the task of writing GPIO controller drivers, and provides driver support for peripheral devices that connect to GPIO pins.

  • GpioClx stub library for GPIO framework extension driver, Msgpioclxstub.lib.

Develop a GPIO controller driver

A GPIO controller driver configures GPIO pins to function as low-bandwidth data I/O channels and as inputs for device interrupts. The driver handles I/O requests to read or write to groups of GPIO pins. Typically, these pins are used to communicate with peripheral devices that are attached to computer motherboards or that are embedded in mobile devices, such as smart phones.

Your GPIO controller driver is a kernel-mode driver framework (KMDF) driver that statically links to Msgpioclxstub.lib. At run time, Msgpioclxstub.lib dynamically links to Msgpioclx.sys. Your driver communicates with Msgpioclx.sys.

Develop a peripheral driver

A peripheral device driver can transfer data to or from a set of GPIO I/O pins, and can logically connect an interrupt service routine (ISR) to a GPIO interrupt pin.

Your driver for the peripheral device can be a KMDF or user-mode driver framework (UMDF) driver.

Note  If you intend to write a user-mode driver that runs on OneCoreUAP-based editions of Windows, it must use UMDF 2.0 programming interfaces. UMDF 1.0 drivers are not supported on those editions.
 

Documentation sections

Describes how to design a GPIO controller driver that uses the GPIO framework extension. Additionally describes how the driver for a peripheral device can use GPIO pins to communicate with the device.

GPIO driver design guide (GPIO controller driver)

Getting Started with Windows Drivers

Write a UMDF driver based on a template

Write a KMDF driver based on a template

Programming interfaces for developing an GPIO controller

Describes the structures, methods, and event callback functions that are defined by the GPIO framework extension to support GPIO controller drivers. Additionally describes the GPIO-specific I/O control requests (IOCTLs) that peripheral device drivers use to communicate with devices that connect to GPIO pins.

Note  These programming interfaces are included in OneCoreUAP-based editions of Windows.
 

General-Purpose I/O (GPIO) Driver Reference

WDF Reference

Create a Universal Windows driver for GPIO peripheral device drivers

For step-by-step guidance, see Getting Started with Universal Windows drivers. Here is a summary of the steps:

  1. Create a skeleton driver project based on either the User Mode Driver (UMDF V2) or Kernel Mode Driver (KMDF) driver templates in the unified WDK.

  2. In the project properties, set Target Platform to Universal.

  3. Create an installation package:

    • If your target is a device that is running Windows 10 for desktop editions, see Using a Universal INF File and InfVerif.

    • If your target is a device that is running Windows 10 Mobile, use PkgGen to generate an .spkg file.

  4. Build, install, deploy, and debug the driver for Windows 10.

Convert an existing GPIO driver to a universal driver

  1. Determine whether your existing driver calls will run on OneCoreUAP Windows.

    • Use the ApiValidator.exe tool included in the Windows Driver Kit (WDK) for Windows 10. See, Validating Universal Windows drivers.
    • Check the Requirements section of the reference page.
  2. Recompile your driver as a universal driver. In the project properties, set Target Platform to Universal.

  3. If the driver calls interfaces that are not part of OneCoreUAP, the compiler displays errors.

  4. Replace those calls with alternate calls, or have a code workaround, or write a new driver.

GPIO samples

GPIO sample drivers contains a collection of these sample drivers:

  • SimGpio (GPIO controller driver)
  • SimGpio_I2C (GPIO controller driver)
  • SimDevice (Peripheral device driver - KMDF)
  • SimDeviceUmdf (Peripheral device driver - UMDF 1.0)
Note  Mobile and Universal Windows drivers do not support UMDF versions older than 2.0.
 

 

 

 

Send comments about this topic to Microsoft

Show: