diff options
Diffstat (limited to 'src/Platform.h')
-rw-r--r-- | src/Platform.h | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/src/Platform.h b/src/Platform.h index a5e4425b..773ec33f 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -49,7 +49,6 @@ Licence: GPL #include "Storage/MassStorage.h" // must be after Pins.h because it needs NumSdCards defined #include "MessageType.h" #include "ZProbeProgrammer.h" -#include "Logger.h" #if defined(DUET_NG) # include "DueXn.h" @@ -107,7 +106,7 @@ const uint32_t Z_PROBE_AXES = (1 << Z_AXIS); // Axes for which the Z-probe i // HEATERS - The bed is assumed to be the at index 0 -// Define the number of temperature readings we average for each thermistor. This should be a power of 2 and at least 4 ** AD_OVERSAMPLE_BITS. +// Define the number of temperature readings we average for each thermistor. This should be a power of 2 and at least 4 ^ AD_OVERSAMPLE_BITS. // Keep THERMISTOR_AVERAGE_READINGS * NUM_HEATERS * 2ms no greater than HEAT_SAMPLE_TIME or the PIDs won't work well. const unsigned int ThermistorAverageReadings = 32; @@ -394,7 +393,7 @@ public: void SetDirection(size_t drive, bool direction); void SetDirectionValue(size_t driver, bool dVal); bool GetDirectionValue(size_t driver) const; - void SetEnableValue(size_t driver, bool eVal); + void SetEnableValue(size_t driver, int8_t eVal); bool GetEnableValue(size_t driver) const; void EnableDriver(size_t driver); void DisableDriver(size_t driver); @@ -436,9 +435,9 @@ public: void SetInstantDv(size_t drive, float value); EndStopHit Stopped(size_t drive) const; float AxisMaximum(size_t axis) const; - void SetAxisMaximum(size_t axis, float value); + void SetAxisMaximum(size_t axis, float value, bool byProbing); float AxisMinimum(size_t axis) const; - void SetAxisMinimum(size_t axis, float value); + void SetAxisMinimum(size_t axis, float value, bool byProbing); float AxisTotalLength(size_t axis) const; float GetPressureAdvance(size_t drive) const; void SetPressureAdvance(size_t extruder, float factor); @@ -481,7 +480,7 @@ public: const ZProbeParameters& GetCurrentZProbeParameters() const { return GetZProbeParameters(zProbeType); } void SetZProbeParameters(int32_t probeType, const struct ZProbeParameters& params); bool HomingZWithProbe() const; - bool WriteZProbeParameters(FileStore *f) const; + bool WritePlatformParameters(FileStore *f) const; void SetProbing(bool isProbing); bool ProgramZProbe(GCodeBuffer& gb, StringRef& reply); void SetZProbeModState(bool b) const; @@ -537,16 +536,23 @@ public: // MCU temperature #if HAS_CPU_TEMP_SENSOR void GetMcuTemperatures(float& minT, float& currT, float& maxT) const; -#endif void SetMcuTemperatureAdjust(float v) { mcuTemperatureAdjust = v; } float GetMcuTemperatureAdjust() const { return mcuTemperatureAdjust; } +#endif -#ifdef DUET_NG +#if HAS_VOLTAGE_MONITOR // Power in voltage void GetPowerVoltages(float& minV, float& currV, float& maxV) const; + bool IsPowerOk() const; + void DisableAutoSave(); + void EnableAutoSave(float saveVoltage, float resumeVoltage); + bool GetAutoSaveSettings(float& saveVoltage, float&resumeVoltage); +#endif + +#if HAS_SMART_DRIVERS float GetTmcDriversTemperature(unsigned int board) const; void DriverCoolingFansOn(uint32_t driverChannelsMonitored); - bool ConfigureAutoSave(GCodeBuffer& gb, StringRef& reply); + bool ConfigureStallDetection(GCodeBuffer& gb, StringRef& reply); #endif // User I/O and servo support @@ -582,6 +588,8 @@ public: void SetLaserPwmFrequency(float freq); float GetLaserPwmFrequency() const { return laserPort.GetFrequency(); } + static uint8_t softwareResetDebugInfo; // extra info for debugging + //------------------------------------------------------------------------------------------------------- private: @@ -592,8 +600,8 @@ private: void ResetChannel(size_t chan); // re-initialise a serial channel float AdcReadingToCpuTemperature(uint32_t reading) const; -#ifdef DUET_NG - void ReportDrivers(uint16_t whichDrivers, const char* text, bool& reported); +#if HAS_SMART_DRIVERS + void ReportDrivers(DriversBitmap whichDrivers, const char* text, bool& reported); #endif // These are the structures used to hold our non-volatile data. @@ -640,7 +648,7 @@ private: } }; -#if SAM4E +#if SAM4E || SAM4S static_assert(SoftwareResetData::numberOfSlots * sizeof(SoftwareResetData) <= 512, "Can't fit software reset data in SAM4E user signature area"); #else static_assert(SoftwareResetData::numberOfSlots * sizeof(SoftwareResetData) <= FLASH_DATA_LENGTH, "NVData too large"); @@ -648,7 +656,6 @@ private: // Logging Logger *logger; - uint32_t lastLogFlushTime; // Z probes ZProbeParameters switchZProbeParameters; // Z probe values for the switch Z-probe @@ -687,7 +694,7 @@ private: volatile DriverStatus driverState[DRIVES]; bool directions[DRIVES]; - bool enableValues[DRIVES]; + int8_t enableValues[DRIVES]; Pin endStopPins[DRIVES]; float maxFeedrates[DRIVES]; float accelerations[DRIVES]; @@ -705,9 +712,12 @@ private: uint32_t slowDrivers; // bitmap of driver port bits that need extended step pulse timing float idleCurrentFactor; -#if defined(DUET_NG) - size_t numTMC2660Drivers; // the number of TMC2660 drivers we have, the remaining are simple enable/step/dir drivers -#elif defined(DUET_06_085) +#if HAS_SMART_DRIVERS + size_t numSmartDrivers; // the number of TMC2660 drivers we have, the remaining are simple enable/step/dir drivers + DriversBitmap pauseOnStallDrivers, rehomeOnStallDrivers; +#endif + +#if defined(DUET_06_085) // Digipots MCP4461 mcpDuet; MCP4461 mcpExpansion; @@ -743,9 +753,12 @@ private: float axisMaxima[MaxAxes]; float axisMinima[MaxAxes]; + AxesBitmap axisMinimaProbed, axisMaximaProbed; EndStopType endStopType[MaxAxes]; bool endStopLogicLevel[MaxAxes]; - + + static bool WriteAxisLimits(FileStore *f, AxesBitmap axesProbed, const float limits[MaxAxes], int sParam); + // Heaters - bed is assumed to be the first Pin tempSensePins[Heaters]; @@ -828,36 +841,38 @@ private: #if HAS_CPU_TEMP_SENSOR // reading temperature on the RADDS messes up one of the heater pins, so don't do it AnalogChannelNumber temperatureAdcChannel; uint32_t highestMcuTemperature, lowestMcuTemperature; -#endif float mcuTemperatureAdjust; +#endif -#ifdef DUET_NG +#if HAS_VOLTAGE_MONITOR AnalogChannelNumber vInMonitorAdcChannel; volatile uint16_t currentVin, highestVin, lowestVin; uint32_t numUnderVoltageEvents; volatile uint32_t numOverVoltageEvents; - uint32_t lastWarningMillis; // When we last sent a warning message about a Vssa short - uint16_t temperatureShutdownDrivers, temperatureWarningDrivers, shortToGroundDrivers, openLoadDrivers; - uint8_t nextDriveToPoll; - bool driversPowered; - bool vssaSenseWorking; - bool onBoardDriversFanRunning; // true if a fan is running to cool the on-board drivers - bool offBoardDriversFanRunning; // true if a fan is running to cool the drivers on the DueX - uint32_t onBoardDriversFanStartMillis; // how many times we have suppressed a temperature warning - uint32_t offBoardDriversFanStartMillis; // how many times we have suppressed a temperature warning - uint16_t autoShutdownReading, autoPauseReading, autoResumeReading; bool autoSaveEnabled; enum class AutoSaveState : uint8_t { starting = 0, normal, - autoPaused, - autoShutdown + autoPaused }; AutoSaveState autoSaveState; #endif +#if HAS_SMART_DRIVERS + uint32_t lastWarningMillis; // When we last sent a warning message about a Vssa short + DriversBitmap temperatureShutdownDrivers, temperatureWarningDrivers, shortToGroundDrivers, openLoadDrivers; + uint8_t nextDriveToPoll; + bool driversPowered; + bool vssaSenseWorking; + bool onBoardDriversFanRunning; // true if a fan is running to cool the on-board drivers + bool offBoardDriversFanRunning; // true if a fan is running to cool the drivers on the DueX + uint32_t onBoardDriversFanStartMillis; // how many times we have suppressed a temperature warning + uint32_t offBoardDriversFanStartMillis; // how many times we have suppressed a temperature warning + uint16_t autoPauseReading, autoResumeReading; +#endif + // RTC time_t realTime; // the current date/time, or zero if never set uint32_t timeLastUpdatedMillis; // the milliseconds counter when we last incremented the time @@ -977,12 +992,6 @@ inline void Platform::SetDriverDirection(uint8_t driver, bool direction) digitalWrite(DIRECTION_PINS[driver], d); } -inline void Platform::SetEnableValue(size_t driver, bool eVal) -{ - enableValues[driver] = eVal; - DisableDriver(driver); // disable the drive, because the enable polarity may have been wrong before -} - inline bool Platform::GetEnableValue(size_t driver) const { return enableValues[driver]; @@ -993,21 +1002,11 @@ inline float Platform::AxisMaximum(size_t axis) const return axisMaxima[axis]; } -inline void Platform::SetAxisMaximum(size_t axis, float value) -{ - axisMaxima[axis] = value; -} - inline float Platform::AxisMinimum(size_t axis) const { return axisMinima[axis]; } -inline void Platform::SetAxisMinimum(size_t axis, float value) -{ - axisMinima[axis] = value; -} - inline float Platform::AxisTotalLength(size_t axis) const { return axisMaxima[axis] - axisMinima[axis]; @@ -1177,7 +1176,7 @@ inline OutputBuffer *Platform::GetAuxGCodeReply() return temp; } -// *** These next two functions must use the same bit assignments in the drivers bitmap *** +// *** These next three functions must use the same bit assignments in the drivers bitmap *** // The bitmaps are organised like this: // Duet WiFi: // All step pins are on port D, so the bitmap is just the map of bits in port D. @@ -1188,6 +1187,8 @@ inline OutputBuffer *Platform::GetAuxGCodeReply() // RADDS: // Step pins are PA2,9,12,15 PB16,19 PC3,12 PD6 // PC12 clashes with PA12 so we shift PC3,12 left one bit +// Alligator: +// Pins on ports B,C,D are used but the bit numbers are all different, so we use their actual positions // Calculate the step bit for a driver. This doesn't need to be fast. /*static*/ inline uint32_t Platform::CalcDriverBitmap(size_t driver) |