PicoLowLevel
Loading...
Searching...
No Matches
CanWrapper Class Reference

A wrapper class for the MCP2515 CAN controller. More...

#include <CanWrapper.h>

Public Member Functions

 CanWrapper (uint8_t csPin, uint32_t speed, SPIClass *spi)
 Constructor that initializes the MCP2515 object with the provided parameters.
 
void begin ()
 Initializes the CAN module.
 
bool sendMessage (uint8_t id, const void *data, uint8_t length)
 Sends a CAN message.
 
bool readMessage (uint8_t *id, byte *data)
 Reads a CAN message.
 

Detailed Description

A wrapper class for the MCP2515 CAN controller.

Constructor & Destructor Documentation

◆ CanWrapper()

CanWrapper::CanWrapper ( uint8_t  csPin,
uint32_t  speed,
SPIClass *  spi 
)
inline

Constructor that initializes the MCP2515 object with the provided parameters.

Parameters
csPinChip select pin for the MCP2515.
speedSPI speed for the MCP2515.
spiSPI interface to use.

Member Function Documentation

◆ begin()

void CanWrapper::begin ( )

Initializes the CAN module.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readMessage()

bool CanWrapper::readMessage ( uint8_t *  id,
byte *  data 
)

Reads a CAN message.

Parameters
idPointer to store the ID of the received CAN message.
dataPointer to store the data of the received CAN message.
Returns
True if a message was read successfully, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendMessage()

bool CanWrapper::sendMessage ( uint8_t  id,
const void *  data,
uint8_t  length 
)

Sends a CAN message.

Parameters
idThe ID of the CAN message.
dataPointer to the data to be sent.
lengthLength of the data to be sent.
Returns
True if the message was sent successfully, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: