Table of Contents

Class Mcp25xxx

Namespace
Iot.Device.Mcp25xxx
Assembly
Iot.Device.Mcp25xxx.dll

A general purpose driver for the Microchip MCP25 CAN controller device family.

public abstract class Mcp25xxx
Inheritance
Mcp25xxx
Derived

Constructors

Mcp25xxx(SpiDevice, int, int, int, int, int, int, int, int, GpioController?, bool)

A general purpose driver for the Microchip MCP25 CAN controller device family.

public Mcp25xxx(SpiDevice spiDevice, int reset = -1, int tx0rts = -1, int tx1rts = -1, int tx2rts = -1, int interrupt = -1, int rx0bf = -1, int rx1bf = -1, int clkout = -1, GpioController? gpioController = null, bool shouldDispose = true)

Parameters

spiDevice SpiDevice

The SPI device used for communication.

reset int

The output pin number that is connected to Reset.

tx0rts int

The output pin number that is connected to Tx0RTS.

tx1rts int

The output pin number that is connected to Tx1RTS.

tx2rts int

The output pin number that is connected to Tx2RTS.

interrupt int

The input pin number that is connected to INT.

rx0bf int

The input pin number that is connected to Rx0BF.

rx1bf int

The input pin number that is connected to Rx1BF.

clkout int

The input pin number that is connected to CLKOUT.

gpioController GpioController

The GPIO controller for defined external pins. If not specified, the default controller will be used.

shouldDispose bool

True to dispose the Gpio Controller

Properties

InterruptPin

Reads the current value of Interrupt pin.

public PinValue InterruptPin { get; }

Property Value

PinValue

ResetPin

Writes a value to Reset pin.

public PinValue ResetPin { set; }

Property Value

PinValue

Rx0BfPin

Reads the current value of Rx0BF pin.

public PinValue Rx0BfPin { get; }

Property Value

PinValue

Rx1BfPin

Reads the current value of Rx1BF pin.

public PinValue Rx1BfPin { get; }

Property Value

PinValue

Tx0RtsPin

Writes a value to Tx0RTS pin.

public PinValue Tx0RtsPin { set; }

Property Value

PinValue

Tx1RtsPin

Writes a value to Tx1RTS pin.

public PinValue Tx1RtsPin { set; }

Property Value

PinValue

Tx2RtsPin

Writes a value to Tx2RTS pin.

public PinValue Tx2RtsPin { set; }

Property Value

PinValue

Methods

BitModify(Address, byte, byte)

Allows the user to set or clear individual bits in a particular register. Not all registers can be bit modified with this command.

public void BitModify(Address address, byte mask, byte value)

Parameters

address Address

The address to write data.

mask byte

The mask to determine which bits in the register will be allowed to change. A '1' will allow a bit to change while a '0' will not.

value byte

The value to be written.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

LoadTxBuffer(TxBufferAddressPointer, SpanByte)

When loading a transmit buffer, reduces the overhead of a normal WRITE command by placing the Address Pointer at one of six locations for transmit buffer.

public void LoadTxBuffer(TxBufferAddressPointer addressPointer, SpanByte buffer)

Parameters

addressPointer TxBufferAddressPointer

The Address Pointer to one of six locations for the transmit buffer.

buffer SpanByte

The data to load in transmit buffer.

Read(Address)

Reads data from the register beginning at the selected address.

public byte Read(Address address)

Parameters

address Address

The address to read.

Returns

byte

The value of address read.

ReadRxBuffer(RxBufferAddressPointer, int)

When reading a receive buffer, reduces the overhead of a normal READ command by placing the Address Pointer at one of four locations for the receive buffer.

public byte[] ReadRxBuffer(RxBufferAddressPointer addressPointer, int byteCount = 1)

Parameters

addressPointer RxBufferAddressPointer

The Address Pointer to one of four locations for the receive buffer.

byteCount int

Number of bytes to read. This must be one or more to read.

Returns

byte[]

The value of address read.

ReadStatus()

Quick polling command that reads several Status bits for transmit and receive functions.

public ReadStatusResponse ReadStatus()

Returns

ReadStatusResponse

The response from READ STATUS instruction.

RequestToSend(bool, bool, bool)

Instructs the controller to begin the message transmission sequence for any of the transmit buffers.

public void RequestToSend(bool txb0, bool txb1, bool txb2)

Parameters

txb0 bool

Instructs the controller to begin the message transmission sequence for TxB0.

txb1 bool

Instructs the controller to begin the message transmission sequence for TxB1.

txb2 bool

Instructs the controller to begin the message transmission sequence for TxB2.

Reset()

Resets the internal registers to the default state and sets Configuration mode.

public void Reset()

RxStatus()

Quick polling command that indicates a filter match and message type (standard, extended and/or remote) of the received message.

public RxStatusResponse RxStatus()

Returns

RxStatusResponse

Response from RX STATUS instruction.

Write(Address, SpanByte)

Writes data to the register beginning at the selected address.

public void Write(Address address, SpanByte buffer)

Parameters

address Address

The starting address to write data.

buffer SpanByte

The buffer that contains the data to be written.

WriteByte(Address, byte)

Writes one byte to the register beginning at the selected address.

public void WriteByte(Address address, byte value)

Parameters

address Address

The address to write the data.

value byte

The value to be written.

WriteByte(IRegister)

Writes a byte to the selected register address.

public void WriteByte(IRegister register)

Parameters

register IRegister

The register to write the data.