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

lap test pass, bench test tomorrow

This commit is contained in:
travis-farmer 2023-10-23 17:41:45 -04:00
parent 0a63befee9
commit e54cd0919c

View File

@ -33,8 +33,7 @@
#include "DCCTimer.h" #include "DCCTimer.h"
#include "DIAG.h" #include "DIAG.h"
#include "Portenta_H7_TimerInterrupt.h" #include "Portenta_H7_TimerInterrupt.h"
#include "pins_arduino.h" #include <Arduino_AdvancedAnalog.h>
#include "pinDefinitions.h"
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
// Experimental code for High Accuracy (HA) DCC Signal mode // Experimental code for High Accuracy (HA) DCC Signal mode
// Warning - use of TIM2 and TIM3 can affect the use of analogWrite() function on certain pins, // Warning - use of TIM2 and TIM3 can affect the use of analogWrite() function on certain pins,
@ -163,31 +162,40 @@ void DCCTimer::reset() {
int16_t ADCee::ADCmax() int16_t ADCee::ADCmax()
{ {
return 4095; return 1023;
} }
int retBuff[2];
AdvancedADC adc(A0, A1);
int ADCee::init(uint8_t pin) { int ADCee::init(uint8_t pin) {
adc.begin(AN_RESOLUTION_10, 16000, 1, 4);
return 123; // random number, faked for now if (adc.available()) {
SampleBuffer buf = adc.read();
buf.release();
}
} }
/* /*
* Read function ADCee::read(pin) to get value instead of analogRead(pin) * Read function ADCee::read(pin) to get value instead of analogRead(pin)
*/ */
int ADCee::read(uint8_t pin, bool fromISR) { int ADCee::read(uint8_t pin, bool fromISR) {
//int current; if (adc.available()) {
//DIAG(F("ADCee Read:%d"),fromISR); SampleBuffer buf = adc.read();
//if (!fromISR) noInterrupts(); switch(pin){
//current = analogRead(pin); case A0:
//if (!fromISR) interrupts(); return buf[0];
break;
mbed::AnalogIn* adc = analogPinToAdcObj(pin); case A1:
if (adc == NULL) { return buf[1];
adc = new mbed::AnalogIn(analogPinToPinName(pin)); break;
analogPinToAdcObj(pin) = adc; default:
return 0;
break;
}
buf.release();
} }
return (int)(adc->read_u16() >> (16 - 10));
return 1023;
} }
/* /*