Commanders
Arduino buttons/bus library
|
#include "CANCommander.hpp"
Public Member Functions | |
CANCommanderClass () | |
void | begin (uint8_t inSPIpin, uint8_t inSpeed, uint8_t inInterrupt, uint16_t inId) |
unsigned long | loop () |
Static Public Member Functions | |
static CANCommanderClass & | GetCurrent () |
This Commanders receive orders from the CAN bus, and translate it into Commanders events.
This CAN bus used a MCP2515 chip, and use the library mcp_can for that. This library uses also the SPI bus to get data.
A sample of the library Commanders give a sender of CAN events to Commanders.
To work, the sender must send a message with the form of
IIIIEDD
where IIII is an unsigned long (four bytes) for the event id, E is the event type (see values of COMMANDERS_EVENT_TYPE), and DD the associated data.
Events thrown:
reason | id | type | data |
---|---|---|---|
message received | id | type | data |
|
inline |
Default constructor.
void CANCommanderClass::begin | ( | uint8_t | inSPIpin, |
uint8_t | inSpeed, | ||
uint8_t | inInterrupt, | ||
uint16_t | inId | ||
) |
Initialize the instance.
inSPIpin | pin for SPI to get data. |
inSpeed | The speed can be (of course, use the defines from mcp_can_dfs.h) |
Value | Speed (define name) |
---|---|
1 | CAN_5KBPS |
2 | CAN_10KBPS |
3 | CAN_20KBPS |
4 | CAN_25KBPS |
5 | CAN_31K25BPS |
6 | CAN_33KBPS |
7 | CAN_40KBPS |
8 | CAN_50KBPS |
9 | CAN_80KBPS |
10 | CAN_83K3BPS |
11 | CAN_95KBPS |
12 | CAN_100KBPS |
13 | CAN_125KBPS |
14 | CAN_200KBPS |
15 | CAN_250KBPS |
16 | CAN_500KBPS |
17 | CAN_666KBPS |
18 | CAN_1000KBPS |
inInterrupt | interrupt number for the reception. |
inId | CAN id. Only the messages with this ID in the header will be read. |
|
inlinestatic |
Get the current instance of DccCommanderClass
|
virtual |
Main loop function.
Reimplemented from Commander.