mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
STM32: Use mask as loop variable
This commit is contained in:
parent
befb41ce98
commit
0266936875
|
@ -30,6 +30,10 @@
|
||||||
#ifdef ARDUINO_ARCH_STM32
|
#ifdef ARDUINO_ARCH_STM32
|
||||||
|
|
||||||
#include "DCCTimer.h"
|
#include "DCCTimer.h"
|
||||||
|
#ifdef DEBUG_ADC
|
||||||
|
#include "TrackManager.h"
|
||||||
|
#endif
|
||||||
|
#include "DIAG.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_NUCLEO_F411RE)
|
#if defined(ARDUINO_NUCLEO_F411RE)
|
||||||
// Nucleo-64 boards don't have Serial1 defined by default
|
// Nucleo-64 boards don't have Serial1 defined by default
|
||||||
|
@ -307,6 +311,8 @@ int ADCee::init(uint8_t pin) {
|
||||||
analogchans[id] = adcchan; // Keep track of which ADC channel is used for reading this pin
|
analogchans[id] = adcchan; // Keep track of which ADC channel is used for reading this pin
|
||||||
usedpins |= (1 << id); // This pin is now ready
|
usedpins |= (1 << id); // This pin is now ready
|
||||||
|
|
||||||
|
DIAG(F("ADCee::init(): value=%d, channel=%d, id=%d"), value, adcchan, id);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,11 +346,13 @@ void ADCee::scan() {
|
||||||
// found value
|
// found value
|
||||||
analogvals[id] = ADC1->DR;
|
analogvals[id] = ADC1->DR;
|
||||||
// advance at least one track
|
// advance at least one track
|
||||||
// for scope debug TrackManager::track[1]->setBrake(0);
|
#ifdef DEBUG_ADC
|
||||||
|
if (id == 1) TrackManager::track[1]->setBrake(0);
|
||||||
|
#endif
|
||||||
waiting = false;
|
waiting = false;
|
||||||
id++;
|
id++;
|
||||||
mask = mask << 1;
|
mask = mask << 1;
|
||||||
if (id == NUM_ADC_INPUTS+1) {
|
if (mask == 0) { // the 1 has been shifted out
|
||||||
id = 0;
|
id = 0;
|
||||||
mask = 1;
|
mask = 1;
|
||||||
}
|
}
|
||||||
|
@ -358,13 +366,15 @@ void ADCee::scan() {
|
||||||
// start new ADC aquire on id
|
// start new ADC aquire on id
|
||||||
ADC1->SQR3 = analogchans[id]; //1st conversion in regular sequence
|
ADC1->SQR3 = analogchans[id]; //1st conversion in regular sequence
|
||||||
ADC1->CR2 |= (1 << 30); //Start 1st conversion SWSTART
|
ADC1->CR2 |= (1 << 30); //Start 1st conversion SWSTART
|
||||||
// for scope debug TrackManager::track[1]->setBrake(1);
|
#ifdef DEBUG_ADC
|
||||||
|
if (id == 1) TrackManager::track[1]->setBrake(1);
|
||||||
|
#endif
|
||||||
waiting = true;
|
waiting = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
id++;
|
id++;
|
||||||
mask = mask << 1;
|
mask = mask << 1;
|
||||||
if (id == NUM_ADC_INPUTS+1) {
|
if (mask == 0) { // the 1 has been shifted out
|
||||||
id = 0;
|
id = 0;
|
||||||
mask = 1;
|
mask = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#define GITHUB_SHA "devel-202306031954Z"
|
#define GITHUB_SHA "devel-202306181725Z"
|
||||||
|
|
|
@ -86,6 +86,13 @@ class TrackManager {
|
||||||
static bool progTrackSyncMain; // true when prog track is a siding switched to main
|
static bool progTrackSyncMain; // true when prog track is a siding switched to main
|
||||||
static bool progTrackBoosted; // true when prog track is not current limited
|
static bool progTrackBoosted; // true when prog track is not current limited
|
||||||
|
|
||||||
|
#ifdef DEBUG_ADC
|
||||||
|
public:
|
||||||
|
#else
|
||||||
|
private:
|
||||||
|
#endif
|
||||||
|
static MotorDriver* track[MAX_TRACKS];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void addTrack(byte t, MotorDriver* driver);
|
static void addTrack(byte t, MotorDriver* driver);
|
||||||
static byte lastTrack;
|
static byte lastTrack;
|
||||||
|
@ -93,7 +100,6 @@ class TrackManager {
|
||||||
static POWERMODE mainPowerGuess;
|
static POWERMODE mainPowerGuess;
|
||||||
static void applyDCSpeed(byte t);
|
static void applyDCSpeed(byte t);
|
||||||
|
|
||||||
static MotorDriver* track[MAX_TRACKS];
|
|
||||||
static TRACK_MODE trackMode[MAX_TRACKS];
|
static TRACK_MODE trackMode[MAX_TRACKS];
|
||||||
static int16_t trackDCAddr[MAX_TRACKS]; // dc address if TRACK_MODE_DC or TRACK_MODE_DCX
|
static int16_t trackDCAddr[MAX_TRACKS]; // dc address if TRACK_MODE_DC or TRACK_MODE_DCX
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
|
Loading…
Reference in New Issue
Block a user