We no longer sell products directly from the GHI Electronics website, click here for more details. Please find a Distributor to complete your online order. If you have any questions regarding this notice please contact us at support@ghielectronics.com.

Plain NETMF On Gadgeteer

Last modified April 14, 2015

Required

Tutorials: First Gadgeteer Project

Introduction

Have you ever needed to use a feature not provided by a module, such as SerialPort, but don't know how to access the pins or COM Port name? Maybe you're prototyping something or using a non-Gadgeteer module with a Gadgeteer board/project. This page will show you how to do just that. Most examples on this page require the Microsoft.SPOT.Hardware assembly. Make sure that the socket you are trying to get a definition from supports it, such as getting PWM only on P type sockets.

Retrieve a pin for a specific socket

If you are looking to get a specific pin to use in a method, such as pin 3 on socket 2, you can use:

Cpu.Pin pin = GT.Socket.GetSocket(2, true, null, null).CpuPins[3];

Retrieve the COM port for a specific socket

If you want to get the COM port for the socket, such as socket 5, that you are currently using as a string to pass to a method, use:

string COMPort = GT.Socket.GetSocket(5, true, null, null).SerialPortName;

Retrieve the SPI module on a specific socket

If you want to get the SPI module for the socket, such as socket 1, that you are currently using, use:

SPI.SPI_module spi = GT.Socket.GetSocket(1, true, null, null).SPIModule;

Retrieve common interfaces on a specific socket

If you want to get a specific interface on the socket, such as PWM or Analog In/Out on socket 1, use the below code. You can then pass those values to the constructors on the specific port in Microsoft.SPOT.Hardware.

Cpu.AnalogChannel ain3 = GT.Socket.GetSocket(1, true, null, null).AnalogInput3; 
Cpu.AnalogChannel ain4 = GT.Socket.GetSocket(1, true, null, null).AnalogInput4; 
Cpu.AnalogChannel ain5 = GT.Socket.GetSocket(1, true, null, null).AnalogInput5;
 
Cpu.AnalogOutputChannel aout = GT.Socket.GetSocket(1, true, null, null).AnalogOutput;
 
Cpu.PWMChannel pwm7 = GT.Socket.GetSocket(1, true, null, null).PWM7; 
Cpu.PWMChannel pwm8 = GT.Socket.GetSocket(1, true, null, null).PWM8; 
Cpu.PWMChannel pwm9 = GT.Socket.GetSocket(1, true, null, null).PWM9;
Leave feedback about this document.
Let us know if the information presented here was accurate, helpful and if you have any suggestions.
Leave feedback about this document.
Let us know if the information presented here was accurate, helpful and if you have any suggestions.

* Indicates required fields.
This form is only for feedback not support.
Review our how to find information guide on locating helpful resources.