Added some more projects and libraries.
This commit is contained in:
parent
f7151392ab
commit
1e1459fa50
94 changed files with 11904 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
#include <SPI.h>
|
||||
#include <mcp2515.h>
|
||||
|
||||
struct can_frame canMsg;
|
||||
MCP2515 mcp2515(10);
|
||||
int cntr = 0;
|
||||
unsigned long oldTime = 0;
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
mcp2515.reset();
|
||||
mcp2515.setBitrate(CAN_125KBPS);
|
||||
mcp2515.setNormalMode();
|
||||
|
||||
Serial.println("------- CAN Speedtest ----------");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (mcp2515.readMessage(&canMsg) == MCP2515::ERROR_OK) {
|
||||
cntr++;
|
||||
}
|
||||
|
||||
if ((millis()-oldTime)>1000) {
|
||||
oldTime = millis();
|
||||
Serial.print(cntr);
|
||||
Serial.println(" msg/sec");
|
||||
cntr = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#include <SPI.h>
|
||||
#include <mcp2515.h>
|
||||
|
||||
struct can_frame canMsg;
|
||||
MCP2515 mcp2515(10);
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
mcp2515.reset();
|
||||
mcp2515.setBitrate(CAN_125KBPS);
|
||||
mcp2515.setNormalMode();
|
||||
|
||||
Serial.println("------- CAN Read ----------");
|
||||
Serial.println("ID DLC DATA");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (mcp2515.readMessage(&canMsg) == MCP2515::ERROR_OK) {
|
||||
Serial.print(canMsg.can_id, HEX); // print ID
|
||||
Serial.print(" ");
|
||||
Serial.print(canMsg.can_dlc, HEX); // print DLC
|
||||
Serial.print(" ");
|
||||
|
||||
for (int i = 0; i<canMsg.can_dlc; i++) { // print the data
|
||||
Serial.print(canMsg.data[i],HEX);
|
||||
Serial.print(" ");
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
#include <SPI.h>
|
||||
#include <mcp2515.h>
|
||||
|
||||
struct can_frame canMsg1;
|
||||
struct can_frame canMsg2;
|
||||
MCP2515 mcp2515(10);
|
||||
|
||||
|
||||
void setup() {
|
||||
canMsg1.can_id = 0x0F6;
|
||||
canMsg1.can_dlc = 8;
|
||||
canMsg1.data[0] = 0x8E;
|
||||
canMsg1.data[1] = 0x87;
|
||||
canMsg1.data[2] = 0x32;
|
||||
canMsg1.data[3] = 0xFA;
|
||||
canMsg1.data[4] = 0x26;
|
||||
canMsg1.data[5] = 0x8E;
|
||||
canMsg1.data[6] = 0xBE;
|
||||
canMsg1.data[7] = 0x86;
|
||||
|
||||
canMsg2.can_id = 0x036;
|
||||
canMsg2.can_dlc = 8;
|
||||
canMsg2.data[0] = 0x0E;
|
||||
canMsg2.data[1] = 0x00;
|
||||
canMsg2.data[2] = 0x00;
|
||||
canMsg2.data[3] = 0x08;
|
||||
canMsg2.data[4] = 0x01;
|
||||
canMsg2.data[5] = 0x00;
|
||||
canMsg2.data[6] = 0x00;
|
||||
canMsg2.data[7] = 0xA0;
|
||||
|
||||
while (!Serial);
|
||||
Serial.begin(115200);
|
||||
|
||||
mcp2515.reset();
|
||||
mcp2515.setBitrate(CAN_125KBPS);
|
||||
mcp2515.setNormalMode();
|
||||
|
||||
Serial.println("Example: Write to CAN");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
mcp2515.sendMessage(&canMsg1);
|
||||
mcp2515.sendMessage(&canMsg2);
|
||||
|
||||
Serial.println("Messages sent");
|
||||
|
||||
delay(100);
|
||||
}
|
||||
BIN
libraries/arduino-mcp2515-master/examples/wiring-diy.png
Normal file
BIN
libraries/arduino-mcp2515-master/examples/wiring-diy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
libraries/arduino-mcp2515-master/examples/wiring.png
Normal file
BIN
libraries/arduino-mcp2515-master/examples/wiring.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 220 KiB |
Loading…
Add table
Add a link
Reference in a new issue