diff options
author | David Crocker <dcrocker@eschertech.com> | 2019-12-16 11:31:39 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2019-12-16 11:31:39 +0300 |
commit | 2bf288f682b319b316598f4e4007fff9cda9745e (patch) | |
tree | 5a52752949f6e25c5f408d60e2fe6dd609ab1cdd | |
parent | a468ab379bcefffe908d8dda86febda5e91e460a (diff) | |
parent | d590ca63bbb00bdfe866ac0ffda23fd7bb68d214 (diff) |
Merge branch 'v3.01-dev' into v3-dev
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | src/Libraries/Fatfs/diskio.cpp | 12 | ||||
-rw-r--r-- | src/Libraries/Fatfs/diskio.h | 17 | ||||
-rw-r--r-- | src/Libraries/Fatfs/fattime_rtc.cpp | 2 | ||||
-rw-r--r-- | src/Libraries/Fatfs/ff.h | 5 | ||||
-rw-r--r-- | src/PortControl.cpp | 10 | ||||
-rw-r--r-- | src/PortControl.h | 10 | ||||
-rw-r--r-- | src/RepRapFirmware.cpp | 16 | ||||
-rw-r--r-- | src/RepRapFirmware.h | 72 | ||||
-rw-r--r-- | src/SoftwareReset.cpp | 4 | ||||
-rw-r--r-- | src/SoftwareReset.h | 4 |
11 files changed, 80 insertions, 73 deletions
@@ -20,3 +20,4 @@ /RADDS_RTOS/ /SAME70XPLD/ .settings/language.settings.xml +/Duet3_V06/ diff --git a/src/Libraries/Fatfs/diskio.cpp b/src/Libraries/Fatfs/diskio.cpp index df173b7d..84f5eb53 100644 --- a/src/Libraries/Fatfs/diskio.cpp +++ b/src/Libraries/Fatfs/diskio.cpp @@ -55,7 +55,7 @@ static unsigned int highestSdRetriesDone = 0; -unsigned int DiskioGetAndClearMaxRetryCount() +unsigned int DiskioGetAndClearMaxRetryCount() noexcept { const unsigned int ret = highestSdRetriesDone; highestSdRetriesDone = 0; @@ -95,7 +95,7 @@ unsigned int DiskioGetAndClearMaxRetryCount() * \return 0 or disk status in combination of DSTATUS bits * (STA_NOINIT, STA_PROTECT). */ -DSTATUS disk_initialize(BYTE drv) +DSTATUS disk_initialize(BYTE drv) noexcept { #if LUN_USB /* USB disk with multiple LUNs */ @@ -141,7 +141,7 @@ DSTATUS disk_initialize(BYTE drv) * \return 0 or disk status in combination of DSTATUS bits * (STA_NOINIT, STA_NODISK, STA_PROTECT). */ -DSTATUS disk_status(BYTE drv) +DSTATUS disk_status(BYTE drv) noexcept { MutexLocker lock((drv >= SD_MMC_HSMCI_MEM_CNT) ? Tasks::GetSpiMutex() : nullptr); @@ -165,7 +165,7 @@ DSTATUS disk_status(BYTE drv) * * \return RES_OK for success, otherwise DRESULT error code. */ -DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, BYTE count) +DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, BYTE count) noexcept { if (reprap.Debug(moduleStorage)) { @@ -233,7 +233,7 @@ DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, BYTE count) * \return RES_OK for success, otherwise DRESULT error code. */ #if _READONLY == 0 -DRESULT disk_write(BYTE drv, BYTE const *buff, DWORD sector, BYTE count) +DRESULT disk_write(BYTE drv, BYTE const *buff, DWORD sector, BYTE count) noexcept { if (reprap.Debug(moduleStorage)) { @@ -313,7 +313,7 @@ DRESULT disk_write(BYTE drv, BYTE const *buff, DWORD sector, BYTE count) * * \return RES_OK for success, otherwise DRESULT error code. */ -DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void *buff) +DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void *buff) noexcept { DRESULT res = RES_PARERR; diff --git a/src/Libraries/Fatfs/diskio.h b/src/Libraries/Fatfs/diskio.h index 43e5966c..a1ecc3b6 100644 --- a/src/Libraries/Fatfs/diskio.h +++ b/src/Libraries/Fatfs/diskio.h @@ -5,8 +5,11 @@ #ifndef _DISKIO #ifdef __cplusplus -unsigned int DiskioGetAndClearMaxRetryCount(); +unsigned int DiskioGetAndClearMaxRetryCount() noexcept; +# define NOEXCEPT noexcept extern "C" { +#else +# define NOEXCEPT #endif #define _READONLY 0 /* 1: Remove write functions */ @@ -31,14 +34,14 @@ typedef enum { /*---------------------------------------*/ /* Prototypes for disk control functions */ -int assign_drives (int, int); -DSTATUS disk_initialize (BYTE); -DSTATUS disk_status (BYTE); -DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); +int assign_drives (int, int) NOEXCEPT; +DSTATUS disk_initialize (BYTE) NOEXCEPT; +DSTATUS disk_status (BYTE) NOEXCEPT; +DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE) NOEXCEPT; #if _READONLY == 0 -DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); +DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE) NOEXCEPT; #endif -DRESULT disk_ioctl (BYTE, BYTE, void*); +DRESULT disk_ioctl (BYTE, BYTE, void*) NOEXCEPT; /* Disk Status Bits (DSTATUS) */ diff --git a/src/Libraries/Fatfs/fattime_rtc.cpp b/src/Libraries/Fatfs/fattime_rtc.cpp index 023c135c..b632385b 100644 --- a/src/Libraries/Fatfs/fattime_rtc.cpp +++ b/src/Libraries/Fatfs/fattime_rtc.cpp @@ -63,7 +63,7 @@ * * \return Current time. */ -extern "C" uint32_t get_fattime() +extern "C" uint32_t get_fattime() noexcept { const Platform& platform = reprap.GetPlatform(); if (!platform.IsDateTimeSet()) diff --git a/src/Libraries/Fatfs/ff.h b/src/Libraries/Fatfs/ff.h index 46e949b0..ccb4d6d0 100644 --- a/src/Libraries/Fatfs/ff.h +++ b/src/Libraries/Fatfs/ff.h @@ -23,7 +23,10 @@ #define FF_DEFINED 86604 /* Revision ID */ #ifdef __cplusplus +# define NOEXCEPT noexcept extern "C" { +#else +# define NOEXCEPT #endif #include "ffconf.h" /* FatFs configuration options */ @@ -348,7 +351,7 @@ static inline FSIZE_t f_size(const FIL *fp) /* RTC function */ #if !FF_FS_READONLY && !FF_FS_NORTC -DWORD get_fattime (void); +DWORD get_fattime (void) NOEXCEPT; #endif /* LFN support functions */ diff --git a/src/PortControl.cpp b/src/PortControl.cpp index 4a3c98fa..41d46a02 100644 --- a/src/PortControl.cpp +++ b/src/PortControl.cpp @@ -13,11 +13,11 @@ #if SUPPORT_IOBITS -PortControl::PortControl() +PortControl::PortControl() noexcept { } -void PortControl::Init() +void PortControl::Init() noexcept { numConfiguredPorts = 0; advanceMillis = 0; @@ -25,14 +25,14 @@ void PortControl::Init() currentPortState = 0; } -void PortControl::Exit() +void PortControl::Exit() noexcept { UpdatePorts(0); numConfiguredPorts = 0; } // Update the IO bits. Return the number of milliseconds before we need to be called again, or 0 to be called when movement restarts. -uint32_t PortControl::UpdatePorts() +uint32_t PortControl::UpdatePorts() noexcept { if (numConfiguredPorts == 0) { @@ -118,7 +118,7 @@ bool PortControl::Configure(GCodeBuffer& gb, const StringRef& reply) return false; } -void PortControl::UpdatePorts(IoBits_t newPortState) +void PortControl::UpdatePorts(IoBits_t newPortState) noexcept { if (newPortState != currentPortState) { diff --git a/src/PortControl.h b/src/PortControl.h index 039d538a..8ea23c3b 100644 --- a/src/PortControl.h +++ b/src/PortControl.h @@ -18,14 +18,14 @@ class GCodeBuffer; class PortControl { public: - PortControl(); - void Init(); - void Exit(); - uint32_t UpdatePorts(); + PortControl() noexcept; + void Init() noexcept; + void Exit() noexcept; + uint32_t UpdatePorts() noexcept; bool Configure(GCodeBuffer& gb, const StringRef& reply); private: - void UpdatePorts(IoBits_t newPortState); + void UpdatePorts(IoBits_t newPortState) noexcept; static const size_t MaxPorts = 16; // the port bitmap is currently a 16-bit word diff --git a/src/RepRapFirmware.cpp b/src/RepRapFirmware.cpp index 48cd1517..101a57f2 100644 --- a/src/RepRapFirmware.cpp +++ b/src/RepRapFirmware.cpp @@ -196,7 +196,7 @@ static const char * const moduleName[] = static_assert(ARRAY_SIZE(moduleName) == Module::numModules + 1); -const char *GetModuleName(uint8_t module) +const char *GetModuleName(uint8_t module) noexcept { return (module < ARRAY_SIZE(moduleName)) ? moduleName[module] : "unknown"; } @@ -204,20 +204,20 @@ const char *GetModuleName(uint8_t module) // class MillisTimer members // Start or restart the timer -void MillisTimer::Start() +void MillisTimer::Start() noexcept { whenStarted = millis(); running = true; } // Check whether the timer is running and a timeout has expired, but don't stop it -bool MillisTimer::Check(uint32_t timeoutMillis) const +bool MillisTimer::Check(uint32_t timeoutMillis) const noexcept { return running && millis() - whenStarted >= timeoutMillis; } // Check whether a timeout has expired and stop the timer if it has, else leave it running if it was running -bool MillisTimer::CheckAndStop(uint32_t timeoutMillis) +bool MillisTimer::CheckAndStop(uint32_t timeoutMillis) noexcept { const bool ret = Check(timeoutMillis); if (ret) @@ -232,7 +232,7 @@ bool MillisTimer::CheckAndStop(uint32_t timeoutMillis) // Utilities and storage not part of any class // For debug use -void debugPrintf(const char* fmt, ...) +void debugPrintf(const char* fmt, ...) noexcept { // Calls to debugPrintf() from with ISRs are unsafe, both because of timing issues and because the call to Platform::MessageF tries to acquire a mutex. // So ignore the call if we are coming from within an ISR. @@ -245,19 +245,19 @@ void debugPrintf(const char* fmt, ...) } } -void delay(uint32_t ms) +void delay(uint32_t ms) noexcept { vTaskDelay(ms); } // Convert a float to double for passing to printf etc. If it is a NaN or infinity, convert it to 9999.9 to avoid getting JSON parse errors. -double HideNan(float val) +double HideNan(float val) noexcept { return (double)((std::isnan(val) || std::isinf(val)) ? 9999.9 : val); } // Append a list of driver numbers to a string, with a space before each one -void ListDrivers(const StringRef& str, DriversBitmap drivers) +void ListDrivers(const StringRef& str, DriversBitmap drivers) noexcept { for (unsigned int d = 0; drivers != 0; ++d) { diff --git a/src/RepRapFirmware.h b/src/RepRapFirmware.h index e0b40680..e2d020ac 100644 --- a/src/RepRapFirmware.h +++ b/src/RepRapFirmware.h @@ -107,59 +107,59 @@ struct DriverId CanAddress boardAddress; - void SetFromBinary(uint32_t val) + void SetFromBinary(uint32_t val) noexcept { localDriver = val & 0x000000FF; const uint32_t brdNum = val >> 16; boardAddress = (brdNum <= CanId::MaxNormalAddress) ? (CanAddress)brdNum : CanId::NoAddress; } - void SetLocal(unsigned int driver) + void SetLocal(unsigned int driver) noexcept { localDriver = (uint8_t)driver; boardAddress = CanId::MasterAddress; } - void Clear() + void Clear() noexcept { localDriver = 0; boardAddress = CanId::NoAddress; } - bool IsLocal() const { return boardAddress == CanId::MasterAddress; } - bool IsRemote() const { return boardAddress != CanId::MasterAddress; } + bool IsLocal() const noexcept { return boardAddress == CanId::MasterAddress; } + bool IsRemote() const noexcept { return boardAddress != CanId::MasterAddress; } - bool operator<(const DriverId other) const + bool operator<(const DriverId other) const noexcept { return boardAddress < other.boardAddress || (boardAddress == other.boardAddress && localDriver < other.localDriver); } - bool operator==(const DriverId other) const + bool operator==(const DriverId other) const noexcept { return boardAddress == other.boardAddress && localDriver == other.localDriver; } - bool operator!=(const DriverId other) const + bool operator!=(const DriverId other) const noexcept { return boardAddress != other.boardAddress || localDriver != other.localDriver; } #else - void SetFromBinary(uint32_t val) + void SetFromBinary(uint32_t val) noexcept { localDriver = (uint8_t)val; } - void SetLocal(unsigned int driver) + void SetLocal(unsigned int driver) noexcept { localDriver = (uint8_t)driver; } - void Clear() { localDriver = 0; } + void Clear() noexcept { localDriver = 0; } - bool IsLocal() const { return true; } - bool IsRemote() const { return false; } + bool IsLocal() const noexcept { return true; } + bool IsRemote() const noexcept { return false; } #endif }; @@ -197,7 +197,7 @@ enum Module : uint8_t noModule = numModules }; -const char *GetModuleName(uint8_t module); +const char *GetModuleName(uint8_t module) noexcept; // Warn of what's to come, so we can use pointers and references to classes without including the entire header files class Network; @@ -288,15 +288,15 @@ union LaserPwmOrIoBits #endif // Debugging support -extern "C" void debugPrintf(const char* fmt, ...) __attribute__ ((format (printf, 1, 2))); +extern "C" void debugPrintf(const char* fmt, ...) noexcept __attribute__ ((format (printf, 1, 2))); #define DEBUG_HERE do { debugPrintf("At " __FILE__ " line %d\n", __LINE__); delay(50); } while (false) // Functions and globals not part of any class -void delay(uint32_t ms); +void delay(uint32_t ms) noexcept; -double HideNan(float val); +double HideNan(float val) noexcept; -void ListDrivers(const StringRef& str, DriversBitmap drivers); +void ListDrivers(const StringRef& str, DriversBitmap drivers) noexcept; // Macro to assign an array from an initialiser list #define ARRAY_INIT(_dest, _init) static_assert(sizeof(_dest) == sizeof(_init), "Incompatible array types"); memcpy(_dest, _init, sizeof(_init)); @@ -307,7 +307,7 @@ void ListDrivers(const StringRef& str, DriversBitmap drivers); // Functions to change the base priority, to shut out interrupts up to a priority level // Get the base priority and shut out interrupts lower than or equal to a specified priority -inline uint32_t ChangeBasePriority(uint32_t prio) +inline uint32_t ChangeBasePriority(uint32_t prio) noexcept { const uint32_t oldPrio = __get_BASEPRI(); __set_BASEPRI_MAX(prio << (8 - __NVIC_PRIO_BITS)); @@ -315,13 +315,13 @@ inline uint32_t ChangeBasePriority(uint32_t prio) } // Restore the base priority following a call to ChangeBasePriority -inline void RestoreBasePriority(uint32_t prio) +inline void RestoreBasePriority(uint32_t prio) noexcept { __set_BASEPRI(prio); } // Set the base priority when we are not interested in the existing value i.e. definitely in non-interrupt code -inline void SetBasePriority(uint32_t prio) +inline void SetBasePriority(uint32_t prio) noexcept { __set_BASEPRI(prio << (8 - __NVIC_PRIO_BITS)); } @@ -330,10 +330,10 @@ inline void SetBasePriority(uint32_t prio) template<class T> class SimpleRangeIterator { public: - SimpleRangeIterator(T value_) : val(value_) {} - bool operator != (SimpleRangeIterator<T> const& other) const { return val != other.val; } - T const& operator*() const { return val; } - SimpleRangeIterator& operator++() { ++val; return *this; } + SimpleRangeIterator(T value_) noexcept : val(value_) {} + bool operator != (SimpleRangeIterator<T> const& other) const noexcept { return val != other.val; } + T const& operator*() const noexcept { return val; } + SimpleRangeIterator& operator++() noexcept { ++val; return *this; } private: T val; @@ -342,9 +342,9 @@ private: template<class T> class SimpleRange { public: - SimpleRange(T limit) : _end(limit) {} - SimpleRangeIterator<T> begin() const { return SimpleRangeIterator<T>(0); } - SimpleRangeIterator<T> end() const { return SimpleRangeIterator<T>(_end); } + SimpleRange(T limit) noexcept : _end(limit) {} + SimpleRangeIterator<T> begin() const noexcept { return SimpleRangeIterator<T>(0); } + SimpleRangeIterator<T> end() const noexcept { return SimpleRangeIterator<T>(_end); } private: const T _end; @@ -357,12 +357,12 @@ private: class MillisTimer { public: - MillisTimer() { running = false; } - void Start(); - void Stop() { running = false; } - bool Check(uint32_t timeoutMillis) const; - bool CheckAndStop(uint32_t timeoutMillis); - bool IsRunning() const { return running; } + MillisTimer() noexcept { running = false; } + void Start() noexcept; + void Stop() noexcept { running = false; } + bool Check(uint32_t timeoutMillis) const noexcept; + bool CheckAndStop(uint32_t timeoutMillis) noexcept; + bool IsRunning() const noexcept { return running; } private: uint32_t whenStarted; @@ -391,8 +391,8 @@ constexpr size_t MaxTotalDrivers = NumDirectDrivers; // Convert between extruder drive numbers and logical drive numbers. // In order to save memory when MaxAxesPlusExtruders < MaxAxes + MaxExtruders, the logical drive number of an axis is the same as the axis number, // but the logical drive number of an extruder is MaxAxesPlusExtruders - 1 - extruder_number. -inline size_t ExtruderToLogicalDrive(size_t extruder) { return MaxAxesPlusExtruders - 1 - extruder; } -inline size_t LogicalDriveToExtruder(size_t drive) { return MaxAxesPlusExtruders - 1 - drive; } +inline size_t ExtruderToLogicalDrive(size_t extruder) noexcept { return MaxAxesPlusExtruders - 1 - extruder; } +inline size_t LogicalDriveToExtruder(size_t drive) noexcept { return MaxAxesPlusExtruders - 1 - drive; } constexpr AxesBitmap DefaultXAxisMapping = MakeBitmap<AxesBitmap>(X_AXIS); // by default, X is mapped to X constexpr AxesBitmap DefaultYAxisMapping = MakeBitmap<AxesBitmap>(Y_AXIS); // by default, Y is mapped to Y diff --git a/src/SoftwareReset.cpp b/src/SoftwareReset.cpp index 39256642..11263f67 100644 --- a/src/SoftwareReset.cpp +++ b/src/SoftwareReset.cpp @@ -34,7 +34,7 @@ const char *const SoftwareResetData::ReasonText[] = uint8_t SoftwareResetData::extraDebugInfo; // extra info for debugging // Return true if this struct can be written without erasing it first -bool SoftwareResetData::isVacant() const +bool SoftwareResetData::isVacant() const noexcept { const uint32_t *p = reinterpret_cast<const uint32_t*>(this); for (size_t i = 0; i < sizeof(*this)/sizeof(uint32_t); ++i) @@ -49,7 +49,7 @@ bool SoftwareResetData::isVacant() const } // Populate this reset data from the parameters passed and the CPU state -void SoftwareResetData::Populate(uint16_t reason, uint32_t time, const uint32_t *stk) +void SoftwareResetData::Populate(uint16_t reason, uint32_t time, const uint32_t *stk) noexcept { magic = SoftwareResetData::magicValue; resetReason = reason | ((extraDebugInfo & 0x07) << 5); diff --git a/src/SoftwareReset.h b/src/SoftwareReset.h index 29c47d91..d53ed3c1 100644 --- a/src/SoftwareReset.h +++ b/src/SoftwareReset.h @@ -67,8 +67,8 @@ struct SoftwareResetData uint32_t taskName; // first 4 bytes of the task name uint32_t stack[23]; // stack when the exception occurred, with the program counter at the bottom - bool isVacant() const; // return true if this struct can be written without erasing it first - void Populate(uint16_t reason, uint32_t time, const uint32_t *stk); + bool isVacant() const noexcept; // return true if this struct can be written without erasing it first + void Populate(uint16_t reason, uint32_t time, const uint32_t *stk) noexcept; static const uint16_t versionValue = 8; // increment this whenever this struct changes static const uint16_t magicValue = 0x7D00 | versionValue; // value we use to recognise that all the flash data has been written |