diff --git a/DCC.cpp b/DCC.cpp index 6c640fb..74397ef 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -56,13 +56,12 @@ void DCC::begin() { StringFormatter::send(Serial,F("\n"), F(VERSION), F(ARDUINO_TYPE), MotorDriverContainer::mDC.getMotorShieldName(), F(GITHUB_SHA)); - /* -NOT YES, PIN CONFLICTS + // BE AWARE, USES I2C PINS, MAY LEAD TO PIN CONFLICTS // Initialise HAL layer before reading EEprom. IODevice::begin(); - */ - //MotorDriverContainer::mDC.add(new MotorDriver(16, 21, UNUSED_PIN, UNUSED_PIN, UNUSED_PIN, 2.00, 2000, UNUSED_PIN, RMT_MAIN)); + //example how to use add: + //MotorDriverContainer::mDC.add(new MotorDriver(16, 21, UNUSED_PIN, UNUSED_PIN, UNUSED_PIN, 2.00, 2000, UNUSED_PIN, RMT_MAIN)); // Load stuff from EEprom (void)EEPROM; // tell compiler not to warn this is unused EEStore::init(); diff --git a/DCCRMT.cpp b/DCCRMT.cpp index 95d0e9a..6a81c25 100644 --- a/DCCRMT.cpp +++ b/DCCRMT.cpp @@ -23,6 +23,7 @@ #include "DIAG.h" #include "DCCRMT.h" #include "DCCWaveform.h" // for MAX_PACKET_SIZE +#include "soc/gpio_sig_map.h" #define DATA_LEN(X) ((X)*9+1) // Each byte has one bit extra and we have one EOF marker @@ -104,6 +105,14 @@ RMTChannel::RMTChannel(byte pin, byte ch, byte plen) { // 2 mem block of 64 RMT items should be enough ESP_ERROR_CHECK(rmt_config(&config)); + /* + // test: config another gpio pin + gpio_num_t gpioNum = (gpio_num_t)(pin-1); + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpioNum], PIN_FUNC_GPIO); + gpio_set_direction(gpioNum, GPIO_MODE_OUTPUT); + gpio_matrix_out(gpioNum, RMT_SIG_OUT0_IDX, 0, 0); + */ + // NOTE: ESP_INTR_FLAG_IRAM is *NOT* included in this bitmask ESP_ERROR_CHECK(rmt_driver_install(config.channel, 0, ESP_INTR_FLAG_LOWMED|ESP_INTR_FLAG_SHARED)); diff --git a/DCCTrack.h b/DCCTrack.h index 5a8d3de..6c22ed9 100644 --- a/DCCTrack.h +++ b/DCCTrack.h @@ -10,8 +10,8 @@ class DCCTrack { DCCTrack(DCCWaveform *w); void schedulePacket(const byte buffer[], byte byteCount, byte repeats); void schedulePacket(dccPacket packet); - inline void addDriver(MotorDriver *m) { mD.push_back(m); - DIAG(F("Track: mDType=%d count=%d"),m->type(), mD.size()); + inline void addDriver(MotorDriver *m) { + mD.push_back(m); }; static DCCTrack mainTrack; static DCCTrack progTrack; diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index fba9fe3..3b6ebdf 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "ESP32-motordriver-2021122-23:21" +#define GITHUB_SHA "ESP32-motordriver-2021129-00:12" diff --git a/MotorDriver.h b/MotorDriver.h index 0121e99..da9e0d9 100644 --- a/MotorDriver.h +++ b/MotorDriver.h @@ -140,7 +140,6 @@ public: static MotorDriverContainer mDC; inline void add(MotorDriver *m) { mD.push_back(m); - DIAG(F("Container: mDType=%d count=%d"),m->type(), mD.size()); }; // void SetCapability(byte n, byte cap, char [] name); inline FSH *getMotorShieldName() { return shieldName; }; @@ -150,7 +149,7 @@ public: return; } for(const auto& d: mD) - DIAG(F("Container: mDType=%d count=%d"),d->type(), mD.size()); + DIAG(F("Container: mDType=%d"),d->type()); }; inline MotorDriver *mainTrack() { std::vector v = getDriverType(TIMER_MAIN); diff --git a/config.example.h b/config.example.h index 8452589..5904ad2 100644 --- a/config.example.h +++ b/config.example.h @@ -45,9 +45,12 @@ The configuration file for DCC-EX Command Station // https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/ // 4 high at boot -#define ESP8266_MOTOR_SHIELD F("ESP8266"), \ - new MotorDriver(D3, D5, UNUSED_PIN, UNUSED_PIN, UNUSED_PIN, 2.99, 2000, UNUSED_PIN),\ - new MotorDriver(D2, D6, UNUSED_PIN, UNUSED_PIN, A0 , 2.99, 2000, UNUSED_PIN) +// BUG: WE STILL NEED AT LEAST ONE TIMER_* motor shield defined, otherwise the packet scheduling does not work +// BUG: WE DO NOT HAVE ANY RMT_PROG CAPABILITY yet. +#define ESP32_MOTOR_SHIELD F("ESP32"), \ + NULL /*new MotorDriver(16, 17, UNUSED_PIN, UNUSED_PIN, 36, 2.00, 2000, UNUSED_PIN, TIMER_MAIN)*/, \ + new MotorDriver(18, 19, UNUSED_PIN, UNUSED_PIN, 39, 2.00, 2000, UNUSED_PIN, TIMER_PROG), \ + new MotorDriver(16, 23, UNUSED_PIN, UNUSED_PIN, UNUSED_PIN, 2.00, 2000, UNUSED_PIN, RMT_MAIN) // ESP32 ADC1 only supported GPIO pins 32 to 39, for example // ADC1 CH4 = GPIO32, ADC1 CH5 = GPIO33, ADC1 CH0 = GPIO36