Byggern
|
A singleton class which implements the communication between the AVR and the MCP2515. More...
#include <mcp2515.h>
Public Member Functions | |
MCP2515 (const MCP2515 &)=delete | |
void | SendMessage (CanMessage &message) |
void | SetLoopback () |
void | SetNormal () |
void | Initialize (SPI::SPI *spi, uint16_t identifier) |
![]() | |
void | SetUpperLevel (void(*handler)(CanMessage &data)) |
Static Public Member Functions | |
static MCP2515 & | GetInstance () |
Private Member Functions | |
void | RequestToSend () |
void | WriteToRegister (uint8_t register_address, uint8_t byte) |
void | ReadFromRegister (uint8_t register_address, uint8_t &byte) |
void | Reset () |
void | BitModify (uint8_t register_address, uint8_t mask, uint8_t data) |
void | ReadStatus (uint8_t &byte) |
void | LoadTxFrame (CanMessage &message) |
void | RxStatus (uint8_t &byte) |
void | ReadRxFrame (CanMessage &message) |
MCP2515 () | |
Private Attributes | |
SPI::SPI * | spi_driver |
volatile bool | clear_to_send = true |
Friends | |
void | MCP2515_INT () |
Additional Inherited Members | |
![]() | |
void(* | upper_level )(CanMessage &data) |
A singleton class which implements the communication between the AVR and the MCP2515.
Throughout the documentation of this class, we will refer to the datasheet of the chip. This can be found at Microchips site
The SPI driver you are using must have meet the following criteria Size of output buffer > 14 bytes Size of input buffer > 11 bytes
Please note: This implementation only uses one recieve and transmit buffer. TX0 and RX0
|
inlineprivate |
Initializer not used due to singleton
|
delete |
Because of singleton - makes sure its not copied etc.
|
private |
Modifies the given MCP2515 register with a bitmask. Please see MCP2515 datasheet page 66
register_address | The address to the MCP2515 register |
mask | Defines which bits to be modified |
data | The byte to be written |
|
inlinestatic |
A Singleton implementation of this class
void MCP2515::Initialize | ( | SPI::SPI * | spi, |
uint16_t | identifier | ||
) |
|
private |
|
private |
|
private |
Reads the RxFrame, i.e. retrieves the recieved data
message | The message to be written into |
|
private |
Gets the status byte from the MCP2515. Please see MCP2515 datasheet page 65, READ STATUS instruction
byte | The byte to be written into |
|
private |
Sends a RTS (Request to Send) signal to the MCP2515.
|
private |
|
private |
Gets the RxStatus byte from the MCP2515. Please see MCP2515 datasheet page 66, RX STATUS instruction
byte | The byte to be written into |
|
virtual |
void MCP2515::SetLoopback | ( | ) |
Initiates the loopback mode of the MCP2515. Please consult the MCP2515 datasheet
void MCP2515::SetNormal | ( | ) |
Initiates the normal mode of the MCP2515. Please consult the MCP2515 datasheet
|
private |
|
friend |
The MCP2515 interrupt handler
|
private |
Flag indicating if we can load the TX frame.