A wrapper class for the MCP2515 CAN controller.
More...
#include <CanWrapper.h>
|
| 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.
|
|
A wrapper class for the MCP2515 CAN controller.
◆ CanWrapper()
CanWrapper::CanWrapper |
( |
uint8_t |
csPin, |
|
|
uint32_t |
speed, |
|
|
SPIClass * |
spi |
|
) |
| |
|
inline |
Constructor that initializes the MCP2515 object with the provided parameters.
- Parameters
-
csPin | Chip select pin for the MCP2515. |
speed | SPI speed for the MCP2515. |
spi | SPI interface to use. |
◆ begin()
void CanWrapper::begin |
( |
| ) |
|
Initializes the CAN module.
◆ readMessage()
bool CanWrapper::readMessage |
( |
uint8_t * |
id, |
|
|
byte * |
data |
|
) |
| |
Reads a CAN message.
- Parameters
-
id | Pointer to store the ID of the received CAN message. |
data | Pointer to store the data of the received CAN message. |
- Returns
- True if a message was read successfully, false otherwise.
◆ sendMessage()
bool CanWrapper::sendMessage |
( |
uint8_t |
id, |
|
|
const void * |
data, |
|
|
uint8_t |
length |
|
) |
| |
Sends a CAN message.
- Parameters
-
id | The ID of the CAN message. |
data | Pointer to the data to be sent. |
length | Length of the data to be sent. |
- Returns
- True if the message was sent successfully, false otherwise.
The documentation for this class was generated from the following files: