Monday, November 30, 2015

GPIO pins allocation under windows 10 IOT build on Raspberry PI

The Windows 10 IOT documentation https://ms-iot.github.io/
indicates that only the following pins are available 4,5,6,12,13,16,17,18,19,20,21,22,23,24,25,26,27 for GPIO.

If you wonder why so many pins are not usable as GPIO. This is because
  • GPIO 2, and 3 are reserved for I2C interface
  • GPIO 7,8,9,10,11 are reserved for SPIO interface
  • GPIO 14,15 are reserved for UART interface.


Note that 35 and 47 are also available but they drive LEDs soldered on the board and not pins on the GPIO connector.

If you are still using Windows10 IOT build 10.0.10240 you must know that for some unknown reasons the Raspberry PI GPIO pins 17, 19, 20, 21 are not usable. I think this is a very good reason to update to build 10.0.10556.

 

Program To list all the available GPIOs

 
I have developed a small program that list all the available GPIOs.
 
The XAML is the following
 

<Page
x:Class="CountGPIO.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CountGPIO"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock x:Name="TextblockOutput" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
</Page>

 
 
And the C# code associated
 

using System;
using Windows.Devices.Gpio;
using Windows.UI.Xaml.Controls;
namespace CountGPIO
{
  public sealed partial class MainPage : Page

  {
    private GpioController gpio;

    public MainPage()
    {
    this.InitializeComponent();

    gpio = GpioController.GetDefault();
    this.TextblockOutput.Text = "List of Supported GPIO pins:" +  Environment.NewLine;
    for (int port = 0; port < 64; port++)
     {
     try

      {
      gpio.OpenPin(port);
      this.TextblockOutput.Text += "GPIO Pin: " + port.ToString() + " is OK" + Environment.NewLine;

      }
     catch (Exception)

      { }
     }
    }
  }
}
 


No comments:

Post a Comment