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

Various STM32 related fixes

This commit is contained in:
pmantoine 2024-09-30 16:13:00 +08:00
parent 0e99ad143b
commit 33c8ed19a9
5 changed files with 18 additions and 16 deletions

View File

@ -70,9 +70,9 @@ HardwareSerial Serial5(PD2, PC12); // Rx=PD2, Tx=PC12 -- UART5 - F446RE
defined(ARDUINO_NUCLEO_F429ZI) || defined(ARDUINO_NUCLEO_F439ZI) || defined(ARDUINO_NUCLEO_F4X9ZI)
// Nucleo-144 boards don't have Serial1 defined by default
HardwareSerial Serial6(PG9, PG14); // Rx=PG9, Tx=PG14 -- USART6
HardwareSerial Serial5(PD2, PC12); // Rx=PD2, Tx=PC12 -- UART5
#if !defined(ARDUINO_NUCLEO_F412ZG)
HardwareSerial Serial2(PD6, PD5); // Rx=PD6, Tx=PD5 -- UART5
HardwareSerial Serial2(PD6, PD5); // Rx=PD6, Tx=PD5 -- UART2
#if !defined(ARDUINO_NUCLEO_F412ZG) // F412ZG does not have UART5
HardwareSerial Serial5(PD2, PC12); // Rx=PD2, Tx=PC12 -- UART5
#endif
// Serial3 is defined to use USART3 by default, but is in fact used as the diag console
// via the debugger on the Nucleo-144. It is therefore unavailable for other DCC-EX uses like WiFi, DFPlayer, etc.
@ -328,7 +328,7 @@ void DCCTimer::DCCEXanalogWriteFrequencyInternal(uint8_t pin, uint32_t frequency
if (pin_timer[pin] != NULL)
{
pin_timer[pin]->setPWM(pin_channel[pin], pin, frequency, 0); // set frequency in Hertz, 0% dutycycle
DIAG(F("DCCEXanalogWriteFrequency::Pin %d on Timer %d, frequency %d"), pin, pin_channel[pin], frequency);
DIAG(F("DCCEXanalogWriteFrequency::Pin %d on Timer Channel %d, frequency %d"), pin, pin_channel[pin], frequency);
}
else
DIAG(F("DCCEXanalogWriteFrequency::failed to allocate HardwareTimer instance!"));

View File

@ -1,5 +1,5 @@
/*
* © 2022-23 Paul M Antoine
* © 2022-24 Paul M Antoine
* © 2023, Neil McKechnie
* All rights reserved.
*
@ -185,7 +185,7 @@ void I2CManagerClass::I2C_init()
GPIOB->OTYPER |= (1<<8) | (1<<9); // PB8 and PB9 set to open drain output capability
GPIOB->OSPEEDR |= (3<<(8*2)) | (3<<(9*2)); // PB8 and PB9 set to High Speed mode
GPIOB->PUPDR &= ~((3<<(8*2)) | (3<<(9*2))); // Clear all PUPDR bits for PB8 and PB9
GPIOB->PUPDR |= (1<<(8*2)) | (1<<(9*2)); // PB8 and PB9 set to pull-up capability
// GPIOB->PUPDR |= (1<<(8*2)) | (1<<(9*2)); // PB8 and PB9 set to pull-up capability
// Alt Function High register routing pins PB8 and PB9 for I2C1:
// Bits (3:2:1:0) = 0:1:0:0 --> AF4 for pin PB8
// Bits (7:6:5:4) = 0:1:0:0 --> AF4 for pin PB9

View File

@ -151,8 +151,8 @@ void TrackManager::setDCCSignal( bool on) {
HAVE_PORTD(shadowPORTD=PORTD);
HAVE_PORTE(shadowPORTE=PORTE);
HAVE_PORTF(shadowPORTF=PORTF);
HAVE_PORTG(shadowPORTF=PORTG);
HAVE_PORTH(shadowPORTF=PORTH);
HAVE_PORTG(shadowPORTG=PORTG);
HAVE_PORTH(shadowPORTH=PORTH);
APPLY_BY_MODE(TRACK_MODE_MAIN,setSignal(on));
HAVE_PORTA(PORTA=shadowPORTA);
HAVE_PORTB(PORTB=shadowPORTB);
@ -160,8 +160,8 @@ void TrackManager::setDCCSignal( bool on) {
HAVE_PORTD(PORTD=shadowPORTD);
HAVE_PORTE(PORTE=shadowPORTE);
HAVE_PORTF(PORTF=shadowPORTF);
HAVE_PORTG(shadowPORTF=PORTG);
HAVE_PORTH(shadowPORTF=PORTH);
HAVE_PORTG(shadowPORTG=PORTG);
HAVE_PORTH(shadowPORTH=PORTH);
}
// setPROGSignal(), called from interrupt context
@ -173,8 +173,8 @@ void TrackManager::setPROGSignal( bool on) {
HAVE_PORTD(shadowPORTD=PORTD);
HAVE_PORTE(shadowPORTE=PORTE);
HAVE_PORTF(shadowPORTF=PORTF);
HAVE_PORTG(shadowPORTF=PORTG);
HAVE_PORTH(shadowPORTF=PORTH);
HAVE_PORTG(shadowPORTG=PORTG);
HAVE_PORTH(shadowPORTH=PORTH);
APPLY_BY_MODE(TRACK_MODE_PROG,setSignal(on));
HAVE_PORTA(PORTA=shadowPORTA);
HAVE_PORTB(PORTB=shadowPORTB);
@ -182,8 +182,8 @@ void TrackManager::setPROGSignal( bool on) {
HAVE_PORTD(PORTD=shadowPORTD);
HAVE_PORTE(PORTE=shadowPORTE);
HAVE_PORTF(PORTF=shadowPORTF);
HAVE_PORTG(shadowPORTF=PORTG);
HAVE_PORTH(shadowPORTF=PORTH);
HAVE_PORTG(shadowPORTG=PORTG);
HAVE_PORTH(shadowPORTH=PORTH);
}
// setDCSignal(), called from normal context

View File

@ -72,8 +72,9 @@ Stream * WifiInterface::wifiStream;
#elif defined(ARDUINO_NUCLEO_F413ZH) || defined(ARDUINO_NUCLEO_F429ZI) \
|| defined(ARDUINO_NUCLEO_F446ZE) || defined(ARDUINO_NUCLEO_F412ZG) \
|| defined(ARDUINO_NUCLEO_F439ZI) || defined(ARDUINO_NUCLEO_F4X9ZI)
#define NUM_SERIAL 2
#define NUM_SERIAL 3
#define SERIAL1 Serial6
#define SERIAL3 Serial2
#else
#warning This variant of Nucleo not yet explicitly supported
#endif

View File

@ -3,7 +3,8 @@
#include "StringFormatter.h"
#define VERSION "5.2.82"
#define VERSION "5.2.83"
// 5.2.83 - Various STM32 related fixes for serial ports, I2C pullups now turned off, and shadowing of PORTG/PORTH for TrackManager now correct
// 5.2.82 - TrackManager and EXRAIL: Introduce more consistent names for <= ...> and SET_TRACK
// 5.2.81 - STM32 Ethernet boards support, also now have specific EX8874 motor driver definition
// 5.2.80 - EthernetInterface upgrade, including STM32 Ethernet support