1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 16:16:13 +01:00

Fixes for compile arduino unowifi r2

This commit is contained in:
dexslab 2020-12-08 14:42:21 -05:00
parent d96c919fee
commit b0388bfc67
6 changed files with 29 additions and 5 deletions

View File

@ -25,6 +25,17 @@
#include <Arduino.h>
int inline analogReadFast(uint8_t ADCpin);
#if defined(ARDUINO_AVR_UNO_WIFI_REV2)
int inline analogReadFast(uint8_t ADCpin)
{ byte ADC0CTRLCoriginal = ADC0.CTRLC;
ADC0.CTRLC = (ADC0CTRLCoriginal & 0b00110000) + 0b01000011;
int adc = analogRead(ADCpin);
ADC0.CTRLC = ADC0CTRLCoriginal;
return adc;
}
#else
int inline analogReadFast(uint8_t ADCpin)
{ byte ADCSRAoriginal = ADCSRA;
@ -33,5 +44,7 @@ int inline analogReadFast(uint8_t ADCpin)
ADCSRA = ADCSRAoriginal;
return adc;
}
#endif
#endif // COMMANDSTATION_DCC_ANALOGREADFAST_H_
#endif
// COMMANDSTATION_DCC_ANALOGREADFAST_H_v

View File

@ -11,7 +11,7 @@
#include "ATMEGA2560/Timer.h"
#elif defined(ARDUINO_AVR_UNO)
#include "ATMEGA328/Timer.h"
#elif defined(ARDUINO_AVR_UNO_WIFI_DEV_ED)
#elif defined(ARDUINO_AVR_UNO_WIFI_REV2)
#include "ATMEGA4809/Timer.h"
#else
#error "Cannot compile - ArduinoTimers library does not support your board, or you are missing compatible build flags."

2
DCC.h
View File

@ -155,7 +155,7 @@ private:
#define ARDUINO_TYPE "NANO"
#elif defined(ARDUINO_AVR_MEGA2560)
#define ARDUINO_TYPE "MEGA"
#elif defined(ARDUINO_AVR_UNO_WIFI_DEV_ED)
#elif defined(ARDUINO_AVR_UNO_WIFI_REV2)
#define ARDUINO_TYPE "UNOWIFIR2"
#else
#error CANNOT COMPILE - DCC++ EX ONLY WORKS WITH AN ARDUINO UNO, NANO 328, OR ARDUINO MEGA 1280/2560

View File

@ -41,7 +41,7 @@ void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver, byte
progTrack.setPowerMode(POWERMODE::OFF);
switch (timerNumber) {
case 1: interruptTimer= &TimerA; break;
#ifndef ARDUINO_AVR_UNO_WIFI_DEV_ED
#ifndef ARDUINO_AVR_UNO_WIFI_REV2
case 2: interruptTimer= &TimerB; break;
#ifndef ARDUINO_AVR_UNO
case 3: interruptTimer= &TimerC; break;

View File

@ -49,4 +49,14 @@ ISR(TIMER2_OVF_vect)
TimerB.isrCallback();
}
#endif
#elif defined(ARDUINO_AVR_UNO_WIFI_REV2)
#include "ATMEGA4809/Timer.h"
Timer TimerA(0);
ISR(TCA0_OVF_vect) {
TimerA.isrCallback();
}
#endif

View File

@ -65,6 +65,7 @@ lib_deps =
mathertel/LiquidCrystal_PCF8574
monitor_speed = 115200
monitor_flags = --echo
build_flags = "-DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO_WIFI_DEV_ED -DARDUINO_ARCH_AVR -DESP_CH_UART -DESP_CH_UART_BR=19200"g
[env:uno]
platform = atmelavr