diff options
Diffstat (limited to 'src/Movement/StepperDrivers/TMC22xx.cpp')
-rw-r--r-- | src/Movement/StepperDrivers/TMC22xx.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/Movement/StepperDrivers/TMC22xx.cpp b/src/Movement/StepperDrivers/TMC22xx.cpp index adb2d479..7c4fca79 100644 --- a/src/Movement/StepperDrivers/TMC22xx.cpp +++ b/src/Movement/StepperDrivers/TMC22xx.cpp @@ -106,7 +106,7 @@ enum class DriversState : uint8_t static DriversState driversState = DriversState::shutDown; -#if TMC22xx_USE_SLAVEADDR +#if TMC22xx_USE_SLAVEADDR && TMC22xx_HAS_MUX static bool currentMuxState; #endif @@ -931,7 +931,7 @@ pre(!driversPowered) IoPort::SetPinMode(p_diagPin, INPUT_PULLDOWN); // pull down not up so that missing drivers don't signal stalls #endif -#if !(TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER) +#if !(TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER || TMC22xx_USE_SLAVEADDR) # if TMC22xx_USES_SERCOM sercom = TMC22xxSercoms[p_driverNumber]; sercomNumber = TMC22xxSercomNumbers[p_driverNumber]; @@ -1531,7 +1531,7 @@ inline void TmcDriverState::UartTmcHandler() noexcept TransferDone(); // tidy up after the transfer we just completed } -#if TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER +#if TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER || TMC22xx_USE_SLAVEADDR # if TMC22xx_USES_SERCOM @@ -1837,16 +1837,15 @@ void SmartDrivers::Init() noexcept // Make sure the ENN pins are high IoPort::SetPinMode(GlobalTmc22xxEnablePin, OUTPUT_HIGH); -#if TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER -# if TMC22xx_USES_SERCOM +#if TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER || TMC22xx_USE_SLAVEADDR // Set up the single UART that communicates with all TMC22xx drivers +# if TMC22xx_USES_SERCOM SetPinFunction(TMC22xxSercomTxPin, TMC22xxSercomTxPinPeriphMode); SetPinFunction(TMC22xxSercomRxPin, TMC22xxSercomRxPinPeriphMode); Serial::InitUart(TMC22xxSercomNumber, DriversBaudRate, TMC22xxSercomRxPad, true); DmacManager::SetInterruptCallback(DmacChanTmcRx, TransferCompleteCallback, CallbackParameter(0)); # else - // Set up the single UART that communicates with all TMC22xx drivers SetPinFunction(TMC22xxUartTxPin, TMC22xxUartPeriphMode); SetPinFunction(TMC22xxUartRxPin, TMC22xxUartPeriphMode); EnablePullup(TMC22xxUartRxPin); @@ -1880,7 +1879,8 @@ void SmartDrivers::Init() noexcept driversState = DriversState::noPower; for (size_t drive = 0; drive < GetNumTmcDrivers(); ++drive) { -#if !(TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER) +#if !(TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER || TMC22xx_USE_SLAVEADDR) + // Set up the individual UARTs that communicate with each of the TMC22xx drivers # if TMC22xx_USES_SERCOM // Initialise the SERCOM that controls this driver gpio_set_pin_function(TMC22xxSercomTxPins[drive], TMC22xxSercomTxPinPeriphModes[drive]); @@ -1889,8 +1889,7 @@ void SmartDrivers::Init() noexcept Serial::InitUart(TMC22xxUarts[drive], TMC22xxSercomNumbers[drive], DriversBaudRate); NVIC_EnableIRQ(TMC22xxSercomIRQns[drive]); # else - // Initialise the UART that controls this driver - // The pins are already set up for UART use in the pins table + // Initialise the UART that controls this driver. The pins are already set up for UART use in the pins table ConfigurePin(TMC22xxUartPins[drive]); // Enable the clock to the UART @@ -1928,7 +1927,7 @@ void SmartDrivers::Init() noexcept void SmartDrivers::Exit() noexcept { IoPort::SetPinMode(GlobalTmc22xxEnablePin, OUTPUT_HIGH); -#if TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER +#if TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER || TMC22xx_USE_SLAVEADDR # if TMC22xx_USES_SERCOM DmacManager::SetInterruptCallback(DmacChanTmcRx, nullptr, CallbackParameter(nullptr)); # else |