Skip to content

Instantly share code, notes, and snippets.

@macchina
Last active April 16, 2018 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save macchina/952aa986151b436e54f1498823575e21 to your computer and use it in GitHub Desktop.
Save macchina/952aa986151b436e54f1498823575e21 to your computer and use it in GitHub Desktop.
Send CAN message to make flashers flash in 2006 Ford Fusion.
// Demo showing how to send CAN message to make flashers flash in 2006 Ford Fusion.
#include "variant.h"
#include <due_can.h>
#include "SamNonDuePin.h"
#define Serial SerialUSB
const int LOWPOW = PIN_EMAC_ERX0;
void setup()
{
pinModeNonDue(LOWPOW, OUTPUT);
digitalWriteNonDue(LOWPOW, HIGH);
pinMode(28, OUTPUT);
digitalWrite(28, LOW);
Serial.begin(115200);
Can1.begin(CAN_BPS_125K);
}
void sendData()
{
CAN_FRAME outgoing;
outgoing.id = 0x0383;
outgoing.extended = false;
outgoing.priority = 4; //0-15 lower is higher priority
outgoing.length = 8;
outgoing.data.s0 = 0x57FF;
outgoing.data.byte[2] = 0x05;
outgoing.data.byte[3] = 0x00;
outgoing.data.high = 0x00000000;
Can1.sendFrame(outgoing);
}
void loop(){
static unsigned long lastTime = 0;
if ((millis() - lastTime) > 1000)
{
lastTime = millis();
sendData();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment