https://github.com/Seeed-Studio/CAN_BUS_Shield
https://www.arduino.cc/en/Reference/SPI
code à compiler
http://vinzzz3410.synology.me/tuscani/genlcd_lib.rar
Code : Tout sélectionner
/*
Infotainment (Hyundai Genesis Coupe) Wake Up LCD Screen
(c)2014 Wesley Treihaft
Thanks to Dreadie for the command.
*/
#include <mcp_can.h>
#include <SPI.h>
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
unsigned char stmp[8] = {67, 02, 0, 0, 0, 0, 255, 255}; // Wake Up Command Data (Dec)
unsigned char stlcd[8] = {16, 84, 117, 115, 99, 97, 110, 105}; // write top lcd Tuscani (Dec)
void setup()
{
Serial.begin(115200);
if(CAN.begin(CAN_100KBPS) ==CAN_OK) Serial.print("can init ok!!\r\n"); // Init CAN Bus, Baudrate: 100k
else Serial.print("Can init fail!!\r\n");
delay(2000); //Delay to wait for the hardware to stabilize
CAN.sendMsgBuf(1088, 0, 8, stmp); // Send Wake Command Once
delay(2000);
CAN.sendMsgBuf(1152, 0, 8, stlcd);
}
void loop()
{
// CAN.sendMsgBuf(1088, 0, 8, stmp); // Send Wake Command Repeat
// delay(100); // Repeat Delay
}
// Wake Up Hex Command: 0x440, 0x43, 0x02, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFFCode : Tout sélectionner
//This Arduino UNO Sketch requires the Seeed CAN-BUS Shield Libraries
//https://github.com/yexiaobo-seeedstudio/CAN_BUS_Shield
#include <SPI.h>
#include <mcp_can.h>
#define INT32U unsigned char
INT32U canId = 0x000;
unsigned char len = 0;
unsigned char buf[8];
char str[20];
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
void setup()
{
Serial.begin(38400);
START_INIT:
if(CAN_OK == CAN.begin(CAN_100KBPS))
{
Serial.println("CAN BUS Shield init ok!");
}
else
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
}
void loop()
{
if(CAN_MSGAVAIL == CAN.checkReceive())
{
CAN.readMsgBuf(&len, buf);
canId = CAN.getCanId();
Serial.print("<");Serial.print(canId);Serial.print(",");
for(int i = 0; i<len; i++)
{
Serial.print(buf[i]);Serial.print(",");
}
Serial.print(">");
Serial.println();
}
}







