Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2019-12-10 18:03:11 +0300
committerDavid Crocker <dcrocker@eschertech.com>2019-12-10 18:03:11 +0300
commitb7daa1866c654eefe9d1427fd5d2c68b476d7cd7 (patch)
treec9ca30e6f07acd55061236c820469e794111fb14 /src
parentd4342a41d2972c20892c793f2ce015e6eafc70ed (diff)
Added more noexcept specifiers
Diffstat (limited to 'src')
-rw-r--r--src/CAN/CanInterface.cpp2
-rw-r--r--src/Duet3_V06/Pins_Duet3_V06.cpp2
-rw-r--r--src/Duet3_V06/Pins_Duet3_V06.h16
-rw-r--r--src/DuetM/Pins_DuetM.cpp2
-rw-r--r--src/DuetM/Pins_DuetM.h16
-rw-r--r--src/DuetNG/Pins_DuetNG.cpp2
-rw-r--r--src/DuetNG/Pins_DuetNG.h16
-rw-r--r--src/Linux/DataTransfer.cpp2
-rw-r--r--src/Movement/DDA.cpp2
-rw-r--r--src/Movement/StepTimer.cpp2
-rw-r--r--src/Movement/StepperDrivers/DriverMode.cpp2
-rw-r--r--src/Movement/StepperDrivers/DriverMode.h4
-rw-r--r--src/Movement/StepperDrivers/TMC22xx.cpp188
-rw-r--r--src/Movement/StepperDrivers/TMC22xx.h38
-rw-r--r--src/Movement/StepperDrivers/TMC2660.cpp152
-rw-r--r--src/Movement/StepperDrivers/TMC2660.h46
-rw-r--r--src/Movement/StepperDrivers/TMC51xx.cpp194
-rw-r--r--src/Movement/StepperDrivers/TMC51xx.h48
-rw-r--r--src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp20
-rw-r--r--src/Networking/LwipEthernet/GMAC/ethernet_sam.h20
-rw-r--r--src/Networking/LwipEthernet/GMAC/same70_gmac.cpp36
-rw-r--r--src/Networking/LwipEthernet/GMAC/same70_gmac.h18
-rw-r--r--src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h5
-rw-r--r--src/Networking/LwipEthernet/LwipEthernetInterface.cpp58
-rw-r--r--src/Networking/LwipEthernet/LwipEthernetInterface.h70
-rw-r--r--src/Networking/LwipEthernet/LwipSocket.cpp38
-rw-r--r--src/Networking/LwipEthernet/LwipSocket.h44
-rw-r--r--src/Platform.cpp6
-rw-r--r--src/RepRap.cpp2
-rw-r--r--src/SoftwareReset.h2
30 files changed, 525 insertions, 528 deletions
diff --git a/src/CAN/CanInterface.cpp b/src/CAN/CanInterface.cpp
index f3891738..932ccdfe 100644
--- a/src/CAN/CanInterface.cpp
+++ b/src/CAN/CanInterface.cpp
@@ -260,7 +260,7 @@ static status_code mcan_fd_send_ext_message(uint32_t id_value, const uint8_t *da
}
// Interrupt handler for MCAN, including RX,TX,ERROR and so on processes
-void MCAN_INT0_Handler(void)
+extern "C" void MCAN_INT0_Handler() noexcept
{
const uint32_t status = mcan_read_interrupt_status(&mcan_instance);
diff --git a/src/Duet3_V06/Pins_Duet3_V06.cpp b/src/Duet3_V06/Pins_Duet3_V06.cpp
index d7f5325b..a96f3508 100644
--- a/src/Duet3_V06/Pins_Duet3_V06.cpp
+++ b/src/Duet3_V06/Pins_Duet3_V06.cpp
@@ -11,7 +11,7 @@
// Function to look up a pin name pass back the corresponding index into the pin table
// On this platform, the mapping from pin names to pins is fixed, so this is a simple lookup
-bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted)
+bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted) noexcept
{
if (StringEqualsIgnoreCase(pn, NoPinName))
{
diff --git a/src/Duet3_V06/Pins_Duet3_V06.h b/src/Duet3_V06/Pins_Duet3_V06.h
index 85305476..414d06a0 100644
--- a/src/Duet3_V06/Pins_Duet3_V06.h
+++ b/src/Duet3_V06/Pins_Duet3_V06.h
@@ -193,7 +193,7 @@ enum class PinCapability: uint8_t
ainrwpwm = 1|2|4|8
};
-constexpr inline PinCapability operator|(PinCapability a, PinCapability b)
+constexpr inline PinCapability operator|(PinCapability a, PinCapability b) noexcept
{
return (PinCapability)((uint8_t)a | (uint8_t)b);
}
@@ -202,9 +202,9 @@ constexpr inline PinCapability operator|(PinCapability a, PinCapability b)
// This can be varied to suit the hardware. It is a struct not a class so that it can be direct initialised in read-only memory.
struct PinEntry
{
- Pin GetPin() const { return pin; }
- PinCapability GetCapability() const { return cap; }
- const char* GetNames() const { return names; }
+ Pin GetPin() const noexcept { return pin; }
+ PinCapability GetCapability() const noexcept { return cap; }
+ const char* GetNames() const noexcept { return names; }
Pin pin;
PinCapability cap;
@@ -275,7 +275,7 @@ constexpr PinEntry PinTable[] =
constexpr unsigned int NumNamedPins = ARRAY_SIZE(PinTable);
// Function to look up a pin name pass back the corresponding index into the pin table
-bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted);
+bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted) noexcept;
// Duet pin numbers for the Linux interface
constexpr Pin LinuxTfrReadyPin = PortEPin(2);
@@ -323,7 +323,7 @@ namespace StepPins
// All our step pins are on port C, so the bitmap is just the map of step bits in port C.
// Calculate the step bit for a driver. This doesn't need to be fast. It must return 0 if the driver is remote.
- static inline uint32_t CalcDriverBitmap(size_t driver)
+ static inline uint32_t CalcDriverBitmap(size_t driver) noexcept
{
return (driver < NumDirectDrivers)
? g_APinDescription[STEP_PINS[driver]].ulPin
@@ -333,7 +333,7 @@ namespace StepPins
// Set the specified step pins high
// This needs to be as fast as possible, so we do a parallel write to the port(s).
// We rely on only those port bits that are step pins being set in the PIO_OWSR register of each port
- static inline void StepDriversHigh(uint32_t driverMap)
+ static inline void StepDriversHigh(uint32_t driverMap) noexcept
{
PIOC->PIO_ODSR = driverMap; // on Duet 3 all step pins are on port C
}
@@ -341,7 +341,7 @@ namespace StepPins
// Set all step pins low
// This needs to be as fast as possible, so we do a parallel write to the port(s).
// We rely on only those port bits that are step pins being set in the PIO_OWSR register of each port
- static inline void StepDriversLow()
+ static inline void StepDriversLow() noexcept
{
PIOC->PIO_ODSR = 0; // on Duet 3 all step pins are on port C
}
diff --git a/src/DuetM/Pins_DuetM.cpp b/src/DuetM/Pins_DuetM.cpp
index 6f0034e2..07461c6e 100644
--- a/src/DuetM/Pins_DuetM.cpp
+++ b/src/DuetM/Pins_DuetM.cpp
@@ -11,7 +11,7 @@
// Function to look up a pin name pass back the corresponding index into the pin table
// On this platform, the mapping from pin names to pins is fixed, so this is a simple lookup
-bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted)
+bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted) noexcept
{
if (StringEqualsIgnoreCase(pn, NoPinName))
{
diff --git a/src/DuetM/Pins_DuetM.h b/src/DuetM/Pins_DuetM.h
index 8215914e..232c3c81 100644
--- a/src/DuetM/Pins_DuetM.h
+++ b/src/DuetM/Pins_DuetM.h
@@ -200,7 +200,7 @@ enum class PinCapability: uint8_t
ainrwpwm = 1|2|4|8
};
-constexpr inline PinCapability operator|(PinCapability a, PinCapability b)
+constexpr inline PinCapability operator|(PinCapability a, PinCapability b) noexcept
{
return (PinCapability)((uint8_t)a | (uint8_t)b);
}
@@ -209,9 +209,9 @@ constexpr inline PinCapability operator|(PinCapability a, PinCapability b)
// This can be varied to suit the hardware. It is a struct not a class so that it can be direct initialised in read-only memory.
struct PinEntry
{
- Pin GetPin() const { return pin; }
- PinCapability GetCapability() const { return cap; }
- const char* GetNames() const { return names; }
+ Pin GetPin() const noexcept { return pin; }
+ PinCapability GetCapability() const noexcept { return cap; }
+ const char* GetNames() const noexcept { return names; }
Pin pin;
PinCapability cap;
@@ -265,7 +265,7 @@ constexpr PinEntry PinTable[] =
constexpr unsigned int NumNamedPins = ARRAY_SIZE(PinTable);
// Function to look up a pin name pass back the corresponding index into the pin table
-bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted);
+bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted) noexcept;
// Default pin allocations
constexpr const char *DefaultEndstopPinNames[] = { "xstop", "ystop", "zstop" };
@@ -298,7 +298,7 @@ namespace StepPins
// All our step pins are on port C, so the bitmap is just the map of step bits in port C.
// Calculate the step bit for a driver. This doesn't need to be fast. It must return 0 if the driver is remote.
- static inline uint32_t CalcDriverBitmap(size_t driver)
+ static inline uint32_t CalcDriverBitmap(size_t driver) noexcept
{
return (driver < NumDirectDrivers)
? g_APinDescription[STEP_PINS[driver]].ulPin
@@ -308,7 +308,7 @@ namespace StepPins
// Set the specified step pins high
// This needs to be as fast as possible, so we do a parallel write to the port(s).
// We rely on only those port bits that are step pins being set in the PIO_OWSR register of each port
- static inline void StepDriversHigh(uint32_t driverMap)
+ static inline void StepDriversHigh(uint32_t driverMap) noexcept
{
PIOC->PIO_ODSR = driverMap; // on Duet Maestro all step pins are on port C
}
@@ -316,7 +316,7 @@ namespace StepPins
// Set all step pins low
// This needs to be as fast as possible, so we do a parallel write to the port(s).
// We rely on only those port bits that are step pins being set in the PIO_OWSR register of each port
- static inline void StepDriversLow()
+ static inline void StepDriversLow() noexcept
{
PIOC->PIO_ODSR = 0; // on Duet Maestro all step pins are on port C
}
diff --git a/src/DuetNG/Pins_DuetNG.cpp b/src/DuetNG/Pins_DuetNG.cpp
index d7f5325b..a96f3508 100644
--- a/src/DuetNG/Pins_DuetNG.cpp
+++ b/src/DuetNG/Pins_DuetNG.cpp
@@ -11,7 +11,7 @@
// Function to look up a pin name pass back the corresponding index into the pin table
// On this platform, the mapping from pin names to pins is fixed, so this is a simple lookup
-bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted)
+bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted) noexcept
{
if (StringEqualsIgnoreCase(pn, NoPinName))
{
diff --git a/src/DuetNG/Pins_DuetNG.h b/src/DuetNG/Pins_DuetNG.h
index f183001d..6b90a9f4 100644
--- a/src/DuetNG/Pins_DuetNG.h
+++ b/src/DuetNG/Pins_DuetNG.h
@@ -205,7 +205,7 @@ enum class PinCapability: uint8_t
ainrwpwm = 1|2|4|8
};
-constexpr inline PinCapability operator|(PinCapability a, PinCapability b)
+constexpr inline PinCapability operator|(PinCapability a, PinCapability b) noexcept
{
return (PinCapability)((uint8_t)a | (uint8_t)b);
}
@@ -214,9 +214,9 @@ constexpr inline PinCapability operator|(PinCapability a, PinCapability b)
// This can be varied to suit the hardware. It is a struct not a class so that it can be direct initialised in read-only memory.
struct PinEntry
{
- Pin GetPin() const { return pin; }
- PinCapability GetCapability() const { return cap; }
- const char* GetNames() const { return names; }
+ Pin GetPin() const noexcept { return pin; }
+ PinCapability GetCapability() const noexcept { return cap; }
+ const char* GetNames() const noexcept { return names; }
Pin pin;
PinCapability cap;
@@ -318,7 +318,7 @@ constexpr PinEntry PinTable[] =
constexpr unsigned int NumNamedPins = ARRAY_SIZE(PinTable);
// Function to look up a pin name pass back the corresponding index into the pin table
-bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted);
+bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted) noexcept;
// Default pin allocations
constexpr const char *DefaultEndstopPinNames[] = { "xstop", "ystop", "zstop" };
@@ -357,7 +357,7 @@ namespace StepPins
// All our step pins are on port D, so the bitmap is just the map of step bits in port D.
// Calculate the step bit for a driver. This doesn't need to be fast. It must return 0 if the driver is remote.
- static inline uint32_t CalcDriverBitmap(size_t driver)
+ static inline uint32_t CalcDriverBitmap(size_t driver) noexcept
{
return (driver < NumDirectDrivers)
? g_APinDescription[STEP_PINS[driver]].ulPin
@@ -367,7 +367,7 @@ namespace StepPins
// Set the specified step pins high
// This needs to be as fast as possible, so we do a parallel write to the port(s).
// We rely on only those port bits that are step pins being set in the PIO_OWSR register of each port
- static inline void StepDriversHigh(uint32_t driverMap)
+ static inline void StepDriversHigh(uint32_t driverMap) noexcept
{
PIOD->PIO_ODSR = driverMap; // on Duet WiFi/Ethernet all step pins are on port D
}
@@ -375,7 +375,7 @@ namespace StepPins
// Set all step pins low
// This needs to be as fast as possible, so we do a parallel write to the port(s).
// We rely on only those port bits that are step pins being set in the PIO_OWSR register of each port
- static inline void StepDriversLow()
+ static inline void StepDriversLow() noexcept
{
PIOD->PIO_ODSR = 0; // on Duet WiFi/Ethernet all step pins are on port D
}
diff --git a/src/Linux/DataTransfer.cpp b/src/Linux/DataTransfer.cpp
index f7e93f60..2604202d 100644
--- a/src/Linux/DataTransfer.cpp
+++ b/src/Linux/DataTransfer.cpp
@@ -118,7 +118,7 @@ void disable_spi()
# error SBC_SPI_HANDLER undefined
#endif
-extern "C" void SBC_SPI_HANDLER(void)
+extern "C" void SBC_SPI_HANDLER() noexcept
{
const uint32_t status = SBC_SPI->SPI_SR; // read status and clear interrupt
SBC_SPI->SPI_IDR = SPI_IER_NSSR; // disable the interrupt
diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp
index 2cdb258a..955685e6 100644
--- a/src/Movement/DDA.cpp
+++ b/src/Movement/DDA.cpp
@@ -2072,7 +2072,7 @@ void DDA::LimitSpeedAndAcceleration(float maxSpeed, float maxAcceleration) noexc
// Prepare a remote extruder, returning the number of steps we are going to do before allowing for pressure advance.
// This replicates some of the functionality that DriveMovement::PrepareExtruder does for local extruder drives.
-int32_t DDA::PrepareRemoteExtruder(size_t drive, float& extrusionPending, float speedChange) const
+int32_t DDA::PrepareRemoteExtruder(size_t drive, float& extrusionPending, float speedChange) const noexcept
{
// Calculate the requested extrusion amount and a few other things
float extrusionRequired = totalDistance * directionVector[drive];
diff --git a/src/Movement/StepTimer.cpp b/src/Movement/StepTimer.cpp
index 25082096..5c0fd23d 100644
--- a/src/Movement/StepTimer.cpp
+++ b/src/Movement/StepTimer.cpp
@@ -99,7 +99,7 @@ void StepTimer::Init() noexcept
#if SAM4S || SAME70
// Get the interrupt clock count. The TCs on the SAM4S and SAME70 are only 16 bits wide, so we maintain the upper 16 bits in a chained counter.
-/*static*/ uint32_t StepTimer::GetTimerTicks()
+/*static*/ uint32_t StepTimer::GetTimerTicks() noexcept
{
uint16_t highWord = STEP_TC->TC_CHANNEL[STEP_TC_CHAN_UPPER].TC_CV; // get the timer high word
do
diff --git a/src/Movement/StepperDrivers/DriverMode.cpp b/src/Movement/StepperDrivers/DriverMode.cpp
index f4d06df5..14242212 100644
--- a/src/Movement/StepperDrivers/DriverMode.cpp
+++ b/src/Movement/StepperDrivers/DriverMode.cpp
@@ -20,7 +20,7 @@ static const char * const DriverModeStrings[] =
static_assert(ARRAY_SIZE(DriverModeStrings) == (unsigned int)DriverMode::unknown + 1, "bad driver mode string table");
-const char* TranslateDriverMode(unsigned int mode)
+const char* TranslateDriverMode(unsigned int mode) noexcept
{
const unsigned int imode = min<unsigned int>(mode, (unsigned int)DriverMode::unknown);
return DriverModeStrings[imode];
diff --git a/src/Movement/StepperDrivers/DriverMode.h b/src/Movement/StepperDrivers/DriverMode.h
index 692872a3..1594a192 100644
--- a/src/Movement/StepperDrivers/DriverMode.h
+++ b/src/Movement/StepperDrivers/DriverMode.h
@@ -17,9 +17,9 @@ enum class DriverMode : unsigned int
unknown // must be last!
};
-const char* TranslateDriverMode(unsigned int mode);
+const char* TranslateDriverMode(unsigned int mode) noexcept;
-inline const char* TranslateDriverMode(DriverMode mode)
+inline const char* TranslateDriverMode(DriverMode mode) noexcept
{
return TranslateDriverMode((unsigned int)mode);
}
diff --git a/src/Movement/StepperDrivers/TMC22xx.cpp b/src/Movement/StepperDrivers/TMC22xx.cpp
index f14cd25c..3af1c715 100644
--- a/src/Movement/StepperDrivers/TMC22xx.cpp
+++ b/src/Movement/StepperDrivers/TMC22xx.cpp
@@ -209,7 +209,7 @@ constexpr uint8_t REGNUM_PWM_AUTO = 0x72;
// Byte 7 8-bit CRC
// Add 1 bit to a CRC
-static inline constexpr uint8_t CRCAddBit(uint8_t crc, uint8_t currentByte, uint8_t bit)
+static inline constexpr uint8_t CRCAddBit(uint8_t crc, uint8_t currentByte, uint8_t bit) noexcept
{
return (((crc ^ (currentByte << (7 - bit))) & 0x80) != 0)
? (crc << 1) ^ 0x07
@@ -217,7 +217,7 @@ static inline constexpr uint8_t CRCAddBit(uint8_t crc, uint8_t currentByte, uint
}
// Add a byte to a CRC
-static inline constexpr uint8_t CRCAddByte(uint8_t crc, uint8_t currentByte)
+static inline constexpr uint8_t CRCAddByte(uint8_t crc, uint8_t currentByte) noexcept
{
crc = CRCAddBit(crc, currentByte, 0);
crc = CRCAddBit(crc, currentByte, 1);
@@ -242,55 +242,55 @@ static constexpr uint8_t ReadIfcountCRC = CRCAddByte(InitialSendCRC, REGNUM_IFCO
class TmcDriverState
{
public:
- void Init(uint32_t p_driverNumber, Pin p_pin);
- void SetAxisNumber(size_t p_axisNumber);
- uint32_t GetAxisNumber() const { return axisNumber; }
- void WriteAll();
- bool SetMicrostepping(uint32_t shift, bool interpolate);
- unsigned int GetMicrostepping(bool& interpolation) const; // Get microstepping
- bool SetDriverMode(unsigned int mode);
- DriverMode GetDriverMode() const;
- void SetCurrent(float current);
- void Enable(bool en);
- void AppendDriverStatus(const StringRef& reply);
- uint8_t GetDriverNumber() const { return driverNumber; }
- bool UpdatePending() const { return registersToUpdate != 0; }
- bool UsesGlobalEnable() const { return enablePin == NoPin; }
-
- bool SetRegister(SmartDriverRegister reg, uint32_t regVal);
- uint32_t GetRegister(SmartDriverRegister reg) const;
-
- float GetStandstillCurrentPercent() const;
- void SetStandstillCurrentPercent(float percent);
-
- void TransferDone() __attribute__ ((hot)); // called by the ISR when the SPI transfer has completed
- void StartTransfer() __attribute__ ((hot)); // called to start a transfer
- void TransferTimedOut() { ++numTimeouts; }
- void AbortTransfer();
-
- uint32_t ReadLiveStatus() const;
- uint32_t ReadAccumulatedStatus(uint32_t bitsToKeep);
+ void Init(uint32_t p_driverNumber, Pin p_pin) noexcept;
+ void SetAxisNumber(size_t p_axisNumber) noexcept;
+ uint32_t GetAxisNumber() const noexcept { return axisNumber; }
+ void WriteAll() noexcept;
+ bool SetMicrostepping(uint32_t shift, bool interpolate) noexcept;
+ unsigned int GetMicrostepping(bool& interpolation) const noexcept;
+ bool SetDriverMode(unsigned int mode) noexcept;
+ DriverMode GetDriverMode() const noexcept;
+ void SetCurrent(float current) noexcept;
+ void Enable(bool en) noexcept;
+ void AppendDriverStatus(const StringRef& reply) noexcept;
+ uint8_t GetDriverNumber() const noexcept { return driverNumber; }
+ bool UpdatePending() const noexcept { return registersToUpdate != 0; }
+ bool UsesGlobalEnable() const noexcept { return enablePin == NoPin; }
+
+ bool SetRegister(SmartDriverRegister reg, uint32_t regVal) noexcept;
+ uint32_t GetRegister(SmartDriverRegister reg) const noexcept;
+
+ float GetStandstillCurrentPercent() const noexcept;
+ void SetStandstillCurrentPercent(float percent) noexcept;
+
+ void TransferDone() noexcept __attribute__ ((hot)); // called by the ISR when the SPI transfer has completed
+ void StartTransfer() noexcept __attribute__ ((hot)); // called to start a transfer
+ void TransferTimedOut() noexcept { ++numTimeouts; }
+ void AbortTransfer() noexcept;
+
+ uint32_t ReadLiveStatus() const noexcept;
+ uint32_t ReadAccumulatedStatus(uint32_t bitsToKeep) noexcept;
// Variables used by the ISR
static TmcDriverState * volatile currentDriver; // volatile because the ISR changes it
static uint32_t transferStartedTime;
- void UartTmcHandler(); // core of the ISR for this driver
+ void UartTmcHandler() noexcept; // core of the ISR for this driver
private:
- bool SetChopConf(uint32_t newVal);
- void UpdateRegister(size_t regIndex, uint32_t regVal);
- void UpdateChopConfRegister(); // calculate the chopper control register and flag it for sending
- void UpdateCurrent();
- void UpdateMaxOpenLoadStepInterval();
+ bool SetChopConf(uint32_t newVal) noexcept;
+ void UpdateRegister(size_t regIndex, uint32_t regVal) noexcept;
+ void UpdateChopConfRegister() noexcept; // calculate the chopper control register and flag it for sending
+ void UpdateCurrent() noexcept;
+ void UpdateMaxOpenLoadStepInterval() noexcept;
#if TMC22xx_HAS_MUX
- void SetUartMux();
- static void SetupDMASend(uint8_t regnum, uint32_t outVal, uint8_t crc) __attribute__ ((hot)); // set up the PDC to send a register
- static void SetupDMAReceive(uint8_t regnum, uint8_t crc) __attribute__ ((hot)); // set up the PDC to receive a register
+ void SetUartMux() noexcept;
+ static void SetupDMASend(uint8_t regnum, uint32_t outVal, uint8_t crc) noexcept __attribute__ ((hot)); // set up the PDC to send a register
+ static void SetupDMAReceive(uint8_t regnum, uint8_t crc) noexcept __attribute__ ((hot)); // set up the PDC to receive a register
#else
- void SetupDMASend(uint8_t regnum, uint32_t outVal, uint8_t crc) __attribute__ ((hot)); // set up the PDC to send a register
- void SetupDMAReceive(uint8_t regnum, uint8_t crc) __attribute__ ((hot)); // set up the PDC to receive a register
+ void SetupDMASend(uint8_t regnum, uint32_t outVal, uint8_t crc) noexcept __attribute__ ((hot)); // set up the PDC to send a register
+ void SetupDMAReceive(uint8_t regnum, uint8_t crc) noexcept __attribute__ ((hot)); // set up the PDC to receive a register
#endif
static constexpr unsigned int NumWriteRegisters = 6; // the number of registers that we write to
@@ -409,7 +409,7 @@ const uint8_t TmcDriverState::ReadRegCRCs[NumReadRegisters] =
static TmcDriverState driverStates[MaxSmartDrivers];
// Set up the PDC to send a register
-inline void TmcDriverState::SetupDMASend(uint8_t regNum, uint32_t regVal, uint8_t crc)
+inline void TmcDriverState::SetupDMASend(uint8_t regNum, uint32_t regVal, uint8_t crc) noexcept
{
// Faster code, not using the ASF
Pdc * const pdc = uart_get_pdc_base(uart);
@@ -435,7 +435,7 @@ inline void TmcDriverState::SetupDMASend(uint8_t regNum, uint32_t regVal, uint8_
}
// Set up the PDC to send a register and receive the status
-inline void TmcDriverState::SetupDMAReceive(uint8_t regNum, uint8_t crc)
+inline void TmcDriverState::SetupDMAReceive(uint8_t regNum, uint8_t crc) noexcept
{
// Faster code, not using the ASF
Pdc * const pdc = uart_get_pdc_base(uart);
@@ -457,7 +457,7 @@ inline void TmcDriverState::SetupDMAReceive(uint8_t regNum, uint8_t crc)
}
// Update the maximum step pulse interval at wich we consider open load detection to be reliable
-void TmcDriverState::UpdateMaxOpenLoadStepInterval()
+void TmcDriverState::UpdateMaxOpenLoadStepInterval() noexcept
{
const uint32_t defaultMaxInterval = StepTimer::StepClockRate/MinimumOpenLoadFullStepsPerSec;
if ((writeRegisters[WriteGConf] & GCONF_SPREAD_CYCLE) != 0)
@@ -478,7 +478,7 @@ void TmcDriverState::UpdateMaxOpenLoadStepInterval()
}
// Set a register value and flag it for updating
-void TmcDriverState::UpdateRegister(size_t regIndex, uint32_t regVal)
+void TmcDriverState::UpdateRegister(size_t regIndex, uint32_t regVal) noexcept
{
registersToUpdate &= ~(1u << regIndex); // make sure it is not updated while we are changing it
uint8_t crc = InitialSendCRC;
@@ -499,13 +499,13 @@ void TmcDriverState::UpdateRegister(size_t regIndex, uint32_t regVal)
}
// Calculate the chopper control register and flag it for sending
-void TmcDriverState::UpdateChopConfRegister()
+void TmcDriverState::UpdateChopConfRegister() noexcept
{
UpdateRegister(WriteChopConf, (enabled) ? configuredChopConfReg : configuredChopConfReg & ~CHOPCONF_TOFF_MASK);
}
// Initialise the state of the driver and its CS pin
-void TmcDriverState::Init(uint32_t p_driverNumber, Pin p_pin)
+void TmcDriverState::Init(uint32_t p_driverNumber, Pin p_pin) noexcept
pre(!driversPowered)
{
driverNumber = p_driverNumber;
@@ -542,30 +542,30 @@ pre(!driversPowered)
readErrors = writeErrors = numReads = numTimeouts = 0;
}
-inline void TmcDriverState::SetAxisNumber(size_t p_axisNumber)
+inline void TmcDriverState::SetAxisNumber(size_t p_axisNumber) noexcept
{
axisNumber = p_axisNumber;
}
// Write all registers. This is called when the drivers are known to be powered up.
-inline void TmcDriverState::WriteAll()
+inline void TmcDriverState::WriteAll() noexcept
{
registersToUpdate = (1u << NumWriteRegisters) - 1;
}
-float TmcDriverState::GetStandstillCurrentPercent() const
+float TmcDriverState::GetStandstillCurrentPercent() const noexcept
{
return (float)(standstillCurrentFraction * 100)/256;
}
-void TmcDriverState::SetStandstillCurrentPercent(float percent)
+void TmcDriverState::SetStandstillCurrentPercent(float percent) noexcept
{
standstillCurrentFraction = (uint8_t)constrain<long>(lrintf((percent * 256)/100), 0, 255);
UpdateCurrent();
}
// Set the microstepping and microstep interpolation. The desired microstepping is (1 << shift).
-bool TmcDriverState::SetMicrostepping(uint32_t shift, bool interpolate)
+bool TmcDriverState::SetMicrostepping(uint32_t shift, bool interpolate) noexcept
{
microstepShiftFactor = shift;
configuredChopConfReg = (configuredChopConfReg & ~(CHOPCONF_MRES_MASK | CHOPCONF_INTPOL)) | ((8 - shift) << CHOPCONF_MRES_SHIFT);
@@ -578,13 +578,13 @@ bool TmcDriverState::SetMicrostepping(uint32_t shift, bool interpolate)
}
// Get microstepping or chopper control register
-unsigned int TmcDriverState::GetMicrostepping(bool& interpolation) const
+unsigned int TmcDriverState::GetMicrostepping(bool& interpolation) const noexcept
{
interpolation = (writeRegisters[WriteChopConf] & CHOPCONF_INTPOL) != 0;
return 1u << microstepShiftFactor;
}
-bool TmcDriverState::SetRegister(SmartDriverRegister reg, uint32_t regVal)
+bool TmcDriverState::SetRegister(SmartDriverRegister reg, uint32_t regVal) noexcept
{
switch(reg)
{
@@ -614,7 +614,7 @@ bool TmcDriverState::SetRegister(SmartDriverRegister reg, uint32_t regVal)
}
}
-uint32_t TmcDriverState::GetRegister(SmartDriverRegister reg) const
+uint32_t TmcDriverState::GetRegister(SmartDriverRegister reg) const noexcept
{
switch(reg)
{
@@ -650,7 +650,7 @@ uint32_t TmcDriverState::GetRegister(SmartDriverRegister reg) const
}
// Set the chopper control register to the settings provided by the user. We allow only the lowest 17 bits to be set.
-bool TmcDriverState::SetChopConf(uint32_t newVal)
+bool TmcDriverState::SetChopConf(uint32_t newVal) noexcept
{
const uint32_t offTime = (newVal & CHOPCONF_TOFF_MASK) >> CHOPCONF_TOFF_SHIFT;
if (offTime == 0 || (offTime == 1 && (newVal & CHOPCONF_TBL_MASK) < (2 << CHOPCONF_TBL_SHIFT)))
@@ -670,7 +670,7 @@ bool TmcDriverState::SetChopConf(uint32_t newVal)
}
// Set the driver mode
-bool TmcDriverState::SetDriverMode(unsigned int mode)
+bool TmcDriverState::SetDriverMode(unsigned int mode) noexcept
{
switch (mode)
{
@@ -688,19 +688,19 @@ bool TmcDriverState::SetDriverMode(unsigned int mode)
}
// Get the driver mode
-DriverMode TmcDriverState::GetDriverMode() const
+DriverMode TmcDriverState::GetDriverMode() const noexcept
{
return ((writeRegisters[WriteGConf] & GCONF_SPREAD_CYCLE) != 0) ? DriverMode::spreadCycle : DriverMode::stealthChop;
}
// Set the motor current
-void TmcDriverState::SetCurrent(float current)
+void TmcDriverState::SetCurrent(float current) noexcept
{
motorCurrent = static_cast<uint32_t>(constrain<float>(current, 50.0, MaximumMotorCurrent));
UpdateCurrent();
}
-void TmcDriverState::UpdateCurrent()
+void TmcDriverState::UpdateCurrent() noexcept
{
// The current sense resistor on the Duet M is 0.082 ohms, to which we must add 0.03 ohms internal resistance.
// Full scale peak motor current in the high sensitivity range is give by I = 0.18/(R+0.03) = 0.18/0.105 ~= 1.6A
@@ -713,7 +713,7 @@ void TmcDriverState::UpdateCurrent()
}
// Enable or disable the driver
-void TmcDriverState::Enable(bool en)
+void TmcDriverState::Enable(bool en) noexcept
{
if (enabled != en)
{
@@ -727,14 +727,14 @@ void TmcDriverState::Enable(bool en)
}
// Read the status
-uint32_t TmcDriverState::ReadLiveStatus() const
+uint32_t TmcDriverState::ReadLiveStatus() const noexcept
{
const uint32_t ret = readRegisters[ReadDrvStat] & (TMC_RR_OT | TMC_RR_OTPW | TMC_RR_S2G | TMC_RR_OLA | TMC_RR_OLB | TMC_RR_STST | TMC_RR_TEMPBITS);
return (enabled) ? ret : ret & ~(TMC_RR_OLA | TMC_RR_OLB);
}
// Read the status
-uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep)
+uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep) noexcept
{
const uint32_t mask = (enabled) ? 0xFFFFFFFF : ~(TMC_RR_OLA | TMC_RR_OLB);
bitsToKeep &= mask;
@@ -746,7 +746,7 @@ uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep)
}
// Append the driver status to a string, and reset the min/max load values
-void TmcDriverState::AppendDriverStatus(const StringRef& reply)
+void TmcDriverState::AppendDriverStatus(const StringRef& reply) noexcept
{
const uint32_t lastReadStatus = readRegisters[ReadDrvStat];
if (lastReadStatus & TMC_RR_OT)
@@ -783,7 +783,7 @@ void TmcDriverState::AppendDriverStatus(const StringRef& reply)
}
// This is called by the ISR when the SPI transfer has completed
-inline void TmcDriverState::TransferDone()
+inline void TmcDriverState::TransferDone() noexcept
{
Cache::InvalidateAfterDMAReceive(receiveData, sizeof(receiveData));
if (sendData[2] & 0x80) // if we were writing a register
@@ -836,7 +836,7 @@ inline void TmcDriverState::TransferDone()
}
// This is called to abandon the current transfer, if any
-void TmcDriverState::AbortTransfer()
+void TmcDriverState::AbortTransfer() noexcept
{
uart->UART_IDR = UART_IDR_ENDRX; // disable end-of-receive interrupt
uart_get_pdc_base(uart)->PERIPH_PTCR = (PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); // disable the PDC
@@ -846,7 +846,7 @@ void TmcDriverState::AbortTransfer()
#if TMC22xx_HAS_MUX
// Set up the UART multiplexer to address the selected driver
-inline void TmcDriverState::SetUartMux()
+inline void TmcDriverState::SetUartMux() noexcept
{
if ((driverNumber & 0x01) != 0)
{
@@ -877,7 +877,7 @@ inline void TmcDriverState::SetUartMux()
#endif
// This is called from the ISR or elsewhere to start a new SPI transfer. Inlined for ISR speed.
-inline void TmcDriverState::StartTransfer()
+inline void TmcDriverState::StartTransfer() noexcept
{
currentDriver = this;
@@ -918,7 +918,7 @@ inline void TmcDriverState::StartTransfer()
// ISR(s) for the UART(s)
-inline void TmcDriverState::UartTmcHandler()
+inline void TmcDriverState::UartTmcHandler() noexcept
{
uart->UART_IDR = UART_IDR_ENDRX; // disable the PDC interrupt
TransferDone(); // tidy up after the transfer we just completed
@@ -946,9 +946,9 @@ inline void TmcDriverState::UartTmcHandler()
#endif
// ISR for the single UART
-extern "C" void TMC22xx_UART_Handler() __attribute__ ((hot));
+extern "C" void TMC22xx_UART_Handler() noexcept __attribute__ ((hot));
-void TMC22xx_UART_Handler()
+void TMC22xx_UART_Handler() noexcept
{
UART_TMC22xx->UART_IDR = UART_IDR_ENDRX; // disable the interrupt
TmcDriverState *driver = TmcDriverState::currentDriver; // capture volatile variable
@@ -961,14 +961,14 @@ void TMC22xx_UART_Handler()
#else
// ISRs for the individual UARTs
-extern "C" void UART_TMC_DRV0_Handler() __attribute__ ((hot));
-void UART_TMC_DRV0_Handler()
+extern "C" void UART_TMC_DRV0_Handler() noexcept __attribute__ ((hot));
+void UART_TMC_DRV0_Handler() noexcept
{
driverStates[0].UartTmcHandler();
}
-extern "C" void UART_TMC_DRV1_Handler() __attribute__ ((hot));
-void UART_TMC_DRV1_Handler()
+extern "C" void UART_TMC_DRV1_Handler() noexcept __attribute__ ((hot));
+void UART_TMC_DRV1_Handler() noexcept
{
driverStates[1].UartTmcHandler();
}
@@ -981,7 +981,7 @@ namespace SmartDrivers
{
// Initialise the driver interface and the drivers, leaving each drive disabled.
// It is assumed that the drivers are not powered, so driversPowered(true) must be called after calling this before the motors can be moved.
- void Init(const Pin driverSelectPins[NumDirectDrivers], size_t numTmcDrivers)
+ void Init(const Pin driverSelectPins[NumDirectDrivers], size_t numTmcDrivers) noexcept
{
numTmc22xxDrivers = min<size_t>(numTmcDrivers, MaxSmartDrivers);
@@ -1034,7 +1034,7 @@ namespace SmartDrivers
}
// Shut down the drivers and stop any related interrupts. Don't call Spin() again after calling this as it may re-enable them.
- void Exit()
+ void Exit() noexcept
{
pinMode(GlobalTmc22xxEnablePin, OUTPUT_HIGH);
#if TMC22xx_HAS_MUX
@@ -1048,7 +1048,7 @@ namespace SmartDrivers
driversState = DriversState::noPower;
}
- void SetAxisNumber(size_t drive, uint32_t axisNumber)
+ void SetAxisNumber(size_t drive, uint32_t axisNumber) noexcept
{
if (drive < numTmc22xxDrivers)
{
@@ -1056,12 +1056,12 @@ namespace SmartDrivers
}
}
- uint32_t GetAxisNumber(size_t drive)
+ uint32_t GetAxisNumber(size_t drive) noexcept
{
return (drive < numTmc22xxDrivers) ? driverStates[drive].GetAxisNumber() : 0;
}
- void SetCurrent(size_t drive, float current)
+ void SetCurrent(size_t drive, float current) noexcept
{
if (drive < numTmc22xxDrivers)
{
@@ -1069,7 +1069,7 @@ namespace SmartDrivers
}
}
- void EnableDrive(size_t drive, bool en)
+ void EnableDrive(size_t drive, bool en) noexcept
{
if (drive < numTmc22xxDrivers)
{
@@ -1077,18 +1077,18 @@ namespace SmartDrivers
}
}
- uint32_t GetLiveStatus(size_t drive)
+ uint32_t GetLiveStatus(size_t drive) noexcept
{
return (drive < numTmc22xxDrivers) ? driverStates[drive].ReadLiveStatus() : 0;
}
- uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep)
+ uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep) noexcept
{
return (drive < numTmc22xxDrivers) ? driverStates[drive].ReadAccumulatedStatus(bitsToKeep) : 0;
}
// Set microstepping or chopper control register
- bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolate)
+ bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolate) noexcept
{
if (drive < numTmc22xxDrivers && microsteps > 0)
{
@@ -1110,24 +1110,24 @@ namespace SmartDrivers
}
// Get microstepping or chopper control register
- unsigned int GetMicrostepping(size_t drive, bool& interpolation)
+ unsigned int GetMicrostepping(size_t drive, bool& interpolation) noexcept
{
return (drive < numTmc22xxDrivers) ? driverStates[drive].GetMicrostepping(interpolation) : 1;
}
- bool SetDriverMode(size_t driver, unsigned int mode)
+ bool SetDriverMode(size_t driver, unsigned int mode) noexcept
{
return driver < numTmc22xxDrivers && driverStates[driver].SetDriverMode(mode);
}
- DriverMode GetDriverMode(size_t driver)
+ DriverMode GetDriverMode(size_t driver) noexcept
{
return (driver < numTmc22xxDrivers) ? driverStates[driver].GetDriverMode() : DriverMode::unknown;
}
// Flag that the the drivers have been powered up or down and handle any timeouts
// Before the first call to this function with 'powered' true, you must call Init()
- void Spin(bool powered)
+ void Spin(bool powered) noexcept
{
if (driversState == DriversState::noPower)
{
@@ -1204,13 +1204,13 @@ namespace SmartDrivers
}
// This is called from the tick ISR, possibly while Spin (with powered either true or false) is being executed
- void TurnDriversOff()
+ void TurnDriversOff() noexcept
{
// When using TMC2660 drivers, this is called when an over-voltage event occurs, so that we can try to protect the drivers by disabling them.
// We don't use it with TMC22xx drivers.
}
- void AppendDriverStatus(size_t drive, const StringRef& reply)
+ void AppendDriverStatus(size_t drive, const StringRef& reply) noexcept
{
if (drive < numTmc22xxDrivers)
{
@@ -1218,12 +1218,12 @@ namespace SmartDrivers
}
}
- float GetStandstillCurrentPercent(size_t drive)
+ float GetStandstillCurrentPercent(size_t drive) noexcept
{
return (drive < numTmc22xxDrivers) ? driverStates[drive].GetStandstillCurrentPercent() : 0.0;
}
- void SetStandstillCurrentPercent(size_t drive, float percent)
+ void SetStandstillCurrentPercent(size_t drive, float percent) noexcept
{
if (drive < numTmc22xxDrivers)
{
@@ -1231,12 +1231,12 @@ namespace SmartDrivers
}
}
- bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal)
+ bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal) noexcept
{
return (driver < numTmc22xxDrivers) && driverStates[driver].SetRegister(reg, regVal);
}
- uint32_t GetRegister(size_t driver, SmartDriverRegister reg)
+ uint32_t GetRegister(size_t driver, SmartDriverRegister reg) noexcept
{
return (driver < numTmc22xxDrivers) ? driverStates[driver].GetRegister(reg) : 0;
}
diff --git a/src/Movement/StepperDrivers/TMC22xx.h b/src/Movement/StepperDrivers/TMC22xx.h
index 566c5806..4c0e753d 100644
--- a/src/Movement/StepperDrivers/TMC22xx.h
+++ b/src/Movement/StepperDrivers/TMC22xx.h
@@ -36,26 +36,26 @@ const uint32_t TMC_RR_TEMPBITS = 15 << 8; // all temperature threshold bits
namespace SmartDrivers
{
- void Init(const Pin[NumDirectDrivers], size_t numTmcDrivers)
+ void Init(const Pin[NumDirectDrivers], size_t numTmcDrivers) noexcept
pre(numTmcDrivers <= NumDirectDrivers);
- void Exit();
- void SetAxisNumber(size_t drive, uint32_t axisNumber);
- uint32_t GetAxisNumber(size_t drive);
- void SetCurrent(size_t drive, float current);
- void EnableDrive(size_t drive, bool en);
- uint32_t GetLiveStatus(size_t drive);
- uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep);
- bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolation);
- unsigned int GetMicrostepping(size_t drive, bool& interpolation);
- bool SetDriverMode(size_t driver, unsigned int mode);
- DriverMode GetDriverMode(size_t driver);
- void Spin(bool powered);
- void TurnDriversOff();
- void AppendDriverStatus(size_t drive, const StringRef& reply);
- float GetStandstillCurrentPercent(size_t drive);
- void SetStandstillCurrentPercent(size_t drive, float percent);
- bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal);
- uint32_t GetRegister(size_t driver, SmartDriverRegister reg);
+ void Exit() noexcept;
+ void SetAxisNumber(size_t drive, uint32_t axisNumber) noexcept;
+ uint32_t GetAxisNumber(size_t drive) noexcept;
+ void SetCurrent(size_t drive, float current) noexcept;
+ void EnableDrive(size_t drive, bool en) noexcept;
+ uint32_t GetLiveStatus(size_t drive) noexcept;
+ uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep) noexcept;
+ bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolation) noexcept;
+ unsigned int GetMicrostepping(size_t drive, bool& interpolation) noexcept;
+ bool SetDriverMode(size_t driver, unsigned int mode) noexcept;
+ DriverMode GetDriverMode(size_t driver) noexcept;
+ void Spin(bool powered) noexcept;
+ void TurnDriversOff() noexcept;
+ void AppendDriverStatus(size_t drive, const StringRef& reply) noexcept;
+ float GetStandstillCurrentPercent(size_t drive) noexcept;
+ void SetStandstillCurrentPercent(size_t drive, float percent) noexcept;
+ bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal) noexcept;
+ uint32_t GetRegister(size_t driver, SmartDriverRegister reg) noexcept;
};
#endif
diff --git a/src/Movement/StepperDrivers/TMC2660.cpp b/src/Movement/StepperDrivers/TMC2660.cpp
index 9f551ccd..fc85a64d 100644
--- a/src/Movement/StepperDrivers/TMC2660.cpp
+++ b/src/Movement/StepperDrivers/TMC2660.cpp
@@ -183,7 +183,7 @@ const uint32_t defaultSmartEnReg =
// Private types and methods
// Convert a required motor current to the CS bits in the SGCSCONF register
-static inline constexpr uint32_t CurrentToCsBits(float current)
+static inline constexpr uint32_t CurrentToCsBits(float current) noexcept
{
// The current sense resistor on the production Duet WiFi is 0.051 ohms.
// This gives us a range of 101mA to 3.236A in 101mA steps in the high sensitivity range (VSENSE = 1)
@@ -196,44 +196,44 @@ constexpr uint32_t MinimumOpenLoadCsBits = CurrentToCsBits(MinimumOpenLoadMotorC
class TmcDriverState
{
public:
- void Init(uint32_t driverNumber, uint32_t p_pin);
- void SetAxisNumber(size_t p_axisNumber);
- void WriteAll();
-
- bool SetMicrostepping(uint32_t shift, bool interpolate);
- unsigned int GetMicrostepping(bool& interpolation) const; // Get microstepping
- bool SetDriverMode(unsigned int mode);
- DriverMode GetDriverMode() const;
- void SetCurrent(float current);
- void Enable(bool en);
- void UpdateChopConfRegister();
- void SetStallDetectThreshold(int sgThreshold);
- void SetStallDetectFilter(bool sgFilter);
- void SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond);
- void AppendStallConfig(const StringRef& reply) const;
- void AppendDriverStatus(const StringRef& reply);
-
- bool SetRegister(SmartDriverRegister reg, uint32_t regVal);
- uint32_t GetRegister(SmartDriverRegister reg) const;
-
- void TransferDone() __attribute__ ((hot)); // called by the ISR when the SPI transfer has completed
- void StartTransfer() __attribute__ ((hot)); // called to start a transfer
-
- uint32_t ReadLiveStatus() const;
- uint32_t ReadAccumulatedStatus(uint32_t bitsToKeep);
-
- uint32_t ReadMicrostepPosition() const { return mstepPosition; }
+ void Init(uint32_t driverNumber, uint32_t p_pin) noexcept;
+ void SetAxisNumber(size_t p_axisNumber) noexcept;
+ void WriteAll() noexcept;
+
+ bool SetMicrostepping(uint32_t shift, bool interpolate) noexcept;
+ unsigned int GetMicrostepping(bool& interpolation) const noexcept;
+ bool SetDriverMode(unsigned int mode) noexcept;
+ DriverMode GetDriverMode() const noexcept;
+ void SetCurrent(float current) noexcept;
+ void Enable(bool en) noexcept;
+ void UpdateChopConfRegister() noexcept;
+ void SetStallDetectThreshold(int sgThreshold) noexcept;
+ void SetStallDetectFilter(bool sgFilter) noexcept;
+ void SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond) noexcept;
+ void AppendStallConfig(const StringRef& reply) const noexcept;
+ void AppendDriverStatus(const StringRef& reply) noexcept;
+
+ bool SetRegister(SmartDriverRegister reg, uint32_t regVal) noexcept;
+ uint32_t GetRegister(SmartDriverRegister reg) const noexcept;
+
+ void TransferDone() noexcept __attribute__ ((hot)); // called by the ISR when the SPI transfer has completed
+ void StartTransfer() noexcept __attribute__ ((hot)); // called to start a transfer
+
+ uint32_t ReadLiveStatus() const noexcept;
+ uint32_t ReadAccumulatedStatus(uint32_t bitsToKeep) noexcept;
+
+ uint32_t ReadMicrostepPosition() const noexcept { return mstepPosition; }
private:
- bool SetChopConf(uint32_t newVal);
+ bool SetChopConf(uint32_t newVal) noexcept;
- void ResetLoadRegisters()
+ void ResetLoadRegisters() noexcept
{
minSgLoadRegister = 1023;
maxSgLoadRegister = 0;
}
- static void SetupDMA(uint32_t outVal) __attribute__ ((hot)); // set up the PDC to send a register and receive the status
+ static void SetupDMA(uint32_t outVal) noexcept __attribute__ ((hot)); // set up the PDC to send a register and receive the status
static constexpr unsigned int NumRegisters = 5; // the number of registers that we write to
volatile uint32_t registers[NumRegisters]; // the values we want the TMC2660 writable registers to have
@@ -285,7 +285,7 @@ volatile static uint32_t spiDataIn = 0; // volatile because the PDC writes
static TmcDriverState * volatile currentDriver = nullptr; // volatile because the ISR changes it
// Set up the PDC to send a register and receive the status
-/*static*/ inline void TmcDriverState::SetupDMA(uint32_t outVal)
+/*static*/ inline void TmcDriverState::SetupDMA(uint32_t outVal) noexcept
{
#if SAME70
/* From the data sheet:
@@ -397,7 +397,7 @@ static TmcDriverState * volatile currentDriver = nullptr; // volatile because th
}
// Initialise the state of the driver and its CS pin
-void TmcDriverState::Init(uint32_t driverNumber, uint32_t p_pin)
+void TmcDriverState::Init(uint32_t driverNumber, uint32_t p_pin) noexcept
pre(!driversPowered)
{
axisNumber = driverNumber; // assume straight through mapping at initialisation
@@ -422,18 +422,18 @@ pre(!driversPowered)
SetStallMinimumStepsPerSecond(DefaultMinimumStepsPerSecond);
}
-inline void TmcDriverState::SetAxisNumber(size_t p_axisNumber)
+inline void TmcDriverState::SetAxisNumber(size_t p_axisNumber) noexcept
{
axisNumber = p_axisNumber;
}
// Write all registers. This is called when the drivers are known to be powered up.
-inline void TmcDriverState::WriteAll()
+inline void TmcDriverState::WriteAll() noexcept
{
registersToUpdate = UpdateAllRegisters;
}
-bool TmcDriverState::SetRegister(SmartDriverRegister reg, uint32_t regVal)
+bool TmcDriverState::SetRegister(SmartDriverRegister reg, uint32_t regVal) noexcept
{
switch(reg)
{
@@ -466,7 +466,7 @@ bool TmcDriverState::SetRegister(SmartDriverRegister reg, uint32_t regVal)
}
}
-uint32_t TmcDriverState::GetRegister(SmartDriverRegister reg) const
+uint32_t TmcDriverState::GetRegister(SmartDriverRegister reg) const noexcept
{
switch(reg)
{
@@ -501,7 +501,7 @@ uint32_t TmcDriverState::GetRegister(SmartDriverRegister reg) const
}
// Check the new chopper control register, update it and return true if it is legal
-bool TmcDriverState::SetChopConf(uint32_t newVal)
+bool TmcDriverState::SetChopConf(uint32_t newVal) noexcept
{
// TOFF = 0 turns the driver off so it is not allowed.
// TOFF = 1 is not allowed if TBL = 0.
@@ -525,7 +525,7 @@ bool TmcDriverState::SetChopConf(uint32_t newVal)
}
// Set the driver mode
-bool TmcDriverState::SetDriverMode(unsigned int mode)
+bool TmcDriverState::SetDriverMode(unsigned int mode) noexcept
{
switch (mode)
{
@@ -544,7 +544,7 @@ bool TmcDriverState::SetDriverMode(unsigned int mode)
}
// Get the driver mode
-DriverMode TmcDriverState::GetDriverMode() const
+DriverMode TmcDriverState::GetDriverMode() const noexcept
{
return ((configuredChopConfReg & TMC_CHOPCONF_CHM) == 0) ? DriverMode::spreadCycle
: ((configuredChopConfReg & TMC_CHOPCONF_RNDTF) == 0) ? DriverMode::constantOffTime
@@ -552,7 +552,7 @@ DriverMode TmcDriverState::GetDriverMode() const
}
// Set the microstepping and microstep interpolation. The desired microstepping is (1 << shift).
-bool TmcDriverState::SetMicrostepping(uint32_t shift, bool interpolate)
+bool TmcDriverState::SetMicrostepping(uint32_t shift, bool interpolate) noexcept
{
microstepShiftFactor = shift;
uint32_t drvCtrlReg = registers[DriveControl] & ~TMC_DRVCTRL_MRES_MASK;
@@ -571,7 +571,7 @@ bool TmcDriverState::SetMicrostepping(uint32_t shift, bool interpolate)
}
// Set the motor current
-void TmcDriverState::SetCurrent(float current)
+void TmcDriverState::SetCurrent(float current) noexcept
{
const uint32_t csBits = CurrentToCsBits(current);
registers[StallGuardConfig] = (registers[StallGuardConfig] & ~TMC_SGCSCONF_CS_MASK) | TMC_SGCSCONF_CS(csBits);
@@ -579,7 +579,7 @@ void TmcDriverState::SetCurrent(float current)
}
// Enable or disable the driver
-void TmcDriverState::Enable(bool en)
+void TmcDriverState::Enable(bool en) noexcept
{
if (enabled != en)
{
@@ -606,21 +606,21 @@ void TmcDriverState::Enable(bool en)
}
}
-void TmcDriverState::UpdateChopConfRegister()
+void TmcDriverState::UpdateChopConfRegister() noexcept
{
registers[ChopperControl] = (enabled) ? configuredChopConfReg : (configuredChopConfReg & ~TMC_CHOPCONF_TOFF_MASK);
registersToUpdate |= (1u << ChopperControl);
}
// Read the status
-inline uint32_t TmcDriverState::ReadLiveStatus() const
+inline uint32_t TmcDriverState::ReadLiveStatus() const noexcept
{
const uint32_t ret = lastReadStatus & (TMC_RR_SG | TMC_RR_OT | TMC_RR_OTPW | TMC_RR_S2G | TMC_RR_OLA | TMC_RR_OLB | TMC_RR_STST);
return (enabled) ? ret : ret & ~(TMC_RR_SG | TMC_RR_OLA | TMC_RR_OLB);
}
// Read the status
-uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep)
+uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep) noexcept
{
const uint32_t mask = (enabled) ? 0xFFFFFFFF : ~(TMC_RR_SG | TMC_RR_OLA | TMC_RR_OLB);
bitsToKeep &= mask;
@@ -631,14 +631,14 @@ uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep)
return status & (TMC_RR_SG | TMC_RR_OT | TMC_RR_OTPW | TMC_RR_S2G | TMC_RR_OLA | TMC_RR_OLB | TMC_RR_STST) & mask;
}
-void TmcDriverState::SetStallDetectThreshold(int sgThreshold)
+void TmcDriverState::SetStallDetectThreshold(int sgThreshold) noexcept
{
const uint32_t sgVal = ((uint32_t)constrain<int>(sgThreshold, -64, 63)) & 127;
registers[StallGuardConfig] = (registers[StallGuardConfig] & ~TMC_SGCSCONF_SGT_MASK) | (sgVal << TMC_SGCSCONF_SGT_SHIFT);
registersToUpdate |= 1u << StallGuardConfig;
}
-void TmcDriverState::SetStallDetectFilter(bool sgFilter)
+void TmcDriverState::SetStallDetectFilter(bool sgFilter) noexcept
{
if (sgFilter)
{
@@ -651,12 +651,12 @@ void TmcDriverState::SetStallDetectFilter(bool sgFilter)
registersToUpdate |= 1u << StallGuardConfig;
}
-void TmcDriverState::SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond)
+void TmcDriverState::SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond) noexcept
{
maxStallStepInterval = StepTimer::StepClockRate/max<unsigned int>(stepsPerSecond, 1);
}
-void TmcDriverState::AppendStallConfig(const StringRef& reply) const
+void TmcDriverState::AppendStallConfig(const StringRef& reply) const noexcept
{
const bool filtered = ((registers[StallGuardConfig] & TMC_SGCSCONF_SGT_SFILT) != 0);
int threshold = (int)((registers[StallGuardConfig] & TMC_SGCSCONF_SGT_MASK) >> TMC_SGCSCONF_SGT_SHIFT);
@@ -669,7 +669,7 @@ void TmcDriverState::AppendStallConfig(const StringRef& reply) const
}
// Append the driver status to a string, and reset the min/max load values
-void TmcDriverState::AppendDriverStatus(const StringRef& reply)
+void TmcDriverState::AppendDriverStatus(const StringRef& reply) noexcept
{
if (lastReadStatus & TMC_RR_OT)
{
@@ -712,14 +712,14 @@ void TmcDriverState::AppendDriverStatus(const StringRef& reply)
}
// Get microstepping
-unsigned int TmcDriverState::GetMicrostepping(bool& interpolation) const
+unsigned int TmcDriverState::GetMicrostepping(bool& interpolation) const noexcept
{
interpolation = (registers[DriveControl] & TMC_DRVCTRL_INTPOL) != 0;
return 1u << microstepShiftFactor;
}
// This is called by the ISR when the SPI transfer has completed
-inline void TmcDriverState::TransferDone()
+inline void TmcDriverState::TransferDone() noexcept
{
fastDigitalWriteHigh(pin); // set the CS pin high for the driver we just polled
if (driversPowered) // if the power is still good, update the status
@@ -770,7 +770,7 @@ inline void TmcDriverState::TransferDone()
}
// This is called from the ISR or elsewhere to start a new SPI transfer. Inlined for ISR speed.
-inline void TmcDriverState::StartTransfer()
+inline void TmcDriverState::StartTransfer() noexcept
{
currentDriver = this;
@@ -865,7 +865,7 @@ namespace SmartDrivers
{
// Initialise the driver interface and the drivers, leaving each drive disabled.
// It is assumed that the drivers are not powered, so driversPowered(true) must be called after calling this before the motors can be moved.
- void Init(const Pin driverSelectPins[NumDirectDrivers], size_t numTmcDrivers)
+ void Init(const Pin driverSelectPins[NumDirectDrivers], size_t numTmcDrivers) noexcept
{
numTmc2660Drivers = min<size_t>(numTmcDrivers, MaxSmartDrivers);
@@ -930,14 +930,14 @@ namespace SmartDrivers
}
// Shut down the drivers and stop any related interrupts. Don't call Spin() again after calling this as it may re-enable them.
- void Exit()
+ void Exit() noexcept
{
digitalWrite(GlobalTmc2660EnablePin, HIGH);
NVIC_DisableIRQ(TMC2660_SPI_IRQn);
driversPowered = false;
}
- void SetAxisNumber(size_t driver, uint32_t axisNumber)
+ void SetAxisNumber(size_t driver, uint32_t axisNumber) noexcept
{
if (driver < numTmc2660Drivers)
{
@@ -945,7 +945,7 @@ namespace SmartDrivers
}
}
- void SetCurrent(size_t driver, float current)
+ void SetCurrent(size_t driver, float current) noexcept
{
if (driver < numTmc2660Drivers)
{
@@ -953,7 +953,7 @@ namespace SmartDrivers
}
}
- void EnableDrive(size_t driver, bool en)
+ void EnableDrive(size_t driver, bool en) noexcept
{
if (driver < numTmc2660Drivers)
{
@@ -961,18 +961,18 @@ namespace SmartDrivers
}
}
- uint32_t GetLiveStatus(size_t driver)
+ uint32_t GetLiveStatus(size_t driver) noexcept
{
return (driver < numTmc2660Drivers) ? driverStates[driver].ReadLiveStatus() : 0;
}
- uint32_t GetAccumulatedStatus(size_t driver, uint32_t bitsToKeep)
+ uint32_t GetAccumulatedStatus(size_t driver, uint32_t bitsToKeep) noexcept
{
return (driver < numTmc2660Drivers) ? driverStates[driver].ReadAccumulatedStatus(bitsToKeep) : 0;
}
// Set microstepping and microstep interpolation
- bool SetMicrostepping(size_t driver, unsigned int microsteps, bool interpolate)
+ bool SetMicrostepping(size_t driver, unsigned int microsteps, bool interpolate) noexcept
{
if (driver < numTmc2660Drivers && microsteps > 0)
{
@@ -994,7 +994,7 @@ namespace SmartDrivers
}
// Get microstepping and interpolation
- unsigned int GetMicrostepping(size_t driver, bool& interpolation)
+ unsigned int GetMicrostepping(size_t driver, bool& interpolation) noexcept
{
if (driver < numTmc2660Drivers)
{
@@ -1004,19 +1004,19 @@ namespace SmartDrivers
return 1;
}
- bool SetDriverMode(size_t driver, unsigned int mode)
+ bool SetDriverMode(size_t driver, unsigned int mode) noexcept
{
return driver < numTmc2660Drivers && driverStates[driver].SetDriverMode(mode);
}
- DriverMode GetDriverMode(size_t driver)
+ DriverMode GetDriverMode(size_t driver) noexcept
{
return (driver < numTmc2660Drivers) ? driverStates[driver].GetDriverMode() : DriverMode::unknown;
}
// Flag the the drivers have been powered up.
// Before the first call to this function with powered true, you must call Init().
- void Spin(bool powered)
+ void Spin(bool powered) noexcept
{
const bool wasPowered = driversPowered;
driversPowered = powered;
@@ -1049,14 +1049,14 @@ namespace SmartDrivers
}
// This is called from the tick ISR, possibly while Spin (with powered either true or false) is being executed
- void TurnDriversOff()
+ void TurnDriversOff() noexcept
{
digitalWrite(GlobalTmc2660EnablePin, HIGH); // disable the drivers
driversPowered = false;
EndstopOrZProbe::UpdateStalledDrivers(LowestNBits<DriversBitmap>(MaxSmartDrivers), false);
}
- void SetStallThreshold(size_t driver, int sgThreshold)
+ void SetStallThreshold(size_t driver, int sgThreshold) noexcept
{
if (driver < numTmc2660Drivers)
{
@@ -1064,7 +1064,7 @@ namespace SmartDrivers
}
}
- void SetStallFilter(size_t driver, bool sgFilter)
+ void SetStallFilter(size_t driver, bool sgFilter) noexcept
{
if (driver < numTmc2660Drivers)
{
@@ -1072,7 +1072,7 @@ namespace SmartDrivers
}
}
- void SetStallMinimumStepsPerSecond(size_t driver, unsigned int stepsPerSecond)
+ void SetStallMinimumStepsPerSecond(size_t driver, unsigned int stepsPerSecond) noexcept
{
if (driver < numTmc2660Drivers)
{
@@ -1080,7 +1080,7 @@ namespace SmartDrivers
}
}
- void AppendStallConfig(size_t driver, const StringRef& reply)
+ void AppendStallConfig(size_t driver, const StringRef& reply) noexcept
{
if (driver < numTmc2660Drivers)
{
@@ -1088,7 +1088,7 @@ namespace SmartDrivers
}
}
- void AppendDriverStatus(size_t driver, const StringRef& reply)
+ void AppendDriverStatus(size_t driver, const StringRef& reply) noexcept
{
if (driver < numTmc2660Drivers)
{
@@ -1096,22 +1096,22 @@ namespace SmartDrivers
}
}
- float GetStandstillCurrentPercent(size_t driver)
+ float GetStandstillCurrentPercent(size_t driver) noexcept
{
return 100.0; // not supported
}
- void SetStandstillCurrentPercent(size_t driver, float percent)
+ void SetStandstillCurrentPercent(size_t driver, float percent) noexcept
{
// not supported so nothing to see here
}
- bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal)
+ bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal) noexcept
{
return (driver < numTmc2660Drivers) && driverStates[driver].SetRegister(reg, regVal);
}
- uint32_t GetRegister(size_t driver, SmartDriverRegister reg)
+ uint32_t GetRegister(size_t driver, SmartDriverRegister reg) noexcept
{
return (driver < numTmc2660Drivers) ? driverStates[driver].GetRegister(reg) : 0;
}
diff --git a/src/Movement/StepperDrivers/TMC2660.h b/src/Movement/StepperDrivers/TMC2660.h
index 4878aa2d..7a51bd07 100644
--- a/src/Movement/StepperDrivers/TMC2660.h
+++ b/src/Movement/StepperDrivers/TMC2660.h
@@ -26,30 +26,30 @@ const uint32_t TMC_RR_STST = 1 << 7; // standstill detected
namespace SmartDrivers
{
- void Init(const Pin[NumDirectDrivers], size_t numTmcDrivers)
+ void Init(const Pin[NumDirectDrivers], size_t numTmcDrivers) noexcept
pre(numTmcDrivers <= NumDirectDrivers);
- void Exit();
- void Spin(bool powered);
- void TurnDriversOff();
-
- void SetAxisNumber(size_t driver, uint32_t axisNumber);
- void SetCurrent(size_t driver, float current);
- void EnableDrive(size_t driver, bool en);
- uint32_t GetLiveStatus(size_t driver);
- uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep);
- bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolation);
- unsigned int GetMicrostepping(size_t drive, bool& interpolation);
- bool SetDriverMode(size_t driver, unsigned int mode);
- DriverMode GetDriverMode(size_t driver);
- void SetStallThreshold(size_t driver, int sgThreshold);
- void SetStallFilter(size_t driver, bool sgFilter);
- void SetStallMinimumStepsPerSecond(size_t driver, unsigned int stepsPerSecond);
- void AppendStallConfig(size_t driver, const StringRef& reply);
- void AppendDriverStatus(size_t driver, const StringRef& reply);
- float GetStandstillCurrentPercent(size_t driver);
- void SetStandstillCurrentPercent(size_t driver, float percent);
- bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal);
- uint32_t GetRegister(size_t driver, SmartDriverRegister reg);
+ void Exit() noexcept;
+ void Spin(bool powered) noexcept;
+ void TurnDriversOff() noexcept;
+
+ void SetAxisNumber(size_t driver, uint32_t axisNumber) noexcept;
+ void SetCurrent(size_t driver, float current) noexcept;
+ void EnableDrive(size_t driver, bool en) noexcept;
+ uint32_t GetLiveStatus(size_t driver) noexcept;
+ uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep) noexcept;
+ bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolation) noexcept;
+ unsigned int GetMicrostepping(size_t drive, bool& interpolation) noexcept;
+ bool SetDriverMode(size_t driver, unsigned int mode) noexcept;
+ DriverMode GetDriverMode(size_t driver) noexcept;
+ void SetStallThreshold(size_t driver, int sgThreshold) noexcept;
+ void SetStallFilter(size_t driver, bool sgFilter) noexcept;
+ void SetStallMinimumStepsPerSecond(size_t driver, unsigned int stepsPerSecond) noexcept;
+ void AppendStallConfig(size_t driver, const StringRef& reply) noexcept;
+ void AppendDriverStatus(size_t driver, const StringRef& reply) noexcept;
+ float GetStandstillCurrentPercent(size_t driver) noexcept;
+ void SetStandstillCurrentPercent(size_t driver, float percent) noexcept;
+ bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal) noexcept;
+ uint32_t GetRegister(size_t driver, SmartDriverRegister reg) noexcept;
};
#endif
diff --git a/src/Movement/StepperDrivers/TMC51xx.cpp b/src/Movement/StepperDrivers/TMC51xx.cpp
index 60e0a30c..c60b8c08 100644
--- a/src/Movement/StepperDrivers/TMC51xx.cpp
+++ b/src/Movement/StepperDrivers/TMC51xx.cpp
@@ -25,12 +25,12 @@
# include <Hardware/Serial.h>
# define SAME70 0
-static inline const Move& GetMoveInstance() { return *moveInstance; }
+static inline const Move& GetMoveInstance() noexcept { return *moveInstance; }
#elif SAME70
# define TMC51xx_USES_SERCOM 0
-static inline const Move& GetMoveInstance() { return reprap.GetMove(); }
+static inline const Move& GetMoveInstance() noexcept { return reprap.GetMove(); }
#endif
@@ -270,45 +270,45 @@ static DriversState driversState = DriversState::noPower;
class TmcDriverState
{
public:
- void Init(uint32_t p_driverNumber);
- void SetAxisNumber(size_t p_axisNumber);
- uint32_t GetAxisNumber() const { return axisNumber; }
- void WriteAll();
- bool SetMicrostepping(uint32_t shift, bool interpolate);
- unsigned int GetMicrostepping(bool& interpolation) const; // Get microstepping
- bool SetDriverMode(unsigned int mode);
- DriverMode GetDriverMode() const;
- void SetCurrent(float current);
- void Enable(bool en);
- void AppendDriverStatus(const StringRef& reply, bool clearGlobalStats);
- bool UpdatePending() const { return (registersToUpdate | newRegistersToUpdate) != 0; }
- void SetStallDetectThreshold(int sgThreshold);
- void SetStallDetectFilter(bool sgFilter);
- void SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond);
- void AppendStallConfig(const StringRef& reply) const;
-
- bool SetRegister(SmartDriverRegister reg, uint32_t regVal);
- uint32_t GetRegister(SmartDriverRegister reg) const;
-
- float GetStandstillCurrentPercent() const;
- void SetStandstillCurrentPercent(float percent);
-
- static void TransferTimedOut() { ++numTimeouts; }
-
- uint32_t ReadLiveStatus() const;
- uint32_t ReadAccumulatedStatus(uint32_t bitsToKeep);
-
- void GetSpiCommand(uint8_t *sendDdataBlock);
- void TransferSucceeded(const uint8_t *rcvDataBlock);
- void TransferFailed();
+ void Init(uint32_t p_driverNumber) noexcept;
+ void SetAxisNumber(size_t p_axisNumber) noexcept;
+ uint32_t GetAxisNumber() const noexcept { return axisNumber; }
+ void WriteAll() noexcept;
+ bool SetMicrostepping(uint32_t shift, bool interpolate) noexcept;
+ unsigned int GetMicrostepping(bool& interpolation) const noexcept;
+ bool SetDriverMode(unsigned int mode) noexcept;
+ DriverMode GetDriverMode() const noexcept;
+ void SetCurrent(float current) noexcept;
+ void Enable(bool en) noexcept;
+ void AppendDriverStatus(const StringRef& reply, bool clearGlobalStats) noexcept;
+ bool UpdatePending() const noexcept { return (registersToUpdate | newRegistersToUpdate) != 0; }
+ void SetStallDetectThreshold(int sgThreshold) noexcept;
+ void SetStallDetectFilter(bool sgFilter) noexcept;
+ void SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond) noexcept;
+ void AppendStallConfig(const StringRef& reply) const noexcept;
+
+ bool SetRegister(SmartDriverRegister reg, uint32_t regVal) noexcept;
+ uint32_t GetRegister(SmartDriverRegister reg) const noexcept;
+
+ float GetStandstillCurrentPercent() const noexcept;
+ void SetStandstillCurrentPercent(float percent) noexcept;
+
+ static void TransferTimedOut() noexcept { ++numTimeouts; }
+
+ uint32_t ReadLiveStatus() const noexcept;
+ uint32_t ReadAccumulatedStatus(uint32_t bitsToKeep) noexcept;
+
+ void GetSpiCommand(uint8_t *sendDdataBlock) noexcept;
+ void TransferSucceeded(const uint8_t *rcvDataBlock) noexcept;
+ void TransferFailed() noexcept;
private:
- bool SetChopConf(uint32_t newVal);
- void UpdateRegister(size_t regIndex, uint32_t regVal);
- void UpdateChopConfRegister(); // calculate the chopper control register and flag it for sending
- void UpdateCurrent();
+ bool SetChopConf(uint32_t newVal) noexcept;
+ void UpdateRegister(size_t regIndex, uint32_t regVal) noexcept;
+ void UpdateChopConfRegister() noexcept; // calculate the chopper control register and flag it for sending
+ void UpdateCurrent() noexcept;
- void ResetLoadRegisters()
+ void ResetLoadRegisters() noexcept
{
minSgLoadRegister = 1023;
maxSgLoadRegister = 0;
@@ -400,7 +400,7 @@ const uint8_t TmcDriverState::ReadRegNumbers[NumReadRegisters] =
uint16_t TmcDriverState::numTimeouts = 0; // how many times a transfer timed out
// Initialise the state of the driver and its CS pin
-void TmcDriverState::Init(uint32_t p_driverNumber)
+void TmcDriverState::Init(uint32_t p_driverNumber) noexcept
pre(!driversPowered)
{
axisNumber = p_driverNumber; // axes are mapped straight through to drivers initially
@@ -438,49 +438,49 @@ pre(!driversPowered)
}
// Set a register value and flag it for updating
-void TmcDriverState::UpdateRegister(size_t regIndex, uint32_t regVal)
+void TmcDriverState::UpdateRegister(size_t regIndex, uint32_t regVal) noexcept
{
writeRegisters[regIndex] = regVal;
newRegistersToUpdate |= (1u << regIndex); // flag it for sending
}
// Calculate the chopper control register and flag it for sending
-void TmcDriverState::UpdateChopConfRegister()
+void TmcDriverState::UpdateChopConfRegister() noexcept
{
UpdateRegister(WriteChopConf, (enabled) ? configuredChopConfReg : configuredChopConfReg & ~CHOPCONF_TOFF_MASK);
}
-void TmcDriverState::SetStallDetectThreshold(int sgThreshold)
+void TmcDriverState::SetStallDetectThreshold(int sgThreshold) noexcept
{
const uint32_t sgVal = ((uint32_t)constrain<int>(sgThreshold, -64, 63)) & 127u;
writeRegisters[WriteCoolConf] = (writeRegisters[WriteCoolConf] & ~COOLCONF_SGT_MASK) | (sgVal << COOLCONF_SGT_SHIFT);
newRegistersToUpdate |= 1u << WriteCoolConf;
}
-inline void TmcDriverState::SetAxisNumber(size_t p_axisNumber)
+inline void TmcDriverState::SetAxisNumber(size_t p_axisNumber) noexcept
{
axisNumber = p_axisNumber;
}
// Write all registers. This is called when the drivers are known to be powered up.
-inline void TmcDriverState::WriteAll()
+inline void TmcDriverState::WriteAll() noexcept
{
newRegistersToUpdate = (1u << NumWriteRegisters) - 1;
}
-float TmcDriverState::GetStandstillCurrentPercent() const
+float TmcDriverState::GetStandstillCurrentPercent() const noexcept
{
return (float)(standstillCurrentFraction * 100)/256;
}
-void TmcDriverState::SetStandstillCurrentPercent(float percent)
+void TmcDriverState::SetStandstillCurrentPercent(float percent) noexcept
{
standstillCurrentFraction = (uint8_t)constrain<long>(lrintf((percent * 256)/100), 0, 255);
UpdateCurrent();
}
// Set the microstepping and microstep interpolation. The desired microstepping is (1 << shift).
-bool TmcDriverState::SetMicrostepping(uint32_t shift, bool interpolate)
+bool TmcDriverState::SetMicrostepping(uint32_t shift, bool interpolate) noexcept
{
microstepShiftFactor = shift;
configuredChopConfReg = (configuredChopConfReg & ~(CHOPCONF_MRES_MASK | CHOPCONF_INTPOL)) | ((8 - shift) << CHOPCONF_MRES_SHIFT);
@@ -493,13 +493,13 @@ bool TmcDriverState::SetMicrostepping(uint32_t shift, bool interpolate)
}
// Get microstepping or chopper control register
-unsigned int TmcDriverState::GetMicrostepping(bool& interpolation) const
+unsigned int TmcDriverState::GetMicrostepping(bool& interpolation) const noexcept
{
interpolation = (writeRegisters[WriteChopConf] & CHOPCONF_INTPOL) != 0;
return 1u << microstepShiftFactor;
}
-bool TmcDriverState::SetRegister(SmartDriverRegister reg, uint32_t regVal)
+bool TmcDriverState::SetRegister(SmartDriverRegister reg, uint32_t regVal) noexcept
{
switch(reg)
{
@@ -536,7 +536,7 @@ bool TmcDriverState::SetRegister(SmartDriverRegister reg, uint32_t regVal)
}
}
-uint32_t TmcDriverState::GetRegister(SmartDriverRegister reg) const
+uint32_t TmcDriverState::GetRegister(SmartDriverRegister reg) const noexcept
{
switch(reg)
{
@@ -577,7 +577,7 @@ uint32_t TmcDriverState::GetRegister(SmartDriverRegister reg) const
}
// Set the chopper control register to the settings provided by the user. We allow only the lowest 17 bits to be set.
-bool TmcDriverState::SetChopConf(uint32_t newVal)
+bool TmcDriverState::SetChopConf(uint32_t newVal) noexcept
{
const uint32_t offTime = (newVal & CHOPCONF_TOFF_MASK) >> CHOPCONF_TOFF_SHIFT;
if (offTime == 0 || (offTime == 1 && (newVal & CHOPCONF_TBL_MASK) < (2 << CHOPCONF_TBL_SHIFT)))
@@ -597,7 +597,7 @@ bool TmcDriverState::SetChopConf(uint32_t newVal)
}
// Set the driver mode
-bool TmcDriverState::SetDriverMode(unsigned int mode)
+bool TmcDriverState::SetDriverMode(unsigned int mode) noexcept
{
switch (mode)
{
@@ -633,7 +633,7 @@ bool TmcDriverState::SetDriverMode(unsigned int mode)
}
// Get the driver mode
-DriverMode TmcDriverState::GetDriverMode() const
+DriverMode TmcDriverState::GetDriverMode() const noexcept
{
return ((writeRegisters[WriteGConf] & GCONF_STEALTHCHOP) != 0) ? DriverMode::stealthChop
: ((writeRegisters[WriteChopConf] & CHOPCONF_CHM) == 0) ? DriverMode::spreadCycle
@@ -644,13 +644,13 @@ DriverMode TmcDriverState::GetDriverMode() const
}
// Set the motor current
-void TmcDriverState::SetCurrent(float current)
+void TmcDriverState::SetCurrent(float current) noexcept
{
motorCurrent = static_cast<uint32_t>(constrain<float>(current, MinimumMotorCurrent, MaxTmc5160Current));
UpdateCurrent();
}
-void TmcDriverState::UpdateCurrent()
+void TmcDriverState::UpdateCurrent() noexcept
{
#if TMC_TYPE == 5130
// Assume a current sense resistor of 0.082 ohms, to which we must add 0.025 ohms internal resistance.
@@ -688,7 +688,7 @@ void TmcDriverState::UpdateCurrent()
}
// Enable or disable the driver
-void TmcDriverState::Enable(bool en)
+void TmcDriverState::Enable(bool en) noexcept
{
if (enabled != en)
{
@@ -698,13 +698,13 @@ void TmcDriverState::Enable(bool en)
}
// Read the status
-uint32_t TmcDriverState::ReadLiveStatus() const
+uint32_t TmcDriverState::ReadLiveStatus() const noexcept
{
return readRegisters[ReadDrvStat] & (TMC_RR_SG | TMC_RR_OT | TMC_RR_OTPW | TMC_RR_S2G | TMC_RR_OLA | TMC_RR_OLB | TMC_RR_STST);
}
// Read the status
-uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep)
+uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep) noexcept
{
TaskCriticalSectionLocker lock;
const uint32_t status = accumulatedReadRegisters[ReadDrvStat];
@@ -713,7 +713,7 @@ uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep)
}
// Append the driver status to a string, and reset the min/max load values
-void TmcDriverState::AppendDriverStatus(const StringRef& reply, bool clearGlobalStats)
+void TmcDriverState::AppendDriverStatus(const StringRef& reply, bool clearGlobalStats) noexcept
{
const uint32_t lastReadStatus = readRegisters[ReadDrvStat];
if (lastReadStatus & TMC_RR_OT)
@@ -763,7 +763,7 @@ void TmcDriverState::AppendDriverStatus(const StringRef& reply, bool clearGlobal
ResetLoadRegisters();
}
-void TmcDriverState::SetStallDetectFilter(bool sgFilter)
+void TmcDriverState::SetStallDetectFilter(bool sgFilter) noexcept
{
if (sgFilter)
{
@@ -776,13 +776,13 @@ void TmcDriverState::SetStallDetectFilter(bool sgFilter)
newRegistersToUpdate |= 1u << WriteCoolConf;
}
-void TmcDriverState::SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond)
+void TmcDriverState::SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond) noexcept
{
//TODO use hardware facility instead
maxStallStepInterval = StepTimer::StepClockRate/max<unsigned int>(stepsPerSecond, 1);
}
-void TmcDriverState::AppendStallConfig(const StringRef& reply) const
+void TmcDriverState::AppendStallConfig(const StringRef& reply) const noexcept
{
const bool filtered = ((writeRegisters[WriteCoolConf] & COOLCONF_SGFILT) != 0);
int threshold = (int)((writeRegisters[WriteCoolConf] & COOLCONF_SGT_MASK) >> COOLCONF_SGT_SHIFT);
@@ -795,7 +795,7 @@ void TmcDriverState::AppendStallConfig(const StringRef& reply) const
}
// In the following, only byte accesses to sendDataBlock are allowed, because accesses to non-cacheable memory must be aligned
-void TmcDriverState::GetSpiCommand(uint8_t *sendDataBlock)
+void TmcDriverState::GetSpiCommand(uint8_t *sendDataBlock) noexcept
{
// Find which register to send. The common case is when no registers need to be updated.
{
@@ -825,7 +825,7 @@ void TmcDriverState::GetSpiCommand(uint8_t *sendDataBlock)
}
}
-void TmcDriverState::TransferSucceeded(const uint8_t *rcvDataBlock)
+void TmcDriverState::TransferSucceeded(const uint8_t *rcvDataBlock) noexcept
{
// If we wrote a register, mark it up to date
if (regIndexBeingUpdated < NumWriteRegisters)
@@ -902,7 +902,7 @@ void TmcDriverState::TransferSucceeded(const uint8_t *rcvDataBlock)
previousRegIndexRequested = (regIndexBeingUpdated == NoRegIndex) ? regIndexRequested : NoRegIndex;
}
-void TmcDriverState::TransferFailed()
+void TmcDriverState::TransferFailed() noexcept
{
regIndexRequested = previousRegIndexRequested = NoRegIndex;
}
@@ -918,7 +918,7 @@ static __nocache uint8_t sendData[5 * MaxSmartDrivers];
static __nocache uint8_t rcvData[5 * MaxSmartDrivers];
// Set up the PDC or DMAC to send a register and receive the status, but don't enable it yet
-static void SetupDMA()
+static void SetupDMA() noexcept
{
#if SAME70
/* From the data sheet:
@@ -1019,7 +1019,7 @@ static void SetupDMA()
#endif
}
-static inline void EnableDma()
+static inline void EnableDma() noexcept
{
#if SAME70
xdmac_channel_enable(XDMAC, DmacChanTmcRx);
@@ -1032,7 +1032,7 @@ static inline void EnableDma()
#endif
}
-static inline void DisableDma()
+static inline void DisableDma() noexcept
{
#if SAME70
xdmac_channel_disable(XDMAC, DmacChanTmcTx);
@@ -1045,7 +1045,7 @@ static inline void DisableDma()
#endif
}
-static inline void ResetSpi()
+static inline void ResetSpi() noexcept
{
#if TMC51xx_USES_SERCOM
hri_sercomspi_clear_CTRLA_ENABLE_bit(SERCOM_TMC51xx); // warning: this makes SCLK float!
@@ -1057,7 +1057,7 @@ static inline void ResetSpi()
#endif
}
-static inline void EnableSpi()
+static inline void EnableSpi() noexcept
{
#if TMC51xx_USES_SERCOM
hri_sercomspi_set_CTRLB_RXEN_bit(SERCOM_TMC51xx);
@@ -1069,7 +1069,7 @@ static inline void EnableSpi()
#endif
}
-static inline void DisableEndOfTransferInterrupt()
+static inline void DisableEndOfTransferInterrupt() noexcept
{
#if SAME70
xdmac_channel_disable_interrupt(XDMAC, DmacChanTmcRx, XDMAC_CIE_BIE);
@@ -1082,7 +1082,7 @@ static inline void DisableEndOfTransferInterrupt()
#endif
}
-static inline void EnableEndOfTransferInterrupt()
+static inline void EnableEndOfTransferInterrupt() noexcept
{
#if SAME70
xdmac_channel_enable_interrupt(XDMAC, DmacChanTmcRx, XDMAC_CIE_BIE);
@@ -1096,7 +1096,7 @@ static inline void EnableEndOfTransferInterrupt()
}
// DMA complete callback
-void RxDmaCompleteCallback(CallbackParameter param)
+void RxDmaCompleteCallback(CallbackParameter param) noexcept
{
#if SAME70
xdmac_channel_disable_interrupt(XDMAC, DmacChanTmcRx, 0xFFFFFFFF);
@@ -1105,7 +1105,7 @@ void RxDmaCompleteCallback(CallbackParameter param)
tmcTask.GiveFromISR();
}
-extern "C" [[noreturn]] void TmcLoop(void *)
+extern "C" [[noreturn]] void TmcLoop(void *) noexcept
{
bool timedOut = true;
for (;;)
@@ -1208,7 +1208,7 @@ extern "C" [[noreturn]] void TmcLoop(void *)
// Initialise the driver interface and the drivers, leaving each drive disabled.
// It is assumed that the drivers are not powered, so driversPowered(true) must be called after calling this before the motors can be moved.
-void SmartDrivers::Init()
+void SmartDrivers::Init() noexcept
{
// Make sure the ENN and CS pins are high
pinMode(GlobalTmc51xxEnablePin, OUTPUT_HIGH);
@@ -1323,7 +1323,7 @@ void SmartDrivers::Init()
}
// Shut down the drivers and stop any related interrupts. Don't call Spin() again after calling this as it may re-enable them.
-void SmartDrivers::Exit()
+void SmartDrivers::Exit() noexcept
{
digitalWrite(GlobalTmc51xxEnablePin, HIGH);
NVIC_DisableIRQ(TMC51xx_SPI_IRQn);
@@ -1331,7 +1331,7 @@ void SmartDrivers::Exit()
driversState = DriversState::noPower;
}
-void SmartDrivers::SetAxisNumber(size_t driver, uint32_t axisNumber)
+void SmartDrivers::SetAxisNumber(size_t driver, uint32_t axisNumber) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1339,12 +1339,12 @@ void SmartDrivers::SetAxisNumber(size_t driver, uint32_t axisNumber)
}
}
-uint32_t SmartDrivers::GetAxisNumber(size_t drive)
+uint32_t SmartDrivers::GetAxisNumber(size_t drive) noexcept
{
return (drive < numTmc51xxDrivers) ? driverStates[drive].GetAxisNumber() : 0;
}
-void SmartDrivers::SetCurrent(size_t driver, float current)
+void SmartDrivers::SetCurrent(size_t driver, float current) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1352,7 +1352,7 @@ void SmartDrivers::SetCurrent(size_t driver, float current)
}
}
-void SmartDrivers::EnableDrive(size_t driver, bool en)
+void SmartDrivers::EnableDrive(size_t driver, bool en) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1360,18 +1360,18 @@ void SmartDrivers::EnableDrive(size_t driver, bool en)
}
}
-uint32_t SmartDrivers::GetLiveStatus(size_t driver)
+uint32_t SmartDrivers::GetLiveStatus(size_t driver) noexcept
{
return (driver < numTmc51xxDrivers) ? driverStates[driver].ReadLiveStatus() : 0;
}
-uint32_t SmartDrivers::GetAccumulatedStatus(size_t driver, uint32_t bitsToKeep)
+uint32_t SmartDrivers::GetAccumulatedStatus(size_t driver, uint32_t bitsToKeep) noexcept
{
return (driver < numTmc51xxDrivers) ? driverStates[driver].ReadAccumulatedStatus(bitsToKeep) : 0;
}
// Set microstepping and microstep interpolation
-bool SmartDrivers::SetMicrostepping(size_t driver, unsigned int microsteps, bool interpolate)
+bool SmartDrivers::SetMicrostepping(size_t driver, unsigned int microsteps, bool interpolate) noexcept
{
if (driver < numTmc51xxDrivers && microsteps > 0)
{
@@ -1393,7 +1393,7 @@ bool SmartDrivers::SetMicrostepping(size_t driver, unsigned int microsteps, bool
}
// Get microstepping and interpolation
-unsigned int SmartDrivers::GetMicrostepping(size_t driver, bool& interpolation)
+unsigned int SmartDrivers::GetMicrostepping(size_t driver, bool& interpolation) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1403,19 +1403,19 @@ unsigned int SmartDrivers::GetMicrostepping(size_t driver, bool& interpolation)
return 1;
}
-bool SmartDrivers::SetDriverMode(size_t driver, unsigned int mode)
+bool SmartDrivers::SetDriverMode(size_t driver, unsigned int mode) noexcept
{
return driver < numTmc51xxDrivers && driverStates[driver].SetDriverMode(mode);
}
-DriverMode SmartDrivers::GetDriverMode(size_t driver)
+DriverMode SmartDrivers::GetDriverMode(size_t driver) noexcept
{
return (driver < numTmc51xxDrivers) ? driverStates[driver].GetDriverMode() : DriverMode::unknown;
}
// Flag that the the drivers have been powered up or down
// Before the first call to this function with 'powered' true, you must call Init()
-void SmartDrivers::Spin(bool powered)
+void SmartDrivers::Spin(bool powered) noexcept
{
TaskCriticalSectionLocker lock;
@@ -1435,13 +1435,13 @@ void SmartDrivers::Spin(bool powered)
}
// This is called from the tick ISR, possibly while Spin (with powered either true or false) is being executed
-void SmartDrivers::TurnDriversOff()
+void SmartDrivers::TurnDriversOff() noexcept
{
digitalWrite(GlobalTmc51xxEnablePin, true); // disable the drivers
driversState = DriversState::noPower;
}
-void SmartDrivers::SetStallThreshold(size_t driver, int sgThreshold)
+void SmartDrivers::SetStallThreshold(size_t driver, int sgThreshold) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1449,7 +1449,7 @@ void SmartDrivers::SetStallThreshold(size_t driver, int sgThreshold)
}
}
-void SmartDrivers::SetStallFilter(size_t driver, bool sgFilter)
+void SmartDrivers::SetStallFilter(size_t driver, bool sgFilter) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1457,7 +1457,7 @@ void SmartDrivers::SetStallFilter(size_t driver, bool sgFilter)
}
}
-void SmartDrivers::SetStallMinimumStepsPerSecond(size_t driver, unsigned int stepsPerSecond)
+void SmartDrivers::SetStallMinimumStepsPerSecond(size_t driver, unsigned int stepsPerSecond) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1465,7 +1465,7 @@ void SmartDrivers::SetStallMinimumStepsPerSecond(size_t driver, unsigned int ste
}
}
-void SmartDrivers::AppendStallConfig(size_t driver, const StringRef& reply)
+void SmartDrivers::AppendStallConfig(size_t driver, const StringRef& reply) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1473,7 +1473,7 @@ void SmartDrivers::AppendStallConfig(size_t driver, const StringRef& reply)
}
}
-void SmartDrivers::AppendDriverStatus(size_t driver, const StringRef& reply)
+void SmartDrivers::AppendDriverStatus(size_t driver, const StringRef& reply) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1481,12 +1481,12 @@ void SmartDrivers::AppendDriverStatus(size_t driver, const StringRef& reply)
}
}
-float SmartDrivers::GetStandstillCurrentPercent(size_t driver)
+float SmartDrivers::GetStandstillCurrentPercent(size_t driver) noexcept
{
return (driver < numTmc51xxDrivers) ? driverStates[driver].GetStandstillCurrentPercent() : 0.0;
}
-void SmartDrivers::SetStandstillCurrentPercent(size_t driver, float percent)
+void SmartDrivers::SetStandstillCurrentPercent(size_t driver, float percent) noexcept
{
if (driver < numTmc51xxDrivers)
{
@@ -1494,12 +1494,12 @@ void SmartDrivers::SetStandstillCurrentPercent(size_t driver, float percent)
}
}
-bool SmartDrivers::SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal)
+bool SmartDrivers::SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal) noexcept
{
return (driver < numTmc51xxDrivers) && driverStates[driver].SetRegister(reg, regVal);
}
-uint32_t SmartDrivers::GetRegister(size_t driver, SmartDriverRegister reg)
+uint32_t SmartDrivers::GetRegister(size_t driver, SmartDriverRegister reg) noexcept
{
return (driver < numTmc51xxDrivers) ? driverStates[driver].GetRegister(reg) : 0;
}
diff --git a/src/Movement/StepperDrivers/TMC51xx.h b/src/Movement/StepperDrivers/TMC51xx.h
index cc2c454e..82aea738 100644
--- a/src/Movement/StepperDrivers/TMC51xx.h
+++ b/src/Movement/StepperDrivers/TMC51xx.h
@@ -26,30 +26,30 @@ const uint32_t TMC_RR_SGRESULT = 0x3FF; // 10-bit stallGuard2 result
namespace SmartDrivers
{
- void Init();
- void Exit();
- void Spin(bool powered);
- void TurnDriversOff();
-
- void SetAxisNumber(size_t driver, uint32_t axisNumber);
- uint32_t GetAxisNumber(size_t drive);
- void SetCurrent(size_t driver, float current);
- void EnableDrive(size_t driver, bool en);
- uint32_t GetLiveStatus(size_t driver);
- uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep);
- bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolation);
- unsigned int GetMicrostepping(size_t drive, bool& interpolation);
- bool SetDriverMode(size_t driver, unsigned int mode);
- DriverMode GetDriverMode(size_t driver);
- void SetStallThreshold(size_t driver, int sgThreshold);
- void SetStallFilter(size_t driver, bool sgFilter);
- void SetStallMinimumStepsPerSecond(size_t driver, unsigned int stepsPerSecond);
- void AppendStallConfig(size_t driver, const StringRef& reply);
- void AppendDriverStatus(size_t driver, const StringRef& reply);
- float GetStandstillCurrentPercent(size_t driver);
- void SetStandstillCurrentPercent(size_t driver, float percent);
- bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal);
- uint32_t GetRegister(size_t driver, SmartDriverRegister reg);
+ void Init() noexcept;
+ void Exit() noexcept;
+ void Spin(bool powered) noexcept;
+ void TurnDriversOff() noexcept;
+
+ void SetAxisNumber(size_t driver, uint32_t axisNumber) noexcept;
+ uint32_t GetAxisNumber(size_t drive) noexcept;
+ void SetCurrent(size_t driver, float current) noexcept;
+ void EnableDrive(size_t driver, bool en) noexcept;
+ uint32_t GetLiveStatus(size_t driver) noexcept;
+ uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep) noexcept;
+ bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolation) noexcept;
+ unsigned int GetMicrostepping(size_t drive, bool& interpolation) noexcept;
+ bool SetDriverMode(size_t driver, unsigned int mode) noexcept;
+ DriverMode GetDriverMode(size_t driver) noexcept;
+ void SetStallThreshold(size_t driver, int sgThreshold) noexcept;
+ void SetStallFilter(size_t driver, bool sgFilter) noexcept;
+ void SetStallMinimumStepsPerSecond(size_t driver, unsigned int stepsPerSecond) noexcept;
+ void AppendStallConfig(size_t driver, const StringRef& reply) noexcept;
+ void AppendDriverStatus(size_t driver, const StringRef& reply) noexcept;
+ float GetStandstillCurrentPercent(size_t driver) noexcept;
+ void SetStandstillCurrentPercent(size_t driver, float percent) noexcept;
+ bool SetRegister(size_t driver, SmartDriverRegister reg, uint32_t regVal) noexcept;
+ uint32_t GetRegister(size_t driver, SmartDriverRegister reg) noexcept;
};
#endif
diff --git a/src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp b/src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp
index e706a153..d4301e93 100644
--- a/src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp
+++ b/src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp
@@ -89,14 +89,14 @@ static timers_info_t gs_timers_table[] = {
#endif
};
-extern uint32_t millis();
+extern uint32_t millis() noexcept;
} // end extern "C"
/**
* \brief Process timing functions.
*/
-void ethernet_timers_update(void)
+void ethernet_timers_update(void) noexcept
{
static uint32_t ul_last_time;
uint32_t ul_cur_time, ul_time_diff, ul_idx_timer;
@@ -127,7 +127,7 @@ void ethernet_timers_update(void)
//************************************************************************************************************
// This sets the static IP configuration on-the-fly
-void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay)
+void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) noexcept
{
ip4_addr_t x_ip_addr, x_net_mask, x_gateway;
x_ip_addr.addr = ipAddress.GetV4LittleEndian();
@@ -143,7 +143,7 @@ void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddres
/** \brief Initialize the Ethernet subsystem.
*
*/
-void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay)
+void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) noexcept
{
ip4_addr_t x_ip_addr, x_net_mask, x_gateway;
x_ip_addr.addr = ipAddress.GetV4LittleEndian();
@@ -169,7 +169,7 @@ void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay)
/** \brief Configure the Ethernet subsystem. Should be called after init_ethernet()
*
*/
-void ethernet_configure_interface(const uint8_t macAddress[], const char *hostname)
+void ethernet_configure_interface(const uint8_t macAddress[], const char *hostname) noexcept
{
ethernetif_set_mac_address(macAddress);
@@ -181,7 +181,7 @@ void ethernet_configure_interface(const uint8_t macAddress[], const char *hostna
/* \brief Perform ethernet auto-negotiation and establish link. Returns true when ready
*
*/
-bool ethernet_establish_link(void)
+bool ethernet_establish_link() noexcept
{
if (ethernetif_establish_link())
{
@@ -194,7 +194,7 @@ bool ethernet_establish_link(void)
/* \brief Is the link still up? Also updates the interface status if the link has gone down
*
*/
-bool ethernet_link_established(void)
+bool ethernet_link_established() noexcept
{
if (!ethernetif_link_established())
{
@@ -210,7 +210,7 @@ bool ethernet_link_established(void)
*
* \return Returns true if data has been processed.
*/
-void ethernet_task(void)
+void ethernet_task() noexcept
{
#if !LWIP_GMAC_TASK
/* Run polling tasks */
@@ -229,7 +229,7 @@ void ethernet_task(void)
*
* \param callback The callback to be called when a new packet is ready
*/
-void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback)
+void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback) noexcept
{
ethernetif_set_rx_callback(callback);
}
@@ -238,7 +238,7 @@ void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback)
/*
* \brief Returns the current IP address
*/
-void ethernet_get_ipaddress(IPAddress& ipAddress, IPAddress& netMask, IPAddress& gateWay)
+void ethernet_get_ipaddress(IPAddress& ipAddress, IPAddress& netMask, IPAddress& gateWay) noexcept
{
ipAddress.SetV4LittleEndian(gs_net_if.ip_addr.addr);
netMask.SetV4LittleEndian(gs_net_if.netmask.addr);
diff --git a/src/Networking/LwipEthernet/GMAC/ethernet_sam.h b/src/Networking/LwipEthernet/GMAC/ethernet_sam.h
index 06516e19..c1948803 100644
--- a/src/Networking/LwipEthernet/GMAC/ethernet_sam.h
+++ b/src/Networking/LwipEthernet/GMAC/ethernet_sam.h
@@ -52,35 +52,35 @@
#include "lwip/netif.h"
// Perform low-level initialisation of the network interface
-void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay);
+void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) noexcept;
// Terminate Ethernet and stop any interrupts, tasks etc. Used when shutting down the whole system.
-inline void ethernet_terminate() { ethernetif_terminate(); }
+inline void ethernet_terminate() noexcept { ethernetif_terminate(); }
// Configure the ethernet interface
-void ethernet_configure_interface(const uint8_t macAddress[], const char *hostname);
+void ethernet_configure_interface(const uint8_t macAddress[], const char *hostname) noexcept;
// Perform ethernet auto-negotiation and establish link. Returns true when ready
-bool ethernet_establish_link(void);
+bool ethernet_establish_link() noexcept;
// Is the link still up? Also updates the interface status if the link has gone down
-bool ethernet_link_established(void);
+bool ethernet_link_established() noexcept;
// Update IPv4 configuration on demand
-void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay);
+void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) noexcept;
// Must be called periodically to keep the LwIP timers running
-void ethernet_timers_update(void);
+void ethernet_timers_update() noexcept;
// Reads all stored network packets and processes them
-void ethernet_task(void);
+void ethernet_task() noexcept;
#if !LWIP_GMAC_TASK
// Set the RX callback for incoming network packets
-void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback);
+void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback) noexcept;
#endif
// Returns the network interface's current IPv4 address
-void ethernet_get_ipaddress(IPAddress& ipAddress, IPAddress& netMask, IPAddress& gateWay);
+void ethernet_get_ipaddress(IPAddress& ipAddress, IPAddress& netMask, IPAddress& gateWay) noexcept;
#endif /* ETHERNET_SAM_H_INCLUDED */
diff --git a/src/Networking/LwipEthernet/GMAC/same70_gmac.cpp b/src/Networking/LwipEthernet/GMAC/same70_gmac.cpp
index 863f4018..2565fe79 100644
--- a/src/Networking/LwipEthernet/GMAC/same70_gmac.cpp
+++ b/src/Networking/LwipEthernet/GMAC/same70_gmac.cpp
@@ -176,7 +176,7 @@ static gmac_dev_tx_cb_t gmac_rx_cb = nullptr;
/**
* \brief GMAC interrupt handler.
*/
-void GMAC_Handler(void)
+extern "C" void GMAC_Handler() noexcept
{
#if LWIP_GMAC_TASK
/* Get interrupt status. */
@@ -214,7 +214,7 @@ void GMAC_Handler(void)
* \param p_gmac_dev Pointer to driver data structure.
* \param startAt The index to start populating from
*/
-static void gmac_rx_populate_queue(struct gmac_device *p_gmac_dev, uint32_t startAt)
+static void gmac_rx_populate_queue(struct gmac_device *p_gmac_dev, uint32_t startAt) noexcept
{
uint32_t ul_index = startAt;
@@ -278,7 +278,7 @@ static void gmac_rx_populate_queue(struct gmac_device *p_gmac_dev, uint32_t star
*
* \param ps_gmac_dev Pointer to driver data structure.
*/
-static void gmac_rx_init(struct gmac_device *ps_gmac_dev)
+static void gmac_rx_init(struct gmac_device *ps_gmac_dev) noexcept
{
uint32_t ul_index = 0;
@@ -308,7 +308,7 @@ static void gmac_rx_init(struct gmac_device *ps_gmac_dev)
*
* \param ps_gmac_dev Pointer to driver data structure.
*/
-static void gmac_tx_init(struct gmac_device *ps_gmac_dev)
+static void gmac_tx_init(struct gmac_device *ps_gmac_dev) noexcept
{
uint32_t ul_index;
@@ -334,7 +334,7 @@ static void gmac_tx_init(struct gmac_device *ps_gmac_dev)
*
* \param netif the lwIP network interface structure for this ethernetif.
*/
-static void gmac_low_level_init(struct netif *netif)
+static void gmac_low_level_init(struct netif *netif) noexcept
{
#if 0 // chrishamm
volatile uint32_t ul_delay;
@@ -402,7 +402,7 @@ static void gmac_low_level_init(struct netif *netif)
* \return ERR_OK if the packet could be sent.
* an err_t value if the packet couldn't be sent.
*/
-static err_t gmac_low_level_output(netif *p_netif, struct pbuf *p)
+static err_t gmac_low_level_output(netif *p_netif, struct pbuf *p) noexcept
{
gmac_device *const ps_gmac_dev = static_cast<gmac_device *>(p_netif->state);
@@ -482,7 +482,7 @@ static err_t gmac_low_level_output(netif *p_netif, struct pbuf *p)
* \return a pbuf filled with the received packet (including MAC header).
* 0 on memory error.
*/
-static pbuf *gmac_low_level_input(struct netif *netif)
+static pbuf *gmac_low_level_input(struct netif *netif) noexcept
{
gmac_device *ps_gmac_dev = static_cast<gmac_device *>(netif->state);
@@ -565,7 +565,7 @@ static pbuf *gmac_low_level_input(struct netif *netif)
*
* \param pvParameters A pointer to the gmac_device instance.
*/
-extern "C" [[noreturn]] void gmac_task(void *pvParameters)
+extern "C" [[noreturn]] void gmac_task(void *pvParameters) noexcept
{
gmac_device * const ps_gmac_dev = static_cast<gmac_device*>(pvParameters);
netif * const p_netif = ps_gmac_dev->netif;
@@ -593,7 +593,7 @@ extern "C" [[noreturn]] void gmac_task(void *pvParameters)
*
* \param netif the lwIP network interface structure for this ethernetif.
*/
-bool ethernetif_input(struct netif *netif)
+bool ethernetif_input(struct netif *netif) noexcept
{
struct eth_hdr *ethhdr;
struct pbuf *p;
@@ -642,7 +642,7 @@ bool ethernetif_input(struct netif *netif)
* ERR_MEM if private data couldn't be allocated.
* any other err_t on error.
*/
-err_t ethernetif_init(struct netif *netif)
+err_t ethernetif_init(struct netif *netif) noexcept
{
LWIP_ASSERT("netif != NULL", (netif != NULL));
@@ -683,7 +683,7 @@ err_t ethernetif_init(struct netif *netif)
return ERR_OK;
}
-void ethernetif_hardware_init(void)
+void ethernetif_hardware_init() noexcept
{
/* Enable GMAC clock. */
pmc_enable_periph_clk(ID_GMAC);
@@ -767,7 +767,7 @@ void ethernetif_hardware_init(void)
NVIC_EnableIRQ(GMAC_IRQn);
}
-bool ethernetif_establish_link(void)
+bool ethernetif_establish_link() noexcept
{
/* Auto Negotiate, work in RMII mode. */
uint8_t result = ethernet_phy_auto_negotiate(GMAC, BOARD_GMAC_PHY_ADDR);
@@ -790,7 +790,7 @@ bool ethernetif_establish_link(void)
}
// Ask the PHY if the link is still up
-bool ethernetif_link_established(void)
+bool ethernetif_link_established() noexcept
{
gmac_enable_management(GMAC, true);
@@ -810,13 +810,13 @@ bool ethernetif_link_established(void)
}
#if !LWIP_GMAC_TASK
-void ethernetif_set_rx_callback(gmac_dev_tx_cb_t callback)
+void ethernetif_set_rx_callback(gmac_dev_tx_cb_t callback) noexcept
{
gmac_rx_cb = callback;
}
#endif
-void ethernetif_set_mac_address(const uint8_t macAddress[])
+void ethernetif_set_mac_address(const uint8_t macAddress[]) noexcept
{
// This function must be called once before low_level_init(), because that is where the
// MAC address of the netif is assigned
@@ -827,7 +827,7 @@ void ethernetif_set_mac_address(const uint8_t macAddress[])
}
// This is called when we shut down
-void ethernetif_terminate()
+void ethernetif_terminate() noexcept
{
NVIC_DisableIRQ(GMAC_IRQn);
#if LWIP_GMAC_TASK
@@ -835,9 +835,9 @@ void ethernetif_terminate()
#endif
}
-extern "C" u32_t millis();
+extern "C" u32_t millis() noexcept;
-extern "C" u32_t sys_now(void)
+extern "C" u32_t sys_now() noexcept
{
return millis();
}
diff --git a/src/Networking/LwipEthernet/GMAC/same70_gmac.h b/src/Networking/LwipEthernet/GMAC/same70_gmac.h
index 6d494faf..8d6bd595 100644
--- a/src/Networking/LwipEthernet/GMAC/same70_gmac.h
+++ b/src/Networking/LwipEthernet/GMAC/same70_gmac.h
@@ -57,24 +57,24 @@ extern "C" {
#ifdef __cplusplus
}
-err_t ethernetif_init(struct netif *netif); // called by LwIP to initialise the interface
+err_t ethernetif_init(struct netif *netif) noexcept; // called by LwIP to initialise the interface
-void ethernetif_terminate(); // called when we shut down
+void ethernetif_terminate() noexcept; // called when we shut down
-bool ethernetif_input(struct netif *netif); // checks for a new packet and returns true if one was processed
+bool ethernetif_input(struct netif *netif) noexcept; // checks for a new packet and returns true if one was processed
-void ethernetif_hardware_init(void); // initialises the low-level hardware interface
+void ethernetif_hardware_init() noexcept; // initialises the low-level hardware interface
-bool ethernetif_establish_link(void); // attempts to establish link and returns true on success
+bool ethernetif_establish_link() noexcept; // attempts to establish link and returns true on success
-bool ethernetif_link_established(void); // asks the PHY if the link is still up
+bool ethernetif_link_established() noexcept; // asks the PHY if the link is still up
#if !LWIP_GMAC_TASK
-typedef void (*gmac_dev_tx_cb_t) (uint32_t ul_status); // copied from gmac_raw.h
-void ethernetif_set_rx_callback(gmac_dev_tx_cb_t callback);
+typedef void (*gmac_dev_tx_cb_t) (uint32_t ul_status) noexcept; // copied from gmac_raw.h
+void ethernetif_set_rx_callback(gmac_dev_tx_cb_t callback) noexcept;
#endif
-void ethernetif_set_mac_address(const uint8_t macAddress[]);
+void ethernetif_set_mac_address(const uint8_t macAddress[]) noexcept;
#endif
diff --git a/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h b/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h
index 3bfa245f..89e44449 100644
--- a/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h
+++ b/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h
@@ -40,7 +40,10 @@
#include <Lwip/src/include/lwip/opt.h>
#ifdef __cplusplus
+# define NOEXCEPT noexcept
extern "C" {
+#else
+# define NOEXCEPT
#endif
#if NO_SYS
@@ -340,7 +343,7 @@ u32_t sys_jiffies(void);
* Returns the current time in milliseconds,
* may be the same as sys_jiffies or at least based on it.
*/
-u32_t sys_now(void);
+u32_t sys_now(void) NOEXCEPT;
/* Critical Region Protection */
/* These functions must be implemented in the sys_arch.c file.
diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
index 79378030..88c42a90 100644
--- a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
+++ b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
@@ -134,7 +134,7 @@ extern "C"
/*-----------------------------------------------------------------------------------*/
-LwipEthernetInterface::LwipEthernetInterface(Platform& p) : platform(p), closeDataPort(false), state(NetworkState::disabled),
+LwipEthernetInterface::LwipEthernetInterface(Platform& p) noexcept : platform(p), closeDataPort(false), state(NetworkState::disabled),
activated(false), initialised(false), usingDhcp(false)
{
ethernetInterface = this;
@@ -175,7 +175,7 @@ DEFINE_GET_OBJECT_MODEL_TABLE(LwipEthernetInterface)
#endif
-void LwipEthernetInterface::Init()
+void LwipEthernetInterface::Init() noexcept
{
interfaceMutex.Create("LwipIface");
//TODO we don't yet use this mutex anywhere!
@@ -193,7 +193,7 @@ void LwipEthernetInterface::Init()
memcpy(macAddress, platform.GetDefaultMacAddress(), sizeof(macAddress));
}
-GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply)
+GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept
{
if (secure != 0 && secure != -1)
{
@@ -229,7 +229,7 @@ GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int
return GCodeResult::error;
}
-GCodeResult LwipEthernetInterface::DisableProtocol(NetworkProtocol protocol, const StringRef& reply)
+GCodeResult LwipEthernetInterface::DisableProtocol(NetworkProtocol protocol, const StringRef& reply) noexcept
{
if (protocol < NumProtocols)
{
@@ -246,7 +246,7 @@ GCodeResult LwipEthernetInterface::DisableProtocol(NetworkProtocol protocol, con
return GCodeResult::error;
}
-void LwipEthernetInterface::StartProtocol(NetworkProtocol protocol)
+void LwipEthernetInterface::StartProtocol(NetworkProtocol protocol) noexcept
{
if (listeningPcbs[protocol] == nullptr)
{
@@ -278,7 +278,7 @@ void LwipEthernetInterface::StartProtocol(NetworkProtocol protocol)
}
}
-void LwipEthernetInterface::ShutdownProtocol(NetworkProtocol protocol)
+void LwipEthernetInterface::ShutdownProtocol(NetworkProtocol protocol) noexcept
{
#if 0 // chrishamm: Also see Network::Stop
for (NetworkResponder* r = responders; r != nullptr; r = r->GetNext())
@@ -317,7 +317,7 @@ void LwipEthernetInterface::ShutdownProtocol(NetworkProtocol protocol)
}
// Report the protocols and ports in use
-GCodeResult LwipEthernetInterface::ReportProtocols(const StringRef& reply) const
+GCodeResult LwipEthernetInterface::ReportProtocols(const StringRef& reply) const noexcept
{
reply.Clear();
for (size_t i = 0; i < NumProtocols; ++i)
@@ -327,7 +327,7 @@ GCodeResult LwipEthernetInterface::ReportProtocols(const StringRef& reply) const
return GCodeResult::ok;
}
-void LwipEthernetInterface::ReportOneProtocol(NetworkProtocol protocol, const StringRef& reply) const
+void LwipEthernetInterface::ReportOneProtocol(NetworkProtocol protocol, const StringRef& reply) const noexcept
{
if (protocolEnabled[protocol])
{
@@ -341,7 +341,7 @@ void LwipEthernetInterface::ReportOneProtocol(NetworkProtocol protocol, const St
// This is called at the end of config.g processing.
// Start the network if it was enabled
-void LwipEthernetInterface::Activate()
+void LwipEthernetInterface::Activate() noexcept
{
if (!activated)
{
@@ -357,14 +357,14 @@ void LwipEthernetInterface::Activate()
}
}
-void LwipEthernetInterface::Exit()
+void LwipEthernetInterface::Exit() noexcept
{
Stop();
ethernet_terminate();
}
// Get the network state into the reply buffer, returning true if there is some sort of error
-GCodeResult LwipEthernetInterface::GetNetworkState(const StringRef& reply)
+GCodeResult LwipEthernetInterface::GetNetworkState(const StringRef& reply) noexcept
{
ethernet_get_ipaddress(ipAddress, netmask, gateway);
const int enableState = EnableState();
@@ -375,7 +375,7 @@ GCodeResult LwipEthernetInterface::GetNetworkState(const StringRef& reply)
}
// Start up the network
-void LwipEthernetInterface::Start()
+void LwipEthernetInterface::Start() noexcept
{
#if defined(DUET3)
digitalWrite(PhyResetPin, true); // bring the Ethernet Phy out of reset
@@ -412,7 +412,7 @@ void LwipEthernetInterface::Start()
}
// Stop the network
-void LwipEthernetInterface::Stop()
+void LwipEthernetInterface::Stop() noexcept
{
if (state != NetworkState::disabled)
{
@@ -430,7 +430,7 @@ void LwipEthernetInterface::Stop()
}
// Main spin loop. If 'full' is true then we are being called from the main spin loop. If false then we are being called during HSMCI idle time.
-void LwipEthernetInterface::Spin()
+void LwipEthernetInterface::Spin() noexcept
{
#if LWIP_GMAC_TASK
MutexLocker lock(lwipMutex);
@@ -542,7 +542,7 @@ void LwipEthernetInterface::Spin()
#endif
}
-void LwipEthernetInterface::Interrupt()
+void LwipEthernetInterface::Interrupt() noexcept
{
#if !LWIP_GMAC_TASK
if (initialised && LockLWIP())
@@ -553,7 +553,7 @@ void LwipEthernetInterface::Interrupt()
#endif
}
-void LwipEthernetInterface::Diagnostics(MessageType mtype)
+void LwipEthernetInterface::Diagnostics(MessageType mtype) noexcept
{
platform.Message(mtype, "- Ethernet -\n");
platform.MessageF(mtype, "State: %d\n", (int)state);
@@ -575,7 +575,7 @@ void LwipEthernetInterface::Diagnostics(MessageType mtype)
}
// Enable or disable the network. For Ethernet the ssid parameter is not used.
-GCodeResult LwipEthernetInterface::EnableInterface(int mode, const StringRef& ssid, const StringRef& reply)
+GCodeResult LwipEthernetInterface::EnableInterface(int mode, const StringRef& ssid, const StringRef& reply) noexcept
{
if (!activated)
{
@@ -598,12 +598,12 @@ GCodeResult LwipEthernetInterface::EnableInterface(int mode, const StringRef& ss
return GCodeResult::ok;
}
-int LwipEthernetInterface::EnableState() const
+int LwipEthernetInterface::EnableState() const noexcept
{
return (state == NetworkState::disabled) ? 0 : 1;
}
-bool LwipEthernetInterface::InNetworkStack() const
+bool LwipEthernetInterface::InNetworkStack() const noexcept
{
#if LWIP_GMAC_TASK
return false;
@@ -612,7 +612,7 @@ bool LwipEthernetInterface::InNetworkStack() const
#endif
}
-bool LwipEthernetInterface::ConnectionEstablished(tcp_pcb *pcb)
+bool LwipEthernetInterface::ConnectionEstablished(tcp_pcb *pcb) noexcept
{
for (LwipSocket *s : sockets)
{
@@ -627,12 +627,12 @@ bool LwipEthernetInterface::ConnectionEstablished(tcp_pcb *pcb)
return false;
}
-IPAddress LwipEthernetInterface::GetIPAddress() const
+IPAddress LwipEthernetInterface::GetIPAddress() const noexcept
{
return ipAddress;
}
-void LwipEthernetInterface::SetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, IPAddress p_gateway)
+void LwipEthernetInterface::SetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, IPAddress p_gateway) noexcept
{
if (state == NetworkState::obtainingIP || state == NetworkState::active)
{
@@ -668,7 +668,7 @@ void LwipEthernetInterface::SetIPAddress(IPAddress p_ipAddress, IPAddress p_netm
}
}
-void LwipEthernetInterface::UpdateHostname(const char *hostname)
+void LwipEthernetInterface::UpdateHostname(const char *hostname) noexcept
{
if (initialised)
{
@@ -677,12 +677,12 @@ void LwipEthernetInterface::UpdateHostname(const char *hostname)
}
}
-void LwipEthernetInterface::SetMacAddress(const uint8_t mac[])
+void LwipEthernetInterface::SetMacAddress(const uint8_t mac[]) noexcept
{
memcpy(macAddress, mac, sizeof(macAddress));
}
-void LwipEthernetInterface::OpenDataPort(Port port)
+void LwipEthernetInterface::OpenDataPort(Port port) noexcept
{
if (listeningPcbs[NumProtocols] != nullptr)
{
@@ -699,7 +699,7 @@ void LwipEthernetInterface::OpenDataPort(Port port)
}
// Close FTP data port and purge associated resources
-void LwipEthernetInterface::TerminateDataPort()
+void LwipEthernetInterface::TerminateDataPort() noexcept
{
if (closeDataPort || !sockets[FtpDataSocketNumber]->IsClosing())
{
@@ -720,7 +720,7 @@ void LwipEthernetInterface::TerminateDataPort()
}
}
-void LwipEthernetInterface::InitSockets()
+void LwipEthernetInterface::InitSockets() noexcept
{
for (size_t i = 0; i < NumProtocols; ++i)
{
@@ -732,7 +732,7 @@ void LwipEthernetInterface::InitSockets()
nextSocketToPoll = 0;
}
-void LwipEthernetInterface::TerminateSockets()
+void LwipEthernetInterface::TerminateSockets() noexcept
{
for (LwipSocket *socket : sockets)
{
@@ -748,7 +748,7 @@ void GetServiceTxtEntries(struct mdns_service *service, void *txt_userdata)
}
}
-void LwipEthernetInterface::RebuildMdnsServices()
+void LwipEthernetInterface::RebuildMdnsServices() noexcept
{
mdns_resp_remove_netif(&gs_net_if);
mdns_resp_add_netif(&gs_net_if, reprap.GetNetwork().GetHostname(), MdnsTtl);
diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.h b/src/Networking/LwipEthernet/LwipEthernetInterface.h
index 94ec30e0..3a4a6f42 100644
--- a/src/Networking/LwipEthernet/LwipEthernetInterface.h
+++ b/src/Networking/LwipEthernet/LwipEthernetInterface.h
@@ -28,36 +28,36 @@ struct tcp_pcb;
class LwipEthernetInterface : public NetworkInterface
{
public:
- LwipEthernetInterface(Platform& p);
-
- void Init() override;
- void Activate() override;
- void Exit() override;
- void Spin() override;
- void Interrupt() override;
- void Diagnostics(MessageType mtype) override;
-
- GCodeResult EnableInterface(int mode, const StringRef& ssid, const StringRef& reply) override; // enable or disable the network
- GCodeResult EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) override;
- GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply) override;
- GCodeResult ReportProtocols(const StringRef& reply) const override;
-
- GCodeResult GetNetworkState(const StringRef& reply) override;
- int EnableState() const override;
- bool InNetworkStack() const override;
- bool IsWiFiInterface() const override { return false; }
-
- void UpdateHostname(const char *hostname) override;
- IPAddress GetIPAddress() const override;
- void SetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, IPAddress p_gateway) override;
- void SetMacAddress(const uint8_t mac[]) override;
- const uint8_t *GetMacAddress() const override { return macAddress; }
+ LwipEthernetInterface(Platform& p) noexcept;
+
+ void Init() noexcept override;
+ void Activate() noexcept override;
+ void Exit() noexcept override;
+ void Spin() noexcept override;
+ void Interrupt() noexcept override;
+ void Diagnostics(MessageType mtype) noexcept override;
+
+ GCodeResult EnableInterface(int mode, const StringRef& ssid, const StringRef& reply) noexcept override; // enable or disable the network
+ GCodeResult EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept override;
+ GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply) noexcept override;
+ GCodeResult ReportProtocols(const StringRef& reply) const noexcept override;
+
+ GCodeResult GetNetworkState(const StringRef& reply) noexcept override;
+ int EnableState() const noexcept override;
+ bool InNetworkStack() const noexcept override;
+ bool IsWiFiInterface() const noexcept override { return false; }
+
+ void UpdateHostname(const char *hostname) noexcept override;
+ IPAddress GetIPAddress() const noexcept override;
+ void SetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, IPAddress p_gateway) noexcept override;
+ void SetMacAddress(const uint8_t mac[]) noexcept override;
+ const uint8_t *GetMacAddress() const noexcept override { return macAddress; }
// LwIP interfaces
- bool ConnectionEstablished(tcp_pcb *pcb);
+ bool ConnectionEstablished(tcp_pcb *pcb) noexcept;
- void OpenDataPort(Port port) override;
- void TerminateDataPort() override;
+ void OpenDataPort(Port port) noexcept override;
+ void TerminateDataPort() noexcept override;
protected:
DECLARE_OBJECT_MODEL
@@ -73,20 +73,20 @@ private:
active // network running
};
- void Start();
- void Stop();
- void InitSockets();
- void TerminateSockets();
+ void Start() noexcept;
+ void Stop() noexcept;
+ void InitSockets() noexcept;
+ void TerminateSockets() noexcept;
- void RebuildMdnsServices();
+ void RebuildMdnsServices() noexcept;
- void StartProtocol(NetworkProtocol protocol)
+ void StartProtocol(NetworkProtocol protocol) noexcept
pre(protocol < NumProtocols);
- void ShutdownProtocol(NetworkProtocol protocol)
+ void ShutdownProtocol(NetworkProtocol protocol) noexcept
pre(protocol < NumProtocols);
- void ReportOneProtocol(NetworkProtocol protocol, const StringRef& reply) const
+ void ReportOneProtocol(NetworkProtocol protocol, const StringRef& reply) const noexcept
pre(protocol < NumProtocols);
Platform& platform;
diff --git a/src/Networking/LwipEthernet/LwipSocket.cpp b/src/Networking/LwipEthernet/LwipSocket.cpp
index 69d7bab5..52c5288c 100644
--- a/src/Networking/LwipEthernet/LwipSocket.cpp
+++ b/src/Networking/LwipEthernet/LwipSocket.cpp
@@ -77,13 +77,13 @@ extern void UnlockLWIP();
// LwipSocket class
-LwipSocket::LwipSocket(NetworkInterface *iface) : Socket(iface), connectionPcb(nullptr),
+LwipSocket::LwipSocket(NetworkInterface *iface) noexcept : Socket(iface), connectionPcb(nullptr),
receivedData(nullptr), state(SocketState::disabled)
{
ReInit();
}
-bool LwipSocket::AcceptConnection(tcp_pcb *pcb)
+bool LwipSocket::AcceptConnection(tcp_pcb *pcb) noexcept
{
if (state == SocketState::listening && pcb->local_port == localPort)
{
@@ -104,7 +104,7 @@ bool LwipSocket::AcceptConnection(tcp_pcb *pcb)
return false;
}
-void LwipSocket::DataReceived(pbuf *data)
+void LwipSocket::DataReceived(pbuf *data) noexcept
{
if (state != SocketState::closing)
{
@@ -125,7 +125,7 @@ void LwipSocket::DataReceived(pbuf *data)
}
}
-void LwipSocket::DataSent(size_t numBytes)
+void LwipSocket::DataSent(size_t numBytes) noexcept
{
if (numBytes <= unAcked)
{
@@ -144,7 +144,7 @@ void LwipSocket::DataSent(size_t numBytes)
}
}
-void LwipSocket::ConnectionClosedGracefully()
+void LwipSocket::ConnectionClosedGracefully() noexcept
{
if (connectionPcb != nullptr)
{
@@ -166,7 +166,7 @@ void LwipSocket::ConnectionClosedGracefully()
}
}
-void LwipSocket::ConnectionError(err_t err)
+void LwipSocket::ConnectionError(err_t err) noexcept
{
DiscardReceivedData();
connectionPcb = nullptr;
@@ -179,7 +179,7 @@ void LwipSocket::ConnectionError(err_t err)
}
// Initialise a TCP socket
-void LwipSocket::Init(SocketNumber skt, Port serverPort, NetworkProtocol p)
+void LwipSocket::Init(SocketNumber skt, Port serverPort, NetworkProtocol p) noexcept
{
UNUSED(skt);
localPort = serverPort;
@@ -189,13 +189,13 @@ void LwipSocket::Init(SocketNumber skt, Port serverPort, NetworkProtocol p)
ReInit();
}
-void LwipSocket::TerminateAndDisable()
+void LwipSocket::TerminateAndDisable() noexcept
{
Terminate();
state = SocketState::disabled;
}
-void LwipSocket::ReInit()
+void LwipSocket::ReInit() noexcept
{
DiscardReceivedData();
whenConnected = whenWritten = whenClosed = 0;
@@ -204,7 +204,7 @@ void LwipSocket::ReInit()
}
// Close a connection when the last packet has been sent
-void LwipSocket::Close()
+void LwipSocket::Close() noexcept
{
if (state != SocketState::disabled && state != SocketState::listening)
{
@@ -223,7 +223,7 @@ void LwipSocket::Close()
}
// Terminate a connection immediately
-void LwipSocket::Terminate()
+void LwipSocket::Terminate() noexcept
{
if (state != SocketState::disabled)
{
@@ -246,19 +246,19 @@ void LwipSocket::Terminate()
}
// Return true if there is or may soon be more data to read
-bool LwipSocket::CanRead() const
+bool LwipSocket::CanRead() const noexcept
{
return (state == SocketState::connected)
|| (state == SocketState::clientDisconnecting && receivedData != nullptr);
}
-bool LwipSocket::CanSend() const
+bool LwipSocket::CanSend() const noexcept
{
return (state == SocketState::connected);
}
// Read 1 character from the receive buffers, returning true if successful
-bool LwipSocket::ReadChar(char& c)
+bool LwipSocket::ReadChar(char& c) noexcept
{
if (receivedData != nullptr)
{
@@ -292,7 +292,7 @@ bool LwipSocket::ReadChar(char& c)
}
// Return a pointer to data in a buffer and a length available
-bool LwipSocket::ReadBuffer(const uint8_t *&buffer, size_t &len)
+bool LwipSocket::ReadBuffer(const uint8_t *&buffer, size_t &len) noexcept
{
if (receivedData != nullptr)
{
@@ -306,7 +306,7 @@ bool LwipSocket::ReadBuffer(const uint8_t *&buffer, size_t &len)
}
// Flag some data as taken from the receive buffers. We never take data from more than one buffer at a time.
-void LwipSocket::Taken(size_t len)
+void LwipSocket::Taken(size_t len) noexcept
{
if (receivedData != nullptr)
{
@@ -333,7 +333,7 @@ void LwipSocket::Taken(size_t len)
}
// Poll a socket to see if it needs to be serviced
-void LwipSocket::Poll()
+void LwipSocket::Poll() noexcept
{
switch (state)
{
@@ -399,7 +399,7 @@ void LwipSocket::Poll()
}
// Discard any received data for this transaction
-void LwipSocket::DiscardReceivedData()
+void LwipSocket::DiscardReceivedData() noexcept
{
if (receivedData != nullptr)
{
@@ -410,7 +410,7 @@ void LwipSocket::DiscardReceivedData()
}
// Send the data, returning the length buffered
-size_t LwipSocket::Send(const uint8_t *data, size_t length)
+size_t LwipSocket::Send(const uint8_t *data, size_t length) noexcept
{
#if LWIP_GMAC_TASK
MutexLocker lock(lwipMutex);
diff --git a/src/Networking/LwipEthernet/LwipSocket.h b/src/Networking/LwipEthernet/LwipSocket.h
index 5f9b1f0f..f2e9ef85 100644
--- a/src/Networking/LwipEthernet/LwipSocket.h
+++ b/src/Networking/LwipEthernet/LwipSocket.h
@@ -21,30 +21,30 @@ struct pbuf;
class LwipSocket : public Socket
{
public:
- LwipSocket(NetworkInterface *iface);
- int GetState() const { return (int)state; } // for debugging
+ LwipSocket(NetworkInterface *iface) noexcept;
+ int GetState() const noexcept { return (int)state; } // for debugging
// LwIP interfaces
- bool AcceptConnection(tcp_pcb *pcb);
- void DataReceived(pbuf *data);
- void DataSent(size_t numBytes);
- void ConnectionClosedGracefully();
- void ConnectionError(err_t err);
+ bool AcceptConnection(tcp_pcb *pcb) noexcept;
+ void DataReceived(pbuf *data) noexcept;
+ void DataSent(size_t numBytes) noexcept;
+ void ConnectionClosedGracefully() noexcept;
+ void ConnectionError(err_t err) noexcept;
// Inherited members of the Socket class
- void Init(SocketNumber s, Port serverPort, NetworkProtocol p);
- void TerminateAndDisable() override;
- void Poll() override;
- void Close() override;
- bool IsClosing() const { return (state == SocketState::closing); }
- void Terminate() override;
- bool ReadChar(char& c) override;
- bool ReadBuffer(const uint8_t *&buffer, size_t &len) override;
- void Taken(size_t len) override;
- bool CanRead() const override;
- bool CanSend() const override;
- size_t Send(const uint8_t *data, size_t length) override;
- void Send() override { }
+ void Init(SocketNumber s, Port serverPort, NetworkProtocol p) noexcept;
+ void TerminateAndDisable() noexcept override;
+ void Poll() noexcept override;
+ void Close() noexcept override;
+ bool IsClosing() const noexcept { return (state == SocketState::closing); }
+ void Terminate() noexcept override;
+ bool ReadChar(char& c) noexcept override;
+ bool ReadBuffer(const uint8_t *&buffer, size_t &len) noexcept override;
+ void Taken(size_t len) noexcept override;
+ bool CanRead() const noexcept override;
+ bool CanSend() const noexcept override;
+ size_t Send(const uint8_t *data, size_t length) noexcept override;
+ void Send() noexcept override { }
private:
enum class SocketState : uint8_t
@@ -58,8 +58,8 @@ private:
aborted
};
- void ReInit();
- void DiscardReceivedData();
+ void ReInit() noexcept;
+ void DiscardReceivedData() noexcept;
uint32_t whenConnected;
uint32_t whenWritten;
diff --git a/src/Platform.cpp b/src/Platform.cpp
index aaab5084..6a0791b2 100644
--- a/src/Platform.cpp
+++ b/src/Platform.cpp
@@ -1329,12 +1329,6 @@ void Platform::SoftwareReset(uint16_t reason, const uint32_t *stk) noexcept
{
reason |= (uint16_t)SoftwareResetReason::inUsbOutput; // if we are resetting because we are stuck in a Spin function, record whether we are trying to send to USB
}
-#if HAS_LWIP_NETWORKING
- if (reprap.GetNetwork().InNetworkStack())
- {
- reason |= (uint16_t)SoftwareResetReason::inLwipSpin;
- }
-#endif
#ifdef SERIAL_AUX_DEVICE
if (SERIAL_AUX_DEVICE.canWrite() == 0
diff --git a/src/RepRap.cpp b/src/RepRap.cpp
index 3377fa7e..d8acfd4d 100644
--- a/src/RepRap.cpp
+++ b/src/RepRap.cpp
@@ -2640,7 +2640,7 @@ void RepRap::ReportInternalError(const char *file, const char *func, int line) c
#if SUPPORT_12864_LCD
-const char *RepRap::GetLatestMessage(uint16_t& sequence) const
+const char *RepRap::GetLatestMessage(uint16_t& sequence) const noexcept
{
sequence = messageSequence;
return message.c_str();
diff --git a/src/SoftwareReset.h b/src/SoftwareReset.h
index 9af2f36b..29c47d91 100644
--- a/src/SoftwareReset.h
+++ b/src/SoftwareReset.h
@@ -38,7 +38,7 @@ enum class SoftwareResetReason : uint16_t
unusedBit = 0x0200, // spare bit
unused2 = 0x0400, // spare bit
inAuxOutput = 0x0800, // this bit is or'ed in if we were in aux output at the time
- inLwipSpin = 0x2000, // we got stuck in a call to LWIP for too long
+ unused_was_inLwipSpin = 0x2000, // no longer used
inUsbOutput = 0x4000, // this bit is or'ed in if we were in USB output at the time
deliberate = 0x8000 // this but it or'ed in if we deliberately caused a fault
};