Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
MCP2515Controller Class Reference

Class that controls the MCP2515 CAN controller. IMCP2515Controller. More...

#include <MCP2515Controller.hpp>

Public Member Functions

 MCP2515Controller (const std::string &spiDevice)
 Construct a new MCP2515Controller::MCP2515Controller object.
 
 MCP2515Controller (const std::string &spiDevice, ISPIController &spiController)
 Construct a new MCP2515Controller::MCP2515Controller object.
 
 ~MCP2515Controller () override
 Destroy the MCP2515Controller::MCP2515Controller object.
 
bool init () override
 Initialize the MCP2515 controller.
 
void processReading () override
 Start reading CAN messages.
 
void stopReading () override
 Stop reading CAN messages.
 
CANMessageProcessorgetMessageProcessor ()
 
bool isStopReadingFlagSet () const override
 Check if the stop reading flag is set.
 
- Public Member Functions inherited from IMCP2515Controller
virtual ~IMCP2515Controller ()=default
 

Private Member Functions

void setupHandlers ()
 Send a CAN message.
 

Private Attributes

ISPIControllerspiController
 Pointer to the ISPIController object.
 
MCP2515Configurator configurator
 MCP2515Configurator object.
 
CANMessageProcessor messageProcessor
 CANMessageProcessor object.
 
bool stopReadingFlag = false
 Flag to indicate if the reading process should stop.
 
bool ownsSPIController = false
 Flag to indicate if the SPI controller is owned by the MCP2515Controller.
 

Additional Inherited Members

- Signals inherited from IMCP2515Controller
void speedUpdated (float newSpeed)
 Signal emitted when the speed is updated.
 
void rpmUpdated (int newRpm)
 Signal emitted when the RPM is updated.
 

Detailed Description

Class that controls the MCP2515 CAN controller. IMCP2515Controller.

Definition at line 31 of file MCP2515Controller.hpp.

Constructor & Destructor Documentation

◆ MCP2515Controller() [1/2]

MCP2515Controller::MCP2515Controller ( const std::string & spiDevice)
explicit

Construct a new MCP2515Controller::MCP2515Controller object.

Parameters
spiDeviceThe SPI device to use for communication.
Exceptions
std::runtime_errorif the SPI device cannot be opened.

This constructor initializes the MCP2515Controller object with the specified SPI device.

Definition at line 39 of file MCP2515Controller.cpp.

Here is the call graph for this function:

◆ MCP2515Controller() [2/2]

MCP2515Controller::MCP2515Controller ( const std::string & spiDevice,
ISPIController & spiController )

Construct a new MCP2515Controller::MCP2515Controller object.

Parameters
spiDeviceThe SPI device to use for communication.
spiControllerThe SPI controller to use for communication.
Exceptions
std::runtime_errorif the SPI device cannot be opened.

This constructor initializes the MCP2515Controller object with the specified SPI device and SPI controller.

Definition at line 56 of file MCP2515Controller.cpp.

Here is the call graph for this function:

◆ ~MCP2515Controller()

MCP2515Controller::~MCP2515Controller ( )
override

Destroy the MCP2515Controller::MCP2515Controller object.

This destructor closes the SPI device and deletes the SPI controller if it was created by the MCP2515Controller.

Definition at line 71 of file MCP2515Controller.cpp.

Member Function Documentation

◆ getMessageProcessor()

CANMessageProcessor & MCP2515Controller::getMessageProcessor ( )
inline

Definition at line 44 of file MCP2515Controller.hpp.

Here is the caller graph for this function:

◆ init()

bool MCP2515Controller::init ( )
overridevirtual

Initialize the MCP2515 controller.

Exceptions
std::runtime_errorif the MCP2515 cannot be reset.
Returns
True if the MCP2515 is successfully initialized

This function initializes the MCP2515 controller by resetting the chip and configuring it.

Implements IMCP2515Controller.

Definition at line 85 of file MCP2515Controller.cpp.

Here is the caller graph for this function:

◆ isStopReadingFlagSet()

bool MCP2515Controller::isStopReadingFlagSet ( ) const
overridevirtual

Check if the stop reading flag is set.

Returns
True if the stop reading flag is set, false otherwise.

This function checks if the stop reading flag is set.

Implements IMCP2515Controller.

Definition at line 167 of file MCP2515Controller.cpp.

Here is the caller graph for this function:

◆ processReading()

void MCP2515Controller::processReading ( )
overridevirtual

Start reading CAN messages.

This function starts reading CAN messages from the MCP2515.

Implements IMCP2515Controller.

Definition at line 108 of file MCP2515Controller.cpp.

Here is the caller graph for this function:

◆ setupHandlers()

void MCP2515Controller::setupHandlers ( )
private

Send a CAN message.

Parameters
frameIDThe frame ID of the message.
dataThe data of the message.

This function sends a CAN message with the specified frame ID and data.

Definition at line 143 of file MCP2515Controller.cpp.

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

◆ stopReading()

void MCP2515Controller::stopReading ( )
overridevirtual

Stop reading CAN messages.

This function stops reading CAN messages from the MCP2515.

Implements IMCP2515Controller.

Definition at line 134 of file MCP2515Controller.cpp.

Here is the caller graph for this function:

Field Documentation

◆ configurator

MCP2515Configurator MCP2515Controller::configurator
private

MCP2515Configurator object.

Definition at line 51 of file MCP2515Controller.hpp.

◆ messageProcessor

CANMessageProcessor MCP2515Controller::messageProcessor
private

CANMessageProcessor object.

Definition at line 53 of file MCP2515Controller.hpp.

◆ ownsSPIController

bool MCP2515Controller::ownsSPIController = false
private

Flag to indicate if the SPI controller is owned by the MCP2515Controller.

Definition at line 58 of file MCP2515Controller.hpp.

◆ spiController

ISPIController* MCP2515Controller::spiController
private

Pointer to the ISPIController object.

Definition at line 49 of file MCP2515Controller.hpp.

◆ stopReadingFlag

bool MCP2515Controller::stopReadingFlag = false
private

Flag to indicate if the reading process should stop.

Definition at line 55 of file MCP2515Controller.hpp.


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