Compare commits
332 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 86165ceca5 | |||
| 8989353fab | |||
| 7e0524109e | |||
| d88e694d06 | |||
| 44d50c2bd3 | |||
| 58548f5051 | |||
| 782eabc226 | |||
| 0ff3ae3cc6 | |||
| 8088c7dcd5 | |||
| 604d10d307 | |||
| 8dcc72ce9c | |||
| d06bcd6dd3 | |||
| b3c2ee56f9 | |||
| 435e98ceed | |||
| 7d21dfc938 | |||
| 2e1ba73926 | |||
| e8a62ee3cf | |||
| 4e8eea8e78 | |||
| d83baf8925 | |||
| 348570fd68 | |||
| cf61562196 | |||
| d02d7a95d1 | |||
| ba07c26761 | |||
| e56295851f | |||
| f7d93dadeb | |||
| 5c87762f9e | |||
| ea78514ff3 | |||
| 2616feb3df | |||
| f4255b14e8 | |||
| 41774ec9de | |||
| 60155aa442 | |||
| 169ec65e72 | |||
| 660420050b | |||
| 0ddb4d88a9 | |||
| 9142f5446a | |||
| 6d4c82f4d8 | |||
| 4424645e04 | |||
| 05517e2096 | |||
| be7bbadabe | |||
| d4a5b10133 | |||
| 4584a52ba5 | |||
| 27bdf4b24e | |||
| c2c6a679ea | |||
| 1c372df449 | |||
| 3a91ab4706 | |||
| 303d871ca7 | |||
| 00c09e95ac | |||
| f3de0f6c53 | |||
| 7415e4e66d | |||
| 6572d7131f | |||
| d9d920e0b3 | |||
| cd5735130d | |||
| 3245a5fdf6 | |||
| 37cf156223 | |||
| d2741c8680 | |||
| dd118e2f36 | |||
| 4975e93350 | |||
| 82e602c847 | |||
| 88d7f4d7be | |||
| 5cf2cf2be9 | |||
| a7f5d38da7 | |||
| ec4a0a3e0d | |||
| 97e0d55073 | |||
| 7efd740950 | |||
| 61d96ce1c9 | |||
| f902e208a3 | |||
| 178a1da165 | |||
| 7ce91c5ffe | |||
| 23faf902ab | |||
| da6c8317a7 | |||
| 6bb6f7f288 | |||
| b3223d7b41 | |||
| 568f292883 | |||
| 4b928b2da8 | |||
| 928d874dea | |||
| ecc8013812 | |||
| 6634bedb25 | |||
| e3d4e328f9 | |||
| 93421f3a00 | |||
| 023cb54fae | |||
| 90bc1993b6 | |||
| 362145f608 | |||
| 5d0429ee2a | |||
| 5f5f76956f | |||
| fd8cd31504 | |||
| a87c517da5 | |||
| d051c2adbd | |||
| 63e7ae793b | |||
| 79dc8a2297 | |||
| 225487f9db | |||
| 47aa61c0ec | |||
| 1bfc51ad5c | |||
| fb48cd0ab4 | |||
| 0251eb85b2 | |||
| d8ed749045 | |||
| 77b06dce0c | |||
| 4f73ac7289 | |||
| 60ab7a1ddb | |||
| 76d8d1742c | |||
| 8e0fac897b | |||
| 0c7035d8a3 | |||
| b5e4511de8 | |||
| 98bcb25fd4 | |||
| af8f9f790a | |||
| 9fd06fa767 | |||
| 4696142a31 | |||
| 435e1535cc | |||
| 4628f0e237 | |||
| e65deacabb | |||
| 55ba5044ef | |||
| 648269e0ec | |||
| 5b56d6698a | |||
| 62206c0386 | |||
| da1a60aeb6 | |||
| 3eaa19fdb0 | |||
| c539254101 | |||
| 24d8daa01b | |||
| 073b7f1e3a | |||
| 5926bacea1 | |||
| c5204807e9 | |||
| 9d5a9621de | |||
| 9cf8537051 | |||
| 56ed55ddba | |||
| 217bae9ff1 | |||
| 250bfac0cc | |||
| 57a87a278b | |||
| 0b7d69d06f | |||
| 79d4123319 | |||
| 648e7f73a5 | |||
| 941b890881 | |||
| 0f9eb480aa | |||
| 0473f7ee58 | |||
| 3a89d34e7f | |||
| cd85fa3abe | |||
| 979876e958 | |||
| cf8316bfbb | |||
| 49ca16c3fb | |||
| d93471fdad | |||
| 872516f9f9 | |||
| 7c7e663911 | |||
| c04d5624da | |||
| d07ce9ef21 | |||
| dcf3587d9a | |||
| 94244c1d93 | |||
| ed39317203 | |||
| 1917ed8741 | |||
| 6f8282f01e | |||
| 4f390ea18f | |||
| cb9a34c6f7 | |||
| 6759aff220 | |||
| b33f4ba300 | |||
| 85089898be | |||
| 4d65ab5a0b | |||
| abf1222f1d | |||
| b2ba9009d0 | |||
| 21ee7be30a | |||
| 9b78138600 | |||
| 160f70be63 | |||
| b98946b5c1 | |||
| 20ac0faa86 | |||
| 700e0fe7d7 | |||
| 328d8b5952 | |||
| 006b7f3f17 | |||
| 6eebcb5e48 | |||
| 0b01aa8276 | |||
| 049fbc92a9 | |||
| bc7720c0cd | |||
| 40fdf8f087 | |||
| 4fc1aba848 | |||
| 828a582f4d | |||
| d1d8417a61 | |||
| 5c3140811d | |||
| 4268d86da1 | |||
| bb017038d4 | |||
| d3f1f3533d | |||
| a445746a8b | |||
| b709baba7a | |||
| ef1d154a4a | |||
| a4bc9e669c | |||
| 5ea7a8373a | |||
| f29baed540 | |||
| d19fc64392 | |||
| 2b789ddab9 | |||
| 86b71b83fa | |||
| 486731162f | |||
| b6ab163814 | |||
| 2ea1bf0e1d | |||
| d9ad8caf02 | |||
| 14314b68ec | |||
| 3002e1cd60 | |||
| 00e738e485 | |||
| 1d6a92751b | |||
| e97e6865c3 | |||
| 55dcff746b | |||
| 691f02acab | |||
| 1f25312b65 | |||
| 26858fdebf | |||
| 7d8d0010e3 | |||
| 277042bc4e | |||
| 768182c691 | |||
| ab06d5c7fb | |||
| f97b8c835a | |||
| f375d9bd7b | |||
| e3d855673e | |||
| 62268aae65 | |||
| 09ddb5a724 | |||
| 56c44b053d | |||
| 2979da73cf | |||
| d3ac4ba83d | |||
| 203e44e026 | |||
| 4ab4dbb8a1 | |||
| 41c7ae5d54 | |||
| 2a72961be4 | |||
| 8d76d8c081 | |||
| c8995b91e2 | |||
| e492c613f7 | |||
| 6ac8f5abb7 | |||
| e0b413cf19 | |||
| a12ac5e175 | |||
| 462d3eeab1 | |||
| 97ec6c1be6 | |||
| 21070c0aaf | |||
| a96c5209d1 | |||
| e8dcbd8300 | |||
| cb75bec06d | |||
| 1e124e6713 | |||
| 84ad7cdc29 | |||
| 195d20cef2 | |||
| 91c8c6d96e | |||
| 1a4b82a5d6 | |||
| 4955aa5b78 | |||
| 131ddeaeba | |||
| b07dd44ec2 | |||
| 1793de4a28 | |||
| 646d90f3da | |||
| bd9dc73d3d | |||
| 5db62d7abd | |||
| 076f59c630 | |||
| 66694a213f | |||
| e2edfabc3c | |||
| f7fe499305 | |||
| f67ad6fd70 | |||
| c488070859 | |||
| 4b124352ef | |||
| 5dadba432e | |||
| dd6cbbbbad | |||
| 638f6f0f06 | |||
| b36163d53a | |||
| 6036a0df6b | |||
| bff0c68078 | |||
| 34fb9c7071 | |||
| d84aff701e | |||
| fa5a1f7d7f | |||
| ca105493aa | |||
| 434e43cc42 | |||
| a9f7e855d8 | |||
| 8cededa7dd | |||
| b6e4acec9d | |||
| aa92fa7ee3 | |||
| 563eda4b6b | |||
| 8652a7bdd2 | |||
| 93167afaf5 | |||
| 02ea13b511 | |||
| d6574a03a1 | |||
| ec02aee46c | |||
| 04909a2010 | |||
| 6b549e1971 | |||
| bb8606ac29 | |||
| 45d22d4f09 | |||
| a37cf24900 | |||
| b8c4098de2 | |||
| 4f67642122 | |||
| e2ee05c976 | |||
| 7e65464dd7 | |||
| d10b11ad9f | |||
| db8522b411 | |||
| ba6c41b798 | |||
| bf316d9ec5 | |||
| 7807b613d5 | |||
| 28a0650cf3 | |||
| 16e1dbbb21 | |||
| 853aec2c9a | |||
| 38cd7b9938 | |||
| 3426c7fc94 | |||
| 64e181979c | |||
| a4809b3a47 | |||
| a62ae2aa2d | |||
| d3c5161476 | |||
| 60b61de395 | |||
| f205bff2cc | |||
| 092aad1813 | |||
| 2cbc84855b | |||
| 167e42af99 | |||
| c55f477520 | |||
| ed775ac985 | |||
| 19818a95a2 | |||
| e70440b7cb | |||
| bb64aa7841 | |||
| 0e8cdd1938 | |||
| f7ff3f0803 | |||
| 8f730cfb6e | |||
| 6cfc4b5711 | |||
| 1b097d0467 | |||
| e69bbc3531 | |||
| 5038cddfd5 | |||
| 1b28a28ced | |||
| b11c3ddbed | |||
| 56b35fc103 | |||
| aaba9b7880 | |||
| 16cb4303a4 | |||
| 506deedfdd | |||
| 3ddb720722 | |||
| 567d77f1cb | |||
| f01cb240d7 | |||
| ff5c8d3570 | |||
| 3b9e0c3dde | |||
| ee28a10795 | |||
| ca4eaf92b4 | |||
| bd690f12bc | |||
| 9590fcd855 | |||
| b14f630f26 | |||
| 6dd054895b | |||
| f62578efec | |||
| d2d6c167df | |||
| 276d78461e | |||
| 911cdd4d2f | |||
| ce3df42e22 | |||
| f642656bff | |||
| b15c207d08 | |||
| 81f5973afc | |||
| f7b261a363 | |||
| 837dc4727d |
@@ -41,6 +41,7 @@ jobs:
|
||||
- mega2560
|
||||
- teensy31
|
||||
- teensy35
|
||||
- teensy41
|
||||
- SAMD51_grandcentral_m4
|
||||
|
||||
# Extended AVR Environments
|
||||
@@ -70,6 +71,7 @@ jobs:
|
||||
- mks_robin_stm32
|
||||
- ARMED
|
||||
- FYSETC_S6
|
||||
- STM32F070CB_malyan
|
||||
- STM32F070RB_malyan
|
||||
- malyan_M300
|
||||
- mks_robin_lite
|
||||
|
||||
+202
-440
File diff suppressed because it is too large
Load Diff
+221
-370
File diff suppressed because it is too large
Load Diff
+56
-52
@@ -170,110 +170,114 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1100)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1101)
|
||||
# Velleman K8400 Controller (derived from 3Drag Controller)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1102)
|
||||
# Velleman K8600 Controller (derived from 3Drag Controller)
|
||||
# Velleman K8600 Controller (Vertex Nano)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1103)
|
||||
# 2PrintBeta BAM&DICE with STK drivers
|
||||
# Velleman K8800 Controller (Vertex Delta)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1104)
|
||||
# 2PrintBeta BAM&DICE Due with STK drivers
|
||||
# 2PrintBeta BAM&DICE with STK drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1105)
|
||||
# MKS BASE v1.0
|
||||
# 2PrintBeta BAM&DICE Due with STK drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1106)
|
||||
# MKS v1.4 with A4982 stepper drivers
|
||||
# MKS BASE v1.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1107)
|
||||
# MKS v1.5 with Allegro A4982 stepper drivers
|
||||
# MKS v1.4 with A4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1108)
|
||||
# MKS v1.6 with Allegro A4982 stepper drivers
|
||||
# MKS v1.5 with Allegro A4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1109)
|
||||
# MKS BASE 1.0 with Heroic HR4982 stepper drivers
|
||||
# MKS v1.6 with Allegro A4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1110)
|
||||
# MKS GEN v1.3 or 1.4
|
||||
# MKS BASE 1.0 with Heroic HR4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1111)
|
||||
# MKS GEN L
|
||||
# MKS GEN v1.3 or 1.4
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1112)
|
||||
# zrib V2.0 control board (Chinese knock off RAMPS replica)
|
||||
# MKS GEN L
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1113)
|
||||
# BigTreeTech or BIQU KFB2.0
|
||||
# zrib V2.0 control board (Chinese knock off RAMPS replica)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1114)
|
||||
# Felix 2.0+ Electronics Board (RAMPS like)
|
||||
# BigTreeTech or BIQU KFB2.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1115)
|
||||
# Invent-A-Part RigidBoard
|
||||
# Felix 2.0+ Electronics Board (RAMPS like)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1116)
|
||||
# Invent-A-Part RigidBoard V2
|
||||
# Invent-A-Part RigidBoard
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1117)
|
||||
# Sainsmart 2-in-1 board
|
||||
# Invent-A-Part RigidBoard V2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1118)
|
||||
# Ultimaker
|
||||
# Sainsmart 2-in-1 board
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1119)
|
||||
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
|
||||
# Ultimaker
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1120)
|
||||
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1121)
|
||||
MCU ?= atmega1280
|
||||
|
||||
# Azteeg X3
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1121)
|
||||
# Azteeg X3 Pro
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1122)
|
||||
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
|
||||
# Azteeg X3 Pro
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1123)
|
||||
# Rumba
|
||||
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1124)
|
||||
# Raise3D Rumba
|
||||
# Rumba
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1125)
|
||||
# Rapide Lite RL200 Rumba
|
||||
# Raise3D Rumba
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1126)
|
||||
# Formbot T-Rex 2 Plus
|
||||
# Rapide Lite RL200 Rumba
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1127)
|
||||
# Formbot T-Rex 3
|
||||
# Formbot T-Rex 2 Plus
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1128)
|
||||
# Formbot Raptor
|
||||
# Formbot T-Rex 3
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1129)
|
||||
# Formbot Raptor 2
|
||||
# Formbot Raptor
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1130)
|
||||
# bq ZUM Mega 3D
|
||||
# Formbot Raptor 2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1131)
|
||||
# MakeBoard Mini v2.1.2 is a control board sold by MicroMake
|
||||
# bq ZUM Mega 3D
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1132)
|
||||
# TriGorilla Anycubic version 1.3 based on RAMPS EFB
|
||||
# MakeBoard Mini v2.1.2 is a control board sold by MicroMake
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1133)
|
||||
# TriGorilla Anycubic version 1.4 based on RAMPS EFB
|
||||
# TriGorilla Anycubic version 1.3 based on RAMPS EFB
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1134)
|
||||
# TriGorilla Anycubic version 1.4 Rev 1.1
|
||||
# TriGorilla Anycubic version 1.4 based on RAMPS EFB
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1135)
|
||||
# Creality: Ender-4, CR-8
|
||||
# TriGorilla Anycubic version 1.4 Rev 1.1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1136)
|
||||
# Creality: CR10S, CR20, CR-X
|
||||
# Creality: Ender-4, CR-8
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1137)
|
||||
# Dagoma F5
|
||||
# Creality: CR10S, CR20, CR-X
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1138)
|
||||
# FYSETC F6 1.3
|
||||
# Dagoma F5
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1139)
|
||||
# FYSETC F6 1.5
|
||||
# FYSETC F6 1.3
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1140)
|
||||
# Duplicator i3 Plus
|
||||
# FYSETC F6 1.5
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1141)
|
||||
# VORON
|
||||
# Duplicator i3 Plus
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1142)
|
||||
# TRONXY V3 1.0
|
||||
# VORON
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1143)
|
||||
# Z-Bolt X Series
|
||||
# TRONXY V3 1.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1144)
|
||||
# TT OSCAR
|
||||
# Z-Bolt X Series
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1145)
|
||||
# Overlord/Overlord Pro
|
||||
# TT OSCAR
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1146)
|
||||
# ADIMLab Gantry v1
|
||||
# Overlord/Overlord Pro
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1147)
|
||||
# ADIMLab Gantry v2
|
||||
# ADIMLab Gantry v1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1148)
|
||||
# BIQU Tango V1
|
||||
# ADIMLab Gantry v2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1149)
|
||||
# MKS GEN L V2
|
||||
# BIQU Tango V1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1150)
|
||||
# Copymaster 3D
|
||||
# MKS GEN L V2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1151)
|
||||
# Ortur 4
|
||||
# MKS GEN L V2.1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1152)
|
||||
# Tenlog D3 Hero
|
||||
# Copymaster 3D
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1153)
|
||||
# Ortur 4
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1154)
|
||||
# Tenlog D3 Hero
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1155)
|
||||
|
||||
#
|
||||
# RAMBo and derivatives
|
||||
@@ -694,7 +698,7 @@ ifeq ($(HARDWARE_VARIANT), Teensy)
|
||||
LIB_CXXSRC += usb_api.cpp
|
||||
|
||||
else ifeq ($(HARDWARE_VARIANT), archim)
|
||||
CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT="Archim"'
|
||||
CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"'
|
||||
LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp USBCore.cpp
|
||||
LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
|
||||
|
||||
|
||||
+6
-8
@@ -28,20 +28,20 @@
|
||||
/**
|
||||
* Marlin release version identifier
|
||||
*/
|
||||
#define SHORT_BUILD_VERSION "LulzbotUnified - 2.0.6"
|
||||
//#define SHORT_BUILD_VERSION "bugfix-2.0.x"
|
||||
|
||||
/**
|
||||
* Verbose version identifier which should contain a reference to the location
|
||||
* from where the binary was downloaded or the source code was compiled.
|
||||
*/
|
||||
#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " Rev2"
|
||||
//#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION
|
||||
|
||||
/**
|
||||
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
|
||||
* here we define this default string as the date where the latest release
|
||||
* version was tagged.
|
||||
*/
|
||||
#define STRING_DISTRIBUTION_DATE "2020-08-09"
|
||||
//#define STRING_DISTRIBUTION_DATE "2019-07-10"
|
||||
|
||||
/**
|
||||
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
||||
@@ -71,8 +71,6 @@
|
||||
* Set the vendor info the serial USB interface, if changable
|
||||
* Currently only supported by DUE platform
|
||||
*/
|
||||
#if ENABLED(TazPro)
|
||||
#define USB_DEVICE_VENDOR_ID 0x27b1 // <-- changed
|
||||
#define USB_DEVICE_PRODUCT_ID 0x0001 // <-- changed
|
||||
#endif
|
||||
//#define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL
|
||||
//#define USB_DEVICE_VENDOR_ID 0x0000
|
||||
//#define USB_DEVICE_PRODUCT_ID 0x0000
|
||||
//#define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom Bitmap for splashscreen
|
||||
*
|
||||
* You may use one of the following tools to generate the C++ bitmap array from
|
||||
* a black and white image:
|
||||
*
|
||||
* - http://www.marlinfw.org/tools/u8glib/converter.html
|
||||
* - http://www.digole.com/tools/PicturetoC_Hex_converter.php
|
||||
*/
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#define CUSTOM_BOOTSCREEN_TIMEOUT 2500
|
||||
#define CUSTOM_BOOTSCREEN_BMPWIDTH 60
|
||||
#define CUSTOM_BOOTSCREEN_BMPHEIGHT 64
|
||||
|
||||
const unsigned char custom_start_bmp[574] PROGMEM = {
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x12, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x23, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x21, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x4c, 0x80, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x5e, 0x80, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x92, 0x40, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0xa1, 0x40, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x1, 0x21, 0x20, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x2, 0x7f, 0x90, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x2, 0x0, 0x10, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x7, 0xff, 0xf8, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x4, 0x0, 0x8, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x8, 0x0, 0x4, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x8, 0x0, 0x6, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x10, 0x0, 0x2, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x30, 0x1e, 0x1, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x20, 0x7f, 0x81, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x41, 0xff, 0xe0, 0x80, 0x0, 0x0,
|
||||
0x0, 0x0, 0x43, 0xfc, 0xf0, 0x80, 0x0, 0x0,
|
||||
0x0, 0x0, 0x87, 0x3b, 0x78, 0x40, 0x0, 0x0,
|
||||
0x0, 0x1, 0x8e, 0xdb, 0xfc, 0x60, 0x0, 0x0,
|
||||
0x0, 0x1, 0xf, 0xeb, 0xcc, 0x20, 0x0, 0x0,
|
||||
0x0, 0x2, 0x1f, 0xed, 0xb6, 0x10, 0x0, 0x0,
|
||||
0x0, 0x2, 0x1f, 0xde, 0xb6, 0x10, 0x0, 0x0,
|
||||
0x0, 0x4, 0x39, 0xcd, 0x7f, 0x8, 0x0, 0x0,
|
||||
0x0, 0x4, 0x36, 0xe0, 0xff, 0x8, 0x0, 0x0,
|
||||
0x0, 0x8, 0x7e, 0xc0, 0xbb, 0x84, 0x0, 0x0,
|
||||
0x0, 0x18, 0x7f, 0x0, 0x5d, 0x86, 0x0, 0x0,
|
||||
0x0, 0x10, 0x7f, 0xc0, 0xed, 0x82, 0x0, 0x0,
|
||||
0x0, 0x20, 0x3c, 0xc0, 0x73, 0x1, 0x0, 0x0,
|
||||
0x0, 0x20, 0x3b, 0x33, 0x7f, 0x1, 0x0, 0x0,
|
||||
0x0, 0x70, 0x1b, 0xe7, 0x7e, 0x3, 0x80, 0x0,
|
||||
0x0, 0xc8, 0x1d, 0xee, 0xde, 0x4, 0xc0, 0x0,
|
||||
0x0, 0x88, 0xf, 0xde, 0xdc, 0x4, 0x40, 0x0,
|
||||
0x1, 0x24, 0xf, 0xdf, 0x3c, 0x9, 0x20, 0x0,
|
||||
0x1, 0x26, 0x7, 0xdb, 0xf8, 0x19, 0x20, 0x0,
|
||||
0x2, 0x72, 0x3, 0xe7, 0xf0, 0x13, 0x90, 0x0,
|
||||
0x2, 0x51, 0x1, 0xff, 0xe0, 0x22, 0x90, 0x0,
|
||||
0x4, 0x89, 0x0, 0x7f, 0x80, 0x24, 0x48, 0x0,
|
||||
0x9, 0x4, 0x80, 0x1e, 0x0, 0x48, 0x24, 0x0,
|
||||
0xb, 0xfe, 0x40, 0x0, 0x0, 0xdf, 0xf4, 0x0,
|
||||
0x10, 0x0, 0x40, 0x0, 0x0, 0x80, 0x2, 0x0,
|
||||
0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x10, 0x22, 0x10, 0x3c, 0x3c, 0xe, 0x1f, 0x0,
|
||||
0x10, 0x22, 0x10, 0x4, 0x22, 0x11, 0x4, 0x0,
|
||||
0x10, 0x22, 0x10, 0x8, 0x22, 0x11, 0x4, 0x0,
|
||||
0x10, 0x22, 0x10, 0x8, 0x3c, 0x11, 0x4, 0x0,
|
||||
0x10, 0x22, 0x10, 0x10, 0x22, 0x11, 0x4, 0x0,
|
||||
0x10, 0x22, 0x10, 0x20, 0x22, 0x11, 0x4, 0x0,
|
||||
0x1e, 0x1c, 0x1e, 0x3c, 0x3c, 0xe, 0x4, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
|
||||
};
|
||||
@@ -15,6 +15,7 @@
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -81,54 +82,29 @@ typedef int8_t pin_t;
|
||||
|
||||
// Serial ports
|
||||
#ifdef USBCON
|
||||
#if ENABLED(BLUETOOTH)
|
||||
#define MYSERIAL0 bluetoothSerial
|
||||
#else
|
||||
#define MYSERIAL0 Serial
|
||||
#endif
|
||||
#define NUM_SERIAL 1
|
||||
#define MYSERIAL0 TERN(BLUETOOTH, bluetoothSerial, Serial)
|
||||
#else
|
||||
#if !WITHIN(SERIAL_PORT, -1, 3)
|
||||
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
|
||||
#define MYSERIAL0 customizedSerial1
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if !WITHIN(SERIAL_PORT_2, -1, 3)
|
||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == SERIAL_PORT
|
||||
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
|
||||
#endif
|
||||
#define MYSERIAL1 customizedSerial2
|
||||
#define NUM_SERIAL 2
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
|
||||
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == SERIAL_PORT
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if !WITHIN(LCD_SERIAL_PORT, -1, 3)
|
||||
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
#define DGUS_SERIAL internalDgusSerial
|
||||
|
||||
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
|
||||
#endif
|
||||
|
||||
#ifdef ANYCUBIC_LCD_SERIAL_PORT
|
||||
#if !WITHIN(ANYCUBIC_LCD_SERIAL_PORT, -1, 3)
|
||||
#error "ANYCUBIC_LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#elif ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT
|
||||
#error "ANYCUBIC_LCD_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif defined(SERIAL_PORT_2) && ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT_2
|
||||
#error "ANYCUBIC_LCD_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
||||
#define LCD_SERIAL lcdSerial
|
||||
#if HAS_DGUS_LCD
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free()
|
||||
#endif
|
||||
#define ANYCUBIC_LCD_SERIAL anycubicLcdSerial
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
|
||||
+662
-678
File diff suppressed because it is too large
Load Diff
@@ -48,11 +48,11 @@
|
||||
|
||||
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
|
||||
// requires two levels of indirection to expand macro values properly)
|
||||
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
|
||||
#define SERIAL_REGNAME(registerbase,number,suffix) _SERIAL_REGNAME(registerbase,number,suffix)
|
||||
#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
|
||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
|
||||
#define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##suffix
|
||||
#else
|
||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
|
||||
#define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##number##suffix
|
||||
#endif
|
||||
|
||||
// Registers used by MarlinSerial class (expanded depending on selected serial port)
|
||||
@@ -217,10 +217,12 @@
|
||||
static ring_buffer_pos_t available();
|
||||
static void write(const uint8_t c);
|
||||
static void flushTX();
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#if HAS_DGUS_LCD
|
||||
static ring_buffer_pos_t get_tx_buffer_free();
|
||||
#endif
|
||||
|
||||
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 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; }
|
||||
@@ -278,55 +280,50 @@
|
||||
|
||||
#endif // !USBCON
|
||||
|
||||
#ifdef INTERNAL_SERIAL_PORT
|
||||
#ifdef MMU2_SERIAL_PORT
|
||||
template <uint8_t serial>
|
||||
struct MarlinInternalSerialCfg {
|
||||
struct MMU2SerialCfg {
|
||||
static constexpr int PORT = serial;
|
||||
static constexpr bool XONOFF = false;
|
||||
static constexpr bool EMERGENCYPARSER = false;
|
||||
static constexpr bool DROPPED_RX = false;
|
||||
static constexpr bool RX_FRAMING_ERRORS = 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 XONOFF = false;
|
||||
static constexpr bool EMERGENCYPARSER = false;
|
||||
static constexpr bool DROPPED_RX = false;
|
||||
static constexpr bool RX_OVERRUNS = false;
|
||||
static constexpr bool RX_FRAMING_ERRORS = false;
|
||||
static constexpr bool MAX_RX_QUEUED = false;
|
||||
};
|
||||
|
||||
extern MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
|
||||
extern MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>> mmuSerial;
|
||||
#endif
|
||||
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
|
||||
template <uint8_t serial>
|
||||
struct MarlinInternalSerialCfg {
|
||||
static constexpr int PORT = serial;
|
||||
static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
|
||||
static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
|
||||
static constexpr bool XONOFF = false;
|
||||
static constexpr bool EMERGENCYPARSER = false;
|
||||
static constexpr bool DROPPED_RX = false;
|
||||
static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS);
|
||||
static constexpr bool RX_FRAMING_ERRORS = false;
|
||||
static constexpr bool MAX_RX_QUEUED = false;
|
||||
struct LCDSerialCfg {
|
||||
static constexpr int PORT = serial;
|
||||
static constexpr bool XONOFF = false;
|
||||
static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
|
||||
static constexpr bool DROPPED_RX = false;
|
||||
static constexpr bool RX_FRAMING_ERRORS = false;
|
||||
static constexpr bool MAX_RX_QUEUED = false;
|
||||
#if HAS_DGUS_LCD
|
||||
static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
|
||||
static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
|
||||
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<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;
|
||||
#endif
|
||||
extern MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>> lcdSerial;
|
||||
|
||||
#ifdef ANYCUBIC_LCD_SERIAL_PORT
|
||||
template <uint8_t serial>
|
||||
struct AnycubicLcdSerialCfg {
|
||||
static constexpr int PORT = serial;
|
||||
static constexpr unsigned int RX_SIZE = 64;
|
||||
static constexpr unsigned int TX_SIZE = 128;
|
||||
static constexpr bool XONOFF = false;
|
||||
static constexpr bool EMERGENCYPARSER = false;
|
||||
static constexpr bool DROPPED_RX = false;
|
||||
static constexpr bool RX_OVERRUNS = false;
|
||||
static constexpr bool RX_FRAMING_ERRORS = false;
|
||||
static constexpr bool MAX_RX_QUEUED = false;
|
||||
};
|
||||
|
||||
extern MarlinSerial<AnycubicLcdSerialCfg<ANYCUBIC_LCD_SERIAL_PORT>> anycubicLcdSerial;
|
||||
#endif
|
||||
|
||||
// Use the UART for Bluetooth in AT90USB configurations
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
* readMicroseconds() - Get the last-written servo pulse width in microseconds.
|
||||
* attached() - Return true if a servo is attached.
|
||||
* detach() - Stop an attached servo from pulsing its i/o pin.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __AVR__
|
||||
|
||||
@@ -59,10 +59,12 @@
|
||||
// Say which 16 bit timers can be used and in what order
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
//#define _useTimer1
|
||||
#define _useTimer3
|
||||
#define _useTimer4
|
||||
#if !HAS_MOTOR_CURRENT_PWM
|
||||
#define _useTimer5 // Timer 5 is used for motor current PWM and can't be used for servos.
|
||||
#if NUM_SERVOS > SERVOS_PER_TIMER
|
||||
#define _useTimer3
|
||||
#if !HAS_MOTOR_CURRENT_PWM && SERVOS > 2 * SERVOS_PER_TIMER
|
||||
#define _useTimer5 // Timer 5 is used for motor current PWM and can't be used for servos.
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(__AVR_ATmega32U4__)
|
||||
#define _useTimer3
|
||||
|
||||
@@ -29,11 +29,17 @@
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
|
||||
#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
|
||||
#define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
|
||||
#define AVR_ATmega2561_FAMILY (defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__))
|
||||
#define AVR_ATmega328_FAMILY (defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__))
|
||||
#if defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__)
|
||||
#define AVR_AT90USB1286_FAMILY 1
|
||||
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__)
|
||||
#define AVR_ATmega1284_FAMILY 1
|
||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
#define AVR_ATmega2560_FAMILY 1
|
||||
#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
|
||||
#define AVR_ATmega2561_FAMILY 1
|
||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
|
||||
#define AVR_ATmega328_FAMILY 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Include Ports and Functions
|
||||
|
||||
@@ -36,9 +36,10 @@
|
||||
* Sanity checks for Spindle / Laser PWM
|
||||
*/
|
||||
#if ENABLED(SPINDLE_LASER_PWM)
|
||||
#include "../ServoTimers.h" // Needed to check timer availability (_useTimer3)
|
||||
#if SPINDLE_LASER_PWM_PIN == 4 || WITHIN(SPINDLE_LASER_PWM_PIN, 11, 13)
|
||||
#error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by a system interrupt."
|
||||
#elif NUM_SERVOS > 0 && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5)
|
||||
#elif NUM_SERVOS > 0 && defined(_useTimer3) && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5)
|
||||
#error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system."
|
||||
#endif
|
||||
#elif defined(SPINDLE_LASER_FREQUENCY)
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
|
||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||
|
||||
#define AVR_ATmega2560_FAMILY_PLUS_70 MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H)
|
||||
#if MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H, TRIGORILLA_14)
|
||||
#define AVR_ATmega2560_FAMILY_PLUS_70 1
|
||||
#endif
|
||||
|
||||
#if AVR_AT90USB1286_FAMILY
|
||||
|
||||
|
||||
@@ -22,15 +22,12 @@
|
||||
* Structures for 2560 family boards that use more than 70 pins
|
||||
*/
|
||||
|
||||
#undef NUM_DIGITAL_PINS
|
||||
#if MB(BQ_ZUM_MEGA_3D)
|
||||
#if MB(BQ_ZUM_MEGA_3D, MINIRAMBO, SCOOVO_X9H, TRIGORILLA_14)
|
||||
#undef NUM_DIGITAL_PINS
|
||||
#define NUM_DIGITAL_PINS 85
|
||||
#elif MB(MIGHTYBOARD_REVE)
|
||||
#undef NUM_DIGITAL_PINS
|
||||
#define NUM_DIGITAL_PINS 80
|
||||
#elif MB(MINIRAMBO)
|
||||
#define NUM_DIGITAL_PINS 85
|
||||
#elif MB(SCOOVO_X9H)
|
||||
#define NUM_DIGITAL_PINS 85
|
||||
#endif
|
||||
|
||||
#define PA 1
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*
|
||||
* 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
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
#if HAS_MARLINUI_U8GLIB
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/Delay.h"
|
||||
@@ -189,5 +189,5 @@ uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#endif // HAS_MARLINUI_U8GLIB
|
||||
#endif // ARDUINO_ARCH_SAM
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description: HAL for Arduino Due and compatible (SAM3X8E)
|
||||
*
|
||||
* For ARDUINO_ARCH_SAM
|
||||
* HAL for Arduino Due and compatible (SAM3X8E)
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAM
|
||||
|
||||
+16
-41
@@ -22,9 +22,7 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Description: HAL for Arduino Due and compatible (SAM3X8E)
|
||||
*
|
||||
* For ARDUINO_ARCH_SAM
|
||||
* HAL for Arduino Due and compatible (SAM3X8E)
|
||||
*/
|
||||
|
||||
#define CPU_32_BIT
|
||||
@@ -38,59 +36,36 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define _MSERIAL(X) Serial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
#define Serial0 Serial
|
||||
|
||||
// Define MYSERIAL0/1 before MarlinSerial includes!
|
||||
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL0 customizedSerial1
|
||||
#elif SERIAL_PORT == 0
|
||||
#define MYSERIAL0 Serial
|
||||
#elif SERIAL_PORT == 1
|
||||
#define MYSERIAL0 Serial1
|
||||
#elif SERIAL_PORT == 2
|
||||
#define MYSERIAL0 Serial2
|
||||
#elif SERIAL_PORT == 3
|
||||
#define MYSERIAL0 Serial3
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == SERIAL_PORT
|
||||
#error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
|
||||
#if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL1 customizedSerial2
|
||||
#elif SERIAL_PORT_2 == 0
|
||||
#define MYSERIAL1 Serial
|
||||
#elif SERIAL_PORT_2 == 1
|
||||
#define MYSERIAL1 Serial1
|
||||
#elif SERIAL_PORT_2 == 2
|
||||
#define MYSERIAL1 Serial2
|
||||
#elif SERIAL_PORT_2 == 3
|
||||
#define MYSERIAL1 Serial3
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
#define NUM_SERIAL 2
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#if DGUS_SERIAL_PORT == SERIAL_PORT
|
||||
#error "DGUS_SERIAL_PORT must be different from SERIAL_PORT. Please update your configuration."
|
||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == -1
|
||||
#define DGUS_SERIAL internalDgusSerial
|
||||
#elif DGUS_SERIAL_PORT == 0
|
||||
#define DGUS_SERIAL Serial
|
||||
#elif DGUS_SERIAL_PORT == 1
|
||||
#define DGUS_SERIAL Serial1
|
||||
#elif DGUS_SERIAL_PORT == 2
|
||||
#define DGUS_SERIAL Serial2
|
||||
#elif DGUS_SERIAL_PORT == 3
|
||||
#define DGUS_SERIAL Serial3
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL lcdSerial
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "DGUS_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."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description: HAL for Arduino Due and compatible (SAM3X8E)
|
||||
* HAL for Arduino Due and compatible (SAM3X8E)
|
||||
*
|
||||
* For ARDUINO_ARCH_SAM
|
||||
*/
|
||||
@@ -595,7 +595,7 @@
|
||||
SPI_Enable(SPI0);
|
||||
|
||||
SET_OUTPUT(DAC0_SYNC);
|
||||
#if EXTRUDERS > 1
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
SET_OUTPUT(DAC1_SYNC);
|
||||
WRITE(DAC1_SYNC, HIGH);
|
||||
#endif
|
||||
@@ -759,7 +759,6 @@
|
||||
*
|
||||
* All of the above can be avoided by defining FORCE_SOFT_SPI to force the
|
||||
* display to use software SPI.
|
||||
*
|
||||
*/
|
||||
|
||||
void spiInit(uint8_t spiRate=6) { // Default to slowest rate if not specified)
|
||||
|
||||
@@ -122,6 +122,8 @@ public:
|
||||
static void write(const uint8_t c);
|
||||
static void flushTX();
|
||||
|
||||
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 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; }
|
||||
|
||||
@@ -52,14 +52,13 @@
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __SAM3X8E__
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
#if HAS_MARLINUI_U8GLIB
|
||||
|
||||
#include <U8glib.h>
|
||||
|
||||
@@ -145,6 +144,6 @@ uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#endif // HAS_MARLINUI_U8GLIB
|
||||
|
||||
#endif //__SAM3X8E__
|
||||
#endif // __SAM3X8E__
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920)
|
||||
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
|
||||
|
||||
#undef SPI_SPEED
|
||||
#define SPI_SPEED 2 // About 2 MHz
|
||||
@@ -144,5 +144,5 @@ uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD && !U8GLIB_ST7920
|
||||
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
|
||||
#endif // ARDUINO_ARCH_SAM
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
#if HAS_MARLINUI_U8GLIB
|
||||
|
||||
#include "../../shared/Delay.h"
|
||||
|
||||
@@ -108,5 +108,5 @@ void u8g_spiSend_sw_DUE_mode_3(uint8_t val) { // 3.5MHz
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#endif // HAS_MARLINUI_U8GLIB
|
||||
#endif // ARDUINO_ARCH_SAM
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
* per page. We can't emulate EE endurance with FLASH for all
|
||||
* bytes, but we can emulate endurance for a given percent of
|
||||
* bytes.
|
||||
*
|
||||
*/
|
||||
|
||||
//#define EE_EMU_DEBUG
|
||||
|
||||
@@ -179,5 +179,4 @@ void pwm_details(int32_t pin) {
|
||||
* ----------------+--------
|
||||
* ID | PB11
|
||||
* VBOF | PB10
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description: HAL for Arduino Due and compatible (SAM3X8E)
|
||||
*
|
||||
* For ARDUINO_ARCH_SAM
|
||||
* HAL Timers for Arduino Due and compatible (SAM3X8E)
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAM
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* HAL for Arduino Due and compatible (SAM3X8E)
|
||||
*
|
||||
* For ARDUINO_ARCH_SAM
|
||||
* HAL Timers for Arduino Due and compatible (SAM3X8E)
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -14,5 +14,5 @@ if current_OS == 'Windows':
|
||||
|
||||
# Use bossac.exe on Windows
|
||||
env.Replace(
|
||||
UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot"
|
||||
UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE"
|
||||
)
|
||||
|
||||
@@ -93,5 +93,5 @@
|
||||
#define USB_VBOF_GPIO (PIO_PB10_IDX)
|
||||
#define USB_VBOF_FLAGS (PIO_PERIPH_A | PIO_DEFAULT)
|
||||
/*! Active level of the USB_VBOF output pin. */
|
||||
#define USB_VBOF_ACTIVE_LEVEL LOW
|
||||
#define USB_VBOF_ACTIVE_STATE LOW
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
@@ -173,11 +173,11 @@
|
||||
# define __always_inline __forceinline
|
||||
#elif (defined __GNUC__)
|
||||
#ifdef __always_inline
|
||||
# undef __always_inline
|
||||
# undef __always_inline
|
||||
#endif
|
||||
# define __always_inline inline __attribute__((__always_inline__))
|
||||
# define __always_inline inline __attribute__((__always_inline__))
|
||||
#elif (defined __ICCARM__)
|
||||
# define __always_inline _Pragma("inline=forced")
|
||||
# define __always_inline _Pragma("inline=forced")
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -188,11 +188,11 @@
|
||||
* heuristics and not inline the function.
|
||||
*/
|
||||
#ifdef __CC_ARM
|
||||
# define __no_inline __attribute__((noinline))
|
||||
# define __no_inline __attribute__((noinline))
|
||||
#elif (defined __GNUC__)
|
||||
# define __no_inline __attribute__((__noinline__))
|
||||
# define __no_inline __attribute__((__noinline__))
|
||||
#elif (defined __ICCARM__)
|
||||
# define __no_inline _Pragma("inline=never")
|
||||
# define __no_inline _Pragma("inline=never")
|
||||
#endif
|
||||
|
||||
/*! \brief This macro is used to test fatal errors.
|
||||
@@ -211,9 +211,9 @@
|
||||
# else
|
||||
#undef TEST_SUITE_DEFINE_ASSERT_MACRO
|
||||
# define Assert(expr) \
|
||||
{\
|
||||
if (!(expr)) while (true);\
|
||||
}
|
||||
{\
|
||||
if (!(expr)) while (true);\
|
||||
}
|
||||
# endif
|
||||
#else
|
||||
# define Assert(expr) ((void) 0)
|
||||
@@ -1106,17 +1106,16 @@ static inline uint16_t convert_byte_array_to_16_bit(uint8_t *data)
|
||||
/* Converts a 8 Byte array into a 32-Bit value */
|
||||
static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t u32;
|
||||
uint8_t u8[8];
|
||||
}long_addr;
|
||||
uint8_t index;
|
||||
for (index = 0; index < 4; index++)
|
||||
{
|
||||
long_addr.u8[index] = *data++;
|
||||
}
|
||||
return long_addr.u32;
|
||||
union
|
||||
{
|
||||
uint32_t u32;
|
||||
uint8_t u8[8];
|
||||
}long_addr;
|
||||
uint8_t index;
|
||||
for (index = 0; index < 4; index++) {
|
||||
long_addr.u8[index] = *data++;
|
||||
}
|
||||
return long_addr.u32;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
*
|
||||
* 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
|
||||
|
||||
/**
|
||||
* Description: HAL for Espressif ESP32 WiFi
|
||||
* HAL for Espressif ESP32 WiFi
|
||||
*/
|
||||
|
||||
#define CPU_32_BIT
|
||||
@@ -58,9 +59,6 @@ extern portMUX_TYPE spinlock;
|
||||
#else
|
||||
#define MYSERIAL1 webSocketSerial
|
||||
#endif
|
||||
#define NUM_SERIAL 2
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock)
|
||||
|
||||
@@ -86,7 +86,7 @@ int RingBuffer::read() {
|
||||
ring_buffer_pos_t RingBuffer::read(uint8_t *buffer) {
|
||||
ring_buffer_pos_t len = available();
|
||||
|
||||
for(ring_buffer_pos_t i = 0; read_index != write_index; i++) {
|
||||
for (ring_buffer_pos_t i = 0; read_index != write_index; i++) {
|
||||
buffer[i] = data[read_index];
|
||||
read_index = NEXT_INDEX(read_index, size);
|
||||
}
|
||||
@@ -139,9 +139,8 @@ size_t WebSocketSerial::write(const uint8_t c) {
|
||||
|
||||
size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) {
|
||||
size_t written = 0;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
for (size_t i = 0; i < size; i++)
|
||||
written += write(buffer[i]);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*
|
||||
* 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
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
|
||||
#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)
|
||||
|
||||
#ifndef I2C_ADDRESS
|
||||
@@ -38,7 +44,7 @@
|
||||
|
||||
// String helper
|
||||
#ifndef PGMSTR
|
||||
#define PGMSTR(NAM,STR) constexpr char NAM[] = STR
|
||||
#define PGMSTR(NAM,STR) const char NAM[] = STR
|
||||
#endif
|
||||
|
||||
inline void watchdog_refresh() {
|
||||
|
||||
@@ -62,7 +62,6 @@ uint8_t _getc();
|
||||
|
||||
extern HalSerial usb_serial;
|
||||
#define MYSERIAL0 usb_serial
|
||||
#define NUM_SERIAL 1
|
||||
|
||||
#define ST7920_DELAY_1 DELAY_NS(600)
|
||||
#define ST7920_DELAY_2 DELAY_NS(750)
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
* Generic RingBuffer
|
||||
* T type of the buffer array
|
||||
* S size of the buffer (must be power of 2)
|
||||
*
|
||||
*/
|
||||
template <typename T, uint32_t S> class RingBuffer {
|
||||
public:
|
||||
@@ -79,6 +78,7 @@ public:
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
EmergencyParser::State emergency_state;
|
||||
static inline bool emergency_parser_enabled() { return true; }
|
||||
#endif
|
||||
|
||||
HalSerial() { host_connected = true; }
|
||||
|
||||
@@ -107,7 +107,7 @@ int main() {
|
||||
std::thread write_serial (write_serial_thread);
|
||||
std::thread read_serial (read_serial_thread);
|
||||
|
||||
#if NUM_SERIAL > 0
|
||||
#ifdef MYSERIAL0
|
||||
MYSERIAL0.begin(BAUDRATE);
|
||||
SERIAL_ECHOLNPGM("x86_64 Initialized");
|
||||
SERIAL_FLUSHTX();
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
|
||||
*
|
||||
* The only modification was to update/delete macros to match the LPC176x.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "../../core/macros.h"
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if BOTH(HAS_GRAPHICAL_LCD, SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
||||
#if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
||||
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
|
||||
// needed due to the speed and mode required for communicating with each device being different.
|
||||
// This requirement can be removed if the SPI access to these devices is updated to use
|
||||
|
||||
@@ -63,58 +63,35 @@ extern "C" volatile uint32_t _millis;
|
||||
#define ST7920_DELAY_3 DELAY_NS(750)
|
||||
#endif
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
#define MSerial0 MSerial
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL0 UsbSerial
|
||||
#elif SERIAL_PORT == 0
|
||||
#define MYSERIAL0 MSerial
|
||||
#elif SERIAL_PORT == 1
|
||||
#define MYSERIAL0 MSerial1
|
||||
#elif SERIAL_PORT == 2
|
||||
#define MYSERIAL0 MSerial2
|
||||
#elif SERIAL_PORT == 3
|
||||
#define MYSERIAL0 MSerial3
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == SERIAL_PORT
|
||||
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == -1
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL1 UsbSerial
|
||||
#elif SERIAL_PORT_2 == 0
|
||||
#define MYSERIAL1 MSerial
|
||||
#elif SERIAL_PORT_2 == 1
|
||||
#define MYSERIAL1 MSerial1
|
||||
#elif SERIAL_PORT_2 == 2
|
||||
#define MYSERIAL1 MSerial2
|
||||
#elif SERIAL_PORT_2 == 3
|
||||
#define MYSERIAL1 MSerial3
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
#define NUM_SERIAL 2
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#if DGUS_SERIAL_PORT == SERIAL_PORT
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == -1
|
||||
#define DGUS_SERIAL UsbSerial
|
||||
#elif DGUS_SERIAL_PORT == 0
|
||||
#define DGUS_SERIAL MSerial
|
||||
#elif DGUS_SERIAL_PORT == 1
|
||||
#define DGUS_SERIAL MSerial1
|
||||
#elif DGUS_SERIAL_PORT == 2
|
||||
#define DGUS_SERIAL MSerial2
|
||||
#elif DGUS_SERIAL_PORT == 3
|
||||
#define DGUS_SERIAL MSerial3
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL UsbSerial
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "DGUS_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."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hardware SPI and a software SPI implementations are included in this file.
|
||||
* Hardware SPI and Software SPI implementations are included in this file.
|
||||
* The hardware SPI runs faster and has higher throughput but is not compatible
|
||||
* with some LCD interfaces/adapters.
|
||||
*
|
||||
@@ -39,10 +39,10 @@
|
||||
* Some of the LCD interfaces/adapters result in the LCD SPI and the SD card
|
||||
* SPI sharing pins. The SCK, MOSI & MISO pins can NOT be set/cleared with
|
||||
* WRITE nor digitalWrite when the hardware SPI module within the LPC17xx is
|
||||
* active. If any of these pins are shared then the software SPI must be used.
|
||||
* active. If any of these pins are shared then the software SPI must be used.
|
||||
*
|
||||
* A more sophisticated hardware SPI can be found at the following link. This
|
||||
* implementation has not been fully debugged.
|
||||
* A more sophisticated hardware SPI can be found at the following link.
|
||||
* This implementation has not been fully debugged.
|
||||
* https://github.com/MarlinFirmware/Marlin/tree/071c7a78f27078fd4aee9a3ef365fcf5e143531e
|
||||
*/
|
||||
|
||||
@@ -51,6 +51,10 @@
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include <SPI.h>
|
||||
|
||||
// Hardware SPI and SPIClass
|
||||
#include <lpc17xx_pinsel.h>
|
||||
#include <lpc17xx_clkpwr.h>
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
@@ -96,78 +100,25 @@
|
||||
|
||||
#else
|
||||
|
||||
// Hardware SPI
|
||||
|
||||
#include <lpc17xx_pinsel.h>
|
||||
#include <lpc17xx_ssp.h>
|
||||
#include <lpc17xx_clkpwr.h>
|
||||
|
||||
// decide which HW SPI device to use
|
||||
#ifndef LPC_HW_SPI_DEV
|
||||
#if (SCK_PIN == P0_07 && MISO_PIN == P0_08 && MOSI_PIN == P0_09)
|
||||
#define LPC_HW_SPI_DEV 1
|
||||
#else
|
||||
#if (SCK_PIN == P0_15 && MISO_PIN == P0_17 && MOSI_PIN == P0_18)
|
||||
#define LPC_HW_SPI_DEV 0
|
||||
#else
|
||||
#error "Invalid pins selected for hardware SPI"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if (LPC_HW_SPI_DEV == 0)
|
||||
#define LPC_SSPn LPC_SSP0
|
||||
#else
|
||||
#define LPC_SSPn LPC_SSP1
|
||||
#endif
|
||||
|
||||
void spiBegin() { // setup SCK, MOSI & MISO pins for SSP0
|
||||
PINSEL_CFG_Type PinCfg; // data structure to hold init values
|
||||
PinCfg.Funcnum = 2;
|
||||
PinCfg.OpenDrain = 0;
|
||||
PinCfg.Pinmode = 0;
|
||||
PinCfg.Pinnum = LPC176x::pin_bit(SCK_PIN);
|
||||
PinCfg.Portnum = LPC176x::pin_port(SCK_PIN);
|
||||
PINSEL_ConfigPin(&PinCfg);
|
||||
SET_OUTPUT(SCK_PIN);
|
||||
|
||||
PinCfg.Pinnum = LPC176x::pin_bit(MISO_PIN);
|
||||
PinCfg.Portnum = LPC176x::pin_port(MISO_PIN);
|
||||
PINSEL_ConfigPin(&PinCfg);
|
||||
SET_INPUT(MISO_PIN);
|
||||
|
||||
PinCfg.Pinnum = LPC176x::pin_bit(MOSI_PIN);
|
||||
PinCfg.Portnum = LPC176x::pin_port(MOSI_PIN);
|
||||
PINSEL_ConfigPin(&PinCfg);
|
||||
SET_OUTPUT(MOSI_PIN);
|
||||
// divide PCLK by 2 for SSP0
|
||||
CLKPWR_SetPCLKDiv(LPC_HW_SPI_DEV == 0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2);
|
||||
spiInit(0);
|
||||
SSP_Cmd(LPC_SSPn, ENABLE); // start SSP running
|
||||
spiInit(SPI_SPEED);
|
||||
}
|
||||
|
||||
void spiInit(uint8_t spiRate) {
|
||||
// table to convert Marlin spiRates (0-5 plus default) into bit rates
|
||||
uint32_t Marlin_speed[7]; // CPSR is always 2
|
||||
Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
|
||||
Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
|
||||
Marlin_speed[2] = 2083333; //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
|
||||
Marlin_speed[3] = 1000000; //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
|
||||
Marlin_speed[4] = 500000; //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
|
||||
Marlin_speed[5] = 250000; //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
|
||||
Marlin_speed[6] = 125000; //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
|
||||
// setup for SPI mode
|
||||
SSP_CFG_Type HW_SPI_init; // data structure to hold init values
|
||||
SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode
|
||||
HW_SPI_init.ClockRate = Marlin_speed[_MIN(spiRate, 6)]; // put in the specified bit rate
|
||||
HW_SPI_init.Mode |= SSP_CR1_SSP_EN;
|
||||
SSP_Init(LPC_SSPn, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers
|
||||
#if MISO_PIN == BOARD_SPI1_MISO_PIN
|
||||
SPI.setModule(1);
|
||||
#elif MISO_PIN == BOARD_SPI2_MISO_PIN
|
||||
SPI.setModule(2);
|
||||
#endif
|
||||
SPI.setDataSize(DATA_SIZE_8BIT);
|
||||
SPI.setDataMode(SPI_MODE0);
|
||||
|
||||
SPI.setClock(SPISettings::spiRate2Clock(spiRate));
|
||||
SPI.begin();
|
||||
}
|
||||
|
||||
static uint8_t doio(uint8_t b) {
|
||||
/* send and receive a single byte */
|
||||
SSP_SendData(LPC_SSPn, b & 0x00FF);
|
||||
while (SSP_GetStatus(LPC_SSPn, SSP_STAT_BUSY)); // wait for it to finish
|
||||
return SSP_ReceiveData(LPC_SSPn) & 0x00FF;
|
||||
return SPI.transfer(b & 0x00FF) & 0x00FF;
|
||||
}
|
||||
|
||||
void spiSend(uint8_t b) { doio(b); }
|
||||
@@ -192,7 +143,7 @@
|
||||
for (uint16_t i = 0; i < nbyte; i++) buf[i] = doio(0xFF);
|
||||
}
|
||||
|
||||
static uint8_t spiTransfer(uint8_t b) {
|
||||
uint8_t spiTransfer(uint8_t b) {
|
||||
return doio(b);
|
||||
}
|
||||
|
||||
@@ -211,30 +162,244 @@
|
||||
|
||||
#endif // LPC_SOFTWARE_SPI
|
||||
|
||||
void SPIClass::begin() { spiBegin(); }
|
||||
/**
|
||||
* @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset.
|
||||
*/
|
||||
static inline void waitSpiTxEnd(LPC_SSP_TypeDef *spi_d) {
|
||||
while (SSP_GetStatus(spi_d, SSP_STAT_TXFIFO_EMPTY) == RESET) { /* nada */ } // wait until TXE=1
|
||||
while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0
|
||||
}
|
||||
|
||||
// Retain the pin init state of the SPI, to avoid init more than once,
|
||||
// even if more instances of SPIClass exist
|
||||
static bool spiInitialised[BOARD_NR_SPI] = { false };
|
||||
|
||||
SPIClass::SPIClass(uint8_t device) {
|
||||
// Init things specific to each SPI device
|
||||
// clock divider setup is a bit of hack, and needs to be improved at a later date.
|
||||
|
||||
#if BOARD_NR_SPI >= 1
|
||||
_settings[0].spi_d = LPC_SSP0;
|
||||
_settings[0].dataMode = SPI_MODE0;
|
||||
_settings[0].dataSize = DATA_SIZE_8BIT;
|
||||
_settings[0].clock = SPI_CLOCK_MAX;
|
||||
//_settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
|
||||
#endif
|
||||
|
||||
#if BOARD_NR_SPI >= 2
|
||||
_settings[1].spi_d = LPC_SSP1;
|
||||
_settings[1].dataMode = SPI_MODE0;
|
||||
_settings[1].dataSize = DATA_SIZE_8BIT;
|
||||
_settings[1].clock = SPI_CLOCK_MAX;
|
||||
//_settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
|
||||
#endif
|
||||
|
||||
setModule(device);
|
||||
|
||||
// Init the GPDMA controller
|
||||
// TODO: call once in the constructor? or each time?
|
||||
GPDMA_Init();
|
||||
}
|
||||
|
||||
void SPIClass::begin() {
|
||||
// Init the SPI pins in the first begin call
|
||||
if ((_currentSetting->spi_d == LPC_SSP0 && spiInitialised[0] == false) ||
|
||||
(_currentSetting->spi_d == LPC_SSP1 && spiInitialised[1] == false)) {
|
||||
pin_t sck, miso, mosi;
|
||||
if (_currentSetting->spi_d == LPC_SSP0) {
|
||||
sck = BOARD_SPI1_SCK_PIN;
|
||||
miso = BOARD_SPI1_MISO_PIN;
|
||||
mosi = BOARD_SPI1_MOSI_PIN;
|
||||
spiInitialised[0] = true;
|
||||
}
|
||||
else if (_currentSetting->spi_d == LPC_SSP1) {
|
||||
sck = BOARD_SPI2_SCK_PIN;
|
||||
miso = BOARD_SPI2_MISO_PIN;
|
||||
mosi = BOARD_SPI2_MOSI_PIN;
|
||||
spiInitialised[1] = true;
|
||||
}
|
||||
PINSEL_CFG_Type PinCfg; // data structure to hold init values
|
||||
PinCfg.Funcnum = 2;
|
||||
PinCfg.OpenDrain = 0;
|
||||
PinCfg.Pinmode = 0;
|
||||
PinCfg.Pinnum = LPC176x::pin_bit(sck);
|
||||
PinCfg.Portnum = LPC176x::pin_port(sck);
|
||||
PINSEL_ConfigPin(&PinCfg);
|
||||
SET_OUTPUT(sck);
|
||||
|
||||
PinCfg.Pinnum = LPC176x::pin_bit(miso);
|
||||
PinCfg.Portnum = LPC176x::pin_port(miso);
|
||||
PINSEL_ConfigPin(&PinCfg);
|
||||
SET_INPUT(miso);
|
||||
|
||||
PinCfg.Pinnum = LPC176x::pin_bit(mosi);
|
||||
PinCfg.Portnum = LPC176x::pin_port(mosi);
|
||||
PINSEL_ConfigPin(&PinCfg);
|
||||
SET_OUTPUT(mosi);
|
||||
}
|
||||
|
||||
updateSettings();
|
||||
SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running
|
||||
}
|
||||
|
||||
void SPIClass::beginTransaction(const SPISettings &cfg) {
|
||||
uint8_t spiRate;
|
||||
switch (cfg.spiRate()) {
|
||||
case 8000000: spiRate = 0; break;
|
||||
case 4000000: spiRate = 1; break;
|
||||
case 2000000: spiRate = 2; break;
|
||||
case 1000000: spiRate = 3; break;
|
||||
case 500000: spiRate = 4; break;
|
||||
case 250000: spiRate = 5; break;
|
||||
case 125000: spiRate = 6; break;
|
||||
default: spiRate = 2; break;
|
||||
}
|
||||
spiInit(spiRate);
|
||||
setBitOrder(cfg.bitOrder);
|
||||
setDataMode(cfg.dataMode);
|
||||
setDataSize(cfg.dataSize);
|
||||
//setClockDivider(determine_baud_rate(_currentSetting->spi_d, settings.clock));
|
||||
begin();
|
||||
}
|
||||
|
||||
uint8_t SPIClass::transfer(const uint8_t B) { return spiTransfer(B); }
|
||||
uint8_t SPIClass::transfer(const uint16_t b) {
|
||||
// Send and receive a single byte
|
||||
SSP_ReceiveData(_currentSetting->spi_d); // read any previous data
|
||||
SSP_SendData(_currentSetting->spi_d, b);
|
||||
waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish
|
||||
return SSP_ReceiveData(_currentSetting->spi_d);
|
||||
}
|
||||
|
||||
uint16_t SPIClass::transfer16(const uint16_t data) {
|
||||
return (transfer((data >> 8) & 0xFF) << 8)
|
||||
| (transfer(data & 0xFF) & 0xFF);
|
||||
return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF);
|
||||
}
|
||||
|
||||
SPIClass SPI;
|
||||
void SPIClass::end() {
|
||||
// SSP_Cmd(_currentSetting->spi_d, DISABLE); // stop device or SSP_DeInit?
|
||||
SSP_DeInit(_currentSetting->spi_d);
|
||||
}
|
||||
|
||||
void SPIClass::send(uint8_t data) {
|
||||
SSP_SendData(_currentSetting->spi_d, data);
|
||||
}
|
||||
|
||||
void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
|
||||
//TODO: LPC dma can only write 0xFFF bytes at once.
|
||||
GPDMA_Channel_CFG_Type GPDMACfg;
|
||||
|
||||
/* Configure GPDMA channel 0 -------------------------------------------------------------*/
|
||||
/* DMA Channel 0 */
|
||||
GPDMACfg.ChannelNum = 0;
|
||||
// Source memory
|
||||
GPDMACfg.SrcMemAddr = (uint32_t)buf;
|
||||
// Destination memory - Not used
|
||||
GPDMACfg.DstMemAddr = 0;
|
||||
// Transfer size
|
||||
GPDMACfg.TransferSize = length;
|
||||
// Transfer width
|
||||
GPDMACfg.TransferWidth = (_currentSetting->dataSize == DATA_SIZE_16BIT) ? GPDMA_WIDTH_HALFWORD : GPDMA_WIDTH_BYTE;
|
||||
// Transfer type
|
||||
GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
|
||||
// Source connection - unused
|
||||
GPDMACfg.SrcConn = 0;
|
||||
// Destination connection
|
||||
GPDMACfg.DstConn = (_currentSetting->spi_d == LPC_SSP0) ? GPDMA_CONN_SSP0_Tx : GPDMA_CONN_SSP1_Tx;
|
||||
|
||||
GPDMACfg.DMALLI = 0;
|
||||
|
||||
// Enable dma on SPI
|
||||
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE);
|
||||
|
||||
// Only increase memory if minc is true
|
||||
GPDMACfg.MemoryIncrease = (minc ? GPDMA_DMACCxControl_SI : 0);
|
||||
|
||||
// Setup channel with given parameter
|
||||
GPDMA_Setup(&GPDMACfg);
|
||||
|
||||
// Enable DMA
|
||||
GPDMA_ChannelCmd(0, ENABLE);
|
||||
|
||||
// Wait for data transfer
|
||||
while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { }
|
||||
|
||||
// Clear err and int
|
||||
GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
|
||||
GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
|
||||
|
||||
// Disable DMA
|
||||
GPDMA_ChannelCmd(0, DISABLE);
|
||||
|
||||
waitSpiTxEnd(_currentSetting->spi_d);
|
||||
|
||||
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE);
|
||||
}
|
||||
|
||||
uint16_t SPIClass::read() {
|
||||
return SSP_ReceiveData(_currentSetting->spi_d);
|
||||
}
|
||||
|
||||
void SPIClass::read(uint8_t *buf, uint32_t len) {
|
||||
for (uint16_t i = 0; i < len; i++) buf[i] = transfer(0xFF);
|
||||
}
|
||||
|
||||
void SPIClass::setClock(uint32_t clock) {
|
||||
_currentSetting->clock = clock;
|
||||
}
|
||||
|
||||
void SPIClass::setModule(uint8_t device) {
|
||||
_currentSetting = &_settings[device - 1];// SPI channels are called 1 2 and 3 but the array is zero indexed
|
||||
}
|
||||
|
||||
void SPIClass::setBitOrder(uint8_t bitOrder) {
|
||||
_currentSetting->bitOrder = bitOrder;
|
||||
}
|
||||
|
||||
void SPIClass::setDataMode(uint8_t dataMode) {
|
||||
_currentSetting->dataMode = dataMode;
|
||||
}
|
||||
|
||||
void SPIClass::setDataSize(uint32_t ds) {
|
||||
_currentSetting->dataSize = ds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up/tear down
|
||||
*/
|
||||
void SPIClass::updateSettings() {
|
||||
//SSP_DeInit(_currentSetting->spi_d); //todo: need force de init?!
|
||||
|
||||
// divide PCLK by 2 for SSP0
|
||||
CLKPWR_SetPCLKDiv(_currentSetting->spi_d == LPC_SSP0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2);
|
||||
|
||||
SSP_CFG_Type HW_SPI_init; // data structure to hold init values
|
||||
SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode
|
||||
HW_SPI_init.ClockRate = _currentSetting->clock;
|
||||
HW_SPI_init.Databit = _currentSetting->dataSize;
|
||||
|
||||
/**
|
||||
* SPI Mode CPOL CPHA Shift SCK-edge Capture SCK-edge
|
||||
* 0 0 0 Falling Rising
|
||||
* 1 0 1 Rising Falling
|
||||
* 2 1 0 Rising Falling
|
||||
* 3 1 1 Falling Rising
|
||||
*/
|
||||
switch (_currentSetting->dataMode) {
|
||||
case SPI_MODE0:
|
||||
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
|
||||
HW_SPI_init.CPOL = SSP_CPOL_HI;
|
||||
break;
|
||||
case SPI_MODE1:
|
||||
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
|
||||
HW_SPI_init.CPOL = SSP_CPOL_HI;
|
||||
break;
|
||||
case SPI_MODE2:
|
||||
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
|
||||
HW_SPI_init.CPOL = SSP_CPOL_LO;
|
||||
break;
|
||||
case SPI_MODE3:
|
||||
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
|
||||
HW_SPI_init.CPOL = SSP_CPOL_LO;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: handle bitOrder
|
||||
SSP_Init(_currentSetting->spi_d, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers
|
||||
}
|
||||
|
||||
#if MISO_PIN == BOARD_SPI1_MISO_PIN
|
||||
SPIClass SPI(1);
|
||||
#elif MISO_PIN == BOARD_SPI2_MISO_PIN
|
||||
SPIClass SPI(2);
|
||||
#endif
|
||||
|
||||
#endif // TARGET_LPC1768
|
||||
|
||||
@@ -24,28 +24,28 @@
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0)
|
||||
#if USING_SERIAL_0
|
||||
MarlinSerial MSerial(LPC_UART0);
|
||||
extern "C" void UART0_IRQHandler() {
|
||||
MSerial.IRQHandler();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
|
||||
#if USING_SERIAL_1
|
||||
MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
|
||||
extern "C" void UART1_IRQHandler() {
|
||||
MSerial1.IRQHandler();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
|
||||
#if USING_SERIAL_2
|
||||
MarlinSerial MSerial2(LPC_UART2);
|
||||
extern "C" void UART2_IRQHandler() {
|
||||
MSerial2.IRQHandler();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
|
||||
#if USING_SERIAL_3
|
||||
MarlinSerial MSerial3(LPC_UART3);
|
||||
extern "C" void UART3_IRQHandler() {
|
||||
MSerial3.IRQHandler();
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
}
|
||||
|
||||
EmergencyParser::State emergency_state;
|
||||
static inline bool emergency_parser_enabled() { return true; }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
|
||||
*
|
||||
* The only modification was to update/delete macros to match the LPC176x.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Servo.h>
|
||||
|
||||
@@ -21,6 +21,13 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if HAS_SPI_TFT || HAS_FSMC_TFT
|
||||
#error "Sorry! TFT displays are not available for HAL/LPC1768."
|
||||
#if HAS_FSMC_TFT
|
||||
#error "Sorry! FSMC TFT displays are not current available for HAL/LPC1768."
|
||||
#endif
|
||||
|
||||
// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
|
||||
#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
|
||||
#undef TOUCH_SCREEN
|
||||
#undef TOUCH_SCREEN_CALIBRATION
|
||||
#define HAS_TOUCH_XPT2046 1
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#if PIO_PLATFORM_VERSION < 1001
|
||||
#error "nxplpc-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries. You may need to remove the platform and let it reinstall automatically."
|
||||
#endif
|
||||
#if PIO_FRAMEWORK_VERSION < 2002
|
||||
#if PIO_FRAMEWORK_VERSION < 2005
|
||||
#error "framework-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries."
|
||||
#endif
|
||||
|
||||
@@ -89,7 +89,10 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
||||
* Serial2 | P0_10 | P0_11 |
|
||||
* Serial3 | P0_00 | P0_01 |
|
||||
*/
|
||||
#if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0)
|
||||
#define ANY_TX(N,V...) DO(IS_TX##N,||,V)
|
||||
#define ANY_RX(N,V...) DO(IS_RX##N,||,V)
|
||||
|
||||
#if USING_SERIAL_0
|
||||
#define IS_TX0(P) (P == P0_02)
|
||||
#define IS_RX0(P) (P == P0_03)
|
||||
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
|
||||
@@ -103,60 +106,67 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
||||
#undef IS_RX0
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
|
||||
#if USING_SERIAL_1
|
||||
#define IS_TX1(P) (P == P0_15)
|
||||
#define IS_RX1(P) (P == P0_16)
|
||||
#define _IS_TX1_1 IS_TX1
|
||||
#define _IS_RX1_1 IS_RX1
|
||||
#if IS_TX1(TMC_SW_SCK)
|
||||
#error "Serial port pins (1) conflict with other pins!"
|
||||
#elif HAS_SPI_LCD
|
||||
#elif HAS_WIRED_LCD
|
||||
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
|
||||
#error "Serial port pins (1) conflict with Encoder Buttons!"
|
||||
#elif IS_TX1(SCK_PIN) || IS_TX1(LCD_PINS_D4) || IS_TX1(DOGLCD_SCK) || IS_TX1(LCD_RESET_PIN) || IS_TX1(LCD_PINS_RS) || IS_TX1(SHIFT_CLK) \
|
||||
|| IS_RX1(LCD_SDSS) || IS_RX1(LCD_PINS_RS) || IS_RX1(MISO_PIN) || IS_RX1(DOGLCD_A0) || IS_RX1(SS_PIN) || IS_RX1(LCD_SDSS) || IS_RX1(DOGLCD_CS) || IS_RX1(LCD_RESET_PIN) || IS_RX1(LCD_BACKLIGHT_PIN)
|
||||
#elif ANY_TX(1, SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK) \
|
||||
|| ANY_RX(1, LCD_SDSS, LCD_PINS_RS, MISO_PIN, DOGLCD_A0, SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
|
||||
#error "Serial port pins (1) conflict with LCD pins!"
|
||||
#endif
|
||||
#endif
|
||||
#undef IS_TX1
|
||||
#undef IS_RX1
|
||||
#undef _IS_TX1_1
|
||||
#undef _IS_RX1_1
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
|
||||
#if USING_SERIAL_2
|
||||
#define IS_TX2(P) (P == P0_10)
|
||||
#define IS_RX2(P) (P == P0_11)
|
||||
#if IS_TX2(X2_ENABLE_PIN) || IS_RX2(X2_DIR_PIN) || IS_RX2(X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
|
||||
#define _IS_TX2_1 IS_TX2
|
||||
#define _IS_RX2_1 IS_RX2
|
||||
#if IS_TX2(X2_ENABLE_PIN) || ANY_RX(2, X2_DIR_PIN, X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
|
||||
#error "Serial port pins (2) conflict with X2 pins!"
|
||||
#elif IS_TX2(Y2_ENABLE_PIN) || IS_RX2(Y2_DIR_PIN) || IS_RX2(Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN))
|
||||
#elif IS_TX2(Y2_ENABLE_PIN) || ANY_RX(2, Y2_DIR_PIN, Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN))
|
||||
#error "Serial port pins (2) conflict with Y2 pins!"
|
||||
#elif IS_TX2(Z2_ENABLE_PIN) || IS_RX2(Z2_DIR_PIN) || IS_RX2(Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN))
|
||||
#elif IS_TX2(Z2_ENABLE_PIN) || ANY_RX(2, Z2_DIR_PIN, Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN))
|
||||
#error "Serial port pins (2) conflict with Z2 pins!"
|
||||
#elif IS_TX2(Z3_ENABLE_PIN) || IS_RX2(Z3_DIR_PIN) || IS_RX2(Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN))
|
||||
#elif IS_TX2(Z3_ENABLE_PIN) || ANY_RX(2, Z3_DIR_PIN, Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN))
|
||||
#error "Serial port pins (2) conflict with Z3 pins!"
|
||||
#elif IS_TX2(Z4_ENABLE_PIN) || IS_RX2(Z4_DIR_PIN) || IS_RX2(Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN))
|
||||
#elif IS_TX2(Z4_ENABLE_PIN) || ANY_RX(2, Z4_DIR_PIN, Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN))
|
||||
#error "Serial port pins (2) conflict with Z4 pins!"
|
||||
#elif IS_RX2(X_DIR_PIN) || IS_RX2(Y_DIR_PIN)
|
||||
#elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
|
||||
#error "Serial port pins (2) conflict with other pins!"
|
||||
#elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN)
|
||||
#error "Serial port pins (2) conflict with Y endstop pin!"
|
||||
#elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN)
|
||||
#error "Serial port pins (2) conflict with probe pin!"
|
||||
#elif IS_TX2(X_ENABLE_PIN) || IS_RX2(X_DIR_PIN) || IS_TX2(Y_ENABLE_PIN) || IS_RX2(Y_DIR_PIN)
|
||||
#elif ANY_TX(2, X_ENABLE_PIN, Y_ENABLE_PIN) || ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
|
||||
#error "Serial port pins (2) conflict with X/Y stepper pins!"
|
||||
#elif EXTRUDERS > 1 && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN)))
|
||||
#elif HAS_MULTI_EXTRUDER && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN)))
|
||||
#error "Serial port pins (2) conflict with E1 stepper pins!"
|
||||
#elif EXTRUDERS && (IS_RX2(E0_DIR_PIN) || IS_RX2(E0_STEP_PIN))
|
||||
#elif EXTRUDERS && ANY_RX(2, E0_DIR_PIN, E0_STEP_PIN)
|
||||
#error "Serial port pins (2) conflict with E stepper pins!"
|
||||
#endif
|
||||
#undef IS_TX2
|
||||
#undef IS_RX2
|
||||
#undef _IS_TX2_1
|
||||
#undef _IS_RX2_1
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
|
||||
#if USING_SERIAL_3
|
||||
#define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
|
||||
#define PIN_IS_RX3(P) (P##_PIN == P0_01)
|
||||
#if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
|
||||
#error "Serial port pins (3) conflict with X endstop pins!"
|
||||
#elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) \
|
||||
|| PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX)
|
||||
#elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) || PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX)
|
||||
#error "Serial port pins (3) conflict with X/Y axis UART pins!"
|
||||
#elif PIN_IS_TX3(X2_DIR) || PIN_IS_RX3(X2_STEP)
|
||||
#error "Serial port pins (3) conflict with X2 pins!"
|
||||
@@ -168,13 +178,16 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
||||
#error "Serial port pins (3) conflict with Z3 pins!"
|
||||
#elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP)
|
||||
#error "Serial port pins (3) conflict with Z4 pins!"
|
||||
#elif EXTRUDERS > 1 && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP))
|
||||
#elif HAS_MULTI_EXTRUDER && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP))
|
||||
#error "Serial port pins (3) conflict with E1 pins!"
|
||||
#endif
|
||||
#undef PIN_IS_TX3
|
||||
#undef PIN_IS_RX3
|
||||
#endif
|
||||
|
||||
#undef ANY_TX
|
||||
#undef ANY_RX
|
||||
|
||||
//
|
||||
// Flag any i2c pin conflicts
|
||||
//
|
||||
@@ -214,7 +227,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
||||
#error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals."
|
||||
#elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP)
|
||||
#error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals."
|
||||
#elif EXTRUDERS > 1 && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP))
|
||||
#elif HAS_MULTI_EXTRUDER && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP))
|
||||
#error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals."
|
||||
#endif
|
||||
#undef PIN_IS_SDA1
|
||||
@@ -240,9 +253,9 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
||||
#error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals."
|
||||
#elif PIN_IS_SDA2(Z4_ENABLE)
|
||||
#error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals."
|
||||
#elif EXTRUDERS > 1 && PIN_IS_SDA2(E1_ENABLE)
|
||||
#elif HAS_MULTI_EXTRUDER && PIN_IS_SDA2(E1_ENABLE)
|
||||
#error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals."
|
||||
#elif EXTRUDERS > 1 && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS)
|
||||
#elif HAS_MULTI_EXTRUDER && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS)
|
||||
#error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals."
|
||||
#elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR))
|
||||
#error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals."
|
||||
|
||||
@@ -24,25 +24,153 @@
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <lpc17xx_ssp.h>
|
||||
#include <lpc17xx_gpdma.h>
|
||||
|
||||
#define MSBFIRST 1
|
||||
#define SPI_MODE3 0
|
||||
//#define MSBFIRST 1
|
||||
|
||||
#define SPI_MODE0 0
|
||||
#define SPI_MODE1 1
|
||||
#define SPI_MODE2 2
|
||||
#define SPI_MODE3 3
|
||||
|
||||
#define DATA_SIZE_8BIT SSP_DATABIT_8
|
||||
#define DATA_SIZE_16BIT SSP_DATABIT_16
|
||||
|
||||
#define SPI_CLOCK_DIV2 8333333 //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
|
||||
#define SPI_CLOCK_DIV4 4166667 //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
|
||||
#define SPI_CLOCK_DIV8 2083333 //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
|
||||
#define SPI_CLOCK_DIV16 1000000 //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
|
||||
#define SPI_CLOCK_DIV32 500000 //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
|
||||
#define SPI_CLOCK_DIV64 250000 //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
|
||||
#define SPI_CLOCK_DIV128 125000 //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
|
||||
|
||||
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2
|
||||
|
||||
#define BOARD_NR_SPI 2
|
||||
|
||||
//#define BOARD_SPI1_NSS_PIN PA4 ?!
|
||||
#define BOARD_SPI1_SCK_PIN P0_15
|
||||
#define BOARD_SPI1_MISO_PIN P0_17
|
||||
#define BOARD_SPI1_MOSI_PIN P0_18
|
||||
|
||||
//#define BOARD_SPI2_NSS_PIN PB12 ?!
|
||||
#define BOARD_SPI2_SCK_PIN P0_07
|
||||
#define BOARD_SPI2_MISO_PIN P0_08
|
||||
#define BOARD_SPI2_MOSI_PIN P0_09
|
||||
|
||||
class SPISettings {
|
||||
public:
|
||||
SPISettings(uint32_t speed, int, int) : spi_speed(speed) {};
|
||||
uint32_t spiRate() const { return spi_speed; }
|
||||
private:
|
||||
uint32_t spi_speed;
|
||||
public:
|
||||
SPISettings(uint32_t spiRate, int inBitOrder, int inDataMode) {
|
||||
init_AlwaysInline(spiRate2Clock(spiRate), inBitOrder, inDataMode, DATA_SIZE_8BIT);
|
||||
}
|
||||
SPISettings(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
|
||||
if (__builtin_constant_p(inClock))
|
||||
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
|
||||
else
|
||||
init_MightInline(inClock, inBitOrder, inDataMode, inDataSize);
|
||||
}
|
||||
SPISettings() {
|
||||
init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
|
||||
}
|
||||
|
||||
//uint32_t spiRate() const { return spi_speed; }
|
||||
|
||||
static inline uint32_t spiRate2Clock(uint32_t spiRate) {
|
||||
uint32_t Marlin_speed[7]; // CPSR is always 2
|
||||
Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
|
||||
Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
|
||||
Marlin_speed[2] = 2083333; //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
|
||||
Marlin_speed[3] = 1000000; //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
|
||||
Marlin_speed[4] = 500000; //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
|
||||
Marlin_speed[5] = 250000; //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
|
||||
Marlin_speed[6] = 125000; //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
|
||||
return Marlin_speed[spiRate > 6 ? 6 : spiRate];
|
||||
}
|
||||
|
||||
private:
|
||||
void init_MightInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
|
||||
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
|
||||
}
|
||||
void init_AlwaysInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) __attribute__((__always_inline__)) {
|
||||
clock = inClock;
|
||||
bitOrder = inBitOrder;
|
||||
dataMode = inDataMode;
|
||||
dataSize = inDataSize;
|
||||
}
|
||||
|
||||
//uint32_t spi_speed;
|
||||
uint32_t clock;
|
||||
uint32_t dataSize;
|
||||
//uint32_t clockDivider;
|
||||
uint8_t bitOrder;
|
||||
uint8_t dataMode;
|
||||
LPC_SSP_TypeDef *spi_d;
|
||||
|
||||
friend class SPIClass;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Wirish SPI interface.
|
||||
*
|
||||
* This is the same interface is available across HAL
|
||||
*
|
||||
* This implementation uses software slave management, so the caller
|
||||
* is responsible for controlling the slave select line.
|
||||
*/
|
||||
class SPIClass {
|
||||
public:
|
||||
void begin();
|
||||
void beginTransaction(const SPISettings&);
|
||||
void endTransaction() {};
|
||||
uint8_t transfer(uint8_t data);
|
||||
uint16_t transfer16(uint16_t data);
|
||||
public:
|
||||
/**
|
||||
* @param spiPortNumber Number of the SPI port to manage.
|
||||
*/
|
||||
SPIClass(uint8_t spiPortNumber);
|
||||
|
||||
/**
|
||||
* Select and configure the current selected SPI device to use
|
||||
*/
|
||||
void begin();
|
||||
|
||||
/**
|
||||
* Disable the current SPI device
|
||||
*/
|
||||
void end();
|
||||
|
||||
void beginTransaction(const SPISettings&);
|
||||
void endTransaction() {}
|
||||
|
||||
// Transfer using 1 "Data Size"
|
||||
uint8_t transfer(uint16_t data);
|
||||
// Transfer 2 bytes in 8 bit mode
|
||||
uint16_t transfer16(uint16_t data);
|
||||
|
||||
void send(uint8_t data);
|
||||
|
||||
uint16_t read();
|
||||
void read(uint8_t *buf, uint32_t len);
|
||||
|
||||
void dmaSend(void *buf, uint16_t length, bool minc);
|
||||
|
||||
/**
|
||||
* @brief Sets the number of the SPI peripheral to be used by
|
||||
* this HardwareSPI instance.
|
||||
*
|
||||
* @param spi_num Number of the SPI port. 1-2 in low density devices
|
||||
* or 1-3 in high density devices.
|
||||
*/
|
||||
void setModule(uint8_t device);
|
||||
|
||||
void setClock(uint32_t clock);
|
||||
void setBitOrder(uint8_t bitOrder);
|
||||
void setDataMode(uint8_t dataMode);
|
||||
void setDataSize(uint32_t ds);
|
||||
|
||||
inline uint32_t getDataSize() { return _currentSetting->dataSize; }
|
||||
|
||||
private:
|
||||
SPISettings _settings[BOARD_NR_SPI];
|
||||
SPISettings *_currentSetting;
|
||||
|
||||
void updateSettings();
|
||||
};
|
||||
|
||||
extern SPIClass SPI;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "../../core/macros.h"
|
||||
|
||||
#if BOTH(SDSUPPORT, HAS_GRAPHICAL_LCD) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
||||
#if BOTH(SDSUPPORT, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
||||
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
|
||||
// needed due to the speed and mode required for communicating with each device being different.
|
||||
// This requirement can be removed if the SPI access to these devices is updated to use
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_SPI_TFT
|
||||
|
||||
#include "tft_spi.h"
|
||||
|
||||
//TFT_SPI tft;
|
||||
|
||||
SPIClass TFT_SPI::SPIx(1);
|
||||
|
||||
#define TFT_CS_H WRITE(TFT_CS_PIN, HIGH)
|
||||
#define TFT_CS_L WRITE(TFT_CS_PIN, LOW)
|
||||
|
||||
#define TFT_DC_H WRITE(TFT_DC_PIN, HIGH)
|
||||
#define TFT_DC_L WRITE(TFT_DC_PIN, LOW)
|
||||
|
||||
#define TFT_RST_H WRITE(TFT_RESET_PIN, HIGH)
|
||||
#define TFT_RST_L WRITE(TFT_RESET_PIN, LOW)
|
||||
|
||||
#define TFT_BLK_H WRITE(TFT_BACKLIGHT_PIN, HIGH)
|
||||
#define TFT_BLK_L WRITE(TFT_BACKLIGHT_PIN, LOW)
|
||||
|
||||
void TFT_SPI::Init() {
|
||||
#if PIN_EXISTS(TFT_RESET)
|
||||
SET_OUTPUT(TFT_RESET_PIN);
|
||||
TFT_RST_H;
|
||||
delay(100);
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(TFT_BACKLIGHT)
|
||||
SET_OUTPUT(TFT_BACKLIGHT_PIN);
|
||||
TFT_BLK_H;
|
||||
#endif
|
||||
|
||||
SET_OUTPUT(TFT_DC_PIN);
|
||||
SET_OUTPUT(TFT_CS_PIN);
|
||||
|
||||
TFT_DC_H;
|
||||
TFT_CS_H;
|
||||
|
||||
/**
|
||||
* STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz
|
||||
* STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1
|
||||
* so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2
|
||||
*/
|
||||
#if 0
|
||||
#if SPI_DEVICE == 1
|
||||
#define SPI_CLOCK_MAX SPI_CLOCK_DIV4
|
||||
#else
|
||||
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2
|
||||
#endif
|
||||
uint8_t clock;
|
||||
uint8_t spiRate = SPI_FULL_SPEED;
|
||||
switch (spiRate) {
|
||||
case SPI_FULL_SPEED: clock = SPI_CLOCK_MAX ; break;
|
||||
case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4 ; break;
|
||||
case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8 ; break;
|
||||
case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break;
|
||||
case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break;
|
||||
case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break;
|
||||
default: clock = SPI_CLOCK_DIV2; // Default from the SPI library
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TFT_MISO_PIN == BOARD_SPI1_MISO_PIN
|
||||
SPIx.setModule(1);
|
||||
#elif TFT_MISO_PIN == BOARD_SPI2_MISO_PIN
|
||||
SPIx.setModule(2);
|
||||
#endif
|
||||
SPIx.setClock(SPI_CLOCK_MAX);
|
||||
SPIx.setBitOrder(MSBFIRST);
|
||||
SPIx.setDataMode(SPI_MODE0);
|
||||
}
|
||||
|
||||
void TFT_SPI::DataTransferBegin(uint16_t DataSize) {
|
||||
SPIx.setDataSize(DataSize);
|
||||
SPIx.begin();
|
||||
TFT_CS_L;
|
||||
}
|
||||
|
||||
uint32_t TFT_SPI::GetID() {
|
||||
uint32_t id;
|
||||
id = ReadID(LCD_READ_ID);
|
||||
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
|
||||
id = ReadID(LCD_READ_ID4);
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32_t TFT_SPI::ReadID(uint16_t Reg) {
|
||||
uint32_t data = 0;
|
||||
|
||||
#if PIN_EXISTS(TFT_MISO)
|
||||
uint8_t d = 0;
|
||||
SPIx.setDataSize(DATASIZE_8BIT);
|
||||
SPIx.setClock(SPI_CLOCK_DIV64);
|
||||
SPIx.begin();
|
||||
TFT_CS_L;
|
||||
WriteReg(Reg);
|
||||
|
||||
LOOP_L_N(i, 4) {
|
||||
SPIx.read((uint8_t*)&d, 1);
|
||||
data = (data << 8) | d;
|
||||
}
|
||||
|
||||
DataTransferEnd();
|
||||
SPIx.setClock(SPI_CLOCK_MAX);
|
||||
#endif
|
||||
|
||||
return data >> 7;
|
||||
}
|
||||
|
||||
bool TFT_SPI::isBusy() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void TFT_SPI::Abort() {
|
||||
DataTransferEnd();
|
||||
}
|
||||
|
||||
void TFT_SPI::Transmit(uint16_t Data) {
|
||||
SPIx.transfer(Data);
|
||||
}
|
||||
|
||||
void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
|
||||
DataTransferBegin(DATASIZE_16BIT); //16
|
||||
TFT_DC_H;
|
||||
SPIx.dmaSend(Data, Count, MemoryIncrease);
|
||||
DataTransferEnd();
|
||||
}
|
||||
|
||||
#endif // HAS_SPI_TFT
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#include <SPI.h>
|
||||
#include <lpc17xx_ssp.h>
|
||||
// #include <lpc17xx_gpdma.h>
|
||||
|
||||
#ifndef LCD_READ_ID
|
||||
#define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
|
||||
#endif
|
||||
#ifndef LCD_READ_ID4
|
||||
#define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341)
|
||||
#endif
|
||||
|
||||
#define DATASIZE_8BIT SSP_DATABIT_8
|
||||
#define DATASIZE_16BIT SSP_DATABIT_16
|
||||
#define TFT_IO TFT_SPI
|
||||
|
||||
#define DMA_MINC_ENABLE 1
|
||||
#define DMA_MINC_DISABLE 0
|
||||
|
||||
class TFT_SPI {
|
||||
private:
|
||||
static uint32_t ReadID(uint16_t Reg);
|
||||
static void Transmit(uint16_t Data);
|
||||
static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
|
||||
|
||||
public:
|
||||
static SPIClass SPIx;
|
||||
|
||||
static void Init();
|
||||
static uint32_t GetID();
|
||||
static bool isBusy();
|
||||
static void Abort();
|
||||
|
||||
static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT);
|
||||
static void DataTransferEnd() { OUT_WRITE(TFT_CS_PIN, HIGH); SPIx.end(); };
|
||||
static void DataTransferAbort();
|
||||
|
||||
static void WriteData(uint16_t Data) { Transmit(Data); }
|
||||
static void WriteReg(uint16_t Reg) { OUT_WRITE(TFT_A0_PIN, LOW); Transmit(Reg); OUT_WRITE(TFT_A0_PIN, HIGH); }
|
||||
|
||||
static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); }
|
||||
// static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
|
||||
static void WriteMultiple(uint16_t Color, uint32_t Count) {
|
||||
static uint16_t Data; Data = Color;
|
||||
//LPC dma can only write 0xFFF bytes at once.
|
||||
#define MAX_DMA_SIZE (0xFFF - 1)
|
||||
while (Count > 0) {
|
||||
TransmitDMA(DMA_MINC_DISABLE, &Data, Count > MAX_DMA_SIZE ? MAX_DMA_SIZE : Count);
|
||||
Count = Count > MAX_DMA_SIZE ? Count - MAX_DMA_SIZE : 0;
|
||||
}
|
||||
#undef MAX_DMA_SIZE
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_TFT_XPT2046 || HAS_TOUCH_XPT2046
|
||||
|
||||
#include "xpt2046.h"
|
||||
#include <SPI.h>
|
||||
|
||||
uint16_t delta(uint16_t a, uint16_t b) { return a > b ? a - b : b - a; }
|
||||
|
||||
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
|
||||
#include <SPI.h>
|
||||
|
||||
SPIClass XPT2046::SPIx(TOUCH_BUTTONS_HW_SPI_DEVICE);
|
||||
|
||||
static void touch_spi_init(uint8_t spiRate) {
|
||||
XPT2046::SPIx.setModule(TOUCH_BUTTONS_HW_SPI_DEVICE);
|
||||
XPT2046::SPIx.setClock(SPI_CLOCK_DIV128);
|
||||
XPT2046::SPIx.setBitOrder(MSBFIRST);
|
||||
XPT2046::SPIx.setDataMode(SPI_MODE0);
|
||||
XPT2046::SPIx.setDataSize(DATA_SIZE_8BIT);
|
||||
}
|
||||
#endif
|
||||
|
||||
void XPT2046::Init() {
|
||||
SET_INPUT(TOUCH_MISO_PIN);
|
||||
SET_OUTPUT(TOUCH_MOSI_PIN);
|
||||
SET_OUTPUT(TOUCH_SCK_PIN);
|
||||
OUT_WRITE(TOUCH_CS_PIN, HIGH);
|
||||
|
||||
#if PIN_EXISTS(TOUCH_INT)
|
||||
// Optional Pendrive interrupt pin
|
||||
SET_INPUT(TOUCH_INT_PIN);
|
||||
#endif
|
||||
|
||||
TERN_(TOUCH_BUTTONS_HW_SPI, touch_spi_init(SPI_SPEED_6));
|
||||
|
||||
// Read once to enable pendrive status pin
|
||||
getRawData(XPT2046_X);
|
||||
}
|
||||
|
||||
bool XPT2046::isTouched() {
|
||||
return isBusy() ? false : (
|
||||
#if PIN_EXISTS(TOUCH_INT)
|
||||
READ(TOUCH_INT_PIN) != HIGH
|
||||
#else
|
||||
getRawData(XPT2046_Z1) >= XPT2046_Z1_THRESHOLD
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
bool XPT2046::getRawPoint(int16_t *x, int16_t *y) {
|
||||
if (isBusy()) return false;
|
||||
if (!isTouched()) return false;
|
||||
*x = getRawData(XPT2046_X);
|
||||
*y = getRawData(XPT2046_Y);
|
||||
return isTouched();
|
||||
}
|
||||
|
||||
uint16_t XPT2046::getRawData(const XPTCoordinate coordinate) {
|
||||
uint16_t data[3];
|
||||
|
||||
DataTransferBegin();
|
||||
TERN_(TOUCH_BUTTONS_HW_SPI, SPIx.begin());
|
||||
|
||||
for (uint16_t i = 0; i < 3 ; i++) {
|
||||
IO(coordinate);
|
||||
data[i] = (IO() << 4) | (IO() >> 4);
|
||||
}
|
||||
|
||||
TERN_(TOUCH_BUTTONS_HW_SPI, SPIx.end());
|
||||
DataTransferEnd();
|
||||
|
||||
uint16_t delta01 = delta(data[0], data[1]),
|
||||
delta02 = delta(data[0], data[2]),
|
||||
delta12 = delta(data[1], data[2]);
|
||||
|
||||
if (delta01 > delta02 || delta01 > delta12)
|
||||
data[delta02 > delta12 ? 0 : 1] = data[2];
|
||||
|
||||
return (data[0] + data[1]) >> 1;
|
||||
}
|
||||
|
||||
uint16_t XPT2046::IO(uint16_t data) {
|
||||
return TERN(TOUCH_BUTTONS_HW_SPI, HardwareIO, SoftwareIO)(data);
|
||||
}
|
||||
|
||||
extern uint8_t spiTransfer(uint8_t b);
|
||||
|
||||
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
|
||||
uint16_t XPT2046::HardwareIO(uint16_t data) {
|
||||
return SPIx.transfer(data & 0xFF);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t XPT2046::SoftwareIO(uint16_t data) {
|
||||
uint16_t result = 0;
|
||||
|
||||
for (uint8_t j = 0x80; j; j >>= 1) {
|
||||
WRITE(TOUCH_SCK_PIN, LOW);
|
||||
WRITE(TOUCH_MOSI_PIN, data & j ? HIGH : LOW);
|
||||
if (READ(TOUCH_MISO_PIN)) result |= j;
|
||||
WRITE(TOUCH_SCK_PIN, HIGH);
|
||||
}
|
||||
WRITE(TOUCH_SCK_PIN, LOW);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_XPT2046
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
#ifndef TOUCH_MISO_PIN
|
||||
#define TOUCH_MISO_PIN MISO_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_MOSI_PIN
|
||||
#define TOUCH_MOSI_PIN MOSI_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_SCK_PIN
|
||||
#define TOUCH_SCK_PIN SCK_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_CS_PIN
|
||||
#define TOUCH_CS_PIN CS_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_INT_PIN
|
||||
#define TOUCH_INT_PIN -1
|
||||
#endif
|
||||
|
||||
#define XPT2046_DFR_MODE 0x00
|
||||
#define XPT2046_SER_MODE 0x04
|
||||
#define XPT2046_CONTROL 0x80
|
||||
|
||||
enum XPTCoordinate : uint8_t {
|
||||
XPT2046_X = 0x10 | XPT2046_CONTROL | XPT2046_DFR_MODE,
|
||||
XPT2046_Y = 0x50 | XPT2046_CONTROL | XPT2046_DFR_MODE,
|
||||
XPT2046_Z1 = 0x30 | XPT2046_CONTROL | XPT2046_DFR_MODE,
|
||||
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
|
||||
};
|
||||
|
||||
#if !defined(XPT2046_Z1_THRESHOLD)
|
||||
#define XPT2046_Z1_THRESHOLD 10
|
||||
#endif
|
||||
|
||||
class XPT2046 {
|
||||
private:
|
||||
static bool isBusy() { return false; }
|
||||
|
||||
static uint16_t getRawData(const XPTCoordinate coordinate);
|
||||
static bool isTouched();
|
||||
|
||||
static inline void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); };
|
||||
static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); };
|
||||
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
|
||||
static uint16_t HardwareIO(uint16_t data);
|
||||
#endif
|
||||
static uint16_t SoftwareIO(uint16_t data);
|
||||
static uint16_t IO(uint16_t data = 0);
|
||||
|
||||
public:
|
||||
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
|
||||
static SPIClass SPIx;
|
||||
#endif
|
||||
|
||||
static void Init();
|
||||
static bool getRawPoint(int16_t *x, int16_t *y);
|
||||
};
|
||||
@@ -21,7 +21,6 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
*
|
||||
* HAL For LPC1768
|
||||
*/
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
#if HAS_MARLINUI_U8GLIB
|
||||
|
||||
#include <U8glib.h>
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
@@ -124,6 +124,6 @@ uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#endif // HAS_MARLINUI_U8GLIB
|
||||
|
||||
#endif // TARGET_LPC1768
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
#if HAS_MARLINUI_U8GLIB
|
||||
|
||||
#include <U8glib.h>
|
||||
|
||||
@@ -193,6 +193,6 @@ uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_v
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#endif // HAS_MARLINUI_U8GLIB
|
||||
|
||||
#endif // TARGET_LPC1768
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
#if HAS_MARLINUI_U8GLIB
|
||||
|
||||
#include <U8glib.h>
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
@@ -133,6 +133,6 @@ uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t ar
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#endif // HAS_MARLINUI_U8GLIB
|
||||
|
||||
#endif // TARGET_LPC1768
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920)
|
||||
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
|
||||
|
||||
#include <SoftwareSPI.h>
|
||||
|
||||
@@ -203,5 +203,5 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD && !U8GLIB_ST7920
|
||||
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
|
||||
#endif // TARGET_LPC1768
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
|
||||
#include "../../feature/e_parser.h"
|
||||
|
||||
EmergencyParser::State emergency_state;
|
||||
|
||||
bool CDC_RecvCallback(const char buffer) {
|
||||
emergency_parser.update(emergency_state, buffer);
|
||||
return true;
|
||||
|
||||
+14
-38
@@ -35,58 +35,34 @@
|
||||
|
||||
// MYSERIAL0 required before MarlinSerial includes!
|
||||
|
||||
#define _MSERIAL(X) Serial##X
|
||||
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL0 Serial
|
||||
#elif SERIAL_PORT == 0
|
||||
#define MYSERIAL0 Serial1
|
||||
#elif SERIAL_PORT == 1
|
||||
#define MYSERIAL0 Serial2
|
||||
#elif SERIAL_PORT == 2
|
||||
#define MYSERIAL0 Serial3
|
||||
#elif SERIAL_PORT == 3
|
||||
#define MYSERIAL0 Serial4
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == SERIAL_PORT
|
||||
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == -1
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL1 Serial
|
||||
#elif SERIAL_PORT_2 == 0
|
||||
#define MYSERIAL1 Serial1
|
||||
#elif SERIAL_PORT_2 == 1
|
||||
#define MYSERIAL1 Serial2
|
||||
#elif SERIAL_PORT_2 == 2
|
||||
#define MYSERIAL1 Serial3
|
||||
#elif SERIAL_PORT_2 == 3
|
||||
#define MYSERIAL1 Serial4
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
#define NUM_SERIAL 2
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#if DGUS_SERIAL_PORT == SERIAL_PORT
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == -1
|
||||
#define DGUS_SERIAL Serial
|
||||
#elif DGUS_SERIAL_PORT == 0
|
||||
#define DGUS_SERIAL Serial1
|
||||
#elif DGUS_SERIAL_PORT == 1
|
||||
#define DGUS_SERIAL Serial2
|
||||
#elif DGUS_SERIAL_PORT == 2
|
||||
#define DGUS_SERIAL Serial3
|
||||
#elif DGUS_SERIAL_PORT == 2
|
||||
#define DGUS_SERIAL Serial4
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL Serial
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "DGUS_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."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* Derived from Adafruit_SPIFlash class with no SdFat references
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -150,5 +150,4 @@ void pwm_details(int32_t pin) {
|
||||
* 93 | PA10 | QSPI: IO2
|
||||
* 94 | PA11 | QSPI: IO3
|
||||
* 95 | PB31 | SD: DETECT
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -63,7 +63,7 @@ uint16_t HAL_adc_result;
|
||||
void HAL_init() {
|
||||
FastIO_init();
|
||||
|
||||
#if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT)
|
||||
#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
|
||||
#endif
|
||||
|
||||
@@ -122,9 +122,14 @@ extern "C" {
|
||||
|
||||
// TODO: Make sure this doesn't cause any delay
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
|
||||
|
||||
uint16_t HAL_adc_get_result() { return HAL_adc_result; }
|
||||
|
||||
// Reset the system (to initiate a firmware flash)
|
||||
void flashFirmware(const int16_t) { NVIC_SystemReset(); }
|
||||
|
||||
// Maple Compatibility
|
||||
systickCallback_t systick_user_callback;
|
||||
void systick_attach_callback(systickCallback_t cb) { systick_user_callback = cb; }
|
||||
void HAL_SYSTICK_Callback() { if (systick_user_callback) systick_user_callback(); }
|
||||
|
||||
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
|
||||
|
||||
+24
-62
@@ -43,83 +43,40 @@
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if SERIAL_PORT == 0
|
||||
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif SERIAL_PORT == -1
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL0 SerialUSB
|
||||
#elif SERIAL_PORT == 1
|
||||
#define MYSERIAL0 MSerial1
|
||||
#elif SERIAL_PORT == 2
|
||||
#define MYSERIAL0 MSerial2
|
||||
#elif SERIAL_PORT == 3
|
||||
#define MYSERIAL0 MSerial3
|
||||
#elif SERIAL_PORT == 4
|
||||
#define MYSERIAL0 MSerial4
|
||||
#elif SERIAL_PORT == 5
|
||||
#define MYSERIAL0 MSerial5
|
||||
#elif SERIAL_PORT == 6
|
||||
#define MYSERIAL0 MSerial6
|
||||
#elif WITHIN(SERIAL_PORT, 1, 6)
|
||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
||||
#error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#define NUM_SERIAL 2
|
||||
#if SERIAL_PORT_2 == 0
|
||||
#error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == SERIAL_PORT
|
||||
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == -1
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL1 SerialUSB
|
||||
#elif SERIAL_PORT_2 == 1
|
||||
#define MYSERIAL1 MSerial1
|
||||
#elif SERIAL_PORT_2 == 2
|
||||
#define MYSERIAL1 MSerial2
|
||||
#elif SERIAL_PORT_2 == 3
|
||||
#define MYSERIAL1 MSerial3
|
||||
#elif SERIAL_PORT_2 == 4
|
||||
#define MYSERIAL1 MSerial4
|
||||
#elif SERIAL_PORT_2 == 5
|
||||
#define MYSERIAL1 MSerial5
|
||||
#elif SERIAL_PORT_2 == 6
|
||||
#define MYSERIAL1 MSerial6
|
||||
#elif WITHIN(SERIAL_PORT_2, 1, 6)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be 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
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
|
||||
#if HAS_DGUS_LCD
|
||||
#if DGUS_SERIAL_PORT == 0
|
||||
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == SERIAL_PORT
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == -1
|
||||
#define DGUS_SERIAL SerialUSB
|
||||
#elif DGUS_SERIAL_PORT == 1
|
||||
#define DGUS_SERIAL MSerial1
|
||||
#elif DGUS_SERIAL_PORT == 2
|
||||
#define DGUS_SERIAL MSerial2
|
||||
#elif DGUS_SERIAL_PORT == 3
|
||||
#define DGUS_SERIAL MSerial3
|
||||
#elif DGUS_SERIAL_PORT == 4
|
||||
#define DGUS_SERIAL MSerial4
|
||||
#elif DGUS_SERIAL_PORT == 5
|
||||
#define DGUS_SERIAL MSerial5
|
||||
#elif DGUS_SERIAL_PORT == 6
|
||||
#define DGUS_SERIAL MSerial6
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL SerialUSB
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 1, 6)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
||||
#error "LCD_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
|
||||
#endif
|
||||
#if HAS_DGUS_LCD
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
|
||||
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* TODO: review this to return 1 for pins that are not analog input
|
||||
*/
|
||||
@@ -220,3 +177,8 @@ uint16_t HAL_adc_get_result();
|
||||
|
||||
#define PLATFORM_M997_SUPPORT
|
||||
void flashFirmware(const int16_t);
|
||||
|
||||
// Maple Compatibility
|
||||
typedef void (*systickCallback_t)(void);
|
||||
void systick_attach_callback(systickCallback_t cb);
|
||||
void HAL_SYSTICK_Callback();
|
||||
|
||||
@@ -132,11 +132,9 @@ static SPISettings spiConfig;
|
||||
* @details Only configures SS pin since stm32duino creates and initialize the SPI object
|
||||
*/
|
||||
void spiBegin() {
|
||||
#if !PIN_EXISTS(SS)
|
||||
#error "SS_PIN not defined!"
|
||||
#if PIN_EXISTS(SS)
|
||||
OUT_WRITE(SS_PIN, HIGH);
|
||||
#endif
|
||||
|
||||
OUT_WRITE(SS_PIN, HIGH);
|
||||
}
|
||||
|
||||
// Configure SPI for specified SPI speed
|
||||
@@ -173,9 +171,7 @@ static SPISettings spiConfig;
|
||||
* @details
|
||||
*/
|
||||
uint8_t spiRec() {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
uint8_t returnByte = SPI.transfer(0xFF);
|
||||
SPI.endTransaction();
|
||||
return returnByte;
|
||||
}
|
||||
|
||||
@@ -191,9 +187,7 @@ static SPISettings spiConfig;
|
||||
void spiRead(uint8_t* buf, uint16_t nbyte) {
|
||||
if (nbyte == 0) return;
|
||||
memset(buf, 0xFF, nbyte);
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.transfer(buf, nbyte);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,9 +198,7 @@ static SPISettings spiConfig;
|
||||
* @details
|
||||
*/
|
||||
void spiSend(uint8_t b) {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.transfer(b);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,10 +211,8 @@ static SPISettings spiConfig;
|
||||
*/
|
||||
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
||||
uint8_t rxBuf[512];
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.transfer(token);
|
||||
SPI.transfer((uint8_t*)buf, &rxBuf, 512);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
#endif // SOFTWARE_SPI
|
||||
|
||||
@@ -49,16 +49,14 @@
|
||||
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2)
|
||||
#endif
|
||||
|
||||
#if defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT >= 0
|
||||
DECLARE_SERIAL_PORT_EXP(DGUS_SERIAL_PORT)
|
||||
#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0
|
||||
DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT)
|
||||
#endif
|
||||
|
||||
void MarlinSerial::begin(unsigned long baud, uint8_t config) {
|
||||
HardwareSerial::begin(baud, config);
|
||||
// replace the IRQ callback with the one we have defined
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
_serial.rx_callback = _rx_callback;
|
||||
#endif
|
||||
// Replace the IRQ callback with the one we have defined
|
||||
TERN_(EMERGENCY_PARSER, _serial.rx_callback = _rx_callback);
|
||||
}
|
||||
|
||||
// This function is Copyright (c) 2006 Nicholas Zambetti.
|
||||
|
||||
@@ -35,6 +35,10 @@ public:
|
||||
#endif
|
||||
{ }
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
static inline bool emergency_parser_enabled() { return true; }
|
||||
#endif
|
||||
|
||||
void begin(unsigned long baud, uint8_t config);
|
||||
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
|
||||
|
||||
|
||||
@@ -1,396 +0,0 @@
|
||||
/*
|
||||
* SoftwareSerial.cpp (formerly NewSoftSerial.cpp)
|
||||
*
|
||||
* Multi-instance software serial library for Arduino/Wiring
|
||||
* -- Interrupt-driven receive and other improvements by ladyada
|
||||
* <https://ladyada.net>
|
||||
* -- Tuning, circular buffer, derivation from class Print/Stream,
|
||||
* multi-instance support, porting to 8MHz processors,
|
||||
* various optimizations, PROGMEM delay tables, inverse logic and
|
||||
* direct port writing by Mikal Hart <http://www.arduiniana.org>
|
||||
* -- Pin change interrupt macros by Paul Stoffregen <https://www.pjrc.com>
|
||||
* -- 20MHz processor support by Garrett Mace <http://www.macetech.com>
|
||||
* -- ATmega1280/2560 support by Brett Hagman <https://www.roguerobotics.com>
|
||||
* -- STM32 support by Armin van der Togt
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* The latest version of this library can always be found at
|
||||
* http://arduiniana.org.
|
||||
*/
|
||||
|
||||
//
|
||||
// Includes
|
||||
//
|
||||
#if defined(PLATFORMIO) && defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include "SoftwareSerial.h"
|
||||
|
||||
#define OVERSAMPLE 3 // in RX, Timer will generate interruption OVERSAMPLE time during a bit. Thus OVERSAMPLE ticks in a bit. (interrupt not synchonized with edge).
|
||||
|
||||
// defined in bit-periods
|
||||
#define HALFDUPLEX_SWITCH_DELAY 5
|
||||
// It's best to define TIMER_SERIAL in variant.h. If not defined, we choose one here
|
||||
// The order is based on (lack of) features and compare channels, we choose the simplest available
|
||||
// because we only need an update interrupt
|
||||
#if !defined(TIMER_SERIAL)
|
||||
#if defined(TIM18_BASE)
|
||||
#define TIMER_SERIAL TIM18
|
||||
#elif defined(TIM7_BASE)
|
||||
#define TIMER_SERIAL TIM7
|
||||
#elif defined(TIM6_BASE)
|
||||
#define TIMER_SERIAL TIM6
|
||||
#elif defined(TIM22_BASE)
|
||||
#define TIMER_SERIAL TIM22
|
||||
#elif defined(TIM21_BASE)
|
||||
#define TIMER_SERIAL TIM21
|
||||
#elif defined(TIM17_BASE)
|
||||
#define TIMER_SERIAL TIM17
|
||||
#elif defined(TIM16_BASE)
|
||||
#define TIMER_SERIAL TIM16
|
||||
#elif defined(TIM15_BASE)
|
||||
#define TIMER_SERIAL TIM15
|
||||
#elif defined(TIM14_BASE)
|
||||
#define TIMER_SERIAL TIM14
|
||||
#elif defined(TIM13_BASE)
|
||||
#define TIMER_SERIAL TIM13
|
||||
#elif defined(TIM11_BASE)
|
||||
#define TIMER_SERIAL TIM11
|
||||
#elif defined(TIM10_BASE)
|
||||
#define TIMER_SERIAL TIM10
|
||||
#elif defined(TIM12_BASE)
|
||||
#define TIMER_SERIAL TIM12
|
||||
#elif defined(TIM19_BASE)
|
||||
#define TIMER_SERIAL TIM19
|
||||
#elif defined(TIM9_BASE)
|
||||
#define TIMER_SERIAL TIM9
|
||||
#elif defined(TIM5_BASE)
|
||||
#define TIMER_SERIAL TIM5
|
||||
#elif defined(TIM4_BASE)
|
||||
#define TIMER_SERIAL TIM4
|
||||
#elif defined(TIM3_BASE)
|
||||
#define TIMER_SERIAL TIM3
|
||||
#elif defined(TIM2_BASE)
|
||||
#define TIMER_SERIAL TIM2
|
||||
#elif defined(TIM20_BASE)
|
||||
#define TIMER_SERIAL TIM20
|
||||
#elif defined(TIM8_BASE)
|
||||
#define TIMER_SERIAL TIM8
|
||||
#elif defined(TIM1_BASE)
|
||||
#define TIMER_SERIAL TIM1
|
||||
#else
|
||||
#error No suitable timer found for SoftwareSerial, define TIMER_SERIAL in variant.h
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
// Statics
|
||||
//
|
||||
HardwareTimer SoftwareSerial::timer(TIMER_SERIAL);
|
||||
const IRQn_Type SoftwareSerial::timer_interrupt_number = static_cast<IRQn_Type>(getTimerUpIrq(TIMER_SERIAL));
|
||||
uint32_t SoftwareSerial::timer_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), TIM_IRQ_PRIO, TIM_IRQ_SUBPRIO);
|
||||
SoftwareSerial *SoftwareSerial::active_listener = nullptr;
|
||||
SoftwareSerial *volatile SoftwareSerial::active_out = nullptr;
|
||||
SoftwareSerial *volatile SoftwareSerial::active_in = nullptr;
|
||||
int32_t SoftwareSerial::tx_tick_cnt = 0; // OVERSAMPLE ticks needed for a bit
|
||||
int32_t volatile SoftwareSerial::rx_tick_cnt = 0; // OVERSAMPLE ticks needed for a bit
|
||||
uint32_t SoftwareSerial::tx_buffer = 0;
|
||||
int32_t SoftwareSerial::tx_bit_cnt = 0;
|
||||
uint32_t SoftwareSerial::rx_buffer = 0;
|
||||
int32_t SoftwareSerial::rx_bit_cnt = -1; // rx_bit_cnt = -1 : waiting for start bit
|
||||
uint32_t SoftwareSerial::cur_speed = 0;
|
||||
|
||||
void SoftwareSerial::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority) {
|
||||
timer_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), preemptPriority, subPriority);
|
||||
}
|
||||
|
||||
//
|
||||
// Private methods
|
||||
//
|
||||
|
||||
void SoftwareSerial::setSpeed(uint32_t speed) {
|
||||
if (speed != cur_speed) {
|
||||
timer.pause();
|
||||
if (speed != 0) {
|
||||
// Disable the timer
|
||||
uint32_t clock_rate, cmp_value;
|
||||
// Get timer clock
|
||||
clock_rate = timer.getTimerClkFreq();
|
||||
int pre = 1;
|
||||
// Calculate prescale an compare value
|
||||
do {
|
||||
cmp_value = clock_rate / (speed * OVERSAMPLE);
|
||||
if (cmp_value >= UINT16_MAX) {
|
||||
clock_rate /= 2;
|
||||
pre *= 2;
|
||||
}
|
||||
} while (cmp_value >= UINT16_MAX);
|
||||
timer.setPrescaleFactor(pre);
|
||||
timer.setOverflow(cmp_value);
|
||||
timer.setCount(0);
|
||||
timer.attachInterrupt(&handleInterrupt);
|
||||
timer.resume();
|
||||
NVIC_SetPriority(timer_interrupt_number, timer_interrupt_priority);
|
||||
}
|
||||
else
|
||||
timer.detachInterrupt();
|
||||
cur_speed = speed;
|
||||
}
|
||||
}
|
||||
|
||||
// This function sets the current object as the "listening"
|
||||
// one and returns true if it replaces another
|
||||
bool SoftwareSerial::listen() {
|
||||
if (active_listener != this) {
|
||||
// wait for any transmit to complete as we may change speed
|
||||
while (active_out);
|
||||
active_listener->stopListening();
|
||||
rx_tick_cnt = 1; // 1 : next interrupt will decrease rx_tick_cnt to 0 which means RX pin level will be considered.
|
||||
rx_bit_cnt = -1; // rx_bit_cnt = -1 : waiting for start bit
|
||||
setSpeed(_speed);
|
||||
active_listener = this;
|
||||
if (!_half_duplex) active_in = this;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Stop listening. Returns true if we were actually listening.
|
||||
bool SoftwareSerial::stopListening() {
|
||||
if (active_listener == this) {
|
||||
// wait for any output to complete
|
||||
while (active_out);
|
||||
if (_half_duplex) setRXTX(false);
|
||||
active_listener = nullptr;
|
||||
active_in = nullptr;
|
||||
// turn off ints
|
||||
setSpeed(0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void SoftwareSerial::setTX() {
|
||||
if (_inverse_logic)
|
||||
LL_GPIO_ResetOutputPin(_transmitPinPort, _transmitPinNumber);
|
||||
else
|
||||
LL_GPIO_SetOutputPin(_transmitPinPort, _transmitPinNumber);
|
||||
pinMode(_transmitPin, OUTPUT);
|
||||
}
|
||||
|
||||
inline void SoftwareSerial::setRX() {
|
||||
pinMode(_receivePin, _inverse_logic ? INPUT_PULLDOWN : INPUT_PULLUP); // pullup for normal logic!
|
||||
}
|
||||
|
||||
inline void SoftwareSerial::setRXTX(bool input) {
|
||||
if (_half_duplex) {
|
||||
if (input) {
|
||||
if (active_in != this) {
|
||||
setRX();
|
||||
rx_bit_cnt = -1; // rx_bit_cnt = -1 : waiting for start bit
|
||||
rx_tick_cnt = 2; // 2 : next interrupt will be discarded. 2 interrupts required to consider RX pin level
|
||||
active_in = this;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (active_in == this) {
|
||||
setTX();
|
||||
active_in = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void SoftwareSerial::send() {
|
||||
if (--tx_tick_cnt <= 0) { // if tx_tick_cnt > 0 interrupt is discarded. Only when tx_tick_cnt reaches 0 is TX pin set.
|
||||
if (tx_bit_cnt++ < 10) { // tx_bit_cnt < 10 transmission is not finished (10 = 1 start +8 bits + 1 stop)
|
||||
// Send data (including start and stop bits)
|
||||
if (tx_buffer & 1)
|
||||
LL_GPIO_SetOutputPin(_transmitPinPort, _transmitPinNumber);
|
||||
else
|
||||
LL_GPIO_ResetOutputPin(_transmitPinPort, _transmitPinNumber);
|
||||
tx_buffer >>= 1;
|
||||
tx_tick_cnt = OVERSAMPLE; // Wait OVERSAMPLE ticks to send next bit
|
||||
}
|
||||
else { // Transmission finished
|
||||
tx_tick_cnt = 1;
|
||||
if (_output_pending) {
|
||||
active_out = nullptr;
|
||||
|
||||
// In half-duplex mode wait HALFDUPLEX_SWITCH_DELAY bit-periods after the byte has
|
||||
// been transmitted before allowing the switch to RX mode
|
||||
}
|
||||
else if (tx_bit_cnt > 10 + OVERSAMPLE * HALFDUPLEX_SWITCH_DELAY) {
|
||||
if (_half_duplex && active_listener == this) setRXTX(true);
|
||||
active_out = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// The receive routine called by the interrupt handler
|
||||
//
|
||||
inline void SoftwareSerial::recv() {
|
||||
if (--rx_tick_cnt <= 0) { // if rx_tick_cnt > 0 interrupt is discarded. Only when rx_tick_cnt reaches 0 is RX pin considered
|
||||
bool inbit = LL_GPIO_IsInputPinSet(_receivePinPort, _receivePinNumber) ^ _inverse_logic;
|
||||
if (rx_bit_cnt == -1) { // rx_bit_cnt = -1 : waiting for start bit
|
||||
if (!inbit) {
|
||||
// got start bit
|
||||
rx_bit_cnt = 0; // rx_bit_cnt == 0 : start bit received
|
||||
rx_tick_cnt = OVERSAMPLE + 1; // Wait 1 bit (OVERSAMPLE ticks) + 1 tick in order to sample RX pin in the middle of the edge (and not too close to the edge)
|
||||
rx_buffer = 0;
|
||||
}
|
||||
else
|
||||
rx_tick_cnt = 1; // Waiting for start bit, but wrong level. Wait for next Interrupt to check RX pin level
|
||||
}
|
||||
else if (rx_bit_cnt >= 8) { // rx_bit_cnt >= 8 : waiting for stop bit
|
||||
if (inbit) {
|
||||
// Stop-bit read complete. Add to buffer.
|
||||
uint8_t next = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;
|
||||
if (next != _receive_buffer_head) {
|
||||
// save new data in buffer: tail points to byte destination
|
||||
_receive_buffer[_receive_buffer_tail] = rx_buffer; // save new byte
|
||||
_receive_buffer_tail = next;
|
||||
}
|
||||
else // rx_bit_cnt = x with x = [0..7] correspond to new bit x received
|
||||
_buffer_overflow = true;
|
||||
}
|
||||
// Full trame received. Restart waiting for start bit at next interrupt
|
||||
rx_tick_cnt = 1;
|
||||
rx_bit_cnt = -1;
|
||||
}
|
||||
else {
|
||||
// data bits
|
||||
rx_buffer >>= 1;
|
||||
if (inbit) rx_buffer |= 0x80;
|
||||
rx_bit_cnt++; // Prepare for next bit
|
||||
rx_tick_cnt = OVERSAMPLE; // Wait OVERSAMPLE ticks before sampling next bit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Interrupt handling
|
||||
//
|
||||
|
||||
/* static */
|
||||
inline void SoftwareSerial::handleInterrupt(HardwareTimer*) {
|
||||
if (active_in) active_in->recv();
|
||||
if (active_out) active_out->send();
|
||||
}
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
SoftwareSerial::SoftwareSerial(uint16_t receivePin, uint16_t transmitPin, bool inverse_logic /* = false */) :
|
||||
_receivePin(receivePin),
|
||||
_transmitPin(transmitPin),
|
||||
_receivePinPort(digitalPinToPort(receivePin)),
|
||||
_receivePinNumber(STM_LL_GPIO_PIN(digitalPinToPinName(receivePin))),
|
||||
_transmitPinPort(digitalPinToPort(transmitPin)),
|
||||
_transmitPinNumber(STM_LL_GPIO_PIN(digitalPinToPinName(transmitPin))),
|
||||
_speed(0),
|
||||
_buffer_overflow(false),
|
||||
_inverse_logic(inverse_logic),
|
||||
_half_duplex(receivePin == transmitPin),
|
||||
_output_pending(0),
|
||||
_receive_buffer_tail(0),
|
||||
_receive_buffer_head(0)
|
||||
{
|
||||
if ((receivePin < NUM_DIGITAL_PINS) || (transmitPin < NUM_DIGITAL_PINS)) {
|
||||
/* Enable GPIO clock for tx and rx pin*/
|
||||
set_GPIO_Port_Clock(STM_PORT(digitalPinToPinName(transmitPin)));
|
||||
set_GPIO_Port_Clock(STM_PORT(digitalPinToPinName(receivePin)));
|
||||
}
|
||||
else
|
||||
_Error_Handler("ERROR: invalid pin number\n", -1);
|
||||
}
|
||||
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
SoftwareSerial::~SoftwareSerial() { end(); }
|
||||
|
||||
//
|
||||
// Public methods
|
||||
//
|
||||
|
||||
void SoftwareSerial::begin(long speed) {
|
||||
#ifdef FORCE_BAUD_RATE
|
||||
speed = FORCE_BAUD_RATE;
|
||||
#endif
|
||||
_speed = speed;
|
||||
if (!_half_duplex) {
|
||||
setTX();
|
||||
setRX();
|
||||
listen();
|
||||
}
|
||||
else
|
||||
setTX();
|
||||
}
|
||||
|
||||
void SoftwareSerial::end() {
|
||||
stopListening();
|
||||
}
|
||||
|
||||
// Read data from buffer
|
||||
int SoftwareSerial::read() {
|
||||
// Empty buffer?
|
||||
if (_receive_buffer_head == _receive_buffer_tail) return -1;
|
||||
|
||||
// Read from "head"
|
||||
uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte
|
||||
_receive_buffer_head = (_receive_buffer_head + 1) % _SS_MAX_RX_BUFF;
|
||||
return d;
|
||||
}
|
||||
|
||||
int SoftwareSerial::available() {
|
||||
return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF;
|
||||
}
|
||||
|
||||
size_t SoftwareSerial::write(uint8_t b) {
|
||||
// wait for previous transmit to complete
|
||||
_output_pending = 1;
|
||||
while (active_out) { /* nada */ }
|
||||
// add start and stop bits.
|
||||
tx_buffer = b << 1 | 0x200;
|
||||
if (_inverse_logic) tx_buffer = ~tx_buffer;
|
||||
tx_bit_cnt = 0;
|
||||
tx_tick_cnt = OVERSAMPLE;
|
||||
setSpeed(_speed);
|
||||
if (_half_duplex) setRXTX(false);
|
||||
_output_pending = 0;
|
||||
// make us active
|
||||
active_out = this;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SoftwareSerial::flush() {
|
||||
noInterrupts();
|
||||
_receive_buffer_head = _receive_buffer_tail = 0;
|
||||
interrupts();
|
||||
}
|
||||
|
||||
int SoftwareSerial::peek() {
|
||||
// Empty buffer?
|
||||
if (_receive_buffer_head == _receive_buffer_tail) return -1;
|
||||
|
||||
// Read from "head"
|
||||
return _receive_buffer[_receive_buffer_head];
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* SoftwareSerial.h (formerly NewSoftSerial.h)
|
||||
*
|
||||
* Multi-instance software serial library for Arduino/Wiring
|
||||
* -- Interrupt-driven receive and other improvements by ladyada
|
||||
* (https://ladyada.net)
|
||||
* -- Tuning, circular buffer, derivation from class Print/Stream,
|
||||
* multi-instance support, porting to 8MHz processors,
|
||||
* various optimizations, PROGMEM delay tables, inverse logic and
|
||||
* direct port writing by Mikal Hart (http://www.arduiniana.org)
|
||||
* -- Pin change interrupt macros by Paul Stoffregen (https://www.pjrc.com)
|
||||
* -- 20MHz processor support by Garrett Mace (http://www.macetech.com)
|
||||
* -- ATmega1280/2560 support by Brett Hagman (https://www.roguerobotics.com/)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* The latest version of this library can always be found at
|
||||
* http://arduiniana.org.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
/******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
#define _SS_MAX_RX_BUFF 64 // RX buffer size
|
||||
|
||||
class SoftwareSerial : public Stream {
|
||||
private:
|
||||
// per object data
|
||||
uint16_t _receivePin;
|
||||
uint16_t _transmitPin;
|
||||
GPIO_TypeDef *_receivePinPort;
|
||||
uint32_t _receivePinNumber;
|
||||
GPIO_TypeDef *_transmitPinPort;
|
||||
uint32_t _transmitPinNumber;
|
||||
uint32_t _speed;
|
||||
|
||||
uint16_t _buffer_overflow: 1;
|
||||
uint16_t _inverse_logic: 1;
|
||||
uint16_t _half_duplex: 1;
|
||||
uint16_t _output_pending: 1;
|
||||
|
||||
unsigned char _receive_buffer[_SS_MAX_RX_BUFF];
|
||||
volatile uint8_t _receive_buffer_tail;
|
||||
volatile uint8_t _receive_buffer_head;
|
||||
|
||||
uint32_t delta_start = 0;
|
||||
|
||||
// static data
|
||||
static HardwareTimer timer;
|
||||
static const IRQn_Type timer_interrupt_number;
|
||||
static uint32_t timer_interrupt_priority;
|
||||
static SoftwareSerial *active_listener;
|
||||
static SoftwareSerial *volatile active_out;
|
||||
static SoftwareSerial *volatile active_in;
|
||||
static int32_t tx_tick_cnt;
|
||||
static volatile int32_t rx_tick_cnt;
|
||||
static uint32_t tx_buffer;
|
||||
static int32_t tx_bit_cnt;
|
||||
static uint32_t rx_buffer;
|
||||
static int32_t rx_bit_cnt;
|
||||
static uint32_t cur_speed;
|
||||
|
||||
// private methods
|
||||
void send();
|
||||
void recv();
|
||||
void setTX();
|
||||
void setRX();
|
||||
void setSpeed(uint32_t speed);
|
||||
void setRXTX(bool input);
|
||||
static void handleInterrupt(HardwareTimer *timer);
|
||||
|
||||
public:
|
||||
// public methods
|
||||
|
||||
SoftwareSerial(uint16_t receivePin, uint16_t transmitPin, bool inverse_logic=false);
|
||||
virtual ~SoftwareSerial();
|
||||
void begin(long speed);
|
||||
bool listen();
|
||||
void end();
|
||||
bool isListening() { return active_listener == this; }
|
||||
bool stopListening();
|
||||
bool overflow() {
|
||||
bool ret = _buffer_overflow;
|
||||
if (ret) _buffer_overflow = false;
|
||||
return ret;
|
||||
}
|
||||
int peek();
|
||||
|
||||
virtual size_t write(uint8_t byte);
|
||||
virtual int read();
|
||||
virtual int available();
|
||||
virtual void flush();
|
||||
operator bool() { return true; }
|
||||
|
||||
static void setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority);
|
||||
|
||||
using Print::write;
|
||||
};
|
||||
@@ -98,7 +98,7 @@ static inline void pwm_details(const pin_t pin) {
|
||||
timer_dev * const tdev = PIN_MAP[pin].timer_device;
|
||||
const uint8_t channel = PIN_MAP[pin].timer_channel;
|
||||
const char num = (
|
||||
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
|
||||
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||
tdev == &timer8 ? '8' :
|
||||
tdev == &timer5 ? '5' :
|
||||
#endif
|
||||
|
||||
@@ -87,7 +87,7 @@ void TFT_FSMC::Init() {
|
||||
|
||||
__HAL_RCC_FSMC_CLK_ENABLE();
|
||||
|
||||
for(uint16_t i = 0; PinMap_FSMC[i].pin != NC; i++)
|
||||
for (uint16_t i = 0; PinMap_FSMC[i].pin != NC; i++)
|
||||
pinmap_pinout(PinMap_FSMC[i].pin, PinMap_FSMC);
|
||||
pinmap_pinout(digitalPinToPinName(TFT_CS_PIN), PinMap_FSMC_CS);
|
||||
pinmap_pinout(digitalPinToPinName(TFT_RS_PIN), PinMap_FSMC_RS);
|
||||
|
||||
@@ -155,9 +155,9 @@ uint16_t XPT2046::getRawData(const XPTCoordinate coordinate) {
|
||||
|
||||
uint16_t XPT2046::HardwareIO(uint16_t data) {
|
||||
__HAL_SPI_ENABLE(&SPIx);
|
||||
while((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
|
||||
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
|
||||
SPIx.Instance->DR = data;
|
||||
while((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {}
|
||||
while ((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {}
|
||||
__HAL_SPI_DISABLE(&SPIx);
|
||||
|
||||
return SPIx.Instance->DR;
|
||||
|
||||
@@ -110,7 +110,6 @@
|
||||
// ------------------------
|
||||
|
||||
HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { NULL };
|
||||
bool timer_enabled[NUM_HARDWARE_TIMERS] = { false };
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
@@ -135,6 +134,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
* which changes the prescaler when an IRQ frequency change is needed
|
||||
* (for example when steppers are turned on)
|
||||
*/
|
||||
|
||||
timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally
|
||||
timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT);
|
||||
break;
|
||||
@@ -145,15 +145,13 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Disable preload. Leaving it default-enabled can cause the timer to stop if it happens
|
||||
// to exit the ISR after the start time for the next interrupt has already passed.
|
||||
timer_instance[timer_num]->setPreloadEnable(false);
|
||||
|
||||
HAL_timer_enable_interrupt(timer_num);
|
||||
|
||||
/*
|
||||
* Initializes (and unfortunately starts) the timer.
|
||||
* This is needed to set correct IRQ priority at the moment but causes
|
||||
* no harm since every call to HAL_timer_start() is actually followed by
|
||||
* a call to HAL_timer_enable_interrupt() which means that there isn't
|
||||
* a case in which you want the timer to run without a callback.
|
||||
*/
|
||||
// Start the timer.
|
||||
timer_instance[timer_num]->resume(); // First call to resume() MUST follow the attachInterrupt()
|
||||
|
||||
// This is fixed in Arduino_Core_STM32 1.8.
|
||||
@@ -161,47 +159,34 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
// timer_instance[timer_num]->setInterruptPriority
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
HAL_NVIC_SetPriority(STEP_TIMER_IRQ_NAME, STEP_TIMER_IRQ_PRIO, 0);
|
||||
timer_instance[timer_num]->setInterruptPriority(STEP_TIMER_IRQ_PRIO, 0);
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
HAL_NVIC_SetPriority(TEMP_TIMER_IRQ_NAME, TEMP_TIMER_IRQ_PRIO, 0);
|
||||
timer_instance[timer_num]->setInterruptPriority(TEMP_TIMER_IRQ_PRIO, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
if (HAL_timer_initialized(timer_num) && !timer_enabled[timer_num]) {
|
||||
timer_enabled[timer_num] = true;
|
||||
if (HAL_timer_initialized(timer_num) && !timer_instance[timer_num]->hasInterrupt()) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
timer_instance[timer_num]->attachInterrupt(Step_Handler);
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
timer_instance[timer_num]->attachInterrupt(Temp_Handler);
|
||||
break;
|
||||
timer_instance[timer_num]->attachInterrupt(Step_Handler);
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
timer_instance[timer_num]->attachInterrupt(Temp_Handler);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
if (HAL_timer_interrupt_enabled(timer_num)) {
|
||||
timer_instance[timer_num]->detachInterrupt();
|
||||
timer_enabled[timer_num] = false;
|
||||
}
|
||||
if (HAL_timer_initialized(timer_num)) timer_instance[timer_num]->detachInterrupt();
|
||||
}
|
||||
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
return HAL_timer_initialized(timer_num) && timer_enabled[timer_num];
|
||||
}
|
||||
|
||||
// Only for use within the HAL
|
||||
TIM_TypeDef * HAL_timer_device(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM: return STEP_TIMER_DEV;
|
||||
case TEMP_TIMER_NUM: return TEMP_TIMER_DEV;
|
||||
}
|
||||
return nullptr;
|
||||
return HAL_timer_initialized(timer_num) && timer_instance[timer_num]->hasInterrupt();
|
||||
}
|
||||
|
||||
void SetTimerInterruptPriorities() {
|
||||
@@ -209,4 +194,87 @@ void SetTimerInterruptPriorities() {
|
||||
TERN_(HAS_SERVOS, libServo::setInterruptPriority(SERVO_TIMER_IRQ_PRIO, 0));
|
||||
}
|
||||
|
||||
// This is a terrible hack to replicate the behavior used in the framework's SoftwareSerial.cpp
|
||||
// to choose a serial timer. It will select TIM7 on most boards used by Marlin, but this is more
|
||||
// resiliant to new MCUs which may not have a TIM7. Best practice is to explicitly specify
|
||||
// TIMER_SERIAL to avoid relying on framework selections which may not be predictable.
|
||||
#if !defined(TIMER_SERIAL)
|
||||
#if defined (TIM18_BASE)
|
||||
#define TIMER_SERIAL TIM18
|
||||
#elif defined (TIM7_BASE)
|
||||
#define TIMER_SERIAL TIM7
|
||||
#elif defined (TIM6_BASE)
|
||||
#define TIMER_SERIAL TIM6
|
||||
#elif defined (TIM22_BASE)
|
||||
#define TIMER_SERIAL TIM22
|
||||
#elif defined (TIM21_BASE)
|
||||
#define TIMER_SERIAL TIM21
|
||||
#elif defined (TIM17_BASE)
|
||||
#define TIMER_SERIAL TIM17
|
||||
#elif defined (TIM16_BASE)
|
||||
#define TIMER_SERIAL TIM16
|
||||
#elif defined (TIM15_BASE)
|
||||
#define TIMER_SERIAL TIM15
|
||||
#elif defined (TIM14_BASE)
|
||||
#define TIMER_SERIAL TIM14
|
||||
#elif defined (TIM13_BASE)
|
||||
#define TIMER_SERIAL TIM13
|
||||
#elif defined (TIM11_BASE)
|
||||
#define TIMER_SERIAL TIM11
|
||||
#elif defined (TIM10_BASE)
|
||||
#define TIMER_SERIAL TIM10
|
||||
#elif defined (TIM12_BASE)
|
||||
#define TIMER_SERIAL TIM12
|
||||
#elif defined (TIM19_BASE)
|
||||
#define TIMER_SERIAL TIM19
|
||||
#elif defined (TIM9_BASE)
|
||||
#define TIMER_SERIAL TIM9
|
||||
#elif defined (TIM5_BASE)
|
||||
#define TIMER_SERIAL TIM5
|
||||
#elif defined (TIM4_BASE)
|
||||
#define TIMER_SERIAL TIM4
|
||||
#elif defined (TIM3_BASE)
|
||||
#define TIMER_SERIAL TIM3
|
||||
#elif defined (TIM2_BASE)
|
||||
#define TIMER_SERIAL TIM2
|
||||
#elif defined (TIM20_BASE)
|
||||
#define TIMER_SERIAL TIM20
|
||||
#elif defined (TIM8_BASE)
|
||||
#define TIMER_SERIAL TIM8
|
||||
#elif defined (TIM1_BASE)
|
||||
#define TIMER_SERIAL TIM1
|
||||
#else
|
||||
#error No suitable timer found for SoftwareSerial, define TIMER_SERIAL in variant.h
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Place all timers used into an array, then recursively check for duplicates during compilation.
|
||||
// This does not currently account for timers used for PWM, such as for fans.
|
||||
// Timers are actually pointers. Convert to integers to simplify constexpr logic.
|
||||
static constexpr uintptr_t timers_in_use[] = {
|
||||
uintptr_t(TEMP_TIMER_DEV), // Override in pins file
|
||||
uintptr_t(STEP_TIMER_DEV), // Override in pins file
|
||||
#if HAS_TMC_SW_SERIAL
|
||||
uintptr_t(TIMER_SERIAL), // Set in variant.h, or as a define in platformio.h if not present in variant.h
|
||||
#endif
|
||||
#if ENABLED(SPEAKER)
|
||||
uintptr_t(TIMER_TONE), // Set in variant.h, or as a define in platformio.h if not present in variant.h
|
||||
#endif
|
||||
#if HAS_SERVOS
|
||||
uintptr_t(TIMER_SERVO), // Set in variant.h, or as a define in platformio.h if not present in variant.h
|
||||
#endif
|
||||
};
|
||||
|
||||
static constexpr bool verify_no_duplicate_timers() {
|
||||
LOOP_L_N(i, COUNT(timers_in_use))
|
||||
LOOP_S_L_N(j, i + 1, COUNT(timers_in_use))
|
||||
if (timers_in_use[i] == timers_in_use[j]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// If this assertion fails at compile time, review the timers_in_use array. If default_envs is
|
||||
// defined properly in platformio.ini, VS Code can evaluate the array when hovering over it,
|
||||
// making it easy to identify the conflicting timers.
|
||||
static_assert(verify_no_duplicate_timers(), "One or more timer conflict detected");
|
||||
|
||||
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
|
||||
|
||||
@@ -30,8 +30,18 @@
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
// STM32 timers may be 16 or 32 bit. Limiting HAL_TIMER_TYPE_MAX to 16 bits
|
||||
// avoids issues with STM32F0 MCUs, which seem to pause timers if UINT32_MAX
|
||||
// is written to the register. STM32F4 timers do not manifest this issue,
|
||||
// even when writing to 16 bit timers.
|
||||
//
|
||||
// The range of the timer can be queried at runtime using IS_TIM_32B_COUNTER_INSTANCE.
|
||||
// This is a more expensive check than a simple compile-time constant, so its
|
||||
// implementation is deferred until the desire for a 32-bit range outweighs the cost
|
||||
// of adding a run-time check and HAL_TIMER_TYPE_MAX is refactored to allow unique
|
||||
// values for each timer.
|
||||
#define hal_timer_t uint32_t
|
||||
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF // Timers can be 16 or 32 bit
|
||||
#define HAL_TIMER_TYPE_MAX UINT16_MAX
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
@@ -61,14 +71,14 @@
|
||||
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
|
||||
extern void Step_Handler(HardwareTimer *htim);
|
||||
extern void Temp_Handler(HardwareTimer *htim);
|
||||
extern void Step_Handler();
|
||||
extern void Temp_Handler();
|
||||
|
||||
#ifndef HAL_STEP_TIMER_ISR
|
||||
#define HAL_STEP_TIMER_ISR() void Step_Handler(HardwareTimer *htim)
|
||||
#define HAL_STEP_TIMER_ISR() void Step_Handler()
|
||||
#endif
|
||||
#ifndef HAL_TEMP_TIMER_ISR
|
||||
#define HAL_TEMP_TIMER_ISR() void Temp_Handler(HardwareTimer *htim)
|
||||
#define HAL_TEMP_TIMER_ISR() void Temp_Handler()
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
@@ -90,8 +100,6 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
// Exposed here to allow all timer priority information to reside in timers.cpp
|
||||
void SetTimerInterruptPriorities();
|
||||
|
||||
//TIM_TypeDef* HAL_timer_device(const uint8_t timer_num); no need to be public for now. not public = not used externally
|
||||
|
||||
// FORCE_INLINE because these are used in performance-critical situations
|
||||
FORCE_INLINE bool HAL_timer_initialized(const uint8_t timer_num) {
|
||||
return timer_instance[timer_num] != NULL;
|
||||
|
||||
@@ -97,6 +97,9 @@ const uint8_t adc_pins[] = {
|
||||
#if HAS_TEMP_ADC_0
|
||||
TEMP_0_PIN,
|
||||
#endif
|
||||
#if HAS_TEMP_ADC_PROBE
|
||||
TEMP_PROBE_PIN,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
TEMP_BED_PIN,
|
||||
#endif
|
||||
@@ -151,6 +154,9 @@ enum TempPinIndex : char {
|
||||
#if HAS_TEMP_ADC_0
|
||||
TEMP_0,
|
||||
#endif
|
||||
#if HAS_TEMP_ADC_PROBE
|
||||
TEMP_PROBE,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
TEMP_BED,
|
||||
#endif
|
||||
@@ -341,6 +347,9 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
#if HAS_TEMP_ADC_0
|
||||
case TEMP_0_PIN: pin_index = TEMP_0; break;
|
||||
#endif
|
||||
#if HAS_TEMP_ADC_PROBE
|
||||
case TEMP_PROBE_PIN: pin_index = TEMP_PROBE; break;
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
case TEMP_BED_PIN: pin_index = TEMP_BED; break;
|
||||
#endif
|
||||
|
||||
@@ -46,12 +46,14 @@
|
||||
#include "msc_sd.h"
|
||||
#endif
|
||||
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
|
||||
#ifndef STM32_FLASH_SIZE
|
||||
#if defined(MCU_STM32F103RE) || defined(MCU_STM32F103VE)
|
||||
#if EITHER(MCU_STM32F103RE, MCU_STM32F103VE)
|
||||
#define STM32_FLASH_SIZE 512
|
||||
#else
|
||||
#define STM32_FLASH_SIZE 256
|
||||
@@ -64,86 +66,50 @@
|
||||
#else
|
||||
#define UsbSerial MarlinCompositeSerial
|
||||
#endif
|
||||
#define MSerial1 Serial1
|
||||
#define MSerial2 Serial2
|
||||
#define MSerial3 Serial3
|
||||
#define MSerial4 Serial4
|
||||
#define MSerial5 Serial5
|
||||
#else
|
||||
#define MSerial1 Serial
|
||||
#define MSerial2 Serial1
|
||||
#define MSerial3 Serial2
|
||||
#define MSerial4 Serial3
|
||||
#define MSerial5 Serial4
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == 0
|
||||
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif SERIAL_PORT == -1
|
||||
#define MYSERIAL0 UsbSerial
|
||||
#elif SERIAL_PORT == 1
|
||||
#define MYSERIAL0 MSerial1
|
||||
#elif SERIAL_PORT == 2
|
||||
#define MYSERIAL0 MSerial2
|
||||
#elif SERIAL_PORT == 3
|
||||
#define MYSERIAL0 MSerial3
|
||||
#elif SERIAL_PORT == 4
|
||||
#define MYSERIAL0 MSerial4
|
||||
#elif SERIAL_PORT == 5
|
||||
#define MYSERIAL0 MSerial5
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||
#define NUM_UARTS 5
|
||||
#else
|
||||
#error "SERIAL_PORT must be from -1 to 5. Please update your configuration."
|
||||
#define NUM_UARTS 3
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL0 UsbSerial
|
||||
#elif WITHIN(SERIAL_PORT, 1, NUM_UARTS)
|
||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||
#elif NUM_UARTS == 5
|
||||
#error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
|
||||
#else
|
||||
#error "SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == 0
|
||||
#error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == SERIAL_PORT
|
||||
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == -1
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL1 UsbSerial
|
||||
#elif SERIAL_PORT_2 == 1
|
||||
#define MYSERIAL1 MSerial1
|
||||
#elif SERIAL_PORT_2 == 2
|
||||
#define MYSERIAL1 MSerial2
|
||||
#elif SERIAL_PORT_2 == 3
|
||||
#define MYSERIAL1 MSerial3
|
||||
#elif SERIAL_PORT_2 == 4
|
||||
#define MYSERIAL1 MSerial4
|
||||
#elif SERIAL_PORT_2 == 5
|
||||
#define MYSERIAL1 MSerial5
|
||||
#elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||
#elif NUM_UARTS == 5
|
||||
#error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration."
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from -1 to 5. Please update your configuration."
|
||||
#endif
|
||||
#define NUM_SERIAL 2
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
|
||||
#ifdef DGUS_SERIAL
|
||||
#if DGUS_SERIAL_PORT == 0
|
||||
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == SERIAL_PORT
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == -1
|
||||
#define DGUS_SERIAL UsbSerial
|
||||
#elif DGUS_SERIAL_PORT == 1
|
||||
#define DGUS_SERIAL MSerial1
|
||||
#elif DGUS_SERIAL_PORT == 2
|
||||
#define DGUS_SERIAL MSerial2
|
||||
#elif DGUS_SERIAL_PORT == 3
|
||||
#define DGUS_SERIAL MSerial3
|
||||
#elif DGUS_SERIAL_PORT == 4
|
||||
#define DGUS_SERIAL MSerial4
|
||||
#elif DGUS_SERIAL_PORT == 5
|
||||
#define DGUS_SERIAL MSerial5
|
||||
#else
|
||||
#error "DGUS_SERIAL_PORT must be from -1 to 5. Please update your configuration."
|
||||
#error "SERIAL_PORT_2 must be -1 or from 1 to 3. Please update your configuration."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL UsbSerial
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 1, NUM_UARTS)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#elif NUM_UARTS == 5
|
||||
#error "LCD_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Set interrupt grouping for this MCU
|
||||
void HAL_init();
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
/**
|
||||
* Software SPI functions originally from Arduino Sd2Card Library
|
||||
* Copyright (c) 2009 by William Greiman
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adapted to the STM32F1 HAL
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
/**
|
||||
* 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 __STM32F1__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "MarlinSerial.h"
|
||||
#include <libmaple/usart.h>
|
||||
|
||||
// Copied from ~/.platformio/packages/framework-arduinoststm32-maple/STM32F1/system/libmaple/usart_private.h
|
||||
// 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) {
|
||||
/* Handle RXNEIE and TXEIE interrupts.
|
||||
* RXNE signifies availability of a byte in DR.
|
||||
*
|
||||
* See table 198 (sec 27.4, p809) in STM document RM0008 rev 15.
|
||||
* We enable RXNEIE.
|
||||
*/
|
||||
uint32_t srflags = regs->SR, cr1its = regs->CR1;
|
||||
|
||||
if ((cr1its & USART_CR1_RXNEIE) && (srflags & USART_SR_RXNE)) {
|
||||
if (srflags & USART_SR_FE || srflags & USART_SR_PE ) {
|
||||
// framing error or parity error
|
||||
regs->DR; // Read and throw away the data, which also clears FE and PE
|
||||
}
|
||||
else {
|
||||
uint8_t c = (uint8)regs->DR;
|
||||
#ifdef USART_SAFE_INSERT
|
||||
// If the buffer is full and the user defines USART_SAFE_INSERT,
|
||||
// ignore new bytes.
|
||||
rb_safe_insert(rb, c);
|
||||
#else
|
||||
// By default, push bytes around in the ring buffer.
|
||||
rb_push_insert(rb, c);
|
||||
#endif
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
if (serial.emergency_parser_enabled())
|
||||
emergency_parser.update(serial.emergency_state, c);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (srflags & USART_SR_ORE) {
|
||||
// overrun and empty data, just do a dummy read to clear ORE
|
||||
// and prevent a raise condition where a continous interrupt stream (due to ORE set) occurs
|
||||
// (see chapter "Overrun error" ) in STM32 reference manual
|
||||
regs->DR;
|
||||
}
|
||||
|
||||
// TXE signifies readiness to send a byte to DR.
|
||||
if ((cr1its & USART_CR1_TXEIE) && (srflags & USART_SR_TXE)) {
|
||||
if (!rb_is_empty(wb))
|
||||
regs->DR=rb_remove(wb);
|
||||
else
|
||||
regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE
|
||||
}
|
||||
}
|
||||
|
||||
// Not every MarlinSerial port should handle emergency parsing.
|
||||
// It would not make sense to parse GCode from TMC responses, for example.
|
||||
constexpr bool serial_handles_emergency(int port) {
|
||||
return false
|
||||
#ifdef SERIAL_PORT
|
||||
|| (SERIAL_PORT) == port
|
||||
#endif
|
||||
#ifdef SERIAL_PORT_2
|
||||
|| (SERIAL_PORT_2) == port
|
||||
#endif
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
|| (LCD_SERIAL_PORT) == port
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
#define DEFINE_HWSERIAL_MARLIN(name, n) \
|
||||
MarlinSerial name(USART##n, \
|
||||
BOARD_USART##n##_TX_PIN, \
|
||||
BOARD_USART##n##_RX_PIN, \
|
||||
serial_handles_emergency(n)); \
|
||||
extern "C" void __irq_usart##n(void) { \
|
||||
my_usart_irq(USART##n->rb, USART##n->wb, USART##n##_BASE, MSerial##n); \
|
||||
}
|
||||
|
||||
#define DEFINE_HWSERIAL_UART_MARLIN(name, n) \
|
||||
MarlinSerial name(UART##n, \
|
||||
BOARD_USART##n##_TX_PIN, \
|
||||
BOARD_USART##n##_RX_PIN, \
|
||||
serial_handles_emergency(n)); \
|
||||
extern "C" void __irq_usart##n(void) { \
|
||||
my_usart_irq(UART##n->rb, UART##n->wb, UART##n##_BASE, MSerial##n); \
|
||||
}
|
||||
|
||||
// Instantiate all UARTs even if they are not needed
|
||||
// This avoids a bunch of logic to figure out every serial
|
||||
// port which may be in use on the system.
|
||||
DEFINE_HWSERIAL_MARLIN(MSerial1, 1);
|
||||
DEFINE_HWSERIAL_MARLIN(MSerial2, 2);
|
||||
DEFINE_HWSERIAL_MARLIN(MSerial3, 3);
|
||||
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||
DEFINE_HWSERIAL_UART_MARLIN(MSerial4, 4);
|
||||
DEFINE_HWSERIAL_UART_MARLIN(MSerial5, 5);
|
||||
#endif
|
||||
|
||||
// Check the type of each serial port by passing it to a template function.
|
||||
// HardwareSerial is known to sometimes hang the controller when an error occurs,
|
||||
// so this case will fail the static assert. All other classes are assumed to be ok.
|
||||
template <typename T>
|
||||
constexpr bool IsSerialClassAllowed(const T&) { return true; }
|
||||
constexpr bool IsSerialClassAllowed(const HardwareSerial&) { return false; }
|
||||
|
||||
#define CHECK_CFG_SERIAL(A) static_assert(IsSerialClassAllowed(A), STRINGIFY(A) " is defined incorrectly");
|
||||
#define CHECK_AXIS_SERIAL(A) static_assert(IsSerialClassAllowed(A##_HARDWARE_SERIAL), STRINGIFY(A) "_HARDWARE_SERIAL must be defined in the form MSerial1, rather than Serial1");
|
||||
|
||||
// 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.
|
||||
#ifdef MYSERIAL0
|
||||
CHECK_CFG_SERIAL(MYSERIAL0);
|
||||
#endif
|
||||
#ifdef MYSERIAL1
|
||||
CHECK_CFG_SERIAL(MYSERIAL1);
|
||||
#endif
|
||||
#ifdef LCD_SERIAL
|
||||
CHECK_CFG_SERIAL(LCD_SERIAL);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(X)
|
||||
CHECK_AXIS_SERIAL(X);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(X2)
|
||||
CHECK_AXIS_SERIAL(X2);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(Y)
|
||||
CHECK_AXIS_SERIAL(Y);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(Y2)
|
||||
CHECK_AXIS_SERIAL(Y2);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(Z)
|
||||
CHECK_AXIS_SERIAL(Z);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(Z2)
|
||||
CHECK_AXIS_SERIAL(Z2);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(Z3)
|
||||
CHECK_AXIS_SERIAL(Z3);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(Z4)
|
||||
CHECK_AXIS_SERIAL(Z4);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(E0)
|
||||
CHECK_AXIS_SERIAL(E0);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(E1)
|
||||
CHECK_AXIS_SERIAL(E1);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(E2)
|
||||
CHECK_AXIS_SERIAL(E2);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(E3)
|
||||
CHECK_AXIS_SERIAL(E3);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(E4)
|
||||
CHECK_AXIS_SERIAL(E4);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(E5)
|
||||
CHECK_AXIS_SERIAL(E5);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(E6)
|
||||
CHECK_AXIS_SERIAL(E6);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(E7)
|
||||
CHECK_AXIS_SERIAL(E7);
|
||||
#endif
|
||||
|
||||
#endif // __STM32F1__
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
#include <libmaple/usart.h>
|
||||
#include <WString.h>
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#include "../../feature/e_parser.h"
|
||||
#endif
|
||||
|
||||
// Increase priority of serial interrupts, to reduce overflow errors
|
||||
#define UART_IRQ_PRIO 1
|
||||
|
||||
class MarlinSerial : public HardwareSerial {
|
||||
public:
|
||||
#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
|
||||
// Shadow the parent methods to set IRQ priority after begin()
|
||||
void begin(uint32 baud) {
|
||||
MarlinSerial::begin(baud, SERIAL_8N1);
|
||||
}
|
||||
|
||||
void begin(uint32 baud, uint8_t config) {
|
||||
HardwareSerial::begin(baud, config);
|
||||
nvic_irq_set_priority(c_dev()->irq_num, UART_IRQ_PRIO);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
extern MarlinSerial MSerial1;
|
||||
extern MarlinSerial MSerial2;
|
||||
extern MarlinSerial MSerial3;
|
||||
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||
extern MarlinSerial MSerial4;
|
||||
extern MarlinSerial MSerial5;
|
||||
#endif
|
||||
@@ -40,6 +40,9 @@
|
||||
#include <boards.h>
|
||||
#include <wirish.h>
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "spi_pins.h"
|
||||
|
||||
/** Time in ms for DMA receive timeout */
|
||||
#define DMA_TIMEOUT 100
|
||||
|
||||
@@ -710,6 +713,6 @@ static spi_baud_rate determine_baud_rate(spi_dev *dev, uint32_t freq) {
|
||||
return baud_rates[i];
|
||||
}
|
||||
|
||||
SPIClass SPI(1);
|
||||
SPIClass SPI(SPI_DEVICE);
|
||||
|
||||
#endif // __STM32F1__
|
||||
|
||||
@@ -57,4 +57,4 @@ void SoftwareSerial::stopListening() {
|
||||
listening = false;
|
||||
}
|
||||
|
||||
#endif //__STM32F1__
|
||||
#endif // __STM32F1__
|
||||
|
||||
@@ -1,331 +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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* u8g_com_stm32duino_fsmc.cpp
|
||||
*
|
||||
* Communication interface for FSMC
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if defined(ARDUINO_ARCH_STM32F1) && PIN_EXISTS(FSMC_CS) // FSMC on 100/144 pins SoCs
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
|
||||
#include <U8glib.h>
|
||||
#include <libmaple/fsmc.h>
|
||||
#include <libmaple/gpio.h>
|
||||
#include <libmaple/dma.h>
|
||||
#include <boards.h>
|
||||
|
||||
#ifndef LCD_READ_ID
|
||||
#define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
|
||||
#endif
|
||||
|
||||
/* Timing configuration */
|
||||
#define FSMC_ADDRESS_SETUP_TIME 15 // AddressSetupTime
|
||||
#define FSMC_DATA_SETUP_TIME 15 // DataSetupTime
|
||||
|
||||
void LCD_IO_Init(uint8_t cs, uint8_t rs);
|
||||
void LCD_IO_WriteData(uint16_t RegValue);
|
||||
void LCD_IO_WriteReg(uint16_t Reg);
|
||||
uint16_t LCD_IO_ReadData(uint16_t RegValue);
|
||||
uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize);
|
||||
#ifdef LCD_USE_DMA_FSMC
|
||||
void LCD_IO_WriteMultiple(uint16_t data, uint32_t count);
|
||||
void LCD_IO_WriteSequence(uint16_t *data, uint16_t length);
|
||||
#endif
|
||||
|
||||
static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT
|
||||
|
||||
uint8_t u8g_com_stm32duino_fsmc_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
if (msgInitCount) {
|
||||
if (msg == U8G_COM_MSG_INIT) msgInitCount--;
|
||||
if (msgInitCount) return -1;
|
||||
}
|
||||
|
||||
static uint8_t isCommand;
|
||||
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_STOP: break;
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_SetPIOutput(u8g, U8G_PI_RESET);
|
||||
|
||||
#ifdef LCD_USE_DMA_FSMC
|
||||
dma_init(FSMC_DMA_DEV);
|
||||
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM);
|
||||
#endif
|
||||
|
||||
LCD_IO_Init(u8g->pin_list[U8G_PI_CS], u8g->pin_list[U8G_PI_A0]);
|
||||
u8g_Delay(50);
|
||||
|
||||
if (arg_ptr) {
|
||||
*((uint32_t *)arg_ptr) = LCD_IO_ReadData(0x0000);
|
||||
if (*((uint32_t *)arg_ptr) == 0)
|
||||
*((uint32_t *)arg_ptr) = (LCD_READ_ID << 24) | LCD_IO_ReadData(LCD_READ_ID, 3);
|
||||
}
|
||||
isCommand = 0;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: // define cmd (arg_val = 0) or data mode (arg_val = 1)
|
||||
isCommand = arg_val == 0 ? 1 : 0;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
if (isCommand)
|
||||
LCD_IO_WriteReg(arg_val);
|
||||
else
|
||||
LCD_IO_WriteData((uint16_t)arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
for (uint8_t i = 0; i < arg_val; i += 2)
|
||||
LCD_IO_WriteData(*(uint16_t *)(((uint32_t)arg_ptr) + i));
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* FSMC LCD IO
|
||||
*/
|
||||
#define __ASM __asm
|
||||
#define __STATIC_INLINE static inline
|
||||
|
||||
__attribute__((always_inline)) __STATIC_INLINE void __DSB() {
|
||||
__ASM volatile ("dsb 0xF":::"memory");
|
||||
}
|
||||
|
||||
#define FSMC_CS_NE1 PD7
|
||||
|
||||
#if ENABLED(STM32_XL_DENSITY)
|
||||
#define FSMC_CS_NE2 PG9
|
||||
#define FSMC_CS_NE3 PG10
|
||||
#define FSMC_CS_NE4 PG12
|
||||
|
||||
#define FSMC_RS_A0 PF0
|
||||
#define FSMC_RS_A1 PF1
|
||||
#define FSMC_RS_A2 PF2
|
||||
#define FSMC_RS_A3 PF3
|
||||
#define FSMC_RS_A4 PF4
|
||||
#define FSMC_RS_A5 PF5
|
||||
#define FSMC_RS_A6 PF12
|
||||
#define FSMC_RS_A7 PF13
|
||||
#define FSMC_RS_A8 PF14
|
||||
#define FSMC_RS_A9 PF15
|
||||
#define FSMC_RS_A10 PG0
|
||||
#define FSMC_RS_A11 PG1
|
||||
#define FSMC_RS_A12 PG2
|
||||
#define FSMC_RS_A13 PG3
|
||||
#define FSMC_RS_A14 PG4
|
||||
#define FSMC_RS_A15 PG5
|
||||
#endif
|
||||
|
||||
#define FSMC_RS_A16 PD11
|
||||
#define FSMC_RS_A17 PD12
|
||||
#define FSMC_RS_A18 PD13
|
||||
#define FSMC_RS_A19 PE3
|
||||
#define FSMC_RS_A20 PE4
|
||||
#define FSMC_RS_A21 PE5
|
||||
#define FSMC_RS_A22 PE6
|
||||
#define FSMC_RS_A23 PE2
|
||||
|
||||
#if ENABLED(STM32_XL_DENSITY)
|
||||
#define FSMC_RS_A24 PG13
|
||||
#define FSMC_RS_A25 PG14
|
||||
#endif
|
||||
|
||||
static uint8_t fsmcInit = 0;
|
||||
|
||||
typedef struct {
|
||||
__IO uint16_t REG;
|
||||
__IO uint16_t RAM;
|
||||
} LCD_CONTROLLER_TypeDef;
|
||||
|
||||
LCD_CONTROLLER_TypeDef *LCD;
|
||||
|
||||
void LCD_IO_Init(uint8_t cs, uint8_t rs) {
|
||||
uint32_t controllerAddress;
|
||||
struct fsmc_nor_psram_reg_map* fsmcPsramRegion;
|
||||
|
||||
if (fsmcInit) return;
|
||||
fsmcInit = 1;
|
||||
|
||||
switch (cs) {
|
||||
case FSMC_CS_NE1: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION1; fsmcPsramRegion = FSMC_NOR_PSRAM1_BASE; break;
|
||||
#if ENABLED(STM32_XL_DENSITY)
|
||||
case FSMC_CS_NE2: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION2; fsmcPsramRegion = FSMC_NOR_PSRAM2_BASE; break;
|
||||
case FSMC_CS_NE3: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION3; fsmcPsramRegion = FSMC_NOR_PSRAM3_BASE; break;
|
||||
case FSMC_CS_NE4: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION4; fsmcPsramRegion = FSMC_NOR_PSRAM4_BASE; break;
|
||||
#endif
|
||||
default: return;
|
||||
}
|
||||
|
||||
#define _ORADDR(N) controllerAddress |= (_BV32(N) - 2)
|
||||
|
||||
switch (rs) {
|
||||
#if ENABLED(STM32_XL_DENSITY)
|
||||
case FSMC_RS_A0: _ORADDR( 1); break;
|
||||
case FSMC_RS_A1: _ORADDR( 2); break;
|
||||
case FSMC_RS_A2: _ORADDR( 3); break;
|
||||
case FSMC_RS_A3: _ORADDR( 4); break;
|
||||
case FSMC_RS_A4: _ORADDR( 5); break;
|
||||
case FSMC_RS_A5: _ORADDR( 6); break;
|
||||
case FSMC_RS_A6: _ORADDR( 7); break;
|
||||
case FSMC_RS_A7: _ORADDR( 8); break;
|
||||
case FSMC_RS_A8: _ORADDR( 9); break;
|
||||
case FSMC_RS_A9: _ORADDR(10); break;
|
||||
case FSMC_RS_A10: _ORADDR(11); break;
|
||||
case FSMC_RS_A11: _ORADDR(12); break;
|
||||
case FSMC_RS_A12: _ORADDR(13); break;
|
||||
case FSMC_RS_A13: _ORADDR(14); break;
|
||||
case FSMC_RS_A14: _ORADDR(15); break;
|
||||
case FSMC_RS_A15: _ORADDR(16); break;
|
||||
#endif
|
||||
case FSMC_RS_A16: _ORADDR(17); break;
|
||||
case FSMC_RS_A17: _ORADDR(18); break;
|
||||
case FSMC_RS_A18: _ORADDR(19); break;
|
||||
case FSMC_RS_A19: _ORADDR(20); break;
|
||||
case FSMC_RS_A20: _ORADDR(21); break;
|
||||
case FSMC_RS_A21: _ORADDR(22); break;
|
||||
case FSMC_RS_A22: _ORADDR(23); break;
|
||||
case FSMC_RS_A23: _ORADDR(24); break;
|
||||
#if ENABLED(STM32_XL_DENSITY)
|
||||
case FSMC_RS_A24: _ORADDR(25); break;
|
||||
case FSMC_RS_A25: _ORADDR(26); break;
|
||||
#endif
|
||||
default: return;
|
||||
}
|
||||
|
||||
rcc_clk_enable(RCC_FSMC);
|
||||
|
||||
gpio_set_mode(GPIOD, 14, GPIO_AF_OUTPUT_PP); // FSMC_D00
|
||||
gpio_set_mode(GPIOD, 15, GPIO_AF_OUTPUT_PP); // FSMC_D01
|
||||
gpio_set_mode(GPIOD, 0, GPIO_AF_OUTPUT_PP); // FSMC_D02
|
||||
gpio_set_mode(GPIOD, 1, GPIO_AF_OUTPUT_PP); // FSMC_D03
|
||||
gpio_set_mode(GPIOE, 7, GPIO_AF_OUTPUT_PP); // FSMC_D04
|
||||
gpio_set_mode(GPIOE, 8, GPIO_AF_OUTPUT_PP); // FSMC_D05
|
||||
gpio_set_mode(GPIOE, 9, GPIO_AF_OUTPUT_PP); // FSMC_D06
|
||||
gpio_set_mode(GPIOE, 10, GPIO_AF_OUTPUT_PP); // FSMC_D07
|
||||
gpio_set_mode(GPIOE, 11, GPIO_AF_OUTPUT_PP); // FSMC_D08
|
||||
gpio_set_mode(GPIOE, 12, GPIO_AF_OUTPUT_PP); // FSMC_D09
|
||||
gpio_set_mode(GPIOE, 13, GPIO_AF_OUTPUT_PP); // FSMC_D10
|
||||
gpio_set_mode(GPIOE, 14, GPIO_AF_OUTPUT_PP); // FSMC_D11
|
||||
gpio_set_mode(GPIOE, 15, GPIO_AF_OUTPUT_PP); // FSMC_D12
|
||||
gpio_set_mode(GPIOD, 8, GPIO_AF_OUTPUT_PP); // FSMC_D13
|
||||
gpio_set_mode(GPIOD, 9, GPIO_AF_OUTPUT_PP); // FSMC_D14
|
||||
gpio_set_mode(GPIOD, 10, GPIO_AF_OUTPUT_PP); // FSMC_D15
|
||||
|
||||
gpio_set_mode(GPIOD, 4, GPIO_AF_OUTPUT_PP); // FSMC_NOE
|
||||
gpio_set_mode(GPIOD, 5, GPIO_AF_OUTPUT_PP); // FSMC_NWE
|
||||
|
||||
gpio_set_mode(PIN_MAP[cs].gpio_device, PIN_MAP[cs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_CS_NEx
|
||||
gpio_set_mode(PIN_MAP[rs].gpio_device, PIN_MAP[rs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_RS_Ax
|
||||
|
||||
fsmcPsramRegion->BCR = FSMC_BCR_WREN | FSMC_BCR_MTYP_SRAM | FSMC_BCR_MWID_16BITS | FSMC_BCR_MBKEN;
|
||||
fsmcPsramRegion->BTR = (FSMC_DATA_SETUP_TIME << 8) | FSMC_ADDRESS_SETUP_TIME;
|
||||
|
||||
afio_remap(AFIO_REMAP_FSMC_NADV);
|
||||
|
||||
LCD = (LCD_CONTROLLER_TypeDef*)controllerAddress;
|
||||
}
|
||||
|
||||
void LCD_IO_WriteData(uint16_t RegValue) {
|
||||
LCD->RAM = RegValue;
|
||||
__DSB();
|
||||
}
|
||||
|
||||
void LCD_IO_WriteReg(uint16_t Reg) {
|
||||
LCD->REG = Reg;
|
||||
__DSB();
|
||||
}
|
||||
|
||||
uint16_t LCD_IO_ReadData(uint16_t RegValue) {
|
||||
LCD->REG = RegValue;
|
||||
__DSB();
|
||||
|
||||
return LCD->RAM;
|
||||
}
|
||||
|
||||
uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) {
|
||||
volatile uint32_t data;
|
||||
LCD->REG = RegValue;
|
||||
__DSB();
|
||||
|
||||
data = LCD->RAM; // dummy read
|
||||
data = LCD->RAM & 0x00FF;
|
||||
|
||||
while (--ReadSize) {
|
||||
data <<= 8;
|
||||
data |= (LCD->RAM & 0x00FF);
|
||||
}
|
||||
return uint32_t(data);
|
||||
}
|
||||
|
||||
#ifdef LCD_USE_DMA_FSMC
|
||||
|
||||
void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) {
|
||||
while (count > 0) {
|
||||
dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, &color, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM);
|
||||
dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, count > 65535 ? 65535 : count);
|
||||
dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
|
||||
while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {};
|
||||
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
|
||||
count = count > 65535 ? count - 65535 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void LCD_IO_WriteSequence(uint16_t *data, uint16_t length) {
|
||||
dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | DMA_PINC_MODE);
|
||||
dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, length);
|
||||
dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
|
||||
while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {};
|
||||
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
}
|
||||
|
||||
void LCD_IO_WriteSequence_Async(uint16_t *data, uint16_t length) {
|
||||
dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | DMA_PINC_MODE);
|
||||
dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, length);
|
||||
dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
}
|
||||
|
||||
void LCD_IO_WaitSequence_Async() {
|
||||
while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {};
|
||||
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
}
|
||||
|
||||
#endif // LCD_USE_DMA_FSMC
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#endif // ARDUINO_ARCH_STM32F1 && FSMC_CS_PIN
|
||||
@@ -1,236 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* 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/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(SPI_GRAPHICAL_TFT) && DISABLED(FORCE_SOFT_SPI)
|
||||
|
||||
#include "../HAL.h"
|
||||
#include <U8glib.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#define SPI_TFT_CS_H OUT_WRITE(SPI_TFT_CS_PIN, HIGH)
|
||||
#define SPI_TFT_CS_L OUT_WRITE(SPI_TFT_CS_PIN, LOW)
|
||||
|
||||
#define SPI_TFT_DC_H OUT_WRITE(SPI_TFT_DC_PIN, HIGH)
|
||||
#define SPI_TFT_DC_L OUT_WRITE(SPI_TFT_DC_PIN, LOW)
|
||||
|
||||
#define SPI_TFT_RST_H OUT_WRITE(SPI_TFT_RST_PIN, HIGH)
|
||||
#define SPI_TFT_RST_L OUT_WRITE(SPI_TFT_RST_PIN, LOW)
|
||||
|
||||
#define SPI_TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH)
|
||||
#define SPI_TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW)
|
||||
|
||||
void LCD_IO_Init(uint8_t cs, uint8_t rs);
|
||||
void LCD_IO_WriteData(uint16_t RegValue);
|
||||
void LCD_IO_WriteReg(uint16_t Reg);
|
||||
uint16_t LCD_IO_ReadData(uint16_t RegValue);
|
||||
uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize);
|
||||
#ifdef LCD_USE_DMA_SPI
|
||||
void LCD_IO_WriteMultiple(uint16_t data, uint32_t count);
|
||||
void LCD_IO_WriteSequence(uint16_t *data, uint16_t length);
|
||||
#endif
|
||||
|
||||
void LCD_WR_REG(uint8_t cmd) {
|
||||
SPI_TFT_CS_L;
|
||||
SPI_TFT_DC_L;
|
||||
SPI.send(cmd);
|
||||
SPI_TFT_CS_H;
|
||||
}
|
||||
void LCD_WR_DATA(uint8_t data) {
|
||||
SPI_TFT_CS_L;
|
||||
SPI_TFT_DC_H;
|
||||
SPI.send(data);
|
||||
SPI_TFT_CS_H;
|
||||
}
|
||||
|
||||
void spi1Init(uint8_t spiRate) {
|
||||
SPI_TFT_CS_H;
|
||||
|
||||
/**
|
||||
* STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz
|
||||
* STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1
|
||||
* so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2
|
||||
*/
|
||||
uint8_t clock;
|
||||
switch (spiRate) {
|
||||
case SPI_FULL_SPEED: clock = SPI_CLOCK_DIV4; break;
|
||||
case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4; break;
|
||||
case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8; break;
|
||||
case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break;
|
||||
case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break;
|
||||
case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break;
|
||||
default: clock = SPI_CLOCK_DIV2; // Default from the SPI library
|
||||
}
|
||||
SPI.setModule(1);
|
||||
SPI.begin();
|
||||
SPI.setClockDivider(clock);
|
||||
SPI.setBitOrder(MSBFIRST);
|
||||
SPI.setDataMode(SPI_MODE0);
|
||||
}
|
||||
|
||||
void LCD_IO_Init(uint8_t cs, uint8_t rs) {
|
||||
spi1Init(SPI_FULL_SPEED);
|
||||
}
|
||||
|
||||
void LCD_IO_WriteData(uint16_t RegValue) {
|
||||
LCD_WR_DATA(RegValue);
|
||||
}
|
||||
|
||||
void LCD_IO_WriteReg(uint16_t Reg) {
|
||||
LCD_WR_REG(Reg);
|
||||
}
|
||||
|
||||
uint16_t LCD_IO_ReadData(uint16_t RegValue) {
|
||||
uint16_t d = 0;
|
||||
SPI_TFT_CS_L;
|
||||
|
||||
SPI_TFT_DC_L;
|
||||
SPI.send(RegValue);
|
||||
SPI_TFT_DC_H;
|
||||
|
||||
SPI.read((uint8_t*)&d, 1); //dummy read
|
||||
SPI.read((uint8_t*)&d, 1);
|
||||
|
||||
SPI_TFT_CS_H;
|
||||
return d >> 7;
|
||||
}
|
||||
|
||||
uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) {
|
||||
uint32_t data = 0;
|
||||
uint8_t d = 0;
|
||||
SPI_TFT_CS_L;
|
||||
|
||||
SPI_TFT_DC_L;
|
||||
SPI.send(RegValue);
|
||||
SPI_TFT_DC_H;
|
||||
|
||||
SPI.read((uint8_t*)&d, 1); //dummy read
|
||||
SPI.read((uint8_t*)&d, 1);
|
||||
data = d;
|
||||
while (--ReadSize) {
|
||||
data <<= 8;
|
||||
SPI.read((uint8_t*)&d, 1);
|
||||
data |= (d & 0xFF);
|
||||
}
|
||||
|
||||
SPI_TFT_CS_H;
|
||||
return uint32_t(data >> 7);
|
||||
}
|
||||
|
||||
#ifdef LCD_USE_DMA_SPI
|
||||
void LCD_IO_WriteMultiple(uint16_t data, uint32_t count) {
|
||||
if (SPI.getDataSize() == DATA_SIZE_8BIT) {
|
||||
count *= 2;
|
||||
}
|
||||
while (count > 0) {
|
||||
SPI_TFT_CS_L;
|
||||
SPI_TFT_DC_H;
|
||||
SPI.dmaSend(&data, 1, true);
|
||||
SPI_TFT_CS_H;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
void LCD_IO_WriteSequence(uint16_t *data, uint16_t length) {
|
||||
if (SPI.getDataSize() == DATA_SIZE_8BIT) {
|
||||
length *= 2;
|
||||
}
|
||||
SPI_TFT_CS_L;
|
||||
SPI_TFT_DC_H;
|
||||
SPI.dmaSend(data, length, true);
|
||||
SPI_TFT_CS_H;
|
||||
}
|
||||
|
||||
void LCD_IO_WriteSequence_Async(uint16_t *data, uint16_t length) {
|
||||
if (SPI.getDataSize() == DATA_SIZE_8BIT) {
|
||||
length *= 2;
|
||||
}
|
||||
SPI_TFT_CS_L;
|
||||
SPI_TFT_DC_H;
|
||||
SPI.dmaSendAsync(data, length, true);
|
||||
SPI_TFT_CS_H;
|
||||
}
|
||||
|
||||
void LCD_IO_WaitSequence_Async() {
|
||||
SPI_TFT_CS_L;
|
||||
SPI_TFT_DC_H;
|
||||
SPI.dmaSendAsync(NULL, 0, true);
|
||||
SPI_TFT_CS_H;
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT
|
||||
|
||||
#ifndef LCD_READ_ID
|
||||
#define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
|
||||
#endif
|
||||
|
||||
uint8_t u8g_com_stm32duino_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
if (msgInitCount) {
|
||||
if (msg == U8G_COM_MSG_INIT) msgInitCount--;
|
||||
if (msgInitCount) return -1;
|
||||
}
|
||||
|
||||
static uint8_t isCommand;
|
||||
|
||||
LCD_IO_Init(-1, -1);
|
||||
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_STOP: break;
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_SetPIOutput(u8g, U8G_PI_RESET);
|
||||
|
||||
u8g_Delay(50);
|
||||
|
||||
if (arg_ptr) {
|
||||
spi1Init(SPI_EIGHTH_SPEED);
|
||||
*((uint32_t *)arg_ptr) = (LCD_READ_ID << 24) | LCD_IO_ReadData(LCD_READ_ID, 3);
|
||||
spi1Init(SPI_FULL_SPEED);
|
||||
}
|
||||
isCommand = 0;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: // define cmd (arg_val = 0) or data mode (arg_val = 1)
|
||||
isCommand = arg_val == 0 ? 1 : 0;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
if (isCommand)
|
||||
LCD_IO_WriteReg(arg_val);
|
||||
else
|
||||
LCD_IO_WriteData((uint16_t)arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
for (uint8_t i = 0; i < arg_val; i += 2)
|
||||
LCD_IO_WriteData(*(uint16_t *)(((uint32_t)arg_ptr) + i));
|
||||
break;
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // SPI_GRAPHICAL_TFT && !FORCE_SOFT_SPI
|
||||
#endif // STM32F1
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if BOTH(HAS_GRAPHICAL_LCD, FORCE_SOFT_SPI)
|
||||
#if BOTH(HAS_MARLINUI_U8GLIB, FORCE_SOFT_SPI)
|
||||
|
||||
#include "../HAL.h"
|
||||
#include <U8glib.h>
|
||||
@@ -161,5 +161,5 @@ uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#endif // HAS_MARLINUI_U8GLIB
|
||||
#endif // STM32F1
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
* with simple implementations supplied by Marlin.
|
||||
*/
|
||||
|
||||
#ifdef __STM32F1__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(IIC_BL24CXX_EEPROM)
|
||||
@@ -79,3 +81,4 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
|
||||
}
|
||||
|
||||
#endif // IIC_BL24CXX_EEPROM
|
||||
#endif // __STM32F1__
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
* Enable USE_SHARED_EEPROM if not supplied by the framework.
|
||||
*/
|
||||
|
||||
#ifdef __STM32F1__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(IIC_BL24CXX_EEPROM)
|
||||
@@ -49,3 +51,4 @@ uint8_t eeprom_read_byte(uint8_t *pos) {
|
||||
}
|
||||
|
||||
#endif // IIC_BL24CXX_EEPROM
|
||||
#endif // __STM32F1__
|
||||
|
||||
@@ -17,17 +17,17 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* HAL PersistentStore for STM32F1
|
||||
*/
|
||||
|
||||
#ifdef __STM32F1__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if USE_WIRED_EEPROM
|
||||
|
||||
/**
|
||||
* PersistentStore for Arduino-style EEPROM interface
|
||||
* with simple implementations supplied by Marlin.
|
||||
*/
|
||||
|
||||
#include "../shared/eeprom_if.h"
|
||||
#include "../shared/eeprom_api.h"
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
#undef SD_CHECK_AND_RETRY
|
||||
#endif
|
||||
|
||||
// This platform has 'touch/xpt2046', not 'tft/xpt2046'
|
||||
#if ENABLED(TOUCH_SCREEN) && !HAS_FSMC_TFT && !HAS_SPI_TFT
|
||||
// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
|
||||
#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
|
||||
#undef TOUCH_SCREEN
|
||||
#undef TOUCH_SCREEN_CALIBRATION
|
||||
#define HAS_TOUCH_XPT2046 1
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
* Test STM32F1-specific configuration values for errors at compile-time.
|
||||
*/
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for STM32F1. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
|
||||
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on STM32F1."
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifdef USE_USB_COMPOSITE
|
||||
#if defined(__STM32F1__) && defined(USE_USB_COMPOSITE)
|
||||
|
||||
#include "msc_sd.h"
|
||||
#include "SPI.h"
|
||||
@@ -21,7 +21,7 @@
|
||||
#define PRODUCT_ID 0x29
|
||||
|
||||
USBMassStorage MarlinMSC;
|
||||
USBCompositeSerial MarlinCompositeSerial;
|
||||
MarlinUSBCompositeSerial MarlinCompositeSerial;
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
@@ -38,6 +38,17 @@ USBCompositeSerial MarlinCompositeSerial;
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
void (*real_rx_callback)(void);
|
||||
|
||||
void my_rx_callback(void) {
|
||||
real_rx_callback();
|
||||
int len = MarlinCompositeSerial.available();
|
||||
while (len-- > 0) // >0 because available() may return a negative value
|
||||
emergency_parser.update(MarlinCompositeSerial.emergency_state, MarlinCompositeSerial.peek());
|
||||
}
|
||||
#endif
|
||||
|
||||
void MSC_SD_init() {
|
||||
USBComposite.setProductId(PRODUCT_ID);
|
||||
// Just set MarlinCompositeSerial enabled to true
|
||||
@@ -59,6 +70,11 @@ void MSC_SD_init() {
|
||||
// Register composite Serial
|
||||
MarlinCompositeSerial.registerComponent();
|
||||
USBComposite.begin();
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
//rx is usbSerialPart.endpoints[2]
|
||||
real_rx_callback = usbSerialPart.endpoints[2].callback;
|
||||
usbSerialPart.endpoints[2].callback = my_rx_callback;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // USE_USB_COMPOSITE
|
||||
#endif // __STM32F1__ && USE_USB_COMPOSITE
|
||||
|
||||
@@ -17,7 +17,26 @@
|
||||
|
||||
#include <USBComposite.h>
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#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 USBCompositeSerial MarlinCompositeSerial;
|
||||
extern MarlinUSBCompositeSerial MarlinCompositeSerial;
|
||||
|
||||
void MSC_SD_init();
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
* No restriction on use. You can use, modify and redistribute it for
|
||||
* personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
|
||||
* Redistributions of source code must retain the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __STM32F1__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if SD_CONNECTION_IS(ONBOARD)
|
||||
@@ -21,23 +22,23 @@
|
||||
#include "fastio.h"
|
||||
|
||||
#if HAS_SHARED_MEDIA
|
||||
#ifndef ON_BOARD_SPI_DEVICE
|
||||
#define ON_BOARD_SPI_DEVICE SPI_DEVICE
|
||||
#ifndef ONBOARD_SPI_DEVICE
|
||||
#define ONBOARD_SPI_DEVICE SPI_DEVICE
|
||||
#endif
|
||||
#define ONBOARD_SD_SPI SPI
|
||||
#else
|
||||
SPIClass OnBoardSPI(ON_BOARD_SPI_DEVICE);
|
||||
#define ONBOARD_SD_SPI OnBoardSPI
|
||||
SPIClass OnboardSPI(ONBOARD_SPI_DEVICE);
|
||||
#define ONBOARD_SD_SPI OnboardSPI
|
||||
#endif
|
||||
|
||||
#if ON_BOARD_SPI_DEVICE == 1
|
||||
#if ONBOARD_SPI_DEVICE == 1
|
||||
#define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_4
|
||||
#else
|
||||
#define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_2
|
||||
#endif
|
||||
|
||||
#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) /* Set OnBoardSPI cs low */
|
||||
#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) /* Set OnBoardSPI cs high */
|
||||
#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) /* Set OnboardSPI cs low */
|
||||
#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) /* Set OnboardSPI cs high */
|
||||
|
||||
#define FCLK_FAST() ONBOARD_SD_SPI.setClockDivider(SPI_CLOCK_MAX)
|
||||
#define FCLK_SLOW() ONBOARD_SD_SPI.setClockDivider(SPI_BAUD_PCLK_DIV_256)
|
||||
@@ -152,7 +153,7 @@ static int select() { /* 1:OK, 0:Timeout */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static void power_on() { /* Enable SSP module and attach it to I/O pads */
|
||||
ONBOARD_SD_SPI.setModule(ON_BOARD_SPI_DEVICE);
|
||||
ONBOARD_SD_SPI.setModule(ONBOARD_SPI_DEVICE);
|
||||
ONBOARD_SD_SPI.begin();
|
||||
ONBOARD_SD_SPI.setBitOrder(MSBFIRST);
|
||||
ONBOARD_SD_SPI.setDataMode(SPI_MODE0);
|
||||
@@ -554,3 +555,4 @@ DRESULT disk_read (
|
||||
#endif // _DISKIO_IOCTL
|
||||
|
||||
#endif // SD_CONNECTION_IS(ONBOARD)
|
||||
#endif // __STM32F1__
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
|
||||
|
||||
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
|
||||
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||
|
||||
#include "sdio.h"
|
||||
|
||||
@@ -108,7 +108,7 @@ bool SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) {
|
||||
SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS);
|
||||
dma_disable(SDIO_DMA_DEV, SDIO_DMA_CHANNEL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Wait for DMA transaction to complete
|
||||
while ((DMA2_BASE->ISR & (DMA_ISR_TEIF4|DMA_ISR_TCIF4)) == 0 ) { /* wait */ }
|
||||
|
||||
@@ -89,6 +89,16 @@ void TFT_FSMC::Init() {
|
||||
uint8_t cs = FSMC_CS_PIN, rs = FSMC_RS_PIN;
|
||||
uint32_t controllerAddress;
|
||||
|
||||
#if PIN_EXISTS(TFT_BACKLIGHT)
|
||||
OUT_WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT));
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_USE_DMA_FSMC)
|
||||
dma_init(FSMC_DMA_DEV);
|
||||
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM);
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(TFT_RESET)
|
||||
OUT_WRITE(TFT_RESET_PIN, HIGH);
|
||||
delay(100);
|
||||
@@ -201,6 +211,8 @@ uint32_t TFT_FSMC::GetID() {
|
||||
id = ReadID(LCD_READ_ID);
|
||||
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
|
||||
id = ReadID(LCD_READ_ID4);
|
||||
if ((id & 0xFF00) == 0 && (id & 0xFF) != 0)
|
||||
id = ReadID(LCD_READ_ID4);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -224,13 +236,15 @@ void TFT_FSMC::Abort() {
|
||||
}
|
||||
|
||||
void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
|
||||
dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | MemoryIncrease);
|
||||
dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Count);
|
||||
dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
#if defined(FSMC_DMA_DEV) && defined(FSMC_DMA_CHANNEL)
|
||||
dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | MemoryIncrease);
|
||||
dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Count);
|
||||
dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
|
||||
while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {};
|
||||
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {};
|
||||
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAS_FSMC_TFT
|
||||
|
||||
@@ -61,4 +61,11 @@ class TFT_FSMC {
|
||||
|
||||
static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_MODE, Data, Count); }
|
||||
static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_CIRC_MODE, &Data, Count); }
|
||||
static void WriteMultiple(uint16_t Color, uint32_t Count) {
|
||||
static uint16_t Data; Data = Color;
|
||||
while (Count > 0) {
|
||||
TransmitDMA(DMA_CIRC_MODE, &Data, Count > 0xFFFF ? 0xFFFF : Count);
|
||||
Count = Count > 0xFFFF ? Count - 0xFFFF : 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,32 +30,32 @@
|
||||
|
||||
SPIClass TFT_SPI::SPIx(1);
|
||||
|
||||
#define SPI_TFT_CS_H OUT_WRITE(TFT_CS_PIN, HIGH)
|
||||
#define SPI_TFT_CS_L OUT_WRITE(TFT_CS_PIN, LOW)
|
||||
#define TFT_CS_H OUT_WRITE(TFT_CS_PIN, HIGH)
|
||||
#define TFT_CS_L OUT_WRITE(TFT_CS_PIN, LOW)
|
||||
|
||||
#define SPI_TFT_DC_H OUT_WRITE(TFT_DC_PIN, HIGH)
|
||||
#define SPI_TFT_DC_L OUT_WRITE(TFT_DC_PIN, LOW)
|
||||
#define TFT_DC_H OUT_WRITE(TFT_DC_PIN, HIGH)
|
||||
#define TFT_DC_L OUT_WRITE(TFT_DC_PIN, LOW)
|
||||
|
||||
#define SPI_TFT_RST_H OUT_WRITE(TFT_RST_PIN, HIGH)
|
||||
#define SPI_TFT_RST_L OUT_WRITE(TFT_RST_PIN, LOW)
|
||||
#define TFT_RST_H OUT_WRITE(TFT_RST_PIN, HIGH)
|
||||
#define TFT_RST_L OUT_WRITE(TFT_RST_PIN, LOW)
|
||||
|
||||
#define SPI_TFT_BLK_H OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH)
|
||||
#define SPI_TFT_BLK_L OUT_WRITE(TFT_BACKLIGHT_PIN, LOW)
|
||||
#define TFT_BLK_H OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH)
|
||||
#define TFT_BLK_L OUT_WRITE(TFT_BACKLIGHT_PIN, LOW)
|
||||
|
||||
void TFT_SPI::Init() {
|
||||
#if PIN_EXISTS(TFT_RESET)
|
||||
// OUT_WRITE(TFT_RESET_PIN, HIGH);
|
||||
SPI_TFT_RST_H;
|
||||
TFT_RST_H;
|
||||
delay(100);
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(TFT_BACKLIGHT)
|
||||
// OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
|
||||
SPI_TFT_BLK_H;
|
||||
TFT_BLK_H;
|
||||
#endif
|
||||
|
||||
SPI_TFT_DC_H;
|
||||
SPI_TFT_CS_H;
|
||||
TFT_DC_H;
|
||||
TFT_CS_H;
|
||||
|
||||
/**
|
||||
* STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz
|
||||
@@ -87,7 +87,7 @@ void TFT_SPI::Init() {
|
||||
void TFT_SPI::DataTransferBegin(uint16_t DataSize) {
|
||||
SPIx.setDataSize(DataSize);
|
||||
SPIx.begin();
|
||||
SPI_TFT_CS_L;
|
||||
TFT_CS_L;
|
||||
}
|
||||
|
||||
uint32_t TFT_SPI::GetID() {
|
||||
@@ -103,16 +103,21 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) {
|
||||
#if !PIN_EXISTS(TFT_MISO)
|
||||
return 0;
|
||||
#else
|
||||
uint16_t d = 0;
|
||||
uint8_t d = 0;
|
||||
uint32_t data = 0;
|
||||
SPIx.setClockDivider(SPI_CLOCK_DIV16);
|
||||
DataTransferBegin(DATASIZE_8BIT);
|
||||
WriteReg(Reg);
|
||||
|
||||
SPI.read((uint8_t*)&d, 1); //dummy read
|
||||
SPI.read((uint8_t*)&d, 1);
|
||||
LOOP_L_N(i, 4) {
|
||||
SPIx.read((uint8_t*)&d, 1);
|
||||
data = (data << 8) | d;
|
||||
}
|
||||
|
||||
DataTransferEnd();
|
||||
SPIx.setClockDivider(SPI_CLOCK_MAX);
|
||||
|
||||
return d >> 7;
|
||||
return data >> 7;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -130,7 +135,7 @@ void TFT_SPI::Transmit(uint16_t Data) {
|
||||
|
||||
void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
|
||||
DataTransferBegin();
|
||||
SPI_TFT_DC_H;
|
||||
TFT_DC_H;
|
||||
if (MemoryIncrease == DMA_MINC_ENABLE) {
|
||||
SPIx.dmaSend(Data, Count, true);
|
||||
}
|
||||
|
||||
@@ -62,4 +62,11 @@ public:
|
||||
|
||||
static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); }
|
||||
static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
|
||||
static void WriteMultiple(uint16_t Color, uint32_t Count) {
|
||||
static uint16_t Data; Data = Color;
|
||||
while (Count > 0) {
|
||||
TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count);
|
||||
Count = Count > 0xFFFF ? Count - 0xFFFF : 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_TFT_XPT2046
|
||||
#if HAS_TFT_XPT2046 || HAS_TOUCH_XPT2046
|
||||
|
||||
#include "xpt2046.h"
|
||||
#include <SPI.h>
|
||||
|
||||
@@ -24,16 +24,18 @@
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
#if !PIN_EXISTS(TOUCH_MISO)
|
||||
#error "TOUCH_MISO_PIN is not defined."
|
||||
#elif !PIN_EXISTS(TOUCH_MOSI)
|
||||
#error "TOUCH_MOSI_PIN is not defined."
|
||||
#elif !PIN_EXISTS(TOUCH_SCK)
|
||||
#error "TOUCH_SCK_PIN is not defined."
|
||||
#elif !PIN_EXISTS(TOUCH_CS)
|
||||
#error "TOUCH_CS_PIN is not defined."
|
||||
#ifndef TOUCH_MISO_PIN
|
||||
#define TOUCH_MISO_PIN MISO_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_MOSI_PIN
|
||||
#define TOUCH_MOSI_PIN MOSI_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_SCK_PIN
|
||||
#define TOUCH_SCK_PIN SCK_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_CS_PIN
|
||||
#define TOUCH_CS_PIN CS_PIN
|
||||
#endif
|
||||
|
||||
#ifndef TOUCH_INT_PIN
|
||||
#define TOUCH_INT_PIN -1
|
||||
#endif
|
||||
|
||||
@@ -46,24 +46,16 @@
|
||||
// Serial override
|
||||
//extern HalSerial usb_serial;
|
||||
|
||||
#define _MSERIAL(X) SerialUART##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
#define SerialUART0 Serial1
|
||||
|
||||
#if defined(STM32F4) && SERIAL_PORT == 0
|
||||
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif SERIAL_PORT == -1
|
||||
#define MYSERIAL0 SerialUSB
|
||||
#elif SERIAL_PORT == 0
|
||||
#define MYSERIAL0 Serial1
|
||||
#elif SERIAL_PORT == 1
|
||||
#define MYSERIAL0 SerialUART1
|
||||
#elif SERIAL_PORT == 2
|
||||
#define MYSERIAL0 SerialUART2
|
||||
#elif SERIAL_PORT == 3
|
||||
#define MYSERIAL0 SerialUART3
|
||||
#elif SERIAL_PORT == 4
|
||||
#define MYSERIAL0 SerialUART4
|
||||
#elif SERIAL_PORT == 5
|
||||
#define MYSERIAL0 SerialUART5
|
||||
#elif SERIAL_PORT == 6
|
||||
#define MYSERIAL0 SerialUART6
|
||||
#elif WITHIN(SERIAL_PORT, 0, 6)
|
||||
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
||||
#endif
|
||||
@@ -71,57 +63,24 @@
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if defined(STM32F4) && SERIAL_PORT_2 == 0
|
||||
#error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == SERIAL_PORT
|
||||
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL1 SerialUSB
|
||||
#elif SERIAL_PORT_2 == 0
|
||||
#define MYSERIAL1 Serial1
|
||||
#elif SERIAL_PORT_2 == 1
|
||||
#define MYSERIAL1 SerialUART1
|
||||
#elif SERIAL_PORT_2 == 2
|
||||
#define MYSERIAL1 SerialUART2
|
||||
#elif SERIAL_PORT_2 == 3
|
||||
#define MYSERIAL1 SerialUART3
|
||||
#elif SERIAL_PORT_2 == 4
|
||||
#define MYSERIAL1 SerialUART4
|
||||
#elif SERIAL_PORT_2 == 5
|
||||
#define MYSERIAL1 SerialUART5
|
||||
#elif SERIAL_PORT_2 == 6
|
||||
#define MYSERIAL1 SerialUART6
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 6)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
|
||||
#endif
|
||||
#define NUM_SERIAL 2
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#if defined(STM32F4) && DGUS_SERIAL_PORT == 0
|
||||
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == SERIAL_PORT
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
||||
#elif DGUS_SERIAL_PORT == -1
|
||||
#define DGUS_SERIAL SerialUSB
|
||||
#elif DGUS_SERIAL_PORT == 0
|
||||
#define DGUS_SERIAL Serial1
|
||||
#elif DGUS_SERIAL_PORT == 1
|
||||
#define DGUS_SERIAL SerialUART1
|
||||
#elif DGUS_SERIAL_PORT == 2
|
||||
#define DGUS_SERIAL SerialUART2
|
||||
#elif DGUS_SERIAL_PORT == 3
|
||||
#define DGUS_SERIAL SerialUART3
|
||||
#elif DGUS_SERIAL_PORT == 4
|
||||
#define DGUS_SERIAL SerialUART4
|
||||
#elif DGUS_SERIAL_PORT == 5
|
||||
#define DGUS_SERIAL SerialUART5
|
||||
#elif DGUS_SERIAL_PORT == 6
|
||||
#define DGUS_SERIAL SerialUART6
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if defined(STM32F4) && LCD_SERIAL_PORT == 0
|
||||
#error "LCD_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||
#elif LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL SerialUSB
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 6)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
||||
#error "LCD_SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user