Class Mcp25xxx
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
SpiDeviceThe SPI device used for communication.
reset
intThe output pin number that is connected to Reset.
tx0rts
intThe output pin number that is connected to Tx0RTS.
tx1rts
intThe output pin number that is connected to Tx1RTS.
tx2rts
intThe output pin number that is connected to Tx2RTS.
interrupt
intThe input pin number that is connected to INT.
rx0bf
intThe input pin number that is connected to Rx0BF.
rx1bf
intThe input pin number that is connected to Rx1BF.
clkout
intThe input pin number that is connected to CLKOUT.
gpioController
GpioControllerThe GPIO controller for defined external pins. If not specified, the default controller will be used.
shouldDispose
boolTrue to dispose the Gpio Controller
Properties
InterruptPin
Reads the current value of Interrupt pin.
public PinValue InterruptPin { get; }
Property Value
ResetPin
Writes a value to Reset pin.
public PinValue ResetPin { set; }
Property Value
Rx0BfPin
Reads the current value of Rx0BF pin.
public PinValue Rx0BfPin { get; }
Property Value
Rx1BfPin
Reads the current value of Rx1BF pin.
public PinValue Rx1BfPin { get; }
Property Value
Tx0RtsPin
Writes a value to Tx0RTS pin.
public PinValue Tx0RtsPin { set; }
Property Value
Tx1RtsPin
Writes a value to Tx1RTS pin.
public PinValue Tx1RtsPin { set; }
Property Value
Tx2RtsPin
Writes a value to Tx2RTS pin.
public PinValue Tx2RtsPin { set; }
Property Value
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
AddressThe address to write data.
mask
byteThe 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
byteThe 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
TxBufferAddressPointerThe Address Pointer to one of six locations for the transmit buffer.
buffer
SpanByteThe 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
AddressThe 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
RxBufferAddressPointerThe Address Pointer to one of four locations for the receive buffer.
byteCount
intNumber 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
boolInstructs the controller to begin the message transmission sequence for TxB0.
txb1
boolInstructs the controller to begin the message transmission sequence for TxB1.
txb2
boolInstructs 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
AddressThe starting address to write data.
buffer
SpanByteThe 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
WriteByte(IRegister)
Writes a byte to the selected register address.
public void WriteByte(IRegister register)
Parameters
register
IRegisterThe register to write the data.