Skip to main content

Class Sc16is7x2

Represents an Sc16is7x2 SPI/I2C dual UART (with 8 GPIO's)

Assembly: Sc16is7x2.dll
View Source
Declaration
public abstract class Sc16is7x2 : ISerialController, IDigitalInputOutputController, IDigitalInputController, IDigitalOutputController, IPinController, II2cPeripheral, ISpiPeripheral

Derived:
Meadow.Foundation.ICs.IOExpanders.Sc16is752

Implements:
Meadow.Hardware.ISerialController, Meadow.Hardware.IDigitalInputOutputController, Meadow.Hardware.IDigitalInputController, Meadow.Hardware.IDigitalOutputController, Meadow.Hardware.IPinController, Meadow.Hardware.II2cPeripheral, Meadow.Hardware.ISpiPeripheral

Properties

PortA

The port name for Port A

View Source
Declaration
public Sc16is7x2.Sc16SerialPortName PortA { get; }

PortB

The port name for Port B

View Source
Declaration
public Sc16is7x2.Sc16SerialPortName PortB { get; }

Pins

03.12.2023: Sc16is7x2 pin definitions for GPIO pins.

View Source
Declaration
public Sc16is7x2.PinDefinitions Pins { get; }

DefaultI2cAddress

The default I2C address for the peripheral

View Source
Declaration
public byte DefaultI2cAddress { get; }

MaxI2cBusSpeed

The maximum I2C bus speed for the peripheral

View Source
Declaration
public I2cBusSpeed MaxI2cBusSpeed { get; }

DefaultSpiBusMode

The default SPI bus mode for the peripheral

View Source
Declaration
public SpiClockConfiguration.Mode DefaultSpiBusMode { get; }

DefaultSpiBusSpeed

The default SPI bus frequency for the peripheral

View Source
Declaration
public Frequency DefaultSpiBusSpeed { get; }

SpiBusMode

The current SPI bus mode for the peripheral

View Source
Declaration
public SpiClockConfiguration.Mode SpiBusMode { get; set; }

SpiBusSpeed

The current SPI bus frequency for the peripheral

View Source
Declaration
public Frequency SpiBusSpeed { get; set; }

Methods

CreateSerialPort(SerialPortName, int, int, Parity, StopBits, int)

Creates an RS232 Serial Port

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

Meadow.Hardware.ISerialPort

Parameters
TypeNameDescription
Meadow.Hardware.SerialPortNameportNameThe Sc16SerialPortName name of the channel to create
System.Int32baudRateThe baud rate used in communication
System.Int32dataBitsThe data bits used in communication
Meadow.Hardware.ParityparityThe parity used in communication
Meadow.Hardware.StopBitsstopBitsThe stop bits used in communication
System.Int32readBufferSizeThe software FIFO read buffer size. (Not the 64 bytes on chip FIFO)

CreateRs485SerialPort(Sc16SerialPortName, int, int, Parity, StopBits, bool)

Creates an RS485 Serial Port

View Source
Declaration
public ISerialPort CreateRs485SerialPort(Sc16is7x2.Sc16SerialPortName portName, int baudRate = 9600, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One, bool invertDE = false)
Returns

Meadow.Hardware.ISerialPort

Parameters
TypeNameDescription
Meadow.Foundation.ICs.IOExpanders.Sc16is7x2.Sc16SerialPortNameportNameThe Sc16SerialPortName name of the channel to create
System.Int32baudRateThe baud rate used in communication
System.Int32dataBitsThe data bits used in communication
Meadow.Hardware.ParityparityThe parity used in communication
Meadow.Hardware.StopBitsstopBitsThe stop bits used in communication
System.BooleaninvertDESet to true to invert the logic (active high) driver enable output signal

CreateDigitalInputPort(IPin, ResistorMode)

Create a digital input port on a SC16IS7x2 IO expander.

View Source
Declaration
public IDigitalInputPort CreateDigitalInputPort(IPin pin, ResistorMode resistorMode = ResistorMode.Disabled)
Returns

Meadow.Hardware.IDigitalInputPort

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe GPIO pin to use.
Meadow.Hardware.ResistorModeresistorModeSC16IS7x2 GPIO's does not support pullup or pulldown on inputs.
Exceptions

System.Exception

SetPortDirection(IPin, PortDirectionType)

Sets the direction of a port

View Source
Declaration
public void SetPortDirection(IPin pin, PortDirectionType direction)
Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin representing the port
Meadow.Hardware.PortDirectionTypedirectionThe port direction (input or output)

ReadPort(IPin)

Gets the value of a particular port.

View Source
Declaration
public bool ReadPort(IPin pin)
Returns

System.Boolean

Parameters
TypeName
Meadow.Hardware.IPinpin

CreateDigitalOutputPort(IPin, bool, OutputType)

Create a digital output port on a SC16IS7x2 IO expander.

View Source
Declaration
public IDigitalOutputPort CreateDigitalOutputPort(IPin pin, bool initialState = false, OutputType outputType = OutputType.PushPull)
Returns

Meadow.Hardware.IDigitalOutputPort

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe GPIO pin to use.
System.BooleaninitialStateInitial state. Either true or false.
Meadow.Hardware.OutputTypeoutputTypeAlways push/pull on SC16IS7x2.
Exceptions

System.NotImplementedException

GetInterruptSource()

Get the Interrupt Identification Register (IIR) value.

View Source
Declaration
public byte GetInterruptSource()
Returns

System.Byte

GetInterruptSourceType(byte)

Get the interrupt source type from the IIR register value. (Interrupt Identification Register) Ref. page 14 and 24 in datasheet. Mostly for debugging. Not sure if multiple sources can be active at the same time. If so, this will need to be modified.

View Source
Declaration
public Sc16is7x2.InterruptSourceType GetInterruptSourceType(byte iir)
Returns

Meadow.Foundation.ICs.IOExpanders.Sc16is7x2.InterruptSourceType

Parameters
TypeNameDescription
System.ByteiirThe IIR register value. (Interrupt Identification Register)

IsValidPin(IPin)

Is the pin valid for this device instance

View Source
Declaration
protected bool IsValidPin(IPin pin)
Returns

System.Boolean: True if pin is valid

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe IPin to validate

PrintAddressContent()

Print the content of the address space for debugging purposes.

View Source
Declaration
public void PrintAddressContent()

ByteToBinaryString(byte)

View Source
Declaration
public string ByteToBinaryString(byte b)
Returns

System.String

Parameters
TypeName
System.Byteb

Implements

  • Meadow.Hardware.ISerialController
  • Meadow.Hardware.IDigitalInputOutputController
  • Meadow.Hardware.IDigitalInputController
  • Meadow.Hardware.IDigitalOutputController
  • Meadow.Hardware.IPinController
  • Meadow.Hardware.II2cPeripheral
  • Meadow.Hardware.ISpiPeripheral