Characteristic Locus
Namespace Meadow.Hardware
Assembly Meadow.dll

Syntax

public interface IIODevice

Fields

DefaultA2DReferenceVoltage

Declaration
public const float DefaultA2DReferenceVoltage = 3.3F

Field Value

Type Description
System.Single

DefaultI2cBusSpeed

The default I2C Bus speed, in Hz, used when speed parameters are not provided

Declaration
public const int DefaultI2cBusSpeed = 100000

Field Value

Type Description
System.Int32

DefaultPwmDutyCycle

Declaration
public const float DefaultPwmDutyCycle = 0.5F

Field Value

Type Description
System.Single

DefaultPwmFrequency

Declaration
public const float DefaultPwmFrequency = 100F

Field Value

Type Description
System.Single

DefaultSpiBusSpeed

The default SPI Bus speed, in kHz, used when speed parameters are not provided

Declaration
public const int DefaultSpiBusSpeed = 375

Field Value

Type Description
System.Int32

Properties

Capabilities

Gets the device capabilities.

Declaration
DeviceCapabilities Capabilities { get; }

Property Value

Type Description
DeviceCapabilities

Methods

CreateAnalogInputPort(IPin, Single)

Declaration
IAnalogInputPort CreateAnalogInputPort(IPin pin, float voltageReference = 3.3F)

Parameters

Type Name Description
IPin pin
System.Single voltageReference

Returns

Type Description
IAnalogInputPort

CreateBiDirectionalPort(IPin, Boolean, InterruptMode, ResistorMode, PortDirectionType, Double, Double, OutputType)

Declaration
IBiDirectionalPort CreateBiDirectionalPort(IPin pin, bool initialState = false, InterruptMode interruptMode = InterruptMode.None, ResistorMode resistorMode = ResistorMode.Disabled, PortDirectionType initialDirection = PortDirectionType.Input, double debounceDuration = 0, double glitchDuration = 0, OutputType output = OutputType.PushPull)

Parameters

Type Name Description
IPin pin
System.Boolean initialState
InterruptMode interruptMode
ResistorMode resistorMode
PortDirectionType initialDirection
System.Double debounceDuration
System.Double glitchDuration
OutputType output

Returns

Type Description
IBiDirectionalPort

CreateDigitalInputPort(IPin, InterruptMode, ResistorMode, Double, Double)

Declaration
IDigitalInputPort CreateDigitalInputPort(IPin pin, InterruptMode interruptMode = InterruptMode.None, ResistorMode resistorMode = ResistorMode.Disabled, double debounceDuration = 0, double glitchDuration = 0)

Parameters

Type Name Description
IPin pin
InterruptMode interruptMode
ResistorMode resistorMode
System.Double debounceDuration
System.Double glitchDuration

Returns

Type Description
IDigitalInputPort

CreateDigitalOutputPort(IPin, Boolean, OutputType)

Declaration
IDigitalOutputPort CreateDigitalOutputPort(IPin pin, bool initialState = false, OutputType initialOutputType = OutputType.PushPull)

Parameters

Type Name Description
IPin pin
System.Boolean initialState
OutputType initialOutputType

Returns

Type Description
IDigitalOutputPort

CreateI2cBus(IPin, IPin, Int32)

Creates an I2C bus instance for the requested pins and bus speed

Declaration
II2cBus CreateI2cBus(IPin clock, IPin data, int frequencyHz = 100000)

Parameters

Type Name Description
IPin clock
IPin data
System.Int32 frequencyHz

The bus speed in (in Hz)

Returns

Type Description
II2cBus

An instance of an I2cBus

CreateI2cBus(IPin[], Int32)

Creates an I2C bus instance for the requested pins and bus speed

Declaration
II2cBus CreateI2cBus(IPin[] pins, int frequencyHz = 100000)

Parameters

Type Name Description
IPin[] pins
System.Int32 frequencyHz

The bus speed in (in Hz)

Returns

Type Description
II2cBus

An instance of an I2cBus

CreatePwmPort(IPin, Single, Single, Boolean)

Declaration
IPwmPort CreatePwmPort(IPin pin, float frequency = 100F, float dutyCycle = 0.5F, bool invert = false)

Parameters

Type Name Description
IPin pin
System.Single frequency
System.Single dutyCycle
System.Boolean invert

Returns

Type Description
IPwmPort

CreateSerialMessagePort(SerialPortName, Byte[], Boolean, Int32, Int32, Parity, StopBits, Int32)

Initializes a new instance of the ISerialMessagePort class that listens for serial messages defined byte[] message termination suffix.

Declaration
ISerialMessagePort CreateSerialMessagePort(SerialPortName portName, byte[] suffixDelimiter, bool preserveDelimiter, int baudRate = 9600, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One, int readBufferSize = 512)

Parameters

Type Name Description
SerialPortName portName

The 'SerialPortName` of port to use.

System.Byte[] suffixDelimiter

A byte[] of the delimiter(s) that denote the end of the message.

System.Boolean preserveDelimiter

Whether or not to preseve the delimiter tokens when passing the message to subscribers.

System.Int32 baudRate

Speed, in bits per second, of the serial port.

System.Int32 dataBits

Number of data bits expected in the serial message frame. Default is 8.

Parity parity

Parity enum describing what type of cyclic-redundancy-check (CRC) bit, if any, should be expected in the serial message frame. Default is Parity.None.

StopBits stopBits

StopBits describing how many bits should be expected at the end of every character in the serial message frame. Default is StopBits.One.

System.Int32 readBufferSize

Size, in bytes, of the read buffer. Default is 512.

Returns

Type Description
ISerialMessagePort

CreateSerialMessagePort(SerialPortName, Byte[], Boolean, Int32, Int32, Int32, Parity, StopBits, Int32)

Initializes a new instance of the ISerialMessagePort class that listens for serial messages defined by a byte[] prefix, and a fixed length.

Declaration
ISerialMessagePort CreateSerialMessagePort(SerialPortName portName, byte[] prefixDelimiter, bool preserveDelimiter, int messageLength, int baudRate = 9600, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One, int readBufferSize = 512)

Parameters

Type Name Description
SerialPortName portName

The 'SerialPortName` of port to use.

System.Byte[] prefixDelimiter

A byte[] of the delimiter(s) that denote the beginning of the message.

System.Boolean preserveDelimiter

Whether or not to preseve the delimiter tokens when passing the message to subscribers.

System.Int32 messageLength

Length of the message, not including the delimiter, to be parsed out of the incoming data.

System.Int32 baudRate

Speed, in bits per second, of the serial port.

System.Int32 dataBits

Number of data bits expected in the serial message frame. Default is 8.

Parity parity

Parity enum describing what type of cyclic-redundancy-check (CRC) bit, if any, should be expected in the serial message frame. Default is Parity.None.

StopBits stopBits

StopBits describing how many bits should be expected at the end of every character in the serial message frame. Default is StopBits.One.

System.Int32 readBufferSize

Size, in bytes, of the read buffer. Default is 512.

Returns

Type Description
ISerialMessagePort

CreateSerialPort(SerialPortName, Int32, Int32, Parity, StopBits, Int32)

Initializes a new instance of a ISerialPort. When parsing text data, we recommend using the more modern, thread-safe ISerialMessagePort.

Declaration
ISerialPort CreateSerialPort(SerialPortName portName, int baudRate = 9600, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One, int readBufferSize = 1024)

Parameters

Type Name Description
SerialPortName portName

The 'SerialPortName` of port to use.

System.Int32 baudRate

Speed, in bits per second, of the serial port.

System.Int32 dataBits

Number of data bits expected in the serial message frame. Default is 8.

Parity parity

Parity enum describing what type of cyclic-redundancy-check (CRC) bit, if any, should be expected in the serial message frame. Default is Parity.None.

StopBits stopBits

StopBits describing how many bits should be expected at the end of every character in the serial message frame. Default is StopBits.One.

System.Int32 readBufferSize

Size, in bytes, of the read buffer. Default is 1024.

Returns

Type Description
ISerialPort

CreateSpiBus(IPin, IPin, IPin, SpiClockConfiguration)

Creates a SPI bus instance for the requested control pins and bus speed

Declaration
ISpiBus CreateSpiBus(IPin clock, IPin mosi, IPin miso, SpiClockConfiguration config)

Parameters

Type Name Description
IPin clock

The IPin instance to use as the bus clock

IPin mosi

The IPin instance to use for data transmit (master out/slave in)

IPin miso

The IPin instance to use for data receive (master in/slave out)

SpiClockConfiguration config

The bus clock configuration parameters

Returns

Type Description
ISpiBus

An instance of an IISpiBus

CreateSpiBus(IPin, IPin, IPin, Int64)

Creates a SPI bus instance for the requested control pins and bus speed

Declaration
ISpiBus CreateSpiBus(IPin clock, IPin mosi, IPin miso, long speedkHz = 375L)

Parameters

Type Name Description
IPin clock

The IPin instance to use as the bus clock

IPin mosi

The IPin instance to use for data transmit (master out/slave in)

IPin miso

The IPin instance to use for data receive (master in/slave out)

System.Int64 speedkHz

The bus speed (in kHz)

Returns

Type Description
ISpiBus

An instance of an IISpiBus

SetClock(DateTime)

Sets the device time

Declaration
void SetClock(DateTime dateTime)

Parameters

Type Name Description
System.DateTime dateTime

SetSynchronizationContext(SynchronizationContext)

Meadow Internal method for setting the device's primary (i.e. entry) SynchronizationContext

Declaration
void SetSynchronizationContext(SynchronizationContext context)

Parameters

Type Name Description
System.Threading.SynchronizationContext context