Compare commits

...

368 Commits

Author SHA1 Message Date
Scott Lahteine
3334582f86 🔖 Version 2.1.2 2022-12-19 14:42:28 -06:00
Scott Lahteine
b2d72de494 📝 Update 2.1.x README 2022-12-19 14:41:09 -06:00
Scott Lahteine
cfa747ed08 🧑‍💻 M593 F "min" freq 2022-12-18 15:49:20 -06:00
Scott Lahteine
92b2076dda 🐛 Fix Melzi encoder 2022-12-18 15:49:20 -06:00
Scott Lahteine
eff6c407a5 🩹 Fix LCD_FOR_MELZI with Tronxy Melzi 2022-12-17 22:17:38 -06:00
EvilGremlin
569bbb18d0 🐛 Fix DOGM time overflow, alignment (#25103) 2022-12-17 22:17:38 -06:00
ellensp
471330b56e 🎨 Suppress warning (#25101) 2022-12-17 22:17:38 -06:00
ellensp
2a724bd94e BTT Octopus with STM32-F407 (#25031) 2022-12-17 22:17:38 -06:00
alextrical
cea2ab1d7f BigTreeTech EBB42 v1.1 (#24964) 2022-12-17 22:17:38 -06:00
ils15
5198a55457 🔧 Use multi-XYZ 'STOP' pins for MIN/MAX (#24855)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-12-17 22:17:38 -06:00
Scott Lahteine
cbb56e3536 Robin Nano v1 CDC (USB mod)
Followup to #24619
2022-12-17 22:17:38 -06:00
Dipl.-Ing. Raoul Rubien, BSc
b3f4eaf6fd 🩹 Fix M115_GEOMETRY_REPORT (#25092) 2022-12-16 14:23:26 -06:00
ellensp
7815b20051 🩹 Inverted probe pin flag (K8400) (#25085) 2022-12-16 14:23:26 -06:00
Scott Lahteine
ffbf6acd6c 🩹 Fix M502 init of default motion
Fix regression from #25035
2022-12-16 14:23:26 -06:00
alextrical
8bafc1d9ae 🩹 Use custom I2C pins for OLED (#24970) 2022-12-16 14:23:26 -06:00
Bart Meijer
ac05f0cb8b SAMD21 HAL / Minitronics v2.0 (#24976) 2022-12-16 14:23:26 -06:00
Alexander Gavrilenko
ec6349f2ac TFT_COLOR_UI async DMA SPI (#24980) 2022-12-16 14:23:26 -06:00
Scott Lahteine
d082223fee 📝 Replace Twitter with Fosstodon 2022-12-16 14:23:26 -06:00
Simon Pilepich
e07a059b2d 🔧 Anycubic alternate Z1/Z2 wiring (#25071) 2022-12-16 14:23:26 -06:00
Krzysztof Błażewicz
313716e7fc JyersUI TMC Settings (#25048) 2022-12-16 14:23:26 -06:00
Keith Bennett
726555901c 🔧 Custom Menu Sanity Check (#25079) 2022-12-16 14:23:26 -06:00
Scott Lahteine
3ad684b10b 🔨 Updated 'mfconfig init' 2022-12-16 14:23:26 -06:00
ellensp
408a53bcdd 🔨 No env:mega1280 for MIGHTYBOARD_REVE (#25080) 2022-12-16 14:23:26 -06:00
tombrazier
eae339b8dc ️ Better IS buffer size calc (#25035) 2022-12-16 14:23:25 -06:00
Vovodroid
79b88471f0 Two controller fans (#24995) 2022-12-16 14:23:25 -06:00
ellensp
86a3362bf6 📌 Pins updates for Longer LK5, etc. (#25012)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-12-16 14:23:25 -06:00
EvilGremlin
0efeedf262 🚸 Progress display followup (#24879) 2022-12-16 14:23:25 -06:00
Sebastien BLAISOT
c86f20010d M150 S default index (#23066)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-12-16 14:23:25 -06:00
Scott Lahteine
5a97ffc414 🔨 Return error on mftest exit 2022-12-16 14:23:25 -06:00
Scott Lahteine
2737286021 📝 Update config comments 2022-12-16 14:23:25 -06:00
ellensp
86a10dc459 🐛 Fix Fast PWM on AVR (#25030)
Followup to #25005
2022-12-16 14:23:25 -06:00
kisslorand
ecdf07f055 ✏️ Fix missing ) (#25055) 2022-12-16 14:23:25 -06:00
Scott Lahteine
686ce0c0e2 🔨 Fix CI Test clean step (2) 2022-12-16 14:23:25 -06:00
Scott Lahteine
3c550e0f19 🎨 Misc. cleanup 2022-12-16 14:23:25 -06:00
Scott Lahteine
071dae0c28 🔨 Fix CI Test clean step 2022-12-16 14:23:25 -06:00
tombrazier
df2a2488a8 🐛 Fix TMC5160 + Input Shaping overcurrent (#25050) 2022-12-16 14:23:25 -06:00
Taylor Talkington
c3090bd4e8 🩹 Ender 3v2 DWIN MarlinUI Fixup (#24984) 2022-12-16 14:23:25 -06:00
Scott Lahteine
0fadb56150 🎨 Trailing whitespace 2022-12-16 14:23:25 -06:00
ellensp
eb125c95b6 🔨 Update renamed.ini (#25042) 2022-12-16 14:23:25 -06:00
ellensp
26edeefeb9 🩹 Fix MSG_MOVE_N_MM substitution (#25043) 2022-12-16 14:23:25 -06:00
kisslorand
96b8c28376 🚸 G30 move to logical XY (#24953) 2022-12-16 14:23:25 -06:00
Scott Lahteine
db3865520f 🎨 Misc. cleanup 2022-12-16 14:23:25 -06:00
Scott Lahteine
51c1645ceb 🧑‍💻 Use spaces indent for Python 2022-12-16 14:23:25 -06:00
トトも
5eb39d5277 📝 Formatted Team Overview (#25029) 2022-12-16 14:23:25 -06:00
Scott Lahteine
0537e78572 🐛 Fix G-code resend race condition
As pointed out in #24972 by @silycr, but simplified.
2022-12-16 14:23:25 -06:00
Taylor Talkington
95019bf526 Ender-3 V2 DWIN for BTT Octopus V1.1 (#24983) 2022-12-16 14:23:25 -06:00
Chris Bagwell
6f5ad55953 ️ More SCURVE cycles on unoptimized cortex-m0 (#24955) 2022-12-16 14:23:25 -06:00
tombrazier
57f6c93192 ️ Input Shaping improvements (#24951) 2022-12-16 14:23:25 -06:00
Trivalik
d2ece1e713 🐛 Fix missing va_end in UnwPrintf (#25027) 2022-12-16 14:23:25 -06:00
studiodyne
12017887f4 🐛 Fix MILLISECONDS_PREHEAT_TIME / mintemp (#24967) 2022-12-16 14:23:25 -06:00
Marcio T
3a28a1fd1d 🩹 Fix ADVANCE_K + DISTINCT_E_FACTORS sanity check (#25007) 2022-12-16 14:23:25 -06:00
Manuel McLure
360e03797f 🔧 Merge TMC26X with TMC config (#24373) 2022-12-16 14:23:25 -06:00
Radek
6185b50dbe 🐛 Fix SKR mini E2 V2 + BTT_MINI_12864_V1 (#24827)
See https://github.com/bigtreetech/BIGTREETECH-SKR-mini-E3/issues/686#issuecomment-1296545443
2022-12-16 14:23:25 -06:00
Vasily Evseenko
b2b8407a75 🍻 Fix Z increase on toolchange without UBL (#22942) 2022-12-16 14:23:25 -06:00
ellensp
c1684a1dbe 🩹 Fix UBL menu compile (#25020) 2022-12-16 14:23:25 -06:00
mikemerryguy
7d0f1dd17c 🚸 Add 50mm manual move (#24884) 2022-12-16 14:23:25 -06:00
Thomas Buck
b6051fe847 🚸 Optional Cutter/Laser status for HD44780 (#25003) 2022-12-16 14:23:25 -06:00
Tanguy Pruvot
b9bed1ca69 🚸 COLOR_UI sleep timeout / setting (#24994) 2022-12-16 14:23:25 -06:00
ellensp
b8ba9d60bb 🔧 Fix TPARA (…SCARA, DELTA) settings (#25016) 2022-12-16 14:23:25 -06:00
Tanguy Pruvot
8fd42eeeb6 ✏️ Fix Robin nano env typo (#24993) 2022-12-16 14:23:25 -06:00
ellensp
19b73a6f29 📺 FYSETC_MINI_12864_2_1 with BTT_SKR_E3_DIP (#24986) 2022-12-16 14:23:25 -06:00
ellensp
db60e0e7dc 🩹 Fix planner typo (#24977) 2022-12-16 14:23:25 -06:00
ellensp
505d73d2ba 🐛 MKS_MINI_12864 on SKR 1.3 needs FORCE_SOFT_SPI (#24850) 2022-12-16 14:23:25 -06:00
EvilGremlin
d05419a8d9 🔧 Check Delta homing direction (#24865) 2022-12-16 14:23:25 -06:00
phigjm
9772f7806b 🩹 Fix SERVICE_INTERVAL reset (#24888) 2022-12-16 14:23:25 -06:00
Marcio T
473d2b888a Fix FAST_PWM_FAN / TouchUI with NO_MOTION_BEFORE_HOMING (#25005)
Fix regressions from #20323, #23463
2022-12-16 14:23:25 -06:00
ellensp
968f04defb 🩹 Fix 2 thermocouples (#24982)
Followup to #24898
2022-12-16 14:23:25 -06:00
Scott Lahteine
30a885a7ef 🐛 Fix M808 starting count
Reported by adcurtin on Discord
2022-12-16 14:23:25 -06:00
Justin Hartmann
847391cfc1 🩹 Fix Overlord compile (#24947) 2022-12-16 14:23:25 -06:00
Pascal de Bruijn
6ea192abe9 🚸 M306: Indicate MPC Autotune (#24949) 2022-12-16 14:23:25 -06:00
ellensp
0de4ec4099 🩹 Allow max endstops MKS Monster 8 V2 (#24944) 2022-12-16 14:23:25 -06:00
Scott Lahteine
c9fa680db9 🐛 Fix Anycubic / Trigorilla pins, etc. (#24971) 2022-12-16 14:23:25 -06:00
Scott Lahteine
379d388b07 🎨 Prefer axis element over index 2022-12-16 14:23:25 -06:00
Scott Lahteine
7002e72f1c 🩹 Fix EEPROM write for !LIN_ADVANCE
Fixes #24963
Followup to #24821
2022-12-16 14:23:25 -06:00
Scott Lahteine
fc2f3cdf40 🩹 MAX Thermocouple followup
Followup to #24898
2022-12-16 14:23:25 -06:00
Scott Lahteine
7feeffdf06 🩹 leds.update needed for reset_timeout
Followup to #23590
2022-12-16 14:23:25 -06:00
Scott Lahteine
ac5464c37c 🧑‍💻 More direct encoder spin 2022-12-16 14:23:25 -06:00
Scott Lahteine
a121c80e1a 🎨 Update SAMD51 headers 2022-12-16 14:23:25 -06:00
Scott Lahteine
2778b00765 🎨 Format some lib-uhs3 code 2022-12-16 14:23:25 -06:00
ellensp
4737af7d70 📌 ZRIB V52-V53 Servo Pins (#24880) 2022-12-16 14:23:25 -06:00
InsanityAutomation
38375cf7a7 Tenlog MB1V23 IDEX board (#24896) 2022-12-16 14:23:25 -06:00
Giuliano Zaro
ddec5faf5a 🌐 Update Italian language (#24915) 2022-12-16 14:23:25 -06:00
ellensp
cbdafd36e0 📌 Remove unused RX/TX pins (#24932) 2022-12-16 14:23:25 -06:00
Keith Bennett
9f5b0b8567 🔧 Update Display Sleep LCD Check (#24934) 2022-12-16 14:23:25 -06:00
Justin Hartmann
d9ffae6578 🩹 Buttons Followup (#24935)
Followup to #24878
2022-12-16 14:23:25 -06:00
Scott Lahteine
1540e8e1d4 🩹 Allow for last non-servo extruder 2022-12-16 14:23:25 -06:00
ellensp
9a4715f31a 🐛 Fix move_extruder_servo (#24908) 2022-12-16 14:23:25 -06:00
InsanityAutomation
a9969d92ea 🐛 Fix FTDUI Status Screen Timeout (#24899) 2022-12-16 14:23:25 -06:00
Manuel McLure
d87d7474c9 🩹 Fix spurious "bad command" (#24923) 2022-12-16 14:23:25 -06:00
Scott Lahteine
4ce2f1e5ba 🩹 Fix M593 report 2022-12-16 14:23:25 -06:00
kurtis-potier-geofabrica
44636f3b74 🚸 Up to 3 MAX Thermocouples (#24898) 2022-12-16 14:23:24 -06:00
Scott Lahteine
e812540f26 🔧 Clean up unused ESP_WIFI pins 2022-12-16 14:23:24 -06:00
tombrazier
c1f0f26bff 🚀 ZV Input Shaping (#24797) 2022-12-16 14:23:24 -06:00
Scott Lahteine
5765449867 🔨 gcc-12 for macOS native 2022-12-16 14:23:24 -06:00
InsanityAutomation
c8b2d0c0fd Controllerfan PWM scaling, kickstart (#24873) 2022-12-16 14:23:24 -06:00
silycr
bdd5da5098 🚸 Probe pins for Chitu V5 (#24910) 2022-12-16 14:23:24 -06:00
ellensp
4d9bf91edc 🔧 Some STM32 UART Sanity Checks (#24795) 2022-12-16 14:23:24 -06:00
Scott Lahteine
682a9b6fbe 🎨 Misc. variant cleanup, translation
Followup to #24787
2022-12-16 14:23:24 -06:00
InsanityAutomation
a913b2437b 🐛 Fix Print Timer stop with MarlinUI abort (#24902) 2022-12-16 14:23:24 -06:00
ellensp
6b1d738995 🔧 No Native USB on AVR (#24906) 2022-12-16 14:23:24 -06:00
Scott Lahteine
dd224b4eb9 🧑‍💻 Pins and debug list cleanup (#24878) 2022-12-16 14:23:24 -06:00
Scott Lahteine
2e2abbcb48 🎨 CONF_SERIAL_IS => SERIAL_IN_USE 2022-12-16 14:23:24 -06:00
ellensp
485fb77596 Tronxy v10 (#24787) 2022-12-16 14:22:44 -06:00
Keith Bennett
29294007ef 🔧 No Sleep for CR-10 Stock Display (#24875) 2022-12-16 14:22:44 -06:00
karliss
256ac01ca2 🐛 Fix compile without Y/Z (#24858)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-12-16 14:22:44 -06:00
Keith Bennett
ca1968a842 🔧 Check Sensorless Homing on all axes (#24872) 2022-12-16 14:22:44 -06:00
InsanityAutomation
6a084e3704 🐛 Fix bed/chamber PID P edit (#24861) 2022-12-16 14:22:44 -06:00
Scott Lahteine
9ae0789166 🎨 HAS_SPI_FLASH => SPI_FLASH 2022-12-16 14:22:44 -06:00
Dan Royer
031ff2d024 🐛 Fix and improve Polargraph (#24847)
Co-Authored-By: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-12-16 14:22:44 -06:00
ellensp
b3e7d1e91e 🐛 Fix operators for V axis (#24866)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-12-16 14:09:29 -06:00
mjbogusz
f39f4d0288 🩹 Fix TFT LCD in Simulation (#24871) 2022-12-16 14:09:26 -06:00
Scott Lahteine
a4d58e8876 🎨 MMU2 cleanup 2022-12-16 14:09:23 -06:00
Scott Lahteine
c52cf77d0a 🐛 Fix M876 without emergency parser
Fix regression from 1fb2fffdbf
2022-12-16 14:09:19 -06:00
adam3654
bfcb8c704a DOGM Display Sleep (#24829) 2022-12-16 14:09:16 -06:00
EvilGremlin
0047b3064d 🩹 Fix temperature include (#24834) 2022-12-16 14:09:12 -06:00
Scott Lahteine
5c195078ff 🎨 Misc. variant cleanup 2022-12-16 14:09:09 -06:00
Scott Lahteine
1a6f9daee8 🧑‍💻 Min and max for base types 2022-12-16 14:09:06 -06:00
EvilGremlin
505f0a647e MKS SKIPR board (#24791) 2022-12-16 14:08:55 -06:00
Scott Lahteine
62b7db9bb7 🔨 Update mfinfo for 2.1.x 2022-12-16 14:08:52 -06:00
Scott Lahteine
3c870f2d4b 🧑‍💻 Min and max for base types 2022-12-16 14:08:48 -06:00
Giuliano Zaro
0203e32c73 ADVANCE_K per-extruder (#24821)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-12-16 14:08:45 -06:00
EvilGremlin
8481264566 ♻️ Set Progress without LCD (#24767)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-12-16 14:08:40 -06:00
EvilGremlin
b0f02b8f9e 🩹 Fix Color UI touchscreen sleep (#24826) 2022-12-16 14:08:36 -06:00
Adam
d6ff8f0062 🩹 Fix Switching Toolhead compile (#24814) 2022-12-16 14:08:33 -06:00
ellensp
8b37b60e58 🧑‍💻 Einsy Rambo EXP headers (#24825) 2022-12-16 14:08:29 -06:00
ellensp
5c68d26d4e 🔨 Detect feature parsing error (#24824) 2022-12-16 14:08:26 -06:00
ellensp
74435b0dcb Creality v5.2.1 board (#24815)
Followup to #24760
2022-12-16 14:08:23 -06:00
Keith Bennett
f17a07df99 🔧 Thermistor (66) sanity-check (#24803) 2022-12-16 14:08:20 -06:00
Eduardo José Tagle
a58f27763f 🐛 Fix DUE compile and errors (#24809) 2022-12-16 14:08:17 -06:00
Scott Lahteine
5aca6ff4f2 🩹 Fix some vector_3 cast operators 2022-12-16 14:08:13 -06:00
Keith Bennett
7b000966f0 🔧 Update Creality 4.2.2 Driver Warning (#24806) 2022-12-16 14:08:10 -06:00
ellensp
6ae0708840 🩹 Disable DEBUG_DGUSLCD (#24798) 2022-12-16 14:08:04 -06:00
Yuri D'Elia
44e4a9c7b1 🎨 Remove non-const compare operators (#24810) 2022-12-16 14:07:59 -06:00
Plynix / Ben Hartiwch
215fcefc1b Creality v5.2.1 board (#24760) 2022-12-16 14:07:56 -06:00
discip
827f9ae792 Pt1000 with 2k2 pullup (SKR 3 / EZ) (#24790) 2022-12-16 14:07:52 -06:00
ellensp
e44f156535 ✏️ Followup for M524 (#24775)
Followup to #24761
2022-12-16 14:07:49 -06:00
Stuart Pittaway
f1a05d19b0 🚸 UUID fallback to STM32 device SN (#24759)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-12-16 14:07:45 -06:00
Keith Bennett
a7a493d795 📌 Specify MarlinFirmware/U8glib (#24792) 2022-12-16 14:07:38 -06:00
Renaud11232
d9967f5395 🔨 Fix LPC1768 autodetect path on Linux (#24773) 2022-12-16 14:07:34 -06:00
Stefan Kalscheuer
5ee74668cf Anycubic i3 Mega LCD file menu fix (#24752) 2022-12-16 14:07:23 -06:00
studiodyne
be149336f0 M217 G wipe retract length 2022-12-16 14:07:08 -06:00
studiodyne
1f72c8341f XY_COUNTERPART_BACKOFF_MM 2022-12-16 14:07:04 -06:00
studiodyne
3d03f96205 RGB_STARTUP_TEST 2022-12-16 14:06:59 -06:00
tombrazier
c996bfddb7 Permit Linear Advance with I2S Streaming (#24684) 2022-12-16 14:06:54 -06:00
Scott Lahteine
647d459a15 Robin Nano v1 CDC (USB mod)
Followup to #24619
2022-12-16 14:06:19 -06:00
Scott Lahteine
29156ffe5d 🐛 Fix recalculate_max_e_jerk 2022-11-09 20:54:40 -06:00
ellensp
eff60964da 🐛 Fix VW axis fields in types.h (#24780) 2022-09-23 00:17:24 -05:00
Giuliano Zaro
5fe1f66478 🚸 Strict index 2 for M913 / M914 XY (#24680) 2022-09-22 13:27:31 -05:00
Arkadiusz Miśkiewicz
2fc97aa240 🚸 Emergency Parse M524 (#24761) 2022-09-22 13:27:31 -05:00
Giuliano Zaro
aa28358267 🐛 Fix / refactor shared PID (#24673)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-09-22 13:27:31 -05:00
Chris Bagwell
e04e18a590 🧑‍💻 STM32G0B1RE Pins Debugging (#24748) 2022-09-22 13:27:31 -05:00
Eduard Sukharev
bdb7f3af3f 🩹 Fix MKS TinyBee + MKS MINI 12864 SD blank on write (#24670) 2022-09-22 13:27:31 -05:00
Eduard Sukharev
2f24c31454 🚸 Sanity check Integrated Babystepping + I2S stream + ESP32 (#24691) 2022-09-22 13:27:31 -05:00
George Fu
96d050c7ba FYSETC SPIDER KING407 (#24696) 2022-09-22 13:27:31 -05:00
ellensp
aabd3e9e19 BTT SKR Mini E3 V3.0.1 (#24722) 2022-09-22 13:27:31 -05:00
XDA-Bam
38b3105900 ️ Minor planner optimization (#24737) 2022-09-22 13:27:31 -05:00
Arkadiusz Miśkiewicz
02810616cc 🚸 On pause report "SD printing byte X/Y" (#24709) 2022-09-22 13:27:31 -05:00
Arkadiusz Miśkiewicz
7daff755f2 🩹 Report M22 / M23 success / fail (#24706) 2022-09-22 13:27:31 -05:00
Gurmeet Athwal
53564fb6f3 🚸 M115 spindle/laser (#24681, #24747) 2022-09-22 13:27:31 -05:00
ellensp
9d9f303c5e 📺 FYSETC Mini 12864 2.1 pins for Creality V4 (#24624) 2022-09-22 13:27:31 -05:00
FBN
b9428bf087 🚸 More automatic MMU2 load (#24750, #24770) 2022-09-22 13:27:08 -05:00
Yuri D'Elia
0642cd8a83 👷 Array macros to …26 elements (#24789) 2022-09-22 13:26:50 -05:00
Scott Lahteine
d2b1467ab3 🌐 Some short menu strings 2022-09-22 13:26:26 -05:00
Keith Bennett
03aba439f6 ️ Only Sync Emulated EEPROM Print Counter (#24731) 2022-09-22 13:26:26 -05:00
Giuliano Zaro
85a47d61e6 🐛 Fix heater timeout PID output (#24682) 2022-09-22 13:17:54 -05:00
Scott Lahteine
78577b13cb 🧑‍💻 Microsteps to stepper.cpp 2022-09-22 13:17:54 -05:00
hartmannathan
b29cd4c510 📝 Fix example comment (#24744) 2022-09-22 13:17:54 -05:00
Scott Lahteine
0eb6a8d12e 📝 Fix comment 2022-09-22 13:17:54 -05:00
JoaquinBerrios
8a8218a8f2 ️ BTT SKR V3.0 / EZ = 480MHz (#24721) 2022-09-22 13:17:54 -05:00
Scott Lahteine
3a18ba0412 🔨 Fix config-labels.py 2022-09-22 13:17:54 -05:00
Scott Lahteine
2828f1d1db 🔨 Outdent py string 2022-09-22 13:17:54 -05:00
dmitrygribenchuk
63507acf98 🔨 Clean up Python imports (#24736) 2022-09-22 13:17:54 -05:00
ButchMonkey
cc2cc7d081 🔨 Fix config.ini custom items, and 'all' (#24720) 2022-09-22 13:17:54 -05:00
ButchMonkey
b676b43874 🔨 Fix configuration.py with encoding UTF-8 (#24719)
- Opening files with Windows-1252 encoding.
2022-09-22 13:17:54 -05:00
Stephen Hawes
2f1b89bd1f Opulo LumenPnP REV04 (#24718) 2022-09-22 13:17:54 -05:00
Keith Bennett
1a2e591d03 🔨 Update SKR 3 env (#24711) 2022-09-22 13:17:54 -05:00
Scott Lahteine
dc65e299fa 📝 Format some comments 2022-09-22 13:17:53 -05:00
EvilGremlin
033bca1773 🔨 Native USB modified env followup (#24669)
Followup to #24619
2022-09-22 13:17:53 -05:00
Bob Kuhn
e350acb360 🐛 Fix UBL regression (#24622)
Fix regression from #24188
2022-09-22 13:17:53 -05:00
Ruedi Steinmann
7d8d2e2c58 🩹 Fix a BUZZ (#24740) 2022-09-09 15:33:54 -05:00
Scott Lahteine
3c6b3e5af4 🔖 Config version 02010200 2022-08-29 19:25:38 -05:00
EvilGremlin
d5e9b25a31 🐛 Fix back button (#24694) 2022-08-29 19:17:32 -05:00
Scott Lahteine
9313c2fd18 ✏️ Fix http:// links 2022-08-29 19:17:31 -05:00
Lefteris Garyfalakis
d8a280bf53 ✏️ Fix LCD sleep conditional (#24685) 2022-08-29 19:17:31 -05:00
Miguel Risco-Castillo
d244389998 🩹 Constrain UBL within mesh bounds (#24631)
Fixes #24630
2022-08-29 19:17:31 -05:00
Keith Bennett
d140be0281 🚸 Up to 10 Preheat Constants (#24636) 2022-08-29 19:17:31 -05:00
ellensp
27bea56025 🔧 Fix Auto-Fan / Controller-Fan pin conflict check (#24648) 2022-08-29 19:17:31 -05:00
ellensp
98ee3fc2b5 🩹 Fix PID debug output (#24647) 2022-08-29 19:17:31 -05:00
Mark
e8394c391e 🐛 Fix Bed Distance Sensor reading (#24649) 2022-08-29 19:17:31 -05:00
Arkadiusz Miśkiewicz
e24d5f9315 M20_TIMESTAMP_SUPPORT (#24679)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-08-29 19:17:31 -05:00
EvilGremlin
ef1cf0d5a1 ♻️ Display sleep minutes, encoder disable option (#24618)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-08-29 19:17:31 -05:00
DejitaruJin
f088722ae8 🩹 Fix SainSmart LCD (#24672) 2022-08-29 19:17:31 -05:00
Keith Bennett
68c5e97fd7 🩹 Fix Freeze Feature (#24664) 2022-08-29 19:17:31 -05:00
Lefteris Garyfalakis
a8cf886aa5 🔨 Suppressible Creality 4.2.2 warning (#24683) 2022-08-29 19:17:31 -05:00
EvilGremlin
a31e65e30b Robin Nano v1 CDC (USB mod) (#24619) 2022-08-29 19:17:31 -05:00
Alexey Galakhov
d94a41527f 🐛 Fix JyersUI (#24652) 2022-08-29 19:17:31 -05:00
Keith Bennett
37a7da075f 🔧 Fix Skew Correction defaults (#24601) 2022-08-29 19:17:31 -05:00
Scott Lahteine
5145266b0d 🎨 Some automated cleanup 2022-08-29 19:17:31 -05:00
Keith Bennett
bdd5f3678e 📺 Add to MKS UI About Screen (#24610) 2022-08-29 19:17:31 -05:00
Keith Bennett
b4af335b7a 🔧 Remove STM32F4 Print Counter Sanity Check (#24605) 2022-08-29 19:17:31 -05:00
Protomosh
cfe1d52bf2 🐛 Fix DGUS Reloaded + STM32 (#24600) 2022-08-29 19:17:31 -05:00
Scott Lahteine
ff09ea13a4 🧑‍💻 Use spaces indent for Python 2022-08-29 19:17:31 -05:00
Scott Lahteine
d93c41a257 🔨 Misc. schema updates 2022-08-29 19:17:31 -05:00
Graham Reed
98e6aacbef 🔨 Fix LPC1768 automatic upload port (#24599) 2022-08-29 19:17:31 -05:00
Scott Lahteine
0adee8fae0 🩹 Fix strtof interpreting a hex value
Bug introduced in #21532
2022-08-29 19:17:31 -05:00
Scott Lahteine
c154302ece 🔨 Add args to schema.py 2022-08-29 19:17:31 -05:00
Scott Lahteine
b5ccddbe35 🎨 Fix '…if_chain' Uncrustify option 2022-08-29 19:17:31 -05:00
Scott Lahteine
d69893309e 🔨 Misc. config py updates 2022-08-29 19:17:31 -05:00
Scott Lahteine
fc3ea96ff9 🧑‍💻 Add operator== for C++20 2022-08-29 19:17:31 -05:00
Keith Bennett
3892d08b06 🧑‍💻 Fix UBL Build Mesh preheat items (#24598)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-08-29 19:17:31 -05:00
Ivan Kravets
857dc73be5 🔨 Fix a PlatformIO debug issue (#24569) 2022-08-29 19:17:31 -05:00
Scott Lahteine
419a145fa3 🔨 Update schema export 2022-08-08 04:42:19 -05:00
Scott Lahteine
398cae7625 🔖 Version 2.1.1 2022-08-06 18:50:49 -05:00
Scott Lahteine
8192cc12d3 🎨 Misc. config cleanup 2022-08-06 18:50:49 -05:00
ExtNeon
7f2a836251 SD Endstop Abort G-Code (#24461) 2022-08-06 18:50:49 -05:00
Mark
b02c3258b5 Bed Distance Sensor (#24554) 2022-08-06 18:50:49 -05:00
Keith Bennett
a0462eb017 🩹 Fix AUTO_FAN_PIN sanity check (#24593) 2022-08-06 18:50:49 -05:00
Scott Lahteine
a1704c10b9 🩹 G0/G1 S seen => seenval 2022-08-06 18:50:49 -05:00
qwertymodo
7196f13125 M150 K – Keep unspecified components (#24315) 2022-08-06 18:50:49 -05:00
J.C. Nelson
e06340abd1 🔨 Trigorilla Pro disk based update (#24591) 2022-08-06 18:50:49 -05:00
Travis Ziegler
98095ddad6 🩹 Fix LPC176x USB Host Shield (#24588) 2022-08-06 18:50:49 -05:00
Scott Lahteine
2f4b121709 👔 Keep "Needs: More Data" open 2022-08-06 18:50:49 -05:00
Ruedi Steinmann
a0409289c8 🚸 Laser with only PWM pin (#24345) 2022-08-06 18:50:49 -05:00
Scott Lahteine
2ccdc4f9ed 🧑‍💻 MARLIN_TEST_BUILD – for future use (#24077) 2022-08-06 18:50:49 -05:00
Scott Lahteine
bbf2033211 🔧 Config INI, dump options (#24528) 2022-08-06 18:50:49 -05:00
Scott Lahteine
9a42d1e577 🩹 Fix Malyan M300 with S-Curve compile
Fixes #24548
2022-08-05 21:54:27 -05:00
ellensp
17794e18ae 🔧 Update 644p/1284p Serial 1 sanity check (#24575) 2022-08-01 01:59:37 -05:00
Scott Lahteine
3b30951e83 🔨 Simplify scripts with pathlib (#24574) 2022-08-01 01:59:37 -05:00
Mike La Spina
c3f2586445 🐛 Fix laser menu enable_state (#24557) 2022-08-01 01:59:37 -05:00
InsanityAutomation
c0cb7e35af Configurable Switching Nozzle dwell (#24304) 2022-08-01 01:59:37 -05:00
tombrazier
fd319928d2 Fix, improve Linear Advance (#24533) 2022-08-01 01:59:37 -05:00
tombrazier
5dad7e0d03 🩹 Use _MIN/_MAX macros for native compatibility (#24570) 2022-08-01 01:59:37 -05:00
DerAndere
9ee558afe1 🐛 Fix kinematic feedrate (#24568) 2022-08-01 01:59:37 -05:00
Keith Bennett
bbaccd342e Encoder Noise Filter (#24538) 2022-08-01 01:59:37 -05:00
lukasradek
6134d55360 📝 README Updates (#24564) 2022-08-01 01:59:37 -05:00
Scott Lahteine
868e76b965 🎨 Renum boards.h 2022-08-01 01:59:37 -05:00
Scott Lahteine
5f105e254d 🐛 Fix M125 for 9 Axis 2022-08-01 01:59:37 -05:00
Scott Lahteine
9534c6e903 🎨 Misc. 'else' cleanup 2022-08-01 01:59:37 -05:00
Ludy
ec9a2ee557 🌐 Update German language (#24555) 2022-08-01 01:59:37 -05:00
Scott Lahteine
d8db00e31f 🧑‍💻 Update planner/stepper includes 2022-08-01 01:59:37 -05:00
Scott Lahteine
e7c262dc30 🩹 Fix lcd_preheat compile 2022-08-01 01:59:37 -05:00
Scott Lahteine
cee9da6132 🔨 Update build/CI scripts 2022-08-01 01:59:37 -05:00
Scott Lahteine
a24b9e16ff 🎨 PIO scripts cleanup 2022-08-01 01:59:37 -05:00
Keith Bennett
1e9232723d 📺 Fix TFT Classic UI non-Touchscreen 1024x600 (#24541) 2022-08-01 01:59:37 -05:00
Keith Bennett
66369f8236 🩹 Fix JyersUI include (#24540) 2022-08-01 01:59:37 -05:00
Keith Bennett
0ca76bf9ed 📝 Update MPCTEMP G-Code M306 T (#24535)
M306 simply reports current values. M306 T starts autotune process.
2022-08-01 01:59:37 -05:00
Scott Lahteine
0f3c3c419e Reinstate JyersUI 2022-08-01 01:59:37 -05:00
Scott Lahteine
89e9ae0662 🧑‍💻 Give the simulator Stepper access 2022-08-01 01:59:37 -05:00
Scott Lahteine
5b8f7686cb 🧑‍💻 Fix and improve build_all_examples 2022-08-01 01:59:37 -05:00
Scott Lahteine
6e02f15dd6 🔨 Minor build script changes 2022-08-01 01:59:37 -05:00
Scott Lahteine
c9445cfc41 🩹 Fix TFT image PACKED conflict 2022-08-01 01:59:37 -05:00
Frederik Kemner
beacb73d93 🩹 Fix gcode.h include (#24527) 2022-08-01 01:59:37 -05:00
InsanityAutomation
53a57ff7bf 🐛 Fix Archim2 USB Hang (#24314) 2022-08-01 01:59:37 -05:00
Scott Lahteine
d726f641a5 EXP header pin numbers redux (#24525)
Followup to 504fec98
2022-08-01 01:59:37 -05:00
InsanityAutomation
feafa321d7 🚸 Use Tool 0 for G30 (#24511) 2022-08-01 01:59:37 -05:00
ellensp
f5b972bb10 📺 SKR_MINI_SCREEN_ADAPTER for BTT SKR Mini E3 V3 (#24521) 2022-08-01 01:59:37 -05:00
Eduard Sukharev
196795c0cc More ESP32 (MKS TinyBee) tests (#24493) 2022-08-01 01:59:36 -05:00
Keith Bennett
c3085d666f 📝 Update Contributing Guide (#24320) 2022-08-01 01:59:36 -05:00
InsanityAutomation
807f2ef969 🚸 Machine-relative Z_STEPPER_ALIGN_XY (#24261)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-08-01 01:59:36 -05:00
Scott Lahteine
f752fe75ee ♻️ Small sound / buzz refactor (#24520) 2022-08-01 01:59:36 -05:00
Scott Lahteine
97a73147fa 🩹 Fix manual move titles (#24518) 2022-08-01 01:59:36 -05:00
tombrazier
915203f545 🩹 Arc/Planner optimization followup (#24509) 2022-08-01 01:59:36 -05:00
Scott Lahteine
173eb3ff71 🚸 Renumber EXP pins to match schematics/RRF/Klipper 2022-08-01 01:59:36 -05:00
Nikolay-Po
96d3c66b64 Steinhart-Hart C Coeff for Custom Thermistor (#24428) 2022-08-01 01:59:36 -05:00
tombrazier
cc4fc28fe0 ️ Optimize Planner calculations (#24484) 2022-08-01 01:59:36 -05:00
Arthur Masson
0a164a88fe Polargraph M665 settings (#24401) 2022-08-01 01:59:36 -05:00
GHGiampy
c72fe1a2f9 🩹 Add'l ProUI fixes (#24500, #24508) 2022-08-01 01:59:17 -05:00
Christophe Huriaux
2add8ca4eb eMotion-Tech eMotronic (Micro-Delta rework) (#24488) 2022-08-01 01:58:45 -05:00
Scott Lahteine
779c24122d 🔨 Update mfprep comment 2022-08-01 01:58:45 -05:00
Scott Lahteine
6ac3f2738e 🔨 Add mftest --default flag 2022-08-01 01:57:17 -05:00
Scott Lahteine
77c6d9af20 🩹 Fix TFT tImage struct packing 2022-08-01 01:57:11 -05:00
GHGiampy
929e12bf49 🔨 Remove log2file monitor filter (#24502) 2022-08-01 01:57:01 -05:00
Keith Bennett
fd18ac5667 📝 Update board MCU comments (#24486) 2022-07-29 18:42:42 -05:00
Scott Lahteine
06c1409843 🩹 Fix MAX31865 approximations
Followup to #24407
2022-07-29 18:42:42 -05:00
Scott Lahteine
ec95e66ff0 🔧 Base NUM_AXES on defined DRIVER_TYPEs (#24106) 2022-07-29 18:42:42 -05:00
Scott Lahteine
53ee7fce5b 🐛 Fix SDIO for STM32 (#24470)
Followup to #24271
2022-07-29 18:42:42 -05:00
Scott Lahteine
10f5f878ce 🚑️ Fix XYZEval = N not setting E 2022-07-29 18:42:42 -05:00
tombrazier
733ca940c0 🐛 Fix 2d mesh print (#24536) 2022-07-22 23:33:30 -05:00
Scott Lahteine
c880c7ed45 🔨 Fix and update Makefile
Followup to 89fe5f6d
2022-07-15 18:48:15 -05:00
Keith Bennett
e5e4cf920d 📌 Pin ESP32SSDP to 1.1.1 (#24489) 2022-07-15 18:48:15 -05:00
Victor Oliveira
3315f6faa4 Creality3D v4.2.5 / CR200B (#24491) 2022-07-15 18:48:15 -05:00
GHGiampy
4a6ad1c98b 🩹 Fix ProUI LED compile (#24473) 2022-07-15 18:48:15 -05:00
Miguel Risco-Castillo
3c9789fda8 🚸 Fix and update ProUI (#24477) 2022-07-15 18:48:15 -05:00
toomuchwonder
3a19d34c75 🩹 Fix MKS UI extruder speed (#24476) 2022-07-15 18:48:15 -05:00
Bob Kuhn
6b19a58f03 🔥 Drop STM L64** drivers, STEVAL_3DP001V1 (#24427) 2022-07-15 18:48:15 -05:00
Scott Lahteine
9283859b1e 🎨 ANY => EITHER 2022-07-15 18:48:15 -05:00
GHGiampy
e840015cad 🔨 Abort firmware update on transfer error (#24472, #24499) 2022-07-15 18:48:15 -05:00
Scott Lahteine
efe04e1016 🧑‍💻 Update Mac Sim directions 2022-07-15 18:48:15 -05:00
Scott Lahteine
f543b3cb84 📌 Ask for PlatformIO 6.1.1 or newer (#24435) 2022-07-15 18:48:15 -05:00
Keith Bennett
6a86c5bad3 MKS Monster8 V2 (#24483) 2022-07-15 18:48:15 -05:00
Scott Lahteine
7207a32434 🧑‍💻 Add Sim debug with lldb 2022-07-15 18:48:15 -05:00
Keith Bennett
678474d55c 🔧 Assert Probe Temp Comp requirements (#24468) 2022-07-15 18:48:15 -05:00
Mike La Spina
24c211307d 🐛 Fix laser/fan sync (#24460)
Followup to #22690, 307dfb15
2022-07-15 18:48:15 -05:00
tombrazier
0c78a6f657 ️ Optimize G2-G3 Arcs (#24366) 2022-07-15 18:48:15 -05:00
Jason Smith
79a332b57e 🩹 Fix LCD_BACKLIGHT_TIMEOUT compile (#24463) 2022-07-15 18:48:15 -05:00
Pauli Jokela
d9ecbdcdbb 🩹 Fix safe homing sanity-check (#24462) 2022-07-15 18:48:15 -05:00
Farva42
527fe2496a MAG_MOUNTED_PROBE (#24420)
Co-Authored-By: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-07-15 18:48:14 -05:00
Scott Lahteine
6c2ffe9d34 🔥 Remove JyersUI (#24459) 2022-07-15 18:48:14 -05:00
Scott Lahteine
0fdedfa2fb 📝 Configurations 02010100 (#24458) 2022-07-15 18:48:14 -05:00
Meilleur Gars
e93a1dd2fa 🚸 JyersUI updates (#24451) 2022-07-15 18:48:14 -05:00
Christophe Huriaux
03760fd79e 🩹 Fix ST7565 LCD contrast init (#24457) 2022-07-15 18:48:14 -05:00
Bob Kuhn
d3aed23e18 🐛 Fix Sensorless Probing compile (#24455) 2022-07-15 18:48:14 -05:00
Eduard Sukharev
893707711e 🐛 Fix MKS TinyBee compile (#24454) 2022-07-15 18:48:14 -05:00
Mike La Spina
d965303a7a ️ Fix and improve Inline Laser Power (#22690) 2022-07-15 18:48:14 -05:00
Keith Bennett
5b6c46db29 BigTreeTech SKR SE BX V3.0 (#24449)
SKR SE BX V3.0 removes the Reverse Driver Protection feature.
2022-07-15 18:48:14 -05:00
EvilGremlin
8f40a2f257 🔨 Fix OpenBLT encode; no-bootloader envs (#24446) 2022-07-15 18:48:14 -05:00
Scott Lahteine
e4f85e8fbc ♻️ Encapsulate PID in class (#24389) 2022-07-15 18:48:14 -05:00
Victor Oliveira
678955949f 🔨 Disable stack protector on macOS simulator (#24443) 2022-07-15 18:48:14 -05:00
Scott Lahteine
923d34550a 🔨 PlatformIO "--target upload" == "--target exec" 2022-07-15 18:48:14 -05:00
Scott Lahteine
ed643e634f 🔨 Fix Warnings/settings force-recompile 2022-07-15 18:48:14 -05:00
Scott Lahteine
3f4c8c31c6 Fix SDIO for STM32
Followup to #24271
2022-07-09 18:19:47 -05:00
Keith Bennett
171ed66de0 🚸 MPCTEMP: Home before cooling (#24434) 2022-07-04 00:29:53 -05:00
Keith Bennett
5f2e4487e7 🩹 Fix MKS TinyBee ADC Vref (#24432) 2022-07-04 00:29:53 -05:00
Scott Lahteine
80c7abd727 🩹 Remove poison wchar_t macro 2022-07-04 00:29:53 -05:00
Scott Lahteine
814b53750f 🩹 Remove obsolete split_move 2022-07-01 22:05:44 -05:00
Moonglow
23e93c51fd 🐛 Fix M149 (#24430) 2022-07-01 07:54:53 -05:00
tombrazier
afbdcc8eee 🚸 Vertical Max7219::quantity in portrait orientation (#24415) 2022-07-01 07:54:53 -05:00
Scott Lahteine
4820947203 Update path to Ender-3 S1 configs 2022-07-01 07:54:53 -05:00
Scott Lahteine
d44aef8b6b 📝 Index Mobo Rev03 => Opulo Lumen Rev3 2022-06-30 22:10:31 -05:00
Scott Lahteine
c1c0496073 🩹 Fix memset block warning 2022-06-30 22:10:26 -05:00
Keith Bennett
a48831d600 🐛 Fix Axis Homing (#24425)
Followup to 4520a51
2022-06-30 22:10:26 -05:00
John Lagonikas
c076094fa9 🐛 Fix MAX31865 PT1000 normalization (#24407)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-06-30 22:10:26 -05:00
Scott Lahteine
57c137a60f ♻️ reset_acceleration_rates => refresh_… 2022-06-30 22:10:05 -05:00
Scott Lahteine
05bdc5640d ♻️ Planner flags refactor 2022-06-30 22:10:05 -05:00
Scott Lahteine
83784bd8b7 📝 Note about UBL bad splits 2022-06-30 22:10:05 -05:00
Scott Lahteine
23f19e9ce8 🎨 Misc. shorthand operators 2022-06-26 10:02:36 -05:00
Scott Lahteine
0435b2220a 🐛 Fix Manual Move axis selection (#24404) 2022-06-26 06:49:14 -05:00
Shlee
ab2fceda2c 📝 Add STM32F4 example, Ruby (#24399) 2022-06-26 06:39:00 -05:00
Giuliano Zaro
88dc360e9d 🌐 Update Italian language (#24398) 2022-06-26 06:39:00 -05:00
Roman Moravčík
f5bdb8b4d2 🌐 Update Slovak language (#24397) 2022-06-26 06:39:00 -05:00
sgparry
3e01e08989 🩹 Fix LCD contrast with K8800 board 2022-06-26 06:39:00 -05:00
tombrazier
4694a7fe74 MAX7219 idle profiler (#24375) 2022-06-26 06:39:00 -05:00
Scott Lahteine
537af0bb03 🌐 Drop unused delta strings 2022-06-24 22:09:59 -05:00
InsanityAutomation
0dc59311ec 🐛 Resolve DUE Servo pulse issue (#24305)
Co-authored-by: sjasonsmith <20053467+sjasonsmith@users.noreply.github.com>
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-06-24 18:03:19 -05:00
tombrazier
0523874e9c 🐛 Fix G2/G3 Arcs stutter / JD speed (#24362) 2022-06-24 18:03:19 -05:00
Scott Lahteine
106537ff43 ✏️ 9-axis followup (sanity-check) 2022-06-24 18:03:19 -05:00
Bob Kuhn
ad96c36730 🐛 Fix Lerdge build / encrypt (#24391)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-06-24 18:03:19 -05:00
Victor Oliveira
a3629a7c28 Classic UI BIQU BX (#24387) 2022-06-24 18:03:19 -05:00
ellensp
b7e1b6b893 🩹 Fix DGUS (MKS) compile (#24378) 2022-06-24 18:03:19 -05:00
Victor Oliveira
253e35e066 🚑️ Fix BIQU BX touch freeze (#24383) 2022-06-24 18:03:19 -05:00
ellensp
831e1b5ecf 🐛 Fix M423 invocation (#24360)
Followup to #23745
2022-06-24 18:03:19 -05:00
tombrazier
c89ca2deb8 🩹 LCD strings followup, fix warning (#24328) 2022-06-24 18:03:19 -05:00
DerAndere
85e94038aa FOAMCUTTER_XYUV (for RAMPS) (#24325)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
2022-06-24 18:03:19 -05:00
ellensp
7c85f25042 🚑️ Fix SD mount bug (#24319)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
2022-06-24 18:03:19 -05:00
Scott Lahteine
eca5e46d17 🎨 Simplify move menus with substitution 2022-06-24 18:03:19 -05:00
Scott Lahteine
78b42ed387 🎨 Use MAP for home axis items 2022-06-24 18:03:19 -05:00
Scott Lahteine
95339c9561 🧑‍💻 Fix STATIC_ITEM_N arg order 2022-06-24 18:03:19 -05:00
Scott Lahteine
da6c16a9cd 🎨 Fix comments, formatting 2022-06-24 18:03:19 -05:00
ellensp
cc27cfb660 👷 CI test without src filter (emulate Arduino) (#24335) 2022-06-24 01:19:42 -05:00
Keith Bennett
25c0593c9b 👷 Use Biqu BX for CI test (#24331) 2022-06-24 01:19:36 -05:00
Scott Lahteine
5fff7bbef4 👔 Fix and comment use_example_configs 2022-06-24 01:11:07 -05:00
Scott Lahteine
3fd592e64b 👔 Update Marlin actions for 2.1.x 2022-06-24 01:11:07 -05:00
John Robertson
c34dd64469 ️ PWM for ESP32 I2S expander (#24193) 2022-06-24 01:11:07 -05:00
Scott Lahteine
7677368aaf 🔖 Moving to bugfix-2.1.x 2022-06-24 01:11:06 -05:00
Scott Lahteine
ece124fdea 🩹 M919 9-axis update 2022-06-20 21:09:20 -05:00
luzpaz
9aa499dbe9 🌐 Fix LCD string, typos (#24324) 2022-06-20 21:09:20 -05:00
Scott Lahteine
78a3ea0ed4 🧑‍💻 Apply F() to some LCD / TFT strings
Followup to #24228
2022-06-13 21:02:31 -05:00
ellensp
c605c1ebb5 🩹 Fix missing ProUI cpp wrapper (#24313) 2022-06-13 21:02:31 -05:00
ellensp
b2c4fb5f3a 🐛 Fix JGAurora A5S A1 build (#24326) 2022-06-13 04:32:49 -05:00
Steven Haigh
60cedf63f2 🩹 Fix ProUI compile (#24310)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2022-06-13 04:32:49 -05:00
Scott Lahteine
1156557a47 🧑‍💻 Misc. servo code cleanup 2022-06-13 04:32:49 -05:00
Scott Lahteine
ea22640d78 🧑‍💻 Remove servo macros 2022-06-13 04:32:49 -05:00
lujios
d886320799 🩹 Fix G33 Delta Sensorless Probing compile (#24291) 2022-06-13 04:32:30 -05:00
Scott Lahteine
a65189c637 👔 Fix and comment use_example_configs 2022-06-13 04:31:26 -05:00
tombrazier
dfc8acf376 🩹 Fix Mesh Leveling + Debug compile (#24297) 2022-06-07 02:15:48 -05:00
ellensp
48d03ca0a9 🩹 Media Change followup (#24302)
Followup to #24015
2022-06-07 02:00:38 -05:00
Miguel Risco-Castillo
85e8d1f9fa 🚸 ProUI G-code preview, PID plot (#24282) 2022-06-07 02:00:38 -05:00
Scott Lahteine
679f4608ab 👔 Update mfconfig import 2022-06-06 23:40:26 -05:00
766 changed files with 33781 additions and 19627 deletions

View File

@@ -14,6 +14,10 @@ end_of_line = lf
indent_style = space
indent_size = 2
[{*.py,*.conf,*.sublime-project}]
[{*.py}]
indent_style = space
indent_size = 4
[{*.conf,*.sublime-project}]
indent_style = tab
indent_size = 4

View File

@@ -34,8 +34,11 @@ This project and everyone participating in it is governed by the [Marlin Code of
We have a Message Board and a Facebook group where our knowledgable user community can provide helpful advice if you have questions.
* [Marlin RepRap forum](https://reprap.org/forum/list.php?415)
* [MarlinFirmware on Facebook](https://www.facebook.com/groups/1049718498464482/)
- [Marlin Documentation](https://marlinfw.org) - Official Marlin documentation
- Facebook Group ["Marlin Firmware"](https://www.facebook.com/groups/1049718498464482/)
- RepRap.org [Marlin Forum](https://forums.reprap.org/list.php?415)
- Facebook Group ["Marlin Firmware for 3D Printers"](https://www.facebook.com/groups/3Dtechtalk/)
- [Marlin Configuration](https://www.youtube.com/results?search_query=marlin+configuration) on YouTube
If chat is more your speed, you can join the MarlinFirmware Discord server:
@@ -116,7 +119,7 @@ Unsure where to begin contributing to Marlin? You can start by looking through t
### Pull Requests
Pull Requests should always be targeted to working branches (e.g., `bugfix-2.0.x` and/or `bugfix-1.1.x`) and never to release branches (e.g., `2.0.x` and/or `1.1.x`). If this is your first Pull Request, please read our [Guide to Pull Requests](https://marlinfw.org/docs/development/getting_started_pull_requests.html) and Github's [Pull Request](https://help.github.com/articles/creating-a-pull-request/) documentation.
Pull Requests should always be targeted to working branches (e.g., `bugfix-2.1.x` and/or `bugfix-1.1.x`) and never to release branches (e.g., `2.0.x` and/or `1.1.x`). If this is your first Pull Request, please read our [Guide to Pull Requests](https://marlinfw.org/docs/development/getting_started_pull_requests.html) and Github's [Pull Request](https://help.github.com/articles/creating-a-pull-request/) documentation.
* Fill in [the required template](pull_request_template.md).
* Don't include issue numbers in the PR title.

1
.gitignore vendored
View File

@@ -147,6 +147,7 @@ vc-fileutils.settings
imgui.ini
eeprom.dat
spi_flash.bin
fs.img
#cmake
CMakeLists.txt

View File

@@ -27,7 +27,7 @@ tests-single-ci:
tests-single-local:
@if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local" ; return 1; fi
export PATH=./buildroot/bin/:./buildroot/tests/:${PATH} \
export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
&& export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
&& run_tests . $(TEST_TARGET) "$(ONLY_TEST)"
.PHONY: tests-single-local
@@ -38,7 +38,7 @@ tests-single-local-docker:
.PHONY: tests-single-local-docker
tests-all-local:
export PATH=./buildroot/bin/:./buildroot/tests/:${PATH} \
export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
&& export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
&& for TEST_TARGET in $$(./get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
.PHONY: tests-all-local

View File

@@ -35,7 +35,7 @@
*
* Advanced settings can be found in Configuration_adv.h
*/
#define CONFIGURATION_H_VERSION 02010000
#define CONFIGURATION_H_VERSION 02010200
//===========================================================================
//============================= Getting Started =============================
@@ -57,15 +57,6 @@
* https://www.thingiverse.com/thing:1278865
*/
//===========================================================================
//========================== DELTA / SCARA / TPARA ==========================
//===========================================================================
//
// Download configurations from the link above and customize for your machine.
// Examples are located in config/examples/delta, .../SCARA, and .../TPARA.
//
//===========================================================================
// @section info
// Author info of this build printed to the host during boot and M115
@@ -121,6 +112,7 @@
* :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000]
*/
#define BAUDRATE 250000
//#define BAUD_RATE_GCODE // Enable G-code M575 to set the baud rate
/**
@@ -129,7 +121,7 @@
* :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
*/
//#define SERIAL_PORT_2 -1
//#define BAUDRATE_2 250000 // Enable to override BAUDRATE
//#define BAUDRATE_2 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE
/**
* Select a third serial port on the board to use for communication with the host.
@@ -137,7 +129,7 @@
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
*/
//#define SERIAL_PORT_3 1
//#define BAUDRATE_3 250000 // Enable to override BAUDRATE
//#define BAUDRATE_3 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE
// Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH
@@ -149,6 +141,8 @@
// Choose your own or use a service like https://www.uuidgenerator.net/version4
//#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
// @section stepper drivers
/**
* Stepper Drivers
*
@@ -157,13 +151,12 @@
*
* Use TMC2208/TMC2208_STANDALONE for TMC2225 drivers and TMC2209/TMC2209_STANDALONE for TMC2226 drivers.
*
* Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01,
* TB6560, TB6600, TMC2100,
* Options: A4988, A5984, DRV8825, LV8729, TB6560, TB6600, TMC2100,
* TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE,
* TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE,
* TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE,
* TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE
* :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
* :['A4988', 'A5984', 'DRV8825', 'LV8729', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
*/
#define X_DRIVER_TYPE A4988
#define Y_DRIVER_TYPE A4988
@@ -249,6 +242,8 @@
//#define SINGLENOZZLE_STANDBY_FAN
#endif
// @section multi-material
/**
* Multi-Material Unit
* Set to one of these predefined models:
@@ -261,6 +256,7 @@
*
* Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails.
* See additional options in Configuration_adv.h.
* :["PRUSA_MMU1", "PRUSA_MMU2", "PRUSA_MMU2S", "EXTENDABLE_EMU_MMU2", "EXTENDABLE_EMU_MMU2S"]
*/
//#define MMU_MODEL PRUSA_MMU2
@@ -280,6 +276,7 @@
#define SWITCHING_NOZZLE_SERVO_NR 0
//#define SWITCHING_NOZZLE_E1_SERVO_NR 1 // If two servos are used, the index of the second
#define SWITCHING_NOZZLE_SERVO_ANGLES { 0, 90 } // Angles for E0, E1 (single servo) or lowered/raised (dual servo)
#define SWITCHING_NOZZLE_SERVO_DWELL 2500 // Dwell time to wait for servo to make physical move
#endif
/**
@@ -396,7 +393,7 @@
//#define HOTEND_OFFSET_Y { 0.0, 5.00 } // (mm) relative Y-offset for each nozzle
//#define HOTEND_OFFSET_Z { 0.0, 0.00 } // (mm) relative Z-offset for each nozzle
// @section machine
// @section psu control
/**
* Power Supply Control
@@ -499,7 +496,7 @@
* 30 : 100kΩ Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K - beta 3950
* 60 : 100kΩ Maker's Tool Works Kapton Bed Thermistor - beta 3950
* 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950
* 66 : 4.7MΩ Dyze Design High Temperature Thermistor
* 66 : 4.7MΩ Dyze Design / Trianglelab T-D500 500°C High Temperature Thermistor
* 67 : 500kΩ SliceEngineering 450°C Thermistor
* 68 : PT100 amplifier board from Dyze Design
* 70 : 100kΩ bq Hephestos 2
@@ -521,6 +518,7 @@
* 110 : Pt100 with 1kΩ pullup (atypical)
* 147 : Pt100 with 4.7kΩ pullup
* 1010 : Pt1000 with 1kΩ pullup (atypical)
* 1022 : Pt1000 with 2.2kΩ pullup
* 1047 : Pt1000 with 4.7kΩ pullup (E3D)
* 20 : Pt100 with circuit in the Ultimainboard V2.x with mainboard ADC reference voltage = INA826 amplifier-board supply voltage.
* NOTE: (1) Must use an ADC input with no pullup. (2) Some INA826 amplifiers are unreliable at 3.3V so consider using sensor 147, 110, or 21.
@@ -558,22 +556,36 @@
#define DUMMY_THERMISTOR_999_VALUE 100
// Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1
//#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000)
//#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000
//#define MAX31865_SENSOR_OHMS_1 100
//#define MAX31865_CALIBRATION_OHMS_1 430
#if TEMP_SENSOR_IS_MAX_TC(0)
#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000)
#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000
#endif
#if TEMP_SENSOR_IS_MAX_TC(1)
#define MAX31865_SENSOR_OHMS_1 100
#define MAX31865_CALIBRATION_OHMS_1 430
#endif
#if TEMP_SENSOR_IS_MAX_TC(2)
#define MAX31865_SENSOR_OHMS_2 100
#define MAX31865_CALIBRATION_OHMS_2 430
#endif
#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
#if HAS_E_TEMP_SENSOR
#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
#endif
#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190
#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
#if TEMP_SENSOR_BED
#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190
#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
#endif
#define TEMP_CHAMBER_RESIDENCY_TIME 10 // (seconds) Time to wait for chamber to "settle" in M191
#define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
#if TEMP_SENSOR_CHAMBER
#define TEMP_CHAMBER_RESIDENCY_TIME 10 // (seconds) Time to wait for chamber to "settle" in M191
#define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
#endif
/**
* Redundant Temperature Sensor (TEMP_SENSOR_REDUNDANT)
@@ -632,6 +644,8 @@
//============================= PID Settings ================================
//===========================================================================
// @section hotend temp
// Enable PIDTEMP for PID control or MPCTEMP for Predictive Model.
// temperature control. Disable both for bang-bang heating.
#define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning
@@ -642,7 +656,8 @@
#define PID_K1 0.95 // Smoothing factor within any PID loop
#if ENABLED(PIDTEMP)
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
//#define PID_DEBUG // Print PID debug data to the serial port. Use 'M303 D' to toggle activation.
//#define PID_PARAMS_PER_HOTEND // Use separate PID parameters for each extruder (useful for mismatched extruders)
// Set/get with G-code: M301 E[extruder number, 0-2]
#if ENABLED(PID_PARAMS_PER_HOTEND)
@@ -663,7 +678,8 @@
*
* Use a physical model of the hotend to control temperature. When configured correctly
* this gives better responsiveness and stability than PID and it also removes the need
* for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model.
* for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 T to autotune the model.
* @section mpctemp
*/
#if ENABLED(MPCTEMP)
//#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash)
@@ -716,6 +732,7 @@
* impact FET heating. This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W
* heater. If your configuration is significantly different than this and you don't understand
* the issues involved, don't use bed PID until someone else verifies that your hardware works.
* @section bed temp
*/
//#define PIDTEMPBED
@@ -731,7 +748,7 @@
#if ENABLED(PIDTEMPBED)
//#define MIN_BED_POWER 0
//#define PID_BED_DEBUG // Sends debug data to the serial port.
//#define PID_BED_DEBUG // Print Bed PID debug data to the serial port.
// 120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
// from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
@@ -759,6 +776,7 @@
* impact FET heating. This also works fine on a Fotek SSR-10DA Solid State Relay into a 200W
* heater. If your configuration is significantly different than this and you don't understand
* the issues involved, don't use chamber PID until someone else verifies that your hardware works.
* @section chamber temp
*/
//#define PIDTEMPCHAMBER
//#define CHAMBER_LIMIT_SWITCHING
@@ -773,7 +791,7 @@
#if ENABLED(PIDTEMPCHAMBER)
#define MIN_CHAMBER_POWER 0
//#define PID_CHAMBER_DEBUG // Sends debug data to the serial port.
//#define PID_CHAMBER_DEBUG // Print Chamber PID debug data to the serial port.
// Lasko "MyHeat Personal Heater" (200w) modified with a Fotek SSR-10DA to control only the heating element
// and placed inside the small Creality printer enclosure tent.
@@ -787,7 +805,6 @@
#endif // PIDTEMPCHAMBER
#if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER)
//#define PID_DEBUG // Sends debug data to the serial port. Use 'M303 D' to toggle activation.
//#define PID_OPENLOOP // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
@@ -797,7 +814,7 @@
//#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of flash)
#endif
// @section extruder
// @section safety
/**
* Prevent extrusion if the temperature is below EXTRUDE_MINTEMP.
@@ -862,14 +879,155 @@
//#define POLARGRAPH
#if ENABLED(POLARGRAPH)
#define POLARGRAPH_MAX_BELT_LEN 1035.0
#define POLAR_SEGMENTS_PER_SECOND 5
#define DEFAULT_SEGMENTS_PER_SECOND 5
#endif
// @section delta
// Enable for DELTA kinematics and configure below
//#define DELTA
#if ENABLED(DELTA)
// Make delta curves from many straight lines (linear interpolation).
// This is a trade-off between visible corners (not enough segments)
// and processor overload (too many expensive sqrt calls).
#define DEFAULT_SEGMENTS_PER_SECOND 200
// After homing move down to a height where XY movement is unconstrained
//#define DELTA_HOME_TO_SAFE_ZONE
// Delta calibration menu
// Add three-point calibration to the MarlinUI menu.
// See http://minow.blogspot.com/index.html#4918805519571907051
//#define DELTA_CALIBRATION_MENU
// G33 Delta Auto-Calibration. Enable EEPROM_SETTINGS to store results.
//#define DELTA_AUTO_CALIBRATION
#if ENABLED(DELTA_AUTO_CALIBRATION)
// Default number of probe points : n*n (1 -> 7)
#define DELTA_CALIBRATION_DEFAULT_POINTS 4
#endif
#if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU)
// Step size for paper-test probing
#define PROBE_MANUALLY_STEP 0.05 // (mm)
#endif
// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
#define DELTA_PRINTABLE_RADIUS 140.0 // (mm)
// Maximum reachable area
#define DELTA_MAX_RADIUS 140.0 // (mm)
// Center-to-center distance of the holes in the diagonal push rods.
#define DELTA_DIAGONAL_ROD 250.0 // (mm)
// Distance between bed and nozzle Z home position
#define DELTA_HEIGHT 250.00 // (mm) Get this value from G33 auto calibrate
#define DELTA_ENDSTOP_ADJ { 0.0, 0.0, 0.0 } // Get these values from G33 auto calibrate
// Horizontal distance bridged by diagonal push rods when effector is centered.
#define DELTA_RADIUS 124.0 // (mm) Get this value from G33 auto calibrate
// Trim adjustments for individual towers
// tower angle corrections for X and Y tower / rotate XYZ so Z tower angle = 0
// measured in degrees anticlockwise looking from above the printer
#define DELTA_TOWER_ANGLE_TRIM { 0.0, 0.0, 0.0 } // Get these values from G33 auto calibrate
// Delta radius and diagonal rod adjustments (mm)
//#define DELTA_RADIUS_TRIM_TOWER { 0.0, 0.0, 0.0 }
//#define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0.0, 0.0, 0.0 }
#endif
// @section scara
/**
* MORGAN_SCARA was developed by QHARLEY in South Africa in 2012-2013.
* Implemented and slightly reworked by JCERNY in June, 2014.
*
* Mostly Printed SCARA is an open source design by Tyler Williams. See:
* https://www.thingiverse.com/thing:2487048
* https://www.thingiverse.com/thing:1241491
*/
//#define MORGAN_SCARA
//#define MP_SCARA
#if EITHER(MORGAN_SCARA, MP_SCARA)
// If movement is choppy try lowering this value
#define DEFAULT_SEGMENTS_PER_SECOND 200
// Length of inner and outer support arms. Measure arm lengths precisely.
#define SCARA_LINKAGE_1 150 // (mm)
#define SCARA_LINKAGE_2 150 // (mm)
// SCARA tower offset (position of Tower relative to bed zero position)
// This needs to be reasonably accurate as it defines the printbed position in the SCARA space.
#define SCARA_OFFSET_X 100 // (mm)
#define SCARA_OFFSET_Y -56 // (mm)
#if ENABLED(MORGAN_SCARA)
//#define DEBUG_SCARA_KINEMATICS
#define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
// Radius around the center where the arm cannot reach
#define MIDDLE_DEAD_ZONE_R 0 // (mm)
#define THETA_HOMING_OFFSET 0 // Calculated from Calibration Guide and M360 / M114. See http://reprap.harleystudio.co.za/?page_id=1073
#define PSI_HOMING_OFFSET 0 // Calculated from Calibration Guide and M364 / M114. See http://reprap.harleystudio.co.za/?page_id=1073
#elif ENABLED(MP_SCARA)
#define SCARA_OFFSET_THETA1 12 // degrees
#define SCARA_OFFSET_THETA2 131 // degrees
#endif
#endif
// @section tpara
// Enable for TPARA kinematics and configure below
//#define AXEL_TPARA
#if ENABLED(AXEL_TPARA)
#define DEBUG_TPARA_KINEMATICS
#define DEFAULT_SEGMENTS_PER_SECOND 200
// Length of inner and outer support arms. Measure arm lengths precisely.
#define TPARA_LINKAGE_1 120 // (mm)
#define TPARA_LINKAGE_2 120 // (mm)
// SCARA tower offset (position of Tower relative to bed zero position)
// This needs to be reasonably accurate as it defines the printbed position in the SCARA space.
#define TPARA_OFFSET_X 0 // (mm)
#define TPARA_OFFSET_Y 0 // (mm)
#define TPARA_OFFSET_Z 0 // (mm)
#define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
// Radius around the center where the arm cannot reach
#define MIDDLE_DEAD_ZONE_R 0 // (mm)
// Calculated from Calibration Guide and M360 / M114. See http://reprap.harleystudio.co.za/?page_id=1073
#define THETA_HOMING_OFFSET 0
#define PSI_HOMING_OFFSET 0
#endif
// @section machine
// Articulated robot (arm). Joints are directly mapped to axes with no kinematics.
//#define ARTICULATED_ROBOT_ARM
// For a hot wire cutter with parallel horizontal axes (X, I) where the heights of the two wire
// ends are controlled by parallel axes (Y, J). Joints are directly mapped to axes (no kinematics).
//#define FOAMCUTTER_XYUV
//===========================================================================
//============================== Endstop Settings ===========================
//===========================================================================
// @section homing
// @section endstops
// Specify here all the endstop connectors that are connected to any endstop or probe.
// Almost all printers will be using one per axis. Probes will use one or more of the
@@ -1217,6 +1375,27 @@
#define Z_PROBE_RETRACT_X X_MAX_POS
#endif
/**
* Magnetically Mounted Probe
* For probes such as Euclid, Klicky, Klackender, etc.
*/
//#define MAG_MOUNTED_PROBE
#if ENABLED(MAG_MOUNTED_PROBE)
#define PROBE_DEPLOY_FEEDRATE (133*60) // (mm/min) Probe deploy speed
#define PROBE_STOW_FEEDRATE (133*60) // (mm/min) Probe stow speed
#define MAG_MOUNTED_DEPLOY_1 { PROBE_DEPLOY_FEEDRATE, { 245, 114, 30 } } // Move to side Dock & Attach probe
#define MAG_MOUNTED_DEPLOY_2 { PROBE_DEPLOY_FEEDRATE, { 210, 114, 30 } } // Move probe off dock
#define MAG_MOUNTED_DEPLOY_3 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed
#define MAG_MOUNTED_DEPLOY_4 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed
#define MAG_MOUNTED_DEPLOY_5 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed
#define MAG_MOUNTED_STOW_1 { PROBE_STOW_FEEDRATE, { 245, 114, 20 } } // Move to dock
#define MAG_MOUNTED_STOW_2 { PROBE_STOW_FEEDRATE, { 245, 114, 0 } } // Place probe beside remover
#define MAG_MOUNTED_STOW_3 { PROBE_STOW_FEEDRATE, { 230, 114, 0 } } // Side move to remove probe
#define MAG_MOUNTED_STOW_4 { PROBE_STOW_FEEDRATE, { 210, 114, 20 } } // Side move to remove probe
#define MAG_MOUNTED_STOW_5 { PROBE_STOW_FEEDRATE, { 0, 0, 0 } } // Extra move if needed
#endif
// Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J
// When the pin is defined you can use M672 to set/reset the probe sensitivity.
//#define DUET_SMART_EFFECTOR
@@ -1232,9 +1411,37 @@
*/
//#define SENSORLESS_PROBING
//
// For Z_PROBE_ALLEN_KEY see the Delta example configurations.
//
/**
* Allen key retractable z-probe as seen on many Kossel delta printers - https://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe
* Deploys by touching z-axis belt. Retracts by pushing the probe down.
*/
//#define Z_PROBE_ALLEN_KEY
#if ENABLED(Z_PROBE_ALLEN_KEY)
// 2 or 3 sets of coordinates for deploying and retracting the spring loaded touch probe on G29,
// if servo actuated touch probe is not defined. Uncomment as appropriate for your printer/probe.
#define Z_PROBE_ALLEN_KEY_DEPLOY_1 { 30.0, DELTA_PRINTABLE_RADIUS, 100.0 }
#define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE XY_PROBE_FEEDRATE
#define Z_PROBE_ALLEN_KEY_DEPLOY_2 { 0.0, DELTA_PRINTABLE_RADIUS, 100.0 }
#define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE (XY_PROBE_FEEDRATE)/10
#define Z_PROBE_ALLEN_KEY_DEPLOY_3 { 0.0, (DELTA_PRINTABLE_RADIUS) * 0.75, 100.0 }
#define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_FEEDRATE
#define Z_PROBE_ALLEN_KEY_STOW_1 { -64.0, 56.0, 23.0 } // Move the probe into position
#define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE XY_PROBE_FEEDRATE
#define Z_PROBE_ALLEN_KEY_STOW_2 { -64.0, 56.0, 3.0 } // Push it down
#define Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE (XY_PROBE_FEEDRATE)/10
#define Z_PROBE_ALLEN_KEY_STOW_3 { -64.0, 56.0, 50.0 } // Move it up to clear
#define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE XY_PROBE_FEEDRATE
#define Z_PROBE_ALLEN_KEY_STOW_4 { 0.0, 0.0, 50.0 }
#define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE XY_PROBE_FEEDRATE
#endif // Z_PROBE_ALLEN_KEY
/**
* Nozzle-to-Probe offsets { X, Y, Z }
@@ -1430,7 +1637,7 @@
#define DISABLE_E false // Disable the extruder when not stepping
#define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled
// @section machine
// @section motion
// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way.
#define INVERT_X_DIR false
@@ -1484,7 +1691,7 @@
//#define V_HOME_DIR -1
//#define W_HOME_DIR -1
// @section machine
// @section geometry
// The size of the printable area
#define X_BED_SIZE 200
@@ -1687,6 +1894,15 @@
#define LEVELING_BED_TEMP 50
#endif
/**
* Bed Distance Sensor
*
* Measures the distance from bed to nozzle with accuracy of 0.01mm.
* For information about this sensor https://github.com/markniu/Bed_Distance_sensor
* Uses I2C port, so it requires I2C library markyue/Panda_SoftMasterI2C.
*/
//#define BD_SENSOR
/**
* Enable detailed logging of G28, G29, M48, etc.
* Turn on with the command 'M111 S32'.
@@ -1700,17 +1916,21 @@
#endif
#if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL)
// Gradually reduce leveling correction until a set height is reached,
// at which point movement will be level to the machine's XY plane.
// The height can be set with M420 Z<height>
/**
* Gradually reduce leveling correction until a set height is reached,
* at which point movement will be level to the machine's XY plane.
* The height can be set with M420 Z<height>
*/
#define ENABLE_LEVELING_FADE_HEIGHT
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
#define DEFAULT_LEVELING_FADE_HEIGHT 10.0 // (mm) Default fade height.
#endif
// For Cartesian machines, instead of dividing moves on mesh boundaries,
// split up moves into short segments like a Delta. This follows the
// contours of the bed more closely than edge-to-edge straight moves.
/**
* For Cartesian machines, instead of dividing moves on mesh boundaries,
* split up moves into short segments like a Delta. This follows the
* contours of the bed more closely than edge-to-edge straight moves.
*/
#define SEGMENT_LEVELED_MOVES
#define LEVELED_SEGMENT_LENGTH 5.0 // (mm) Length of all segments (except the last one)
@@ -1809,7 +2029,7 @@
//#define LCD_BED_TRAMMING
#if ENABLED(LCD_BED_TRAMMING)
#define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets
#define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets
#define BED_TRAMMING_HEIGHT 0.0 // (mm) Z height of nozzle at leveling points
#define BED_TRAMMING_Z_HOP 4.0 // (mm) Z height of nozzle between leveling points
//#define BED_TRAMMING_INCLUDE_CENTER // Move to the center after the last corner
@@ -1921,9 +2141,8 @@
#define XY_DIAG_BD 282.8427124746
#define XY_SIDE_AD 200
// Or, set the default skew factors directly here
// to override the above measurements:
#define XY_SKEW_FACTOR 0.0
// Or, set the XY skew factor directly:
//#define XY_SKEW_FACTOR 0.0
//#define SKEW_CORRECTION_FOR_Z
#if ENABLED(SKEW_CORRECTION_FOR_Z)
@@ -1932,8 +2151,10 @@
#define YZ_DIAG_AC 282.8427124746
#define YZ_DIAG_BD 282.8427124746
#define YZ_SIDE_AD 200
#define XZ_SKEW_FACTOR 0.0
#define YZ_SKEW_FACTOR 0.0
// Or, set the Z skew factors directly:
//#define XZ_SKEW_FACTOR 0.0
//#define YZ_SKEW_FACTOR 0.0
#endif
// Enable this option for M852 to set skew at runtime
@@ -1944,7 +2165,7 @@
//============================= Additional Features ===========================
//=============================================================================
// @section extras
// @section eeprom
/**
* EEPROM
@@ -1964,6 +2185,8 @@
//#define EEPROM_INIT_NOW // Init EEPROM on first boot after a new build.
#endif
// @section host
//
// Host Keepalive
//
@@ -1974,6 +2197,8 @@
#define DEFAULT_KEEPALIVE_INTERVAL 2 // Number of seconds between "busy" messages. Set with M113.
#define BUSY_WHILE_HEATING // Some hosts require "busy" messages even during heating
// @section units
//
// G20/G21 Inch mode support
//
@@ -1987,7 +2212,7 @@
// @section temperature
//
// Preheat Constants - Up to 6 are supported without changes
// Preheat Constants - Up to 10 are supported without changes
//
#define PREHEAT_1_LABEL "PLA"
#define PREHEAT_1_TEMP_HOTEND 180
@@ -2001,6 +2226,8 @@
#define PREHEAT_2_TEMP_CHAMBER 35
#define PREHEAT_2_FAN_SPEED 0 // Value from 0 to 255
// @section motion
/**
* Nozzle Park
*
@@ -2099,6 +2326,8 @@
#endif
// @section host
/**
* Print Job Timer
*
@@ -2125,6 +2354,8 @@
*/
#define PRINTJOB_TIMER_AUTOSTART
// @section stats
/**
* Print Counter
*
@@ -2139,9 +2370,11 @@
*/
//#define PRINTCOUNTER
#if ENABLED(PRINTCOUNTER)
#define PRINTCOUNTER_SAVE_INTERVAL 60 // (minutes) EEPROM save interval during print
#define PRINTCOUNTER_SAVE_INTERVAL 60 // (minutes) EEPROM save interval during print. A value of 0 will save stats at end of print.
#endif
// @section security
/**
* Password
*
@@ -2177,7 +2410,7 @@
//============================= LCD and SD support ============================
//=============================================================================
// @section lcd
// @section interface
/**
* LCD LANGUAGE
@@ -2293,6 +2526,16 @@
//
//#define REVERSE_SELECT_DIRECTION
//
// Encoder EMI Noise Filter
//
// This option increases encoder samples to filter out phantom encoder clicks caused by EMI noise.
//
//#define ENCODER_NOISE_FILTER
#if ENABLED(ENCODER_NOISE_FILTER)
#define ENCODER_SAMPLES 10
#endif
//
// Individual Axis Homing
//
@@ -2323,6 +2566,7 @@
//======================== LCD / Controller Selection =========================
//======================== (Character-based LCDs) =========================
//=============================================================================
// @section lcd
//
// RepRapDiscount Smart Controller.
@@ -2497,7 +2741,7 @@
//
// ReprapWorld Graphical LCD
// https://reprapworld.com/?products_details&products_id/1218
// https://reprapworld.com/electronics/3d-printer-modules/autonomous-printing/graphical-lcd-screen-v1-0/
//
//#define REPRAPWORLD_GRAPHICAL_LCD
@@ -2624,6 +2868,12 @@
//
//#define SILVER_GATE_GLCD_CONTROLLER
//
// eMotion Tech LCD with SD
// https://www.reprap-france.com/produit/1234568748-ecran-graphique-128-x-64-points-2-1
//
//#define EMOTION_TECH_LCD
//=============================================================================
//============================== OLED Displays ==============================
//=============================================================================
@@ -2746,6 +2996,7 @@
//#define ANYCUBIC_LCD_CHIRON
#if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
//#define ANYCUBIC_LCD_DEBUG
//#define ANYCUBIC_LCD_GCODE_EXT // Add ".gcode" to menu entries for DGUS clone compatibility
#endif
//
@@ -2814,7 +3065,7 @@
//#define MKS_ROBIN_TFT_V1_1R
//
// 480x320, 3.5", FSMC Stock Display from TronxXY
// 480x320, 3.5", FSMC Stock Display from Tronxy
//
//#define TFT_TRONXY_X5SA
@@ -2881,6 +3132,10 @@
//#define TFT_COLOR_UI
//#define TFT_LVGL_UI
#if ENABLED(TFT_COLOR_UI)
//#define TFT_SHARED_SPI // SPI is shared between TFT display and other devices. Disable async data transfer
#endif
#if ENABLED(TFT_LVGL_UI)
//#define MKS_WIFI_MODULE // MKS WiFi module
#endif
@@ -2913,10 +3168,11 @@
//
//#define TOUCH_SCREEN
#if ENABLED(TOUCH_SCREEN)
#define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
#define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
#define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
#define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
//#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn)
//#define DISABLE_ENCODER // Disable the click encoder, if any
//#define TOUCH_IDLE_SLEEP_MINS 5 // (minutes) Display Sleep after a period of inactivity. Set with M255 S.
#define TOUCH_SCREEN_CALIBRATION
@@ -2951,7 +3207,7 @@
//=============================== Extra Features ==============================
//=============================================================================
// @section extras
// @section fans
// Set number of user-controlled fans. Disable to use all board-defined fans.
// :[1,2,3,4,5,6,7,8]
@@ -2975,14 +3231,18 @@
// duty cycle is attained.
//#define SOFT_PWM_DITHER
// @section extras
// Support for the BariCUDA Paste Extruder
//#define BARICUDA
// @section lights
// Temperature status LEDs that display the hotend and bed temperature.
// If all hotends, bed temperature, and target temperature are under 54C
// then the BLUE led is on. Otherwise the RED led is on. (1C hysteresis)
//#define TEMP_STAT_LEDS
// Support for the BariCUDA Paste Extruder
//#define BARICUDA
// Support for BlinkM/CyzRgb
//#define BLINKM
@@ -3003,16 +3263,19 @@
* luminance values can be set from 0 to 255.
* For NeoPixel LED an overall brightness parameter is also available.
*
* *** CAUTION ***
* === CAUTION ===
* LED Strips require a MOSFET Chip between PWM lines and LEDs,
* as the Arduino cannot handle the current the LEDs will require.
* Failure to follow this precaution can destroy your Arduino!
*
* NOTE: A separate 5V power supply is required! The NeoPixel LED needs
* more current than the Arduino 5V linear regulator can produce.
* *** CAUTION ***
*
* LED Type. Enable only one of the following two options.
* Requires PWM frequency between 50 <> 100Hz (Check HAL or variant)
* Use FAST_PWM_FAN, if possible, to reduce fan noise.
*/
// LED Type. Enable only one of the following two options:
//#define RGB_LED
//#define RGBW_LED
@@ -3021,6 +3284,10 @@
//#define RGB_LED_G_PIN 43
//#define RGB_LED_B_PIN 35
//#define RGB_LED_W_PIN -1
//#define RGB_STARTUP_TEST // For PWM pins, fade between all colors
#if ENABLED(RGB_STARTUP_TEST)
#define RGB_STARTUP_TEST_INNER_MS 10 // (ms) Reduce or increase fading speed
#endif
#endif
// Support for Adafruit NeoPixel LED driver
@@ -3042,6 +3309,7 @@
#define NEOPIXEL2_PIXELS 15 // Number of LEDs in the second strip
#define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255)
#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup
#define NEOPIXEL_M150_DEFAULT -1 // Default strip for M150 without 'S'. Use -1 to set all by default.
#else
//#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel
#endif
@@ -3068,6 +3336,8 @@
#define PRINTER_EVENT_LEDS
#endif
// @section servos
/**
* Number of servos
*

File diff suppressed because it is too large Load Diff

View File

@@ -109,7 +109,7 @@ LIQUID_TWI2 ?= 0
# This defines if Wire is needed
WIRE ?= 0
# This defines if Tone is needed (i.e SPEAKER is defined in Configuration.h)
# This defines if Tone is needed (i.e., SPEAKER is defined in Configuration.h)
# Disabling this (and SPEAKER) saves approximately 350 bytes of memory.
TONE ?= 1
@@ -307,133 +307,22 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1154)
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)
# Tenlog D3,5,6 Pro IDEX printers
else ifeq ($(HARDWARE_MOTHERBOARD),1157)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1158)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1159)
# Longer LK1 PRO / Alfawise U20 Pro (PRO version)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1160)
# Longer LKx PRO / Alfawise Uxx Pro (PRO version)
# Longer LK1 PRO / Alfawise U20 Pro (PRO version)
else ifeq ($(HARDWARE_MOTHERBOARD),1161)
# 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 v1.4 with A4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1108)
# MKS v1.5 with Allegro A4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1109)
# MKS 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)
# zrib V2.0 control board (Chinese RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1114)
# BigTreeTech or BIQU KFB2.0
else ifeq ($(HARDWARE_MOTHERBOARD),1115)
# Felix 2.0+ Electronics Board (RAMPS like)
else ifeq ($(HARDWARE_MOTHERBOARD),1116)
# Invent-A-Part RigidBoard
else ifeq ($(HARDWARE_MOTHERBOARD),1117)
# Invent-A-Part RigidBoard V2
else ifeq ($(HARDWARE_MOTHERBOARD),1118)
# Sainsmart 2-in-1 board
else ifeq ($(HARDWARE_MOTHERBOARD),1119)
# Ultimaker
else ifeq ($(HARDWARE_MOTHERBOARD),1120)
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
else ifeq ($(HARDWARE_MOTHERBOARD),1121)
MCU ?= atmega1280
PROG_MCU ?= m1280
# Azteeg X3
else ifeq ($(HARDWARE_MOTHERBOARD),1122)
# Azteeg X3 Pro
else ifeq ($(HARDWARE_MOTHERBOARD),1123)
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
else ifeq ($(HARDWARE_MOTHERBOARD),1124)
# Rumba
else ifeq ($(HARDWARE_MOTHERBOARD),1125)
# Raise3D Rumba
else ifeq ($(HARDWARE_MOTHERBOARD),1126)
# Rapide Lite RL200 Rumba
else ifeq ($(HARDWARE_MOTHERBOARD),1127)
# Formbot T-Rex 2 Plus
else ifeq ($(HARDWARE_MOTHERBOARD),1128)
# Formbot T-Rex 3
else ifeq ($(HARDWARE_MOTHERBOARD),1129)
# Formbot Raptor
else ifeq ($(HARDWARE_MOTHERBOARD),1130)
# Formbot Raptor 2
else ifeq ($(HARDWARE_MOTHERBOARD),1131)
# bq ZUM Mega 3D
else ifeq ($(HARDWARE_MOTHERBOARD),1132)
# MakeBoard Mini v2.1.2 is a control board sold by MicroMake
else ifeq ($(HARDWARE_MOTHERBOARD),1133)
# TriGorilla Anycubic version 1.3 based on RAMPS EFB
else ifeq ($(HARDWARE_MOTHERBOARD),1134)
# TriGorilla Anycubic version 1.4 based on RAMPS EFB
else ifeq ($(HARDWARE_MOTHERBOARD),1135)
# TriGorilla Anycubic version 1.4 Rev 1.1
else ifeq ($(HARDWARE_MOTHERBOARD),1136)
# Creality: Ender-4, CR-8
else ifeq ($(HARDWARE_MOTHERBOARD),1137)
# Creality: CR10S, CR20, CR-X
else ifeq ($(HARDWARE_MOTHERBOARD),1138)
# Dagoma F5
else ifeq ($(HARDWARE_MOTHERBOARD),1139)
# FYSETC F6 1.3
else ifeq ($(HARDWARE_MOTHERBOARD),1140)
# FYSETC F6 1.5
else ifeq ($(HARDWARE_MOTHERBOARD),1141)
# Duplicator i3 Plus
else ifeq ($(HARDWARE_MOTHERBOARD),1142)
# VORON
else ifeq ($(HARDWARE_MOTHERBOARD),1143)
# TRONXY V3 1.0
else ifeq ($(HARDWARE_MOTHERBOARD),1144)
# Z-Bolt X Series
else ifeq ($(HARDWARE_MOTHERBOARD),1145)
# TT OSCAR
else ifeq ($(HARDWARE_MOTHERBOARD),1146)
# Overlord/Overlord Pro
else ifeq ($(HARDWARE_MOTHERBOARD),1147)
# ADIMLab Gantry v1
else ifeq ($(HARDWARE_MOTHERBOARD),1148)
# ADIMLab Gantry v2
else ifeq ($(HARDWARE_MOTHERBOARD),1149)
# BIQU Tango V1
else ifeq ($(HARDWARE_MOTHERBOARD),1150)
# MKS GEN L V2
else ifeq ($(HARDWARE_MOTHERBOARD),1151)
# MKS GEN L V2.1
else ifeq ($(HARDWARE_MOTHERBOARD),1152)
# Copymaster 3D
else ifeq ($(HARDWARE_MOTHERBOARD),1153)
# Ortur 4
else ifeq ($(HARDWARE_MOTHERBOARD),1154)
# Tenlog D3 Hero
else ifeq ($(HARDWARE_MOTHERBOARD),1155)
# Longer LKx PRO / Alfawise Uxx Pro (PRO version)
else ifeq ($(HARDWARE_MOTHERBOARD),1162)
# Zonestar zrib V5.3 (Chinese RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1163)
# Pxmalion Core I3
else ifeq ($(HARDWARE_MOTHERBOARD),1164)
#
# RAMBo and derivatives

View File

@@ -28,7 +28,7 @@
/**
* Marlin release version identifier
*/
//#define SHORT_BUILD_VERSION "2.1"
//#define SHORT_BUILD_VERSION "2.1.2"
/**
* 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 "2022-06-04"
//#define STRING_DISTRIBUTION_DATE "2022-12-17"
/**
* Defines a generic printer name to be output to the LCD after booting Marlin.

211
Marlin/config.ini Normal file
View File

@@ -0,0 +1,211 @@
#
# Marlin Firmware
# config.ini - Options to apply before the build
#
[config:base]
ini_use_config = none
# Load all config: sections in this file
;ini_use_config = all
# Load config file relative to Marlin/
;ini_use_config = another.ini
# Download configurations from GitHub
;ini_use_config = example/Creality/Ender-5 Plus @ bugfix-2.1.x
# Download configurations from your server
;ini_use_config = https://me.myserver.com/path/to/configs
# Evaluate config:base and do a config dump
;ini_use_config = base
;config_export = 2
[config:minimal]
motherboard = BOARD_RAMPS_14_EFB
serial_port = 0
baudrate = 250000
use_watchdog = on
thermal_protection_hotends = on
thermal_protection_hysteresis = 4
thermal_protection_period = 40
bufsize = 4
block_buffer_size = 16
max_cmd_size = 96
extruders = 1
temp_sensor_0 = 1
temp_hysteresis = 3
heater_0_mintemp = 5
heater_0_maxtemp = 275
preheat_1_temp_hotend = 180
bang_max = 255
pidtemp = on
pid_k1 = 0.95
pid_max = BANG_MAX
pid_functional_range = 10
default_kp = 22.20
default_ki = 1.08
default_kd = 114.00
x_driver_type = A4988
y_driver_type = A4988
z_driver_type = A4988
e0_driver_type = A4988
x_bed_size = 200
x_min_pos = 0
x_max_pos = X_BED_SIZE
y_bed_size = 200
y_min_pos = 0
y_max_pos = Y_BED_SIZE
z_min_pos = 0
z_max_pos = 200
x_home_dir = -1
y_home_dir = -1
z_home_dir = -1
use_xmin_plug = on
use_ymin_plug = on
use_zmin_plug = on
x_min_endstop_inverting = false
y_min_endstop_inverting = false
z_min_endstop_inverting = false
default_axis_steps_per_unit = { 80, 80, 400, 500 }
axis_relative_modes = { false, false, false, false }
default_max_feedrate = { 300, 300, 5, 25 }
default_max_acceleration = { 3000, 3000, 100, 10000 }
homing_feedrate_mm_m = { (50*60), (50*60), (4*60) }
homing_bump_divisor = { 2, 2, 4 }
x_enable_on = 0
y_enable_on = 0
z_enable_on = 0
e_enable_on = 0
invert_x_dir = false
invert_y_dir = true
invert_z_dir = false
invert_e0_dir = false
invert_e_step_pin = false
invert_x_step_pin = false
invert_y_step_pin = false
invert_z_step_pin = false
disable_x = false
disable_y = false
disable_z = false
disable_e = false
proportional_font_ratio = 1.0
default_nominal_filament_dia = 1.75
junction_deviation_mm = 0.013
default_acceleration = 3000
default_travel_acceleration = 3000
default_retract_acceleration = 3000
default_minimumfeedrate = 0.0
default_mintravelfeedrate = 0.0
minimum_planner_speed = 0.05
min_steps_per_segment = 6
default_minsegmenttime = 20000
[config:basic]
bed_overshoot = 10
busy_while_heating = on
default_ejerk = 5.0
default_keepalive_interval = 2
default_leveling_fade_height = 0.0
disable_inactive_extruder = on
display_charset_hd44780 = JAPANESE
eeprom_boot_silent = on
eeprom_chitchat = on
endstoppullups = on
extrude_maxlength = 200
extrude_mintemp = 170
host_keepalive_feature = on
hotend_overshoot = 15
jd_handle_small_segments = on
lcd_info_screen_style = 0
lcd_language = en
max_bed_power = 255
mesh_inset = 0
min_software_endstops = on
max_software_endstops = on
min_software_endstop_x = on
min_software_endstop_y = on
min_software_endstop_z = on
max_software_endstop_x = on
max_software_endstop_y = on
max_software_endstop_z = on
preheat_1_fan_speed = 0
preheat_1_label = "PLA"
preheat_1_temp_bed = 70
prevent_cold_extrusion = on
prevent_lengthy_extrude = on
printjob_timer_autostart = on
probing_margin = 10
show_bootscreen = on
soft_pwm_scale = 0
string_config_h_author = "(none, default config)"
temp_bed_hysteresis = 3
temp_bed_residency_time = 10
temp_bed_window = 1
temp_residency_time = 10
temp_window = 1
validate_homing_endstops = on
xy_probe_feedrate = (133*60)
z_clearance_between_probes = 5
z_clearance_deploy_probe = 10
z_clearance_multi_probe = 5
[config:advanced]
arc_support = on
auto_report_temperatures = on
autotemp = on
autotemp_oldweight = 0.98
bed_check_interval = 5000
default_stepper_deactive_time = 120
default_volumetric_extruder_limit = 0.00
disable_inactive_e = true
disable_inactive_x = true
disable_inactive_y = true
disable_inactive_z = true
e0_auto_fan_pin = -1
encoder_100x_steps_per_sec = 80
encoder_10x_steps_per_sec = 30
encoder_rate_multiplier = on
extended_capabilities_report = on
extruder_auto_fan_speed = 255
extruder_auto_fan_temperature = 50
fanmux0_pin = -1
fanmux1_pin = -1
fanmux2_pin = -1
faster_gcode_parser = on
homing_bump_mm = { 5, 5, 2 }
max_arc_segment_mm = 1.0
min_arc_segment_mm = 0.1
min_circle_segments = 72
n_arc_correction = 25
serial_overrun_protection = on
slowdown = on
slowdown_divisor = 2
temp_sensor_bed = 0
thermal_protection_bed_hysteresis = 2
thermocouple_max_errors = 15
tx_buffer_size = 0
watch_bed_temp_increase = 2
watch_bed_temp_period = 60
watch_temp_increase = 2
watch_temp_period = 20

View File

@@ -32,6 +32,7 @@
#include <HardwareSerial.h>
#else
#include "MarlinSerial.h"
#define BOARD_NO_NATIVE_USB
#endif
#include <stdint.h>
@@ -106,36 +107,36 @@ typedef Servo hal_servo_t;
#define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0)
#else
#if !WITHIN(SERIAL_PORT, -1, 3)
#error "SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
#if !WITHIN(SERIAL_PORT, 0, 3)
#error "SERIAL_PORT must be from 0 to 3."
#endif
#define MYSERIAL1 customizedSerial1
#ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3)
#error "SERIAL_PORT_2 must be from 0 to 3, or -1 for USB Serial."
#if !WITHIN(SERIAL_PORT_2, 0, 3)
#error "SERIAL_PORT_2 must be from 0 to 3."
#endif
#define MYSERIAL2 customizedSerial2
#endif
#ifdef SERIAL_PORT_3
#if !WITHIN(SERIAL_PORT_3, -1, 3)
#error "SERIAL_PORT_3 must be from 0 to 3, or -1 for USB Serial."
#if !WITHIN(SERIAL_PORT_3, 0, 3)
#error "SERIAL_PORT_3 must be from 0 to 3."
#endif
#define MYSERIAL3 customizedSerial3
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if !WITHIN(MMU2_SERIAL_PORT, -1, 3)
#error "MMU2_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
#if !WITHIN(MMU2_SERIAL_PORT, 0, 3)
#error "MMU2_SERIAL_PORT must be from 0 to 3"
#endif
#define MMU2_SERIAL mmuSerial
#endif
#ifdef LCD_SERIAL_PORT
#if !WITHIN(LCD_SERIAL_PORT, -1, 3)
#error "LCD_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
#if !WITHIN(LCD_SERIAL_PORT, 0, 3)
#error "LCD_SERIAL_PORT must be from 0 to 3."
#endif
#define LCD_SERIAL lcdSerial
#if HAS_DGUS_LCD

View File

@@ -66,27 +66,26 @@ static volatile int8_t Channel[_Nbr_16timers]; // counter for the s
/************ static functions common to all instances ***********************/
static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t* TCNTn, volatile uint16_t* OCRnA) {
if (Channel[timer] < 0)
*TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer
else {
if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && SERVO(timer, Channel[timer]).Pin.isActive)
extDigitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
}
static inline void handle_interrupts(const timer16_Sequence_t timer, volatile uint16_t* TCNTn, volatile uint16_t* OCRnA) {
int8_t cho = Channel[timer]; // Handle the prior Channel[timer] first
if (cho < 0) // Channel -1 indicates the refresh interval completed...
*TCNTn = 0; // ...so reset the timer
else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled?
extDigitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW
Channel[timer]++; // increment to the next channel
if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
*OCRnA = *TCNTn + SERVO(timer, Channel[timer]).ticks;
if (SERVO(timer, Channel[timer]).Pin.isActive) // check if activated
extDigitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // it's an active channel so pulse it high
Channel[timer] = ++cho; // Handle the next channel (or 0)
if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) {
*OCRnA = *TCNTn + SERVO(timer, cho).ticks; // set compare to current ticks plus duration
if (SERVO(timer, cho).Pin.isActive) // activated?
extDigitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH
}
else {
// finished all channels so wait for the refresh period to expire before starting over
if (((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL)) // allow a few ticks to ensure the next OCR1A not missed
*OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL);
else
*OCRnA = *TCNTn + 4; // at least REFRESH_INTERVAL has elapsed
Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
const unsigned int cval = ((unsigned)*TCNTn) + 32 / (SERVO_TIMER_PRESCALER), // allow 32 cycles to ensure the next OCR1A not missed
ival = (unsigned int)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed
*OCRnA = max(cval, ival);
Channel[timer] = -1; // reset the timer counter to 0 on the next call
}
}
@@ -123,91 +122,102 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
/****************** end of static functions ******************************/
void initISR(timer16_Sequence_t timer) {
#ifdef _useTimer1
if (timer == _timer1) {
TCCR1A = 0; // normal counting mode
TCCR1B = _BV(CS11); // set prescaler of 8
TCNT1 = 0; // clear the timer count
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
SBI(TIFR, OCF1A); // clear any pending interrupts;
SBI(TIMSK, OCIE1A); // enable the output compare interrupt
#else
// here if not ATmega8 or ATmega128
SBI(TIFR1, OCF1A); // clear any pending interrupts;
SBI(TIMSK1, OCIE1A); // enable the output compare interrupt
#endif
#ifdef WIRING
timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
#endif
}
#endif
void initISR(const timer16_Sequence_t timer_index) {
switch (timer_index) {
default: break;
#ifdef _useTimer3
if (timer == _timer3) {
TCCR3A = 0; // normal counting mode
TCCR3B = _BV(CS31); // set prescaler of 8
TCNT3 = 0; // clear the timer count
#ifdef __AVR_ATmega128__
SBI(TIFR, OCF3A); // clear any pending interrupts;
SBI(ETIMSK, OCIE3A); // enable the output compare interrupt
#else
SBI(TIFR3, OCF3A); // clear any pending interrupts;
SBI(TIMSK3, OCIE3A); // enable the output compare interrupt
#endif
#ifdef WIRING
timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only
#endif
}
#endif
#ifdef _useTimer1
case _timer1:
TCCR1A = 0; // normal counting mode
TCCR1B = _BV(CS11); // set prescaler of 8
TCNT1 = 0; // clear the timer count
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
SBI(TIFR, OCF1A); // clear any pending interrupts;
SBI(TIMSK, OCIE1A); // enable the output compare interrupt
#else
// here if not ATmega8 or ATmega128
SBI(TIFR1, OCF1A); // clear any pending interrupts;
SBI(TIMSK1, OCIE1A); // enable the output compare interrupt
#endif
#ifdef WIRING
timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
#endif
break;
#endif
#ifdef _useTimer4
if (timer == _timer4) {
TCCR4A = 0; // normal counting mode
TCCR4B = _BV(CS41); // set prescaler of 8
TCNT4 = 0; // clear the timer count
TIFR4 = _BV(OCF4A); // clear any pending interrupts;
TIMSK4 = _BV(OCIE4A); // enable the output compare interrupt
}
#endif
#ifdef _useTimer3
case _timer3:
TCCR3A = 0; // normal counting mode
TCCR3B = _BV(CS31); // set prescaler of 8
TCNT3 = 0; // clear the timer count
#ifdef __AVR_ATmega128__
SBI(TIFR, OCF3A); // clear any pending interrupts;
SBI(ETIMSK, OCIE3A); // enable the output compare interrupt
#else
SBI(TIFR3, OCF3A); // clear any pending interrupts;
SBI(TIMSK3, OCIE3A); // enable the output compare interrupt
#endif
#ifdef WIRING
timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only
#endif
break;
#endif
#ifdef _useTimer5
if (timer == _timer5) {
TCCR5A = 0; // normal counting mode
TCCR5B = _BV(CS51); // set prescaler of 8
TCNT5 = 0; // clear the timer count
TIFR5 = _BV(OCF5A); // clear any pending interrupts;
TIMSK5 = _BV(OCIE5A); // enable the output compare interrupt
}
#endif
#ifdef _useTimer4
case _timer4:
TCCR4A = 0; // normal counting mode
TCCR4B = _BV(CS41); // set prescaler of 8
TCNT4 = 0; // clear the timer count
TIFR4 = _BV(OCF4A); // clear any pending interrupts;
TIMSK4 = _BV(OCIE4A); // enable the output compare interrupt
break;
#endif
#ifdef _useTimer5
case _timer5:
TCCR5A = 0; // normal counting mode
TCCR5B = _BV(CS51); // set prescaler of 8
TCNT5 = 0; // clear the timer count
TIFR5 = _BV(OCF5A); // clear any pending interrupts;
TIMSK5 = _BV(OCIE5A); // enable the output compare interrupt
break;
#endif
}
}
void finISR(timer16_Sequence_t timer) {
void finISR(const timer16_Sequence_t timer_index) {
// Disable use of the given timer
#ifdef WIRING
if (timer == _timer1) {
CBI(
#if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
TIMSK1
#else
TIMSK
#endif
, OCIE1A); // disable timer 1 output compare interrupt
timerDetach(TIMER1OUTCOMPAREA_INT);
}
else if (timer == _timer3) {
CBI(
#if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
TIMSK3
#else
ETIMSK
#endif
, OCIE3A); // disable the timer3 output compare A interrupt
timerDetach(TIMER3OUTCOMPAREA_INT);
switch (timer_index) {
default: break;
case _timer1:
CBI(
#if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
TIMSK1
#else
TIMSK
#endif
, OCIE1A // disable timer 1 output compare interrupt
);
timerDetach(TIMER1OUTCOMPAREA_INT);
break;
case _timer3:
CBI(
#if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
TIMSK3
#else
ETIMSK
#endif
, OCIE3A // disable the timer3 output compare A interrupt
);
timerDetach(TIMER3OUTCOMPAREA_INT);
break;
}
#else // !WIRING
// For arduino - in future: call here to a currently undefined function to reset the timer
UNUSED(timer);
UNUSED(timer_index);
#endif
}

View File

@@ -146,10 +146,10 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
LIMIT(res_pc_temp, 1U, maxtop);
// Calculate frequencies of test prescaler and resolution values
const uint32_t f_diff = _MAX(f, f_desired) - _MIN(f, f_desired),
f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)),
const uint16_t f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)),
f_pc_temp = (F_CPU) / (2 * p * res_pc_temp);
const int f_diff = _MAX(f, f_desired) - _MIN(f, f_desired),
f_fast_diff = _MAX(f_fast_temp, f_desired) - _MIN(f_fast_temp, f_desired),
f_pc_temp = (F_CPU) / (2 * p * res_pc_temp),
f_pc_diff = _MAX(f_pc_temp, f_desired) - _MIN(f_pc_temp, f_desired);
if (f_fast_diff < f_diff && f_fast_diff <= f_pc_diff) { // FAST values are closest to desired f

View File

@@ -293,11 +293,11 @@ enum ClockSource2 : uint8_t {
#if HAS_MOTOR_CURRENT_PWM
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_Z || P == MOTOR_CURRENT_PWM_XY)
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1 || P == MOTOR_CURRENT_PWM_Z || P == MOTOR_CURRENT_PWM_XY)
#elif PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_Z)
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1 || P == MOTOR_CURRENT_PWM_Z)
#else
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E)
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1)
#endif
#else
#define PWM_CHK_MOTOR_CURRENT(P) false

View File

@@ -35,16 +35,26 @@
|| X_STEP_PIN == N || Y_STEP_PIN == N || Z_STEP_PIN == N \
|| X_DIR_PIN == N || Y_DIR_PIN == N || Z_DIR_PIN == N \
|| X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \
|| BTN_EN1 == N || BTN_EN2 == N \
)
#if CONF_SERIAL_IS(0) // D0-D1. No known conflicts.
#if SERIAL_IN_USE(0)
// D0-D1. No known conflicts.
#endif
#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
#error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
#if SERIAL_IN_USE(1)
#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__)
#if CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)
#error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
#endif
#else
#if CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)
#error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board."
#endif
#endif
#endif
#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
#endif
#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
#endif
#undef CHECK_SERIAL_PIN

View File

@@ -210,7 +210,7 @@ public:
static void adc_init() {}
// Called by Temperature::init for each sensor at startup
static void adc_enable(const uint8_t ch) {}
static void adc_enable(const uint8_t /*ch*/) {}
// Begin ADC sampling on the given channel. Called from Temperature::isr!
static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); }

View File

@@ -247,12 +247,12 @@
b <<= 1; // little setup time
WRITE(SD_SCK_PIN, HIGH);
DELAY_NS(spiDelayNS);
DELAY_NS_VAR(spiDelayNS);
b |= (READ(SD_MISO_PIN) != 0);
WRITE(SD_SCK_PIN, LOW);
DELAY_NS(spiDelayNS);
DELAY_NS_VAR(spiDelayNS);
} while (--bits);
return b;
}

View File

@@ -41,7 +41,7 @@
practice, we need alignment to 256 bytes to make this work in all
cases */
__attribute__ ((aligned(256)))
static DeviceVectors ram_tab = { nullptr };
static DeviceVectors ram_tab[61] = { nullptr };
/**
* This function checks if the exception/interrupt table is already in SRAM or not.

View File

@@ -47,12 +47,12 @@
#include "../shared/servo.h"
#include "../shared/servo_private.h"
static volatile int8_t Channel[_Nbr_16timers]; // counter for the servo being pulsed for each timer (or -1 if refresh interval)
static Flags<_Nbr_16timers> DisablePending; // ISR should disable the timer at the next timer reset
// ------------------------
/// Interrupt handler for the TC0 channel 1.
// ------------------------
void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel);
void Servo_Handler(const timer16_Sequence_t, Tc*, const uint8_t);
#ifdef _useTimer1
void HANDLER_FOR_TIMER1() { Servo_Handler(_timer1, TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); }
@@ -70,88 +70,92 @@ void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel);
void HANDLER_FOR_TIMER5() { Servo_Handler(_timer5, TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); }
#endif
void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) {
// clear interrupt
tc->TC_CHANNEL[channel].TC_SR;
if (Channel[timer] < 0)
tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer
else if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && SERVO(timer, Channel[timer]).Pin.isActive)
extDigitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
void Servo_Handler(const timer16_Sequence_t timer, Tc *tc, const uint8_t channel) {
static int8_t Channel[_Nbr_16timers]; // Servo counters to pulse (or -1 for refresh interval)
int8_t cho = Channel[timer]; // Handle the prior Channel[timer] first
if (cho < 0) { // Channel -1 indicates the refresh interval completed...
tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // ...so reset the timer
if (DisablePending[timer]) {
// Disabling only after the full servo period expires prevents
// pulses being too close together if immediately re-enabled.
DisablePending.clear(timer);
TC_Stop(tc, channel);
tc->TC_CHANNEL[channel].TC_SR; // clear interrupt
return;
}
}
else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled?
extDigitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW
Channel[timer]++; // increment to the next channel
if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks;
if (SERVO(timer,Channel[timer]).Pin.isActive) // check if activated
extDigitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // its an active channel so pulse it high
Channel[timer] = ++cho; // go to the next channel (or 0)
if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) {
tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer, cho).ticks;
if (SERVO(timer, cho).Pin.isActive) // activated?
extDigitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH
}
else {
// finished all channels so wait for the refresh period to expire before starting over
tc->TC_CHANNEL[channel].TC_RA =
tc->TC_CHANNEL[channel].TC_CV < usToTicks(REFRESH_INTERVAL) - 4
? (unsigned int)usToTicks(REFRESH_INTERVAL) // allow a few ticks to ensure the next OCR1A not missed
: tc->TC_CHANNEL[channel].TC_CV + 4; // at least REFRESH_INTERVAL has elapsed
Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
const unsigned int cval = tc->TC_CHANNEL[channel].TC_CV + 128 / (SERVO_TIMER_PRESCALER), // allow 128 cycles to ensure the next CV not missed
ival = (unsigned int)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed
tc->TC_CHANNEL[channel].TC_RA = max(cval, ival);
Channel[timer] = -1; // reset the timer CCR on the next call
}
tc->TC_CHANNEL[channel].TC_SR; // clear interrupt
}
static void _initISR(Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) {
pmc_enable_periph_clk(id);
TC_Configure(tc, channel,
TC_CMR_TCCLKS_TIMER_CLOCK3 | // MCK/32
TC_CMR_WAVE | // Waveform mode
TC_CMR_WAVSEL_UP_RC ); // Counter running up and reset when equals to RC
TC_CMR_WAVE // Waveform mode
| TC_CMR_WAVSEL_UP_RC // Counter running up and reset when equal to RC
| (SERVO_TIMER_PRESCALER == 2 ? TC_CMR_TCCLKS_TIMER_CLOCK1 : 0) // MCK/2
| (SERVO_TIMER_PRESCALER == 8 ? TC_CMR_TCCLKS_TIMER_CLOCK2 : 0) // MCK/8
| (SERVO_TIMER_PRESCALER == 32 ? TC_CMR_TCCLKS_TIMER_CLOCK3 : 0) // MCK/32
| (SERVO_TIMER_PRESCALER == 128 ? TC_CMR_TCCLKS_TIMER_CLOCK4 : 0) // MCK/128
);
/* 84MHz, MCK/32, for 1.5ms: 3937 */
TC_SetRA(tc, channel, 2625); // 1ms
// Wait 1ms before the first ISR
TC_SetRA(tc, channel, (F_CPU) / (SERVO_TIMER_PRESCALER) / 1000UL); // 1ms
/* Configure and enable interrupt */
// Configure and enable interrupt
NVIC_EnableIRQ(irqn);
// TC_IER_CPAS: RA Compare
tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPAS;
tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPAS; // TC_IER_CPAS: RA Compare
// Enables the timer clock and performs a software reset to start the counting
TC_Start(tc, channel);
}
void initISR(timer16_Sequence_t timer) {
#ifdef _useTimer1
if (timer == _timer1)
_initISR(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1, ID_TC_FOR_TIMER1, IRQn_FOR_TIMER1);
#endif
#ifdef _useTimer2
if (timer == _timer2)
_initISR(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2, ID_TC_FOR_TIMER2, IRQn_FOR_TIMER2);
#endif
#ifdef _useTimer3
if (timer == _timer3)
_initISR(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3, ID_TC_FOR_TIMER3, IRQn_FOR_TIMER3);
#endif
#ifdef _useTimer4
if (timer == _timer4)
_initISR(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4, ID_TC_FOR_TIMER4, IRQn_FOR_TIMER4);
#endif
#ifdef _useTimer5
if (timer == _timer5)
_initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5);
#endif
void initISR(const timer16_Sequence_t timer_index) {
CRITICAL_SECTION_START();
const bool disable_soon = DisablePending[timer_index];
DisablePending.clear(timer_index);
CRITICAL_SECTION_END();
if (!disable_soon) switch (timer_index) {
default: break;
#ifdef _useTimer1
case _timer1: return _initISR(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1, ID_TC_FOR_TIMER1, IRQn_FOR_TIMER1);
#endif
#ifdef _useTimer2
case _timer2: return _initISR(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2, ID_TC_FOR_TIMER2, IRQn_FOR_TIMER2);
#endif
#ifdef _useTimer3
case _timer3: return _initISR(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3, ID_TC_FOR_TIMER3, IRQn_FOR_TIMER3);
#endif
#ifdef _useTimer4
case _timer4: return _initISR(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4, ID_TC_FOR_TIMER4, IRQn_FOR_TIMER4);
#endif
#ifdef _useTimer5
case _timer5: return _initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5);
#endif
}
}
void finISR(timer16_Sequence_t) {
#ifdef _useTimer1
TC_Stop(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1);
#endif
#ifdef _useTimer2
TC_Stop(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2);
#endif
#ifdef _useTimer3
TC_Stop(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3);
#endif
#ifdef _useTimer4
TC_Stop(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4);
#endif
#ifdef _useTimer5
TC_Stop(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5);
#endif
void finISR(const timer16_Sequence_t timer_index) {
// Timer is disabled from the ISR, to ensure proper final pulse length.
DisablePending.set(timer_index);
}
#endif // HAS_SERVOS

View File

@@ -37,7 +37,7 @@
#define _useTimer5
#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays
#define SERVO_TIMER_PRESCALER 32 // timer prescaler
#define SERVO_TIMER_PRESCALER 2 // timer prescaler
/*
TC0, chan 0 => TC0_Handler

View File

@@ -36,15 +36,15 @@
|| X_DIR_PIN == N || Y_DIR_PIN == N || Z_DIR_PIN == N \
|| X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \
)
#if CONF_SERIAL_IS(0) // D0-D1. No known conflicts.
#if SERIAL_IN_USE(0) // D0-D1. No known conflicts.
#endif
#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
#if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
#error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
#endif
#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
#endif
#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
#endif
#undef CHECK_SERIAL_PIN

View File

@@ -70,7 +70,7 @@
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#define GET_ARRAY_PIN(p) pin_array[p].pin
#define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0)
#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
#define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
#define IS_ANALOG(P) WITHIN(P, char(analogInputToDigitalPin(0)), char(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1)))
#define pwm_status(pin) (((g_pinStatus[pin] & 0xF) == PIN_STATUS_PWM) && \

View File

@@ -89,10 +89,17 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
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);
TC_Configure(tc, channel,
TC_CMR_WAVE
| TC_CMR_WAVSEL_UP_RC
| (HAL_TIMER_PRESCALER == 2 ? TC_CMR_TCCLKS_TIMER_CLOCK1 : 0)
| (HAL_TIMER_PRESCALER == 8 ? TC_CMR_TCCLKS_TIMER_CLOCK2 : 0)
| (HAL_TIMER_PRESCALER == 32 ? TC_CMR_TCCLKS_TIMER_CLOCK3 : 0)
| (HAL_TIMER_PRESCALER == 128 ? TC_CMR_TCCLKS_TIMER_CLOCK4 : 0)
);
// Set compare value
TC_SetRC(tc, channel, VARIANT_MCK / 2 / frequency);
TC_SetRC(tc, channel, VARIANT_MCK / (HAL_TIMER_PRESCALER) / frequency);
// And start timer
TC_Start(tc, channel);

View File

@@ -35,7 +35,8 @@
typedef uint32_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals
#define HAL_TIMER_PRESCALER 2
#define HAL_TIMER_RATE ((F_CPU) / (HAL_TIMER_PRESCALER)) // frequency of timers peripherals
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 2 // Timer Index for Stepper

View File

@@ -6,14 +6,14 @@
#
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"
)

View File

@@ -1059,7 +1059,7 @@ static inline void convert_64_bit_to_byte_array(uint64_t value, uint8_t *data)
while (val_index < 8)
{
data[val_index++] = value & 0xFF;
value = value >> 8;
value >>= 8;
}
}

View File

@@ -62,7 +62,7 @@ void usb_task_idle(void) {
// Attend SD card access from the USB MSD -- Prioritize access to improve speed
int delay = 2;
while (main_b_msc_enable && --delay > 0) {
if (udi_msc_process_trans()) delay = 10000;
if (udi_msc_process_trans()) delay = 20;
// Reset the watchdog, just to be sure
REG_WDT_CR = WDT_CR_WDRSTT | WDT_CR_KEY(0xA5);

View File

@@ -65,6 +65,7 @@ portMUX_TYPE MarlinHAL::spinlock = portMUX_INITIALIZER_UNLOCKED;
// ------------------------
uint16_t MarlinHAL::adc_result;
pwm_pin_t MarlinHAL::pwm_pin_data[MAX_EXPANDER_BITS];
// ------------------------
// Private Variables
@@ -330,21 +331,46 @@ int8_t get_pwm_channel(const pin_t pin, const uint32_t freq, const uint16_t res)
}
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=_BV(PWM_RESOLUTION)-1*/, const bool invert/*=false*/) {
const int8_t cid = get_pwm_channel(pin, PWM_FREQUENCY, PWM_RESOLUTION);
if (cid >= 0) {
uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, _BV(PWM_RESOLUTION)-1);
ledcWrite(cid, duty);
}
#if ENABLED(I2S_STEPPER_STREAM)
if (pin > 127) {
const uint8_t pinlo = pin & 0x7F;
pwm_pin_t &pindata = pwm_pin_data[pinlo];
const uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, pindata.pwm_cycle_ticks);
if (duty == 0 || duty == pindata.pwm_cycle_ticks) { // max or min (i.e., on/off)
pindata.pwm_duty_ticks = 0; // turn off PWM for this pin
duty ? SBI32(i2s_port_data, pinlo) : CBI32(i2s_port_data, pinlo); // set pin level
}
else
pindata.pwm_duty_ticks = duty; // PWM duty count = # of 4µs ticks per full PWM cycle
}
else
#endif
{
const int8_t cid = get_pwm_channel(pin, PWM_FREQUENCY, PWM_RESOLUTION);
if (cid >= 0) {
const uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, _BV(PWM_RESOLUTION)-1);
ledcWrite(cid, duty);
}
}
}
int8_t MarlinHAL::set_pwm_frequency(const pin_t pin, const uint32_t f_desired) {
const int8_t cid = channel_for_pin(pin);
if (cid >= 0) {
if (f_desired == ledcReadFreq(cid)) return cid; // no freq change
ledcDetachPin(chan_pin[cid]);
chan_pin[cid] = 0; // remove old freq channel
}
return get_pwm_channel(pin, f_desired, PWM_RESOLUTION); // try for new one
#if ENABLED(I2S_STEPPER_STREAM)
if (pin > 127) {
pwm_pin_data[pin & 0x7F].pwm_cycle_ticks = 1000000UL / f_desired / 4; // # of 4µs ticks per full PWM cycle
return 0;
}
else
#endif
{
const int8_t cid = channel_for_pin(pin);
if (cid >= 0) {
if (f_desired == ledcReadFreq(cid)) return cid; // no freq change
ledcDetachPin(chan_pin[cid]);
chan_pin[cid] = 0; // remove old freq channel
}
return get_pwm_channel(pin, f_desired, PWM_RESOLUTION); // try for new one
}
}
// use hardware PWM if avail, if not then ISR

View File

@@ -60,14 +60,17 @@
#endif
#endif
#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock)
#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock)
#define CRITICAL_SECTION_START() portENTER_CRITICAL(&hal.spinlock)
#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&hal.spinlock)
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
#define PWM_FREQUENCY 1000u // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency()
#define PWM_RESOLUTION 10u // Default PWM bit resolution
#define CHANNEL_MAX_NUM 15u // max PWM channel # to allocate (7 to only use low speed, 15 to use low & high)
#define MAX_PWM_IOPIN 33u // hardware pwm pins < 34
#ifndef MAX_EXPANDER_BITS
#define MAX_EXPANDER_BITS 32 // I2S expander bit width (max 32)
#endif
// ------------------------
// Types
@@ -76,6 +79,12 @@
typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs.
typedef int16_t pin_t;
typedef struct pwm_pin {
uint32_t pwm_cycle_ticks = 1000000UL / (PWM_FREQUENCY) / 4; // # ticks per pwm cycle
uint32_t pwm_tick_count = 0; // current tick count
uint32_t pwm_duty_ticks = 0; // # of ticks for current duty cycle
} pwm_pin_t;
class Servo;
typedef Servo hal_servo_t;
@@ -197,6 +206,8 @@ public:
// Free SRAM
static int freeMemory();
static pwm_pin_t pwm_pin_data[MAX_EXPANDER_BITS];
//
// ADC Methods
//

View File

@@ -139,22 +139,40 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg) {
}
void stepperTask(void *parameter) {
uint32_t remaining = 0;
uint32_t nextMainISR = 0;
#if ENABLED(LIN_ADVANCE)
uint32_t nextAdvanceISR = Stepper::LA_ADV_NEVER;
#endif
while (1) {
for (;;) {
xQueueReceive(dma.queue, &dma.current, portMAX_DELAY);
dma.rw_pos = 0;
while (dma.rw_pos < DMA_SAMPLE_COUNT) {
// Fill with the port data post pulse_phase until the next step
if (remaining) {
if (nextMainISR && TERN1(LIN_ADVANCE, nextAdvanceISR))
i2s_push_sample();
remaining--;
}
else {
// i2s_push_sample() is also called from Stepper::pulse_phase_isr() and Stepper::advance_isr()
// in a rare case where both are called, we need to double decrement the counters
const uint8_t push_count = 1 + (!nextMainISR && TERN0(LIN_ADVANCE, !nextAdvanceISR));
#if ENABLED(LIN_ADVANCE)
if (!nextAdvanceISR) {
Stepper::advance_isr();
nextAdvanceISR = Stepper::la_interval;
}
else if (nextAdvanceISR == Stepper::LA_ADV_NEVER)
nextAdvanceISR = Stepper::la_interval;
#endif
if (!nextMainISR) {
Stepper::pulse_phase_isr();
remaining = Stepper::block_phase_isr();
nextMainISR = Stepper::block_phase_isr();
}
nextMainISR -= push_count;
TERN_(LIN_ADVANCE, nextAdvanceISR -= push_count);
}
}
}
@@ -337,6 +355,26 @@ uint8_t i2s_state(uint8_t pin) {
}
void i2s_push_sample() {
// Every 4µs (when space in DMA buffer) toggle each expander PWM output using
// the current duty cycle/frequency so they sync with any steps (once
// through the DMA/FIFO buffers). PWM signal inversion handled by other functions
LOOP_L_N(p, MAX_EXPANDER_BITS) {
if (hal.pwm_pin_data[p].pwm_duty_ticks > 0) { // pin has active pwm?
if (hal.pwm_pin_data[p].pwm_tick_count == 0) {
if (TEST32(i2s_port_data, p)) { // hi->lo
CBI32(i2s_port_data, p);
hal.pwm_pin_data[p].pwm_tick_count = hal.pwm_pin_data[p].pwm_cycle_ticks - hal.pwm_pin_data[p].pwm_duty_ticks;
}
else { // lo->hi
SBI32(i2s_port_data, p);
hal.pwm_pin_data[p].pwm_tick_count = hal.pwm_pin_data[p].pwm_duty_ticks;
}
}
else
hal.pwm_pin_data[p].pwm_tick_count--;
}
}
dma.current[dma.rw_pos++] = i2s_port_data;
}

View File

@@ -20,3 +20,10 @@
*
*/
#pragma once
//
// Board-specific options need to be defined before HAL.h
//
#if MB(MKS_TINYBEE)
#define MAX_EXPANDER_BITS 24 // TinyBee has 3 x HC595
#endif

View File

@@ -45,6 +45,14 @@
#error "FAST_PWM_FAN is not available on TinyBee."
#endif
#if BOTH(I2S_STEPPER_STREAM, BABYSTEPPING) && DISABLED(INTEGRATED_BABYSTEPPING)
#error "BABYSTEPPING on I2S stream requires INTEGRATED_BABYSTEPPING."
#endif
#if USING_PULLDOWNS
#error "PULLDOWN pin mode is not available on ESP32 boards."
#endif
#if BOTH(I2S_STEPPER_STREAM, LIN_ADVANCE) && DISABLED(EXPERIMENTAL_I2S_LA)
#error "I2S stream is currently incompatible with LIN_ADVANCE."
#endif

View File

@@ -32,6 +32,13 @@
#include "HAL.h"
#include "SPI.h"
#if ENABLED(SDSUPPORT)
#include "../../sd/cardreader.h"
#if ENABLED(ESP3D_WIFISUPPORT)
#include "sd_ESP32.h"
#endif
#endif
static SPISettings spiConfig;
@@ -45,6 +52,11 @@ static SPISettings spiConfig;
uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT
#if ENABLED(PAUSE_LCD_FOR_BUSY_SD)
if (card.flag.saving || card.flag.logging || TERN0(ESP3D_WIFISUPPORT, sd_busy_lock == true)) return 0;
#endif
if (msgInitCount) {
if (msg == U8G_COM_MSG_INIT) msgInitCount--;
if (msgInitCount) return -1;

View File

@@ -69,12 +69,12 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
std::size_t bytes_written = 0;
for (std::size_t i = 0; i < size; i++) {
buffer[pos+i] = value[i];
bytes_written ++;
buffer[pos + i] = value[i];
bytes_written++;
}
crc16(crc, value, size);
pos = pos + size;
pos += size;
return (bytes_written != size); // return true for any error
}
@@ -82,21 +82,21 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uin
std::size_t bytes_read = 0;
if (writing) {
for (std::size_t i = 0; i < size; i++) {
value[i] = buffer[pos+i];
bytes_read ++;
value[i] = buffer[pos + i];
bytes_read++;
}
crc16(crc, value, size);
}
else {
uint8_t temp[size];
for (std::size_t i = 0; i < size; i++) {
temp[i] = buffer[pos+i];
bytes_read ++;
temp[i] = buffer[pos + i];
bytes_read++;
}
crc16(crc, temp, size);
}
pos = pos + size;
pos += size;
return bytes_read != size; // return true for any error
}

View File

@@ -26,8 +26,8 @@
struct LowpassFilter {
uint64_t data_delay = 0;
uint16_t update(uint16_t value) {
data_delay = data_delay - (data_delay >> 6) + value;
return (uint16_t)(data_delay >> 6);
data_delay += value - (data_delay >> 6);
return uint16_t(data_delay >> 6);
}
};

View File

@@ -318,8 +318,16 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
// Enable DMA
GPDMA_ChannelCmd(0, ENABLE);
/*
* Observed behaviour on normal data transfer completion (SKR 1.3 board / LPC1768 MCU)
* GPDMA_STAT_INTTC flag is SET
* GPDMA_STAT_INTERR flag is NOT SET
* GPDMA_STAT_RAWINTTC flag is NOT SET
* GPDMA_STAT_RAWINTERR flag is SET
*/
// Wait for data transfer
while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { }
while (!GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)) {}
// Clear err and int
GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
@@ -333,6 +341,43 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE);
}
void SPIClass::dmaSendAsync(void *buf, uint16_t length, bool minc) {
//TODO: LPC dma can only write 0xFFF bytes at once.
GPDMA_Channel_CFG_Type GPDMACfg;
/* Configure GPDMA channel 0 -------------------------------------------------------------*/
/* DMA Channel 0 */
GPDMACfg.ChannelNum = 0;
// Source memory
GPDMACfg.SrcMemAddr = (uint32_t)buf;
// Destination memory - Not used
GPDMACfg.DstMemAddr = 0;
// Transfer size
GPDMACfg.TransferSize = length;
// Transfer width
GPDMACfg.TransferWidth = (_currentSetting->dataSize == DATA_SIZE_16BIT) ? GPDMA_WIDTH_HALFWORD : GPDMA_WIDTH_BYTE;
// Transfer type
GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
// Source connection - unused
GPDMACfg.SrcConn = 0;
// Destination connection
GPDMACfg.DstConn = (_currentSetting->spi_d == LPC_SSP0) ? GPDMA_CONN_SSP0_Tx : GPDMA_CONN_SSP1_Tx;
GPDMACfg.DMALLI = 0;
// Enable dma on SPI
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE);
// Only increase memory if minc is true
GPDMACfg.MemoryIncrease = (minc ? GPDMA_DMACCxControl_SI : 0);
// Setup channel with given parameter
GPDMA_Setup(&GPDMACfg);
// Enable DMA
GPDMA_ChannelCmd(0, ENABLE);
}
uint16_t SPIClass::read() {
return SSP_ReceiveData(_currentSetting->spi_d);
}

View File

@@ -29,6 +29,6 @@
// LPC1768 boards seem to lose steps when saving to EEPROM during print (issue #20785)
// TODO: Which other boards are incompatible?
#if defined(MCU_LPC1768) && PRINTCOUNTER_SAVE_INTERVAL > 0
#if defined(MCU_LPC1768) && ENABLED(FLASH_EEPROM_EMULATION) && PRINTCOUNTER_SAVE_INTERVAL > 0
#define PRINTCOUNTER_SYNC 1
#endif

View File

@@ -155,6 +155,7 @@ public:
void read(uint8_t *buf, uint32_t len);
void dmaSend(void *buf, uint16_t length, bool minc);
void dmaSendAsync(void *buf, uint16_t length, bool minc);
/**
* @brief Sets the number of the SPI peripheral to be used by

View File

@@ -26,7 +26,7 @@
#include "tft_spi.h"
SPIClass TFT_SPI::SPIx(1);
SPIClass TFT_SPI::SPIx(TFT_SPI_DEVICE);
void TFT_SPI::Init() {
#if PIN_EXISTS(TFT_RESET)
@@ -38,40 +38,10 @@ void TFT_SPI::Init() {
OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
#endif
SET_OUTPUT(TFT_DC_PIN);
SET_OUTPUT(TFT_CS_PIN);
WRITE(TFT_DC_PIN, HIGH);
WRITE(TFT_CS_PIN, HIGH);
OUT_WRITE(TFT_DC_PIN, HIGH);
OUT_WRITE(TFT_CS_PIN, HIGH);
/**
* STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz
* STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1
* so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2
*/
#if 0
#if SPI_DEVICE == 1
#define SPI_CLOCK_MAX SPI_CLOCK_DIV4
#else
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2
#endif
uint8_t clock;
uint8_t spiRate = SPI_FULL_SPEED;
switch (spiRate) {
case SPI_FULL_SPEED: clock = SPI_CLOCK_MAX ; break;
case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4 ; break;
case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8 ; break;
case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break;
case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break;
case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break;
default: clock = SPI_CLOCK_DIV2; // Default from the SPI library
}
#endif
#if TFT_MISO_PIN == BOARD_SPI1_MISO_PIN
SPIx.setModule(1);
#elif TFT_MISO_PIN == BOARD_SPI2_MISO_PIN
SPIx.setModule(2);
#endif
SPIx.setModule(TFT_SPI_DEVICE);
SPIx.setClock(SPI_CLOCK_MAX_TFT);
SPIx.setBitOrder(MSBFIRST);
SPIx.setDataMode(SPI_MODE0);
@@ -114,17 +84,62 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) {
return data >> 7;
}
bool TFT_SPI::isBusy() { return false; }
bool TFT_SPI::isBusy() {
#define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->DMACCSrcAddr != 0)
void TFT_SPI::Abort() { DataTransferEnd(); }
// DMA Channel 0 is hardcoded in dmaSendAsync() and dmaSend()
if (!__IS_DMA_CONFIGURED(LPC_GPDMACH0)) return false;
void TFT_SPI::Transmit(uint16_t Data) { SPIx.transfer(Data); }
if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)) {
// You should not be here - DMA transfer error flag is set
// Abort DMA transfer and release SPI
}
else {
// Check if DMA transfer completed flag is set
if (!GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)) return true;
// Check if SPI TX butter is empty and SPI is idle
if ((SSP_GetStatus(LPC_SSPx, SSP_STAT_TXFIFO_EMPTY) == RESET) || (SSP_GetStatus(LPC_SSPx, SSP_STAT_BUSY) == SET)) return true;
}
Abort();
return false;
}
void TFT_SPI::Abort() {
// DMA Channel 0 is hardcoded in dmaSendAsync() and dmaSend()
// Disable DMA
GPDMA_ChannelCmd(0, DISABLE);
// Clear ERR and TC
GPDMA_ClearIntPending(GPDMA_STATCLR_INTTC, 0);
GPDMA_ClearIntPending(GPDMA_STATCLR_INTERR, 0);
// Disable DMA on SPI
SSP_DMACmd(LPC_SSPx, SSP_DMA_TX, DISABLE);
// Deconfigure DMA Channel 0
LPC_GPDMACH0->DMACCControl = 0U;
LPC_GPDMACH0->DMACCConfig = 0U;
LPC_GPDMACH0->DMACCSrcAddr = 0U;
LPC_GPDMACH0->DMACCDestAddr = 0U;
void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
DataTransferBegin(DATASIZE_16BIT);
WRITE(TFT_DC_PIN, HIGH);
SPIx.dmaSend(Data, Count, MemoryIncrease);
DataTransferEnd();
}
void TFT_SPI::Transmit(uint16_t Data) { SPIx.transfer(Data); }
void TFT_SPI::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
DataTransferBegin(DATASIZE_16BIT);
SPIx.dmaSend(Data, Count, MemoryIncrease);
Abort();
}
void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
DataTransferBegin(DATASIZE_16BIT);
SPIx.dmaSendAsync(Data, Count, MemoryIncrease);
TERN_(TFT_SHARED_SPI, while (isBusy()));
}
#endif // HAS_SPI_TFT

View File

@@ -27,6 +27,18 @@
#include <lpc17xx_ssp.h>
// #include <lpc17xx_gpdma.h>
#define IS_SPI(N) (BOARD_NR_SPI >= N && (TFT_SCK_PIN == BOARD_SPI##N##_SCK_PIN) && (TFT_MOSI_PIN == BOARD_SPI##N##_MOSI_PIN) && (TFT_MISO_PIN == BOARD_SPI##N##_MISO_PIN))
#if IS_SPI(1)
#define TFT_SPI_DEVICE 1
#define LPC_SSPx LPC_SSP0
#elif IS_SPI(2)
#define TFT_SPI_DEVICE 2
#define LPC_SSPx LPC_SSP1
#else
#error "Invalid TFT SPI configuration."
#endif
#undef IS_SPI
#ifndef LCD_READ_ID
#define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
#endif
@@ -34,17 +46,19 @@
#define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341)
#endif
#define DATASIZE_8BIT SSP_DATABIT_8
#define DATASIZE_16BIT SSP_DATABIT_16
#define TFT_IO_DRIVER TFT_SPI
#define DATASIZE_8BIT SSP_DATABIT_8
#define DATASIZE_16BIT SSP_DATABIT_16
#define TFT_IO_DRIVER TFT_SPI
#define DMA_MAX_SIZE 0xFFF
#define DMA_MINC_ENABLE 1
#define DMA_MINC_DISABLE 0
#define DMA_MINC_ENABLE 1
#define DMA_MINC_DISABLE 0
class TFT_SPI {
private:
static uint32_t ReadID(uint16_t Reg);
static void Transmit(uint16_t Data);
static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
public:
@@ -56,22 +70,20 @@ public:
static void Abort();
static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT);
static void DataTransferEnd() { OUT_WRITE(TFT_CS_PIN, HIGH); SPIx.end(); };
static void DataTransferEnd() { WRITE(TFT_CS_PIN, HIGH); SSP_Cmd(LPC_SSPx, DISABLE); };
static void DataTransferAbort();
static void WriteData(uint16_t Data) { Transmit(Data); }
static void WriteReg(uint16_t Reg) { OUT_WRITE(TFT_A0_PIN, LOW); Transmit(Reg); OUT_WRITE(TFT_A0_PIN, HIGH); }
static void WriteReg(uint16_t Reg) { WRITE(TFT_DC_PIN, LOW); Transmit(Reg); WRITE(TFT_DC_PIN, HIGH); }
static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); }
// static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); }
static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_MINC_ENABLE, Data, Count); }
static void WriteMultiple(uint16_t Color, uint32_t Count) {
static uint16_t Data; Data = Color;
//LPC dma can only write 0xFFF bytes at once.
#define MAX_DMA_SIZE (0xFFF - 1)
while (Count > 0) {
TransmitDMA(DMA_MINC_DISABLE, &Data, Count > MAX_DMA_SIZE ? MAX_DMA_SIZE : Count);
Count = Count > MAX_DMA_SIZE ? Count - MAX_DMA_SIZE : 0;
Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count);
Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0;
}
#undef MAX_DMA_SIZE
}
};

View File

@@ -44,9 +44,11 @@ uint16_t delta(uint16_t a, uint16_t b) { return a > b ? a - b : b - a; }
#endif
void XPT2046::Init() {
SET_INPUT(TOUCH_MISO_PIN);
SET_OUTPUT(TOUCH_MOSI_PIN);
SET_OUTPUT(TOUCH_SCK_PIN);
#if DISABLED(TOUCH_BUTTONS_HW_SPI)
SET_INPUT(TOUCH_MISO_PIN);
SET_OUTPUT(TOUCH_MOSI_PIN);
SET_OUTPUT(TOUCH_SCK_PIN);
#endif
OUT_WRITE(TOUCH_CS_PIN, HIGH);
#if PIN_EXISTS(TOUCH_INT)

View File

@@ -9,119 +9,127 @@ from __future__ import print_function
import pioutil
if pioutil.is_pio_build():
target_filename = "FIRMWARE.CUR"
target_drive = "REARM"
target_filename = "FIRMWARE.CUR"
target_drive = "REARM"
import os,getpass,platform
import platform
current_OS = platform.system()
Import("env")
current_OS = platform.system()
Import("env")
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 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
#
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
def before_upload(source, target, env):
try:
from pathlib import Path
#
# Find a disk for upload
#
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
from pathlib import PureWindowsPath
# 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:
upload_disk = final_drive_name
target_file_found = True
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 = PureWindowsPath(final_drive_name)
if target_filename in volume_info:
if not target_file_found:
upload_disk = PureWindowsPath(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:
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
#
elif current_OS == 'Linux':
#
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
#
import getpass
user = getpass.getuser()
mpath = Path('/media', user)
drives = [ x for x in mpath.iterdir() if x.is_dir() ]
if target_drive in drives: # If target drive is found, use it.
target_drive_found = True
upload_disk = mpath / target_drive
else:
for drive in drives:
try:
fpath = mpath / drive
filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
except:
continue
else:
if target_filename in filenames:
upload_disk = mpath / 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"
)
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:
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
elif current_OS == 'Darwin': # MAC
#
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
#
dpath = Path('/Volumes') # human readable names
drives = [ x for x in dpath.iterdir() if x.is_dir() ]
if target_drive in drives and not target_file_found: # set upload if not found target file yet
target_drive_found = True
upload_disk = dpath / target_drive
for drive in drives:
try:
fpath = dpath / drive # will get an error if the drive is protected
filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
except:
continue
else:
if target_filename in filenames:
upload_disk = dpath / drive
target_file_found = True
break
#
# 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')
#
# Set upload_port to drive if found
#
if target_file_found or target_drive_found:
env.Replace(UPLOAD_PORT=str(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)

View File

@@ -44,7 +44,7 @@
*
* Now you can simply SET_OUTPUT(STEP); WRITE(STEP, HIGH); WRITE(STEP, LOW);
*
* Why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
* Why double up on these macros? see https://gcc.gnu.org/onlinedocs/cpp/Stringification.html
*/
/// Read a pin

View File

@@ -51,7 +51,7 @@ enum XPTCoordinate : uint8_t {
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
};
#if !defined(XPT2046_Z1_THRESHOLD)
#ifndef XPT2046_Z1_THRESHOLD
#define XPT2046_Z1_THRESHOLD 10
#endif

View File

@@ -168,4 +168,4 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
#endif
#endif // IS_U8GLIB_ST7920
#endif // TARGET_LPC1768
#endif // __PLAT_NATIVE_SIM__

View File

@@ -0,0 +1,212 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD21__
#include "../../inc/MarlinConfig.h"
#include <wiring_private.h>
#if USING_HW_SERIALUSB
DefaultSerial1 MSerialUSB(false, SerialUSB);
#endif
#if USING_HW_SERIAL0
DefaultSerial2 MSerial1(false, Serial1);
#endif
#if USING_HW_SERIAL1
DefaultSerial3 MSerial2(false, Serial2);
#endif
#define WDT_CONFIG_PER_7_Val 0x9u
#define WDT_CONFIG_PER_Pos 0
#define WDT_CONFIG_PER_7 (WDT_CONFIG_PER_7_Val << WDT_CONFIG_PER_Pos)
#if ENABLED(USE_WATCHDOG)
#define WDT_TIMEOUT_REG TERN(WATCHDOG_DURATION_8S, WDT_CONFIG_PER_CYC8192, WDT_CONFIG_PER_CYC4096) // 4 or 8 second timeout
void MarlinHAL::watchdog_init() {
// Set up the generic clock (GCLK2) used to clock the watchdog timer at 1.024kHz
GCLK->GENDIV.reg = GCLK_GENDIV_DIV(4) | // Divide the 32.768kHz clock source by divisor 32, where 2^(4 + 1): 32.768kHz/32=1.024kHz
GCLK_GENDIV_ID(2); // Select Generic Clock (GCLK) 2
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
REG_GCLK_GENCTRL = GCLK_GENCTRL_DIVSEL | // Set to divide by 2^(GCLK_GENDIV_DIV(4) + 1)
GCLK_GENCTRL_IDC | // Set the duty cycle to 50/50 HIGH/LOW
GCLK_GENCTRL_GENEN | // Enable GCLK2
GCLK_GENCTRL_SRC_OSCULP32K | // Set the clock source to the ultra low power oscillator (OSCULP32K)
GCLK_GENCTRL_ID(2); // Select GCLK2
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
// Feed GCLK2 to WDT (Watchdog Timer)
REG_GCLK_CLKCTRL = GCLK_CLKCTRL_CLKEN | // Enable GCLK2 to the WDT
GCLK_CLKCTRL_GEN_GCLK2 | // Select GCLK2
GCLK_CLKCTRL_ID_WDT; // Feed the GCLK2 to the WDT
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
WDT->CONFIG.bit.PER = WDT_CONFIG_PER_7; // Set the WDT reset timeout to 4 seconds
while (WDT->STATUS.bit.SYNCBUSY); // Wait for synchronization
REG_WDT_CTRL = WDT_CTRL_ENABLE; // Enable the WDT in normal mode
while (WDT->STATUS.bit.SYNCBUSY); // Wait for synchronization
}
// Reset watchdog. MUST be called at least every 4 seconds after the
// first watchdog_init or SAMD will go into emergency procedures.
void MarlinHAL::watchdog_refresh() {
WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY;
while (WDT->STATUS.bit.SYNCBUSY);
}
#endif
// ------------------------
// Types
// ------------------------
// ------------------------
// Private Variables
// ------------------------
// ------------------------
// Private functions
// ------------------------
void MarlinHAL::dma_init() {}
// ------------------------
// Public functions
// ------------------------
// HAL initialization task
void MarlinHAL::init() {
TERN_(DMA_IS_REQUIRED, dma_init());
#if ENABLED(SDSUPPORT)
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
#endif
}
#pragma push_macro("WDT")
#undef WDT // Required to be able to use '.bit.WDT'. Compiler wrongly replace struct field with WDT define
uint8_t MarlinHAL::get_reset_source() {
return 0;
}
#pragma pop_macro("WDT")
void MarlinHAL::reboot() { NVIC_SystemReset(); }
extern "C" {
void * _sbrk(int incr);
extern unsigned int __bss_end__; // end of bss section
}
// Return free memory between end of heap (or end bss) and whatever is current
int freeMemory() {
int free_memory, heap_end = (int)_sbrk(0);
return (int)&free_memory - (heap_end ?: (int)&__bss_end__);
}
// ------------------------
// ADC
// ------------------------
uint16_t MarlinHAL::adc_result;
void MarlinHAL::adc_init() {
/* thanks to https://www.eevblog.com/forum/microcontrollers/samd21g18-adc-with-resrdy-interrupts-only-reads-once-or-twice/ */
ADC->CTRLA.bit.ENABLE = false;
while(ADC->STATUS.bit.SYNCBUSY);
// load chip corrections
uint32_t bias = (*((uint32_t *) ADC_FUSES_BIASCAL_ADDR) & ADC_FUSES_BIASCAL_Msk) >> ADC_FUSES_BIASCAL_Pos;
uint32_t linearity = (*((uint32_t *) ADC_FUSES_LINEARITY_0_ADDR) & ADC_FUSES_LINEARITY_0_Msk) >> ADC_FUSES_LINEARITY_0_Pos;
linearity |= ((*((uint32_t *) ADC_FUSES_LINEARITY_1_ADDR) & ADC_FUSES_LINEARITY_1_Msk) >> ADC_FUSES_LINEARITY_1_Pos) << 5;
/* Wait for bus synchronization. */
while (ADC->STATUS.bit.SYNCBUSY) {};
ADC->CALIB.reg = ADC_CALIB_BIAS_CAL(bias) | ADC_CALIB_LINEARITY_CAL(linearity);
/* Wait for bus synchronization. */
while (ADC->STATUS.bit.SYNCBUSY) {};
ADC->CTRLA.bit.SWRST = true;
while(ADC->STATUS.bit.SYNCBUSY);
ADC->REFCTRL.reg = ADC_REFCTRL_REFSEL_INTVCC1;
ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_32| ADC_AVGCTRL_ADJRES(4);;
ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV128 |
ADC_CTRLB_RESSEL_16BIT |
ADC_CTRLB_FREERUN;
while(ADC->STATUS.bit.SYNCBUSY);
ADC->SAMPCTRL.bit.SAMPLEN = 0x00;
while(ADC->STATUS.bit.SYNCBUSY);
ADC->INPUTCTRL.reg = ADC_INPUTCTRL_INPUTSCAN(HAL_ADC_AIN_LEN) // scan (INPUTSCAN + NUM_EXTUDERS - 1) pins
| ADC_INPUTCTRL_GAIN_DIV2 |ADC_INPUTCTRL_MUXNEG_GND| HAL_ADC_AIN_START ; /* set to first AIN */
while(ADC->STATUS.bit.SYNCBUSY);
ADC->INTENSET.reg |= ADC_INTENSET_RESRDY; // enable Result Ready ADC interrupts
while (ADC->STATUS.bit.SYNCBUSY);
NVIC_EnableIRQ(ADC_IRQn); // enable ADC interrupts
NVIC_SetPriority(ADC_IRQn, 3);
ADC->CTRLA.bit.ENABLE = true;
}
volatile uint32_t adc_results[HAL_ADC_AIN_NUM_SENSORS];
void ADC_Handler() {
while(ADC->STATUS.bit.SYNCBUSY == 1);
int pos = ADC->INPUTCTRL.bit.INPUTOFFSET;
adc_results[pos] = ADC->RESULT.reg; /* Read the value. */
ADC->INTFLAG.reg = ADC_INTENSET_RESRDY; /* Clear the data ready flag. */
}
void MarlinHAL::adc_start(const pin_t pin) {
/* due to the way INPUTOFFSET works, the last sensor is the first position in the array
and we want the ADC_handler interrupt to be as simple possible, so we do the calculation here.
*/
unsigned int pos = PIN_TO_INPUTCTRL(pin) - HAL_ADC_AIN_START + 1;
if (pos == HAL_ADC_AIN_NUM_SENSORS) pos = 0;
adc_result = adc_results[pos]; // 16-bit resolution
//adc_result = 0xFFFF;
}
#endif // __SAMD21__

223
Marlin/src/HAL/SAMD21/HAL.h Normal file
View File

@@ -0,0 +1,223 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#define CPU_32_BIT
#include "../shared/Marduino.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
#include "fastio.h"
// ------------------------
// Serial ports
// ------------------------
#include "../../core/serial_hook.h"
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
extern DefaultSerial1 MSerialUSB;
// Serial ports
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
extern DefaultSerial2 MSerial0;
extern DefaultSerial3 MSerial1;
#define __MSERIAL(X) MSerial##X
#define _MSERIAL(X) __MSERIAL(X)
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
#if WITHIN(SERIAL_PORT, 0, 1)
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
#elif SERIAL_PORT == -1
#define MYSERIAL1 MSerialUSB
#else
#error "SERIAL_PORT must be -1 (Native USB only)."
#endif
#ifdef SERIAL_PORT_2
#if WITHIN(SERIAL_PORT_2, 0, 1)
#define MYSERIAL2 MSERIAL(SERIAL_PORT)
#elif SERIAL_PORT_2 == -1
#define MYSERIAL2 MSerialUSB
#else
#error "SERIAL_PORT_2 must be -1 (Native USB only)."
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if WITHIN(MMU2_SERIAL_PORT, 0, 1)
#define MMU2_SERIAL MSERIAL(SERIAL_PORT)
#elif MMU2_SERIAL_PORT == -1
#define MMU2_SERIAL MSerialUSB
#else
#error "MMU2_SERIAL_PORT must be -1 (Native USB only)."
#endif
#endif
#ifdef LCD_SERIAL_PORT
#if WITHIN(LCD_SERIAL_PORT, 0, 1)
#define LCD_SERIAL MSERIAL(SERIAL_PORT)
#elif LCD_SERIAL_PORT == -1
#define LCD_SERIAL MSerialUSB
#else
#error "LCD_SERIAL_PORT must be -1 (Native USB only)."
#endif
#endif
typedef int8_t pin_t;
#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp
class Servo;
typedef Servo hal_servo_t;
//
// Interrupts
//
#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq()
#define CRITICAL_SECTION_END() if (irqon) __enable_irq()
#define cli() __disable_irq() // Disable interrupts
#define sei() __enable_irq() // Enable interrupts
//
// ADC
//
#define HAL_ADC_FILTERED 1 // Disable Marlin's oversampling. The HAL filters ADC values.
#define HAL_ADC_VREF 3.3
#define HAL_ADC_RESOLUTION 12
#define HAL_ADC_AIN_START ADC_INPUTCTRL_MUXPOS_PIN3
#define HAL_ADC_AIN_NUM_SENSORS 3
#define HAL_ADC_AIN_LEN HAL_ADC_AIN_NUM_SENSORS-1
//
// Pin Mapping for M42, M43, M226
//
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
//
// Tone
//
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
void noTone(const pin_t _pin);
// ------------------------
// Class Utilities
// ------------------------
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#ifdef __cplusplus
extern "C" {
#endif
char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
extern "C" int freeMemory();
#ifdef __cplusplus
}
#endif
#pragma GCC diagnostic pop
// ------------------------
// MarlinHAL Class
// ------------------------
class MarlinHAL {
public:
// Earliest possible init, before setup()
MarlinHAL() {}
// Watchdog
static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {});
static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {});
static void init(); // Called early in setup()
static void init_board() {} // Called less early in setup()
static void reboot(); // Restart the firmware from 0x0
// Interrupts
static bool isr_state() { return !__get_PRIMASK(); }
static void isr_on() { sei(); }
static void isr_off() { cli(); }
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
static void idletask() {}
// Reset
static uint8_t get_reset_source();
static void clear_reset_source() {}
// Free SRAM
static int freeMemory() { return ::freeMemory(); }
//
// ADC Methods
//
static uint16_t adc_result;
// Called by Temperature::init once at startup
static void adc_init();
// Called by Temperature::init for each sensor at startup
static void adc_enable(const uint8_t ch) {}
// Begin ADC sampling on the given pin. Called from Temperature::isr!
static void adc_start(const pin_t pin);
// Is the ADC ready for reading?
static bool adc_ready() { return true; }
// The current value of the ADC register
static uint16_t adc_value() { return adc_result; }
/**
* Set the PWM duty cycle for the pin to the given value.
* No option to invert the duty cycle [default = false]
* No option to change the scale of the provided value to enable finer PWM duty control [default = 255]
*/
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
analogWrite(pin, v);
}
private:
static void dma_init();
};

View File

@@ -0,0 +1,148 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
/**
* Hardware and software SPI implementations are included in this file.
*
* Control of the slave select pin(s) is handled by the calling routines and
* SAMD21 let hardware SPI handling to remove SS from its logic.
*/
#ifdef __SAMD21__
// --------------------------------------------------------------------------
// Includes
// --------------------------------------------------------------------------
#include "../../inc/MarlinConfig.h"
#include <SPI.h>
// --------------------------------------------------------------------------
// Public functions
// --------------------------------------------------------------------------
#if EITHER(SOFTWARE_SPI, FORCE_SOFT_SPI)
// ------------------------
// Software SPI
// ------------------------
#error "Software SPI not supported for SAMD21. Use Hardware SPI."
#else // !SOFTWARE_SPI
static SPISettings spiConfig;
// ------------------------
// Hardware SPI
// ------------------------
void spiBegin() {
spiInit(SPI_HALF_SPEED);
}
void spiInit(uint8_t spiRate) {
// Use datarates Marlin uses
uint32_t clock;
switch (spiRate) {
case SPI_FULL_SPEED: clock = 8000000; break;
case SPI_HALF_SPEED: clock = 4000000; break;
case SPI_QUARTER_SPEED: clock = 2000000; break;
case SPI_EIGHTH_SPEED: clock = 1000000; break;
case SPI_SIXTEENTH_SPEED: clock = 500000; break;
case SPI_SPEED_5: clock = 250000; break;
case SPI_SPEED_6: clock = 125000; break;
default: clock = 4000000; break; // Default from the SPI library
}
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
SPI.begin();
}
/**
* @brief Receives a single byte from the SPI port.
*
* @return Byte received
*
* @details
*/
uint8_t spiRec() {
SPI.beginTransaction(spiConfig);
uint8_t returnByte = SPI.transfer(0xFF);
SPI.endTransaction();
return returnByte;
}
/**
* @brief Receives a number of bytes from the SPI port to a buffer
*
* @param buf Pointer to starting address of buffer to write to.
* @param nbyte Number of bytes to receive.
* @return Nothing
*/
void spiRead(uint8_t *buf, uint16_t nbyte) {
if (nbyte == 0) return;
memset(buf, 0xFF, nbyte);
SPI.beginTransaction(spiConfig);
SPI.transfer(buf, nbyte);
SPI.endTransaction();
}
/**
* @brief Sends a single byte on SPI port
*
* @param b Byte to send
*
* @details
*/
void spiSend(uint8_t b) {
SPI.beginTransaction(spiConfig);
SPI.transfer(b);
SPI.endTransaction();
}
/**
* @brief Write token and then write from 512 byte buffer to SPI (for SD card)
*
* @param buf Pointer with buffer start address
* @return Nothing
*
* @details Uses DMA
*/
void spiSendBlock(uint8_t token, const uint8_t *buf) {
SPI.beginTransaction(spiConfig);
SPI.transfer(token);
SPI.transfer((uint8_t*)buf, 512);
SPI.endTransaction();
}
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
spiConfig = SPISettings(spiClock, (BitOrder)bitOrder, dataMode);
SPI.beginTransaction(spiConfig);
}
#endif // !SOFTWARE_SPI
#endif // __SAMD21__

View File

@@ -0,0 +1,31 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#pragma once
#include <SPI.h>
using MarlinSPI = SPIClass;

View File

@@ -0,0 +1,82 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(QSPI_EEPROM)
#include "QSPIFlash.h"
#define INVALID_ADDR 0xFFFFFFFF
#define SECTOR_OF(a) (a & ~(SFLASH_SECTOR_SIZE - 1))
#define OFFSET_OF(a) (a & (SFLASH_SECTOR_SIZE - 1))
Adafruit_SPIFlashBase * QSPIFlash::_flashBase = nullptr;
uint8_t QSPIFlash::_buf[SFLASH_SECTOR_SIZE];
uint32_t QSPIFlash::_addr = INVALID_ADDR;
void QSPIFlash::begin() {
if (_flashBase) return;
_flashBase = new Adafruit_SPIFlashBase(new Adafruit_FlashTransport_QSPI());
_flashBase->begin(nullptr);
}
size_t QSPIFlash::size() {
return _flashBase->size();
}
uint8_t QSPIFlash::readByte(const uint32_t address) {
if (SECTOR_OF(address) == _addr) return _buf[OFFSET_OF(address)];
return _flashBase->read8(address);
}
void QSPIFlash::writeByte(const uint32_t address, const uint8_t value) {
uint32_t const sector_addr = SECTOR_OF(address);
// Page changes, flush old and update new cache
if (sector_addr != _addr) {
flush();
_addr = sector_addr;
// read a whole page from flash
_flashBase->readBuffer(sector_addr, _buf, SFLASH_SECTOR_SIZE);
}
_buf[OFFSET_OF(address)] = value;
}
void QSPIFlash::flush() {
if (_addr == INVALID_ADDR) return;
_flashBase->eraseSector(_addr / SFLASH_SECTOR_SIZE);
_flashBase->writeBuffer(_addr, _buf, SFLASH_SECTOR_SIZE);
_addr = INVALID_ADDR;
}
#endif // QSPI_EEPROM

View File

@@ -0,0 +1,49 @@
/**
* @file QSPIFlash.h
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach and Dean Miller for Adafruit Industries LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Derived from Adafruit_SPIFlash class with no SdFat references
*/
#pragma once
#include <Adafruit_SPIFlashBase.h>
// This class extends Adafruit_SPIFlashBase by adding caching support.
//
// This class will use 4096 Bytes of RAM as a block cache.
class QSPIFlash {
public:
static void begin();
static size_t size();
static uint8_t readByte(const uint32_t address);
static void writeByte(const uint32_t address, const uint8_t v);
static void flush();
private:
static Adafruit_SPIFlashBase * _flashBase;
static uint8_t _buf[SFLASH_SECTOR_SIZE];
static uint32_t _addr;
};
extern QSPIFlash qspi;

View File

@@ -0,0 +1,66 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#define SYNC(sc) while (sc) { \
asm(""); \
}
// Get SAMD port/pin from specified arduino pin
#define GET_SAMD_PORT(P) _GET_SAMD_PORT(PIN_TO_SAMD_PIN(P))
#define GET_SAMD_PIN(P) _GET_SAMD_PIN(PIN_TO_SAMD_PIN(P))
// Get external interrupt line associated to specified arduino pin
#define PIN_TO_EILINE(P) _SAMDPORTPIN_TO_EILINE(GET_SAMD_PORT(P), GET_SAMD_PIN(P))
// Get adc/ain associated to specified arduino pin
#define PIN_TO_ADC(P) (ANAPIN_TO_ADCAIN(P) >> 8)
// Private defines
#define PIN_TO_SAMD_PIN(P) DIO##P##_PIN
#define _GET_SAMD_PORT(P) ((P) >> 5)
#define _GET_SAMD_PIN(P) ((P) & 0x1F)
// Get external interrupt line
#define _SAMDPORTPIN_TO_EILINE(P,B) ((P == 0 && WITHIN(B, 0, 31) && B != 26 && B != 28 && B != 29) ? (B) & 0xF \
: (P == 1 && (WITHIN(B, 0, 25) || WITHIN(B, 30, 31))) ? (B) & 0xF \
: (P == 1 && WITHIN(B, 26, 29)) ? 12 + (B) - 26 \
: (P == 2 && (WITHIN(B, 0, 6) || WITHIN(B, 10, 31)) && B != 29) ? (B) & 0xF \
: (P == 2 && B == 7) ? 9 \
: (P == 3 && WITHIN(B, 0, 1)) ? (B) \
: (P == 3 && WITHIN(B, 8, 12)) ? 3 + (B) - 8 \
: (P == 3 && WITHIN(B, 20, 21)) ? 10 + (B) - 20 \
: -1)
#define A2_AIN 3
#define A3_AIN 4
#define A4_AIN 5
#define PIN_TO_AIN(P) A##P##_AIN
#define AIN_TO_RESULT(P) ( (P - HAL_ADC_AIN_START == HAL_ADC_AIN_NUM_SENSORS-1) ? 0 : (P - HAL_ADC_AIN_START + 1) )

View File

@@ -0,0 +1,220 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
/**
* This comes from Arduino library which at the moment is buggy and uncompilable
*/
#ifdef __SAMD21__
#include "../../inc/MarlinConfig.h"
#if HAS_SERVOS
#include "../shared/servo.h"
#include "../shared/servo_private.h"
#include "SAMD21.h"
#define __TC_GCLK_ID(t) TC##t##_GCLK_ID
#define _TC_GCLK_ID(t) __TC_GCLK_ID(t)
#define TC_GCLK_ID _TC_GCLK_ID(SERVO_TC)
#define _TC_PRESCALER(d) TC_CTRLA_PRESCALER_DIV##d##_Val
#define TC_PRESCALER(d) _TC_PRESCALER(d)
#define __SERVO_IRQn(t) TC##t##_IRQn
#define _SERVO_IRQn(t) __SERVO_IRQn(t)
#define SERVO_IRQn _SERVO_IRQn(SERVO_TC)
#define HAL_SERVO_TIMER_ISR() TC_HANDLER(SERVO_TC)
#define TIMER_TCCHANNEL(t) ((t) & 1)
#define TC_COUNTER_START_VAL 0xFFFF
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() {
Tcc * const tc = timer_config[SERVO_TC].pTcc;
tc->CTRLBSET.reg = TCC_CTRLBCLR_CMD_READSYNC;
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
return tc->COUNT.bit.COUNT;
}
// ----------------------------
// Interrupt handler for the TC
// ----------------------------
HAL_SERVO_TIMER_ISR() {
Tcc * const tc = timer_config[SERVO_TC].pTcc;
const timer16_Sequence_t timer =
#ifndef _useTimer1
_timer2
#elif !defined(_useTimer2)
_timer1
#else
(tc->INTFLAG.reg & tc->INTENSET.reg & TC_INTFLAG_MC0) ? _timer1 : _timer2
#endif
;
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
int8_t cho = currentServoIndex[timer]; // Handle the prior servo first
if (cho < 0) { // Servo -1 indicates the refresh interval completed...
#if defined(_useTimer1) && defined(_useTimer2)
if (currentServoIndex[timer ^ 1] >= 0) {
// Wait for both channels
// Clear the interrupt
tc->INTFLAG.reg = (tcChannel == 0) ? TC_INTFLAG_MC0 : TC_INTFLAG_MC1;
return;
}
#endif
tc->COUNT.reg = TC_COUNTER_START_VAL; // ...so reset the timer
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
}
else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled?
digitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW
currentServoIndex[timer] = ++cho; // go to the next channel (or 0)
if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) {
if (SERVO(timer, cho).Pin.isActive) // activated?
digitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH
tc->CC[tcChannel].reg = getTimerCount() - (uint16_t)SERVO(timer, cho).ticks;
}
else {
// finished all channels so wait for the refresh period to expire before starting over
currentServoIndex[timer] = -1; // reset the timer COUNT.reg on the next call
const uint16_t cval = getTimerCount() - 256 / (SERVO_TIMER_PRESCALER), // allow 256 cycles to ensure the next CV not missed
ival = (TC_COUNTER_START_VAL) - (uint16_t)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed
tc->CC[tcChannel].reg = min(cval, ival);
}
if (tcChannel == 0) {
SYNC(tc->SYNCBUSY.bit.CC0);
tc->INTFLAG.reg = TC_INTFLAG_MC0; // Clear the interrupt
}
else {
SYNC(tc->SYNCBUSY.bit.CC1);
tc->INTFLAG.reg = TC_INTFLAG_MC1; // Clear the interrupt
}
}
void initISR(const timer16_Sequence_t timer) {
Tcc * const tc = timer_config[SERVO_TC].pTcc;
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
static bool initialized = false; // Servo TC has been initialized
if (!initialized) {
NVIC_DisableIRQ(SERVO_IRQn);
// Disable the timer
tc->CTRLA.bit.ENABLE = false;
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
// Select GCLK0 as timer/counter input clock source
GCLK->CLKCTRL.reg =(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(TCC0_GCLK_ID));
SYNC (GCLK->STATUS.bit.SYNCBUSY);
// Reset the timer
tc->CTRLA.bit.SWRST = true;
SYNC(tc->CTRLA.bit.SWRST);
// Set timer counter mode to 16 bits
tc->CTRLA.reg = TC_CTRLA_MODE_COUNT16;
// Set timer counter mode as normal PWM
tc->WAVE.bit.WAVEGEN = TCC_WAVE_WAVEGEN_NPWM_Val;
// Set the prescaler factor
tc->CTRLA.bit.PRESCALER = TC_PRESCALER(SERVO_TIMER_PRESCALER);
// Count down
tc->CTRLBSET.reg = TCC_CTRLBCLR_DIR;
SYNC(tc->SYNCBUSY.bit.CTRLB);
// Reset all servo indexes
memset((void *)currentServoIndex, 0xFF, sizeof(currentServoIndex));
// Configure interrupt request
NVIC_ClearPendingIRQ(SERVO_IRQn);
NVIC_SetPriority(SERVO_IRQn, 5);
NVIC_EnableIRQ(SERVO_IRQn);
initialized = true;
}
if (!tc->CTRLA.bit.ENABLE) {
// Reset the timer counter
tc->COUNT.reg = TC_COUNTER_START_VAL;
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
// Enable the timer and start it
tc->CTRLA.bit.ENABLE = true;
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
}
// First interrupt request after 1 ms
tc->CC[tcChannel].reg = getTimerCount() - (uint16_t)usToTicks(1000UL);
if (tcChannel == 0 ) {
SYNC(tc->SYNCBUSY.bit.CC0);
// Clear pending match interrupt
tc->INTFLAG.reg = TC_INTENSET_MC0;
// Enable the match channel interrupt request
tc->INTENSET.reg = TC_INTENSET_MC0;
}
else {
SYNC(tc->SYNCBUSY.bit.CC1);
// Clear pending match interrupt
tc->INTFLAG.reg = TC_INTENSET_MC1;
// Enable the match channel interrupt request
tc->INTENSET.reg = TC_INTENSET_MC1;
}
}
void finISR(const timer16_Sequence_t timer_index) {
Tcc * const tc = timer_config[SERVO_TC].pTcc;
const uint8_t tcChannel = TIMER_TCCHANNEL(timer_index);
// Disable the match channel interrupt request
tc->INTENCLR.reg = (tcChannel == 0) ? TC_INTENCLR_MC0 : TC_INTENCLR_MC1;
if (true
#if defined(_useTimer1) && defined(_useTimer2)
&& (tc->INTENCLR.reg & (TC_INTENCLR_MC0|TC_INTENCLR_MC1)) == 0
#endif
) {
// Disable the timer if not used
tc->CTRLA.bit.ENABLE = false;
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
}
}
#endif // HAS_SERVOS
#endif // __SAMD21__

View File

@@ -0,0 +1,45 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#define _useTimer1
#define _useTimer2
#define TRIM_DURATION 5 // compensation ticks to trim adjust for digitalWrite delays
#define SERVO_TIMER_PRESCALER 64 // timer prescaler factor to 64 (avoid overflowing 16-bit clock counter, at 120MHz this is 1831 ticks per millisecond
#define SERVO_TC 3
typedef enum {
#ifdef _useTimer1
_timer1,
#endif
#ifdef _useTimer2
_timer2,
#endif
_Nbr_16timers
} timer16_Sequence_t;

View File

@@ -0,0 +1,141 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD21__
#include "../../inc/MarlinConfig.h"
#if ENABLED(FLASH_EEPROM_EMULATION)
#define TOTAL_FLASH_SIZE (MARLIN_EEPROM_SIZE+255)/256*256
/* reserve flash memory */
static const uint8_t flashdata[TOTAL_FLASH_SIZE] __attribute__((__aligned__(256))) { }; \
#include "../shared/eeprom_api.h"
size_t PersistentStore::capacity() {
return MARLIN_EEPROM_SIZE;
/* const uint8_t psz = NVMCTRL->SEESTAT.bit.PSZ,
sblk = NVMCTRL->SEESTAT.bit.SBLK;
return (!psz && !sblk) ? 0
: (psz <= 2) ? (0x200 << psz)
: (sblk == 1 || psz == 3) ? 4096
: (sblk == 2 || psz == 4) ? 8192
: (sblk <= 4 || psz == 5) ? 16384
: (sblk >= 9 && psz == 7) ? 65536
: 32768;*/
}
uint32_t PAGE_SIZE;
uint32_t ROW_SIZE;
bool hasWritten = false;
uint8_t * buffer;
void _erase(const volatile void *flash_ptr) {
NVMCTRL->ADDR.reg = ((uint32_t)flash_ptr) / 2;
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_ER;
while (!NVMCTRL->INTFLAG.bit.READY) { }
}
void erase(const volatile void *flash_ptr, uint32_t size) {
const uint8_t *ptr = (const uint8_t *)flash_ptr;
while (size > ROW_SIZE) {
_erase(ptr);
ptr += ROW_SIZE;
size -= ROW_SIZE;
}
_erase(ptr);
}
bool PersistentStore::access_start() {
/* clear page buffer*/
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC;
while (NVMCTRL->INTFLAG.bit.READY == 0) { }
PAGE_SIZE = pow(2,3 + NVMCTRL->PARAM.bit.PSZ);
ROW_SIZE= PAGE_SIZE * 4;
/*NVMCTRL->SEECFG.reg = NVMCTRL_SEECFG_WMODE_BUFFERED; // Buffered mode and segment reallocation active
if (NVMCTRL->SEESTAT.bit.RLOCK)
NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_USEE); */ // Unlock E2P data write access
// erase(&flashdata[0], TOTAL_FLASH_SIZE);
return true;
}
bool PersistentStore::access_finish() {
if (hasWritten) {
erase(&flashdata[0], TOTAL_FLASH_SIZE);
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC;
while (NVMCTRL->INTFLAG.bit.READY == 0) { }
NVMCTRL->CTRLB.bit.MANW = 0;
volatile uint32_t *dst_addr = (volatile uint32_t *) &flashdata;
uint32_t *pointer = (uint32_t *) buffer;
for (uint32_t i = 0; i < TOTAL_FLASH_SIZE; i+=4) {
*dst_addr = (uint32_t) *pointer;
pointer++;
dst_addr ++;
}
// Execute "WP" Write Page
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_WP;
while (NVMCTRL->INTFLAG.bit.READY == 0) { }
free(buffer);
hasWritten = false;
}
return true;
}
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
if (!hasWritten) {
// init temp buffer
buffer = (uint8_t *) malloc(MARLIN_EEPROM_SIZE);
hasWritten=true;
}
memcpy(buffer+pos,value,size);
pos += size;
return false;
}
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
volatile uint8_t *dst_addr = (volatile uint8_t *) &flashdata;
dst_addr += pos;
memcpy(value,(const void *) dst_addr,size);
pos += size;
return false;
}
#endif // FLASH_EEPROM_EMULATION
#endif // __SAMD21__

View File

@@ -0,0 +1,79 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD21__
#include "../../inc/MarlinConfig.h"
#if ENABLED(QSPI_EEPROM)
#error "QSPI_EEPROM emulation Not implemented on SAMD21"
#include "../shared/eeprom_api.h"
#include "QSPIFlash.h"
static bool initialized;
size_t PersistentStore::capacity() { return qspi.size(); }
bool PersistentStore::access_start() {
if (!initialized) {
qspi.begin();
initialized = true;
}
return true;
}
bool PersistentStore::access_finish() {
qspi.flush();
return true;
}
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
while (size--) {
const uint8_t v = *value;
qspi.writeByte(pos, v);
crc16(crc, &v, 1);
pos++;
value++;
}
return false;
}
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
while (size--) {
uint8_t c = qspi.readByte(pos);
if (writing) *value = c;
crc16(crc, &c, 1);
pos++;
value++;
}
return false;
}
#endif // QSPI_EEPROM
#endif // __SAMD21__

View File

@@ -0,0 +1,82 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD21__
#include "../../inc/MarlinConfig.h"
#if USE_WIRED_EEPROM
#error "USE_WIRED_EEPROM emulation Not implemented on SAMD21"
/**
* PersistentStore for Arduino-style EEPROM interface
* with simple implementations supplied by Marlin.
*/
#include "../shared/eeprom_if.h"
#include "../shared/eeprom_api.h"
#ifndef MARLIN_EEPROM_SIZE
#error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM."
#endif
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
bool PersistentStore::access_start() { eeprom_init(); return true; }
bool PersistentStore::access_finish() { return true; }
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
uint16_t written = 0;
while (size--) {
const uint8_t v = *value;
uint8_t * const p = (uint8_t * const)pos;
if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed!
eeprom_write_byte(p, v);
if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
if (eeprom_read_byte(p) != v) {
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
return true;
}
}
crc16(crc, &v, 1);
pos++;
value++;
}
return false;
}
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
while (size--) {
uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c;
crc16(crc, &c, 1);
pos++;
value++;
}
return false;
}
#endif // USE_WIRED_EEPROM
#endif // __SAMD21__

View File

@@ -0,0 +1,253 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
/**
* Endstop interrupts for ATMEL SAMD21 based targets.
*
* On SAMD21, all pins support external interrupt capability.
* Any pin can be used for external interrupts, but there are some restrictions.
* At most 16 different external interrupts can be used at one time.
* Further, you cant just pick any 16 pins to use. This is because every pin on the SAMD21
* connects to what is called an EXTINT line, and only one pin per EXTINT line can be used for external
* interrupts at a time
*/
/**
* Endstop Interrupts
*
* Without endstop interrupts the endstop pins must be polled continually in
* the temperature-ISR via endstops.update(), most of the time finding no change.
* With this feature endstops.update() is called only when we know that at
* least one endstop has changed state, saving valuable CPU cycles.
*
* This feature only works when all used endstop pins can generate an 'external interrupt'.
*
* Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
* (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
*/
#include "../../module/endstops.h"
#define MATCH_EILINE(P1,P2) (P1 != P2 && PIN_TO_EILINE(P1) == PIN_TO_EILINE(P2))
#define MATCH_X_MAX_EILINE(P) TERN0(HAS_X_MAX, DEFER4(MATCH_EILINE)(P, X_MAX_PIN))
#define MATCH_X_MIN_EILINE(P) TERN0(HAS_X_MIN, DEFER4(MATCH_EILINE)(P, X_MIN_PIN))
#define MATCH_Y_MAX_EILINE(P) TERN0(HAS_Y_MAX, DEFER4(MATCH_EILINE)(P, Y_MAX_PIN))
#define MATCH_Y_MIN_EILINE(P) TERN0(HAS_Y_MIN, DEFER4(MATCH_EILINE)(P, Y_MIN_PIN))
#define MATCH_Z_MAX_EILINE(P) TERN0(HAS_Z_MAX, DEFER4(MATCH_EILINE)(P, Z_MAX_PIN))
#define MATCH_Z_MIN_EILINE(P) TERN0(HAS_Z_MIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PIN))
#define MATCH_I_MAX_EILINE(P) TERN0(HAS_I_MAX, DEFER4(MATCH_EILINE)(P, I_MAX_PIN))
#define MATCH_I_MIN_EILINE(P) TERN0(HAS_I_MIN, DEFER4(MATCH_EILINE)(P, I_MIN_PIN))
#define MATCH_J_MAX_EILINE(P) TERN0(HAS_J_MAX, DEFER4(MATCH_EILINE)(P, J_MAX_PIN))
#define MATCH_J_MIN_EILINE(P) TERN0(HAS_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN))
#define MATCH_K_MAX_EILINE(P) TERN0(HAS_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN))
#define MATCH_K_MIN_EILINE(P) TERN0(HAS_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN))
#define MATCH_U_MAX_EILINE(P) TERN0(HAS_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN))
#define MATCH_U_MIN_EILINE(P) TERN0(HAS_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN))
#define MATCH_V_MAX_EILINE(P) TERN0(HAS_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN))
#define MATCH_V_MIN_EILINE(P) TERN0(HAS_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN))
#define MATCH_W_MAX_EILINE(P) TERN0(HAS_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN))
#define MATCH_W_MIN_EILINE(P) TERN0(HAS_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN))
#define MATCH_Z2_MAX_EILINE(P) TERN0(HAS_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN))
#define MATCH_Z2_MIN_EILINE(P) TERN0(HAS_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN))
#define MATCH_Z3_MAX_EILINE(P) TERN0(HAS_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN))
#define MATCH_Z3_MIN_EILINE(P) TERN0(HAS_Z3_MIN, DEFER4(MATCH_EILINE)(P, Z3_MIN_PIN))
#define MATCH_Z4_MAX_EILINE(P) TERN0(HAS_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN))
#define MATCH_Z4_MIN_EILINE(P) TERN0(HAS_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN))
#define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(HAS_Z_MIN_PROBE_PIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN))
#define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \
&& !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \
&& !MATCH_Y_MAX_EILINE(P) && !MATCH_Y_MIN_EILINE(P) \
&& !MATCH_Z_MAX_EILINE(P) && !MATCH_Z_MIN_EILINE(P) \
&& !MATCH_I_MAX_EILINE(P) && !MATCH_I_MIN_EILINE(P) \
&& !MATCH_J_MAX_EILINE(P) && !MATCH_J_MIN_EILINE(P) \
&& !MATCH_K_MAX_EILINE(P) && !MATCH_K_MIN_EILINE(P) \
&& !MATCH_U_MAX_EILINE(P) && !MATCH_U_MIN_EILINE(P) \
&& !MATCH_V_MAX_EILINE(P) && !MATCH_V_MIN_EILINE(P) \
&& !MATCH_W_MAX_EILINE(P) && !MATCH_W_MIN_EILINE(P) \
&& !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \
&& !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
&& !MATCH_Z_MIN_PROBE_EILINE(P) )
// One ISR for all EXT-Interrupts
void endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() {
#define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
#if HAS_X_MAX
#if !AVAILABLE_EILINE(X_MAX_PIN)
#error "X_MAX_PIN has no EXTINT line available."
#endif
_ATTACH(X_MAX_PIN);
#endif
#if HAS_X_MIN
#if !AVAILABLE_EILINE(X_MIN_PIN)
#error "X_MIN_PIN has no EXTINT line available."
#endif
_ATTACH(X_MIN_PIN);
#endif
#if HAS_Y_MAX
#if !AVAILABLE_EILINE(Y_MAX_PIN)
#error "Y_MAX_PIN has no EXTINT line available."
#endif
_ATTACH(Y_MAX_PIN);
#endif
#if HAS_Y_MIN
#if !AVAILABLE_EILINE(Y_MIN_PIN)
#error "Y_MIN_PIN has no EXTINT line available."
#endif
_ATTACH(Y_MIN_PIN);
#endif
#if HAS_Z_MAX
#if !AVAILABLE_EILINE(Z_MAX_PIN)
#error "Z_MAX_PIN has no EXTINT line available."
#endif
_ATTACH(Z_MAX_PIN);
#endif
#if HAS_Z_MIN
#if !AVAILABLE_EILINE(Z_MIN_PIN)
#error "Z_MIN_PIN has no EXTINT line available."
#endif
_ATTACH(Z_MIN_PIN);
#endif
#if HAS_Z2_MAX
#if !AVAILABLE_EILINE(Z2_MAX_PIN)
#error "Z2_MAX_PIN has no EXTINT line available."
#endif
_ATTACH(Z2_MAX_PIN);
#endif
#if HAS_Z2_MIN
#if !AVAILABLE_EILINE(Z2_MIN_PIN)
#error "Z2_MIN_PIN has no EXTINT line available."
#endif
_ATTACH(Z2_MIN_PIN);
#endif
#if HAS_Z3_MAX
#if !AVAILABLE_EILINE(Z3_MAX_PIN)
#error "Z3_MAX_PIN has no EXTINT line available."
#endif
_ATTACH(Z3_MAX_PIN);
#endif
#if HAS_Z3_MIN
#if !AVAILABLE_EILINE(Z3_MIN_PIN)
#error "Z3_MIN_PIN has no EXTINT line available."
#endif
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
#if !AVAILABLE_EILINE(Z4_MAX_PIN)
#error "Z4_MAX_PIN has no EXTINT line available."
#endif
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
#if !AVAILABLE_EILINE(Z4_MIN_PIN)
#error "Z4_MIN_PIN has no EXTINT line available."
#endif
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
#if !AVAILABLE_EILINE(Z_MIN_PROBE_PIN)
#error "Z_MIN_PROBE_PIN has no EXTINT line available."
#endif
_ATTACH(Z_MIN_PROBE_PIN);
#endif
#if HAS_I_MAX
#if !AVAILABLE_EILINE(I_MAX_PIN)
#error "I_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(I_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_I_MIN
#if !AVAILABLE_EILINE(I_MIN_PIN)
#error "I_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(I_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_J_MAX
#if !AVAILABLE_EILINE(J_MAX_PIN)
#error "J_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(J_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_J_MIN
#if !AVAILABLE_EILINE(J_MIN_PIN)
#error "J_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(J_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_K_MAX
#if !AVAILABLE_EILINE(K_MAX_PIN)
#error "K_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(K_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_K_MIN
#if !AVAILABLE_EILINE(K_MIN_PIN)
#error "K_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(K_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_U_MAX
#if !AVAILABLE_EILINE(U_MAX_PIN)
#error "U_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(U_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_U_MIN
#if !AVAILABLE_EILINE(U_MIN_PIN)
#error "U_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(U_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_V_MAX
#if !AVAILABLE_EILINE(V_MAX_PIN)
#error "V_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(V_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_V_MIN
#if !AVAILABLE_EILINE(V_MIN_PIN)
#error "V_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(V_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_W_MAX
#if !AVAILABLE_EILINE(W_MAX_PIN)
#error "W_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(W_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_W_MIN
#if !AVAILABLE_EILINE(W_MIN_PIN)
#error "W_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(W_MIN_PIN, endstop_ISR, CHANGE);
#endif
}

View File

@@ -0,0 +1,216 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
/**
* Fast IO functions for SAMD21
*/
#include "SAMD21.h"
/**
* Utility functions
*/
#ifndef MASK
#define MASK(PIN) _BV(PIN)
#endif
/**
* Magic I/O routines
*
* Now you can simply SET_OUTPUT(IO); WRITE(IO, HIGH); WRITE(IO, LOW);
*/
// Read a pin
#define READ(IO) ((PORT->Group[(EPortType)GET_SAMD_PORT(IO)].IN.reg & MASK(GET_SAMD_PIN(IO))) != 0)
// Write to a pin
#define WRITE(IO,V) do{ \
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
const uint32_t mask = MASK(GET_SAMD_PIN(IO)); \
\
if (V) PORT->Group[port].OUTSET.reg = mask; \
else PORT->Group[port].OUTCLR.reg = mask; \
}while(0)
// Toggle a pin
#define TOGGLE(IO) PORT->Group[(EPortType)GET_SAMD_PORT(IO)].OUTTGL.reg = MASK(GET_SAMD_PIN(IO));
// Set pin as input
#define SET_INPUT(IO) do{ \
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
const uint32_t pin = GET_SAMD_PIN(IO); \
\
PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN); \
PORT->Group[port].DIRCLR.reg = MASK(pin); \
}while(0)
// Set pin as input with pullup
#define SET_INPUT_PULLUP(IO) do{ \
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
const uint32_t pin = GET_SAMD_PIN(IO); \
const uint32_t mask = MASK(pin); \
\
PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); \
PORT->Group[port].DIRCLR.reg = mask; \
PORT->Group[port].OUTSET.reg = mask; \
}while(0)
// Set pin as input with pulldown
#define SET_INPUT_PULLDOWN(IO) do{ \
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
const uint32_t pin = GET_SAMD_PIN(IO); \
const uint32_t mask = MASK(pin); \
\
PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); \
PORT->Group[port].DIRCLR.reg = mask; \
PORT->Group[port].OUTCLR.reg = mask; \
}while(0)
// Set pin as output (push pull)
#define SET_OUTPUT(IO) do{ \
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
const uint32_t pin = GET_SAMD_PIN(IO); \
\
PORT->Group[port].DIRSET.reg = MASK(pin); \
PORT->Group[port].PINCFG[pin].reg = 0; \
}while(0)
// Set pin as output (open drain)
#define SET_OUTPUT_OD(IO) do{ \
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
const uint32_t pin = GET_SAMD_PIN(IO); \
\
PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_PULLEN); \
PORT->Group[port].DIRCLR.reg = MASK(pin); \
}while(0)
// Set pin as PWM (push pull)
#define SET_PWM SET_OUTPUT
// Set pin as PWM (open drain)
#define SET_PWM_OD SET_OUTPUT_OD
// check if pin is an output
#define IS_OUTPUT(IO) ((PORT->Group[(EPortType)GET_SAMD_PORT(IO)].DIR.reg & MASK(GET_SAMD_PIN(IO))) \
|| (PORT->Group[(EPortType)GET_SAMD_PORT(IO)].PINCFG[GET_SAMD_PIN(IO)].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN)
// check if pin is an input
#define IS_INPUT(IO) !IS_OUTPUT(IO)
// Shorthand
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
#define OUT_WRITE_OD(IO,V) do{ SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0)
// digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO)
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
/**
* Ports and functions
* Added as necessary or if I feel like it- not a comprehensive list!
*/
/*
* Some of these share the same source and so can't be used in the same time
*/
#define PWM_PIN(P) (WITHIN(P, 2, 13) || WITHIN(P, 22, 23) || WITHIN(P, 44, 45) || P == 48)
// Return fulfilled ADCx->INPUTCTRL.reg
#define PIN_TO_INPUTCTRL(P) ( (P == 0) ? ADC_INPUTCTRL_MUXPOS_PIN0 \
: ((P) == 1) ? ADC_INPUTCTRL_MUXPOS_PIN1 \
: ((P) == 2) ? ADC_INPUTCTRL_MUXPOS_PIN3 \
: ((P) == 3) ? ADC_INPUTCTRL_MUXPOS_PIN4 \
: ((P) == 4) ? ADC_INPUTCTRL_MUXPOS_PIN5 \
: ((P) == 5) ? ADC_INPUTCTRL_MUXPOS_PIN5 \
: ((P) == 6) ? ADC_INPUTCTRL_MUXPOS_PIN6 \
: ((P) == 7) ? ADC_INPUTCTRL_MUXPOS_PIN7 \
: ((P) == 8) ? ADC_INPUTCTRL_MUXPOS_PIN8 \
: ((P) == 9) ? ADC_INPUTCTRL_MUXPOS_PIN9 \
: ((P) == 10) ? ADC_INPUTCTRL_MUXPOS_PIN10 \
: ((P) == 11) ? ADC_INPUTCTRL_MUXPOS_PIN11 \
: ((P) == 12) ? ADC_INPUTCTRL_MUXPOS_PIN12 \
: ((P) == 13) ? ADC_INPUTCTRL_MUXPOS_PIN13 \
: ((P) == 14) ? ADC_INPUTCTRL_MUXPOS_PIN14 \
: ADC_INPUTCTRL_MUXPOS_PIN15)
#define digitalPinToAnalogInput(P) (WITHIN(P, 67, 74) ? (P) - 67 : WITHIN(P, 54, 61) ? 8 + (P) - 54 : WITHIN(P, 12, 13) ? 16 + (P) - 12 : P == 9 ? 18 : -1)
/**
* pins
*/
// PORTA
#define DIO28_PIN PIN_PA02 // A0
#define DIO56_PIN PIN_PA03 // A13
#define DIO31_PIN PIN_PA04 // A13
#define DIO32_PIN PIN_PA05 // A1
#define DIO8_PIN PIN_PA06 // A14
#define DIO9_PIN PIN_PA07 // A15
#define DIO4_PIN PIN_PA08 // A15
#define DIO3_PIN PIN_PA09 // A15
#define DIO1_PIN PIN_PA10
#define DIO0_PIN PIN_PA11
#define DIO18_PIN PIN_PA12
#define DIO52_PIN PIN_PA13
#define DIO2_PIN PIN_PA14
#define DIO5_PIN PIN_PA15
#define DIO11_PIN PIN_PA16
#define DIO13_PIN PIN_PA17
#define DIO10_PIN PIN_PA18
#define DIO12_PIN PIN_PA19
#define DIO6_PIN PIN_PA20
#define DIO07_PIN PIN_PA21
#define DIO34_PIN PIN_PA22
#define DIO35_PIN PIN_PA23
#define DIO42_PIN PIN_PA24
#define DIO43_PIN PIN_PA25
#define DIO40_PIN PIN_PA27
#define DIO26_PIN PIN_PB00
#define DIO27_PIN PIN_PB01 // A0
#define DIO33_PIN PIN_PB02
#define DIO39_PIN PIN_PB03
#define DIO14_PIN PIN_PB04
#define DIO15_PIN PIN_PB05
#define DIO16_PIN PIN_PB06
#define DIO17_PIN PIN_PB07
#define DIO29_PIN PIN_PB08
#define DIO30_PIN PIN_PB09
#define DIO37_PIN PIN_PB10
#define DIO38_PIN PIN_PB11
#define DIO36_PIN PIN_PB12
#define DIO19_PIN PIN_PB13
#define DIO20_PIN PIN_PB14
#define DIO21_PIN PIN_PB15
#define DIO22_PIN PIN_PB16
#define DIO23_PIN PIN_PB17
#define DIO44_PIN PIN_PB22
#define DIO45_PIN PIN_PB23
#define DIO24_PIN PIN_PB30
#define DIO25_PIN PIN_PB31
#define DIO53_PIN PIN_PA21
#define DIO54_PIN PIN_PA06
#define DIO55_PIN PIN_PA07

View File

@@ -0,0 +1,31 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#pragma once
#if HAS_SPI_TFT || HAS_FSMC_TFT
#error "Sorry! TFT displays are not available for HAL/SAMD21."
#endif

View File

@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#pragma once

View File

@@ -0,0 +1,33 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#pragma once
#if USE_FALLBACK_EEPROM
#define FLASH_EEPROM_EMULATION
#elif EITHER(I2C_EEPROM, SPI_EEPROM)
#define USE_SHARED_EEPROM 1
#endif

View File

@@ -0,0 +1,50 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
/**
* Test SAMD21 specific configuration values for errors at compile-time.
*/
#if SERVO_TC == MF_TIMER_RTC
#error "Servos can't use RTC timer"
#endif
#if ENABLED(EMERGENCY_PARSER)
#error "EMERGENCY_PARSER is not yet implemented for SAMD21. Disable EMERGENCY_PARSER to continue."
#endif
#if ENABLED(SDIO_SUPPORT)
#error "SDIO_SUPPORT is not supported on SAMD21."
#endif
#if ENABLED(FAST_PWM_FAN)
#error "Features requiring Hardware PWM (FAST_PWM_FAN) are not yet supported on SAMD21."
#endif
#if ENABLED(POSTMORTEM_DEBUGGING)
#error "POSTMORTEM_DEBUGGING is not yet supported on SAMD21."
#endif

View File

@@ -0,0 +1,160 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#define NUMBER_PINS_TOTAL PINS_COUNT
#define digitalRead_mod(p) extDigitalRead(p)
#define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); SERIAL_ECHO(buffer); }while (0)
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
#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)
#define GET_ARRAY_PIN(p) pin_array[p].pin
#define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL)
#define DIGITAL_PIN_TO_ANALOG_PIN(p) digitalPinToAnalogInput(p)
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P)!=-1)
#define pwm_status(pin) digitalPinHasPWM(pin)
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
// uses pin index
#define M43_NEVER_TOUCH(Q) ((Q) >= 75)
bool GET_PINMODE(int8_t pin) { // 1: output, 0: input
const EPortType samdport = g_APinDescription[pin].ulPort;
const uint32_t samdpin = g_APinDescription[pin].ulPin;
return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN;
}
void pwm_details(int32_t pin) {
if (pwm_status(pin)) {
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
//SERIAL_ECHOPGM("PWM = ", duty);
}
}
/**
* SAMD21 Board pin| PORT | Label
* ----------------+--------+-------
* 0 | PB25 | "RX0"
* 1 | PB24 | "TX0"
* 2 | PC18 |
* 3 | PC19 |
* 4 | PC20 |
* 5 | PC21 |
* 6 | PD20 |
* 7 | PD21 |
* 8 | PB18 |
* 9 | PB2 |
* 10 | PB22 |
* 11 | PB23 |
* 12 | PB0 | "A16"
* 13 | PB1 | LED AMBER "L" / "A17"
* 14 | PB16 | "TX3"
* 15 | PB17 | "RX3"
* 16 | PC22 | "TX2"
* 17 | PC23 | "RX2"
* 18 | PB12 | "TX1" / "A18"
* 19 | PB13 | "RX1"
* 20 | PB20 | "SDA"
* 21 | PB21 | "SCL"
* 22 | PD12 |
* 23 | PA15 |
* 24 | PC17 |
* 25 | PC16 |
* 26 | PA12 |
* 27 | PA13 |
* 28 | PA14 |
* 29 | PB19 |
* 30 | PA23 |
* 31 | PA22 |
* 32 | PA21 |
* 33 | PA20 |
* 34 | PA19 |
* 35 | PA18 |
* 36 | PA17 |
* 37 | PA16 |
* 38 | PB15 |
* 39 | PB14 |
* 40 | PC13 |
* 41 | PC12 |
* 42 | PC15 |
* 43 | PC14 |
* 44 | PC11 |
* 45 | PC10 |
* 46 | PC6 |
* 47 | PC7 |
* 48 | PC4 |
* 49 | PC5 |
* 50 | PD11 |
* 51 | PD8 |
* 52 | PD9 |
* 53 | PD10 |
* 54 | PB5 | "A8"
* 55 | PB6 | "A9"
* 56 | PB7 | "A10"
* 57 | PB8 | "A11"
* 58 | PB9 | "A12"
* 69 | PA4 | "A13"
* 60 | PA6 | "A14"
* 61 | PA7 | "A15"
* 62 | PB17 |
* 63 | PB20 |
* 64 | PD11 |
* 65 | PD8 |
* 66 | PD9 |
* 67 | PA2 | "A0" / "DAC0"
* 68 | PA5 | "A1" / "DAC1"
* 69 | PB3 | "A2"
* 70 | PC0 | "A3"
* 71 | PC1 | "A4"
* 72 | PC2 | "A5"
* 73 | PC3 | "A6"
* 74 | PB4 | "A7"
* 75 | PC31 | LED GREEN "RX"
* 76 | PC30 | LED GREEN "TX"
* 77 | PA27 | USB: Host enable
* 78 | PA24 | USB: D-
* 79 | PA25 | USB: D+
* 80 | PB29 | SD: MISO
* 81 | PB27 | SD: SCK
* 82 | PB26 | SD: MOSI
* 83 | PB28 | SD: CS
* 84 | PA3 | AREF
* 85 | PA2 | DAC0 (Duplicate)
* 86 | PA5 | DAC1 (Duplicate)
* 87 | PB1 | LED AMBER "L" (Duplicate)
* 88 | PC24 | NeoPixel
* 89 | PB10 | QSPI: SCK
* 90 | PB11 | QSPI: CS
* 91 | PA8 | QSPI: IO0
* 92 | PA9 | QSPI: IO1
* 93 | PA10 | QSPI: IO2
* 94 | PA11 | QSPI: IO3
* 95 | PB31 | SD: DETECT
*/

View File

@@ -0,0 +1,54 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
/**
* SAMD21 Default SPI Pins
*
* SS SCK MISO MOSI
* +-------------------------+
* SPI | 53 52 50 51 |
* SPI1 | 83 81 80 82 |
* +-------------------------+
* Any pin can be used for Chip Select (SD_SS_PIN)
*/
#ifndef SD_SCK_PIN
#define SD_SCK_PIN 38
#endif
#ifndef SD_MISO_PIN
#define SD_MISO_PIN 36
#endif
#ifndef SD_MOSI_PIN
#define SD_MOSI_PIN 37
#endif
#ifndef SDSS
#define SDSS 18
#endif
#ifndef SD_SS_PIN
#define SD_SS_PIN SDSS
#endif

View File

@@ -0,0 +1,217 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD21__
// --------------------------------------------------------------------------
// Includes
// --------------------------------------------------------------------------
#include "../../inc/MarlinConfig.h"
#include "ServoTimers.h" // for SERVO_TC
// --------------------------------------------------------------------------
// Local defines
// --------------------------------------------------------------------------
#define NUM_HARDWARE_TIMERS 9
// --------------------------------------------------------------------------
// Private Variables
// --------------------------------------------------------------------------
const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = {
{ {.pTcc=TCC0}, TimerType::tcc, TCC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2)
{ {.pTcc=TCC1}, TimerType::tcc, TCC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers)
{ {.pTcc=TCC2}, TimerType::tcc, TCC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5)
{ {.pTc=TC3}, TimerType::tc, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (assigned priority 1)
{ {.pTc=TC4}, TimerType::tc, TC4_IRQn, TC_PRIORITY(4) }, // 4 - software serial (no interrupts used)
{ {.pTc=TC5}, TimerType::tc, TC5_IRQn, TC_PRIORITY(5) },
{ {.pTc=TC6}, TimerType::tc, TC6_IRQn, TC_PRIORITY(6) },
{ {.pTc=TC7}, TimerType::tc, TC7_IRQn, TC_PRIORITY(7) },
{ {.pRtc=RTC}, TimerType::rtc, RTC_IRQn, TC_PRIORITY(8) } // 8 - temperature (assigned priority 6)
};
// --------------------------------------------------------------------------
// Private functions
// --------------------------------------------------------------------------
FORCE_INLINE void Disable_Irq(IRQn_Type irq) {
NVIC_DisableIRQ(irq);
// We NEED memory barriers to ensure Interrupts are actually disabled!
// ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
__DSB();
__ISB();
}
static bool tcIsSyncing(Tc * tc) {
return tc->COUNT32.STATUS.reg & TC_STATUS_SYNCBUSY;
}
static void tcReset( Tc * tc) {
tc->COUNT32.CTRLA.reg = TC_CTRLA_SWRST;
while (tcIsSyncing(tc)) {}
while (tc->COUNT32.CTRLA.bit.SWRST) {}
}
// --------------------------------------------------------------------------
// Public functions
// --------------------------------------------------------------------------
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
// Disable interrupt, just in case it was already enabled
NVIC_DisableIRQ(irq);
NVIC_ClearPendingIRQ(irq);
if (timer_num == MF_TIMER_RTC) {
// https://github.com/arduino-libraries/RTCZero
Rtc * const rtc = timer_config[timer_num].pRtc;
PM->APBAMASK.reg |= PM_APBAMASK_RTC;
GCLK->CLKCTRL.reg = (uint32_t)((GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK4 | (RTC_GCLK_ID << GCLK_CLKCTRL_ID_Pos)));
while (GCLK->STATUS.bit.SYNCBUSY) {}
GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSCULP32K | GCLK_GENCTRL_ID(4) | GCLK_GENCTRL_DIVSEL );
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) {}
GCLK->GENDIV.reg = GCLK_GENDIV_ID(4);
GCLK->GENDIV.bit.DIV=4;
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) {}
// Disable timer interrupt
rtc->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY);
while(rtc->MODE0.STATUS.bit.SYNCBUSY) {}
// Stop timer, just in case, to be able to reconfigure it
rtc->MODE0.CTRL.reg =
RTC_MODE0_CTRL_MODE_COUNT32 | // Mode 0 = 32-bits counter
RTC_MODE0_CTRL_PRESCALER_DIV1024; // Divisor = 1024
while(rtc->MODE0.STATUS.bit.SYNCBUSY) {}
// Mode, reset counter on match
rtc->MODE0.CTRL.reg = RTC_MODE0_CTRL_MODE_COUNT32 | RTC_MODE0_CTRL_MATCHCLR;
// Set compare value
rtc->MODE0.COMP[0].reg = (32768 + frequency / 2) / frequency;
SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY);
// Enable interrupt on compare
rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0; // reset pending interrupt
rtc->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0; // enable compare 0 interrupt
// And start timer
rtc->MODE0.CTRL.bit.ENABLE = true;
SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY);
}
else if (timer_config[timer_num].type==TimerType::tcc) {
Tcc * const tc = timer_config[timer_num].pTcc;
PM->APBCMASK.reg |= PM_APBCMASK_TCC0;
GCLK->CLKCTRL.reg =(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(TCC0_GCLK_ID));
SYNC (GCLK->STATUS.bit.SYNCBUSY);
tc->CTRLA.reg = TCC_CTRLA_SWRST;
SYNC (tc->SYNCBUSY.reg & TCC_SYNCBUSY_SWRST) {}
SYNC (tc->CTRLA.bit.SWRST);
tc->CTRLA.reg &= ~(TCC_CTRLA_ENABLE); // disable TC module
tc->CTRLA.reg |= TCC_WAVE_WAVEGEN_MFRQ;
tc->CTRLA.reg |= TCC_CTRLA_PRESCALER_DIV2;
tc->CC[0].reg = (HAL_TIMER_RATE) / frequency;
tc->INTENSET.reg = TCC_INTFLAG_MC0;
tc->CTRLA.reg |= TCC_CTRLA_ENABLE;
tc->INTFLAG.reg = 0xFF;
SYNC ( tc->STATUS.reg & TC_STATUS_SYNCBUSY);
}
else {
Tc * const tc = timer_config[timer_num].pTc;
// Disable timer interrupt
tc->COUNT32.INTENCLR.reg = TC_INTENCLR_OVF; // disable overflow interrupt
// TCn clock setup
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TC4_TC5)) ;
SYNC (GCLK->STATUS.bit.SYNCBUSY);
tcReset(tc); // reset TC
// Set Timer counter 5 Mode to 16 bits, it will become a 16bit counter ('mode1' in the datasheet)
tc->COUNT32.CTRLA.reg |= TC_CTRLA_MODE_COUNT32;
// Set TC waveform generation mode to 'match frequency'
tc->COUNT32.CTRLA.reg |= TC_CTRLA_WAVEGEN_MFRQ;
//set prescaler
//the clock normally counts at the GCLK_TC frequency, but we can set it to divide that frequency to slow it down
//you can use different prescaler divisons here like TC_CTRLA_PRESCALER_DIV1 to get a different range
tc->COUNT32.CTRLA.reg |= TC_CTRLA_PRESCALER_DIV1 | TC_CTRLA_ENABLE; //it will divide GCLK_TC frequency by 1024
//set the compare-capture register.
//The counter will count up to this value (it's a 16bit counter so we use uint16_t)
//this is how we fine-tune the frequency, make it count to a lower or higher value
//system clock should be 1MHz (8MHz/8) at Reset by default
tc->COUNT32.CC[0].reg = (uint16_t) (HAL_TIMER_RATE / frequency);
while (tcIsSyncing(tc)) {}
// Enable the TC interrupt request
tc->COUNT32.INTENSET.bit.MC0 = 1;
while (tcIsSyncing(tc)) {}
}
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 = timer_config[timer_num].IRQ_Id;
NVIC_EnableIRQ(irq);
}
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
Disable_Irq(irq);
}
// missing from CMSIS: Check if interrupt is enabled or not
static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
}
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
return NVIC_GetEnabledIRQ(irq);
}
#endif // __SAMD21__

View File

@@ -0,0 +1,160 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#include <stdint.h>
// --------------------------------------------------------------------------
// Defines
// --------------------------------------------------------------------------
typedef uint32_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
#define HAL_TIMER_RATE F_CPU // frequency of timers peripherals
#define MF_TIMER_RTC 8 // This is not a TC but a RTC
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 4 // Timer Index for Stepper
#endif
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP MF_TIMER_RTC // Timer Index for Temperature
#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 PULSE_TIMER_RATE STEPPER_TIMER_RATE
#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(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(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#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(MF_TIMER_STEP)
#endif
#if MF_TIMER_STEP != MF_TIMER_PULSE
#define HAL_PULSE_TIMER_ISR() TC_HANDLER(MF_TIMER_PULSE)
#endif
#if MF_TIMER_TEMP == MF_TIMER_RTC
#define HAL_TEMP_TIMER_ISR() void RTC_Handler()
#else
#define HAL_TEMP_TIMER_ISR() TC_HANDLER(MF_TIMER_TEMP)
#endif
// --------------------------------------------------------------------------
// Types
// --------------------------------------------------------------------------
typedef enum { tcc, tc, rtc } TimerType;
typedef struct {
union {
Tc *pTc;
Tcc *pTcc;
Rtc *pRtc;
};
TimerType type;
IRQn_Type IRQ_Id;
uint8_t priority;
} tTimerConfig;
// --------------------------------------------------------------------------
// Public Variables
// --------------------------------------------------------------------------
extern const tTimerConfig timer_config[];
// --------------------------------------------------------------------------
// Public functions
// --------------------------------------------------------------------------
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 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 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 MF_TIMER_RTC
Tc * const tc = timer_config[timer_num].pTc;
tc->COUNT32.READREQ.reg = TC_READREQ_RREQ;
// Request a read synchronization
SYNC (tc->COUNT32.STATUS.bit.SYNCBUSY);
//SYNC(tc->COUNT32.STATUS.bit.SYNCBUSY );
return tc->COUNT32.COUNT.reg;
}
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);
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
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| RTC_MODE0_INTFLAG_OVF;
}
else if (timer_config[timer_num].type == TimerType::tcc){
Tcc * const tc = timer_config[timer_num].pTcc;
// Clear interrupt flag
tc->INTFLAG.reg = TCC_INTFLAG_OVF;
}
else {
Tc * const tc = timer_config[timer_num].pTc;
// Clear interrupt flag
tc->COUNT32.INTFLAG.bit.MC0 = 1;
}
}
#define HAL_timer_isr_epilogue(timer_num)

View File

@@ -0,0 +1,32 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
// adapted from I2C/master/master.c example
// https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
#ifdef __SAMD21__
#endif // __SAMD21__

View File

@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#pragma once

View File

@@ -0,0 +1,41 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#pragma once
/**
* SAMD21 LCD-specific defines
*/
// The following are optional depending on the platform.
// definitions of HAL specific com and device drivers.
uint8_t u8g_com_samd21_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
// connect U8g com generic com names to the desired driver
#define U8G_COM_HW_SPI u8g_com_samd21_st7920_hw_spi_fn // use SAMD21 specific hardware SPI routine
#define U8G_COM_ST7920_HW_SPI u8g_com_samd21_st7920_hw_spi_fn

View File

@@ -0,0 +1,42 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
/**
* Low level pin manipulation routines - used by all the drivers.
*
* These are based on the SAMD51 pinMode, digitalRead & digitalWrite routines.
*
* Couldn't just call exact copies because the overhead killed the LCD update speed
* With an intermediate level the softspi was running in the 10-20kHz range which
* resulted in using about about 25% of the CPU's time.
*/
#ifdef __SAMD21__
#include <Arduino.h>
#endif // __SAMD21__

View File

@@ -0,0 +1,42 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#pragma once
/**
* Low level pin manipulation routines - used by all the drivers.
*
* These are based on the SAMD51 pinMode, digitalRead & digitalWrite routines.
*
* Couldn't just call exact copies because the overhead killed the LCD update speed
* With an intermediate level the softspi was running in the 10-20kHz range which
* resulted in using about about 25% of the CPU's time.
*/
void u8g_SetPinOutput(uint8_t internal_pin_number);
void u8g_SetPinInput(uint8_t internal_pin_number);
void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status);
uint8_t u8g_GetPinLevel(uint8_t pin);

View File

@@ -0,0 +1,154 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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/>.
*
*/
/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
/**
* Based on u8g_com_msp430_hw_spi.c
*
* Universal 8bit Graphics Library
*
* Copyright (c) 2012, olikraus@gmail.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef __SAMD21__
#include <U8glib-HAL.h>
#include "SPI.h"
#include "../../shared/HAL_SPI.h"
#ifndef LCD_SPI_SPEED
#define LCD_SPI_SPEED SPI_QUARTER_SPEED
#endif
void u8g_SetPIOutput(u8g_t *u8g, uint8_t pin_index) {
if (u8g->pin_list[pin_index]!= U8G_PIN_NONE)
pinMode(u8g->pin_list[pin_index],OUTPUT);
}
void u8g_SetPILevel(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
if (u8g->pin_list[pin_index]!= U8G_PIN_NONE)
digitalWrite(u8g->pin_list[pin_index],level);
}
uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
static SPISettings lcdSPIConfig;
switch (msg) {
case U8G_COM_MSG_STOP:
break;
case U8G_COM_MSG_INIT:
u8g_SetPIOutput(u8g, U8G_PI_CS);
u8g_SetPIOutput(u8g, U8G_PI_A0);
u8g_SetPIOutput(u8g, U8G_PI_RESET);
u8g_SetPILevel(u8g, U8G_PI_CS, LOW);
spiBegin();
lcdSPIConfig = SPISettings(900000, MSBFIRST, SPI_MODE0);
u8g->pin_list[U8G_PI_A0_STATE] = 0;
break;
case U8G_COM_MSG_ADDRESS: // define cmd (arg_val = 0) or data mode (arg_val = 1)
u8g_SetPILevel(u8g, U8G_PI_A0, arg_val);
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
break;
case U8G_COM_MSG_CHIP_SELECT: // arg_val == 1 means chip selected, but ST7920 is active high, so needs inverting
u8g_SetPILevel(u8g, U8G_PI_CS, arg_val ? HIGH : LOW);
break;
case U8G_COM_MSG_RESET:
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
break;
case U8G_COM_MSG_WRITE_BYTE:
SPI.beginTransaction(lcdSPIConfig);
if (u8g->pin_list[U8G_PI_A0_STATE] == 0) { // command
SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2;
}
else if (u8g->pin_list[U8G_PI_A0_STATE] == 1) { // data
SPI.transfer(0x0fa); u8g->pin_list[U8G_PI_A0_STATE] = 2;
}
SPI.transfer(arg_val & 0x0f0);
SPI.transfer(arg_val << 4);
SPI.endTransaction();
break;
case U8G_COM_MSG_WRITE_SEQ:
SPI.beginTransaction(lcdSPIConfig);
if (u8g->pin_list[U8G_PI_A0_STATE] == 0 ) { // command
SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2;
}
else if (u8g->pin_list[U8G_PI_A0_STATE] == 1) { // data
SPI.transfer(0x0fa); u8g->pin_list[U8G_PI_A0_STATE] = 2;
}
uint8_t *ptr = (uint8_t*)arg_ptr;
while (arg_val > 0) {
SPI.transfer((*ptr) & 0x0f0);
SPI.transfer((*ptr) << 4);
ptr++;
arg_val--;
}
SPI.endTransaction();
break;
}
return 1;
}
#endif // __SAMD21__

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -18,6 +19,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD51__
#include "../../inc/MarlinConfig.h"
@@ -598,7 +603,7 @@ void MarlinHAL::dma_init() {
void MarlinHAL::init() {
TERN_(DMA_IS_REQUIRED, dma_init());
#if ENABLED(SDSUPPORT)
#if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT)
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -20,6 +21,10 @@
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#define CPU_32_BIT
#include "../shared/Marduino.h"

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -19,6 +20,10 @@
*
*/
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
/**
* Hardware and software SPI implementations are included in this file.
*

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -18,6 +19,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#ifdef ADAFRUIT_GRAND_CENTRAL_M4
/**

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -20,6 +21,10 @@
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#include "../../core/serial_hook.h"
typedef Serial1Class<Uart> UartT;

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -20,6 +21,10 @@
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#define SYNC(sc) while (sc) { \
asm(""); \
}

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -19,6 +20,10 @@
*
*/
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
/**
* This comes from Arduino library which at the moment is buggy and uncompilable
*/
@@ -77,7 +82,8 @@ HAL_SERVO_TIMER_ISR() {
;
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
if (currentServoIndex[timer] < 0) {
int8_t cho = currentServoIndex[timer]; // Handle the prior servo first
if (cho < 0) { // Servo -1 indicates the refresh interval completed...
#if defined(_useTimer1) && defined(_useTimer2)
if (currentServoIndex[timer ^ 1] >= 0) {
// Wait for both channels
@@ -86,45 +92,37 @@ HAL_SERVO_TIMER_ISR() {
return;
}
#endif
tc->COUNT16.COUNT.reg = TC_COUNTER_START_VAL;
tc->COUNT16.COUNT.reg = TC_COUNTER_START_VAL; // ...so reset the timer
SYNC(tc->COUNT16.SYNCBUSY.bit.COUNT);
}
else if (SERVO_INDEX(timer, currentServoIndex[timer]) < ServoCount && SERVO(timer, currentServoIndex[timer]).Pin.isActive)
digitalWrite(SERVO(timer, currentServoIndex[timer]).Pin.nbr, LOW); // pulse this channel low if activated
else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled?
digitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW
// Select the next servo controlled by this timer
currentServoIndex[timer]++;
currentServoIndex[timer] = ++cho; // go to the next channel (or 0)
if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) {
if (SERVO(timer, cho).Pin.isActive) // activated?
digitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH
if (SERVO_INDEX(timer, currentServoIndex[timer]) < ServoCount && currentServoIndex[timer] < SERVOS_PER_TIMER) {
if (SERVO(timer, currentServoIndex[timer]).Pin.isActive) // check if activated
digitalWrite(SERVO(timer, currentServoIndex[timer]).Pin.nbr, HIGH); // it's an active channel so pulse it high
tc->COUNT16.CC[tcChannel].reg = getTimerCount() - (uint16_t)SERVO(timer, currentServoIndex[timer]).ticks;
tc->COUNT16.CC[tcChannel].reg = getTimerCount() - (uint16_t)SERVO(timer, cho).ticks;
}
else {
// finished all channels so wait for the refresh period to expire before starting over
currentServoIndex[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
const uint16_t tcCounterValue = getTimerCount();
if ((TC_COUNTER_START_VAL - tcCounterValue) + 4UL < usToTicks(REFRESH_INTERVAL)) // allow a few ticks to ensure the next OCR1A not missed
tc->COUNT16.CC[tcChannel].reg = TC_COUNTER_START_VAL - (uint16_t)usToTicks(REFRESH_INTERVAL);
else
tc->COUNT16.CC[tcChannel].reg = (uint16_t)(tcCounterValue - 4UL); // at least REFRESH_INTERVAL has elapsed
currentServoIndex[timer] = -1; // reset the timer COUNT.reg on the next call
const uint16_t cval = getTimerCount() - 256 / (SERVO_TIMER_PRESCALER), // allow 256 cycles to ensure the next CV not missed
ival = (TC_COUNTER_START_VAL) - (uint16_t)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed
tc->COUNT16.CC[tcChannel].reg = min(cval, ival);
}
if (tcChannel == 0) {
SYNC(tc->COUNT16.SYNCBUSY.bit.CC0);
// Clear the interrupt
tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0;
tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0; // Clear the interrupt
}
else {
SYNC(tc->COUNT16.SYNCBUSY.bit.CC1);
// Clear the interrupt
tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC1;
tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC1; // Clear the interrupt
}
}
void initISR(timer16_Sequence_t timer) {
void initISR(const timer16_Sequence_t timer) {
Tc * const tc = timer_config[SERVO_TC].pTc;
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
@@ -201,9 +199,9 @@ void initISR(timer16_Sequence_t timer) {
}
}
void finISR(timer16_Sequence_t timer) {
void finISR(const timer16_Sequence_t timer_index) {
Tc * const tc = timer_config[SERVO_TC].pTc;
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
const uint8_t tcChannel = TIMER_TCCHANNEL(timer_index);
// Disable the match channel interrupt request
tc->COUNT16.INTENCLR.reg = (tcChannel == 0) ? TC_INTENCLR_MC0 : TC_INTENCLR_MC1;

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -20,6 +21,10 @@
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#define _useTimer1
#define _useTimer2

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -18,6 +19,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD51__
#include "../../inc/MarlinConfig.h"

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -18,6 +19,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD51__
#include "../../inc/MarlinConfig.h"

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -18,6 +19,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD51__
#include "../../inc/MarlinConfig.h"

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -20,6 +21,10 @@
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
/**
* Endstop interrupts for ATMEL SAMD51 based targets.
*

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -20,6 +21,10 @@
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
/**
* Fast IO functions for SAMD51
*/

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -18,6 +19,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
/**
* Test SAMD51 specific configuration values for errors at compile-time.

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -20,6 +21,10 @@
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#define NUMBER_PINS_TOTAL PINS_COUNT
#define digitalRead_mod(p) extDigitalRead(p)
@@ -29,7 +34,7 @@
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#define GET_ARRAY_PIN(p) pin_array[p].pin
#define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL)
#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
#define DIGITAL_PIN_TO_ANALOG_PIN(p) digitalPinToAnalogInput(p)
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P)!=-1)
#define pwm_status(pin) digitalPinHasPWM(pin)

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -20,6 +21,10 @@
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#ifdef ADAFRUIT_GRAND_CENTRAL_M4
/*

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -18,6 +19,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#ifdef __SAMD51__
// --------------------------------------------------------------------------

View File

@@ -1,8 +1,9 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* 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
@@ -20,6 +21,10 @@
*/
#pragma once
/**
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*/
#include <stdint.h>
// --------------------------------------------------------------------------

View File

@@ -95,7 +95,7 @@
static_assert(IS_FLASH_SECTOR(FLASH_SECTOR), "FLASH_SECTOR is invalid");
static_assert(IS_POWER_OF_2(FLASH_UNIT_SIZE), "FLASH_UNIT_SIZE should be a power of 2, please check your chip's spec sheet");
#endif
#endif // FLASH_EEPROM_LEVELING
static bool eeprom_data_written = false;
@@ -189,15 +189,15 @@ bool PersistentStore::access_finish() {
UNLOCK_FLASH();
uint32_t offset = 0;
uint32_t address = SLOT_ADDRESS(current_slot);
uint32_t address_end = address + MARLIN_EEPROM_SIZE;
uint32_t data = 0;
uint32_t offset = 0,
address = SLOT_ADDRESS(current_slot),
address_end = address + MARLIN_EEPROM_SIZE,
data = 0;
bool success = true;
while (address < address_end) {
memcpy(&data, ram_eeprom + offset, sizeof(uint32_t));
memcpy(&data, ram_eeprom + offset, sizeof(data));
status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data);
if (status == HAL_OK) {
address += sizeof(uint32_t);
@@ -221,7 +221,8 @@ bool PersistentStore::access_finish() {
return success;
#else
#else // !FLASH_EEPROM_LEVELING
// The following was written for the STM32F4 but may work with other MCUs as well.
// Most STM32F4 flash does not allow reading from flash during erase operations.
// This takes about a second on a STM32F407 with a 128kB sector used as EEPROM.
@@ -235,7 +236,8 @@ bool PersistentStore::access_finish() {
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
eeprom_data_written = false;
#endif
#endif // !FLASH_EEPROM_LEVELING
}
return true;

View File

@@ -27,3 +27,8 @@
#elif EITHER(I2C_EEPROM, SPI_EEPROM)
#define USE_SHARED_EEPROM 1
#endif
// Some STM32F4 boards may lose steps when saving to EEPROM during print (PR #17946)
#if defined(STM32F4xx) && ENABLED(FLASH_EEPROM_EMULATION) && PRINTCOUNTER_SAVE_INTERVAL > 0
#define PRINTCOUNTER_SYNC 1
#endif

View File

@@ -37,11 +37,6 @@
#error "SDCARD_EEPROM_EMULATION requires SDSUPPORT. Enable SDSUPPORT or choose another EEPROM emulation."
#endif
#if defined(STM32F4xx) && BOTH(PRINTCOUNTER, FLASH_EEPROM_EMULATION)
#warning "FLASH_EEPROM_EMULATION may cause long delays when writing and should not be used while printing."
#error "Disable PRINTCOUNTER or choose another EEPROM emulation."
#endif
#if !defined(STM32F4xx) && ENABLED(FLASH_EEPROM_LEVELING)
#error "FLASH_EEPROM_LEVELING is currently only supported on STM32F4 hardware."
#endif
@@ -55,3 +50,62 @@
#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32H7xx, STM32F4xx, STM32F1xx)
#error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware."
#endif
/**
* Check for common serial pin conflicts
*/
#define _CHECK_SERIAL_PIN(N) (( \
BTN_EN1 == N || DOGLCD_CS == N || HEATER_BED_PIN == N || FAN_PIN == N || \
SDIO_D2_PIN == N || SDIO_D3_PIN == N || SDIO_CK_PIN == N || SDIO_CMD_PIN == N \
))
#define CHECK_SERIAL_PIN(T,N) defined(UART##N##_##T##_PIN) && _CHECK_SERIAL_PIN(UART##N##_##T##_PIN)
#if SERIAL_IN_USE(1)
#if CHECK_SERIAL_PIN(TX,1)
#error "Serial Port 1 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,1)
#error "Serial Port 1 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(2)
#if CHECK_SERIAL_PIN(TX,2)
#error "Serial Port 2 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,2)
#error "Serial Port 2 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(3)
#if CHECK_SERIAL_PIN(TX,3)
#error "Serial Port 3 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,3)
#error "Serial Port 3 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(4)
#if CHECK_SERIAL_PIN(TX,4)
#error "Serial Port 4 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,4)
#error "Serial Port 4 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(5)
#if CHECK_SERIAL_PIN(TX,5)
#error "Serial Port 5 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,5)
#error "Serial Port 5 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(6)
#if CHECK_SERIAL_PIN(TX,6)
#error "Serial Port 6 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,6)
#error "Serial Port 6 RX IO pins conflict with another pin on the board."
#endif
#endif
#undef CHECK_SERIAL_PIN
#undef _CHECK_SERIAL_PIN

View File

@@ -102,17 +102,18 @@ const XrefInfo pin_xref[] PROGMEM = {
#define PIN_NUM_ALPHA_LEFT(P) (((P & 0x000F) < 10) ? ('0' + (P & 0x000F)) : '1')
#define PIN_NUM_ALPHA_RIGHT(P) (((P & 0x000F) > 9) ? ('0' + (P & 0x000F) - 10) : 0 )
#define PORT_NUM(P) ((P >> 4) & 0x0007)
#define PORT_ALPHA(P) ('A' + (P >> 4))
#define PORT_ALPHA(P) ('A' + (P >> 4))
/**
* Translation of routines & variables used by pinsDebug.h
*/
#if PA0 >= NUM_DIGITAL_PINS
#if NUM_ANALOG_FIRST >= NUM_DIGITAL_PINS
#define HAS_HIGH_ANALOG_PINS 1
#endif
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS)
#define VALID_PIN(ANUM) ((ANUM) >= 0 && (ANUM) < NUMBER_PINS_TOTAL)
#define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1)
#define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS))
#define VALID_PIN(P) (WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1) || TERN0(HAS_HIGH_ANALOG_PINS, WITHIN(P, NUM_ANALOG_FIRST, NUM_ANALOG_LAST)))
#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads
#define PRINT_PIN(Q)
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
@@ -168,7 +169,7 @@ bool GET_PINMODE(const pin_t Ard_num) {
}
int8_t digital_pin_to_analog_pin(const pin_t Ard_num) {
if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_FIRST + NUM_ANALOG_INPUTS - 1))
if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))
return Ard_num - NUM_ANALOG_FIRST;
const uint32_t ind = digitalPinToAnalogInput(Ard_num);
@@ -206,8 +207,11 @@ void port_print(const pin_t Ard_num) {
SERIAL_ECHO_SP(7);
// Print number to be used with M42
int calc_p = Ard_num % (NUM_DIGITAL_PINS + 1);
if (Ard_num > NUM_DIGITAL_PINS && calc_p > 7) calc_p += 8;
int calc_p = Ard_num;
if (Ard_num > NUM_DIGITAL_PINS) {
calc_p -= NUM_ANALOG_FIRST;
if (calc_p > 7) calc_p += 8;
}
SERIAL_ECHOPGM(" M42 P", calc_p);
SERIAL_CHAR(' ');
if (calc_p < 100) {

View File

@@ -33,157 +33,43 @@
#include <stdint.h>
#include <stdbool.h>
// use local drivers
#if defined(STM32F103xE) || defined(STM32F103xG)
#include <stm32f1xx.h>
#include <stm32f1xx_hal_rcc_ex.h>
#include <stm32f1xx_hal_sd.h>
#elif defined(STM32F4xx)
#include <stm32f4xx.h>
#include <stm32f4xx_hal_rcc.h>
#include <stm32f4xx_hal_dma.h>
#include <stm32f4xx_hal_gpio.h>
#include <stm32f4xx_hal_sd.h>
#elif defined(STM32F7xx)
#include <stm32f7xx.h>
#include <stm32f7xx_hal_rcc.h>
#include <stm32f7xx_hal_dma.h>
#include <stm32f7xx_hal_gpio.h>
#include <stm32f7xx_hal_sd.h>
#elif defined(STM32H7xx)
#include <stm32h7xx.h>
#define SDIO_FOR_STM32H7
#include <stm32h7xx_hal_rcc.h>
#include <stm32h7xx_hal_dma.h>
#include <stm32h7xx_hal_gpio.h>
#include <stm32h7xx_hal_sd.h>
#else
#error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, STM32F7xx, or STM32H7xx."
#error "SDIO is only supported with STM32F103xE, STM32F103xG, STM32F4xx, STM32F7xx, and STM32H7xx."
#endif
// SDIO Max Clock (naming from STM Manual, don't change)
#define SDIOCLK 48000000
// Target Clock, configurable. Default is 18MHz, from STM32F1
#ifndef SDIO_CLOCK
#define SDIO_CLOCK 18000000 // 18 MHz
#endif
#define SD_TIMEOUT 1000 // ms
// SDIO Max Clock (naming from STM Manual, don't change)
#define SDIOCLK 48000000
#if defined(STM32F1xx)
DMA_HandleTypeDef hdma_sdio;
extern "C" void DMA2_Channel4_5_IRQHandler(void) {
HAL_DMA_IRQHandler(&hdma_sdio);
}
#elif defined(STM32F4xx)
DMA_HandleTypeDef hdma_sdio_rx;
DMA_HandleTypeDef hdma_sdio_tx;
extern "C" void DMA2_Stream3_IRQHandler(void) {
HAL_DMA_IRQHandler(&hdma_sdio_rx);
}
extern "C" void DMA2_Stream6_IRQHandler(void) {
HAL_DMA_IRQHandler(&hdma_sdio_tx);
}
#elif defined(STM32H7xx)
#define __HAL_RCC_SDIO_FORCE_RESET __HAL_RCC_SDMMC1_FORCE_RESET
#define __HAL_RCC_SDIO_RELEASE_RESET __HAL_RCC_SDMMC1_RELEASE_RESET
#define __HAL_RCC_SDIO_CLK_ENABLE __HAL_RCC_SDMMC1_CLK_ENABLE
#define SDIO SDMMC1
#define SDIO_IRQn SDMMC1_IRQn
#define SDIO_IRQHandler SDMMC1_IRQHandler
#define SDIO_CLOCK_EDGE_RISING SDMMC_CLOCK_EDGE_RISING
#define SDIO_CLOCK_POWER_SAVE_DISABLE SDMMC_CLOCK_POWER_SAVE_DISABLE
#define SDIO_BUS_WIDE_1B SDMMC_BUS_WIDE_1B
#define SDIO_BUS_WIDE_4B SDMMC_BUS_WIDE_4B
#define SDIO_HARDWARE_FLOW_CONTROL_DISABLE SDMMC_HARDWARE_FLOW_CONTROL_DISABLE
#endif
uint8_t waitingRxCplt = 0;
uint8_t waitingTxCplt = 0;
SD_HandleTypeDef hsd;
extern "C" void SDIO_IRQHandler(void) {
HAL_SD_IRQHandler(&hsd);
}
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsdio) {
waitingTxCplt = 0;
}
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsdio) {
waitingRxCplt = 0;
}
void HAL_SD_MspInit(SD_HandleTypeDef *hsd) {
pinmap_pinout(PC_12, PinMap_SD);
pinmap_pinout(PD_2, PinMap_SD);
pinmap_pinout(PC_8, PinMap_SD);
#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus
// D1-D3
pinmap_pinout(PC_9, PinMap_SD);
pinmap_pinout(PC_10, PinMap_SD);
pinmap_pinout(PC_11, PinMap_SD);
#endif
__HAL_RCC_SDIO_CLK_ENABLE();
HAL_NVIC_EnableIRQ(SDIO_IRQn);
// DMA Config
#if defined(STM32F1xx)
__HAL_RCC_DMA2_CLK_ENABLE();
HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn);
hdma_sdio.Instance = DMA2_Channel4;
hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_sdio.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_sdio.Init.MemInc = DMA_MINC_ENABLE;
hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_sdio.Init.Mode = DMA_NORMAL;
hdma_sdio.Init.Priority = DMA_PRIORITY_LOW;
HAL_DMA_Init(&hdma_sdio);
__HAL_LINKDMA(hsd, hdmarx ,hdma_sdio);
__HAL_LINKDMA(hsd, hdmatx, hdma_sdio);
#elif defined(STM32F4xx)
__HAL_RCC_DMA2_CLK_ENABLE();
HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn);
HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn);
hdma_sdio_rx.Instance = DMA2_Stream3;
hdma_sdio_rx.Init.Channel = DMA_CHANNEL_4;
hdma_sdio_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_sdio_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_sdio_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_sdio_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_sdio_rx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_sdio_rx.Init.Mode = DMA_PFCTRL;
hdma_sdio_rx.Init.Priority = DMA_PRIORITY_LOW;
hdma_sdio_rx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
hdma_sdio_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_sdio_rx.Init.MemBurst = DMA_MBURST_INC4;
hdma_sdio_rx.Init.PeriphBurst = DMA_PBURST_INC4;
HAL_DMA_Init(&hdma_sdio_rx);
__HAL_LINKDMA(hsd,hdmarx,hdma_sdio_rx);
hdma_sdio_tx.Instance = DMA2_Stream6;
hdma_sdio_tx.Init.Channel = DMA_CHANNEL_4;
hdma_sdio_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_sdio_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_sdio_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_sdio_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_sdio_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_sdio_tx.Init.Mode = DMA_PFCTRL;
hdma_sdio_tx.Init.Priority = DMA_PRIORITY_LOW;
hdma_sdio_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
hdma_sdio_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_sdio_tx.Init.MemBurst = DMA_MBURST_INC4;
hdma_sdio_tx.Init.PeriphBurst = DMA_PBURST_INC4;
HAL_DMA_Init(&hdma_sdio_tx);
__HAL_LINKDMA(hsd,hdmatx,hdma_sdio_tx);
#endif
}
void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) {
#if !defined(STM32F1xx)
__HAL_RCC_SDIO_FORCE_RESET();
delay(10);
__HAL_RCC_SDIO_RELEASE_RESET();
delay(10);
#endif
}
SD_HandleTypeDef hsd; // SDIO structure
static uint32_t clock_to_divider(uint32_t clk) {
#if defined(STM32H7xx)
#ifdef SDIO_FOR_STM32H7
// SDMMC_CK frequency = sdmmc_ker_ck / [2 * CLKDIV].
uint32_t sdmmc_clk = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SDMMC);
uint32_t sdmmc_clk = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SDMMC);
return sdmmc_clk / (2U * SDIO_CLOCK) + (sdmmc_clk % (2U * SDIO_CLOCK) != 0);
#else
// limit the SDIO master clock to 8/3 of PCLK2. See STM32 Manuals
@@ -198,62 +84,359 @@ static uint32_t clock_to_divider(uint32_t clk) {
#endif
}
bool SDIO_Init() {
HAL_StatusTypeDef sd_state = HAL_OK;
if (hsd.Instance == SDIO)
HAL_SD_DeInit(&hsd);
/* HAL SD initialization */
hsd.Instance = SDIO;
hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK);
sd_state = HAL_SD_Init(&hsd);
#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3)
if (sd_state == HAL_OK) {
sd_state = HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B);
}
// Start the SDIO clock
void HAL_SD_MspInit(SD_HandleTypeDef *hsd) {
UNUSED(hsd);
#ifdef SDIO_FOR_STM32H7
pinmap_pinout(PC_12, PinMap_SD);
pinmap_pinout(PD_2, PinMap_SD);
pinmap_pinout(PC_8, PinMap_SD);
#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // Define D1-D3 only for 4-bit wide SDIO bus
pinmap_pinout(PC_9, PinMap_SD);
pinmap_pinout(PC_10, PinMap_SD);
pinmap_pinout(PC_11, PinMap_SD);
#endif
__HAL_RCC_SDMMC1_CLK_ENABLE();
HAL_NVIC_EnableIRQ(SDMMC1_IRQn);
#else
__HAL_RCC_SDIO_CLK_ENABLE();
#endif
return (sd_state == HAL_OK) ? true : false;
}
bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
uint32_t timeout = HAL_GetTick() + SD_TIMEOUT;
#ifdef SDIO_FOR_STM32H7
while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) {
if (HAL_GetTick() >= timeout) return false;
#define SD_TIMEOUT 1000 // ms
extern "C" void SDMMC1_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); }
uint8_t waitingRxCplt = 0, waitingTxCplt = 0;
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsdio) { waitingTxCplt = 0; }
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsdio) { waitingRxCplt = 0; }
void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) {
__HAL_RCC_SDMMC1_FORCE_RESET(); delay(10);
__HAL_RCC_SDMMC1_RELEASE_RESET(); delay(10);
}
waitingRxCplt = 1;
if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)dst, block, 1) != HAL_OK)
bool SDIO_Init() {
HAL_StatusTypeDef sd_state = HAL_OK;
if (hsd.Instance == SDMMC1) HAL_SD_DeInit(&hsd);
// HAL SD initialization
hsd.Instance = SDMMC1;
hsd.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hsd.Init.BusWide = SDMMC_BUS_WIDE_1B;
hsd.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK);
sd_state = HAL_SD_Init(&hsd);
#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3)
if (sd_state == HAL_OK)
sd_state = HAL_SD_ConfigWideBusOperation(&hsd, SDMMC_BUS_WIDE_4B);
#endif
return (sd_state == HAL_OK);
}
#else // !SDIO_FOR_STM32H7
#define SD_TIMEOUT 500 // ms
// SDIO retries, configurable. Default is 3, from STM32F1
#ifndef SDIO_READ_RETRIES
#define SDIO_READ_RETRIES 3
#endif
// F4 supports one DMA for RX and another for TX, but Marlin will never
// do read and write at same time, so we use the same DMA for both.
DMA_HandleTypeDef hdma_sdio;
#ifdef STM32F1xx
#define DMA_IRQ_HANDLER DMA2_Channel4_5_IRQHandler
#elif defined(STM32F4xx)
#define DMA_IRQ_HANDLER DMA2_Stream3_IRQHandler
#else
#error "Unknown STM32 architecture."
#endif
extern "C" void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); }
extern "C" void DMA_IRQ_HANDLER(void) { HAL_DMA_IRQHandler(&hdma_sdio); }
/*
SDIO_INIT_CLK_DIV is 118
SDIO clock frequency is 48MHz / (TRANSFER_CLOCK_DIV + 2)
SDIO init clock frequency should not exceed 400kHz = 48MHz / (118 + 2)
Default TRANSFER_CLOCK_DIV is 2 (118 / 40)
Default SDIO clock frequency is 48MHz / (2 + 2) = 12 MHz
This might be too fast for stable SDIO operations
MKS Robin SDIO seems stable with BusWide 1bit and ClockDiv 8 (i.e., 4.8MHz SDIO clock frequency)
More testing is required as there are clearly some 4bit init problems.
*/
void go_to_transfer_speed() {
/* Default SDIO peripheral configuration for SD card initialization */
hsd.Init.ClockEdge = hsd.Init.ClockEdge;
hsd.Init.ClockBypass = hsd.Init.ClockBypass;
hsd.Init.ClockPowerSave = hsd.Init.ClockPowerSave;
hsd.Init.BusWide = hsd.Init.BusWide;
hsd.Init.HardwareFlowControl = hsd.Init.HardwareFlowControl;
hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK);
/* Initialize SDIO peripheral interface with default configuration */
SDIO_Init(hsd.Instance, hsd.Init);
}
void SD_LowLevel_Init() {
uint32_t tempreg;
// Enable GPIO clocks
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = 1; // GPIO_NOPULL
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
#if DISABLED(STM32F1xx)
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
#endif
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_12; // D0 & SCK
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus
GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; // D1-D3
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
#endif
// Configure PD.02 CMD line
GPIO_InitStruct.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
// Setup DMA
#ifdef STM32F1xx
hdma_sdio.Init.Mode = DMA_NORMAL;
hdma_sdio.Instance = DMA2_Channel4;
HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn);
#elif defined(STM32F4xx)
hdma_sdio.Init.Mode = DMA_PFCTRL;
hdma_sdio.Instance = DMA2_Stream3;
hdma_sdio.Init.Channel = DMA_CHANNEL_4;
hdma_sdio.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
hdma_sdio.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_sdio.Init.MemBurst = DMA_MBURST_INC4;
hdma_sdio.Init.PeriphBurst = DMA_PBURST_INC4;
HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn);
#endif
HAL_NVIC_EnableIRQ(SDIO_IRQn);
hdma_sdio.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_sdio.Init.MemInc = DMA_MINC_ENABLE;
hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_sdio.Init.Priority = DMA_PRIORITY_LOW;
__HAL_LINKDMA(&hsd, hdmarx, hdma_sdio);
__HAL_LINKDMA(&hsd, hdmatx, hdma_sdio);
#ifdef STM32F1xx
__HAL_RCC_SDIO_CLK_ENABLE();
__HAL_RCC_DMA2_CLK_ENABLE();
#else
__HAL_RCC_SDIO_FORCE_RESET(); delay(2);
__HAL_RCC_SDIO_RELEASE_RESET(); delay(2);
__HAL_RCC_SDIO_CLK_ENABLE();
__HAL_RCC_DMA2_FORCE_RESET(); delay(2);
__HAL_RCC_DMA2_RELEASE_RESET(); delay(2);
__HAL_RCC_DMA2_CLK_ENABLE();
#endif
// Initialize the SDIO (with initial <400Khz Clock)
tempreg = 0 // Reset value
| SDIO_CLKCR_CLKEN // Clock enabled
| SDIO_INIT_CLK_DIV; // Clock Divider. Clock = 48000 / (118 + 2) = 400Khz
// Keep the rest at 0 => HW_Flow Disabled, Rising Clock Edge, Disable CLK ByPass, Bus Width = 0, Power save Disable
SDIO->CLKCR = tempreg;
// Power up the SDIO
SDIO_PowerState_ON(SDIO);
hsd.Instance = SDIO;
}
bool SDIO_Init() {
uint8_t retryCnt = SDIO_READ_RETRIES;
bool status;
hsd.Instance = SDIO;
hsd.State = HAL_SD_STATE_RESET;
SD_LowLevel_Init();
uint8_t retry_Cnt = retryCnt;
for (;;) {
hal.watchdog_refresh();
status = (bool) HAL_SD_Init(&hsd);
if (!status) break;
if (!--retry_Cnt) return false; // return failing status if retries are exhausted
}
go_to_transfer_speed();
#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined
retry_Cnt = retryCnt;
for (;;) {
hal.watchdog_refresh();
if (!HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B)) break; // some cards are only 1 bit wide so a pass here is not required
if (!--retry_Cnt) break;
}
if (!retry_Cnt) { // wide bus failed, go back to one bit wide mode
hsd.State = (HAL_SD_StateTypeDef) 0; // HAL_SD_STATE_RESET
SD_LowLevel_Init();
retry_Cnt = retryCnt;
for (;;) {
hal.watchdog_refresh();
status = (bool) HAL_SD_Init(&hsd);
if (!status) break;
if (!--retry_Cnt) return false; // return failing status if retries are exhausted
}
go_to_transfer_speed();
}
#endif
return true;
}
/**
* @brief Read or Write a block
* @details Read or Write a block with SDIO
*
* @param block The block index
* @param src The data buffer source for a write
* @param dst The data buffer destination for a read
*
* @return true on success
*/
static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) {
if (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false;
hal.watchdog_refresh();
HAL_StatusTypeDef ret;
if (src) {
hdma_sdio.Init.Direction = DMA_MEMORY_TO_PERIPH;
HAL_DMA_Init(&hdma_sdio);
ret = HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t*)src, block, 1);
}
else {
hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY;
HAL_DMA_Init(&hdma_sdio);
ret = HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t*)dst, block, 1);
}
if (ret != HAL_OK) {
HAL_DMA_Abort_IT(&hdma_sdio);
HAL_DMA_DeInit(&hdma_sdio);
return false;
}
millis_t timeout = millis() + SD_TIMEOUT;
// Wait the transfer
while (hsd.State != HAL_SD_STATE_READY) {
if (ELAPSED(millis(), timeout)) {
HAL_DMA_Abort_IT(&hdma_sdio);
HAL_DMA_DeInit(&hdma_sdio);
return false;
}
}
while (__HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TC_FLAG_INDEX(&hdma_sdio)) != 0
|| __HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TE_FLAG_INDEX(&hdma_sdio)) != 0) { /* nada */ }
HAL_DMA_Abort_IT(&hdma_sdio);
HAL_DMA_DeInit(&hdma_sdio);
timeout = millis() + SD_TIMEOUT;
while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) if (ELAPSED(millis(), timeout)) return false;
return true;
}
#endif // !SDIO_FOR_STM32H7
/**
* @brief Read a block
* @details Read a block from media with SDIO
*
* @param block The block index
* @param src The block buffer
*
* @return true on success
*/
bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
#ifdef SDIO_FOR_STM32H7
uint32_t timeout = HAL_GetTick() + SD_TIMEOUT;
while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER)
if (HAL_GetTick() >= timeout) return false;
waitingRxCplt = 1;
if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t*)dst, block, 1) != HAL_OK)
return false;
timeout = HAL_GetTick() + SD_TIMEOUT;
while (waitingRxCplt)
if (HAL_GetTick() >= timeout) return false;
return true;
#else
uint8_t retries = SDIO_READ_RETRIES;
while (retries--) if (SDIO_ReadWriteBlock_DMA(block, nullptr, dst)) return true;
return false;
timeout = HAL_GetTick() + SD_TIMEOUT;
while (waitingRxCplt)
if (HAL_GetTick() >= timeout) return false;
return true;
#endif
}
/**
* @brief Write a block
* @details Write a block to media with SDIO
*
* @param block The block index
* @param src The block data
*
* @return true on success
*/
bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
uint32_t timeout = HAL_GetTick() + SD_TIMEOUT;
#ifdef SDIO_FOR_STM32H7
while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER)
if (HAL_GetTick() >= timeout) return false;
uint32_t timeout = HAL_GetTick() + SD_TIMEOUT;
waitingTxCplt = 1;
if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)src, block, 1) != HAL_OK)
while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER)
if (HAL_GetTick() >= timeout) return false;
waitingTxCplt = 1;
if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t*)src, block, 1) != HAL_OK)
return false;
timeout = HAL_GetTick() + SD_TIMEOUT;
while (waitingTxCplt)
if (HAL_GetTick() >= timeout) return false;
return true;
#else
uint8_t retries = SDIO_READ_RETRIES;
while (retries--) if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true;
return false;
timeout = HAL_GetTick() + SD_TIMEOUT;
while (waitingTxCplt)
if (HAL_GetTick() >= timeout) return false;
return true;
#endif
}
bool SDIO_IsReady() {

View File

@@ -150,33 +150,37 @@ void GT911::read_reg(uint16_t reg, uint8_t reg_len, uint8_t* r_data, uint8_t r_l
sw_iic.start();
sw_iic.send_byte(gt911_slave_address + 1); // Set read mode
LOOP_L_N(i, r_len) {
LOOP_L_N(i, r_len)
r_data[i] = sw_iic.read_byte(1); // Read data from reg
}
sw_iic.stop();
}
void GT911::Init() {
OUT_WRITE(GT911_RST_PIN, LOW);
OUT_WRITE(GT911_INT_PIN, LOW);
delay(20);
delay(11);
WRITE(GT911_INT_PIN, HIGH);
delayMicroseconds(110);
WRITE(GT911_RST_PIN, HIGH);
delay(6);
WRITE(GT911_INT_PIN, LOW);
delay(55);
SET_INPUT(GT911_INT_PIN);
sw_iic.init();
uint8_t clear_reg = 0x0000;
write_reg(0x814E, 2, &clear_reg, 2); // Reset to 0 for start
uint8_t clear_reg = 0x00;
write_reg(0x814E, 2, &clear_reg, 1); // Reset to 0 for start
}
bool GT911::getFirstTouchPoint(int16_t *x, int16_t *y) {
read_reg(0x814E, 2, &reg.REG.status, 1);
if (reg.REG.status & 0x80) {
if (reg.REG.status >= 0x80 && reg.REG.status <= 0x85) {
read_reg(0x8150, 2, reg.map + 2, 38);
uint8_t clear_reg = 0x00;
write_reg(0x814E, 2, &clear_reg, 1); // Reset to 0 for start
read_reg(0x8150, 2, reg.map + 2, 8 * (reg.REG.status & 0x0F));
// First touch point
*x = ((reg.REG.point[0].xh & 0x0F) << 8) | reg.REG.point[0].xl;
*y = ((reg.REG.point[0].yh & 0x0F) << 8) | reg.REG.point[0].yl;

View File

@@ -23,7 +23,7 @@
#include "../../../inc/MarlinConfig.h"
#define GT911_SLAVE_ADDRESS 0xBA
#define GT911_SLAVE_ADDRESS 0x28
#if !PIN_EXISTS(GT911_RST)
#error "GT911_RST_PIN is not defined."
@@ -39,42 +39,18 @@ class SW_IIC {
private:
uint16_t scl_pin;
uint16_t sda_pin;
void write_scl(bool level)
{
WRITE(scl_pin, level);
}
void write_sda(bool level)
{
WRITE(sda_pin, level);
}
bool read_sda()
{
return READ(sda_pin);
}
void set_sda_out()
{
SET_OUTPUT(sda_pin);
}
void set_sda_in()
{
SET_INPUT_PULLUP(sda_pin);
}
static void iic_delay(uint8_t t)
{
delayMicroseconds(t);
}
void write_scl(bool level) { WRITE(scl_pin, level); }
void write_sda(bool level) { WRITE(sda_pin, level); }
bool read_sda() { return READ(sda_pin); }
void set_sda_out() { SET_OUTPUT(sda_pin); }
void set_sda_in() { SET_INPUT_PULLUP(sda_pin); }
static void iic_delay(uint8_t t) { delayMicroseconds(t); }
public:
SW_IIC(uint16_t sda, uint16_t scl);
// setSCL/SDA have to be called before begin()
void setSCL(uint16_t scl)
{
scl_pin = scl;
};
void setSDA(uint16_t sda)
{
sda_pin = sda;
};
void setSCL(uint16_t scl) { scl_pin = scl; }
void setSDA(uint16_t sda) { sda_pin = sda; }
void init(); // Initialize the IO port of IIC
void start(); // Send IIC start signal
void stop(); // Send IIC stop signal

View File

@@ -147,21 +147,36 @@ uint32_t TFT_FSMC::ReadID(tft_data_t Reg) {
}
bool TFT_FSMC::isBusy() {
#if defined(STM32F1xx)
volatile bool dmaEnabled = (DMAtx.Instance->CCR & DMA_CCR_EN) != RESET;
#ifdef STM32F1xx
#define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN)
#define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->CPAR != 0)
#elif defined(STM32F4xx)
volatile bool dmaEnabled = DMAtx.Instance->CR & DMA_SxCR_EN;
#define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN)
#define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->PAR != 0)
#endif
if (dmaEnabled) {
if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) != 0 || __HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) != 0)
Abort();
}
else
Abort();
return dmaEnabled;
if (!__IS_DMA_CONFIGURED(&DMAtx)) return false;
// Check if DMA transfer error or transfer complete flags are set
if ((__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) == 0) && (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) == 0)) return true;
__DSB();
Abort();
return false;
}
void TFT_FSMC::Abort() {
HAL_DMA_Abort(&DMAtx); // Abort DMA transfer if any
HAL_DMA_DeInit(&DMAtx); // Deconfigure DMA
}
void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
DMAtx.Init.PeriphInc = MemoryIncrease;
HAL_DMA_Init(&DMAtx);
HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(LCD->RAM), Count);
}
void TFT_FSMC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
DMAtx.Init.PeriphInc = MemoryIncrease;
HAL_DMA_Init(&DMAtx);
DataTransferBegin();

View File

@@ -41,6 +41,7 @@
#define DATASIZE_8BIT SPI_DATASIZE_8BIT
#define DATASIZE_16BIT SPI_DATASIZE_16BIT
#define TFT_IO_DRIVER TFT_FSMC
#define DMA_MAX_SIZE 0xFFFF
#define TFT_DATASIZE TERN(TFT_INTERFACE_FSMC_8BIT, DATASIZE_8BIT, DATASIZE_16BIT)
typedef TERN(TFT_INTERFACE_FSMC_8BIT, uint8_t, uint16_t) tft_data_t;
@@ -59,13 +60,14 @@ class TFT_FSMC {
static uint32_t ReadID(tft_data_t Reg);
static void Transmit(tft_data_t Data) { LCD->RAM = Data; __DSB(); }
static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
public:
static void Init();
static uint32_t GetID();
static bool isBusy();
static void Abort() { __HAL_DMA_DISABLE(&DMAtx); }
static void Abort();
static void DataTransferBegin(uint16_t DataWidth = TFT_DATASIZE) {}
static void DataTransferEnd() {};
@@ -73,13 +75,14 @@ class TFT_FSMC {
static void WriteData(uint16_t Data) { Transmit(tft_data_t(Data)); }
static void WriteReg(uint16_t Reg) { LCD->REG = tft_data_t(Reg); __DSB(); }
static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); }
static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); }
static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); }
static void WriteMultiple(uint16_t Color, uint32_t Count) {
static uint16_t Data; Data = Color;
while (Count > 0) {
TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count);
Count = Count > 0xFFFF ? Count - 0xFFFF : 0;
Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count);
Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0;
}
}
};

View File

@@ -356,7 +356,7 @@ void TFT_LTDC::WriteReg(uint16_t Reg) {
reg = Reg;
}
void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
void TFT_LTDC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
while (x_cur != x_min && Count) {
Transmit(*Data);
@@ -372,9 +372,9 @@ void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou
if (MemoryIncrease == DMA_PINC_ENABLE) {
DrawImage(x_min, y_cur, x_min + width, y_cur + height, Data);
Data += width * height;
} else {
DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data);
}
else
DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data);
y_cur += height;
}

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