inital nfc code

This commit is contained in:
2022-03-09 10:24:23 +01:00
parent 395c9f3e2c
commit a08c8e447f
13 changed files with 1091 additions and 19 deletions

View File

@ -12,19 +12,17 @@
#include "staticvector.h"
#include "turnout.h"
#include "signal.h"
#define COMMAND_BUFFER_SIZE 64
#define SNPRINTF_BUFFER_SIZE 128
#define EPPROM_SIZE 1024
#include "shiftreg.h"
#include "softspim.h"
#include "nfcbord.h"
#include "defines.h"
char buffer[SNPRINTF_BUFFER_SIZE];
static constexpr uint8_t EEPROM_RESERVE = 32;
static constexpr uint8_t BLOCK = 4;
SVector<Train, 32> trains;
SVector<Turnout, 32> turnouts;
SVector<Signal, 32> signals;
NfcBoard nfcBoard;
bool autoff = true;
bool powerIsOn = true;
@ -252,6 +250,12 @@ void serialDispatch(Serial* serial)
if(token != NULL)
ret = signalDispatch(token, serial);
}
else if(strcmp(token, "nfc") == 0)
{
token = strtok(NULL, " ");
if(token != NULL)
ret = nfcBoard.dispatch(token, serial);
}
else if(strncmp(token, "erase", 4) == 0)
{
for(uint16_t i = 0; i < EPPROM_SIZE; i++) EEPROM_write_char(i, 0);
@ -327,7 +331,7 @@ int main()
TCNT0 = 0;
TCCR0B = (1<<CS02); // run timer0 with /256 scaler
DDRD = (1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5);
DDRD = (1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5);
restore_state();