Microsoft.IoT.Lightning.Providers library contains a set of providers to interface with the on board controller buses through the Lightning direct memory mapped driver (DMAP).
The DMAP driver is an in-developement driver that provides GPIO performance improvements over the default inbox driver. to lean more about these performance improvements visit the Lightning Performance Testing page.
While DMAP driver offer GPIO performance improvements over the Inbox driver, controller commands are sent to the DMAP driver through user-mode memory mapped addresses for each of the controllers. An app that only uses the Lightning provider APIs, Microsoft.IoT.Lightning.Providers.*, or an Arduino Wiring sketch will be safe to use. However, a malicious app would be able to write directly to that memory and cause hardware/security issues. On a machine with only trusted apps, the DMAP is generally safe to use.
Additonally, samples showing how to use the different providers are available on GitHub ms-iot/BusProviders repository.
A quick way to start coding using the Lightning providers is to start with one of the samples in the GitHub ms-iot/BusProviders repository.
Each of the samples references the Lightning SDK and is configured properly to use the Lightning providers library.
Note, To run the samples, the DMAP driver need to be enabled using the Windows Devices Web Portal. Refer to the Lightning Setup Guide for detailed information on how to enable it.
Additionally, it’s straightforward to add the required Lightning providers Nuget reference and support to a new or existing application. Follow the steps below:
In your application, right click the project and click the “Manage NuGet Packages…” menu item
The NuGet Package Manager will open. In the Browse tab, search for the “Lightning SDK”, making sure to check the “Include prerelease” checkbox.
Select the latest version, and click “Install” to add the Lightning SDK to your project.
Follow any on-screen instructions if needed. When installation is complete, a reference to the Lightning SDK will be added to your project.
Add the code below to your manifest file, Package.appxmanifest.
Both capabilities must be added to the AppX manifest of your project under the
<Capabilities> node. Also, make sure to add the required namespaces to your manifest if needed.
To check if Lightning is enabled, the
LightningProvider.IsLightningEnabled property should be used. In general, it is always a good practice to verify if the Lightning driver is enabled before using the Lightning provider APIs.
The simplest way to use the providers is to set the Lightning Provider as the default inside your app.
The code below will, if the Lightning Provider is available, set
Microsoft.IoT.Lightning.Providers.LightningProvider as the default provider. Otherwise, when no default provider is explicitly set, the various busses will fall back to the default one.
After you have a controller for the desired bus, you can use it as you normally would.
If you want to use a different default provider, the sections below show how you can use the Lightning providers for individual busses.
using Microsoft.IoT.Lightning.Providers; using Windows.Devices; using Windows.Devices.Spi;
The following samples demonstrate using the Lightning providers with supported bus types:
Blinky (UI) with Lightning Provider demonstrates GPIO with Lightning Provider in a foreground application
BlinkyHeadless with Lightning Provider demonstrates GPIO with Lightning Provider in a headless application
SPIDisplay with Lightning Provider demonstrates the usage of the API to control a device using SPI with Lightning Provider
WeatherStation with Lightning Provider demonstrates interacting with a device using I2C with Lightning Provider
Windows SDK required for building and using the library is 10.0.10586.0 or higher which can be downloaded from here.
For more information on setting everything up, refer to our get started guide..
The Lightning Provider library depends on the Microsoft.IoT.Lightning Nuget package, which in turn depends on the Arduino SDK Nuget package. Both Nuget packages are referenced in the library projects, and are available from Nuget.org.
Currently, Microsoft.IoT.Lightning Nuget is still pre-release, so should be updated from Nuget.org, when newer versions are available.
In order to install prerelease (current) version of Microsoft.IoT.Lightning Nuget package as well as receive prerelease updates to the Lightning package, make sure to set the “Include prerelease” option in the Nuget Package Manager.
Lightning providers support is currently included in the Fall Update builds for Windows IoT Core. You can download a Windows 10 IoT Core image from our downloads page. Click on “Download Insider Preview” for your device type.
The APIs in the Lightning Provider library require the Lightning Direct Memory Mapped driver to be enabled on the target device. Both Raspberry Pi 2/3 and MinnowBoard Max have the driver available, but not enabled by default.
The driver can be enabled using the Windows Devices Web Portal. Refer to the Lightning Setup Guide for detailed information on how to enable the Lightning driver.
The driver can also be enabled with the DmapUtil command:
DmapUtil: Utility to turn the DMAP direct memory mapper driver on or off Usage: dmaputil.exe status|enable|disable status [-v] Print out whether dmap is currently enabled. Pass the -v flag for detailed configuration information. enable Enable dmap on next boot. disable Disable dmap on next boot.