├── .cproject ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── BugReport.yml │ ├── FeatureRequest.yml │ └── config.yml └── workflows │ ├── deploy.yml │ ├── issues.yml │ ├── prerelease.yml │ └── release.yml ├── .gitignore ├── .project ├── .settings ├── org.eclipse.cdt.codan.core.prefs ├── org.eclipse.cdt.core.prefs ├── org.eclipse.cdt.managedbuilder.core.prefs ├── org.eclipse.core.resources.prefs └── org.eclipse.core.runtime.prefs ├── AddingNewKinematics.md ├── BuildInstructions.md ├── Developer-documentation ├── Movement in RepRapFirmware.odt ├── New ESP8266 WiFi module code for Duet WiFi.odt ├── OpenAPI.yaml ├── S-curve equations.wxmx └── S-curve move planning.odt ├── Driver ├── DuetDriverFiles.zip ├── README.md ├── duet.inf └── duetinf.cat ├── HTTP requests.md ├── JSON responses.md ├── LICENCE ├── Maths ├── BedLevelling-2-point.wxm ├── BedLevelling-3-point.wxm ├── BedLevelling-4-point.wxm ├── DeltaMaths.txt ├── ExtruderStepMaths.odt ├── closestPointOfApproach2d.wxmx ├── closestPointOfApproach3d.wxmx ├── delta.wxmx ├── trilateration-triple.wxmx └── trilateration.wxmx ├── PccbEmbeddedFiles └── sys │ ├── config.g │ ├── config1 │ ├── config.g │ ├── homeall.g │ └── homez.g │ └── config2 │ ├── config.g │ ├── homeall.g │ └── homez.g ├── README.md ├── Scripts ├── DriverSigning │ └── signdriver.bat └── OpenOCD │ ├── duet3_openocd.cfg │ └── duet3_openocd_memtest.cfg ├── Tools ├── CrcAppender │ ├── linux-x86_64 │ │ └── CrcAppender │ ├── macos-x86_64 │ │ └── CrcAppender │ └── win-x86-64 │ │ └── CrcAppender.exe ├── Windows │ ├── bossac.exe │ └── listComPorts.exe ├── stackanalyzer │ ├── README.md │ ├── go.mod │ ├── linux │ │ └── stackanalyzer │ ├── macos │ │ └── stackanalyzer │ ├── stackanalyzer.go │ └── win │ │ └── stackanalyzer.exe └── uf2conv │ ├── uf2conv.py │ └── uf2families.json ├── WHATS_NEW.md ├── WHATS_NEW_RRF3.md └── src ├── Accelerometers ├── Accelerometers.cpp ├── Accelerometers.h ├── LISAccelerometer.cpp └── LISAccelerometer.h ├── AppNotifyIndices.h ├── BugList.txt ├── CAN ├── CanDriversData.cpp ├── CanDriversData.h ├── CanInterface.cpp ├── CanInterface.h ├── CanMessageGenericConstructor.cpp ├── CanMessageGenericConstructor.h ├── CanMotion.cpp ├── CanMotion.h ├── CommandProcessor.cpp ├── CommandProcessor.h ├── ExpansionManager.cpp └── ExpansionManager.h ├── ClosedLoop ├── ClosedLoop.cpp └── ClosedLoop.h ├── Comms ├── AuxDevice.cpp ├── AuxDevice.h ├── FirmwareUpdater.cpp ├── FirmwareUpdater.h ├── Modbus.h ├── PanelDueUpdater.cpp └── PanelDueUpdater.h ├── Config ├── Configuration.h ├── Pins.cpp ├── Pins.h ├── Pins_Duet3Mini.h ├── Pins_Duet3_MB6HC.h ├── Pins_Duet3_MB6XD.h ├── Pins_DuetNG.h ├── Pins_FMDC.h └── Pins_Pccb.h ├── Display ├── ButtonMenuItem.cpp ├── ButtonMenuItem.h ├── Display.cpp ├── Display.h ├── DisplayOrientation.h ├── FilesMenuItem.cpp ├── FilesMenuItem.h ├── ImageMenuItem.cpp ├── ImageMenuItem.h ├── Lcd │ ├── Fonts │ │ ├── ER3301_1.cpp │ │ ├── ER3301_1.h │ │ ├── LcdFont.h │ │ ├── glcd11x14.cpp │ │ ├── glcd19x21.cpp │ │ ├── glcd28x32.cpp │ │ └── glcd7x11.cpp │ ├── ILI9488 │ │ ├── ILI9488.cpp │ │ └── ILI9488.h │ ├── Lcd.cpp │ ├── Lcd.h │ ├── MonoLcd.cpp │ ├── MonoLcd.h │ ├── ST7567 │ │ ├── Lcd7567.cpp │ │ └── Lcd7567.h │ ├── ST7920 │ │ ├── Lcd7920.cpp │ │ └── Lcd7920.h │ ├── TFTLcd.cpp │ └── TFTLcd.h ├── Menu.cpp ├── Menu.h ├── MenuItem.cpp ├── MenuItem.h ├── ResistiveTouch.cpp ├── ResistiveTouch.h ├── RotaryEncoder.cpp ├── RotaryEncoder.h ├── TextMenuItem.cpp ├── TextMenuItem.h ├── ValueMenuItem.cpp └── ValueMenuItem.h ├── DuetNG ├── DueXn.cpp ├── DueXn.h ├── SX1509.cpp ├── SX1509.h └── SX1509Registers.h ├── Endstops ├── Endstop.cpp ├── Endstop.h ├── EndstopDefs.h ├── EndstopsManager.cpp ├── EndstopsManager.h ├── LocalZProbe.cpp ├── LocalZProbe.h ├── RemoteZProbe.cpp ├── RemoteZProbe.h ├── StallDetectionEndstop.cpp ├── StallDetectionEndstop.h ├── SwitchEndstop.cpp ├── SwitchEndstop.h ├── ZProbe.cpp ├── ZProbe.h ├── ZProbeEndstop.cpp └── ZProbeEndstop.h ├── Fans ├── Fan.cpp ├── Fan.h ├── FansManager.cpp ├── FansManager.h ├── LocalFan.cpp ├── LocalFan.h ├── RemoteFan.cpp └── RemoteFan.h ├── FilamentMonitors ├── Duet3DFilamentMonitor.cpp ├── Duet3DFilamentMonitor.h ├── FilamentMonitor.cpp ├── FilamentMonitor.h ├── LaserFilamentMonitor.cpp ├── LaserFilamentMonitor.h ├── PulsedFilamentMonitor.cpp ├── PulsedFilamentMonitor.h ├── RotatingMagnetFilamentMonitor.cpp ├── RotatingMagnetFilamentMonitor.h ├── SimpleFilamentMonitor.cpp └── SimpleFilamentMonitor.h ├── GCodes ├── CollisionAvoider.cpp ├── CollisionAvoider.h ├── GCodeBuffer │ ├── BinaryParser.cpp │ ├── BinaryParser.h │ ├── ExpressionParser.cpp │ ├── ExpressionParser.h │ ├── GCodeBuffer.cpp │ ├── GCodeBuffer.h │ ├── StringParser.cpp │ └── StringParser.h ├── GCodeChannel.h ├── GCodeException.cpp ├── GCodeException.h ├── GCodeFileInfo.cpp ├── GCodeFileInfo.h ├── GCodeInput.cpp ├── GCodeInput.h ├── GCodeMachineState.cpp ├── GCodeMachineState.h ├── GCodeQueue.cpp ├── GCodeQueue.h ├── GCodes.cpp ├── GCodes.h ├── GCodes2.cpp ├── GCodes3.cpp ├── GCodes4.cpp ├── GCodes5.cpp ├── GCodes6.cpp ├── GCodes7.cpp ├── KeepoutZone.cpp ├── KeepoutZone.h ├── ObjectTracker.cpp ├── ObjectTracker.h ├── RestorePoint.cpp ├── RestorePoint.h ├── SimulationMode.h ├── StraightProbeSettings.cpp ├── StraightProbeSettings.h ├── TriggerItem.cpp └── TriggerItem.h ├── GPIO ├── GpInPort.cpp ├── GpInPort.h ├── GpOutPort.cpp └── GpOutPort.h ├── Hardware ├── ExceptionHandlers.cpp ├── ExceptionHandlers.h ├── I2C.cpp ├── I2C.h ├── IoPorts.cpp ├── IoPorts.h ├── NonVolatileMemory.cpp ├── NonVolatileMemory.h ├── SAM4E │ ├── Devices.cpp │ ├── Devices.h │ ├── Main.cpp │ ├── PinDescription.h │ └── sam4e8e_flash.ld ├── SAM4S │ ├── Devices.cpp │ ├── Devices.h │ ├── Main.cpp │ ├── PinDescription.h │ └── sam4s8c_flash.ld ├── SAME5x │ ├── Devices.cpp │ ├── Devices.h │ ├── Ethernet │ │ ├── GmacInterface.cpp │ │ ├── GmacInterface.h │ │ ├── conf_eth.h │ │ ├── gmac.h │ │ ├── gmac_phy.c │ │ └── ksz8081rna │ │ │ ├── ethernet_phy.c │ │ │ └── ethernet_phy.h │ ├── Main.cpp │ ├── PinDescription.h │ ├── same51n19a_flash.ld │ ├── same51n19a_flash_16k_bootloader.ld │ ├── same54p20a_flash.ld │ └── same54p20a_flash_16k_bootloader.ld ├── SAME70 │ ├── Devices.cpp │ ├── Devices.h │ ├── Ethernet │ │ ├── GmacInterface.cpp │ │ ├── GmacInterface.h │ │ └── ksz8081rna │ │ │ ├── ethernet_phy.c │ │ │ └── ethernet_phy.h │ ├── Main.cpp │ ├── PinDescription.h │ └── same70q20b_flash.ld ├── SoftwareReset.cpp ├── SoftwareReset.h └── Spi │ ├── SharedSpiClient.cpp │ ├── SharedSpiClient.h │ ├── SharedSpiDevice.cpp │ ├── SharedSpiDevice.h │ ├── SpiDevice.cpp │ ├── SpiDevice.h │ └── SpiMode.h ├── Heating ├── FOPDT.cpp ├── FOPDT.h ├── Heat.cpp ├── Heat.h ├── Heater.cpp ├── Heater.h ├── HeaterMonitor.cpp ├── HeaterMonitor.h ├── LocalHeater.cpp ├── LocalHeater.h ├── RemoteHeater.cpp ├── RemoteHeater.h └── Sensors │ ├── AdcSensorADS131A02.cpp │ ├── AdcSensorADS131A02.h │ ├── AdditionalOutputSensor.cpp │ ├── AdditionalOutputSensor.h │ ├── BME280.cpp │ ├── BME280.h │ ├── CpuTemperatureSensor.cpp │ ├── CpuTemperatureSensor.h │ ├── CurrentLoopTemperatureSensor.cpp │ ├── CurrentLoopTemperatureSensor.h │ ├── DhtSensor.cpp │ ├── DhtSensor.h │ ├── LinearAnalogSensor.cpp │ ├── LinearAnalogSensor.h │ ├── RemoteSensor.cpp │ ├── RemoteSensor.h │ ├── RtdSensor31865.cpp │ ├── RtdSensor31865.h │ ├── SensorWithPort.cpp │ ├── SensorWithPort.h │ ├── SpiTemperatureSensor.cpp │ ├── SpiTemperatureSensor.h │ ├── TemperatureSensor.cpp │ ├── TemperatureSensor.h │ ├── Thermistor.cpp │ ├── Thermistor.h │ ├── ThermocoupleSensor31855.cpp │ ├── ThermocoupleSensor31855.h │ ├── ThermocoupleSensor31856.cpp │ ├── ThermocoupleSensor31856.h │ ├── TmcDriverTemperatureSensor.cpp │ ├── TmcDriverTemperatureSensor.h │ └── bme280_defs.h ├── InputMonitors ├── InputMonitor.cpp └── InputMonitor.h ├── LedStrips ├── DotStarLedStrip.cpp ├── DotStarLedStrip.h ├── LedStripBase.cpp ├── LedStripBase.h ├── LedStripManager.cpp ├── LedStripManager.h ├── LocalLedStrip.cpp ├── LocalLedStrip.h ├── NeoPixelLedStrip.cpp ├── NeoPixelLedStrip.h ├── RemoteLedStrip.cpp └── RemoteLedStrip.h ├── Libraries ├── .gitignore ├── Fatfs │ ├── diskio.cpp │ ├── diskio.h │ ├── fattime_rtc.cpp │ ├── ff.c │ ├── ff.h │ ├── ffconf.h │ └── ffunicode.c ├── sd_mmc │ ├── conf_sd_mmc.h │ ├── ctrl_access.cpp │ ├── ctrl_access.h │ ├── sd_mmc.cpp │ ├── sd_mmc.h │ ├── sd_mmc_mem.cpp │ ├── sd_mmc_mem.h │ ├── sd_mmc_protocol.h │ ├── sd_mmc_spi.cpp │ └── sd_mmc_spi.h └── sha1 │ ├── sha1.c │ └── sha1.h ├── Memory usage.ods ├── Movement ├── Axis and drive allocation and release.md ├── AxisShaper.cpp ├── AxisShaper.h ├── BedProbing │ ├── Grid.cpp │ ├── Grid.h │ ├── RandomProbePointSet.cpp │ └── RandomProbePointSet.h ├── Coordinate and endpoint management.ods ├── DDA.cpp ├── DDA.h ├── DDARing.cpp ├── DDARing.h ├── DriveMovement.cpp ├── DriveMovement.h ├── ExtruderShaper.cpp ├── ExtruderShaper.h ├── HeightControl │ ├── HeightController.cpp │ └── HeightController.h ├── HomingMode.h ├── Kinematics │ ├── CoreKinematics.cpp │ ├── CoreKinematics.h │ ├── FiveBarScaraKinematics.cpp │ ├── FiveBarScaraKinematics.h │ ├── HangprinterKinematics.cpp │ ├── HangprinterKinematics.h │ ├── Kinematics.cpp │ ├── Kinematics.h │ ├── LinearDeltaKinematics.cpp │ ├── LinearDeltaKinematics.h │ ├── PolarKinematics.cpp │ ├── PolarKinematics.h │ ├── RotaryDeltaKinematics.cpp │ ├── RotaryDeltaKinematics.h │ ├── RoundBedKinematics.cpp │ ├── RoundBedKinematics.h │ ├── ScaraKinematics.cpp │ ├── ScaraKinematics.h │ ├── ZLeadscrewKinematics.cpp │ └── ZLeadscrewKinematics.h ├── Move.cpp ├── Move.h ├── Move2.cpp ├── Move3.cpp ├── MoveDebugFlags.h ├── MoveSegment.cpp ├── MoveSegment.h ├── MoveTiming.h ├── MovementError.cpp ├── MovementError.h ├── PhaseStep.cpp ├── PhaseStep.h ├── RawMove.cpp ├── RawMove.h ├── StepTimer.cpp ├── StepTimer.h ├── StepperDrivers │ ├── DriverData.cpp │ ├── DriverData.h │ ├── DriverMode.cpp │ ├── DriverMode.h │ ├── SmartDrivers.h │ ├── TMC22xx.cpp │ ├── TMC22xx.h │ ├── TMC2660.cpp │ ├── TMC2660.h │ ├── TMC51xx.cpp │ └── TMC51xx.h └── Trigonometry.h ├── Networking ├── ESP8266WiFi │ ├── WiFiInterface.cpp │ ├── WiFiInterface.h │ ├── WiFiSocket.cpp │ ├── WiFiSocket.h │ ├── WifiFirmwareUploader.cpp │ └── WifiFirmwareUploader.h ├── FtpResponder.cpp ├── FtpResponder.h ├── HttpResponder.cpp ├── HttpResponder.h ├── LwipEthernet │ ├── AllocateFromPbufPool.h │ ├── GMAC │ │ ├── ethernet_sam.cpp │ │ └── ethernet_sam.h │ ├── Lwip │ │ ├── CHANGELOG │ │ ├── CMakeLists.txt │ │ ├── COPYING │ │ ├── FEATURES │ │ ├── FILES │ │ ├── README │ │ ├── UPGRADING │ │ ├── doc │ │ │ ├── FILES │ │ │ ├── NO_SYS_SampleCode.c │ │ │ ├── ZeroCopyRx.c │ │ │ ├── contrib.txt │ │ │ ├── mdns.txt │ │ │ ├── mqtt_client.txt │ │ │ ├── ppp.txt │ │ │ └── savannah.txt │ │ ├── lwipopts.h │ │ └── src │ │ │ ├── FILES │ │ │ ├── Filelists.cmake │ │ │ ├── Filelists.mk │ │ │ ├── api │ │ │ ├── api_lib.c │ │ │ ├── api_msg.c │ │ │ ├── err.c │ │ │ ├── if_api.c │ │ │ ├── netbuf.c │ │ │ ├── netdb.c │ │ │ ├── netifapi.c │ │ │ ├── sockets.c │ │ │ └── tcpip.c │ │ │ ├── apps │ │ │ ├── altcp_tls │ │ │ │ ├── altcp_tls_mbedtls.c │ │ │ │ ├── altcp_tls_mbedtls_mem.c │ │ │ │ ├── altcp_tls_mbedtls_mem.h │ │ │ │ └── altcp_tls_mbedtls_structs.h │ │ │ ├── http │ │ │ │ ├── altcp_proxyconnect.c │ │ │ │ ├── fs.c │ │ │ │ ├── fs │ │ │ │ │ ├── 404.html │ │ │ │ │ ├── img │ │ │ │ │ │ └── sics.gif │ │ │ │ │ └── index.html │ │ │ │ ├── fsdata.c │ │ │ │ ├── fsdata.h │ │ │ │ ├── http_client.c │ │ │ │ ├── httpd.c │ │ │ │ ├── httpd_structs.h │ │ │ │ └── makefsdata │ │ │ │ │ ├── makefsdata │ │ │ │ │ ├── makefsdata.c │ │ │ │ │ ├── readme.txt │ │ │ │ │ └── tinydir.h │ │ │ ├── lwiperf │ │ │ │ └── lwiperf.c │ │ │ ├── mdns │ │ │ │ └── mdns.c │ │ │ ├── mqtt │ │ │ │ └── mqtt.c │ │ │ ├── netbiosns │ │ │ │ └── netbiosns.c │ │ │ ├── smtp │ │ │ │ └── smtp.c │ │ │ ├── snmp │ │ │ │ ├── snmp_asn1.c │ │ │ │ ├── snmp_asn1.h │ │ │ │ ├── snmp_core.c │ │ │ │ ├── snmp_core_priv.h │ │ │ │ ├── snmp_mib2.c │ │ │ │ ├── snmp_mib2_icmp.c │ │ │ │ ├── snmp_mib2_interfaces.c │ │ │ │ ├── snmp_mib2_ip.c │ │ │ │ ├── snmp_mib2_snmp.c │ │ │ │ ├── snmp_mib2_system.c │ │ │ │ ├── snmp_mib2_tcp.c │ │ │ │ ├── snmp_mib2_udp.c │ │ │ │ ├── snmp_msg.c │ │ │ │ ├── snmp_msg.h │ │ │ │ ├── snmp_netconn.c │ │ │ │ ├── snmp_pbuf_stream.c │ │ │ │ ├── snmp_pbuf_stream.h │ │ │ │ ├── snmp_raw.c │ │ │ │ ├── snmp_scalar.c │ │ │ │ ├── snmp_snmpv2_framework.c │ │ │ │ ├── snmp_snmpv2_usm.c │ │ │ │ ├── snmp_table.c │ │ │ │ ├── snmp_threadsync.c │ │ │ │ ├── snmp_traps.c │ │ │ │ ├── snmpv3.c │ │ │ │ ├── snmpv3_mbedtls.c │ │ │ │ └── snmpv3_priv.h │ │ │ ├── sntp │ │ │ │ └── sntp.c │ │ │ └── tftp │ │ │ │ └── tftp_server.c │ │ │ ├── core │ │ │ ├── altcp.c │ │ │ ├── altcp_alloc.c │ │ │ ├── altcp_tcp.c │ │ │ ├── def.c │ │ │ ├── dns.c │ │ │ ├── inet_chksum.c │ │ │ ├── init.c │ │ │ ├── ip.c │ │ │ ├── ipv4 │ │ │ │ ├── autoip.c │ │ │ │ ├── dhcp.c │ │ │ │ ├── etharp.c │ │ │ │ ├── icmp.c │ │ │ │ ├── igmp.c │ │ │ │ ├── ip4.c │ │ │ │ ├── ip4_addr.c │ │ │ │ └── ip4_frag.c │ │ │ ├── ipv6 │ │ │ │ ├── dhcp6.c │ │ │ │ ├── ethip6.c │ │ │ │ ├── icmp6.c │ │ │ │ ├── inet6.c │ │ │ │ ├── ip6.c │ │ │ │ ├── ip6_addr.c │ │ │ │ ├── ip6_frag.c │ │ │ │ ├── mld6.c │ │ │ │ └── nd6.c │ │ │ ├── mem.c │ │ │ ├── memp.c │ │ │ ├── netif.c │ │ │ ├── pbuf.c │ │ │ ├── raw.c │ │ │ ├── stats.c │ │ │ ├── sys.c │ │ │ ├── tcp.c │ │ │ ├── tcp_in.c │ │ │ ├── tcp_out.c │ │ │ ├── timeouts.c │ │ │ └── udp.c │ │ │ ├── include │ │ │ ├── arch │ │ │ │ ├── cc.h │ │ │ │ ├── perf.h │ │ │ │ └── sys_arch.h │ │ │ ├── compat │ │ │ │ ├── posix │ │ │ │ │ ├── arpa │ │ │ │ │ │ └── inet.h │ │ │ │ │ ├── net │ │ │ │ │ │ └── if.h │ │ │ │ │ ├── netdb.h │ │ │ │ │ └── sys │ │ │ │ │ │ └── socket.h │ │ │ │ └── stdc │ │ │ │ │ └── errno.h │ │ │ ├── lwip │ │ │ │ ├── altcp.h │ │ │ │ ├── altcp_tcp.h │ │ │ │ ├── altcp_tls.h │ │ │ │ ├── api.h │ │ │ │ ├── apps │ │ │ │ │ ├── FILES │ │ │ │ │ ├── altcp_proxyconnect.h │ │ │ │ │ ├── altcp_tls_mbedtls_opts.h │ │ │ │ │ ├── fs.h │ │ │ │ │ ├── http_client.h │ │ │ │ │ ├── httpd.h │ │ │ │ │ ├── httpd_opts.h │ │ │ │ │ ├── lwiperf.h │ │ │ │ │ ├── mdns.h │ │ │ │ │ ├── mdns_opts.h │ │ │ │ │ ├── mdns_priv.h │ │ │ │ │ ├── mqtt.h │ │ │ │ │ ├── mqtt_opts.h │ │ │ │ │ ├── mqtt_priv.h │ │ │ │ │ ├── netbiosns.h │ │ │ │ │ ├── netbiosns_opts.h │ │ │ │ │ ├── smtp.h │ │ │ │ │ ├── smtp_opts.h │ │ │ │ │ ├── snmp.h │ │ │ │ │ ├── snmp_core.h │ │ │ │ │ ├── snmp_mib2.h │ │ │ │ │ ├── snmp_opts.h │ │ │ │ │ ├── snmp_scalar.h │ │ │ │ │ ├── snmp_snmpv2_framework.h │ │ │ │ │ ├── snmp_snmpv2_usm.h │ │ │ │ │ ├── snmp_table.h │ │ │ │ │ ├── snmp_threadsync.h │ │ │ │ │ ├── snmpv3.h │ │ │ │ │ ├── sntp.h │ │ │ │ │ ├── sntp_opts.h │ │ │ │ │ ├── tftp_opts.h │ │ │ │ │ └── tftp_server.h │ │ │ │ ├── arch.h │ │ │ │ ├── autoip.h │ │ │ │ ├── debug.h │ │ │ │ ├── def.h │ │ │ │ ├── dhcp.h │ │ │ │ ├── dhcp6.h │ │ │ │ ├── dns.h │ │ │ │ ├── err.h │ │ │ │ ├── errno.h │ │ │ │ ├── etharp.h │ │ │ │ ├── ethip6.h │ │ │ │ ├── icmp.h │ │ │ │ ├── icmp6.h │ │ │ │ ├── if_api.h │ │ │ │ ├── igmp.h │ │ │ │ ├── inet.h │ │ │ │ ├── inet_chksum.h │ │ │ │ ├── init.h │ │ │ │ ├── init.h.cmake.in │ │ │ │ ├── ip.h │ │ │ │ ├── ip4.h │ │ │ │ ├── ip4_addr.h │ │ │ │ ├── ip4_frag.h │ │ │ │ ├── ip6.h │ │ │ │ ├── ip6_addr.h │ │ │ │ ├── ip6_frag.h │ │ │ │ ├── ip6_zone.h │ │ │ │ ├── ip_addr.h │ │ │ │ ├── mem.h │ │ │ │ ├── memp.h │ │ │ │ ├── mld6.h │ │ │ │ ├── nd6.h │ │ │ │ ├── netbuf.h │ │ │ │ ├── netdb.h │ │ │ │ ├── netif.h │ │ │ │ ├── netifapi.h │ │ │ │ ├── opt.h │ │ │ │ ├── pbuf.h │ │ │ │ ├── priv │ │ │ │ │ ├── altcp_priv.h │ │ │ │ │ ├── api_msg.h │ │ │ │ │ ├── mem_priv.h │ │ │ │ │ ├── memp_priv.h │ │ │ │ │ ├── memp_std.h │ │ │ │ │ ├── nd6_priv.h │ │ │ │ │ ├── raw_priv.h │ │ │ │ │ ├── sockets_priv.h │ │ │ │ │ ├── tcp_priv.h │ │ │ │ │ └── tcpip_priv.h │ │ │ │ ├── prot │ │ │ │ │ ├── autoip.h │ │ │ │ │ ├── dhcp.h │ │ │ │ │ ├── dhcp6.h │ │ │ │ │ ├── dns.h │ │ │ │ │ ├── etharp.h │ │ │ │ │ ├── ethernet.h │ │ │ │ │ ├── iana.h │ │ │ │ │ ├── icmp.h │ │ │ │ │ ├── icmp6.h │ │ │ │ │ ├── ieee.h │ │ │ │ │ ├── igmp.h │ │ │ │ │ ├── ip.h │ │ │ │ │ ├── ip4.h │ │ │ │ │ ├── ip6.h │ │ │ │ │ ├── mld6.h │ │ │ │ │ ├── nd6.h │ │ │ │ │ ├── tcp.h │ │ │ │ │ └── udp.h │ │ │ │ ├── raw.h │ │ │ │ ├── sio.h │ │ │ │ ├── snmp.h │ │ │ │ ├── sockets.h │ │ │ │ ├── stats.h │ │ │ │ ├── sys.h │ │ │ │ ├── sys.h.keep │ │ │ │ ├── tcp.h │ │ │ │ ├── tcpbase.h │ │ │ │ ├── tcpip.h │ │ │ │ ├── timeouts.h │ │ │ │ └── udp.h │ │ │ └── netif │ │ │ │ ├── bridgeif.h │ │ │ │ ├── bridgeif_opts.h │ │ │ │ ├── etharp.h │ │ │ │ ├── ethernet.h │ │ │ │ ├── ieee802154.h │ │ │ │ ├── lowpan6.h │ │ │ │ ├── lowpan6_ble.h │ │ │ │ ├── lowpan6_common.h │ │ │ │ ├── lowpan6_opts.h │ │ │ │ ├── ppp │ │ │ │ ├── ccp.h │ │ │ │ ├── chap-md5.h │ │ │ │ ├── chap-new.h │ │ │ │ ├── chap_ms.h │ │ │ │ ├── eap.h │ │ │ │ ├── ecp.h │ │ │ │ ├── eui64.h │ │ │ │ ├── fsm.h │ │ │ │ ├── ipcp.h │ │ │ │ ├── ipv6cp.h │ │ │ │ ├── lcp.h │ │ │ │ ├── magic.h │ │ │ │ ├── mppe.h │ │ │ │ ├── polarssl │ │ │ │ │ ├── arc4.h │ │ │ │ │ ├── des.h │ │ │ │ │ ├── md4.h │ │ │ │ │ ├── md5.h │ │ │ │ │ └── sha1.h │ │ │ │ ├── ppp.h │ │ │ │ ├── ppp_impl.h │ │ │ │ ├── ppp_opts.h │ │ │ │ ├── pppapi.h │ │ │ │ ├── pppcrypt.h │ │ │ │ ├── pppdebug.h │ │ │ │ ├── pppoe.h │ │ │ │ ├── pppol2tp.h │ │ │ │ ├── pppos.h │ │ │ │ ├── upap.h │ │ │ │ └── vj.h │ │ │ │ ├── slipif.h │ │ │ │ └── zepif.h │ │ │ └── netif │ │ │ ├── FILES │ │ │ ├── bridgeif.c │ │ │ ├── bridgeif_fdb.c │ │ │ ├── ethernet.c │ │ │ ├── lowpan6.c │ │ │ ├── lowpan6_ble.c │ │ │ ├── lowpan6_common.c │ │ │ ├── ppp │ │ │ ├── PPPD_FOLLOWUP │ │ │ ├── auth.c │ │ │ ├── ccp.c │ │ │ ├── chap-md5.c │ │ │ ├── chap-new.c │ │ │ ├── chap_ms.c │ │ │ ├── demand.c │ │ │ ├── eap.c │ │ │ ├── ecp.c │ │ │ ├── eui64.c │ │ │ ├── fsm.c │ │ │ ├── ipcp.c │ │ │ ├── ipv6cp.c │ │ │ ├── lcp.c │ │ │ ├── magic.c │ │ │ ├── mppe.c │ │ │ ├── multilink.c │ │ │ ├── polarssl │ │ │ │ ├── README │ │ │ │ ├── arc4.c │ │ │ │ ├── des.c │ │ │ │ ├── md4.c │ │ │ │ ├── md5.c │ │ │ │ └── sha1.c │ │ │ ├── ppp.c │ │ │ ├── pppapi.c │ │ │ ├── pppcrypt.c │ │ │ ├── pppoe.c │ │ │ ├── pppol2tp.c │ │ │ ├── pppos.c │ │ │ ├── upap.c │ │ │ ├── utils.c │ │ │ └── vj.c │ │ │ ├── slipif.c │ │ │ └── zepif.c │ ├── LwipEthernetInterface.cpp │ ├── LwipEthernetInterface.h │ ├── LwipSocket.cpp │ └── LwipSocket.h ├── MQTT │ ├── MQTT_C │ │ ├── CMakeLists.txt │ │ ├── Doxyfile │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build.zig │ │ ├── cmake │ │ │ └── FindMbedTLS.cmake │ │ ├── docs │ │ │ ├── annotated.html │ │ │ ├── arrowdown.png │ │ │ ├── arrowright.png │ │ │ ├── bc_s.png │ │ │ ├── bdwn.png │ │ │ ├── bio_publisher_8c-example.html │ │ │ ├── classes.html │ │ │ ├── closed.png │ │ │ ├── dir_000001_000000.html │ │ │ ├── dir_68267d1309a1af8e8297ef4c3efbcdba.html │ │ │ ├── dir_68267d1309a1af8e8297ef4c3efbcdba_dep.map │ │ │ ├── dir_68267d1309a1af8e8297ef4c3efbcdba_dep.md5 │ │ │ ├── dir_68267d1309a1af8e8297ef4c3efbcdba_dep.png │ │ │ ├── dir_d44c64559bbebec7f509842c48db8b23.html │ │ │ ├── doc.png │ │ │ ├── doxygen.css │ │ │ ├── doxygen.png │ │ │ ├── dynsections.js │ │ │ ├── examples.html │ │ │ ├── files.html │ │ │ ├── folderclosed.png │ │ │ ├── folderopen.png │ │ │ ├── functions.html │ │ │ ├── functions_func.html │ │ │ ├── functions_vars.html │ │ │ ├── globals.html │ │ │ ├── globals_defs.html │ │ │ ├── globals_enum.html │ │ │ ├── globals_func.html │ │ │ ├── graph_legend.html │ │ │ ├── graph_legend.md5 │ │ │ ├── graph_legend.png │ │ │ ├── group__api.html │ │ │ ├── group__details.html │ │ │ ├── group__packers.html │ │ │ ├── group__pal.html │ │ │ ├── group__unpackers.html │ │ │ ├── index.html │ │ │ ├── jquery.js │ │ │ ├── menu.js │ │ │ ├── menudata.js │ │ │ ├── modules.html │ │ │ ├── mqtt-c-logo.png │ │ │ ├── mqtt_8c.html │ │ │ ├── mqtt_8c__incl.map │ │ │ ├── mqtt_8c__incl.md5 │ │ │ ├── mqtt_8c__incl.png │ │ │ ├── mqtt_8h.html │ │ │ ├── mqtt_8h__dep__incl.map │ │ │ ├── mqtt_8h__dep__incl.md5 │ │ │ ├── mqtt_8h__dep__incl.png │ │ │ ├── mqtt_8h__incl.map │ │ │ ├── mqtt_8h__incl.md5 │ │ │ ├── mqtt_8h__incl.png │ │ │ ├── mqtt_8h_source.html │ │ │ ├── mqtt__pal_8c.html │ │ │ ├── mqtt__pal_8c__incl.map │ │ │ ├── mqtt__pal_8c__incl.md5 │ │ │ ├── mqtt__pal_8c__incl.png │ │ │ ├── mqtt__pal_8h.html │ │ │ ├── mqtt__pal_8h__dep__incl.map │ │ │ ├── mqtt__pal_8h__dep__incl.md5 │ │ │ ├── mqtt__pal_8h__dep__incl.png │ │ │ ├── mqtt__pal_8h_source.html │ │ │ ├── nav_f.png │ │ │ ├── nav_g.png │ │ │ ├── nav_h.png │ │ │ ├── open.png │ │ │ ├── openssl_publisher_8c-example.html │ │ │ ├── reconnect_subscriber_8c-example.html │ │ │ ├── simple_publisher_8c-example.html │ │ │ ├── simple_subscriber_8c-example.html │ │ │ ├── splitbar.png │ │ │ ├── structmqtt__client.html │ │ │ ├── structmqtt__fixed__header.html │ │ │ ├── structmqtt__message__queue.html │ │ │ ├── structmqtt__queued__message.html │ │ │ ├── structmqtt__response.html │ │ │ ├── structmqtt__response__connack.html │ │ │ ├── structmqtt__response__pingresp.html │ │ │ ├── structmqtt__response__puback.html │ │ │ ├── structmqtt__response__pubcomp.html │ │ │ ├── structmqtt__response__publish.html │ │ │ ├── structmqtt__response__pubrec.html │ │ │ ├── structmqtt__response__pubrel.html │ │ │ ├── structmqtt__response__suback.html │ │ │ ├── structmqtt__response__unsuback.html │ │ │ ├── sync_off.png │ │ │ ├── sync_on.png │ │ │ ├── tab_a.png │ │ │ ├── tab_b.png │ │ │ ├── tab_h.png │ │ │ ├── tab_s.png │ │ │ └── tabs.css │ │ ├── examples │ │ │ ├── bearssl_publisher.c │ │ │ ├── bio_publisher.c │ │ │ ├── bio_publisher_win.c │ │ │ ├── mbedtls_publisher.c │ │ │ ├── mosquitto.org.pem │ │ │ ├── openssl_publisher.c │ │ │ ├── openssl_publisher_win.c │ │ │ ├── reconnect_subscriber.c │ │ │ ├── simple_publisher.c │ │ │ ├── simple_subscriber.c │ │ │ └── templates │ │ │ │ ├── bearssl_sockets.h │ │ │ │ ├── bio_sockets.h │ │ │ │ ├── mbedtls_sockets.h │ │ │ │ ├── openssl_sockets.h │ │ │ │ └── posix_sockets.h │ │ ├── include │ │ │ ├── mqtt.h │ │ │ └── mqtt_pal_original.h │ │ ├── makefile │ │ ├── src │ │ │ ├── mqtt.c │ │ │ └── mqtt_pal.c │ │ └── tests.c │ ├── MqttClient.cpp │ ├── MqttClient.h │ ├── mqtt_pal.cpp │ └── mqtt_pal.h ├── MulticastDiscovery │ ├── MulticastResponder.cpp │ ├── MulticastResponder.h │ ├── Notes on multicast implementation.md │ ├── fgmc_header.h │ ├── fgmc_protocol.cpp │ └── fgmc_protocol.h ├── Network.cpp ├── Network.h ├── NetworkBuffer.cpp ├── NetworkBuffer.h ├── NetworkClient.cpp ├── NetworkClient.h ├── NetworkDefs.h ├── NetworkInterface.cpp ├── NetworkInterface.h ├── NetworkResponder.cpp ├── NetworkResponder.h ├── Socket.h ├── TelnetResponder.cpp ├── TelnetResponder.h ├── UploadingNetworkResponder.cpp ├── UploadingNetworkResponder.h └── W5500Ethernet │ ├── MdnsResponder.cpp │ ├── MdnsResponder.h │ ├── W5500Interface.cpp │ ├── W5500Interface.h │ ├── W5500Socket.cpp │ ├── W5500Socket.h │ └── Wiznet │ ├── .gitattributes │ ├── .gitignore │ ├── Ethernet │ ├── Socket_APIs_V3.0.3.chm │ ├── W5500 │ │ ├── w5500.cpp │ │ └── w5500.h │ ├── WizSpi.cpp │ ├── WizSpi.h │ ├── socketlib.cpp │ ├── socketlib.h │ ├── wizchip_conf.cpp │ └── wizchip_conf.h │ ├── Internet │ └── DHCP │ │ ├── dhcp.cpp │ │ └── dhcp.h │ └── README.md ├── ObjectModel ├── GlobalVariables.cpp ├── GlobalVariables.h ├── ObjectModel.cpp ├── ObjectModel.h ├── TypeCode.h ├── Variable.cpp └── Variable.h ├── Platform ├── ArrayHandle.cpp ├── ArrayHandle.h ├── AveragingFilter.h ├── Event.cpp ├── Event.h ├── Heap.cpp ├── Heap.h ├── Logger.cpp ├── Logger.h ├── MessageBox.cpp ├── MessageBox.h ├── MessageType.h ├── OutputMemory.cpp ├── OutputMemory.h ├── Platform.cpp ├── Platform.h ├── PortControl.cpp ├── PortControl.h ├── PrintPausedReason.h ├── RepRap.cpp ├── RepRap.h ├── StringHandle.cpp ├── StringHandle.h ├── TaskPriorities.h ├── Tasks.cpp ├── Tasks.h ├── UniqueId.cpp └── UniqueId.h ├── PrintMonitor ├── PrintMonitor.cpp └── PrintMonitor.h ├── RTOS work pending.txt ├── RepRapFirmware.cpp ├── RepRapFirmware.h ├── RepRapFirmware.pdp ├── SBC ├── DataTransfer.cpp ├── DataTransfer.h ├── SbcInterface.cpp ├── SbcInterface.h └── SbcMessageFormats.h ├── Storage ├── CRC16.cpp ├── CRC16.h ├── CRC32.cpp ├── CRC32.h ├── EmbeddedFiles.cpp ├── FileData.h ├── FileInfoParser.cpp ├── FileInfoParser.h ├── FileStore.cpp ├── FileStore.h ├── FileWriteBuffer.h ├── MassStorage.cpp └── MassStorage.h ├── Todo-next.txt ├── Tools ├── Filament.cpp ├── Filament.h ├── Spindle.cpp ├── Spindle.h ├── Tool.cpp └── Tool.h ├── Version.cpp ├── Version.h ├── bossa ├── Applet.cpp ├── Applet.h ├── BossaFlash.cpp ├── BossaFlash.h ├── Device.cpp ├── Device.h ├── EefcFlash.cpp ├── EefcFlash.h ├── Flasher.cpp ├── Flasher.h ├── Samba.cpp ├── Samba.h ├── SerialPort.h ├── WordCopyApplet.cpp ├── WordCopyApplet.h ├── WordCopyArm.asm ├── WordCopyArm.cpp └── WordCopyArm.h ├── libc ├── atoi.cpp ├── eCvInclude │ └── malloc.h ├── errno.c ├── local.h ├── memcmp.c ├── memcpy.c ├── memmove.c ├── memset.c ├── nano-mallocr.c ├── readme-libc.txt └── strptime.cpp ├── libcpp ├── eh_alloc.cc ├── readme-libcpp.txt ├── unwind-cxx.h └── vterminate.cc └── modbus-rtu.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | *.inf binary -text 4 | 5 | # Custom for Visual Studio 6 | *.cs diff=csharp 7 | *.sln merge=union 8 | *.csproj merge=union 9 | *.vbproj merge=union 10 | *.fsproj merge=union 11 | *.dbproj merge=union 12 | 13 | # Standard to msysgit 14 | *.doc diff=astextplain 15 | *.DOC diff=astextplain 16 | *.docx diff=astextplain 17 | *.DOCX diff=astextplain 18 | *.dot diff=astextplain 19 | *.DOT diff=astextplain 20 | *.pdf diff=astextplain 21 | *.PDF diff=astextplain 22 | *.rtf diff=astextplain 23 | *.RTF diff=astextplain 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Duet3D Community Support 4 | url: https://forum.duet3d.com// 5 | about: Please ask and answer questions here. 6 | - name: Duet3D Documentation 7 | url: https://docs.duet3d.com 8 | about: Detailed documentation for Duet electronics and RepRapFirmware. 9 | -------------------------------------------------------------------------------- /.github/workflows/issues.yml: -------------------------------------------------------------------------------- 1 | name: Auto-close blank templates 2 | on: 3 | issues: 4 | types: [opened] 5 | jobs: 6 | add-comment: 7 | runs-on: ubuntu-latest 8 | permissions: 9 | issues: write 10 | steps: 11 | - name: Check user permission 12 | id: check 13 | uses: scherermichael-oss/action-has-permission@master 14 | with: 15 | required-permission: write 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 18 | - if: steps.check.outputs.has-permission == false && contains(github.event.issue.labels.*.name, 'bug') == false && contains(github.event.issue.labels.*.name, 'enhancement') == false 19 | name: Close Issue 20 | uses: peter-evans/close-issue@v1 21 | with: 22 | comment: | 23 | This issue has been automatically closed because it does not originate from a Duet3D administrator. 24 | Please create a discussion on https://forum.duet3d.com first and fill out the corresponding GitHub template if the bug or feature request is acknowledged. 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object and intermediate files 2 | *.o 3 | *.d 4 | 5 | # Misc 6 | /.settings/language.settings.xml 7 | 8 | # Emacs backup and auto-save files 9 | *~ 10 | \#*\# 11 | 12 | # Output folders 13 | /Duet2/ 14 | /Duet2_SBC/ 15 | /DuetMaestro/ 16 | /PCCB_10/ 17 | /Duet3ATE/ 18 | /Duet3MiniATE/ 19 | /Duet3Mini5plus/ 20 | /Duet3Mini5plus_Debug/ 21 | /Duet3_MB6HC/ 22 | /Duet3_MB6XD/ 23 | /Duet3_CAN0/ 24 | /Duet3_Debug/ 25 | /FMDC_V02/ 26 | /FMDC_V02_Debug/ 27 | /FMDC_V03/ 28 | /Duet3_MB6HC_no_SD/ 29 | /Duet3_MB6HC_S_curve/ 30 | /.clangd 31 | /.clang-format 32 | /src/Temp/ 33 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/Display/Lcd/Fonts/glcd11x14.cpp=UTF-8 3 | encoding//src/Display/Lcd/Fonts/glcd7x11.cpp=UTF-8 4 | encoding//src/Movement/StepperDrivers/TMC51xx.cpp=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.runtime.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | line.separator=\n 3 | -------------------------------------------------------------------------------- /AddingNewKinematics.md: -------------------------------------------------------------------------------- 1 | This file is no longer maintained. See https://github.com/Duet3D/RepRapFirmware/wiki/Adding-New-Kinematics instead. -------------------------------------------------------------------------------- /BuildInstructions.md: -------------------------------------------------------------------------------- 1 | This file is no longer maintained. See https://github.com/Duet3D/RepRapFirmware/wiki/Building-RepRapFirmware instead. -------------------------------------------------------------------------------- /Developer-documentation/Movement in RepRapFirmware.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Developer-documentation/Movement in RepRapFirmware.odt -------------------------------------------------------------------------------- /Developer-documentation/New ESP8266 WiFi module code for Duet WiFi.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Developer-documentation/New ESP8266 WiFi module code for Duet WiFi.odt -------------------------------------------------------------------------------- /Developer-documentation/S-curve equations.wxmx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Developer-documentation/S-curve equations.wxmx -------------------------------------------------------------------------------- /Developer-documentation/S-curve move planning.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Developer-documentation/S-curve move planning.odt -------------------------------------------------------------------------------- /Driver/DuetDriverFiles.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Driver/DuetDriverFiles.zip -------------------------------------------------------------------------------- /Driver/README.md: -------------------------------------------------------------------------------- 1 | These are the Windows device driver files for Duet electronics running RepRapFirmware 1.12 and later. 2 | 3 | Due to the difficulties of downloading text files from github without the line endings getting changed (which messes up the digital signature), I recommend you download the Zip file and extract the contents to a folder on your PC. 4 | -------------------------------------------------------------------------------- /Driver/duetinf.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Driver/duetinf.cat -------------------------------------------------------------------------------- /HTTP requests.md: -------------------------------------------------------------------------------- 1 | This file is no longer maintained. See https://github.com/Duet3D/RepRapFirmware/wiki/HTTP-requests instead. -------------------------------------------------------------------------------- /JSON responses.md: -------------------------------------------------------------------------------- 1 | This file is no longer maintained. See https://github.com/Duet3D/RepRapFirmware/wiki/JSON-responses instead. -------------------------------------------------------------------------------- /Maths/BedLevelling-2-point.wxm: -------------------------------------------------------------------------------- 1 | /* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/ 2 | /* [ Created with wxMaxima version 17.05.0 ] */ 3 | /* [wxMaxima: input start ] */ 4 | eq1:h=H+a*x+b*y; 5 | /* [wxMaxima: input end ] */ 6 | 7 | 8 | /* [wxMaxima: input start ] */ 9 | eq2:h0=H+a*x0+b*y0; 10 | /* [wxMaxima: input end ] */ 11 | 12 | 13 | /* [wxMaxima: input start ] */ 14 | eq3:h1=H+a*x1+b*y1; 15 | /* [wxMaxima: input end ] */ 16 | 17 | 18 | /* [wxMaxima: input start ] */ 19 | eq4:h2=H+a*(x0+y1-y0)+b*(y0-(x1-x0)); 20 | /* [wxMaxima: input end ] */ 21 | 22 | 23 | /* [wxMaxima: input start ] */ 24 | eq5:h2=h0; 25 | /* [wxMaxima: input end ] */ 26 | 27 | 28 | /* [wxMaxima: input start ] */ 29 | eq6:subst(eq5,eq4); 30 | /* [wxMaxima: input end ] */ 31 | 32 | 33 | /* [wxMaxima: input start ] */ 34 | eq7:solve([eq2,eq3,eq6],[a,b,H]); 35 | /* [wxMaxima: input end ] */ 36 | 37 | 38 | /* [wxMaxima: input start ] */ 39 | eq8:subst(eq7,eq1); 40 | /* [wxMaxima: input end ] */ 41 | 42 | 43 | /* [wxMaxima: input start ] */ 44 | eq9:dhbydh0=factor(diff(rhs(eq8),h0)); 45 | /* [wxMaxima: input end ] */ 46 | 47 | 48 | /* [wxMaxima: input start ] */ 49 | eq10:dhbydh1=factor(diff(rhs(eq8),h1)); 50 | /* [wxMaxima: input end ] */ 51 | 52 | 53 | /* [wxMaxima: input start ] */ 54 | eq11:expand((x1-x0)^2+(y1-y0)^2)=d^2; 55 | /* [wxMaxima: input end ] */ 56 | 57 | 58 | /* [wxMaxima: input start ] */ 59 | eq12:subst(eq11,eq9); 60 | /* [wxMaxima: input end ] */ 61 | 62 | 63 | /* [wxMaxima: input start ] */ 64 | eq13:subst(eq11,eq10); 65 | /* [wxMaxima: input end ] */ 66 | 67 | 68 | 69 | /* Maxima can't load/batch files which end with a comment! */ 70 | "Created with wxMaxima"$ 71 | -------------------------------------------------------------------------------- /Maths/BedLevelling-3-point.wxm: -------------------------------------------------------------------------------- 1 | /* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/ 2 | /* [ Created with wxMaxima version 14.12.1 ] */ 3 | 4 | /* [wxMaxima: input start ] */ 5 | eq1:h=H+a*x+b*y; 6 | /* [wxMaxima: input end ] */ 7 | 8 | /* [wxMaxima: input start ] */ 9 | eq2:h0=H+a*x0+b*y0; 10 | /* [wxMaxima: input end ] */ 11 | 12 | /* [wxMaxima: input start ] */ 13 | eq3:h1=H+a*x1+b*y1; 14 | /* [wxMaxima: input end ] */ 15 | 16 | /* [wxMaxima: input start ] */ 17 | eq4:h2=H+a*x2+b*y2; 18 | /* [wxMaxima: input end ] */ 19 | 20 | /* [wxMaxima: input start ] */ 21 | eq5:solve([eq2,eq3,eq4],[a,b,H]); 22 | /* [wxMaxima: input end ] */ 23 | 24 | /* [wxMaxima: input start ] */ 25 | eq6:subst(eq5,eq1); 26 | /* [wxMaxima: input end ] */ 27 | 28 | /* [wxMaxima: input start ] */ 29 | eq7:dhbydh0=factor(diff(rhs(eq6),h0)); 30 | /* [wxMaxima: input end ] */ 31 | 32 | /* [wxMaxima: input start ] */ 33 | eq8:dhbydh1=factor(diff(rhs(eq6),h1)); 34 | /* [wxMaxima: input end ] */ 35 | 36 | /* [wxMaxima: input start ] */ 37 | eq9:dhbydh2=factor(diff(rhs(eq6),h2)); 38 | /* [wxMaxima: input end ] */ 39 | 40 | /* [wxMaxima: input start ] */ 41 | eq10:x1*y2-x0*y2-x2*y1+x0*y1+x2*y0-x1*y0=d; 42 | /* [wxMaxima: input end ] */ 43 | 44 | /* [wxMaxima: input start ] */ 45 | eq11:subst(eq10,eq7); 46 | /* [wxMaxima: input end ] */ 47 | 48 | /* [wxMaxima: input start ] */ 49 | eq12:subst(eq10,eq8); 50 | /* [wxMaxima: input end ] */ 51 | 52 | /* [wxMaxima: input start ] */ 53 | eq13:subst(eq10,eq9); 54 | /* [wxMaxima: input end ] */ 55 | 56 | /* Maxima can't load/batch files which end with a comment! */ 57 | "Created with wxMaxima"$ 58 | -------------------------------------------------------------------------------- /Maths/ExtruderStepMaths.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Maths/ExtruderStepMaths.odt -------------------------------------------------------------------------------- /Maths/closestPointOfApproach2d.wxmx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Maths/closestPointOfApproach2d.wxmx -------------------------------------------------------------------------------- /Maths/closestPointOfApproach3d.wxmx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Maths/closestPointOfApproach3d.wxmx -------------------------------------------------------------------------------- /Maths/delta.wxmx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Maths/delta.wxmx -------------------------------------------------------------------------------- /Maths/trilateration-triple.wxmx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Maths/trilateration-triple.wxmx -------------------------------------------------------------------------------- /Maths/trilateration.wxmx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Maths/trilateration.wxmx -------------------------------------------------------------------------------- /PccbEmbeddedFiles/sys/config.g: -------------------------------------------------------------------------------- 1 | M505 P"config1" 2 | M98 P"config.g" 3 | -------------------------------------------------------------------------------- /PccbEmbeddedFiles/sys/config1/config.g: -------------------------------------------------------------------------------- 1 | M584 Z0 2 | M906 Z1000 3 | M92 Z400 4 | M572 Z1 P"stop0" 5 | M569 P2 R-1 6 | M569 P3 R-1 7 | M569 P4 R-1 8 | M569 P5 R-1 9 | M569 P6 R-1 10 | -------------------------------------------------------------------------------- /PccbEmbeddedFiles/sys/config1/homeall.g: -------------------------------------------------------------------------------- 1 | M98 P"homez.g" 2 | -------------------------------------------------------------------------------- /PccbEmbeddedFiles/sys/config1/homez.g: -------------------------------------------------------------------------------- 1 | G1 H1 Z-200 F3000 2 | G1 H2 Z5 3 | G1 H1 Z10 F1000 4 | -------------------------------------------------------------------------------- /PccbEmbeddedFiles/sys/config2/config.g: -------------------------------------------------------------------------------- 1 | M584 Z1 2 | M906 Z1000 3 | M92 Z800 4 | -------------------------------------------------------------------------------- /PccbEmbeddedFiles/sys/config2/homeall.g: -------------------------------------------------------------------------------- 1 | M98 P"homez.g 2 | -------------------------------------------------------------------------------- /PccbEmbeddedFiles/sys/config2/homez.g: -------------------------------------------------------------------------------- 1 | G92 Z0 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is firmware for controlling 3D printers and related devices using electronics based on ARM Cortex main processors. The current processors supported are the ATSAM4E, ATSAM4S, SAME70 and SAME5x. There is a fork of this firmware that supports LPC1768/1769 and STM processors. 2 | 3 | # Documentation 4 | All documentation has been moved to the [RepRapFirmware GitHub Wiki](https://github.com/Duet3D/RepRapFirmware/wiki). 5 | 6 | # Licence 7 | The source files in this project (RepRapFirmware) are licensed under GPLv3, see http://www.gnu.org/licenses/gpl-3.0.en.html. The associated CoreNG project, which provides a partial hardware abstraction layer, includes files derived from the Advanced Software Framework (formerly Atmel Software Framework) from Microchip. Those files have a more restrictive license, in particular they may only be used for code that targets Atmel/Microchip processors. 8 | -------------------------------------------------------------------------------- /Scripts/DriverSigning/signdriver.bat: -------------------------------------------------------------------------------- 1 | cd ..rem CD to the RepRapFirmware root directory before running this 2 | "C:\Program Files (x86)\Windows Kits\10\bin\x86\Inf2Cat.exe" /driver:Driver /os:XP_X86,Vista_X86,Vista_X64,7_X86,7_X64,8_X86,8_X64,6_3_X86,6_3_X64,10_X86,10_X64 3 | set PASSWORD= 4 | set /P PASSWORD=Private key password: %=% 5 | "C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe" sign /f g:\EscherTechnologies.pfx /p %PASSWORD% /tr http://timestamp.comodoca.com /v Driver/duetinf.cat 6 | "C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe" verify /pa /tw Driver/duetinf.cat -------------------------------------------------------------------------------- /Scripts/OpenOCD/duet3_openocd.cfg: -------------------------------------------------------------------------------- 1 | # Atmel-ICE JTAG/SWD in-circuit debugger. 2 | interface cmsis-dap 3 | cmsis_dap_vid_pid 0x03eb 0x2141 4 | 5 | # Chip info 6 | set CHIPNAME atsame70q20 7 | source [find target/atsamv.cfg] 8 | 9 | -------------------------------------------------------------------------------- /Scripts/OpenOCD/duet3_openocd_memtest.cfg: -------------------------------------------------------------------------------- 1 | # Atmel-ICE JTAG/SWD in-circuit debugger. 2 | interface cmsis-dap 3 | cmsis_dap_vid_pid 0x03eb 0x2141 4 | 5 | # Chip info 6 | set CHIPNAME atsame70q20 7 | source [find target/atsamv.cfg] 8 | 9 | reset_config srst_only 10 | 11 | # Run memtest 12 | source [find tools/memtest.tcl] 13 | runAllMemTests 0x20400000 0x60000 14 | -------------------------------------------------------------------------------- /Tools/CrcAppender/linux-x86_64/CrcAppender: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Tools/CrcAppender/linux-x86_64/CrcAppender -------------------------------------------------------------------------------- /Tools/CrcAppender/macos-x86_64/CrcAppender: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Tools/CrcAppender/macos-x86_64/CrcAppender -------------------------------------------------------------------------------- /Tools/CrcAppender/win-x86-64/CrcAppender.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Tools/CrcAppender/win-x86-64/CrcAppender.exe -------------------------------------------------------------------------------- /Tools/Windows/bossac.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Tools/Windows/bossac.exe -------------------------------------------------------------------------------- /Tools/Windows/listComPorts.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Tools/Windows/listComPorts.exe -------------------------------------------------------------------------------- /Tools/stackanalyzer/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Duet3D/RepRapFirmware/Tools/stackanalyzer 2 | 3 | go 1.15 4 | -------------------------------------------------------------------------------- /Tools/stackanalyzer/linux/stackanalyzer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Tools/stackanalyzer/linux/stackanalyzer -------------------------------------------------------------------------------- /Tools/stackanalyzer/macos/stackanalyzer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Tools/stackanalyzer/macos/stackanalyzer -------------------------------------------------------------------------------- /Tools/stackanalyzer/win/stackanalyzer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/Tools/stackanalyzer/win/stackanalyzer.exe -------------------------------------------------------------------------------- /WHATS_NEW.md: -------------------------------------------------------------------------------- 1 | This file is no longer maintained. See https://github.com/Duet3D/RepRapFirmware/wiki/Changelog-RRF-1.x-&-2.x instead. -------------------------------------------------------------------------------- /WHATS_NEW_RRF3.md: -------------------------------------------------------------------------------- 1 | This file is no longer maintained. See https://github.com/Duet3D/RepRapFirmware/wiki/Changelog-RRF-3.x instead. -------------------------------------------------------------------------------- /src/Accelerometers/Accelerometers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Accelerometers.h 3 | * 4 | * Created on: 19 Mar 2021 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_ACCELEROMETERS_ACCELEROMETERS_H_ 9 | #define SRC_ACCELEROMETERS_ACCELEROMETERS_H_ 10 | 11 | #include 12 | 13 | #if SUPPORT_ACCELEROMETERS 14 | 15 | #include 16 | 17 | #if SUPPORT_CAN_EXPANSION 18 | # include 19 | #endif 20 | 21 | class CanMessageAccelerometerData; 22 | 23 | namespace Accelerometers 24 | { 25 | bool HasLocalAccelerometer() noexcept; 26 | unsigned int GetLocalAccelerometerRuns() noexcept; 27 | unsigned int GetLocalAccelerometerDataPoints() noexcept; 28 | uint8_t GetLocalAccelerometerOrientation() noexcept; 29 | GCodeResult ConfigureAccelerometer(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); 30 | GCodeResult StartAccelerometer(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); 31 | void Exit() noexcept; 32 | #if SUPPORT_CAN_EXPANSION 33 | void ProcessReceivedData(CanAddress src, const CanMessageAccelerometerData& msg, size_t msgLen) noexcept; 34 | #endif 35 | #if 0 // We don't currently support accelerometers on main boards used as expansion boards 36 | //#if SUPPORT_REMOTE_COMMANDS 37 | void Diagnostics(const StringRef& reply) noexcept; 38 | #endif 39 | } 40 | 41 | #endif 42 | 43 | #endif /* SRC_ACCELEROMETERS_ACCELEROMETERS_H_ */ 44 | -------------------------------------------------------------------------------- /src/AppNotifyIndices.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AppNotifyIndices.h 3 | * 4 | * Created on: 2 Jan 2024 5 | * Author: David 6 | * 7 | * Definitions of task notification indices used by the application layer 8 | */ 9 | 10 | #ifndef SRC_APPNOTIFYINDICES_H_ 11 | #define SRC_APPNOTIFYINDICES_H_ 12 | 13 | #if SUPPORT_CAN_EXPANSION 14 | # include 15 | #else 16 | # include 17 | #endif 18 | 19 | namespace NotifyIndices 20 | { 21 | #if SUPPORT_CAN_EXPANSION 22 | constexpr uint32_t FirstAvailableApp = NextAvailableAfterCANlib; 23 | #else 24 | constexpr uint32_t FirstAvailableApp = NextAvailableAfterCore; 25 | #endif 26 | constexpr uint32_t I2C = FirstAvailableApp; 27 | constexpr uint32_t Spi = FirstAvailableApp; 28 | constexpr uint32_t AccelerometerHardware = FirstAvailableApp + 1; 29 | constexpr uint32_t HeightController = FirstAvailableApp + 2; 30 | constexpr uint32_t AccelerometerDataCollector = FirstAvailableApp + 2; 31 | constexpr uint32_t Heat = FirstAvailableApp + 2; 32 | constexpr uint32_t Tmc = FirstAvailableApp + 2; 33 | constexpr uint32_t Move = FirstAvailableApp + 2; 34 | constexpr uint32_t DueX = FirstAvailableApp + 2; 35 | constexpr uint32_t CanMessageQueue = FirstAvailableApp + 3; 36 | constexpr uint32_t CanSender = FirstAvailableApp + 3; 37 | constexpr uint32_t SbcInterface = FirstAvailableApp + 3; 38 | constexpr uint32_t WiFi = FirstAvailableApp + 3; 39 | constexpr uint32_t EthernetHardware = FirstAvailableApp + 3; 40 | constexpr uint32_t Laser = FirstAvailableApp + 3; 41 | constexpr uint32_t TotalUsed = FirstAvailableApp + 4; 42 | } 43 | 44 | #ifdef RTOS 45 | # include 46 | static_assert(NotifyIndices::TotalUsed <= configTASK_NOTIFICATION_ARRAY_ENTRIES); 47 | #endif 48 | 49 | #endif /* SRC_APPNOTIFYINDICES_H_ */ 50 | -------------------------------------------------------------------------------- /src/CAN/CanDriversData.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CanDriversData.cpp 3 | * 4 | * Created on: 23 Dec 2021 5 | * Author: David 6 | */ 7 | 8 | #include "CanDriversData.h" 9 | 10 | #if SUPPORT_CAN_EXPANSION 11 | 12 | // Insert a new entry, keeping the list ordered 13 | void CanDriversList::AddEntry(DriverId driver) noexcept 14 | { 15 | if (numEntries < ARRAY_SIZE(drivers)) 16 | { 17 | // We could do a binary search here but the number of CAN drivers supported isn't huge, so linear search instead 18 | size_t insertPoint = 0; 19 | while (insertPoint < numEntries && drivers[insertPoint] < driver) 20 | { 21 | ++insertPoint; 22 | } 23 | 24 | if (insertPoint == numEntries) 25 | { 26 | drivers[numEntries] = driver; 27 | ++numEntries; 28 | } 29 | else if (drivers[insertPoint] != driver) 30 | { 31 | memmove(drivers + (insertPoint + 1), drivers + insertPoint, (numEntries - insertPoint) * sizeof(drivers[0])); 32 | drivers[insertPoint] = driver; 33 | ++numEntries; 34 | } 35 | } 36 | } 37 | 38 | // Get the details of the drivers on the next board and advance startFrom beyond the entries for this board 39 | CanAddress CanDriversList::GetNextBoardDriverBitmap(size_t& startFrom, CanDriversBitmap& driversBitmap) const noexcept 40 | { 41 | driversBitmap.Clear(); 42 | if (startFrom >= numEntries) 43 | { 44 | return CanId::NoAddress; 45 | } 46 | const CanAddress boardAddress = drivers[startFrom].boardAddress; 47 | do 48 | { 49 | driversBitmap.SetBit(drivers[startFrom].localDriver); 50 | ++startFrom; 51 | } while (startFrom < numEntries && drivers[startFrom].boardAddress == boardAddress); 52 | return boardAddress; 53 | } 54 | 55 | #endif 56 | 57 | // End 58 | -------------------------------------------------------------------------------- /src/CAN/CanMotion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CanMotion.h 3 | * 4 | * Created on: 11 Aug 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_CAN_CANMOTION_H_ 9 | #define SRC_CAN_CANMOTION_H_ 10 | 11 | #include "RepRapFirmware.h" 12 | 13 | #if SUPPORT_CAN_EXPANSION 14 | 15 | #include 16 | 17 | class CanMessageBuffer; 18 | 19 | namespace CanMotion 20 | { 21 | void Init() noexcept; 22 | void StartMovement() noexcept; 23 | void AddAxisMovement(const PrepParams& params, DriverId canDriver, int32_t steps) noexcept; 24 | void AddExtruderMovement(const PrepParams& params, DriverId canDriver, float extrusion, bool usePressureAdvance) noexcept; 25 | uint32_t FinishMovement(const DDA& dda, uint32_t moveStartTime, bool simulating) noexcept; 26 | bool CanPrepareMove() noexcept; 27 | CanMessageBuffer *GetUrgentMessage() noexcept; 28 | 29 | // The next 4 functions may be called from the step ISR, so they can't send CAN messages directly 30 | void InsertHiccup(uint32_t numClocks) noexcept; 31 | void StopDriverWhenProvisional(DriverId driver) noexcept 32 | pre(driver.IsRemote()); 33 | bool StopDriverWhenExecuting(DriverId driver, int32_t netStepsTaken) noexcept 34 | pre(driver.IsRemote()); 35 | void FinishedStoppingDrivers() noexcept; 36 | bool RevertStoppedDrivers() noexcept; 37 | } 38 | 39 | #endif 40 | 41 | #endif /* SRC_CAN_CANMOTION_H_ */ 42 | -------------------------------------------------------------------------------- /src/CAN/CommandProcessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CommandProcessor.h 3 | * 4 | * Created on: 12 Aug 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_CAN_COMMANDPROCESSOR_H_ 9 | #define SRC_CAN_COMMANDPROCESSOR_H_ 10 | 11 | #include "RepRapFirmware.h" 12 | 13 | #if SUPPORT_CAN_EXPANSION 14 | 15 | class CanMessageBuffer; 16 | 17 | namespace CommandProcessor 18 | { 19 | void ProcessReceivedMessage(CanMessageBuffer *buf) noexcept; // Process a received broadcast or request message and free the message buffer 20 | void AppendBadMotionStats(const StringRef& reply) noexcept; // Append diagnostics relating to bad motion messages 21 | } 22 | 23 | #endif 24 | 25 | #endif /* SRC_CAN_COMMANDPROCESSOR_H_ */ 26 | -------------------------------------------------------------------------------- /src/ClosedLoop/ClosedLoop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ClosedLoop.h 3 | * 4 | * Created on: 19 Mar 2021 5 | * Author: Louis 6 | */ 7 | 8 | #ifndef SRC_CLOSEDLOOP_CLOSEDLOOP_H 9 | #define SRC_CLOSEDLOOP_CLOSEDLOOP_H 10 | 11 | #include 12 | 13 | #if SUPPORT_CAN_EXPANSION && (HAS_MASS_STORAGE || HAS_SBC_INTERFACE) 14 | # include 15 | 16 | class CanMessageClosedLoopData; 17 | 18 | namespace ClosedLoop 19 | { 20 | GCodeResult StartDataCollection(DriverId id, GCodeBuffer&, const StringRef&) THROWS(GCodeException) pre(id.IsRemote()); 21 | void ProcessReceivedData(CanAddress src, const CanMessageClosedLoopData& msg, size_t msgLen) noexcept; 22 | } 23 | 24 | #endif 25 | 26 | #endif // SRC_CLOSEDLOOP_CLOSEDLOOP_H 27 | -------------------------------------------------------------------------------- /src/Comms/FirmwareUpdater.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FirmwareUpdater.h 3 | * 4 | * Created on: 21 May 2016 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_NETWORKING_FIRMWAREUPDATER_H_ 9 | #define SRC_NETWORKING_FIRMWAREUPDATER_H_ 10 | 11 | #include 12 | 13 | namespace FirmwareUpdater 14 | { 15 | enum { 16 | Mainboard = 0, 17 | Sbc = 2, // Module 2 used to be the DWC binary file, now it is used to update SBC firmware 18 | #if HAS_WIFI_NETWORKING 19 | WifiFirmwareModule = 1, 20 | WifiExternalFirmwareModule = 3, 21 | #endif 22 | #if HAS_AUX_DEVICES 23 | PanelDueFirmwareModule = 4, 24 | #endif 25 | NumUpdateModules 26 | }; 27 | 28 | GCodeResult CheckFirmwareUpdatePrerequisites( 29 | Bitmap moduleMap, 30 | GCodeBuffer& gb, 31 | const StringRef& reply, 32 | size_t serialChannel, 33 | const StringRef& filenameRef) noexcept; 34 | bool IsReady() noexcept; 35 | void UpdateModule(unsigned int module, const size_t serialChannel, const StringRef& filenameRef) noexcept; 36 | } 37 | 38 | #endif /* SRC_NETWORKING_FIRMWAREUPDATER_H_ */ 39 | -------------------------------------------------------------------------------- /src/Comms/Modbus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Modbus.h 3 | * 4 | * Created on: 14 Aug 2024 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_COMMS_MODBUS_H_ 9 | #define SRC_COMMS_MODBUS_H_ 10 | 11 | #include 12 | 13 | // Modbus RTU function codes 14 | enum class ModbusFunction : uint16_t 15 | { 16 | readCoils = 0x01, 17 | readDiscreteInputs = 0x02, 18 | readHoldingRegisters = 0x03, 19 | readInputRegisters = 0x04, 20 | writeSingleCoil = 0x05, 21 | writeSingleRegister = 0x06, 22 | writeMultipleCoils = 0x0F, 23 | writeMultipleRegisters = 0x10, 24 | readDeviceId1 = 0x0E, 25 | readDeviceId2 = 0x2B, 26 | 27 | generic = 0x100 28 | }; 29 | 30 | #endif /* SRC_COMMS_MODBUS_H_ */ 31 | -------------------------------------------------------------------------------- /src/Config/Pins.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Pins.cpp 3 | * 4 | * Created on: 31 Mar 2019 5 | * Author: David 6 | */ 7 | 8 | #include "RepRapFirmware.h" 9 | 10 | // Pins lookup functions, possibly hardware-dependent 11 | 12 | // Return a pointer to the pin description entry. Declared in and called from CoreN2G. Return nullptr if the pin number is out of range. 13 | const PinDescriptionBase *_ecv_from _ecv_null AppGetPinDescription(Pin p) noexcept 14 | { 15 | return (p < ARRAY_SIZE(PinTable)) ? &PinTable[p] : nullptr; 16 | } 17 | 18 | // Function to look up a pin name and pass back the corresponding index into the pin table 19 | // On this platform, the mapping from pin names to pins is fixed, so this is a simple lookup 20 | bool LookupPinName(const char *_ecv_array pn, LogicalPin &lpin, bool &hardwareInverted) noexcept 21 | { 22 | if (StringEqualsIgnoreCase(pn, NoPinName)) 23 | { 24 | lpin = NoLogicalPin; 25 | hardwareInverted = false; 26 | return true; 27 | } 28 | 29 | for (size_t lp = 0; lp < ARRAY_SIZE(PinTable); ++lp) 30 | { 31 | const char *_ecv_array _ecv_null q = PinTable[lp].pinNames; 32 | if (q == nullptr) 33 | { 34 | continue; 35 | } 36 | while (*q != 0) 37 | { 38 | // Try the next alias in the list of names for this pin 39 | const char *_ecv_array p = pn; 40 | bool hwInverted = (*q == '!'); 41 | if (hwInverted) 42 | { 43 | ++q; 44 | } 45 | while (*q != ',' && *q != 0 && *p == *q) 46 | { 47 | ++p; 48 | ++q; 49 | } 50 | if (*p == 0 && (*q == 0 || *q == ',')) 51 | { 52 | // Found a match 53 | lpin = (LogicalPin)lp; 54 | hardwareInverted = hwInverted; 55 | return true; 56 | } 57 | 58 | // Skip to the start of the next alias 59 | while (*q != 0 && *q != ',') 60 | { 61 | ++q; 62 | } 63 | if (*q == ',') 64 | { 65 | ++q; 66 | } 67 | } 68 | } 69 | return false; 70 | } 71 | 72 | // End 73 | -------------------------------------------------------------------------------- /src/Display/ButtonMenuItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ButtonMenuItem.h 3 | * 4 | * Created on: 25 Apr 2022 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_DISPLAY_BUTTONMENUITEM_H_ 9 | #define SRC_DISPLAY_BUTTONMENUITEM_H_ 10 | 11 | #include "MenuItem.h" 12 | 13 | #if SUPPORT_DIRECT_LCD 14 | 15 | class ButtonMenuItem final : public MenuItem 16 | { 17 | public: 18 | DECLARE_FREELIST_NEW_DELETE(ButtonMenuItem) 19 | 20 | ButtonMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, const char *_ecv_array t, const char *_ecv_array cmd, const char *_ecv_array acFile) noexcept; 21 | void Draw(Lcd &_ecv_from lcd, PixelNumber maxWidth, bool highlight) noexcept override; 22 | void UpdateWidthAndHeight(Lcd &_ecv_from lcd) noexcept override; 23 | bool Select(const StringRef& cmd) noexcept override; 24 | 25 | PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept override; 26 | 27 | protected: 28 | void CorePrint(Lcd &_ecv_from lcd) noexcept override; 29 | 30 | private: 31 | const char *_ecv_array text; 32 | const char *_ecv_array command; 33 | const char *_ecv_array m_acFile; // used when action ("command") is "menu" 34 | }; 35 | 36 | #endif 37 | 38 | #endif /* SRC_DISPLAY_BUTTONMENUITEM_H_ */ 39 | -------------------------------------------------------------------------------- /src/Display/DisplayOrientation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DisplayOrientation.h 3 | * 4 | * Created: 04/11/2014 17:34:21 5 | * Author: David 6 | */ 7 | 8 | 9 | #ifndef SRC_DISPLAY_DISPLAYORIENTATION_H_ 10 | #define SRC_DISPLAY_DISPLAYORIENTATION_H_ 11 | 12 | #include 13 | 14 | // Enumeration to define the orientation of the display. 15 | // To keep the code small and fast, we use individual bits to say what needs to be done on the display. 16 | // Then we define the supported orientations in terms of those bits. 17 | enum DisplayOrientation : uint8_t { 18 | Default = 0x00, 19 | SwapXY = 0x01, 20 | ReverseX = 0x02, 21 | ReverseY = 0x04, 22 | InvertText = ReverseY, 23 | InvertBitmap = ReverseX 24 | }; 25 | 26 | #endif /* SRC_DISPLAY_DISPLAYORIENTATION_H_ */ 27 | -------------------------------------------------------------------------------- /src/Display/ImageMenuItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ImageMenuItem.h 3 | * 4 | * Created on: 25 Apr 2022 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_DISPLAY_IMAGEMENUITEM_H_ 9 | #define SRC_DISPLAY_IMAGEMENUITEM_H_ 10 | 11 | #include "MenuItem.h" 12 | 13 | #if SUPPORT_DIRECT_LCD 14 | 15 | class ImageMenuItem final : public MenuItem 16 | { 17 | public: 18 | DECLARE_FREELIST_NEW_DELETE(ImageMenuItem) 19 | 20 | ImageMenuItem(PixelNumber r, PixelNumber c, const char *_ecv_array pFileName) noexcept; 21 | 22 | void Draw(Lcd &_ecv_from lcd, PixelNumber rightMargin, bool highlight) noexcept override; 23 | void UpdateWidthAndHeight(Lcd &_ecv_from lcd) noexcept override; 24 | 25 | private: 26 | String fileName; 27 | }; 28 | 29 | #endif 30 | 31 | #endif /* SRC_DISPLAY_IMAGEMENUITEM_H_ */ 32 | -------------------------------------------------------------------------------- /src/Display/Lcd/Fonts/LcdFont.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LcdFont.h 3 | * 4 | * Created on: 15 Jul 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_DISPLAY_LCD_FONTS_LCDFONT_H_ 9 | #define SRC_DISPLAY_LCD_FONTS_LCDFONT_H_ 10 | 11 | #include 12 | 13 | // Struct for describing a font table, always held in PROGMEM 14 | struct LcdFont 15 | { 16 | const uint8_t *_ecv_array ptr; // pointer to font table 17 | uint16_t startCharacter; // Unicode code point of the first character in the font 18 | uint16_t endCharacter; // Unicode code point of the last character in the font 19 | uint8_t height; // row height in pixels - only this number of pixels will be fetched and drawn - maximum 16 in this version of the software 20 | uint8_t width; // max character width in pixels (the font table contains this number of bytes or words per character, plus 1 for the active width) 21 | uint8_t numSpaces; // number of space columns between characters before kerning 22 | }; 23 | 24 | #endif /* SRC_DISPLAY_LCD_FONTS_LCDFONT_H_ */ 25 | -------------------------------------------------------------------------------- /src/Display/Lcd/ST7920/Lcd7920.h: -------------------------------------------------------------------------------- 1 | #ifndef LCD7920_H 2 | #define LCD7920_H 3 | 4 | #include "RepRapFirmware.h" 5 | 6 | #if SUPPORT_12864_LCD 7 | 8 | #include 9 | 10 | // Class for driving 128x64 graphical LCD fitted with ST7920 controller 11 | // This drives the GLCD in serial mode so that it needs just 2 pins. 12 | 13 | // Derive the LCD class from the Print class so that we can print stuff to it in alpha mode 14 | class Lcd7920 : public MonoLcd 15 | { 16 | public: 17 | // Construct a GLCD driver. 18 | Lcd7920(const LcdFont * const fnts[], size_t nFonts) noexcept; 19 | 20 | // Flush just some data, returning true if this needs to be called again 21 | bool FlushSome() noexcept override; 22 | 23 | // Get the display type 24 | DisplayControllerType GetControllerType() const noexcept override; 25 | 26 | protected: 27 | void HardwareInit() noexcept override; 28 | 29 | private: 30 | void CommandDelay() noexcept; 31 | void DataDelay() noexcept; 32 | void SendLcdCommand(uint8_t byteToSend) noexcept; 33 | void SendLcdData(uint8_t byteToSend) noexcept; 34 | void SetGraphicsAddress(unsigned int r, unsigned int c) noexcept; 35 | }; 36 | 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/Display/Lcd/TFTLcd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TFTLcd.cpp 3 | * 4 | * Created on: 6 May 2022 5 | * Author: David 6 | */ 7 | 8 | #include "TFTLcd.h" 9 | 10 | #if SUPPORT_ILI9488_LCD 11 | 12 | #if USE_FONT_CHIP 13 | TFTLcd::TFTLcd(PixelNumber nr, PixelNumber nc, Pin fontCsPin, SpiMode mode, uint8_t sercomNum) noexcept 14 | : Lcd(nr, nc, fontCsPin), 15 | #else 16 | TFTLcd::TFTLcd(PixelNumber nr, PixelNumber nc, const LcdFont * const fnts[], size_t nFonts, SpiMode mode, uint8_t sercomNum) noexcept 17 | : Lcd(nr, nc, fnts, nFonts), 18 | #endif 19 | spiDev(sercomNum), 20 | fgColour(Colours::White), bgColour(Colours::Blue), 21 | spiMode(mode) 22 | { 23 | } 24 | 25 | TFTLcd::~TFTLcd() 26 | { 27 | SetPinMode(csPin, INPUT_PULLUP); 28 | } 29 | 30 | // Get the SPI frequency 31 | uint32_t TFTLcd::GetSpiFrequency() const noexcept 32 | { 33 | return spiFrequency; 34 | } 35 | 36 | // Initialize the display 37 | void TFTLcd::Init(Pin p_csPin, Pin p_a0Pin, bool csPolarity, uint32_t freq, uint8_t p_contrastRatio, uint8_t p_resistorRatio) noexcept 38 | { 39 | csPin = p_csPin; 40 | csPol = csPolarity; 41 | spiFrequency = freq; 42 | spiDev.SetClockFrequencyAndMode(freq, spiMode, true); // note we currently always use 9-bit SPI 43 | SetPinMode(csPin, (csPolarity) ? OUTPUT_LOW : OUTPUT_HIGH); 44 | HardwareInit(); 45 | } 46 | 47 | #endif 48 | 49 | // End 50 | -------------------------------------------------------------------------------- /src/Display/Lcd/TFTLcd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TFTLcd.h 3 | * 4 | * Created on: 6 May 2022 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_DISPLAY_LCD_TFTLCD_H_ 9 | #define SRC_DISPLAY_LCD_TFTLCD_H_ 10 | 11 | #include "Lcd.h" 12 | #include 13 | 14 | #if SUPPORT_ILI9488_LCD 15 | 16 | // This class represents a TFT LCD that uses an exclusive SPI channel to send data to the screen 17 | class TFTLcd : public Lcd 18 | { 19 | public: 20 | #if USE_FONT_CHIP 21 | TFTLcd(PixelNumber nr, PixelNumber nc, Pin fontCsPin, SpiMode mode, uint8_t sercomNum) noexcept; 22 | #else 23 | TFTLcd(PixelNumber nr, PixelNumber nc, const LcdFont * const fnts[], size_t nFonts, SpiMode mode, uint8_t sercomNum) noexcept; 24 | #endif 25 | 26 | virtual ~TFTLcd(); 27 | 28 | // Get the SPI frequency 29 | uint32_t GetSpiFrequency() const noexcept override; 30 | 31 | // Initialize the display 32 | void Init(Pin p_csPin, Pin p_a0Pin, bool csPolarity, uint32_t freq, uint8_t p_contrastRatio, uint8_t p_resistorRatio) noexcept override; 33 | 34 | // Flush just some data, returning true if this needs to be called again 35 | bool FlushSome() noexcept override { return false; } 36 | 37 | // Set the foreground colour. Does nothing on monochrome displays. 38 | void SetForegroundColour(Colour col) noexcept override final { fgColour = col; } 39 | 40 | // Set the background colour. Does nothing on monochrome displays. 41 | void SetBackgroundColour(Colour col) noexcept override final { bgColour = col; } 42 | 43 | protected: 44 | virtual void HardwareInit() noexcept = 0; 45 | 46 | SpiDevice spiDev; 47 | Colour fgColour, bgColour; 48 | Pin csPin = NoPin; 49 | bool csPol; 50 | 51 | private: 52 | uint32_t spiFrequency = 0; 53 | SpiMode spiMode; 54 | }; 55 | 56 | #endif 57 | 58 | #endif /* SRC_DISPLAY_LCD_TFTLCD_H_ */ 59 | -------------------------------------------------------------------------------- /src/Display/ResistiveTouch.h: -------------------------------------------------------------------------------- 1 | /* 2 | UTouch.cpp - library support for Color TFT LCD Touch screens on SAM3X 3 | Originally based on Utouch library by Henning Karlsen. 4 | Rewritten by D Crocker using the approach described in TI app note http://www.ti.com/lit/pdf/sbaa036. 5 | */ 6 | 7 | #ifndef SRC_DISPLAY_RESISTIVE_TOUCH_H 8 | #define SRC_DISPLAY_RESISTIVE_TOUCH_H 9 | 10 | #include 11 | 12 | #if SUPPORT_RESISTIVE_TOUCH 13 | 14 | #include "DisplayOrientation.h" 15 | #include 16 | 17 | class ResistiveTouch 18 | { 19 | public: 20 | ResistiveTouch(Pin csp, Pin irqp) noexcept; 21 | 22 | void Init(uint16_t xp, uint16_t yp, DisplayOrientation orientationAdjust) noexcept; 23 | bool Read(uint16_t &x, uint16_t &y, bool &repeat, uint16_t* null rawX = nullptr, uint16_t *null rawY = nullptr) noexcept; 24 | void Calibrate(uint16_t xlow, uint16_t xhigh, uint16_t ylow, uint16_t yhigh, uint16_t margin) noexcept; 25 | 26 | private: 27 | SharedSpiClient spiDev; 28 | Pin csPin, irqPin; 29 | uint16_t disp_x_size, disp_y_size; 30 | uint16_t scaleX, scaleY; 31 | int16_t offsetX, offsetY; 32 | 33 | DisplayOrientation orientAdjust; 34 | bool pressed; 35 | 36 | bool GetData(bool wantY, uint16_t &rslt) noexcept; 37 | void WriteCommand(uint8_t command) noexcept; 38 | uint16_t ReadData(uint8_t command) noexcept; 39 | static uint16_t Diff(uint16_t a, uint16_t b) noexcept { return (a < b) ? b - a : a - b; } 40 | 41 | static constexpr uint32_t SpiFrequency = 2000000; // max supported by the XPT2046 is 2.5MHz 42 | }; 43 | 44 | #endif 45 | 46 | #endif // SRC_DISPLAY_RESISTIVE_TOUCH_H 47 | -------------------------------------------------------------------------------- /src/Display/RotaryEncoder.h: -------------------------------------------------------------------------------- 1 | #ifndef __RotaryEncoderIncluded 2 | #define __RotaryEncoderIncluded 3 | 4 | #include "RepRapFirmware.h" 5 | #include 6 | 7 | #if SUPPORT_ROTARY_ENCODER 8 | 9 | // Class to manage a rotary encoder with a push button 10 | class RotaryEncoder INHERIT_OBJECT_MODEL 11 | { 12 | const Pin pin0, pin1, pinButton; 13 | int ppc; 14 | int encoderChange; 15 | unsigned int encoderState; 16 | bool buttonState; 17 | bool newPress; 18 | bool reverseDirection; 19 | uint32_t whenSame; 20 | 21 | unsigned int ReadEncoderState() const noexcept; 22 | 23 | static constexpr uint32_t DebounceMillis = 5; 24 | 25 | public: 26 | RotaryEncoder(Pin p0, Pin p1, Pin pb) noexcept; 27 | 28 | void Init(int pulsesPerClick) noexcept; 29 | void Poll() noexcept; 30 | int GetChange() noexcept; 31 | bool GetButtonPress() noexcept; 32 | int GetPulsesPerClick() const noexcept { return ppc; } 33 | 34 | protected: 35 | DECLARE_OBJECT_MODEL 36 | }; 37 | 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/Display/TextMenuItem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TextMenuItem.cpp 3 | * 4 | * Created on: 25 Apr 2022 5 | * Author: David 6 | */ 7 | 8 | #include "TextMenuItem.h" 9 | 10 | #if SUPPORT_DIRECT_LCD 11 | 12 | TextMenuItem::TextMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, const char *_ecv_array t) noexcept 13 | : MenuItem(r, c, w, a, fn), text(t) 14 | { 15 | } 16 | 17 | void TextMenuItem::CorePrint(Lcd &_ecv_from lcd) noexcept 18 | { 19 | lcd.printf("%s", text); 20 | } 21 | 22 | void TextMenuItem::Draw(Lcd &_ecv_from lcd, PixelNumber rightMargin, bool highlight) noexcept 23 | { 24 | // We ignore the 'highlight' parameter because text items are not selectable 25 | if (IsVisible() && (!drawn || itemChanged)) 26 | { 27 | PrintAligned(lcd, rightMargin); 28 | itemChanged = false; 29 | drawn = true; 30 | } 31 | } 32 | 33 | void TextMenuItem::UpdateWidthAndHeight(Lcd &_ecv_from lcd) noexcept 34 | { 35 | if (width == 0) 36 | { 37 | lcd.SetFont(fontNumber); 38 | lcd.SetCursor(lcd.GetNumRows(), 0); 39 | lcd.SetRightMargin(lcd.GetNumCols()); 40 | lcd.TextInvert(false); 41 | lcd.printf("%s", text); 42 | width = lcd.GetColumn(); 43 | if (align == LeftAlign) 44 | { 45 | ++width; // add a space column after left-aligned text with no explicit width, so that the next item can follow immediately 46 | } 47 | } 48 | if (height == 0) 49 | { 50 | lcd.SetFont(fontNumber); 51 | height = lcd.GetFontHeight(); 52 | } 53 | } 54 | 55 | #endif 56 | 57 | // End 58 | -------------------------------------------------------------------------------- /src/Display/TextMenuItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TextMenuItem.h 3 | * 4 | * Created on: 25 Apr 2022 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_DISPLAY_TEXTMENUITEM_H_ 9 | #define SRC_DISPLAY_TEXTMENUITEM_H_ 10 | 11 | #include "MenuItem.h" 12 | 13 | #if SUPPORT_DIRECT_LCD 14 | 15 | class TextMenuItem final : public MenuItem 16 | { 17 | public: 18 | DECLARE_FREELIST_NEW_DELETE(TextMenuItem) 19 | 20 | TextMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, const char *_ecv_array t) noexcept; 21 | void Draw(Lcd &_ecv_from lcd, PixelNumber maxWidth, bool highlight) noexcept override; 22 | void UpdateWidthAndHeight(Lcd &_ecv_from lcd) noexcept override; 23 | 24 | protected: 25 | void CorePrint(Lcd &_ecv_from lcd) noexcept override; 26 | 27 | private: 28 | const char *_ecv_array text; 29 | }; 30 | 31 | #endif 32 | 33 | #endif /* SRC_DISPLAY_TEXTMENUITEM_H_ */ 34 | -------------------------------------------------------------------------------- /src/DuetNG/DueXn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DueXn.h 3 | * 4 | * Created on: 19 Oct 2016 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_DUETNG_DUEXN_H_ 9 | #define SRC_DUETNG_DUEXN_H_ 10 | 11 | #include 12 | 13 | enum class ExpansionBoardType : uint8_t 14 | { 15 | none, 16 | DueX0, 17 | DueX2, 18 | DueX2_v0_11 = (uint8_t)DueX2 + 1, 19 | DueX5, 20 | DueX5_v0_11 = (uint8_t)DueX5 + 1 21 | }; 22 | 23 | namespace DuetExpansion 24 | { 25 | ExpansionBoardType DueXnInit() noexcept; // Look for a DueXn, initialise it and return which expansion board is attached 26 | void Exit() noexcept; // Stop the expander polling task 27 | void AdditionalOutputInit() noexcept; // Look for an additional output pin expander 28 | void DueXnTaskInit() noexcept; // Create the DueXn task and enable the associated interrupt from the DueXn 29 | const char* _ecv_array null GetExpansionBoardName() noexcept; // Return the name of the expansion board, or nullptr if no expansion board 30 | const char* _ecv_array null GetAdditionalExpansionBoardName() noexcept; // Return the name of the additional expansion board, or nullptr if no expansion board 31 | void SetPinMode(Pin pin, PinMode mode, bool debounce) noexcept; // Set the I/O mode of a pin 32 | bool DigitalRead(Pin pin) noexcept; // Read a pin 33 | void DigitalWrite(Pin pin, bool high) noexcept; // Write a pin 34 | void AnalogOut(Pin pin, float pwm) noexcept; // Set the PWM value on this pin 35 | uint16_t DiagnosticRead() noexcept; // Diagnose the SX1509 by setting all pins as inputs and reading them 36 | void Diagnostics(const StringRef& reply) noexcept; // Print diagnostic data 37 | } 38 | 39 | #endif /* SRC_DUETNG_DUEXN_H_ */ 40 | -------------------------------------------------------------------------------- /src/Endstops/Endstop.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Endstop.cpp 3 | * 4 | * Created on: 4 Apr 2019 5 | * Author: David 6 | */ 7 | 8 | #include "Endstop.h" 9 | 10 | // Endstop base class 11 | #if SUPPORT_TMC2660 || SUPPORT_TMC51xx 12 | LocalDriversBitmap EndstopOrZProbe::stalledDrivers; // used to track which drivers are reported as stalled, for stall detect endstops and stall detect Z probes 13 | #endif 14 | 15 | #if SUPPORT_OBJECT_MODEL 16 | 17 | // Object model table and functions 18 | // Note: if using GCC version 7.3.1 20180622 and lambda functions are used in this table, you must compile this file with option -std=gnu++17. 19 | // Otherwise the table will be allocated in RAM instead of flash, which wastes too much RAM. 20 | 21 | // Macro to build a standard lambda function that includes the necessary type conversions 22 | #define OBJECT_MODEL_FUNC(...) OBJECT_MODEL_FUNC_BODY(Endstop, __VA_ARGS__) 23 | #define OBJECT_MODEL_FUNC_IF(_condition,...) OBJECT_MODEL_FUNC_IF_BODY(Endstop, _condition,__VA_ARGS__) 24 | 25 | constexpr ObjectModelTableEntry Endstop::objectModelTable[] = 26 | { 27 | // Within each group, these entries must be in alphabetical order 28 | // 0. Endstop members 29 | { "highEnd", OBJECT_MODEL_FUNC(self->GetAtHighEnd()), ObjectModelEntryFlags::none }, 30 | { "probe", OBJECT_MODEL_FUNC_IF(self->IsZProbe(), (int32_t)self->GetZProbeNumber()), ObjectModelEntryFlags::none }, 31 | { "triggered", OBJECT_MODEL_FUNC(self->Stopped()), ObjectModelEntryFlags::live }, 32 | { "type", OBJECT_MODEL_FUNC(self->GetEndstopType().ToString()), ObjectModelEntryFlags::none }, 33 | }; 34 | 35 | constexpr uint8_t Endstop::objectModelTableDescriptor[] = { 1, 4 }; 36 | 37 | DEFINE_GET_OBJECT_MODEL_TABLE(Endstop) 38 | 39 | #endif 40 | 41 | Endstop::Endstop(uint8_t p_axis, EndStopPosition pos) noexcept 42 | : EndstopOrZProbe(p_axis), atHighEnd(pos == EndStopPosition::highEndStop) 43 | { 44 | } 45 | 46 | // End 47 | -------------------------------------------------------------------------------- /src/Endstops/ZProbeEndstop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZProbeEndstop.h 3 | * 4 | * Created on: 15 Sep 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_ENDSTOPS_ZPROBEENDSTOP_H_ 9 | #define SRC_ENDSTOPS_ZPROBEENDSTOP_H_ 10 | 11 | #include "Endstop.h" 12 | 13 | class ZProbeEndstop final : public Endstop 14 | { 15 | public: 16 | DECLARE_FREELIST_NEW_DELETE(ZProbeEndstop) 17 | 18 | ZProbeEndstop(uint8_t p_axis, EndStopPosition pos, size_t zProbeNum) noexcept; 19 | 20 | EndStopType GetEndstopType() const noexcept override { return EndStopType::zProbeAsEndstop; } 21 | bool IsZProbe() const noexcept override { return true; } 22 | int GetZProbeNumber() const noexcept override { return zProbeNumber; } 23 | bool Stopped() const noexcept override; 24 | void PrimeAxis(const Kinematics &_ecv_from kin, const AxisDriversConfig& axisDrivers, float speed) THROWS(GCodeException) override; 25 | EndstopHitDetails CheckTriggered() noexcept override; 26 | bool Acknowledge(EndstopHitDetails what) noexcept override; 27 | void AppendDetails(const StringRef& str) noexcept override; 28 | 29 | private: 30 | size_t zProbeNumber; // which Z probe to use, always 0 for now 31 | bool stopAll; 32 | }; 33 | 34 | #endif /* SRC_ENDSTOPS_ZPROBEENDSTOP_H_ */ 35 | -------------------------------------------------------------------------------- /src/Fans/RemoteFan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RemoteFan.h 3 | * 4 | * Created on: 3 Sep 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_FANS_REMOTEFAN_H_ 9 | #define SRC_FANS_REMOTEFAN_H_ 10 | 11 | #include "Fan.h" 12 | 13 | #if SUPPORT_CAN_EXPANSION 14 | 15 | class RemoteFan : public Fan 16 | { 17 | public: 18 | RemoteFan(unsigned int fanNum, CanAddress boardNum) noexcept; 19 | ~RemoteFan() noexcept; 20 | 21 | bool Check(bool checkSensors) noexcept override; // update the fan PWM returning true if it is a thermostatic fan that is on 22 | bool IsEnabled() const noexcept override; 23 | int32_t GetRPM() const noexcept override { return lastRpm; } 24 | float GetPwm() const noexcept override { return lastPwm; } 25 | GCodeResult SetFanParameters(bool setFreq, PwmFrequency freq, bool setPpr, float ppr, const StringRef& reply) noexcept override; 26 | GCodeResult ReportPortDetails(const StringRef& str) const noexcept override; 27 | void UpdateFromRemote(CanAddress src, const FanReport& report) noexcept override; 28 | #if SUPPORT_REMOTE_COMMANDS 29 | bool IsLocal() const noexcept override { return false; } 30 | #endif 31 | 32 | GCodeResult ConfigurePort(const char *pinNames, PwmFrequency freq, float ppr, const StringRef& reply) noexcept; 33 | 34 | protected: 35 | bool UpdateFanConfiguration(const StringRef& reply) noexcept override; 36 | GCodeResult Refresh(const StringRef& reply) noexcept override; 37 | 38 | private: 39 | int32_t lastRpm; 40 | float lastPwm; 41 | uint32_t whenLastReportReceived; 42 | CanAddress boardNumber; 43 | }; 44 | 45 | #endif 46 | 47 | #endif /* SRC_FANS_REMOTEFAN_H_ */ 48 | -------------------------------------------------------------------------------- /src/FilamentMonitors/SimpleFilamentMonitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SimpleFilamentSensor.h 3 | * 4 | * Created on: 20 Jul 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_FILAMENTSENSORS_SIMPLEFILAMENTMONITOR_H_ 9 | #define SRC_FILAMENTSENSORS_SIMPLEFILAMENTMONITOR_H_ 10 | 11 | #include "FilamentMonitor.h" 12 | 13 | class SimpleFilamentMonitor : public FilamentMonitor 14 | { 15 | public: 16 | SimpleFilamentMonitor(unsigned int drv, unsigned int monitorType, DriverId did) noexcept; 17 | 18 | protected: 19 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& seen) THROWS(GCodeException) override; 20 | void Diagnostics(const StringRef& reply) noexcept override; 21 | #if SUPPORT_REMOTE_COMMANDS 22 | GCodeResult Configure(const CanMessageGenericParser& parser, const StringRef& reply) noexcept override; 23 | void GetLiveData(FilamentMonitorDataNew2& data) const noexcept override; 24 | #endif 25 | FilamentSensorStatus Check(bool isPrinting, bool fromIsr, uint32_t isrMillis, float filamentConsumed) noexcept override; 26 | FilamentSensorStatus Clear() noexcept override; 27 | 28 | #if SUPPORT_CAN_EXPANSION 29 | void UpdateLiveData(const FilamentMonitorDataNew2& data) noexcept override; 30 | #endif 31 | 32 | bool Interrupt() noexcept override; 33 | const char *_ecv_array GetTypeText() const noexcept override { return "simple"; } 34 | 35 | private: 36 | void Poll() noexcept; 37 | 38 | bool highWhenNoFilament; 39 | bool filamentPresent; 40 | }; 41 | 42 | #endif /* SRC_FILAMENTSENSORS_SIMPLEFILAMENTMONITOR_H_ */ 43 | -------------------------------------------------------------------------------- /src/GCodes/CollisionAvoider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CollisionAvoider.h 3 | * 4 | * Created on: 15 Aug 2022 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_GCODES_COLLISIONAVOIDER_H_ 9 | #define SRC_GCODES_COLLISIONAVOIDER_H_ 10 | 11 | #include 12 | 13 | #if SUPPORT_ASYNC_MOVES 14 | 15 | #include 16 | 17 | class CollisionAvoider 18 | { 19 | public: 20 | CollisionAvoider() noexcept; 21 | 22 | bool IsValid() const noexcept; 23 | int GetLowerAxis() const noexcept { return lowerAxis; } 24 | int GetUpperAxis() const noexcept { return upperAxis; } 25 | float GetMinSeparation()const noexcept { return minSeparation; } 26 | 27 | // Reset the position accumulators 28 | void ResetPositions(const float positions[], AxesBitmap whichPositions) noexcept; 29 | 30 | // If the new move doesn't risk a collision, update the position accumulators and return true; else return false 31 | bool UpdatePositions(const float axisPositions[], AxesBitmap axesHomed) noexcept; 32 | 33 | // Set the parameters 34 | void Set(int axisL, int axisH, float sep) noexcept; 35 | 36 | private: 37 | float minSeparation; 38 | float lowerAxisMax; 39 | float upperAxisMin; 40 | int lowerAxis; 41 | int upperAxis; 42 | }; 43 | 44 | #endif 45 | 46 | #endif /* SRC_GCODES_COLLISIONAVOIDER_H_ */ 47 | -------------------------------------------------------------------------------- /src/GCodes/GCodeChannel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GCodeChannel.h 3 | * 4 | * Created on: 04 Jul 2019 5 | * Author: Christian 6 | */ 7 | 8 | #ifndef SRC_GCODES_GCODEBUFFER_CODECHANNEL_H_ 9 | #define SRC_GCODES_GCODEBUFFER_CODECHANNEL_H_ 10 | 11 | #include 12 | #include 13 | 14 | // The Microchip device library for SAME5x defines USB as the USB peripheral. 15 | // We can't change the channel name to something else because it breaks compatibility with DSF, so #undef it here 16 | #ifdef USB 17 | # undef USB 18 | #endif 19 | 20 | NamedEnum(GCodeChannel, uint8_t, HTTP, Telnet, File, USB, Aux, Trigger, Queue, LCD, SBC, Daemon, Aux2, Autopause, File2, Queue2); 21 | 22 | constexpr size_t NumGCodeChannels = GCodeChannel::NumValues; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/GCodes/GCodeFileInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GCodeFileInfo.cpp 3 | * 4 | * Created on: 11 Jan 2020 5 | * Author: David 6 | */ 7 | 8 | #include "GCodeFileInfo.h" 9 | 10 | void GCodeFileInfo::Init() noexcept 11 | { 12 | isValid = false; 13 | incomplete = true; 14 | objectHeight = 0.0; 15 | layerHeight = 0.0; 16 | numLayers = 0; 17 | printTime = simulatedTime = 0; 18 | numFilaments = 0; 19 | lastModifiedTime = 0; 20 | generatedBy.Clear(); 21 | fileSize = 0; 22 | headerSize = 0; 23 | for (float& f : filamentNeeded) 24 | { 25 | f = 0.0; 26 | } 27 | for (ThumbnailInfo& th : thumbnails) 28 | { 29 | th.Invalidate(); 30 | } 31 | } 32 | 33 | // End 34 | -------------------------------------------------------------------------------- /src/GCodes/GCodeFileInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GCodeFileInfo.h 3 | * 4 | * Created on: 1 Apr 2019 5 | * Author: Christian 6 | */ 7 | 8 | #ifndef SRC_GCODES_GCODEFILEINFO_H_ 9 | #define SRC_GCODES_GCODEFILEINFO_H_ 10 | 11 | #include "RepRapFirmware.h" 12 | 13 | // Struct to hold GCode file information 14 | struct GCodeFileInfo 15 | { 16 | struct ThumbnailInfo 17 | { 18 | NamedEnum(ImageFormat, uint8_t, png, qoi, jpeg); 19 | FilePosition offset; 20 | uint32_t size; 21 | uint16_t width, height; 22 | ImageFormat format; 23 | 24 | ThumbnailInfo() noexcept : width(0), format(ImageFormat::png) { } 25 | bool IsValid() const noexcept { return width != 0; } 26 | void Invalidate() noexcept { width = 0; } 27 | }; 28 | 29 | GCodeFileInfo() noexcept { Init(); } 30 | void Init() noexcept; 31 | 32 | FilePosition fileSize; 33 | FilePosition headerSize; 34 | time_t lastModifiedTime; 35 | float layerHeight; 36 | unsigned int numLayers; 37 | float objectHeight; 38 | float filamentNeeded[MaxFilaments]; 39 | uint32_t printTime; 40 | uint32_t simulatedTime; 41 | unsigned int numFilaments; 42 | bool isValid; 43 | bool incomplete; 44 | ThumbnailInfo thumbnails[MaxThumbnails]; 45 | String generatedBy; 46 | }; 47 | 48 | #endif /* SRC_GCODES_GCODEFILEINFO_H_ */ 49 | -------------------------------------------------------------------------------- /src/GCodes/RestorePoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RestorePoint.h 3 | * 4 | * Created on: 14 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_GCODES_RESTOREPOINT_H_ 9 | #define SRC_GCODES_RESTOREPOINT_H_ 10 | 11 | #include 12 | #include 13 | 14 | class RestorePoint INHERIT_OBJECT_MODEL 15 | { 16 | public: 17 | float moveCoords[MaxAxes]; // The user coordinates when we paused 18 | float feedRate; // The feed rate for the current move 19 | float virtualExtruderPosition; // The virtual extruder position at the start of this move 20 | float proportionDone; // How much of this move we have already done (zero unless we interrupted a move) 21 | FilePosition filePos; // The file position that this move was read from 22 | float initialUserC0, initialUserC1; // If we paused during an arc move and proportionDone is nonzero, the X and Y user coordinates at the start of the move 23 | int toolNumber; // The tool number that was active 24 | float fanSpeed; // the last fan speed that was set by M106 with no P parameter 25 | 26 | #if SUPPORT_LASER || SUPPORT_IOBITS 27 | LaserPwmOrIoBits laserPwmOrIoBits; // The output port bits setting for this move, or the laser power 28 | #endif 29 | 30 | #if SUPPORT_LASER 31 | LaserPixelData laserPixelData; 32 | #endif 33 | 34 | RestorePoint() noexcept; 35 | void Init() noexcept; 36 | 37 | protected: 38 | DECLARE_OBJECT_MODEL_WITH_ARRAYS 39 | }; 40 | 41 | #endif /* SRC_GCODES_RESTOREPOINT_H_ */ 42 | -------------------------------------------------------------------------------- /src/GCodes/SimulationMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SimulationMode.h 3 | * 4 | * Created on: 12 Dec 2023 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_GCODES_SIMULATIONMODE_H_ 9 | #define SRC_GCODES_SIMULATIONMODE_H_ 10 | 11 | #include 12 | 13 | enum class SimulationMode : uint8_t 14 | { off = 0, // not simulating 15 | debug, // simulating step generation 16 | normal, // not generating steps, just timing 17 | partial, // generating DDAs but doing nothing with them 18 | highest = partial 19 | }; 20 | 21 | #endif /* SRC_GCODES_SIMULATIONMODE_H_ */ 22 | -------------------------------------------------------------------------------- /src/GCodes/StraightProbeSettings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * StraightProbeSettings.cpp 3 | * 4 | * Created on: 4 Oct 2019 5 | * Author: manuel 6 | */ 7 | 8 | #include "StraightProbeSettings.h" 9 | #include 10 | 11 | StraightProbeSettings::StraightProbeSettings() noexcept 12 | { 13 | Reset(); 14 | } 15 | 16 | void StraightProbeSettings::Reset() noexcept 17 | { 18 | feedRateOverride = 0.0; 19 | movingAxes = AxesBitmap(); 20 | type = StraightProbeType::unset; 21 | for (size_t axis = 0; axis < MaxAxes; ++axis) 22 | { 23 | target[axis] = 0.0; 24 | } 25 | } 26 | 27 | void StraightProbeSettings::SetCoordsToTarget(float coords[MaxAxes]) const noexcept 28 | { 29 | for (size_t axis = 0; axis < MaxAxes; ++axis) 30 | { 31 | coords[axis] = target[axis]; 32 | } 33 | } 34 | 35 | // End 36 | -------------------------------------------------------------------------------- /src/GCodes/TriggerItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Trigger.h 3 | * 4 | * Created on: 6 Jun 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_GCODES_TRIGGERITEM_H_ 9 | #define SRC_GCODES_TRIGGERITEM_H_ 10 | 11 | #include 12 | #include 13 | 14 | class TriggerItem 15 | { 16 | public: 17 | TriggerItem() noexcept; 18 | 19 | void Init() noexcept; 20 | 21 | // Return true if this trigger is unused, i.e. it doesn't watch any pins 22 | bool IsUnused() const noexcept; 23 | 24 | // Check whether this trigger is active and update the input states 25 | bool Check() noexcept; 26 | 27 | // Handle M581 for this trigger 28 | GCodeResult Configure(unsigned int number, GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); 29 | 30 | // Handle M582 for this trigger 31 | bool CheckLevel() noexcept; 32 | 33 | private: 34 | static void AppendInputNames(AxesBitmap endstops, InputPortsBitmap inputs, const StringRef& reply) noexcept; 35 | 36 | AxesBitmap highLevelEndstops, lowLevelEndstops, endstopStates; 37 | InputPortsBitmap highLevelInputs, lowLevelInputs, inputStates; 38 | int8_t condition; 39 | }; 40 | 41 | #endif /* SRC_GCODES_TRIGGERITEM_H_ */ 42 | -------------------------------------------------------------------------------- /src/GPIO/GpInPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GpInPort.h 3 | * 4 | * Created on: 11 Feb 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_GPIO_GPINPORT_H_ 9 | #define SRC_GPIO_GPINPORT_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #if SUPPORT_CAN_EXPANSION 16 | # include 17 | #endif 18 | 19 | class GpInputPort INHERIT_OBJECT_MODEL 20 | { 21 | public: 22 | GpInputPort() noexcept : 23 | #if SUPPORT_CAN_EXPANSION 24 | boardAddress(CanInterface::GetCanAddress()), 25 | #endif 26 | currentState(false) { } 27 | GpInputPort(const GpInputPort&) = delete; 28 | 29 | bool GetState() const noexcept; 30 | bool IsUnused() const noexcept; 31 | 32 | #if SUPPORT_CAN_EXPANSION 33 | void SetState(CanAddress src, bool b) noexcept { if (src == boardAddress) { currentState = b; } } 34 | #endif 35 | 36 | GCodeResult Configure(uint32_t gpinNumber, GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); 37 | 38 | protected: 39 | DECLARE_OBJECT_MODEL 40 | 41 | private: 42 | IoPort port; // will be initialised by PwmPort default constructor 43 | #if SUPPORT_CAN_EXPANSION 44 | RemoteInputHandle handle; 45 | CanAddress boardAddress; 46 | #endif 47 | bool currentState; 48 | }; 49 | 50 | #endif /* SRC_GPIO_GPINPORT_H_ */ 51 | -------------------------------------------------------------------------------- /src/GPIO/GpOutPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GpOutPort.h 3 | * 4 | * Created on: 11 Feb 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_GPIO_GPOUTPORT_H_ 9 | #define SRC_GPIO_GPOUTPORT_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | class CanMessageGenericParser; 16 | 17 | class GpOutputPort INHERIT_OBJECT_MODEL 18 | { 19 | public: 20 | GpOutputPort() noexcept 21 | : lastPwm(0.0) 22 | #if SUPPORT_CAN_EXPANSION 23 | , boardAddress(CanInterface::GetCanAddress()) 24 | #endif 25 | { } 26 | 27 | GpOutputPort(const GpOutputPort&) = delete; 28 | 29 | bool IsUnused() const noexcept; 30 | #if SUPPORT_CAN_EXPANSION 31 | bool IsLocal() const noexcept; 32 | #endif 33 | GCodeResult WriteAnalog(uint32_t gpioPortNumber, bool isServo, float pwm, const GCodeBuffer& gb, const StringRef& reply) noexcept; 34 | void WriteDigital(bool value) noexcept; 35 | GCodeResult Configure(uint32_t gpioNumber, bool isServo, GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); 36 | PwmFrequency GetPwmFrequency() const noexcept { return port.GetFrequency(); } 37 | void WriteAnalog(float pwm) noexcept; 38 | 39 | #if SUPPORT_REMOTE_COMMANDS 40 | GCodeResult AssignFromRemote(uint32_t gpioPortNumber, const CanMessageGenericParser& parser, const StringRef& reply) noexcept; 41 | #endif 42 | 43 | #ifdef PCCB 44 | void Assign(const char *pinName) noexcept; 45 | #endif 46 | 47 | protected: 48 | DECLARE_OBJECT_MODEL 49 | 50 | private: 51 | PwmPort port; // will be initialised by PwmPort default constructor 52 | float lastPwm; 53 | #if SUPPORT_CAN_EXPANSION 54 | CanAddress boardAddress; 55 | #endif 56 | }; 57 | 58 | #endif /* SRC_GPIO_GPOUTPORT_H_ */ 59 | -------------------------------------------------------------------------------- /src/Hardware/ExceptionHandlers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CrashHandlers.h 3 | * 4 | * Created on: 24 Aug 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_EXCEPTIONHANDLERS_H_ 9 | #define SRC_HARDWARE_EXCEPTIONHANDLERS_H_ 10 | 11 | #include "SoftwareReset.h" 12 | 13 | [[noreturn]] void SoftwareReset(SoftwareResetReason initialReason, const uint32_t *_ecv_array _ecv_null stk = nullptr) noexcept; 14 | [[noreturn]] void OutOfMemoryHandler() noexcept; 15 | 16 | #endif /* SRC_HARDWARE_EXCEPTIONHANDLERS_H_ */ 17 | -------------------------------------------------------------------------------- /src/Hardware/I2C.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C.cpp 3 | * 4 | * Created on: 13 May 2019 5 | * Author: David 6 | */ 7 | 8 | #include "I2C.h" 9 | #include 10 | #include 11 | 12 | #if defined(I2C_IFACE) 13 | static bool i2cInitialised = false; 14 | #endif 15 | 16 | // Initialise the I2C interface, if not already done 17 | void I2C::Init() noexcept 18 | { 19 | #if defined(I2C_IFACE) 20 | if (!i2cInitialised) 21 | { 22 | MutexLocker lock(Tasks::GetI2CMutex()); 23 | if (!i2cInitialised) // test it again, now that we own the mutex 24 | { 25 | NVIC_SetPriority(I2C_IRQn, NvicPriorityTwi); // we use I2C to talk to the DueX before Platform::InitialiseInterrupts is called, so need to do this here 26 | I2C_IFACE.BeginMaster(I2cClockFreq); 27 | i2cInitialised = true; 28 | } 29 | } 30 | #endif 31 | } 32 | 33 | #if defined(I2C_IFACE) 34 | 35 | #include "RTOSIface/RTOSIface.h" 36 | 37 | static TaskHandle _ecv_null twiTask = nullptr; // the task that is waiting for a TWI command to complete 38 | 39 | extern "C" void WIRE_ISR_HANDLER() noexcept 40 | { 41 | WIRE_INTERFACE->TWI_IDR = 0xFFFFFFFFu; 42 | TaskBase::GiveFromISR(twiTask, NotifyIndices::I2C); // wake up the task 43 | twiTask = nullptr; 44 | } 45 | 46 | uint32_t I2C::statusWaitFunc(Twi *twi, uint32_t bitsToWaitFor) noexcept 47 | { 48 | bool ok = true; 49 | uint32_t sr = twi->TWI_SR; 50 | while (ok && (sr & bitsToWaitFor) == 0) 51 | { 52 | // Suspend this task until we get an interrupt indicating that a status bit that we are interested in has been set 53 | twiTask = TaskBase::GetCallerTaskHandle(); 54 | twi->TWI_IDR = 0xFFFFFFFFu; 55 | twi->TWI_IER = bitsToWaitFor; 56 | NVIC_EnableIRQ(I2C_IRQn); 57 | ok = TaskBase::TakeIndexed(NotifyIndices::I2C, 2); 58 | twiTask = nullptr; 59 | twi->TWI_IDR = 0xFFFFFFFFu; 60 | sr = twi->TWI_SR; 61 | } 62 | return sr; 63 | } 64 | 65 | #endif 66 | 67 | // End 68 | -------------------------------------------------------------------------------- /src/Hardware/I2C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C.h 3 | * 4 | * Created on: 13 May 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_I2C_H_ 9 | #define SRC_HARDWARE_I2C_H_ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef I2C_IFACE 15 | # include 16 | # include "Wire.h" 17 | #endif 18 | 19 | namespace I2C 20 | { 21 | void Init() noexcept; 22 | 23 | #ifdef I2C_IFACE 24 | 25 | uint32_t statusWaitFunc(Twi *twi, uint32_t bitsToWaitFor) noexcept; 26 | 27 | // Transfer data to/from an I2C peripheral. 28 | // If the caller needs to do multiple I2C transactions without being interrupted, it should own the i2C mutex before calling this. 29 | // Otherwise the caller need not own the mutex because it will be acquired here. 30 | inline size_t Transfer(uint16_t address, uint8_t *_ecv_array buffer, size_t numToWrite, size_t numToRead) noexcept 31 | { 32 | MutexLocker Lock(Tasks::GetI2CMutex()); 33 | return I2C_IFACE.Transfer(address, buffer, numToWrite, numToRead, statusWaitFunc); 34 | } 35 | 36 | #endif 37 | 38 | } 39 | 40 | #endif /* SRC_HARDWARE_I2C_H_ */ 41 | -------------------------------------------------------------------------------- /src/Hardware/SAM4E/Devices.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Devices.h 3 | * 4 | * Created on: 11 Aug 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SAM4E_DEVICES_H_ 9 | #define SRC_HARDWARE_SAM4E_DEVICES_H_ 10 | 11 | #include 12 | 13 | extern AsyncSerial serialUart; 14 | extern AsyncSerial serialWiFi; 15 | 16 | #define SUPPORT_USB 1 // needed by SerialCDC.h 17 | #include 18 | 19 | extern SerialCDC serialUSB; 20 | 21 | #include 22 | extern TwoWire Wire; 23 | 24 | void DeviceInit() noexcept; 25 | void StopAnalogTask() noexcept; 26 | void StopUsbTask() noexcept; 27 | 28 | #endif /* SRC_HARDWARE_SAM4E_DEVICES_H_ */ 29 | -------------------------------------------------------------------------------- /src/Hardware/SAM4E/Main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Main.cpp 3 | * Program entry point 4 | * Created on: 11 Jul 2020 5 | * Author: David 6 | * License: GNU GPL version 3 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | // Program initialisation 13 | void AppInit() noexcept 14 | { 15 | // When the reset button is pressed on pre-production Duet WiFi boards, if the TMC2660 drivers were previously enabled then we get 16 | // uncommanded motor movements if the STEP lines pick up any noise. Try to reduce that by initialising the pins that control the drivers early here. 17 | // On the production boards the ENN line is pulled high by an external pullup resistor and that prevents motor movements. 18 | // We no longer do the direction pins because we use some of those as board version indicators. 19 | for (size_t drive = 0; drive < MaxSmartDrivers; ++drive) 20 | { 21 | SetPinMode(STEP_PINS[drive], OUTPUT_LOW); 22 | SetPinMode(ENABLE_PINS[drive], OUTPUT_HIGH); 23 | } 24 | } 25 | 26 | // End 27 | -------------------------------------------------------------------------------- /src/Hardware/SAM4E/PinDescription.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PinDescription.h 3 | * 4 | * Created on: 10 Jul 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SAM4E_PINDESCRIPTION_H_ 9 | #define SRC_HARDWARE_SAM4E_PINDESCRIPTION_H_ 10 | 11 | #include 12 | 13 | // Enum to represent allowed types of pin access 14 | // We don't have a separate bit for servo, because Duet PWM-capable ports can be used for servos if they are on the Duet main board 15 | enum class PinCapability: uint8_t 16 | { 17 | // Individual capabilities 18 | none = 0u, 19 | read = 1u, 20 | ain = 2u, 21 | write = 4u, 22 | pwm = 8u, 23 | 24 | // Combinations 25 | ainr = 1u|2u, 26 | rw = 1u|4u, 27 | wpwm = 4u|8u, 28 | rwpwm = 1u|4u|8u, 29 | ainrw = 1u|2u|4u, 30 | ainrwpwm = 1u|2u|4u|8u 31 | }; 32 | 33 | constexpr inline PinCapability operator|(PinCapability a, PinCapability b) noexcept 34 | { 35 | return (PinCapability)((uint8_t)a | (uint8_t)b); 36 | } 37 | 38 | // The pin description says what functions are available on each pin, filtered to avoid allocating the same function to more than one pin.. 39 | // It is a struct not a class so that it can be direct initialised in read-only memory. 40 | struct PinDescription : public PinDescriptionBase 41 | { 42 | PinCapability cap; 43 | const char* _ecv_array null pinNames; 44 | 45 | PinCapability GetCapability() const noexcept { return cap; } 46 | const char* _ecv_array null GetNames() const noexcept { return pinNames; } 47 | }; 48 | 49 | #endif /* SRC_HARDWARE_SAM4E_PINDESCRIPTION_H_ */ 50 | -------------------------------------------------------------------------------- /src/Hardware/SAM4S/Devices.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Devices.cpp 3 | * 4 | * Created on: 11 Aug 2020 5 | * Author: David 6 | */ 7 | 8 | #include "Devices.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #ifndef PCCB 16 | AsyncSerial serialUart (UART1, UART1_IRQn, ID_UART1, 512, 512, [](AsyncSerial*) noexcept { }, [](AsyncSerial*) noexcept { }); 17 | 18 | void UART1_Handler(void) noexcept 19 | { 20 | serialUart.IrqHandler(); 21 | } 22 | 23 | void SerialInit() noexcept 24 | { 25 | SetPinFunction(APIN_Serial0_RXD, Serial0PeriphMode); 26 | SetPinFunction(APIN_Serial0_TXD, Serial0PeriphMode); 27 | EnablePullup(APIN_Serial0_RXD); 28 | } 29 | #endif 30 | 31 | SerialCDC serialUSB; 32 | 33 | void SdhcInit() noexcept 34 | { 35 | SetPinFunction(HsmciClockPin, HsmciPinsFunction); 36 | for (Pin p : HsmciOtherPins) 37 | { 38 | SetPinFunction(p, HsmciPinsFunction); 39 | EnablePullup(p); 40 | } 41 | } 42 | 43 | void WireInit() noexcept 44 | { 45 | pmc_enable_periph_clk(WIRE_INTERFACE_ID); 46 | SetPinFunction(TWI_Data, TWIPeriphMode); 47 | SetPinFunction(TWI_CK, TWIPeriphMode); 48 | 49 | NVIC_DisableIRQ(WIRE_ISR_ID); 50 | NVIC_ClearPendingIRQ(WIRE_ISR_ID); 51 | } 52 | 53 | TwoWire Wire(WIRE_INTERFACE, WireInit); 54 | 55 | 56 | // Device initialisation 57 | void DeviceInit() noexcept 58 | { 59 | LegacyAnalogIn::AnalogInInit(); 60 | AnalogOut::Init(); 61 | 62 | #ifndef PCCB 63 | SerialInit(); 64 | #endif 65 | SdhcInit(); 66 | 67 | #ifndef PCCB 68 | // Set up PB4..PB7 as normal I/O, not JTAG 69 | matrix_set_system_io(CCFG_SYSIO_SYSIO4 | CCFG_SYSIO_SYSIO5 | CCFG_SYSIO_SYSIO6 | CCFG_SYSIO_SYSIO7); 70 | #endif 71 | } 72 | 73 | void StopAnalogTask() noexcept 74 | { 75 | } 76 | 77 | void StopUsbTask() noexcept 78 | { 79 | } 80 | 81 | // End 82 | -------------------------------------------------------------------------------- /src/Hardware/SAM4S/Devices.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Devices.h 3 | * 4 | * Created on: 11 Aug 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SAM4S_DEVICES_H_ 9 | #define SRC_HARDWARE_SAM4S_DEVICES_H_ 10 | 11 | #ifndef PCCB 12 | # include 13 | # include 14 | 15 | extern AsyncSerial serialUart; 16 | #endif 17 | 18 | #define SUPPORT_USB 1 // needed by SerialCDC.h 19 | #include 20 | 21 | extern SerialCDC serialUSB; 22 | 23 | #include 24 | extern TwoWire Wire; 25 | 26 | void DeviceInit() noexcept; 27 | void StopAnalogTask() noexcept; 28 | void StopUsbTask() noexcept; 29 | 30 | #endif /* SRC_HARDWARE_SAM4S_DEVICES_H_ */ 31 | -------------------------------------------------------------------------------- /src/Hardware/SAM4S/Main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Main.cpp 3 | * Program entry point 4 | * Created on: 11 Jul 2020 5 | * Author: David 6 | * License: GNU GPL version 3 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | // Program initialisation 13 | void AppInit() noexcept 14 | { 15 | #if defined(DUET_M) 16 | // The prototype boards don't have a pulldown on LCD_BEEP, which causes a hissing sound from the beeper on the 12864 display until the pin is initialised 17 | pinMode(LcdBeepPin, OUTPUT_LOW); 18 | 19 | // Set the 12864 display CS pin low to prevent it from receiving garbage due to other SPI traffic 20 | pinMode(LcdCSPin, OUTPUT_LOW); 21 | 22 | // On the prototype boards the stepper driver expansion ports don't have external pullup resistors on their enable pins 23 | pinMode(ENABLE_PINS[5], OUTPUT_HIGH); 24 | pinMode(ENABLE_PINS[6], OUTPUT_HIGH); 25 | #endif 26 | } 27 | 28 | // End 29 | -------------------------------------------------------------------------------- /src/Hardware/SAM4S/PinDescription.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PinDescription.h 3 | * 4 | * Created on: 10 Jul 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SAM4S_PINDESCRIPTION_H_ 9 | #define SRC_HARDWARE_SAM4S_PINDESCRIPTION_H_ 10 | 11 | #include 12 | 13 | // Enum to represent allowed types of pin access 14 | // We don't have a separate bit for servo, because Duet PWM-capable ports can be used for servos if they are on the Duet main board 15 | enum class PinCapability: uint8_t 16 | { 17 | // Individual capabilities 18 | none = 0u, 19 | read = 1u, 20 | ain = 2u, 21 | write = 4u, 22 | pwm = 8u, 23 | npDma = 16u, 24 | 25 | // Combinations 26 | ainr = 1u|2u, 27 | rw = 1u|4u, 28 | wpwm = 4u|8u, 29 | rwpwm = 1u|4u|8u, 30 | ainrw = 1u|2u|4u, 31 | ainrwpwm = 1u|2u|4u|8u, 32 | npDmaW = 4u | 16u 33 | }; 34 | 35 | constexpr inline PinCapability operator|(PinCapability a, PinCapability b) noexcept 36 | { 37 | return (PinCapability)((uint8_t)a | (uint8_t)b); 38 | } 39 | 40 | constexpr inline PinCapability operator&(PinCapability a, PinCapability b) noexcept 41 | { 42 | return (PinCapability)((uint8_t)a & (uint8_t)b); 43 | } 44 | 45 | // The pin description says what functions are available on each pin, filtered to avoid allocating the same function to more than one pin.. 46 | // It is a struct not a class so that it can be direct initialised in read-only memory. 47 | struct PinDescription : public PinDescriptionBase 48 | { 49 | PinCapability cap; 50 | const char* _ecv_array null pinNames; 51 | 52 | PinCapability GetCapability() const noexcept { return cap; } 53 | const char* _ecv_array null GetNames() const noexcept { return pinNames; } 54 | }; 55 | 56 | #endif /* SRC_HARDWARE_SAM4S_PINDESCRIPTION_H_ */ 57 | -------------------------------------------------------------------------------- /src/Hardware/SAME5x/Devices.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Devices.h 3 | * 4 | * Created on: 9 Jul 2020 5 | * Author: David 6 | * License: GNU GPL v3 7 | */ 8 | 9 | #ifndef SRC_HARDWARE_SAME5X_DEVICES_H_ 10 | #define SRC_HARDWARE_SAME5X_DEVICES_H_ 11 | 12 | #include 13 | 14 | extern AsyncSerial serialUart0, serialUart1; 15 | 16 | #define SUPPORT_USB 1 // needed by SerialCDC.h 17 | #include 18 | 19 | extern SerialCDC serialUSB; 20 | 21 | void DeviceInit() noexcept; 22 | void StopAnalogTask() noexcept; 23 | void StopUsbTask() noexcept; 24 | 25 | // GCLK numbers not defined in the core 26 | constexpr unsigned int GclkNum25MHz = 2; // for Ethernet PHY 27 | 28 | #endif /* SRC_HARDWARE_SAME5X_DEVICES_H_ */ 29 | -------------------------------------------------------------------------------- /src/Hardware/SAME5x/Ethernet/GmacInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SAME5x GmacInterface.h 3 | * 4 | * Created on: 19 Jun 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SAME5X_ETHERNET_GMACINTERFACE_H_ 9 | #define SRC_HARDWARE_SAME5X_ETHERNET_GMACINTERFACE_H_ 10 | 11 | extern "C" { 12 | #include "lwip/err.h" 13 | #include "lwip/ip_addr.h" 14 | #include "lwip/netif.h" 15 | #include "netif/etharp.h" 16 | } 17 | 18 | #include 19 | #include 20 | 21 | err_t ethernetif_init(struct netif *netif) noexcept; // called by LwIP to initialise the interface 22 | 23 | void ethernetif_terminate() noexcept; // called when we shut down 24 | 25 | bool ethernetif_input(struct netif *netif) noexcept; // checks for a new packet and returns true if one was processed 26 | 27 | void ethernetif_hardware_init() noexcept; // initialises the low-level hardware interface 28 | 29 | bool ethernetif_establish_link() noexcept; // attempts to establish link and returns true on success 30 | 31 | bool ethernetif_link_established() noexcept; // asks the PHY if the link is still up 32 | 33 | void ethernetif_set_mac_address(const uint8_t macAddress[]) noexcept; 34 | 35 | void ethernetif_diagnostics(const StringRef& reply) noexcept; 36 | 37 | #endif /* SRC_HARDWARE_SAME5X_ETHERNET_GMACINTERFACE_H_ */ 38 | -------------------------------------------------------------------------------- /src/Hardware/SAME5x/Ethernet/conf_eth.h: -------------------------------------------------------------------------------- 1 | // Ethernet configuration for SAME54 2 | 3 | #ifndef CONF_ETH_H_INCLUDED 4 | #define CONF_ETH_H_INCLUDED 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /** 11 | * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data 12 | * to be sent into one single pbuf. This is for compatibility with DMA-enabled 13 | * MACs that do not support scatter-gather. 14 | */ 15 | #define LWIP_NETIF_TX_SINGLE_PBUF 1 16 | 17 | /** Number of buffer for RX */ 18 | #define GMAC_RX_BUFFERS 8 19 | 20 | /** Number of buffer for TX */ 21 | #define GMAC_TX_BUFFERS 4 22 | 23 | /** The MAC can support frame lengths up to 1536 bytes */ 24 | #define GMAC_FRAME_LENGTH_MAX 1536 25 | 26 | /** MAC PHY operation max retry count */ 27 | #define MAC_PHY_RETRY_MAX 1000000 28 | 29 | /** Ethernet MII/RMII mode */ 30 | #define ETH_PHY_MODE GMAC_PHY_RMII 31 | 32 | /** GMAC HW configurations */ 33 | #define BOARD_GMAC_PHY_ADDR 0 34 | 35 | /** MAC address definition. The MAC address must be unique on the network. */ 36 | #define ETHERNET_CONF_ETHADDR0 0xBE 37 | #define ETHERNET_CONF_ETHADDR1 0xEF 38 | #define ETHERNET_CONF_ETHADDR2 0xDE 39 | #define ETHERNET_CONF_ETHADDR3 0xAD 40 | #define ETHERNET_CONF_ETHADDR4 0xFE 41 | #define ETHERNET_CONF_ETHADDR5 0xED 42 | 43 | #endif /* CONF_ETH_H_INCLUDED */ 44 | -------------------------------------------------------------------------------- /src/Hardware/SAME5x/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void AppInit() noexcept 6 | { 7 | } 8 | 9 | // Return the XOSC frequency in MHz 10 | unsigned int AppGetXoscFrequency() noexcept 11 | { 12 | return 25; 13 | } 14 | 15 | // Return the XOSC number 16 | unsigned int AppGetXoscNumber() noexcept 17 | { 18 | return 1; 19 | } 20 | 21 | // End 22 | -------------------------------------------------------------------------------- /src/Hardware/SAME5x/PinDescription.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PinDescription.h 3 | * 4 | * Created on: 10 Jul 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SAME5X_PINDESCRIPTION_H_ 9 | #define SRC_HARDWARE_SAME5X_PINDESCRIPTION_H_ 10 | 11 | #include 12 | 13 | // Enum to represent allowed types of pin access 14 | // We don't have a separate bit for servo, because Duet PWM-capable ports can be used for servos if they are on the Duet main board 15 | enum class PinCapability: uint8_t 16 | { 17 | // Individual capabilities 18 | none = 0u, 19 | read = 1u, // digital read 20 | ain = 2u, // analog read 21 | write = 4u, // digital write 22 | pwm = 8u, // PWM write 23 | npDma = 16u, // Neopixel output using DMA e.g. using SPI MOSI 24 | 25 | // Combinations 26 | ainr = 1u|2u, 27 | rw = 1u|4u, 28 | wpwm = 4u|8u, 29 | rwpwm = 1u|4u|8u, 30 | ainrw = 1u|2u|4u, 31 | ainrwpwm = 1u|2u|4u|8u, 32 | npDmaW = 4u | 16u 33 | }; 34 | 35 | constexpr inline PinCapability operator|(PinCapability a, PinCapability b) noexcept 36 | { 37 | return (PinCapability)((uint8_t)a | (uint8_t)b); 38 | } 39 | 40 | constexpr inline PinCapability operator&(PinCapability a, PinCapability b) noexcept 41 | { 42 | return (PinCapability)((uint8_t)a & (uint8_t)b); 43 | } 44 | 45 | // The pin description says what functions are available on each pin, filtered to avoid allocating the same function to more than one pin.. 46 | // It is a struct not a class so that it can be direct initialised in read-only memory. 47 | struct PinDescription : public PinDescriptionBase 48 | { 49 | PinCapability cap; 50 | const char* _ecv_array null pinNames; 51 | 52 | PinCapability GetCapability() const noexcept { return cap; } 53 | const char* _ecv_array null GetNames() const noexcept { return pinNames; } 54 | }; 55 | 56 | #endif /* SRC_HARDWARE_SAME5X_PINDESCRIPTION_H_ */ 57 | -------------------------------------------------------------------------------- /src/Hardware/SAME70/Devices.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Devices.h 3 | * 4 | * Created on: 11 Aug 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SAME70_DEVICES_H_ 9 | #define SRC_HARDWARE_SAME70_DEVICES_H_ 10 | 11 | #include 12 | #include 13 | 14 | extern AsyncSerial serialUart1; 15 | extern USARTClass serialUart2; 16 | 17 | #if defined(DUET3_MB6HC) 18 | extern AsyncSerial serialWiFi; 19 | #endif 20 | 21 | #define SUPPORT_USB 1 // needed by SerialCDC.h 22 | #include "SerialCDC.h" 23 | 24 | extern SerialCDC serialUSB; 25 | 26 | void DeviceInit() noexcept; 27 | void StopAnalogTask() noexcept; 28 | void StopUsbTask() noexcept; 29 | 30 | #endif /* SRC_HARDWARE_SAME70_DEVICES_H_ */ 31 | -------------------------------------------------------------------------------- /src/Hardware/SAME70/Main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Main.cpp 3 | * Program entry point 4 | * Created on: 11 Jul 2020 5 | * Author: David 6 | * License: GNU GPL version 3 7 | */ 8 | 9 | #include 10 | 11 | // Program initialisation 12 | void AppInit() noexcept 13 | { 14 | } 15 | 16 | // End 17 | -------------------------------------------------------------------------------- /src/Hardware/SAME70/PinDescription.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PinDescription.h 3 | * 4 | * Created on: 10 Jul 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SAME70_PINDESCRIPTION_H_ 9 | #define SRC_HARDWARE_SAME70_PINDESCRIPTION_H_ 10 | 11 | #include 12 | 13 | // Enum to represent allowed types of pin access 14 | // We don't have a separate bit for servo, because Duet PWM-capable ports can be used for servos if they are on the Duet main board 15 | enum class PinCapability: uint8_t 16 | { 17 | // Individual capabilities 18 | none = 0u, 19 | read = 1u, // digital read 20 | ain = 2u, // analog read 21 | write = 4u, // digital write 22 | pwm = 8u, // PWM write 23 | npDma = 16u, // Neopixel output using DMA e.g. using SPI MOSI 24 | 25 | // Combinations 26 | ainr = 1u|2u, 27 | rw = 1u|4u, 28 | wpwm = 4u|8u, 29 | rwpwm = 1u|4u|8u, 30 | ainrw = 1u|2u|4u, 31 | ainrwpwm = 1u|2u|4u|8u, 32 | npDmaW = 4u | 16u 33 | }; 34 | 35 | constexpr inline PinCapability operator|(PinCapability a, PinCapability b) noexcept 36 | { 37 | return (PinCapability)((uint8_t)a | (uint8_t)b); 38 | } 39 | 40 | constexpr inline PinCapability operator&(PinCapability a, PinCapability b) noexcept 41 | { 42 | return (PinCapability)((uint8_t)a & (uint8_t)b); 43 | } 44 | 45 | // The pin description says what functions are available on each pin, filtered to avoid allocating the same function to more than one pin.. 46 | // It is a struct not a class so that it can be direct initialised in read-only memory. 47 | struct PinDescription : public PinDescriptionBase 48 | { 49 | PinCapability cap; 50 | const char *_ecv_array null pinNames; 51 | 52 | PinCapability GetCapability() const noexcept { return cap; } 53 | const char *_ecv_array null GetNames() const noexcept { return pinNames; } 54 | }; 55 | 56 | #endif /* SRC_HARDWARE_SAME70_PINDESCRIPTION_H_ */ 57 | -------------------------------------------------------------------------------- /src/Hardware/Spi/SharedSpiClient.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SharedSpiDevice.cpp 3 | * 4 | * Created on: 28 Jul 2019 5 | * Author: David 6 | */ 7 | 8 | #include "SharedSpiClient.h" 9 | #include "SharedSpiDevice.h" 10 | #include 11 | 12 | // SharedSpiDevice class members 13 | SharedSpiClient::SharedSpiClient(SharedSpiDevice& dev, uint32_t clockFreq, SpiMode m, Pin p, bool polarity) noexcept 14 | : device(dev), clockFrequency(clockFreq), csPin(p), mode(m), csActivePolarity(polarity) 15 | { 16 | InitCsPin(); 17 | } 18 | 19 | void SharedSpiClient::InitCsPin() const noexcept 20 | { 21 | if (csPin != NoPin) 22 | { 23 | ::SetPinMode(csPin, (csActivePolarity) ? OUTPUT_LOW : OUTPUT_HIGH); 24 | } 25 | } 26 | 27 | // Get ownership of this SPI and assert CS, returning true if successful 28 | bool SharedSpiClient::Select(uint32_t timeout) const noexcept 29 | { 30 | const bool ok = device.Take(timeout); 31 | if (ok) 32 | { 33 | device.SetClockFrequencyAndMode(clockFrequency, mode 34 | #if SAME5x 35 | , false // for now we always use 8-bit mode 36 | #endif 37 | ); // this also enables the SPI peripheral 38 | delayMicroseconds(1); // allow the clock time to settle 39 | IoPort::WriteDigital(csPin, csActivePolarity); 40 | } 41 | return ok; 42 | } 43 | 44 | // Release CS and release ownership of the SPI bus 45 | void SharedSpiClient::Deselect() const noexcept 46 | { 47 | IoPort::WriteDigital(csPin, !csActivePolarity); 48 | delayMicroseconds(1); // in case the clock makes an abrupt transition when we disable SPI 49 | device.Disable(); 50 | device.Release(); 51 | } 52 | 53 | bool SharedSpiClient::TransceivePacket(const uint8_t *_ecv_array _ecv_null tx_data, uint8_t *_ecv_array _ecv_null rx_data, size_t len) const noexcept 54 | { 55 | return device.TransceivePacket(tx_data, rx_data, len); 56 | } 57 | 58 | // End 59 | -------------------------------------------------------------------------------- /src/Hardware/Spi/SharedSpiClient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SharedSpiDevice.h 3 | * 4 | * Created on: 1 Jul 2019 5 | * Author: David 6 | * 7 | * This currently supports only a single SPI channel. To support multiple SPI channels we would need to make the underlying SERCOM device 8 | * configured in SPI mode a separate object, and have a pointer or reference to it in SharedSpiDevice. 9 | */ 10 | 11 | #ifndef SRC_HARDWARE_SPI_SHAREDSPICLIENT_H_ 12 | #define SRC_HARDWARE_SPI_SHAREDSPICLIENT_H_ 13 | 14 | #include 15 | #include "SpiMode.h" 16 | #include 17 | 18 | class SharedSpiDevice; 19 | 20 | class SharedSpiClient 21 | { 22 | public: 23 | SharedSpiClient(SharedSpiDevice& dev, uint32_t clockFreq, SpiMode m, Pin p, bool polarity) noexcept; 24 | 25 | void SetCsPin(Pin p) noexcept { csPin = p; InitCsPin(); } 26 | void SetCsPolarity(bool b) noexcept { csActivePolarity = b; } 27 | void SetClockFrequency(uint32_t clockFreq) noexcept { clockFrequency = clockFreq; } 28 | 29 | uint32_t GetFrequency() const noexcept { return clockFrequency; } 30 | 31 | bool Select(uint32_t timeout = Mutex::TimeoutUnlimited) const noexcept; // get SPI ownership and select the device, return true if successful 32 | void Deselect() const noexcept; 33 | bool TransceivePacket(const uint8_t *_ecv_array _ecv_null tx_data, uint8_t *_ecv_array _ecv_null rx_data, size_t len) const noexcept; 34 | bool ReadPacket(uint8_t *_ecv_array rx_data, size_t len) const noexcept { return TransceivePacket(nullptr, rx_data, len); } 35 | bool WritePacket(const uint8_t *_ecv_array tx_data, size_t len) const noexcept { return TransceivePacket(tx_data, nullptr, len); } 36 | 37 | private: 38 | void InitCsPin() const noexcept; 39 | 40 | SharedSpiDevice& device; 41 | uint32_t clockFrequency; 42 | Pin csPin; 43 | SpiMode mode; 44 | bool csActivePolarity; 45 | }; 46 | 47 | #endif /* SRC_HARDWARE_SPI_SHAREDSPICLIENT_H_ */ 48 | -------------------------------------------------------------------------------- /src/Hardware/Spi/SharedSpiDevice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SharedSpiDevice.cpp 3 | * 4 | * Created on: 16 Jun 2020 5 | * Author: David 6 | */ 7 | 8 | #include "SharedSpiDevice.h" 9 | 10 | // SharedSpiDevice members 11 | 12 | SharedSpiDevice::SharedSpiDevice(uint8_t sercomNum) noexcept 13 | : SpiDevice(sercomNum) 14 | { 15 | mutex.Create("SPI"); 16 | } 17 | 18 | // Static members 19 | 20 | SharedSpiDevice *_ecv_null SharedSpiDevice::mainSharedSpiDevice = nullptr; 21 | 22 | void SharedSpiDevice::Init() noexcept 23 | { 24 | #if SAME5x 25 | SetPinMode(SharedSpiMosiPin, INPUT_PULLDOWN); 26 | SetPinMode(SharedSpiMisoPin, INPUT_PULLDOWN); 27 | SetPinMode(SharedSpiSclkPin, INPUT_PULLDOWN); 28 | SetPinFunction(SharedSpiMosiPin, SharedSpiPinFunction); 29 | SetPinFunction(SharedSpiMisoPin, SharedSpiPinFunction); 30 | SetPinFunction(SharedSpiSclkPin, SharedSpiPinFunction); 31 | SetDriveStrength(SharedSpiMosiPin, 2); 32 | SetDriveStrength(SharedSpiSclkPin, 2); // some devices (e.g. TFT LCD font chip) need fast rise and fall times 33 | mainSharedSpiDevice = new SharedSpiDevice(SharedSpiSercomNumber); 34 | #elif USART_SPI 35 | SetPinFunction(APIN_USART_SSPI_SCK, USARTSPISckPeriphMode); 36 | SetPinFunction(APIN_USART_SSPI_MOSI, USARTSPIMosiPeriphMode); 37 | SetPinFunction(APIN_USART_SSPI_MISO, USARTSPIMisoPeriphMode); 38 | mainSharedSpiDevice = new SharedSpiDevice(0); 39 | #else 40 | ConfigurePin(g_APinDescription[APIN_SHARED_SPI_SCK]); 41 | ConfigurePin(g_APinDescription[APIN_SHARED_SPI_MOSI]); 42 | ConfigurePin(g_APinDescription[APIN_SHARED_SPI_MISO]); 43 | mainSharedSpiDevice = new SharedSpiDevice(0); 44 | #endif 45 | } 46 | 47 | // End 48 | -------------------------------------------------------------------------------- /src/Hardware/Spi/SharedSpiDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SharedSpiDevice.h 3 | * 4 | * Created on: 16 Jun 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SPI_SHAREDSPIDEVICE_H_ 9 | #define SRC_HARDWARE_SPI_SHAREDSPIDEVICE_H_ 10 | 11 | #include "SpiDevice.h" 12 | #include 13 | 14 | class SharedSpiDevice : public SpiDevice 15 | { 16 | public: 17 | explicit SharedSpiDevice(uint8_t sercomNum) noexcept; 18 | 19 | // Get ownership of this SPI, return true if successful 20 | bool Take(uint32_t timeout) noexcept { return mutex.Take(timeout); } 21 | 22 | // Release ownership of this SPI 23 | void Release() noexcept { mutex.Release(); } 24 | 25 | static void Init() noexcept; 26 | static SharedSpiDevice& GetMainSharedSpiDevice() noexcept { return *mainSharedSpiDevice; } 27 | 28 | private: 29 | Mutex mutex; 30 | 31 | static SharedSpiDevice *_ecv_null mainSharedSpiDevice; 32 | }; 33 | 34 | #endif /* SRC_HARDWARE_SPI_SHAREDSPIDEVICE_H_ */ 35 | -------------------------------------------------------------------------------- /src/Hardware/Spi/SpiMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SpiMode.h 3 | * 4 | * Created on: 16 Jun 2020 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HARDWARE_SPI_SPIMODE_H_ 9 | #define SRC_HARDWARE_SPI_SPIMODE_H_ 10 | 11 | enum class SpiMode : uint8_t 12 | { 13 | mode0 = 0, mode1, mode2, mode3 14 | }; 15 | 16 | // Definitions for backwards compatibility with RRF code 17 | constexpr SpiMode SPI_MODE_0 = SpiMode::mode0; 18 | constexpr SpiMode SPI_MODE_1 = SpiMode::mode1; 19 | constexpr SpiMode SPI_MODE_2 = SpiMode::mode2; 20 | constexpr SpiMode SPI_MODE_3 = SpiMode::mode3; 21 | 22 | #endif /* SRC_HARDWARE_SPI_SPIMODE_H_ */ 23 | -------------------------------------------------------------------------------- /src/Heating/Sensors/AdditionalOutputSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AdditionalOutputSensor.h 3 | * 4 | * Created on: 17 Oct 2019 5 | * Author: manuel 6 | */ 7 | 8 | #ifndef ADDITIONALOUTPUTSENSOR_H_ 9 | #define ADDITIONALOUTPUTSENSOR_H_ 10 | 11 | # include "TemperatureSensor.h" 12 | 13 | class AdditionalOutputSensor : public TemperatureSensor 14 | { 15 | public: 16 | AdditionalOutputSensor(unsigned int sensorNum, const char *_ecv_array type, bool pEnforcePollOrder) noexcept; 17 | virtual ~AdditionalOutputSensor() noexcept override; 18 | 19 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& changed) THROWS(GCodeException) override; 20 | #if SUPPORT_REMOTE_COMMANDS 21 | GCodeResult Configure(const CanMessageGenericParser& parser, const StringRef& reply) noexcept override; 22 | #endif 23 | 24 | void Poll() noexcept override; 25 | 26 | protected: 27 | // Append the pin details to the reply buffer 28 | void AppendPinDetails(const StringRef& reply) const noexcept override; 29 | 30 | uint8_t parentSensor; 31 | uint8_t outputNumber; 32 | 33 | private: 34 | GCodeResult ConfigurePort(const char *_ecv_array portName, const StringRef& reply) noexcept; 35 | 36 | bool enforcePollOrder; 37 | }; 38 | 39 | #endif /* ADDITIONALOUTPUTSENSOR_H_ */ 40 | -------------------------------------------------------------------------------- /src/Heating/Sensors/CpuTemperatureSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CpuTemperatureSensor.cpp 3 | * 4 | * Created on: 8 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #include "CpuTemperatureSensor.h" 9 | #include 10 | #include 11 | 12 | #if HAS_CPU_TEMP_SENSOR 13 | 14 | // Sensor type descriptors 15 | TemperatureSensor::SensorTypeDescriptor CpuTemperatureSensor::typeDescriptor(TypeName, [](unsigned int sensorNum) noexcept -> TemperatureSensor *_ecv_from { return new CpuTemperatureSensor(sensorNum); } ); 16 | 17 | CpuTemperatureSensor::CpuTemperatureSensor(unsigned int sensorNum) noexcept : TemperatureSensor(sensorNum, "Microcontroller embedded temperature sensor") 18 | { 19 | } 20 | 21 | void CpuTemperatureSensor::Poll() noexcept 22 | { 23 | const MinCurMax temperatures = reprap.GetPlatform().GetMcuTemperatures(); 24 | SetResult(temperatures.current, TemperatureError::ok); 25 | } 26 | 27 | #endif 28 | 29 | // End 30 | -------------------------------------------------------------------------------- /src/Heating/Sensors/CpuTemperatureSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CpuTemperatureSensor.h 3 | * 4 | * Created on: 8 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_SENSORS_CPUTEMPERATURESENSOR_H_ 9 | #define SRC_HEATING_SENSORS_CPUTEMPERATURESENSOR_H_ 10 | 11 | #include "TemperatureSensor.h" 12 | 13 | #if HAS_CPU_TEMP_SENSOR 14 | 15 | class CpuTemperatureSensor : public TemperatureSensor 16 | { 17 | public: 18 | explicit CpuTemperatureSensor(unsigned int sensorNum) noexcept; 19 | 20 | void Poll() noexcept override; 21 | const char *_ecv_array GetShortSensorType() const noexcept override { return TypeName; } 22 | 23 | static constexpr const char *_ecv_array TypeName = "mcutemp"; 24 | 25 | private: 26 | static SensorTypeDescriptor typeDescriptor; 27 | }; 28 | 29 | #endif 30 | 31 | #endif /* SRC_HEATING_SENSORS_CPUTEMPERATURESENSOR_H_ */ 32 | -------------------------------------------------------------------------------- /src/Heating/Sensors/CurrentLoopTemperatureSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LinearAdcTemperatureSensor.h 3 | * 4 | * Created on: 8 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_LINEARADCTEMPERATURESENSOR_H_ 9 | #define SRC_HEATING_LINEARADCTEMPERATURESENSOR_H_ 10 | 11 | #include "SpiTemperatureSensor.h" 12 | 13 | #if SUPPORT_SPI_SENSORS 14 | 15 | class CurrentLoopTemperatureSensor : public SpiTemperatureSensor 16 | { 17 | public: 18 | explicit CurrentLoopTemperatureSensor(unsigned int sensorNum) noexcept; 19 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& changed) THROWS(GCodeException) override; 20 | 21 | #if SUPPORT_REMOTE_COMMANDS 22 | GCodeResult Configure(const CanMessageGenericParser& parser, const StringRef& reply) noexcept override; // configure the sensor from M308 parameters 23 | #endif 24 | 25 | void Poll() noexcept override; 26 | const char *_ecv_array GetShortSensorType() const noexcept override { return TypeName; } 27 | 28 | static constexpr const char *_ecv_array TypeName = "currentloop"; 29 | 30 | private: 31 | static SensorTypeDescriptor typeDescriptor; 32 | 33 | TemperatureError TryGetLinearAdcTemperature(float& t) noexcept; 34 | GCodeResult FinishConfiguring(bool changed, const StringRef& reply) noexcept; 35 | void CalcDerivedParameters() noexcept; 36 | 37 | // Configurable parameters 38 | float tempAt4mA, tempAt20mA; 39 | uint32_t chipChannel; 40 | bool isDifferential; 41 | 42 | // Derived parameters 43 | float minLinearAdcTemp, linearAdcDegCPerCount; 44 | 45 | static constexpr float DefaultTempAt4mA = 385.0; 46 | static constexpr float DefaultTempAt20mA = 1600.0; 47 | static constexpr uint32_t DefaultChipChannel = 0; 48 | }; 49 | 50 | #endif // SUPPORT_SPI_SENSORS 51 | 52 | #endif /* SRC_HEATING_LINEARADCTEMPERATURESENSOR_H_ */ 53 | -------------------------------------------------------------------------------- /src/Heating/Sensors/LinearAnalogSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LinearAnalogSensor.h 3 | * 4 | * Created on: 16 Apr 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_SENSORS_LINEARANALOGSENSOR_H_ 9 | #define SRC_HEATING_SENSORS_LINEARANALOGSENSOR_H_ 10 | 11 | #include "SensorWithPort.h" 12 | 13 | class LinearAnalogSensor : public SensorWithPort 14 | { 15 | public: 16 | explicit LinearAnalogSensor(unsigned int sensorNum) noexcept; 17 | 18 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& changed) THROWS(GCodeException) override; 19 | #if SUPPORT_REMOTE_COMMANDS 20 | GCodeResult Configure(const CanMessageGenericParser& parser, const StringRef& reply) noexcept override; 21 | #endif 22 | 23 | void Poll() noexcept override; 24 | const char *_ecv_array GetShortSensorType() const noexcept override { return TypeName; } 25 | 26 | static constexpr const char *_ecv_array TypeName = "linearanalog"; 27 | 28 | protected: 29 | DECLARE_OBJECT_MODEL 30 | 31 | private: 32 | static SensorTypeDescriptor typeDescriptor; 33 | 34 | void CalcDerivedParameters() noexcept; 35 | 36 | // Configurable parameters 37 | float lowTemp, highTemp; 38 | bool filtered; 39 | 40 | // Derived parameters 41 | int adcFilterChannel; 42 | float linearIncreasePerCount; 43 | 44 | static constexpr float DefaultLowTemp = 0.0; 45 | static constexpr float DefaultHighTemp = 100.0; 46 | }; 47 | 48 | #endif /* SRC_HEATING_SENSORS_LINEARANALOGSENSOR_H_ */ 49 | -------------------------------------------------------------------------------- /src/Heating/Sensors/RemoteSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RemoteSensor.h 3 | * 4 | * Created on: 23 Jul 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_SENSORS_REMOTESENSOR_H_ 9 | #define SRC_HEATING_SENSORS_REMOTESENSOR_H_ 10 | 11 | #include "TemperatureSensor.h" 12 | 13 | #if SUPPORT_CAN_EXPANSION 14 | 15 | class RemoteSensor : public TemperatureSensor 16 | { 17 | public: 18 | RemoteSensor(unsigned int sensorNum, CanAddress pBoardAddress) noexcept; 19 | ~RemoteSensor(); 20 | 21 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& changed) THROWS(GCodeException) override; 22 | CanAddress GetBoardAddress() const noexcept override { return boardAddress; } 23 | void Poll() noexcept override { } // nothing to do here because reception of CAN messages update the reading 24 | void UpdateRemoteTemperature(CanAddress src, const CanSensorReport& report) noexcept override; 25 | const char *GetShortSensorType() const noexcept override { return "remote"; } // TODO save the actual type 26 | 27 | private: 28 | CanAddress boardAddress; 29 | }; 30 | 31 | #endif 32 | 33 | #endif /* SRC_HEATING_SENSORS_REMOTESENSOR_H_ */ 34 | -------------------------------------------------------------------------------- /src/Heating/Sensors/RtdSensor31865.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RtdSensor31865.h 3 | * 4 | * Created on: 8 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_RTDSENSOR31865_H_ 9 | #define SRC_HEATING_RTDSENSOR31865_H_ 10 | 11 | #include "SpiTemperatureSensor.h" 12 | 13 | #if SUPPORT_SPI_SENSORS 14 | 15 | class RtdSensor31865 : public SpiTemperatureSensor 16 | { 17 | public: 18 | explicit RtdSensor31865(unsigned int sensorNum) noexcept; 19 | 20 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& changed) THROWS(GCodeException) override; 21 | 22 | #if SUPPORT_REMOTE_COMMANDS 23 | GCodeResult Configure(const CanMessageGenericParser& parser, const StringRef& reply) noexcept override; // configure the sensor from M308 parameters 24 | #endif 25 | 26 | void Poll() noexcept override; 27 | const char *_ecv_array GetShortSensorType() const noexcept override { return TypeName; } 28 | 29 | static constexpr const char *_ecv_array TypeName = "rtdmax31865"; 30 | 31 | protected: 32 | DECLARE_OBJECT_MODEL 33 | 34 | private: 35 | static SensorTypeDescriptor typeDescriptor; 36 | 37 | TemperatureError TryInitRtd() const noexcept; 38 | GCodeResult FinishConfiguring(bool changed, const StringRef& reply) noexcept; 39 | 40 | uint32_t rrefTimes100; // reference resistor in units of 0.01 ohms 41 | uint8_t cr0; 42 | }; 43 | 44 | #endif //SUPPORT_SPI_SENSORS 45 | 46 | #endif /* SRC_HEATING_RTDSENSOR31865_H_ */ 47 | -------------------------------------------------------------------------------- /src/Heating/Sensors/SensorWithPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SensorWithPort.h 3 | * 4 | * Created on: 18 Jul 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_SENSORS_SENSORWITHPORT_H_ 9 | #define SRC_HEATING_SENSORS_SENSORWITHPORT_H_ 10 | 11 | #include "TemperatureSensor.h" 12 | 13 | class CanMessageGenericParser; 14 | 15 | class SensorWithPort : public TemperatureSensor 16 | { 17 | protected: 18 | DECLARE_OBJECT_MODEL 19 | 20 | SensorWithPort(unsigned int sensorNum, const char *_ecv_array type) noexcept; 21 | ~SensorWithPort() noexcept override; 22 | 23 | // Try to configure the port 24 | bool ConfigurePort(GCodeBuffer& gb, const StringRef& reply, PinAccess access, bool& seen) THROWS(GCodeException); 25 | 26 | #if SUPPORT_REMOTE_COMMANDS 27 | // Try to configure the port 28 | bool ConfigurePort(const CanMessageGenericParser& parser, const StringRef& reply, PinAccess access, bool& seen); 29 | #endif 30 | 31 | // Append the pin details to the reply buffer 32 | void AppendPinDetails(const StringRef& reply) const noexcept override; 33 | 34 | IoPort port; 35 | }; 36 | 37 | #endif /* SRC_HEATING_SENSORS_SENSORWITHPORT_H_ */ 38 | -------------------------------------------------------------------------------- /src/Heating/Sensors/SpiTemperatureSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SpiTemperatureSensor.h 3 | * 4 | * Created on: 8 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_SPITEMPERATURESENSOR_H_ 9 | #define SRC_HEATING_SPITEMPERATURESENSOR_H_ 10 | 11 | #include "SensorWithPort.h" 12 | 13 | #if SUPPORT_SPI_SENSORS 14 | 15 | #include 16 | 17 | class SpiTemperatureSensor : public SensorWithPort 18 | { 19 | protected: 20 | SpiTemperatureSensor(unsigned int sensorNum, const char *_ecv_array name, SpiMode spiMode, uint32_t clockFrequency) noexcept; 21 | 22 | bool ConfigurePort(GCodeBuffer& gb, const StringRef& reply, bool& seen) THROWS(GCodeException); 23 | 24 | #if SUPPORT_REMOTE_COMMANDS 25 | bool ConfigurePort(const CanMessageGenericParser& parser, const StringRef& reply, bool& seen) noexcept; 26 | #endif 27 | 28 | void InitSpi() noexcept; 29 | TemperatureError DoSpiTransaction(const uint8_t *_ecv_array _ecv_null dataOut, size_t nbytes, uint32_t& rslt) const noexcept 30 | pre(nbytes <= 8); 31 | TemperatureError DoSpiTransaction(const uint8_t dataOut[], uint8_t dataIn[], size_t nbytes) const noexcept; 32 | 33 | SharedSpiClient device; 34 | }; 35 | 36 | #endif // SUPPORT_SPI_SENSORS 37 | 38 | #endif /* SRC_HEATING_SPITEMPERATURESENSOR_H_ */ 39 | -------------------------------------------------------------------------------- /src/Heating/Sensors/ThermocoupleSensor31855.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ThermocoupleSensor31855.h 3 | * 4 | * Created on: 8 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_THERMOCOUPLESENSOR31855_H_ 9 | #define SRC_HEATING_THERMOCOUPLESENSOR31855_H_ 10 | 11 | #include "SpiTemperatureSensor.h" 12 | 13 | #if SUPPORT_SPI_SENSORS 14 | 15 | class ThermocoupleSensor31855 : public SpiTemperatureSensor 16 | { 17 | public: 18 | explicit ThermocoupleSensor31855(unsigned int sensorNum) noexcept; 19 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& changed) THROWS(GCodeException) override; 20 | 21 | #if SUPPORT_REMOTE_COMMANDS 22 | GCodeResult Configure(const CanMessageGenericParser& parser, const StringRef& reply) noexcept override; // configure the sensor from M308 parameters 23 | #endif 24 | 25 | void Poll() noexcept override; 26 | const char *_ecv_array GetShortSensorType() const noexcept override { return TypeName; } 27 | 28 | static constexpr const char *_ecv_array TypeName = "thermocouplemax31855"; 29 | 30 | private: 31 | static SensorTypeDescriptor typeDescriptor; 32 | 33 | GCodeResult FinishConfiguring(bool changed, const StringRef& reply) noexcept; 34 | }; 35 | 36 | #endif // SUPPORT_SPI_SENSORS 37 | 38 | #endif /* SRC_HEATING_THERMOCOUPLESENSOR31855_H_ */ 39 | -------------------------------------------------------------------------------- /src/Heating/Sensors/ThermocoupleSensor31856.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ThermocoupleSensor31856.h 3 | * 4 | * Created on: 27 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_SENSORS_THERMOCOUPLESENSOR31856_H_ 9 | #define SRC_HEATING_SENSORS_THERMOCOUPLESENSOR31856_H_ 10 | 11 | #include "SpiTemperatureSensor.h" 12 | 13 | #if SUPPORT_SPI_SENSORS 14 | 15 | class ThermocoupleSensor31856 : public SpiTemperatureSensor 16 | { 17 | public: 18 | explicit ThermocoupleSensor31856(unsigned int sensorNum) noexcept; 19 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& changed) THROWS(GCodeException) override; 20 | 21 | #if SUPPORT_REMOTE_COMMANDS 22 | GCodeResult Configure(const CanMessageGenericParser& parser, const StringRef& reply) noexcept override; // configure the sensor from M308 parameters 23 | #endif 24 | 25 | void Poll() noexcept override; 26 | const char *_ecv_array GetShortSensorType() const noexcept override { return TypeName; } 27 | 28 | static constexpr const char *_ecv_array TypeName = "thermocouplemax31856"; 29 | 30 | private: 31 | static SensorTypeDescriptor typeDescriptor; 32 | 33 | TemperatureError TryInitThermocouple() const noexcept; 34 | GCodeResult FinishConfiguring(bool changed, const StringRef& reply) noexcept; 35 | 36 | uint8_t cr0; 37 | uint8_t thermocoupleType; 38 | }; 39 | 40 | #endif // SUPPORT_SPI_SENSORS 41 | 42 | #endif /* SRC_HEATING_SENSORS_THERMOCOUPLESENSOR31856_H_ */ 43 | -------------------------------------------------------------------------------- /src/Heating/Sensors/TmcDriverTemperatureSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TmcDriverTemperatureSensor.cpp 3 | * 4 | * Created on: 8 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #include "TmcDriverTemperatureSensor.h" 9 | #include 10 | #include 11 | 12 | #if HAS_SMART_DRIVERS 13 | 14 | // Sensor type descriptors 15 | TemperatureSensor::SensorTypeDescriptor TmcDriverTemperatureSensor::primaryTmcDriverSensorDescriptor(PrimaryTypeName, [](unsigned int sensorNum) noexcept -> TemperatureSensor *_ecv_from { return new TmcDriverTemperatureSensor(sensorNum, 0); } ); 16 | 17 | #if defined(DUET_NG) || defined(PCCB_10) 18 | TemperatureSensor:: SensorTypeDescriptor TmcDriverTemperatureSensor::duexTmcDriverSensorDescriptor(DuexTypeName, [](unsigned int sensorNum) noexcept -> TemperatureSensor *_ecv_from { return new TmcDriverTemperatureSensor(sensorNum, 1); } ); 19 | #endif 20 | 21 | TmcDriverTemperatureSensor::TmcDriverTemperatureSensor(unsigned int sensorNum, unsigned int chan) noexcept 22 | : TemperatureSensor(sensorNum, "Stepper driver temperature warnings"), channel(chan) 23 | { 24 | } 25 | 26 | const char *_ecv_array TmcDriverTemperatureSensor::GetShortSensorType() const noexcept 27 | { 28 | #ifdef DUET_NG 29 | return (channel == 1) ? DuexTypeShortName : PrimaryTypeName; 30 | #else 31 | return PrimaryTypeName; 32 | #endif 33 | } 34 | 35 | void TmcDriverTemperatureSensor::Poll() noexcept 36 | { 37 | SetResult(reprap.GetMove().GetTmcDriversTemperature(channel), TemperatureError::ok); 38 | } 39 | 40 | #endif 41 | 42 | // End 43 | -------------------------------------------------------------------------------- /src/Heating/Sensors/TmcDriverTemperatureSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TmcDriverTemperatureSensor.h 3 | * 4 | * Created on: 8 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_HEATING_SENSORS_TMCDRIVERTEMPERATURESENSOR_H_ 9 | #define SRC_HEATING_SENSORS_TMCDRIVERTEMPERATURESENSOR_H_ 10 | 11 | #include "TemperatureSensor.h" 12 | 13 | #if HAS_SMART_DRIVERS 14 | 15 | class TmcDriverTemperatureSensor : public TemperatureSensor 16 | { 17 | public: 18 | TmcDriverTemperatureSensor(unsigned int sensorNum, unsigned int chan) noexcept; 19 | 20 | int GetSmartDriversChannel() const noexcept override { return (int) channel; } // Get the smart drivers channel that this sensor monitors, or -1 if it doesn't 21 | void Poll() noexcept override; 22 | const char *_ecv_array GetShortSensorType() const noexcept override; 23 | 24 | static constexpr const char *_ecv_array PrimaryTypeName = "drivers"; 25 | #if defined(DUET_NG) || defined(PCCB_10) 26 | static constexpr const char *_ecv_array DuexTypeName = "drivers-duex"; 27 | static constexpr const char *_ecv_array DuexTypeShortName = "driversduex"; 28 | #endif 29 | 30 | private: 31 | static SensorTypeDescriptor primaryTmcDriverSensorDescriptor; 32 | #if defined(DUET_NG) || defined(PCCB_10) 33 | static SensorTypeDescriptor duexTmcDriverSensorDescriptor; 34 | #endif 35 | 36 | unsigned int channel; 37 | }; 38 | 39 | #endif 40 | 41 | #endif /* SRC_HEATING_SENSORS_TMCDRIVERTEMPERATURESENSOR_H_ */ 42 | -------------------------------------------------------------------------------- /src/LedStrips/DotStarLedStrip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DotStarLedStrip.h 3 | * 4 | * Created on: 30 Apr 2023 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_LEDSTRIPS_DOTSTARLEDSTRIP_H_ 9 | #define SRC_LEDSTRIPS_DOTSTARLEDSTRIP_H_ 10 | 11 | #include "LocalLedStrip.h" 12 | 13 | #if SUPPORT_LED_STRIPS && SUPPORT_DMA_DOTSTAR 14 | 15 | class DotStarLedStrip : public LocalLedStrip 16 | { 17 | public: 18 | enum class ColorOrder : uint8_t 19 | { 20 | BGR = 0, 21 | BRG, 22 | RGB, 23 | RBG, 24 | GBR, 25 | GRB, 26 | count 27 | }; 28 | 29 | DotStarLedStrip() noexcept; 30 | 31 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, const char *_ecv_array pinName) THROWS(GCodeException) override; 32 | GCodeResult HandleM150(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException) override; 33 | 34 | #if SUPPORT_REMOTE_COMMANDS 35 | GCodeResult Configure(CanMessageGenericParser& parser, const StringRef& reply, uint8_t& extra) noexcept override; 36 | GCodeResult HandleM150(CanMessageGenericParser& parser, const StringRef& reply) noexcept override; 37 | #endif 38 | 39 | protected: 40 | size_t GetBytesPerLed() const noexcept override; 41 | 42 | private: 43 | GCodeResult SendDotStarData(uint32_t data, uint32_t numLeds, bool following) noexcept; 44 | 45 | static constexpr uint32_t DefaultDotStarSpiClockFrequency = 1000000; // 1MHz default 46 | 47 | unsigned int numRemaining = 0; // how much of the current request remains after the current transfer 48 | unsigned int totalSent = 0; // total amount of data sent since the start frame 49 | bool needStartFrame = true; 50 | ColorOrder colorOrder; 51 | }; 52 | 53 | #endif 54 | 55 | #endif /* SRC_LEDSTRIPS_DOTSTARLEDSTRIP_H_ */ 56 | -------------------------------------------------------------------------------- /src/LedStrips/LedStripBase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * LedStripBase.cpp 3 | * 4 | * Created on: 30 Apr 2023 5 | * Author: David 6 | */ 7 | 8 | #include "LedStripBase.h" 9 | 10 | #if SUPPORT_LED_STRIPS 11 | 12 | // Object model table and functions 13 | // Note: if using GCC version 7.3.1 20180622 and lambda functions are used in this table, you must compile this file with option -std=gnu++17. 14 | // Otherwise the table will be allocate in RAM instead of flash, which wastes too much RAM. 15 | 16 | // Macro to build a standard lambda function that includes the necessary type conversions 17 | #define OBJECT_MODEL_FUNC(...) OBJECT_MODEL_FUNC_BODY(LedStripBase, __VA_ARGS__) 18 | #define OBJECT_MODEL_FUNC_IF(_condition, ...) OBJECT_MODEL_FUNC_IF_BODY(LedStripBase, _condition, __VA_ARGS__) 19 | 20 | constexpr ObjectModelTableEntry LedStripBase::objectModelTable[] = 21 | { 22 | // 0. 23 | { "stopMovement", OBJECT_MODEL_FUNC(self->MustStopMovement()), ObjectModelEntryFlags::none }, 24 | { "type", OBJECT_MODEL_FUNC(self->GetTypeText()), ObjectModelEntryFlags::none }, 25 | }; 26 | 27 | constexpr uint8_t LedStripBase::objectModelTableDescriptor[] = 28 | { 29 | 1, // number of sections 30 | 2 // number in section 0 31 | }; 32 | 33 | DEFINE_GET_OBJECT_MODEL_TABLE(LedStripBase) 34 | 35 | const char *_ecv_array LedStripBase::GetTypeText() const noexcept 36 | { 37 | return type.ToString(); 38 | } 39 | 40 | #endif 41 | 42 | // End 43 | -------------------------------------------------------------------------------- /src/LedStrips/LedStripManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LedStripManager.h 3 | * 4 | * Created on: 30 Apr 2023 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_LEDSTRIPS_LEDSTRIPMANAGER_H_ 9 | #define SRC_LEDSTRIPS_LEDSTRIPMANAGER_H_ 10 | 11 | #include 12 | 13 | #if SUPPORT_LED_STRIPS 14 | 15 | #include "LedStripBase.h" 16 | 17 | #if SUPPORT_REMOTE_COMMANDS 18 | class CanMessageGeneric; 19 | #endif 20 | 21 | class LedStripManager 22 | { 23 | public: 24 | LedStripManager() noexcept; 25 | 26 | GCodeResult CreateStrip(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); 27 | GCodeResult HandleM150(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); 28 | bool MustStopMovement(GCodeBuffer& gb) noexcept; // test whether this strip requires motion to be stopped before sending a command 29 | 30 | size_t GetNumLedStrips() const noexcept; // called by RepRap.cpp object model entry 31 | const LedStripBase *_ecv_from _ecv_null GetLedStrip(size_t index) const noexcept; // called by RepRap.cpp object model entry 32 | 33 | #if SUPPORT_REMOTE_COMMANDS 34 | GCodeResult HandleM950Led(const CanMessageGeneric &msg, const StringRef& reply, uint8_t& extra) noexcept; 35 | GCodeResult HandleLedSetColours(const CanMessageGeneric &msg, const StringRef& reply) noexcept; 36 | #endif 37 | 38 | static ReadWriteLock ledLock; // needs to be public and static because RepRap.cpp needs to get it for the object model 39 | 40 | private: 41 | LedStripBase *_ecv_from _ecv_null strips[MaxLedStrips]; 42 | }; 43 | 44 | #endif 45 | 46 | #endif /* SRC_LEDSTRIPS_LEDSTRIPMANAGER_H_ */ 47 | -------------------------------------------------------------------------------- /src/LedStrips/NeoPixelLedStrip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NeoPixelLedStrip.h 3 | * 4 | * Created on: 30 Apr 2023 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_LEDSTRIPS_NEOPIXELLEDSTRIP_H_ 9 | #define SRC_LEDSTRIPS_NEOPIXELLEDSTRIP_H_ 10 | 11 | #include "LocalLedStrip.h" 12 | 13 | #if SUPPORT_LED_STRIPS 14 | 15 | class NeoPixelLedStrip : public LocalLedStrip 16 | { 17 | public: 18 | explicit NeoPixelLedStrip(bool p_isRGBW) noexcept; 19 | 20 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, const char *_ecv_array _ecv_null pinName) THROWS(GCodeException) override; 21 | GCodeResult HandleM150(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException) override; 22 | 23 | #if SUPPORT_REMOTE_COMMANDS 24 | GCodeResult Configure(CanMessageGenericParser& parser, const StringRef& reply, uint8_t& extra) noexcept override; 25 | GCodeResult HandleM150(CanMessageGenericParser& parser, const StringRef& reply) noexcept override; 26 | #endif 27 | 28 | protected: 29 | size_t GetBytesPerLed() const noexcept override; 30 | 31 | private: 32 | static constexpr uint32_t DefaultNeoPixelSpiClockFrequency = 2500000; // must be between about 2MHz and about 4MHz 33 | static constexpr uint32_t MinNeoPixelResetTicks = (250 * StepClockRate)/1000000; // 250us minimum Neopixel reset time on later chips 34 | 35 | GCodeResult BitBangData(const LedParams& params) noexcept; 36 | 37 | #if SUPPORT_DMA_NEOPIXEL 38 | GCodeResult SpiSendData(const LedParams& params) noexcept; 39 | #endif 40 | 41 | unsigned int numAlreadyInBuffer = 0; // number of pixels already store in the buffer 42 | bool isRGBW; 43 | bool needStartDelay = true; 44 | }; 45 | 46 | #endif 47 | 48 | #endif /* SRC_LEDSTRIPS_NEOPIXELLEDSTRIP_H_ */ 49 | -------------------------------------------------------------------------------- /src/LedStrips/RemoteLedStrip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RemoteLedStrip.h 3 | * 4 | * Created on: 30 Apr 2023 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_LEDSTRIPS_REMOTELEDSTRIP_H_ 9 | #define SRC_LEDSTRIPS_REMOTELEDSTRIP_H_ 10 | 11 | #include "LedStripBase.h" 12 | 13 | #if SUPPORT_LED_STRIPS && SUPPORT_CAN_EXPANSION 14 | 15 | class RemoteLedStrip : public LedStripBase 16 | { 17 | public: 18 | RemoteLedStrip(LedStripType p_type, size_t p_slotNumber, CanAddress p_boardNumber) noexcept; 19 | ~RemoteLedStrip() override; 20 | 21 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, const char *_ecv_array pinName) THROWS(GCodeException) override; 22 | GCodeResult HandleM150(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException) override; 23 | bool MustStopMovement() const noexcept override { return (remoteProperties & 0x01) == 0; } 24 | 25 | #if SUPPORT_REMOTE_COMMANDS 26 | GCodeResult Configure(CanMessageGenericParser& parser, const StringRef& reply, uint8_t& extra) noexcept override { return GCodeResult::remoteInternalError; } 27 | GCodeResult HandleM150(CanMessageGenericParser& parser, const StringRef& reply) noexcept override { return GCodeResult::remoteInternalError; } 28 | #endif 29 | 30 | protected: 31 | DECLARE_OBJECT_MODEL 32 | 33 | private: 34 | size_t slotNumber; 35 | AutoStringHandle pinNameString; 36 | CanAddress boardNumber; 37 | uint8_t remoteProperties; // bit 0 means the remote driver uses DMA 38 | }; 39 | 40 | #endif 41 | 42 | #endif /* SRC_LEDSTRIPS_REMOTELEDSTRIP_H_ */ 43 | -------------------------------------------------------------------------------- /src/Libraries/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /src/Memory usage.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Memory usage.ods -------------------------------------------------------------------------------- /src/Movement/Coordinate and endpoint management.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Movement/Coordinate and endpoint management.ods -------------------------------------------------------------------------------- /src/Movement/ExtruderShaper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * PressureAdvanceShaper.cpp 3 | * 4 | * Created on: 14 May 2021 5 | * Author: David 6 | */ 7 | 8 | #include "ExtruderShaper.h" 9 | 10 | // No code here yet because all members are inlined 11 | 12 | // End 13 | -------------------------------------------------------------------------------- /src/Movement/ExtruderShaper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PressureAdvanceShaper.h 3 | * 4 | * Created on: 14 May 2021 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_MOVEMENT_EXTRUDERSHAPER_H_ 9 | #define SRC_MOVEMENT_EXTRUDERSHAPER_H_ 10 | 11 | #include 12 | 13 | // This class implements MoveSegment generation for extruders with pressure advance. 14 | // It also tracks extrusion that has been commanded but not implemented because less than one full step has been accumulated. 15 | // Currently it only supports linear pressure advance. 16 | class ExtruderShaper 17 | { 18 | public: 19 | ExtruderShaper() 20 | : k(0.0) 21 | { } 22 | 23 | // Temporary functions until we support more sophisticated pressure advance 24 | float GetKclocks() const noexcept { return k; } // get pressure advance in step clocks 25 | float GetKseconds() const noexcept { return k * (1.0/(float)StepClockRate); } 26 | void SetKseconds(float val) noexcept { k = val * StepClockRate; } // set pressure advance in seconds 27 | 28 | private: 29 | float k; // the pressure advance constant in step clocks 30 | }; 31 | 32 | #endif /* SRC_MOVEMENT_EXTRUDERSHAPER_H_ */ 33 | -------------------------------------------------------------------------------- /src/Movement/HomingMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HomingMode.h 3 | * 4 | * Created on: 1 Jan 2025 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_MOVEMENT_HOMINGMODE_H_ 9 | #define SRC_MOVEMENT_HOMINGMODE_H_ 10 | 11 | #include 12 | 13 | // Class used to define homing mode 14 | enum class HomingMode : uint8_t 15 | { 16 | homeCartesianAxes, 17 | homeIndividualDrives, 18 | }; 19 | 20 | #endif /* SRC_MOVEMENT_HOMINGMODE_H_ */ 21 | -------------------------------------------------------------------------------- /src/Movement/Kinematics/RoundBedKinematics.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RoundBedKinematics.cpp 3 | * 4 | * Created on: 16 Feb 2021 5 | * Author: manuel 6 | */ 7 | 8 | #include "RoundBedKinematics.h" 9 | #include 10 | #include 11 | 12 | RoundBedKinematics::RoundBedKinematics(KinematicsType t, SegmentationType segType) noexcept 13 | : Kinematics(t, segType), printRadiusSquared(0.0) 14 | { 15 | } 16 | 17 | 18 | // Return true if the specified XY position is reachable by the print head reference point. 19 | bool RoundBedKinematics::IsReachable(float axesCoords[MaxAxes], AxesBitmap axes) const noexcept 20 | { 21 | if (axes.IsBitSet(X_AXIS) && axes.IsBitSet(Y_AXIS) && (fsquare(axesCoords[X_AXIS]) + fsquare(axesCoords[Y_AXIS]) >= printRadiusSquared)) 22 | { 23 | return false; 24 | } 25 | axes.ClearBit(X_AXIS); 26 | axes.ClearBit(Y_AXIS); 27 | return Kinematics::IsReachable(axesCoords, axes); 28 | } 29 | 30 | // End 31 | -------------------------------------------------------------------------------- /src/Movement/Kinematics/RoundBedKinematics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RoundBedKinematics.h 3 | * 4 | * Created on: 16 Feb 2021 5 | * Author: manuel 6 | */ 7 | 8 | #ifndef SRC_MOVEMENT_KINEMATICS_ROUNDBEDKINEMATICS_H_ 9 | #define SRC_MOVEMENT_KINEMATICS_ROUNDBEDKINEMATICS_H_ 10 | 11 | #include "RepRapFirmware.h" 12 | #include "Kinematics.h" 13 | #include 14 | 15 | class RoundBedKinematics : public Kinematics 16 | { 17 | public: 18 | bool IsReachable(float axesCoords[MaxAxes], AxesBitmap axes) const noexcept override; 19 | 20 | protected: 21 | RoundBedKinematics(KinematicsType t, SegmentationType segType) noexcept; 22 | 23 | float printRadiusSquared; 24 | }; 25 | 26 | #endif /* SRC_MOVEMENT_KINEMATICS_ROUNDBEDKINEMATICS_H_ */ 27 | -------------------------------------------------------------------------------- /src/Movement/Kinematics/ZLeadscrewKinematics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZLeadscrewKinematics.h 3 | * 4 | * Created on: 8 Jul 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_MOVEMENT_KINEMATICS_ZLEADSCREWKINEMATICS_H_ 9 | #define SRC_MOVEMENT_KINEMATICS_ZLEADSCREWKINEMATICS_H_ 10 | 11 | #include "Kinematics.h" 12 | 13 | // This is used as the base class for any kinematic that supports auto or manual bed levelling (as distinct from bed compensation) using leadscrews or bed adjusting screws. 14 | class ZLeadscrewKinematics : public Kinematics 15 | { 16 | public: 17 | ZLeadscrewKinematics(KinematicsType k) noexcept; 18 | ZLeadscrewKinematics(KinematicsType t, SegmentationType segType) noexcept; 19 | 20 | bool Configure(unsigned int mCode, GCodeBuffer& gb, const StringRef& reply, bool& error) THROWS(GCodeException) override; 21 | bool SupportsAutoCalibration() const noexcept override; 22 | bool DoAutoCalibration(MovementState& ms, size_t numFactors, const RandomProbePointSet& probePoints, const StringRef& reply) noexcept override; 23 | #if HAS_MASS_STORAGE || HAS_SBC_INTERFACE 24 | bool WriteResumeSettings(FileStore *f) const noexcept override; 25 | #endif 26 | 27 | protected: 28 | DECLARE_OBJECT_MODEL_WITH_ARRAYS 29 | 30 | private: 31 | void AppendCorrections(const floatc_t corrections[], const StringRef& reply) const noexcept; 32 | 33 | static const unsigned int MaxLeadscrews = 4; // the maximum we support for auto bed levelling 34 | 35 | unsigned int numLeadscrews; 36 | float leadscrewX[MaxLeadscrews], leadscrewY[MaxLeadscrews]; 37 | float correctionFactor; 38 | float maxCorrection; 39 | float screwPitch; 40 | float lastCorrections[MaxLeadscrews]; 41 | }; 42 | 43 | #endif /* SRC_MOVEMENT_KINEMATICS_ZLEADSCREWKINEMATICS_H_ */ 44 | -------------------------------------------------------------------------------- /src/Movement/MoveDebugFlags.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MoveDebugFlags.h 3 | * 4 | * Created on: 20 Aug 2023 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_MOVEMENT_MOVEDEBUGFLAGS_H_ 9 | #define SRC_MOVEMENT_MOVEDEBUGFLAGS_H_ 10 | 11 | namespace MoveDebugFlags 12 | { 13 | // Bit numbers in the move debug bitmap. The lowest 8 bits are the default settings 14 | constexpr unsigned int PrintBadMoves = 0; 15 | constexpr unsigned int PrintAllMoves = 1; 16 | constexpr unsigned int CollisionData = 2; 17 | 18 | constexpr unsigned int Lookahead = 8; 19 | constexpr unsigned int ZProbing = 9; 20 | constexpr unsigned int AxisAllocation = 10; 21 | constexpr unsigned int SimulateSteppingDrivers = 11; 22 | constexpr unsigned int Segments = 12; 23 | constexpr unsigned int PhaseStep = 13; 24 | constexpr unsigned int PrintTransforms = 14; 25 | } 26 | 27 | #endif /* SRC_MOVEMENT_MOVEDEBUGFLAGS_H_ */ 28 | -------------------------------------------------------------------------------- /src/Movement/MoveSegment.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MoveSegment.cpp 3 | * 4 | * Created on: 26 Feb 2021 5 | * Author: David 6 | */ 7 | 8 | #include "MoveSegment.h" 9 | 10 | // Static members 11 | 12 | MoveSegment *_ecv_null MoveSegment::freeList = nullptr; 13 | unsigned int MoveSegment::numCreated = 0; 14 | 15 | // Allocate a MoveSegment, from the freelist if possible, else create a new one 16 | MoveSegment *MoveSegment::Allocate(MoveSegment *_ecv_null p_next) noexcept 17 | { 18 | const auto iflags = IrqSave(); 19 | MoveSegment *_ecv_null ms = freeList; 20 | if (ms != nullptr) 21 | { 22 | freeList = ms->next; 23 | IrqRestore(iflags); 24 | ms->next = p_next; 25 | } 26 | else 27 | { 28 | ++numCreated; 29 | IrqRestore(iflags); 30 | ms = new MoveSegment(p_next); 31 | } 32 | return ms; 33 | } 34 | 35 | // Release a MoveSegment 36 | void MoveSegment::ReleaseAll(MoveSegment *_ecv_null item) noexcept 37 | { 38 | while (item != nullptr) 39 | { 40 | MoveSegment *itemToRelease = item; 41 | item = item->next; 42 | Release(itemToRelease); 43 | } 44 | } 45 | 46 | void MoveSegment::DebugPrint() const noexcept 47 | { 48 | debugPrintf("s=%" PRIu32 " t=%" PRIu32 " d=%.2f u=%.4e a=%.4e f=%02" PRIx32 "\n", startTime, duration, (double)distance, (double)CalcU(), (double)a, flags.all); 49 | } 50 | 51 | // Append details of this segment to a string buffer 52 | void MoveSegment::AppendDetails(const StringRef& str) const noexcept 53 | { 54 | str.catf("s=%" PRIu32 " t=%" PRIu32 " d=%.2f u=%.4e a=%.4e f=%02" PRIx32 "\n", startTime, duration, (double)distance, (double)CalcU(), (double)a, flags.all); 55 | } 56 | 57 | /*static*/ void MoveSegment::DebugPrintList(const MoveSegment *_ecv_null segs) noexcept 58 | { 59 | if (segs == nullptr) 60 | { 61 | debugPrintf("null seg\n"); 62 | } 63 | else 64 | { 65 | while (segs != nullptr) 66 | { 67 | segs->DebugPrint(); 68 | segs = segs->GetNext(); 69 | } 70 | } 71 | } 72 | 73 | // End 74 | -------------------------------------------------------------------------------- /src/Movement/MovementError.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MovementError.cpp 3 | * 4 | * Created on: 23 Apr 2025 5 | * Author: David 6 | */ 7 | 8 | #include "MovementError.h" 9 | 10 | const char *_ecv_array GetMovementErrorText(MovementError err) noexcept 11 | { 12 | switch (err) 13 | { 14 | case MovementError::microstep_position_too_large: return "microstep position too large"; 15 | case MovementError::unreachable_position: return "unreachable position"; 16 | case MovementError::move_duration_too_long: return "move duration too long"; 17 | 18 | case MovementError::ok: 19 | case MovementError::noMovement: 20 | default: 21 | return "no error"; 22 | } 23 | } 24 | 25 | // End 26 | -------------------------------------------------------------------------------- /src/Movement/MovementError.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MovementError.h 3 | * 4 | * Created on: 23 Apr 2025 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_MOVEMENT_MOVEMENTERROR_H_ 9 | #define SRC_MOVEMENT_MOVEMENTERROR_H_ 10 | 11 | #include 12 | 13 | // Class to represent the types of movement error that can occur but can't easily be detected before the move is queued 14 | enum class MovementError : uint8_t 15 | { 16 | ok, // move can be executed 17 | noMovement, // no significant movement was commanded so the move can be ignored 18 | microstep_position_too_large, // exceeded about +/- 2^31 microsteps from zero position 19 | unreachable_position, // the kinematics can't reach the requested position 20 | move_duration_too_long // the move would take more than about 2^31 step clocks 21 | }; 22 | 23 | const char *_ecv_array GetMovementErrorText(MovementError err) noexcept; 24 | 25 | #endif /* SRC_MOVEMENT_MOVEMENTERROR_H_ */ 26 | -------------------------------------------------------------------------------- /src/Movement/StepperDrivers/DriverData.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DriverData.cpp 3 | * 4 | * Created on: 25 Sept 2023 5 | * Author: David 6 | */ 7 | 8 | #include "DriverData.h" 9 | 10 | #define OBJECT_MODEL_FUNC(...) OBJECT_MODEL_FUNC_BODY(DriverData, __VA_ARGS__) 11 | #define OBJECT_MODEL_FUNC_IF(_condition, ...) OBJECT_MODEL_FUNC_IF_BODY(DriverData, _condition, __VA_ARGS__) 12 | 13 | constexpr ObjectModelTableEntry DriverData::objectModelTable[] = 14 | { 15 | // Within each group, these entries must be in alphabetical order 16 | // 0. DriverData members 17 | { "closedLoop", OBJECT_MODEL_FUNC_IF(self->haveClosedLoopData, self, 1), ObjectModelEntryFlags::liveNotPanelDue }, 18 | { "status", OBJECT_MODEL_FUNC(self->status.all), ObjectModelEntryFlags::liveNotPanelDue }, 19 | 20 | // 1. closedLoop members 21 | { "currentFraction", OBJECT_MODEL_FUNC(self, 2), ObjectModelEntryFlags::liveNotPanelDue }, 22 | { "positionError", OBJECT_MODEL_FUNC(self, 3), ObjectModelEntryFlags::liveNotPanelDue }, 23 | 24 | // 2. closedLoop.currentFraction members 25 | { "avg", OBJECT_MODEL_FUNC((float)self->averageCurrentFraction, 2), ObjectModelEntryFlags::liveNotPanelDue }, 26 | { "max", OBJECT_MODEL_FUNC((float)self->maxCurrentFraction, 2), ObjectModelEntryFlags::liveNotPanelDue }, 27 | 28 | // 3. closedLoop.positionError members 29 | { "max", OBJECT_MODEL_FUNC((float)self->maxAbsPositionError, 2), ObjectModelEntryFlags::liveNotPanelDue }, 30 | { "rms", OBJECT_MODEL_FUNC((float)self->rmsPositionError, 2), ObjectModelEntryFlags::liveNotPanelDue }, 31 | }; 32 | 33 | constexpr uint8_t DriverData::objectModelTableDescriptor[] = { 4, 2, 2, 2, 2 }; 34 | 35 | DEFINE_GET_OBJECT_MODEL_TABLE(DriverData) 36 | 37 | // End 38 | -------------------------------------------------------------------------------- /src/Movement/StepperDrivers/DriverData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DriverData.h 3 | * 4 | * Created on: 25 Sept 2023 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_MOVEMENT_STEPPERDRIVERS_DRIVERDATA_H_ 9 | #define SRC_MOVEMENT_STEPPERDRIVERS_DRIVERDATA_H_ 10 | 11 | #include 12 | #include 13 | 14 | // Data structure to represent driver parameters 15 | class DriverData INHERIT_OBJECT_MODEL 16 | { 17 | protected: 18 | DECLARE_OBJECT_MODEL 19 | 20 | public: 21 | StandardDriverStatus status; 22 | // Add additional fields here e.g. configured motor current 23 | // ... 24 | // Fields for closed loop data collection 25 | bool haveClosedLoopData = false; 26 | float16_t averageCurrentFraction = 0.0, maxCurrentFraction = 0.0, rmsPositionError = 0.0, maxAbsPositionError = 0.0; 27 | }; 28 | 29 | #endif /* SRC_MOVEMENT_STEPPERDRIVERS_DRIVERDATA_H_ */ 30 | -------------------------------------------------------------------------------- /src/Movement/StepperDrivers/DriverMode.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DriverMode.cpp 3 | * 4 | * Created on: 27 Apr 2018 5 | * Author: David 6 | */ 7 | 8 | #include 9 | #include "DriverMode.h" 10 | 11 | // This table must be in the same order as enum DriverMode 12 | static const char *_ecv_array const DriverModeStrings[] = 13 | { 14 | "constant off-time", 15 | "random off-time", 16 | "spreadCycle", 17 | "stealthChop", 18 | #if SUPPORT_TMC51xx && (SUPPORT_CLOSED_LOOP || SUPPORT_PHASE_STEPPING) 19 | "direct", 20 | #endif 21 | "unknown" 22 | }; 23 | 24 | static_assert(ARRAY_SIZE(DriverModeStrings) == (unsigned int)DriverMode::unknown + 1, "bad driver mode string table"); 25 | 26 | const char *_ecv_array TranslateDriverMode(unsigned int mode) noexcept 27 | { 28 | const unsigned int imode = min(mode, (unsigned int)DriverMode::unknown); 29 | return DriverModeStrings[imode]; 30 | } 31 | 32 | // End 33 | -------------------------------------------------------------------------------- /src/Movement/StepperDrivers/DriverMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DriverModes.h 3 | * 4 | * Created on: 27 Apr 2018 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_MOVEMENT_STEPPERDRIVERS_DRIVERMODE_H_ 9 | #define SRC_MOVEMENT_STEPPERDRIVERS_DRIVERMODE_H_ 10 | 11 | enum class DriverMode : unsigned int 12 | { 13 | constantOffTime = 0, 14 | randomOffTime, 15 | spreadCycle, 16 | stealthChop, // includes stealthChop2 17 | #if SUPPORT_PHASE_STEPPING || SUPPORT_CLOSED_LOOP 18 | direct, // field-oriented control 19 | #endif 20 | unknown // must be last! 21 | }; 22 | 23 | const char *_ecv_array TranslateDriverMode(unsigned int mode) noexcept; 24 | 25 | inline const char *_ecv_array TranslateDriverMode(DriverMode mode) noexcept 26 | { 27 | return TranslateDriverMode((unsigned int)mode); 28 | } 29 | 30 | // Register codes used to implement M569 command parameters. 31 | // This common set is used for all smart drivers. Not all are complete registers, some are just parts of registers. 32 | 33 | enum class SmartDriverRegister : unsigned int 34 | { 35 | toff, 36 | tblank, 37 | hstart, 38 | hend, 39 | hdec, 40 | chopperControl, 41 | coolStep, 42 | tpwmthrs, 43 | tcoolthrs, 44 | thigh, 45 | mstepPos, 46 | pwmScale, 47 | pwmAuto 48 | }; 49 | 50 | #endif /* SRC_MOVEMENT_STEPPERDRIVERS_DRIVERMODE_H_ */ 51 | -------------------------------------------------------------------------------- /src/Movement/StepperDrivers/SmartDrivers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SmartDrivers.h 3 | * 4 | * Created on: 10 Jan 2025 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_MOVEMENT_STEPPERDRIVERS_SMARTDRIVERS_H_ 9 | #define SRC_MOVEMENT_STEPPERDRIVERS_SMARTDRIVERS_H_ 10 | 11 | #if SUPPORT_TMC2660 12 | # include "TMC2660.h" 13 | #endif 14 | #if SUPPORT_TMC22xx 15 | # include "TMC22xx.h" 16 | #endif 17 | #if SUPPORT_TMC51xx 18 | # include "TMC51xx.h" 19 | #endif 20 | 21 | #endif /* SRC_MOVEMENT_STEPPERDRIVERS_SMARTDRIVERS_H_ */ 22 | -------------------------------------------------------------------------------- /src/Networking/ESP8266WiFi/WifiFirmwareUploader.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/ESP8266WiFi/WifiFirmwareUploader.cpp -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/AllocateFromPbufPool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AllocateFromPbufPool.h 3 | * 4 | * Created on: 2 Jul 2024 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_NETWORKING_LWIPETHERNET_ALLOCATEFROMPBUFPOOL_H_ 9 | #define SRC_NETWORKING_LWIPETHERNET_ALLOCATEFROMPBUFPOOL_H_ 10 | 11 | #include 12 | 13 | // The following functions are defined in file LwipEthernetInterface.cpp because that uses the correct include files already 14 | 15 | // Flag that allocation from the PBUF pool is allowed and set up the variables 16 | extern void InitAllocationFromPbufPool() noexcept; 17 | 18 | // Function to allocate memory from the LWIP PBUF pool. Use this only when Lwip Ethernet will definitely not be used. 19 | // Return a pointer to the allocated memory, or nullptr if there was insufficient memory left. 20 | extern void *AllocateFromPbufPool(size_t bytes) noexcept; 21 | 22 | #endif /* SRC_NETWORKING_LWIPETHERNET_ALLOCATEFROMPBUFPOOL_H_ */ 23 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | project(lwIP) 4 | 5 | set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 6 | include(src/Filelists.cmake) 7 | 8 | # Package generation 9 | set(CPACK_SOURCE_GENERATOR "ZIP") 10 | set(CPACK_SOURCE_PACKAGE_DESCRIPTION_SUMMARY "lwIP lightweight IP stack") 11 | set(CPACK_PACKAGE_VERSION_MAJOR "${LWIP_VERSION_MAJOR}") 12 | set(CPACK_PACKAGE_VERSION_MINOR "${LWIP_VERSION_MINOR}") 13 | set(CPACK_PACKAGE_VERSION_PATCH "${LWIP_VERSION_REVISION}") 14 | set(CPACK_SOURCE_IGNORE_FILES "/build/;${CPACK_SOURCE_IGNORE_FILES};.git") 15 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "lwip-${LWIP_VERSION_MAJOR}.${LWIP_VERSION_MINOR}.${LWIP_VERSION_REVISION}") 16 | include(CPack) 17 | 18 | # Target for package generation 19 | add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) 20 | add_dependencies(dist lwipdocs) 21 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/COPYING: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/FEATURES: -------------------------------------------------------------------------------- 1 | lwIP is a small independent implementation of the TCP/IP protocol suite targeted at embedded systems. 2 | 3 | The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM. 4 | 5 | Main features include: 6 | - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE, 6LowPAN (via IEEE 802.15.4, BLE or ZEP; since v2.1.0) 7 | - DHCP client, stateless DHCPv6 (since v2.1.0), DNS client (incl. mDNS hostname resolver), AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3 (since v2.1.0), private MIB support & MIB compiler) 8 | - APIs: specialized APIs for enhanced performance & zero copy, optional Berkeley-alike socket API 9 | - Extended features: IP forwarding over multiple network interfaces 10 | - Extended TCP features: congestion control, RTT estimation and fast recovery/fast retransmit, sending SACKs (since v2.1.0), "altcp": nearly transparent TLS for any tcp pcb (since v2.1.0) 11 | - Addon applications: HTTP server (HTTPS via altcp), HTTP(S) client (since v2.1.0), SNTP client, SMTP client (SMTPS via altcp), ping, NetBIOS nameserver, mDNS responder, MQTT client (TLS support since v2.1.0), TFTP server, iPerf2 counterpart 12 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/FILES: -------------------------------------------------------------------------------- 1 | src/ - The source code for the lwIP TCP/IP stack. 2 | doc/ - The documentation for lwIP. 3 | test/ - Some code to test whether the sources do what they should. 4 | 5 | See also the FILES file in each subdirectory. 6 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/doc/FILES: -------------------------------------------------------------------------------- 1 | doxygen/ - Configuration files and scripts to create the lwIP doxygen source 2 | documentation (found at http://www.nongnu.org/lwip/) 3 | 4 | savannah.txt - How to obtain the current development source code. 5 | contrib.txt - How to contribute to lwIP as a developer. 6 | rawapi.txt - The documentation for the core API of lwIP. 7 | Also provides an overview about the other APIs and multithreading. 8 | sys_arch.txt - The documentation for a system abstraction layer of lwIP. 9 | ppp.txt - Documentation of the PPP interface for lwIP. 10 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/doc/ZeroCopyRx.c: -------------------------------------------------------------------------------- 1 | typedef struct my_custom_pbuf 2 | { 3 | struct pbuf_custom p; 4 | void* dma_descriptor; 5 | } my_custom_pbuf_t; 6 | 7 | LWIP_MEMPOOL_DECLARE(RX_POOL, 10, sizeof(my_custom_pbuf_t), "Zero-copy RX PBUF pool"); 8 | 9 | void my_pbuf_free_custom(void* p) 10 | { 11 | SYS_ARCH_DECL_PROTECT(old_level); 12 | 13 | my_custom_pbuf_t* my_puf = (my_custom_pbuf_t*)p; 14 | 15 | // invalidate data cache here - lwIP and/or application may have written into buffer! 16 | // (invalidate is faster than flushing, and noone needs the correct data in the buffer) 17 | invalidate_cpu_cache(p->payload, p->tot_len); 18 | 19 | SYS_ARCH_PROTECT(old_level); 20 | free_rx_dma_descriptor(my_pbuf->dma_descriptor); 21 | LWIP_MEMPOOL_FREE(RX_POOL, my_pbuf); 22 | SYS_ARCH_UNPROTECT(old_level); 23 | } 24 | 25 | void eth_rx_irq() 26 | { 27 | dma_descriptor* dma_desc = get_RX_DMA_descriptor_from_ethernet(); 28 | my_custom_pbuf_t* my_pbuf = (my_custom_pbuf_t*)LWIP_MEMPOOL_ALLOC(RX_POOL); 29 | 30 | my_pbuf->p.custom_free_function = my_pbuf_free_custom; 31 | my_pbuf->dma_descriptor = dma_desc; 32 | 33 | invalidate_cpu_cache(dma_desc->rx_data, dma_desc->rx_length); 34 | 35 | struct pbuf* p = pbuf_alloced_custom(PBUF_RAW, 36 | dma_desc->rx_length, 37 | PBUF_REF, 38 | &my_pbuf->p, 39 | dma_desc->rx_data, 40 | dma_desc->max_buffer_size); 41 | 42 | if(netif->input(p, netif) != ERR_OK) { 43 | pbuf_free(p); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/FILES: -------------------------------------------------------------------------------- 1 | api/ - The code for the high-level wrapper API. Not needed if 2 | you use the lowel-level call-back/raw API. 3 | 4 | apps/ - Higher layer applications that are specifically programmed 5 | with the lwIP low-level raw API. 6 | 7 | core/ - The core of the TPC/IP stack; protocol implementations, 8 | memory and buffer management, and the low-level raw API. 9 | 10 | include/ - lwIP include files. 11 | 12 | netif/ - Generic network interface device drivers are kept here. 13 | 14 | For more information on the various subdirectories, check the FILES 15 | file in each directory. 16 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/apps/http/fs/404.html: -------------------------------------------------------------------------------- 1 | 2 | lwIP - A Lightweight TCP/IP Stack 3 | 4 | 5 | 6 | 19 |
7 | SICS logo 9 | 10 |

lwIP - A Lightweight TCP/IP Stack

11 |

404 - Page not found

12 |

13 | Sorry, the page you are requesting was not found on this 14 | server. 15 |

16 |
17 |   18 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/apps/http/fs/img/sics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/LwipEthernet/Lwip/src/apps/http/fs/img/sics.gif -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/apps/http/makefsdata/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains a script ('makefsdata') to create C code suitable for 2 | httpd for given html pages (or other files) in a directory. 3 | 4 | There is also a plain C console application doing the same and extended a bit. 5 | 6 | Usage: htmlgen [targetdir] [-s] [-i]s 7 | targetdir: relative or absolute path to files to convert 8 | switch -s: toggle processing of subdirectories (default is on) 9 | switch -e: exclude HTTP header from file (header is created at runtime, default is on) 10 | switch -11: include HTTP 1.1 header (1.0 is default) 11 | 12 | if targetdir not specified, makefsdata will attempt to 13 | process files in subdirectory 'fs'. 14 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/arch/sys_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_SYS_ARCH_H__ 2 | #define __ARCH_SYS_ARCH_H__ 3 | 4 | #define SYS_MBOX_NULL NULL 5 | #define SYS_SEM_NULL NULL 6 | 7 | typedef void * sys_prot_t; 8 | 9 | typedef void * sys_sem_t; 10 | 11 | typedef struct 12 | { 13 | struct QueueBase *m; 14 | } sys_mbox_t; 15 | 16 | typedef void * sys_thread_t; 17 | 18 | typedef struct 19 | { 20 | struct Mutex *m; 21 | } sys_mutex_t; 22 | 23 | #endif /* __ARCH_SYS_ARCH_H__ */ 24 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/compat/posix/arpa/inet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/compat/posix/net/if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/if_api.h. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | */ 35 | 36 | #include "lwip/if_api.h" 37 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/compat/posix/netdb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/netdb.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/netdb.h" 34 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/compat/posix/sys/socket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/compat/stdc/errno.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix/stdc wrapper for lwip/errno.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/errno.h" 34 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/lwip/apps/FILES: -------------------------------------------------------------------------------- 1 | This directory contains application headers. 2 | Every application shall provide one api file APP.h and optionally one options file APP_opts.h 3 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/lwip/apps/snmp_snmpv2_framework.h: -------------------------------------------------------------------------------- 1 | /* 2 | Generated by LwipMibCompiler 3 | */ 4 | 5 | #ifndef LWIP_HDR_APPS_SNMP_FRAMEWORK_MIB_H 6 | #define LWIP_HDR_APPS_SNMP_FRAMEWORK_MIB_H 7 | 8 | #include "lwip/apps/snmp_opts.h" 9 | #if LWIP_SNMP 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | #include "lwip/apps/snmp_core.h" 16 | 17 | extern const struct snmp_obj_id usmNoAuthProtocol; 18 | extern const struct snmp_obj_id usmHMACMD5AuthProtocol; 19 | extern const struct snmp_obj_id usmHMACSHAAuthProtocol; 20 | 21 | extern const struct snmp_obj_id usmNoPrivProtocol; 22 | extern const struct snmp_obj_id usmDESPrivProtocol; 23 | extern const struct snmp_obj_id usmAESPrivProtocol; 24 | 25 | extern const struct snmp_mib snmpframeworkmib; 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif /* __cplusplus */ 30 | 31 | #endif /* LWIP_SNMP */ 32 | #endif /* LWIP_HDR_APPS_SNMP_FRAMEWORK_MIB_H */ 33 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/lwip/apps/snmp_snmpv2_usm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Generated by LwipMibCompiler 3 | */ 4 | 5 | #ifndef LWIP_HDR_APPS_SNMP_USER_BASED_SM_MIB_H 6 | #define LWIP_HDR_APPS_SNMP_USER_BASED_SM_MIB_H 7 | 8 | #include "lwip/apps/snmp_opts.h" 9 | #if LWIP_SNMP 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | #include "lwip/apps/snmp_core.h" 16 | 17 | extern const struct snmp_mib snmpusmmib; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif /* __cplusplus */ 22 | 23 | #endif /* LWIP_SNMP */ 24 | #endif /* LWIP_HDR_APPS_SNMP_USER_BASED_SM_MIB_H */ 25 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/netif/etharp.h: -------------------------------------------------------------------------------- 1 | /* ARP has been moved to core/ipv4, provide this #include for compatibility only */ 2 | #include "lwip/etharp.h" 3 | #include "netif/ethernet.h" 4 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/include/netif/ppp/chap-md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chap-md5.h - New CHAP/MD5 implementation. 3 | * 4 | * Copyright (c) 2003 Paul Mackerras. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. The name(s) of the authors of this software must not be used to 14 | * endorse or promote products derived from this software without 15 | * prior written permission. 16 | * 17 | * 3. Redistributions of any form whatsoever must retain the following 18 | * acknowledgment: 19 | * "This product includes software developed by Paul Mackerras 20 | * ". 21 | * 22 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 23 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 24 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 25 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 27 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 28 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | */ 30 | 31 | #include "netif/ppp/ppp_opts.h" 32 | #if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 33 | 34 | extern const struct chap_digest_type md5_digest; 35 | 36 | #endif /* PPP_SUPPORT && CHAP_SUPPORT */ 37 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/netif/FILES: -------------------------------------------------------------------------------- 1 | This directory contains generic network interface device drivers that 2 | do not contain any hardware or architecture specific code. The files 3 | are: 4 | 5 | ethernet.c 6 | Shared code for Ethernet based interfaces. 7 | 8 | lowpan6.c 9 | A 6LoWPAN implementation as a netif. 10 | 11 | lowpan6_ble.c 12 | A 6LoWPAN over Bluetooth Low Energy (BLE) implementation as netif, 13 | according to RFC-7668. 14 | 15 | slipif.c 16 | A generic implementation of the SLIP (Serial Line IP) 17 | protocol. It requires a sio (serial I/O) module to work. 18 | 19 | ppp/ Point-to-Point Protocol stack 20 | The lwIP PPP support is based from pppd (http://ppp.samba.org) with 21 | huge changes to match code size and memory requirements for embedded 22 | devices. Please read /doc/ppp.txt and ppp/PPPD_FOLLOWUP for a detailed 23 | explanation. 24 | -------------------------------------------------------------------------------- /src/Networking/LwipEthernet/Lwip/src/netif/ppp/polarssl/README: -------------------------------------------------------------------------------- 1 | About PolarSSL files into lwIP PPP support 2 | ------------------------------------------ 3 | 4 | This folder contains some files fetched from the latest BSD release of 5 | the PolarSSL project (PolarSSL 0.10.1-bsd) for ciphers and encryption 6 | methods we need for lwIP PPP support. 7 | 8 | The PolarSSL files were cleaned to contain only the necessary struct 9 | fields and functions needed for lwIP. 10 | 11 | The PolarSSL API was not changed at all, so if you are already using 12 | PolarSSL you can choose to skip the compilation of the included PolarSSL 13 | library into lwIP. 14 | 15 | If you are not using the embedded copy you must include external 16 | libraries into your arch/cc.h port file. 17 | 18 | Beware of the stack requirements which can be a lot larger if you are not 19 | using our cleaned PolarSSL library. 20 | 21 | 22 | PolarSSL project website: http://polarssl.org/ 23 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Liam Bindle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/cmake/FindMbedTLS.cmake: -------------------------------------------------------------------------------- 1 | find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h) 2 | 3 | find_library(MBEDCRYPTO_LIBRARY mbedcrypto) 4 | find_library(MBEDTLS_LIBRARY mbedtls) 5 | find_library(MBEDX509_LIBRARY mbedx509) 6 | 7 | include(FindPackageHandleStandardArgs) 8 | find_package_handle_standard_args(MbedTLS DEFAULT_MSG 9 | MBEDTLS_INCLUDE_DIRS MBEDCRYPTO_LIBRARY MBEDTLS_LIBRARY MBEDX509_LIBRARY) 10 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/arrowdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/arrowdown.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/arrowright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/arrowright.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/bc_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/bc_s.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/bdwn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/bdwn.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/closed.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/dir_68267d1309a1af8e8297ef4c3efbcdba_dep.map: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/dir_68267d1309a1af8e8297ef4c3efbcdba_dep.md5: -------------------------------------------------------------------------------- 1 | 9426e705d6c99c39f2fe3934158670e3 -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/dir_68267d1309a1af8e8297ef4c3efbcdba_dep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/dir_68267d1309a1af8e8297ef4c3efbcdba_dep.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/doc.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/doxygen.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/folderclosed.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/folderopen.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/graph_legend.md5: -------------------------------------------------------------------------------- 1 | 387ff8eb65306fa251338d3c9bd7bfff -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/graph_legend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/graph_legend.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt-c-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/mqtt-c-logo.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt_8c__incl.map: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt_8c__incl.md5: -------------------------------------------------------------------------------- 1 | 68dd7e11984224dba8347dc84dabb5e2 -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt_8c__incl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/mqtt_8c__incl.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt_8h__dep__incl.map: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt_8h__dep__incl.md5: -------------------------------------------------------------------------------- 1 | 28a95cc45fecbac42acf7f94cf34aff6 -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt_8h__dep__incl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/mqtt_8h__dep__incl.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt_8h__incl.map: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt_8h__incl.md5: -------------------------------------------------------------------------------- 1 | 6999781e54df41331bfe60626d788b57 -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt_8h__incl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/mqtt_8h__incl.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt__pal_8c__incl.map: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt__pal_8c__incl.md5: -------------------------------------------------------------------------------- 1 | d3b4b6c0862483926546f997e01ffeff -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt__pal_8c__incl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/mqtt__pal_8c__incl.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt__pal_8h__dep__incl.map: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt__pal_8h__dep__incl.md5: -------------------------------------------------------------------------------- 1 | 8ef04c12d1a76ef09a858a745429d1db -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/mqtt__pal_8h__dep__incl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/mqtt__pal_8h__dep__incl.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/nav_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/nav_f.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/nav_g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/nav_g.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/nav_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/nav_h.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/open.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/splitbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/splitbar.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/sync_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/sync_off.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/sync_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/sync_on.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/tab_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/tab_a.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/tab_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/tab_b.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/tab_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/tab_h.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/docs/tab_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/MQTT/MQTT_C/docs/tab_s.png -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/examples/mosquitto.org.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEAzCCAuugAwIBAgIUBY1hlCGvdj4NhBXkZ/uLUZNILAwwDQYJKoZIhvcNAQEL 3 | BQAwgZAxCzAJBgNVBAYTAkdCMRcwFQYDVQQIDA5Vbml0ZWQgS2luZ2RvbTEOMAwG 4 | A1UEBwwFRGVyYnkxEjAQBgNVBAoMCU1vc3F1aXR0bzELMAkGA1UECwwCQ0ExFjAU 5 | BgNVBAMMDW1vc3F1aXR0by5vcmcxHzAdBgkqhkiG9w0BCQEWEHJvZ2VyQGF0Y2hv 6 | by5vcmcwHhcNMjAwNjA5MTEwNjM5WhcNMzAwNjA3MTEwNjM5WjCBkDELMAkGA1UE 7 | BhMCR0IxFzAVBgNVBAgMDlVuaXRlZCBLaW5nZG9tMQ4wDAYDVQQHDAVEZXJieTES 8 | MBAGA1UECgwJTW9zcXVpdHRvMQswCQYDVQQLDAJDQTEWMBQGA1UEAwwNbW9zcXVp 9 | dHRvLm9yZzEfMB0GCSqGSIb3DQEJARYQcm9nZXJAYXRjaG9vLm9yZzCCASIwDQYJ 10 | KoZIhvcNAQEBBQADggEPADCCAQoCggEBAME0HKmIzfTOwkKLT3THHe+ObdizamPg 11 | UZmD64Tf3zJdNeYGYn4CEXbyP6fy3tWc8S2boW6dzrH8SdFf9uo320GJA9B7U1FW 12 | Te3xda/Lm3JFfaHjkWw7jBwcauQZjpGINHapHRlpiCZsquAthOgxW9SgDgYlGzEA 13 | s06pkEFiMw+qDfLo/sxFKB6vQlFekMeCymjLCbNwPJyqyhFmPWwio/PDMruBTzPH 14 | 3cioBnrJWKXc3OjXdLGFJOfj7pP0j/dr2LH72eSvv3PQQFl90CZPFhrCUcRHSSxo 15 | E6yjGOdnz7f6PveLIB574kQORwt8ePn0yidrTC1ictikED3nHYhMUOUCAwEAAaNT 16 | MFEwHQYDVR0OBBYEFPVV6xBUFPiGKDyo5V3+Hbh4N9YSMB8GA1UdIwQYMBaAFPVV 17 | 6xBUFPiGKDyo5V3+Hbh4N9YSMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL 18 | BQADggEBAGa9kS21N70ThM6/Hj9D7mbVxKLBjVWe2TPsGfbl3rEDfZ+OKRZ2j6AC 19 | 6r7jb4TZO3dzF2p6dgbrlU71Y/4K0TdzIjRj3cQ3KSm41JvUQ0hZ/c04iGDg/xWf 20 | +pp58nfPAYwuerruPNWmlStWAXf0UTqRtg4hQDWBuUFDJTuWuuBvEXudz74eh/wK 21 | sMwfu1HFvjy5Z0iMDU8PUDepjVolOCue9ashlS4EB5IECdSR2TItnAIiIwimx839 22 | LdUdRudafMu5T5Xma182OC0/u/xRlEm+tvKGGmfFcN0piqVl8OrSPBgIlb+1IKJE 23 | m/XriWr/Cq4h/JfB7NTsezVslgkBaoU= 24 | -----END CERTIFICATE----- 25 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/examples/templates/bio_sockets.h: -------------------------------------------------------------------------------- 1 | #if !defined(__BIO_SOCKET_TEMPLATE_H__) 2 | #define __BIO_SOCKET_TEMPLATE_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | A template for opening a non-blocking BIO socket. 10 | */ 11 | BIO* open_nb_socket(const char* addr, const char* port) { 12 | BIO* bio = BIO_new_connect(addr); 13 | BIO_set_nbio(bio, 1); 14 | BIO_set_conn_port(bio, port); 15 | 16 | /* timeout after 10 seconds */ 17 | int start_time = time(NULL); 18 | while(BIO_do_connect(bio) == 0 && (int)time(NULL) - start_time < 10); 19 | 20 | if (BIO_do_connect(bio) <= 0) { 21 | fprintf(stderr, "Failed to open socket: BIO_do_connect returned <= 0\n"); 22 | return NULL; 23 | } 24 | 25 | return bio; 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/Networking/MQTT/MQTT_C/makefile: -------------------------------------------------------------------------------- 1 | UNAME = $(shell uname -o) 2 | 3 | CC = gcc 4 | CFLAGS = -Wextra -Wall -std=gnu99 -Iinclude -Wno-unused-parameter -Wno-unused-variable -Wno-duplicate-decl-specifier 5 | 6 | ifeq ($(UNAME), Msys) 7 | MSFLAGS = -lws2_32 8 | endif 9 | 10 | MQTT_C_SOURCES = src/mqtt.c src/mqtt_pal.c 11 | MQTT_C_EXAMPLES = bin/simple_publisher bin/simple_subscriber bin/reconnect_subscriber bin/bio_publisher bin/openssl_publisher 12 | MQTT_C_UNITTESTS = bin/tests 13 | BINDIR = bin 14 | 15 | all: $(BINDIR) $(MQTT_C_UNITTESTS) $(MQTT_C_EXAMPLES) 16 | 17 | bin/simple_%: examples/simple_%.c $(MQTT_C_SOURCES) 18 | $(CC) $(CFLAGS) $^ -lpthread $(MSFLAGS) -o $@ 19 | 20 | bin/reconnect_%: examples/reconnect_%.c $(MQTT_C_SOURCES) 21 | $(CC) $(CFLAGS) $^ -lpthread $(MSFLAGS) -o $@ 22 | 23 | bin/bio_%: examples/bio_%.c $(MQTT_C_SOURCES) 24 | $(CC) $(CFLAGS) `pkg-config --cflags openssl` -D MQTT_USE_BIO $^ -lpthread $(MSFLAGS) `pkg-config --libs openssl` -o $@ 25 | 26 | bin/openssl_%: examples/openssl_%.c $(MQTT_C_SOURCES) 27 | $(CC) $(CFLAGS) `pkg-config --cflags openssl` -D MQTT_USE_BIO $^ -lpthread $(MSFLAGS) `pkg-config --libs openssl` -o $@ 28 | 29 | $(BINDIR): 30 | mkdir -p $(BINDIR) 31 | 32 | $(MQTT_C_UNITTESTS): tests.c $(MQTT_C_SOURCES) 33 | $(CC) $(CFLAGS) $^ -lcmocka $(MSFLAGS) -o $@ 34 | 35 | clean: 36 | rm -rf $(BINDIR) 37 | 38 | check: all 39 | ./$(MQTT_C_UNITTESTS) 40 | -------------------------------------------------------------------------------- /src/Networking/MQTT/mqtt_pal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * mqtt_pal.cpp 3 | * 4 | * Created on: 01 Nov 2022 5 | * Author: rechrtb 6 | */ 7 | #include 8 | #include 9 | #include 10 | 11 | #include "mqtt.h" 12 | 13 | /* 14 | * MQTT-C PAL layer implementation 15 | */ 16 | 17 | ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags) 18 | { 19 | Socket* skt = static_cast(fd); 20 | 21 | ssize_t res = 0; 22 | 23 | if (skt->CanSend()) 24 | { 25 | res = skt->Send((const uint8_t*)buf, len); 26 | } 27 | else 28 | { 29 | res = MQTT_ERROR_SOCKET_ERROR; 30 | } 31 | 32 | return res; 33 | } 34 | 35 | ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t sz, int flags) 36 | { 37 | Socket* skt = static_cast(fd); 38 | 39 | ssize_t res = 0; 40 | char c = 0; 41 | 42 | if (skt->CanRead()) 43 | { 44 | char *cbuf = static_cast(buf); 45 | while (res < static_cast(sz) && skt->ReadChar(c)) 46 | { 47 | cbuf[res] = c; 48 | res++; 49 | } 50 | } 51 | else 52 | { 53 | res = MQTT_ERROR_SOCKET_ERROR; 54 | } 55 | 56 | return res; 57 | } 58 | 59 | void mqtt_pal_mutex_init(mqtt_pal_mutex_t *mutex) 60 | { 61 | static const char name[] = "MQTTClient"; 62 | mutex->m = new Mutex(); 63 | mutex->m->Create(name); 64 | } 65 | 66 | void mqtt_pal_mutex_lock(mqtt_pal_mutex_t *mutex) 67 | { 68 | mutex->m->Take(); 69 | } 70 | 71 | void mqtt_pal_mutex_unlock(mqtt_pal_mutex_t *mutex) 72 | { 73 | mutex->m->Release(); 74 | } 75 | -------------------------------------------------------------------------------- /src/Networking/MulticastDiscovery/MulticastResponder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MulricastResponder.h 3 | * 4 | * Created on: 12 Jul 2022 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_NETWORKING_MULTICASTRESPONDER_H_ 9 | #define SRC_NETWORKING_MULTICASTRESPONDER_H_ 10 | 11 | #include 12 | 13 | #if SUPPORT_MULTICAST_DISCOVERY 14 | 15 | #include 16 | 17 | namespace MulticastResponder 18 | { 19 | void Init() noexcept; 20 | void Spin() noexcept; 21 | void Start(TcpPort port) noexcept; 22 | void Stop() noexcept; 23 | void SendResponse(uint8_t *data, size_t length) noexcept; 24 | void ScheduleReboot() noexcept; 25 | void Diagnostics(const StringRef& reply) noexcept; 26 | } 27 | 28 | #endif 29 | 30 | #endif /* SRC_NETWORKING_MULTICASTRESPONDER_H_ */ 31 | -------------------------------------------------------------------------------- /src/Networking/NetworkClient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NetworkClient.h 3 | * 4 | * Created on: 01 Nov 2022 5 | * Author: rechrtb 6 | */ 7 | 8 | #ifndef SRC_NETWORKING_NETWORKCLIENT_H_ 9 | #define SRC_NETWORKING_NETWORKCLIENT_H_ 10 | 11 | #include 12 | #include "NetworkResponder.h" 13 | 14 | #if HAS_CLIENTS 15 | 16 | // Forward declarations 17 | class NetworkClient; 18 | class NetworkInterface; 19 | class Socket; 20 | 21 | // Base class for implementing a network client. Unlike a plain responder, 22 | // a client requests an outgoing connection instead of just listening for incoming ones. 23 | class NetworkClient : public NetworkResponder 24 | { 25 | public: 26 | NetworkClient(const NetworkClient&) = delete; 27 | NetworkClient(NetworkResponder *n, NetworkClient *c) noexcept; 28 | 29 | bool Start(NetworkProtocol protocol, NetworkInterface *iface) noexcept; 30 | void Stop(NetworkProtocol protocol, NetworkInterface *iface) noexcept; 31 | bool Accept(Socket *s, NetworkProtocol protocol) noexcept override; 32 | void Terminate(NetworkProtocol protocol, const NetworkInterface *iface) noexcept override; 33 | 34 | NetworkClient *GetNext() const noexcept { return next; } 35 | 36 | virtual bool HandlesProtocol(NetworkProtocol p) noexcept = 0; 37 | 38 | protected: 39 | virtual bool Start(NetworkInterface *interface) noexcept; 40 | virtual void Stop() noexcept = 0; 41 | virtual bool Accept(Socket *socket) noexcept = 0; 42 | virtual void Terminate() noexcept = 0; 43 | 44 | virtual void ConnectionLost() noexcept override; 45 | 46 | private: 47 | NetworkClient *next; // Next network client in the list 48 | uint32_t whenRequest; // Use to keep track of time spent requesting a connection 49 | 50 | static NetworkClient *clients; // Head of the list of all network clients 51 | }; 52 | 53 | #endif 54 | 55 | #endif /* SRC_NETWORKING_NETWORKCLIENT_H_ */ 56 | -------------------------------------------------------------------------------- /src/Networking/TelnetResponder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TelnetResponder.h 3 | * 4 | * Created on: 14 Apr 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_NETWORKING_TELNETRESPONDER_H_ 9 | #define SRC_NETWORKING_TELNETRESPONDER_H_ 10 | 11 | #include "NetworkResponder.h" 12 | 13 | class TelnetResponder : public NetworkResponder 14 | { 15 | public: 16 | explicit TelnetResponder(NetworkResponder *_ecv_from n) noexcept; 17 | bool Spin() noexcept override; // do some work, returning true if we did anything significant 18 | bool Accept(Socket *_ecv_from s, NetworkProtocol protocol) noexcept override; // ask the responder to accept this connection, returns true if it did 19 | void Terminate(NetworkProtocol protocol, const NetworkInterface *_ecv_from interface) noexcept override; // terminate the responder if it is serving the specified protocol on the specified interface 20 | 21 | static void InitStatic() noexcept; 22 | static void Disable() noexcept; 23 | static void HandleGCodeReply(const char *_ecv_array _ecv_null reply) noexcept; 24 | static void HandleGCodeReply(OutputBuffer *_ecv_null reply) noexcept; 25 | void Diagnostics(const StringRef& reply) const noexcept override; 26 | 27 | protected: 28 | void ConnectionLost() noexcept override; 29 | 30 | private: 31 | void CharFromClient(char c) noexcept; 32 | void ProcessLine() noexcept; 33 | 34 | bool SendGCodeReply() noexcept; 35 | 36 | bool haveCompleteLine; 37 | char clientMessage[MaxGCodeLength]; 38 | size_t clientPointer; 39 | uint32_t connectTime; 40 | 41 | static unsigned int numSessions; 42 | static unsigned int clientsServed; 43 | static OutputBuffer *_ecv_null gcodeReply; 44 | static Mutex gcodeReplyMutex; 45 | 46 | static const uint32_t TelnetSetupDuration = 4000; // ignore the first Telnet request within this duration (in ms) 47 | }; 48 | 49 | #endif /* SRC_NETWORKING_TELNETRESPONDER_H_ */ 50 | -------------------------------------------------------------------------------- /src/Networking/UploadingNetworkResponder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UploadingNetworkResponder.h 3 | * 4 | * Created on: 3 Feb 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_NETWORKING_UPLOADINGNETWORKRESPONDER_H_ 9 | #define SRC_NETWORKING_UPLOADINGNETWORKRESPONDER_H_ 10 | 11 | #include "NetworkResponder.h" 12 | 13 | class UploadingNetworkResponder : public NetworkResponder 14 | { 15 | protected: 16 | explicit UploadingNetworkResponder(NetworkResponder *_ecv_from _ecv_null n) noexcept; 17 | 18 | void ConnectionLost() noexcept override; 19 | virtual void CancelUpload() noexcept; 20 | 21 | #if HAS_MASS_STORAGE 22 | bool StartUpload(const char *_ecv_array folder, const char *_ecv_array fileName, const OpenMode mode, const uint32_t preAllocSize = 0) noexcept; 23 | void FinishUpload(uint32_t fileLength, time_t fileLastModified, bool gotCrc, uint32_t expectedCrc) noexcept; 24 | 25 | // File uploads 26 | FileData fileBeingUploaded; 27 | uint32_t uploadedBytes; // how many bytes have already been written 28 | bool uploadError; 29 | bool dummyUpload; 30 | #endif 31 | 32 | String filenameBeingProcessed; // usually the name of the file being uploaded, but also used by HttpResponder and FtpResponder 33 | }; 34 | 35 | #endif /* SRC_NETWORKING_UPLOADINGNETWORKRESPONDER_H_ */ 36 | -------------------------------------------------------------------------------- /src/Networking/W5500Ethernet/MdnsResponder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mDNSResponder.h 3 | * 4 | * Created on: 18 Sep 2019 5 | * Author: Christian 6 | */ 7 | 8 | #ifndef SRC_NETWORKING_W5500ETHERNET_MDNSRESPONDER_H_ 9 | #define SRC_NETWORKING_W5500ETHERNET_MDNSRESPONDER_H_ 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | #include "NetworkDefs.h" 19 | 20 | class W5500Socket; 21 | 22 | class MdnsResponder { 23 | public: 24 | explicit MdnsResponder(W5500Socket *sock) noexcept; 25 | 26 | void UpdateServiceRecords() noexcept; 27 | void Spin() noexcept; 28 | void Announce() noexcept; 29 | 30 | private: 31 | W5500Socket *socket; 32 | uint32_t lastAnnouncement; 33 | 34 | void ProcessPacket(const uint8_t *_ecv_array data, size_t length) const noexcept; 35 | bool CheckHostname(const uint8_t *_ecv_array ptr, size_t maxLength, size_t& bytesProcessed) const noexcept; 36 | void SendARecord(uint16_t transaction) const noexcept; 37 | }; 38 | 39 | #endif /* SRC_NETWORKING_W5500ETHERNET_MDNSRESPONDER_H_ */ 40 | -------------------------------------------------------------------------------- /src/Networking/W5500Ethernet/Wiznet/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /src/Networking/W5500Ethernet/Wiznet/.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # ========================= 18 | # Operating System Files 19 | # ========================= 20 | 21 | # OSX 22 | # ========================= 23 | 24 | .DS_Store 25 | .AppleDouble 26 | .LSOverride 27 | 28 | # Icon must end with two \r 29 | Icon 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /src/Networking/W5500Ethernet/Wiznet/Ethernet/Socket_APIs_V3.0.3.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/Networking/W5500Ethernet/Wiznet/Ethernet/Socket_APIs_V3.0.3.chm -------------------------------------------------------------------------------- /src/Networking/W5500Ethernet/Wiznet/Ethernet/WizSpi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Spi.h 3 | * 4 | * Created on: 16 Dec 2016 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_DUETNG_DUETETHERNET_ETHERNET3_UTILITY_WIZSPI_H_ 9 | #define SRC_DUETNG_DUETETHERNET_ETHERNET3_UTILITY_WIZSPI_H_ 10 | 11 | #include "RepRapFirmware.h" 12 | #include "spi/spi.h" 13 | 14 | namespace WizSpi 15 | { 16 | void Init() noexcept; 17 | void Stop() noexcept; 18 | void AssertSS() noexcept; 19 | void ReleaseSS() noexcept; 20 | void SendAddress(uint32_t addr) noexcept; 21 | uint8_t ReadByte() noexcept; 22 | void WriteByte(uint8_t b) noexcept; 23 | spi_status_t ReadBurst(uint8_t* rx_data, size_t len) noexcept; 24 | spi_status_t SendBurst(const uint8_t* tx_data, size_t len) noexcept; 25 | } 26 | 27 | #endif /* SRC_DUETNG_DUETETHERNET_ETHERNET3_UTILITY_WIZSPI_H_ */ 28 | -------------------------------------------------------------------------------- /src/ObjectModel/GlobalVariables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GlobalVariables.h 3 | * 4 | * Created on: 31 Mar 2021 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_OBJECTMODEL_GLOBALVARIABLES_H_ 9 | #define SRC_OBJECTMODEL_GLOBALVARIABLES_H_ 10 | 11 | #include "ObjectModel.h" 12 | #include "Variable.h" 13 | #include 14 | 15 | class GlobalVariables INHERIT_OBJECT_MODEL 16 | { 17 | public: 18 | GlobalVariables() noexcept { } 19 | 20 | ReadLockedPointer GetForReading() noexcept; 21 | WriteLockedPointer GetForWriting() noexcept; 22 | 23 | VariableSet& GetVariables() noexcept { return vars; } 24 | 25 | void ReportAllAsJson(OutputBuffer *buf) const THROWS(GCodeException); 26 | 27 | protected: 28 | DECLARE_OBJECT_MODEL 29 | 30 | // Construct a JSON representation of those parts of the object model requested by the user 31 | // This overrides the standard definition because the variable names are not fixed 32 | void ReportAsJson(OutputBuffer *buf, ObjectExplorationContext& context, const ObjectModelClassDescriptor * null classDescriptor, uint8_t tableNumber, const char *_ecv_array filter) const 33 | THROWS(GCodeException) override; 34 | 35 | private: 36 | VariableSet vars; 37 | mutable ReadWriteLock lock; 38 | }; 39 | 40 | #endif /* SRC_OBJECTMODEL_GLOBALVARIABLES_H_ */ 41 | -------------------------------------------------------------------------------- /src/ObjectModel/TypeCode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TypeCode.h 3 | * 4 | * Created on: 27 Sept 2022 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_OBJECTMODEL_TYPECODE_H_ 9 | #define SRC_OBJECTMODEL_TYPECODE_H_ 10 | 11 | #include 12 | 13 | #define SUPPORT_BITMAP64 (SAME70 || SAME5x) // we don't have any 64-bit bitmaps in the OM on Duet 2 14 | 15 | // Type codes to indicate what type of expression we have and how it is represented. 16 | // The "Special" type is for items that we have to evaluate when we are ready to write them out, in particular strings whose storage might disappear. 17 | enum class TypeCode : uint8_t 18 | { 19 | None = 0, 20 | Bool, 21 | Char, 22 | Uint32, 23 | Int32, 24 | Uint64, // only 56 bits actually available 25 | Float, 26 | Bitmap16, 27 | Bitmap32, 28 | #if SUPPORT_BITMAP64 29 | Bitmap64, // only 56 bits actually available 30 | #else 31 | Bitmap64_unused, 32 | #endif 33 | Enum32, 34 | ObjectModel_tc, // renamed for eCv to avoid clash with class ObjectModel 35 | CString, 36 | HeapString, 37 | HeapArray, 38 | IPAddress_tc, // renamed for eCv to avoid clash with class IPAddress in RRFLibraries 39 | ObjectModelArray, 40 | DateTime_tc, // renamed for eCv to avoid clash with class DateTime 41 | DriverId_tc, // renamed for eCv to avoid clash with class DriverId 42 | MacAddress_tc, // renamed for eCv to avoid clash with class MacAddress 43 | Special, 44 | Port, 45 | UniqueId_tc, 46 | Duration, // a duration represented an unsigned number of seconds (used by the 12864 LCD code) 47 | #if SUPPORT_CAN_EXPANSION 48 | CanExpansionBoardDetails 49 | #endif 50 | }; 51 | 52 | #endif /* SRC_OBJECTMODEL_TYPECODE_H_ */ 53 | -------------------------------------------------------------------------------- /src/Platform/Heap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Heap.h 3 | * 4 | * Created on: 5 Mar 2021 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_PLATFORM_HEAP_H_ 9 | #define SRC_PLATFORM_HEAP_H_ 10 | 11 | #include 12 | #include // for class ReadLockedPointer 13 | 14 | #include 15 | 16 | #define CHECK_HANDLES (1) // set nonzero to check that handles are valid before dereferencing them 17 | 18 | namespace Heap 19 | { 20 | // Struct used to represent an area of storage on the heap. 21 | // If this is changed, check whether struct ArrayStorageSpace in ArrayHandle.cpp needs to be changed too. 22 | struct StorageSpace 23 | { 24 | uint16_t length; // length of this object in bytes including this length field, always rounded up to a multiple of 4 25 | char data[]; // array of unspecified length at the end of a struct is a GNU extension (valid in C but not valid in standard C++) 26 | }; 27 | 28 | struct IndexSlot 29 | { 30 | StorageSpace *_ecv_null storage; 31 | std::atomic refCount; 32 | 33 | IndexSlot() noexcept : storage(nullptr), refCount(0) { } 34 | 35 | bool IsFree() const noexcept { return refCount.load() == 0 && storage == nullptr; } 36 | }; 37 | 38 | IndexSlot *AllocateHandle() noexcept; 39 | StorageSpace *AllocateSpace(size_t length) noexcept; 40 | void CheckSlotGood(IndexSlot *slotPtr) noexcept; 41 | void IncreaseRefCount(IndexSlot *slotPtr) noexcept; 42 | void DeleteSlot(IndexSlot *slotPtr) noexcept; 43 | void GarbageCollect() noexcept; 44 | bool CheckIntegrity(const StringRef& errmsg) noexcept; 45 | void Diagnostics(const StringRef& reply, Platform& p) noexcept; 46 | 47 | extern ReadWriteLock heapLock; 48 | } 49 | 50 | inline void Heap::IncreaseRefCount(IndexSlot *slotPtr) noexcept 51 | { 52 | ++slotPtr->refCount; 53 | } 54 | 55 | #endif /* SRC_PLATFORM_HEAP_H_ */ 56 | -------------------------------------------------------------------------------- /src/Platform/PortControl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PortControl.h 3 | * 4 | * Created on: 15 Jun 2017 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_PORTCONTROL_H_ 9 | #define SRC_PORTCONTROL_H_ 10 | 11 | #include "RepRapFirmware.h" 12 | #include "Hardware/IoPorts.h" 13 | 14 | class GCodeBuffer; 15 | 16 | #if SUPPORT_IOBITS 17 | 18 | class PortControl 19 | { 20 | public: 21 | PortControl() noexcept; 22 | void Init() noexcept; 23 | void Exit() noexcept; 24 | GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); 25 | 26 | // Functions called by DDARing 27 | void UpdatePorts(IoBits_t newPortState) noexcept; 28 | bool IsConfigured() const noexcept { return numConfiguredPorts != 0; } 29 | uint32_t GetAdvanceClocks() const noexcept { return advanceClocks; } 30 | 31 | private: 32 | 33 | static const size_t MaxIoBitsPorts = 16; // the port bitmap is currently a 16-bit word 34 | 35 | uint8_t gpOutPortNumbers[MaxIoBitsPorts]; 36 | size_t numConfiguredPorts; 37 | uint32_t advanceMillis; 38 | uint32_t advanceClocks; 39 | IoBits_t currentPortState; 40 | }; 41 | 42 | #endif 43 | 44 | #endif /* SRC_PORTCONTROL_H_ */ 45 | -------------------------------------------------------------------------------- /src/Platform/PrintPausedReason.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PrintPausedReason.h 3 | * 4 | * Created on: 12 Dec 2021 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_PLATFORM_PRINTPAUSEDREASON_H_ 9 | #define SRC_PLATFORM_PRINTPAUSEDREASON_H_ 10 | 11 | #include 12 | 13 | // The following values must be kept in sync with DSF! So don't change them unless making major changes to the SBC interface. 14 | enum class PrintPausedReason : uint8_t 15 | { 16 | dontPause = 0, // used by RRF but not by DSF 17 | user = 1, 18 | gcode = 2, 19 | filamentChange = 3, 20 | trigger = 4, 21 | heaterFault = 5, 22 | filamentError = 6, 23 | stall = 7, 24 | lowVoltage = 8, 25 | driverError = 9 26 | }; 27 | 28 | #endif /* SRC_PLATFORM_PRINTPAUSEDREASON_H_ */ 29 | -------------------------------------------------------------------------------- /src/Platform/TaskPriorities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TaskPriorities.h 3 | * 4 | * Created on: 23 Oct 2019 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_TASKPRIORITIES_H_ 9 | #define SRC_TASKPRIORITIES_H_ 10 | 11 | // Task priorities. These must all be less than configMAX_PRIORITIES defined in FreeRTOSConfig.g. 12 | namespace TaskPriority 13 | { 14 | constexpr unsigned int IdlePriority = 0; 15 | constexpr unsigned int SpinPriority = 1; // priority for tasks that rarely block 16 | #if HAS_SBC_INTERFACE 17 | constexpr unsigned int SbcPriority = 2; // priority for SBC task 18 | #endif 19 | constexpr unsigned int HeatPriority = 3; 20 | constexpr unsigned int UsbPriority = 3; // priority of USB task when using tinyusb 21 | constexpr unsigned int MovePriority = 4; 22 | constexpr unsigned int TmcPriority = 4; 23 | constexpr unsigned int AinPriority = 4; 24 | constexpr unsigned int HeightFollowingPriority = 4; 25 | #ifdef DUET_NG 26 | constexpr unsigned int DueXPriority = 5; 27 | #endif 28 | #if SUPPORT_PHASE_STEPPING 29 | constexpr unsigned int TmcPhaseStepPriority = 5; 30 | #endif 31 | constexpr unsigned int LaserPriority = 5; 32 | constexpr unsigned int CanSenderPriority = 5; 33 | constexpr unsigned int EthernetPriority = 5; 34 | constexpr unsigned int CanReceiverPriority = 6; 35 | constexpr unsigned int Accelerometer = 6; 36 | constexpr unsigned int CanClockPriority = 7; 37 | 38 | // Assert that the highest priority one isn't too high 39 | static_assert(CanClockPriority < configMAX_PRIORITIES); 40 | } 41 | 42 | #endif /* SRC_TASKPRIORITIES_H_ */ 43 | -------------------------------------------------------------------------------- /src/Platform/Tasks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Startup.h 3 | * 4 | * Created on: 26 Mar 2018 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_TASKS_H_ 9 | #define SRC_TASKS_H_ 10 | 11 | #include 12 | #include 13 | #include // for align_val_t 14 | 15 | namespace Tasks 16 | { 17 | void Diagnostics(const StringRef& reply) noexcept; 18 | TaskHandle GetMainTask() noexcept; 19 | void TerminateMainTask() noexcept; 20 | ptrdiff_t GetNeverUsedRam() noexcept; 21 | void *AllocPermanent(size_t sz, std::align_val_t align = (std::align_val_t) 22 | #if SAME70 23 | __STDCPP_DEFAULT_NEW_ALIGNMENT__ 24 | #else 25 | // gcc defines __STDCPP_DEFAULT_NEW_ALIGNMENT__ as 8, which is wasteful of memory on ARM Cortex M4 processors 26 | sizeof(float) 27 | #endif 28 | ) noexcept; 29 | const char *_ecv_array GetHeapTop() noexcept; 30 | Mutex *GetI2CMutex() noexcept; 31 | void *GetNVMBuffer(const uint32_t *_ecv_array null stk) noexcept; 32 | } 33 | 34 | #if SUPPORT_CAN_EXPANSION 35 | 36 | // Functions called by CanMessageBuffer in CANlib 37 | void *MessageBufferAlloc(size_t sz, std::align_val_t align) noexcept; 38 | void MessageBufferDelete(void *ptr, std::align_val_t align) noexcept; 39 | 40 | #endif 41 | 42 | #endif /* SRC_TASKS_H_ */ 43 | -------------------------------------------------------------------------------- /src/Platform/UniqueId.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * UniqueId.cpp 3 | * 4 | * Created on: 4 Oct 2021 5 | * Author: David 6 | */ 7 | 8 | #include "UniqueId.h" 9 | 10 | // Append the unique ID in character form to an output buffer 11 | void UniqueId::AppendCharsToBuffer(OutputBuffer *buf) const noexcept 12 | { 13 | AppendCharsTo([buf](char c)-> void { buf->cat(c);}); 14 | } 15 | 16 | // Generate a MAC address from this unique ID. Caller should check IsValid() first. 17 | void UniqueId::GenerateMacAddress(MacAddress& addr) const noexcept 18 | { 19 | // The unique ID is 128 bits long whereas the whole MAC address is only 48 bits, so we can't guarantee that each Duet will get a unique MAC address this way. 20 | // There are 16 ID bytes not including the checksum. It appears that the last bytes are more likely to change, so they must be included. 21 | memset(addr.bytes, 0, sizeof(addr.bytes)); 22 | addr.bytes[0] = 0xBE; // use a fixed first byte with the locally-administered bit set 23 | const uint8_t *_ecv_array const idBytes = reinterpret_cast(data); 24 | for (size_t i = 0; i < 16; ++i) 25 | { 26 | addr.bytes[(i % 5) + 1] ^= idBytes[i]; 27 | } 28 | } 29 | 30 | // End 31 | -------------------------------------------------------------------------------- /src/Platform/UniqueId.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UniqueId.h 3 | * 4 | * Created on: 4 Oct 2021 5 | * Author: David 6 | * 7 | * This class extends UniqueIdBase to add additional functions 8 | */ 9 | 10 | #ifndef SRC_PLATFORM_UNIQUEID_H_ 11 | #define SRC_PLATFORM_UNIQUEID_H_ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | // Unique ID class extended with some additional functions 18 | class UniqueId : public UniqueIdBase 19 | { 20 | public: 21 | void AppendCharsToBuffer(OutputBuffer *buf) const noexcept; 22 | void GenerateMacAddress(MacAddress& addr) const noexcept; 23 | }; 24 | 25 | #endif /* SRC_PLATFORM_UNIQUEID_H_ */ 26 | -------------------------------------------------------------------------------- /src/RepRapFirmware.pdp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Duet3D/RepRapFirmware/d7937bd8f0a917190bb57023e7e1641cbc261a18/src/RepRapFirmware.pdp -------------------------------------------------------------------------------- /src/Storage/CRC16.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CRC16.h 3 | * 4 | * Created on: 4 Dec 2020 5 | * Author: David 6 | * 7 | * This calculates CRC16 CCIT with initial CRC value Zero. 8 | */ 9 | 10 | #ifndef SRC_STORAGE_CRC16_H_ 11 | #define SRC_STORAGE_CRC16_H_ 12 | 13 | #include 14 | 15 | class CRC16 16 | { 17 | public: 18 | CRC16() noexcept; 19 | 20 | void Reset(uint16_t initialValue) noexcept; 21 | uint16_t Get() const noexcept; 22 | 23 | void Update(uint8_t c) noexcept { UpdateNormal(c, crc16_xmodem_table); } 24 | void Update(const uint8_t *_ecv_array c, size_t len) noexcept pre(c.lim >= len) { UpdateNormal(c, len, crc16_xmodem_table); } 25 | 26 | #if SUPPORT_MODBUS_RTU 27 | void UpdateModbus(uint8_t c) noexcept pre(table.lim == 256) { UpdateReflected(c, crc16_modbus_table); } 28 | void UpdateModbus(const uint8_t *c, size_t len) noexcept pre(c.lim >= len) { UpdateReflected(c, len, crc16_modbus_table); } 29 | #endif 30 | 31 | private: 32 | void UpdateNormal(uint8_t c, const uint16_t *_ecv_array table) noexcept pre(table.lim == 256); 33 | void UpdateNormal(const uint8_t *_ecv_array c, size_t len, const uint16_t *_ecv_array table) noexcept pre(c.lim >= len; table.lim == 256); 34 | void UpdateReflected(uint8_t c, const uint16_t *_ecv_array table) noexcept pre(table.lim == 256); 35 | void UpdateReflected(const uint8_t *_ecv_array c, size_t len, const uint16_t *_ecv_array table) noexcept pre(c.lim >= len; table.lim == 256); 36 | 37 | static const uint16_t crc16_xmodem_table[]; 38 | 39 | #if SUPPORT_MODBUS_RTU 40 | static const uint16_t crc16_modbus_table[]; 41 | #endif 42 | 43 | uint16_t crc; 44 | }; 45 | 46 | inline CRC16::CRC16() noexcept 47 | { 48 | Reset(0); 49 | } 50 | 51 | inline uint16_t CRC16::Get() const noexcept 52 | { 53 | return crc; 54 | } 55 | 56 | inline void CRC16::Reset(uint16_t initialValue) noexcept 57 | { 58 | crc = initialValue; 59 | } 60 | 61 | #endif /* SRC_STORAGE_CRC16_H_ */ 62 | -------------------------------------------------------------------------------- /src/Storage/CRC32.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC32_H 2 | #define CRC32_H 3 | 4 | #include 5 | 6 | #if SAME5x 7 | # define USE_SAME5x_HARDWARE_CRC 1 8 | #else 9 | # define USE_SAME5x_HARDWARE_CRC 0 10 | #endif 11 | 12 | // Note: when USE_SAME5x_HARDWARE_CRC is true, the Update methods must not be called from an ISR! 13 | class CRC32 14 | { 15 | private: 16 | uint32_t crc; 17 | 18 | public: 19 | CRC32() noexcept; 20 | 21 | void Update(char c) noexcept; 22 | void Update(const char *_ecv_array s, size_t len) noexcept pre(s.lim >= len) 23 | __attribute__((optimize("no-unroll-loops"))); // we already optimised the loops, and on the SAME5x unrolling them could make us feed data to the CRC unit too fast 24 | void Reset(uint32_t initialValue = 0xFFFFFFFFu) noexcept; 25 | uint32_t Get() const noexcept; 26 | 27 | #if USE_SAME5x_HARDWARE_CRC 28 | // Special function used to CRC a whole number of 32-bit words aligned on a word boundary, used to check for memory corruption 29 | static uint32_t CalcCRC32(const uint32_t *_ecv_array data, const uint32_t *_ecv_array end) noexcept; 30 | __attribute__((optimize("no-unroll-loops"))); // we already optimised the loops, and on the SAME5x unrolling them could make us feed data to the CRC unit too fast 31 | #endif 32 | }; 33 | 34 | inline uint32_t CRC32::Get() const noexcept 35 | { 36 | return ~crc; 37 | } 38 | 39 | inline void CRC32::Reset(uint32_t initialValue) noexcept 40 | { 41 | crc = initialValue; 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/Tools/Spindle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Spindle.h 3 | * 4 | * Created on: Mar 21, 2018 5 | * Author: Christian 6 | */ 7 | 8 | #ifndef SPINDLE_H 9 | #define SPINDLE_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | NamedEnum(SpindleState, uint8_t, unconfigured, stopped, forward, reverse); 17 | NamedEnum(SpindleType, uint8_t, enaDir, fwdRev); 18 | 19 | const SpindleType DefaultSpindleType(SpindleType::enaDir); 20 | 21 | class Spindle INHERIT_OBJECT_MODEL 22 | { 23 | private: 24 | void SetRpm(uint32_t rpm) noexcept; 25 | PwmPort pwmPort, onOffPort, reverseNotForwardPort; 26 | float minPwm, maxPwm, idlePwm; 27 | uint32_t currentRpm, configuredRpm, minRpm, maxRpm; 28 | PwmFrequency frequency; 29 | SpindleType type; 30 | SpindleState state; 31 | 32 | protected: 33 | DECLARE_OBJECT_MODEL 34 | 35 | public: 36 | Spindle() noexcept; 37 | 38 | GCodeResult Configure(uint32_t spindleNumber, GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); 39 | 40 | uint32_t GetCurrentRpm() const noexcept { return currentRpm; } 41 | uint32_t GetMinRpm() const noexcept { return minRpm; } 42 | uint32_t GetMaxRpm() const noexcept { return maxRpm; } 43 | uint32_t GetRpm() const noexcept { return configuredRpm; } 44 | bool IsValidRpm(uint32_t rpm) const noexcept { return rpm >= minRpm && rpm <= maxRpm; } 45 | void SetConfiguredRpm(uint32_t rpm, bool updateCurrentRpm) noexcept; 46 | SpindleType GetType() const noexcept { return type; } 47 | SpindleState GetState() const noexcept { return state; } 48 | void SetState(SpindleState newState) noexcept; 49 | bool IsConfigured() const noexcept { return state != SpindleState::unconfigured; } 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/Version.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Version.cpp 3 | * 4 | * Created on: 12 Aug 2022 5 | * Author: David 6 | */ 7 | 8 | #include "Version.h" 9 | #include 10 | 11 | const char *_ecv_array const DateText = IsoDate; 12 | const char *_ecv_array const TimeSuffix = " " __TIME__; 13 | 14 | // End 15 | -------------------------------------------------------------------------------- /src/Version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Version.h 3 | * 4 | * Created on: 25 Dec 2016 5 | * Author: David 6 | */ 7 | 8 | #ifndef SRC_VERSION_H_ 9 | #define SRC_VERSION_H_ 10 | 11 | #include 12 | 13 | #ifndef VERSION 14 | // Note: the complete VERSION string must be in standard version number format and must not contain spaces! This is so that DWC can parse it. 15 | # define MAIN_VERSION "3.6.0" 16 | # ifdef USE_CAN0 17 | # define VERSION_SUFFIX "(CAN0)" 18 | # elif defined(SUPPORT_S_CURVE) && SUPPORT_S_CURVE 19 | # define VERSION_SUFFIX "(S-curve)" 20 | # else 21 | # define VERSION_SUFFIX "" 22 | # endif 23 | # define VERSION MAIN_VERSION VERSION_SUFFIX 24 | #endif 25 | 26 | extern const char *_ecv_array const DateText; 27 | extern const char *_ecv_array const TimeSuffix; 28 | 29 | #endif /* SRC_VERSION_H_ */ 30 | -------------------------------------------------------------------------------- /src/bossa/WordCopyArm.asm: -------------------------------------------------------------------------------- 1 | .global start 2 | .global stack 3 | .global reset 4 | .global dst_addr 5 | .global src_addr 6 | .global words 7 | 8 | .text 9 | .thumb 10 | .align 0 11 | 12 | start: 13 | ldr r0, dst_addr 14 | ldr r1, src_addr 15 | ldr r2, words 16 | b check 17 | 18 | copy: 19 | ldmia r1!, {r3} 20 | stmia r0!, {r3} 21 | sub r2, #1 22 | 23 | check: 24 | cmp r2, #0 25 | bne copy 26 | 27 | @ Fix for SAM-BA stack bug 28 | ldr r0, reset 29 | cmp r0, #0 30 | bne return 31 | ldr r0, stack 32 | mov sp, r0 33 | 34 | return: 35 | bx lr 36 | 37 | .align 0 38 | stack: 39 | .word 0 40 | reset: 41 | .word 0 42 | dst_addr: 43 | .word 0 44 | src_addr: 45 | .word 0 46 | words: 47 | .word 0 48 | -------------------------------------------------------------------------------- /src/bossa/WordCopyArm.cpp: -------------------------------------------------------------------------------- 1 | // WARNING!!! DO NOT EDIT - FILE GENERATED BY APPLETGEN 2 | #include "WordCopyArm.h" 3 | #include "WordCopyApplet.h" 4 | 5 | const WordCopyArm WordCopyApplet::applet = 6 | { 7 | // dst_addr 8 | 0x00000028, 9 | // reset 10 | 0x00000024, 11 | // src_addr 12 | 0x0000002c, 13 | // stack 14 | 0x00000020, 15 | // start 16 | 0x00000000, 17 | // words 18 | 0x00000030, 19 | // code 20 | { 21 | 0x09, 0x48, 0x0a, 0x49, 0x0a, 0x4a, 0x02, 0xe0, 0x08, 0xc9, 0x08, 0xc0, 0x01, 0x3a, 0x00, 0x2a, 22 | 0xfa, 0xd1, 0x04, 0x48, 0x00, 0x28, 0x01, 0xd1, 0x01, 0x48, 0x85, 0x46, 0x70, 0x47, 0xc0, 0x46, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 25 | } 26 | }; 27 | 28 | // End 29 | 30 | -------------------------------------------------------------------------------- /src/bossa/WordCopyArm.h: -------------------------------------------------------------------------------- 1 | // WARNING!!! DO NOT EDIT - FILE GENERATED BY APPLETGEN 2 | #ifndef _WORDCOPYARM_H 3 | #define _WORDCOPYARM_H 4 | 5 | #include 6 | 7 | typedef struct 8 | { 9 | uint32_t dst_addr; 10 | uint32_t reset; 11 | uint32_t src_addr; 12 | uint32_t stack; 13 | uint32_t start; 14 | uint32_t words; 15 | uint8_t code[52]; 16 | } WordCopyArm; 17 | 18 | #endif // _WORDCOPYARM_H 19 | -------------------------------------------------------------------------------- /src/libc/atoi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * atoi.cpp 3 | * 4 | * Created on: 8 Jan 2023 5 | * Author: David 6 | * 7 | * This replaces the atoi function newlib. We redefine it to avoid calling strtol, which needs a reent_struct. 8 | * atoi is called by lwip. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #undef atoi // SafeStrtod.h defines this as a macro to tell you not to use it 15 | extern "C" int atoi(const char *s) noexcept 16 | { 17 | return (int)StrToI32(s,nullptr); 18 | } 19 | 20 | // End 21 | -------------------------------------------------------------------------------- /src/libc/eCvInclude/malloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * malloc.h 3 | * 4 | * Created on: 17 Dec 2024 5 | * Author: David 6 | * 7 | * This is a stub version of gcc's malloc.h file. 8 | * When running eCv we can't include the original one form the gcc compiler installation because it relies on too many gcc-specific defines. 9 | * Therefore add folder that contains this header file to the eCv include path. 10 | */ 11 | 12 | #ifndef SRC_LIBC_ECVINCLUDE_MALLOC_H_ 13 | #define SRC_LIBC_ECVINCLUDE_MALLOC_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #include 20 | 21 | /* This version of struct mallinfo must match the one in libc/stdlib/mallocr.c. */ 22 | 23 | struct mallinfo { 24 | size_t arena; /* total space allocated from system */ 25 | size_t ordblks; /* number of non-inuse chunks */ 26 | size_t smblks; /* unused -- always zero */ 27 | size_t hblks; /* number of mmapped regions */ 28 | size_t hblkhd; /* total space in mmapped regions */ 29 | size_t usmblks; /* unused -- always zero */ 30 | size_t fsmblks; /* unused -- always zero */ 31 | size_t uordblks; /* total allocated space */ 32 | size_t fordblks; /* total non-inuse space */ 33 | size_t keepcost; /* top-most, releasable (via malloc_trim) space */ 34 | }; 35 | 36 | extern struct mallinfo mallinfo (void); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* SRC_LIBC_ECVINCLUDE_MALLOC_H_ */ 43 | -------------------------------------------------------------------------------- /src/libc/errno.c: -------------------------------------------------------------------------------- 1 | /* 2 | * errno.c 3 | * 4 | * Created on: 1 Oct 2022 5 | * Author: David 6 | * 7 | * This file replaces the one in newlib in order to avoid pulling the reent struct 8 | */ 9 | 10 | static int globalErrno = 0; 11 | 12 | int * __errno () noexcept 13 | { 14 | return &globalErrno; 15 | } 16 | 17 | // End 18 | -------------------------------------------------------------------------------- /src/libc/local.h: -------------------------------------------------------------------------------- 1 | /* 2 | Taken from glibc: 3 | Add the compiler optimization to inhibit loop transformation to library 4 | calls. This is used to avoid recursive calls in memset and memmove 5 | default implementations. 6 | */ 7 | 8 | #ifdef _HAVE_CC_INHIBIT_LOOP_TO_LIBCALL 9 | # define __inhibit_loop_to_libcall \ 10 | __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) 11 | #else 12 | # define __inhibit_loop_to_libcall 13 | #endif 14 | -------------------------------------------------------------------------------- /src/libc/readme-libc.txt: -------------------------------------------------------------------------------- 1 | README file for libc folder 2 | =========================== 3 | 4 | On ARM Cortex M7 processors, accesses to strongly-ordered memory such as our "nocache" RAM segment must be aligned. Therefore we compile with option -fno-unaligned-access. 5 | Unfortunately, newlib (the standard C library) isn't compiled with -fno-unaligned-access, and memcpy in particular sometimes does unaligned accesses. 6 | To fix this, we include our own copy of memcpy here. Similarly for other memory-related functions that might be used to access DMA buffers. 7 | 8 | strptime.cpp in this folder is a cut-down version that doesn't need a locale, saving about 360 bytes of RAM. This is sufficient for RepRapFirmware because we don't 9 | need to recognise month or day names. 10 | 11 | DC 2020-01-10 12 | -------------------------------------------------------------------------------- /src/libcpp/readme-libcpp.txt: -------------------------------------------------------------------------------- 1 | README file for libcpp folder 2 | ============================= 3 | 4 | The folder contains files from GNU libsupc++. THEY MUST BE KEP UP-TO-DATE WITH THE ONES IN THE libsupc++ LIBRARY!!! 5 | 6 | File eh-alloc.cc is a modified version of the original GNU one which doesn't maintain an emergency buffer tool for 7 | allocating exception objects if allocation using malloc() mfails. This saves more than 2K dynamic RAM. 8 | 9 | File unwind-cxx.h is an include file needed by eh_alloc.cpp, unmodified from the original. 10 | 11 | File vterminate.cc is a replacement for the original. The original attempts to print information about the terminating exception, 12 | which pulls in fputs(), which we don't have/don't want. 13 | 14 | DC 2020-01-10, updated 2023-03-31 15 | -------------------------------------------------------------------------------- /src/libcpp/vterminate.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * vterminate.cc 3 | * 4 | * Created on: 22 Jan 2020 5 | * Author: David 6 | */ 7 | 8 | #include 9 | 10 | namespace __gnu_cxx 11 | { 12 | // A replacement for the standard terminate_handler which prints 13 | // more information about the terminating exception (if any) on 14 | // stderr. 15 | void __verbose_terminate_handler() 16 | { 17 | abort(); 18 | } 19 | } 20 | 21 | // End 22 | --------------------------------------------------------------------------------