mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-27 06:11:25 +01:00
Basic hardware and railcom abstraction
This commit is contained in:
parent
22406b44ed
commit
c16358facc
@ -2,6 +2,7 @@
|
||||
#include "Hardware.h"
|
||||
#include "DCCWaveform.h"
|
||||
#include "DIAG.h"
|
||||
#include "Railcom.h"
|
||||
DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true);
|
||||
DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false);
|
||||
|
||||
@ -185,7 +186,7 @@ void DCCWaveform::checkRailcom() {
|
||||
if (isMainTrack && RAILCOM_CUTOUT) {
|
||||
byte preamble = PREAMBLE_BITS_MAIN - remainingPreambles;
|
||||
if (preamble == RAILCOM_PREAMBLES_BEFORE_CUTOUT) {
|
||||
// TODO Railcom::startCutout();
|
||||
Railcom::startCutout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
Hardware.cpp
11
Hardware.cpp
@ -1,4 +1,5 @@
|
||||
#include <Arduino.h>
|
||||
#include <TimerOne.h>
|
||||
#include <TimerThree.h>
|
||||
|
||||
#include "Hardware.h"
|
||||
@ -40,3 +41,13 @@ void Hardware::setCallback(int duration, void (*isr)()) {
|
||||
Timer3.disablePwm(TIMER3_B_PIN);
|
||||
Timer3.attachInterrupt(isr);
|
||||
}
|
||||
void Hardware::setSingleCallback(int duration, void (*isr)()) {
|
||||
Timer1.initialize(duration);
|
||||
Timer1.disablePwm(TIMER1_A_PIN);
|
||||
Timer1.disablePwm(TIMER1_B_PIN);
|
||||
Timer1.attachInterrupt(isr);
|
||||
}
|
||||
void Hardware::resetSingleCallback(int duration) {
|
||||
if (duration==0) Timer1.stop();
|
||||
else Timer1.initialize(duration);
|
||||
}
|
||||
|
@ -7,4 +7,6 @@ class Hardware {
|
||||
static void setSignal(bool isMainTrack, bool high);
|
||||
static int getCurrentMilliamps(bool isMainTrack);
|
||||
static void setCallback(int duration, void (*isr)());
|
||||
static void setSingleCallback(int duration, void (*isr)());
|
||||
static void resetSingleCallback(int duration);
|
||||
};
|
||||
|
25
Railcom.cpp
Normal file
25
Railcom.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "Railcom.h"
|
||||
#include "Hardware.h"
|
||||
|
||||
void Railcom::startCutout() {
|
||||
return;
|
||||
/*** todo when ready ***
|
||||
interruptState=0;
|
||||
Hardware::setSingleCallback(RAILCOM_T0,interrupt);
|
||||
*************/
|
||||
}
|
||||
|
||||
void Railcom::interrupt() {
|
||||
/*** TODO when ready .. railcom state machine
|
||||
switch (interruptState) {
|
||||
case 0: //
|
||||
Hardware::setPower(true,false);
|
||||
state=1;
|
||||
nextInterrupt=RAILCOM_T1;
|
||||
break;
|
||||
}
|
||||
**********************/
|
||||
}
|
||||
byte Railcom::interruptState;
|
||||
byte Railcom::bitsReceived;
|
||||
byte Railcom::buffer[MAX_BUFFER];
|
Loading…
Reference in New Issue
Block a user