From 1f578f76ea2d42e51ed7d440568370e6f36e60b7 Mon Sep 17 00:00:00 2001 From: David Crocker Date: Mon, 30 Nov 2020 16:14:29 +0000 Subject: Reworked use of optimisation attributes --- src/Comms/PanelDueUpdater.cpp | 6 ++++-- src/Comms/PanelDueUpdater.h | 4 ++-- src/GCodes/GCodeBuffer/BinaryParser.h | 10 +++++----- src/GCodes/GCodeBuffer/GCodeBuffer.h | 10 +++++----- src/GCodes/GCodeBuffer/StringParser.h | 12 ++++++------ src/GCodes/GCodes.h | 2 +- src/Movement/DDA.cpp | 3 --- src/Movement/DDA.h | 18 +++++++++--------- src/Movement/DDARing.h | 12 ++++++------ src/Movement/DriveMovement.h | 14 +++++++------- src/Movement/Move.h | 2 +- src/Movement/StepTimer.cpp | 2 +- src/Movement/StepTimer.h | 10 +++++----- src/Movement/StepperDrivers/TMC22xx.cpp | 18 +++++++++--------- src/Movement/StepperDrivers/TMC2660.cpp | 8 ++++---- src/Platform.h | 2 +- src/RepRapFirmware.h | 2 ++ 17 files changed, 68 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/Comms/PanelDueUpdater.cpp b/src/Comms/PanelDueUpdater.cpp index f6ee6893..23f5ef30 100644 --- a/src/Comms/PanelDueUpdater.cpp +++ b/src/Comms/PanelDueUpdater.cpp @@ -249,9 +249,9 @@ void PanelDueUpdater::Spin() noexcept auto auxPort = GetAuxPort(); auxPort->SetInterruptCallback(currentInterruptCallbackFn); currentInterruptCallbackFn = nullptr; - #if ALLOW_OTHER_AUX +#if ALLOW_OTHER_AUX serialChannel = NumSerialChannels+1; - #endif +#endif currentBaudRate = 0; // Delete all objects we new'd @@ -300,3 +300,5 @@ UARTClass* PanelDueUpdater::GetAuxPort() noexcept #endif &SERIAL_AUX_DEVICE; } + +// End diff --git a/src/Comms/PanelDueUpdater.h b/src/Comms/PanelDueUpdater.h index a75bf20e..6ce72f66 100644 --- a/src/Comms/PanelDueUpdater.h +++ b/src/Comms/PanelDueUpdater.h @@ -21,8 +21,8 @@ constexpr size_t RequiredBaudRate = 115200; -constexpr const char * const panelDueCommandEraseAndReset = "{\"controlCommand\":\"eraseAndReset\"}\n"; -constexpr const char * const panelDueCommandReset = "{\"controlCommand\":\"reset\"}\n"; +constexpr const char * panelDueCommandEraseAndReset = "{\"controlCommand\":\"eraseAndReset\"}\n"; +constexpr const char * panelDueCommandReset = "{\"controlCommand\":\"reset\"}\n"; constexpr uint32_t WaitMsAfterEraseAndReset = 1000; // How long to wait in ms after eraseAndReset diff --git a/src/GCodes/GCodeBuffer/BinaryParser.h b/src/GCodes/GCodeBuffer/BinaryParser.h index 6948381b..2f480388 100644 --- a/src/GCodes/GCodeBuffer/BinaryParser.h +++ b/src/GCodes/GCodeBuffer/BinaryParser.h @@ -27,7 +27,7 @@ public: void Init() noexcept; // Set it up to parse another G-code void Put(const uint32_t *data, size_t len) noexcept; // Add an entire binary code, overwriting any existing content void DecodeCommand() noexcept; // Print the buffer content in debug mode and prepare for execution - bool Seen(char c) noexcept __attribute__((hot)); // Is a character present? + bool Seen(char c) noexcept SPEED_CRITICAL; // Is a character present? char GetCommandLetter() const noexcept; bool HasCommandNumber() const noexcept; @@ -35,8 +35,8 @@ public: int8_t GetCommandFraction() const noexcept; bool ContainsExpression() const noexcept; - float GetFValue() THROWS(GCodeException) __attribute__((hot)); // Get a float after a key letter - int32_t GetIValue() THROWS(GCodeException) __attribute__((hot)); // Get an integer after a key letter + float GetFValue() THROWS(GCodeException) SPEED_CRITICAL; // Get a float after a key letter + int32_t GetIValue() THROWS(GCodeException) SPEED_CRITICAL; // Get an integer after a key letter uint32_t GetUIValue() THROWS(GCodeException); // Get an unsigned integer value DriverId GetDriverId() THROWS(GCodeException); // Get a driver ID void GetIPAddress(IPAddress& returnedIp) THROWS(GCodeException); // Get an IP address quad after a key letter @@ -46,7 +46,7 @@ public: void GetQuotedString(const StringRef& str) THROWS(GCodeException); // Get and copy a quoted string void GetPossiblyQuotedString(const StringRef& str, bool allowEmpty = false) THROWS(GCodeException); // Get and copy a string which may or may not be quoted void GetReducedString(const StringRef& str) THROWS(GCodeException); // Get and copy a quoted string, removing certain characters - void GetFloatArray(float arr[], size_t& length, bool doPad) THROWS(GCodeException) __attribute__((hot)); // Get a colon-separated list of floats after a key letter + void GetFloatArray(float arr[], size_t& length, bool doPad) THROWS(GCodeException) SPEED_CRITICAL; // Get a colon-separated list of floats after a key letter void GetIntArray(int32_t arr[], size_t& length, bool doPad) THROWS(GCodeException); // Get a :-separated list of ints after a key letter void GetUnsignedArray(uint32_t arr[], size_t& length, bool doPad) THROWS(GCodeException); // Get a :-separated list of unsigned ints after a key letter void GetDriverIdArray(DriverId arr[], size_t& length) THROWS(GCodeException); // Get a :-separated list of drivers after a key letter @@ -71,7 +71,7 @@ private: GCodeException ConstructParseException(const char *str, uint32_t param) const noexcept; size_t AddPadding(size_t bytesRead) const noexcept { return (bytesRead + 3u) & (~3u); } - template void GetArray(T arr[], size_t& length, bool doPad) THROWS(GCodeException) __attribute__((hot)); + template void GetArray(T arr[], size_t& length, bool doPad) THROWS(GCodeException) SPEED_CRITICAL; void WriteParameters(const StringRef& s, bool quoteStrings) const noexcept; size_t bufferLength; diff --git a/src/GCodes/GCodeBuffer/GCodeBuffer.h b/src/GCodes/GCodeBuffer/GCodeBuffer.h index 83d7fb79..99b9ce81 100644 --- a/src/GCodes/GCodeBuffer/GCodeBuffer.h +++ b/src/GCodes/GCodeBuffer/GCodeBuffer.h @@ -49,7 +49,7 @@ public: void Init() noexcept; // Set it up to parse another G-code void Diagnostics(MessageType mtype) noexcept; // Write some debug info - bool Put(char c) noexcept __attribute__((hot)); // Add a character to the end + bool Put(char c) noexcept SPEED_CRITICAL; // Add a character to the end #if HAS_LINUX_INTERFACE void PutBinary(const uint32_t *data, size_t len) noexcept; // Add an entire binary G-Code, overwriting any existing content #endif @@ -71,12 +71,12 @@ public: GCodeResult GetLastResult() const noexcept { return lastResult; } void SetLastResult(GCodeResult r) noexcept { lastResult = r; } - bool Seen(char c) noexcept __attribute__((hot)); // Is a character present? + bool Seen(char c) noexcept SPEED_CRITICAL; // Is a character present? void MustSee(char c) THROWS(GCodeException); // Test for character present, throw error if not - float GetFValue() THROWS(GCodeException) __attribute__((hot)); // Get a float after a key letter + float GetFValue() THROWS(GCodeException) SPEED_CRITICAL; // Get a float after a key letter float GetDistance() THROWS(GCodeException); // Get a distance or coordinate and convert it from inches to mm if necessary - int32_t GetIValue() THROWS(GCodeException) __attribute__((hot)); // Get an integer after a key letter + int32_t GetIValue() THROWS(GCodeException) SPEED_CRITICAL; // Get an integer after a key letter int32_t GetLimitedIValue(char c, int32_t minValue, int32_t maxValue) THROWS(GCodeException) post(minValue <= result; result <= maxValue); // Get an integer after a key letter uint32_t GetUIValue() THROWS(GCodeException); // Get an unsigned integer value @@ -92,7 +92,7 @@ public: void GetQuotedString(const StringRef& str) THROWS(GCodeException); // Get and copy a quoted string void GetPossiblyQuotedString(const StringRef& str) THROWS(GCodeException); // Get and copy a string which may or may not be quoted void GetReducedString(const StringRef& str) THROWS(GCodeException); // Get and copy a quoted string, removing certain characters - void GetFloatArray(float arr[], size_t& length, bool doPad) THROWS(GCodeException) __attribute__((hot)); // Get a colon-separated list of floats after a key letter + void GetFloatArray(float arr[], size_t& length, bool doPad) THROWS(GCodeException) SPEED_CRITICAL; // Get a colon-separated list of floats after a key letter void GetIntArray(int32_t arr[], size_t& length, bool doPad) THROWS(GCodeException); // Get a :-separated list of ints after a key letter void GetUnsignedArray(uint32_t arr[], size_t& length, bool doPad) THROWS(GCodeException); // Get a :-separated list of unsigned ints after a key letter void GetDriverIdArray(DriverId arr[], size_t& length) THROWS(GCodeException); // Get a :-separated list of drivers after a key letter diff --git a/src/GCodes/GCodeBuffer/StringParser.h b/src/GCodes/GCodeBuffer/StringParser.h index 958cf6c5..28045528 100644 --- a/src/GCodes/GCodeBuffer/StringParser.h +++ b/src/GCodes/GCodeBuffer/StringParser.h @@ -27,7 +27,7 @@ public: StringParser(GCodeBuffer& gcodeBuffer) noexcept; void Init() noexcept; // Set it up to parse another G-code void Diagnostics(MessageType mtype) noexcept; // Write some debug info - bool Put(char c) noexcept __attribute__((hot)); // Add a character to the end + bool Put(char c) noexcept SPEED_CRITICAL; // Add a character to the end void PutCommand(const char *str) noexcept; // Put a complete command but don't decode it void DecodeCommand() noexcept; // Decode the next command in the line void PutAndDecode(const char *str, size_t len) noexcept; // Add an entire string, overwriting any existing content @@ -44,10 +44,10 @@ public: bool IsLastCommand() const noexcept; bool ContainsExpression() const noexcept { return seenExpression; } - bool Seen(char c) noexcept __attribute__((hot)); // Is a character present? - float GetFValue() THROWS(GCodeException) __attribute__((hot)); // Get a float after a key letter - float GetDistance() THROWS(GCodeException); // Get a distance or coordinate and convert it from inches to mm if necessary - int32_t GetIValue() THROWS(GCodeException) __attribute__((hot)); // Get an integer after a key letter + bool Seen(char c) noexcept SPEED_CRITICAL; // Is a character present? + float GetFValue() THROWS(GCodeException) SPEED_CRITICAL; // Get a float after a key letter + float GetDistance() THROWS(GCodeException) SPEED_CRITICAL; // Get a distance or coordinate and convert it from inches to mm if necessary + int32_t GetIValue() THROWS(GCodeException) SPEED_CRITICAL; // Get an integer after a key letter uint32_t GetUIValue() THROWS(GCodeException); // Get an unsigned integer value DriverId GetDriverId() THROWS(GCodeException); // Get a driver ID void GetIPAddress(IPAddress& returnedIp) THROWS(GCodeException); // Get an IP address quad after a key letter @@ -57,7 +57,7 @@ public: void GetQuotedString(const StringRef& str, bool allowEmpty = false) THROWS(GCodeException); // Get and copy a quoted string void GetPossiblyQuotedString(const StringRef& str, bool allowEmpty = false) THROWS(GCodeException); // Get and copy a string which may or may not be quoted void GetReducedString(const StringRef& str) THROWS(GCodeException); // Get and copy a quoted string, removing certain characters - void GetFloatArray(float arr[], size_t& length, bool doPad) THROWS(GCodeException) __attribute__((hot)); // Get a colon-separated list of floats after a key letter + void GetFloatArray(float arr[], size_t& length, bool doPad) THROWS(GCodeException) SPEED_CRITICAL; // Get a colon-separated list of floats after a key letter void GetIntArray(int32_t arr[], size_t& length, bool doPad) THROWS(GCodeException); // Get a :-separated list of ints after a key letter void GetUnsignedArray(uint32_t arr[], size_t& length, bool doPad) THROWS(GCodeException); // Get a :-separated list of unsigned ints after a key letter void GetDriverIdArray(DriverId arr[], size_t& length) THROWS(GCodeException); // Get a :-separated list of drivers after a key letter diff --git a/src/GCodes/GCodes.h b/src/GCodes/GCodes.h index 38683584..b459876b 100644 --- a/src/GCodes/GCodes.h +++ b/src/GCodes/GCodes.h @@ -332,7 +332,7 @@ private: void HandleReply(GCodeBuffer& gb, OutputBuffer *reply) noexcept; void HandleReplyPreserveResult(GCodeBuffer& gb, GCodeResult rslt, const char *reply) noexcept; // Handle G-Code replies - bool DoStraightMove(GCodeBuffer& gb, bool isCoordinated, const char *& err) __attribute__((hot)); // Execute a straight move + bool DoStraightMove(GCodeBuffer& gb, bool isCoordinated, const char *& err) SPEED_CRITICAL; // Execute a straight move bool DoArcMove(GCodeBuffer& gb, bool clockwise, const char *& err) // Execute an arc move pre(segmentsLeft == 0; resourceOwners[MoveResource] == &gb); void FinaliseMove(GCodeBuffer& gb) noexcept; // Adjust the move parameters to account for segmentation and/or part of the move having been done already diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp index f26f08ce..5c61a1ef 100644 --- a/src/Movement/DDA.cpp +++ b/src/Movement/DDA.cpp @@ -1789,9 +1789,6 @@ void DDA::CheckEndstops(Platform& platform) noexcept #endif } -// The remaining functions are speed-critical, so use full optimisation -// The GCC optimize pragma appears to be broken, if we try to force O3 optimisation here then functions are never inlined - // Start executing this move. Must be called with interrupts disabled or basepri >= set interrupt priority, to avoid a race condition. void DDA::Start(Platform& p, uint32_t tim) noexcept pre(state == frozen) diff --git a/src/Movement/DDA.h b/src/Movement/DDA.h index c178d0a9..1098be67 100644 --- a/src/Movement/DDA.h +++ b/src/Movement/DDA.h @@ -39,21 +39,21 @@ public: DDA(DDA* n) noexcept; - bool InitStandardMove(DDARing& ring, const RawMove &nextMove, bool doMotorMapping) noexcept __attribute__ ((hot)); // Set up a new move, returning true if it represents real movement + bool InitStandardMove(DDARing& ring, const RawMove &nextMove, bool doMotorMapping) noexcept SPEED_CRITICAL; // Set up a new move, returning true if it represents real movement bool InitLeadscrewMove(DDARing& ring, float feedrate, const float amounts[MaxDriversPerAxis]) noexcept; // Set up a leadscrew motor move #if SUPPORT_ASYNC_MOVES bool InitAsyncMove(DDARing& ring, const AsyncMove& nextMove) noexcept; // Set up an async move #endif - void Start(Platform& p, uint32_t tim) noexcept __attribute__ ((hot)); // Start executing the DDA, i.e. move the move. - void StepDrivers(Platform& p) noexcept __attribute__ ((hot)); // Take one step of the DDA, called by timed interrupt. - bool ScheduleNextStepInterrupt(StepTimer& timer) const noexcept; // Schedule the next interrupt, returning true if we can't because it is already due + void Start(Platform& p, uint32_t tim) noexcept SPEED_CRITICAL; // Start executing the DDA, i.e. move the move. + void StepDrivers(Platform& p) noexcept SPEED_CRITICAL; // Take one step of the DDA, called by timed interrupt. + bool ScheduleNextStepInterrupt(StepTimer& timer) const noexcept SPEED_CRITICAL; // Schedule the next interrupt, returning true if we can't because it is already due void SetNext(DDA *n) noexcept { next = n; } void SetPrevious(DDA *p) noexcept { prev = p; } void Complete() noexcept { state = completed; } bool Free() noexcept; - void Prepare(uint8_t simMode, float extrusionPending[]) noexcept __attribute__ ((hot)); // Calculate all the values and freeze this DDA + void Prepare(uint8_t simMode, float extrusionPending[]) noexcept SPEED_CRITICAL; // Calculate all the values and freeze this DDA bool HasStepError() const noexcept; bool CanPauseAfter() const noexcept; bool IsPrintingMove() const noexcept { return flags.isPrintingMove; } // Return true if this involves both XY movement and extrusion @@ -170,11 +170,11 @@ public: private: DriveMovement *FindDM(size_t drive) const noexcept; // find the DM for a drive if there is one even if it is completed DriveMovement *FindActiveDM(size_t drive) const noexcept; // find the DM for a drive if there is one but only if it is active - void RecalculateMove(DDARing& ring) noexcept __attribute__ ((hot)); - void MatchSpeeds() noexcept __attribute__ ((hot)); + void RecalculateMove(DDARing& ring) noexcept SPEED_CRITICAL; + void MatchSpeeds() noexcept SPEED_CRITICAL; void ReduceHomingSpeed() noexcept; // called to reduce homing speed when a near-endstop is triggered void StopDrive(size_t drive) noexcept; // stop movement of a drive and recalculate the endpoint - void InsertDM(DriveMovement *dm) noexcept __attribute__ ((hot)); + void InsertDM(DriveMovement *dm) noexcept SPEED_CRITICAL; void DeactivateDM(size_t drive) noexcept; void ReleaseDMs() noexcept; bool IsDecelerationMove() const noexcept; // return true if this move is or have been might have been intended to be a deceleration-only move @@ -186,7 +186,7 @@ private: int32_t PrepareRemoteExtruder(size_t drive, float& extrusionPending, float speedChange) const noexcept; #endif - static void DoLookahead(DDARing& ring, DDA *laDDA) noexcept __attribute__ ((hot)); // Try to smooth out moves in the queue + static void DoLookahead(DDARing& ring, DDA *laDDA) noexcept SPEED_CRITICAL; // Try to smooth out moves in the queue static float Normalise(float v[], AxesBitmap unitLengthAxes) noexcept; // Normalise a vector to unit length over the specified axes static float Normalise(float v[]) noexcept; // Normalise a vector to unit length over all axes float NormaliseLinearMotion(AxesBitmap linearAxes) noexcept; // Make the direction vector unit-normal in XYZ diff --git a/src/Movement/DDARing.h b/src/Movement/DDARing.h index 44bc9ad2..35cf3f15 100644 --- a/src/Movement/DDARing.h +++ b/src/Movement/DDARing.h @@ -23,21 +23,21 @@ public: void RecycleDDAs() noexcept; bool CanAddMove() const noexcept; - bool AddStandardMove(const RawMove &nextMove, bool doMotorMapping) noexcept __attribute__ ((hot)); // Set up a new move, returning true if it represents real movement + bool AddStandardMove(const RawMove &nextMove, bool doMotorMapping) noexcept SPEED_CRITICAL; // Set up a new move, returning true if it represents real movement bool AddSpecialMove(float feedRate, const float coords[MaxDriversPerAxis]) noexcept; #if SUPPORT_ASYNC_MOVES bool AddAsyncMove(const AsyncMove& nextMove) noexcept; #endif - void Spin(uint8_t simulationMode, bool shouldStartMove) noexcept; // Try to process moves in the ring + void Spin(uint8_t simulationMode, bool shouldStartMove) noexcept SPEED_CRITICAL; // Try to process moves in the ring bool IsIdle() const noexcept; // Return true if this DDA ring is idle float PushBabyStepping(size_t axis, float amount) noexcept; // Try to push some babystepping through the lookahead queue, returning the amount pushed - void Interrupt(Platform& p) noexcept; // Check endstops, generate step pulses + void Interrupt(Platform& p) noexcept SPEED_CRITICAL; // Check endstops, generate step pulses void OnMoveCompleted(DDA *cdda, Platform& p) noexcept; // called when the state has been set to 'completed' - bool ScheduleNextStepInterrupt() noexcept; // Schedule the next step interrupt, returning true if we failed because it is due immediately - void CurrentMoveCompleted() noexcept __attribute__ ((hot)); // Signal that the current move has just been completed + bool ScheduleNextStepInterrupt() noexcept SPEED_CRITICAL; // Schedule the next step interrupt, returning true if we failed because it is due immediately + void CurrentMoveCompleted() noexcept SPEED_CRITICAL; // Signal that the current move has just been completed uint32_t ExtruderPrintingSince() const noexcept { return extrudersPrintingSince; } // When we started doing normal moves after the most recent extruder-only move int32_t GetAccumulatedExtrusion(size_t extruder, size_t drive, bool& isPrinting) noexcept; @@ -84,7 +84,7 @@ public: bool SetWaitingToEmpty() noexcept; private: - bool StartNextMove(Platform& p, uint32_t startTime) noexcept __attribute__ ((hot)); // Start the next move, returning true if laser or IObits need to be controlled + bool StartNextMove(Platform& p, uint32_t startTime) noexcept SPEED_CRITICAL; // Start the next move, returning true if laser or IObits need to be controlled void PrepareMoves(DDA *firstUnpreparedMove, int32_t moveTimeLeft, unsigned int alreadyPrepared, uint8_t simulationMode) noexcept; static void TimerCallback(CallbackParameter p) noexcept; diff --git a/src/Movement/DriveMovement.h b/src/Movement/DriveMovement.h index 242f8a52..3fa3b336 100644 --- a/src/Movement/DriveMovement.h +++ b/src/Movement/DriveMovement.h @@ -134,11 +134,11 @@ public: DriveMovement(DriveMovement *next) noexcept; - bool CalcNextStepTimeCartesian(const DDA &dda, bool live) noexcept __attribute__ ((hot)); - bool CalcNextStepTimeDelta(const DDA &dda, bool live) noexcept __attribute__ ((hot)); - bool PrepareCartesianAxis(const DDA& dda, const PrepParams& params) noexcept __attribute__ ((hot)); - bool PrepareDeltaAxis(const DDA& dda, const PrepParams& params) noexcept __attribute__ ((hot)); - bool PrepareExtruder(const DDA& dda, const PrepParams& params, float& extrusionPending, float speedChange, bool doCompensation) noexcept __attribute__ ((hot)); + bool CalcNextStepTimeCartesian(const DDA &dda, bool live) noexcept SPEED_CRITICAL; + bool CalcNextStepTimeDelta(const DDA &dda, bool live) noexcept SPEED_CRITICAL; + bool PrepareCartesianAxis(const DDA& dda, const PrepParams& params) noexcept SPEED_CRITICAL; + bool PrepareDeltaAxis(const DDA& dda, const PrepParams& params) noexcept SPEED_CRITICAL; + bool PrepareExtruder(const DDA& dda, const PrepParams& params, float& extrusionPending, float speedChange, bool doCompensation) noexcept SPEED_CRITICAL; void ReduceSpeed(uint32_t inverseSpeedFactor) noexcept; void DebugPrint() const noexcept; int32_t GetNetStepsLeft() const noexcept; @@ -160,8 +160,8 @@ public: static void Release(DriveMovement *item) noexcept; private: - bool CalcNextStepTimeCartesianFull(const DDA &dda, bool live) noexcept __attribute__ ((hot)); - bool CalcNextStepTimeDeltaFull(const DDA &dda, bool live) noexcept __attribute__ ((hot)); + bool CalcNextStepTimeCartesianFull(const DDA &dda, bool live) noexcept SPEED_CRITICAL; + bool CalcNextStepTimeDeltaFull(const DDA &dda, bool live) noexcept SPEED_CRITICAL; static DriveMovement *freeList; static int numFree; diff --git a/src/Movement/Move.h b/src/Movement/Move.h index 11f9efcc..70a3e167 100644 --- a/src/Movement/Move.h +++ b/src/Movement/Move.h @@ -64,7 +64,7 @@ public: int32_t GetEndPoint(size_t drive) const noexcept; // Get the current position of a motor float LiveCoordinate(unsigned int axisOrExtruder, const Tool *tool) noexcept; // Gives the last point at the end of the last complete DDA bool WaitingForAllMovesFinished() noexcept; // Tell the lookahead ring we are waiting for it to empty and return true if it is - void DoLookAhead() noexcept __attribute__ ((hot)); // Run the look-ahead procedure + void DoLookAhead() noexcept SPEED_CRITICAL; // Run the look-ahead procedure void SetNewPosition(const float positionNow[MaxAxesPlusExtruders], bool doBedCompensation) noexcept; // Set the current position to be this void SetLiveCoordinates(const float coords[MaxAxesPlusExtruders]) noexcept; // Force the live coordinates (see above) to be these void ResetExtruderPositions() noexcept; // Resets the extrusion amounts of the live coordinates diff --git a/src/Movement/StepTimer.cpp b/src/Movement/StepTimer.cpp index 8f4a8b77..f77e68be 100644 --- a/src/Movement/StepTimer.cpp +++ b/src/Movement/StepTimer.cpp @@ -217,7 +217,7 @@ void StepTimer::DisableTimerInterrupt() noexcept } // Step pulse timer interrupt -extern "C" void STEP_TC_HANDLER() noexcept __attribute__ ((hot)); +extern "C" void STEP_TC_HANDLER() noexcept SPEED_CRITICAL; void STEP_TC_HANDLER() noexcept { diff --git a/src/Movement/StepTimer.h b/src/Movement/StepTimer.h index d72adcbc..5b0a7849 100644 --- a/src/Movement/StepTimer.h +++ b/src/Movement/StepTimer.h @@ -27,19 +27,19 @@ public: void SetCallback(TimerCallbackFunction cb, CallbackParameter param) noexcept; // Schedule a callback at a particular tick count, returning true if it was not scheduled because it is already due or imminent - bool ScheduleCallback(Ticks when) noexcept; + bool ScheduleCallback(Ticks when) noexcept SPEED_CRITICAL; // As ScheduleCallback but base priority >= NvicPriorityStep when called. Can be called from within a callback. - bool ScheduleCallbackFromIsr(Ticks when) noexcept; + bool ScheduleCallbackFromIsr(Ticks when) noexcept SPEED_CRITICAL; // Check whether a callback really is due, schedule it if not. Returns true if it really is due. Can be called from within a callback. - bool ScheduleCallbackFromIsr() noexcept; + bool ScheduleCallbackFromIsr() noexcept SPEED_CRITICAL; // Cancel any scheduled callbacks void CancelCallback() noexcept; // As CancelCallback but base priority >= NvicPriorityStep when called - void CancelCallbackFromIsr() noexcept; + void CancelCallbackFromIsr() noexcept SPEED_CRITICAL; // Initialise the timer system static void Init() noexcept; @@ -48,7 +48,7 @@ public: static void DisableTimerInterrupt() noexcept; // Get the current tick count - static Ticks GetTimerTicks() noexcept __attribute__ ((hot)); + static Ticks GetTimerTicks() noexcept SPEED_CRITICAL; // Get the current tick count when we only need a 16-bit value. Faster than GetTimerTicks() on the SAM4S and SAME70. static uint16_t GetTimerTicks16() noexcept; diff --git a/src/Movement/StepperDrivers/TMC22xx.cpp b/src/Movement/StepperDrivers/TMC22xx.cpp index e39879e1..957dcbe8 100644 --- a/src/Movement/StepperDrivers/TMC22xx.cpp +++ b/src/Movement/StepperDrivers/TMC22xx.cpp @@ -469,8 +469,8 @@ public: bool DriverAssumedPresent() const noexcept { return numWrites != 0 || numTimeouts < DriverNotPresentTimeouts; } - 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 TransferDone() noexcept SPEED_CRITICAL; // called by the ISR when the SPI transfer has completed + void StartTransfer() noexcept SPEED_CRITICAL; // called to start a transfer void TransferTimedOut() noexcept { if (DriverAssumedPresent()) @@ -526,11 +526,11 @@ private: void SetUartMux() noexcept; #endif #if (TMC22xx_HAS_MUX || TMC22xx_SINGLE_DRIVER) && !TMC22xx_USE_SLAVEADDR - static void SetupDMASend(uint8_t regnum, uint32_t outVal) noexcept __attribute__ ((hot)); // set up the DMAC to send a register - static void SetupDMARead(uint8_t regnum, uint8_t crc) noexcept __attribute__ ((hot)); // set up the DMAC to receive a register + static void SetupDMASend(uint8_t regnum, uint32_t outVal) noexcept SPEED_CRITICAL; // set up the DMAC to send a register + static void SetupDMARead(uint8_t regnum, uint8_t crc) noexcept SPEED_CRITICAL; // set up the DMAC to receive a register #else - void SetupDMASend(uint8_t regnum, uint32_t outVal) noexcept __attribute__ ((hot)); // set up the DMAC to send a register - void SetupDMARead(uint8_t regnum) noexcept __attribute__ ((hot)); // set up the DMAC to receive a register + void SetupDMASend(uint8_t regnum, uint32_t outVal) noexcept SPEED_CRITICAL; // set up the DMAC to send a register + void SetupDMARead(uint8_t regnum) noexcept SPEED_CRITICAL; // set up the DMAC to receive a register #endif #if HAS_STALL_DETECT @@ -1555,7 +1555,7 @@ void TransferCompleteCallback(CallbackParameter, DmaCallbackReason reason) noexc # endif // ISR for the single UART -extern "C" void TMC22xx_UART_Handler() noexcept __attribute__ ((hot)); +extern "C" void TMC22xx_UART_Handler() noexcept SPEED_CRITICAL; void TMC22xx_UART_Handler() noexcept { @@ -1569,13 +1569,13 @@ void TMC22xx_UART_Handler() noexcept #else // ISRs for the individual UARTs -extern "C" void UART_TMC_DRV0_Handler() noexcept __attribute__ ((hot)); +extern "C" void UART_TMC_DRV0_Handler() noexcept SPEED_CRITICAL; void UART_TMC_DRV0_Handler() noexcept { driverStates[0].UartTmcHandler(); } -extern "C" void UART_TMC_DRV1_Handler() noexcept __attribute__ ((hot)); +extern "C" void UART_TMC_DRV1_Handler() noexcept SPEED_CRITICAL; void UART_TMC_DRV1_Handler() noexcept { driverStates[1].UartTmcHandler(); diff --git a/src/Movement/StepperDrivers/TMC2660.cpp b/src/Movement/StepperDrivers/TMC2660.cpp index 7c0f8034..bc672b50 100644 --- a/src/Movement/StepperDrivers/TMC2660.cpp +++ b/src/Movement/StepperDrivers/TMC2660.cpp @@ -226,8 +226,8 @@ public: 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 + void TransferDone() noexcept SPEED_CRITICAL; // called by the ISR when the SPI transfer has completed + void StartTransfer() noexcept SPEED_CRITICAL; // called to start a transfer uint32_t ReadLiveStatus() const noexcept; uint32_t ReadAccumulatedStatus(uint32_t bitsToKeep) noexcept; @@ -244,7 +244,7 @@ private: maxSgLoadRegister = 0; } - static void SetupDMA(uint32_t outVal) noexcept __attribute__ ((hot)); // set up the PDC to send a register and receive the status + static void SetupDMA(uint32_t outVal) noexcept SPEED_CRITICAL; // 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 @@ -849,7 +849,7 @@ inline void TmcDriverState::StartTransfer() noexcept # error TMC handler name not defined #endif -extern "C" void TMC2660_SPI_Handler(void) noexcept __attribute__ ((hot)); +extern "C" void TMC2660_SPI_Handler(void) noexcept SPEED_CRITICAL; void TMC2660_SPI_Handler(void) noexcept { diff --git a/src/Platform.h b/src/Platform.h index 42cebe3a..1b0d53e1 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -357,7 +357,7 @@ public: const MacAddress& GetDefaultMacAddress() const noexcept { return defaultMacAddress; } // Timing - void Tick() noexcept __attribute__((hot)); // Process a systick interrupt + void Tick() noexcept SPEED_CRITICAL; // Process a systick interrupt // Real-time clock bool IsDateTimeSet() const noexcept { return realTime != 0; } // Has the RTC been set yet? diff --git a/src/RepRapFirmware.h b/src/RepRapFirmware.h index e83c98e0..c54e5fb0 100644 --- a/src/RepRapFirmware.h +++ b/src/RepRapFirmware.h @@ -98,6 +98,8 @@ inline void memcpyf(float *dst, const float *src, size_t numFloats) noexcept #endif +#define SPEED_CRITICAL __attribute__((optimize("O2"))) + // API level definition. // ApiLevel 1 is the first level that supports rr_model. constexpr unsigned int ApiLevel = 1; -- cgit v1.2.3