WIP / Refactored Switch Software
This commit is contained in:
67
Software/Switch/Swtich/MeyCan.h
Normal file
67
Software/Switch/Swtich/MeyCan.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef MEYCAN_H
|
||||
#define MEYCAN_H
|
||||
|
||||
#include <SPI.h>
|
||||
#include <mcp2515.h>
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int pin_id;
|
||||
bool pin_state;
|
||||
bool is_input;
|
||||
byte meyPinId;
|
||||
|
||||
PinState() {}
|
||||
void Init(int pin_id, byte meyPinId)
|
||||
{
|
||||
this->pin_id = pin_id;
|
||||
this->pin_state = true;
|
||||
this->is_input = true;
|
||||
this->meyPinId = meyPinId;
|
||||
}
|
||||
} PinState;
|
||||
|
||||
|
||||
/* START MEYCAN */
|
||||
|
||||
const byte SOFTWARE_VERSION_HIGH = 5;
|
||||
const byte SOFTWARE_VERSION_LOW = 0;
|
||||
const byte HARDWARE_VERSION_HIGH = 7;
|
||||
const byte HARDWARE_VERSION_LOW = 0;
|
||||
|
||||
const uint16_t HELP_PACKAGE_CAN_ID = 0x0FFFUL;
|
||||
const uint16_t SWITCH_TRIGGERED_CAN_ID = 0x0050;
|
||||
const uint16_t TRIGGER_SWITCH_CAN_ID = 0x0055;
|
||||
|
||||
extern MCP2515* canInterfaces[4];
|
||||
|
||||
void SetCanInterface(byte index, byte pinId);
|
||||
void SetMeyPin(byte index, byte meyPinId, byte pinId);
|
||||
|
||||
void SetupMeyCan();
|
||||
|
||||
void HandleFrame(can_frame *frame);
|
||||
void HandleTriggerMeypinCanPackage(can_frame *frame);
|
||||
byte CircularShift(byte b);
|
||||
uint16_t GetDeviceId(uint32_t canFrameId);
|
||||
uint16_t GetPackageType(uint32_t canFrameId);
|
||||
byte GetDeviceIdLow();
|
||||
|
||||
byte GetDeviceIdHigh();
|
||||
|
||||
uint32_t CreateCanId(uint16_t commandId);
|
||||
void SendVersionPackage(MCP2515 *interface);
|
||||
|
||||
void SendSwitchedTriggeredCanPackage(byte pinId, int state);
|
||||
void SendDoTriggerSwitchCanPackage(uint16_t targetCanId, byte pinId, byte state);
|
||||
|
||||
void DoSendCanPkg(can_frame *frame);
|
||||
void DoSendCanPkg(MCP2515 *interface, can_frame *frame);
|
||||
|
||||
void CalculateMyDeviceId();
|
||||
|
||||
/* STOP MEYCAN */
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user