Software for V7 refactored
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
#include <avr/io.h>;
|
||||
#include <avr/xmega.h>;
|
||||
#include <SPI.h>;
|
||||
#include <mcp2515.h>;
|
||||
#include "MeyCan.h";
|
||||
#include "MeyRule.h";
|
||||
|
||||
|
||||
struct can_frame incomingCanFrame;
|
||||
|
||||
void setup() {
|
||||
@@ -28,8 +25,7 @@ void setup() {
|
||||
AddToggle(0x0196, 3, 0x9829, 1); // Flurlicht von Papas Büro
|
||||
AddToggle(0x0632, 1, 0x9829, 5); // Flurlicht von Papas Büro
|
||||
|
||||
|
||||
// _PROTECTED_WRITE(CLKCTRL.MCLKCTRLA, CLKCTRL.MCLKCTRLA | 1 << 7);
|
||||
_PROTECTED_WRITE(CLKCTRL.MCLKCTRLA, CLKCTRL.MCLKCTRLA | 1 << 7);
|
||||
|
||||
delay(10); // a bit delay for mcp2515 to get the clock
|
||||
|
||||
@@ -42,10 +38,10 @@ void setup() {
|
||||
SetMeyPin(6, 7, PIN_PC1);
|
||||
SetMeyPin(7, 8, PIN_PC0);
|
||||
|
||||
SetCanInterface(0, PIN_PA2);
|
||||
SetCanInterface(1, PIN_PA3);
|
||||
SetCanInterface(2, PIN_PB0);
|
||||
SetCanInterface(3, PIN_PB1);
|
||||
AddCanInterface(PIN_PA2);
|
||||
AddCanInterface(PIN_PA3);
|
||||
AddCanInterface(PIN_PB0);
|
||||
AddCanInterface(PIN_PB1);
|
||||
|
||||
|
||||
SetupMeyCan();
|
||||
@@ -54,19 +50,13 @@ void setup() {
|
||||
|
||||
void loop()
|
||||
{
|
||||
for (int i = 0; i < sizeof(canInterfaces) / sizeof(MCP2515*); i++)
|
||||
{
|
||||
if (canInterfaces[i]->readMessage(&incomingCanFrame) == MCP2515::ERROR_OK)
|
||||
{
|
||||
// A received CAN Frame is forwarded to all other MCPs given, but not to the receiving one (no echo )
|
||||
for (int j = 0; j < sizeof(canInterfaces) / sizeof(MCP2515*); j++)
|
||||
{
|
||||
if (j == i) continue; // thats for the echo
|
||||
DoSendCanPkg(canInterfaces[j], &incomingCanFrame);
|
||||
}
|
||||
ForEachCanInterface(CheckCanInterface);
|
||||
}
|
||||
|
||||
HandleFrame(&incomingCanFrame);
|
||||
// HandleRules(&incomingCanFrame);
|
||||
}
|
||||
void CheckCanInterface(MCP2515 *interface)
|
||||
{
|
||||
if (interface->readMessage(&incomingCanFrame) == MCP2515::ERROR_OK)
|
||||
{
|
||||
HandleFrame(&incomingCanFrame, interface);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user