Browse Source

Squashed commit of the following:

commit 4b9fce2e85
Merge: ecb08b15be e17d710c5c
Author: Sergey <sergey@terentiev.me>
Date:   Mon Dec 27 16:47:22 2021 +0300

    Merge branch '2.0.x' into vanilla_fb_2.0.x

commit e17d710c5c
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Sat Dec 25 22:13:20 2021 -0600

    ๐Ÿ”– Marlin 2.0.9.3

commit 9b13ae2399
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Sat Dec 25 19:41:01 2021 -0800

    ๐Ÿ› Fix MKS Robin E3 NeoPixel pin default (#23350)

commit 06f36dc746
Author: kaidegit <60053077+kaidegit@users.noreply.github.com>
Date:   Sun Dec 26 10:12:20 2021 +0800

    ๐Ÿ› Fix open for bin rename (#23351)

commit 98eca9cb23
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Sat Dec 25 03:27:45 2021 -0600

    ๐Ÿ”ง Move MOTHERBOARD closer to top

commit 6268795003
Author: fflosi <34758322+fflosi@users.noreply.github.com>
Date:   Sat Dec 25 05:57:07 2021 -0300

    โœจ Per-axis TMC hold multiplier (#23345)

commit b4f0922a7c
Author: Sola <42537573+solawc@users.noreply.github.com>
Date:   Fri Dec 24 14:03:32 2021 +0800

    โœจ MKS TinyBee board support (#23340)

    Co-Authored-By: Sola <42537573+solawc@users.noreply.github.com>

commit aef613acd3
Author: Robby Candra <robbycandra.mail@gmail.com>
Date:   Thu Dec 23 15:19:39 2021 +0700

    ๐Ÿ”ง Group FAST_PWM_FAN.options (#23331)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit 9ecfa1d252
Author: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com>
Date:   Tue Dec 21 23:09:55 2021 -0500

    โœจ BLTouch High Speed mode runtime configuration (#22916, #23337)

    Co-Authored-By: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit e0bed1e344
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Wed Dec 22 15:44:04 2021 +1300

    โœจ Option to reset EEPROM on first run (#23276)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit d21fa25ab8
Author: Spencer Owen <owenspencer@gmail.com>
Date:   Sat Dec 18 18:58:46 2021 -0700

    โœจ Creality3D V4.2.3 / Ender-2 Pro board (#23307)

commit 0dc1a58b24
Author: X-Ryl669 <boite.pour.spam@gmail.com>
Date:   Tue Dec 14 07:22:06 2021 +0100

    โœจ Configurations embed and retrieve (#21321, #23303)

commit f2ca70e232
Author: John Lagonikas <39417467+zeleps@users.noreply.github.com>
Date:   Wed Dec 8 20:55:09 2021 +0200

    ๐Ÿ› Fix and improve MAX31865 (#23215)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit a6bed22839
Author: BigTreeTech <38851044+bigtreetech@users.noreply.github.com>
Date:   Sat Dec 11 03:38:03 2021 +0800

    โœจ BigTreeTech SKR mini E3 V3.0 (STM32G0B1RET6) (#23283)

commit efd67cf80d
Author: Giuseppe499 <giuseppe499@live.it>
Date:   Tue Dec 7 02:53:51 2021 +0100

    โœจ X Twist Compensation & Calibration (#23238)

commit 15204470a8
Author: ladismrkolj <ladismrkolj@gmail.com>
Date:   Sun Dec 5 22:41:39 2021 +0100

    ๐Ÿ”ง Chamber Fan index option (#23262)

commit 48358d6a5c
Author: Mike La Spina <mike.laspina@shaw.ca>
Date:   Fri Dec 3 12:48:48 2021 -0600

    ๐Ÿ—๏ธ Fix Maple HAL/STM32F1 PWM (#23211)

commit d7abb891cd
Author: Tanguy Pruvot <tpruvot@users.noreply.github.com>
Date:   Fri Dec 3 19:31:48 2021 +0100

    ๐Ÿ—๏ธ Rework STM32 timer frequency protection (#23187)

commit 52a44eb200
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Tue Nov 30 15:04:05 2021 -0600

    ๐Ÿ› Fix STM32 FastPWM

commit 9b1c0a75e1
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Nov 27 18:33:32 2021 -0600

    ๐ŸŽจ Rename HAL timer elements

commit d75e7784e5
Author: schmttc <89831403+schmttc@users.noreply.github.com>
Date:   Wed Nov 24 08:52:18 2021 +1100

    โœจ EasyThreeD ET4000+ board and UI (#23080)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit 0e60c8b7e0
Author: John Robertson <john@cirtech.co.uk>
Date:   Tue Nov 23 21:24:24 2021 +0000

    โœจ MarkForged YX kinematics (#23163)

commit 018c7b1cf4
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Sun Nov 21 11:25:06 2021 -0800

    โœจ BigTreeTech Mini 12864 V1.0 (#23130)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit af1d603374
Author: Giuliano Zaro <3684609+GMagician@users.noreply.github.com>
Date:   Tue Nov 23 21:01:53 2021 +0100

    โœจ Fan tachometer support (#23086, #23180, #23199)

    Co-Authored-By: Scott Lahteine <github@thinkyhead.com>

commit 884308f964
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Tue Nov 16 08:54:30 2021 -0600

    ๐Ÿ”ง SOUND_MENU_ITEM for E3V2

commit 7269990413
Author: Miguel Risco-Castillo <mriscoc@users.noreply.github.com>
Date:   Wed Nov 10 11:31:35 2021 -0500

    ๐Ÿšธ Expose sub-options for E3V2 Enhanced (#23099)

commit 2a90d93b17
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Wed Nov 17 09:33:42 2021 -0800

    ๐Ÿ“Œ Overridable probe-related pins (#23107)

commit 6e284f8823
Author: BigTreeTech <38851044+bigtreetech@users.noreply.github.com>
Date:   Wed Nov 10 23:56:10 2021 +0800

    โœจ Support for BIQU B1-SE-Plus strain gauge probe (#23101)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit a2349fc411
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Fri Dec 24 23:47:52 2021 -0600

    ๐Ÿ”จ Configurable firmware bin filename

    Configuration.h > FIRMWARE_BIN

commit a3964b2b40
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Fri Dec 24 20:59:28 2021 -0600

    ๐Ÿ”จ Ignore more generated files

commit 226ee7c1f3
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Fri Dec 24 01:46:51 2021 -0600

    ๐Ÿ”ง Sanity check MMU2_MENUS

commit 2c12171f46
Author: Attila BODY <attila.body@gmail.com>
Date:   Fri Dec 24 06:57:20 2021 +0100

    ๐Ÿ› Fix Robin Nano v3 filament runout pins (#23344)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit d034a9c295
Author: MrAlvin <umo-testing@3iii.dk>
Date:   Thu Dec 23 10:47:52 2021 +0100

    ๐Ÿšธ Show mm'ss during first hour (#23335)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit d2c7104bb3
Author: Robby Candra <robbycandra.mail@gmail.com>
Date:   Wed Dec 15 07:51:19 2021 +0700

    ๐Ÿšธ Change "SD" to "Media" or "SD/FD" (#23297)

commit 570c7e8638
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Wed Dec 22 13:48:38 2021 +1300

    ๐Ÿ› Fix Chitu Z_STOP_PIN (#23330)

commit cc4578a3d3
Author: Tanguy Pruvot <tpruvot@users.noreply.github.com>
Date:   Thu Dec 23 07:49:15 2021 +0100

    ๐Ÿฉน Fix settings G21 report (#23338)

commit 1db84be66a
Author: Mike La Spina <mike.laspina@shaw.ca>
Date:   Tue Dec 21 01:26:31 2021 -0600

    ๐Ÿš‘๏ธ FAST_PWM_FAN default 1KHz base freq. (#23326)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit 77c9668fe2
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Tue Dec 14 19:25:28 2021 +1300

    ๐Ÿ› Fix LCD_BED_LEVELING compile (#23298)

commit 22cf9b444e
Author: GHGiampy <83699429+GHGiampy@users.noreply.github.com>
Date:   Mon Dec 20 09:44:43 2021 +0100

    ๐Ÿง‘โ€๐Ÿ’ป Option allowing > 127 Neopixels (#23322)

commit 97798d1e47
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Thu Jul 8 01:33:49 2021 -0500

    ๐ŸŽจ Update SKR V2 pins

commit f4b808456a
Author: Giuliano Zaro <3684609+GMagician@users.noreply.github.com>
Date:   Tue Dec 14 01:47:57 2021 +0100

    ๐Ÿšธ Use M600 for disabled MMU (#21865)

commit 6264736968
Author: Tanguy Pruvot <tpruvot@users.noreply.github.com>
Date:   Tue Dec 14 01:41:21 2021 +0100

    ๐Ÿ› Fix TFT_COLOR_UI Release Media issue (#23123)

commit 7a5f103bcf
Author: John Lagonikas <39417467+zeleps@users.noreply.github.com>
Date:   Sat Dec 18 01:31:10 2021 +0200

    ๐Ÿ”ง Warning for IGNORE_THERMOCOUPLE_ERRORS (#23312)

commit 1a8307b196
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Sat Dec 18 17:38:29 2021 -0600

    ๐Ÿ“ Fix a config comment

commit 13a1c86ae8
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Tue Dec 14 13:18:24 2021 +1300

    โœจ M115 flag EXTENDED_M20 (#22941)

commit 15656201d2
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Tue Dec 14 13:13:34 2021 +1300

    โœ๏ธ Clean up duplicate defs (#23182)

commit f3e372cb4c
Author: Robby Candra <robbycandra.mail@gmail.com>
Date:   Tue Dec 14 07:11:52 2021 +0700

    ๐Ÿฉน Init fan speed at boot (#23181)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit c781ecc437
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Mon Dec 13 16:15:46 2021 -0600

    ๐Ÿ”ง Fix unknown board test

commit daa8fff6c6
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Sun Dec 12 16:16:40 2021 -0600

    ๐Ÿฉน SD abort requires open file

    See #22566

commit d481bba327
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Sun Dec 12 11:06:45 2021 +1300

    ๐Ÿ› Fix MARLIN_F103Rx variant SCK / MOSI pins (#23282)

commit 32b08ae04c
Author: Scott Alfter <scott@alfter.us>
Date:   Wed Dec 8 23:18:04 2021 -0800

    Fix Endstops::report_states (#23280)

    Fix regression 4d45fdf0eb

commit f00a0356c7
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Wed Dec 8 18:36:08 2021 -0600

    ๐ŸŽจ Misc. probe / endstop cleanup

commit 9871800874
Author: Sola <42537573+solawc@users.noreply.github.com>
Date:   Thu Dec 9 03:37:45 2021 +0800

    ๐Ÿ› Fix MKS LVGL UI retraction (#23267)

commit 39c2c038be
Author: Robby Candra <robbycandra.mail@gmail.com>
Date:   Thu Dec 9 02:15:31 2021 +0700

    ๐Ÿฉน Coerce pin_t in set_pwm_duty macros (#23273)

commit 285d6488a3
Author: Jason Smith <jason.inet@gmail.com>
Date:   Wed Dec 8 11:10:37 2021 -0800

    ๐Ÿ› Fix ACTION_ITEM with nullptr (#23195)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit eecbd09a46
Author: Robby Candra <robbycandra.mail@gmail.com>
Date:   Thu Dec 9 01:57:50 2021 +0700

    ๐Ÿšธ Onboard SD for SKR 2.0 / SKR PRO (#23274)

commit 8d4e4ac115
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Wed Dec 8 12:40:23 2021 -0600

    ๐ŸŽจ Rename MAX31865 elements

commit b77a5d4c8d
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Mon Dec 6 20:18:50 2021 -0600

    โœ๏ธ MAX31856 => MAX31865

commit c3b8b3e7e6
Author: Mike La Spina <mike.laspina@shaw.ca>
Date:   Mon Dec 6 15:52:18 2021 -0600

    ๐Ÿฉน Fix non-PWM cutter compile (#23169)

commit 7123b15801
Author: Stuart Pittaway <1201909+stuartpittaway@users.noreply.github.com>
Date:   Mon Dec 6 21:40:18 2021 +0000

    ๐Ÿ› Fix TWIBus Wire.begin call (#23183)

commit 8a2f13d657
Author: Chris Pepper <p3p@p3psoft.co.uk>
Date:   Sun Dec 5 22:18:02 2021 +0000

    ๐Ÿ› HAL_reboot for native HAL (#23246)

commit 251d9fc1d7
Author: tommywienert <53783769+tommywienert@users.noreply.github.com>
Date:   Sun Dec 5 23:16:23 2021 +0100

    ๐Ÿ› Fix env:chitu_f103 (#23225)

commit 5eeb9650b5
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Mon Dec 6 10:42:56 2021 +1300

    ๐Ÿ“Œ More Longer3D LKx Pro serial tests  (#23260)

commit c0addd1d33
Author: Stuart Pittaway <1201909+stuartpittaway@users.noreply.github.com>
Date:   Sat Dec 4 23:44:10 2021 +0000

    โœจ M3426 to read i2c MCP3426 ADC (#23184)

commit 05b57278d4
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Dec 4 17:17:10 2021 -0600

    ๐Ÿ”ง Cutter pins for SKR 2.0

commit aa3ec2fbfd
Author: Robby Candra <robbycandra.mail@gmail.com>
Date:   Sun Dec 5 05:14:19 2021 +0700

    ๐Ÿšธ Park nozzle on "loud kill" (#23172)

commit 4468516aa2
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Sun Dec 5 11:10:29 2021 +1300

    โœจ BigTree SKR 2 with F429 (#23177)

commit 95d006b406
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Sat Dec 4 09:48:54 2021 +1300

    ๐Ÿ› Fix TIMER_TONE for ZM3E4 (#23212)

commit 5b057b4bcf
Author: Jiri Jirus <jiri.jirus@cloudaper.com>
Date:   Tue Nov 30 21:46:48 2021 +0100

    ๐Ÿฉน Assume 4K EEPROM for RUMBA32 BTT (#23205)

commit 77af48e547
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Tue Nov 30 13:03:31 2021 -0600

    ๐Ÿ› Fix STM32 FastPWM

commit 0f7f709aad
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Sat Nov 27 14:59:32 2021 -0800

    โœ๏ธ Fix Unicode (#23186)

commit a8c0e11cb1
Author: Jason Smith <jason.inet@gmail.com>
Date:   Sat Nov 27 13:54:39 2021 -0800

    ๐Ÿฉน Handle nullptr in CardReader::printLongPath (#23197)

commit 0556da85b0
Author: Anson Liu <ansonl@users.noreply.github.com>
Date:   Sat Nov 27 17:58:05 2021 -0500

    ๐Ÿฉน UM2 extruder cooling fan on PJ6 (#23194)

commit 93652e5c6f
Author: George Fu <nailao_5918@163.com>
Date:   Sun Nov 28 03:26:53 2021 +0800

    โœจ  FYSETC Spider v2.2 (#23208)

commit f3fc1d15a3
Author: Giuliano Zaro <3684609+GMagician@users.noreply.github.com>
Date:   Tue Nov 23 22:33:33 2021 +0100

    ๐Ÿฉน Fix include path (#23150)

commit 3148060550
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Tue Nov 23 13:54:31 2021 -0800

    ๐Ÿ“Œ Biqu BX temporary framework workaround (#23131)

commit 5f08864d1f
Author: Mike La Spina <mike.laspina@shaw.ca>
Date:   Tue Nov 23 14:05:50 2021 -0600

    ๐Ÿ› Fix STM32 set_pwm_duty (#23125)

commit 184fc36a08
Author: Tanguy Pruvot <tpruvot@users.noreply.github.com>
Date:   Sun Nov 21 20:13:01 2021 +0100

    ๐Ÿ› Fix TFT backlight sleep/wake (#23153)

commit 281ed99868
Author: Tanguy Pruvot <tpruvot@users.noreply.github.com>
Date:   Sat Nov 20 02:44:53 2021 +0100

    โšก๏ธ Reduce calls to set fan PWM (#23149)

commit 2cc4a1b326
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Wed Nov 17 13:01:44 2021 -0600

    ๐ŸŽจ Misc formatting

commit c5bd08755c
Author: BigTreeTech <38851044+bigtreetech@users.noreply.github.com>
Date:   Thu Nov 18 01:35:28 2021 +0800

    ๐Ÿ› Init PROBE_ENABLE_PIN (#23133)

commit 99f58f63f2
Author: luzpaz <luzpaz@users.noreply.github.com>
Date:   Wed Nov 17 12:09:01 2021 -0500

    ๐ŸŽจ Fix misspelling (#23137)

commit c2a674d2c1
Author: espr14 <espr14@gmail.com>
Date:   Wed Nov 17 18:07:11 2021 +0100

    ๐Ÿ—๏ธ Planner::busy() (#23145)

commit feffc19867
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Tue Nov 16 14:06:36 2021 -0600

    ๐Ÿ› Fix fast PWM WGM code

    Followup to #23102

commit f637e1c501
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Tue Nov 16 12:49:25 2021 -0600

    ๐Ÿ”จ Bring Makefile up to date

commit 78240a279b
Author: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com>
Date:   Tue Nov 16 19:32:43 2021 +0300

    ๐Ÿ”จ Ignore sim flashdrive file (#23129)

commit 656034d2d9
Author: Luc Van Daele <lvd@sound-silence.com>
Date:   Tue Nov 16 16:24:53 2021 +0100

    ๐Ÿ› Fix G33, Delta radii, reachable (#22795)

commit 39a81d167e
Author: Mikhail Basov <github@basov.net>
Date:   Mon Nov 15 07:46:34 2021 +0300

    ๐Ÿšธ LCD_SHOW_E_TOTAL for TFT_COLOR_UI (#23127)

commit cb1570d162
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sun Nov 14 17:19:57 2021 -0600

    ๐Ÿ› Fix SENSORLESS_HOMING for 6-axis

commit 8cb646cc20
Author: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com>
Date:   Mon Nov 15 00:15:07 2021 +0300

    ๐Ÿšธ Simplify touchscreen calibration for SimUI (#23124)

commit 3cccb21dc9
Author: Miguel Risco-Castillo <mriscoc@users.noreply.github.com>
Date:   Wed Nov 10 11:55:20 2021 -0500

    ๐Ÿšธ Fix up E3V2 Enhanced (#23100)

commit 7f4a49cc44
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Fri Oct 22 13:21:26 2021 -0500

    ๐ŸŽจ Misc. issue review patches

commit e0c439fe91
Author: Mike La Spina <mike.laspina@shaw.ca>
Date:   Sun Nov 14 05:55:31 2021 -0600

    โšก๏ธ Controller Fan software PWM (etc.) (#23102)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit 49e233e06f
Author: Tanguy Pruvot <tpruvot@users.noreply.github.com>
Date:   Fri Nov 12 21:26:19 2021 +0100

    ๐ŸŽจ MPX ARM Mini pins cleanup (#23113)

commit b662dd1f92
Author: Mike La Spina <mike.laspina@shaw.ca>
Date:   Fri Nov 12 12:14:28 2021 -0600

    ๐Ÿ› [LCP1768] Init PWM in set_pwm_duty (#23110)

commit 700cae43ab
Author: Skruppy <skruppy@onmars.eu>
Date:   Fri Nov 12 15:57:24 2021 +0100

    ๐Ÿฉน Fix RGB case light compile (#23108)

commit 1c74c6e7ac
Author: George Fu <nailao_5918@163.com>
Date:   Wed Nov 10 23:58:20 2021 +0800

    ๐Ÿ› Fix FYSETC Cheetah 2.0 pins for production (#23104)

commit 757a9477db
Author: Minims <github@minims.fr>
Date:   Sun Oct 10 01:10:21 2021 +0200

    ๐Ÿฉน Adjust GTR 1.0 ST7920 display delay (#22904)

commit 59d43408f6
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Sat Dec 25 00:57:30 2021 -0600

    fix breaks in F() resolution

commit 1d8941d008
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Tue Oct 5 21:35:31 2021 -0500

    ๐Ÿ”จ Port libsdl2_net required for macOS simulator

commit 17f853d99c
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Tue Nov 9 08:30:02 2021 -0800

    โšก๏ธ BTT002 (STM32F407VET6) variant, MK3_FAN_PINS flag (#23093)

commit 6f9f25dbb2
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sun Nov 7 01:11:51 2021 -0600

    ๐ŸŽจ Misc. code cleanup

commit 0273a68587
Author: VragVideo <91742261+VragVideo@users.noreply.github.com>
Date:   Sun Oct 3 06:12:51 2021 +0300

    โœจ WYH L12864 LCD (Alfawise Ex8) (#22863)

commit 58a26fcaac
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Sat Nov 6 23:09:15 2021 -0700

    ๐Ÿšธ Indicate Preheating for probe / leveling (#23088)

commit 489aca03ff
Author: Evgeniy Zhabotinskiy <evg-zhabotinsky@users.noreply.github.com>
Date:   Sun Nov 7 07:16:18 2021 +0300

    ๐Ÿฉน Fix M503 report (#23084)

commit f32e19e1c6
Author: Jin <3448324+jinhong-@users.noreply.github.com>
Date:   Sun Nov 7 11:53:36 2021 +0800

    ๐Ÿป Preliminary fix for Max31865 SPI (#22682)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit 57bd04b6ce
Author: dwzg <50058606+dwzg@users.noreply.github.com>
Date:   Sun Nov 7 04:48:00 2021 +0100

    ๐Ÿ› Fix JyersUI scrolling filename, etc. (#23082)

    Co-authored-by: Scott Lahteine <github@thinkyhead.com>

commit 396df93220
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Sun Nov 7 15:27:53 2021 +1300

    ๐Ÿ› Fix DGUS Reloaded status message (#23090)

commit 9b76b58b79
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Thu Nov 4 12:18:23 2021 -0500

    ๐Ÿป Get/clear reset source earlier

    Followup to #23075

commit 9fffed7160
Author: Skruppy <skruppy@onmars.eu>
Date:   Thu Nov 4 18:11:57 2021 +0100

    ๐Ÿ› Prevent AVR watchdogpile (#23075)

commit fd136d5501
Author: Tanguy Pruvot <tpruvot@users.noreply.github.com>
Date:   Thu Nov 4 18:04:04 2021 +0100

    ๐Ÿ› Fix TFT backlight [STM32] (#23062)

commit 89ec1c71f0
Author: BigTreeTech <38851044+bigtreetech@users.noreply.github.com>
Date:   Thu Nov 4 18:54:38 2021 +0800

    ๐Ÿ› Fix Octopus-Pro Max31865 / SPI (#23072)

commit fc2020c6ec
Author: Robby Candra <robbycandra.mail@gmail.com>
Date:   Thu Nov 4 17:28:42 2021 +0700

    ๐Ÿ”จ Fix IntelliSense / PIO conflicts (#23058)

    Co-authored-by: Scott Lahteine <github@thinkyhead.com>

commit f97635de36
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Thu Nov 4 14:04:06 2021 +1300

    ๐Ÿ“Œ 'STOP' auto-assign, some Chitu V9 pins (#22889)

    Co-authored-by: Scott Lahteine <github@thinkyhead.com>

commit a0a57406a2
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Wed Nov 3 07:06:31 2021 -0500

    ๐Ÿ”จ Script 'mfprep' finds pending commits

commit 5efef86cfa
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Wed Nov 3 07:02:21 2021 -0500

    ๐Ÿ”จ Update git helper scripts

commit 20c747753d
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Tue Nov 2 01:28:00 2021 -0500

    ๐Ÿ”จ Support ABM in mf scripts

commit 08a9c61587
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Mon Nov 1 23:15:29 2021 -0700

    ๐Ÿ“Œ Default NeoPixel pin for MKS Robin E3/E3D (#23060)

commit 0d91b07797
Author: Andrei M <22990561+andrei-moraru@users.noreply.github.com>
Date:   Tue Nov 2 01:47:16 2021 -0400

    โš—๏ธ Use pwm_set_duty over analogWrite to set PWM (#23048)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit b033da1782
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Mon Nov 1 22:43:40 2021 -0700

    ๐Ÿ”ง Endstop / DIAG homing conflict warning (#23050)

commit 4dcd872be5
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Mon Nov 1 21:23:54 2021 -0700

    โœจ Allow Low EJERK with LA, optional (#23054)

commit 7e9e2a7435
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Mon Nov 1 20:23:24 2021 -0700

    โœจ Artillery Ruby (STM32F401RCT6) (#23029)

commit 0b84194127
Author: tombrazier <68918209+tombrazier@users.noreply.github.com>
Date:   Mon Nov 1 23:03:50 2021 +0000

    ๐Ÿšธ More flexible Probe Temperature Compensation (#23033)

commit efd9329c81
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Thu Jul 8 01:17:16 2021 -0500

    ๐Ÿ“ Tweak EXP comments

commit 5cbb820e29
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Oct 30 23:43:19 2021 -0500

    ๐Ÿ”จ Help for GDB remote debugging

commit 5a0166489e
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Oct 30 22:43:02 2021 -0500

    ๐Ÿฉน Fix linker error (transfer_port_index)

commit 692c9a6312
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Oct 30 04:16:37 2021 -0500

    ๐Ÿ’š Update Ender-3 V2 config path

    MarlinFirmware/Configurations#600

commit 545d14f9a5
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Oct 30 01:39:33 2021 -0500

    ๐ŸŽจ Adjust Ender-3 V2 DWIN options

commit 7b9e01eb2b
Author: aalku <aalku7@gmail.com>
Date:   Sat Oct 30 07:17:20 2021 +0200

    โœจ Shutdown Host Action (#22908)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit 8562f0ec44
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Fri Oct 29 20:46:55 2021 -0500

    โœจ "Rutilea" ESP32 board (#22880)

commit 6f59d8171f
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Fri Oct 29 20:42:52 2021 -0500

    ๐Ÿ”ง Configuration version 02000903

commit d29a9014f2
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Wed Oct 27 21:36:06 2021 -0500

    ๐ŸŽจ Standard 'cooldown' method

commit 205d867e4b
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Wed Oct 27 20:01:44 2021 -0500

    ๐ŸŽจ Standard material presets behavior

commit 84f9490149
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Wed Oct 27 21:15:58 2021 -0500

    ๐ŸŽจ Define HAS_PREHEAT conditional

commit 1fd4258423
Author: tome9111991 <57866234+tome9111991@users.noreply.github.com>
Date:   Sat Oct 30 00:49:12 2021 +0200

    ๐Ÿ› Fix E3V2 (CrealityUI) Tune/Prepare > Zoffset (#23040)

commit e8a55972a7
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Thu Oct 28 19:22:35 2021 -0500

    ๐Ÿ› Fix EZBoard V2 board name

commit aef413202e
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Thu Oct 28 03:26:05 2021 -0700

    ๐Ÿ› Fix MKS Robin E3/E3D Z Stop/Probe pins (#23034)

commit cbc7dadf42
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Tue Oct 26 21:54:43 2021 -0500

    ๐ŸŽจ Apply HAS_MULTI_HOTEND conditional

commit c508ecc414
Author: Zlopi <zlopi.ru@gmail.com>
Date:   Wed Oct 27 23:10:46 2021 +0300

    ๐Ÿšธ Scroll long filename on MKS TFT (#23031)

commit 384a31765f
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Thu Oct 28 09:06:06 2021 +1300

    ๐Ÿฉน Retain LCD pins with motor expansion (#23024)

commit 0f2c4fc40b
Author: somehibs <hibs@circuitco.de>
Date:   Wed Oct 27 21:00:02 2021 +0100

    ๐Ÿ› Fix serial PORT_RESTORE (and BUFFER_MONITORING) (#23022)

commit 66a274452c
Author: tome9111991 <57866234+tome9111991@users.noreply.github.com>
Date:   Wed Oct 27 21:58:32 2021 +0200

    ๐Ÿ› Fix E3V2 (CrealityUI) position display (#23023)

    Followup to #23005, #22778

commit 12f8168d1e
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Tue Oct 26 19:36:16 2021 -0500

    ๐Ÿšธ Tweaks to UBL G29 Q

commit 2142e1dae4
Author: woisy00 <spam@bergermeier.info>
Date:   Wed Oct 27 01:05:34 2021 +0200

    ๐Ÿ› Fix AUTOTEMP bug (thermal runaway) (#23025)

    Regression from 9823a37

commit 8d21ea55a2
Author: tombrazier <68918209+tombrazier@users.noreply.github.com>
Date:   Mon Oct 25 06:33:40 2021 +0100

    ๐Ÿ› Add USE_TEMP_EXT_COMPENSATION options (#23007)

commit a0da7e8a1f
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Sun Oct 24 23:33:27 2021 -0500

    ๐Ÿ”ง Fewer alerts about Z_SAFE_HOMING

commit e2452d6c57
Author: tome9111991 <57866234+tome9111991@users.noreply.github.com>
Date:   Fri Oct 22 18:16:07 2021 +0200

    ๐Ÿ› Fix SHOW_REMAINING_TIME option for JyersUI (#22999)

commit 5173a3140d
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Fri Oct 22 08:52:31 2021 -0700

    โœจ BigTreeTech TFT35 SPI V1.0 (#22986)

commit e44f2b7d2d
Author: Mike La Spina <mike.laspina@shaw.ca>
Date:   Tue Oct 19 06:05:23 2021 -0500

    ๐Ÿฉน Fix pragma ignored for older GCC (#22978)

commit ed78f7f4e6
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Tue Oct 19 05:59:48 2021 -0500

    ๐ŸŽจ Refactor MOSFET pins layout (#22983)

commit aa198e41dd
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Tue Oct 19 05:52:41 2021 -0500

    ๐ŸŽจ Pragma GCC cleanup

commit 18b38fb58a
Author: Jason Smith <jason.inet@gmail.com>
Date:   Mon Oct 18 01:11:16 2021 -0700

    ๐Ÿ› Fix max chamber fan speed (#22977)

commit 5d79d8fad6
Author: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date:   Mon Oct 18 00:57:54 2021 -0700

    ๐Ÿ› Fix I2C EEPROM SDA/SCL aliases with SKR Mini E3 V2 (#22955)

commit e7a746966d
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Mon Oct 18 20:54:20 2021 +1300

    ๐Ÿ› Fix MMU1 compile (#22965)

commit 555f35d46f
Author: Mike La Spina <mike.laspina@shaw.ca>
Date:   Mon Oct 18 02:40:47 2021 -0500

    ๐ŸŽจ Suppress type warning (#22976)

commit de77dfcbbd
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sun Oct 17 22:10:08 2021 -0500

    ๐ŸŽจ Add MKS UI goto_previous_ui

commit af08f16efc
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sun Oct 17 20:24:41 2021 -0500

    ๐Ÿšธ Tweak MKS UI G-code console

commit 01a0f3a8cf
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sun Oct 17 18:11:16 2021 -0500

    ๐ŸŽจ Fix up MKS UI defines

commit f80bcdcc5c
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Fri Oct 15 00:24:08 2021 -0500

    ๐ŸŽจ Refactor Host Actions as singleton

commit 1ead7ce681
Author: ellensp <530024+ellensp@users.noreply.github.com>
Date:   Fri Oct 15 14:38:03 2021 +1300

    ๐Ÿ”ง Add, update TFT sanity checks (#22928)

commit dffa56463e
Author: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com>
Date:   Tue Oct 12 23:19:05 2021 -0400

    โšก๏ธ Formbot ST7920 delays, intentional X2 pins (#22915)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit ae98d2e5ea
Author: Dmytro <svetotled@gmail.com>
Date:   Wed Oct 13 05:45:00 2021 +0300

    ๐ŸŽจ Update MKS UI for no bed, extruder (#22938)

    Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>

commit 5b1ef638ee
Author: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com>
Date:   Tue Oct 12 19:40:56 2021 -0400

    ๐Ÿ› Fix IDEX + DISABLE_INACTIVE_EXTRUDER (#22925)

commit f3be03da20
Author: Stuart Pittaway <1201909+stuartpittaway@users.noreply.github.com>
Date:   Mon Oct 11 23:42:29 2021 +0100

    โœจ M261 S I2C output format (#22890)

    Co-authored-by: Scott Lahteine <github@thinkyhead.com>

commit 64128a5bcb
Author: Tanguy Pruvot <tpruvot@users.noreply.github.com>
Date:   Sun Oct 10 01:05:24 2021 +0200

    ๐Ÿ› Queue string followup (#22900)

commit 0018c94a79
Author: Pyro-Fox <36782094+Pyro-Fox@users.noreply.github.com>
Date:   Sat Oct 9 15:09:50 2021 -0700

    ๐Ÿ› LCD string followup (#22892)

commit d48cb11537
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Tue Oct 5 21:19:28 2021 -0500

    ๐Ÿ› Followup to F() in config_line

    Followup to 1dafd1887e

commit d9f7de7a24
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Mon Oct 4 19:50:14 2021 -0500

    ๐Ÿ› ExtUI F() followups

    Followup to 12b5d997a2

commit 3d102a77ca
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Tue Sep 28 20:15:52 2021 -0500

    ๐ŸŽจ Apply F() to kill / sendinfoscreen

commit 492d70424d
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Tue Sep 28 19:28:29 2021 -0500

    ๐ŸŽจ Apply F() to MKS UI errors, assets

commit 24dbeceb45
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Mon Sep 27 13:46:42 2021 -0500

    ๐ŸŽจ Apply F() to various reports

commit cabd538fdd
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Mon Sep 27 13:40:01 2021 -0500

    ๐ŸŽจ Apply F() to G-code report header

commit 9cf1c3cf05
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Sat Sep 25 23:52:41 2021 -0500

    ๐ŸŽจ Apply F() to UTF-8/MMU2 string put

commit c3ae221a10
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Sat Sep 25 22:11:48 2021 -0500

    ๐ŸŽจ Apply F() to some ExtUI functions

commit 7626d859a6
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Mon Sep 27 11:55:08 2021 -0500

    ๐ŸŽจ Apply F() to Host Actions strings

commit 360311f232
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Sep 25 17:05:11 2021 -0500

    ๐ŸŽจ Apply F() to status message

commit 433eedd50f
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Mon Sep 27 11:03:07 2021 -0500

    ๐ŸŽจ Apply F() to serial macros

commit 46c53f6730
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Sep 25 21:11:31 2021 -0500

    ๐ŸŽจ Apply F() to G-code suite and queue

commit 2b9ae0cc33
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Sep 25 18:43:52 2021 -0500

    ๐ŸŽจ Apply F() to G-code subcommands

commit 433a27e475
Author: Scott Lahteine <github@thinkyhead.com>
Date:   Sat Sep 25 18:22:37 2021 -0500

    ๐ŸŽจ Update F string declarations

commit 1de265ea5d
Author: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date:   Mon Oct 4 00:24:41 2021 -0500

    ๐ŸŽจ Axis name string interpolation, with examples (#22879)

commit ecb08b15be
Merge: 798d12c2af 854ce63358
Author: Sergey <sergey@terentiev.me>
Date:   Wed Dec 22 11:58:28 2021 +0300

    Merge branch '2.0.x' into vanilla_fb_2.0.x

commit 854ce63358
Author: Robby Candra <robbycandra.mail@gmail.com>
Date:   Sun Dec 19 05:33:21 2021 +0700

    ๐Ÿ› Fix loud_kill heater disable (#23314)

commit 170f77fada
Author: lukrow80 <64228214+lukrow80@users.noreply.github.com>
Date:   Tue Nov 23 22:30:13 2021 +0100

    ๐Ÿ› Fix homing current for extra axes (#23152)

    Followup to #19112

commit 72b99bf1ba
Author: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com>
Date:   Sat Oct 9 19:13:19 2021 -0400

    ๐Ÿ› Fix IDEX Duplication Mode Positioning (#22914)

    Fixing #22538

commit 1a8583f4fc
Author: Robby Candra <robbycandra.mail@gmail.com>
Date:   Wed Nov 24 04:19:32 2021 +0700

    ๐Ÿ› Fix serial_data_available (#23160)
FB4S_WIFI
Sergey 3 years ago
parent
commit
9b2be293eb
  1. 12
      .gitignore
  2. 87
      Marlin/Configuration.h
  3. 264
      Marlin/Configuration_adv.h
  4. 165
      Marlin/Makefile
  5. 4
      Marlin/Version.h
  6. 21
      Marlin/src/HAL/AVR/HAL.cpp
  7. 14
      Marlin/src/HAL/AVR/HAL.h
  8. 94
      Marlin/src/HAL/AVR/fast_pwm.cpp
  9. 30
      Marlin/src/HAL/AVR/fastio.h
  10. 2
      Marlin/src/HAL/AVR/inc/SanityCheck.h
  11. 43
      Marlin/src/HAL/AVR/pinsDebug.h
  12. 20
      Marlin/src/HAL/AVR/timers.h
  13. 11
      Marlin/src/HAL/DUE/HAL.h
  14. 6
      Marlin/src/HAL/DUE/Tone.cpp
  15. 4
      Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp
  16. 4
      Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp
  17. 16
      Marlin/src/HAL/DUE/timers.cpp
  18. 50
      Marlin/src/HAL/DUE/timers.h
  19. 19
      Marlin/src/HAL/DUE/upload_extra_script.py
  20. 6
      Marlin/src/HAL/ESP32/HAL.cpp
  21. 10
      Marlin/src/HAL/ESP32/HAL.h
  22. 6
      Marlin/src/HAL/ESP32/Tone.cpp
  23. 30
      Marlin/src/HAL/ESP32/i2s.cpp
  24. 18
      Marlin/src/HAL/ESP32/timers.cpp
  25. 36
      Marlin/src/HAL/ESP32/timers.h
  26. 9
      Marlin/src/HAL/LINUX/HAL.h
  27. 27
      Marlin/src/HAL/LINUX/timers.h
  28. 6
      Marlin/src/HAL/LPC1768/HAL.h
  29. 8
      Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp
  30. 20
      Marlin/src/HAL/LPC1768/fast_pwm.cpp
  31. 4
      Marlin/src/HAL/LPC1768/timers.cpp
  32. 64
      Marlin/src/HAL/LPC1768/timers.h
  33. 4
      Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp
  34. 4
      Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp
  35. 198
      Marlin/src/HAL/LPC1768/upload_extra_script.py
  36. 5
      Marlin/src/HAL/NATIVE_SIM/HAL.h
  37. 30
      Marlin/src/HAL/NATIVE_SIM/timers.h
  38. 4
      Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp
  39. 9
      Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp
  40. 11
      Marlin/src/HAL/SAMD51/HAL.h
  41. 8
      Marlin/src/HAL/SAMD51/Servo.cpp
  42. 2
      Marlin/src/HAL/SAMD51/inc/SanityCheck.h
  43. 20
      Marlin/src/HAL/SAMD51/timers.cpp
  44. 62
      Marlin/src/HAL/SAMD51/timers.h
  45. 2
      Marlin/src/HAL/STM32/HAL.cpp
  46. 6
      Marlin/src/HAL/STM32/HAL.h
  47. 2
      Marlin/src/HAL/STM32/HAL_MinSerial.cpp
  48. 11
      Marlin/src/HAL/STM32/MarlinSPI.cpp
  49. 71
      Marlin/src/HAL/STM32/fast_pwm.cpp
  50. 12
      Marlin/src/HAL/STM32/tft/tft_spi.cpp
  51. 26
      Marlin/src/HAL/STM32/timers.cpp
  52. 30
      Marlin/src/HAL/STM32/timers.h
  53. 3
      Marlin/src/HAL/STM32F1/HAL.cpp
  54. 6
      Marlin/src/HAL/STM32F1/HAL.h
  55. 18
      Marlin/src/HAL/STM32F1/Servo.cpp
  56. 30
      Marlin/src/HAL/STM32F1/build_flags.py
  57. 50
      Marlin/src/HAL/STM32F1/fast_pwm.cpp
  58. 2
      Marlin/src/HAL/STM32F1/inc/SanityCheck.h
  59. 2
      Marlin/src/HAL/STM32F1/onboard_sd.cpp
  60. 30
      Marlin/src/HAL/STM32F1/timers.cpp
  61. 72
      Marlin/src/HAL/STM32F1/timers.h
  62. 12
      Marlin/src/HAL/TEENSY31_32/HAL.h
  63. 20
      Marlin/src/HAL/TEENSY31_32/timers.cpp
  64. 36
      Marlin/src/HAL/TEENSY31_32/timers.h
  65. 12
      Marlin/src/HAL/TEENSY35_36/HAL.h
  66. 20
      Marlin/src/HAL/TEENSY35_36/timers.cpp
  67. 36
      Marlin/src/HAL/TEENSY35_36/timers.h
  68. 10
      Marlin/src/HAL/TEENSY40_41/HAL.cpp
  69. 14
      Marlin/src/HAL/TEENSY40_41/HAL.h
  70. 28
      Marlin/src/HAL/TEENSY40_41/timers.cpp
  71. 40
      Marlin/src/HAL/TEENSY40_41/timers.h
  72. 36
      Marlin/src/HAL/shared/Delay.cpp
  73. 15
      Marlin/src/HAL/shared/Delay.h
  74. 9
      Marlin/src/HAL/shared/Marduino.h
  75. 2
      Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp
  76. 2
      Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp
  77. 5
      Marlin/src/HAL/shared/progmem.h
  78. 72
      Marlin/src/MarlinCore.cpp
  79. 2
      Marlin/src/MarlinCore.h
  80. 82
      Marlin/src/core/boards.h
  81. 8
      Marlin/src/core/debug_out.h
  82. 16
      Marlin/src/core/debug_section.h
  83. 1
      Marlin/src/core/language.h
  84. 38
      Marlin/src/core/macros.h
  85. 24
      Marlin/src/core/serial.cpp
  86. 128
      Marlin/src/core/serial.h
  87. 9
      Marlin/src/core/types.h
  88. 9
      Marlin/src/core/utility.cpp
  89. 104
      Marlin/src/feature/adc/adc_mcp3426.cpp
  90. 41
      Marlin/src/feature/adc/adc_mcp3426.h
  91. 2
      Marlin/src/feature/backlash.cpp
  92. 59
      Marlin/src/feature/bedlevel/abl/x_twist.cpp
  93. 37
      Marlin/src/feature/bedlevel/abl/x_twist.h
  94. 3
      Marlin/src/feature/bedlevel/bedlevel.h
  95. 22
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  96. 59
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  97. 30
      Marlin/src/feature/bltouch.cpp
  98. 15
      Marlin/src/feature/bltouch.h
  99. 2
      Marlin/src/feature/cancel_object.cpp
  100. 5
      Marlin/src/feature/caselight.cpp

12
.gitignore

@ -22,12 +22,16 @@
# Generated files
_Version.h
bdf2u8g
marlin_config.json
mczip.h
*.gen
*.sublime-workspace
#
# OS
#
applet/
*.DS_Store
.DS_Store
#
# Misc
@ -146,11 +150,13 @@ vc-fileutils.settings
#Simulation
imgui.ini
eeprom.dat
spi_flash.bin
#cmake
CMakeLists.txt
src/CMakeLists.txt
CMakeListsPrivate.txt
build/
# CLion
cmake-build-*
@ -167,7 +173,3 @@ __pycache__
# IOLogger logs
*_log.csv
# Simulation / Native
eeprom.dat
imgui.ini

87
Marlin/Configuration.h

@ -35,7 +35,7 @@
*
* Advanced settings can be found in Configuration_adv.h
*/
#define CONFIGURATION_H_VERSION 02000902
#define CONFIGURATION_H_VERSION 02000903
//===========================================================================
//============================= Getting Started =============================
@ -94,6 +94,11 @@
// @section machine
// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
#define MOTHERBOARD BOARD_MKS_ROBIN_NANO
#endif
/**
* Select the serial port on the board to use for communication with the host.
* This allows the connection of wireless adapters (for instance) to non-default port pins.
@ -137,12 +142,6 @@
// Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH
// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
// #define MOTHERBOARD BOARD_MKS_ROBIN_NANO_V1_3_F4
#define MOTHERBOARD BOARD_MKS_ROBIN_NANO
#endif
// Name displayed in the LCD "Ready" message and Info menu
#define CUSTOM_MACHINE_NAME "FBGhost 4s/5"
@ -756,6 +755,7 @@
//#define COREZX
//#define COREZY
//#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042
//#define MARKFORGED_YX
// Enable for a belt style printer with endless "Z" motion
//#define BELTPRINTER
@ -1013,7 +1013,7 @@
*
* See https://github.com/synthetos/TinyG/wiki/Jerk-Controlled-Motion-Explained
*/
#define S_CURVE_ACCELERATION
//#define S_CURVE_ACCELERATION
//===========================================================================
//============================= Z Probe Options =============================
@ -1220,6 +1220,15 @@
#endif
#endif
/**
* Probe Enable / Disable
* The probe only provides a triggered signal when enabled.
*/
//#define PROBE_ENABLE_DISABLE
#if ENABLED(PROBE_ENABLE_DISABLE)
//#define PROBE_ENABLE_PIN -1 // Override the default pin here
#endif
/**
* Multiple Probing
*
@ -1925,6 +1934,7 @@ EEPROM_W25Q
#endif
#define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors.
//#define EEPROM_INIT_NOW // Init EEPROM on first boot after a new build.
#endif
//
@ -2471,6 +2481,11 @@ EEPROM_W25Q
//#define VIKI2
//#define miniVIKI
//
// Alfawise Ex8 printer LCD marked as WYH L12864 COG
//
//#define WYH_L12864
//
// MakerLab Mini Panel with graphic
// controller and SD support - https://reprap.org/wiki/Mini_panel
@ -2540,6 +2555,11 @@ EEPROM_W25Q
//#define FYSETC_MINI_12864_2_1 // Type A/B. NeoPixel RGB Backlight
//#define FYSETC_GENERIC_12864_1_1 // Larger display with basic ON/OFF backlight.
//
// BigTreeTech Mini 12864 V1.0 is an alias for FYSETC_MINI_12864_2_1. Type A/B. NeoPixel RGB Backlight.
//
//#define BTT_MINI_12864_V1
//
// Factory display for Creality CR-10
// https://www.aliexpress.com/item/32833148327.html
@ -2732,32 +2752,32 @@ EEPROM_W25Q
*/
//
// 480x320, 3.5", SPI Display From MKS
// Normally used in MKS Robin Nano V2
// 480x320, 3.5", SPI Display with Rotary Encoder from MKS
// Usually paired with MKS Robin Nano V2 & V3
//
//#define MKS_TS35_V2_0
//
// 320x240, 2.4", FSMC Display From MKS
// Normally used in MKS Robin Nano V1.2
// Usually paired with MKS Robin Nano V1.2
//
//#define MKS_ROBIN_TFT24
//
// 320x240, 2.8", FSMC Display From MKS
// Normally used in MKS Robin Nano V1.2
// Usually paired with MKS Robin Nano V1.2
//
//#define MKS_ROBIN_TFT28
//
// 320x240, 3.2", FSMC Display From MKS
// Normally used in MKS Robin Nano V1.2
// Usually paired with MKS Robin Nano V1.2
//
//#define MKS_ROBIN_TFT32
//
// 480x320, 3.5", FSMC Display From MKS
// Normally used in MKS Robin Nano V1.2
// Usually paired with MKS Robin Nano V1.2
//
#define MKS_ROBIN_TFT35
@ -2768,7 +2788,7 @@ EEPROM_W25Q
//
// 320x240, 3.2", FSMC Display From MKS
// Normally used in MKS Robin
// Usually paired with MKS Robin
//
//#define MKS_ROBIN_TFT_V1_1R
@ -2798,10 +2818,15 @@ EEPROM_W25Q
//#define ANET_ET5_TFT35
//
// 1024x600, 7", RGB Stock Display from BIQU-BX
// 1024x600, 7", RGB Stock Display with Rotary Encoder from BIQU-BX
//
//#define BIQU_BX_TFT70
//
// 480x320, 3.5", SPI Stock Display with Rotary Encoder from BIQU B1 SE Series
//
//#define BTT_TFT35_SPI_V1_0
//
// Generic TFT with detailed options
//
@ -2856,23 +2881,11 @@ EEPROM_W25Q
//
// Ender-3 v2 OEM display. A DWIN display with Rotary Encoder.
//
//#define DWIN_CREALITY_LCD
//
// Ender-3 v2 OEM display, enhanced.
//
//#define DWIN_CREALITY_LCD_ENHANCED
//
// Ender-3 v2 OEM display with enhancements by Jacob Myers
//
//#define DWIN_CREALITY_LCD_JYERSUI
//
// MarlinUI for Creality's DWIN display (and others)
//
//#define DWIN_MARLINUI_PORTRAIT
//#define DWIN_MARLINUI_LANDSCAPE
//#define DWIN_CREALITY_LCD // Creality UI
//#define DWIN_CREALITY_LCD_ENHANCED // Enhanced UI
//#define DWIN_CREALITY_LCD_JYERSUI // Jyers UI by Jacob Myers
//#define DWIN_MARLINUI_PORTRAIT // MarlinUI (portrait orientation)
//#define DWIN_MARLINUI_LANDSCAPE // MarlinUI (landscape orientation)
//
// Touch Screen Settings
@ -2908,6 +2921,11 @@ EEPROM_W25Q
//#define REPRAPWORLD_KEYPAD
//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press
//
// EasyThreeD ET-4000+ with button input and status LED
//
//#define EASYTHREED_UI
//=============================================================================
//=============================== Extra Features ==============================
//=============================================================================
@ -2918,9 +2936,6 @@ EEPROM_W25Q
// :[1,2,3,4,5,6,7,8]
//#define NUM_M106_FANS 1
// Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino
//#define FAST_PWM_FAN
// Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
// which is not as annoying as with the hardware PWM. On the other hand, if this frequency
// is too low, you should also increment SOFT_PWM_SCALE.

264
Marlin/Configuration_adv.h

@ -30,7 +30,7 @@
*
* Basic settings can be found in Configuration.h
*/
#define CONFIGURATION_ADV_H_VERSION 02000902
#define CONFIGURATION_ADV_H_VERSION 02000903
//===========================================================================
//============================= Thermal Settings ============================
@ -142,11 +142,20 @@
* FORCE_HW_SPI: Ignore SCK/MOSI/MISO pins and just use the CS pin & default SPI bus.
* MAX31865_WIRES: Set the number of wires for the probe connected to a MAX31865 board, 2-4. Default: 2
* MAX31865_50HZ: Enable 50Hz filter instead of the default 60Hz.
* MAX31865_USE_READ_ERROR_DETECTION: Detects random read errors from value spikes (a 20ยฐC difference in less than 1sec)
* MAX31865_USE_AUTO_MODE: Faster and more frequent reads than 1-shot, but bias voltage always on, slightly affecting RTD temperature.
* MAX31865_MIN_SAMPLING_TIME_MSEC: in 1-shot mode, the minimum time between subsequent reads. This reduces the effect of bias voltage by leaving the sensor unpowered for longer intervals.
* MAX31865_WIRE_OHMS: In 2-wire configurations, manually set the wire resistance for more accurate readings
*/
//#define TEMP_SENSOR_FORCE_HW_SPI
//#define MAX31865_SENSOR_WIRES_0 2
//#define MAX31865_SENSOR_WIRES_1 2
//#define MAX31865_50HZ_FILTER
//#define MAX31865_USE_READ_ERROR_DETECTION
//#define MAX31865_USE_AUTO_MODE
//#define MAX31865_MIN_SAMPLING_TIME_MSEC 100
//#define MAX31865_WIRE_OHMS_0 0.0f
//#define MAX31865_WIRE_OHMS_1 0.0f
/**
* Hephestos 2 24V heated bed upgrade kit.
@ -186,7 +195,8 @@
//#define CHAMBER_FAN // Enable a fan on the chamber
#if ENABLED(CHAMBER_FAN)
#define CHAMBER_FAN_MODE 2 // Fan control mode: 0=Static; 1=Linear increase when temp is higher than target; 2=V-shaped curve; 3=similar to 1 but fan is always on.
//#define CHAMBER_FAN_INDEX 2 // Index of a fan to repurpose as the chamber fan. (Default: first unused fan)
#define CHAMBER_FAN_MODE 2 // Fan control mode: 0=Static; 1=Linear increase when temp is higher than target; 2=V-shaped curve; 3=similar to 1 but fan is always on.
#if CHAMBER_FAN_MODE == 0
#define CHAMBER_FAN_BASE 255 // Chamber fan PWM (0-255)
#elif CHAMBER_FAN_MODE == 1
@ -329,14 +339,14 @@
* Thermal Protection parameters for the laser cooler.
*/
#if ENABLED(THERMAL_PROTECTION_COOLER)
#define THERMAL_PROTECTION_COOLER_PERIOD 10 // Seconds
#define THERMAL_PROTECTION_COOLER_HYSTERESIS 3 // Degrees Celsius
#define THERMAL_PROTECTION_COOLER_PERIOD 10 // Seconds
#define THERMAL_PROTECTION_COOLER_HYSTERESIS 3 // Degrees Celsius
/**
* Laser cooling watch settings (M143/M193).
*/
#define WATCH_COOLER_TEMP_PERIOD 60 // Seconds
#define WATCH_COOLER_TEMP_INCREASE 3 // Degrees Celsius
#define WATCH_COOLER_TEMP_PERIOD 60 // Seconds
#define WATCH_COOLER_TEMP_INCREASE 3 // Degrees Celsius
#endif
#if ENABLED(PIDTEMP)
@ -414,7 +424,7 @@
*/
#define AUTOTEMP
#if ENABLED(AUTOTEMP)
#define AUTOTEMP_OLDWEIGHT 0.98
#define AUTOTEMP_OLDWEIGHT 0.98 // Factor used to weight previous readings (0.0 < value < 1.0)
// Turn on AUTOTEMP on M104/M109 by default using proportions set here
//#define AUTOTEMP_PROPORTIONAL
#if ENABLED(AUTOTEMP_PROPORTIONAL)
@ -539,18 +549,21 @@
//#define FAN_MAX_PWM 128
/**
* FAST PWM FAN Settings
* Fan Fast PWM
*
* Use to change the FAST FAN PWM frequency (if enabled in Configuration.h)
* Combinations of PWM Modes, prescale values and TOP resolutions are used internally to produce a
* frequency as close as possible to the desired frequency.
* Combinations of PWM Modes, prescale values and TOP resolutions are used internally
* to produce a frequency as close as possible to the desired frequency.
*
* FAST_PWM_FAN_FREQUENCY [undefined by default]
* FAST_PWM_FAN_FREQUENCY
* Set this to your desired frequency.
* If left undefined this defaults to F = F_CPU/(2*255*1)
* i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers.
* These defaults are the same as with the old FAST_PWM_FAN implementation - no migration is required
* For AVR, if left undefined this defaults to F = F_CPU/(2*255*1)
* i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers.
* For non AVR, if left undefined this defaults to F = 1Khz.
* This F value is only to protect the hardware from an absence of configuration
* and not to complete it when users are not aware that the frequency must be specifically set to support the target board.
*
* NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behavior.
* Setting very high frequencies can damage your hardware.
*
* USE_OCR2A_AS_TOP [undefined by default]
* Boards that use TIMER2 for PWM have limitations resulting in only a few possible frequencies on TIMER2:
@ -560,9 +573,17 @@
* PWM on pin OC2A. Only use this option if you don't need PWM on 0C2A. (Check your schematic.)
* USE_OCR2A_AS_TOP sacrifices duty cycle control resolution to achieve this broader range of frequencies.
*/
//#define FAST_PWM_FAN // Increase the fan PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino
#if ENABLED(FAST_PWM_FAN)
//#define FAST_PWM_FAN_FREQUENCY 31400
//#define FAST_PWM_FAN_FREQUENCY 31400 // Define here to override the defaults below
//#define USE_OCR2A_AS_TOP
#ifndef FAST_PWM_FAN_FREQUENCY
#ifdef __AVR__
#define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1))
#else
#define FAST_PWM_FAN_FREQUENCY 1000U
#endif
#endif
#endif
/**
@ -603,6 +624,40 @@
#define COOLER_AUTO_FAN_TEMPERATURE 18
#define COOLER_AUTO_FAN_SPEED 255
/**
* Hotend Cooling Fans tachometers
*
* Define one or more tachometer pins to enable fan speed
* monitoring, and reporting of fan speeds with M123.
*
* NOTE: Only works with fans up to 7000 RPM.
*/
//#define FOURWIRES_FANS // Needed with AUTO_FAN when 4-wire PWM fans are installed
//#define E0_FAN_TACHO_PIN -1
//#define E0_FAN_TACHO_PULLUP
//#define E0_FAN_TACHO_PULLDOWN
//#define E1_FAN_TACHO_PIN -1
//#define E1_FAN_TACHO_PULLUP
//#define E1_FAN_TACHO_PULLDOWN
//#define E2_FAN_TACHO_PIN -1
//#define E2_FAN_TACHO_PULLUP
//#define E2_FAN_TACHO_PULLDOWN
//#define E3_FAN_TACHO_PIN -1
//#define E3_FAN_TACHO_PULLUP
//#define E3_FAN_TACHO_PULLDOWN
//#define E4_FAN_TACHO_PIN -1
//#define E4_FAN_TACHO_PULLUP
//#define E4_FAN_TACHO_PULLDOWN
//#define E5_FAN_TACHO_PIN -1
//#define E5_FAN_TACHO_PULLUP
//#define E5_FAN_TACHO_PULLDOWN
//#define E6_FAN_TACHO_PIN -1
//#define E6_FAN_TACHO_PULLUP
//#define E6_FAN_TACHO_PULLDOWN
//#define E7_FAN_TACHO_PIN -1
//#define E7_FAN_TACHO_PULLUP
//#define E7_FAN_TACHO_PULLDOWN
/**
* Part-Cooling Fan Multiplexer
*
@ -853,12 +908,14 @@
//#define BLTOUCH_FORCE_MODE_SET
/**
* Use "HIGH SPEED" mode for probing.
* Enable "HIGH SPEED" option for probing.
* Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems.
* This feature was designed for Deltabots with very fast Z moves; however, higher speed Cartesians
* might be able to use it. If the machine can't raise Z fast enough the BLTouch may go into ALARM.
*
* Set the default state here, change with 'M401 S' or UI, use M500 to save, M502 to reset.
*/
//#define BLTOUCH_HS_MODE
//#define BLTOUCH_HS_MODE true
// Safety: Enable voltage mode settings in the LCD menu.
//#define BLTOUCH_LCD_VOLTAGE_MENU
@ -1235,6 +1292,22 @@
// Set a convenient position to do the calibration (probing point and nozzle/bed-distance)
//#define PROBE_OFFSET_WIZARD_XY_POS { X_CENTER, Y_CENTER }
#endif
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
// Add a calibration procedure in the Probe Offsets menu
// to compensate for twist in the X-axis.
//#define X_AXIS_TWIST_COMPENSATION
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
/**
* Enable to init the Probe Z-Offset when starting the Wizard.
* Use a height slightly above the estimated nozzle-to-probe Z offset.
* For example, with an offset of -5, consider a starting height of -4.
*/
#define XATC_START_Z 0.0
#define XATC_MAX_POINTS 3 // Number of points to probe in the wizard
#define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe
#endif
#endif
#endif
// Include a page of printer information in the LCD Main Menu
@ -1246,9 +1319,6 @@
// BACK menu items keep the highlight at the top
//#define TURBO_BACK_MENU_ITEM
// Add a mute option to the LCD menu
#define SOUND_MENU_ITEM
/**
* LED Control Menu
* Add LED Control to the LCD menu
@ -1280,7 +1350,11 @@
#endif // HAS_LCD_MENU
#if HAS_DISPLAY
#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI)
#define SOUND_MENU_ITEM // Add a mute option to the LCD menu
#endif
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
// The timeout (in ms) to return to the status screen from sub-menus
//#define LCD_TIMEOUT_TO_STATUS 15000
@ -1306,7 +1380,7 @@
// LCD Print Progress options
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
#if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, IS_DWIN_MARLINUI)
#if CAN_SHOW_REMAINING_TIME
//#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
@ -1534,6 +1608,14 @@
#define SD_FIRMWARE_UPDATE_INACTIVE_VALUE 0xFF
#endif
/**
* Enable this option if you have more than ~3K of unused flash space.
* Marlin will embed all settings in the firmware binary as compressed data.
* Use 'M503 C' to write the settings out to the SD Card as 'mc.zip'.
* See docs/ConfigEmbedding.md for details on how to use 'mc-apply.py'.
*/
//#define CONFIGURATION_EMBEDDING
// Add an optimized binary file transfer mode, initiated with 'M28 B1'
//#define BINARY_FILE_TRANSFER
@ -1605,7 +1687,7 @@
* Set STATUS_EXPIRE_SECONDS to zero to never clear the status.
* This will prevent position updates from being displayed.
*/
#if ENABLED(U8GLIB_ST7920)
#if IS_U8GLIB_ST7920
// Enable this option and reduce the value to optimize screen updates.
// The normal delay is 10ยตs. Use the lowest value that still gives a reliable display.
//#define DOGM_SPI_DELAY_US 5
@ -1634,7 +1716,7 @@
//#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap
//#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames
//#define STATUS_HEAT_PERCENT // Show heating in a progress bar
//#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~โ€ญ3260 (or ~940) bytes of PROGMEM.
//#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of PROGMEM.
// Frivolous Game Options
//#define MARLIN_BRICKOUT
@ -1915,6 +1997,7 @@
#define LIN_ADVANCE_K 0 // Unit: mm compression per 1mm/s extruder speed
//#define LA_DEBUG // If enabled, this will generate debug information output over USB.
#define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration
//#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends.
#endif
// @section leveling
@ -1990,59 +2073,69 @@
/**
* Thermal Probe Compensation
* Probe measurements are adjusted to compensate for temperature distortion.
* Use G76 to calibrate this feature. Use M871 to set values manually.
* For a more detailed explanation of the process see G76_M871.cpp.
*
* Adjust probe measurements to compensate for distortion associated with the temperature
* of the probe, bed, and/or hotend.
* Use G76 to automatically calibrate this feature for probe and bed temperatures.
* (Extruder temperature/offset values must be calibrated manually.)
* Use M871 to set temperature/offset values manually.
* For more details see https://marlinfw.org/docs/features/probe_temp_compensation.html
*/
#if HAS_BED_PROBE && TEMP_SENSOR_PROBE && TEMP_SENSOR_BED
// Enable thermal first layer compensation using bed and probe temperatures
#define PROBE_TEMP_COMPENSATION
//#define PTC_PROBE // Compensate based on probe temperature
//#define PTC_BED // Compensate based on bed temperature
//#define PTC_HOTEND // Compensate based on hotend temperature
// Add additional compensation depending on hotend temperature
// Note: this values cannot be calibrated and have to be set manually
#if ENABLED(PROBE_TEMP_COMPENSATION)
#if ANY(PTC_PROBE, PTC_BED, PTC_HOTEND)
/**
* If the probe is outside the defined range, use linear extrapolation with the closest
* point and the point with index PTC_LINEAR_EXTRAPOLATION. e.g., If set to 4 it will use the
* linear extrapolation between data[0] and data[4] for values below PTC_PROBE_START.
*/
//#define PTC_LINEAR_EXTRAPOLATION 4
#if ENABLED(PTC_PROBE)
// Probe temperature calibration generates a table of values starting at PTC_PROBE_START
// (e.g., 30), in steps of PTC_PROBE_RES (e.g., 5) with PTC_PROBE_COUNT (e.g., 10) samples.
#define PTC_PROBE_START 30 // (ยฐC)
#define PTC_PROBE_RES 5 // (ยฐC)
#define PTC_PROBE_COUNT 10
#define PTC_PROBE_ZOFFS { 0 } // (ยตm) Z adjustments per sample
#endif
#if ENABLED(PTC_BED)
// Bed temperature calibration builds a similar table.
#define PTC_BED_START 60 // (ยฐC)
#define PTC_BED_RES 5 // (ยฐC)
#define PTC_BED_COUNT 10
#define PTC_BED_ZOFFS { 0 } // (ยตm) Z adjustments per sample
#endif
#if ENABLED(PTC_HOTEND)
// Note: There is no automatic calibration for the hotend. Use M871.
#define PTC_HOTEND_START 180 // (ยฐC)
#define PTC_HOTEND_RES 5 // (ยฐC)
#define PTC_HOTEND_COUNT 20
#define PTC_HOTEND_ZOFFS { 0 } // (ยตm) Z adjustments per sample
#endif
// G76 options
#if BOTH(PTC_PROBE, PTC_BED)
// Park position to wait for probe cooldown
#define PTC_PARK_POS { 0, 0, 100 }
// Probe position to probe and wait for probe to reach target temperature
//#define PTC_PROBE_POS { 12.0f, 7.3f } // Example: MK52 magnetic heatbed
#define PTC_PROBE_POS { 90, 100 }
// Enable additional compensation using hotend temperature
// Note: this values cannot be calibrated automatically but have to be set manually
//#define USE_TEMP_EXT_COMPENSATION
// Probe temperature calibration generates a table of values starting at PTC_SAMPLE_START
// (e.g., 30), in steps of PTC_SAMPLE_RES (e.g., 5) with PTC_SAMPLE_COUNT (e.g., 10) samples.
//#define PTC_SAMPLE_START 30 // (ยฐC)
//#define PTC_SAMPLE_RES 5 // (ยฐC)
//#define PTC_SAMPLE_COUNT 10
// Bed temperature calibration builds a similar table.
//#define BTC_SAMPLE_START 60 // (ยฐC)
//#define BTC_SAMPLE_RES 5 // (ยฐC)
//#define BTC_SAMPLE_COUNT 10
// The temperature the probe should be at while taking measurements during bed temperature
// calibration.
//#define BTC_PROBE_TEMP 30 // (ยฐC)
// The temperature the probe should be at while taking measurements during
// bed temperature calibration.
#define PTC_PROBE_TEMP 30 // (ยฐC)
// Height above Z=0.0 to raise the nozzle. Lowering this can help the probe to heat faster.
// Note: the Z=0.0 offset is determined by the probe offset which can be set using M851.
//#define PTC_PROBE_HEATING_OFFSET 0.5
// Height to raise the Z-probe between heating and taking the next measurement. Some probes
// may fail to untrigger if they have been triggered for a long time, which can be solved by
// increasing the height the probe is raised to.
//#define PTC_PROBE_RAISE 15
// If the probe is outside of the defined range, use linear extrapolation using the closest
// point and the PTC_LINEAR_EXTRAPOLATION'th next point. E.g. if set to 4 it will use data[0]
// and data[4] to perform linear extrapolation for values below PTC_SAMPLE_START.
//#define PTC_LINEAR_EXTRAPOLATION 4
// Note: The Z=0.0 offset is determined by the probe Z offset (e.g., as set with M851 Z).
#define PTC_PROBE_HEATING_OFFSET 0.5
#endif
#endif
#endif // PTC_PROBE || PTC_BED || PTC_HOTEND
// @section extras
@ -2175,13 +2268,13 @@
// For debug-echo: 128 bytes for the optimal speed.
// Other output doesn't need to be that speedy.
// :[0, 2, 4, 8, 16, 32, 64, 128, 256]
#define TX_BUFFER_SIZE 256
#define TX_BUFFER_SIZE 64
// Host Receive Buffer Size
// Without XON/XOFF flow control (see SERIAL_XON_XOFF below) 32 bytes should be enough.
// To use flow control, set this buffer size to at least 1024 bytes.
// :[0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
#define RX_BUFFER_SIZE 2048
#define RX_BUFFER_SIZE 512
#if RX_BUFFER_SIZE >= 1024
// Enable to have the controller send XON/XOFF control characters to
@ -2338,7 +2431,7 @@
// Longer prime to clean out a SINGLENOZZLE
#define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length
#define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/min) Extra priming feedrate
#define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm/min) Retract before cooling for less stringing, better wipe, etc.
#define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm) Retract before cooling for less stringing, better wipe, etc.
// Cool after prime to reduce stringing
#define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip
@ -2599,6 +2692,7 @@
#define X_RSENSE 0.11
#define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ...
//#define X_INTERPOLATE true // Enable to override 'INTERPOLATE' for the X axis
//#define X_HOLD_MULTIPLIER 0.5 // Enable to override 'HOLD_MULTIPLIER' for the X axis
#endif
#if AXIS_IS_TMC(X2)
@ -2608,6 +2702,7 @@
#define X2_RSENSE 0.11
#define X2_CHAIN_POS -1
//#define X2_INTERPOLATE true
//#define X2_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(Y)
@ -2617,6 +2712,7 @@
#define Y_RSENSE 0.11
#define Y_CHAIN_POS -1
//#define Y_INTERPOLATE true
//#define Y_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(Y2)
@ -2626,6 +2722,7 @@
#define Y2_RSENSE 0.11
#define Y2_CHAIN_POS -1
//#define Y2_INTERPOLATE true
//#define Y2_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(Z)
@ -2635,6 +2732,7 @@
#define Z_RSENSE 0.11
#define Z_CHAIN_POS -1
//#define Z_INTERPOLATE true
//#define Z_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(Z2)
@ -2644,6 +2742,7 @@
#define Z2_RSENSE 0.11
#define Z2_CHAIN_POS -1
//#define Z2_INTERPOLATE true
//#define Z2_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(Z3)
@ -2653,6 +2752,7 @@
#define Z3_RSENSE 0.11
#define Z3_CHAIN_POS -1
//#define Z3_INTERPOLATE true
//#define Z3_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(Z4)
@ -2662,6 +2762,7 @@
#define Z4_RSENSE 0.11
#define Z4_CHAIN_POS -1
//#define Z4_INTERPOLATE true
//#define Z4_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(I)
@ -2671,6 +2772,7 @@
#define I_RSENSE 0.11
#define I_CHAIN_POS -1
//#define I_INTERPOLATE true
//#define I_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(J)
@ -2680,6 +2782,7 @@
#define J_RSENSE 0.11
#define J_CHAIN_POS -1
//#define J_INTERPOLATE true
//#define J_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(K)
@ -2689,6 +2792,7 @@
#define K_RSENSE 0.11
#define K_CHAIN_POS -1
//#define K_INTERPOLATE true
//#define K_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(E0)
@ -2697,6 +2801,7 @@
#define E0_RSENSE 0.11
#define E0_CHAIN_POS -1
//#define E0_INTERPOLATE true
//#define E0_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(E1)
@ -2705,6 +2810,7 @@
#define E1_RSENSE 0.11
#define E1_CHAIN_POS -1
//#define E1_INTERPOLATE true
//#define E1_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(E2)
@ -2713,6 +2819,7 @@
#define E2_RSENSE 0.11
#define E2_CHAIN_POS -1
//#define E2_INTERPOLATE true
//#define E2_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(E3)
@ -2721,6 +2828,7 @@
#define E3_RSENSE 0.11
#define E3_CHAIN_POS -1
//#define E3_INTERPOLATE true
//#define E3_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(E4)
@ -2729,6 +2837,7 @@
#define E4_RSENSE 0.11
#define E4_CHAIN_POS -1
//#define E4_INTERPOLATE true
//#define E4_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(E5)
@ -2737,6 +2846,7 @@
#define E5_RSENSE 0.11
#define E5_CHAIN_POS -1
//#define E5_INTERPOLATE true
//#define E5_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(E6)
@ -2745,6 +2855,7 @@
#define E6_RSENSE 0.11
#define E6_CHAIN_POS -1
//#define E6_INTERPOLATE true
//#define E6_HOLD_MULTIPLIER 0.5
#endif
#if AXIS_IS_TMC(E7)
@ -2753,6 +2864,7 @@
#define E7_RSENSE 0.11
#define E7_CHAIN_POS -1
//#define E7_INTERPOLATE true
//#define E7_HOLD_MULTIPLIER 0.5
#endif
/**
@ -3597,6 +3709,12 @@
*/
//#define CNC_COORDINATE_SYSTEMS
/**
* Auto-report fan speed with M123 S<seconds>
* Requires fans with tachometer pins
*/
//#define AUTO_REPORT_FANS
/**
* Auto-report temperatures with M155 S<seconds>
*/
@ -3840,7 +3958,8 @@
#if ENABLED(HOST_ACTION_COMMANDS)
//#define HOST_PAUSE_M76
//#define HOST_PROMPT_SUPPORT
//#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
//#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
//#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down
#endif
/**
@ -4214,3 +4333,6 @@
*/
//#define SOFT_RESET_VIA_SERIAL // 'KILL' and '^X' commands will soft-reset the controller
//#define SOFT_RESET_ON_KILL // Use a digital button to soft-reset the controller after KILL
// Report uncleaned reset reason from register r2 instead of MCUSR. Supported by Optiboot on AVR.
//#define OPTIBOOT_RESET_REASON

165
Marlin/Makefile

@ -191,6 +191,134 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1034)
# RAMPS Derivatives - ATmega1280, ATmega2560
#
# 3Drag Controller
else ifeq ($(HARDWARE_MOTHERBOARD),1100)
# Velleman K8200 Controller (derived from 3Drag Controller)
else ifeq ($(HARDWARE_MOTHERBOARD),1101)
# Velleman K8400 Controller (derived from 3Drag Controller)
else ifeq ($(HARDWARE_MOTHERBOARD),1102)
# Velleman K8600 Controller (Vertex Nano)
else ifeq ($(HARDWARE_MOTHERBOARD),1103)
# Velleman K8800 Controller (Vertex Delta)
else ifeq ($(HARDWARE_MOTHERBOARD),1104)
# 2PrintBeta BAM&DICE with STK drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1105)
# 2PrintBeta BAM&DICE Due with STK drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1106)
# MKS BASE v1.0
else ifeq ($(HARDWARE_MOTHERBOARD),1107)
# MKS BASE v1.4 with Allegro A4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1108)
# MKS BASE v1.5 with Allegro A4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1109)
# MKS BASE v1.6 with Allegro A4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1110)
# MKS BASE 1.0 with Heroic HR4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1111)
# MKS GEN v1.3 or 1.4
else ifeq ($(HARDWARE_MOTHERBOARD),1112)
# MKS GEN L
else ifeq ($(HARDWARE_MOTHERBOARD),1113)
# BigTreeTech or BIQU KFB2.0
else ifeq ($(HARDWARE_MOTHERBOARD),1114)
# zrib V2.0 (Chinese RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1115)
# zrib V5.2 (Chinese RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1116)
# Felix 2.0+ Electronics Board (RAMPS like)
else ifeq ($(HARDWARE_MOTHERBOARD),1117)
# Invent-A-Part RigidBoard
else ifeq ($(HARDWARE_MOTHERBOARD),1118)
# Invent-A-Part RigidBoard V2
else ifeq ($(HARDWARE_MOTHERBOARD),1119)
# Sainsmart 2-in-1 board
else ifeq ($(HARDWARE_MOTHERBOARD),1120)
# Ultimaker
else ifeq ($(HARDWARE_MOTHERBOARD),1121)
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
else ifeq ($(HARDWARE_MOTHERBOARD),1122)
MCU ?= atmega1280
PROG_MCU ?= m1280
# Azteeg X3
else ifeq ($(HARDWARE_MOTHERBOARD),1123)
# Azteeg X3 Pro
else ifeq ($(HARDWARE_MOTHERBOARD),1124)
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
else ifeq ($(HARDWARE_MOTHERBOARD),1125)
# Rumba
else ifeq ($(HARDWARE_MOTHERBOARD),1126)
# Raise3D N series Rumba derivative
else ifeq ($(HARDWARE_MOTHERBOARD),1127)
# Rapide Lite 200 (v1, low-cost RUMBA clone with drv)
else ifeq ($(HARDWARE_MOTHERBOARD),1128)
# Formbot T-Rex 2 Plus
else ifeq ($(HARDWARE_MOTHERBOARD),1129)
# Formbot T-Rex 3
else ifeq ($(HARDWARE_MOTHERBOARD),1130)
# Formbot Raptor
else ifeq ($(HARDWARE_MOTHERBOARD),1131)
# Formbot Raptor 2
else ifeq ($(HARDWARE_MOTHERBOARD),1132)
# bq ZUM Mega 3D
else ifeq ($(HARDWARE_MOTHERBOARD),1133)
# MakeBoard Mini v2.1.2 by MicroMake
else ifeq ($(HARDWARE_MOTHERBOARD),1134)
# TriGorilla Anycubic version 1.3-based on RAMPS EFB
else ifeq ($(HARDWARE_MOTHERBOARD),1135)
# ... Ver 1.4
else ifeq ($(HARDWARE_MOTHERBOARD),1136)
# ... Rev 1.1 (new servo pin order)
else ifeq ($(HARDWARE_MOTHERBOARD),1137)
# Creality: Ender-4, CR-8
else ifeq ($(HARDWARE_MOTHERBOARD),1138)
# Creality: CR10S, CR20, CR-X
else ifeq ($(HARDWARE_MOTHERBOARD),1139)
# Dagoma F5
else ifeq ($(HARDWARE_MOTHERBOARD),1140)
# FYSETC F6 1.3
else ifeq ($(HARDWARE_MOTHERBOARD),1141)
# FYSETC F6 1.4
else ifeq ($(HARDWARE_MOTHERBOARD),1142)
# Wanhao Duplicator i3 Plus
else ifeq ($(HARDWARE_MOTHERBOARD),1143)
# VORON Design
else ifeq ($(HARDWARE_MOTHERBOARD),1144)
# Tronxy TRONXY-V3-1.0
else ifeq ($(HARDWARE_MOTHERBOARD),1145)
# Z-Bolt X Series
else ifeq ($(HARDWARE_MOTHERBOARD),1146)
# TT OSCAR
else ifeq ($(HARDWARE_MOTHERBOARD),1147)
# Overlord/Overlord Pro
else ifeq ($(HARDWARE_MOTHERBOARD),1148)
# ADIMLab Gantry v1
else ifeq ($(HARDWARE_MOTHERBOARD),1149)
# ADIMLab Gantry v2
else ifeq ($(HARDWARE_MOTHERBOARD),1150)
# BIQU Tango V1
else ifeq ($(HARDWARE_MOTHERBOARD),1151)
# MKS GEN L V2
else ifeq ($(HARDWARE_MOTHERBOARD),1152)
# MKS GEN L V2.1
else ifeq ($(HARDWARE_MOTHERBOARD),1153)
# Copymaster 3D
else ifeq ($(HARDWARE_MOTHERBOARD),1154)
# Ortur 4
else ifeq ($(HARDWARE_MOTHERBOARD),1155)
# Tenlog D3 Hero IDEX printer
else ifeq ($(HARDWARE_MOTHERBOARD),1156)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1157)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1158)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1159)
# Longer LK1 PRO / Alfawise U20 Pro (PRO version)
else ifeq ($(HARDWARE_MOTHERBOARD),1160)
# Longer LKx PRO / Alfawise Uxx Pro (PRO version)
else ifeq ($(HARDWARE_MOTHERBOARD),1161)
# 3Drag Controller
else ifeq ($(HARDWARE_MOTHERBOARD),1100)
# Velleman K8200 Controller (derived from 3Drag Controller)
@ -358,20 +486,38 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1311)
else ifeq ($(HARDWARE_MOTHERBOARD),1312)
# Mega controller
else ifeq ($(HARDWARE_MOTHERBOARD),1313)
# Geeetech GT2560 Rev B for Mecreator2
# Geeetech GT2560 Rev A
else ifeq ($(HARDWARE_MOTHERBOARD),1314)
# Geeetech GT2560 Rev. A
# Geeetech GT2560 Rev A+ (with auto level probe)
else ifeq ($(HARDWARE_MOTHERBOARD),1315)
# Geeetech GT2560 Rev. A+ (with auto level probe)
# Geeetech GT2560 Rev B
else ifeq ($(HARDWARE_MOTHERBOARD),1316)
# Geeetech GT2560 Rev B for A10(M/D)
# Geeetech GT2560 Rev B for A10(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1317)
# Geeetech GT2560 Rev B for A20(M/D)
# Geeetech GT2560 Rev B for A10(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1318)
# Einstart retrofit
# Geeetech GT2560 Rev B for Mecreator2
else ifeq ($(HARDWARE_MOTHERBOARD),1319)
# Wanhao 0ne+ i3 Mini
# Geeetech GT2560 Rev B for A20(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1320)
# Einstart retrofit
else ifeq ($(HARDWARE_MOTHERBOARD),1321)
# Wanhao 0ne+ i3 Mini
else ifeq ($(HARDWARE_MOTHERBOARD),1322)
# Leapfrog Xeed 2015
else ifeq ($(HARDWARE_MOTHERBOARD),1323)
# PICA Shield (original version)
else ifeq ($(HARDWARE_MOTHERBOARD),1324)
# PICA Shield (rev C or later)
else ifeq ($(HARDWARE_MOTHERBOARD),1325)
# Intamsys 4.0 (Funmat HT)
else ifeq ($(HARDWARE_MOTHERBOARD),1326)
# Malyan M180 Mainboard Version 2 (no display function, direct gcode only)
else ifeq ($(HARDWARE_MOTHERBOARD),1327)
# Geeetech GT2560 Rev B for A20(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1328)
# Mega controller & Protoneer CNC Shield V3.00
else ifeq ($(HARDWARE_MOTHERBOARD),1329)
#
# ATmega1281, ATmega2561
@ -445,6 +591,11 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1510)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
PROG_MCU ?= m1284p
# ZoneStar ZMIB V2
else ifeq ($(HARDWARE_MOTHERBOARD),1511)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
PROG_MCU ?= m1284p
#
# Other ATmega644P, ATmega644, ATmega1284P

4
Marlin/Version.h

@ -28,7 +28,7 @@
/**
* Marlin release version identifier
*/
//#define SHORT_BUILD_VERSION "2.0.9.2"
//#define SHORT_BUILD_VERSION "2.0.9.3"
/**
* Verbose version identifier which should contain a reference to the location
@ -41,7 +41,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
//#define STRING_DISTRIBUTION_DATE "2021-09-03"
//#define STRING_DISTRIBUTION_DATE "2021-12-25"
/**
* Defines a generic printer name to be output to the LCD after booting Marlin.

21
Marlin/src/HAL/AVR/HAL.cpp

@ -35,12 +35,31 @@
// Public Variables
// ------------------------
//uint8_t MCUSR;
// Don't initialize/override variable (which would happen in .init4)
uint8_t reset_reason __attribute__((section(".noinit")));
// ------------------------
// Public functions
// ------------------------
__attribute__((naked)) // Don't output function pro- and epilogue
__attribute__((used)) // Output the function, even if "not used"
__attribute__((section(".init3"))) // Put in an early user definable section
void HAL_save_reset_reason() {
#if ENABLED(OPTIBOOT_RESET_REASON)
__asm__ __volatile__(
A("STS %0, r2")
: "=m"(reset_reason)
);
#else
reset_reason = MCUSR;
#endif
// Clear within 16ms since WDRF bit enables a 16ms watchdog timer -> Boot loop
MCUSR = 0;
wdt_disable();
}
void HAL_init() {
// Init Servo Pins
#define INIT_SERVO(N) OUT_WRITE(SERVO##N##_PIN, LOW)

14
Marlin/src/HAL/AVR/HAL.h

@ -91,7 +91,7 @@ typedef int8_t pin_t;
// Public Variables
// ------------------------
//extern uint8_t MCUSR;
extern uint8_t reset_reason;
// Serial ports
#ifdef USBCON
@ -152,21 +152,19 @@ void HAL_init();
//void _delay_ms(const int delay);
inline void HAL_clear_reset_source() { MCUSR = 0; }
inline uint8_t HAL_get_reset_source() { return MCUSR; }
inline void HAL_clear_reset_source() { }
inline uint8_t HAL_get_reset_source() { return reset_reason; }
void HAL_reboot();
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
extern "C" int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#pragma GCC diagnostic pop
// ADC
#ifdef DIDR2
@ -223,7 +221,7 @@ void set_pwm_frequency(const pin_t pin, int f_desired);
/**
* set_pwm_duty
* Sets the PWM duty cycle of the provided pin to the provided value
* Set the PWM duty cycle of the provided pin to the provided value
* Optionally allows inverting the duty cycle [default = false]
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
*/

94
Marlin/src/HAL/AVR/fast_pwm.cpp

@ -22,11 +22,10 @@
#ifdef __AVR__
#include "../../inc/MarlinConfigPre.h"
#include "HAL.h"
#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM
#include "HAL.h"
struct Timer {
volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer
volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer
@ -55,8 +54,8 @@ Timer get_pwm_timer(const pin_t pin) {
case TIMER1A: case TIMER1B:
#endif
break;
#if defined(TCCR2) || defined(TCCR2A)
#ifdef TCCR2
#if HAS_TCCR2 || defined(TCCR2A)
#if HAS_TCCR2
case TIMER2: {
Timer timer = {
/*TCCRnQ*/ { &TCCR2, nullptr, nullptr },
@ -153,7 +152,7 @@ Timer get_pwm_timer(const pin_t pin) {
void set_pwm_frequency(const pin_t pin, int f_desired) {
Timer timer = get_pwm_timer(pin);
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
if (timer.n == 0) return; // Don't proceed if protected timer or not recognized
uint16_t size;
if (timer.n == 2) size = 255; else size = 65535;
@ -201,16 +200,10 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
res = res_temp_fast;
j = i;
// Set the Wave Generation Mode to FAST PWM
if (timer.n == 2) {
wgm = (
#if ENABLED(USE_OCR2A_AS_TOP)
WGM2_FAST_PWM_OCR2A
#else
WGM2_FAST_PWM
#endif
);
}
else wgm = WGM_FAST_PWM_ICRn;
if (timer.n == 2)
wgm = TERN(USE_OCR2A_AS_TOP, WGM2_FAST_PWM_OCR2A, WGM2_FAST_PWM);
else
wgm = WGM_FAST_PWM_ICRn;
}
// If PHASE CORRECT values are closes to desired f
else if (f_phase_diff < f_diff) {
@ -218,16 +211,10 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
res = res_temp_phase_correct;
j = i;
// Set the Wave Generation Mode to PWM PHASE CORRECT
if (timer.n == 2) {
wgm = (
#if ENABLED(USE_OCR2A_AS_TOP)
WGM2_PWM_PC_OCR2A
#else
WGM2_PWM_PC
#endif
);
}
else wgm = WGM_PWM_PC_ICRn;
if (timer.n == 2)
wgm = TERN(USE_OCR2A_AS_TOP, WGM2_PWM_PC_OCR2A, WGM2_FAST_PWM);
else
wgm = WGM_PWM_PC_ICRn;
}
}
}
@ -235,48 +222,39 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
_SET_CSn(timer.TCCRnQ, j);
if (timer.n == 2) {
#if ENABLED(USE_OCR2A_AS_TOP)
_SET_OCRnQ(timer.OCRnQ, 0, res); // Set OCR2A value (TOP) = res
#endif
TERN_(USE_OCR2A_AS_TOP, _SET_OCRnQ(timer.OCRnQ, 0, res)); // Set OCR2A value (TOP) = res
}
else
_SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res
}
#endif // NEEDS_HARDWARE_PWM
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
// If v is 0 or v_size (max), digitalWrite to LOW or HIGH.
// Note that digitalWrite also disables pwm output for us (sets COM bit to 0)
if (v == 0)
digitalWrite(pin, invert);
else if (v == v_size)
digitalWrite(pin, !invert);
else {
Timer timer = get_pwm_timer(pin);
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
// Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted)
_SET_COMnQ(timer.TCCRnQ, (timer.q
#ifdef TCCR2
+ (timer.q == 2) // COM20 is on bit 4 of TCCR2, thus requires q + 1 in the macro
#endif
), COM_CLEAR_SET + invert
);
#if NEEDS_HARDWARE_PWM
uint16_t top;
if (timer.n == 2) { // if TIMER2
top = (
#if ENABLED(USE_OCR2A_AS_TOP)
*timer.OCRnQ[0] // top = OCR2A
#else
255 // top = 0xFF (max)
#endif
);
// If v is 0 or v_size (max), digitalWrite to LOW or HIGH.
// Note that digitalWrite also disables pwm output for us (sets COM bit to 0)
if (v == 0)
digitalWrite(pin, invert);
else if (v == v_size)
digitalWrite(pin, !invert);
else {
Timer timer = get_pwm_timer(pin);
if (timer.n == 0) return; // Don't proceed if protected timer or not recognized
// Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted)
_SET_COMnQ(timer.TCCRnQ, timer.q TERN_(HAS_TCCR2, + (timer.q == 2)), COM_CLEAR_SET + invert); // COM20 is on bit 4 of TCCR2, so +1 for q==2
const uint16_t top = timer.n == 2 ? TERN(USE_OCR2A_AS_TOP, *timer.OCRnQ[0], 255) : *timer.ICRn;
_SET_OCRnQ(timer.OCRnQ, timer.q, uint16_t(uint32_t(v) * top / v_size)); // Scale 8/16-bit v to top value
}
else
top = *timer.ICRn; // top = ICRn
_SET_OCRnQ(timer.OCRnQ, timer.q, v * float(top) / float(v_size)); // Scale 8/16-bit v to top value
}
#else
analogWrite(pin, v);
UNUSED(v_size);
UNUSED(invert);
#endif
}
#endif // NEEDS_HARDWARE_PWM
#endif // __AVR__

30
Marlin/src/HAL/AVR/fastio.h

@ -211,32 +211,32 @@ enum ClockSource2 : char {
// Set Clock Select bits
// Ex: SET_CS3(PRESCALER_64);
#ifdef TCCR2
#define HAS_TCCR2 1
#endif
#define _SET_CS(T,V) (TCCR##T##B = (TCCR##T##B & ~(0x7 << CS##T##0)) | ((int(V) & 0x7) << CS##T##0))
#define _SET_CS0(V) _SET_CS(0,V)
#define _SET_CS1(V) _SET_CS(1,V)
#ifdef TCCR2
#define _SET_CS2(V) (TCCR2 = (TCCR2 & ~(0x7 << CS20)) | (int(V) << CS20))
#else
#define _SET_CS2(V) _SET_CS(2,V)
#endif
#define _SET_CS3(V) _SET_CS(3,V)
#define _SET_CS4(V) _SET_CS(4,V)
#define _SET_CS5(V) _SET_CS(5,V)
#define SET_CS0(V) _SET_CS0(CS_##V)
#define SET_CS1(V) _SET_CS1(CS_##V)
#ifdef TCCR2
#if HAS_TCCR2
#define _SET_CS2(V) (TCCR2 = (TCCR2 & ~(0x7 << CS20)) | (int(V) << CS20))
#define SET_CS2(V) _SET_CS2(CS2_##V)
#else
#define _SET_CS2(V) _SET_CS(2,V)
#define SET_CS2(V) _SET_CS2(CS_##V)
#endif
#define SET_CS3(V) _SET_CS3(CS_##V)
#define SET_CS4(V) _SET_CS4(CS_##V)
#define SET_CS5(V) _SET_CS5(CS_##V)
#define SET_CS(T,V) SET_CS##T(V)
// Runtime (see set_pwm_frequency)
#define _SET_CSn(TCCRnQ, V) do{ \
(*(TCCRnQ)[1] = (*(TCCRnQ[1]) & ~(0x7 << 0)) | ((int(V) & 0x7) << 0)); \
}while(0)
#define _SET_CSn(TCCRnQ, V) (*(TCCRnQ)[1] = (*(TCCRnQ[1]) & ~(0x7 << 0)) | ((int(V) & 0x7) << 0))
// Set Compare Mode bits
// Ex: SET_COMS(4,CLEAR_SET,CLEAR_SET,CLEAR_SET);
@ -247,21 +247,15 @@ enum ClockSource2 : char {
#define SET_COMC(T,V) SET_COM(T,C,V)
#define SET_COMS(T,V1,V2,V3) do{ SET_COMA(T,V1); SET_COMB(T,V2); SET_COMC(T,V3); }while(0)
// Runtime (see set_pwm_duty)
#define _SET_COMnQ(TCCRnQ, Q, V) do{ \
(*(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << (6-2*(Q)))) | (int(V) << (6-2*(Q)))); \
}while(0)
#define _SET_COMnQ(TCCRnQ, Q, V) (*(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << (6-2*(Q)))) | (int(V) << (6-2*(Q))))
// Set OCRnQ register
// Runtime (see set_pwm_duty):
#define _SET_OCRnQ(OCRnQ, Q, V) do{ \
(*(OCRnQ)[(Q)] = (0x0000) | (int(V) & 0xFFFF)); \
}while(0)
#define _SET_OCRnQ(OCRnQ, Q, V) (*(OCRnQ)[Q] = int(V) & 0xFFFF)
// Set ICRn register (one per timer)
// Runtime (see set_pwm_frequency)
#define _SET_ICRn(ICRn, V) do{ \
(*(ICRn) = (0x0000) | (int(V) & 0xFFFF)); \
}while(0)
#define _SET_ICRn(ICRn, V) (*(ICRn) = int(V) & 0xFFFF)
// Set Noise Canceler bit
// Ex: SET_ICNC(2,1)

2
Marlin/src/HAL/AVR/inc/SanityCheck.h

@ -28,7 +28,7 @@
/**
* Checks for FAST PWM
*/
#if ENABLED(FAST_PWM_FAN) && (ENABLED(USE_OCR2A_AS_TOP) && defined(TCCR2))
#if ALL(FAST_PWM_FAN, USE_OCR2A_AS_TOP, HAS_TCCR2)
#error "USE_OCR2A_AS_TOP does not apply to devices with a single output TIMER2"
#endif

43
Marlin/src/HAL/AVR/pinsDebug.h

@ -102,7 +102,7 @@ void PRINT_ARRAY_NAME(uint8_t x) {
return true; \
} else return false
#define ABTEST(N) defined(TCCR##N##A) && defined(COM##N##A1)
/**
* Print a pin's PWM status.
@ -113,7 +113,7 @@ static bool pwm_status(uint8_t pin) {
switch (digitalPinToTimer_DEBUG(pin)) {
#if defined(TCCR0A) && defined(COM0A1)
#if ABTEST(0)
#ifdef TIMER0A
#if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
PWM_CASE(0, A);
@ -122,20 +122,20 @@ static bool pwm_status(uint8_t pin) {
PWM_CASE(0, B);
#endif
#if defined(TCCR1A) && defined(COM1A1)
#if ABTEST(1)
PWM_CASE(1, A);
PWM_CASE(1, B);
#if defined(COM1C1) && defined(TIMER1C)
PWM_CASE(1, C);
#endif
#if defined(COM1C1) && defined(TIMER1C)
PWM_CASE(1, C);
#endif
#endif
#if defined(TCCR2A) && defined(COM2A1)
#if ABTEST(2)
PWM_CASE(2, A);
PWM_CASE(2, B);
#endif
#if defined(TCCR3A) && defined(COM3A1)
#if ABTEST(3)
PWM_CASE(3, A);
PWM_CASE(3, B);
#ifdef COM3C1
@ -149,7 +149,7 @@ static bool pwm_status(uint8_t pin) {
PWM_CASE(4, C);
#endif
#if defined(TCCR5A) && defined(COM5A1)
#if ABTEST(5)
PWM_CASE(5, A);
PWM_CASE(5, B);
PWM_CASE(5, C);
@ -166,16 +166,16 @@ static bool pwm_status(uint8_t pin) {
const volatile uint8_t* const PWM_other[][3] PROGMEM = {
{ &TCCR0A, &TCCR0B, &TIMSK0 },
{ &TCCR1A, &TCCR1B, &TIMSK1 },
#if defined(TCCR2A) && defined(COM2A1)
#if ABTEST(2)
{ &TCCR2A, &TCCR2B, &TIMSK2 },
#endif
#if defined(TCCR3A) && defined(COM3A1)
#if ABTEST(3)
{ &TCCR3A, &TCCR3B, &TIMSK3 },
#endif
#ifdef TCCR4A
{ &TCCR4A, &TCCR4B, &TIMSK4 },
#endif
#if defined(TCCR5A) && defined(COM5A1)
#if ABTEST(5)
{ &TCCR5A, &TCCR5B, &TIMSK5 },
#endif
};
@ -195,11 +195,11 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
{ (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, 0 },
#endif
#if defined(TCCR2A) && defined(COM2A1)
#if ABTEST(2)
{ &OCR2A, &OCR2B, 0 },
#endif
#if defined(TCCR3A) && defined(COM3A1)
#if ABTEST(3)
#ifdef COM3C1
{ (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C },
#else
@ -211,7 +211,7 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
{ (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C },
#endif
#if defined(TCCR5A) && defined(COM5A1)
#if ABTEST(5)
{ (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C },
#endif
};
@ -281,7 +281,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
static void pwm_details(uint8_t pin) {
switch (digitalPinToTimer_DEBUG(pin)) {
#if defined(TCCR0A) && defined(COM0A1)
#if ABTEST(0)
#ifdef TIMER0A
#if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
case TIMER0A: timer_prefix(0, 'A', 3); break;
@ -290,7 +290,7 @@ static void pwm_details(uint8_t pin) {
case TIMER0B: timer_prefix(0, 'B', 3); break;
#endif
#if defined(TCCR1A) && defined(COM1A1)
#if ABTEST(1)
case TIMER1A: timer_prefix(1, 'A', 4); break;
case TIMER1B: timer_prefix(1, 'B', 4); break;
#if defined(COM1C1) && defined(TIMER1C)
@ -298,12 +298,12 @@ static void pwm_details(uint8_t pin) {
#endif
#endif
#if defined(TCCR2A) && defined(COM2A1)
#if ABTEST(2)
case TIMER2A: timer_prefix(2, 'A', 3); break;
case TIMER2B: timer_prefix(2, 'B', 3); break;
#endif
#if defined(TCCR3A) && defined(COM3A1)
#if ABTEST(3)
case TIMER3A: timer_prefix(3, 'A', 4); break;
case TIMER3B: timer_prefix(3, 'B', 4); break;
#ifdef COM3C1
@ -317,7 +317,7 @@ static void pwm_details(uint8_t pin) {
case TIMER4C: timer_prefix(4, 'C', 4); break;
#endif
#if defined(TCCR5A) && defined(COM5A1)
#if ABTEST(5)
case TIMER5A: timer_prefix(5, 'A', 4); break;
case TIMER5B: timer_prefix(5, 'B', 4); break;
case TIMER5C: timer_prefix(5, 'C', 4); break;
@ -351,7 +351,6 @@ static void pwm_details(uint8_t pin) {
#endif
} // pwm_details
#ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs
int digitalRead_mod(const int8_t pin) { // same as digitalRead except the PWM stop section has been removed
const uint8_t port = digitalPinToPort_DEBUG(pin);
@ -397,3 +396,5 @@ static void pwm_details(uint8_t pin) {
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#undef ABTEST

20
Marlin/src/HAL/AVR/timers.h

@ -34,14 +34,14 @@ typedef uint16_t hal_timer_t;
#define HAL_TIMER_RATE ((F_CPU) / 8) // i.e., 2MHz or 2.5MHz
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 1
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 1
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 0
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 0
#endif
#define TEMP_TIMER_FREQUENCY ((F_CPU) / 64.0 / 256.0)
@ -64,7 +64,7 @@ typedef uint16_t hal_timer_t;
FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
switch (timer_num) {
case STEP_TIMER_NUM:
case MF_TIMER_STEP:
// waveform generation = 0100 = CTC
SET_WGM(1, CTC_OCRnA);
@ -84,7 +84,7 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
TCNT1 = 0;
break;
case TEMP_TIMER_NUM:
case MF_TIMER_TEMP:
// Use timer0 for temperature measurement
// Interleave temperature interrupt with millies interrupt
OCR0B = 128;
@ -109,8 +109,8 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
* (otherwise, characters will be lost due to UART overflow).
* Then: Stepper, Endstops, Temperature, and -finally- all others.
*/
#define HAL_timer_isr_prologue(TIMER_NUM)
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_prologue(T)
#define HAL_timer_isr_epilogue(T)
/* 18 cycles maximum latency */
#ifndef HAL_STEP_TIMER_ISR

11
Marlin/src/HAL/DUE/HAL.h

@ -144,6 +144,11 @@ inline void HAL_adc_init() {}//todo
void HAL_adc_start_conversion(const uint8_t ch);
uint16_t HAL_adc_get_result();
//
// PWM
//
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
//
// Pin Map
//
@ -168,16 +173,14 @@ void HAL_init();
//
void _delay_ms(const int delay);
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#pragma GCC diagnostic pop
#ifdef __cplusplus
extern "C" {

6
Marlin/src/HAL/DUE/Tone.cpp

@ -38,17 +38,17 @@ volatile static int32_t toggles;
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) {
tone_pin = _pin;
toggles = 2 * frequency * duration / 1000;
HAL_timer_start(TONE_TIMER_NUM, 2 * frequency);
HAL_timer_start(MF_TIMER_TONE, 2 * frequency);
}
void noTone(const pin_t _pin) {
HAL_timer_disable_interrupt(TONE_TIMER_NUM);
HAL_timer_disable_interrupt(MF_TIMER_TONE);
extDigitalWrite(_pin, LOW);
}
HAL_TONE_TIMER_ISR() {
static uint8_t pin_state = 0;
HAL_timer_isr_prologue(TONE_TIMER_NUM);
HAL_timer_isr_prologue(MF_TIMER_TONE);
if (toggles) {
toggles--;

4
Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(U8GLIB_ST7920)
#if IS_U8GLIB_ST7920
#include "../../../inc/MarlinConfig.h"
#include "../../shared/Delay.h"
@ -182,5 +182,5 @@ uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
}
#endif // LIGHTWEIGHT_UI
#endif // U8GLIB_ST7920
#endif // IS_U8GLIB_ST7920
#endif // ARDUINO_ARCH_SAM

4
Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#include "u8g_com_HAL_DUE_sw_spi_shared.h"
@ -141,5 +141,5 @@ uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
return 1;
}
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#endif // ARDUINO_ARCH_SAM

16
Marlin/src/HAL/DUE/timers.cpp

@ -42,7 +42,7 @@
// Private Variables
// ------------------------
const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = {
{ TC0, 0, TC0_IRQn, 3}, // 0 - [servo timer5]
{ TC0, 1, TC1_IRQn, 0}, // 1
{ TC0, 2, TC2_IRQn, 2}, // 2 - stepper
@ -66,9 +66,9 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
*/
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
Tc *tc = TimerConfig[timer_num].pTimerRegs;
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
uint32_t channel = TimerConfig[timer_num].channel;
Tc *tc = timer_config[timer_num].pTimerRegs;
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
uint32_t channel = timer_config[timer_num].channel;
// Disable interrupt, just in case it was already enabled
NVIC_DisableIRQ(irq);
@ -86,7 +86,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
pmc_set_writeprotect(false);
pmc_enable_periph_clk((uint32_t)irq);
NVIC_SetPriority(irq, TimerConfig [timer_num].priority);
NVIC_SetPriority(irq, timer_config[timer_num].priority);
// wave mode, reset counter on match with RC,
TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK1);
@ -105,12 +105,12 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
}
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
NVIC_EnableIRQ(irq);
}
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
NVIC_DisableIRQ(irq);
// We NEED memory barriers to ensure Interrupts are actually disabled!
@ -125,7 +125,7 @@ static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
}
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
return NVIC_GetEnabledIRQ(irq);
}

50
Marlin/src/HAL/DUE/timers.h

@ -37,35 +37,35 @@ typedef uint32_t hal_timer_t;
#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 2 // Timer Index for Stepper
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 2 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 4 // Timer Index for Temperature
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 4 // Timer Index for Temperature
#endif
#ifndef TONE_TIMER_NUM
#define TONE_TIMER_NUM 6 // index of timer to use for beeper tones
#ifndef MF_TIMER_TONE
#define MF_TIMER_TONE 6 // index of timer to use for beeper tones
#endif
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per ยตs
#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US)
#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per ยตs
#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US)
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() void TC2_Handler()
@ -92,7 +92,7 @@ typedef struct {
// Public Variables
// ------------------------
extern const tTimerConfig TimerConfig[];
extern const tTimerConfig timer_config[];
// ------------------------
// Public functions
@ -101,17 +101,17 @@ extern const tTimerConfig TimerConfig[];
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
const tTimerConfig * const pConfig = &TimerConfig[timer_num];
const tTimerConfig * const pConfig = &timer_config[timer_num];
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = compare;
}
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
const tTimerConfig * const pConfig = &TimerConfig[timer_num];
const tTimerConfig * const pConfig = &timer_config[timer_num];
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
}
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
const tTimerConfig * const pConfig = &TimerConfig[timer_num];
const tTimerConfig * const pConfig = &timer_config[timer_num];
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
}
@ -120,9 +120,9 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
const tTimerConfig * const pConfig = &TimerConfig[timer_num];
const tTimerConfig * const pConfig = &timer_config[timer_num];
// Reading the status register clears the interrupt flag
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR;
}
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_epilogue(T)

19
Marlin/src/HAL/DUE/upload_extra_script.py

@ -4,15 +4,16 @@
# Windows: bossac.exe
# Other: leave unchanged
#
import pioutil
if pioutil.is_pio_build():
import platform
current_OS = platform.system()
import platform
current_OS = platform.system()
if current_OS == 'Windows':
if current_OS == 'Windows':
Import("env")
Import("env")
# Use bossac.exe on Windows
env.Replace(
UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE"
)
# Use bossac.exe on Windows
env.Replace(
UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE"
)

6
Marlin/src/HAL/ESP32/HAL.cpp

@ -276,7 +276,7 @@ void analogWrite(pin_t pin, int value) {
idx = numPWMUsed;
pwmPins[idx] = pin;
// Start timer on first use
if (idx == 0) HAL_timer_start(PWM_TIMER_NUM, PWM_TIMER_FREQUENCY);
if (idx == 0) HAL_timer_start(MF_TIMER_PWM, PWM_TIMER_FREQUENCY);
++numPWMUsed;
}
@ -287,7 +287,7 @@ void analogWrite(pin_t pin, int value) {
// Handle PWM timer interrupt
HAL_PWM_TIMER_ISR() {
HAL_timer_isr_prologue(PWM_TIMER_NUM);
HAL_timer_isr_prologue(MF_TIMER_PWM);
static uint8_t count = 0;
@ -301,7 +301,7 @@ HAL_PWM_TIMER_ISR() {
// 128 for 7 Bit resolution
count = (count + 1) & 0x7F;
HAL_timer_isr_epilogue(PWM_TIMER_NUM);
HAL_timer_isr_epilogue(MF_TIMER_PWM);
}
#endif // ARDUINO_ARCH_ESP32

10
Marlin/src/HAL/ESP32/HAL.h

@ -105,16 +105,14 @@ void HAL_reboot();
void _delay_ms(int delay);
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#pragma GCC diagnostic pop
void analogWrite(pin_t pin, int value);
@ -131,6 +129,10 @@ void HAL_adc_init();
void HAL_adc_start_conversion(const uint8_t adc_pin);
// PWM
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
// Pin Map
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)

6
Marlin/src/HAL/ESP32/Tone.cpp

@ -38,16 +38,16 @@ volatile static int32_t toggles;
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) {
tone_pin = _pin;
toggles = 2 * frequency * duration / 1000;
HAL_timer_start(TONE_TIMER_NUM, 2 * frequency);
HAL_timer_start(MF_TIMER_TONE, 2 * frequency);
}
void noTone(const pin_t _pin) {
HAL_timer_disable_interrupt(TONE_TIMER_NUM);
HAL_timer_disable_interrupt(MF_TIMER_TONE);
WRITE(_pin, LOW);
}
HAL_TONE_TIMER_ISR() {
HAL_timer_isr_prologue(TONE_TIMER_NUM);
HAL_timer_isr_prologue(MF_TIMER_TONE);
if (toggles) {
toggles--;

30
Marlin/src/HAL/ESP32/i2s.cpp

@ -64,12 +64,9 @@ uint32_t i2s_port_data = 0;
#define I2S_EXIT_CRITICAL() portEXIT_CRITICAL(&i2s_spinlock[i2s_num])
static inline void gpio_matrix_out_check(uint32_t gpio, uint32_t signal_idx, bool out_inv, bool oen_inv) {
//if pin = -1, do not need to configure
if (gpio != -1) {
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpio], PIN_FUNC_GPIO);
gpio_set_direction((gpio_num_t)gpio, (gpio_mode_t)GPIO_MODE_DEF_OUTPUT);
gpio_matrix_out(gpio, signal_idx, out_inv, oen_inv);
}
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpio], PIN_FUNC_GPIO);
gpio_set_direction((gpio_num_t)gpio, (gpio_mode_t)GPIO_MODE_DEF_OUTPUT);
gpio_matrix_out(gpio, signal_idx, out_inv, oen_inv);
}
static esp_err_t i2s_reset_fifo(i2s_port_t i2s_num) {
@ -256,13 +253,7 @@ int i2s_init() {
I2S0.fifo_conf.dscr_en = 0;
I2S0.conf_chan.tx_chan_mod = (
#if ENABLED(I2S_STEPPER_SPLIT_STREAM)
4
#else
0
#endif
);
I2S0.conf_chan.tx_chan_mod = TERN(I2S_STEPPER_SPLIT_STREAM, 4, 0);
I2S0.fifo_conf.tx_fifo_mod = 0;
I2S0.conf.tx_mono = 0;
@ -313,9 +304,16 @@ int i2s_init() {
xTaskCreatePinnedToCore(stepperTask, "StepperTask", 10000, nullptr, 1, nullptr, CONFIG_ARDUINO_RUNNING_CORE); // run I2S stepper task on same core as rest of Marlin
// Route the i2s pins to the appropriate GPIO
gpio_matrix_out_check(I2S_DATA, I2S0O_DATA_OUT23_IDX, 0, 0);
gpio_matrix_out_check(I2S_BCK, I2S0O_BCK_OUT_IDX, 0, 0);
gpio_matrix_out_check(I2S_WS, I2S0O_WS_OUT_IDX, 0, 0);
// If a pin is not defined, no need to configure
#if defined(I2S_DATA) && I2S_DATA >= 0
gpio_matrix_out_check(I2S_DATA, I2S0O_DATA_OUT23_IDX, 0, 0);
#endif
#if defined(I2S_BCK) && I2S_BCK >= 0
gpio_matrix_out_check(I2S_BCK, I2S0O_BCK_OUT_IDX, 0, 0);
#endif
#if defined(I2S_WS) && I2S_WS >= 0
gpio_matrix_out_check(I2S_WS, I2S0O_WS_OUT_IDX, 0, 0);
#endif
// Start the I2S peripheral
return i2s_start(I2S_NUM_0);

18
Marlin/src/HAL/ESP32/timers.cpp

@ -41,7 +41,7 @@
static timg_dev_t *TG[2] = {&TIMERG0, &TIMERG1};
const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = {
{ TIMER_GROUP_0, TIMER_0, STEPPER_TIMER_PRESCALE, stepTC_Handler }, // 0 - Stepper
{ TIMER_GROUP_0, TIMER_1, TEMP_TIMER_PRESCALE, tempTC_Handler }, // 1 - Temperature
{ TIMER_GROUP_1, TIMER_0, PWM_TIMER_PRESCALE, pwmTC_Handler }, // 2 - PWM
@ -53,7 +53,7 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
// ------------------------
void IRAM_ATTR timer_isr(void *para) {
const tTimerConfig& timer = TimerConfig[(int)para];
const tTimerConfig& timer = timer_config[(int)para];
// Retrieve the interrupt status and the counter value
// from the timer that reported the interrupt
@ -82,7 +82,7 @@ void IRAM_ATTR timer_isr(void *para) {
* @param frequency frequency of the timer
*/
void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) {
const tTimerConfig timer = TimerConfig[timer_num];
const tTimerConfig timer = timer_config[timer_num];
timer_config_t config;
config.divider = timer.divider;
@ -115,7 +115,7 @@ void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) {
* @param count threshold at which the interrupt is triggered
*/
void HAL_timer_set_compare(const uint8_t timer_num, hal_timer_t count) {
const tTimerConfig timer = TimerConfig[timer_num];
const tTimerConfig timer = timer_config[timer_num];
timer_set_alarm_value(timer.group, timer.idx, count);
}
@ -125,7 +125,7 @@ void HAL_timer_set_compare(const uint8_t timer_num, hal_timer_t count) {
* @return the timer current threshold for the alarm to be triggered
*/
hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
const tTimerConfig timer = TimerConfig[timer_num];
const tTimerConfig timer = timer_config[timer_num];
uint64_t alarm_value;
timer_get_alarm_value(timer.group, timer.idx, &alarm_value);
@ -139,7 +139,7 @@ hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
* @return the current counter of the alarm
*/
hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
const tTimerConfig timer = TimerConfig[timer_num];
const tTimerConfig timer = timer_config[timer_num];
uint64_t counter_value;
timer_get_counter_value(timer.group, timer.idx, &counter_value);
return counter_value;
@ -150,7 +150,7 @@ hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
* @param timer_num timer number to enable interrupts on
*/
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
//const tTimerConfig timer = TimerConfig[timer_num];
//const tTimerConfig timer = timer_config[timer_num];
//timer_enable_intr(timer.group, timer.idx);
}
@ -159,12 +159,12 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num) {
* @param timer_num timer number to disable interrupts on
*/
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
//const tTimerConfig timer = TimerConfig[timer_num];
//const tTimerConfig timer = timer_config[timer_num];
//timer_disable_intr(timer.group, timer.idx);
}
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
const tTimerConfig timer = TimerConfig[timer_num];
const tTimerConfig timer = timer_config[timer_num];
return TG[timer.group]->int_ena.val | BIT(timer_num);
}

36
Marlin/src/HAL/ESP32/timers.h

@ -32,20 +32,20 @@
typedef uint64_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFFFFFFFFFFULL
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
#endif
#ifndef PWM_TIMER_NUM
#define PWM_TIMER_NUM 2 // index of timer to use for PWM outputs
#ifndef MF_TIMER_PWM
#define MF_TIMER_PWM 2 // index of timer to use for PWM outputs
#endif
#ifndef TONE_TIMER_NUM
#define TONE_TIMER_NUM 3 // index of timer for beeper tones
#ifndef MF_TIMER_TONE
#define MF_TIMER_TONE 3 // index of timer for beeper tones
#endif
#define HAL_TIMER_RATE APB_CLK_FREQ // frequency of timer peripherals
@ -79,12 +79,12 @@ typedef uint64_t hal_timer_t;
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#ifndef HAL_TEMP_TIMER_ISR
#define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler()
@ -121,7 +121,7 @@ typedef struct {
// Public Variables
// ------------------------
extern const tTimerConfig TimerConfig[];
extern const tTimerConfig timer_config[];
// ------------------------
// Public functions
@ -136,5 +136,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
void HAL_timer_disable_interrupt(const uint8_t timer_num);
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
#define HAL_timer_isr_prologue(TIMER_NUM)
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_prologue(T)
#define HAL_timer_isr_epilogue(T)

9
Marlin/src/HAL/LINUX/HAL.h

@ -79,16 +79,14 @@ extern MSerialT usb_serial;
inline void HAL_init() {}
// Utility functions
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#pragma GCC diagnostic pop
// ADC
#define HAL_ADC_VREF 5.0
@ -103,6 +101,9 @@ void HAL_adc_enable_channel(const uint8_t ch);
void HAL_adc_start_conversion(const uint8_t ch);
uint16_t HAL_adc_get_result();
// PWM
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
// Reset source
inline void HAL_clear_reset_source(void) {}
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }

27
Marlin/src/HAL/LINUX/timers.h

@ -37,14 +37,14 @@ typedef uint32_t hal_timer_t;
#define HAL_TIMER_RATE ((SystemCoreClock) / 4) // frequency of timers peripherals
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
#endif
#define TEMP_TIMER_RATE 1000000
@ -58,12 +58,12 @@ typedef uint32_t hal_timer_t;
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() extern "C" void TIMER0_IRQHandler()
@ -77,7 +77,6 @@ typedef uint32_t hal_timer_t;
#define HAL_PWM_TIMER_ISR() extern "C" void TIMER3_IRQHandler()
#define HAL_PWM_TIMER_IRQn
void HAL_timer_init();
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
@ -93,5 +92,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
void HAL_timer_disable_interrupt(const uint8_t timer_num);
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
#define HAL_timer_isr_prologue(TIMER_NUM)
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_prologue(T)
#define HAL_timer_isr_epilogue(T)

6
Marlin/src/HAL/LPC1768/HAL.h

@ -123,16 +123,14 @@ extern DefaultSerial1 USBSerial;
//
// Utility functions
//
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#pragma GCC diagnostic pop
//
// ADC API

8
Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp

@ -90,15 +90,15 @@ bool PersistentStore::access_finish() {
// to see errors that are happening in read_data / write_data
static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
#if ENABLED(DEBUG_SD_EEPROM_EMULATION)
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
FSTR_P const rw_str = write ? F("write") : F("read");
SERIAL_CHAR(' ');
SERIAL_ECHOPGM_P(rw_str);
SERIAL_ECHOF(rw_str);
SERIAL_ECHOLNPGM("_data(", pos, ",", *value, ",", size, ", ...)");
if (total) {
SERIAL_ECHOPGM(" f_");
SERIAL_ECHOPGM_P(rw_str);
SERIAL_ECHOF(rw_str);
SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
SERIAL_ECHOLNF(write ? F("written=") : F("read="), total);
}
else
SERIAL_ECHOLNPGM(" f_lseek()=", s);

20
Marlin/src/HAL/LPC1768/fast_pwm.cpp

@ -22,18 +22,20 @@
#ifdef TARGET_LPC1768
#include "../../inc/MarlinConfigPre.h"
#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM
#include <pwm.h>
void set_pwm_frequency(const pin_t pin, int f_desired) {
LPC176x::pwm_set_frequency(pin, f_desired);
}
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size);
if (!LPC176x::pin_is_valid(pin)) return;
if (LPC176x::pwm_attach_pin(pin))
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
}
#endif // NEEDS_HARDWARE_PWM
#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM
void set_pwm_frequency(const pin_t pin, int f_desired) {
LPC176x::pwm_set_frequency(pin, f_desired);
}
#endif
#endif // TARGET_LPC1768

4
Marlin/src/HAL/LPC1768/timers.cpp

@ -40,7 +40,7 @@ void HAL_timer_init() {
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
switch (timer_num) {
case 0:
case MF_TIMER_STEP:
LPC_TIM0->MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them
LPC_TIM0->MR0 = uint32_t(STEPPER_TIMER_RATE) / frequency; // Match value (period) to set frequency
LPC_TIM0->TCR = _BV(SBIT_CNTEN); // Counter Enable
@ -49,7 +49,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
NVIC_EnableIRQ(TIMER0_IRQn);
break;
case 1:
case MF_TIMER_TEMP:
LPC_TIM1->MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them
LPC_TIM1->MR0 = uint32_t(TEMP_TIMER_RATE) / frequency;
LPC_TIM1->TCR = _BV(SBIT_CNTEN); // Counter Enable

64
Marlin/src/HAL/LPC1768/timers.h

@ -60,17 +60,17 @@ typedef uint32_t hal_timer_t;
#define HAL_TIMER_RATE ((F_CPU) / 4) // frequency of timers peripherals
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
#endif
#ifndef PWM_TIMER_NUM
#define PWM_TIMER_NUM 3 // Timer Index for PWM
#ifndef MF_TIMER_PWM
#define MF_TIMER_PWM 3 // Timer Index for PWM
#endif
#define TEMP_TIMER_RATE 1000000
@ -84,23 +84,23 @@ typedef uint32_t hal_timer_t;
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() _HAL_TIMER_ISR(STEP_TIMER_NUM)
#define HAL_STEP_TIMER_ISR() _HAL_TIMER_ISR(MF_TIMER_STEP)
#endif
#ifndef HAL_TEMP_TIMER_ISR
#define HAL_TEMP_TIMER_ISR() _HAL_TIMER_ISR(TEMP_TIMER_NUM)
#define HAL_TEMP_TIMER_ISR() _HAL_TIMER_ISR(MF_TIMER_TEMP)
#endif
// Timer references by index
#define STEP_TIMER_PTR _HAL_TIMER(STEP_TIMER_NUM)
#define TEMP_TIMER_PTR _HAL_TIMER(TEMP_TIMER_NUM)
#define STEP_TIMER_PTR _HAL_TIMER(MF_TIMER_STEP)
#define TEMP_TIMER_PTR _HAL_TIMER(MF_TIMER_TEMP)
// ------------------------
// Public functions
@ -110,38 +110,38 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
switch (timer_num) {
case 0: STEP_TIMER_PTR->MR0 = compare; break; // Stepper Timer Match Register 0
case 1: TEMP_TIMER_PTR->MR0 = compare; break; // Temp Timer Match Register 0
case MF_TIMER_STEP: STEP_TIMER_PTR->MR0 = compare; break; // Stepper Timer Match Register 0
case MF_TIMER_TEMP: TEMP_TIMER_PTR->MR0 = compare; break; // Temp Timer Match Register 0
}
}
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
switch (timer_num) {
case 0: return STEP_TIMER_PTR->MR0; // Stepper Timer Match Register 0
case 1: return TEMP_TIMER_PTR->MR0; // Temp Timer Match Register 0
case MF_TIMER_STEP: return STEP_TIMER_PTR->MR0; // Stepper Timer Match Register 0
case MF_TIMER_TEMP: return TEMP_TIMER_PTR->MR0; // Temp Timer Match Register 0
}
return 0;
}
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
switch (timer_num) {
case 0: return STEP_TIMER_PTR->TC; // Stepper Timer Count
case 1: return TEMP_TIMER_PTR->TC; // Temp Timer Count
case MF_TIMER_STEP: return STEP_TIMER_PTR->TC; // Stepper Timer Count
case MF_TIMER_TEMP: return TEMP_TIMER_PTR->TC; // Temp Timer Count
}
return 0;
}
FORCE_INLINE static void HAL_timer_enable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case 0: NVIC_EnableIRQ(TIMER0_IRQn); break; // Enable interrupt handler
case 1: NVIC_EnableIRQ(TIMER1_IRQn); break; // Enable interrupt handler
case MF_TIMER_STEP: NVIC_EnableIRQ(TIMER0_IRQn); break; // Enable interrupt handler
case MF_TIMER_TEMP: NVIC_EnableIRQ(TIMER1_IRQn); break; // Enable interrupt handler
}
}
FORCE_INLINE static void HAL_timer_disable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case 0: NVIC_DisableIRQ(TIMER0_IRQn); break; // Disable interrupt handler
case 1: NVIC_DisableIRQ(TIMER1_IRQn); break; // Disable interrupt handler
case MF_TIMER_STEP: NVIC_DisableIRQ(TIMER0_IRQn); break; // Disable interrupt handler
case MF_TIMER_TEMP: NVIC_DisableIRQ(TIMER1_IRQn); break; // Disable interrupt handler
}
// We NEED memory barriers to ensure Interrupts are actually disabled!
@ -157,17 +157,17 @@ FORCE_INLINE static bool NVIC_GetEnableIRQ(IRQn_Type IRQn) {
FORCE_INLINE static bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
switch (timer_num) {
case 0: return NVIC_GetEnableIRQ(TIMER0_IRQn); // Check if interrupt is enabled or not
case 1: return NVIC_GetEnableIRQ(TIMER1_IRQn); // Check if interrupt is enabled or not
case MF_TIMER_STEP: return NVIC_GetEnableIRQ(TIMER0_IRQn); // Check if interrupt is enabled or not
case MF_TIMER_TEMP: return NVIC_GetEnableIRQ(TIMER1_IRQn); // Check if interrupt is enabled or not
}
return false;
}
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
switch (timer_num) {
case 0: SBI(STEP_TIMER_PTR->IR, SBIT_CNTEN); break;
case 1: SBI(TEMP_TIMER_PTR->IR, SBIT_CNTEN); break;
case MF_TIMER_STEP: SBI(STEP_TIMER_PTR->IR, SBIT_CNTEN); break;
case MF_TIMER_TEMP: SBI(TEMP_TIMER_PTR->IR, SBIT_CNTEN); break;
}
}
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_epilogue(T)

4
Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(U8GLIB_ST7920)
#if IS_U8GLIB_ST7920
#include <U8glib-HAL.h>
#include <SoftwareSPI.h>
@ -143,5 +143,5 @@ uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t ar
return 1;
}
#endif // U8GLIB_ST7920
#endif // IS_U8GLIB_ST7920
#endif // TARGET_LPC1768

4
Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#include <SoftwareSPI.h>
#include "../../shared/HAL_SPI.h"
@ -205,5 +205,5 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
return 1;
}
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#endif // TARGET_LPC1768

198
Marlin/src/HAL/LPC1768/upload_extra_script.py

@ -1,123 +1,127 @@
#
# sets output_port
# upload_extra_script.py
# set the output_port
# if target_filename is found then that drive is used
# else if target_drive is found then that drive is used
#
from __future__ import print_function
target_filename = "FIRMWARE.CUR"
target_drive = "REARM"
import pioutil
if pioutil.is_pio_build():
import os,getpass,platform
target_filename = "FIRMWARE.CUR"
target_drive = "REARM"
current_OS = platform.system()
Import("env")
import os,getpass,platform
def print_error(e):
print('\nUnable to find destination disk (%s)\n' \
'Please select it in platformio.ini using the upload_port keyword ' \
'(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \
'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \
%(e, env.get('PIOENV')))
current_OS = platform.system()
Import("env")
def before_upload(source, target, env):
try:
#
# Find a disk for upload
#
upload_disk = 'Disk not found'
target_file_found = False
target_drive_found = False
if current_OS == 'Windows':
def print_error(e):
print('\nUnable to find destination disk (%s)\n' \
'Please select it in platformio.ini using the upload_port keyword ' \
'(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \
'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \
%(e, env.get('PIOENV')))
def before_upload(source, target, env):
try:
#
# Find a disk for upload
#
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
# Windows - doesn't care about the disk's name, only cares about the drive letter
import subprocess,string
from ctypes import windll
upload_disk = 'Disk not found'
target_file_found = False
target_drive_found = False
if current_OS == 'Windows':
#
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
# Windows - doesn't care about the disk's name, only cares about the drive letter
import subprocess,string
from ctypes import windll
# getting list of drives
# https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
drives = []
bitmask = windll.kernel32.GetLogicalDrives()
for letter in string.ascii_uppercase:
if bitmask & 1:
drives.append(letter)
bitmask >>= 1
# getting list of drives
# https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
drives = []
bitmask = windll.kernel32.GetLogicalDrives()
for letter in string.ascii_uppercase:
if bitmask & 1:
drives.append(letter)
bitmask >>= 1
for drive in drives:
final_drive_name = drive + ':\\'
# print ('disc check: {}'.format(final_drive_name))
try:
volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT))
except Exception as e:
print ('error:{}'.format(e))
continue
else:
if target_drive in volume_info and not target_file_found: # set upload if not found target file yet
target_drive_found = True
upload_disk = final_drive_name
if target_filename in volume_info:
if not target_file_found:
for drive in drives:
final_drive_name = drive + ':\\'
# print ('disc check: {}'.format(final_drive_name))
try:
volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT))
except Exception as e:
print ('error:{}'.format(e))
continue
else:
if target_drive in volume_info and not target_file_found: # set upload if not found target file yet
target_drive_found = True
upload_disk = final_drive_name
target_file_found = True
if target_filename in volume_info:
if not target_file_found:
upload_disk = final_drive_name
target_file_found = True
elif current_OS == 'Linux':
#
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
#
drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser()))
if target_drive in drives: # If target drive is found, use it.
target_drive_found = True
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep
else:
elif current_OS == 'Linux':
#
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
#
drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser()))
if target_drive in drives: # If target drive is found, use it.
target_drive_found = True
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep
else:
for drive in drives:
try:
files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive))
except:
continue
else:
if target_filename in files:
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep
target_file_found = True
break
#
# set upload_port to drive if found
#
if target_file_found or target_drive_found:
env.Replace(
UPLOAD_FLAGS="-P$UPLOAD_PORT"
)
elif current_OS == 'Darwin': # MAC
#
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
#
drives = os.listdir('/Volumes') # human readable names
if target_drive in drives and not target_file_found: # set upload if not found target file yet
target_drive_found = True
upload_disk = '/Volumes/' + target_drive + '/'
for drive in drives:
try:
files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive))
filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected
except:
continue
else:
if target_filename in files:
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep
if target_filename in filenames:
if not target_file_found:
upload_disk = '/Volumes/' + drive + '/'
target_file_found = True
break
#
# set upload_port to drive if found
#
if target_file_found or target_drive_found:
env.Replace(
UPLOAD_FLAGS="-P$UPLOAD_PORT"
)
elif current_OS == 'Darwin': # MAC
#
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
# Set upload_port to drive if found
#
drives = os.listdir('/Volumes') # human readable names
if target_drive in drives and not target_file_found: # set upload if not found target file yet
target_drive_found = True
upload_disk = '/Volumes/' + target_drive + '/'
for drive in drives:
try:
filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected
except:
continue
else:
if target_filename in filenames:
if not target_file_found:
upload_disk = '/Volumes/' + drive + '/'
target_file_found = True
#
# Set upload_port to drive if found
#
if target_file_found or target_drive_found:
env.Replace(UPLOAD_PORT=upload_disk)
print('\nUpload disk: ', upload_disk, '\n')
else:
print_error('Autodetect Error')
if target_file_found or target_drive_found:
env.Replace(UPLOAD_PORT=upload_disk)
print('\nUpload disk: ', upload_disk, '\n')
else:
print_error('Autodetect Error')
except Exception as e:
print_error(str(e))
except Exception as e:
print_error(str(e))
env.AddPreAction("upload", before_upload)
env.AddPreAction("upload", before_upload)

5
Marlin/src/HAL/NATIVE_SIM/HAL.h

@ -133,10 +133,15 @@ void HAL_adc_enable_channel(const uint8_t ch);
void HAL_adc_start_conversion(const uint8_t ch);
uint16_t HAL_adc_get_result();
// PWM
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
// Reset source
inline void HAL_clear_reset_source(void) {}
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
void HAL_reboot();
/* ---------------- Delay in cycles */
#define DELAY_CYCLES(x) Kernel::delayCycles(x)

30
Marlin/src/HAL/NATIVE_SIM/timers.h

@ -37,17 +37,17 @@ typedef uint64_t hal_timer_t;
#define HAL_TIMER_RATE ((SystemCoreClock) / 4) // frequency of timers peripherals
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
#endif
#ifndef SYSTICK_TIMER_NUM
#define SYSTICK_TIMER_NUM 2 // Timer Index for Systick
#ifndef MF_TIMER_SYSTICK
#define MF_TIMER_SYSTICK 2 // Timer Index for Systick
#endif
#define SYSTICK_TIMER_FREQUENCY 1000
@ -62,12 +62,12 @@ typedef uint64_t hal_timer_t;
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() extern "C" void TIMER0_IRQHandler()
@ -87,5 +87,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
void HAL_timer_disable_interrupt(const uint8_t timer_num);
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
#define HAL_timer_isr_prologue(TIMER_NUM)
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_prologue(T)
#define HAL_timer_isr_epilogue(T)

4
Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfig.h"
#if ENABLED(U8GLIB_ST7920)
#if IS_U8GLIB_ST7920
#include <U8glib-HAL.h>
#include "../../shared/Delay.h"
@ -167,5 +167,5 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
}
#endif
#endif // U8GLIB_ST7920
#endif // IS_U8GLIB_ST7920
#endif // TARGET_LPC1768

9
Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfig.h"
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#undef SPI_SPEED
#define SPI_SPEED 2 // About 2 MHz
@ -208,8 +208,11 @@ uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_pt
}
#endif
#elif !ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI, HAS_MARLINUI_HD44780) && HAS_MARLINUI_U8GLIB
#elif NONE(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI, HAS_MARLINUI_HD44780) && HAS_MARLINUI_U8GLIB
#include <U8glib-HAL.h>
uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {return 0;}
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#endif // __PLAT_NATIVE_SIM__

11
Marlin/src/HAL/SAMD51/HAL.h

@ -127,6 +127,11 @@ void HAL_adc_init();
void HAL_adc_start_conversion(const uint8_t adc_pin);
//
// PWM
//
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
//
// Pin Map
//
@ -153,16 +158,14 @@ void HAL_idletask();
//
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#pragma GCC diagnostic pop
#ifdef __cplusplus
extern "C" {

8
Marlin/src/HAL/SAMD51/Servo.cpp

@ -53,7 +53,7 @@
static volatile int8_t currentServoIndex[_Nbr_16timers]; // index for the servo being pulsed for each timer (or -1 if refresh interval)
FORCE_INLINE static uint16_t getTimerCount() {
Tc * const tc = TimerConfig[SERVO_TC].pTc;
Tc * const tc = timer_config[SERVO_TC].pTc;
tc->COUNT16.CTRLBSET.reg = TC_CTRLBCLR_CMD_READSYNC;
SYNC(tc->COUNT16.SYNCBUSY.bit.CTRLB || tc->COUNT16.SYNCBUSY.bit.COUNT);
@ -65,7 +65,7 @@ FORCE_INLINE static uint16_t getTimerCount() {
// Interrupt handler for the TC
// ----------------------------
HAL_SERVO_TIMER_ISR() {
Tc * const tc = TimerConfig[SERVO_TC].pTc;
Tc * const tc = timer_config[SERVO_TC].pTc;
const timer16_Sequence_t timer =
#ifndef _useTimer1
_timer2
@ -125,7 +125,7 @@ HAL_SERVO_TIMER_ISR() {
}
void initISR(timer16_Sequence_t timer) {
Tc * const tc = TimerConfig[SERVO_TC].pTc;
Tc * const tc = timer_config[SERVO_TC].pTc;
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
static bool initialized = false; // Servo TC has been initialized
@ -202,7 +202,7 @@ void initISR(timer16_Sequence_t timer) {
}
void finISR(timer16_Sequence_t timer) {
Tc * const tc = TimerConfig[SERVO_TC].pTc;
Tc * const tc = timer_config[SERVO_TC].pTc;
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
// Disable the match channel interrupt request

2
Marlin/src/HAL/SAMD51/inc/SanityCheck.h

@ -36,7 +36,7 @@
#error "OnBoard SPI BUS can't be shared with other devices."
#endif
#if SERVO_TC == RTC_TIMER_NUM
#if SERVO_TC == MF_TIMER_RTC
#error "Servos can't use RTC timer"
#endif

20
Marlin/src/HAL/SAMD51/timers.cpp

@ -31,13 +31,13 @@
// Local defines
// --------------------------------------------------------------------------
#define NUM_HARDWARE_TIMERS 8
#define NUM_HARDWARE_TIMERS 9
// --------------------------------------------------------------------------
// Private Variables
// --------------------------------------------------------------------------
const tTimerConfig TimerConfig[NUM_HARDWARE_TIMERS+1] = {
const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = {
{ {.pTc=TC0}, TC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2)
{ {.pTc=TC1}, TC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers)
{ {.pTc=TC2}, TC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5)
@ -67,13 +67,13 @@ FORCE_INLINE void Disable_Irq(IRQn_Type irq) {
// --------------------------------------------------------------------------
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
// Disable interrupt, just in case it was already enabled
Disable_Irq(irq);
if (timer_num == RTC_TIMER_NUM) {
Rtc * const rtc = TimerConfig[timer_num].pRtc;
if (timer_num == MF_TIMER_RTC) {
Rtc * const rtc = timer_config[timer_num].pRtc;
// Disable timer interrupt
rtc->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
@ -101,7 +101,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
SYNC(rtc->MODE0.SYNCBUSY.bit.ENABLE);
}
else {
Tc * const tc = TimerConfig[timer_num].pTc;
Tc * const tc = timer_config[timer_num].pTc;
// Disable timer interrupt
tc->COUNT32.INTENCLR.reg = TC_INTENCLR_OVF; // disable overflow interrupt
@ -141,17 +141,17 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
}
// Finally, enable IRQ
NVIC_SetPriority(irq, TimerConfig[timer_num].priority);
NVIC_SetPriority(irq, timer_config[timer_num].priority);
NVIC_EnableIRQ(irq);
}
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
NVIC_EnableIRQ(irq);
}
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
Disable_Irq(irq);
}
@ -161,7 +161,7 @@ static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
}
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
return NVIC_GetEnabledIRQ(irq);
}

62
Marlin/src/HAL/SAMD51/timers.h

@ -25,21 +25,22 @@
// --------------------------------------------------------------------------
// Defines
// --------------------------------------------------------------------------
#define RTC_TIMER_NUM 8 // This is not a TC but a RTC
typedef uint32_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
#define HAL_TIMER_RATE F_CPU // frequency of timers peripherals
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#define MF_TIMER_RTC 8 // This is not a TC but a RTC
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM RTC_TIMER_NUM // Timer Index for Temperature
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP MF_TIMER_RTC // Timer Index for Temperature
#endif
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
@ -52,30 +53,29 @@ typedef uint32_t hal_timer_t;
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#define TC_PRIORITY(t) t == SERVO_TC ? 1 \
: (t == STEP_TIMER_NUM || t == PULSE_TIMER_NUM) ? 2 \
: (t == TEMP_TIMER_NUM) ? 6 \
: 7
#define TC_PRIORITY(t) ( t == SERVO_TC ? 1 \
: (t == MF_TIMER_STEP || t == MF_TIMER_PULSE) ? 2 \
: (t == MF_TIMER_TEMP) ? 6 : 7 )
#define _TC_HANDLER(t) void TC##t##_Handler()
#define TC_HANDLER(t) _TC_HANDLER(t)
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() TC_HANDLER(STEP_TIMER_NUM)
#define HAL_STEP_TIMER_ISR() TC_HANDLER(MF_TIMER_STEP)
#endif
#if STEP_TIMER_NUM != PULSE_TIMER_NUM
#define HAL_PULSE_TIMER_ISR() TC_HANDLER(PULSE_TIMER_NUM)
#if MF_TIMER_STEP != MF_TIMER_PULSE
#define HAL_PULSE_TIMER_ISR() TC_HANDLER(MF_TIMER_PULSE)
#endif
#if TEMP_TIMER_NUM == RTC_TIMER_NUM
#if MF_TIMER_TEMP == MF_TIMER_RTC
#define HAL_TEMP_TIMER_ISR() void RTC_Handler()
#else
#define HAL_TEMP_TIMER_ISR() TC_HANDLER(TEMP_TIMER_NUM)
#define HAL_TEMP_TIMER_ISR() TC_HANDLER(MF_TIMER_TEMP)
#endif
// --------------------------------------------------------------------------
@ -95,7 +95,7 @@ typedef struct {
// Public Variables
// --------------------------------------------------------------------------
extern const tTimerConfig TimerConfig[];
extern const tTimerConfig timer_config[];
// --------------------------------------------------------------------------
// Public functions
@ -104,20 +104,20 @@ extern const tTimerConfig TimerConfig[];
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
// Should never be called with timer RTC_TIMER_NUM
Tc * const tc = TimerConfig[timer_num].pTc;
// Should never be called with timer MF_TIMER_RTC
Tc * const tc = timer_config[timer_num].pTc;
tc->COUNT32.CC[0].reg = compare;
}
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
// Should never be called with timer RTC_TIMER_NUM
Tc * const tc = TimerConfig[timer_num].pTc;
// Should never be called with timer MF_TIMER_RTC
Tc * const tc = timer_config[timer_num].pTc;
return (hal_timer_t)tc->COUNT32.CC[0].reg;
}
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
// Should never be called with timer RTC_TIMER_NUM
Tc * const tc = TimerConfig[timer_num].pTc;
// Should never be called with timer MF_TIMER_RTC
Tc * const tc = timer_config[timer_num].pTc;
tc->COUNT32.CTRLBSET.reg = TC_CTRLBCLR_CMD_READSYNC;
SYNC(tc->COUNT32.SYNCBUSY.bit.CTRLB || tc->COUNT32.SYNCBUSY.bit.COUNT);
return tc->COUNT32.COUNT.reg;
@ -128,13 +128,13 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
if (timer_num == RTC_TIMER_NUM) {
Rtc * const rtc = TimerConfig[timer_num].pRtc;
if (timer_num == MF_TIMER_RTC) {
Rtc * const rtc = timer_config[timer_num].pRtc;
// Clear interrupt flag
rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
}
else {
Tc * const tc = TimerConfig[timer_num].pTc;
Tc * const tc = timer_config[timer_num].pTc;
// Clear interrupt flag
tc->COUNT32.INTFLAG.reg = TC_INTFLAG_OVF;
}

2
Marlin/src/HAL/STM32/HAL.cpp

@ -154,7 +154,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRe
uint16_t HAL_adc_get_result() { return HAL_adc_result; }
// Reset the system to initiate a firmware flash
void flashFirmware(const int16_t) { HAL_reboot(); }
WEAK void flashFirmware(const int16_t) { HAL_reboot(); }
// Maple Compatibility
volatile uint32_t systick_uptime_millis = 0;

6
Marlin/src/HAL/STM32/HAL.h

@ -130,7 +130,11 @@
// Types
// ------------------------
typedef int16_t pin_t;
#ifdef STM32G0B1xx
typedef int32_t pin_t;
#else
typedef int16_t pin_t;
#endif
#define HAL_SERVO_LIB libServo
#define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos()

2
Marlin/src/HAL/STM32/HAL_MinSerial.cpp

@ -135,7 +135,7 @@ void install_min_serial() {
HAL_min_serial_out = &TX;
}
#if DISABLED(DYNAMIC_VECTORTABLE) && DISABLED(STM32F0xx) // Cortex M0 can't jump to a symbol that's too far from the current function, so we work around this in exception_arm.cpp
#if NONE(DYNAMIC_VECTORTABLE, STM32F0xx, STM32G0xx) // Cortex M0 can't jump to a symbol that's too far from the current function, so we work around this in exception_arm.cpp
extern "C" {
__attribute__((naked)) void JumpHandler_ASM() {
__asm__ __volatile__ (

11
Marlin/src/HAL/STM32/MarlinSPI.cpp

@ -114,16 +114,19 @@ byte MarlinSPI::transfer(uint8_t _data) {
return rxData;
}
__STATIC_INLINE void LL_SPI_EnableDMAReq_RX(SPI_TypeDef *SPIx) { SET_BIT(SPIx->CR2, SPI_CR2_RXDMAEN); }
__STATIC_INLINE void LL_SPI_EnableDMAReq_TX(SPI_TypeDef *SPIx) { SET_BIT(SPIx->CR2, SPI_CR2_TXDMAEN); }
uint8_t MarlinSPI::dmaTransfer(const void *transmitBuf, void *receiveBuf, uint16_t length) {
const uint8_t ff = 0xFF;
//if ((hspi->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) //only enable if disabled
//if (!LL_SPI_IsEnabled(_spi.handle)) // only enable if disabled
__HAL_SPI_ENABLE(&_spi.handle);
if (receiveBuf) {
setupDma(_spi.handle, _dmaRx, DMA_PERIPH_TO_MEMORY, true);
HAL_DMA_Start(&_dmaRx, (uint32_t)&(_spi.handle.Instance->DR), (uint32_t)receiveBuf, length);
SET_BIT(_spi.handle.Instance->CR2, SPI_CR2_RXDMAEN); /* Enable Rx DMA Request */
LL_SPI_EnableDMAReq_RX(_spi.handle.Instance); // Enable Rx DMA Request
}
// check for 2 lines transfer
@ -136,7 +139,7 @@ uint8_t MarlinSPI::dmaTransfer(const void *transmitBuf, void *receiveBuf, uint16
if (transmitBuf) {
setupDma(_spi.handle, _dmaTx, DMA_MEMORY_TO_PERIPH, mincTransmit);
HAL_DMA_Start(&_dmaTx, (uint32_t)transmitBuf, (uint32_t)&(_spi.handle.Instance->DR), length);
SET_BIT(_spi.handle.Instance->CR2, SPI_CR2_TXDMAEN); /* Enable Tx DMA Request */
LL_SPI_EnableDMAReq_TX(_spi.handle.Instance); // Enable Tx DMA Request
}
if (transmitBuf) {
@ -160,7 +163,7 @@ uint8_t MarlinSPI::dmaSend(const void * transmitBuf, uint16_t length, bool minc)
setupDma(_spi.handle, _dmaTx, DMA_MEMORY_TO_PERIPH, minc);
HAL_DMA_Start(&_dmaTx, (uint32_t)transmitBuf, (uint32_t)&(_spi.handle.Instance->DR), length);
__HAL_SPI_ENABLE(&_spi.handle);
SET_BIT(_spi.handle.Instance->CR2, SPI_CR2_TXDMAEN); /* Enable Tx DMA Request */
LL_SPI_EnableDMAReq_TX(_spi.handle.Instance); // Enable Tx DMA Request
HAL_DMA_PollForTransfer(&_dmaTx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY);
HAL_DMA_Abort(&_dmaTx);
// DeInit objects

71
Marlin/src/HAL/STM32/fast_pwm.cpp

@ -24,39 +24,60 @@
#ifdef HAL_STM32
#include "../../inc/MarlinConfigPre.h"
#include "../../inc/MarlinConfig.h"
#if NEEDS_HARDWARE_PWM
// Array to support sticky frequency sets per timer
static uint16_t timer_freq[TIMER_NUM];
#include "HAL.h"
#include "timers.h"
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
const PinName pin_name = digitalPinToPinName(pin);
TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM);
void set_pwm_frequency(const pin_t pin, int f_desired) {
if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
const timer_index_t index = get_timer_index(Instance);
const bool needs_freq = (HardwareTimer_Handle[index] == nullptr);
if (needs_freq) // A new instance must be set to the default frequency of PWM_FREQUENCY
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM));
PinName pin_name = digitalPinToPinName(pin);
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance
HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this);
const uint32_t channel = STM_PIN_CHANNEL(pinmap_function(pin_name, PinMap_PWM));
const TimerModes_t previousMode = HT->getMode(channel);
if (previousMode != TIMER_OUTPUT_COMPARE_PWM1)
HT->setMode(channel, TIMER_OUTPUT_COMPARE_PWM1, pin);
LOOP_S_L_N(i, 0, NUM_HARDWARE_TIMERS) // Protect used timers
if (timer_instance[i] && timer_instance[i]->getHandle()->Instance == Instance)
return;
if (needs_freq && timer_freq[index] == 0) // If the timer is unconfigured and no freq is set then default PWM_FREQUENCY
set_pwm_frequency(pin_name, PWM_FREQUENCY); // Set the frequency and save the value to the assigned index no.
pwm_start(pin_name, f_desired, 0, RESOLUTION_8B_COMPARE_FORMAT);
// Note the resolution is sticky here, the input can be upto 16 bits and that would require RESOLUTION_16B_COMPARE_FORMAT (16)
// If such a need were to manifest then we would need to calc the resolution based on the v_size parameter and add code for it.
const uint16_t value = invert ? v_size - v : v;
HT->setCaptureCompare(channel, value, RESOLUTION_8B_COMPARE_FORMAT); // Sets the duty, the calc is done in the library :)
pinmap_pinout(pin_name, PinMap_PWM); // Make sure the pin output state is set.
if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) HT->resume();
}
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
PinName pin_name = digitalPinToPinName(pin);
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM);
uint16_t adj_val = Instance->ARR * v / v_size;
if (invert) adj_val = Instance->ARR - adj_val;
switch (get_pwm_channel(pin_name)) {
case TIM_CHANNEL_1: LL_TIM_OC_SetCompareCH1(Instance, adj_val); break;
case TIM_CHANNEL_2: LL_TIM_OC_SetCompareCH2(Instance, adj_val); break;
case TIM_CHANNEL_3: LL_TIM_OC_SetCompareCH3(Instance, adj_val); break;
case TIM_CHANNEL_4: LL_TIM_OC_SetCompareCH4(Instance, adj_val); break;
}
void set_pwm_frequency(const pin_t pin, int f_desired) {
if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
const PinName pin_name = digitalPinToPinName(pin);
TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance
const timer_index_t index = get_timer_index(Instance);
// Protect used timers.
#ifdef STEP_TIMER
if (index == TIMER_INDEX(STEP_TIMER)) return;
#endif
#ifdef TEMP_TIMER
if (index == TIMER_INDEX(TEMP_TIMER)) return;
#endif
#if defined(PULSE_TIMER) && MF_TIMER_PULSE != MF_TIMER_STEP
if (index == TIMER_INDEX(PULSE_TIMER)) return;
#endif
if (HardwareTimer_Handle[index] == nullptr) // If frequency is set before duty we need to create a handle here.
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM));
HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this);
HT->setOverflow(f_desired, HERTZ_FORMAT);
timer_freq[index] = f_desired; // Save the last frequency so duty will not set the default for this timer number.
}
#endif // NEEDS_HARDWARE_PWM
#endif // HAL_STM32

12
Marlin/src/HAL/STM32/tft/tft_spi.cpp

@ -161,11 +161,11 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) {
for (i = 0; i < 4; i++) {
#if TFT_MISO_PIN != TFT_MOSI_PIN
//if (hspi->Init.Direction == SPI_DIRECTION_2LINES) {
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {}
SPIx.Instance->DR = 0;
//}
#endif
while ((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {}
while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_RXNE)) {}
Data = (Data << 8) | SPIx.Instance->DR;
}
@ -195,8 +195,8 @@ bool TFT_SPI::isBusy() {
void TFT_SPI::Abort() {
// Wait for any running spi
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {}
while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {}
while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {}
// First, abort any running dma
HAL_DMA_Abort(&DMAtx);
// DeInit objects
@ -214,8 +214,8 @@ void TFT_SPI::Transmit(uint16_t Data) {
SPIx.Instance->DR = Data;
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {}
while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {}
while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {}
if (TFT_MISO_PIN != TFT_MOSI_PIN)
__HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received is not read

26
Marlin/src/HAL/STM32/timers.cpp

@ -67,7 +67,7 @@
#endif
#endif
#ifdef STM32F0xx
#if defined(STM32F0xx) || defined(STM32G0xx)
#define MCU_STEP_TIMER 16
#define MCU_TEMP_TIMER 17
#elif defined(STM32F1xx)
@ -97,9 +97,15 @@
#define STEP_TIMER_DEV _TIMER_DEV(STEP_TIMER)
#define TEMP_TIMER_DEV _TIMER_DEV(TEMP_TIMER)
// ------------------------
// --------------------------------------------------------------------------
// Local defines
// --------------------------------------------------------------------------
#define NUM_HARDWARE_TIMERS 2
// --------------------------------------------------------------------------
// Private Variables
// ------------------------
// --------------------------------------------------------------------------
HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { nullptr };
@ -110,7 +116,7 @@ HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { nullptr };
uint32_t GetStepperTimerClkFreq() {
// Timer input clocks vary between devices, and in some cases between timers on the same device.
// Retrieve at runtime to ensure device compatibility. Cache result to avoid repeated overhead.
static uint32_t clkfreq = timer_instance[STEP_TIMER_NUM]->getTimerClkFreq();
static uint32_t clkfreq = timer_instance[MF_TIMER_STEP]->getTimerClkFreq();
return clkfreq;
}
@ -118,7 +124,7 @@ uint32_t GetStepperTimerClkFreq() {
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
if (!HAL_timer_initialized(timer_num)) {
switch (timer_num) {
case STEP_TIMER_NUM: // STEPPER TIMER - use a 32bit timer if possible
case MF_TIMER_STEP: // STEPPER TIMER - use a 32bit timer if possible
timer_instance[timer_num] = new HardwareTimer(STEP_TIMER_DEV);
/* Set the prescaler to the final desired value.
* This will change the effective ISR callback frequency but when
@ -137,7 +143,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally
timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT);
break;
case TEMP_TIMER_NUM: // TEMP TIMER - any available 16bit timer
case MF_TIMER_TEMP: // TEMP TIMER - any available 16bit timer
timer_instance[timer_num] = new HardwareTimer(TEMP_TIMER_DEV);
// The prescale factor is computed automatically for HERTZ_FORMAT
timer_instance[timer_num]->setOverflow(frequency, HERTZ_FORMAT);
@ -157,10 +163,10 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
// These calls can be removed and replaced with
// timer_instance[timer_num]->setInterruptPriority
switch (timer_num) {
case STEP_TIMER_NUM:
case MF_TIMER_STEP:
timer_instance[timer_num]->setInterruptPriority(STEP_TIMER_IRQ_PRIO, 0);
break;
case TEMP_TIMER_NUM:
case MF_TIMER_TEMP:
timer_instance[timer_num]->setInterruptPriority(TEMP_TIMER_IRQ_PRIO, 0);
break;
}
@ -170,10 +176,10 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
if (HAL_timer_initialized(timer_num) && !timer_instance[timer_num]->hasInterrupt()) {
switch (timer_num) {
case STEP_TIMER_NUM:
case MF_TIMER_STEP:
timer_instance[timer_num]->attachInterrupt(Step_Handler);
break;
case TEMP_TIMER_NUM:
case MF_TIMER_TEMP:
timer_instance[timer_num]->attachInterrupt(Temp_Handler);
break;
}

30
Marlin/src/HAL/STM32/timers.h

@ -40,17 +40,13 @@
#define hal_timer_t uint32_t
#define HAL_TIMER_TYPE_MAX UINT16_MAX
#define NUM_HARDWARE_TIMERS 2
// Marlin timer_instance[] content (unrelated to timer selection)
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
#define MF_TIMER_PULSE MF_TIMER_STEP
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
#endif
#define TIMER_INDEX_(T) TIMER##T##_INDEX // TIMER#_INDEX enums (timer_index_t) depend on TIM#_BASE defines.
#define TIMER_INDEX(T) TIMER_INDEX_(T) // Convert Timer ID to HardwareTimer_Handle index.
#define TEMP_TIMER_FREQUENCY 1000 // Temperature::isr() is expected to be called at around 1kHz
@ -64,12 +60,12 @@ extern uint32_t GetStepperTimerClkFreq();
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
extern void Step_Handler();
extern void Temp_Handler();
@ -120,5 +116,5 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha
}
}
#define HAL_timer_isr_prologue(TIMER_NUM)
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_prologue(T)
#define HAL_timer_isr_epilogue(T)

3
Marlin/src/HAL/STM32F1/HAL.cpp

@ -449,8 +449,7 @@ uint16_t analogRead(pin_t pin) {
// Wrapper to maple unprotected analogWrite
void analogWrite(pin_t pin, int pwm_val8) {
if (PWM_PIN(pin))
analogWrite(uint8_t(pin), pwm_val8);
if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8);
}
void HAL_reboot() { nvic_sys_reset(); }

6
Marlin/src/HAL/STM32F1/HAL.h

@ -264,7 +264,10 @@ void analogWrite(pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!?
#define PLATFORM_M997_SUPPORT
void flashFirmware(const int16_t);
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
#ifndef PWM_FREQUENCY
#define PWM_FREQUENCY 1000 // Default PWM Frequency
#endif
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
/**
* set_pwm_frequency
@ -278,5 +281,6 @@ void set_pwm_frequency(const pin_t pin, int f_desired);
* Set the PWM duty cycle of the provided pin to the provided value
* Optionally allows inverting the duty cycle [default = false]
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
* The timer must be pre-configured with set_pwm_frequency() if the default frequency is not desired.
*/
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);

18
Marlin/src/HAL/STM32F1/Servo.cpp

@ -60,7 +60,7 @@ uint8_t ServoCount = 0;
#define US_TO_ANGLE(us) int16_t(map((us), SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW, minAngle, maxAngle))
void libServo::servoWrite(uint8_t inPin, uint16_t duty_cycle) {
#ifdef SERVO0_TIMER_NUM
#ifdef MF_TIMER_SERVO0
if (servoIndex == 0) {
pwmSetDuty(duty_cycle);
return;
@ -74,7 +74,7 @@ void libServo::servoWrite(uint8_t inPin, uint16_t duty_cycle) {
libServo::libServo() {
servoIndex = ServoCount < MAX_SERVOS ? ServoCount++ : INVALID_SERVO;
timer_set_interrupt_priority(SERVO0_TIMER_NUM, SERVO0_TIMER_IRQ_PRIO);
HAL_timer_set_interrupt_priority(MF_TIMER_SERVO0, SERVO0_TIMER_IRQ_PRIO);
}
bool libServo::attach(const int32_t inPin, const int32_t inMinAngle, const int32_t inMaxAngle) {
@ -85,7 +85,7 @@ bool libServo::attach(const int32_t inPin, const int32_t inMinAngle, const int32
maxAngle = inMaxAngle;
angle = -1;
#ifdef SERVO0_TIMER_NUM
#ifdef MF_TIMER_SERVO0
if (servoIndex == 0 && setupSoftPWM(inPin)) {
pin = inPin; // set attached()
return true;
@ -119,7 +119,7 @@ bool libServo::detach() {
int32_t libServo::read() const {
if (attached()) {
#ifdef SERVO0_TIMER_NUM
#ifdef MF_TIMER_SERVO0
if (servoIndex == 0) return angle;
#endif
timer_dev *tdev = PIN_MAP[pin].timer_device;
@ -141,9 +141,9 @@ void libServo::move(const int32_t value) {
}
}
#ifdef SERVO0_TIMER_NUM
#ifdef MF_TIMER_SERVO0
extern "C" void Servo_IRQHandler() {
static timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM);
static timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0);
uint16_t SR = timer_get_status(tdev);
if (SR & TIMER_SR_CC1IF) { // channel 1 off
#ifdef SERVO0_PWM_OD
@ -164,7 +164,7 @@ void libServo::move(const int32_t value) {
}
bool libServo::setupSoftPWM(const int32_t inPin) {
timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM);
timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0);
if (!tdev) return false;
#ifdef SERVO0_PWM_OD
OUT_WRITE_OD(inPin, 1);
@ -189,7 +189,7 @@ void libServo::move(const int32_t value) {
}
void libServo::pwmSetDuty(const uint16_t duty_cycle) {
timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM);
timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0);
timer_set_compare(tdev, 1, duty_cycle);
timer_generate_update(tdev);
if (duty_cycle) {
@ -208,7 +208,7 @@ void libServo::move(const int32_t value) {
}
void libServo::pauseSoftPWM() { // detach
timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM);
timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0);
timer_pause(tdev);
pwmSetDuty(0);
}

30
Marlin/src/HAL/STM32F1/build_flags.py

@ -30,25 +30,27 @@ if __name__ == "__main__":
# extra script for linker options
else:
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
env.Append(
import pioutil
if pioutil.is_pio_build():
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
env.Append(
ARFLAGS=["rcs"],
ASFLAGS=["-x", "assembler-with-cpp"],
CXXFLAGS=[
"-fabi-version=0",
"-fno-use-cxa-atexit",
"-fno-threadsafe-statics"
"-fabi-version=0",
"-fno-use-cxa-atexit",
"-fno-threadsafe-statics"
],
LINKFLAGS=[
"-Os",
"-mcpu=cortex-m3",
"-ffreestanding",
"-mthumb",
"--specs=nano.specs",
"--specs=nosys.specs",
"-u_printf_float",
"-Os",
"-mcpu=cortex-m3",
"-ffreestanding",
"-mthumb",
"--specs=nano.specs",
"--specs=nosys.specs",
"-u_printf_float",
],
)
)

50
Marlin/src/HAL/STM32F1/fast_pwm.cpp

@ -23,30 +23,54 @@
#include "../../inc/MarlinConfigPre.h"
#if NEEDS_HARDWARE_PWM
#include <pwm.h>
#include "HAL.h"
#include "timers.h"
#define NR_TIMERS TERN(STM32_XL_DENSITY, 14, 8) // Maple timers, 14 for STM32_XL_DENSITY (F/G chips), 8 for HIGH density (C D E)
static uint16_t timer_freq[NR_TIMERS];
inline uint8_t timer_and_index_for_pin(const pin_t pin, timer_dev **timer_ptr) {
*timer_ptr = PIN_MAP[pin].timer_device;
for (uint8_t i = 0; i < NR_TIMERS; i++) if (*timer_ptr == HAL_get_timer_dev(i))
return i;
return 0;
}
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
if (!PWM_PIN(pin)) return;
timer_dev *timer; UNUSED(timer);
if (timer_freq[timer_and_index_for_pin(pin, &timer)] == 0)
set_pwm_frequency(pin, PWM_FREQUENCY);
const uint8_t channel = PIN_MAP[pin].timer_channel;
const uint16_t duty = invert ? v_size - v : v;
timer_set_compare(timer, channel, duty);
timer_set_mode(timer, channel, TIMER_PWM); // PWM Output Mode
}
void set_pwm_frequency(const pin_t pin, int f_desired) {
if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
timer_dev *timer = PIN_MAP[pin].timer_device;
uint8_t channel = PIN_MAP[pin].timer_channel;
timer_dev *timer; UNUSED(timer);
timer_freq[timer_and_index_for_pin(pin, &timer)] = f_desired;
// Protect used timers
if (timer == get_timer_dev(TEMP_TIMER_NUM)) return;
if (timer == get_timer_dev(STEP_TIMER_NUM)) return;
#if PULSE_TIMER_NUM != STEP_TIMER_NUM
if (timer == get_timer_dev(PULSE_TIMER_NUM)) return;
if (timer == HAL_get_timer_dev(MF_TIMER_TEMP)) return;
if (timer == HAL_get_timer_dev(MF_TIMER_STEP)) return;
#if MF_TIMER_PULSE != MF_TIMER_STEP
if (timer == HAL_get_timer_dev(MF_TIMER_PULSE)) return;
#endif
if (!(timer->regs.bas->SR & TIMER_CR1_CEN)) // Ensure the timer is enabled
timer_init(timer);
const uint8_t channel = PIN_MAP[pin].timer_channel;
timer_set_mode(timer, channel, TIMER_PWM);
uint16_t preload = 255; // Lock 255 PWM resolution for high frequencies
// Preload (resolution) cannot be equal to duty of 255 otherwise it may not result in digital off or on.
uint16_t preload = 254;
int32_t prescaler = (HAL_TIMER_RATE) / (preload + 1) / f_desired - 1;
if (prescaler > 65535) { // For low frequencies increase prescaler
prescaler = 65535;
@ -57,12 +81,4 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
timer_set_prescaler(timer, prescaler);
}
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
timer_dev *timer = PIN_MAP[pin].timer_device;
uint16_t max_val = timer->regs.bas->ARR * v / v_size;
if (invert) max_val = v_size - max_val;
pwmWrite(pin, max_val);
}
#endif // NEEDS_HARDWARE_PWM
#endif // __STM32F1__

2
Marlin/src/HAL/STM32F1/inc/SanityCheck.h

@ -39,7 +39,7 @@
#error "SERIAL_STATS_DROPPED_RX is not supported on the STM32F1 platform."
#endif
#if ENABLED(NEOPIXEL_LED) && DISABLED(MKS_MINI_12864_V3)
#if ENABLED(NEOPIXEL_LED) && DISABLED(FYSETC_MINI_12864_2_1)
#error "NEOPIXEL_LED (Adafruit NeoPixel) is not supported for HAL/STM32F1. Comment out this line to proceed at your own risk!"
#endif

2
Marlin/src/HAL/STM32F1/onboard_sd.cpp

@ -280,7 +280,7 @@ DSTATUS disk_initialize (
if (drv) return STA_NOINIT; // Supports only drive 0
sd_power_on(); // Initialize SPI
if (Stat & STA_NODISK) return Stat; // Is a card existing in the soket?
if (Stat & STA_NODISK) return Stat; // Is a card existing in the socket?
FCLK_SLOW();
for (n = 10; n; n--) xchg_spi(0xFF); // Send 80 dummy clocks

30
Marlin/src/HAL/STM32F1/timers.cpp

@ -47,10 +47,7 @@
* TODO: Calculate Timer prescale value, so we get the 32bit to adjust
*/
void timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority) {
void HAL_timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority) {
nvic_irq_num irq_num;
switch (timer_num) {
case 1: irq_num = NVIC_TIMER1_CC; break;
@ -73,7 +70,6 @@ void timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority)
nvic_irq_set_priority(irq_num, priority);
}
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
/**
* Give the Stepper ISR a higher priority (lower number)
@ -81,7 +77,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
*/
switch (timer_num) {
case STEP_TIMER_NUM:
case MF_TIMER_STEP:
timer_pause(STEP_TIMER_DEV);
timer_set_mode(STEP_TIMER_DEV, STEP_TIMER_CHAN, TIMER_OUTPUT_COMPARE); // counter
timer_set_count(STEP_TIMER_DEV, 0);
@ -91,11 +87,11 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, _MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (STEPPER_TIMER_RATE) / frequency));
timer_no_ARR_preload_ARPE(STEP_TIMER_DEV); // Need to be sure no preload on ARR register
timer_attach_interrupt(STEP_TIMER_DEV, STEP_TIMER_CHAN, stepTC_Handler);
timer_set_interrupt_priority(STEP_TIMER_NUM, STEP_TIMER_IRQ_PRIO);
HAL_timer_set_interrupt_priority(MF_TIMER_STEP, STEP_TIMER_IRQ_PRIO);
timer_generate_update(STEP_TIMER_DEV);
timer_resume(STEP_TIMER_DEV);
break;
case TEMP_TIMER_NUM:
case MF_TIMER_TEMP:
timer_pause(TEMP_TIMER_DEV);
timer_set_mode(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, TIMER_OUTPUT_COMPARE);
timer_set_count(TEMP_TIMER_DEV, 0);
@ -103,7 +99,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
timer_set_reload(TEMP_TIMER_DEV, 0xFFFF);
timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, _MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (F_CPU) / (TEMP_TIMER_PRESCALE) / frequency));
timer_attach_interrupt(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, tempTC_Handler);
timer_set_interrupt_priority(TEMP_TIMER_NUM, TEMP_TIMER_IRQ_PRIO);
HAL_timer_set_interrupt_priority(MF_TIMER_TEMP, TEMP_TIMER_IRQ_PRIO);
timer_generate_update(TEMP_TIMER_DEV);
timer_resume(TEMP_TIMER_DEV);
break;
@ -112,31 +108,31 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case STEP_TIMER_NUM: ENABLE_STEPPER_DRIVER_INTERRUPT(); break;
case TEMP_TIMER_NUM: ENABLE_TEMPERATURE_INTERRUPT(); break;
case MF_TIMER_STEP: ENABLE_STEPPER_DRIVER_INTERRUPT(); break;
case MF_TIMER_TEMP: ENABLE_TEMPERATURE_INTERRUPT(); break;
}
}
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case STEP_TIMER_NUM: DISABLE_STEPPER_DRIVER_INTERRUPT(); break;
case TEMP_TIMER_NUM: DISABLE_TEMPERATURE_INTERRUPT(); break;
case MF_TIMER_STEP: DISABLE_STEPPER_DRIVER_INTERRUPT(); break;
case MF_TIMER_TEMP: DISABLE_TEMPERATURE_INTERRUPT(); break;
}
}
static inline bool timer_irq_enabled(const timer_dev * const dev, const uint8_t interrupt) {
static inline bool HAL_timer_irq_enabled(const timer_dev * const dev, const uint8_t interrupt) {
return bool(*bb_perip(&(dev->regs).gen->DIER, interrupt));
}
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
switch (timer_num) {
case STEP_TIMER_NUM: return timer_irq_enabled(STEP_TIMER_DEV, STEP_TIMER_CHAN);
case TEMP_TIMER_NUM: return timer_irq_enabled(TEMP_TIMER_DEV, TEMP_TIMER_CHAN);
case MF_TIMER_STEP: return HAL_timer_irq_enabled(STEP_TIMER_DEV, STEP_TIMER_CHAN);
case MF_TIMER_TEMP: return HAL_timer_irq_enabled(TEMP_TIMER_DEV, TEMP_TIMER_CHAN);
}
return false;
}
timer_dev* get_timer_dev(int number) {
timer_dev* HAL_get_timer_dev(int number) {
switch (number) {
#if STM32_HAVE_TIMER(1)
case 1: return &timer1;

72
Marlin/src/HAL/STM32F1/timers.h

@ -65,30 +65,30 @@ typedef uint16_t hal_timer_t;
* - Otherwise it uses Timer 8 on boards with STM32_HIGH_DENSITY
* or Timer 4 on other boards.
*/
#ifndef STEP_TIMER_NUM
#ifndef MF_TIMER_STEP
#if defined(MCU_STM32F103CB) || defined(MCU_STM32F103C8)
#define STEP_TIMER_NUM 4 // For C8/CB boards, use timer 4
#define MF_TIMER_STEP 4 // For C8/CB boards, use timer 4
#else
#define STEP_TIMER_NUM 5 // for other boards, five is fine.
#define MF_TIMER_STEP 5 // for other boards, five is fine.
#endif
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 2 // Timer Index for Temperature
//#define TEMP_TIMER_NUM 4 // 2->4, Timer 2 for Stepper Current PWM
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 2 // Timer Index for Temperature
//#define MF_TIMER_TEMP 4 // 2->4, Timer 2 for Stepper Current PWM
#endif
#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_E3_DIP, BTT_SKR_MINI_E3_V1_2, MKS_ROBIN_LITE, MKS_ROBIN_E3D, MKS_ROBIN_E3)
// SKR Mini E3 boards use PA8 as FAN_PIN, so TIMER 1 is used for Fan PWM.
#ifdef STM32_HIGH_DENSITY
#define SERVO0_TIMER_NUM 8 // tone.cpp uses Timer 4
#define MF_TIMER_SERVO0 8 // tone.cpp uses Timer 4
#else
#define SERVO0_TIMER_NUM 3 // tone.cpp uses Timer 8
#define MF_TIMER_SERVO0 3 // tone.cpp uses Timer 8
#endif
#else
#define SERVO0_TIMER_NUM 1 // SERVO0 or BLTOUCH
#define MF_TIMER_SERVO0 1 // SERVO0 or BLTOUCH
#endif
#define STEP_TIMER_IRQ_PRIO 2
@ -98,22 +98,22 @@ typedef uint16_t hal_timer_t;
#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
#define STEPPER_TIMER_PRESCALE 18 // prescaler for setting stepper timer, 4Mhz
#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per ยตs
#define STEPPER_TIMER_PRESCALE 18 // prescaler for setting stepper timer, 4Mhz
#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per ยตs
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
timer_dev* get_timer_dev(int number);
#define TIMER_DEV(num) get_timer_dev(num)
#define STEP_TIMER_DEV TIMER_DEV(STEP_TIMER_NUM)
#define TEMP_TIMER_DEV TIMER_DEV(TEMP_TIMER_NUM)
timer_dev* HAL_get_timer_dev(int number);
#define TIMER_DEV(num) HAL_get_timer_dev(num)
#define STEP_TIMER_DEV TIMER_DEV(MF_TIMER_STEP)
#define TEMP_TIMER_DEV TIMER_DEV(MF_TIMER_TEMP)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() timer_enable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() timer_disable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() timer_enable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN)
#define DISABLE_TEMPERATURE_INTERRUPT() timer_disable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN)
@ -138,8 +138,8 @@ extern "C" {
// Public Variables
// ------------------------
//static HardwareTimer StepperTimer(STEP_TIMER_NUM);
//static HardwareTimer TempTimer(TEMP_TIMER_NUM);
//static HardwareTimer StepperTimer(MF_TIMER_STEP);
//static HardwareTimer TempTimer(MF_TIMER_TEMP);
// ------------------------
// Public functions
@ -163,13 +163,13 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
switch (timer_num) {
case STEP_TIMER_NUM:
case MF_TIMER_STEP:
// NOTE: WE have set ARPE = 0, which means the Auto reload register is not preloaded
// and there is no need to use any compare, as in the timer mode used, setting ARR to the compare value
// will result in exactly the same effect, ie triggering an interrupt, and on top, set counter to 0
timer_set_reload(STEP_TIMER_DEV, compare); // We reload direct ARR as needed during counting up
break;
case TEMP_TIMER_NUM:
case MF_TIMER_TEMP:
timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, compare);
break;
}
@ -177,18 +177,18 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
switch (timer_num) {
case STEP_TIMER_NUM:
// No counter to clear
timer_generate_update(STEP_TIMER_DEV);
return;
case TEMP_TIMER_NUM:
timer_set_count(TEMP_TIMER_DEV, 0);
timer_generate_update(TEMP_TIMER_DEV);
return;
case MF_TIMER_STEP:
// No counter to clear
timer_generate_update(STEP_TIMER_DEV);
return;
case MF_TIMER_TEMP:
timer_set_count(TEMP_TIMER_DEV, 0);
timer_generate_update(TEMP_TIMER_DEV);
return;
}
}
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_epilogue(T)
// No command is available in framework to turn off ARPE bit, which is turned on by default in libmaple.
// Needed here to reset ARPE=0 for stepper timer
@ -196,6 +196,6 @@ FORCE_INLINE static void timer_no_ARR_preload_ARPE(timer_dev *dev) {
bb_peri_set_bit(&(dev->regs).gen->CR1, TIMER_CR1_ARPE_BIT, 0);
}
void timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority);
void HAL_timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority);
#define TIMER_OC_NO_PRELOAD 0 // Need to disable preload also on compare registers.

12
Marlin/src/HAL/TEENSY31_32/HAL.h

@ -98,16 +98,14 @@ void HAL_reboot();
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
extern "C" int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#pragma GCC diagnostic pop
// ADC
@ -124,6 +122,12 @@ void HAL_adc_init();
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result();
// PWM
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
// Pin Map
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)

20
Marlin/src/HAL/TEENSY31_32/timers.cpp

@ -47,7 +47,7 @@ FORCE_INLINE static void __DSB() {
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
switch (timer_num) {
case 0:
case MF_TIMER_STEP:
FTM0_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN;
FTM0_SC = 0x00; // Set this to zero before changing the modulus
FTM0_CNT = 0x0000; // Reset the count to zero
@ -56,7 +56,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
FTM0_SC = (FTM_SC_CLKS(0b1) & FTM_SC_CLKS_MASK) | (FTM_SC_PS(FTM0_TIMER_PRESCALE_BITS) & FTM_SC_PS_MASK); // Bus clock 60MHz divided by prescaler 8
FTM0_C0SC = FTM_CSC_CHIE | FTM_CSC_MSA | FTM_CSC_ELSA;
break;
case 1:
case MF_TIMER_TEMP:
FTM1_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; // Disable write protection, Enable FTM1
FTM1_SC = 0x00; // Set this to zero before changing the modulus
FTM1_CNT = 0x0000; // Reset the count to zero
@ -70,15 +70,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case 0: NVIC_ENABLE_IRQ(IRQ_FTM0); break;
case 1: NVIC_ENABLE_IRQ(IRQ_FTM1); break;
case MF_TIMER_STEP: NVIC_ENABLE_IRQ(IRQ_FTM0); break;
case MF_TIMER_TEMP: NVIC_ENABLE_IRQ(IRQ_FTM1); break;
}
}
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case 0: NVIC_DISABLE_IRQ(IRQ_FTM0); break;
case 1: NVIC_DISABLE_IRQ(IRQ_FTM1); break;
case MF_TIMER_STEP: NVIC_DISABLE_IRQ(IRQ_FTM0); break;
case MF_TIMER_TEMP: NVIC_DISABLE_IRQ(IRQ_FTM1); break;
}
// We NEED memory barriers to ensure Interrupts are actually disabled!
@ -89,20 +89,20 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
switch (timer_num) {
case 0: return NVIC_IS_ENABLED(IRQ_FTM0);
case 1: return NVIC_IS_ENABLED(IRQ_FTM1);
case MF_TIMER_STEP: return NVIC_IS_ENABLED(IRQ_FTM0);
case MF_TIMER_TEMP: return NVIC_IS_ENABLED(IRQ_FTM1);
}
return false;
}
void HAL_timer_isr_prologue(const uint8_t timer_num) {
switch (timer_num) {
case 0:
case MF_TIMER_STEP:
FTM0_CNT = 0x0000;
FTM0_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
FTM0_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag
break;
case 1:
case MF_TIMER_TEMP:
FTM1_CNT = 0x0000;
FTM1_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
FTM1_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag

36
Marlin/src/HAL/TEENSY31_32/timers.h

@ -46,14 +46,14 @@ typedef uint32_t hal_timer_t;
#define HAL_TIMER_RATE (FTM0_TIMER_RATE)
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
#endif
#define TEMP_TIMER_FREQUENCY 1000
@ -66,12 +66,12 @@ typedef uint32_t hal_timer_t;
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr() //void TC3_Handler()
@ -84,23 +84,23 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
switch (timer_num) {
case 0: FTM0_C0V = compare; break;
case 1: FTM1_C0V = compare; break;
case MF_TIMER_STEP: FTM0_C0V = compare; break;
case MF_TIMER_TEMP: FTM1_C0V = compare; break;
}
}
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
switch (timer_num) {
case 0: return FTM0_C0V;
case 1: return FTM1_C0V;
case MF_TIMER_STEP: return FTM0_C0V;
case MF_TIMER_TEMP: return FTM1_C0V;
}
return 0;
}
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
switch (timer_num) {
case 0: return FTM0_CNT;
case 1: return FTM1_CNT;
case MF_TIMER_STEP: return FTM0_CNT;
case MF_TIMER_TEMP: return FTM1_CNT;
}
return 0;
}
@ -110,4 +110,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
void HAL_timer_isr_prologue(const uint8_t timer_num);
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_epilogue(T)

12
Marlin/src/HAL/TEENSY35_36/HAL.h

@ -105,16 +105,14 @@ void HAL_reboot();
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
extern "C" int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#pragma GCC diagnostic pop
// ADC
@ -131,6 +129,12 @@ void HAL_adc_init();
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result();
// PWM
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
// Pin Map
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)

20
Marlin/src/HAL/TEENSY35_36/timers.cpp

@ -47,7 +47,7 @@ FORCE_INLINE static void __DSB() {
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
switch (timer_num) {
case 0:
case MF_TIMER_STEP:
FTM0_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN;
FTM0_SC = 0x00; // Set this to zero before changing the modulus
FTM0_CNT = 0x0000; // Reset the count to zero
@ -56,7 +56,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
FTM0_SC = (FTM_SC_CLKS(0b1) & FTM_SC_CLKS_MASK) | (FTM_SC_PS(FTM0_TIMER_PRESCALE_BITS) & FTM_SC_PS_MASK); // Bus clock 60MHz divided by prescaler 8
FTM0_C0SC = FTM_CSC_CHIE | FTM_CSC_MSA | FTM_CSC_ELSA;
break;
case 1:
case MF_TIMER_TEMP:
FTM1_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; // Disable write protection, Enable FTM1
FTM1_SC = 0x00; // Set this to zero before changing the modulus
FTM1_CNT = 0x0000; // Reset the count to zero
@ -70,15 +70,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case 0: NVIC_ENABLE_IRQ(IRQ_FTM0); break;
case 1: NVIC_ENABLE_IRQ(IRQ_FTM1); break;
case MF_TIMER_STEP: NVIC_ENABLE_IRQ(IRQ_FTM0); break;
case MF_TIMER_TEMP: NVIC_ENABLE_IRQ(IRQ_FTM1); break;
}
}
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case 0: NVIC_DISABLE_IRQ(IRQ_FTM0); break;
case 1: NVIC_DISABLE_IRQ(IRQ_FTM1); break;
case MF_TIMER_STEP: NVIC_DISABLE_IRQ(IRQ_FTM0); break;
case MF_TIMER_TEMP: NVIC_DISABLE_IRQ(IRQ_FTM1); break;
}
// We NEED memory barriers to ensure Interrupts are actually disabled!
@ -89,20 +89,20 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
switch (timer_num) {
case 0: return NVIC_IS_ENABLED(IRQ_FTM0);
case 1: return NVIC_IS_ENABLED(IRQ_FTM1);
case MF_TIMER_STEP: return NVIC_IS_ENABLED(IRQ_FTM0);
case MF_TIMER_TEMP: return NVIC_IS_ENABLED(IRQ_FTM1);
}
return false;
}
void HAL_timer_isr_prologue(const uint8_t timer_num) {
switch (timer_num) {
case 0:
case MF_TIMER_STEP:
FTM0_CNT = 0x0000;
FTM0_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
FTM0_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag
break;
case 1:
case MF_TIMER_TEMP:
FTM1_CNT = 0x0000;
FTM1_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
FTM1_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag

36
Marlin/src/HAL/TEENSY35_36/timers.h

@ -45,14 +45,14 @@ typedef uint32_t hal_timer_t;
#define HAL_TIMER_RATE (FTM0_TIMER_RATE)
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
#endif
#define TEMP_TIMER_FREQUENCY 1000
@ -65,12 +65,12 @@ typedef uint32_t hal_timer_t;
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr() //void TC3_Handler()
@ -83,23 +83,23 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
switch (timer_num) {
case 0: FTM0_C0V = compare; break;
case 1: FTM1_C0V = compare; break;
case MF_TIMER_STEP: FTM0_C0V = compare; break;
case MF_TIMER_TEMP: FTM1_C0V = compare; break;
}
}
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
switch (timer_num) {
case 0: return FTM0_C0V;
case 1: return FTM1_C0V;
case MF_TIMER_STEP: return FTM0_C0V;
case MF_TIMER_TEMP: return FTM1_C0V;
}
return 0;
}
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
switch (timer_num) {
case 0: return FTM0_CNT;
case 1: return FTM1_CNT;
case MF_TIMER_STEP: return FTM0_CNT;
case MF_TIMER_TEMP: return FTM1_CNT;
}
return 0;
}
@ -109,4 +109,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
void HAL_timer_isr_prologue(const uint8_t timer_num);
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_epilogue(T)

10
Marlin/src/HAL/TEENSY40_41/HAL.cpp

@ -106,17 +106,17 @@ void HAL_adc_init() {
void HAL_clear_reset_source() {
uint32_t reset_source = SRC_SRSR;
SRC_SRSR = reset_source;
}
}
uint8_t HAL_get_reset_source() {
switch (SRC_SRSR & 0xFF) {
case 1: return RST_POWER_ON; break;
case 2: return RST_SOFTWARE; break;
case 4: return RST_EXTERNAL; break;
// case 8: return RST_BROWN_OUT; break;
//case 8: return RST_BROWN_OUT; break;
case 16: return RST_WATCHDOG; break;
case 64: return RST_JTAG; break;
// case 128: return RST_OVERTEMP; break;
case 64: return RST_JTAG; break;
//case 128: return RST_OVERTEMP; break;
}
return 0;
}
@ -168,7 +168,7 @@ uint16_t HAL_adc_get_result() {
return 0;
}
bool is_output(uint8_t pin) {
bool is_output(pin_t pin) {
const struct digital_pin_bitband_and_config_table_struct *p;
p = digital_pin_to_info_PGM + pin;
return (*(p->reg + 1) & p->mask);

14
Marlin/src/HAL/TEENSY40_41/HAL.h

@ -125,16 +125,14 @@ void HAL_reboot();
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
extern "C" uint32_t freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#pragma GCC diagnostic pop
// ADC
@ -152,8 +150,14 @@ void HAL_adc_init();
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result();
// PWM
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
// Pin Map
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
bool is_output(uint8_t pin);
bool is_output(pin_t pin);

28
Marlin/src/HAL/TEENSY40_41/timers.cpp

@ -30,7 +30,7 @@
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
switch (timer_num) {
case 0:
case MF_TIMER_STEP:
CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode
CCM_CCGR1 |= CCM_CCGR1_GPT1_BUS(CCM_CCGR_ON);
@ -48,7 +48,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
attachInterruptVector(IRQ_GPT1, &stepTC_Handler);
NVIC_SET_PRIORITY(IRQ_GPT1, 16);
break;
case 1:
case MF_TIMER_TEMP:
CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode
CCM_CCGR0 |= CCM_CCGR0_GPT2_BUS(CCM_CCGR_ON);
@ -71,19 +71,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case 0:
NVIC_ENABLE_IRQ(IRQ_GPT1);
break;
case 1:
NVIC_ENABLE_IRQ(IRQ_GPT2);
break;
case MF_TIMER_STEP: NVIC_ENABLE_IRQ(IRQ_GPT1); break;
case MF_TIMER_TEMP: NVIC_ENABLE_IRQ(IRQ_GPT2); break;
}
}
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case 0: NVIC_DISABLE_IRQ(IRQ_GPT1); break;
case 1: NVIC_DISABLE_IRQ(IRQ_GPT2); break;
case MF_TIMER_STEP: NVIC_DISABLE_IRQ(IRQ_GPT1); break;
case MF_TIMER_TEMP: NVIC_DISABLE_IRQ(IRQ_GPT2); break;
}
// We NEED memory barriers to ensure Interrupts are actually disabled!
@ -93,20 +89,16 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
switch (timer_num) {
case 0: return (NVIC_IS_ENABLED(IRQ_GPT1));
case 1: return (NVIC_IS_ENABLED(IRQ_GPT2));
case MF_TIMER_STEP: return (NVIC_IS_ENABLED(IRQ_GPT1));
case MF_TIMER_TEMP: return (NVIC_IS_ENABLED(IRQ_GPT2));
}
return false;
}
void HAL_timer_isr_prologue(const uint8_t timer_num) {
switch (timer_num) {
case 0:
GPT1_SR = GPT_IR_OF1IE; // clear OF3 bit
break;
case 1:
GPT2_SR = GPT_IR_OF1IE; // clear OF3 bit
break;
case MF_TIMER_STEP: GPT1_SR = GPT_IR_OF1IE; break; // clear OF3 bit
case MF_TIMER_TEMP: GPT2_SR = GPT_IR_OF1IE; break; // clear OF3 bit
}
asm volatile("dsb");
}

40
Marlin/src/HAL/TEENSY40_41/timers.h

@ -43,14 +43,14 @@ typedef uint32_t hal_timer_t;
#define GPT1_TIMER_RATE (GPT_TIMER_RATE / GPT1_TIMER_PRESCALE) // 75MHz
#define GPT2_TIMER_RATE (GPT_TIMER_RATE / GPT2_TIMER_PRESCALE) // 15MHz
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#endif
#ifndef PULSE_TIMER_NUM
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef TEMP_TIMER_NUM
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
#endif
#define TEMP_TIMER_RATE 1000000
@ -64,12 +64,12 @@ typedef uint32_t hal_timer_t;
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler() // GPT1_Handler()
@ -87,27 +87,23 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
switch (timer_num) {
case 0:
GPT1_OCR1 = compare - 1;
break;
case 1:
GPT2_OCR1 = compare - 1;
break;
case MF_TIMER_STEP: GPT1_OCR1 = compare - 1; break;
case MF_TIMER_TEMP: GPT2_OCR1 = compare - 1; break;
}
}
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
switch (timer_num) {
case 0: return GPT1_OCR1;
case 1: return GPT2_OCR1;
case MF_TIMER_STEP: return GPT1_OCR1;
case MF_TIMER_TEMP: return GPT2_OCR1;
}
return 0;
}
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
switch (timer_num) {
case 0: return GPT1_CNT;
case 1: return GPT2_CNT;
case MF_TIMER_STEP: return GPT1_CNT;
case MF_TIMER_TEMP: return GPT2_CNT;
}
return 0;
}
@ -118,4 +114,4 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
void HAL_timer_isr_prologue(const uint8_t timer_num);
//void HAL_timer_isr_epilogue(const uint8_t timer_num) {}
#define HAL_timer_isr_epilogue(TIMER_NUM)
#define HAL_timer_isr_epilogue(T)

36
Marlin/src/HAL/shared/Delay.cpp

@ -108,13 +108,14 @@
#if ENABLED(MARLIN_DEV_MODE)
void dump_delay_accuracy_check() {
auto report_call_time = [](PGM_P const name, PGM_P const unit, const uint32_t cycles, const uint32_t total, const bool do_flush=true) {
auto report_call_time = [](FSTR_P const name, FSTR_P const unit, const uint32_t cycles, const uint32_t total, const bool do_flush=true) {
SERIAL_ECHOPGM("Calling ");
SERIAL_ECHOPGM_P(name);
SERIAL_ECHOF(name);
SERIAL_ECHOLNPGM(" for ", cycles);
SERIAL_ECHOPGM_P(unit);
SERIAL_ECHOF(unit);
SERIAL_ECHOLNPGM(" took: ", total);
SERIAL_ECHOPGM_P(unit);
SERIAL_CHAR(' ');
SERIAL_ECHOF(unit);
if (do_flush) SERIAL_FLUSHTX();
};
@ -126,41 +127,42 @@
constexpr uint32_t testValues[] = { 1, 5, 10, 20, 50, 100, 150, 200, 350, 500, 750, 1000 };
for (auto i : testValues) {
s = micros(); DELAY_US(i); e = micros();
report_call_time(PSTR("delay"), PSTR("us"), i, e - s);
report_call_time(F("delay"), F("us"), i, e - s);
}
if (HW_REG(_DWT_CTRL)) {
static FSTR_P cyc = F("cycles");
static FSTR_P dcd = F("DELAY_CYCLES directly ");
for (auto i : testValues) {
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(i); e = HW_REG(_DWT_CYCCNT);
report_call_time(PSTR("runtime delay"), PSTR("cycles"), i, e - s);
report_call_time(F("runtime delay"), cyc, i, e - s);
}
// Measure the delay to call a real function compared to a function pointer
s = HW_REG(_DWT_CYCCNT); delay_dwt(1); e = HW_REG(_DWT_CYCCNT);
report_call_time(PSTR("delay_dwt"), PSTR("cycles"), 1, e - s);
static PGMSTR(dcd, "DELAY_CYCLES directly ");
report_call_time(F("delay_dwt"), cyc, 1, e - s);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 1); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, PSTR("cycles"), 1, e - s, false);
report_call_time(dcd, cyc, 1, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 5); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, PSTR("cycles"), 5, e - s, false);
report_call_time(dcd, cyc, 5, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(10); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, PSTR("cycles"), 10, e - s, false);
report_call_time(dcd, cyc, 10, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(20); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, PSTR("cycles"), 20, e - s, false);
report_call_time(dcd, cyc, 20, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(50); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, PSTR("cycles"), 50, e - s, false);
report_call_time(dcd, cyc, 50, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(100); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, PSTR("cycles"), 100, e - s, false);
report_call_time(dcd, cyc, 100, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(200); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, PSTR("cycles"), 200, e - s, false);
report_call_time(dcd, cyc, 200, e - s, false);
}
}
#endif // MARLIN_DEV_MODE
@ -170,7 +172,7 @@
void calibrate_delay_loop() {}
#if ENABLED(MARLIN_DEV_MODE)
void dump_delay_accuracy_check() { SERIAL_ECHOPGM_P(PSTR("N/A on this platform")); }
void dump_delay_accuracy_check() { SERIAL_ECHOPGM("N/A on this platform"); }
#endif
#endif

15
Marlin/src/HAL/shared/Delay.h

@ -92,6 +92,12 @@ void calibrate_delay_loop();
#define DELAY_CYCLES(X) do { SmartDelay<IS_CONSTEXPR(X), IS_CONSTEXPR(X) ? X : 0> _smrtdly_X(X); } while(0)
#if GCC_VERSION <= 70000
#define DELAY_CYCLES_VAR(X) DelayCycleFnc(X)
#else
#define DELAY_CYCLES_VAR DELAY_CYCLES
#endif
// For delay in microseconds, no smart delay selection is required, directly call the delay function
// Teensy compiler is too old and does not accept smart delay compile-time / run-time selection correctly
#define DELAY_US(x) DelayCycleFnc((x) * ((F_CPU) / 1000000UL))
@ -200,9 +206,12 @@ void calibrate_delay_loop();
#endif
#if ENABLED(DELAY_NS_ROUND_DOWN)
#define DELAY_NS(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL) / 1000UL) // floor
#define _NS_TO_CYCLES(x) ( (x) * ((F_CPU) / 1000000UL) / 1000UL) // floor
#elif ENABLED(DELAY_NS_ROUND_CLOSEST)
#define DELAY_NS(x) DELAY_CYCLES(((x) * ((F_CPU) / 1000000UL) + 500) / 1000UL) // round
#define _NS_TO_CYCLES(x) (((x) * ((F_CPU) / 1000000UL) + 500) / 1000UL) // round
#else
#define DELAY_NS(x) DELAY_CYCLES(((x) * ((F_CPU) / 1000000UL) + 999) / 1000UL) // "ceil"
#define _NS_TO_CYCLES(x) (((x) * ((F_CPU) / 1000000UL) + 999) / 1000UL) // "ceil"
#endif
#define DELAY_NS(x) DELAY_CYCLES(_NS_TO_CYCLES(x))
#define DELAY_NS_VAR(x) DELAY_CYCLES_VAR(_NS_TO_CYCLES(x))

9
Marlin/src/HAL/shared/Marduino.h

@ -39,7 +39,7 @@
#define DISABLED(V...) DO(DIS,&&,V)
#undef _BV
#define _BV(b) (1UL << (b))
#define _BV(b) (1 << (b))
#ifndef SBI
#define SBI(A,B) (A |= _BV(B))
#endif
@ -87,3 +87,10 @@
#endif
#include "progmem.h"
class __FlashStringHelper;
typedef const __FlashStringHelper* FSTR_P;
#ifndef FPSTR
#define FPSTR(S) (reinterpret_cast<FSTR_P>(S))
#endif
#define FTOP(S) (reinterpret_cast<const char*>(S))

2
Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp

@ -41,7 +41,7 @@
#define START_FLASH_ADDR 0x00000000
#define END_FLASH_ADDR 0x00080000
#elif defined(__STM32F1__) || defined(STM32F1xx) || defined(STM32F0xx)
#elif defined(__STM32F1__) || defined(STM32F1xx) || defined(STM32F0xx) || defined(STM32G0xx)
// For STM32F103ZET6/STM32F103VET6/STM32F0xx
// SRAM (0x20000000 - 0x20010000) (64kb)

2
Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp

@ -101,7 +101,7 @@ struct __attribute__((packed)) ContextSavedFrame {
uint32_t ELR;
};
#if DISABLED(STM32F0xx)
#if NONE(STM32F0xx, STM32G0xx)
extern "C"
__attribute__((naked)) void CommonHandler_ASM() {
__asm__ __volatile__ (

5
Marlin/src/HAL/shared/progmem.h

@ -38,7 +38,8 @@
#define PSTR(str) (str)
#endif
#ifndef F
#define F(str) (str)
class __FlashStringHelper;
#define F(str) (reinterpret_cast<const __FlashStringHelper *>(PSTR(str)))
#endif
#ifndef _SFR_BYTE
#define _SFR_BYTE(n) (n)
@ -110,7 +111,7 @@
#define strrchr_P(str, c) strrchr((str), (c))
#endif
#ifndef strsep_P
#define strsep_P(strp, delim) strsep((strp), (delim))
#define strsep_P(pstr, delim) strsep((pstr), (delim))
#endif
#ifndef strspn_P
#define strspn_P(str, chrs) strspn((str), (chrs))

72
Marlin/src/MarlinCore.cpp

@ -212,10 +212,18 @@
#include "module/tool_change.h"
#if HAS_FANCHECK
#include "feature/fancheck.h"
#endif
#if ENABLED(USE_CONTROLLER_FAN)
#include "feature/controllerfan.h"
#endif
#if HAS_PRUSA_MMU1
#include "feature/mmu/mmu.h"
#endif
#if HAS_PRUSA_MMU2
#include "feature/mmu/mmu2.h"
#endif
@ -240,6 +248,10 @@
#include "feature/power.h"
#endif
#if ENABLED(EASYTHREED_UI)
#include "feature/easythreed_ui.h"
#endif
PGMSTR(M112_KILL_STR, "M112 Shutdown");
MarlinState marlin_state = MF_INITIALIZING;
@ -357,15 +369,15 @@ void startOrResumeJob() {
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
#ifdef EVENT_GCODE_SD_ABORT
queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT));
queue.inject(F(EVENT_GCODE_SD_ABORT));
#endif
TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine());
}
inline void finishSDPrinting() {
if (queue.enqueue_one_P(PSTR("M1001"))) { // Keep trying until it gets queued
marlin_state = MF_RUNNING; // Signal to stop trying
if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued
marlin_state = MF_RUNNING; // Signal to stop trying
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished());
}
@ -474,7 +486,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
if (!IS_SD_PRINTING() && !READ(HOME_PIN)) { // HOME_PIN goes LOW when pressed
if (ELAPSED(ms, next_home_key_ms)) {
next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
LCD_MESSAGEPGM(MSG_AUTO_HOME);
LCD_MESSAGE(MSG_AUTO_HOME);
queue.inject_P(G28_STR);
}
}
@ -493,14 +505,14 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
if (ELAPSED(ms, next_cub_ms_##N)) { \
next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \
CODE; \
queue.inject_P(PSTR(BUTTON##N##_GCODE)); \
queue.inject(F(BUTTON##N##_GCODE)); \
TERN_(HAS_LCD_MENU, ui.quick_feedback()); \
} \
} \
}while(0)
#define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP)
#define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGEPGM_P(PSTR(BUTTON##N##_DESC)))
#define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP)
#define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGE_F(BUTTON##N##_DESC))
#if HAS_BETTER_USER_BUTTON(1)
CHECK_BETTER_USER_BUTTON(1);
@ -629,6 +641,8 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
#endif
#endif
TERN_(EASYTHREED_UI, easythreed_ui.run());
TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
TERN_(AUTO_POWER_CONTROL, powerManager.check(!ui.on_status_screen() || printJobOngoing() || printingIsPaused()));
@ -770,7 +784,10 @@ void idle(bool no_stepper_sleep/*=false*/) {
(void)check_tool_sensor_stats(active_extruder, true);
// Handle filament runout sensors
TERN_(HAS_FILAMENT_SENSOR, runout.run());
#if HAS_FILAMENT_SENSOR
if (TERN1(HAS_PRUSA_MMU2, !mmu2.enabled()))
runout.run();
#endif
// Run HAL idle tasks
TERN_(HAL_IDLETASK, HAL_idletask());
@ -825,6 +842,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
#if HAS_AUTO_REPORTING
if (!gcode.autoreport_paused) {
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
TERN_(AUTO_REPORT_FANS, fan_check.auto_reporter.tick());
TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick());
TERN_(BUFFER_MONITORING, queue.auto_report_buffer_statistics());
@ -852,16 +870,16 @@ void idle(bool no_stepper_sleep/*=false*/) {
* Kill all activity and lock the machine.
* After this the machine will need to be reset.
*/
void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
thermalManager.disable_all_heaters();
TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
// Echo the LCD message to serial for extra context
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P(lcd_error); }
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); }
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR));
#else
UNUSED(lcd_error); UNUSED(lcd_component);
#endif
@ -872,7 +890,7 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
SERIAL_ERROR_MSG(STR_ERR_KILLED);
#ifdef ACTION_ON_KILL
host_action_kill();
hostui.kill();
#endif
minkill(steppers_off);
@ -935,7 +953,7 @@ void stop() {
if (!IsStopped()) {
SERIAL_ERROR_MSG(STR_ERR_STOPPED);
LCD_MESSAGEPGM(MSG_STOPPED);
LCD_MESSAGE(MSG_STOPPED);
safe_delay(350); // allow enough time for messages to get out before stopping
marlin_state = MF_STOPPED;
}
@ -1100,6 +1118,10 @@ void setup() {
tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable
// Check startup - does nothing if bootloader sets MCUSR to 0
const byte mcu = HAL_get_reset_source();
HAL_clear_reset_source();
#if ENABLED(MARLIN_DEV_MODE)
auto log_current_ms = [&](PGM_P const msg) {
SERIAL_ECHO_START();
@ -1228,15 +1250,14 @@ void setup() {
SETUP_RUN(esp_wifi_init());
// Check startup - does nothing if bootloader sets MCUSR to 0
const byte mcu = HAL_get_reset_source();
// Report Reset Reason
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
HAL_clear_reset_source();
// Identify myself as Marlin x.x.x
SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION);
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
SERIAL_ECHO_MSG(
@ -1268,6 +1289,8 @@ void setup() {
SETUP_RUN(controllerFan.setup());
#endif
TERN_(HAS_FANCHECK, fan_check.init());
// UI must be initialized before EEPROM
// (because EEPROM code calls the UI).
@ -1346,6 +1369,9 @@ void setup() {
#endif
#if HAS_BED_PROBE
#if PIN_EXISTS(PROBE_ENABLE)
OUT_WRITE(PROBE_ENABLE_PIN, LOW); // Disable
#endif
SETUP_RUN(endstops.enable_z_probe(false));
#endif
@ -1521,11 +1547,11 @@ void setup() {
#ifdef STARTUP_COMMANDS
SETUP_LOG("STARTUP_COMMANDS");
queue.inject_P(PSTR(STARTUP_COMMANDS));
queue.inject(F(STARTUP_COMMANDS));
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
SETUP_RUN(host_action_prompt_end());
SETUP_RUN(hostui.prompt_end());
#endif
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
@ -1547,15 +1573,15 @@ void setup() {
#endif
#if HAS_DWIN_E3V2_BASIC
SETUP_LOG("E3V2 Init");
Encoder_Configuration();
HMI_Init();
HMI_SetLanguageCache();
HMI_StartFrame(true);
DWIN_StatusChanged_P(GET_TEXT(WELCOME_MSG));
#endif
#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
ui.reset_status(true); // Show service messages or keep current status
SETUP_RUN(ui.reset_status(true)); // Show service messages or keep current status
#endif
#if ENABLED(MAX7219_DEBUG)
@ -1586,7 +1612,11 @@ void setup() {
#endif
#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI)
ui.check_touch_calibration();
SETUP_RUN(ui.check_touch_calibration());
#endif
#if ENABLED(EASYTHREED_UI)
SETUP_RUN(easythreed_ui.init());
#endif
#if ENABLED(MKS_WIFI)
mks_wifi_init();

2
Marlin/src/MarlinCore.h

@ -38,7 +38,7 @@ inline void idle_no_sleep() { idle(true); }
extern bool G38_did_trigger; // Flag from the ISR to indicate the endstop changed
#endif
void kill(PGM_P const lcd_error=nullptr, PGM_P const lcd_component=nullptr, const bool steppers_off=false);
void kill(FSTR_P const lcd_error=nullptr, FSTR_P const lcd_component=nullptr, const bool steppers_off=false);
void minkill(const bool steppers_off=false);
// Global State of the firmware

82
Marlin/src/core/boards.h

@ -324,39 +324,41 @@
#define BOARD_BTT_SKR_MINI_E3_V1_0 4024 // BigTreeTech SKR Mini E3 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V1_2 4025 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V2_0 4026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE)
#define BOARD_BTT_SKR_MINI_MZ_V1_0 4027 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC)
#define BOARD_BTT_SKR_E3_DIP 4028 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
#define BOARD_BTT_SKR_CR6 4029 // BigTreeTech SKR CR6 v1.0 (STM32F103RE)
#define BOARD_JGAURORA_A5S_A1 4030 // JGAurora A5S A1 (STM32F103ZET6)
#define BOARD_FYSETC_AIO_II 4031 // FYSETC AIO_II
#define BOARD_FYSETC_CHEETAH 4032 // FYSETC Cheetah
#define BOARD_FYSETC_CHEETAH_V12 4033 // FYSETC Cheetah V1.2
#define BOARD_LONGER3D_LK 4034 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
#define BOARD_CCROBOT_MEEB_3DP 4035 // ccrobot-online.com MEEB_3DP (STM32F103RC)
#define BOARD_CHITU3D_V5 4036 // Chitu3D TronXY X5SA V5 Board
#define BOARD_CHITU3D_V6 4037 // Chitu3D TronXY X5SA V6 Board
#define BOARD_CHITU3D_V9 4038 // Chitu3D TronXY X5SA V9 Board
#define BOARD_CREALITY_V4 4039 // Creality v4.x (STM32F103RE)
#define BOARD_CREALITY_V427 4040 // Creality v4.2.7 (STM32F103RE)
#define BOARD_CREALITY_V4210 4041 // Creality v4.2.10 (STM32F103RE) as found in the CR-30
#define BOARD_CREALITY_V431 4042 // Creality v4.3.1 (STM32F103RE)
#define BOARD_CREALITY_V431_A 4043 // Creality v4.3.1a (STM32F103RE)
#define BOARD_CREALITY_V431_B 4044 // Creality v4.3.1b (STM32F103RE)
#define BOARD_CREALITY_V431_C 4045 // Creality v4.3.1c (STM32F103RE)
#define BOARD_CREALITY_V431_D 4046 // Creality v4.3.1d (STM32F103RE)
#define BOARD_CREALITY_V452 4047 // Creality v4.5.2 (STM32F103RE)
#define BOARD_CREALITY_V453 4048 // Creality v4.5.3 (STM32F103RE)
#define BOARD_CREALITY_V24S1 4049 // Creality v2.4.S1 (STM32F103RE) v101 as found in the Ender 7
#define BOARD_TRIGORILLA_PRO 4050 // Trigorilla Pro (STM32F103ZET6)
#define BOARD_FLY_MINI 4051 // FLYmaker FLY MINI (STM32F103RCT6)
#define BOARD_FLSUN_HISPEED 4052 // FLSUN HiSpeedV1 (STM32F103VET6)
#define BOARD_BEAST 4053 // STM32F103RET6 Libmaple-based controller
#define BOARD_MINGDA_MPX_ARM_MINI 4054 // STM32F103ZET6 Mingda MD-16
#define BOARD_GTM32_PRO_VD 4055 // STM32F103VET6 controller
#define BOARD_ZONESTAR_ZM3E2 4056 // Zonestar ZM3E2 (STM32F103RCT6)
#define BOARD_ZONESTAR_ZM3E4 4057 // Zonestar ZM3E4 V1 (STM32F103VCT6)
#define BOARD_ZONESTAR_ZM3E4V2 4058 // Zonestar ZM3E4 V2 (STM32F103VCT6)
#define BOARD_ERYONE_ERY32_MINI 4059 // Eryone Ery32 mini (STM32F103VET6)
#define BOARD_BTT_SKR_MINI_E3_V3_0 4027 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RE)
#define BOARD_BTT_SKR_MINI_MZ_V1_0 4028 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC)
#define BOARD_BTT_SKR_E3_DIP 4029 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
#define BOARD_BTT_SKR_CR6 4030 // BigTreeTech SKR CR6 v1.0 (STM32F103RE)
#define BOARD_JGAURORA_A5S_A1 4031 // JGAurora A5S A1 (STM32F103ZET6)
#define BOARD_FYSETC_AIO_II 4032 // FYSETC AIO_II
#define BOARD_FYSETC_CHEETAH 4033 // FYSETC Cheetah
#define BOARD_FYSETC_CHEETAH_V12 4034 // FYSETC Cheetah V1.2
#define BOARD_LONGER3D_LK 4035 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
#define BOARD_CCROBOT_MEEB_3DP 4036 // ccrobot-online.com MEEB_3DP (STM32F103RC)
#define BOARD_CHITU3D_V5 4037 // Chitu3D TronXY X5SA V5 Board
#define BOARD_CHITU3D_V6 4038 // Chitu3D TronXY X5SA V6 Board
#define BOARD_CHITU3D_V9 4039 // Chitu3D TronXY X5SA V9 Board
#define BOARD_CREALITY_V4 4040 // Creality v4.x (STM32F103RE)
#define BOARD_CREALITY_V423 4041 // Creality v4.2.3 (STM32F103RE)
#define BOARD_CREALITY_V427 4042 // Creality v4.2.7 (STM32F103RE)
#define BOARD_CREALITY_V4210 4043 // Creality v4.2.10 (STM32F103RE) as found in the CR-30
#define BOARD_CREALITY_V431 4044 // Creality v4.3.1 (STM32F103RE)
#define BOARD_CREALITY_V431_A 4045 // Creality v4.3.1a (STM32F103RE)
#define BOARD_CREALITY_V431_B 4046 // Creality v4.3.1b (STM32F103RE)
#define BOARD_CREALITY_V431_C 4047 // Creality v4.3.1c (STM32F103RE)
#define BOARD_CREALITY_V431_D 4048 // Creality v4.3.1d (STM32F103RE)
#define BOARD_CREALITY_V452 4049 // Creality v4.5.2 (STM32F103RE)
#define BOARD_CREALITY_V453 4050 // Creality v4.5.3 (STM32F103RE)
#define BOARD_CREALITY_V24S1 4051 // Creality v2.4.S1 (STM32F103RE) v101 as found in the Ender 7
#define BOARD_TRIGORILLA_PRO 4052 // Trigorilla Pro (STM32F103ZET6)
#define BOARD_FLY_MINI 4053 // FLYmaker FLY MINI (STM32F103RCT6)
#define BOARD_FLSUN_HISPEED 4054 // FLSUN HiSpeedV1 (STM32F103VET6)
#define BOARD_BEAST 4055 // STM32F103RET6 Libmaple-based controller
#define BOARD_MINGDA_MPX_ARM_MINI 4056 // STM32F103ZET6 Mingda MD-16
#define BOARD_GTM32_PRO_VD 4057 // STM32F103VET6 controller
#define BOARD_ZONESTAR_ZM3E2 4058 // Zonestar ZM3E2 (STM32F103RCT6)
#define BOARD_ZONESTAR_ZM3E4 4059 // Zonestar ZM3E4 V1 (STM32F103VCT6)
#define BOARD_ZONESTAR_ZM3E4V2 4060 // Zonestar ZM3E4 V2 (STM32F103VCT6)
#define BOARD_ERYONE_ERY32_MINI 4061 // Eryone Ery32 mini (STM32F103VET6)
//
// ARM Cortex-M4F
@ -382,7 +384,7 @@
#define BOARD_BTT_BTT002_V1_0 4210 // BigTreeTech BTT002 v1.0 (STM32F407VGT6)
#define BOARD_BTT_E3_RRF 4211 // BigTreeTech E3 RRF (STM32F407VGT6)
#define BOARD_BTT_SKR_V2_0_REV_A 4212 // BigTreeTech SKR v2.0 Rev A (STM32F407VGT6)
#define BOARD_BTT_SKR_V2_0_REV_B 4213 // BigTreeTech SKR v2.0 Rev B (STM32F407VGT6)
#define BOARD_BTT_SKR_V2_0_REV_B 4213 // BigTreeTech SKR v2.0 Rev B (STM32F407VGT6/STM32F429VGT6)
#define BOARD_BTT_GTR_V1_0 4214 // BigTreeTech GTR v1.0 (STM32F407IGT)
#define BOARD_BTT_OCTOPUS_V1_0 4215 // BigTreeTech Octopus v1.0 (STM32F446ZET6)
#define BOARD_BTT_OCTOPUS_V1_1 4216 // BigTreeTech Octopus v1.1 (STM32F446ZET6)
@ -402,10 +404,12 @@
#define BOARD_ANET_ET4 4230 // ANET ET4 V1.x (STM32F407VGT6)
#define BOARD_ANET_ET4P 4231 // ANET ET4P V1.x (STM32F407VGT6)
#define BOARD_FYSETC_CHEETAH_V20 4232 // FYSETC Cheetah V2.0
#define BOARD_TH3D_EZBOARD_LITE_V2 4233 // TH3D EZBoard Lite v2.0
#define BOARD_TH3D_EZBOARD_V2 4233 // TH3D EZBoard v2.0
#define BOARD_INDEX_REV03 4234 // Index PnP Controller REV03 (STM32F407VET6/VGT6)
#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4235 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VET6)
#define BOARD_MKS_EAGLE 4236 // MKS Eagle (STM32F407VET6)
#define BOARD_ARTILLERY_RUBY 4237 // Artillery Ruby (STM32F401RCT6)
#define BOARD_FYSETC_SPIDER_V2_2 4238 // FYSETC Spider V2.2 (STM32F446VET6)
//
// ARM Cortex M7
@ -425,9 +429,11 @@
#define BOARD_MRR_ESPA 6001 // MRR ESPA based on ESP32 (native pins only)
#define BOARD_MRR_ESPE 6002 // MRR ESPE based on ESP32 (with I2S stepper stream)
#define BOARD_E4D_BOX 6003 // E4d@BOX
#define BOARD_FYSETC_E4 6004 // FYSETC E4
#define BOARD_PANDA_ZHU 6005 // Panda_ZHU
#define BOARD_PANDA_M4 6006 // Panda_M4
#define BOARD_RESP32_CUSTOM 6004 // Rutilea ESP32 custom board
#define BOARD_FYSETC_E4 6005 // FYSETC E4
#define BOARD_PANDA_ZHU 6006 // Panda_ZHU
#define BOARD_PANDA_M4 6007 // Panda_M4
#define BOARD_MKS_TINYBEE 6008 // MKS TinyBee based on ESP32 (with I2S stepper stream)
//
// SAMD51 ARM Cortex M4

8
Marlin/src/core/debug_out.h

@ -36,6 +36,8 @@
#undef DEBUG_ECHOLN
#undef DEBUG_ECHOPGM
#undef DEBUG_ECHOLNPGM
#undef DEBUG_ECHOF
#undef DEBUG_ECHOLNF
#undef DEBUG_ECHOPGM_P
#undef DEBUG_ECHOLNPGM_P
#undef DEBUG_ECHOPAIR_F
@ -54,7 +56,7 @@
#if DEBUG_OUT
#include "debug_section.h"
#define DEBUG_SECTION(N,S,D) SectionLog N(PSTR(S),D)
#define DEBUG_SECTION(N,S,D) SectionLog N(F(S),D)
#define DEBUG_ECHO_START SERIAL_ECHO_START
#define DEBUG_ERROR_START SERIAL_ERROR_START
@ -65,6 +67,8 @@
#define DEBUG_ECHOLN SERIAL_ECHOLN
#define DEBUG_ECHOPGM SERIAL_ECHOPGM
#define DEBUG_ECHOLNPGM SERIAL_ECHOLNPGM
#define DEBUG_ECHOF SERIAL_ECHOF
#define DEBUG_ECHOLNF SERIAL_ECHOLNF
#define DEBUG_ECHOPGM SERIAL_ECHOPGM
#define DEBUG_ECHOPGM_P SERIAL_ECHOPGM_P
#define DEBUG_ECHOPAIR_F SERIAL_ECHOPAIR_F
@ -94,6 +98,8 @@
#define DEBUG_ECHOLN(...) NOOP
#define DEBUG_ECHOPGM(...) NOOP
#define DEBUG_ECHOLNPGM(...) NOOP
#define DEBUG_ECHOF(...) NOOP
#define DEBUG_ECHOLNF(...) NOOP
#define DEBUG_ECHOPGM_P(...) NOOP
#define DEBUG_ECHOLNPGM_P(...) NOOP
#define DEBUG_ECHOPAIR_F(...) NOOP

16
Marlin/src/core/debug_section.h

@ -26,22 +26,22 @@
class SectionLog {
public:
SectionLog(PGM_P const msg=nullptr, bool inbug=true) {
the_msg = msg;
if ((debug = inbug)) echo_msg(PSTR(">>>"));
SectionLog(FSTR_P const fmsg=nullptr, bool inbug=true) {
the_msg = fmsg;
if ((debug = inbug)) echo_msg(F(">>>"));
}
~SectionLog() { if (debug) echo_msg(PSTR("<<<")); }
~SectionLog() { if (debug) echo_msg(F("<<<")); }
private:
PGM_P the_msg;
FSTR_P the_msg;
bool debug;
void echo_msg(PGM_P const pre) {
SERIAL_ECHOPGM_P(pre);
void echo_msg(FSTR_P const fpre) {
SERIAL_ECHOF(fpre);
if (the_msg) {
SERIAL_CHAR(' ');
SERIAL_ECHOPGM_P(the_msg);
SERIAL_ECHOF(the_msg);
}
SERIAL_CHAR(' ');
print_pos(current_position);

1
Marlin/src/core/language.h

@ -140,6 +140,7 @@
#define STR_RESEND "Resend: "
#define STR_UNKNOWN_COMMAND "Unknown command: \""
#define STR_ACTIVE_EXTRUDER "Active Extruder: "
#define STR_ERR_FANSPEED "Fan speed E"
#define STR_PROBE_OFFSET "Probe Offset"
#define STR_SKEW_MIN "min_skew_factor: "

38
Marlin/src/core/macros.h

@ -33,6 +33,12 @@
#define _AXIS(A) (A##_AXIS)
#define _XSTOP_ 0x01
#define _YSTOP_ 0x02
#define _ZSTOP_ 0x03
#define _ISTOP_ 0x04
#define _JSTOP_ 0x05
#define _KSTOP_ 0x06
#define _XMIN_ 0x11
#define _YMIN_ 0x12
#define _ZMIN_ 0x13
@ -160,7 +166,7 @@
#endif
// Macros to chain up to 14 conditions
// Macros to chain up to 40 conditions
#define _DO_1(W,C,A) (_##W##_1(A))
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B))
#define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V))
@ -176,6 +182,31 @@
#define _DO_13(W,C,A,V...) (_##W##_1(A) C _DO_12(W,C,V))
#define _DO_14(W,C,A,V...) (_##W##_1(A) C _DO_13(W,C,V))
#define _DO_15(W,C,A,V...) (_##W##_1(A) C _DO_14(W,C,V))
#define _DO_16(W,C,A,V...) (_##W##_1(A) C _DO_15(W,C,V))
#define _DO_17(W,C,A,V...) (_##W##_1(A) C _DO_16(W,C,V))
#define _DO_18(W,C,A,V...) (_##W##_1(A) C _DO_17(W,C,V))
#define _DO_19(W,C,A,V...) (_##W##_1(A) C _DO_18(W,C,V))
#define _DO_20(W,C,A,V...) (_##W##_1(A) C _DO_19(W,C,V))
#define _DO_21(W,C,A,V...) (_##W##_1(A) C _DO_20(W,C,V))
#define _DO_22(W,C,A,V...) (_##W##_1(A) C _DO_21(W,C,V))
#define _DO_23(W,C,A,V...) (_##W##_1(A) C _DO_22(W,C,V))
#define _DO_24(W,C,A,V...) (_##W##_1(A) C _DO_23(W,C,V))
#define _DO_25(W,C,A,V...) (_##W##_1(A) C _DO_24(W,C,V))
#define _DO_26(W,C,A,V...) (_##W##_1(A) C _DO_25(W,C,V))
#define _DO_27(W,C,A,V...) (_##W##_1(A) C _DO_26(W,C,V))
#define _DO_28(W,C,A,V...) (_##W##_1(A) C _DO_27(W,C,V))
#define _DO_29(W,C,A,V...) (_##W##_1(A) C _DO_28(W,C,V))
#define _DO_30(W,C,A,V...) (_##W##_1(A) C _DO_29(W,C,V))
#define _DO_31(W,C,A,V...) (_##W##_1(A) C _DO_30(W,C,V))
#define _DO_32(W,C,A,V...) (_##W##_1(A) C _DO_31(W,C,V))
#define _DO_33(W,C,A,V...) (_##W##_1(A) C _DO_32(W,C,V))
#define _DO_34(W,C,A,V...) (_##W##_1(A) C _DO_33(W,C,V))
#define _DO_35(W,C,A,V...) (_##W##_1(A) C _DO_34(W,C,V))
#define _DO_36(W,C,A,V...) (_##W##_1(A) C _DO_35(W,C,V))
#define _DO_37(W,C,A,V...) (_##W##_1(A) C _DO_36(W,C,V))
#define _DO_38(W,C,A,V...) (_##W##_1(A) C _DO_37(W,C,V))
#define _DO_39(W,C,A,V...) (_##W##_1(A) C _DO_38(W,C,V))
#define _DO_40(W,C,A,V...) (_##W##_1(A) C _DO_39(W,C,V))
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
#define DO(W,C,V...) (_DO_N(W,C,NUM_ARGS(V),V))
@ -251,6 +282,11 @@
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
}while(0)
#define CODE_16( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O; P
#define CODE_15( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O
#define CODE_14( A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N
#define CODE_13( A,B,C,D,E,F,G,H,I,J,K,L,M,...) A; B; C; D; E; F; G; H; I; J; K; L; M
#define CODE_12( A,B,C,D,E,F,G,H,I,J,K,L,...) A; B; C; D; E; F; G; H; I; J; K; L
#define CODE_11( A,B,C,D,E,F,G,H,I,J,K,...) A; B; C; D; E; F; G; H; I; J; K
#define CODE_10( A,B,C,D,E,F,G,H,I,J,...) A; B; C; D; E; F; G; H; I; J
#define CODE_9( A,B,C,D,E,F,G,H,I,...) A; B; C; D; E; F; G; H; I

24
Marlin/src/core/serial.cpp

@ -69,23 +69,23 @@ PGMSTR(SP_I_LBL, " " AXIS4_STR ":"); PGMSTR(SP_J_LBL, " " AXIS5_STR ":"); PGMSTR
#endif
void serialprintPGM(PGM_P str) {
void serial_print_P(PGM_P str) {
while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c);
}
void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serialprintPGM(echomagic); }
void serial_error_start() { static PGMSTR(errormagic, "Error:"); serialprintPGM(errormagic); }
void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serial_print_P(echomagic); }
void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P(errormagic); }
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post/*=nullptr*/) {
if (pre) serialprintPGM(pre);
serialprintPGM(onoff ? on : off);
if (post) serialprintPGM(post);
void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) {
if (pre) serial_print(pre);
serial_print(onoff ? on : off);
if (post) serial_print(post);
}
void serialprint_onoff(const bool onoff) { serialprintPGM(onoff ? PSTR(STR_ON) : PSTR(STR_OFF)); }
void serialprint_onoff(const bool onoff) { serial_print(onoff ? F(STR_ON) : F(STR_OFF)); }
void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
void serialprint_truefalse(const bool tf) { serialprintPGM(tf ? PSTR("true") : PSTR("false")); }
void serialprint_truefalse(const bool tf) { serial_print(tf ? F("true") : F("false")); }
void print_bin(uint16_t val) {
for (uint8_t i = 16; i--;) {
@ -94,10 +94,10 @@ void print_bin(uint16_t val) {
}
}
void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) {
if (prefix) serialprintPGM(prefix);
void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) {
if (prefix) serial_print(prefix);
SERIAL_ECHOPGM_P(
LIST_N(DOUBLE(LINEAR_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k)
);
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
if (suffix) serial_print(suffix); else SERIAL_EOL();
}

128
Marlin/src/core/serial.h

@ -87,7 +87,7 @@ extern uint8_t marlin_debug_flags;
// interface with the ability to output to multiple serial ports.
#if HAS_MULTI_SERIAL
#define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p)
#define _PORT_RESTORE(n,p) RESTORE(n)
#define _PORT_RESTORE(n) RESTORE(n)
#define SERIAL_ASSERT(P) if (multiSerial.portMask!=(P)) { debugger(); }
// If we have a catchall, use that directly
#ifdef SERIAL_CATCHALL
@ -167,13 +167,10 @@ inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); }
#define AS_CHAR(C) serial_char_t(C)
#define AS_DIGIT(C) AS_CHAR('0' + (C))
// SERIAL_ECHO_F prints a floating point value with optional precision
inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }
template <typename T>
void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); }
// SERIAL_PRINT works like SERIAL_ECHO but allow to specify the encoding base of the number printed
// SERIAL_PRINT works like SERIAL_ECHO but also takes the numeric base
template <typename T, typename U>
void SERIAL_PRINT(T x, U y) { SERIAL_IMPL.print(x, y); }
@ -184,8 +181,20 @@ void SERIAL_PRINTLN(T x, PrintBase y) { SERIAL_IMPL.println(x, y); }
inline void SERIAL_FLUSH() { SERIAL_IMPL.flush(); }
inline void SERIAL_FLUSHTX() { SERIAL_IMPL.flushTX(); }
// Print a single PROGMEM string to serial
void serialprintPGM(PGM_P str);
// Serial echo and error prefixes
#define SERIAL_ECHO_START() serial_echo_start()
#define SERIAL_ERROR_START() serial_error_start()
// Serial end-of-line
#define SERIAL_EOL() SERIAL_CHAR('\n')
// Print a single PROGMEM, PGM_P, or PSTR() string.
void serial_print_P(PGM_P str);
inline void serial_println_P(PGM_P str) { serial_print_P(str); SERIAL_EOL(); }
// Print a single FSTR_P, F(), or FPSTR() string.
inline void serial_print(FSTR_P const fstr) { serial_print_P(FTOP(fstr)); }
inline void serial_println(FSTR_P const fstr) { serial_println_P(FTOP(fstr)); }
//
// SERIAL_ECHOPGM... macros are used to output string-value pairs.
@ -195,8 +204,8 @@ void serialprintPGM(PGM_P str);
#define __SEP_N(N,V...) _SEP_##N(V)
#define _SEP_N(N,V...) __SEP_N(N,V)
#define _SEP_N_REF() _SEP_N
#define _SEP_1(s) serialprintPGM(PSTR(s));
#define _SEP_2(s,v) serial_echopair_PGM(PSTR(s),v);
#define _SEP_1(s) serial_print(F(s));
#define _SEP_2(s,v) serial_echopair(F(s),v);
#define _SEP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SEP_N_REF)()(TWO_ARGS(V),V);
#define SERIAL_ECHOPGM(V...) do{ EVAL(_SEP_N(TWO_ARGS(V),V)); }while(0)
@ -204,8 +213,8 @@ void serialprintPGM(PGM_P str);
#define __SELP_N(N,V...) _SELP_##N(V)
#define _SELP_N(N,V...) __SELP_N(N,V)
#define _SELP_N_REF() _SELP_N
#define _SELP_1(s) serialprintPGM(PSTR(s "\n"));
#define _SELP_2(s,v) serial_echopair_PGM(PSTR(s),v); SERIAL_EOL();
#define _SELP_1(s) serial_print(F(s "\n"));
#define _SELP_2(s,v) serial_echolnpair(F(s),v);
#define _SELP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SELP_N_REF)()(TWO_ARGS(V),V);
#define SERIAL_ECHOLNPGM(V...) do{ EVAL(_SELP_N(TWO_ARGS(V),V)); }while(0)
@ -213,8 +222,8 @@ void serialprintPGM(PGM_P str);
#define __SEP_N_P(N,V...) _SEP_##N##_P(V)
#define _SEP_N_P(N,V...) __SEP_N_P(N,V)
#define _SEP_N_P_REF() _SEP_N_P
#define _SEP_1_P(p) serialprintPGM(p);
#define _SEP_2_P(p,v) serial_echopair_PGM(p,v);
#define _SEP_1_P(p) serial_print_P(p);
#define _SEP_2_P(p,v) serial_echopair_P(p,v);
#define _SEP_3_P(p,v,V...) _SEP_2_P(p,v); DEFER2(_SEP_N_P_REF)()(TWO_ARGS(V),V);
#define SERIAL_ECHOPGM_P(V...) do{ EVAL(_SEP_N_P(TWO_ARGS(V),V)); }while(0)
@ -222,11 +231,29 @@ void serialprintPGM(PGM_P str);
#define __SELP_N_P(N,V...) _SELP_##N##_P(V)
#define _SELP_N_P(N,V...) __SELP_N_P(N,V)
#define _SELP_N_P_REF() _SELP_N_P
#define _SELP_1_P(p) { serialprintPGM(p); SERIAL_EOL(); }
#define _SELP_2_P(p,v) { serial_echopair_PGM(p,v); SERIAL_EOL(); }
#define _SELP_1_P(p) serial_println_P(p)
#define _SELP_2_P(p,v) serial_echolnpair_P(p,v)
#define _SELP_3_P(p,v,V...) { _SEP_2_P(p,v); DEFER2(_SELP_N_P_REF)()(TWO_ARGS(V),V); }
#define SERIAL_ECHOLNPGM_P(V...) do{ EVAL(_SELP_N_P(TWO_ARGS(V),V)); }while(0)
// Print up to 20 pairs of values. Odd elements must be FSTR_P, F(), or FPSTR().
#define __SEP_N_F(N,V...) _SEP_##N##_F(V)
#define _SEP_N_F(N,V...) __SEP_N_F(N,V)
#define _SEP_N_F_REF() _SEP_N_F
#define _SEP_1_F(p) serial_print(p);
#define _SEP_2_F(p,v) serial_echopair(p,v);
#define _SEP_3_F(p,v,V...) _SEP_2_F(p,v); DEFER2(_SEP_N_F_REF)()(TWO_ARGS(V),V);
#define SERIAL_ECHOF(V...) do{ EVAL(_SEP_N_F(TWO_ARGS(V),V)); }while(0)
// Print up to 20 pairs of values followed by newline. Odd elements must be FSTR_P, F(), or FPSTR().
#define __SELP_N_F(N,V...) _SELP_##N##_F(V)
#define _SELP_N_F(N,V...) __SELP_N_F(N,V)
#define _SELP_N_F_REF() _SELP_N_F
#define _SELP_1_F(p) serial_println(p)
#define _SELP_2_F(p,v) serial_echolnpair(p,v)
#define _SELP_3_F(p,v,V...) { _SEP_2_F(p,v); DEFER2(_SELP_N_F_REF)()(TWO_ARGS(V),V); }
#define SERIAL_ECHOLNF(V...) do{ EVAL(_SELP_N_F(TWO_ARGS(V),V)); }while(0)
#ifdef AllowDifferentTypeInList
inline void SERIAL_ECHOLIST_IMPL() {}
@ -236,47 +263,49 @@ void serialprintPGM(PGM_P str);
template <typename T, typename ... Args>
void SERIAL_ECHOLIST_IMPL(T && t, Args && ... args) {
SERIAL_IMPL.print(t);
serialprintPGM(PSTR(", "));
serial_print(F(", "));
SERIAL_ECHOLIST_IMPL(args...);
}
template <typename ... Args>
void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) {
SERIAL_IMPL.print(str);
void SERIAL_ECHOLIST(FSTR_P const str, Args && ... args) {
SERIAL_IMPL.print(FTOP(str));
SERIAL_ECHOLIST_IMPL(args...);
}
#else // Optimization if the listed type are all the same (seems to be the case in the codebase so use that instead)
template <typename ... Args>
void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) {
serialprintPGM(str);
void SERIAL_ECHOLIST(FSTR_P const fstr, Args && ... args) {
serial_print(fstr);
typename Private::first_type_of<Args...>::type values[] = { args... };
constexpr size_t argsSize = sizeof...(args);
for (size_t i = 0; i < argsSize; i++) {
if (i) serialprintPGM(PSTR(", "));
if (i) serial_print(F(", "));
SERIAL_IMPL.print(values[i]);
}
}
#endif
#define SERIAL_ECHOPAIR_F_P(P,V...) do{ serialprintPGM(P); SERIAL_ECHO_F(V); }while(0)
#define SERIAL_ECHOLNPAIR_F_P(V...) do{ SERIAL_ECHOPAIR_F_P(V); SERIAL_EOL(); }while(0)
// SERIAL_ECHO_F prints a floating point value with optional precision
inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }
#define SERIAL_ECHOPAIR_F_P(P,V...) do{ serial_print_P(P); SERIAL_ECHO_F(V); }while(0)
#define SERIAL_ECHOLNPAIR_F_P(P,V...) do{ SERIAL_ECHOPAIR_F_P(P,V); SERIAL_EOL(); }while(0)
#define SERIAL_ECHOPAIR_F(S,V...) SERIAL_ECHOPAIR_F_P(PSTR(S),V)
#define SERIAL_ECHOLNPAIR_F(V...) do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0)
#define SERIAL_ECHOPAIR_F_F(S,V...) do{ serial_print(S); SERIAL_ECHO_F(V); }while(0)
#define SERIAL_ECHOLNPAIR_F_F(S,V...) do{ SERIAL_ECHOPAIR_F_F(S,V); SERIAL_EOL(); }while(0)
#define SERIAL_ECHO_START() serial_echo_start()
#define SERIAL_ERROR_START() serial_error_start()
#define SERIAL_EOL() SERIAL_CHAR('\n')
#define SERIAL_ECHOPAIR_F(S,V...) SERIAL_ECHOPAIR_F_F(F(S),V)
#define SERIAL_ECHOLNPAIR_F(V...) do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0)
#define SERIAL_ECHO_MSG(V...) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0)
#define SERIAL_ERROR_MSG(V...) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0)
#define SERIAL_ECHO_MSG(V...) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0)
#define SERIAL_ERROR_MSG(V...) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0)
#define SERIAL_ECHO_SP(C) serial_spaces(C)
#define SERIAL_ECHO_SP(C) serial_spaces(C)
#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, PSTR(PRE), PSTR(ON), PSTR(OFF), PSTR(POST))
#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, F(PRE), F(ON), F(OFF), F(POST))
#if SERIAL_FLOAT_PRECISION
#define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION)
@ -287,33 +316,42 @@ void serialprintPGM(PGM_P str);
//
// Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
//
inline void serial_echopair_PGM(PGM_P const s_P, serial_char_t v) { serialprintPGM(s_P); SERIAL_CHAR(v.c); }
inline void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); }
inline void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); }
inline void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
inline void serial_echopair_P(PGM_P const pstr, serial_char_t v) { serial_print_P(pstr); SERIAL_CHAR(v.c); }
inline void serial_echopair_P(PGM_P const pstr, float v) { serial_print_P(pstr); SERIAL_DECIMAL(v); }
inline void serial_echopair_P(PGM_P const pstr, double v) { serial_print_P(pstr); SERIAL_DECIMAL(v); }
//inline void serial_echopair_P(PGM_P const pstr, const char *v) { serial_print_P(pstr); SERIAL_ECHO(v); }
inline void serial_echopair_P(PGM_P const pstr, FSTR_P v) { serial_print_P(pstr); SERIAL_ECHOF(v); }
// Default implementation for types without a specialization. Handles integers.
template <typename T>
void serial_echopair_PGM(PGM_P const s_P, T v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
inline void serial_echopair_P(PGM_P const pstr, T v) { serial_print_P(pstr); SERIAL_ECHO(v); }
// Add a newline.
template <typename T>
inline void serial_echolnpair_P(PGM_P const pstr, T v) { serial_echopair_P(pstr, v); SERIAL_EOL(); }
// Catch-all for __FlashStringHelper *
template <typename T>
inline void serial_echopair(FSTR_P const fstr, T v) { serial_echopair_P(FTOP(fstr), v); }
inline void serial_echopair_PGM(PGM_P const s_P, bool v) { serial_echopair_PGM(s_P, (int)v); }
inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (uintptr_t)v); }
// Add a newline to the serial output
template <typename T>
inline void serial_echolnpair(FSTR_P const fstr, T v) { serial_echolnpair_P(FTOP(fstr), v); }
void serial_echo_start();
void serial_error_start();
void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post=nullptr);
void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr);
void serialprint_onoff(const bool onoff);
void serialprintln_onoff(const bool onoff);
void serialprint_truefalse(const bool tf);
void serial_spaces(uint8_t count);
void print_bin(const uint16_t val);
void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix=nullptr, PGM_P const suffix=nullptr);
void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr);
inline void print_pos(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) {
inline void print_pos(const xyz_pos_t &xyz, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) {
print_pos(LINEAR_AXIS_ELEM(xyz), prefix, suffix);
}
#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0)
#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, PSTR(PREFIX), nullptr); }while(0)
#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0)
#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, F(PREFIX)); }while(0)

9
Marlin/src/core/types.h

@ -26,13 +26,6 @@
#include "../inc/MarlinConfigPre.h"
class __FlashStringHelper;
typedef const __FlashStringHelper* FSTR_P;
#ifndef FPSTR
#define FPSTR(S) (reinterpret_cast<FSTR_P>(S))
#endif
#define FTOP(S) (reinterpret_cast<const char*>(S))
//
// Conditional type assignment magic. For example...
//
@ -89,7 +82,7 @@ enum AxisEnum : uint8_t {
#undef _EN_ITEM
// Core also keeps toolhead directions
#if EITHER(IS_CORE, MARKFORGED_XY)
#if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
, X_HEAD, Y_HEAD, Z_HEAD
#endif

9
Marlin/src/core/utility.cpp

@ -60,7 +60,8 @@ void safe_delay(millis_t ms) {
TERN_(DELTA, "Delta")
TERN_(IS_SCARA, "SCARA")
TERN_(IS_CORE, "Core")
TERN_(MARKFORGED_XY, "MarkForged")
TERN_(MARKFORGED_XY, "MarkForgedXY")
TERN_(MARKFORGED_YX, "MarkForgedYX")
TERN_(IS_CARTESIAN, "Cartesian")
);
@ -92,9 +93,9 @@ void safe_delay(millis_t ms) {
SERIAL_ECHOPGM(" (Aligned With");
if (probe.offset_xy.y > 0)
SERIAL_ECHOPGM_P(ENABLED(IS_SCARA) ? PSTR("-Distal") : PSTR("-Back"));
SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back")));
else if (probe.offset_xy.y < 0)
SERIAL_ECHOPGM_P(ENABLED(IS_SCARA) ? PSTR("-Proximal") : PSTR("-Front"));
SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front")));
else if (probe.offset_xy.x != 0)
SERIAL_ECHOPGM("-Center");
@ -102,7 +103,7 @@ void safe_delay(millis_t ms) {
#endif
SERIAL_ECHOPGM_P(probe.offset.z < 0 ? PSTR("Below") : probe.offset.z > 0 ? PSTR("Above") : PSTR("Same Z as"));
SERIAL_ECHOF(probe.offset.z < 0 ? F("Below") : probe.offset.z > 0 ? F("Above") : F("Same Z as"));
SERIAL_ECHOLNPGM(" Nozzle)");
#endif

104
Marlin/src/feature/adc/adc_mcp3426.cpp

@ -0,0 +1,104 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* adc_mcp3426.cpp - library for MicroChip MCP3426 I2C A/D converter
*
* For implementation details, please take a look at the datasheet:
* https://www.microchip.com/en-us/product/MCP3426
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(HAS_MCP3426_ADC)
#include "adc_mcp3426.h"
// Read the ADC value from MCP342X on a specific channel
int16_t MCP3426::ReadValue(uint8_t channel, uint8_t gain) {
Error = false;
#if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
Wire.setSDA(pin_t(I2C_SDA_PIN));
Wire.setSCL(pin_t(I2C_SCL_PIN));
#endif
Wire.begin(); // No address joins the BUS as the master
Wire.beginTransmission(I2C_ADDRESS(MCP342X_ADC_I2C_ADDRESS));
// Continuous Conversion Mode, 16 bit, Channel 1, Gain x4
// 26 = 0b00011000
// RXXCSSGG
// R = Ready Bit
// XX = Channel (00=1, 01=2, 10=3 (MCP3428), 11=4 (MCP3428))
// C = Conversion Mode Bit (1= Continuous Conversion Mode (Default))
// SS = Sample rate, 10=15 samples per second @ 16 bits
// GG = Gain 00 =x1
uint8_t controlRegister = 0b00011000;
if (channel == 2) controlRegister |= 0b00100000; // Select channel 2
if (gain == 2)
controlRegister |= 0b00000001;
else if (gain == 4)
controlRegister |= 0b00000010;
else if (gain == 8)
controlRegister |= 0b00000011;
Wire.write(controlRegister);
if (Wire.endTransmission() != 0) {
Error = true;
return 0;
}
const uint8_t len = 3;
uint8_t buffer[len] = {};
do {
Wire.requestFrom(I2C_ADDRESS(MCP342X_ADC_I2C_ADDRESS), len);
if (Wire.available() != len) {
Error = true;
return 0;
}
for (uint8_t i = 0; i < len; ++i)
buffer[i] = Wire.read();
// Is conversion ready, if not loop around again
} while ((buffer[2] & 0x80) != 0);
union TwoBytesToInt16 {
uint8_t bytes[2];
int16_t integervalue;
};
TwoBytesToInt16 ConversionUnion;
ConversionUnion.bytes[1] = buffer[0];
ConversionUnion.bytes[0] = buffer[1];
return ConversionUnion.integervalue;
}
MCP3426 mcp3426;
#endif // HAS_MCP3426_ADC

41
Marlin/src/feature/adc/adc_mcp3426.h

@ -0,0 +1,41 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Arduino library for MicroChip MCP3426 I2C A/D converter.
* https://www.microchip.com/en-us/product/MCP3426
*/
#include <stdint.h>
#include <Wire.h>
// Address of MCP342X chip
#define MCP342X_ADC_I2C_ADDRESS 104
class MCP3426 {
public:
int16_t ReadValue(uint8_t channel, uint8_t gain);
bool Error;
};
extern MCP3426 mcp3426;

2
Marlin/src/feature/backlash.cpp

@ -64,7 +64,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
static axis_bits_t last_direction_bits;
axis_bits_t changed_dir = last_direction_bits ^ dm;
// Ignore direction change unless steps are taken in that direction
#if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY)
#if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX)
if (!da) CBI(changed_dir, X_AXIS);
if (!db) CBI(changed_dir, Y_AXIS);
if (!dc) CBI(changed_dir, Z_AXIS);

59
Marlin/src/feature/bedlevel/abl/x_twist.cpp

@ -0,0 +1,59 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
#include "../bedlevel.h"
XATC xatc;
float XATC::spacing, XATC::start;
xatc_points_t XATC::z_values;
void XATC::print_points() {
SERIAL_ECHOLNPGM(" X-Twist Correction:");
LOOP_L_N(x, XATC_MAX_POINTS) {
SERIAL_CHAR(' ');
if (!isnan(z_values[x])) {
if (z_values[x] >= 0) SERIAL_CHAR('+');
SERIAL_ECHO_F(z_values[x], 3);
}
else {
LOOP_L_N(i, 6)
SERIAL_CHAR(i ? '=' : ' ');
}
}
SERIAL_EOL();
}
float lerp(const_float_t t, const_float_t a, const_float_t b) { return a + t * (b - a); }
float XATC::compensation(const xy_pos_t &raw) {
float t = (raw.x - start) / spacing;
int i = FLOOR(t);
LIMIT(i, 0, XATC_MAX_POINTS - 2);
t -= i;
return lerp(t, z_values[i], z_values[i + 1]);
}
#endif // X_AXIS_TWIST_COMPENSATION

37
Marlin/src/feature/bedlevel/abl/x_twist.h

@ -0,0 +1,37 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../../../inc/MarlinConfigPre.h"
typedef float xatc_points_t[XATC_MAX_POINTS];
class XATC {
public:
static float spacing, start;
static xatc_points_t z_values;
static float compensation(const xy_pos_t &raw);
static void print_points();
};
extern XATC xatc;

3
Marlin/src/feature/bedlevel/bedlevel.h

@ -63,6 +63,9 @@ class TemporaryBedLevelingState {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
#include "abl/abl.h"
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
#include "abl/x_twist.h"
#endif
#elif ENABLED(AUTO_BED_LEVELING_UBL)
#include "ubl/ubl.h"
#elif ENABLED(MESH_BED_LEVELING)

22
Marlin/src/feature/bedlevel/ubl/ubl.cpp

@ -180,10 +180,8 @@ void unified_bed_leveling::display_map(const uint8_t map_type) {
SERIAL_EOL();
serial_echo_column_labels(eachsp - 2);
}
else {
SERIAL_ECHOPGM(" for ");
SERIAL_ECHOPGM_P(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
}
else
SERIAL_ECHOPGM(" for ", csv ? F("CSV:\n") : F("LCD:\n"));
// Add XY probe offset from extruder because probe.probe_at_point() subtracts them when
// moving to the XY position to be measured. This ensures better agreement between
@ -213,7 +211,7 @@ void unified_bed_leveling::display_map(const uint8_t map_type) {
// TODO: Display on Graphical LCD
}
else if (isnan(f))
SERIAL_ECHOPGM_P(human ? PSTR(" . ") : PSTR("NAN"));
SERIAL_ECHOF(human ? F(" . ") : F("NAN"));
else if (human || csv) {
if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0)
SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits
@ -281,10 +279,10 @@ bool unified_bed_leveling::sanity_check() {
}
#endif
process_subcommands_now_P(G28_STR); // Home
process_subcommands_now_P(PSTR(ALIGN_GCODE "\n" // Align multi z axis if available
PROBE_GCODE "\n" // Build mesh with available hardware
"G29P3\nG29P3")); // Ensure mesh is complete by running smart fill twice
process_subcommands_now(FPSTR(G28_STR)); // Home
process_subcommands_now(F(ALIGN_GCODE "\n" // Align multi z axis if available
PROBE_GCODE "\n" // Build mesh with available hardware
"G29P3\nG29P3")); // Ensure mesh is complete by running smart fill twice
if (parser.seenval('S')) {
char umw_gcode[32];
@ -292,9 +290,9 @@ bool unified_bed_leveling::sanity_check() {
queue.inject(umw_gcode);
}
process_subcommands_now_P(PSTR("G29A\nG29F10\n" // Set UBL Active & Fade 10
"M140S0\nM104S0\n" // Turn off heaters
"M500")); // Store settings
process_subcommands_now(F("G29A\nG29F10\n" // Set UBL Active & Fade 10
"M140S0\nM104S0\n" // Turn off heaters
"M500")); // Store settings
}
#endif // UBL_MESH_WIZARD

59
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

@ -346,13 +346,14 @@ void unified_bed_leveling::G29() {
if (parser.seen('Q')) {
const int16_t test_pattern = parser.has_value() ? parser.value_int() : -99;
if (!WITHIN(test_pattern, -1, 2)) {
SERIAL_ECHOLNPGM("Invalid test_pattern value. (-1 to 2)\n");
if (!WITHIN(test_pattern, TERN0(UBL_DEVEL_DEBUGGING, -1), 2)) {
SERIAL_ECHOLNPGM("?Invalid (Q) test pattern. (" TERN(UBL_DEVEL_DEBUGGING, "-1", "0") " to 2)\n");
return;
}
SERIAL_ECHOLNPGM("Loading test_pattern values.\n");
SERIAL_ECHOLNPGM("Applying test pattern.\n");
switch (test_pattern) {
default:
case -1: TERN_(UBL_DEVEL_DEBUGGING, g29_eeprom_dump()); break;
case 0:
@ -656,7 +657,7 @@ void unified_bed_leveling::G29() {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
if (probe_deployed) {
planner.synchronize();
gcode.process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT));
gcode.process_subcommands_now(F(Z_PROBE_END_SCRIPT));
}
#else
UNUSED(probe_deployed);
@ -736,7 +737,7 @@ void unified_bed_leveling::shift_mesh_height() {
const uint8_t point_num = (GRID_MAX_POINTS - count) + 1;
SERIAL_ECHOLNPGM("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS)));
#if HAS_LCD_MENU
if (ui.button_pressed()) {
@ -789,12 +790,12 @@ void unified_bed_leveling::shift_mesh_height() {
#endif // HAS_BED_PROBE
void set_message_with_feedback(PGM_P const msg_P) {
void set_message_with_feedback(FSTR_P const fstr) {
#if HAS_LCD_MENU
ui.set_status_P(msg_P);
ui.set_status(fstr);
ui.quick_feedback();
#else
UNUSED(msg_P);
UNUSED(fstr);
#endif
}
@ -850,7 +851,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
planner.synchronize();
SERIAL_ECHOPGM("Place shim under nozzle");
LCD_MESSAGEPGM(MSG_UBL_BC_INSERT);
LCD_MESSAGE(MSG_UBL_BC_INSERT);
ui.return_to_status();
echo_and_take_a_measurement();
@ -859,7 +860,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
planner.synchronize();
SERIAL_ECHOPGM("Remove shim");
LCD_MESSAGEPGM(MSG_UBL_BC_REMOVE);
LCD_MESSAGE(MSG_UBL_BC_REMOVE);
echo_and_take_a_measurement();
const float z2 = measure_point_with_encoder();
@ -905,7 +906,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
if (!position_is_reachable(ppos)) break; // SHOULD NOT OCCUR (find_closest_mesh_point only returns reachable points)
LCD_MESSAGEPGM(MSG_UBL_MOVING_TO_NEXT);
LCD_MESSAGE(MSG_UBL_MOVING_TO_NEXT);
do_blocking_move_to(ppos);
do_z_clearance(z_clearance);
@ -917,11 +918,11 @@ void set_message_with_feedback(PGM_P const msg_P) {
if (parser.seen_test('B')) {
SERIAL_ECHOPGM("Place Shim & Measure");
LCD_MESSAGEPGM(MSG_UBL_BC_INSERT);
LCD_MESSAGE(MSG_UBL_BC_INSERT);
}
else {
SERIAL_ECHOPGM("Measure");
LCD_MESSAGEPGM(MSG_UBL_BC_INSERT2);
LCD_MESSAGE(MSG_UBL_BC_INSERT2);
}
const float z_step = 0.01f; // 0.01mm per encoder tick, occasionally step
@ -974,7 +975,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
save_ubl_active_state_and_disable();
LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
LCD_MESSAGE(MSG_UBL_FINE_TUNE_MESH);
ui.capture(); // Take over control of the LCD encoder
do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance
@ -1039,7 +1040,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
if (_click_and_hold([]{
ui.return_to_status();
do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES);
set_message_with_feedback(GET_TEXT(MSG_EDITING_STOPPED));
set_message_with_feedback(GET_TEXT_F(MSG_EDITING_STOPPED));
})) break;
// TODO: Disable leveling here so the Z value becomes the 'native' Z value.
@ -1060,7 +1061,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES);
LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
LCD_MESSAGE(MSG_UBL_DONE_EDITING_MESH);
SERIAL_ECHOLNPGM("Done Editing Mesh");
if (lcd_map_control)
@ -1077,7 +1078,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
bool unified_bed_leveling::G29_parse_parameters() {
bool err_flag = false;
set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29));
set_message_with_feedback(GET_TEXT_F(MSG_UBL_DOING_G29));
param.C_constant = 0;
param.R_repetition = 0;
@ -1200,7 +1201,7 @@ void unified_bed_leveling::save_ubl_active_state_and_disable() {
ubl_state_recursion_chk++;
if (ubl_state_recursion_chk != 1) {
SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR));
set_message_with_feedback(GET_TEXT_F(MSG_UBL_SAVE_ERROR));
return;
}
#endif
@ -1213,7 +1214,7 @@ void unified_bed_leveling::restore_ubl_active_state_and_leave() {
#if ENABLED(UBL_DEVEL_DEBUGGING)
if (--ubl_state_recursion_chk) {
SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR));
set_message_with_feedback(GET_TEXT_F(MSG_UBL_RESTORE_ERROR));
return;
}
#endif
@ -1438,7 +1439,7 @@ void unified_bed_leveling::smart_fill_mesh() {
if (do_3_pt_leveling) {
SERIAL_ECHOLNPGM("Tilting mesh (1/3)");
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity);
if (isnan(measured_z))
@ -1457,7 +1458,7 @@ void unified_bed_leveling::smart_fill_mesh() {
if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (2/3)");
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, param.V_verbosity);
#ifdef VALIDATE_MESH_TILT
@ -1477,7 +1478,7 @@ void unified_bed_leveling::smart_fill_mesh() {
if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (3/3)");
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
measured_z = probe.probe_at_point(points[2], PROBE_PT_LAST_STOW, param.V_verbosity);
#ifdef VALIDATE_MESH_TILT
@ -1518,7 +1519,7 @@ void unified_bed_leveling::smart_fill_mesh() {
if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh point ", point_num, "/", total_points, "\n");
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));
measured_z = probe.probe_at_point(rpos, parser.seen_test('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling
@ -1609,7 +1610,7 @@ void unified_bed_leveling::smart_fill_mesh() {
}
if (DEBUGGING(LEVELING)) {
rotation.debug(PSTR("rotation matrix:\n"));
rotation.debug(F("rotation matrix:\n"));
DEBUG_ECHOPAIR_F("LSF Results A=", lsf_results.A, 7);
DEBUG_ECHOPAIR_F(" B=", lsf_results.B, 7);
DEBUG_ECHOLNPAIR_F(" D=", lsf_results.D, 7);
@ -1636,14 +1637,14 @@ void unified_bed_leveling::smart_fill_mesh() {
auto normed = [&](const xy_pos_t &pos, const_float_t zadd) {
return normal.x * pos.x + normal.y * pos.y + zadd;
};
auto debug_pt = [](PGM_P const pre, const xy_pos_t &pos, const_float_t zadd) {
d_from(); SERIAL_ECHOPGM_P(pre);
auto debug_pt = [](FSTR_P const pre, const xy_pos_t &pos, const_float_t zadd) {
d_from(); SERIAL_ECHOF(pre);
DEBUG_ECHO_F(normed(pos, zadd), 6);
DEBUG_ECHOLNPAIR_F(" Z error = ", zadd - get_z_correction(pos), 6);
};
debug_pt(PSTR("1st point: "), probe_pt[0], normal.z * z1);
debug_pt(PSTR("2nd point: "), probe_pt[1], normal.z * z2);
debug_pt(PSTR("3rd point: "), probe_pt[2], normal.z * z3);
debug_pt(F("1st point: "), probe_pt[0], normal.z * z1);
debug_pt(F("2nd point: "), probe_pt[1], normal.z * z2);
debug_pt(F("3rd point: "), probe_pt[2], normal.z * z3);
d_from(); DEBUG_ECHOPGM("safe home with Z=");
DEBUG_ECHOLNPAIR_F("0 : ", normed(safe_homing_xy, 0), 6);
d_from(); DEBUG_ECHOPGM("safe home with Z=");

30
Marlin/src/feature/bltouch.cpp

@ -28,7 +28,12 @@
BLTouch bltouch;
bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
#ifdef BLTOUCH_HS_MODE
bool BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
#else
constexpr bool BLTouch::high_speed_mode;
#endif
#include "../module/servo.h"
#include "../module/probe.h"
@ -63,18 +68,17 @@ void BLTouch::init(const bool set_voltage/*=false*/) {
#else
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPGM("last_written_mode - ", last_written_mode);
DEBUG_ECHOLNPGM("config mode - "
#if ENABLED(BLTOUCH_SET_5V_MODE)
"BLTOUCH_SET_5V_MODE"
#else
"OD"
#endif
);
}
#ifdef DEBUG_OUT
if (DEBUGGING(LEVELING)) {
PGMSTR(mode0, "OD");
PGMSTR(mode1, "5V");
DEBUG_ECHOPGM("BLTouch Mode: ");
DEBUG_ECHOPGM_P(bltouch.od_5v_mode ? mode1 : mode0);
DEBUG_ECHOLNPGM(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")");
}
#endif
const bool should_set = last_written_mode != ENABLED(BLTOUCH_SET_5V_MODE);
const bool should_set = od_5v_mode != ENABLED(BLTOUCH_SET_5V_MODE);
#endif
@ -193,7 +197,7 @@ void BLTouch::mode_conv_proc(const bool M5V) {
_mode_store();
if (M5V) _set_5V_mode(); else _set_OD_mode();
_stow();
last_written_mode = M5V;
od_5v_mode = M5V;
}
#endif // BLTOUCH

15
Marlin/src/feature/bltouch.h

@ -23,10 +23,6 @@
#include "../inc/MarlinConfigPre.h"
#if DISABLED(BLTOUCH_HS_MODE)
#define BLTOUCH_SLOW_MODE 1
#endif
// BLTouch commands are sent as servo angles
typedef unsigned char BLTCommand;
@ -70,8 +66,17 @@ typedef unsigned char BLTCommand;
class BLTouch {
public:
static void init(const bool set_voltage=false);
static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
static bool od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
#ifdef BLTOUCH_HS_MODE
static bool high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
#else
static constexpr bool high_speed_mode = false;
#endif
static inline float z_extra_clearance() { return high_speed_mode ? 7 : 0; }
// DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing
static bool deploy() { return deploy_proc(); }

2
Marlin/src/feature/cancel_object.cpp

@ -46,7 +46,7 @@ void CancelObject::set_active_object(const int8_t obj) {
#if BOTH(HAS_STATUS_MESSAGE, CANCEL_OBJECTS_REPORTING)
if (active_object >= 0)
ui.status_printf_P(0, PSTR(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object));
ui.status_printf(0, F(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object));
else
ui.reset_status();
#endif

5
Marlin/src/feature/caselight.cpp

@ -39,7 +39,6 @@ CaseLight caselight;
bool CaseLight::on = CASE_LIGHT_DEFAULT_ON;
#if CASE_LIGHT_IS_COLOR_LED
#include "leds/leds.h"
constexpr uint8_t init_case_light[] = CASE_LIGHT_DEFAULT_COLOR;
LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2] OPTARG(HAS_WHITE_LED, init_case_light[3]) };
#endif
@ -65,12 +64,12 @@ void CaseLight::update(const bool sflag) {
#endif
#if CASE_LIGHT_IS_COLOR_LED
leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w), n10ct));
leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w) OPTARG(NEOPIXEL_LED, n10ct)));
#else // !CASE_LIGHT_IS_COLOR_LED
#if CASELIGHT_USES_BRIGHTNESS
if (pin_is_pwm())
analogWrite(pin_t(CASE_LIGHT_PIN), (
set_pwm_duty(pin_t(CASE_LIGHT_PIN), (
#if CASE_LIGHT_MAX_PWM == 255
n10ct
#else

Some files were not shown because too many files changed in this diff

Loadingโ€ฆ
Cancel
Save