Compare commits
451 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 988140a467 | |||
| c320503d78 | |||
| d90d15817c | |||
| 4479f438fd | |||
| 5573d98ecc | |||
| 38b44e3fc9 | |||
| d4ab2024f5 | |||
| 790bba1556 | |||
| b51aed8aa5 | |||
| 1f52112d72 | |||
| ad907a51e2 | |||
| 6673359d89 | |||
| 560448afed | |||
| deaefbf1dc | |||
| 9823a37362 | |||
| 15bda88d04 | |||
| de73b9b934 | |||
| 2fc854eda0 | |||
| 60607ed18d | |||
| 546e56ef3d | |||
| dc78e0a250 | |||
| 5ffa6f3331 | |||
| 1a23ffd776 | |||
| c07f99d5e4 | |||
| ae8be31247 | |||
| 4f6910c131 | |||
| d787cd3076 | |||
| cc3e878f90 | |||
| b9b9a3115a | |||
| 36d3b6aa95 | |||
| 911cd1a6d3 | |||
| da84b59ee4 | |||
| 11343bb0ea | |||
| e05616ada1 | |||
| 3107d8a0f4 | |||
| 7f1fa0d1ff | |||
| 604c5dedf4 | |||
| 71f2617263 | |||
| 8532c2b9b6 | |||
| 1affbe2100 | |||
| 9dc2712c47 | |||
| 6e1024737d | |||
| 03a41021de | |||
| a73cff8e4f | |||
| 8857fc6c4b | |||
| f671e6d138 | |||
| 4d6ebf95fc | |||
| 8c512191b2 | |||
| f147a8990a | |||
| 048f6b4731 | |||
| 9cba3c87ef | |||
| dbd28eecc9 | |||
| 2c62886c71 | |||
| fe0b770033 | |||
| b75e682c50 | |||
| bb6d718e19 | |||
| 28a136d7f4 | |||
| 10ec5c7f34 | |||
| 55c31fbe9a | |||
| 2f1fd4bbaa | |||
| 18a10c0db1 | |||
| aad0f517b4 | |||
| 1b9ff68f8c | |||
| aa054471f2 | |||
| f2ff75f3a2 | |||
| 5dc8f5cfab | |||
| ced1bb9404 | |||
| 9f14127fd6 | |||
| b95e548ddb | |||
| b4402a789a | |||
| 87bef13a4c | |||
| 72cc5a49e6 | |||
| a94fa7b476 | |||
| 43b712d42b | |||
| 2c5967925f | |||
| 4182cf3e9e | |||
| a1796ecace | |||
| 3eb8e26174 | |||
| d05bf563a2 | |||
| 3ea56ba4c7 | |||
| f56929d0df | |||
| 101f09aabd | |||
| a0d312396a | |||
| 6903a2ffc5 | |||
| 8dee12ff05 | |||
| 9299f4e98a | |||
| 6225870aa9 | |||
| dad486c01b | |||
| 0b7e857614 | |||
| 431f6bf3a5 | |||
| 9372aa99af | |||
| 81c29ecc7e | |||
| dd388aedfd | |||
| a46e025725 | |||
| fd270ddc6c | |||
| 369ffe518d | |||
| 0afa4cc957 | |||
| 872f031405 | |||
| 35791c6371 | |||
| 137f70b122 | |||
| dfa33082bb | |||
| b2bc85f6f6 | |||
| 21372c3d4e | |||
| 7ee9aefed7 | |||
| 8c9a59c29e | |||
| 28404f9e87 | |||
| e66e51fa6d | |||
| 2b9842e094 | |||
| f52cba6aff | |||
| 713de872ce | |||
| 1aa421efe5 | |||
| dd42831cba | |||
| f0b662ff58 | |||
| e8ca077f30 | |||
| 2328f8b9b8 | |||
| 680172a084 | |||
| 254b25296b | |||
| 903d0b91fc | |||
| 54ccfcc705 | |||
| dfacd260bb | |||
| 04b83d50a2 | |||
| 1236585693 | |||
| c76008bd6a | |||
| e0aa9ce372 | |||
| ee7701c15b | |||
| 6e1c133e33 | |||
| 969268166e | |||
| 83a156ef47 | |||
| 6136959a6a | |||
| 4f840c211c | |||
| db5967472b | |||
| e65a84f6ea | |||
| b385758e22 | |||
| 526924559f | |||
| 24623d398c | |||
| 56462cf082 | |||
| f384f81253 | |||
| 427b5d61f4 | |||
| e27fba0c06 | |||
| 7a1ec78563 | |||
| ec42be346d | |||
| ccf990a0d7 | |||
| fd77251fdd | |||
| f7d9305786 | |||
| bcda46e3f3 | |||
| 7fc75fc482 | |||
| 45fff07a4c | |||
| 08d54b3d78 | |||
| 735c1b6183 | |||
| bb1039d4c9 | |||
| a21d4c06ae | |||
| 12468f5e9f | |||
| 468e437390 | |||
| d167af4c38 | |||
| 3061a31c92 | |||
| 73e354b7a0 | |||
| 0cc03f912c | |||
| f003e52009 | |||
| 13c4eef637 | |||
| d5b06624fb | |||
| a3a10b62f2 | |||
| 03160719eb | |||
| b276a7fd17 | |||
| 37e2250992 | |||
| bdb8c07bb2 | |||
| 27f9437d31 | |||
| ba301fd800 | |||
| 34cda524c4 | |||
| 53d7ae4e9b | |||
| 7a027be255 | |||
| ece06c26a9 | |||
| 8d28853774 | |||
| fb8b421aac | |||
| b3ecede429 | |||
| b8d7925d0d | |||
| 95e0ed2826 | |||
| 11e11b8767 | |||
| a4c73860a1 | |||
| 241297b6d6 | |||
| 65e24f812f | |||
| fd455be55c | |||
| 7e172bf456 | |||
| a211dc03b3 | |||
| 490d4a504a | |||
| c076a7f7a2 | |||
| 7b23f41fd4 | |||
| f2b9becd7e | |||
| f298cde47e | |||
| 28fa18874b | |||
| e699f9cbf6 | |||
| 31a434b9d7 | |||
| d86910ce94 | |||
| 79ee2fa20a | |||
| 9e0fc44210 | |||
| 35e9c131d6 | |||
| e27a2a96a0 | |||
| 29fa369f71 | |||
| db82a25177 | |||
| b2f77bb050 | |||
| d9e79fd728 | |||
| 52e8d8db54 | |||
| cbf325a6b8 | |||
| 8fd88eee2b | |||
| 98a27bff0d | |||
| 00985cffea | |||
| 0fe1051101 | |||
| fd2477923c | |||
| d4fb372899 | |||
| ce1ec22704 | |||
| 03789c4d97 | |||
| e0ca244623 | |||
| 3c41f108df | |||
| 7069d03ab2 | |||
| 01215f5015 | |||
| 42d00b13df | |||
| 1f21a499d4 | |||
| 274c729fd3 | |||
| 9d24ee8daf | |||
| dd5e0f724a | |||
| 653d73ff07 | |||
| 662d81c801 | |||
| 187602dfaf | |||
| 8707ae23e2 | |||
| 0127763ade | |||
| e7c711996b | |||
| 1e726fe405 | |||
| 24e18a9fbd | |||
| 5f824c5708 | |||
| 57e4b82b66 | |||
| 6dcb77f7b5 | |||
| 42761acf4f | |||
| 01756b6b02 | |||
| b35bfeb1c3 | |||
| af4e8b171c | |||
| 5233e66762 | |||
| 52c246ae19 | |||
| e34f279295 | |||
| ee66d9ccf9 | |||
| 1c19af2c8f | |||
| 10aaab6350 | |||
| 62f060a389 | |||
| 004bed8a7f | |||
| a971233068 | |||
| 67ae845b3c | |||
| 708ea3d0bb | |||
| 49564e5310 | |||
| 604afd52d1 | |||
| 6dac71e618 | |||
| d58bbd5da1 | |||
| 68299c6a5e | |||
| d079634c5e | |||
| 9025c63c43 | |||
| c6ef86029c | |||
| e3deb6e9a5 | |||
| 6eec242a07 | |||
| 28b8bf566b | |||
| 0ce3f6efe0 | |||
| 617f5dfe5e | |||
| 1f12273de1 | |||
| 65483dcc95 | |||
| 32d859eede | |||
| c74f972627 | |||
| 33c78d2bb2 | |||
| 7626ef57b9 | |||
| 07b4cc145b | |||
| 27366197f3 | |||
| d49969ddf3 | |||
| c91a91008c | |||
| 92b4c05090 | |||
| d45ad8f827 | |||
| fa3bd72eea | |||
| d3068125c5 | |||
| e269e936e3 | |||
| 0d2645b3e1 | |||
| 9d0e64a725 | |||
| 9e004a9496 | |||
| 5ac08a44c6 | |||
| c72b1c5893 | |||
| c65bf64756 | |||
| 7201433060 | |||
| 7bbdbcfb6d | |||
| 3f01b222b2 | |||
| c929fb52dd | |||
| 11b407045a | |||
| 811bb7997c | |||
| d932cd9be1 | |||
| 5e5dfff6fe | |||
| 107f692de8 | |||
| a1019413f4 | |||
| b95f5c5bea | |||
| 8c0cb6cce8 | |||
| ee93101b24 | |||
| 7f4c5b86db | |||
| 9bf33e4dcd | |||
| 876c2586b9 | |||
| b9ed139546 | |||
| 85d61de61c | |||
| b8186b5081 | |||
| fb67b9bdad | |||
| 2c983d6c7a | |||
| 7c28d6b869 | |||
| 53035de136 | |||
| d7ca3ea27c | |||
| c12be1f98c | |||
| 90be1c3fa7 | |||
| 727bf7dd8c | |||
| e9425d711d | |||
| 9d42beb2e6 | |||
| ea8d682664 | |||
| 8f7bac4999 | |||
| 3921369f98 | |||
| a243996aca | |||
| 0f612d5021 | |||
| 14567f3459 | |||
| a54154e760 | |||
| ac10fdc50f | |||
| 90c0194598 | |||
| 09d07f76b3 | |||
| d33fe2378c | |||
| 7b9f7d8aba | |||
| 0681b8096c | |||
| d879853e8f | |||
| 0a279cf666 | |||
| c0870d417a | |||
| ac82dc418a | |||
| 144272e735 | |||
| d62aa6221b | |||
| 68abaeab19 | |||
| 00bc094914 | |||
| 84a47a6691 | |||
| 03b53ffde1 | |||
| ef14b18f8e | |||
| 3f90ecfd77 | |||
| a275e4e5b8 | |||
| fd45854000 | |||
| a10626705d | |||
| 0cbc44d8bf | |||
| 5c93b49a6f | |||
| df238fe6a0 | |||
| f1d4713097 | |||
| d0f953218f | |||
| fda9fb563b | |||
| 49b5e1d9bf | |||
| eb84acaf5b | |||
| e9364c7cba | |||
| 08f392cdd3 | |||
| bb597dcf66 | |||
| fec58157ac | |||
| 6be8ffb771 | |||
| 1b19eed195 | |||
| fb41413b76 | |||
| 40c8f2001d | |||
| b41f41589a | |||
| 69a6d26c80 | |||
| 0fef29b6e3 | |||
| f7e2467da1 | |||
| dc44edc1b8 | |||
| ca53d88284 | |||
| 5e46f63e17 | |||
| 43a91e5963 | |||
| 1d5862a39b | |||
| 7c786506e1 | |||
| d03c3980de | |||
| 9bbe9455cf | |||
| 6376b683c7 | |||
| 9dba7cd371 | |||
| 49e252df03 | |||
| 8049db20ff | |||
| ecf5f5d21d | |||
| 12a39450b0 | |||
| c753fc690f | |||
| 35c1b330ec | |||
| a88ae2080c | |||
| e8aa6ab735 | |||
| f2726399dd | |||
| d47e694048 | |||
| 44c57ab05a | |||
| 4a89731025 | |||
| 2b928b4754 | |||
| 923ca6f104 | |||
| 4472ba2b6b | |||
| 7f3dcb3e8a | |||
| a26f2fb00b | |||
| 8ff87c120a | |||
| 4327b5c1b0 | |||
| d6de6de1bb | |||
| 9eecb2f542 | |||
| 54debf855c | |||
| acda53aa1c | |||
| 71921bc9b2 | |||
| bc5c52dc95 | |||
| cf1f8aff77 | |||
| d78f2926ec | |||
| 46916d322e | |||
| 299f849ffa | |||
| bbf06152da | |||
| 8ffae97128 | |||
| d4ac8bc67b | |||
| 8e1637a2cc | |||
| 4e8d92bece | |||
| 4eedeabb51 | |||
| 3009707723 | |||
| 8edcf03715 | |||
| abea8ff8f4 | |||
| 3dd1fe4211 | |||
| d2969d2326 | |||
| e3831c146d | |||
| 218de578e0 | |||
| 87fbda8344 | |||
| e9ab6c10cf | |||
| 1eb592550c | |||
| dc3cfd0d9d | |||
| 2f17f2207a | |||
| d2e1e9a0ac | |||
| c0a3931595 | |||
| 55d1938977 | |||
| 3a99d001ff | |||
| 7033003c36 | |||
| 21c7e699f1 | |||
| 208200a3cc | |||
| ba2cadb479 | |||
| ca47dffa35 | |||
| 548d5603ea | |||
| 6b458676b1 | |||
| 63448f3244 | |||
| 2d88bcb67e | |||
| effc37362a | |||
| 3ba80d11eb | |||
| 900047298e | |||
| c86c85437f | |||
| 18d0e1b365 | |||
| a34b4471b5 | |||
| ae9372bc16 | |||
| 848e9ea241 | |||
| d21d6f6c9e | |||
| b35d0c61b9 | |||
| 5c1c99da0c | |||
| 261778e540 | |||
| 6ee6205e18 | |||
| d47ceb2e8b | |||
| 75beeb7b25 | |||
| 522735b858 | |||
| 4f7d610c96 | |||
| d2cee0be7a | |||
| 20c60fe8f1 | |||
| 877b3c65f9 | |||
| aa9b6280ff | |||
| 2a9ecf46a5 | |||
| cf9a8e184e | |||
| b12fe74d75 | |||
| 8b927a283e |
+2
-2
@@ -19,9 +19,9 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Our automatic versioning scheme generates the following file
|
# Generated files
|
||||||
# NEVER put it in the repository
|
|
||||||
_Version.h
|
_Version.h
|
||||||
|
bdf2u8g
|
||||||
|
|
||||||
#
|
#
|
||||||
# OS
|
# OS
|
||||||
|
|||||||
+281
-361
File diff suppressed because it is too large
Load Diff
+373
-272
File diff suppressed because it is too large
Load Diff
@@ -323,6 +323,8 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1203)
|
|||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1204)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1204)
|
||||||
# abee Scoovo X9H
|
# abee Scoovo X9H
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1205)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1205)
|
||||||
|
# Rambo ThinkerV2
|
||||||
|
else ifeq ($(HARDWARE_MOTHERBOARD),1206)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Other ATmega1280, ATmega2560
|
# Other ATmega1280, ATmega2560
|
||||||
|
|||||||
+7
-7
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Marlin 3D Printer Firmware
|
* Marlin 3D Printer Firmware
|
||||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
*
|
*
|
||||||
* Based on Sprinter and grbl.
|
* Based on Sprinter and grbl.
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
@@ -28,25 +28,25 @@
|
|||||||
/**
|
/**
|
||||||
* Marlin release version identifier
|
* Marlin release version identifier
|
||||||
*/
|
*/
|
||||||
#define SHORT_BUILD_VERSION "2.0.7_SX1"
|
//#define SHORT_BUILD_VERSION "bugfix-2.0.x"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verbose version identifier which should contain a reference to the location
|
* Verbose version identifier which should contain a reference to the location
|
||||||
* from where the binary was downloaded or the source code was compiled.
|
* from where the binary was downloaded or the source code was compiled.
|
||||||
*/
|
*/
|
||||||
#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " TM3D"
|
//#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
|
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
|
||||||
* here we define this default string as the date where the latest release
|
* here we define this default string as the date where the latest release
|
||||||
* version was tagged.
|
* version was tagged.
|
||||||
*/
|
*/
|
||||||
#define STRING_DISTRIBUTION_DATE "2021-01-03"
|
//#define STRING_DISTRIBUTION_DATE "2019-07-10"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
||||||
*/
|
*/
|
||||||
#define MACHINE_NAME "TM3D SX4"
|
//#define MACHINE_NAME "3D Printer"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SOURCE_CODE_URL is the location where users will find the Marlin Source
|
* The SOURCE_CODE_URL is the location where users will find the Marlin Source
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
* has a distinct Github fork— the Source Code URL should just be the main
|
* has a distinct Github fork— the Source Code URL should just be the main
|
||||||
* Marlin repository.
|
* Marlin repository.
|
||||||
*/
|
*/
|
||||||
#define SOURCE_CODE_URL "https://github.com/InsanityAutomation/Marlin/tree/TM_SX4_2.0"
|
//#define SOURCE_CODE_URL "github.com/MarlinFirmware/Marlin"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default generic printer UUID.
|
* Default generic printer UUID.
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
* The WEBSITE_URL is the location where users can get more information such as
|
* The WEBSITE_URL is the location where users can get more information such as
|
||||||
* documentation about a specific Marlin release.
|
* documentation about a specific Marlin release.
|
||||||
*/
|
*/
|
||||||
#define WEBSITE_URL "tinymachines3d.com"
|
//#define WEBSITE_URL "marlinfw.org"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the vendor info the serial USB interface, if changable
|
* Set the vendor info the serial USB interface, if changable
|
||||||
|
|||||||
+67
-57
@@ -29,65 +29,75 @@
|
|||||||
* - http://www.marlinfw.org/tools/u8glib/converter.html
|
* - http://www.marlinfw.org/tools/u8glib/converter.html
|
||||||
* - http://www.digole.com/tools/PicturetoC_Hex_converter.php
|
* - http://www.digole.com/tools/PicturetoC_Hex_converter.php
|
||||||
*/
|
*/
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#define CUSTOM_BOOTSCREEN_TIMEOUT 2500
|
#define CUSTOM_BOOTSCREEN_TIMEOUT 2500
|
||||||
#define CUSTOM_BOOTSCREEN_BMPWIDTH 128
|
#define CUSTOM_BOOTSCREEN_BMPWIDTH 125
|
||||||
#define CUSTOM_BOOTSCREEN_INVERTED
|
//#define CUSTOM_BOOTSCREEN_INVERTED
|
||||||
|
|
||||||
const unsigned char custom_start_bmp[] PROGMEM = {
|
const unsigned char custom_start_bmp[] PROGMEM = {
|
||||||
B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ..............................................................##................................................................
|
||||||
B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ..............................................................##.##.............................................................
|
||||||
B11111101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ................................................................#...#...........................................................
|
||||||
B11111110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ................................................................###..###........................................................
|
||||||
B11111100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x71,0x80,0x00,0x00,0x00,0x00,0x00,0x00, // .................................................................###...##.......................................................
|
||||||
B11111110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x40,0x00,0x00,0x00,0x00,0x00,0x00, // ..................................................................##.....#......................................................
|
||||||
B11111100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x20,0x00,0x00,0x00,0x00,0x00,0x00, // ..................................................................####....#.....................................................
|
||||||
B11111110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x20,0x00,0x00,0x00,0x00,0x00,0x00, // ................................................................########..#.....................................................
|
||||||
B11111100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x01,0xF8,0x00,0x87,0xF8,0x00,0x00,0x00,0x00,0x00,0x00, // ...............................................######...........#....########...................................................
|
||||||
B11111110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
|
0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x00,0x83,0xE0,0x00,0x00,0x00,0x00,0x00,0x00, // ..............................................##....##..........#.....#####.....................................................
|
||||||
B11111100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
|
0x00,0x00,0x00,0x00,0x00,0x06,0x0C,0x00,0x81,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, // .............................................##.....##..........#......###......................................................
|
||||||
B11111110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
|
0x00,0x00,0x00,0x00,0x00,0x0C,0x06,0x00,0x80,0xE3,0x00,0x00,0x00,0x00,0x00,0x00, // ............................................##.......##.........#.......###...##................................................
|
||||||
B11111100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000000,B00000001,B11110000,B00111111,
|
0x00,0x00,0x00,0x00,0x00,0x18,0x06,0x00,0x80,0x6F,0x80,0x00,0x00,0x00,0x00,0x00, // ...........................................##........##.........#........##.#####...............................................
|
||||||
B11111110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000000,B00000010,B00001000,B00011111,
|
0x00,0x00,0x00,0x00,0x1C,0x38,0x02,0x00,0x80,0x3C,0xC0,0x00,0x00,0x00,0x00,0x00, // ...................................###....###.........#.........#.........####..##..............................................
|
||||||
B11111100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000000,B00000101,B00000100,B00111111,
|
0x00,0x00,0x00,0x00,0x1F,0x30,0x03,0x00,0xC0,0x3C,0x60,0x00,0x00,0x00,0x00,0x00, // ...................................#####..##..........##........##........####...##.............................................
|
||||||
B11111110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000000,B00001010,B00000010,B00011111,
|
0x00,0x00,0x00,0x00,0x77,0xB0,0x02,0xFF,0x60,0x3C,0x30,0x00,0x00,0x00,0x00,0x00, // .................................###.####.##..........#.########.##.......####....##............................................
|
||||||
B11111100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000000,B00010101,B00000001,B00111111,
|
0x00,0x00,0x00,0x00,0xE0,0xF8,0x06,0xFF,0xB0,0x3C,0x18,0x00,0x00,0x00,0x00,0x00, // ................................###.....#####........##.#########.##......####.....##...........................................
|
||||||
B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
|
0x00,0x00,0x00,0x00,0xC0,0xD8,0x0D,0x81,0x98,0x1C,0x08,0x00,0x00,0x00,0x00,0x00, // ................................##......##.##.......##.##......##..##......###......#...........................................
|
||||||
B11111100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000000,B00010100,B00000001,B00111111,
|
0x00,0x00,0x00,0x03,0x80,0xD8,0x09,0x80,0xDC,0xFC,0x08,0x00,0x00,0x00,0x00,0x00, // ..............................###.......##.##.......#..##.......##.###..######......#...........................................
|
||||||
B11111110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
|
0x00,0x00,0x00,0x02,0x00,0xD8,0x1B,0x00,0x6F,0xE4,0x0C,0x00,0x00,0x00,0x00,0x00, // ..............................#.........##.##......##.##.........##.#######..#......##..........................................
|
||||||
B11111100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B00010101,B00000001,B00111111,
|
0x00,0x00,0x00,0x02,0x00,0xDF,0xFB,0x00,0x37,0x06,0x0C,0x00,0x00,0x00,0x00,0x00, // ..............................#.........##.##########.##..........##.###.....##.....##..........................................
|
||||||
B11111110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101010,B00001010,B00000010,B00011111,
|
0x00,0x00,0x00,0x06,0x00,0xE7,0xF6,0x00,0x18,0x03,0x04,0x00,0x00,0x00,0x00,0x00, // .............................##.........###..#######.##............##.........##.....#..........................................
|
||||||
B11111100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010001,B00000101,B00000100,B00111111,
|
0x00,0x00,0x00,0x06,0x00,0xE0,0x0E,0x00,0x18,0x0F,0x04,0x00,0x00,0x00,0x00,0x00, // .............................##.........###.........###............##.......####.....#..........................................
|
||||||
B11111110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100001,B00000010,B10001000,B00011111,
|
0x00,0x00,0x00,0x06,0x00,0xC0,0x2E,0x00,0x1B,0xFF,0xC6,0x00,0x00,0x00,0x00,0x00, // .............................##.........##........#.###............##.############...##.........................................
|
||||||
B11111100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010001,B00000001,B11110000,B00111111,
|
0x3F,0xFC,0x1F,0xF6,0x7D,0x81,0xE6,0x00,0x1B,0xC7,0xC6,0x00,0x00,0x00,0x00,0x00, // ..############.....#########.##..#####.##......####..##............##.####...#####...##.........................................
|
||||||
B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101010,B00000000,B00000000,B00011111,
|
0x7F,0xFE,0x3F,0xFF,0x1F,0x8F,0xC3,0xFF,0xFF,0xFF,0xFC,0x1F,0xFF,0x38,0x03,0xC0, // .##############...##############...######...######....################################.....#############..###.........####......
|
||||||
B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00000000,B00000000,B00111111,
|
0xFF,0xFF,0xFF,0xFF,0x8F,0x1F,0xC7,0xFF,0xFF,0xFF,0xF8,0xFF,0xFF,0x3C,0x03,0xE0, // #################################...####...#######...################################...################..####........#####.....
|
||||||
B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
|
0x10,0x0F,0xF0,0x0F,0x8F,0xFF,0x83,0xFF,0xF7,0xFF,0xF8,0xFF,0xFC,0x3C,0x03,0xE0, // ...#........########........#####...#############.....##############.################...##############....####........#####.....
|
||||||
B11111100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
|
0x00,0x0F,0xF0,0x07,0xFF,0xFF,0x01,0x9E,0x27,0xFC,0xC2,0xF8,0x00,0x3E,0x03,0xE0, // ............########.........###################.......##..####...#..#########..##....#.#####.............#####.......#####.....
|
||||||
B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
|
0x0F,0xFF,0xF0,0x03,0xDF,0xFE,0x01,0xCE,0x6C,0xFC,0x47,0xF8,0x00,0x3F,0xFF,0xE0, // ....################..........####.############........###..###..##.##..######...#...########.............#################.....
|
||||||
B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
|
0x1F,0xFF,0xF0,0x03,0xC3,0xFC,0x00,0xFF,0xCC,0xFF,0xFF,0xF0,0x00,0x3F,0xFF,0xE0, // ...#################..........####....########..........##########..##..####################..............#################.....
|
||||||
B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
|
0x1F,0xFF,0xF0,0x03,0xC3,0xFC,0x00,0x0E,0x1C,0xFF,0xF9,0xE0,0x00,0x3F,0xFF,0xE0, // ...#################..........####....########..............###....###..#############..####...............#################.....
|
||||||
B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
|
0x00,0x0F,0xF0,0x0F,0xC7,0xFC,0x00,0x0E,0x1C,0xFF,0xF1,0xE0,0x00,0x3F,0xFF,0xE0, // ............########........######...#########..............###....###..############...####...............#################.....
|
||||||
B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
|
0x00,0x0F,0xF8,0x0F,0x87,0xFE,0x00,0x0E,0x0C,0xF8,0xF0,0xF0,0x00,0x3C,0x03,0xE0, // ............#########.......#####....##########.............###.....##..#####...####....####..............####........#####.....
|
||||||
B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
|
0x7F,0xFF,0xFF,0xFF,0xBF,0x8F,0x00,0x3F,0xE6,0xF8,0xE0,0xFC,0x00,0x3C,0x03,0xE0, // .################################.#######...####..........#########..##.#####...###.....######............####........#####.....
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
|
0x7F,0xFF,0xFF,0xFF,0xFF,0x07,0xC0,0xFF,0xE7,0xFF,0xFC,0xFF,0xFF,0x3C,0x03,0xE0, // .#######################################.....#####......###########..#################..################..####........#####.....
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
|
0xFF,0xFF,0xFF,0xFF,0xFE,0x03,0xE0,0x8E,0x33,0xFF,0xFC,0x1F,0xFF,0x3C,0x03,0xE0, // #######################################.......#####.....#...###...##..################.....#############..####........#####.....
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
|
0x7F,0xFC,0x3F,0xF0,0x3C,0x01,0xF1,0x9E,0x31,0xFF,0xF9,0x0F,0xFE,0x3C,0x03,0xC0, // .#############....##########......####.........#####...##..####...##...##############..#....###########...####........####......
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x19,0xFF,0xC1,0x00,0x00,0x00,0x00,0x00, // ......................................................##...........##..###########.....#........................................
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x0C,0xE0,0xC1,0x00,0x00,0x00,0x00,0x00, // ......................................................##............##..###.....##.....#........................................
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x0C,0x00,0x42,0x00,0x00,0x00,0x00,0x00, // .....................................................##.............##...........#....#.........................................
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x01,0x62,0x00,0x00,0x00,0x00,0x00, // .....................................................##..............##........#.##...#.........................................
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x06,0x3F,0x62,0x00,0x00,0x00,0x00,0x00, // ....................................................##...............##...######.##...#.........................................
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x38,0x0E,0x00,0x0D,0xFD,0xEE,0x00,0x00,0x00,0x00,0x00, // ..........................................###.......###.............##.#######.####.###.........................................
|
||||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00,0x00,0x7F,0xE6,0x00,0x19,0x81,0xFC,0x00,0x00,0x00,0x00,0x00, // .........................................##########..##............##..##......#######..........................................
|
||||||
B11100000,B00101110,B11111011,B01111101,B11111011,B11111011,B11001111,B11000001,B11011111,B10111011,B00111110,B11000000,B11100001,B11111110,B00111100,B00011111,
|
0x00,0x00,0x00,0x00,0x00,0xEF,0xF7,0x00,0x1B,0x01,0xF0,0x00,0x00,0x00,0x00,0x00, // ........................................###.########.###...........##.##.......#####............................................
|
||||||
B11111101,B11101110,B01111011,B00111001,B11111001,B11110011,B11001111,B10011110,B11011111,B10111011,B00111110,B11011111,B11011110,B11111100,B11011101,B11100111,
|
0x00,0x00,0x00,0x00,0x00,0xC0,0x33,0x00,0x33,0x01,0xC8,0x00,0x00,0x00,0x00,0x00, // ........................................##........##..##..........##..##.......###..#...........................................
|
||||||
B11111101,B11101110,B00111011,B10111011,B11111001,B11101011,B11010111,B10111111,B01011111,B10111011,B01011110,B11011111,B11011110,B11111101,B11101101,B11110111,
|
0x00,0x00,0x00,0x00,0x00,0x80,0x1B,0x00,0x36,0x01,0x98,0x00,0x00,0x00,0x00,0x00, // ........................................#..........##.##..........##.##........##..##...........................................
|
||||||
B11111101,B11101110,B10111011,B11010011,B11111010,B11101011,B10110111,B00111111,B11011111,B10111011,B01001110,B11011111,B11011111,B11111111,B11001101,B11110011,
|
0x00,0x00,0x00,0x00,0x01,0x80,0x0D,0xFF,0xEC,0x01,0xF0,0x00,0x00,0x00,0x00,0x00, // .......................................##...........##.############.##.........#####............................................
|
||||||
B11111101,B11101110,B11011011,B11000111,B11111010,B11101011,B10111011,B01111111,B11000000,B00111011,B01101110,B11000000,B11100011,B11111111,B00011101,B11110011,
|
0x00,0x00,0x00,0x00,0x01,0x00,0x0E,0xFF,0xD8,0x01,0xE0,0x00,0x00,0x00,0x00,0x00, // .......................................#............###.##########.##..........####.............................................
|
||||||
B11111101,B11101110,B11001011,B11101111,B11111010,B11011011,B10111011,B01111111,B11011111,B10111011,B01100110,B11011111,B11111000,B11111111,B11001101,B11110011,
|
0x00,0x00,0x00,0x01,0xF1,0x80,0x06,0x60,0x38,0x07,0xA0,0x00,0x00,0x00,0x00,0x00, // ...............................#####...##............##..##.......###........####.#.............................................
|
||||||
B11111101,B11101110,B11101011,B11101111,B11111011,B01011011,B00000011,B00111111,B01011111,B10111011,B01110110,B11011111,B11111110,B01111111,B11101101,B11110011,
|
0x00,0x00,0x00,0x01,0xFD,0x80,0x03,0x00,0x18,0x05,0x40,0x00,0x00,0x00,0x00,0x00, // ...............................#######.##.............##...........##........#.#.#..............................................
|
||||||
B11111101,B11101110,B11110011,B11101111,B11111011,B01011011,B01111001,B10111110,B11011111,B10111011,B01111010,B11011111,B11011110,B01111101,B11101101,B11110111,
|
0x00,0x00,0x00,0x01,0x8F,0xC0,0x06,0xFF,0xDC,0x0A,0x80,0x00,0x00,0x00,0x00,0x00, // ...............................##...######...........##.##########.###......#.#.#...............................................
|
||||||
B11111101,B11101110,B11110011,B11101111,B11111011,B10111010,B11111101,B10011110,B11011111,B10111011,B01111100,B11011111,B11011110,B11111101,B11001101,B11100111,
|
0x00,0x00,0x00,0x00,0x81,0xE0,0x0C,0xFF,0xCC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00, // ................................#......####.........##..##########..##.....#####................................................
|
||||||
B11111101,B11101110,B11111011,B11101111,B11111011,B10111010,B11111101,B11000001,B11011111,B10111011,B01111110,B11000000,B11100000,B11111110,B00011100,B00011111
|
0x00,0x00,0x00,0x00,0x81,0xF0,0x0D,0x80,0x6C,0xFE,0x00,0x00,0x00,0x00,0x00,0x00, // ................................#......#####........##.##........##.##..#######.................................................
|
||||||
|
0x00,0x00,0x00,0x00,0x40,0xFE,0x1B,0x00,0x67,0x8C,0x00,0x00,0x00,0x00,0x00,0x00, // .................................#......#######....##.##.........##..####...##..................................................
|
||||||
|
0x00,0x00,0x00,0x00,0x20,0x7F,0xF6,0x00,0x20,0x18,0x00,0x00,0x00,0x00,0x00,0x00, // ..................................#......###########.##...........#........##...................................................
|
||||||
|
0x00,0x00,0x00,0x00,0x10,0x30,0x6E,0x00,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, // ...................................#......##.....##.###...........##########....................................................
|
||||||
|
0x00,0x00,0x00,0x00,0x04,0x30,0x0E,0x00,0xFF,0xA0,0x00,0x00,0x00,0x00,0x00,0x00, // .....................................#....##........###.........#########.#.....................................................
|
||||||
|
0x00,0x00,0x00,0x00,0x03,0x30,0x06,0x00,0xE1,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ......................................##..##.........##.........###....#........................................................
|
||||||
|
0x00,0x00,0x00,0x00,0x01,0xF0,0x03,0x03,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // .......................................#####..........##......#####...#.........................................................
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // .......................................................##########...#...........................................................
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ..............................................................#...##............................................................
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 // .............................................................###................................................................
|
||||||
};
|
};
|
||||||
|
|||||||
+34
-36
@@ -33,42 +33,40 @@
|
|||||||
//
|
//
|
||||||
// Status Screen Logo bitmap
|
// Status Screen Logo bitmap
|
||||||
//
|
//
|
||||||
#define STATUS_LOGO_Y 3
|
#define STATUS_LOGO_Y 1
|
||||||
#define STATUS_LOGO_WIDTH 24
|
#define STATUS_LOGO_WIDTH 32
|
||||||
|
|
||||||
const unsigned char status_logo_bmp[] PROGMEM = {
|
const unsigned char status_logo_bmp[] PROGMEM = {
|
||||||
B11111111,B11111111,B11111111,
|
0x00,0x00,0x00,0x00, // ................................
|
||||||
B10000000,B00000000,B00000001,
|
0x00,0x00,0x00,0x00, // ................................
|
||||||
B10001110,B00000000,B11100001,
|
0x00,0x00,0x00,0x00, // ................................
|
||||||
B10011111,B00000001,B11110001,
|
0x00,0x00,0x10,0x00, // ...................#............
|
||||||
B10010011,B10000001,B00111001,
|
0x00,0x00,0x06,0x00, // .....................##.........
|
||||||
B10011111,B10000001,B11111001,
|
0x00,0x00,0x00,0x00, // ................................
|
||||||
B10011111,B10000001,B11111001,
|
0x01,0x00,0x00,0x00, // .......#........................
|
||||||
B10011111,B10111001,B11111001,
|
0x08,0x00,0x01,0x00, // ....#..................#........
|
||||||
B10001111,B00101000,B11110001,
|
0x01,0x00,0x41,0x00, // .......#.........#.....#........
|
||||||
B10000000,B00111000,B00000001,
|
0x01,0x00,0x02,0x00, // .......#..............#.........
|
||||||
B10000000,B00000000,B00000001,
|
0x00,0xE0,0x00,0x00, // ........###.....................
|
||||||
B10011111,B11111111,B11111001,
|
0x80,0x08,0x10,0x80, // #...........#......#....#.......
|
||||||
B10010001,B01110100,B10011001,
|
0x04,0x00,0x00,0x40, // .....#...................#......
|
||||||
B10011011,B00000110,B10101001,
|
0x08,0x00,0x08,0x00, // ....#...............#...........
|
||||||
B10011011,B01010100,B10101001,
|
0x10,0x04,0x00,0x00, // ...#.........#..................
|
||||||
B10011011,B01010110,B10101001,
|
0x00,0x00,0x00,0x30, // ..........................##....
|
||||||
B10011011,B01010100,B10011001,
|
0x00,0x00,0x00,0x20, // ..........................#.....
|
||||||
B10011111,B11111111,B11111001,
|
0x00,0x01,0xE8,0x20, // ...............####.#.....#.....
|
||||||
B11111111,B11111111,B11111111
|
0x00,0x00,0x00,0x60, // .........................##.....
|
||||||
|
0x00,0x00,0x02,0x00, // ......................#.........
|
||||||
|
0x00,0x08,0x00,0x00, // ............#...................
|
||||||
|
0x00,0x00,0x01,0x20, // .......................#..#.....
|
||||||
|
0x02,0xE8,0x10,0x60, // ......#.###.#......#.....##.....
|
||||||
|
0x00,0x00,0x00,0x40, // .........................#......
|
||||||
|
0x00,0x03,0xC0,0x60, // ..............####.......##.....
|
||||||
|
0x64,0x00,0x10,0x00, // .##..#.............#............
|
||||||
|
0x04,0x03,0xC0,0x00, // .....#........####..............
|
||||||
|
0x02,0x00,0x20,0x00, // ......#...........#.............
|
||||||
|
0x00,0x28,0x00,0x00, // ..........#.#...................
|
||||||
|
0x00,0x08,0x20,0x00, // ............#.....#.............
|
||||||
|
0x00,0x00,0x40,0x00, // .................#..............
|
||||||
|
0x00,0x00,0x00,0x00 // ................................
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
|
||||||
// Use default bitmaps
|
|
||||||
//
|
|
||||||
#define STATUS_HOTEND_ANIM
|
|
||||||
#define STATUS_BED_ANIM
|
|
||||||
#if HOTENDS < 2
|
|
||||||
#define STATUS_LOGO_X 8
|
|
||||||
#define STATUS_HEATERS_X 40
|
|
||||||
#define STATUS_BED_X 72
|
|
||||||
#else
|
|
||||||
#define STATUS_LOGO_X 0
|
|
||||||
#define STATUS_HEATERS_X 32
|
|
||||||
#define STATUS_BED_X 80
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -24,6 +24,13 @@
|
|||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
#include "HAL.h"
|
#include "HAL.h"
|
||||||
|
|
||||||
|
#ifdef USBCON
|
||||||
|
DefaultSerial1 MSerial0(false, Serial);
|
||||||
|
#ifdef BLUETOOTH
|
||||||
|
BTSerial btSerial(false, bluetoothSerial);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Public Variables
|
// Public Variables
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|||||||
@@ -82,21 +82,36 @@ typedef int8_t pin_t;
|
|||||||
|
|
||||||
// Serial ports
|
// Serial ports
|
||||||
#ifdef USBCON
|
#ifdef USBCON
|
||||||
#define MYSERIAL0 TERN(BLUETOOTH, bluetoothSerial, Serial)
|
#include "../../core/serial_hook.h"
|
||||||
|
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||||
|
extern DefaultSerial1 MSerial0;
|
||||||
|
#ifdef BLUETOOTH
|
||||||
|
typedef ForwardSerial1Class< decltype(bluetoothSerial) > BTSerial;
|
||||||
|
extern BTSerial btSerial;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0)
|
||||||
#else
|
#else
|
||||||
#if !WITHIN(SERIAL_PORT, -1, 3)
|
#if !WITHIN(SERIAL_PORT, -1, 3)
|
||||||
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#define MYSERIAL0 customizedSerial1
|
#define MYSERIAL1 customizedSerial1
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if !WITHIN(SERIAL_PORT_2, -1, 3)
|
#if !WITHIN(SERIAL_PORT_2, -1, 3)
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#define MYSERIAL1 customizedSerial2
|
#define MYSERIAL2 customizedSerial2
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MMU2_SERIAL_PORT
|
||||||
|
#if !WITHIN(MMU2_SERIAL_PORT, -1, 3)
|
||||||
|
#error "MMU2_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
#define MMU2_SERIAL mmuSerial
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LCD_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if !WITHIN(LCD_SERIAL_PORT, -1, 3)
|
#if !WITHIN(LCD_SERIAL_PORT, -1, 3)
|
||||||
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ void MarlinSerial<Cfg>::flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::write(const uint8_t c) {
|
size_t MarlinSerial<Cfg>::write(const uint8_t c) {
|
||||||
if (Cfg::TX_SIZE == 0) {
|
if (Cfg::TX_SIZE == 0) {
|
||||||
|
|
||||||
_written = true;
|
_written = true;
|
||||||
@@ -480,7 +480,7 @@ void MarlinSerial<Cfg>::write(const uint8_t c) {
|
|||||||
// location". This makes sure flush() won't return until the bytes
|
// location". This makes sure flush() won't return until the bytes
|
||||||
// actually got written
|
// actually got written
|
||||||
B_TXC = 1;
|
B_TXC = 1;
|
||||||
return;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1);
|
const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1);
|
||||||
@@ -510,6 +510,7 @@ void MarlinSerial<Cfg>::write(const uint8_t c) {
|
|||||||
// Enable TX ISR - Non atomic, but it will eventually enable TX ISR
|
// Enable TX ISR - Non atomic, but it will eventually enable TX ISR
|
||||||
B_UDRIE = 1;
|
B_UDRIE = 1;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
@@ -556,161 +557,6 @@ void MarlinSerial<Cfg>::flushTX() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Imports from print.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(char c, int base) {
|
|
||||||
print((long)c, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(unsigned char b, int base) {
|
|
||||||
print((unsigned long)b, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(int n, int base) {
|
|
||||||
print((long)n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(unsigned int n, int base) {
|
|
||||||
print((unsigned long)n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(long n, int base) {
|
|
||||||
if (base == 0) write(n);
|
|
||||||
else if (base == 10) {
|
|
||||||
if (n < 0) { print('-'); n = -n; }
|
|
||||||
printNumber(n, 10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printNumber(n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(unsigned long n, int base) {
|
|
||||||
if (base == 0) write(n);
|
|
||||||
else printNumber(n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(double n, int digits) {
|
|
||||||
printFloat(n, digits);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println() {
|
|
||||||
print('\r');
|
|
||||||
print('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(const String& s) {
|
|
||||||
print(s);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(const char c[]) {
|
|
||||||
print(c);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(char c, int base) {
|
|
||||||
print(c, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(unsigned char b, int base) {
|
|
||||||
print(b, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(int n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(unsigned int n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(long n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(unsigned long n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(double n, int digits) {
|
|
||||||
print(n, digits);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private Methods
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::printNumber(unsigned long n, uint8_t base) {
|
|
||||||
if (n) {
|
|
||||||
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
|
|
||||||
int8_t i = 0;
|
|
||||||
while (n) {
|
|
||||||
buf[i++] = n % base;
|
|
||||||
n /= base;
|
|
||||||
}
|
|
||||||
while (i--)
|
|
||||||
print((char)(buf[i] + (buf[i] < 10 ? '0' : 'A' - 10)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
print('0');
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::printFloat(double number, uint8_t digits) {
|
|
||||||
// Handle negative numbers
|
|
||||||
if (number < 0.0) {
|
|
||||||
print('-');
|
|
||||||
number = -number;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
|
||||||
double rounding = 0.5;
|
|
||||||
LOOP_L_N(i, digits) rounding *= 0.1;
|
|
||||||
number += rounding;
|
|
||||||
|
|
||||||
// Extract the integer part of the number and print it
|
|
||||||
unsigned long int_part = (unsigned long)number;
|
|
||||||
double remainder = number - (double)int_part;
|
|
||||||
print(int_part);
|
|
||||||
|
|
||||||
// Print the decimal point, but only if there are digits beyond
|
|
||||||
if (digits) {
|
|
||||||
print('.');
|
|
||||||
// Extract digits from the remainder one at a time
|
|
||||||
while (digits--) {
|
|
||||||
remainder *= 10.0;
|
|
||||||
int toPrint = int(remainder);
|
|
||||||
print(toPrint);
|
|
||||||
remainder -= toPrint;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hookup ISR handlers
|
// Hookup ISR handlers
|
||||||
ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _RX_vect)) {
|
ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _RX_vect)) {
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>::store_rxd_char();
|
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>::store_rxd_char();
|
||||||
@@ -720,11 +566,9 @@ ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _UDRE_vect)) {
|
|||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>::_tx_udr_empty_irq();
|
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>::_tx_udr_empty_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preinstantiate
|
// Because of the template definition above, it's required to instantiate the template to have all methods generated
|
||||||
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>;
|
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >;
|
||||||
|
MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
|
||||||
// Instantiate
|
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
|
|
||||||
@@ -737,12 +581,8 @@ MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
|||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>::_tx_udr_empty_irq();
|
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>::_tx_udr_empty_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preinstantiate
|
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> >;
|
||||||
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>;
|
MSerialT2 customizedSerial2(MSerialT2::HasEmergencyParser);
|
||||||
|
|
||||||
// Instantiate
|
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MMU2_SERIAL_PORT
|
#ifdef MMU2_SERIAL_PORT
|
||||||
@@ -755,12 +595,8 @@ MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
|||||||
MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>>::_tx_udr_empty_irq();
|
MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>>::_tx_udr_empty_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preinstantiate
|
template class MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> >;
|
||||||
template class MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>>;
|
MSerialT3 mmuSerial(MSerialT3::HasEmergencyParser);
|
||||||
|
|
||||||
// Instantiate
|
|
||||||
MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>> mmuSerial;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LCD_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
@@ -773,11 +609,8 @@ MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
|||||||
MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>>::_tx_udr_empty_irq();
|
MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>>::_tx_udr_empty_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preinstantiate
|
template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >;
|
||||||
template class MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>>;
|
MSerialT4 lcdSerial(MSerialT4::HasEmergencyParser);
|
||||||
|
|
||||||
// Instantiate
|
|
||||||
MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>> lcdSerial;
|
|
||||||
|
|
||||||
#if HAS_DGUS_LCD
|
#if HAS_DGUS_LCD
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
@@ -796,7 +629,7 @@ MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
|||||||
|
|
||||||
// For AT90USB targets use the UART for BT interfacing
|
// For AT90USB targets use the UART for BT interfacing
|
||||||
#if defined(USBCON) && ENABLED(BLUETOOTH)
|
#if defined(USBCON) && ENABLED(BLUETOOTH)
|
||||||
HardwareSerial bluetoothSerial;
|
MSerialT5 bluetoothSerial(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // __AVR__
|
#endif // __AVR__
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <WString.h>
|
#include <WString.h>
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
#include "../../core/serial_hook.h"
|
||||||
|
|
||||||
#ifndef SERIAL_PORT
|
#ifndef SERIAL_PORT
|
||||||
#define SERIAL_PORT 0
|
#define SERIAL_PORT 0
|
||||||
@@ -135,10 +136,6 @@
|
|||||||
UART_DECL(3);
|
UART_DECL(3);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEC 10
|
|
||||||
#define HEX 16
|
|
||||||
#define OCT 8
|
|
||||||
#define BIN 2
|
|
||||||
#define BYTE 0
|
#define BYTE 0
|
||||||
|
|
||||||
// Templated type selector
|
// Templated type selector
|
||||||
@@ -202,60 +199,30 @@
|
|||||||
static FORCE_INLINE void atomic_set_rx_tail(ring_buffer_pos_t value);
|
static FORCE_INLINE void atomic_set_rx_tail(ring_buffer_pos_t value);
|
||||||
static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_tail();
|
static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_tail();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FORCE_INLINE static void store_rxd_char();
|
FORCE_INLINE static void store_rxd_char();
|
||||||
FORCE_INLINE static void _tx_udr_empty_irq();
|
FORCE_INLINE static void _tx_udr_empty_irq();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MarlinSerial() {};
|
static void begin(const long);
|
||||||
static void begin(const long);
|
static void end();
|
||||||
static void end();
|
static int peek();
|
||||||
static int peek();
|
static int read();
|
||||||
static int read();
|
static void flush();
|
||||||
static void flush();
|
static ring_buffer_pos_t available();
|
||||||
static ring_buffer_pos_t available();
|
static size_t write(const uint8_t c);
|
||||||
static void write(const uint8_t c);
|
static void flushTX();
|
||||||
static void flushTX();
|
#if HAS_DGUS_LCD
|
||||||
#if HAS_DGUS_LCD
|
static ring_buffer_pos_t get_tx_buffer_free();
|
||||||
static ring_buffer_pos_t get_tx_buffer_free();
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
|
enum { HasEmergencyParser = Cfg::EMERGENCYPARSER };
|
||||||
|
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
|
||||||
|
|
||||||
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
|
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
|
||||||
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
|
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
|
||||||
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
|
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
|
||||||
FORCE_INLINE static ring_buffer_pos_t rxMaxEnqueued() { return Cfg::MAX_RX_QUEUED ? rx_max_enqueued : 0; }
|
FORCE_INLINE static ring_buffer_pos_t rxMaxEnqueued() { return Cfg::MAX_RX_QUEUED ? rx_max_enqueued : 0; }
|
||||||
|
|
||||||
FORCE_INLINE static void write(const char* str) { while (*str) write(*str++); }
|
|
||||||
FORCE_INLINE static void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
|
|
||||||
FORCE_INLINE static void print(const String& s) { for (int i = 0; i < (int)s.length(); i++) write(s[i]); }
|
|
||||||
FORCE_INLINE static void print(const char* str) { write(str); }
|
|
||||||
|
|
||||||
static void print(char, int = BYTE);
|
|
||||||
static void print(unsigned char, int = BYTE);
|
|
||||||
static void print(int, int = DEC);
|
|
||||||
static void print(unsigned int, int = DEC);
|
|
||||||
static void print(long, int = DEC);
|
|
||||||
static void print(unsigned long, int = DEC);
|
|
||||||
static void print(double, int = 2);
|
|
||||||
|
|
||||||
static void println(const String& s);
|
|
||||||
static void println(const char[]);
|
|
||||||
static void println(char, int = BYTE);
|
|
||||||
static void println(unsigned char, int = BYTE);
|
|
||||||
static void println(int, int = DEC);
|
|
||||||
static void println(unsigned int, int = DEC);
|
|
||||||
static void println(long, int = DEC);
|
|
||||||
static void println(unsigned long, int = DEC);
|
|
||||||
static void println(double, int = 2);
|
|
||||||
static void println();
|
|
||||||
operator bool() { return true; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void printNumber(unsigned long, const uint8_t);
|
|
||||||
static void printFloat(double, uint8_t);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <uint8_t serial>
|
template <uint8_t serial>
|
||||||
@@ -270,12 +237,13 @@
|
|||||||
static constexpr bool RX_FRAMING_ERRORS = ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS);
|
static constexpr bool RX_FRAMING_ERRORS = ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS);
|
||||||
static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
|
static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
|
||||||
};
|
};
|
||||||
extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
|
||||||
|
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
|
||||||
|
extern MSerialT customizedSerial1;
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
|
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2;
|
||||||
extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
|
extern MSerialT2 customizedSerial2;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // !USBCON
|
#endif // !USBCON
|
||||||
@@ -284,49 +252,41 @@
|
|||||||
template <uint8_t serial>
|
template <uint8_t serial>
|
||||||
struct MMU2SerialCfg {
|
struct MMU2SerialCfg {
|
||||||
static constexpr int PORT = serial;
|
static constexpr int PORT = serial;
|
||||||
|
static constexpr unsigned int RX_SIZE = 32;
|
||||||
|
static constexpr unsigned int TX_SIZE = 32;
|
||||||
static constexpr bool XONOFF = false;
|
static constexpr bool XONOFF = false;
|
||||||
static constexpr bool EMERGENCYPARSER = false;
|
static constexpr bool EMERGENCYPARSER = false;
|
||||||
static constexpr bool DROPPED_RX = false;
|
static constexpr bool DROPPED_RX = false;
|
||||||
static constexpr bool RX_FRAMING_ERRORS = false;
|
static constexpr bool RX_FRAMING_ERRORS = false;
|
||||||
static constexpr bool MAX_RX_QUEUED = false;
|
static constexpr bool MAX_RX_QUEUED = false;
|
||||||
static constexpr unsigned int RX_SIZE = 32;
|
|
||||||
static constexpr unsigned int TX_SIZE = 32;
|
|
||||||
static constexpr bool RX_OVERRUNS = false;
|
static constexpr bool RX_OVERRUNS = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>> mmuSerial;
|
typedef Serial1Class< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialT3;
|
||||||
|
extern MSerialT3 mmuSerial;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LCD_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
|
|
||||||
template <uint8_t serial>
|
template <uint8_t serial>
|
||||||
struct LCDSerialCfg {
|
struct LCDSerialCfg {
|
||||||
static constexpr int PORT = serial;
|
static constexpr int PORT = serial;
|
||||||
static constexpr bool XONOFF = false;
|
static constexpr unsigned int RX_SIZE = TERN(HAS_DGUS_LCD, DGUS_RX_BUFFER_SIZE, 64);
|
||||||
static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
|
static constexpr unsigned int TX_SIZE = TERN(HAS_DGUS_LCD, DGUS_TX_BUFFER_SIZE, 128);
|
||||||
static constexpr bool DROPPED_RX = false;
|
static constexpr bool XONOFF = false;
|
||||||
static constexpr bool RX_FRAMING_ERRORS = false;
|
static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
|
||||||
static constexpr bool MAX_RX_QUEUED = false;
|
static constexpr bool DROPPED_RX = false;
|
||||||
#if HAS_DGUS_LCD
|
static constexpr bool RX_FRAMING_ERRORS = false;
|
||||||
static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
|
static constexpr bool MAX_RX_QUEUED = false;
|
||||||
static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
|
static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, SERIAL_STATS_RX_BUFFER_OVERRUNS);
|
||||||
static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
|
|
||||||
#elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
|
|
||||||
static constexpr unsigned int RX_SIZE = 64;
|
|
||||||
static constexpr unsigned int TX_SIZE = 128;
|
|
||||||
static constexpr bool RX_OVERRUNS = false;
|
|
||||||
#else
|
|
||||||
static constexpr unsigned int RX_SIZE = 64;
|
|
||||||
static constexpr unsigned int TX_SIZE = 128;
|
|
||||||
static constexpr bool RX_OVERRUNS = false
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>> lcdSerial;
|
typedef Serial1Class< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialT4;
|
||||||
|
extern MSerialT4 lcdSerial;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use the UART for Bluetooth in AT90USB configurations
|
// Use the UART for Bluetooth in AT90USB configurations
|
||||||
#if defined(USBCON) && ENABLED(BLUETOOTH)
|
#if defined(USBCON) && ENABLED(BLUETOOTH)
|
||||||
extern HardwareSerial bluetoothSerial;
|
typedef Serial1Class<HardwareSerial> MSerialT5;
|
||||||
|
extern MSerialT5 bluetoothSerial;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ enum ClockSource2 : char {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Determine which harware PWMs are already in use
|
// Determine which harware PWMs are already in use
|
||||||
#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
|
#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN || P == COOLER_AUTO_FAN_PIN)
|
||||||
#if PIN_EXISTS(CONTROLLER_FAN)
|
#if PIN_EXISTS(CONTROLLER_FAN)
|
||||||
#define PWM_CHK_FAN_B(P) (_PWM_CHK_FAN_B(P) || P == CONTROLLER_FAN_PIN)
|
#define PWM_CHK_FAN_B(P) (_PWM_CHK_FAN_B(P) || P == CONTROLLER_FAN_PIN)
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -56,3 +56,10 @@
|
|||||||
#if BOTH(HAS_TMC_SW_SERIAL, MONITOR_DRIVER_STATUS)
|
#if BOTH(HAS_TMC_SW_SERIAL, MONITOR_DRIVER_STATUS)
|
||||||
#error "MONITOR_DRIVER_STATUS causes performance issues when used with SoftwareSerial-connected drivers. Disable MONITOR_DRIVER_STATUS or use hardware serial to continue."
|
#error "MONITOR_DRIVER_STATUS causes performance issues when used with SoftwareSerial-connected drivers. Disable MONITOR_DRIVER_STATUS or use hardware serial to continue."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Postmortem debugging
|
||||||
|
*/
|
||||||
|
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||||
|
#error "POSTMORTEM_DEBUGGING is not supported on AVR boards."
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -235,8 +235,8 @@ static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin");
|
|||||||
|
|
||||||
inline void com_print(const uint8_t N, const uint8_t Z) {
|
inline void com_print(const uint8_t N, const uint8_t Z) {
|
||||||
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
|
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
|
||||||
SERIAL_ECHOPGM(" COM");
|
SERIAL_ECHOPAIR(" COM", AS_CHAR('0' + N));
|
||||||
SERIAL_CHAR('0' + N, Z);
|
SERIAL_CHAR(Z);
|
||||||
SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
|
SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,8 +247,8 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
|
|||||||
uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1))));
|
uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1))));
|
||||||
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);
|
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);
|
||||||
|
|
||||||
SERIAL_ECHOPGM(" TIMER");
|
SERIAL_ECHOPAIR(" TIMER", AS_CHAR(T + '0'));
|
||||||
SERIAL_CHAR(T + '0', L);
|
SERIAL_CHAR(L);
|
||||||
SERIAL_ECHO_SP(3);
|
SERIAL_ECHO_SP(3);
|
||||||
|
|
||||||
if (N == 3) {
|
if (N == 3) {
|
||||||
@@ -262,19 +262,11 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
|
|||||||
SERIAL_ECHOPAIR(" WGM: ", WGM);
|
SERIAL_ECHOPAIR(" WGM: ", WGM);
|
||||||
com_print(T,L);
|
com_print(T,L);
|
||||||
SERIAL_ECHOPAIR(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) ));
|
SERIAL_ECHOPAIR(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) ));
|
||||||
|
SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "A: ", *TCCRA);
|
||||||
SERIAL_ECHOPGM(" TCCR");
|
SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "B: ", *TCCRB);
|
||||||
SERIAL_CHAR(T + '0');
|
|
||||||
SERIAL_ECHOPAIR("A: ", *TCCRA);
|
|
||||||
|
|
||||||
SERIAL_ECHOPGM(" TCCR");
|
|
||||||
SERIAL_CHAR(T + '0');
|
|
||||||
SERIAL_ECHOPAIR("B: ", *TCCRB);
|
|
||||||
|
|
||||||
const uint8_t *TMSK = (uint8_t*)TIMSK(T);
|
const uint8_t *TMSK = (uint8_t*)TIMSK(T);
|
||||||
SERIAL_ECHOPGM(" TIMSK");
|
SERIAL_ECHOPAIR(" TIMSK", AS_CHAR(T + '0'), ": ", *TMSK);
|
||||||
SERIAL_CHAR(T + '0');
|
|
||||||
SERIAL_ECHOPAIR(": ", *TMSK);
|
|
||||||
|
|
||||||
const uint8_t OCIE = L - 'A' + 1;
|
const uint8_t OCIE = L - 'A' + 1;
|
||||||
if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); }
|
if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); }
|
||||||
|
|||||||
@@ -1,342 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2020 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/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifdef ARDUINO_ARCH_SAM
|
|
||||||
|
|
||||||
#include "../../core/macros.h"
|
|
||||||
#include "../../core/serial.h"
|
|
||||||
|
|
||||||
#include "../shared/backtrace/unwinder.h"
|
|
||||||
#include "../shared/backtrace/unwmemaccess.h"
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
// Debug monitor that dumps to the Programming port all status when
|
|
||||||
// an exception or WDT timeout happens - And then resets the board
|
|
||||||
|
|
||||||
// All the Monitor routines must run with interrupts disabled and
|
|
||||||
// under an ISR execution context. That is why we cannot reuse the
|
|
||||||
// Serial interrupt routines or any C runtime, as we don't know the
|
|
||||||
// state we are when running them
|
|
||||||
|
|
||||||
// A SW memory barrier, to ensure GCC does not overoptimize loops
|
|
||||||
#define sw_barrier() __asm__ volatile("": : :"memory");
|
|
||||||
|
|
||||||
// (re)initialize UART0 as a monitor output to 250000,n,8,1
|
|
||||||
static void TXBegin() {
|
|
||||||
|
|
||||||
// Disable UART interrupt in NVIC
|
|
||||||
NVIC_DisableIRQ( UART_IRQn );
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
|
|
||||||
// Disable clock
|
|
||||||
pmc_disable_periph_clk( ID_UART );
|
|
||||||
|
|
||||||
// Configure PMC
|
|
||||||
pmc_enable_periph_clk( ID_UART );
|
|
||||||
|
|
||||||
// Disable PDC channel
|
|
||||||
UART->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS;
|
|
||||||
|
|
||||||
// Reset and disable receiver and transmitter
|
|
||||||
UART->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS;
|
|
||||||
|
|
||||||
// Configure mode: 8bit, No parity, 1 bit stop
|
|
||||||
UART->UART_MR = UART_MR_CHMODE_NORMAL | US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_NO;
|
|
||||||
|
|
||||||
// Configure baudrate (asynchronous, no oversampling) to BAUDRATE bauds
|
|
||||||
UART->UART_BRGR = (SystemCoreClock / (BAUDRATE << 4));
|
|
||||||
|
|
||||||
// Enable receiver and transmitter
|
|
||||||
UART->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send character through UART with no interrupts
|
|
||||||
static void TX(char c) {
|
|
||||||
while (!(UART->UART_SR & UART_SR_TXRDY)) { WDT_Restart(WDT); sw_barrier(); };
|
|
||||||
UART->UART_THR = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send String through UART
|
|
||||||
static void TX(const char* s) {
|
|
||||||
while (*s) TX(*s++);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TXDigit(uint32_t d) {
|
|
||||||
if (d < 10) TX((char)(d+'0'));
|
|
||||||
else if (d < 16) TX((char)(d+'A'-10));
|
|
||||||
else TX('?');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send Hex number thru UART
|
|
||||||
static void TXHex(uint32_t v) {
|
|
||||||
TX("0x");
|
|
||||||
for (uint8_t i = 0; i < 8; i++, v <<= 4)
|
|
||||||
TXDigit((v >> 28) & 0xF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send Decimal number thru UART
|
|
||||||
static void TXDec(uint32_t v) {
|
|
||||||
if (!v) {
|
|
||||||
TX('0');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char nbrs[14];
|
|
||||||
char *p = &nbrs[0];
|
|
||||||
while (v != 0) {
|
|
||||||
*p++ = '0' + (v % 10);
|
|
||||||
v /= 10;
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
p--;
|
|
||||||
TX(*p);
|
|
||||||
} while (p != &nbrs[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dump a backtrace entry
|
|
||||||
static bool UnwReportOut(void* ctx, const UnwReport* bte) {
|
|
||||||
int* p = (int*)ctx;
|
|
||||||
|
|
||||||
(*p)++;
|
|
||||||
TX('#'); TXDec(*p); TX(" : ");
|
|
||||||
TX(bte->name?bte->name:"unknown"); TX('@'); TXHex(bte->function);
|
|
||||||
TX('+'); TXDec(bte->address - bte->function);
|
|
||||||
TX(" PC:");TXHex(bte->address); TX('\n');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef UNW_DEBUG
|
|
||||||
void UnwPrintf(const char* format, ...) {
|
|
||||||
char dest[256];
|
|
||||||
va_list argptr;
|
|
||||||
va_start(argptr, format);
|
|
||||||
vsprintf(dest, format, argptr);
|
|
||||||
va_end(argptr);
|
|
||||||
TX(&dest[0]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Table of function pointers for passing to the unwinder */
|
|
||||||
static const UnwindCallbacks UnwCallbacks = {
|
|
||||||
UnwReportOut,
|
|
||||||
UnwReadW,
|
|
||||||
UnwReadH,
|
|
||||||
UnwReadB
|
|
||||||
#ifdef UNW_DEBUG
|
|
||||||
, UnwPrintf
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HardFaultHandler_C:
|
|
||||||
* This is called from the HardFault_HandlerAsm with a pointer the Fault stack
|
|
||||||
* as the parameter. We can then read the values from the stack and place them
|
|
||||||
* into local variables for ease of reading.
|
|
||||||
* We then read the various Fault Status and Address Registers to help decode
|
|
||||||
* cause of the fault.
|
|
||||||
* The function ends with a BKPT instruction to force control back into the debugger
|
|
||||||
*/
|
|
||||||
extern "C"
|
|
||||||
void HardFault_HandlerC(unsigned long *sp, unsigned long lr, unsigned long cause) {
|
|
||||||
|
|
||||||
static const char* causestr[] = {
|
|
||||||
"NMI","Hard","Mem","Bus","Usage","Debug","WDT","RSTC"
|
|
||||||
};
|
|
||||||
|
|
||||||
UnwindFrame btf;
|
|
||||||
|
|
||||||
// Dump report to the Programming port (interrupts are DISABLED)
|
|
||||||
TXBegin();
|
|
||||||
TX("\n\n## Software Fault detected ##\n");
|
|
||||||
TX("Cause: "); TX(causestr[cause]); TX('\n');
|
|
||||||
|
|
||||||
TX("R0 : "); TXHex(((unsigned long)sp[0])); TX('\n');
|
|
||||||
TX("R1 : "); TXHex(((unsigned long)sp[1])); TX('\n');
|
|
||||||
TX("R2 : "); TXHex(((unsigned long)sp[2])); TX('\n');
|
|
||||||
TX("R3 : "); TXHex(((unsigned long)sp[3])); TX('\n');
|
|
||||||
TX("R12 : "); TXHex(((unsigned long)sp[4])); TX('\n');
|
|
||||||
TX("LR : "); TXHex(((unsigned long)sp[5])); TX('\n');
|
|
||||||
TX("PC : "); TXHex(((unsigned long)sp[6])); TX('\n');
|
|
||||||
TX("PSR : "); TXHex(((unsigned long)sp[7])); TX('\n');
|
|
||||||
|
|
||||||
// Configurable Fault Status Register
|
|
||||||
// Consists of MMSR, BFSR and UFSR
|
|
||||||
TX("CFSR : "); TXHex((*((volatile unsigned long *)(0xE000ED28)))); TX('\n');
|
|
||||||
|
|
||||||
// Hard Fault Status Register
|
|
||||||
TX("HFSR : "); TXHex((*((volatile unsigned long *)(0xE000ED2C)))); TX('\n');
|
|
||||||
|
|
||||||
// Debug Fault Status Register
|
|
||||||
TX("DFSR : "); TXHex((*((volatile unsigned long *)(0xE000ED30)))); TX('\n');
|
|
||||||
|
|
||||||
// Auxiliary Fault Status Register
|
|
||||||
TX("AFSR : "); TXHex((*((volatile unsigned long *)(0xE000ED3C)))); TX('\n');
|
|
||||||
|
|
||||||
// Read the Fault Address Registers. These may not contain valid values.
|
|
||||||
// Check BFARVALID/MMARVALID to see if they are valid values
|
|
||||||
// MemManage Fault Address Register
|
|
||||||
TX("MMAR : "); TXHex((*((volatile unsigned long *)(0xE000ED34)))); TX('\n');
|
|
||||||
|
|
||||||
// Bus Fault Address Register
|
|
||||||
TX("BFAR : "); TXHex((*((volatile unsigned long *)(0xE000ED38)))); TX('\n');
|
|
||||||
|
|
||||||
TX("ExcLR: "); TXHex(lr); TX('\n');
|
|
||||||
TX("ExcSP: "); TXHex((unsigned long)sp); TX('\n');
|
|
||||||
|
|
||||||
btf.sp = ((unsigned long)sp) + 8*4; // The original stack pointer
|
|
||||||
btf.fp = btf.sp;
|
|
||||||
btf.lr = ((unsigned long)sp[5]);
|
|
||||||
btf.pc = ((unsigned long)sp[6]) | 1; // Force Thumb, as CORTEX only support it
|
|
||||||
|
|
||||||
// Perform a backtrace
|
|
||||||
TX("\nBacktrace:\n\n");
|
|
||||||
int ctr = 0;
|
|
||||||
UnwindStart(&btf, &UnwCallbacks, &ctr);
|
|
||||||
|
|
||||||
// Disable all NVIC interrupts
|
|
||||||
NVIC->ICER[0] = 0xFFFFFFFF;
|
|
||||||
NVIC->ICER[1] = 0xFFFFFFFF;
|
|
||||||
|
|
||||||
// Relocate VTOR table to default position
|
|
||||||
SCB->VTOR = 0;
|
|
||||||
|
|
||||||
// Disable USB
|
|
||||||
otg_disable();
|
|
||||||
|
|
||||||
// Restart watchdog
|
|
||||||
WDT_Restart(WDT);
|
|
||||||
|
|
||||||
// Reset controller
|
|
||||||
NVIC_SystemReset();
|
|
||||||
for (;;) WDT_Restart(WDT);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void NMI_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#0")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void HardFault_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#1")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void MemManage_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#2")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void BusFault_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#3")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void UsageFault_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#4")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void DebugMon_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#5")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is NOT an exception, it is an interrupt handler - Nevertheless, the framing is the same */
|
|
||||||
__attribute__((naked)) void WDT_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#6")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void RSTC_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#7")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // ARDUINO_ARCH_SAM
|
|
||||||
@@ -40,6 +40,8 @@ uint16_t HAL_adc_result;
|
|||||||
// Public functions
|
// Public functions
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
|
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
|
||||||
|
|
||||||
// HAL initialization task
|
// HAL initialization task
|
||||||
void HAL_init() {
|
void HAL_init() {
|
||||||
// Initialize the USB stack
|
// Initialize the USB stack
|
||||||
@@ -47,6 +49,7 @@ void HAL_init() {
|
|||||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||||
#endif
|
#endif
|
||||||
usb_task_init();
|
usb_task_init();
|
||||||
|
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
|
||||||
}
|
}
|
||||||
|
|
||||||
// HAL idle task
|
// HAL idle task
|
||||||
@@ -102,4 +105,18 @@ uint16_t HAL_adc_get_result() {
|
|||||||
return HAL_adc_result;
|
return HAL_adc_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward the default serial ports
|
||||||
|
#if ANY_SERIAL_IS(0)
|
||||||
|
DefaultSerial1 MSerial0(false, Serial);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(1)
|
||||||
|
DefaultSerial2 MSerial1(false, Serial1);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(2)
|
||||||
|
DefaultSerial3 MSerial2(false, Serial2);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(3)
|
||||||
|
DefaultSerial4 MSerial3(false, Serial3);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // ARDUINO_ARCH_SAM
|
#endif // ARDUINO_ARCH_SAM
|
||||||
|
|||||||
+26
-18
@@ -36,29 +36,47 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define _MSERIAL(X) Serial##X
|
#include "../../core/serial_hook.h"
|
||||||
#define MSERIAL(X) _MSERIAL(X)
|
|
||||||
#define Serial0 Serial
|
|
||||||
|
|
||||||
// Define MYSERIAL0/1 before MarlinSerial includes!
|
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||||
|
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||||
|
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||||
|
typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4;
|
||||||
|
extern DefaultSerial1 MSerial0;
|
||||||
|
extern DefaultSerial2 MSerial1;
|
||||||
|
extern DefaultSerial3 MSerial2;
|
||||||
|
extern DefaultSerial4 MSerial3;
|
||||||
|
|
||||||
|
#define _MSERIAL(X) MSerial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
|
||||||
|
// Define MYSERIAL1/2 before MarlinSerial includes!
|
||||||
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
|
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
|
||||||
#define MYSERIAL0 customizedSerial1
|
#define MYSERIAL1 customizedSerial1
|
||||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||||
#else
|
#else
|
||||||
#error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
|
#if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
|
||||||
#define MYSERIAL1 customizedSerial2
|
#define MYSERIAL2 customizedSerial2
|
||||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MMU2_SERIAL_PORT
|
||||||
|
#if WITHIN(MMU2_SERIAL_PORT, 0, 3)
|
||||||
|
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
|
||||||
|
#else
|
||||||
|
#error "MMU2_SERIAL_PORT must be from 0 to 3. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LCD_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if LCD_SERIAL_PORT == -1
|
#if LCD_SERIAL_PORT == -1
|
||||||
#define LCD_SERIAL lcdSerial
|
#define LCD_SERIAL lcdSerial
|
||||||
@@ -75,16 +93,6 @@
|
|||||||
// On AVR this is in math.h?
|
// On AVR this is in math.h?
|
||||||
#define square(x) ((x)*(x))
|
#define square(x) ((x)*(x))
|
||||||
|
|
||||||
#ifndef strncpy_P
|
|
||||||
#define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Fix bug in pgm_read_ptr
|
|
||||||
#undef pgm_read_ptr
|
|
||||||
#define pgm_read_ptr(addr) (*((void**)(addr)))
|
|
||||||
#undef pgm_read_word
|
|
||||||
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
|
|
||||||
|
|
||||||
typedef int8_t pin_t;
|
typedef int8_t pin_t;
|
||||||
|
|
||||||
#define SHARED_SERVOS HAS_SERVOS
|
#define SHARED_SERVOS HAS_SERVOS
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifdef ARDUINO_ARCH_SAM
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
|
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||||
|
|
||||||
|
#include "../shared/HAL_MinSerial.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
static void TXBegin() {
|
||||||
|
// Disable UART interrupt in NVIC
|
||||||
|
NVIC_DisableIRQ( UART_IRQn );
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
// Disable clock
|
||||||
|
pmc_disable_periph_clk( ID_UART );
|
||||||
|
|
||||||
|
// Configure PMC
|
||||||
|
pmc_enable_periph_clk( ID_UART );
|
||||||
|
|
||||||
|
// Disable PDC channel
|
||||||
|
UART->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS;
|
||||||
|
|
||||||
|
// Reset and disable receiver and transmitter
|
||||||
|
UART->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS;
|
||||||
|
|
||||||
|
// Configure mode: 8bit, No parity, 1 bit stop
|
||||||
|
UART->UART_MR = UART_MR_CHMODE_NORMAL | US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_NO;
|
||||||
|
|
||||||
|
// Configure baudrate (asynchronous, no oversampling) to BAUDRATE bauds
|
||||||
|
UART->UART_BRGR = (SystemCoreClock / (BAUDRATE << 4));
|
||||||
|
|
||||||
|
// Enable receiver and transmitter
|
||||||
|
UART->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A SW memory barrier, to ensure GCC does not overoptimize loops
|
||||||
|
#define sw_barrier() __asm__ volatile("": : :"memory");
|
||||||
|
static void TX(char c) {
|
||||||
|
while (!(UART->UART_SR & UART_SR_TXRDY)) { WDT_Restart(WDT); sw_barrier(); };
|
||||||
|
UART->UART_THR = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void install_min_serial() {
|
||||||
|
HAL_min_serial_init = &TXBegin;
|
||||||
|
HAL_min_serial_out = &TX;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DISABLED(DYNAMIC_VECTORTABLE)
|
||||||
|
extern "C" {
|
||||||
|
__attribute__((naked)) void JumpHandler_ASM() {
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"b CommonHandler_ASM\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) HardFault_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) BusFault_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) UsageFault_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) MemManage_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) NMI_Handler();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // POSTMORTEM_DEBUGGING
|
||||||
|
#endif // ARDUINO_ARCH_SAM
|
||||||
@@ -240,7 +240,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// all the others
|
// all the others
|
||||||
static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4µs => 125khz
|
static uint32_t spiDelayCyclesX4 = 4 * (F_CPU) / 1000000; // 4µs => 125khz
|
||||||
|
|
||||||
static uint8_t spiTransferX(uint8_t b) { // using Mode 0
|
static uint8_t spiTransferX(uint8_t b) { // using Mode 0
|
||||||
int bits = 8;
|
int bits = 8;
|
||||||
@@ -249,12 +249,12 @@
|
|||||||
b <<= 1; // little setup time
|
b <<= 1; // little setup time
|
||||||
|
|
||||||
WRITE(SD_SCK_PIN, HIGH);
|
WRITE(SD_SCK_PIN, HIGH);
|
||||||
__delay_4cycles(spiDelayCyclesX4);
|
DELAY_CYCLES(spiDelayCyclesX4);
|
||||||
|
|
||||||
b |= (READ(SD_MISO_PIN) != 0);
|
b |= (READ(SD_MISO_PIN) != 0);
|
||||||
|
|
||||||
WRITE(SD_SCK_PIN, LOW);
|
WRITE(SD_SCK_PIN, LOW);
|
||||||
__delay_4cycles(spiDelayCyclesX4);
|
DELAY_CYCLES(spiDelayCyclesX4);
|
||||||
} while (--bits);
|
} while (--bits);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
@@ -510,7 +510,7 @@
|
|||||||
spiRxBlock = (pfnSpiRxBlock)spiRxBlockX;
|
spiRxBlock = (pfnSpiRxBlock)spiRxBlockX;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
spiDelayCyclesX4 = ((F_CPU) / 1000000) >> (6 - spiRate);
|
spiDelayCyclesX4 = ((F_CPU) / 1000000) >> (6 - spiRate) << 2; // spiRate of 2 gives the maximum error with current CPU
|
||||||
spiTransferTx = (pfnSpiTransfer)spiTransferX;
|
spiTransferTx = (pfnSpiTransfer)spiTransferX;
|
||||||
spiTransferRx = (pfnSpiTransfer)spiTransferX;
|
spiTransferRx = (pfnSpiTransfer)spiTransferX;
|
||||||
spiTxBlock = (pfnSpiTxBlock)spiTxBlockX;
|
spiTxBlock = (pfnSpiTxBlock)spiTxBlockX;
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ void MarlinSerial<Cfg>::flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::write(const uint8_t c) {
|
size_t MarlinSerial<Cfg>::write(const uint8_t c) {
|
||||||
_written = true;
|
_written = true;
|
||||||
|
|
||||||
if (Cfg::TX_SIZE == 0) {
|
if (Cfg::TX_SIZE == 0) {
|
||||||
@@ -400,7 +400,7 @@ void MarlinSerial<Cfg>::write(const uint8_t c) {
|
|||||||
// XOFF char at the RX isr, but it is properly handled there
|
// XOFF char at the RX isr, but it is properly handled there
|
||||||
if (!(HWUART->UART_IMR & UART_IMR_TXRDY) && (HWUART->UART_SR & UART_SR_TXRDY)) {
|
if (!(HWUART->UART_IMR & UART_IMR_TXRDY) && (HWUART->UART_SR & UART_SR_TXRDY)) {
|
||||||
HWUART->UART_THR = c;
|
HWUART->UART_THR = c;
|
||||||
return;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1);
|
const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1);
|
||||||
@@ -428,6 +428,7 @@ void MarlinSerial<Cfg>::write(const uint8_t c) {
|
|||||||
// Enable TX isr - Non atomic, but it will eventually enable TX isr
|
// Enable TX isr - Non atomic, but it will eventually enable TX isr
|
||||||
HWUART->UART_IER = UART_IER_TXRDY;
|
HWUART->UART_IER = UART_IER_TXRDY;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
@@ -473,169 +474,16 @@ void MarlinSerial<Cfg>::flushTX() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Imports from print.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(char c, int base) {
|
|
||||||
print((long)c, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(unsigned char b, int base) {
|
|
||||||
print((unsigned long)b, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(int n, int base) {
|
|
||||||
print((long)n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(unsigned int n, int base) {
|
|
||||||
print((unsigned long)n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(long n, int base) {
|
|
||||||
if (base == 0) write(n);
|
|
||||||
else if (base == 10) {
|
|
||||||
if (n < 0) { print('-'); n = -n; }
|
|
||||||
printNumber(n, 10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printNumber(n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(unsigned long n, int base) {
|
|
||||||
if (base == 0) write(n);
|
|
||||||
else printNumber(n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::print(double n, int digits) {
|
|
||||||
printFloat(n, digits);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println() {
|
|
||||||
print('\r');
|
|
||||||
print('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(const String& s) {
|
|
||||||
print(s);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(const char c[]) {
|
|
||||||
print(c);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(char c, int base) {
|
|
||||||
print(c, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(unsigned char b, int base) {
|
|
||||||
print(b, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(int n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(unsigned int n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(long n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(unsigned long n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::println(double n, int digits) {
|
|
||||||
print(n, digits);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private Methods
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::printNumber(unsigned long n, uint8_t base) {
|
|
||||||
if (n) {
|
|
||||||
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
|
|
||||||
int8_t i = 0;
|
|
||||||
while (n) {
|
|
||||||
buf[i++] = n % base;
|
|
||||||
n /= base;
|
|
||||||
}
|
|
||||||
while (i--)
|
|
||||||
print((char)(buf[i] + (buf[i] < 10 ? '0' : 'A' - 10)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
print('0');
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Cfg>
|
|
||||||
void MarlinSerial<Cfg>::printFloat(double number, uint8_t digits) {
|
|
||||||
// Handle negative numbers
|
|
||||||
if (number < 0.0) {
|
|
||||||
print('-');
|
|
||||||
number = -number;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
|
||||||
double rounding = 0.5;
|
|
||||||
LOOP_L_N(i, digits) rounding *= 0.1;
|
|
||||||
number += rounding;
|
|
||||||
|
|
||||||
// Extract the integer part of the number and print it
|
|
||||||
unsigned long int_part = (unsigned long)number;
|
|
||||||
double remainder = number - (double)int_part;
|
|
||||||
print(int_part);
|
|
||||||
|
|
||||||
// Print the decimal point, but only if there are digits beyond
|
|
||||||
if (digits) {
|
|
||||||
print('.');
|
|
||||||
// Extract digits from the remainder one at a time
|
|
||||||
while (digits--) {
|
|
||||||
remainder *= 10.0;
|
|
||||||
int toPrint = int(remainder);
|
|
||||||
print(toPrint);
|
|
||||||
remainder -= toPrint;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If not using the USB port as serial port
|
// If not using the USB port as serial port
|
||||||
#if SERIAL_PORT >= 0
|
#if SERIAL_PORT >= 0
|
||||||
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>; // Define
|
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >;
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1; // Instantiate
|
MSerialT customizedSerial1(MarlinSerialCfg<SERIAL_PORT>::EMERGENCYPARSER);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
|
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
|
||||||
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>; // Define
|
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> >;
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2; // Instantiate
|
MSerialT2 customizedSerial2(MarlinSerialCfg<SERIAL_PORT_2>::EMERGENCYPARSER);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // ARDUINO_ARCH_SAM
|
#endif // ARDUINO_ARCH_SAM
|
||||||
|
|||||||
@@ -30,11 +30,7 @@
|
|||||||
#include <WString.h>
|
#include <WString.h>
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
#include "../../core/serial_hook.h"
|
||||||
#define DEC 10
|
|
||||||
#define HEX 16
|
|
||||||
#define OCT 8
|
|
||||||
#define BIN 2
|
|
||||||
|
|
||||||
// Define constants and variables for buffering incoming serial data. We're
|
// Define constants and variables for buffering incoming serial data. We're
|
||||||
// using a ring buffer (I think), in which rx_buffer_head is the index of the
|
// using a ring buffer (I think), in which rx_buffer_head is the index of the
|
||||||
@@ -119,7 +115,7 @@ public:
|
|||||||
static int read();
|
static int read();
|
||||||
static void flush();
|
static void flush();
|
||||||
static ring_buffer_pos_t available();
|
static ring_buffer_pos_t available();
|
||||||
static void write(const uint8_t c);
|
static size_t write(const uint8_t c);
|
||||||
static void flushTX();
|
static void flushTX();
|
||||||
|
|
||||||
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
|
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
|
||||||
@@ -128,35 +124,6 @@ public:
|
|||||||
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
|
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
|
||||||
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
|
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
|
||||||
FORCE_INLINE static ring_buffer_pos_t rxMaxEnqueued() { return Cfg::MAX_RX_QUEUED ? rx_max_enqueued : 0; }
|
FORCE_INLINE static ring_buffer_pos_t rxMaxEnqueued() { return Cfg::MAX_RX_QUEUED ? rx_max_enqueued : 0; }
|
||||||
|
|
||||||
FORCE_INLINE static void write(const char* str) { while (*str) write(*str++); }
|
|
||||||
FORCE_INLINE static void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
|
|
||||||
FORCE_INLINE static void print(const String& s) { for (int i = 0; i < (int)s.length(); i++) write(s[i]); }
|
|
||||||
FORCE_INLINE static void print(const char* str) { write(str); }
|
|
||||||
|
|
||||||
static void print(char, int = 0);
|
|
||||||
static void print(unsigned char, int = 0);
|
|
||||||
static void print(int, int = DEC);
|
|
||||||
static void print(unsigned int, int = DEC);
|
|
||||||
static void print(long, int = DEC);
|
|
||||||
static void print(unsigned long, int = DEC);
|
|
||||||
static void print(double, int = 2);
|
|
||||||
|
|
||||||
static void println(const String& s);
|
|
||||||
static void println(const char[]);
|
|
||||||
static void println(char, int = 0);
|
|
||||||
static void println(unsigned char, int = 0);
|
|
||||||
static void println(int, int = DEC);
|
|
||||||
static void println(unsigned int, int = DEC);
|
|
||||||
static void println(long, int = DEC);
|
|
||||||
static void println(unsigned long, int = DEC);
|
|
||||||
static void println(double, int = 2);
|
|
||||||
static void println();
|
|
||||||
operator bool() { return true; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void printNumber(unsigned long, const uint8_t);
|
|
||||||
static void printFloat(double, uint8_t);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Serial port configuration
|
// Serial port configuration
|
||||||
@@ -174,9 +141,11 @@ struct MarlinSerialCfg {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if SERIAL_PORT >= 0
|
#if SERIAL_PORT >= 0
|
||||||
extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
|
||||||
|
extern MSerialT customizedSerial1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
|
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
|
||||||
extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
|
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2;
|
||||||
|
extern MSerialT2 customizedSerial2;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -33,10 +33,6 @@
|
|||||||
|
|
||||||
#include "MarlinSerialUSB.h"
|
#include "MarlinSerialUSB.h"
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
#include "../../feature/e_parser.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Imports from Atmel USB Stack/CDC implementation
|
// Imports from Atmel USB Stack/CDC implementation
|
||||||
extern "C" {
|
extern "C" {
|
||||||
bool usb_task_cdc_isenabled();
|
bool usb_task_cdc_isenabled();
|
||||||
@@ -50,10 +46,6 @@ extern "C" {
|
|||||||
// Pending character
|
// Pending character
|
||||||
static int pending_char = -1;
|
static int pending_char = -1;
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
static EmergencyParser::State emergency_state; // = EP_RESET
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Public Methods
|
// Public Methods
|
||||||
void MarlinSerialUSB::begin(const long) {}
|
void MarlinSerialUSB::begin(const long) {}
|
||||||
|
|
||||||
@@ -73,7 +65,7 @@ int MarlinSerialUSB::peek() {
|
|||||||
|
|
||||||
pending_char = udi_cdc_getc();
|
pending_char = udi_cdc_getc();
|
||||||
|
|
||||||
TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)pending_char));
|
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, (char)pending_char));
|
||||||
|
|
||||||
return pending_char;
|
return pending_char;
|
||||||
}
|
}
|
||||||
@@ -95,29 +87,27 @@ int MarlinSerialUSB::read() {
|
|||||||
|
|
||||||
int c = udi_cdc_getc();
|
int c = udi_cdc_getc();
|
||||||
|
|
||||||
TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)c));
|
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, (char)c));
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MarlinSerialUSB::available() {
|
int MarlinSerialUSB::available() {
|
||||||
/* If Pending chars */
|
if (pending_char > 0) return pending_char;
|
||||||
return pending_char >= 0 ||
|
return pending_char == 0 ||
|
||||||
/* or USB CDC enumerated and configured on the PC side and some
|
// or USB CDC enumerated and configured on the PC side and some bytes where sent to us */
|
||||||
bytes where sent to us */
|
(usb_task_cdc_isenabled() && udi_cdc_is_rx_ready());
|
||||||
(usb_task_cdc_isenabled() && udi_cdc_is_rx_ready());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarlinSerialUSB::flush() { }
|
void MarlinSerialUSB::flush() { }
|
||||||
void MarlinSerialUSB::flushTX() { }
|
|
||||||
|
|
||||||
void MarlinSerialUSB::write(const uint8_t c) {
|
size_t MarlinSerialUSB::write(const uint8_t c) {
|
||||||
|
|
||||||
/* Do not even bother sending anything if USB CDC is not enumerated
|
/* Do not even bother sending anything if USB CDC is not enumerated
|
||||||
or not configured on the PC side or there is no program on the PC
|
or not configured on the PC side or there is no program on the PC
|
||||||
listening to our messages */
|
listening to our messages */
|
||||||
if (!usb_task_cdc_isenabled() || !usb_task_cdc_dtr_active())
|
if (!usb_task_cdc_isenabled() || !usb_task_cdc_dtr_active())
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
/* Wait until the PC has read the pending to be sent data */
|
/* Wait until the PC has read the pending to be sent data */
|
||||||
while (usb_task_cdc_isenabled() &&
|
while (usb_task_cdc_isenabled() &&
|
||||||
@@ -129,161 +119,20 @@ void MarlinSerialUSB::write(const uint8_t c) {
|
|||||||
or not configured on the PC side or there is no program on the PC
|
or not configured on the PC side or there is no program on the PC
|
||||||
listening to our messages at this point */
|
listening to our messages at this point */
|
||||||
if (!usb_task_cdc_isenabled() || !usb_task_cdc_dtr_active())
|
if (!usb_task_cdc_isenabled() || !usb_task_cdc_dtr_active())
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
// Fifo full
|
// Fifo full
|
||||||
// udi_cdc_signal_overrun();
|
// udi_cdc_signal_overrun();
|
||||||
udi_cdc_putc(c);
|
udi_cdc_putc(c);
|
||||||
}
|
return 1;
|
||||||
|
|
||||||
/**
|
|
||||||
* Imports from print.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
void MarlinSerialUSB::print(char c, int base) {
|
|
||||||
print((long)c, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::print(unsigned char b, int base) {
|
|
||||||
print((unsigned long)b, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::print(int n, int base) {
|
|
||||||
print((long)n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::print(unsigned int n, int base) {
|
|
||||||
print((unsigned long)n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::print(long n, int base) {
|
|
||||||
if (base == 0)
|
|
||||||
write(n);
|
|
||||||
else if (base == 10) {
|
|
||||||
if (n < 0) {
|
|
||||||
print('-');
|
|
||||||
n = -n;
|
|
||||||
}
|
|
||||||
printNumber(n, 10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printNumber(n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::print(unsigned long n, int base) {
|
|
||||||
if (base == 0) write(n);
|
|
||||||
else printNumber(n, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::print(double n, int digits) {
|
|
||||||
printFloat(n, digits);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println() {
|
|
||||||
print('\r');
|
|
||||||
print('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println(const String& s) {
|
|
||||||
print(s);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println(const char c[]) {
|
|
||||||
print(c);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println(char c, int base) {
|
|
||||||
print(c, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println(unsigned char b, int base) {
|
|
||||||
print(b, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println(int n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println(unsigned int n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println(long n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println(unsigned long n, int base) {
|
|
||||||
print(n, base);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::println(double n, int digits) {
|
|
||||||
print(n, digits);
|
|
||||||
println();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private Methods
|
|
||||||
|
|
||||||
void MarlinSerialUSB::printNumber(unsigned long n, uint8_t base) {
|
|
||||||
if (n) {
|
|
||||||
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
|
|
||||||
int8_t i = 0;
|
|
||||||
while (n) {
|
|
||||||
buf[i++] = n % base;
|
|
||||||
n /= base;
|
|
||||||
}
|
|
||||||
while (i--)
|
|
||||||
print((char)(buf[i] + (buf[i] < 10 ? '0' : 'A' - 10)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
print('0');
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinSerialUSB::printFloat(double number, uint8_t digits) {
|
|
||||||
// Handle negative numbers
|
|
||||||
if (number < 0.0) {
|
|
||||||
print('-');
|
|
||||||
number = -number;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
|
||||||
double rounding = 0.5;
|
|
||||||
LOOP_L_N(i, digits)
|
|
||||||
rounding *= 0.1;
|
|
||||||
|
|
||||||
number += rounding;
|
|
||||||
|
|
||||||
// Extract the integer part of the number and print it
|
|
||||||
unsigned long int_part = (unsigned long)number;
|
|
||||||
double remainder = number - (double)int_part;
|
|
||||||
print(int_part);
|
|
||||||
|
|
||||||
// Print the decimal point, but only if there are digits beyond
|
|
||||||
if (digits) {
|
|
||||||
print('.');
|
|
||||||
// Extract digits from the remainder one at a time
|
|
||||||
while (digits--) {
|
|
||||||
remainder *= 10.0;
|
|
||||||
int toPrint = int(remainder);
|
|
||||||
print(toPrint);
|
|
||||||
remainder -= toPrint;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preinstantiate
|
// Preinstantiate
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
MarlinSerialUSB customizedSerial1;
|
MSerialT customizedSerial1(TERN0(EMERGENCY_PARSER, true));
|
||||||
#endif
|
#endif
|
||||||
#if SERIAL_PORT_2 == -1
|
#if SERIAL_PORT_2 == -1
|
||||||
MarlinSerialUSB customizedSerial2;
|
MSerialT customizedSerial2(TERN0(EMERGENCY_PARSER, true));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // HAS_USB_SERIAL
|
#endif // HAS_USB_SERIAL
|
||||||
|
|||||||
@@ -27,73 +27,37 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
#if HAS_USB_SERIAL
|
#if HAS_USB_SERIAL
|
||||||
|
|
||||||
#include <WString.h>
|
#include <WString.h>
|
||||||
|
#include "../../core/serial_hook.h"
|
||||||
|
|
||||||
#define DEC 10
|
|
||||||
#define HEX 16
|
|
||||||
#define OCT 8
|
|
||||||
#define BIN 2
|
|
||||||
|
|
||||||
class MarlinSerialUSB {
|
struct MarlinSerialUSB {
|
||||||
|
void begin(const long);
|
||||||
public:
|
void end();
|
||||||
MarlinSerialUSB() {};
|
int peek();
|
||||||
static void begin(const long);
|
int read();
|
||||||
static void end();
|
void flush();
|
||||||
static int peek();
|
int available();
|
||||||
static int read();
|
size_t write(const uint8_t c);
|
||||||
static void flush();
|
|
||||||
static void flushTX();
|
|
||||||
static bool available();
|
|
||||||
static void write(const uint8_t c);
|
|
||||||
|
|
||||||
#if ENABLED(SERIAL_STATS_DROPPED_RX)
|
#if ENABLED(SERIAL_STATS_DROPPED_RX)
|
||||||
FORCE_INLINE static uint32_t dropped() { return 0; }
|
FORCE_INLINE uint32_t dropped() { return 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
||||||
FORCE_INLINE static int rxMaxEnqueued() { return 0; }
|
FORCE_INLINE int rxMaxEnqueued() { return 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FORCE_INLINE static void write(const char* str) { while (*str) write(*str++); }
|
|
||||||
FORCE_INLINE static void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
|
|
||||||
FORCE_INLINE static void print(const String& s) { for (int i = 0; i < (int)s.length(); i++) write(s[i]); }
|
|
||||||
FORCE_INLINE static void print(const char* str) { write(str); }
|
|
||||||
|
|
||||||
static void print(char, int = 0);
|
|
||||||
static void print(unsigned char, int = 0);
|
|
||||||
static void print(int, int = DEC);
|
|
||||||
static void print(unsigned int, int = DEC);
|
|
||||||
static void print(long, int = DEC);
|
|
||||||
static void print(unsigned long, int = DEC);
|
|
||||||
static void print(double, int = 2);
|
|
||||||
|
|
||||||
static void println(const String& s);
|
|
||||||
static void println(const char[]);
|
|
||||||
static void println(char, int = 0);
|
|
||||||
static void println(unsigned char, int = 0);
|
|
||||||
static void println(int, int = DEC);
|
|
||||||
static void println(unsigned int, int = DEC);
|
|
||||||
static void println(long, int = DEC);
|
|
||||||
static void println(unsigned long, int = DEC);
|
|
||||||
static void println(double, int = 2);
|
|
||||||
static void println();
|
|
||||||
operator bool() { return true; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void printNumber(unsigned long, const uint8_t);
|
|
||||||
static void printFloat(double, uint8_t);
|
|
||||||
};
|
};
|
||||||
|
typedef Serial1Class<MarlinSerialUSB> MSerialT;
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
extern MarlinSerialUSB customizedSerial1;
|
extern MSerialT customizedSerial1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT_2 == -1
|
#if SERIAL_PORT_2 == -1
|
||||||
extern MarlinSerialUSB customizedSerial2;
|
extern MSerialT customizedSerial2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // HAS_USB_SERIAL
|
#endif // HAS_USB_SERIAL
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
|
|
||||||
#if ENABLED(U8GLIB_ST7920)
|
#if ENABLED(U8GLIB_ST7920)
|
||||||
|
|
||||||
|
#include "../../../inc/MarlinConfig.h"
|
||||||
#include "../../shared/Delay.h"
|
#include "../../shared/Delay.h"
|
||||||
|
|
||||||
#include <U8glib.h>
|
#include <U8glib.h>
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
|
|
||||||
#if HAS_MARLINUI_U8GLIB
|
#if HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
|
#include "../../../inc/MarlinConfig.h"
|
||||||
#include "../../shared/Delay.h"
|
#include "../../shared/Delay.h"
|
||||||
|
|
||||||
#include <U8glib.h>
|
#include <U8glib.h>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
#define PWM_PIN(P) WITHIN(P, 2, 13)
|
#define PWM_PIN(P) WITHIN(P, 2, 13)
|
||||||
|
|
||||||
#ifndef MASK
|
#ifndef MASK
|
||||||
#define MASK(PIN) (1 << PIN)
|
#define MASK(PIN) _BV(PIN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,5 +57,5 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_TMC_SW_SERIAL
|
#if HAS_TMC_SW_SERIAL
|
||||||
#error "TMC220x Software Serial is not supported on this platform."
|
#error "TMC220x Software Serial is not supported on the DUE platform."
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
|||||||
|
|
||||||
// missing from CMSIS: Check if interrupt is enabled or not
|
// missing from CMSIS: Check if interrupt is enabled or not
|
||||||
static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
|
static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
|
||||||
return (NVIC->ISER[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F))) != 0;
|
return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
|
|||||||
{
|
{
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
sprintf_P(buffer, PSTR("SDRD: %d @ 0x%08x\n"), nb_sector, addr);
|
sprintf_P(buffer, PSTR("SDRD: %d @ 0x%08x\n"), nb_sector, addr);
|
||||||
PORT_REDIRECT(0);
|
PORT_REDIRECT(SERIAL_PORTMASK(0));
|
||||||
SERIAL_ECHO(buffer);
|
SERIAL_ECHO(buffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -108,7 +108,7 @@ Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
|
|||||||
{
|
{
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
sprintf_P(buffer, PSTR("SDWR: %d @ 0x%08x\n"), nb_sector, addr);
|
sprintf_P(buffer, PSTR("SDWR: %d @ 0x%08x\n"), nb_sector, addr);
|
||||||
PORT_REDIRECT(0);
|
PORT_REDIRECT(SERIAL_PORTMASK(0));
|
||||||
SERIAL_ECHO(buffer);
|
SERIAL_ECHO(buffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,14 +20,10 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FlushableHardwareSerial.h"
|
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
|
||||||
FlushableHardwareSerial::FlushableHardwareSerial(int uart_nr)
|
#include "FlushableHardwareSerial.h"
|
||||||
: HardwareSerial(uart_nr)
|
|
||||||
{}
|
|
||||||
|
|
||||||
FlushableHardwareSerial flushableSerial(0);
|
Serial1Class<FlushableHardwareSerial> flushableSerial(false, 0);
|
||||||
|
|
||||||
#endif // ARDUINO_ARCH_ESP32
|
#endif
|
||||||
|
|||||||
@@ -21,17 +21,14 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
|
||||||
|
|
||||||
#include <HardwareSerial.h>
|
#include <HardwareSerial.h>
|
||||||
|
|
||||||
|
#include "../shared/Marduino.h"
|
||||||
|
#include "../../core/serial_hook.h"
|
||||||
|
|
||||||
class FlushableHardwareSerial : public HardwareSerial {
|
class FlushableHardwareSerial : public HardwareSerial {
|
||||||
public:
|
public:
|
||||||
FlushableHardwareSerial(int uart_nr);
|
FlushableHardwareSerial(int uart_nr) : HardwareSerial(uart_nr) {}
|
||||||
|
|
||||||
inline void flushTX() { /* No need to flush the hardware serial, but defined here for compatibility. */ }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FlushableHardwareSerial flushableSerial;
|
extern Serial1Class<FlushableHardwareSerial> flushableSerial;
|
||||||
|
|
||||||
#endif // ARDUINO_ARCH_ESP32
|
|
||||||
|
|||||||
@@ -40,6 +40,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(ESP3D_WIFISUPPORT)
|
||||||
|
DefaultSerial1 MSerial0(false, Serial2Socket);
|
||||||
|
#endif
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Externs
|
// Externs
|
||||||
// ------------------------
|
// ------------------------
|
||||||
@@ -86,8 +90,6 @@ volatile int numPWMUsed = 0,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void HAL_init() { TERN_(I2S_STEPPER_STREAM, i2s_init()); }
|
|
||||||
|
|
||||||
void HAL_init_board() {
|
void HAL_init_board() {
|
||||||
|
|
||||||
#if ENABLED(ESP3D_WIFISUPPORT)
|
#if ENABLED(ESP3D_WIFISUPPORT)
|
||||||
@@ -122,6 +124,10 @@ void HAL_init_board() {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Initialize the i2s peripheral only if the I2S stepper stream is enabled.
|
||||||
|
// The following initialization is performed after Serial1 and Serial2 are defined as
|
||||||
|
// their native pins might conflict with the i2s stream even when they are remapped.
|
||||||
|
TERN_(I2S_STEPPER_STREAM, i2s_init());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_idletask() {
|
void HAL_idletask() {
|
||||||
@@ -179,6 +185,7 @@ void HAL_adc_init() {
|
|||||||
TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
|
TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
|
||||||
TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
|
TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
|
||||||
TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
|
TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
|
||||||
|
TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db));
|
||||||
TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db));
|
TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db));
|
||||||
|
|
||||||
// Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.
|
// Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.
|
||||||
|
|||||||
@@ -51,13 +51,15 @@
|
|||||||
|
|
||||||
extern portMUX_TYPE spinlock;
|
extern portMUX_TYPE spinlock;
|
||||||
|
|
||||||
#define MYSERIAL0 flushableSerial
|
#define MYSERIAL1 flushableSerial
|
||||||
|
|
||||||
#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
|
#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
|
||||||
#if ENABLED(ESP3D_WIFISUPPORT)
|
#if ENABLED(ESP3D_WIFISUPPORT)
|
||||||
#define MYSERIAL1 Serial2Socket
|
typedef ForwardSerial1Class< decltype(Serial2Socket) > DefaultSerial1;
|
||||||
|
extern DefaultSerial1 MSerial0;
|
||||||
|
#define MYSERIAL2 MSerial0
|
||||||
#else
|
#else
|
||||||
#define MYSERIAL1 webSocketSerial
|
#define MYSERIAL2 webSocketSerial
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -67,10 +69,6 @@ extern portMUX_TYPE spinlock;
|
|||||||
#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
|
#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
|
||||||
#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)
|
#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)
|
||||||
|
|
||||||
// Fix bug in pgm_read_ptr
|
|
||||||
#undef pgm_read_ptr
|
|
||||||
#define pgm_read_ptr(addr) (*(addr))
|
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Types
|
// Types
|
||||||
// ------------------------
|
// ------------------------
|
||||||
@@ -90,6 +88,13 @@ extern uint16_t HAL_adc_result;
|
|||||||
// Public functions
|
// Public functions
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tone
|
||||||
|
//
|
||||||
|
void toneInit();
|
||||||
|
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
|
||||||
|
void noTone(const pin_t _pin);
|
||||||
|
|
||||||
// clear reset reason
|
// clear reset reason
|
||||||
void HAL_clear_reset_source();
|
void HAL_clear_reset_source();
|
||||||
|
|
||||||
@@ -134,7 +139,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin);
|
|||||||
#define HAL_IDLETASK 1
|
#define HAL_IDLETASK 1
|
||||||
#define BOARD_INIT() HAL_init_board();
|
#define BOARD_INIT() HAL_init_board();
|
||||||
void HAL_idletask();
|
void HAL_idletask();
|
||||||
void HAL_init();
|
inline void HAL_init() {}
|
||||||
void HAL_init_board();
|
void HAL_init_board();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Servo {
|
|||||||
MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo
|
MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo
|
||||||
TAU_MSEC = 20,
|
TAU_MSEC = 20,
|
||||||
TAU_USEC = (TAU_MSEC * 1000),
|
TAU_USEC = (TAU_MSEC * 1000),
|
||||||
MAX_COMPARE = ((1 << 16) - 1), // 65535
|
MAX_COMPARE = _BV(16) - 1, // 65535
|
||||||
CHANNEL_MAX_NUM = 16;
|
CHANNEL_MAX_NUM = 16;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* Copypaste of SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: Tone function for ESP32
|
||||||
|
* Derived from https://forum.arduino.cc/index.php?topic=136500.msg2903012#msg2903012
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
#include "HAL.h"
|
||||||
|
|
||||||
|
static pin_t tone_pin;
|
||||||
|
volatile static int32_t toggles;
|
||||||
|
|
||||||
|
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) {
|
||||||
|
tone_pin = _pin;
|
||||||
|
toggles = 2 * frequency * duration / 1000;
|
||||||
|
HAL_timer_start(TONE_TIMER_NUM, 2 * frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
void noTone(const pin_t _pin) {
|
||||||
|
HAL_timer_disable_interrupt(TONE_TIMER_NUM);
|
||||||
|
WRITE(_pin, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_TONE_TIMER_ISR() {
|
||||||
|
HAL_timer_isr_prologue(TONE_TIMER_NUM);
|
||||||
|
|
||||||
|
if (toggles) {
|
||||||
|
toggles--;
|
||||||
|
TOGGLE(tone_pin);
|
||||||
|
}
|
||||||
|
else noTone(tone_pin); // turn off interrupt
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ARDUINO_ARCH_ESP32
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
|
|
||||||
WebSocketSerial webSocketSerial;
|
MSerialT webSocketSerial(false);
|
||||||
AsyncWebSocket ws("/ws"); // TODO Move inside the class.
|
AsyncWebSocket ws("/ws"); // TODO Move inside the class.
|
||||||
|
|
||||||
// RingBuffer impl
|
// RingBuffer impl
|
||||||
@@ -144,9 +144,5 @@ size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) {
|
|||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketSerial::flushTX() {
|
|
||||||
// No need to do anything as there's no benefit to sending partial lines over the websocket connection.
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // WIFISUPPORT
|
#endif // WIFISUPPORT
|
||||||
#endif // ARDUINO_ARCH_ESP32
|
#endif // ARDUINO_ARCH_ESP32
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
#include "../../core/serial_hook.h"
|
||||||
|
|
||||||
#include <Stream.h>
|
#include <Stream.h>
|
||||||
|
|
||||||
@@ -68,12 +69,9 @@ public:
|
|||||||
int peek();
|
int peek();
|
||||||
int read();
|
int read();
|
||||||
void flush();
|
void flush();
|
||||||
void flushTX();
|
|
||||||
size_t write(const uint8_t c);
|
size_t write(const uint8_t c);
|
||||||
size_t write(const uint8_t* buffer, size_t size);
|
size_t write(const uint8_t* buffer, size_t size);
|
||||||
|
|
||||||
operator bool() { return true; }
|
|
||||||
|
|
||||||
#if ENABLED(SERIAL_STATS_DROPPED_RX)
|
#if ENABLED(SERIAL_STATS_DROPPED_RX)
|
||||||
FORCE_INLINE uint32_t dropped() { return 0; }
|
FORCE_INLINE uint32_t dropped() { return 0; }
|
||||||
#endif
|
#endif
|
||||||
@@ -83,4 +81,5 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WebSocketSerial webSocketSerial;
|
typedef Serial1Class<WebSocketSerial> MSerialT;
|
||||||
|
extern MSerialT webSocketSerial;
|
||||||
|
|||||||
@@ -30,9 +30,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_TMC_SW_SERIAL
|
#if HAS_TMC_SW_SERIAL
|
||||||
#error "TMC220x Software Serial is not supported on this platform."
|
#error "TMC220x Software Serial is not supported on ESP32."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOTH(WIFISUPPORT, ESP3D_WIFISUPPORT)
|
#if BOTH(WIFISUPPORT, ESP3D_WIFISUPPORT)
|
||||||
#error "Only enable one WiFi option, either WIFISUPPORT or ESP3D_WIFISUPPORT."
|
#error "Only enable one WiFi option, either WIFISUPPORT or ESP3D_WIFISUPPORT."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||||
|
#error "POSTMORTEM_DEBUGGING is not yet supported on ESP32."
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
|
|||||||
{ TIMER_GROUP_0, TIMER_0, STEPPER_TIMER_PRESCALE, stepTC_Handler }, // 0 - Stepper
|
{ TIMER_GROUP_0, TIMER_0, STEPPER_TIMER_PRESCALE, stepTC_Handler }, // 0 - Stepper
|
||||||
{ TIMER_GROUP_0, TIMER_1, TEMP_TIMER_PRESCALE, tempTC_Handler }, // 1 - Temperature
|
{ TIMER_GROUP_0, TIMER_1, TEMP_TIMER_PRESCALE, tempTC_Handler }, // 1 - Temperature
|
||||||
{ TIMER_GROUP_1, TIMER_0, PWM_TIMER_PRESCALE, pwmTC_Handler }, // 2 - PWM
|
{ TIMER_GROUP_1, TIMER_0, PWM_TIMER_PRESCALE, pwmTC_Handler }, // 2 - PWM
|
||||||
{ TIMER_GROUP_1, TIMER_1, 1, nullptr }, // 3
|
{ TIMER_GROUP_1, TIMER_1, TONE_TIMER_PRESCALE, toneTC_Handler }, // 3 - Tone
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ typedef uint64_t hal_timer_t;
|
|||||||
#ifndef PWM_TIMER_NUM
|
#ifndef PWM_TIMER_NUM
|
||||||
#define PWM_TIMER_NUM 2 // index of timer to use for PWM outputs
|
#define PWM_TIMER_NUM 2 // index of timer to use for PWM outputs
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef TONE_TIMER_NUM
|
||||||
|
#define TONE_TIMER_NUM 3 // index of timer for beeper tones
|
||||||
|
#endif
|
||||||
|
|
||||||
#define HAL_TIMER_RATE APB_CLK_FREQ // frequency of timer peripherals
|
#define HAL_TIMER_RATE APB_CLK_FREQ // frequency of timer peripherals
|
||||||
|
|
||||||
@@ -59,6 +62,8 @@ typedef uint64_t hal_timer_t;
|
|||||||
|
|
||||||
#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
|
#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
|
||||||
|
|
||||||
|
#define TONE_TIMER_PRESCALE 1000 // Arbitrary value, no idea what i'm doing here
|
||||||
|
|
||||||
#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
|
#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
|
||||||
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
|
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
|
||||||
|
|
||||||
@@ -90,11 +95,15 @@ typedef uint64_t hal_timer_t;
|
|||||||
#ifndef HAL_PWM_TIMER_ISR
|
#ifndef HAL_PWM_TIMER_ISR
|
||||||
#define HAL_PWM_TIMER_ISR() extern "C" void pwmTC_Handler()
|
#define HAL_PWM_TIMER_ISR() extern "C" void pwmTC_Handler()
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAL_TONE_TIMER_ISR
|
||||||
|
#define HAL_TONE_TIMER_ISR() extern "C" void toneTC_Handler()
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void tempTC_Handler();
|
void tempTC_Handler();
|
||||||
void stepTC_Handler();
|
void stepTC_Handler();
|
||||||
void pwmTC_Handler();
|
void pwmTC_Handler();
|
||||||
|
void toneTC_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|||||||
@@ -29,12 +29,6 @@
|
|||||||
|
|
||||||
#include HAL_PATH(.,HAL.h)
|
#include HAL_PATH(.,HAL.h)
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
|
||||||
#define NUM_SERIAL 2
|
|
||||||
#else
|
|
||||||
#define NUM_SERIAL 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION)
|
#define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION)
|
||||||
|
|
||||||
#ifndef I2C_ADDRESS
|
#ifndef I2C_ADDRESS
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
#include "../shared/Delay.h"
|
#include "../shared/Delay.h"
|
||||||
|
|
||||||
HalSerial usb_serial;
|
MSerialT usb_serial(TERN0(EMERGENCY_PARSER, true));
|
||||||
|
|
||||||
// U8glib required functions
|
// U8glib required functions
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ uint8_t _getc();
|
|||||||
|
|
||||||
#define SHARED_SERVOS HAS_SERVOS
|
#define SHARED_SERVOS HAS_SERVOS
|
||||||
|
|
||||||
extern HalSerial usb_serial;
|
extern MSerialT usb_serial;
|
||||||
#define MYSERIAL0 usb_serial
|
#define MYSERIAL1 usb_serial
|
||||||
|
|
||||||
#define ST7920_DELAY_1 DELAY_NS(600)
|
#define ST7920_DELAY_1 DELAY_NS(600)
|
||||||
#define ST7920_DELAY_2 DELAY_NS(750)
|
#define ST7920_DELAY_2 DELAY_NS(750)
|
||||||
@@ -113,8 +113,3 @@ inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
|||||||
FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
|
FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
|
||||||
Clock::delayCycles(x);
|
Clock::delayCycles(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add strcmp_P if missing
|
|
||||||
#ifndef strcmp_P
|
|
||||||
#define strcmp_P(a, b) strcmp((a), (b))
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -35,5 +35,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_TMC_SW_SERIAL
|
#if HAS_TMC_SW_SERIAL
|
||||||
#error "TMC220x Software Serial is not supported on this platform."
|
#error "TMC220x Software Serial is not supported on LINUX."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||||
|
#error "POSTMORTEM_DEBUGGING is not yet supported on LINUX."
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -73,27 +73,6 @@ extern "C" {
|
|||||||
void GpioDisableInt(uint32_t port, uint32_t pin);
|
void GpioDisableInt(uint32_t port, uint32_t pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Program Memory
|
|
||||||
#define pgm_read_ptr(addr) (*((void**)(addr)))
|
|
||||||
#define pgm_read_byte_near(addr) (*((uint8_t*)(addr)))
|
|
||||||
#define pgm_read_float_near(addr) (*((float*)(addr)))
|
|
||||||
#define pgm_read_word_near(addr) (*((uint16_t*)(addr)))
|
|
||||||
#define pgm_read_dword_near(addr) (*((uint32_t*)(addr)))
|
|
||||||
#define pgm_read_byte(addr) pgm_read_byte_near(addr)
|
|
||||||
#define pgm_read_float(addr) pgm_read_float_near(addr)
|
|
||||||
#define pgm_read_word(addr) pgm_read_word_near(addr)
|
|
||||||
#define pgm_read_dword(addr) pgm_read_dword_near(addr)
|
|
||||||
|
|
||||||
using std::memcpy;
|
|
||||||
#define memcpy_P memcpy
|
|
||||||
#define sprintf_P sprintf
|
|
||||||
#define strstr_P strstr
|
|
||||||
#define strncpy_P strncpy
|
|
||||||
#define vsnprintf_P vsnprintf
|
|
||||||
#define strcpy_P strcpy
|
|
||||||
#define snprintf_P snprintf
|
|
||||||
#define strlen_P strlen
|
|
||||||
|
|
||||||
// Time functions
|
// Time functions
|
||||||
extern "C" void delay(const int milis);
|
extern "C" void delay(const int milis);
|
||||||
void _delay_ms(const int delay);
|
void _delay_ms(const int delay);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#if ENABLED(EMERGENCY_PARSER)
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
#include "../../../feature/e_parser.h"
|
#include "../../../feature/e_parser.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "../../../core/serial_hook.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -73,19 +74,11 @@ private:
|
|||||||
volatile uint32_t index_read;
|
volatile uint32_t index_read;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HalSerial {
|
struct HalSerial {
|
||||||
public:
|
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
EmergencyParser::State emergency_state;
|
|
||||||
static inline bool emergency_parser_enabled() { return true; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HalSerial() { host_connected = true; }
|
HalSerial() { host_connected = true; }
|
||||||
|
|
||||||
void begin(int32_t) {}
|
void begin(int32_t) {}
|
||||||
|
void end() {}
|
||||||
void end() {}
|
|
||||||
|
|
||||||
int peek() {
|
int peek() {
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
@@ -100,7 +93,7 @@ public:
|
|||||||
return transmit_buffer.write(c);
|
return transmit_buffer.write(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool() { return host_connected; }
|
bool connected() { return host_connected; }
|
||||||
|
|
||||||
uint16_t available() {
|
uint16_t available() {
|
||||||
return (uint16_t)receive_buffer.available();
|
return (uint16_t)receive_buffer.available();
|
||||||
@@ -117,92 +110,9 @@ public:
|
|||||||
while (transmit_buffer.available()) { /* nada */ }
|
while (transmit_buffer.available()) { /* nada */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
void printf(const char *format, ...) {
|
|
||||||
static char buffer[256];
|
|
||||||
va_list vArgs;
|
|
||||||
va_start(vArgs, format);
|
|
||||||
int length = vsnprintf((char *) buffer, 256, (char const *) format, vArgs);
|
|
||||||
va_end(vArgs);
|
|
||||||
if (length > 0 && length < 256) {
|
|
||||||
if (host_connected) {
|
|
||||||
for (int i = 0; i < length;) {
|
|
||||||
if (transmit_buffer.write(buffer[i])) {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEC 10
|
|
||||||
#define HEX 16
|
|
||||||
#define OCT 8
|
|
||||||
#define BIN 2
|
|
||||||
|
|
||||||
void print_bin(uint32_t value, uint8_t num_digits) {
|
|
||||||
uint32_t mask = 1 << (num_digits -1);
|
|
||||||
for (uint8_t i = 0; i < num_digits; i++) {
|
|
||||||
if (!(i % 4) && i) write(' ');
|
|
||||||
if (!(i % 16) && i) write(' ');
|
|
||||||
if (value & mask) write('1');
|
|
||||||
else write('0');
|
|
||||||
value <<= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(const char value[]) { printf("%s" , value); }
|
|
||||||
void print(char value, int nbase = 0) {
|
|
||||||
if (nbase == BIN) print_bin(value, 8);
|
|
||||||
else if (nbase == OCT) printf("%3o", value);
|
|
||||||
else if (nbase == HEX) printf("%2X", value);
|
|
||||||
else if (nbase == DEC ) printf("%d", value);
|
|
||||||
else printf("%c" , value);
|
|
||||||
}
|
|
||||||
void print(unsigned char value, int nbase = 0) {
|
|
||||||
if (nbase == BIN) print_bin(value, 8);
|
|
||||||
else if (nbase == OCT) printf("%3o", value);
|
|
||||||
else if (nbase == HEX) printf("%2X", value);
|
|
||||||
else printf("%u" , value);
|
|
||||||
}
|
|
||||||
void print(int value, int nbase = 0) {
|
|
||||||
if (nbase == BIN) print_bin(value, 16);
|
|
||||||
else if (nbase == OCT) printf("%6o", value);
|
|
||||||
else if (nbase == HEX) printf("%4X", value);
|
|
||||||
else printf("%d", value);
|
|
||||||
}
|
|
||||||
void print(unsigned int value, int nbase = 0) {
|
|
||||||
if (nbase == BIN) print_bin(value, 16);
|
|
||||||
else if (nbase == OCT) printf("%6o", value);
|
|
||||||
else if (nbase == HEX) printf("%4X", value);
|
|
||||||
else printf("%u" , value);
|
|
||||||
}
|
|
||||||
void print(long value, int nbase = 0) {
|
|
||||||
if (nbase == BIN) print_bin(value, 32);
|
|
||||||
else if (nbase == OCT) printf("%11o", value);
|
|
||||||
else if (nbase == HEX) printf("%8X", value);
|
|
||||||
else printf("%ld" , value);
|
|
||||||
}
|
|
||||||
void print(unsigned long value, int nbase = 0) {
|
|
||||||
if (nbase == BIN) print_bin(value, 32);
|
|
||||||
else if (nbase == OCT) printf("%11o", value);
|
|
||||||
else if (nbase == HEX) printf("%8X", value);
|
|
||||||
else printf("%lu" , value);
|
|
||||||
}
|
|
||||||
void print(float value, int round = 6) { printf("%f" , value); }
|
|
||||||
void print(double value, int round = 6) { printf("%f" , value); }
|
|
||||||
|
|
||||||
void println(const char value[]) { printf("%s\n" , value); }
|
|
||||||
void println(char value, int nbase = 0) { print(value, nbase); println(); }
|
|
||||||
void println(unsigned char value, int nbase = 0) { print(value, nbase); println(); }
|
|
||||||
void println(int value, int nbase = 0) { print(value, nbase); println(); }
|
|
||||||
void println(unsigned int value, int nbase = 0) { print(value, nbase); println(); }
|
|
||||||
void println(long value, int nbase = 0) { print(value, nbase); println(); }
|
|
||||||
void println(unsigned long value, int nbase = 0) { print(value, nbase); println(); }
|
|
||||||
void println(float value, int round = 6) { printf("%f\n" , value); }
|
|
||||||
void println(double value, int round = 6) { printf("%f\n" , value); }
|
|
||||||
void println() { print('\n'); }
|
|
||||||
|
|
||||||
volatile RingBuffer<uint8_t, 128> receive_buffer;
|
volatile RingBuffer<uint8_t, 128> receive_buffer;
|
||||||
volatile RingBuffer<uint8_t, 128> transmit_buffer;
|
volatile RingBuffer<uint8_t, 128> transmit_buffer;
|
||||||
volatile bool host_connected;
|
volatile bool host_connected;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef Serial1Class<HalSerial> MSerialT;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Marlin 3D Printer Firmware
|
* Marlin 3D Printer Firmware
|
||||||
*
|
|
||||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@@ -106,8 +105,8 @@ int main() {
|
|||||||
std::thread write_serial (write_serial_thread);
|
std::thread write_serial (write_serial_thread);
|
||||||
std::thread read_serial (read_serial_thread);
|
std::thread read_serial (read_serial_thread);
|
||||||
|
|
||||||
#ifdef MYSERIAL0
|
#ifdef MYSERIAL1
|
||||||
MYSERIAL0.begin(BAUDRATE);
|
MYSERIAL1.begin(BAUDRATE);
|
||||||
SERIAL_ECHOLNPGM("x86_64 Initialized");
|
SERIAL_ECHOLNPGM("x86_64 Initialized");
|
||||||
SERIAL_FLUSHTX();
|
SERIAL_FLUSHTX();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,322 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2020 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/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifdef TARGET_LPC1768
|
|
||||||
|
|
||||||
#include "../../core/macros.h"
|
|
||||||
#include "../../core/serial.h"
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include "../shared/backtrace/unwinder.h"
|
|
||||||
#include "../shared/backtrace/unwmemaccess.h"
|
|
||||||
#include "watchdog.h"
|
|
||||||
#include <debug_frmwrk.h>
|
|
||||||
|
|
||||||
|
|
||||||
// Debug monitor that dumps to the Programming port all status when
|
|
||||||
// an exception or WDT timeout happens - And then resets the board
|
|
||||||
|
|
||||||
// All the Monitor routines must run with interrupts disabled and
|
|
||||||
// under an ISR execution context. That is why we cannot reuse the
|
|
||||||
// Serial interrupt routines or any C runtime, as we don't know the
|
|
||||||
// state we are when running them
|
|
||||||
|
|
||||||
// A SW memory barrier, to ensure GCC does not overoptimize loops
|
|
||||||
#define sw_barrier() __asm__ volatile("": : :"memory");
|
|
||||||
|
|
||||||
// (re)initialize UART0 as a monitor output to 250000,n,8,1
|
|
||||||
static void TXBegin() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send character through UART with no interrupts
|
|
||||||
static void TX(char c) {
|
|
||||||
_DBC(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send String through UART
|
|
||||||
static void TX(const char* s) {
|
|
||||||
while (*s) TX(*s++);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TXDigit(uint32_t d) {
|
|
||||||
if (d < 10) TX((char)(d+'0'));
|
|
||||||
else if (d < 16) TX((char)(d+'A'-10));
|
|
||||||
else TX('?');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send Hex number thru UART
|
|
||||||
static void TXHex(uint32_t v) {
|
|
||||||
TX("0x");
|
|
||||||
for (uint8_t i = 0; i < 8; i++, v <<= 4)
|
|
||||||
TXDigit((v >> 28) & 0xF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send Decimal number thru UART
|
|
||||||
static void TXDec(uint32_t v) {
|
|
||||||
if (!v) {
|
|
||||||
TX('0');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char nbrs[14];
|
|
||||||
char *p = &nbrs[0];
|
|
||||||
while (v != 0) {
|
|
||||||
*p++ = '0' + (v % 10);
|
|
||||||
v /= 10;
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
p--;
|
|
||||||
TX(*p);
|
|
||||||
} while (p != &nbrs[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dump a backtrace entry
|
|
||||||
static bool UnwReportOut(void* ctx, const UnwReport* bte) {
|
|
||||||
int* p = (int*)ctx;
|
|
||||||
|
|
||||||
(*p)++;
|
|
||||||
TX('#'); TXDec(*p); TX(" : ");
|
|
||||||
TX(bte->name?bte->name:"unknown"); TX('@'); TXHex(bte->function);
|
|
||||||
TX('+'); TXDec(bte->address - bte->function);
|
|
||||||
TX(" PC:");TXHex(bte->address); TX('\n');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef UNW_DEBUG
|
|
||||||
void UnwPrintf(const char* format, ...) {
|
|
||||||
char dest[256];
|
|
||||||
va_list argptr;
|
|
||||||
va_start(argptr, format);
|
|
||||||
vsprintf(dest, format, argptr);
|
|
||||||
va_end(argptr);
|
|
||||||
TX(&dest[0]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Table of function pointers for passing to the unwinder */
|
|
||||||
static const UnwindCallbacks UnwCallbacks = {
|
|
||||||
UnwReportOut,
|
|
||||||
UnwReadW,
|
|
||||||
UnwReadH,
|
|
||||||
UnwReadB
|
|
||||||
#ifdef UNW_DEBUG
|
|
||||||
,UnwPrintf
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HardFaultHandler_C:
|
|
||||||
* This is called from the HardFault_HandlerAsm with a pointer the Fault stack
|
|
||||||
* as the parameter. We can then read the values from the stack and place them
|
|
||||||
* into local variables for ease of reading.
|
|
||||||
* We then read the various Fault Status and Address Registers to help decode
|
|
||||||
* cause of the fault.
|
|
||||||
* The function ends with a BKPT instruction to force control back into the debugger
|
|
||||||
*/
|
|
||||||
extern "C"
|
|
||||||
void HardFault_HandlerC(unsigned long *sp, unsigned long lr, unsigned long cause) {
|
|
||||||
|
|
||||||
static const char* causestr[] = {
|
|
||||||
"NMI","Hard","Mem","Bus","Usage","Debug","WDT","RSTC"
|
|
||||||
};
|
|
||||||
|
|
||||||
UnwindFrame btf;
|
|
||||||
|
|
||||||
// Dump report to the Programming port (interrupts are DISABLED)
|
|
||||||
TXBegin();
|
|
||||||
TX("\n\n## Software Fault detected ##\n");
|
|
||||||
TX("Cause: "); TX(causestr[cause]); TX('\n');
|
|
||||||
|
|
||||||
TX("R0 : "); TXHex(((unsigned long)sp[0])); TX('\n');
|
|
||||||
TX("R1 : "); TXHex(((unsigned long)sp[1])); TX('\n');
|
|
||||||
TX("R2 : "); TXHex(((unsigned long)sp[2])); TX('\n');
|
|
||||||
TX("R3 : "); TXHex(((unsigned long)sp[3])); TX('\n');
|
|
||||||
TX("R12 : "); TXHex(((unsigned long)sp[4])); TX('\n');
|
|
||||||
TX("LR : "); TXHex(((unsigned long)sp[5])); TX('\n');
|
|
||||||
TX("PC : "); TXHex(((unsigned long)sp[6])); TX('\n');
|
|
||||||
TX("PSR : "); TXHex(((unsigned long)sp[7])); TX('\n');
|
|
||||||
|
|
||||||
// Configurable Fault Status Register
|
|
||||||
// Consists of MMSR, BFSR and UFSR
|
|
||||||
TX("CFSR : "); TXHex((*((volatile unsigned long *)(0xE000ED28)))); TX('\n');
|
|
||||||
|
|
||||||
// Hard Fault Status Register
|
|
||||||
TX("HFSR : "); TXHex((*((volatile unsigned long *)(0xE000ED2C)))); TX('\n');
|
|
||||||
|
|
||||||
// Debug Fault Status Register
|
|
||||||
TX("DFSR : "); TXHex((*((volatile unsigned long *)(0xE000ED30)))); TX('\n');
|
|
||||||
|
|
||||||
// Auxiliary Fault Status Register
|
|
||||||
TX("AFSR : "); TXHex((*((volatile unsigned long *)(0xE000ED3C)))); TX('\n');
|
|
||||||
|
|
||||||
// Read the Fault Address Registers. These may not contain valid values.
|
|
||||||
// Check BFARVALID/MMARVALID to see if they are valid values
|
|
||||||
// MemManage Fault Address Register
|
|
||||||
TX("MMAR : "); TXHex((*((volatile unsigned long *)(0xE000ED34)))); TX('\n');
|
|
||||||
|
|
||||||
// Bus Fault Address Register
|
|
||||||
TX("BFAR : "); TXHex((*((volatile unsigned long *)(0xE000ED38)))); TX('\n');
|
|
||||||
|
|
||||||
TX("ExcLR: "); TXHex(lr); TX('\n');
|
|
||||||
TX("ExcSP: "); TXHex((unsigned long)sp); TX('\n');
|
|
||||||
|
|
||||||
btf.sp = ((unsigned long)sp) + 8*4; // The original stack pointer
|
|
||||||
btf.fp = btf.sp;
|
|
||||||
btf.lr = ((unsigned long)sp[5]);
|
|
||||||
btf.pc = ((unsigned long)sp[6]) | 1; // Force Thumb, as CORTEX only support it
|
|
||||||
|
|
||||||
// Perform a backtrace
|
|
||||||
TX("\nBacktrace:\n\n");
|
|
||||||
int ctr = 0;
|
|
||||||
UnwindStart(&btf, &UnwCallbacks, &ctr);
|
|
||||||
|
|
||||||
// Disable all NVIC interrupts
|
|
||||||
NVIC->ICER[0] = 0xFFFFFFFF;
|
|
||||||
NVIC->ICER[1] = 0xFFFFFFFF;
|
|
||||||
|
|
||||||
// Relocate VTOR table to default position
|
|
||||||
SCB->VTOR = 0;
|
|
||||||
|
|
||||||
// Clear cause of reset to prevent entering smoothie bootstrap
|
|
||||||
HAL_clear_reset_source();
|
|
||||||
|
|
||||||
// Restart watchdog
|
|
||||||
#if ENABLED(USE_WATCHDOG)
|
|
||||||
//WDT_Restart(WDT);
|
|
||||||
watchdog_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Reset controller
|
|
||||||
NVIC_SystemReset();
|
|
||||||
|
|
||||||
// Nothing below here is compiled because NVIC_SystemReset loops forever
|
|
||||||
|
|
||||||
for (;;) { TERN_(USE_WATCHDOG, watchdog_init()); }
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
__attribute__((naked)) void NMI_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#0")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void HardFault_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#1")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void MemManage_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#2")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void BusFault_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#3")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void UsageFault_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#4")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void DebugMon_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#5")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is NOT an exception, it is an interrupt handler - Nevertheless, the framing is the same */
|
|
||||||
__attribute__((naked)) void WDT_IRQHandler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#6")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((naked)) void RSTC_Handler() {
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
".syntax unified" "\n\t"
|
|
||||||
A("tst lr, #4")
|
|
||||||
A("ite eq")
|
|
||||||
A("mrseq r0, msp")
|
|
||||||
A("mrsne r0, psp")
|
|
||||||
A("mov r1,lr")
|
|
||||||
A("mov r2,#7")
|
|
||||||
A("b HardFault_HandlerC")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // TARGET_LPC1768
|
|
||||||
@@ -29,6 +29,8 @@
|
|||||||
#include "watchdog.h"
|
#include "watchdog.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DefaultSerial1 USBSerial(false, UsbSerial);
|
||||||
|
|
||||||
uint32_t HAL_adc_reading = 0;
|
uint32_t HAL_adc_reading = 0;
|
||||||
|
|
||||||
// U8glib required functions
|
// U8glib required functions
|
||||||
@@ -61,7 +63,12 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
|
|||||||
return ind > -1 ? ind : dval;
|
return ind > -1 ? ind : dval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flashFirmware(const int16_t) { NVIC_SystemReset(); }
|
void flashFirmware(const int16_t) {
|
||||||
|
delay(500); // Give OS time to disconnect
|
||||||
|
USB_Connect(false); // USB clear connection
|
||||||
|
delay(1000); // Give OS time to notice
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
|
||||||
void HAL_clear_reset_source(void) {
|
void HAL_clear_reset_source(void) {
|
||||||
TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
|
TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
|
||||||
|
|||||||
@@ -60,31 +60,43 @@ extern "C" volatile uint32_t _millis;
|
|||||||
#define ST7920_DELAY_3 DELAY_NS(750)
|
#define ST7920_DELAY_3 DELAY_NS(750)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1;
|
||||||
|
extern DefaultSerial1 USBSerial;
|
||||||
|
|
||||||
#define _MSERIAL(X) MSerial##X
|
#define _MSERIAL(X) MSerial##X
|
||||||
#define MSERIAL(X) _MSERIAL(X)
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
#define MSerial0 MSerial
|
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 UsbSerial
|
#define MYSERIAL1 USBSerial
|
||||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if SERIAL_PORT_2 == -1
|
#if SERIAL_PORT_2 == -1
|
||||||
#define MYSERIAL1 UsbSerial
|
#define MYSERIAL2 USBSerial
|
||||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MMU2_SERIAL_PORT
|
||||||
|
#if MMU2_SERIAL_PORT == -1
|
||||||
|
#define MMU2_SERIAL USBSerial
|
||||||
|
#elif WITHIN(MMU2_SERIAL_PORT, 0, 3)
|
||||||
|
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
|
||||||
|
#else
|
||||||
|
#error "MMU2_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LCD_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if LCD_SERIAL_PORT == -1
|
#if LCD_SERIAL_PORT == -1
|
||||||
#define LCD_SERIAL UsbSerial
|
#define LCD_SERIAL USBSerial
|
||||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||||
#else
|
#else
|
||||||
@@ -204,16 +216,3 @@ void HAL_clear_reset_source(void);
|
|||||||
uint8_t HAL_get_reset_source(void);
|
uint8_t HAL_get_reset_source(void);
|
||||||
|
|
||||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||||
|
|
||||||
// Add strcmp_P if missing
|
|
||||||
#ifndef strcmp_P
|
|
||||||
#define strcmp_P(a, b) strcmp((a), (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef strcat_P
|
|
||||||
#define strcat_P(a, b) strcat((a), (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef strcpy_P
|
|
||||||
#define strcpy_P(a, b) strcpy((a), (b))
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifdef TARGET_LPC1768
|
||||||
|
|
||||||
|
#include "HAL.h"
|
||||||
|
|
||||||
|
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||||
|
|
||||||
|
#include "../shared/HAL_MinSerial.h"
|
||||||
|
#include <debug_frmwrk.h>
|
||||||
|
|
||||||
|
static void TX(char c) { _DBC(c); }
|
||||||
|
void install_min_serial() { HAL_min_serial_out = &TX; }
|
||||||
|
|
||||||
|
#if DISABLED(DYNAMIC_VECTORTABLE)
|
||||||
|
extern "C" {
|
||||||
|
__attribute__((naked)) void JumpHandler_ASM() {
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"b CommonHandler_ASM\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) HardFault_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) BusFault_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) UsageFault_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) MemManage_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"))) NMI_Handler();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // POSTMORTEM_DEBUGGING
|
||||||
|
#endif // TARGET_LPC1768
|
||||||
@@ -24,21 +24,47 @@
|
|||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
#include "MarlinSerial.h"
|
#include "MarlinSerial.h"
|
||||||
|
|
||||||
#if USING_SERIAL_0
|
#if ANY_SERIAL_IS(0)
|
||||||
MarlinSerial MSerial(LPC_UART0);
|
MarlinSerial _MSerial(LPC_UART0);
|
||||||
extern "C" void UART0_IRQHandler() { MSerial.IRQHandler(); }
|
MSerialT MSerial0(true, _MSerial);
|
||||||
|
extern "C" void UART0_IRQHandler() { _MSerial.IRQHandler(); }
|
||||||
#endif
|
#endif
|
||||||
#if USING_SERIAL_1
|
#if ANY_SERIAL_IS(1)
|
||||||
MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
|
MarlinSerial _MSerial1((LPC_UART_TypeDef *) LPC_UART1);
|
||||||
extern "C" void UART1_IRQHandler() { MSerial1.IRQHandler(); }
|
MSerialT MSerial1(true, _MSerial1);
|
||||||
|
extern "C" void UART1_IRQHandler() { _MSerial1.IRQHandler(); }
|
||||||
#endif
|
#endif
|
||||||
#if USING_SERIAL_2
|
#if ANY_SERIAL_IS(2)
|
||||||
MarlinSerial MSerial2(LPC_UART2);
|
MarlinSerial _MSerial2(LPC_UART2);
|
||||||
extern "C" void UART2_IRQHandler() { MSerial2.IRQHandler(); }
|
MSerialT MSerial2(true, _MSerial2);
|
||||||
|
extern "C" void UART2_IRQHandler() { _MSerial2.IRQHandler(); }
|
||||||
#endif
|
#endif
|
||||||
#if USING_SERIAL_3
|
#if ANY_SERIAL_IS(3)
|
||||||
MarlinSerial MSerial3(LPC_UART3);
|
MarlinSerial _MSerial3(LPC_UART3);
|
||||||
extern "C" void UART3_IRQHandler() { MSerial3.IRQHandler(); }
|
MSerialT MSerial3(true, _MSerial3);
|
||||||
|
extern "C" void UART3_IRQHandler() { _MSerial3.IRQHandler(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
|
||||||
|
bool MarlinSerial::recv_callback(const char c) {
|
||||||
|
// Need to figure out which serial port we are and react in consequence (Marlin does not have CONTAINER_OF macro)
|
||||||
|
if (false) {}
|
||||||
|
#if ANY_SERIAL_IS(0)
|
||||||
|
else if (this == &_MSerial) emergency_parser.update(MSerial0.emergency_state, c);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(1)
|
||||||
|
else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(2)
|
||||||
|
else if (this == &_MSerial2) emergency_parser.update(MSerial2.emergency_state, c);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(3)
|
||||||
|
else if (this == &_MSerial3) emergency_parser.update(MSerial3.emergency_state, c);
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TARGET_LPC1768
|
#endif // TARGET_LPC1768
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#if ENABLED(EMERGENCY_PARSER)
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
#include "../../feature/e_parser.h"
|
#include "../../feature/e_parser.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "../../core/serial_hook.h"
|
||||||
|
|
||||||
#ifndef SERIAL_PORT
|
#ifndef SERIAL_PORT
|
||||||
#define SERIAL_PORT 0
|
#define SERIAL_PORT 0
|
||||||
@@ -41,27 +42,26 @@
|
|||||||
|
|
||||||
class MarlinSerial : public HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE> {
|
class MarlinSerial : public HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE> {
|
||||||
public:
|
public:
|
||||||
MarlinSerial(LPC_UART_TypeDef *UARTx) :
|
MarlinSerial(LPC_UART_TypeDef *UARTx) : HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE>(UARTx) { }
|
||||||
HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE>(UARTx)
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
, emergency_state(EmergencyParser::State::EP_RESET)
|
|
||||||
#endif
|
|
||||||
{ }
|
|
||||||
|
|
||||||
void end() {}
|
void end() {}
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
bool recv_callback(const char c) override {
|
bool recv_callback(const char c) override;
|
||||||
emergency_parser.update(emergency_state, c);
|
|
||||||
return true; // do not discard character
|
|
||||||
}
|
|
||||||
|
|
||||||
EmergencyParser::State emergency_state;
|
|
||||||
static inline bool emergency_parser_enabled() { return true; }
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MarlinSerial MSerial;
|
// On LPC176x framework, HardwareSerial does not implement the same interface as Arduino's Serial, so overloads
|
||||||
extern MarlinSerial MSerial1;
|
// of 'available' and 'read' method are not used in this multiple inheritance scenario.
|
||||||
extern MarlinSerial MSerial2;
|
// Instead, use a ForwardSerial here that adapts the interface.
|
||||||
extern MarlinSerial MSerial3;
|
typedef ForwardSerial1Class<MarlinSerial> MSerialT;
|
||||||
|
extern MSerialT MSerial0;
|
||||||
|
extern MSerialT MSerial1;
|
||||||
|
extern MSerialT MSerial2;
|
||||||
|
extern MSerialT MSerial3;
|
||||||
|
|
||||||
|
// Consequently, we can't use a RuntimeSerial either. The workaround would be to use a RuntimeSerial<ForwardSerial<MarlinSerial>> type here
|
||||||
|
// Right now, let's ignore this until it's actually required.
|
||||||
|
#if ENABLED(SERIAL_RUNTIME_HOOK)
|
||||||
|
#error "SERIAL_RUNTIME_HOOK is not yet supported for LPC176x."
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
* Emulate EEPROM storage using Flash Memory
|
* Emulate EEPROM storage using Flash Memory
|
||||||
*
|
*
|
||||||
* Use a single 32K flash sector to store EEPROM data. To reduce the
|
* Use a single 32K flash sector to store EEPROM data. To reduce the
|
||||||
* number of erase operations a simple "levelling" scheme is used that
|
* number of erase operations a simple "leveling" scheme is used that
|
||||||
* maintains a number of EEPROM "slots" within the larger flash sector.
|
* maintains a number of EEPROM "slots" within the larger flash sector.
|
||||||
* Each slot is used in turn and the entire sector is only erased when all
|
* Each slot is used in turn and the entire sector is only erased when all
|
||||||
* slots have been used.
|
* slots have been used.
|
||||||
|
|||||||
@@ -83,17 +83,16 @@ bool PersistentStore::access_finish() {
|
|||||||
static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
|
static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
|
||||||
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
|
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
|
||||||
SERIAL_CHAR(' ');
|
SERIAL_CHAR(' ');
|
||||||
serialprintPGM(rw_str);
|
SERIAL_ECHOPGM_P(rw_str);
|
||||||
SERIAL_ECHOLNPAIR("_data(", pos, ",", int(value), ",", int(size), ", ...)");
|
SERIAL_ECHOLNPAIR("_data(", pos, ",", value, ",", size, ", ...)");
|
||||||
if (total) {
|
if (total) {
|
||||||
SERIAL_ECHOPGM(" f_");
|
SERIAL_ECHOPGM(" f_");
|
||||||
serialprintPGM(rw_str);
|
SERIAL_ECHOPGM_P(rw_str);
|
||||||
SERIAL_ECHOPAIR("()=", int(s), "\n size=", int(size), "\n bytes_");
|
SERIAL_ECHOPAIR("()=", s, "\n size=", size, "\n bytes_");
|
||||||
serialprintPGM(write ? PSTR("written=") : PSTR("read="));
|
SERIAL_ECHOLNPAIR_P(write ? PSTR("written=") : PSTR("read="), total);
|
||||||
SERIAL_ECHOLN(total);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SERIAL_ECHOLNPAIR(" f_lseek()=", int(s));
|
SERIAL_ECHOLNPAIR(" f_lseek()=", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// File function return codes for type FRESULT. This goes away soon, but
|
// File function return codes for type FRESULT. This goes away soon, but
|
||||||
|
|||||||
@@ -26,3 +26,9 @@
|
|||||||
#elif EITHER(I2C_EEPROM, SPI_EEPROM)
|
#elif EITHER(I2C_EEPROM, SPI_EEPROM)
|
||||||
#define USE_SHARED_EEPROM 1
|
#define USE_SHARED_EEPROM 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// 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
|
||||||
|
#define PRINTCOUNTER_SYNC 1
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
/**
|
/**
|
||||||
* Detect an old pins file by checking for old ADC pins values.
|
* Detect an old pins file by checking for old ADC pins values.
|
||||||
*/
|
*/
|
||||||
#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && _CAT(P,_PIN) != 2 && _CAT(P,_PIN) != 3
|
#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !WITHIN(_CAT(P,_PIN), TERN(LPC1768_IS_SKRV1_3, 0, 2), 3) // Include P0_00 and P0_01 for SKR V1.3 board
|
||||||
#if _OLD_TEMP_PIN(TEMP_BED)
|
#if _OLD_TEMP_PIN(TEMP_BED)
|
||||||
#error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
|
#error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
|
||||||
#elif _OLD_TEMP_PIN(TEMP_0)
|
#elif _OLD_TEMP_PIN(TEMP_0)
|
||||||
@@ -92,7 +92,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#define ANY_TX(N,V...) DO(IS_TX##N,||,V)
|
#define ANY_TX(N,V...) DO(IS_TX##N,||,V)
|
||||||
#define ANY_RX(N,V...) DO(IS_RX##N,||,V)
|
#define ANY_RX(N,V...) DO(IS_RX##N,||,V)
|
||||||
|
|
||||||
#if USING_SERIAL_0
|
#if ANY_SERIAL_IS(0)
|
||||||
#define IS_TX0(P) (P == P0_02)
|
#define IS_TX0(P) (P == P0_02)
|
||||||
#define IS_RX0(P) (P == P0_03)
|
#define IS_RX0(P) (P == P0_03)
|
||||||
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
|
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
|
||||||
@@ -106,7 +106,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#undef IS_RX0
|
#undef IS_RX0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USING_SERIAL_1
|
#if ANY_SERIAL_IS(1)
|
||||||
#define IS_TX1(P) (P == P0_15)
|
#define IS_TX1(P) (P == P0_15)
|
||||||
#define IS_RX1(P) (P == P0_16)
|
#define IS_RX1(P) (P == P0_16)
|
||||||
#define _IS_TX1_1 IS_TX1
|
#define _IS_TX1_1 IS_TX1
|
||||||
@@ -116,7 +116,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#elif HAS_WIRED_LCD
|
#elif HAS_WIRED_LCD
|
||||||
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
|
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
|
||||||
#error "Serial port pins (1) conflict with Encoder Buttons!"
|
#error "Serial port pins (1) conflict with Encoder Buttons!"
|
||||||
#elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK) \
|
#elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK_PIN) \
|
||||||
|| ANY_RX(1, LCD_SDSS, LCD_PINS_RS, SD_MISO_PIN, DOGLCD_A0, SD_SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
|
|| ANY_RX(1, LCD_SDSS, LCD_PINS_RS, SD_MISO_PIN, DOGLCD_A0, SD_SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
|
||||||
#error "Serial port pins (1) conflict with LCD pins!"
|
#error "Serial port pins (1) conflict with LCD pins!"
|
||||||
#endif
|
#endif
|
||||||
@@ -127,7 +127,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#undef _IS_RX1_1
|
#undef _IS_RX1_1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USING_SERIAL_2
|
#if ANY_SERIAL_IS(2)
|
||||||
#define IS_TX2(P) (P == P0_10)
|
#define IS_TX2(P) (P == P0_10)
|
||||||
#define IS_RX2(P) (P == P0_11)
|
#define IS_RX2(P) (P == P0_11)
|
||||||
#define _IS_TX2_1 IS_TX2
|
#define _IS_TX2_1 IS_TX2
|
||||||
@@ -161,7 +161,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#undef _IS_RX2_1
|
#undef _IS_RX2_1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USING_SERIAL_3
|
#if ANY_SERIAL_IS(3)
|
||||||
#define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
|
#define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
|
||||||
#define PIN_IS_RX3(P) (P##_PIN == P0_01)
|
#define PIN_IS_RX3(P) (P##_PIN == P0_01)
|
||||||
#if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
|
#if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
|
||||||
@@ -270,7 +270,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
||||||
#error "SERIAL_STATS_MAX_RX_QUEUED is not supported on this platform."
|
#error "SERIAL_STATS_MAX_RX_QUEUED is not supported on LPC176x."
|
||||||
#elif ENABLED(SERIAL_STATS_DROPPED_RX)
|
#elif ENABLED(SERIAL_STATS_DROPPED_RX)
|
||||||
#error "SERIAL_STATS_DROPPED_RX is not supported on this platform."
|
#error "SERIAL_STATS_DROPPED_RX is not supported on LPX176x."
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ extern "C" {
|
|||||||
|
|
||||||
void SysTick_Callback() { disk_timerproc(); }
|
void SysTick_Callback() { disk_timerproc(); }
|
||||||
|
|
||||||
|
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
|
||||||
|
|
||||||
void HAL_init() {
|
void HAL_init() {
|
||||||
|
|
||||||
// Init LEDs
|
// Init LEDs
|
||||||
@@ -119,13 +121,11 @@ void HAL_init() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
USB_Init(); // USB Initialization
|
USB_Init(); // USB Initialization
|
||||||
USB_Connect(FALSE); // USB clear connection
|
USB_Connect(false); // USB clear connection
|
||||||
delay(1000); // Give OS time to notice
|
delay(1000); // Give OS time to notice
|
||||||
USB_Connect(TRUE);
|
USB_Connect(true);
|
||||||
|
|
||||||
#if HAS_SD_HOST_DRIVE
|
TERN_(HAS_SD_HOST_DRIVE, MSC_SD_Init(0)); // Enable USB SD card access
|
||||||
MSC_SD_Init(0); // Enable USB SD card access
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const millis_t usb_timeout = millis() + 2000;
|
const millis_t usb_timeout = millis() + 2000;
|
||||||
while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
|
while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
|
||||||
@@ -137,6 +137,8 @@ void HAL_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HAL_timer_init();
|
HAL_timer_init();
|
||||||
|
|
||||||
|
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
|
||||||
}
|
}
|
||||||
|
|
||||||
// HAL idle task
|
// HAL idle task
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ FORCE_INLINE static void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
|||||||
|
|
||||||
// This function is missing from CMSIS
|
// This function is missing from CMSIS
|
||||||
FORCE_INLINE static bool NVIC_GetEnableIRQ(IRQn_Type IRQn) {
|
FORCE_INLINE static bool NVIC_GetEnableIRQ(IRQn_Type IRQn) {
|
||||||
return (NVIC->ISER[((uint32_t)IRQn) >> 5] & (1 << ((uint32_t)IRQn) & 0x1F)) != 0;
|
return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE static bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
FORCE_INLINE static bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ from __future__ import print_function
|
|||||||
target_filename = "FIRMWARE.CUR"
|
target_filename = "FIRMWARE.CUR"
|
||||||
target_drive = "REARM"
|
target_drive = "REARM"
|
||||||
|
|
||||||
import os
|
import os,getpass,platform
|
||||||
import getpass
|
|
||||||
import platform
|
|
||||||
|
|
||||||
current_OS = platform.system()
|
current_OS = platform.system()
|
||||||
Import("env")
|
Import("env")
|
||||||
@@ -33,9 +31,8 @@ try:
|
|||||||
#
|
#
|
||||||
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
|
# 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
|
# Windows - doesn't care about the disk's name, only cares about the drive letter
|
||||||
import subprocess
|
import subprocess,string
|
||||||
from ctypes import windll
|
from ctypes import windll
|
||||||
import string
|
|
||||||
|
|
||||||
# getting list of drives
|
# getting list of drives
|
||||||
# https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
|
# https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
|
|
||||||
EmergencyParser::State emergency_state;
|
EmergencyParser::State emergency_state;
|
||||||
|
|
||||||
bool CDC_RecvCallback(const char buffer) {
|
bool CDC_RecvCallback(const char c) {
|
||||||
emergency_parser.update(emergency_state, buffer);
|
emergency_parser.update(emergency_state, c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,24 @@
|
|||||||
#include <Adafruit_ZeroDMA.h>
|
#include <Adafruit_ZeroDMA.h>
|
||||||
#include <wiring_private.h>
|
#include <wiring_private.h>
|
||||||
|
|
||||||
|
#ifdef ADAFRUIT_GRAND_CENTRAL_M4
|
||||||
|
#if ANY_SERIAL_IS(-1)
|
||||||
|
DefaultSerial1 MSerial0(false, Serial);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(0)
|
||||||
|
DefaultSerial2 MSerial1(false, Serial1);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(1)
|
||||||
|
DefaultSerial3 MSerial2(false, Serial2);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(2)
|
||||||
|
DefaultSerial4 MSerial3(false, Serial3);
|
||||||
|
#endif
|
||||||
|
#if ANY_SERIAL_IS(3)
|
||||||
|
DefaultSerial5 MSerial4(false, Serial4);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Local defines
|
// Local defines
|
||||||
// ------------------------
|
// ------------------------
|
||||||
@@ -39,6 +57,7 @@
|
|||||||
#define GET_PROBE_ADC() TERN(HAS_TEMP_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1)
|
#define GET_PROBE_ADC() TERN(HAS_TEMP_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1)
|
||||||
#define GET_BED_ADC() TERN(HAS_TEMP_ADC_BED, PIN_TO_ADC(TEMP_BED_PIN), -1)
|
#define GET_BED_ADC() TERN(HAS_TEMP_ADC_BED, PIN_TO_ADC(TEMP_BED_PIN), -1)
|
||||||
#define GET_CHAMBER_ADC() TERN(HAS_TEMP_ADC_CHAMBER, PIN_TO_ADC(TEMP_CHAMBER_PIN), -1)
|
#define GET_CHAMBER_ADC() TERN(HAS_TEMP_ADC_CHAMBER, PIN_TO_ADC(TEMP_CHAMBER_PIN), -1)
|
||||||
|
#define GET_COOLER_ADC() TERN(HAS_TEMP_ADC_COOLER, PIN_TO_ADC(TEMP_COOLER_PIN), -1)
|
||||||
#define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1)
|
#define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1)
|
||||||
#define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1)
|
#define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1)
|
||||||
|
|
||||||
@@ -48,6 +67,7 @@
|
|||||||
|| GET_PROBE_ADC() == n \
|
|| GET_PROBE_ADC() == n \
|
||||||
|| GET_BED_ADC() == n \
|
|| GET_BED_ADC() == n \
|
||||||
|| GET_CHAMBER_ADC() == n \
|
|| GET_CHAMBER_ADC() == n \
|
||||||
|
|| GET_COOLER_ADC() == n \
|
||||||
|| GET_FILAMENT_WIDTH_ADC() == n \
|
|| GET_FILAMENT_WIDTH_ADC() == n \
|
||||||
|| GET_BUTTONS_ADC() == n \
|
|| GET_BUTTONS_ADC() == n \
|
||||||
)
|
)
|
||||||
@@ -126,6 +146,9 @@ uint16_t HAL_adc_result;
|
|||||||
#if GET_CHAMBER_ADC() == 0
|
#if GET_CHAMBER_ADC() == 0
|
||||||
TEMP_CHAMBER_PIN,
|
TEMP_CHAMBER_PIN,
|
||||||
#endif
|
#endif
|
||||||
|
#if GET_COOLER_ADC() == 0
|
||||||
|
TEMP_COOLER_PIN,
|
||||||
|
#endif
|
||||||
#if GET_FILAMENT_WIDTH_ADC() == 0
|
#if GET_FILAMENT_WIDTH_ADC() == 0
|
||||||
FILWIDTH_PIN,
|
FILWIDTH_PIN,
|
||||||
#endif
|
#endif
|
||||||
@@ -166,6 +189,9 @@ uint16_t HAL_adc_result;
|
|||||||
#if GET_CHAMBER_ADC() == 1
|
#if GET_CHAMBER_ADC() == 1
|
||||||
TEMP_CHAMBER_PIN,
|
TEMP_CHAMBER_PIN,
|
||||||
#endif
|
#endif
|
||||||
|
#if GET_COOLER_ADC() == 1
|
||||||
|
TEMP_COOLER_PIN,
|
||||||
|
#endif
|
||||||
#if GET_FILAMENT_WIDTH_ADC() == 1
|
#if GET_FILAMENT_WIDTH_ADC() == 1
|
||||||
FILWIDTH_PIN,
|
FILWIDTH_PIN,
|
||||||
#endif
|
#endif
|
||||||
@@ -214,6 +240,9 @@ uint16_t HAL_adc_result;
|
|||||||
#if GET_CHAMBER_ADC() == 0
|
#if GET_CHAMBER_ADC() == 0
|
||||||
{ PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) },
|
{ PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) },
|
||||||
#endif
|
#endif
|
||||||
|
#if GET_COOLER_ADC() == 0
|
||||||
|
{ PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) },
|
||||||
|
#endif
|
||||||
#if GET_FILAMENT_WIDTH_ADC() == 0
|
#if GET_FILAMENT_WIDTH_ADC() == 0
|
||||||
{ PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
|
{ PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
|
||||||
#endif
|
#endif
|
||||||
@@ -263,6 +292,9 @@ uint16_t HAL_adc_result;
|
|||||||
#if GET_CHAMBER_ADC() == 1
|
#if GET_CHAMBER_ADC() == 1
|
||||||
{ PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) },
|
{ PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) },
|
||||||
#endif
|
#endif
|
||||||
|
#if GET_COOLER_ADC() == 1
|
||||||
|
{ PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) },
|
||||||
|
#endif
|
||||||
#if GET_FILAMENT_WIDTH_ADC() == 1
|
#if GET_FILAMENT_WIDTH_ADC() == 1
|
||||||
{ PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
|
{ PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,34 +32,54 @@
|
|||||||
#include "MarlinSerial_AGCM4.h"
|
#include "MarlinSerial_AGCM4.h"
|
||||||
|
|
||||||
// Serial ports
|
// Serial ports
|
||||||
|
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||||
|
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||||
|
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||||
|
typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4;
|
||||||
|
typedef ForwardSerial1Class< decltype(Serial4) > DefaultSerial5;
|
||||||
|
extern DefaultSerial1 MSerial0;
|
||||||
|
extern DefaultSerial2 MSerial1;
|
||||||
|
extern DefaultSerial3 MSerial2;
|
||||||
|
extern DefaultSerial4 MSerial3;
|
||||||
|
extern DefaultSerial5 MSerial4;
|
||||||
|
|
||||||
// MYSERIAL0 required before MarlinSerial includes!
|
// MYSERIAL1 required before MarlinSerial includes!
|
||||||
|
|
||||||
#define __MSERIAL(X) Serial##X
|
#define __MSERIAL(X) MSerial##X
|
||||||
#define _MSERIAL(X) __MSERIAL(X)
|
#define _MSERIAL(X) __MSERIAL(X)
|
||||||
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 Serial
|
#define MYSERIAL1 MSerial0
|
||||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if SERIAL_PORT_2 == -1
|
#if SERIAL_PORT_2 == -1
|
||||||
#define MYSERIAL1 Serial
|
#define MYSERIAL2 MSerial0
|
||||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MMU2_SERIAL_PORT
|
||||||
|
#if MMU2_SERIAL_PORT == -1
|
||||||
|
#define MMU2_SERIAL MSerial0
|
||||||
|
#elif WITHIN(MMU2_SERIAL_PORT, 0, 3)
|
||||||
|
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
|
||||||
|
#else
|
||||||
|
#error "MMU2_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LCD_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if LCD_SERIAL_PORT == -1
|
#if LCD_SERIAL_PORT == -1
|
||||||
#define LCD_SERIAL Serial
|
#define LCD_SERIAL MSerial0
|
||||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -21,30 +21,30 @@
|
|||||||
#ifdef ADAFRUIT_GRAND_CENTRAL_M4
|
#ifdef ADAFRUIT_GRAND_CENTRAL_M4
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Framework doesn't define some serial to save sercom resources
|
* Framework doesn't define some serials to save sercom resources
|
||||||
* hence if these are used I need to define them
|
* hence if these are used I need to define them
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1
|
#if ANY_SERIAL_IS(1)
|
||||||
Uart Serial2(&sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX);
|
UartT Serial2(false, &sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX);
|
||||||
void SERCOM4_0_Handler() { Serial2.IrqHandler(); }
|
void SERCOM4_0_Handler() { Serial2.IrqHandler(); }
|
||||||
void SERCOM4_1_Handler() { Serial2.IrqHandler(); }
|
void SERCOM4_1_Handler() { Serial2.IrqHandler(); }
|
||||||
void SERCOM4_2_Handler() { Serial2.IrqHandler(); }
|
void SERCOM4_2_Handler() { Serial2.IrqHandler(); }
|
||||||
void SERCOM4_3_Handler() { Serial2.IrqHandler(); }
|
void SERCOM4_3_Handler() { Serial2.IrqHandler(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2
|
#if ANY_SERIAL_IS(2)
|
||||||
Uart Serial3(&sercom1, PIN_SERIAL3_RX, PIN_SERIAL3_TX, PAD_SERIAL3_RX, PAD_SERIAL3_TX);
|
UartT Serial3(false, &sercom1, PIN_SERIAL3_RX, PIN_SERIAL3_TX, PAD_SERIAL3_RX, PAD_SERIAL3_TX);
|
||||||
void SERCOM1_0_Handler() { Serial3.IrqHandler(); }
|
void SERCOM1_0_Handler() { Serial3.IrqHandler(); }
|
||||||
void SERCOM1_1_Handler() { Serial3.IrqHandler(); }
|
void SERCOM1_1_Handler() { Serial3.IrqHandler(); }
|
||||||
void SERCOM1_2_Handler() { Serial3.IrqHandler(); }
|
void SERCOM1_2_Handler() { Serial3.IrqHandler(); }
|
||||||
void SERCOM1_3_Handler() { Serial3.IrqHandler(); }
|
void SERCOM1_3_Handler() { Serial3.IrqHandler(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3
|
#if ANY_SERIAL_IS(3)
|
||||||
Uart Serial4(&sercom5, PIN_SERIAL4_RX, PIN_SERIAL4_TX, PAD_SERIAL4_RX, PAD_SERIAL4_TX);
|
UartT Serial4(false, &sercom5, PIN_SERIAL4_RX, PIN_SERIAL4_TX, PAD_SERIAL4_RX, PAD_SERIAL4_TX);
|
||||||
void SERCOM5_0_Handler() { Serial4.IrqHandler(); }
|
void SERCOM5_0_Handler() { Serial4.IrqHandler(); }
|
||||||
void SERCOM5_1_Handler() { Serial4.IrqHandler(); }
|
void SERCOM5_1_Handler() { Serial4.IrqHandler(); }
|
||||||
void SERCOM5_2_Handler() { Serial4.IrqHandler(); }
|
void SERCOM5_2_Handler() { Serial4.IrqHandler(); }
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
extern Uart Serial2;
|
#include "../../core/serial_hook.h"
|
||||||
extern Uart Serial3;
|
|
||||||
extern Uart Serial4;
|
typedef Serial1Class<Uart> UartT;
|
||||||
|
|
||||||
|
extern UartT Serial2;
|
||||||
|
extern UartT Serial3;
|
||||||
|
extern UartT Serial4;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MASK
|
#ifndef MASK
|
||||||
#define MASK(PIN) (1 << PIN)
|
#define MASK(PIN) _BV(PIN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -50,3 +50,7 @@
|
|||||||
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
|
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
|
||||||
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on SAMD51."
|
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on SAMD51."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||||
|
#error "POSTMORTEM_DEBUGGING is not yet supported on AGCM4."
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
|||||||
|
|
||||||
// missing from CMSIS: Check if interrupt is enabled or not
|
// missing from CMSIS: Check if interrupt is enabled or not
|
||||||
static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
|
static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
|
||||||
return (NVIC->ISER[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F))) != 0;
|
return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||||
|
|||||||
@@ -28,6 +28,10 @@
|
|||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
#include "../shared/Delay.h"
|
#include "../shared/Delay.h"
|
||||||
|
|
||||||
|
#ifdef USBCON
|
||||||
|
DefaultSerial1 MSerial0(false, SerialUSB);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SRAM_EEPROM_EMULATION)
|
#if ENABLED(SRAM_EEPROM_EMULATION)
|
||||||
#if STM32F7xx
|
#if STM32F7xx
|
||||||
#include <stm32f7xx_ll_pwr.h>
|
#include <stm32f7xx_ll_pwr.h>
|
||||||
@@ -38,6 +42,11 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAS_SD_HOST_DRIVE
|
||||||
|
#include "msc_sd.h"
|
||||||
|
#include "usbd_cdc_if.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Public Variables
|
// Public Variables
|
||||||
// ------------------------
|
// ------------------------
|
||||||
@@ -48,21 +57,18 @@ uint16_t HAL_adc_result;
|
|||||||
// Public functions
|
// Public functions
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
// Needed for DELAY_NS() / DELAY_US() on CORTEX-M7
|
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
|
||||||
#if (defined(__arm__) || defined(__thumb__)) && __CORTEX_M == 7
|
|
||||||
// HAL pre-initialization task
|
|
||||||
// Force the preinit function to run between the premain() and main() function
|
|
||||||
// of the STM32 arduino core
|
|
||||||
__attribute__((constructor (102)))
|
|
||||||
void HAL_preinit() {
|
|
||||||
enableCycleCounter();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// HAL initialization task
|
// HAL initialization task
|
||||||
void HAL_init() {
|
void HAL_init() {
|
||||||
FastIO_init();
|
FastIO_init();
|
||||||
|
|
||||||
|
// Ensure F_CPU is a constant expression.
|
||||||
|
// If the compiler breaks here, it means that delay code that should compute at compile time will not work.
|
||||||
|
// So better safe than sorry here.
|
||||||
|
constexpr int cpuFreq = F_CPU;
|
||||||
|
UNUSED(cpuFreq);
|
||||||
|
|
||||||
#if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT) && (defined(SDSS) && SDSS != -1)
|
#if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT) && (defined(SDSS) && SDSS != -1)
|
||||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||||
#endif
|
#endif
|
||||||
@@ -84,6 +90,21 @@ void HAL_init() {
|
|||||||
#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC
|
#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC
|
||||||
USB_Hook_init();
|
USB_Hook_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
|
||||||
|
|
||||||
|
#if HAS_SD_HOST_DRIVE
|
||||||
|
MSC_SD_init(); // Enable USB SD card access
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// HAL idle task
|
||||||
|
void HAL_idletask() {
|
||||||
|
#if HAS_SHARED_MEDIA
|
||||||
|
// Stm32duino currently doesn't have a "loop/idle" method
|
||||||
|
CDC_resume_receive();
|
||||||
|
CDC_continue_transmit();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
||||||
|
|||||||
+21
-13
@@ -39,6 +39,9 @@
|
|||||||
|
|
||||||
#ifdef USBCON
|
#ifdef USBCON
|
||||||
#include <USBSerial.h>
|
#include <USBSerial.h>
|
||||||
|
#include "../../core/serial_hook.h"
|
||||||
|
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
|
||||||
|
extern DefaultSerial1 MSerial0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
@@ -48,26 +51,36 @@
|
|||||||
#define MSERIAL(X) _MSERIAL(X)
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 SerialUSB
|
#define MYSERIAL1 MSerial0
|
||||||
#elif WITHIN(SERIAL_PORT, 1, 6)
|
#elif WITHIN(SERIAL_PORT, 1, 6)
|
||||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
|
#error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if SERIAL_PORT_2 == -1
|
#if SERIAL_PORT_2 == -1
|
||||||
#define MYSERIAL1 SerialUSB
|
#define MYSERIAL2 MSerial0
|
||||||
#elif WITHIN(SERIAL_PORT_2, 1, 6)
|
#elif WITHIN(SERIAL_PORT_2, 1, 6)
|
||||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration."
|
#error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MMU2_SERIAL_PORT
|
||||||
|
#if MMU2_SERIAL_PORT == -1
|
||||||
|
#define MMU2_SERIAL MSerial0
|
||||||
|
#elif WITHIN(MMU2_SERIAL_PORT, 1, 6)
|
||||||
|
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
|
||||||
|
#else
|
||||||
|
#error "MMU2_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LCD_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if LCD_SERIAL_PORT == -1
|
#if LCD_SERIAL_PORT == -1
|
||||||
#define LCD_SERIAL SerialUSB
|
#define LCD_SERIAL MSerial0
|
||||||
#elif WITHIN(LCD_SERIAL_PORT, 1, 6)
|
#elif WITHIN(LCD_SERIAL_PORT, 1, 6)
|
||||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||||
#else
|
#else
|
||||||
@@ -96,14 +109,6 @@
|
|||||||
// On AVR this is in math.h?
|
// On AVR this is in math.h?
|
||||||
#define square(x) ((x)*(x))
|
#define square(x) ((x)*(x))
|
||||||
|
|
||||||
#ifndef strncpy_P
|
|
||||||
#define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Fix bug in pgm_read_ptr
|
|
||||||
#undef pgm_read_ptr
|
|
||||||
#define pgm_read_ptr(addr) (*(addr))
|
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Types
|
// Types
|
||||||
// ------------------------
|
// ------------------------
|
||||||
@@ -130,6 +135,8 @@ extern uint16_t HAL_adc_result;
|
|||||||
|
|
||||||
// Enable hooks into setup for HAL
|
// Enable hooks into setup for HAL
|
||||||
void HAL_init();
|
void HAL_init();
|
||||||
|
#define HAL_IDLETASK 1
|
||||||
|
void HAL_idletask();
|
||||||
|
|
||||||
// Clear reset reason
|
// Clear reset reason
|
||||||
void HAL_clear_reset_source();
|
void HAL_clear_reset_source();
|
||||||
@@ -187,6 +194,7 @@ void flashFirmware(const int16_t);
|
|||||||
typedef void (*systickCallback_t)(void);
|
typedef void (*systickCallback_t)(void);
|
||||||
void systick_attach_callback(systickCallback_t cb);
|
void systick_attach_callback(systickCallback_t cb);
|
||||||
void HAL_SYSTICK_Callback();
|
void HAL_SYSTICK_Callback();
|
||||||
|
|
||||||
extern volatile uint32_t systick_uptime_millis;
|
extern volatile uint32_t systick_uptime_millis;
|
||||||
|
|
||||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
* Copyright (c) 2017 Victor Perez
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
|
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||||
|
|
||||||
|
#include "../shared/HAL_MinSerial.h"
|
||||||
|
#include "watchdog.h"
|
||||||
|
|
||||||
|
/* Instruction Synchronization Barrier */
|
||||||
|
#define isb() __asm__ __volatile__ ("isb" : : : "memory")
|
||||||
|
|
||||||
|
/* Data Synchronization Barrier */
|
||||||
|
#define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
|
||||||
|
|
||||||
|
// Dumb mapping over the registers of a USART device on STM32
|
||||||
|
struct USARTMin {
|
||||||
|
volatile uint32_t SR;
|
||||||
|
volatile uint32_t DR;
|
||||||
|
volatile uint32_t BRR;
|
||||||
|
volatile uint32_t CR1;
|
||||||
|
volatile uint32_t CR2;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if WITHIN(SERIAL_PORT, 1, 6)
|
||||||
|
// Depending on the CPU, the serial port is different for USART1
|
||||||
|
static const uintptr_t regsAddr[] = {
|
||||||
|
TERN(STM32F1xx, 0x40013800, 0x40011000), // USART1
|
||||||
|
0x40004400, // USART2
|
||||||
|
0x40004800, // USART3
|
||||||
|
0x40004C00, // UART4_BASE
|
||||||
|
0x40005000, // UART5_BASE
|
||||||
|
0x40011400 // USART6
|
||||||
|
};
|
||||||
|
static USARTMin * regs = (USARTMin*)regsAddr[SERIAL_PORT - 1];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void TXBegin() {
|
||||||
|
#if !WITHIN(SERIAL_PORT, 1, 6)
|
||||||
|
#warning "Using POSTMORTEM_DEBUGGING requires a physical U(S)ART hardware in case of severe error."
|
||||||
|
#warning "Disabling the severe error reporting feature currently because the used serial port is not a HW port."
|
||||||
|
#else
|
||||||
|
// This is common between STM32F1/STM32F2 and STM32F4
|
||||||
|
const int nvicUART[] = { /* NVIC_USART1 */ 37, /* NVIC_USART2 */ 38, /* NVIC_USART3 */ 39, /* NVIC_UART4 */ 52, /* NVIC_UART5 */ 53, /* NVIC_USART6 */ 71 };
|
||||||
|
int nvicIndex = nvicUART[SERIAL_PORT - 1];
|
||||||
|
|
||||||
|
struct NVICMin {
|
||||||
|
volatile uint32_t ISER[32];
|
||||||
|
volatile uint32_t ICER[32];
|
||||||
|
};
|
||||||
|
|
||||||
|
NVICMin * nvicBase = (NVICMin*)0xE000E100;
|
||||||
|
nvicBase->ICER[nvicIndex / 32] |= _BV32(nvicIndex % 32);
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
// Example for USART1 disable: (RCC->APB2ENR &= ~(RCC_APB2ENR_USART1EN))
|
||||||
|
// Too difficult to reimplement here, let's query the STM32duino macro here
|
||||||
|
#if SERIAL_PORT == 1
|
||||||
|
__HAL_RCC_USART1_CLK_DISABLE();
|
||||||
|
__HAL_RCC_USART1_CLK_ENABLE();
|
||||||
|
#elif SERIAL_PORT == 2
|
||||||
|
__HAL_RCC_USART2_CLK_DISABLE();
|
||||||
|
__HAL_RCC_USART2_CLK_ENABLE();
|
||||||
|
#elif SERIAL_PORT == 3
|
||||||
|
__HAL_RCC_USART3_CLK_DISABLE();
|
||||||
|
__HAL_RCC_USART3_CLK_ENABLE();
|
||||||
|
#elif SERIAL_PORT == 4
|
||||||
|
__HAL_RCC_UART4_CLK_DISABLE(); // BEWARE: UART4 and not USART4 here
|
||||||
|
__HAL_RCC_UART4_CLK_ENABLE();
|
||||||
|
#elif SERIAL_PORT == 5
|
||||||
|
__HAL_RCC_UART5_CLK_DISABLE(); // BEWARE: UART5 and not USART5 here
|
||||||
|
__HAL_RCC_UART5_CLK_ENABLE();
|
||||||
|
#elif SERIAL_PORT == 6
|
||||||
|
__HAL_RCC_USART6_CLK_DISABLE();
|
||||||
|
__HAL_RCC_USART6_CLK_ENABLE();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint32_t brr = regs->BRR;
|
||||||
|
regs->CR1 = 0; // Reset the USART
|
||||||
|
regs->CR2 = 0; // 1 stop bit
|
||||||
|
|
||||||
|
// If we don't touch the BRR (baudrate register), we don't need to recompute.
|
||||||
|
regs->BRR = brr;
|
||||||
|
|
||||||
|
regs->CR1 = _BV(3) | _BV(13); // 8 bits, no parity, 1 stop bit (TE | UE)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// A SW memory barrier, to ensure GCC does not overoptimize loops
|
||||||
|
#define sw_barrier() __asm__ volatile("": : :"memory");
|
||||||
|
static void TX(char c) {
|
||||||
|
#if WITHIN(SERIAL_PORT, 1, 6)
|
||||||
|
constexpr uint32_t usart_sr_txe = _BV(7);
|
||||||
|
while (!(regs->SR & usart_sr_txe)) {
|
||||||
|
TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
|
||||||
|
sw_barrier();
|
||||||
|
}
|
||||||
|
regs->DR = c;
|
||||||
|
#else
|
||||||
|
// Let's hope a mystical guru will fix this, one day by writting interrupt-free USB CDC ACM code (or, at least, by polling the registers since interrupt will be queued but will never trigger)
|
||||||
|
// For now, it's completely lost to oblivion.
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void install_min_serial() {
|
||||||
|
HAL_min_serial_init = &TXBegin;
|
||||||
|
HAL_min_serial_out = &TX;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DISABLED(DYNAMIC_VECTORTABLE) && DISABLED(STM32F0xx) // Cortex M0 can't jump to a symbol that's too far from the current function, so we work around this in exception_arm.cpp
|
||||||
|
extern "C" {
|
||||||
|
__attribute__((naked)) void JumpHandler_ASM() {
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"b CommonHandler_ASM\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) HardFault_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) BusFault_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) UsageFault_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) MemManage_Handler();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) NMI_Handler();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // POSTMORTEM_DEBUGGING
|
||||||
|
#endif // ARDUINO_ARCH_STM32
|
||||||
@@ -51,18 +51,28 @@ static SPISettings spiConfig;
|
|||||||
OUT_WRITE(SD_MOSI_PIN, HIGH);
|
OUT_WRITE(SD_MOSI_PIN, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t delay_STM32_soft_spi;
|
// Use function with compile-time value so we can actually reach the desired frequency
|
||||||
|
// Need to adjust this a little bit: on a 72MHz clock, we have 14ns/clock
|
||||||
|
// and we'll use ~3 cycles to jump to the method and going back, so it'll take ~40ns from the given clock here
|
||||||
|
#define CALLING_COST_NS (3U * 1000000000U) / (F_CPU)
|
||||||
|
void (*delaySPIFunc)();
|
||||||
|
void delaySPI_125() { DELAY_NS(125 - CALLING_COST_NS); }
|
||||||
|
void delaySPI_250() { DELAY_NS(250 - CALLING_COST_NS); }
|
||||||
|
void delaySPI_500() { DELAY_NS(500 - CALLING_COST_NS); }
|
||||||
|
void delaySPI_1000() { DELAY_NS(1000 - CALLING_COST_NS); }
|
||||||
|
void delaySPI_2000() { DELAY_NS(2000 - CALLING_COST_NS); }
|
||||||
|
void delaySPI_4000() { DELAY_NS(4000 - CALLING_COST_NS); }
|
||||||
|
|
||||||
void spiInit(uint8_t spiRate) {
|
void spiInit(uint8_t spiRate) {
|
||||||
// Use datarates Marlin uses
|
// Use datarates Marlin uses
|
||||||
switch (spiRate) {
|
switch (spiRate) {
|
||||||
case SPI_FULL_SPEED: delay_STM32_soft_spi = 125; break; // desired: 8,000,000 actual: ~1.1M
|
case SPI_FULL_SPEED: delaySPIFunc = &delaySPI_125; break; // desired: 8,000,000 actual: ~1.1M
|
||||||
case SPI_HALF_SPEED: delay_STM32_soft_spi = 125; break; // desired: 4,000,000 actual: ~1.1M
|
case SPI_HALF_SPEED: delaySPIFunc = &delaySPI_125; break; // desired: 4,000,000 actual: ~1.1M
|
||||||
case SPI_QUARTER_SPEED:delay_STM32_soft_spi = 250; break; // desired: 2,000,000 actual: ~890K
|
case SPI_QUARTER_SPEED:delaySPIFunc = &delaySPI_250; break; // desired: 2,000,000 actual: ~890K
|
||||||
case SPI_EIGHTH_SPEED: delay_STM32_soft_spi = 500; break; // desired: 1,000,000 actual: ~590K
|
case SPI_EIGHTH_SPEED: delaySPIFunc = &delaySPI_500; break; // desired: 1,000,000 actual: ~590K
|
||||||
case SPI_SPEED_5: delay_STM32_soft_spi = 1000; break; // desired: 500,000 actual: ~360K
|
case SPI_SPEED_5: delaySPIFunc = &delaySPI_1000; break; // desired: 500,000 actual: ~360K
|
||||||
case SPI_SPEED_6: delay_STM32_soft_spi = 2000; break; // desired: 250,000 actual: ~210K
|
case SPI_SPEED_6: delaySPIFunc = &delaySPI_2000; break; // desired: 250,000 actual: ~210K
|
||||||
default: delay_STM32_soft_spi = 4000; break; // desired: 125,000 actual: ~123K
|
default: delaySPIFunc = &delaySPI_4000; break; // desired: 125,000 actual: ~123K
|
||||||
}
|
}
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
}
|
}
|
||||||
@@ -75,9 +85,9 @@ static SPISettings spiConfig;
|
|||||||
WRITE(SD_SCK_PIN, LOW);
|
WRITE(SD_SCK_PIN, LOW);
|
||||||
WRITE(SD_MOSI_PIN, b & 0x80);
|
WRITE(SD_MOSI_PIN, b & 0x80);
|
||||||
|
|
||||||
DELAY_NS(delay_STM32_soft_spi);
|
delaySPIFunc();
|
||||||
WRITE(SD_SCK_PIN, HIGH);
|
WRITE(SD_SCK_PIN, HIGH);
|
||||||
DELAY_NS(delay_STM32_soft_spi);
|
delaySPIFunc();
|
||||||
|
|
||||||
b <<= 1; // little setup time
|
b <<= 1; // little setup time
|
||||||
b |= (READ(SD_MISO_PIN) != 0);
|
b |= (READ(SD_MISO_PIN) != 0);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#define DECLARE_SERIAL_PORT(ser_num) \
|
#define DECLARE_SERIAL_PORT(ser_num) \
|
||||||
void _rx_complete_irq_ ## ser_num (serial_t * obj); \
|
void _rx_complete_irq_ ## ser_num (serial_t * obj); \
|
||||||
MarlinSerial MSerial ## ser_num (USART ## ser_num, &_rx_complete_irq_ ## ser_num); \
|
MSerialT MSerial ## ser_num (true, USART ## ser_num, &_rx_complete_irq_ ## ser_num); \
|
||||||
void _rx_complete_irq_ ## ser_num (serial_t * obj) { MSerial ## ser_num ._rx_complete_irq(obj); }
|
void _rx_complete_irq_ ## ser_num (serial_t * obj) { MSerial ## ser_num ._rx_complete_irq(obj); }
|
||||||
|
|
||||||
#define DECLARE_SERIAL_PORT_EXP(ser_num) DECLARE_SERIAL_PORT(ser_num)
|
#define DECLARE_SERIAL_PORT_EXP(ser_num) DECLARE_SERIAL_PORT(ser_num)
|
||||||
@@ -48,6 +48,10 @@
|
|||||||
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2)
|
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT >= 0
|
||||||
|
DECLARE_SERIAL_PORT_EXP(MMU2_SERIAL_PORT)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0
|
#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0
|
||||||
DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT)
|
DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT)
|
||||||
#endif
|
#endif
|
||||||
@@ -77,7 +81,7 @@ void MarlinSerial::_rx_complete_irq(serial_t *obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
emergency_parser.update(emergency_state, c);
|
emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, c);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,21 +24,15 @@
|
|||||||
#include "../../feature/e_parser.h"
|
#include "../../feature/e_parser.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../../core/serial_hook.h"
|
||||||
|
|
||||||
typedef void (*usart_rx_callback_t)(serial_t * obj);
|
typedef void (*usart_rx_callback_t)(serial_t * obj);
|
||||||
|
|
||||||
class MarlinSerial : public HardwareSerial {
|
struct MarlinSerial : public HardwareSerial {
|
||||||
public:
|
|
||||||
MarlinSerial(void* peripheral, usart_rx_callback_t rx_callback) :
|
MarlinSerial(void* peripheral, usart_rx_callback_t rx_callback) :
|
||||||
HardwareSerial(peripheral), _rx_callback(rx_callback)
|
HardwareSerial(peripheral), _rx_callback(rx_callback)
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
, emergency_state(EmergencyParser::State::EP_RESET)
|
|
||||||
#endif
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
static inline bool emergency_parser_enabled() { return true; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void begin(unsigned long baud, uint8_t config);
|
void begin(unsigned long baud, uint8_t config);
|
||||||
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
|
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
|
||||||
|
|
||||||
@@ -46,19 +40,17 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
usart_rx_callback_t _rx_callback;
|
usart_rx_callback_t _rx_callback;
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
EmergencyParser::State emergency_state;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MarlinSerial MSerial1;
|
typedef Serial1Class<MarlinSerial> MSerialT;
|
||||||
extern MarlinSerial MSerial2;
|
extern MSerialT MSerial1;
|
||||||
extern MarlinSerial MSerial3;
|
extern MSerialT MSerial2;
|
||||||
extern MarlinSerial MSerial4;
|
extern MSerialT MSerial3;
|
||||||
extern MarlinSerial MSerial5;
|
extern MSerialT MSerial4;
|
||||||
extern MarlinSerial MSerial6;
|
extern MSerialT MSerial5;
|
||||||
extern MarlinSerial MSerial7;
|
extern MSerialT MSerial6;
|
||||||
extern MarlinSerial MSerial8;
|
extern MSerialT MSerial7;
|
||||||
extern MarlinSerial MSerial9;
|
extern MSerialT MSerial8;
|
||||||
extern MarlinSerial MSerial10;
|
extern MSerialT MSerial9;
|
||||||
extern MarlinSerial MSerialLP1;
|
extern MSerialT MSerial10;
|
||||||
|
extern MSerialT MSerialLP1;
|
||||||
|
|||||||
@@ -163,7 +163,6 @@
|
|||||||
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
|
||||||
#if DISABLED(STM32F1xx)
|
#if DISABLED(STM32F1xx)
|
||||||
// TODO: use __HAL_RCC_SDIO_RELEASE_RESET() and __HAL_RCC_SDIO_CLK_ENABLE();
|
// TODO: use __HAL_RCC_SDIO_RELEASE_RESET() and __HAL_RCC_SDIO_CLK_ENABLE();
|
||||||
RCC->APB2RSTR &= ~RCC_APB2RSTR_SDIORST_Msk; // take SDIO out of reset
|
RCC->APB2RSTR &= ~RCC_APB2RSTR_SDIORST_Msk; // take SDIO out of reset
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
#include "stm32_def.h"
|
#include "stm32_def.h"
|
||||||
|
|
||||||
#define DEBUG_OUT ENABLED(EEPROM_CHITCHAT)
|
#define DEBUG_OUT ENABLED(EEPROM_CHITCHAT)
|
||||||
#include "src/core/debug_out.h"
|
#include "../../core/debug_out.h"
|
||||||
|
|
||||||
#ifndef MARLIN_EEPROM_SIZE
|
#ifndef MARLIN_EEPROM_SIZE
|
||||||
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
|
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
|
||||||
@@ -61,7 +61,9 @@
|
|||||||
#define FLASH_UNIT_SIZE 0x20000 // 128kB
|
#define FLASH_UNIT_SIZE 0x20000 // 128kB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FLASH_ADDRESS_START (FLASH_END - ((FLASH_SECTOR_TOTAL - (FLASH_SECTOR)) * (FLASH_UNIT_SIZE)) + 1)
|
#ifndef FLASH_ADDRESS_START
|
||||||
|
#define FLASH_ADDRESS_START (FLASH_END - ((FLASH_SECTOR_TOTAL - (FLASH_SECTOR)) * (FLASH_UNIT_SIZE)) + 1)
|
||||||
|
#endif
|
||||||
#define FLASH_ADDRESS_END (FLASH_ADDRESS_START + FLASH_UNIT_SIZE - 1)
|
#define FLASH_ADDRESS_END (FLASH_ADDRESS_START + FLASH_UNIT_SIZE - 1)
|
||||||
|
|
||||||
#define EEPROM_SLOTS ((FLASH_UNIT_SIZE) / (MARLIN_EEPROM_SIZE))
|
#define EEPROM_SLOTS ((FLASH_UNIT_SIZE) / (MARLIN_EEPROM_SIZE))
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ void FastIO_init(); // Must be called before using fast io macros
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->IDR, _BV32(STM_PIN(digitalPinToPinName(IO)))))
|
#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->IDR, _BV32(STM_PIN(digitalPinToPinName(IO)))))
|
||||||
#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR ^= _BV32(STM_PIN(digitalPinToPinName(IO))))
|
#define _TOGGLE(IO) TBI32(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR, STM_PIN(digitalPinToPinName(IO)))
|
||||||
|
|
||||||
#define _GET_MODE(IO)
|
#define _GET_MODE(IO)
|
||||||
#define _SET_MODE(IO,M) pinMode(IO, M)
|
#define _SET_MODE(IO,M) pinMode(IO, M)
|
||||||
|
|||||||
@@ -21,6 +21,12 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USBD_USE_CDC_COMPOSITE) && DISABLED(NO_SD_HOST_DRIVE)
|
#if defined(USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE)
|
||||||
#define HAS_SD_HOST_DRIVE 1
|
#define HAS_SD_HOST_DRIVE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Fix F_CPU not being a compile-time constant in STSTM32 framework
|
||||||
|
#ifdef BOARD_F_CPU
|
||||||
|
#undef F_CPU
|
||||||
|
#define F_CPU BOARD_F_CPU
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -47,9 +47,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
||||||
#error "SERIAL_STATS_MAX_RX_QUEUED is not supported on this platform."
|
#error "SERIAL_STATS_MAX_RX_QUEUED is not supported on STM32."
|
||||||
#elif ENABLED(SERIAL_STATS_DROPPED_RX)
|
#elif ENABLED(SERIAL_STATS_DROPPED_RX)
|
||||||
#error "SERIAL_STATS_DROPPED_RX is not supported on this platform."
|
#error "SERIAL_STATS_DROPPED_RX is not supported on STM32."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32F4xx, STM32F1xx)
|
#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32F4xx, STM32F1xx)
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
* Copyright (c) 2019 BigTreeTech [https://github.com/bigtreetech]
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && HAS_SD_HOST_DRIVE
|
||||||
|
|
||||||
|
#include "msc_sd.h"
|
||||||
|
#include "../shared/Marduino.h"
|
||||||
|
#include "usbd_core.h"
|
||||||
|
#include <USB.h>
|
||||||
|
#include <USBMscHandler.h>
|
||||||
|
|
||||||
|
#define BLOCK_SIZE 512
|
||||||
|
#define PRODUCT_ID 0x29
|
||||||
|
|
||||||
|
#include "../../sd/cardreader.h"
|
||||||
|
|
||||||
|
class Sd2CardUSBMscHandler : public USBMscHandler {
|
||||||
|
public:
|
||||||
|
bool GetCapacity(uint32_t *pBlockNum, uint16_t *pBlockSize) {
|
||||||
|
*pBlockNum = card.getSd2Card().cardSize();
|
||||||
|
*pBlockSize = BLOCK_SIZE;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Write(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) {
|
||||||
|
auto sd2card = card.getSd2Card();
|
||||||
|
// single block
|
||||||
|
if (blkLen == 1) {
|
||||||
|
watchdog_refresh();
|
||||||
|
sd2card.writeBlock(blkAddr, pBuf);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// multi block optmization
|
||||||
|
sd2card.writeStart(blkAddr, blkLen);
|
||||||
|
while (blkLen--) {
|
||||||
|
watchdog_refresh();
|
||||||
|
sd2card.writeData(pBuf);
|
||||||
|
pBuf += BLOCK_SIZE;
|
||||||
|
}
|
||||||
|
sd2card.writeStop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Read(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) {
|
||||||
|
auto sd2card = card.getSd2Card();
|
||||||
|
// single block
|
||||||
|
if (blkLen == 1) {
|
||||||
|
watchdog_refresh();
|
||||||
|
sd2card.readBlock(blkAddr, pBuf);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// multi block optmization
|
||||||
|
sd2card.readStart(blkAddr);
|
||||||
|
while (blkLen--) {
|
||||||
|
watchdog_refresh();
|
||||||
|
sd2card.readData(pBuf);
|
||||||
|
pBuf += BLOCK_SIZE;
|
||||||
|
}
|
||||||
|
sd2card.readStop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsReady() {
|
||||||
|
return card.isMounted();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Sd2CardUSBMscHandler usbMscHandler;
|
||||||
|
|
||||||
|
/* USB Mass storage Standard Inquiry Data */
|
||||||
|
uint8_t Marlin_STORAGE_Inquirydata[] = { /* 36 */
|
||||||
|
/* LUN 0 */
|
||||||
|
0x00,
|
||||||
|
0x80,
|
||||||
|
0x02,
|
||||||
|
0x02,
|
||||||
|
(STANDARD_INQUIRY_DATA_LEN - 5),
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
'M', 'A', 'R', 'L', 'I', 'N', ' ', ' ', /* Manufacturer : 8 bytes */
|
||||||
|
'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */
|
||||||
|
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
||||||
|
'0', '.', '0', '1', /* Version : 4 Bytes */
|
||||||
|
};
|
||||||
|
|
||||||
|
USBMscHandler *pSingleMscHandler = &usbMscHandler;
|
||||||
|
|
||||||
|
void MSC_SD_init() {
|
||||||
|
USBDevice.end();
|
||||||
|
delay(200);
|
||||||
|
USBDevice.begin();
|
||||||
|
USBDevice.registerMscHandlers(1, &pSingleMscHandler, Marlin_STORAGE_Inquirydata);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __STM32F1__ && HAS_SD_HOST_DRIVE
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
* Copyright (c) 2019 BigTreeTech [https://github.com/bigtreetech]
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
void MSC_SD_init();
|
||||||
@@ -84,7 +84,6 @@ class TFT_FSMC {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef STM32F1xx
|
#ifdef STM32F1xx
|
||||||
#define FSMC_PIN_DATA STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, AFIO_NONE)
|
#define FSMC_PIN_DATA STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, AFIO_NONE)
|
||||||
#elif defined(STM32F4xx)
|
#elif defined(STM32F4xx)
|
||||||
|
|||||||
@@ -207,12 +207,12 @@ void TFT_SPI::Transmit(uint16_t Data) {
|
|||||||
while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {}
|
while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {}
|
||||||
|
|
||||||
if (TFT_MISO_PIN != TFT_MOSI_PIN)
|
if (TFT_MISO_PIN != TFT_MOSI_PIN)
|
||||||
__HAL_SPI_CLEAR_OVRFLAG(&SPIx); /* Clear overrun flag in 2 Lines communication mode because received is not read */
|
__HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received is not read
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
|
void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
|
||||||
// Wait last dma finish, to start another
|
// Wait last dma finish, to start another
|
||||||
while(isBusy()) { }
|
while (isBusy()) { /* nada */ }
|
||||||
|
|
||||||
DMAtx.Init.MemInc = MemoryIncrease;
|
DMAtx.Init.MemInc = MemoryIncrease;
|
||||||
HAL_DMA_Init(&DMAtx);
|
HAL_DMA_Init(&DMAtx);
|
||||||
@@ -225,7 +225,7 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun
|
|||||||
HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(SPIx.Instance->DR), Count);
|
HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(SPIx.Instance->DR), Count);
|
||||||
__HAL_SPI_ENABLE(&SPIx);
|
__HAL_SPI_ENABLE(&SPIx);
|
||||||
|
|
||||||
SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); /* Enable Tx DMA Request */
|
SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); // Enable Tx DMA Request
|
||||||
|
|
||||||
HAL_DMA_PollForTransfer(&DMAtx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY);
|
HAL_DMA_PollForTransfer(&DMAtx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY);
|
||||||
Abort();
|
Abort();
|
||||||
|
|||||||
@@ -84,6 +84,32 @@
|
|||||||
|
|
||||||
#if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE
|
#if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE
|
||||||
USBSerial SerialUSB;
|
USBSerial SerialUSB;
|
||||||
|
DefaultSerial1 MSerial0(true, SerialUSB);
|
||||||
|
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
#include "../libmaple/usb/stm32f1/usb_reg_map.h"
|
||||||
|
#include "libmaple/usb_cdcacm.h"
|
||||||
|
// The original callback is not called (no way to retrieve address).
|
||||||
|
// That callback detects a special STM32 reset sequence: this functionality is not essential
|
||||||
|
// as M997 achieves the same.
|
||||||
|
void my_rx_callback(unsigned int, void*) {
|
||||||
|
// max length of 16 is enough to contain all emergency commands
|
||||||
|
uint8 buf[16];
|
||||||
|
|
||||||
|
//rx is usbSerialPart.endpoints[2]
|
||||||
|
uint16 len = usb_get_ep_rx_count(USB_CDCACM_RX_ENDP);
|
||||||
|
uint32 total = usb_cdcacm_data_available();
|
||||||
|
|
||||||
|
if (len == 0 || total == 0 || !WITHIN(total, len, COUNT(buf)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// cannot get character by character due to bug in composite_cdcacm_peek_ex
|
||||||
|
len = usb_cdcacm_peek(buf, total);
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < len; i++)
|
||||||
|
emergency_parser.update(MSerial0.emergency_state, buf[i + total - len]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint16_t HAL_adc_result;
|
uint16_t HAL_adc_result;
|
||||||
@@ -106,6 +132,9 @@ const uint8_t adc_pins[] = {
|
|||||||
#if HAS_TEMP_CHAMBER
|
#if HAS_TEMP_CHAMBER
|
||||||
TEMP_CHAMBER_PIN,
|
TEMP_CHAMBER_PIN,
|
||||||
#endif
|
#endif
|
||||||
|
#if HAS_TEMP_COOLER
|
||||||
|
TEMP_COOLER_PIN,
|
||||||
|
#endif
|
||||||
#if HAS_TEMP_ADC_1
|
#if HAS_TEMP_ADC_1
|
||||||
TEMP_1_PIN,
|
TEMP_1_PIN,
|
||||||
#endif
|
#endif
|
||||||
@@ -163,6 +192,9 @@ enum TempPinIndex : char {
|
|||||||
#if HAS_TEMP_CHAMBER
|
#if HAS_TEMP_CHAMBER
|
||||||
TEMP_CHAMBER,
|
TEMP_CHAMBER,
|
||||||
#endif
|
#endif
|
||||||
|
#if HAS_TEMP_COOLER
|
||||||
|
TEMP_COOLER_PIN,
|
||||||
|
#endif
|
||||||
#if HAS_TEMP_ADC_1
|
#if HAS_TEMP_ADC_1
|
||||||
TEMP_1,
|
TEMP_1,
|
||||||
#endif
|
#endif
|
||||||
@@ -246,6 +278,8 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
|||||||
} }
|
} }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
|
||||||
|
|
||||||
void HAL_init() {
|
void HAL_init() {
|
||||||
NVIC_SetPriorityGrouping(0x3);
|
NVIC_SetPriorityGrouping(0x3);
|
||||||
#if PIN_EXISTS(LED)
|
#if PIN_EXISTS(LED)
|
||||||
@@ -253,12 +287,15 @@ void HAL_init() {
|
|||||||
#endif
|
#endif
|
||||||
#if HAS_SD_HOST_DRIVE
|
#if HAS_SD_HOST_DRIVE
|
||||||
MSC_SD_init();
|
MSC_SD_init();
|
||||||
|
#elif BOTH(SERIAL_USB, EMERGENCY_PARSER)
|
||||||
|
usb_cdcacm_set_hooks(USB_CDCACM_HOOK_RX, my_rx_callback);
|
||||||
#endif
|
#endif
|
||||||
#if PIN_EXISTS(USB_CONNECT)
|
#if PIN_EXISTS(USB_CONNECT)
|
||||||
OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection
|
OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection
|
||||||
delay(1000); // Give OS time to notice
|
delay(1000); // Give OS time to notice
|
||||||
OUT_WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING);
|
OUT_WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING);
|
||||||
#endif
|
#endif
|
||||||
|
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the minimal serial handler
|
||||||
}
|
}
|
||||||
|
|
||||||
// HAL idle task
|
// HAL idle task
|
||||||
@@ -354,6 +391,9 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
|||||||
#if HAS_TEMP_CHAMBER
|
#if HAS_TEMP_CHAMBER
|
||||||
case TEMP_CHAMBER_PIN: pin_index = TEMP_CHAMBER; break;
|
case TEMP_CHAMBER_PIN: pin_index = TEMP_CHAMBER; break;
|
||||||
#endif
|
#endif
|
||||||
|
#if HAS_TEMP_COOLER
|
||||||
|
case TEMP_COOLER_PIN: pin_index = TEMP_COOLER; break;
|
||||||
|
#endif
|
||||||
#if HAS_TEMP_ADC_1
|
#if HAS_TEMP_ADC_1
|
||||||
case TEMP_1_PIN: pin_index = TEMP_1; break;
|
case TEMP_1_PIN: pin_index = TEMP_1; break;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -61,8 +61,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_USB
|
#ifdef SERIAL_USB
|
||||||
|
typedef ForwardSerial1Class< USBSerial > DefaultSerial1;
|
||||||
|
extern DefaultSerial1 MSerial0;
|
||||||
|
|
||||||
#if !HAS_SD_HOST_DRIVE
|
#if !HAS_SD_HOST_DRIVE
|
||||||
#define UsbSerial Serial
|
#define UsbSerial MSerial0
|
||||||
#else
|
#else
|
||||||
#define UsbSerial MarlinCompositeSerial
|
#define UsbSerial MarlinCompositeSerial
|
||||||
#endif
|
#endif
|
||||||
@@ -78,9 +81,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 UsbSerial
|
#define MYSERIAL1 UsbSerial
|
||||||
#elif WITHIN(SERIAL_PORT, 1, NUM_UARTS)
|
#elif WITHIN(SERIAL_PORT, 1, NUM_UARTS)
|
||||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||||
#elif NUM_UARTS == 5
|
#elif NUM_UARTS == 5
|
||||||
#error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
|
#error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
|
||||||
#else
|
#else
|
||||||
@@ -89,9 +92,9 @@
|
|||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if SERIAL_PORT_2 == -1
|
#if SERIAL_PORT_2 == -1
|
||||||
#define MYSERIAL1 UsbSerial
|
#define MYSERIAL2 UsbSerial
|
||||||
#elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS)
|
#elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS)
|
||||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||||
#elif NUM_UARTS == 5
|
#elif NUM_UARTS == 5
|
||||||
#error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration."
|
#error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration."
|
||||||
#else
|
#else
|
||||||
@@ -99,6 +102,18 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MMU2_SERIAL_PORT
|
||||||
|
#if MMU2_SERIAL_PORT == -1
|
||||||
|
#define MMU2_SERIAL UsbSerial
|
||||||
|
#elif WITHIN(MMU2_SERIAL_PORT, 1, NUM_UARTS)
|
||||||
|
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
|
||||||
|
#elif NUM_UARTS == 5
|
||||||
|
#error "MMU2_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
|
||||||
|
#else
|
||||||
|
#error "MMU2_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LCD_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if LCD_SERIAL_PORT == -1
|
#if LCD_SERIAL_PORT == -1
|
||||||
#define LCD_SERIAL UsbSerial
|
#define LCD_SERIAL UsbSerial
|
||||||
@@ -109,8 +124,9 @@
|
|||||||
#else
|
#else
|
||||||
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
#if HAS_DGUS_LCD
|
||||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set interrupt grouping for this MCU
|
// Set interrupt grouping for this MCU
|
||||||
@@ -139,14 +155,6 @@ void HAL_idletask();
|
|||||||
// On AVR this is in math.h?
|
// On AVR this is in math.h?
|
||||||
#define square(x) ((x)*(x))
|
#define square(x) ((x)*(x))
|
||||||
|
|
||||||
#ifndef strncpy_P
|
|
||||||
#define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Fix bug in pgm_read_ptr
|
|
||||||
#undef pgm_read_ptr
|
|
||||||
#define pgm_read_ptr(addr) (*(addr))
|
|
||||||
|
|
||||||
#define RST_POWER_ON 1
|
#define RST_POWER_ON 1
|
||||||
#define RST_EXTERNAL 2
|
#define RST_EXTERNAL 2
|
||||||
#define RST_BROWN_OUT 4
|
#define RST_BROWN_OUT 4
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
* Copyright (c) 2017 Victor Perez
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifdef __STM32F1__
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
|
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||||
|
|
||||||
|
#include "../shared/HAL_MinSerial.h"
|
||||||
|
#include "watchdog.h"
|
||||||
|
|
||||||
|
#include <libmaple/usart.h>
|
||||||
|
#include <libmaple/rcc.h>
|
||||||
|
#include <libmaple/nvic.h>
|
||||||
|
|
||||||
|
/* Instruction Synchronization Barrier */
|
||||||
|
#define isb() __asm__ __volatile__ ("isb" : : : "memory")
|
||||||
|
|
||||||
|
/* Data Synchronization Barrier */
|
||||||
|
#define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
|
||||||
|
|
||||||
|
static void TXBegin() {
|
||||||
|
#if !WITHIN(SERIAL_PORT, 1, 6)
|
||||||
|
#warning "Using POSTMORTEM_DEBUGGING requires a physical U(S)ART hardware in case of severe error."
|
||||||
|
#warning "Disabling the severe error reporting feature currently because the used serial port is not a HW port."
|
||||||
|
#else
|
||||||
|
// We use MYSERIAL1 here, so we need to figure out how to get the linked register
|
||||||
|
struct usart_dev* dev = MYSERIAL1.c_dev();
|
||||||
|
|
||||||
|
// Or use this if removing libmaple
|
||||||
|
// int irq = dev->irq_num;
|
||||||
|
// int nvicUART[] = { NVIC_USART1 /* = 37 */, NVIC_USART2 /* = 38 */, NVIC_USART3 /* = 39 */, NVIC_UART4 /* = 52 */, NVIC_UART5 /* = 53 */ };
|
||||||
|
// Disabling irq means setting the bit in the NVIC ICER register located at
|
||||||
|
// Disable UART interrupt in NVIC
|
||||||
|
nvic_irq_disable(dev->irq_num);
|
||||||
|
|
||||||
|
// Use this if removing libmaple
|
||||||
|
//NVIC_BASE->ICER[1] |= _BV(irq - 32);
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
rcc_clk_disable(dev->clk_id);
|
||||||
|
rcc_clk_enable(dev->clk_id);
|
||||||
|
|
||||||
|
usart_reg_map *regs = dev->regs;
|
||||||
|
regs->CR1 = 0; // Reset the USART
|
||||||
|
regs->CR2 = 0; // 1 stop bit
|
||||||
|
|
||||||
|
// If we don't touch the BRR (baudrate register), we don't need to recompute. Else we would need to call
|
||||||
|
usart_set_baud_rate(dev, 0, BAUDRATE);
|
||||||
|
|
||||||
|
regs->CR1 = (USART_CR1_TE | USART_CR1_UE); // 8 bits, no parity, 1 stop bit
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// A SW memory barrier, to ensure GCC does not overoptimize loops
|
||||||
|
#define sw_barrier() __asm__ volatile("": : :"memory");
|
||||||
|
static void TX(char c) {
|
||||||
|
#if WITHIN(SERIAL_PORT, 1, 6)
|
||||||
|
struct usart_dev* dev = MYSERIAL1.c_dev();
|
||||||
|
while (!(dev->regs->SR & USART_SR_TXE)) {
|
||||||
|
TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
|
||||||
|
sw_barrier();
|
||||||
|
}
|
||||||
|
dev->regs->DR = c;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void install_min_serial() {
|
||||||
|
HAL_min_serial_init = &TXBegin;
|
||||||
|
HAL_min_serial_out = &TX;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DISABLED(DYNAMIC_VECTORTABLE) && DISABLED(STM32F0xx) // Cortex M0 can't branch to a symbol that's too far, so we have a specific hack for them
|
||||||
|
extern "C" {
|
||||||
|
__attribute__((naked)) void JumpHandler_ASM() {
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"b CommonHandler_ASM\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __exc_hardfault();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __exc_busfault();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __exc_usagefault();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __exc_memmanage();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __exc_nmi();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __stm32reservedexception7();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __stm32reservedexception8();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __stm32reservedexception9();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __stm32reservedexception10();
|
||||||
|
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) __stm32reservedexception13();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // POSTMORTEM_DEBUGGING
|
||||||
|
#endif // __STM32F1__
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
// Copied from ~/.platformio/packages/framework-arduinoststm32-maple/STM32F1/system/libmaple/usart_private.h
|
// Copied from ~/.platformio/packages/framework-arduinoststm32-maple/STM32F1/system/libmaple/usart_private.h
|
||||||
// Changed to handle Emergency Parser
|
// Changed to handle Emergency Parser
|
||||||
static inline __always_inline void my_usart_irq(ring_buffer *rb, ring_buffer *wb, usart_reg_map *regs, MarlinSerial &serial) {
|
static inline __always_inline void my_usart_irq(ring_buffer *rb, ring_buffer *wb, usart_reg_map *regs, MSerialT &serial) {
|
||||||
/* Handle RXNEIE and TXEIE interrupts.
|
/* Handle RXNEIE and TXEIE interrupts.
|
||||||
* RXNE signifies availability of a byte in DR.
|
* RXNE signifies availability of a byte in DR.
|
||||||
*
|
*
|
||||||
@@ -90,20 +90,20 @@ constexpr bool serial_handles_emergency(int port) {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEFINE_HWSERIAL_MARLIN(name, n) \
|
#define DEFINE_HWSERIAL_MARLIN(name, n) \
|
||||||
MarlinSerial name(USART##n, \
|
MSerialT name(serial_handles_emergency(n),\
|
||||||
BOARD_USART##n##_TX_PIN, \
|
USART##n, \
|
||||||
BOARD_USART##n##_RX_PIN, \
|
BOARD_USART##n##_TX_PIN, \
|
||||||
serial_handles_emergency(n)); \
|
BOARD_USART##n##_RX_PIN); \
|
||||||
extern "C" void __irq_usart##n(void) { \
|
extern "C" void __irq_usart##n(void) { \
|
||||||
my_usart_irq(USART##n->rb, USART##n->wb, USART##n##_BASE, MSerial##n); \
|
my_usart_irq(USART##n->rb, USART##n->wb, USART##n##_BASE, MSerial##n); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEFINE_HWSERIAL_UART_MARLIN(name, n) \
|
#define DEFINE_HWSERIAL_UART_MARLIN(name, n) \
|
||||||
MarlinSerial name(UART##n, \
|
MSerialT name(serial_handles_emergency(n), \
|
||||||
|
UART##n, \
|
||||||
BOARD_USART##n##_TX_PIN, \
|
BOARD_USART##n##_TX_PIN, \
|
||||||
BOARD_USART##n##_RX_PIN, \
|
BOARD_USART##n##_RX_PIN); \
|
||||||
serial_handles_emergency(n)); \
|
|
||||||
extern "C" void __irq_usart##n(void) { \
|
extern "C" void __irq_usart##n(void) { \
|
||||||
my_usart_irq(UART##n->rb, UART##n->wb, UART##n##_BASE, MSerial##n); \
|
my_usart_irq(UART##n->rb, UART##n->wb, UART##n##_BASE, MSerial##n); \
|
||||||
}
|
}
|
||||||
@@ -134,12 +134,12 @@ constexpr bool IsSerialClassAllowed(const HardwareSerial&) { return false; }
|
|||||||
// If you encounter this error, replace SerialX with MSerialX, for example MSerial3.
|
// If you encounter this error, replace SerialX with MSerialX, for example MSerial3.
|
||||||
|
|
||||||
// Non-TMC ports were already validated in HAL.h, so do not require verbose error messages.
|
// Non-TMC ports were already validated in HAL.h, so do not require verbose error messages.
|
||||||
#ifdef MYSERIAL0
|
|
||||||
CHECK_CFG_SERIAL(MYSERIAL0);
|
|
||||||
#endif
|
|
||||||
#ifdef MYSERIAL1
|
#ifdef MYSERIAL1
|
||||||
CHECK_CFG_SERIAL(MYSERIAL1);
|
CHECK_CFG_SERIAL(MYSERIAL1);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef MYSERIAL2
|
||||||
|
CHECK_CFG_SERIAL(MYSERIAL2);
|
||||||
|
#endif
|
||||||
#ifdef LCD_SERIAL
|
#ifdef LCD_SERIAL
|
||||||
CHECK_CFG_SERIAL(LCD_SERIAL);
|
CHECK_CFG_SERIAL(LCD_SERIAL);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,28 +26,13 @@
|
|||||||
#include <WString.h>
|
#include <WString.h>
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
#include "../../core/serial_hook.h"
|
||||||
#include "../../feature/e_parser.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Increase priority of serial interrupts, to reduce overflow errors
|
// Increase priority of serial interrupts, to reduce overflow errors
|
||||||
#define UART_IRQ_PRIO 1
|
#define UART_IRQ_PRIO 1
|
||||||
|
|
||||||
class MarlinSerial : public HardwareSerial {
|
struct MarlinSerial : public HardwareSerial {
|
||||||
public:
|
MarlinSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) : HardwareSerial(usart_device, tx_pin, rx_pin) { }
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
const bool ep_enabled;
|
|
||||||
EmergencyParser::State emergency_state;
|
|
||||||
inline bool emergency_parser_enabled() { return ep_enabled; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MarlinSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin, bool TERN_(EMERGENCY_PARSER, ep_capable)) :
|
|
||||||
HardwareSerial(usart_device, tx_pin, rx_pin)
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
, ep_enabled(ep_capable)
|
|
||||||
, emergency_state(EmergencyParser::State::EP_RESET)
|
|
||||||
#endif
|
|
||||||
{ }
|
|
||||||
|
|
||||||
#ifdef UART_IRQ_PRIO
|
#ifdef UART_IRQ_PRIO
|
||||||
// Shadow the parent methods to set IRQ priority after begin()
|
// Shadow the parent methods to set IRQ priority after begin()
|
||||||
@@ -62,10 +47,12 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MarlinSerial MSerial1;
|
typedef Serial1Class<MarlinSerial> MSerialT;
|
||||||
extern MarlinSerial MSerial2;
|
|
||||||
extern MarlinSerial MSerial3;
|
extern MSerialT MSerial1;
|
||||||
|
extern MSerialT MSerial2;
|
||||||
|
extern MSerialT MSerial3;
|
||||||
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||||
extern MarlinSerial MSerial4;
|
extern MSerialT MSerial4;
|
||||||
extern MarlinSerial MSerial5;
|
extern MSerialT MSerial5;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ uint8_t ServoCount = 0;
|
|||||||
*
|
*
|
||||||
* This uses the smallest prescaler that allows an overflow < 2^16.
|
* This uses the smallest prescaler that allows an overflow < 2^16.
|
||||||
*/
|
*/
|
||||||
#define MAX_OVERFLOW UINT16_MAX //((1 << 16) - 1)
|
#define MAX_OVERFLOW UINT16_MAX // _BV(16) - 1
|
||||||
#define CYC_MSEC (1000 * CYCLES_PER_MICROSECOND)
|
#define CYC_MSEC (1000 * CYCLES_PER_MICROSECOND)
|
||||||
#define TAU_MSEC 20
|
#define TAU_MSEC 20
|
||||||
#define TAU_USEC (TAU_MSEC * 1000)
|
#define TAU_USEC (TAU_MSEC * 1000)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void eeprom_init() { BL24CXX::init(); }
|
|||||||
// Public functions
|
// Public functions
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
void eeprom_write_byte(uint8_t *pos, unsigned char value) {
|
void eeprom_write_byte(uint8_t *pos, uint8_t value) {
|
||||||
const unsigned eeprom_address = (unsigned)pos;
|
const unsigned eeprom_address = (unsigned)pos;
|
||||||
return BL24CXX::writeOneByte(eeprom_address, value);
|
return BL24CXX::writeOneByte(eeprom_address, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Marlin 3D Printer Firmware
|
* Marlin 3D Printer Firmware
|
||||||
*
|
|
||||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -29,9 +29,9 @@
|
|||||||
|
|
||||||
#include <libmaple/gpio.h>
|
#include <libmaple/gpio.h>
|
||||||
|
|
||||||
#define READ(IO) (PIN_MAP[IO].gpio_device->regs->IDR & (1U << PIN_MAP[IO].gpio_bit) ? HIGH : LOW)
|
#define READ(IO) (PIN_MAP[IO].gpio_device->regs->IDR & _BV32(PIN_MAP[IO].gpio_bit) ? HIGH : LOW)
|
||||||
#define WRITE(IO,V) (PIN_MAP[IO].gpio_device->regs->BSRR = (1U << PIN_MAP[IO].gpio_bit) << ((V) ? 0 : 16))
|
#define WRITE(IO,V) (PIN_MAP[IO].gpio_device->regs->BSRR = _BV32(PIN_MAP[IO].gpio_bit) << ((V) ? 0 : 16))
|
||||||
#define TOGGLE(IO) (PIN_MAP[IO].gpio_device->regs->ODR = PIN_MAP[IO].gpio_device->regs->ODR ^ (1U << PIN_MAP[IO].gpio_bit))
|
#define TOGGLE(IO) TBI32(PIN_MAP[IO].gpio_device->regs->ODR, PIN_MAP[IO].gpio_bit)
|
||||||
|
|
||||||
#define _GET_MODE(IO) gpio_get_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit)
|
#define _GET_MODE(IO) gpio_get_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit)
|
||||||
#define _SET_MODE(IO,M) gpio_set_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit, M)
|
#define _SET_MODE(IO,M) gpio_set_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit, M)
|
||||||
|
|||||||
@@ -34,9 +34,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
||||||
#error "SERIAL_STATS_MAX_RX_QUEUED is not supported on this platform."
|
#error "SERIAL_STATS_MAX_RX_QUEUED is not supported on the STM32F1 platform."
|
||||||
#elif ENABLED(SERIAL_STATS_DROPPED_RX)
|
#elif ENABLED(SERIAL_STATS_DROPPED_RX)
|
||||||
#error "SERIAL_STATS_DROPPED_RX is not supported on this platform."
|
#error "SERIAL_STATS_DROPPED_RX is not supported on the STM32F1 platform."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(NEOPIXEL_LED)
|
#if ENABLED(NEOPIXEL_LED)
|
||||||
|
|||||||
@@ -19,11 +19,12 @@
|
|||||||
|
|
||||||
#include "msc_sd.h"
|
#include "msc_sd.h"
|
||||||
#include "SPI.h"
|
#include "SPI.h"
|
||||||
|
#include "usb_reg_map.h"
|
||||||
|
|
||||||
#define PRODUCT_ID 0x29
|
#define PRODUCT_ID 0x29
|
||||||
|
|
||||||
USBMassStorage MarlinMSC;
|
USBMassStorage MarlinMSC;
|
||||||
MarlinUSBCompositeSerial MarlinCompositeSerial;
|
Serial1Class<USBCompositeSerial> MarlinCompositeSerial(true);
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
@@ -41,14 +42,28 @@ MarlinUSBCompositeSerial MarlinCompositeSerial;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
void (*real_rx_callback)(void);
|
|
||||||
|
|
||||||
void my_rx_callback(void) {
|
// The original callback is not called (no way to retrieve address).
|
||||||
real_rx_callback();
|
// That callback detects a special STM32 reset sequence: this functionality is not essential
|
||||||
int len = MarlinCompositeSerial.available();
|
// as M997 achieves the same.
|
||||||
while (len-- > 0) // >0 because available() may return a negative value
|
void my_rx_callback(unsigned int, void*) {
|
||||||
emergency_parser.update(MarlinCompositeSerial.emergency_state, MarlinCompositeSerial.peek());
|
// max length of 16 is enough to contain all emergency commands
|
||||||
|
uint8 buf[16];
|
||||||
|
|
||||||
|
//rx is usbSerialPart.endpoints[2]
|
||||||
|
uint16 len = usb_get_ep_rx_count(usbSerialPart.endpoints[2].address);
|
||||||
|
uint32 total = composite_cdcacm_data_available();
|
||||||
|
|
||||||
|
if (len == 0 || total == 0 || !WITHIN(total, len, COUNT(buf)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// cannot get character by character due to bug in composite_cdcacm_peek_ex
|
||||||
|
len = composite_cdcacm_peek(buf, total);
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < len; i++)
|
||||||
|
emergency_parser.update(MarlinCompositeSerial.emergency_state, buf[i+total-len]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void MSC_SD_init() {
|
void MSC_SD_init() {
|
||||||
@@ -73,9 +88,7 @@ void MSC_SD_init() {
|
|||||||
MarlinCompositeSerial.registerComponent();
|
MarlinCompositeSerial.registerComponent();
|
||||||
USBComposite.begin();
|
USBComposite.begin();
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
//rx is usbSerialPart.endpoints[2]
|
composite_cdcacm_set_hooks(USBHID_CDCACM_HOOK_RX, my_rx_callback);
|
||||||
real_rx_callback = usbSerialPart.endpoints[2].callback;
|
|
||||||
usbSerialPart.endpoints[2].callback = my_rx_callback;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,25 +18,9 @@
|
|||||||
#include <USBComposite.h>
|
#include <USBComposite.h>
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
#include "../../core/serial_hook.h"
|
||||||
#include "../../feature/e_parser.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class MarlinUSBCompositeSerial : public USBCompositeSerial {
|
|
||||||
public:
|
|
||||||
MarlinUSBCompositeSerial() : USBCompositeSerial()
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
, emergency_state(EmergencyParser::State::EP_RESET)
|
|
||||||
#endif
|
|
||||||
{ }
|
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
EmergencyParser::State emergency_state;
|
|
||||||
inline bool emergency_parser_enabled() { return true; }
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
extern USBMassStorage MarlinMSC;
|
extern USBMassStorage MarlinMSC;
|
||||||
extern MarlinUSBCompositeSerial MarlinCompositeSerial;
|
extern Serial1Class<USBCompositeSerial> MarlinCompositeSerial;
|
||||||
|
|
||||||
void MSC_SD_init();
|
void MSC_SD_init();
|
||||||
|
|||||||
@@ -31,6 +31,13 @@
|
|||||||
|
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
|
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
||||||
|
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
|
||||||
|
#if WITHIN(SERIAL_PORT, 0, 3)
|
||||||
|
IMPLEMENT_SERIAL(SERIAL_PORT);
|
||||||
|
#endif
|
||||||
|
USBSerialType USBSerial(false, SerialUSB);
|
||||||
|
|
||||||
uint16_t HAL_adc_result;
|
uint16_t HAL_adc_result;
|
||||||
|
|
||||||
static const uint8_t pin2sc1a[] = {
|
static const uint8_t pin2sc1a[] = {
|
||||||
|
|||||||
@@ -50,14 +50,25 @@
|
|||||||
#define IS_TEENSY32 1
|
#define IS_TEENSY32 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _MSERIAL(X) Serial##X
|
#include "../../core/serial_hook.h"
|
||||||
#define MSERIAL(X) _MSERIAL(X)
|
|
||||||
#define Serial0 Serial
|
#define Serial0 Serial
|
||||||
|
#define _DECLARE_SERIAL(X) \
|
||||||
|
typedef ForwardSerial1Class<decltype(Serial##X)> DefaultSerial##X; \
|
||||||
|
extern DefaultSerial##X MSerial##X
|
||||||
|
#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X)
|
||||||
|
|
||||||
|
typedef ForwardSerial1Class<decltype(SerialUSB)> USBSerialType;
|
||||||
|
extern USBSerialType USBSerial;
|
||||||
|
|
||||||
|
#define _MSERIAL(X) MSerial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 SerialUSB
|
#define MYSERIAL1 USBSerial
|
||||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
DECLARE_SERIAL(SERIAL_PORT);
|
||||||
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HAL_SERVO_LIB libServo
|
#define HAL_SERVO_LIB libServo
|
||||||
@@ -74,17 +85,6 @@ typedef int8_t pin_t;
|
|||||||
#define ENABLE_ISRS() __enable_irq()
|
#define ENABLE_ISRS() __enable_irq()
|
||||||
#define DISABLE_ISRS() __disable_irq()
|
#define DISABLE_ISRS() __disable_irq()
|
||||||
|
|
||||||
#ifndef strncpy_P
|
|
||||||
#define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Fix bug in pgm_read_ptr
|
|
||||||
#undef pgm_read_ptr
|
|
||||||
#define pgm_read_ptr(addr) (*((void**)(addr)))
|
|
||||||
// Add type-checking to pgm_read_word
|
|
||||||
#undef pgm_read_word
|
|
||||||
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
|
|
||||||
|
|
||||||
inline void HAL_init() {}
|
inline void HAL_init() {}
|
||||||
|
|
||||||
// Clear the reset reason
|
// Clear the reset reason
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MASK
|
#ifndef MASK
|
||||||
#define MASK(PIN) (1 << PIN)
|
#define MASK(PIN) _BV(PIN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000)
|
#define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000)
|
||||||
|
|||||||
@@ -34,5 +34,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_TMC_SW_SERIAL
|
#if HAS_TMC_SW_SERIAL
|
||||||
#error "TMC220x Software Serial is not supported on this platform."
|
#error "TMC220x Software Serial is not supported on Teensy 3.1/3.2."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||||
|
#error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 3.1/3.2."
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -31,6 +31,14 @@
|
|||||||
|
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
|
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
||||||
|
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
|
||||||
|
#if WITHIN(SERIAL_PORT, 0, 3)
|
||||||
|
IMPLEMENT_SERIAL(SERIAL_PORT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
USBSerialType USBSerial(false, SerialUSB);
|
||||||
|
|
||||||
uint16_t HAL_adc_result, HAL_adc_select;
|
uint16_t HAL_adc_result, HAL_adc_select;
|
||||||
|
|
||||||
static const uint8_t pin2sc1a[] = {
|
static const uint8_t pin2sc1a[] = {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user