none
Modifying SpbAccelerometer sample to GPIO Expansion device RRS feed

  • Question

  • Hello everyone,

    I intend to develop a an application that allows me to read and write bytes to a device connected to the I2C controller (I'm using NUC DE3815TYKHE.)

    The sample project that seems closest to what I need is the SpbAccelerometer example, which is shown on the MSDN Guide (SpbAccelerometer driver cookbook) . The guide is quite brief but the sample solution is huge (the source code alone might have exceeded 10000 lines of code!) which leaves me slightly overwhelmed. I have been trying to understand the code for a week now, but I suspect that I may be approaching this the wrong way.

    Can someone give me a pointer? I'm not sure where the entry point is.

    Should I be calling the methods in the Device class? How do I know which methods can be called?


    • Edited by Yu Ang Monday, October 13, 2014 6:33 AM
    Monday, October 13, 2014 6:32 AM

Answers

  • As noted in the description associated with the driver, it is a UMDF (User Mode Driver Framework) version 1.0 driver. UMDF was a user-mode implementation of WDF (Windows Driver Foundation) that was frankly, ill-conceived (it used COM and was very different from KMDF). While it is a little dated, Penny's book is a great way to learn WDF.

    Thankfully, UMDF 1.0 was retired in favor of UMDF 2.0, which is almost exactly the same as KMDF - but I believe that it only runs on Win8.1 and later. If you can live with Win8.1+, then you should look at the GPIO sample drivers in the WDK and build them for UMDF. They are much smaller (~2,500 lines) and you could get them to work in user-mode without too much trouble (or stay in kernel-mode).

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Monday, October 13, 2014 9:15 PM
    Moderator

All replies

  • As noted in the description associated with the driver, it is a UMDF (User Mode Driver Framework) version 1.0 driver. UMDF was a user-mode implementation of WDF (Windows Driver Foundation) that was frankly, ill-conceived (it used COM and was very different from KMDF). While it is a little dated, Penny's book is a great way to learn WDF.

    Thankfully, UMDF 1.0 was retired in favor of UMDF 2.0, which is almost exactly the same as KMDF - but I believe that it only runs on Win8.1 and later. If you can live with Win8.1+, then you should look at the GPIO sample drivers in the WDK and build them for UMDF. They are much smaller (~2,500 lines) and you could get them to work in user-mode without too much trouble (or stay in kernel-mode).

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Monday, October 13, 2014 9:15 PM
    Moderator
  • Hi Yu,

    There’s documentation in MSDN for extending the sample to support new devices - http://msdn.microsoft.com/en-us/library/windows/hardware/dn760711(v=vs.85).aspx

    Registers used by this sample are defined in ADXL345.h. To extend the sample to the new device update the register address and values defined here (As long as the new device is another sensor this sample can be used as a template). Register addresses are defined in Ln 30-59.

    Code that interacts with the device (sending read/write requests) is in AccelerometerDevice.cpp. Functions inside CAccelerometerDevice all read/write to registers:

    CAccelerometerDevice::ConfigureHardware()

    CAccelerometerDevice::SetReportInterval()

    CAccelerometerDevice::SetChangeSensitivity()

    CAccelerometerDevice::RequestNewData()

    CAccelerometerDevice::SetDeviceStateStandby()

    CAccelerometerDevice::SetDeviceStatePolling()

    CAccelerometerDevice::SetDeviceStateEventing()

    These functions use methods exposed by CSpbRequest class. CSpbRequest in turn uses a remote IO target that it opens to the SPB Controller.

    The sample also demonstrates how to setup handlers for GPIO interrupts (inside CAccelerometerDevice::ConnectInterrupt and CAccelerometerDevice:: OnInterruptIsr).

    To extend this sample to other device, start first by looking at the datasheet of ADXL345 and then the code inside CAccelerometerDevice to see how interactions work. The HTML file (SpbAccelerometer.htm) also goes over the organization of the sample.

    Check out the documentation in - http://msdn.microsoft.com/en-us/library/windows/hardware/dn760709(v=vs.85).aspx. It goes over driver initialization and other entry points.

     Hope this will help you get started.


    Monday, October 13, 2014 11:09 PM