How do I access GPIO, I²C, SPI, PWM, etc. in the Windows environment?

Currently I have two Intel NUC5i5MYBE motherboards. One board has WindRiver Linux and another one has Windows 10 Enterprise.

On Linux, I don't have any trouble while accessing all of the above, but problem with Windows environment.

In Windows, my target is to use the CreateFile function of Windows to open such interfaces.

But before I call this function I need to supply a device path to this function. For that, my target is to use the following functions as well as a data structure to find out the device path.

SetupDiGetClassDevs()

SetupDiEnumDeviceInterfaces()

SetupDiGetDeviceInterfaceDetail()

HDEVINFO

SP_DEVINFO_DATA

PSP_DEVICE_INTERFACE_DETAIL_DATA

But the major problem and unknown thing is how to supply a GUID to SetupDiGetClassDevs as the first argument?

The Windows prototype for SetupDiGetClassDevs is as follows.

HDEVINFO SetupDiGetClassDevs(
  _In_opt_ const GUID   *ClassGuid,
  _In_opt_       PCTSTR Enumerator,
  _In_opt_       HWND   hwndParent,
  _In_           DWORD  Flags
);
1

There are 1 answers

4
vijiboy On BEST ANSWER

For a known/specific device, you can find the Class Guid from its INF file OR from Registry - As this SO post suggests - Obtaining GUID for Existing USB Device on Windows XP. Then use this Class Guid in the call to SetupDiGetClassDevs

Guid From INF file: For accessing INF file entries Use SetupOpenInfFile, SetupFindFirstLine, and SetupGetStringField - as per this msdn document https://msdn.microsoft.com/en-us/library/windows/hardware/ff549402(v=vs.85).aspx

Guid From Registry: there are many posts to access registry keys like this SO post - How to read a value from the Windows registry

Finally do remember to destroy the DeviceInfo after you are finished using them like so:

    if (hdevinfo) {
    SetupDiDestroyDeviceInfoList(DeviceInfoSet);
    }