From 77e8b3166fe5ad86b286d3fc01389c55a6e24fc0 Mon Sep 17 00:00:00 2001 From: Malte Reents Date: Sun, 19 May 2024 11:44:44 +0200 Subject: [PATCH] src folder --- src/MarlinCore.cpp | 1668 +++++++++ src/MarlinCore.h | 86 + src/pins/esp32/env_validate.h | 26 + src/pins/esp32/pins_E4D.h | 103 + src/pins/esp32/pins_ENWI_ESPNP.h | 118 + src/pins/esp32/pins_ESP32.h | 86 + src/pins/esp32/pins_ESPA_common.h | 81 + src/pins/esp32/pins_FYSETC_E4.h | 72 + src/pins/esp32/pins_MKS_TINYBEE.h | 193 ++ src/pins/esp32/pins_MRR_ESPA.h | 58 + src/pins/esp32/pins_MRR_ESPE.h | 164 + src/pins/esp32/pins_PANDA_M4.h | 38 + src/pins/esp32/pins_PANDA_ZHU.h | 61 + src/pins/esp32/pins_PANDA_common.h | 128 + src/pins/esp32/pins_RESP32_CUSTOM.h | 37 + src/pins/linux/pins_RAMPS_LINUX.h | 698 ++++ src/pins/lpc1768/env_validate.h | 30 + src/pins/lpc1768/pins_AZSMZ_MINI.h | 159 + src/pins/lpc1768/pins_BIQU_B300_V1.0.h | 180 + src/pins/lpc1768/pins_BIQU_BQ111_A4.h | 149 + src/pins/lpc1768/pins_BTT_SKR_V1_1.h | 255 ++ src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 486 +++ src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 512 +++ src/pins/lpc1768/pins_BTT_SKR_common.h | 209 ++ src/pins/lpc1768/pins_EMOTRONIC.h | 149 + src/pins/lpc1768/pins_GMARSH_X6_REV1.h | 174 + src/pins/lpc1768/pins_MKS_SBASE.h | 387 +++ src/pins/lpc1768/pins_MKS_SGEN_L.h | 416 +++ src/pins/lpc1768/pins_RAMPS_RE_ARM.h | 495 +++ src/pins/lpc1768/pins_SELENA_COMPACT.h | 116 + src/pins/lpc1769/env_validate.h | 26 + src/pins/lpc1769/pins_AZTEEG_X5_GT.h | 124 + src/pins/lpc1769/pins_AZTEEG_X5_MINI.h | 211 ++ src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h | 42 + src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h | 291 ++ src/pins/lpc1769/pins_BTT_SKR_V1_4_TURBO.h | 34 + src/pins/lpc1769/pins_COHESION3D_MINI.h | 175 + src/pins/lpc1769/pins_COHESION3D_REMIX.h | 286 ++ src/pins/lpc1769/pins_FLY_CDY.h | 183 + src/pins/lpc1769/pins_MKS_SGEN.h | 58 + src/pins/lpc1769/pins_MKS_SGEN_L_V2.h | 453 +++ src/pins/lpc1769/pins_SMOOTHIEBOARD.h | 179 + src/pins/lpc1769/pins_TH3D_EZBOARD.h | 227 ++ src/pins/mega/env_validate.h | 32 + src/pins/mega/pins_CHEAPTRONIC.h | 78 + src/pins/mega/pins_CHEAPTRONICv2.h | 138 + src/pins/mega/pins_CNCONTROLS_11.h | 162 + src/pins/mega/pins_CNCONTROLS_12.h | 169 + src/pins/mega/pins_CNCONTROLS_15.h | 126 + src/pins/mega/pins_EINSTART-S.h | 112 + src/pins/mega/pins_ELEFU_3.h | 150 + src/pins/mega/pins_GT2560_REV_A.h | 169 + src/pins/mega/pins_GT2560_REV_A_PLUS.h | 34 + src/pins/mega/pins_GT2560_REV_B.h | 30 + src/pins/mega/pins_GT2560_V3.h | 217 ++ src/pins/mega/pins_GT2560_V3_A20.h | 41 + src/pins/mega/pins_GT2560_V3_MC2.h | 35 + src/pins/mega/pins_GT2560_V4.h | 30 + src/pins/mega/pins_GT2560_V4_A20.h | 43 + src/pins/mega/pins_HJC2560C_REV2.h | 171 + src/pins/mega/pins_INTAMSYS40.h | 149 + src/pins/mega/pins_LEAPFROG.h | 91 + src/pins/mega/pins_LEAPFROG_XEED2015.h | 113 + src/pins/mega/pins_MALYAN_M180.h | 100 + src/pins/mega/pins_MEGACONTROLLER.h | 164 + src/pins/mega/pins_MEGATRONICS.h | 132 + src/pins/mega/pins_MEGATRONICS_2.h | 153 + src/pins/mega/pins_MEGATRONICS_3.h | 193 ++ src/pins/mega/pins_MIGHTYBOARD_REVE.h | 278 ++ src/pins/mega/pins_MINITRONICS.h | 142 + src/pins/mega/pins_OVERLORD.h | 144 + src/pins/mega/pins_PICA.h | 153 + src/pins/mega/pins_PICAOLD.h | 29 + src/pins/mega/pins_PROTONEER_CNC_SHIELD_V3.h | 77 + src/pins/mega/pins_SILVER_GATE.h | 102 + src/pins/mega/pins_WANHAO_ONEPLUS.h | 109 + src/pins/mega/pins_WEEDO_62A.h | 106 + src/pins/pins.h | 903 +++++ src/pins/pinsDebug.h | 293 ++ src/pins/pinsDebug_list.h | 1796 ++++++++++ src/pins/pins_postprocess.h | 1435 ++++++++ src/pins/rambo/env_validate.h | 26 + src/pins/rambo/pins_EINSY_RAMBO.h | 216 ++ src/pins/rambo/pins_EINSY_RETRO.h | 210 ++ src/pins/rambo/pins_MINIRAMBO.h | 202 ++ src/pins/rambo/pins_RAMBO.h | 280 ++ src/pins/rambo/pins_RAMBO_THINKERV2.h | 60 + src/pins/rambo/pins_SCOOVO_X9H.h | 158 + src/pins/ramps/env_validate.h | 35 + src/pins/ramps/pins_3DRAG.h | 173 + src/pins/ramps/pins_AZTEEG_X3.h | 97 + src/pins/ramps/pins_AZTEEG_X3_PRO.h | 178 + src/pins/ramps/pins_BAM_DICE_DUE.h | 47 + src/pins/ramps/pins_BIQU_KFB_2.h | 40 + src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h | 126 + src/pins/ramps/pins_COPYMASTER_3D.h | 34 + src/pins/ramps/pins_DAGOMA_F5.h | 66 + src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h | 183 + src/pins/ramps/pins_FELIX2.h | 63 + src/pins/ramps/pins_FORMBOT_RAPTOR.h | 181 + src/pins/ramps/pins_FORMBOT_RAPTOR2.h | 74 + src/pins/ramps/pins_FORMBOT_TREX2PLUS.h | 189 ++ src/pins/ramps/pins_FORMBOT_TREX3.h | 187 + src/pins/ramps/pins_FYSETC_F6_13.h | 301 ++ src/pins/ramps/pins_FYSETC_F6_14.h | 55 + src/pins/ramps/pins_K8200.h | 33 + src/pins/ramps/pins_K8400.h | 66 + src/pins/ramps/pins_K8600.h | 100 + src/pins/ramps/pins_K8800.h | 116 + src/pins/ramps/pins_LONGER3D_LKx_PRO.h | 121 + src/pins/ramps/pins_MAKEBOARD_MINI.h | 33 + src/pins/ramps/pins_MKS_BASE_10.h | 37 + src/pins/ramps/pins_MKS_BASE_14.h | 170 + src/pins/ramps/pins_MKS_BASE_15.h | 35 + src/pins/ramps/pins_MKS_BASE_16.h | 59 + src/pins/ramps/pins_MKS_BASE_HEROIC.h | 36 + src/pins/ramps/pins_MKS_BASE_common.h | 75 + src/pins/ramps/pins_MKS_GEN_13.h | 130 + src/pins/ramps/pins_MKS_GEN_L.h | 59 + src/pins/ramps/pins_MKS_GEN_L_V2.h | 89 + src/pins/ramps/pins_MKS_GEN_L_V21.h | 85 + src/pins/ramps/pins_ORTUR_4.h | 105 + src/pins/ramps/pins_PXMALION_CORE_I3.h | 86 + src/pins/ramps/pins_RAMPS.h | 916 +++++ src/pins/ramps/pins_RAMPS_13.h | 42 + src/pins/ramps/pins_RAMPS_CREALITY.h | 72 + src/pins/ramps/pins_RAMPS_ENDER_4.h | 41 + src/pins/ramps/pins_RAMPS_OLD.h | 117 + src/pins/ramps/pins_RAMPS_PLUS.h | 94 + src/pins/ramps/pins_RAMPS_S_12.h | 280 ++ src/pins/ramps/pins_RIGIDBOARD.h | 129 + src/pins/ramps/pins_RIGIDBOARD_V2.h | 52 + src/pins/ramps/pins_RL200.h | 52 + src/pins/ramps/pins_RUMBA.h | 250 ++ src/pins/ramps/pins_RUMBA_RAISE3D.h | 31 + src/pins/ramps/pins_SAINSMART_2IN1.h | 42 + src/pins/ramps/pins_TANGO.h | 53 + src/pins/ramps/pins_TENLOG_D3_HERO.h | 187 + src/pins/ramps/pins_TRIGORILLA_13.h | 43 + src/pins/ramps/pins_TRIGORILLA_14.h | 147 + src/pins/ramps/pins_TRONXY_V3_1_0.h | 280 ++ src/pins/ramps/pins_TT_OSCAR.h | 509 +++ src/pins/ramps/pins_ULTIMAIN_2.h | 141 + src/pins/ramps/pins_ULTIMAKER.h | 166 + src/pins/ramps/pins_ULTIMAKER_OLD.h | 272 ++ src/pins/ramps/pins_VORON.h | 55 + src/pins/ramps/pins_ZRIB_V20.h | 87 + src/pins/ramps/pins_ZRIB_V52.h | 159 + src/pins/ramps/pins_ZRIB_V53.h | 511 +++ src/pins/ramps/pins_Z_BOLT_X_SERIES.h | 303 ++ src/pins/sam/env_validate.h | 33 + src/pins/sam/pins_ADSK.h | 207 ++ src/pins/sam/pins_ALLIGATOR_R2.h | 157 + src/pins/sam/pins_ARCHIM1.h | 205 ++ src/pins/sam/pins_ARCHIM2.h | 262 ++ src/pins/sam/pins_CNCONTROLS_15D.h | 137 + src/pins/sam/pins_DUE3DOM.h | 171 + src/pins/sam/pins_DUE3DOM_MINI.h | 172 + src/pins/sam/pins_KRATOS32.h | 179 + src/pins/sam/pins_PRINTRBOARD_G2.h | 171 + src/pins/sam/pins_RADDS.h | 296 ++ src/pins/sam/pins_RAMPS4DUE.h | 52 + src/pins/sam/pins_RAMPS_DUO.h | 131 + src/pins/sam/pins_RAMPS_FD_V1.h | 264 ++ src/pins/sam/pins_RAMPS_FD_V2.h | 52 + src/pins/sam/pins_RAMPS_SMART.h | 142 + src/pins/sam/pins_RURAMPS4D_11.h | 292 ++ src/pins/sam/pins_RURAMPS4D_13.h | 277 ++ src/pins/sam/pins_ULTRATRONICS_PRO.h | 176 + src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h | 616 ++++ src/pins/samd/pins_BRICOLEMON_V1_0.h | 676 ++++ src/pins/samd/pins_RAMPS_144.h | 571 ++++ src/pins/sanguino/env_validate.h | 42 + src/pins/sanguino/pins_ANET_10.h | 305 ++ src/pins/sanguino/pins_AZTEEG_X1.h | 30 + src/pins/sanguino/pins_GEN3_MONOLITHIC.h | 98 + src/pins/sanguino/pins_GEN3_PLUS.h | 98 + src/pins/sanguino/pins_GEN6.h | 120 + src/pins/sanguino/pins_GEN6_DELUXE.h | 54 + src/pins/sanguino/pins_GEN7_12.h | 146 + src/pins/sanguino/pins_GEN7_13.h | 54 + src/pins/sanguino/pins_GEN7_14.h | 119 + src/pins/sanguino/pins_GEN7_CUSTOM.h | 139 + src/pins/sanguino/pins_MELZI.h | 47 + src/pins/sanguino/pins_MELZI_CREALITY.h | 141 + src/pins/sanguino/pins_MELZI_MAKR3D.h | 29 + src/pins/sanguino/pins_MELZI_MALYAN.h | 45 + src/pins/sanguino/pins_MELZI_TRONXY.h | 60 + src/pins/sanguino/pins_MELZI_V2.h | 37 + src/pins/sanguino/pins_OMCA.h | 149 + src/pins/sanguino/pins_OMCA_A.h | 135 + src/pins/sanguino/pins_SANGUINOLOLU_11.h | 316 ++ src/pins/sanguino/pins_SANGUINOLOLU_12.h | 42 + src/pins/sanguino/pins_SETHI.h | 123 + src/pins/sanguino/pins_STB_11.h | 30 + src/pins/sanguino/pins_ZMIB_V2.h | 232 ++ src/pins/sensitive_pins.h | 896 +++++ src/pins/stm32f0/pins_MALYAN_M200_V2.h | 30 + src/pins/stm32f0/pins_MALYAN_M300.h | 90 + src/pins/stm32f1/env_validate.h | 32 + src/pins/stm32f1/pins_BEAST.h | 145 + src/pins/stm32f1/pins_BTT_SKR_CR6.h | 186 + src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h | 292 ++ src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h | 51 + src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h | 50 + src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h | 84 + .../stm32f1/pins_BTT_SKR_MINI_E3_common.h | 386 +++ src/pins/stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h | 26 + src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h | 257 ++ src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h | 185 + src/pins/stm32f1/pins_CHITU3D.h | 265 ++ src/pins/stm32f1/pins_CHITU3D_V5.h | 28 + src/pins/stm32f1/pins_CHITU3D_V6.h | 34 + src/pins/stm32f1/pins_CHITU3D_V9.h | 40 + src/pins/stm32f1/pins_CHITU3D_common.h | 177 + src/pins/stm32f1/pins_CREALITY_V24S1.h | 36 + src/pins/stm32f1/pins_CREALITY_V24S1_301.h | 94 + src/pins/stm32f1/pins_CREALITY_V25S1.h | 152 + src/pins/stm32f1/pins_CREALITY_V4.h | 251 ++ src/pins/stm32f1/pins_CREALITY_V4210.h | 227 ++ src/pins/stm32f1/pins_CREALITY_V422.h | 31 + src/pins/stm32f1/pins_CREALITY_V423.h | 44 + src/pins/stm32f1/pins_CREALITY_V425.h | 77 + src/pins/stm32f1/pins_CREALITY_V427.h | 45 + src/pins/stm32f1/pins_CREALITY_V431.h | 51 + src/pins/stm32f1/pins_CREALITY_V452.h | 44 + src/pins/stm32f1/pins_CREALITY_V453.h | 44 + src/pins/stm32f1/pins_CREALITY_V45x.h | 114 + src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h | 196 ++ src/pins/stm32f1/pins_FLSUN_HISPEED.h | 328 ++ src/pins/stm32f1/pins_FLY_MINI.h | 190 ++ src/pins/stm32f1/pins_FYSETC_AIO_II.h | 207 ++ src/pins/stm32f1/pins_FYSETC_CHEETAH.h | 200 ++ src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h | 59 + src/pins/stm32f1/pins_GTM32_MINI.h | 235 ++ src/pins/stm32f1/pins_GTM32_MINI_A30.h | 229 ++ src/pins/stm32f1/pins_GTM32_PRO_VB.h | 240 ++ src/pins/stm32f1/pins_GTM32_PRO_VD.h | 30 + src/pins/stm32f1/pins_GTM32_REV_B.h | 232 ++ src/pins/stm32f1/pins_JGAURORA_A5S_A1.h | 147 + src/pins/stm32f1/pins_LONGER3D_LK.h | 212 ++ src/pins/stm32f1/pins_MALYAN_M200.h | 95 + src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h | 161 + src/pins/stm32f1/pins_MKS_ROBIN.h | 282 ++ src/pins/stm32f1/pins_MKS_ROBIN_E3.h | 36 + src/pins/stm32f1/pins_MKS_ROBIN_E3D.h | 67 + src/pins/stm32f1/pins_MKS_ROBIN_E3D_V1_1.h | 67 + src/pins/stm32f1/pins_MKS_ROBIN_E3P.h | 395 +++ src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1.h | 36 + .../stm32f1/pins_MKS_ROBIN_E3_V1_1_common.h | 39 + src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h | 265 ++ src/pins/stm32f1/pins_MKS_ROBIN_LITE.h | 175 + src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h | 159 + src/pins/stm32f1/pins_MKS_ROBIN_MINI.h | 206 ++ src/pins/stm32f1/pins_MKS_ROBIN_NANO.h | 51 + src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 395 +++ src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h | 211 ++ src/pins/stm32f1/pins_MKS_ROBIN_PRO.h | 318 ++ src/pins/stm32f1/pins_MORPHEUS.h | 93 + src/pins/stm32f1/pins_PANDA_PI_V29.h | 224 ++ src/pins/stm32f1/pins_STM32F1R.h | 138 + src/pins/stm32f1/pins_STM3R_MINI.h | 159 + src/pins/stm32f1/pins_TRIGORILLA_PRO.h | 208 ++ src/pins/stm32f1/pins_ZM3E2_V1_0.h | 235 ++ src/pins/stm32f1/pins_ZM3E4_V1_0.h | 356 ++ src/pins/stm32f1/pins_ZM3E4_V2_0.h | 329 ++ src/pins/stm32f4/env_validate.h | 28 + src/pins/stm32f4/pins_ANET_ET4.h | 218 ++ src/pins/stm32f4/pins_ANET_ET4P.h | 33 + src/pins/stm32f4/pins_ARMED.h | 228 ++ src/pins/stm32f4/pins_ARTILLERY_RUBY.h | 184 + src/pins/stm32f4/pins_BLACK_STM32F407VE.h | 156 + src/pins/stm32f4/pins_BTT_BTT002_V1_0.h | 336 ++ src/pins/stm32f4/pins_BTT_E3_RRF.h | 420 +++ src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 494 +++ src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h | 44 + src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h | 35 + src/pins/stm32f4/pins_BTT_OCTOPUS_V1_1.h | 35 + src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h | 545 +++ src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h | 30 + src/pins/stm32f4/pins_BTT_SKR_PRO_V1_2.h | 30 + src/pins/stm32f4/pins_BTT_SKR_PRO_common.h | 568 ++++ src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_A.h | 29 + src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_B.h | 26 + src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h | 580 ++++ src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h | 38 + src/pins/stm32f4/pins_FLYF407ZG.h | 312 ++ src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h | 259 ++ src/pins/stm32f4/pins_FYSETC_S6.h | 340 ++ src/pins/stm32f4/pins_FYSETC_S6_V2_0.h | 71 + src/pins/stm32f4/pins_FYSETC_SPIDER.h | 123 + src/pins/stm32f4/pins_FYSETC_SPIDER_V2_2.h | 34 + src/pins/stm32f4/pins_LERDGE_K.h | 272 ++ src/pins/stm32f4/pins_LERDGE_S.h | 232 ++ src/pins/stm32f4/pins_LERDGE_X.h | 175 + src/pins/stm32f4/pins_MKS_EAGLE.h | 35 + src/pins/stm32f4/pins_MKS_MONSTER8_V1.h | 51 + src/pins/stm32f4/pins_MKS_MONSTER8_V2.h | 57 + src/pins/stm32f4/pins_MKS_MONSTER8_common.h | 368 ++ src/pins/stm32f4/pins_MKS_ROBIN2.h | 101 + .../stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h | 45 + src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h | 72 + .../stm32f4/pins_MKS_ROBIN_NANO_V3_common.h | 391 +++ src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 378 +++ src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h | 206 ++ src/pins/stm32f4/pins_RUMBA32_AUS3D.h | 77 + src/pins/stm32f4/pins_RUMBA32_BTT.h | 67 + src/pins/stm32f4/pins_RUMBA32_MKS.h | 87 + src/pins/stm32f4/pins_RUMBA32_common.h | 179 + src/pins/stm32f4/pins_STEVAL_3DP001V1.h | 325 ++ src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h | 275 ++ src/pins/stm32f4/pins_VAKE403D.h | 226 ++ src/pins/stm32f7/pins_NUCLEO_F767ZI.h | 197 ++ src/pins/stm32f7/pins_REMRAM_V1.h | 136 + src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h | 439 +++ src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h | 28 + src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h | 26 + src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h | 234 ++ src/pins/stm32h7/pins_BTT_SKR_V3_0.h | 26 + src/pins/stm32h7/pins_BTT_SKR_V3_0_EZ.h | 26 + src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h | 569 ++++ src/pins/teensy2/env_validate.h | 28 + src/pins/teensy2/pins_5DPRINT.h | 146 + src/pins/teensy2/pins_BRAINWAVE.h | 126 + src/pins/teensy2/pins_BRAINWAVE_PRO.h | 136 + src/pins/teensy2/pins_PRINTRBOARD.h | 170 + src/pins/teensy2/pins_PRINTRBOARD_REVF.h | 280 ++ src/pins/teensy2/pins_SAV_MKI.h | 183 + src/pins/teensy2/pins_TEENSY2.h | 186 + src/pins/teensy2/pins_TEENSYLU.h | 168 + src/pins/teensy3/pins_TEENSY31_32.h | 112 + src/pins/teensy3/pins_TEENSY35_36.h | 152 + src/pins/teensy4/pins_T41U5XBB.h | 126 + src/pins/teensy4/pins_TEENSY41.h | 131 + src/sd/Sd2Card.cpp | 681 ++++ src/sd/Sd2Card.h | 197 ++ src/sd/Sd2Card_sdio.h | 59 + src/sd/SdBaseFile.cpp | 2236 ++++++++++++ src/sd/SdBaseFile.h | 402 +++ src/sd/SdFatConfig.h | 112 + src/sd/SdFatStructs.h | 609 ++++ src/sd/SdFatUtil.cpp | 62 + src/sd/SdFatUtil.h | 42 + src/sd/SdFile.cpp | 102 + src/sd/SdFile.h | 55 + src/sd/SdInfo.h | 265 ++ src/sd/SdVolume.cpp | 405 +++ src/sd/SdVolume.h | 201 ++ src/sd/cardreader.cpp | 1343 ++++++++ src/sd/cardreader.h | 388 +++ src/sd/disk_io_driver.h | 67 + src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 328 ++ src/sd/usb_flashdrive/Sd2Card_FlashDrive.h | 80 + src/sd/usb_flashdrive/lib-uhs2/README.txt | 43 + src/sd/usb_flashdrive/lib-uhs2/Usb.cpp | 795 +++++ src/sd/usb_flashdrive/lib-uhs2/Usb.h | 53 + src/sd/usb_flashdrive/lib-uhs2/UsbCore.h | 312 ++ src/sd/usb_flashdrive/lib-uhs2/address.h | 271 ++ .../usb_flashdrive/lib-uhs2/confdescparser.h | 201 ++ src/sd/usb_flashdrive/lib-uhs2/hexdump.h | 68 + src/sd/usb_flashdrive/lib-uhs2/macros.h | 86 + src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp | 1209 +++++++ src/sd/usb_flashdrive/lib-uhs2/masstorage.h | 559 +++ src/sd/usb_flashdrive/lib-uhs2/max3421e.h | 242 ++ src/sd/usb_flashdrive/lib-uhs2/message.cpp | 128 + src/sd/usb_flashdrive/lib-uhs2/message.h | 85 + src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp | 77 + src/sd/usb_flashdrive/lib-uhs2/parsetools.h | 145 + src/sd/usb_flashdrive/lib-uhs2/printhex.h | 80 + src/sd/usb_flashdrive/lib-uhs2/settings.h | 236 ++ src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h | 170 + src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp | 206 ++ src/sd/usb_flashdrive/lib-uhs2/usbhost.h | 58 + src/sd/usb_flashdrive/lib-uhs3/README.txt | 29 + .../UHS_BULK_STORAGE/UHS_BULK_STORAGE.h | 249 ++ .../UHS_BULK_STORAGE_INLINE.h | 1205 +++++++ .../UHS_host/UHS_BULK_STORAGE/UHS_SCSI.h | 327 ++ .../lib-uhs3/UHS_host/UHS_UNOFFICIAL_IDs.h | 33 + .../lib-uhs3/UHS_host/UHS_USB_IDs.h | 2993 +++++++++++++++++ .../lib-uhs3/UHS_host/UHS_UsbCore.h | 336 ++ .../lib-uhs3/UHS_host/UHS_address.h | 248 ++ .../lib-uhs3/UHS_host/UHS_hexdump.h | 70 + .../lib-uhs3/UHS_host/UHS_host.h | 111 + .../lib-uhs3/UHS_host/UHS_host_INLINE.h | 1222 +++++++ .../lib-uhs3/UHS_host/UHS_macros.h | 230 ++ .../lib-uhs3/UHS_host/UHS_message.h | 91 + .../lib-uhs3/UHS_host/UHS_printf_HELPER.h | 200 ++ .../lib-uhs3/UHS_host/UHS_printhex.h | 96 + .../lib-uhs3/UHS_host/UHS_settings.h | 141 + .../lib-uhs3/UHS_host/UHS_usb_ch9.h | 222 ++ .../lib-uhs3/UHS_host/UHS_usbhost.h | 449 +++ .../lib-uhs3/UHS_host/UHS_util_INLINE.h | 129 + .../UHS_host/USB_HOST_SHIELD/UHS_max3421e.h | 226 ++ .../USB_HOST_SHIELD/USB_HOST_SHIELD.h | 519 +++ .../USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h | 1003 ++++++ .../lib-uhs3/UHS_host/macro_logic.h | 152 + .../lib-uhs3/dyn_SWI/SWI_INLINE.h | 244 ++ .../usb_flashdrive/lib-uhs3/dyn_SWI/dyn_SWI.h | 172 + 398 files changed, 82963 insertions(+) create mode 100644 src/MarlinCore.cpp create mode 100644 src/MarlinCore.h create mode 100644 src/pins/esp32/env_validate.h create mode 100644 src/pins/esp32/pins_E4D.h create mode 100644 src/pins/esp32/pins_ENWI_ESPNP.h create mode 100644 src/pins/esp32/pins_ESP32.h create mode 100644 src/pins/esp32/pins_ESPA_common.h create mode 100644 src/pins/esp32/pins_FYSETC_E4.h create mode 100644 src/pins/esp32/pins_MKS_TINYBEE.h create mode 100644 src/pins/esp32/pins_MRR_ESPA.h create mode 100644 src/pins/esp32/pins_MRR_ESPE.h create mode 100644 src/pins/esp32/pins_PANDA_M4.h create mode 100644 src/pins/esp32/pins_PANDA_ZHU.h create mode 100644 src/pins/esp32/pins_PANDA_common.h create mode 100644 src/pins/esp32/pins_RESP32_CUSTOM.h create mode 100644 src/pins/linux/pins_RAMPS_LINUX.h create mode 100644 src/pins/lpc1768/env_validate.h create mode 100644 src/pins/lpc1768/pins_AZSMZ_MINI.h create mode 100644 src/pins/lpc1768/pins_BIQU_B300_V1.0.h create mode 100644 src/pins/lpc1768/pins_BIQU_BQ111_A4.h create mode 100644 src/pins/lpc1768/pins_BTT_SKR_V1_1.h create mode 100644 src/pins/lpc1768/pins_BTT_SKR_V1_3.h create mode 100644 src/pins/lpc1768/pins_BTT_SKR_V1_4.h create mode 100644 src/pins/lpc1768/pins_BTT_SKR_common.h create mode 100644 src/pins/lpc1768/pins_EMOTRONIC.h create mode 100644 src/pins/lpc1768/pins_GMARSH_X6_REV1.h create mode 100644 src/pins/lpc1768/pins_MKS_SBASE.h create mode 100644 src/pins/lpc1768/pins_MKS_SGEN_L.h create mode 100644 src/pins/lpc1768/pins_RAMPS_RE_ARM.h create mode 100644 src/pins/lpc1768/pins_SELENA_COMPACT.h create mode 100644 src/pins/lpc1769/env_validate.h create mode 100644 src/pins/lpc1769/pins_AZTEEG_X5_GT.h create mode 100644 src/pins/lpc1769/pins_AZTEEG_X5_MINI.h create mode 100644 src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h create mode 100644 src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h create mode 100644 src/pins/lpc1769/pins_BTT_SKR_V1_4_TURBO.h create mode 100644 src/pins/lpc1769/pins_COHESION3D_MINI.h create mode 100644 src/pins/lpc1769/pins_COHESION3D_REMIX.h create mode 100644 src/pins/lpc1769/pins_FLY_CDY.h create mode 100644 src/pins/lpc1769/pins_MKS_SGEN.h create mode 100644 src/pins/lpc1769/pins_MKS_SGEN_L_V2.h create mode 100644 src/pins/lpc1769/pins_SMOOTHIEBOARD.h create mode 100644 src/pins/lpc1769/pins_TH3D_EZBOARD.h create mode 100644 src/pins/mega/env_validate.h create mode 100644 src/pins/mega/pins_CHEAPTRONIC.h create mode 100644 src/pins/mega/pins_CHEAPTRONICv2.h create mode 100644 src/pins/mega/pins_CNCONTROLS_11.h create mode 100644 src/pins/mega/pins_CNCONTROLS_12.h create mode 100644 src/pins/mega/pins_CNCONTROLS_15.h create mode 100644 src/pins/mega/pins_EINSTART-S.h create mode 100644 src/pins/mega/pins_ELEFU_3.h create mode 100644 src/pins/mega/pins_GT2560_REV_A.h create mode 100644 src/pins/mega/pins_GT2560_REV_A_PLUS.h create mode 100644 src/pins/mega/pins_GT2560_REV_B.h create mode 100644 src/pins/mega/pins_GT2560_V3.h create mode 100644 src/pins/mega/pins_GT2560_V3_A20.h create mode 100644 src/pins/mega/pins_GT2560_V3_MC2.h create mode 100644 src/pins/mega/pins_GT2560_V4.h create mode 100644 src/pins/mega/pins_GT2560_V4_A20.h create mode 100644 src/pins/mega/pins_HJC2560C_REV2.h create mode 100644 src/pins/mega/pins_INTAMSYS40.h create mode 100644 src/pins/mega/pins_LEAPFROG.h create mode 100644 src/pins/mega/pins_LEAPFROG_XEED2015.h create mode 100644 src/pins/mega/pins_MALYAN_M180.h create mode 100644 src/pins/mega/pins_MEGACONTROLLER.h create mode 100644 src/pins/mega/pins_MEGATRONICS.h create mode 100644 src/pins/mega/pins_MEGATRONICS_2.h create mode 100644 src/pins/mega/pins_MEGATRONICS_3.h create mode 100644 src/pins/mega/pins_MIGHTYBOARD_REVE.h create mode 100644 src/pins/mega/pins_MINITRONICS.h create mode 100644 src/pins/mega/pins_OVERLORD.h create mode 100644 src/pins/mega/pins_PICA.h create mode 100644 src/pins/mega/pins_PICAOLD.h create mode 100644 src/pins/mega/pins_PROTONEER_CNC_SHIELD_V3.h create mode 100644 src/pins/mega/pins_SILVER_GATE.h create mode 100644 src/pins/mega/pins_WANHAO_ONEPLUS.h create mode 100644 src/pins/mega/pins_WEEDO_62A.h create mode 100644 src/pins/pins.h create mode 100644 src/pins/pinsDebug.h create mode 100644 src/pins/pinsDebug_list.h create mode 100644 src/pins/pins_postprocess.h create mode 100644 src/pins/rambo/env_validate.h create mode 100644 src/pins/rambo/pins_EINSY_RAMBO.h create mode 100644 src/pins/rambo/pins_EINSY_RETRO.h create mode 100644 src/pins/rambo/pins_MINIRAMBO.h create mode 100644 src/pins/rambo/pins_RAMBO.h create mode 100644 src/pins/rambo/pins_RAMBO_THINKERV2.h create mode 100644 src/pins/rambo/pins_SCOOVO_X9H.h create mode 100644 src/pins/ramps/env_validate.h create mode 100644 src/pins/ramps/pins_3DRAG.h create mode 100644 src/pins/ramps/pins_AZTEEG_X3.h create mode 100644 src/pins/ramps/pins_AZTEEG_X3_PRO.h create mode 100644 src/pins/ramps/pins_BAM_DICE_DUE.h create mode 100644 src/pins/ramps/pins_BIQU_KFB_2.h create mode 100644 src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h create mode 100644 src/pins/ramps/pins_COPYMASTER_3D.h create mode 100644 src/pins/ramps/pins_DAGOMA_F5.h create mode 100644 src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h create mode 100644 src/pins/ramps/pins_FELIX2.h create mode 100644 src/pins/ramps/pins_FORMBOT_RAPTOR.h create mode 100644 src/pins/ramps/pins_FORMBOT_RAPTOR2.h create mode 100644 src/pins/ramps/pins_FORMBOT_TREX2PLUS.h create mode 100644 src/pins/ramps/pins_FORMBOT_TREX3.h create mode 100644 src/pins/ramps/pins_FYSETC_F6_13.h create mode 100644 src/pins/ramps/pins_FYSETC_F6_14.h create mode 100644 src/pins/ramps/pins_K8200.h create mode 100644 src/pins/ramps/pins_K8400.h create mode 100644 src/pins/ramps/pins_K8600.h create mode 100644 src/pins/ramps/pins_K8800.h create mode 100644 src/pins/ramps/pins_LONGER3D_LKx_PRO.h create mode 100644 src/pins/ramps/pins_MAKEBOARD_MINI.h create mode 100644 src/pins/ramps/pins_MKS_BASE_10.h create mode 100644 src/pins/ramps/pins_MKS_BASE_14.h create mode 100644 src/pins/ramps/pins_MKS_BASE_15.h create mode 100644 src/pins/ramps/pins_MKS_BASE_16.h create mode 100644 src/pins/ramps/pins_MKS_BASE_HEROIC.h create mode 100644 src/pins/ramps/pins_MKS_BASE_common.h create mode 100644 src/pins/ramps/pins_MKS_GEN_13.h create mode 100644 src/pins/ramps/pins_MKS_GEN_L.h create mode 100644 src/pins/ramps/pins_MKS_GEN_L_V2.h create mode 100644 src/pins/ramps/pins_MKS_GEN_L_V21.h create mode 100644 src/pins/ramps/pins_ORTUR_4.h create mode 100644 src/pins/ramps/pins_PXMALION_CORE_I3.h create mode 100644 src/pins/ramps/pins_RAMPS.h create mode 100644 src/pins/ramps/pins_RAMPS_13.h create mode 100644 src/pins/ramps/pins_RAMPS_CREALITY.h create mode 100644 src/pins/ramps/pins_RAMPS_ENDER_4.h create mode 100644 src/pins/ramps/pins_RAMPS_OLD.h create mode 100644 src/pins/ramps/pins_RAMPS_PLUS.h create mode 100644 src/pins/ramps/pins_RAMPS_S_12.h create mode 100644 src/pins/ramps/pins_RIGIDBOARD.h create mode 100644 src/pins/ramps/pins_RIGIDBOARD_V2.h create mode 100644 src/pins/ramps/pins_RL200.h create mode 100644 src/pins/ramps/pins_RUMBA.h create mode 100644 src/pins/ramps/pins_RUMBA_RAISE3D.h create mode 100644 src/pins/ramps/pins_SAINSMART_2IN1.h create mode 100644 src/pins/ramps/pins_TANGO.h create mode 100644 src/pins/ramps/pins_TENLOG_D3_HERO.h create mode 100644 src/pins/ramps/pins_TRIGORILLA_13.h create mode 100644 src/pins/ramps/pins_TRIGORILLA_14.h create mode 100644 src/pins/ramps/pins_TRONXY_V3_1_0.h create mode 100644 src/pins/ramps/pins_TT_OSCAR.h create mode 100644 src/pins/ramps/pins_ULTIMAIN_2.h create mode 100644 src/pins/ramps/pins_ULTIMAKER.h create mode 100644 src/pins/ramps/pins_ULTIMAKER_OLD.h create mode 100644 src/pins/ramps/pins_VORON.h create mode 100644 src/pins/ramps/pins_ZRIB_V20.h create mode 100644 src/pins/ramps/pins_ZRIB_V52.h create mode 100644 src/pins/ramps/pins_ZRIB_V53.h create mode 100644 src/pins/ramps/pins_Z_BOLT_X_SERIES.h create mode 100644 src/pins/sam/env_validate.h create mode 100644 src/pins/sam/pins_ADSK.h create mode 100644 src/pins/sam/pins_ALLIGATOR_R2.h create mode 100644 src/pins/sam/pins_ARCHIM1.h create mode 100644 src/pins/sam/pins_ARCHIM2.h create mode 100644 src/pins/sam/pins_CNCONTROLS_15D.h create mode 100644 src/pins/sam/pins_DUE3DOM.h create mode 100644 src/pins/sam/pins_DUE3DOM_MINI.h create mode 100644 src/pins/sam/pins_KRATOS32.h create mode 100644 src/pins/sam/pins_PRINTRBOARD_G2.h create mode 100644 src/pins/sam/pins_RADDS.h create mode 100644 src/pins/sam/pins_RAMPS4DUE.h create mode 100644 src/pins/sam/pins_RAMPS_DUO.h create mode 100644 src/pins/sam/pins_RAMPS_FD_V1.h create mode 100644 src/pins/sam/pins_RAMPS_FD_V2.h create mode 100644 src/pins/sam/pins_RAMPS_SMART.h create mode 100644 src/pins/sam/pins_RURAMPS4D_11.h create mode 100644 src/pins/sam/pins_RURAMPS4D_13.h create mode 100644 src/pins/sam/pins_ULTRATRONICS_PRO.h create mode 100644 src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h create mode 100644 src/pins/samd/pins_BRICOLEMON_V1_0.h create mode 100644 src/pins/samd/pins_RAMPS_144.h create mode 100644 src/pins/sanguino/env_validate.h create mode 100644 src/pins/sanguino/pins_ANET_10.h create mode 100644 src/pins/sanguino/pins_AZTEEG_X1.h create mode 100644 src/pins/sanguino/pins_GEN3_MONOLITHIC.h create mode 100644 src/pins/sanguino/pins_GEN3_PLUS.h create mode 100644 src/pins/sanguino/pins_GEN6.h create mode 100644 src/pins/sanguino/pins_GEN6_DELUXE.h create mode 100644 src/pins/sanguino/pins_GEN7_12.h create mode 100644 src/pins/sanguino/pins_GEN7_13.h create mode 100644 src/pins/sanguino/pins_GEN7_14.h create mode 100644 src/pins/sanguino/pins_GEN7_CUSTOM.h create mode 100644 src/pins/sanguino/pins_MELZI.h create mode 100644 src/pins/sanguino/pins_MELZI_CREALITY.h create mode 100644 src/pins/sanguino/pins_MELZI_MAKR3D.h create mode 100644 src/pins/sanguino/pins_MELZI_MALYAN.h create mode 100644 src/pins/sanguino/pins_MELZI_TRONXY.h create mode 100644 src/pins/sanguino/pins_MELZI_V2.h create mode 100644 src/pins/sanguino/pins_OMCA.h create mode 100644 src/pins/sanguino/pins_OMCA_A.h create mode 100644 src/pins/sanguino/pins_SANGUINOLOLU_11.h create mode 100644 src/pins/sanguino/pins_SANGUINOLOLU_12.h create mode 100644 src/pins/sanguino/pins_SETHI.h create mode 100644 src/pins/sanguino/pins_STB_11.h create mode 100644 src/pins/sanguino/pins_ZMIB_V2.h create mode 100644 src/pins/sensitive_pins.h create mode 100644 src/pins/stm32f0/pins_MALYAN_M200_V2.h create mode 100644 src/pins/stm32f0/pins_MALYAN_M300.h create mode 100644 src/pins/stm32f1/env_validate.h create mode 100644 src/pins/stm32f1/pins_BEAST.h create mode 100644 src/pins/stm32f1/pins_BTT_SKR_CR6.h create mode 100644 src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h create mode 100644 src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h create mode 100644 src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h create mode 100644 src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h create mode 100644 src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h create mode 100644 src/pins/stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h create mode 100644 src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h create mode 100644 src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h create mode 100644 src/pins/stm32f1/pins_CHITU3D.h create mode 100644 src/pins/stm32f1/pins_CHITU3D_V5.h create mode 100644 src/pins/stm32f1/pins_CHITU3D_V6.h create mode 100644 src/pins/stm32f1/pins_CHITU3D_V9.h create mode 100644 src/pins/stm32f1/pins_CHITU3D_common.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V24S1.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V24S1_301.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V25S1.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V4.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V4210.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V422.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V423.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V425.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V427.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V431.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V452.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V453.h create mode 100644 src/pins/stm32f1/pins_CREALITY_V45x.h create mode 100644 src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h create mode 100644 src/pins/stm32f1/pins_FLSUN_HISPEED.h create mode 100644 src/pins/stm32f1/pins_FLY_MINI.h create mode 100644 src/pins/stm32f1/pins_FYSETC_AIO_II.h create mode 100644 src/pins/stm32f1/pins_FYSETC_CHEETAH.h create mode 100644 src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h create mode 100644 src/pins/stm32f1/pins_GTM32_MINI.h create mode 100644 src/pins/stm32f1/pins_GTM32_MINI_A30.h create mode 100644 src/pins/stm32f1/pins_GTM32_PRO_VB.h create mode 100644 src/pins/stm32f1/pins_GTM32_PRO_VD.h create mode 100644 src/pins/stm32f1/pins_GTM32_REV_B.h create mode 100644 src/pins/stm32f1/pins_JGAURORA_A5S_A1.h create mode 100644 src/pins/stm32f1/pins_LONGER3D_LK.h create mode 100644 src/pins/stm32f1/pins_MALYAN_M200.h create mode 100644 src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_E3.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_E3D.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_E3D_V1_1.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_E3P.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1_common.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_LITE.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_MINI.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_NANO.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h create mode 100644 src/pins/stm32f1/pins_MKS_ROBIN_PRO.h create mode 100644 src/pins/stm32f1/pins_MORPHEUS.h create mode 100644 src/pins/stm32f1/pins_PANDA_PI_V29.h create mode 100644 src/pins/stm32f1/pins_STM32F1R.h create mode 100644 src/pins/stm32f1/pins_STM3R_MINI.h create mode 100644 src/pins/stm32f1/pins_TRIGORILLA_PRO.h create mode 100644 src/pins/stm32f1/pins_ZM3E2_V1_0.h create mode 100644 src/pins/stm32f1/pins_ZM3E4_V1_0.h create mode 100644 src/pins/stm32f1/pins_ZM3E4_V2_0.h create mode 100644 src/pins/stm32f4/env_validate.h create mode 100644 src/pins/stm32f4/pins_ANET_ET4.h create mode 100644 src/pins/stm32f4/pins_ANET_ET4P.h create mode 100644 src/pins/stm32f4/pins_ARMED.h create mode 100644 src/pins/stm32f4/pins_ARTILLERY_RUBY.h create mode 100644 src/pins/stm32f4/pins_BLACK_STM32F407VE.h create mode 100644 src/pins/stm32f4/pins_BTT_BTT002_V1_0.h create mode 100644 src/pins/stm32f4/pins_BTT_E3_RRF.h create mode 100644 src/pins/stm32f4/pins_BTT_GTR_V1_0.h create mode 100644 src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h create mode 100644 src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h create mode 100644 src/pins/stm32f4/pins_BTT_OCTOPUS_V1_1.h create mode 100644 src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h create mode 100644 src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h create mode 100644 src/pins/stm32f4/pins_BTT_SKR_PRO_V1_2.h create mode 100644 src/pins/stm32f4/pins_BTT_SKR_PRO_common.h create mode 100644 src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_A.h create mode 100644 src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_B.h create mode 100644 src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h create mode 100644 src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h create mode 100644 src/pins/stm32f4/pins_FLYF407ZG.h create mode 100644 src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h create mode 100644 src/pins/stm32f4/pins_FYSETC_S6.h create mode 100644 src/pins/stm32f4/pins_FYSETC_S6_V2_0.h create mode 100644 src/pins/stm32f4/pins_FYSETC_SPIDER.h create mode 100644 src/pins/stm32f4/pins_FYSETC_SPIDER_V2_2.h create mode 100644 src/pins/stm32f4/pins_LERDGE_K.h create mode 100644 src/pins/stm32f4/pins_LERDGE_S.h create mode 100644 src/pins/stm32f4/pins_LERDGE_X.h create mode 100644 src/pins/stm32f4/pins_MKS_EAGLE.h create mode 100644 src/pins/stm32f4/pins_MKS_MONSTER8_V1.h create mode 100644 src/pins/stm32f4/pins_MKS_MONSTER8_V2.h create mode 100644 src/pins/stm32f4/pins_MKS_MONSTER8_common.h create mode 100644 src/pins/stm32f4/pins_MKS_ROBIN2.h create mode 100644 src/pins/stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h create mode 100644 src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h create mode 100644 src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h create mode 100644 src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h create mode 100644 src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h create mode 100644 src/pins/stm32f4/pins_RUMBA32_AUS3D.h create mode 100644 src/pins/stm32f4/pins_RUMBA32_BTT.h create mode 100644 src/pins/stm32f4/pins_RUMBA32_MKS.h create mode 100644 src/pins/stm32f4/pins_RUMBA32_common.h create mode 100644 src/pins/stm32f4/pins_STEVAL_3DP001V1.h create mode 100644 src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h create mode 100644 src/pins/stm32f4/pins_VAKE403D.h create mode 100644 src/pins/stm32f7/pins_NUCLEO_F767ZI.h create mode 100644 src/pins/stm32f7/pins_REMRAM_V1.h create mode 100644 src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h create mode 100644 src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h create mode 100644 src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h create mode 100644 src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h create mode 100644 src/pins/stm32h7/pins_BTT_SKR_V3_0.h create mode 100644 src/pins/stm32h7/pins_BTT_SKR_V3_0_EZ.h create mode 100644 src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h create mode 100644 src/pins/teensy2/env_validate.h create mode 100644 src/pins/teensy2/pins_5DPRINT.h create mode 100644 src/pins/teensy2/pins_BRAINWAVE.h create mode 100644 src/pins/teensy2/pins_BRAINWAVE_PRO.h create mode 100644 src/pins/teensy2/pins_PRINTRBOARD.h create mode 100644 src/pins/teensy2/pins_PRINTRBOARD_REVF.h create mode 100644 src/pins/teensy2/pins_SAV_MKI.h create mode 100644 src/pins/teensy2/pins_TEENSY2.h create mode 100644 src/pins/teensy2/pins_TEENSYLU.h create mode 100644 src/pins/teensy3/pins_TEENSY31_32.h create mode 100644 src/pins/teensy3/pins_TEENSY35_36.h create mode 100644 src/pins/teensy4/pins_T41U5XBB.h create mode 100644 src/pins/teensy4/pins_TEENSY41.h create mode 100644 src/sd/Sd2Card.cpp create mode 100644 src/sd/Sd2Card.h create mode 100644 src/sd/Sd2Card_sdio.h create mode 100644 src/sd/SdBaseFile.cpp create mode 100644 src/sd/SdBaseFile.h create mode 100644 src/sd/SdFatConfig.h create mode 100644 src/sd/SdFatStructs.h create mode 100644 src/sd/SdFatUtil.cpp create mode 100644 src/sd/SdFatUtil.h create mode 100644 src/sd/SdFile.cpp create mode 100644 src/sd/SdFile.h create mode 100644 src/sd/SdInfo.h create mode 100644 src/sd/SdVolume.cpp create mode 100644 src/sd/SdVolume.h create mode 100644 src/sd/cardreader.cpp create mode 100644 src/sd/cardreader.h create mode 100644 src/sd/disk_io_driver.h create mode 100644 src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp create mode 100644 src/sd/usb_flashdrive/Sd2Card_FlashDrive.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/README.txt create mode 100644 src/sd/usb_flashdrive/lib-uhs2/Usb.cpp create mode 100644 src/sd/usb_flashdrive/lib-uhs2/Usb.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/UsbCore.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/address.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/confdescparser.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/hexdump.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/macros.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp create mode 100644 src/sd/usb_flashdrive/lib-uhs2/masstorage.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/max3421e.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/message.cpp create mode 100644 src/sd/usb_flashdrive/lib-uhs2/message.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp create mode 100644 src/sd/usb_flashdrive/lib-uhs2/parsetools.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/printhex.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/settings.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h create mode 100644 src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp create mode 100644 src/sd/usb_flashdrive/lib-uhs2/usbhost.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/README.txt create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_SCSI.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UNOFFICIAL_IDs.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_USB_IDs.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UsbCore.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_address.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_hexdump.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_macros.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_message.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printf_HELPER.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_settings.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_util_INLINE.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/UHS_max3421e.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/UHS_host/macro_logic.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/SWI_INLINE.h create mode 100644 src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/dyn_SWI.h diff --git a/src/MarlinCore.cpp b/src/MarlinCore.cpp new file mode 100644 index 0000000..e059c2e --- /dev/null +++ b/src/MarlinCore.cpp @@ -0,0 +1,1668 @@ +/** + * 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 . + * + */ + +/** + * About Marlin + * + * This firmware is a mashup between Sprinter and grbl. + * - https://github.com/kliment/Sprinter + * - https://github.com/grbl/grbl + */ + +#include "MarlinCore.h" + +#include "HAL/shared/Delay.h" +#include "HAL/shared/esp_wifi.h" +#include "HAL/shared/cpu_exception/exception_hook.h" + +#ifdef ARDUINO + #include +#endif +#include + +#include "core/utility.h" + +#include "module/motion.h" +#include "module/planner.h" +#include "module/endstops.h" +#include "module/temperature.h" +#include "module/settings.h" +#include "module/printcounter.h" // PrintCounter or Stopwatch + +#include "module/stepper.h" +#include "module/stepper/indirection.h" + +#include "gcode/gcode.h" +#include "gcode/parser.h" +#include "gcode/queue.h" + +#include "feature/pause.h" +#include "sd/cardreader.h" + +#include "lcd/marlinui.h" +#if HAS_TOUCH_BUTTONS + #include "lcd/touch/touch_buttons.h" +#endif + +#if HAS_TFT_LVGL_UI + #include "lcd/extui/mks_ui/tft_lvgl_configuration.h" + #include "lcd/extui/mks_ui/draw_ui.h" + #include "lcd/extui/mks_ui/mks_hardware.h" + #include +#endif + +#if HAS_DWIN_E3V2 + #include "lcd/e3v2/common/encoder.h" + #if ENABLED(DWIN_CREALITY_LCD) + #include "lcd/e3v2/creality/dwin.h" + #elif ENABLED(DWIN_LCD_PROUI) + #include "lcd/e3v2/proui/dwin.h" + #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "lcd/e3v2/jyersui/dwin.h" + #endif +#endif + +#if HAS_ETHERNET + #include "feature/ethernet.h" +#endif + +#if ENABLED(IIC_BL24CXX_EEPROM) + #include "libs/BL24CXX.h" +#endif + +#if ENABLED(DIRECT_STEPPING) + #include "feature/direct_stepping.h" +#endif + +#if ENABLED(HOST_ACTION_COMMANDS) + #include "feature/host_actions.h" +#endif + +#if HAS_BEEPER + #include "libs/buzzer.h" +#endif + +#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) + #include "feature/closedloop.h" +#endif + +#if HAS_MOTOR_CURRENT_I2C + #include "feature/digipot/digipot.h" +#endif + +#if ENABLED(MIXING_EXTRUDER) + #include "feature/mixing.h" +#endif + +#if ENABLED(MAX7219_DEBUG) + #include "feature/max7219.h" +#endif + +#if HAS_COLOR_LEDS + #include "feature/leds/leds.h" +#endif + +#if ENABLED(BLTOUCH) + #include "feature/bltouch.h" +#endif + +#if ENABLED(POLL_JOG) + #include "feature/joystick.h" +#endif + +#if HAS_SERVOS + #include "module/servo.h" +#endif + +#if HAS_MOTOR_CURRENT_DAC + #include "feature/dac/stepper_dac.h" +#endif + +#if ENABLED(EXPERIMENTAL_I2CBUS) + #include "feature/twibus.h" +#endif + +#if ENABLED(I2C_POSITION_ENCODERS) + #include "feature/encoder_i2c.h" +#endif + +#if (HAS_TRINAMIC_CONFIG || HAS_TMC_SPI) && DISABLED(PSU_DEFAULT_OFF) + #include "feature/tmc_util.h" +#endif + +#if HAS_CUTTER + #include "feature/spindle_laser.h" +#endif + +#if ENABLED(SDSUPPORT) + CardReader card; +#endif + +#if ENABLED(G38_PROBE_TARGET) + uint8_t G38_move; // = 0 + bool G38_did_trigger; // = false +#endif + +#if ENABLED(DELTA) + #include "module/delta.h" +#elif ENABLED(POLARGRAPH) + #include "module/polargraph.h" +#elif IS_SCARA + #include "module/scara.h" +#endif + +#if HAS_LEVELING + #include "feature/bedlevel/bedlevel.h" +#endif + +#if ENABLED(GCODE_REPEAT_MARKERS) + #include "feature/repeat.h" +#endif + +#if ENABLED(POWER_LOSS_RECOVERY) + #include "feature/powerloss.h" +#endif + +#if ENABLED(CANCEL_OBJECTS) + #include "feature/cancel_object.h" +#endif + +#if HAS_FILAMENT_SENSOR + #include "feature/runout.h" +#endif + +#if EITHER(PROBE_TARE, HAS_Z_SERVO_PROBE) + #include "module/probe.h" +#endif + +#if ENABLED(HOTEND_IDLE_TIMEOUT) + #include "feature/hotend_idle.h" +#endif + +#if ENABLED(TEMP_STAT_LEDS) + #include "feature/leds/tempstat.h" +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) + #include "feature/caselight.h" +#endif + +#if HAS_FANMUX + #include "feature/fanmux.h" +#endif + +#include "module/tool_change.h" + +#if HAS_FANCHECK + #include "feature/fancheck.h" +#endif + +#if ENABLED(USE_CONTROLLER_FAN) + #include "feature/controllerfan.h" +#endif + +#if HAS_PRUSA_MMU1 + #include "feature/mmu/mmu.h" +#endif + +#if HAS_PRUSA_MMU2 + #include "feature/mmu/mmu2.h" +#endif + +#if HAS_L64XX + #include "libs/L64XX/L64XX_Marlin.h" +#endif + +#if ENABLED(PASSWORD_FEATURE) + #include "feature/password/password.h" +#endif + +#if ENABLED(DGUS_LCD_UI_MKS) + #include "lcd/extui/dgus/DGUSScreenHandler.h" +#endif + +#if HAS_DRIVER_SAFE_POWER_PROTECT + #include "feature/stepper_driver_safety.h" +#endif + +#if ENABLED(PSU_CONTROL) + #include "feature/power.h" +#endif + +#if ENABLED(EASYTHREED_UI) + #include "feature/easythreed_ui.h" +#endif + +PGMSTR(M112_KILL_STR, "M112 Shutdown"); + +MarlinState marlin_state = MF_INITIALIZING; + +// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop +bool wait_for_heatup = true; + +// For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop +#if HAS_RESUME_CONTINUE + bool wait_for_user; // = false; + + void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) { + UNUSED(no_sleep); + KEEPALIVE_STATE(PAUSED_FOR_USER); + wait_for_user = true; + if (ms) ms += millis(); // expire time + while (wait_for_user && !(ms && ELAPSED(millis(), ms))) + idle(TERN_(ADVANCED_PAUSE_FEATURE, no_sleep)); + wait_for_user = false; + while (ui.button_pressed()) safe_delay(50); + } + +#endif + +/** + * *************************************************************************** + * ******************************** FUNCTIONS ******************************** + * *************************************************************************** + */ + +/** + * Stepper Reset (RigidBoard, et.al.) + */ +#if HAS_STEPPER_RESET + void disableStepperDrivers() { OUT_WRITE(STEPPER_RESET_PIN, LOW); } // Drive down to keep motor driver chips in reset + void enableStepperDrivers() { SET_INPUT(STEPPER_RESET_PIN); } // Set to input, allowing pullups to pull the pin high +#endif + +/** + * Sensitive pin test for M42, M226 + */ + +#include "pins/sensitive_pins.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnarrowing" + +#ifndef RUNTIME_ONLY_ANALOG_TO_DIGITAL + template + constexpr pin_t OnlyPins<_SP_END, D...>::table[sizeof...(D)]; +#endif + +bool pin_is_protected(const pin_t pin) { + #ifdef RUNTIME_ONLY_ANALOG_TO_DIGITAL + static const pin_t sensitive_pins[] PROGMEM = { SENSITIVE_PINS }; + const size_t pincount = COUNT(sensitive_pins); + #else + static constexpr size_t pincount = OnlyPins::size; + static const pin_t (&sensitive_pins)[pincount] PROGMEM = OnlyPins::table; + #endif + LOOP_L_N(i, pincount) { + const pin_t * const pptr = &sensitive_pins[i]; + if (pin == (sizeof(pin_t) == 2 ? (pin_t)pgm_read_word(pptr) : (pin_t)pgm_read_byte(pptr))) return true; + } + return false; +} + +#pragma GCC diagnostic pop + +bool printer_busy() { + return planner.movesplanned() || printingIsActive(); +} + +/** + * A Print Job exists when the timer is running or SD is printing + */ +bool printJobOngoing() { return print_job_timer.isRunning() || IS_SD_PRINTING(); } + +/** + * Printing is active when a job is underway but not paused + */ +bool printingIsActive() { return !did_pause_print && printJobOngoing(); } + +/** + * Printing is paused according to SD or host indicators + */ +bool printingIsPaused() { + return did_pause_print || print_job_timer.isPaused() || IS_SD_PAUSED(); +} + +void startOrResumeJob() { + if (!printingIsPaused()) { + TERN_(GCODE_REPEAT_MARKERS, repeat.reset()); + TERN_(CANCEL_OBJECTS, cancelable.reset()); + TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0); + #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) + ui.reset_remaining_time(); + #endif + } + print_job_timer.start(); +} + +#if ENABLED(SDSUPPORT) + + inline void abortSDPrinting() { + IF_DISABLED(NO_SD_AUTOSTART, card.autofile_cancel()); + card.abortFilePrintNow(TERN_(SD_RESORT, true)); + + queue.clear(); + quickstop_stepper(); + + print_job_timer.abort(); + + IF_DISABLED(SD_ABORT_NO_COOLDOWN, thermalManager.disable_all_heaters()); + + TERN(HAS_CUTTER, cutter.kill(), thermalManager.zero_fan_speeds()); // Full cutter shutdown including ISR control + + wait_for_heatup = false; + + TERN_(POWER_LOSS_RECOVERY, recovery.purge()); + + #ifdef EVENT_GCODE_SD_ABORT + queue.inject(F(EVENT_GCODE_SD_ABORT)); + #endif + + TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine()); + } + + inline void finishSDPrinting() { + if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued + marlin_state = MF_RUNNING; // Signal to stop trying + TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine()); + TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished()); + } + } + +#endif // SDSUPPORT + +/** + * Minimal management of Marlin's core activities: + * - Keep the command buffer full + * - Check for maximum inactive time between commands + * - Check for maximum inactive time between stepper commands + * - Check if CHDK_PIN needs to go LOW + * - Check for KILL button held down + * - Check for HOME button held down + * - Check for CUSTOM USER button held down + * - Check if cooling fan needs to be switched on + * - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT) + * - Pulse FET_SAFETY_PIN if it exists + */ +inline void manage_inactivity(const bool no_stepper_sleep=false) { + + queue.get_available_commands(); + + const millis_t ms = millis(); + + // Prevent steppers timing-out + const bool do_reset_timeout = no_stepper_sleep + || TERN0(PAUSE_PARK_NO_STEPPER_TIMEOUT, did_pause_print); + + // Reset both the M18/M84 activity timeout and the M85 max 'kill' timeout + if (do_reset_timeout) gcode.reset_stepper_timeout(ms); + + if (gcode.stepper_max_timed_out(ms)) { + SERIAL_ERROR_START(); + SERIAL_ECHOPGM(STR_KILL_PRE); + SERIAL_ECHOLNPGM(STR_KILL_INACTIVE_TIME, parser.command_ptr); + kill(); + } + + const bool has_blocks = planner.has_blocks_queued(); // Any moves in the planner? + if (has_blocks) gcode.reset_stepper_timeout(ms); // Reset timeout for M18/M84, M85 max 'kill', and laser. + + // M18 / M84 : Handle steppers inactive time timeout + #if HAS_DISABLE_INACTIVE_AXIS + if (gcode.stepper_inactive_time) { + + static bool already_shutdown_steppers; // = false + + if (!has_blocks && !do_reset_timeout && gcode.stepper_inactive_timeout()) { + if (!already_shutdown_steppers) { + already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this + + // Individual axes will be disabled if configured + TERN_(DISABLE_INACTIVE_X, stepper.disable_axis(X_AXIS)); + TERN_(DISABLE_INACTIVE_Y, stepper.disable_axis(Y_AXIS)); + TERN_(DISABLE_INACTIVE_Z, stepper.disable_axis(Z_AXIS)); + TERN_(DISABLE_INACTIVE_I, stepper.disable_axis(I_AXIS)); + TERN_(DISABLE_INACTIVE_J, stepper.disable_axis(J_AXIS)); + TERN_(DISABLE_INACTIVE_K, stepper.disable_axis(K_AXIS)); + TERN_(DISABLE_INACTIVE_E, stepper.disable_e_steppers()); + + TERN_(AUTO_BED_LEVELING_UBL, bedlevel.steppers_were_disabled()); + } + } + else + already_shutdown_steppers = false; + } + #endif + + #if ENABLED(PHOTO_GCODE) && PIN_EXISTS(CHDK) + // Check if CHDK should be set to LOW (after M240 set it HIGH) + extern millis_t chdk_timeout; + if (chdk_timeout && ELAPSED(ms, chdk_timeout)) { + chdk_timeout = 0; + WRITE(CHDK_PIN, LOW); + } + #endif + + #if HAS_KILL + + // Check if the kill button was pressed and wait just in case it was an accidental + // key kill key press + // ------------------------------------------------------------------------------- + static int killCount = 0; // make the inactivity button a bit less responsive + const int KILL_DELAY = 750; + if (kill_state()) + killCount++; + else if (killCount > 0) + killCount--; + + // Exceeded threshold and we can confirm that it was not accidental + // KILL the machine + // ---------------------------------------------------------------- + if (killCount >= KILL_DELAY) { + SERIAL_ERROR_START(); + SERIAL_ECHOPGM(STR_KILL_PRE); + SERIAL_ECHOLNPGM(STR_KILL_BUTTON); + kill(); + } + #endif + + #if HAS_FREEZE_PIN + stepper.frozen = READ(FREEZE_PIN) == FREEZE_STATE; + #endif + + #if HAS_HOME + // Handle a standalone HOME button + constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL; + static millis_t next_home_key_ms; // = 0 + if (!IS_SD_PRINTING() && !READ(HOME_PIN)) { // HOME_PIN goes LOW when pressed + if (ELAPSED(ms, next_home_key_ms)) { + next_home_key_ms = ms + HOME_DEBOUNCE_DELAY; + LCD_MESSAGE(MSG_AUTO_HOME); + queue.inject_P(G28_STR); + } + } + #endif + + #if ENABLED(CUSTOM_USER_BUTTONS) + // Handle a custom user button if defined + const bool printer_not_busy = !printingIsActive(); + #define HAS_CUSTOM_USER_BUTTON(N) (PIN_EXISTS(BUTTON##N) && defined(BUTTON##N##_HIT_STATE) && defined(BUTTON##N##_GCODE)) + #define HAS_BETTER_USER_BUTTON(N) HAS_CUSTOM_USER_BUTTON(N) && defined(BUTTON##N##_DESC) + #define _CHECK_CUSTOM_USER_BUTTON(N, CODE) do{ \ + constexpr millis_t CUB_DEBOUNCE_DELAY_##N = 250UL; \ + static millis_t next_cub_ms_##N; \ + if (BUTTON##N##_HIT_STATE == READ(BUTTON##N##_PIN) \ + && (ENABLED(BUTTON##N##_WHEN_PRINTING) || printer_not_busy)) { \ + if (ELAPSED(ms, next_cub_ms_##N)) { \ + next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \ + CODE; \ + queue.inject(F(BUTTON##N##_GCODE)); \ + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \ + } \ + } \ + }while(0) + + #define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP) + #define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGE_F(BUTTON##N##_DESC)) + + #if HAS_BETTER_USER_BUTTON(1) + CHECK_BETTER_USER_BUTTON(1); + #elif HAS_CUSTOM_USER_BUTTON(1) + CHECK_CUSTOM_USER_BUTTON(1); + #endif + #if HAS_BETTER_USER_BUTTON(2) + CHECK_BETTER_USER_BUTTON(2); + #elif HAS_CUSTOM_USER_BUTTON(2) + CHECK_CUSTOM_USER_BUTTON(2); + #endif + #if HAS_BETTER_USER_BUTTON(3) + CHECK_BETTER_USER_BUTTON(3); + #elif HAS_CUSTOM_USER_BUTTON(3) + CHECK_CUSTOM_USER_BUTTON(3); + #endif + #if HAS_BETTER_USER_BUTTON(4) + CHECK_BETTER_USER_BUTTON(4); + #elif HAS_CUSTOM_USER_BUTTON(4) + CHECK_CUSTOM_USER_BUTTON(4); + #endif + #if HAS_BETTER_USER_BUTTON(5) + CHECK_BETTER_USER_BUTTON(5); + #elif HAS_CUSTOM_USER_BUTTON(5) + CHECK_CUSTOM_USER_BUTTON(5); + #endif + #if HAS_BETTER_USER_BUTTON(6) + CHECK_BETTER_USER_BUTTON(6); + #elif HAS_CUSTOM_USER_BUTTON(6) + CHECK_CUSTOM_USER_BUTTON(6); + #endif + #if HAS_BETTER_USER_BUTTON(7) + CHECK_BETTER_USER_BUTTON(7); + #elif HAS_CUSTOM_USER_BUTTON(7) + CHECK_CUSTOM_USER_BUTTON(7); + #endif + #if HAS_BETTER_USER_BUTTON(8) + CHECK_BETTER_USER_BUTTON(8); + #elif HAS_CUSTOM_USER_BUTTON(8) + CHECK_CUSTOM_USER_BUTTON(8); + #endif + #if HAS_BETTER_USER_BUTTON(9) + CHECK_BETTER_USER_BUTTON(9); + #elif HAS_CUSTOM_USER_BUTTON(9) + CHECK_CUSTOM_USER_BUTTON(9); + #endif + #if HAS_BETTER_USER_BUTTON(10) + CHECK_BETTER_USER_BUTTON(10); + #elif HAS_CUSTOM_USER_BUTTON(10) + CHECK_CUSTOM_USER_BUTTON(10); + #endif + #if HAS_BETTER_USER_BUTTON(11) + CHECK_BETTER_USER_BUTTON(11); + #elif HAS_CUSTOM_USER_BUTTON(11) + CHECK_CUSTOM_USER_BUTTON(11); + #endif + #if HAS_BETTER_USER_BUTTON(12) + CHECK_BETTER_USER_BUTTON(12); + #elif HAS_CUSTOM_USER_BUTTON(12) + CHECK_CUSTOM_USER_BUTTON(12); + #endif + #if HAS_BETTER_USER_BUTTON(13) + CHECK_BETTER_USER_BUTTON(13); + #elif HAS_CUSTOM_USER_BUTTON(13) + CHECK_CUSTOM_USER_BUTTON(13); + #endif + #if HAS_BETTER_USER_BUTTON(14) + CHECK_BETTER_USER_BUTTON(14); + #elif HAS_CUSTOM_USER_BUTTON(14) + CHECK_CUSTOM_USER_BUTTON(14); + #endif + #if HAS_BETTER_USER_BUTTON(15) + CHECK_BETTER_USER_BUTTON(15); + #elif HAS_CUSTOM_USER_BUTTON(15) + CHECK_CUSTOM_USER_BUTTON(15); + #endif + #if HAS_BETTER_USER_BUTTON(16) + CHECK_BETTER_USER_BUTTON(16); + #elif HAS_CUSTOM_USER_BUTTON(16) + CHECK_CUSTOM_USER_BUTTON(16); + #endif + #if HAS_BETTER_USER_BUTTON(17) + CHECK_BETTER_USER_BUTTON(17); + #elif HAS_CUSTOM_USER_BUTTON(17) + CHECK_CUSTOM_USER_BUTTON(17); + #endif + #if HAS_BETTER_USER_BUTTON(18) + CHECK_BETTER_USER_BUTTON(18); + #elif HAS_CUSTOM_USER_BUTTON(18) + CHECK_CUSTOM_USER_BUTTON(18); + #endif + #if HAS_BETTER_USER_BUTTON(19) + CHECK_BETTER_USER_BUTTON(19); + #elif HAS_CUSTOM_USER_BUTTON(19) + CHECK_CUSTOM_USER_BUTTON(19); + #endif + #if HAS_BETTER_USER_BUTTON(20) + CHECK_BETTER_USER_BUTTON(20); + #elif HAS_CUSTOM_USER_BUTTON(20) + CHECK_CUSTOM_USER_BUTTON(20); + #endif + #if HAS_BETTER_USER_BUTTON(21) + CHECK_BETTER_USER_BUTTON(21); + #elif HAS_CUSTOM_USER_BUTTON(21) + CHECK_CUSTOM_USER_BUTTON(21); + #endif + #if HAS_BETTER_USER_BUTTON(22) + CHECK_BETTER_USER_BUTTON(22); + #elif HAS_CUSTOM_USER_BUTTON(22) + CHECK_CUSTOM_USER_BUTTON(22); + #endif + #if HAS_BETTER_USER_BUTTON(23) + CHECK_BETTER_USER_BUTTON(23); + #elif HAS_CUSTOM_USER_BUTTON(23) + CHECK_CUSTOM_USER_BUTTON(23); + #endif + #if HAS_BETTER_USER_BUTTON(24) + CHECK_BETTER_USER_BUTTON(24); + #elif HAS_CUSTOM_USER_BUTTON(24) + CHECK_CUSTOM_USER_BUTTON(24); + #endif + #if HAS_BETTER_USER_BUTTON(25) + CHECK_BETTER_USER_BUTTON(25); + #elif HAS_CUSTOM_USER_BUTTON(25) + CHECK_CUSTOM_USER_BUTTON(25); + #endif + #endif + + TERN_(EASYTHREED_UI, easythreed_ui.run()); + + TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down + + TERN_(AUTO_POWER_CONTROL, powerManager.check(!ui.on_status_screen() || printJobOngoing() || printingIsPaused())); + + TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check()); + + #if ENABLED(EXTRUDER_RUNOUT_PREVENT) + if (thermalManager.degHotend(active_extruder) > (EXTRUDER_RUNOUT_MINTEMP) + && ELAPSED(ms, gcode.previous_move_ms + SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS)) + && !planner.has_blocks_queued() + ) { + #if ENABLED(SWITCHING_EXTRUDER) + bool oldstatus; + switch (active_extruder) { + default: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 0); stepper.ENABLE_EXTRUDER(0); break; + #if E_STEPPERS > 1 + case 2: case 3: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 1); stepper.ENABLE_EXTRUDER(1); break; + #if E_STEPPERS > 2 + case 4: case 5: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 2); stepper.ENABLE_EXTRUDER(2); break; + #if E_STEPPERS > 3 + case 6: case 7: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 3); stepper.ENABLE_EXTRUDER(3); break; + #endif // E_STEPPERS > 3 + #endif // E_STEPPERS > 2 + #endif // E_STEPPERS > 1 + } + #else // !SWITCHING_EXTRUDER + bool oldstatus; + switch (active_extruder) { + default: + #define _CASE_EN(N) case N: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, N); stepper.ENABLE_EXTRUDER(N); break; + REPEAT(E_STEPPERS, _CASE_EN); + } + #endif + + const float olde = current_position.e; + current_position.e += EXTRUDER_RUNOUT_EXTRUDE; + line_to_current_position(MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED)); + current_position.e = olde; + planner.set_e_position_mm(olde); + planner.synchronize(); + + #if ENABLED(SWITCHING_EXTRUDER) + switch (active_extruder) { + default: if (oldstatus) stepper.ENABLE_EXTRUDER(0); else stepper.DISABLE_EXTRUDER(0); break; + #if E_STEPPERS > 1 + case 2: case 3: if (oldstatus) stepper.ENABLE_EXTRUDER(1); else stepper.DISABLE_EXTRUDER(1); break; + #if E_STEPPERS > 2 + case 4: case 5: if (oldstatus) stepper.ENABLE_EXTRUDER(2); else stepper.DISABLE_EXTRUDER(2); break; + #endif // E_STEPPERS > 2 + #endif // E_STEPPERS > 1 + } + #else // !SWITCHING_EXTRUDER + switch (active_extruder) { + #define _CASE_RESTORE(N) case N: if (oldstatus) stepper.ENABLE_EXTRUDER(N); else stepper.DISABLE_EXTRUDER(N); break; + REPEAT(E_STEPPERS, _CASE_RESTORE); + } + #endif // !SWITCHING_EXTRUDER + + gcode.reset_stepper_timeout(ms); + } + #endif // EXTRUDER_RUNOUT_PREVENT + + #if ENABLED(DUAL_X_CARRIAGE) + // handle delayed move timeout + if (delayed_move_time && ELAPSED(ms, delayed_move_time) && IsRunning()) { + // travel moves have been received so enact them + delayed_move_time = 0xFFFFFFFFUL; // force moves to be done + destination = current_position; + prepare_line_to_destination(); + planner.synchronize(); + } + #endif + + TERN_(TEMP_STAT_LEDS, handle_status_leds()); + + TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers()); + + TERN_(MONITOR_L6470_DRIVER_STATUS, L64xxManager.monitor_driver()); + + // Limit check_axes_activity frequency to 10Hz + static millis_t next_check_axes_ms = 0; + if (ELAPSED(ms, next_check_axes_ms)) { + planner.check_axes_activity(); + next_check_axes_ms = ms + 100UL; + } + + #if PIN_EXISTS(FET_SAFETY) + static millis_t FET_next; + if (ELAPSED(ms, FET_next)) { + FET_next = ms + FET_SAFETY_DELAY; // 2µs pulse every FET_SAFETY_DELAY mS + OUT_WRITE(FET_SAFETY_PIN, !FET_SAFETY_INVERTED); + DELAY_US(2); + WRITE(FET_SAFETY_PIN, FET_SAFETY_INVERTED); + } + #endif +} + +/** + * Standard idle routine keeps the machine alive: + * - Core Marlin activities + * - Manage heaters (and Watchdog) + * - Max7219 heartbeat, animation, etc. + * + * Only after setup() is complete: + * - Handle filament runout sensors + * - Run HAL idle tasks + * - Handle Power-Loss Recovery + * - Run StallGuard endstop checks + * - Handle SD Card insert / remove + * - Handle USB Flash Drive insert / remove + * - Announce Host Keepalive state (if any) + * - Update the Print Job Timer state + * - Update the Beeper queue + * - Read Buttons and Update the LCD + * - Run i2c Position Encoders + * - Auto-report Temperatures / SD Status + * - Update the Průša MMU2 + * - Handle Joystick jogging + */ +void idle(bool no_stepper_sleep/*=false*/) { + #if ENABLED(MARLIN_DEV_MODE) + static uint16_t idle_depth = 0; + if (++idle_depth > 5) SERIAL_ECHOLNPGM("idle() call depth: ", idle_depth); + #endif + + // Core Marlin activities + manage_inactivity(no_stepper_sleep); + + // Manage Heaters (and Watchdog) + thermalManager.task(); + + // Max7219 heartbeat, animation, etc + TERN_(MAX7219_DEBUG, max7219.idle_tasks()); + + // Return if setup() isn't completed + if (marlin_state == MF_INITIALIZING) goto IDLE_DONE; + + // TODO: Still causing errors + (void)check_tool_sensor_stats(active_extruder, true); + + // Handle filament runout sensors + #if HAS_FILAMENT_SENSOR + if (TERN1(HAS_PRUSA_MMU2, !mmu2.enabled())) + runout.run(); + #endif + + // Run HAL idle tasks + hal.idletask(); + + // Check network connection + TERN_(HAS_ETHERNET, ethernet.check()); + + // Handle Power-Loss Recovery + #if ENABLED(POWER_LOSS_RECOVERY) && PIN_EXISTS(POWER_LOSS) + if (IS_SD_PRINTING()) recovery.outage(); + #endif + + // Run StallGuard endstop checks + #if ENABLED(SPI_ENDSTOPS) + if (endstops.tmc_spi_homing.any && TERN1(IMPROVE_HOMING_RELIABILITY, ELAPSED(millis(), sg_guard_period))) + LOOP_L_N(i, 4) if (endstops.tmc_spi_homing_check()) break; // Read SGT 4 times per idle loop + #endif + + // Handle SD Card insert / remove + TERN_(SDSUPPORT, card.manage_media()); + + // Handle USB Flash Drive insert / remove + TERN_(USB_FLASH_DRIVE_SUPPORT, card.diskIODriver()->idle()); + + // Announce Host Keepalive state (if any) + TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive()); + + // Update the Print Job Timer state + TERN_(PRINTCOUNTER, print_job_timer.tick()); + + // Update the Beeper queue + TERN_(HAS_BEEPER, buzzer.tick()); + + // Handle UI input / draw events + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); + + // Run i2c Position Encoders + #if ENABLED(I2C_POSITION_ENCODERS) + { + static millis_t i2cpem_next_update_ms; + if (planner.has_blocks_queued()) { + const millis_t ms = millis(); + if (ELAPSED(ms, i2cpem_next_update_ms)) { + I2CPEM.update(); + i2cpem_next_update_ms = ms + I2CPE_MIN_UPD_TIME_MS; + } + } + } + #endif + + // Auto-report Temperatures / SD Status + #if HAS_AUTO_REPORTING + if (!gcode.autoreport_paused) { + TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick()); + TERN_(AUTO_REPORT_FANS, fan_check.auto_reporter.tick()); + TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick()); + TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick()); + TERN_(BUFFER_MONITORING, queue.auto_report_buffer_statistics()); + } + #endif + + // Update the Průša MMU2 + TERN_(HAS_PRUSA_MMU2, mmu2.mmu_loop()); + + // Handle Joystick jogging + TERN_(POLL_JOG, joystick.inject_jog_moves()); + + // Direct Stepping + TERN_(DIRECT_STEPPING, page_manager.write_responses()); + + // Update the LVGL interface + TERN_(HAS_TFT_LVGL_UI, LV_TASK_HANDLER()); + + IDLE_DONE: + TERN_(MARLIN_DEV_MODE, idle_depth--); + return; +} + +/** + * Kill all activity and lock the machine. + * After this the machine will need to be reset. + */ +void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) { + thermalManager.disable_all_heaters(); + + TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control + + // Echo the LCD message to serial for extra context + if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); } + + #if HAS_DISPLAY + ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR)); + #else + UNUSED(lcd_error); UNUSED(lcd_component); + #endif + + TERN_(HAS_TFT_LVGL_UI, lv_draw_error_message(lcd_error)); + + // "Error:Printer halted. kill() called!" + SERIAL_ERROR_MSG(STR_ERR_KILLED); + + #ifdef ACTION_ON_KILL + hostui.kill(); + #endif + + minkill(steppers_off); +} + +void minkill(const bool steppers_off/*=false*/) { + + // Wait a short time (allows messages to get out before shutting down. + for (int i = 1000; i--;) DELAY_US(600); + + cli(); // Stop interrupts + + // Wait to ensure all interrupts stopped + for (int i = 1000; i--;) DELAY_US(250); + + // Reiterate heaters off + thermalManager.disable_all_heaters(); + + TERN_(HAS_CUTTER, cutter.kill()); // Reiterate cutter shutdown + + // Power off all steppers (for M112) or just the E steppers + steppers_off ? stepper.disable_all_steppers() : stepper.disable_e_steppers(); + + TERN_(PSU_CONTROL, powerManager.power_off()); + + TERN_(HAS_SUICIDE, suicide()); + + #if EITHER(HAS_KILL, SOFT_RESET_ON_KILL) + + // Wait for both KILL and ENC to be released + while (TERN0(HAS_KILL, kill_state()) || TERN0(SOFT_RESET_ON_KILL, ui.button_pressed())) + hal.watchdog_refresh(); + + // Wait for either KILL or ENC to be pressed again + while (TERN1(HAS_KILL, !kill_state()) && TERN1(SOFT_RESET_ON_KILL, !ui.button_pressed())) + hal.watchdog_refresh(); + + // Reboot the board + hal.reboot(); + + #else + + for (;;) hal.watchdog_refresh(); // Wait for RESET button or power-cycle + + #endif +} + +/** + * Turn off heaters and stop the print in progress + * After a stop the machine may be resumed with M999 + */ +void stop() { + thermalManager.disable_all_heaters(); // 'unpause' taken care of in here + + print_job_timer.stop(); + + #if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE) + thermalManager.set_fans_paused(false); // Un-pause fans for safety + #endif + + if (!IsStopped()) { + SERIAL_ERROR_MSG(STR_ERR_STOPPED); + LCD_MESSAGE(MSG_STOPPED); + safe_delay(350); // allow enough time for messages to get out before stopping + marlin_state = MF_STOPPED; + } +} + +inline void tmc_standby_setup() { + #if PIN_EXISTS(X_STDBY) + SET_INPUT_PULLDOWN(X_STDBY_PIN); + #endif + #if PIN_EXISTS(X2_STDBY) + SET_INPUT_PULLDOWN(X2_STDBY_PIN); + #endif + #if PIN_EXISTS(Y_STDBY) + SET_INPUT_PULLDOWN(Y_STDBY_PIN); + #endif + #if PIN_EXISTS(Y2_STDBY) + SET_INPUT_PULLDOWN(Y2_STDBY_PIN); + #endif + #if PIN_EXISTS(Z_STDBY) + SET_INPUT_PULLDOWN(Z_STDBY_PIN); + #endif + #if PIN_EXISTS(Z2_STDBY) + SET_INPUT_PULLDOWN(Z2_STDBY_PIN); + #endif + #if PIN_EXISTS(Z3_STDBY) + SET_INPUT_PULLDOWN(Z3_STDBY_PIN); + #endif + #if PIN_EXISTS(Z4_STDBY) + SET_INPUT_PULLDOWN(Z4_STDBY_PIN); + #endif + #if PIN_EXISTS(I_STDBY) + SET_INPUT_PULLDOWN(I_STDBY_PIN); + #endif + #if PIN_EXISTS(J_STDBY) + SET_INPUT_PULLDOWN(J_STDBY_PIN); + #endif + #if PIN_EXISTS(K_STDBY) + SET_INPUT_PULLDOWN(K_STDBY_PIN); + #endif + #if PIN_EXISTS(E0_STDBY) + SET_INPUT_PULLDOWN(E0_STDBY_PIN); + #endif + #if PIN_EXISTS(E1_STDBY) + SET_INPUT_PULLDOWN(E1_STDBY_PIN); + #endif + #if PIN_EXISTS(E2_STDBY) + SET_INPUT_PULLDOWN(E2_STDBY_PIN); + #endif + #if PIN_EXISTS(E3_STDBY) + SET_INPUT_PULLDOWN(E3_STDBY_PIN); + #endif + #if PIN_EXISTS(E4_STDBY) + SET_INPUT_PULLDOWN(E4_STDBY_PIN); + #endif + #if PIN_EXISTS(E5_STDBY) + SET_INPUT_PULLDOWN(E5_STDBY_PIN); + #endif + #if PIN_EXISTS(E6_STDBY) + SET_INPUT_PULLDOWN(E6_STDBY_PIN); + #endif + #if PIN_EXISTS(E7_STDBY) + SET_INPUT_PULLDOWN(E7_STDBY_PIN); + #endif +} + +/** + * Marlin Firmware entry-point. Abandon Hope All Ye Who Enter Here. + * Setup before the program loop: + * + * - Call any special pre-init set for the board + * - Put TMC drivers into Low Power Standby mode + * - Init the serial ports (so setup can be debugged) + * - Set up the kill and suicide pins + * - Prepare (disable) board JTAG and Debug ports + * - Init serial for a connected MKS TFT with WiFi + * - Install Marlin custom Exception Handlers, if set. + * - Init Marlin's HAL interfaces (for SPI, i2c, etc.) + * - Init some optional hardware and features: + * • MAX Thermocouple pins + * • Duet Smart Effector + * • Filament Runout Sensor + * • TMC220x Stepper Drivers (Serial) + * • PSU control + * • Power-loss Recovery + * • L64XX Stepper Drivers (SPI) + * • Stepper Driver Reset: DISABLE + * • TMC Stepper Drivers (SPI) + * • Run hal.init_board() for additional pins setup + * • ESP WiFi + * - Get the Reset Reason and report it + * - Print startup messages and diagnostics + * - Calibrate the HAL DELAY for precise timing + * - Init the buzzer, possibly a custom timer + * - Init more optional hardware: + * • Color LED illumination + * • Neopixel illumination + * • Controller Fan + * • Creality DWIN LCD (show boot image) + * • Tare the Probe if possible + * - Mount the (most likely external) SD Card + * - Load settings from EEPROM (or use defaults) + * - Init the Ethernet Port + * - Init Touch Buttons (for emulated DOGLCD) + * - Adjust the (certainly wrong) current position by the home offset + * - Init the Planner::position (steps) based on current (native) position + * - Initialize more managers and peripherals: + * • Temperatures + * • Print Job Timer + * • Endstops and Endstop Interrupts + * • Stepper ISR - Kind of Important! + * • Servos + * • Servo-based Probe + * • Photograph Pin + * • Laser/Spindle tool Power / PWM + * • Coolant Control + * • Bed Probe + * • Stepper Driver Reset: ENABLE + * • Digipot I2C - Stepper driver current control + * • Stepper DAC - Stepper driver current control + * • Solenoid (probe, or for other use) + * • Home Pin + * • Custom User Buttons + * • Red/Blue Status LEDs + * • Case Light + * • Prusa MMU filament changer + * • Fan Multiplexer + * • Mixing Extruder + * • BLTouch Probe + * • I2C Position Encoders + * • Custom I2C Bus handlers + * • Enhanced tools or extruders: + * • Switching Extruder + * • Switching Nozzle + * • Parking Extruder + * • Magnetic Parking Extruder + * • Switching Toolhead + * • Electromagnetic Switching Toolhead + * • Watchdog Timer - Also Kind of Important! + * • Closed Loop Controller + * - Run Startup Commands, if defined + * - Tell host to close Host Prompts + * - Test Trinamic driver connections + * - Init Prusa MMU2 filament changer + * - Init and test BL24Cxx EEPROM + * - Init Creality DWIN encoder, show faux progress bar + * - Reset Status Message / Show Service Messages + * - Init MAX7219 LED Matrix + * - Init Direct Stepping (Klipper-style motion control) + * - Init TFT LVGL UI (with 3D Graphics) + * - Apply Password Lock - Hold for Authentication + * - Open Touch Screen Calibration screen, if not calibrated + * - Set Marlin to RUNNING State + */ +void setup() { + #ifdef FASTIO_INIT + FASTIO_INIT(); + #endif + + #ifdef BOARD_PREINIT + BOARD_PREINIT(); // Low-level init (before serial init) + #endif + + tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable + + // Check startup - does nothing if bootloader sets MCUSR to 0 + const byte mcu = hal.get_reset_source(); + hal.clear_reset_source(); + + #if ENABLED(MARLIN_DEV_MODE) + auto log_current_ms = [&](PGM_P const msg) { + SERIAL_ECHO_START(); + SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHOPGM("] "); + SERIAL_ECHOLNPGM_P(msg); + }; + #define SETUP_LOG(M) log_current_ms(PSTR(M)) + #else + #define SETUP_LOG(...) NOOP + #endif + #define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0) + + MYSERIAL1.begin(BAUDRATE); + millis_t serial_connect_timeout = millis() + 1000UL; + while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + + #if HAS_MULTI_SERIAL && !HAS_ETHERNET + #ifndef BAUDRATE_2 + #define BAUDRATE_2 BAUDRATE + #endif + MYSERIAL2.begin(BAUDRATE_2); + serial_connect_timeout = millis() + 1000UL; + while (!MYSERIAL2.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + #ifdef SERIAL_PORT_3 + #ifndef BAUDRATE_3 + #define BAUDRATE_3 BAUDRATE + #endif + MYSERIAL3.begin(BAUDRATE_3); + serial_connect_timeout = millis() + 1000UL; + while (!MYSERIAL3.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + #endif + #endif + SERIAL_ECHOLNPGM("start"); + + // Set up these pins early to prevent suicide + #if HAS_KILL + SETUP_LOG("KILL_PIN"); + #if KILL_PIN_STATE + SET_INPUT_PULLDOWN(KILL_PIN); + #else + SET_INPUT_PULLUP(KILL_PIN); + #endif + #endif + + #if ENABLED(FREEZE_FEATURE) + SETUP_LOG("FREEZE_PIN"); + #if FREEZE_STATE + SET_INPUT_PULLDOWN(FREEZE_PIN); + #else + SET_INPUT_PULLUP(FREEZE_PIN); + #endif + #endif + + #if HAS_SUICIDE + SETUP_LOG("SUICIDE_PIN"); + OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_STATE); + #endif + + #ifdef JTAGSWD_RESET + SETUP_LOG("JTAGSWD_RESET"); + JTAGSWD_RESET(); + #endif + + // Disable any hardware debug to free up pins for IO + #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE) + delay(10); + SETUP_LOG("JTAGSWD_DISABLE"); + JTAGSWD_DISABLE(); + #elif ENABLED(DISABLE_JTAG) && defined(JTAG_DISABLE) + delay(10); + SETUP_LOG("JTAG_DISABLE"); + JTAG_DISABLE(); + #endif + + TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime + + SETUP_RUN(hal.init()); + + // Init and disable SPI thermocouples; this is still needed + #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0)) + OUT_WRITE(TEMP_0_CS_PIN, HIGH); // Disable + #endif + #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + OUT_WRITE(TEMP_1_CS_PIN, HIGH); + #endif + + #if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) + OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); // Put Smart Effector into NORMAL mode + #endif + + #if HAS_FILAMENT_SENSOR + SETUP_RUN(runout.setup()); + #endif + + #if HAS_TMC220x + SETUP_RUN(tmc_serial_begin()); + #endif + + #if HAS_TMC_SPI + #if DISABLED(TMC_USE_SW_SPI) + SETUP_RUN(SPI.begin()); + #endif + SETUP_RUN(tmc_init_cs_pins()); + #endif + + #if HAS_L64XX + SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers + #endif + + #if ENABLED(PSU_CONTROL) + SETUP_LOG("PSU_CONTROL"); + powerManager.init(); + #endif + + #if ENABLED(POWER_LOSS_RECOVERY) + SETUP_RUN(recovery.setup()); + #endif + + #if HAS_STEPPER_RESET + SETUP_RUN(disableStepperDrivers()); + #endif + + SETUP_RUN(hal.init_board()); + + SETUP_RUN(esp_wifi_init()); + + // Report Reset Reason + if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); + if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); + if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET); + if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); + if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); + + // Identify myself as Marlin x.x.x + SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION); + #if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR) + SERIAL_ECHO_MSG( + " Last Updated: " STRING_DISTRIBUTION_DATE + " | Author: " STRING_CONFIG_H_AUTHOR + ); + #endif + SERIAL_ECHO_MSG(" Compiled: " __DATE__); + SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE)); + + // Some HAL need precise delay adjustment + calibrate_delay_loop(); + + // Init buzzer pin(s) + #if HAS_BEEPER + SETUP_RUN(buzzer.init()); + #endif + + // Set up LEDs early + #if HAS_COLOR_LEDS + SETUP_RUN(leds.setup()); + #endif + + #if ENABLED(NEOPIXEL2_SEPARATE) + SETUP_RUN(leds2.setup()); + #endif + + #if ENABLED(USE_CONTROLLER_FAN) // Set up fan controller to initialize also the default configurations. + SETUP_RUN(controllerFan.setup()); + #endif + + TERN_(HAS_FANCHECK, fan_check.init()); + + // UI must be initialized before EEPROM + // (because EEPROM code calls the UI). + + SETUP_RUN(ui.init()); + + #if PIN_EXISTS(SAFE_POWER) + #if HAS_DRIVER_SAFE_POWER_PROTECT + SETUP_RUN(stepper_driver_backward_check()); + #else + SETUP_LOG("SAFE_POWER"); + OUT_WRITE(SAFE_POWER_PIN, HIGH); + #endif + #endif + + #if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION) + SETUP_RUN(card.mount()); // Mount media with settings before first_load + #endif + + SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults) + // This also updates variables in the planner, elsewhere + + #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN) + SETUP_RUN(ui.show_bootscreen()); + const millis_t bootscreen_ms = millis(); + #endif + + #if ENABLED(PROBE_TARE) + SETUP_RUN(probe.tare_init()); + #endif + + #if HAS_ETHERNET + SETUP_RUN(ethernet.init()); + #endif + + #if HAS_TOUCH_BUTTONS + SETUP_RUN(touchBt.init()); + #endif + + TERN_(HAS_M206_COMMAND, current_position += home_offset); // Init current position based on home_offset + + sync_plan_position(); // Vital to init stepper/planner equivalent for current_position + + SETUP_RUN(thermalManager.init()); // Initialize temperature loop + + SETUP_RUN(print_job_timer.init()); // Initial setup of print job timer + + SETUP_RUN(endstops.init()); // Init endstops and pullups + + #if ENABLED(DELTA) && !HAS_SOFTWARE_ENDSTOPS + SETUP_RUN(refresh_delta_clip_start_height()); // Init safe delta height without soft endstops + #endif + + SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts! + + #if HAS_SERVOS + SETUP_RUN(servo_init()); + #endif + + #if HAS_Z_SERVO_PROBE + SETUP_RUN(probe.servo_probe_init()); + #endif + + #if HAS_PHOTOGRAPH + OUT_WRITE(PHOTOGRAPH_PIN, LOW); + #endif + + #if HAS_CUTTER + SETUP_RUN(cutter.init()); + #endif + + #if ENABLED(COOLANT_MIST) + OUT_WRITE(COOLANT_MIST_PIN, COOLANT_MIST_INVERT); // Init Mist Coolant OFF + #endif + #if ENABLED(COOLANT_FLOOD) + OUT_WRITE(COOLANT_FLOOD_PIN, COOLANT_FLOOD_INVERT); // Init Flood Coolant OFF + #endif + + #if HAS_BED_PROBE + #if PIN_EXISTS(PROBE_ENABLE) + OUT_WRITE(PROBE_ENABLE_PIN, LOW); // Disable + #endif + SETUP_RUN(endstops.enable_z_probe(false)); + #endif + + #if HAS_STEPPER_RESET + SETUP_RUN(enableStepperDrivers()); + #endif + + #if HAS_MOTOR_CURRENT_I2C + SETUP_RUN(digipot_i2c.init()); + #endif + + #if HAS_MOTOR_CURRENT_DAC + SETUP_RUN(stepper_dac.init()); + #endif + + #if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1 + OUT_WRITE(SOL1_PIN, LOW); // OFF + #endif + + #if HAS_HOME + SET_INPUT_PULLUP(HOME_PIN); + #endif + + #if ENABLED(CUSTOM_USER_BUTTONS) + #define INIT_CUSTOM_USER_BUTTON_PIN(N) do{ SET_INPUT(BUTTON##N##_PIN); WRITE(BUTTON##N##_PIN, !BUTTON##N##_HIT_STATE); }while(0) + + #if HAS_CUSTOM_USER_BUTTON(1) + INIT_CUSTOM_USER_BUTTON_PIN(1); + #endif + #if HAS_CUSTOM_USER_BUTTON(2) + INIT_CUSTOM_USER_BUTTON_PIN(2); + #endif + #if HAS_CUSTOM_USER_BUTTON(3) + INIT_CUSTOM_USER_BUTTON_PIN(3); + #endif + #if HAS_CUSTOM_USER_BUTTON(4) + INIT_CUSTOM_USER_BUTTON_PIN(4); + #endif + #if HAS_CUSTOM_USER_BUTTON(5) + INIT_CUSTOM_USER_BUTTON_PIN(5); + #endif + #if HAS_CUSTOM_USER_BUTTON(6) + INIT_CUSTOM_USER_BUTTON_PIN(6); + #endif + #if HAS_CUSTOM_USER_BUTTON(7) + INIT_CUSTOM_USER_BUTTON_PIN(7); + #endif + #if HAS_CUSTOM_USER_BUTTON(8) + INIT_CUSTOM_USER_BUTTON_PIN(8); + #endif + #if HAS_CUSTOM_USER_BUTTON(9) + INIT_CUSTOM_USER_BUTTON_PIN(9); + #endif + #if HAS_CUSTOM_USER_BUTTON(10) + INIT_CUSTOM_USER_BUTTON_PIN(10); + #endif + #if HAS_CUSTOM_USER_BUTTON(11) + INIT_CUSTOM_USER_BUTTON_PIN(11); + #endif + #if HAS_CUSTOM_USER_BUTTON(12) + INIT_CUSTOM_USER_BUTTON_PIN(12); + #endif + #if HAS_CUSTOM_USER_BUTTON(13) + INIT_CUSTOM_USER_BUTTON_PIN(13); + #endif + #if HAS_CUSTOM_USER_BUTTON(14) + INIT_CUSTOM_USER_BUTTON_PIN(14); + #endif + #if HAS_CUSTOM_USER_BUTTON(15) + INIT_CUSTOM_USER_BUTTON_PIN(15); + #endif + #if HAS_CUSTOM_USER_BUTTON(16) + INIT_CUSTOM_USER_BUTTON_PIN(16); + #endif + #if HAS_CUSTOM_USER_BUTTON(17) + INIT_CUSTOM_USER_BUTTON_PIN(17); + #endif + #if HAS_CUSTOM_USER_BUTTON(18) + INIT_CUSTOM_USER_BUTTON_PIN(18); + #endif + #if HAS_CUSTOM_USER_BUTTON(19) + INIT_CUSTOM_USER_BUTTON_PIN(19); + #endif + #if HAS_CUSTOM_USER_BUTTON(20) + INIT_CUSTOM_USER_BUTTON_PIN(20); + #endif + #if HAS_CUSTOM_USER_BUTTON(21) + INIT_CUSTOM_USER_BUTTON_PIN(21); + #endif + #if HAS_CUSTOM_USER_BUTTON(22) + INIT_CUSTOM_USER_BUTTON_PIN(22); + #endif + #if HAS_CUSTOM_USER_BUTTON(23) + INIT_CUSTOM_USER_BUTTON_PIN(23); + #endif + #if HAS_CUSTOM_USER_BUTTON(24) + INIT_CUSTOM_USER_BUTTON_PIN(24); + #endif + #if HAS_CUSTOM_USER_BUTTON(25) + INIT_CUSTOM_USER_BUTTON_PIN(25); + #endif + #endif + + #if PIN_EXISTS(STAT_LED_RED) + OUT_WRITE(STAT_LED_RED_PIN, LOW); // OFF + #endif + #if PIN_EXISTS(STAT_LED_BLUE) + OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // OFF + #endif + + #if ENABLED(CASE_LIGHT_ENABLE) + SETUP_RUN(caselight.init()); + #endif + + #if HAS_PRUSA_MMU1 + SETUP_RUN(mmu_init()); + #endif + + #if HAS_FANMUX + SETUP_RUN(fanmux_init()); + #endif + + #if ENABLED(MIXING_EXTRUDER) + SETUP_RUN(mixer.init()); + #endif + + #if ENABLED(BLTOUCH) + SETUP_RUN(bltouch.init(/*set_voltage=*/true)); + #endif + + #if ENABLED(MAGLEV4) + OUT_WRITE(MAGLEV_TRIGGER_PIN, LOW); + #endif + + #if ENABLED(I2C_POSITION_ENCODERS) + SETUP_RUN(I2CPEM.init()); + #endif + + #if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0 + SETUP_LOG("i2c..."); + i2c.onReceive(i2c_on_receive); + i2c.onRequest(i2c_on_request); + #endif + + #if DO_SWITCH_EXTRUDER + SETUP_RUN(move_extruder_servo(0)); // Initialize extruder servo + #endif + + #if ENABLED(SWITCHING_NOZZLE) + SETUP_LOG("SWITCHING_NOZZLE"); + // Initialize nozzle servo(s) + #if SWITCHING_NOZZLE_TWO_SERVOS + lower_nozzle(0); + raise_nozzle(1); + #else + move_nozzle_servo(0); + #endif + #endif + + #if ENABLED(PARKING_EXTRUDER) + SETUP_RUN(pe_solenoid_init()); + #elif ENABLED(MAGNETIC_PARKING_EXTRUDER) + SETUP_RUN(mpe_settings_init()); + #elif ENABLED(SWITCHING_TOOLHEAD) + SETUP_RUN(swt_init()); + #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) + SETUP_RUN(est_init()); + #endif + + #if ENABLED(USE_WATCHDOG) + SETUP_RUN(hal.watchdog_init()); // Reinit watchdog after hal.get_reset_source call + #endif + + #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) + SETUP_RUN(closedloop.init()); + #endif + + #ifdef STARTUP_COMMANDS + SETUP_LOG("STARTUP_COMMANDS"); + queue.inject(F(STARTUP_COMMANDS)); + #endif + + #if ENABLED(HOST_PROMPT_SUPPORT) + SETUP_RUN(hostui.prompt_end()); + #endif + + #if HAS_DRIVER_SAFE_POWER_PROTECT + SETUP_RUN(stepper_driver_backward_report()); + #endif + + #if HAS_PRUSA_MMU2 + SETUP_RUN(mmu2.init()); + #endif + + #if ENABLED(IIC_BL24CXX_EEPROM) + BL24CXX::init(); + const uint8_t err = BL24CXX::check(); + SERIAL_ECHO_TERNARY(err, "BL24CXX Check ", "failed", "succeeded", "!\n"); + #endif + + #if HAS_DWIN_E3V2_BASIC + SETUP_RUN(DWIN_InitScreen()); + #endif + + #if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC + SETUP_RUN(ui.reset_status(true)); // Show service messages or keep current status + #endif + + #if ENABLED(MAX7219_DEBUG) + SETUP_RUN(max7219.init()); + #endif + + #if ENABLED(DIRECT_STEPPING) + SETUP_RUN(page_manager.init()); + #endif + + #if HAS_TFT_LVGL_UI + #if ENABLED(SDSUPPORT) + if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts + #endif + SETUP_RUN(tft_lvgl_init()); + #endif + + #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN) + const millis_t elapsed = millis() - bootscreen_ms; + #if ENABLED(MARLIN_DEV_MODE) + SERIAL_ECHOLNPGM("elapsed=", elapsed); + #endif + SETUP_RUN(ui.bootscreen_completion(elapsed)); + #endif + + #if ENABLED(PASSWORD_ON_STARTUP) + SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided + #endif + + #if BOTH(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI) + SETUP_RUN(ui.check_touch_calibration()); + #endif + + #if ENABLED(EASYTHREED_UI) + SETUP_RUN(easythreed_ui.init()); + #endif + + #if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF) + SETUP_RUN(test_tmc_connection()); + #endif + + marlin_state = MF_RUNNING; + + SETUP_LOG("setup() completed."); +} + +/** + * The main Marlin program loop + * + * - Call idle() to handle all tasks between G-code commands + * Note that no G-codes from the queue can be executed during idle() + * but many G-codes can be called directly anytime like macros. + * - Check whether SD card auto-start is needed now. + * - Check whether SD print finishing is needed now. + * - Run one G-code command from the immediate or main command queue + * and open up one space. Commands in the main queue may come from sd + * card, host, or by direct injection. The queue will continue to fill + * as long as idle() or manage_inactivity() are being called. + */ +void loop() { + do { + idle(); + + #if ENABLED(SDSUPPORT) + if (card.flag.abort_sd_printing) abortSDPrinting(); + if (marlin_state == MF_SD_COMPLETE) finishSDPrinting(); + #endif + + queue.advance(); + + #if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + powerManager.checkAutoPowerOff(); + #endif + + endstops.event_handler(); + + TERN_(HAS_TFT_LVGL_UI, printer_state_polling()); + + } while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards +} diff --git a/src/MarlinCore.h b/src/MarlinCore.h new file mode 100644 index 0000000..f80405a --- /dev/null +++ b/src/MarlinCore.h @@ -0,0 +1,86 @@ +/** + * 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 . + * + */ +#pragma once + +#include "inc/MarlinConfig.h" + +#include +#include +#include + +void stop(); + +// Pass true to keep steppers from timing out +void idle(bool no_stepper_sleep=false); +inline void idle_no_sleep() { idle(true); } + +#if ENABLED(G38_PROBE_TARGET) + extern uint8_t G38_move; // Flag to tell the ISR that G38 is in progress, and the type + extern bool G38_did_trigger; // Flag from the ISR to indicate the endstop changed +#endif + +void kill(FSTR_P const lcd_error=nullptr, FSTR_P const lcd_component=nullptr, const bool steppers_off=false); +void minkill(const bool steppers_off=false); + +// Global State of the firmware +enum MarlinState : uint8_t { + MF_INITIALIZING = 0, + MF_STOPPED, + MF_KILLED, + MF_RUNNING, + MF_SD_COMPLETE, + MF_PAUSED, + MF_WAITING, +}; + +extern MarlinState marlin_state; +inline bool IsRunning() { return marlin_state >= MF_RUNNING; } +inline bool IsStopped() { return marlin_state == MF_STOPPED; } + +bool printingIsActive(); +bool printJobOngoing(); +bool printingIsPaused(); +void startOrResumeJob(); + +bool printer_busy(); + +extern bool wait_for_heatup; + +#if HAS_RESUME_CONTINUE + extern bool wait_for_user; + void wait_for_user_response(millis_t ms=0, const bool no_sleep=false); +#endif + +bool pin_is_protected(const pin_t pin); + +#if HAS_SUICIDE + inline void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_STATE); } +#endif + +#if HAS_KILL + #ifndef KILL_PIN_STATE + #define KILL_PIN_STATE LOW + #endif + inline bool kill_state() { return READ(KILL_PIN) == KILL_PIN_STATE; } +#endif + +extern const char M112_KILL_STR[]; diff --git a/src/pins/esp32/env_validate.h b/src/pins/esp32/env_validate.h new file mode 100644 index 0000000..ce14c33 --- /dev/null +++ b/src/pins/esp32/env_validate.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(ARDUINO_ARCH_ESP32) + #error "Oops! Select an ESP32 board in 'Tools > Board.'" +#endif diff --git a/src/pins/esp32/pins_E4D.h b/src/pins/esp32/pins_E4D.h new file mode 100644 index 0000000..d12b527 --- /dev/null +++ b/src/pins/esp32/pins_E4D.h @@ -0,0 +1,103 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * E4d@box pin assignments + * + * Small factor 3D printer control board based on the ESP32 microcontroller for Laser, CNC and 3D printers. + * More info at https://atbox.tech/ and the E4d@box Facebook page. + */ + +#include "env_validate.h" + +#if EXTRUDERS > 1 || E_STEPPERS > 1 + #error "E4d@box only supports 1 E stepper." +#elif HAS_MULTI_HOTEND + #error "E4d@box only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "E4d@box" +#define BOARD_WEBSITE_URL "github.com/Exilaus/E4d@box" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Redefine I2S for ESP32 +// +#undef I2S_WS +#undef I2S_BCK +#undef I2S_DATA +#define I2S_WS 23 +#define I2S_BCK 22 +#define I2S_DATA 21 + +// +// Limit Switches +// +#define X_STOP_PIN 34 +#define Y_STOP_PIN 35 +#define Z_STOP_PIN 16 + +// +// Steppers +// +#define X_STEP_PIN 12 +#define X_DIR_PIN 13 +#define X_ENABLE_PIN 17 +//#define X_CS_PIN 0 + +#define Y_STEP_PIN 32 +#define Y_DIR_PIN 33 +#define Y_ENABLE_PIN X_ENABLE_PIN +//#define Y_CS_PIN 13 + +#define Z_STEP_PIN 25 +#define Z_DIR_PIN 26 +#define Z_ENABLE_PIN X_ENABLE_PIN +//#define Z_CS_PIN 5 // SS_PIN + +#define E0_STEP_PIN 27 +#define E0_DIR_PIN 14 +#define E0_ENABLE_PIN X_ENABLE_PIN +//#define E0_CS_PIN 21 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 36 // Analog Input +#define TEMP_BED_PIN 39 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define FAN_PIN 0 +#define HEATER_BED_PIN 15 + +// +// MicroSD card on SPI +// +#define SD_MOSI_PIN 23 +#define SD_MISO_PIN 19 +#define SD_SCK_PIN 18 +#define SDSS 5 +#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers diff --git a/src/pins/esp32/pins_ENWI_ESPNP.h b/src/pins/esp32/pins_ENWI_ESPNP.h new file mode 100644 index 0000000..80923d9 --- /dev/null +++ b/src/pins/esp32/pins_ENWI_ESPNP.h @@ -0,0 +1,118 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Espressif ESP32 (Tensilica Xtensa LX6) on ESPNP by enwi + * Website https://github.com/enwi/ESPNP + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "ESPNP" +#define DEFAULT_MACHINE_NAME "ESP Pick and Place" + +// +// I2S (steppers & other output-only pins) +// +#define I2S_STEPPER_STREAM +#if ENABLED(I2S_STEPPER_STREAM) + #define I2S_WS 17 + #define I2S_BCK 22 + #define I2S_DATA 21 +#endif + +// +// Servos +// +#define SERVO0_PIN 26 +#define SERVO1_PIN 25 + +// +// Limit Switches +// +#define X_STOP_PIN 36 +#define Y_STOP_PIN 39 +#define Z_STOP_PIN 34 +#define I_STOP_PIN 35 +#define J_STOP_PIN 05 +#define K_STOP_PIN 16 + +// +// Steppers +// +#define X_ENABLE_PIN 136 +#define X_DIR_PIN 137 +#define X_STEP_PIN 138 +#define X_CS_PIN 139 + +#define Y_ENABLE_PIN 140 +#define Y_DIR_PIN 141 +#define Y_STEP_PIN 142 +#define Y_CS_PIN 143 + +#define Z_ENABLE_PIN 144 +#define Z_DIR_PIN 145 +#define Z_STEP_PIN 146 +#define Z_CS_PIN 147 + +#define I_ENABLE_PIN 148 +#define I_DIR_PIN 149 +#define I_STEP_PIN 150 +#define I_CS_PIN 151 + +#define J_ENABLE_PIN 152 +#define J_DIR_PIN 153 +#define J_STEP_PIN 154 +#define J_CS_PIN 155 + +#define K_ENABLE_PIN 156 +#define K_DIR_PIN 157 +#define K_STEP_PIN 158 +#define K_CS_PIN 159 + +// Reduce baud rate to improve software serial reliability +#define TMC_BAUD_RATE 19200 + +// +// Temperature Sensors +// +//#define TEMP_0_PIN 36 // Analog Input +//#define TEMP_BED_PIN 39 // Analog Input + +// General use mosfets, useful for things like pumps and solenoids +// Shift register pins 128, 129, 130 and 131 are broken out and can be used +#define FAN_PIN 132 +#define FAN1_PIN 134 +#define FAN2_PIN 135 +#define FAN3_PIN 136 + +// #define FAN_SOFT_PWM_REQUIRED // check if needed + +// Neopixel Rings +#define NEOPIXEL_PIN 14 +#define NEOPIXEL2_PIN 27 + +// SPI +#define MISO_PIN 19 +#define MOSI_PIN 23 +#define SCK_PIN 18 diff --git a/src/pins/esp32/pins_ESP32.h b/src/pins/esp32/pins_ESP32.h new file mode 100644 index 0000000..266de7e --- /dev/null +++ b/src/pins/esp32/pins_ESP32.h @@ -0,0 +1,86 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Espressif ESP32 (Tensilica Xtensa LX6) pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Espressif ESP32" + +// +// I2S (steppers & other output-only pins) +// +#define I2S_STEPPER_STREAM +#if ENABLED(I2S_STEPPER_STREAM) + #define I2S_WS 25 + #define I2S_BCK 26 + #define I2S_DATA 27 +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 34 +#define Y_MIN_PIN 35 +#define Z_MIN_PIN 15 + +// +// Steppers +// +#define X_STEP_PIN 128 +#define X_DIR_PIN 129 +#define X_ENABLE_PIN 130 +//#define X_CS_PIN 0 + +#define Y_STEP_PIN 131 +#define Y_DIR_PIN 132 +#define Y_ENABLE_PIN 133 +//#define Y_CS_PIN 13 + +#define Z_STEP_PIN 134 +#define Z_DIR_PIN 135 +#define Z_ENABLE_PIN 136 +//#define Z_CS_PIN 5 // SS_PIN + +#define E0_STEP_PIN 137 +#define E0_DIR_PIN 138 +#define E0_ENABLE_PIN 139 +//#define E0_CS_PIN 21 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 36 // Analog Input +#define TEMP_BED_PIN 39 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define FAN_PIN 13 +#define HEATER_BED_PIN 4 + +// SPI +#define SDSS 5 diff --git a/src/pins/esp32/pins_ESPA_common.h b/src/pins/esp32/pins_ESPA_common.h new file mode 100644 index 0000000..ca949cd --- /dev/null +++ b/src/pins/esp32/pins_ESPA_common.h @@ -0,0 +1,81 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * ESPA-like pin assignments + * Supports 4 stepper drivers, heated bed, single hotend. + */ + +#include "env_validate.h" + +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#endif + +// +// Limit Switches +// +#define X_STOP_PIN 34 +#define Y_STOP_PIN 35 +#define Z_STOP_PIN 15 + +// +// Steppers +// +#define X_STEP_PIN 27 +#define X_DIR_PIN 26 +#define X_ENABLE_PIN 25 + +#define Y_STEP_PIN 33 +#define Y_DIR_PIN 32 +#define Y_ENABLE_PIN X_ENABLE_PIN + +#define Z_STEP_PIN 14 +#define Z_DIR_PIN 12 +#define Z_ENABLE_PIN X_ENABLE_PIN + +#define E0_STEP_PIN 16 +#define E0_DIR_PIN 17 +#define E0_ENABLE_PIN X_ENABLE_PIN + +// +// Temperature Sensors +// +#define TEMP_0_PIN 36 // Analog Input +#define TEMP_BED_PIN 39 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define FAN_PIN 13 +#define HEATER_BED_PIN 4 + +// +// MicroSD card +// +#define SD_MOSI_PIN 23 +#define SD_MISO_PIN 19 +#define SD_SCK_PIN 18 +#define SDSS 5 +#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers diff --git a/src/pins/esp32/pins_FYSETC_E4.h b/src/pins/esp32/pins_FYSETC_E4.h new file mode 100644 index 0000000..7dc5997 --- /dev/null +++ b/src/pins/esp32/pins_FYSETC_E4.h @@ -0,0 +1,72 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * FYSETC E4 pin assignments + * + * 3D printer control board based on the ESP32 microcontroller. + * Supports 4 stepper drivers, heated bed, single hotend. + */ + +#include "env_validate.h" + +#if EXTRUDERS > 1 || E_STEPPERS > 1 + #error "FYSETC E4 only supports 1 E stepper." +#elif HAS_MULTI_HOTEND + #error "FYSETC E4 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "FYSETC_E4" + +#include "pins_ESPA_common.h" + +#if HAS_TMC_UART + // + // TMC2209 stepper drivers + // + + // + // Hardware serial 1 + // + #define X_HARDWARE_SERIAL Serial1 + #define Y_HARDWARE_SERIAL Serial1 + #define Z_HARDWARE_SERIAL Serial1 + #define E0_HARDWARE_SERIAL Serial1 + + #define TMC_BAUD_RATE 115200 +#endif + +/** + * Hardware serial pins + * + * Override these pins in Configuration.h or Configuration_adv.h if needed. + * + * Note: Serial2 can be defined using HARDWARE_SERIAL2_RX and HARDWARE_SERIAL2_TX + * but MRR ESPA does not have enough spare pins for such reassignment. + */ +#ifndef HARDWARE_SERIAL1_RX + #define HARDWARE_SERIAL1_RX 21 +#endif +#ifndef HARDWARE_SERIAL1_TX + #define HARDWARE_SERIAL1_TX 22 +#endif diff --git a/src/pins/esp32/pins_MKS_TINYBEE.h b/src/pins/esp32/pins_MKS_TINYBEE.h new file mode 100644 index 0000000..04210bb --- /dev/null +++ b/src/pins/esp32/pins_MKS_TINYBEE.h @@ -0,0 +1,193 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * MRR ESPE pin assignments + * MRR ESPE is a 3D printer control board based on the ESP32 microcontroller. + * Supports 5 stepper drivers (using I2S stepper stream), heated bed, + * single hotend, and LCD controller. + */ + +#include "env_validate.h" + +#if EXTRUDERS > 2 || E_STEPPERS > 2 + #error "MKS TinyBee supports up to 2 E steppers." +#elif HOTENDS > 2 + #error "MKS TinyBee supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS TinyBee" +#define BOARD_WEBSITE_URL "https://github.com/makerbase-mks" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// MAX_EXPANDER_BITS is defined for MKS TinyBee in HAL/ESP32/inc/Conditionals_adv.h + +// +// Servos +// +#define SERVO0_PIN 2 + +// +// Limit Switches +// +#define X_STOP_PIN 33 +#define Y_STOP_PIN 32 +#define Z_STOP_PIN 22 +//#define FIL_RUNOUT_PIN 35 + +// +// Enable I2S stepper stream +// +#define I2S_STEPPER_STREAM +#if ENABLED(I2S_STEPPER_STREAM) + #define I2S_WS 26 + #define I2S_BCK 25 + #define I2S_DATA 27 +#endif + +// +// Steppers +// +#define X_STEP_PIN 129 +#define X_DIR_PIN 130 +#define X_ENABLE_PIN 128 + +#define Y_STEP_PIN 132 +#define Y_DIR_PIN 133 +#define Y_ENABLE_PIN 131 + +#define Z_STEP_PIN 135 +#define Z_DIR_PIN 136 +#define Z_ENABLE_PIN 134 + +#define E0_STEP_PIN 138 +#define E0_DIR_PIN 139 +#define E0_ENABLE_PIN 137 + +#define E1_STEP_PIN 141 +#define E1_DIR_PIN 142 +#define E1_ENABLE_PIN 140 + +#define Z2_STEP_PIN 141 +#define Z2_DIR_PIN 142 +#define Z2_ENABLE_PIN 140 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 36 // Analog Input +#define TEMP_1_PIN 34 // Analog Input, you need set R6=0Ω and R7=NC +#define TEMP_BED_PIN 39 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 145 +#define HEATER_1_PIN 146 +#define FAN_PIN 147 +#define FAN1_PIN 148 +#define HEATER_BED_PIN 144 + +//#define CONTROLLER_FAN_PIN 148 +//#define E0_AUTO_FAN_PIN 148 // need to update Configuration_adv.h @section extruder +//#define E1_AUTO_FAN_PIN 149 // need to update Configuration_adv.h @section extruder + +// +// ADC Reference Voltage +// +#define ADC_REFERENCE_VOLTAGE 2.565 // 2.5V reference VDDA + +/** + * ------ ------ + * (BEEPER) 149 | 1 2 | 13 (BTN_ENC) (SPI MISO) 19 | 1 2 | 18 (SPI SCK) + * (LCD_EN) 21 | 3 4 | 4 (LCD_RS) (BTN_EN1) 14 | 3 4 | 5 (SPI CS) + * (LCD_D4) 0 5 6 | 16 (LCD_D5) (BTN_EN2) 12 5 6 | 23 (SPI MOSI) + * (LCD_D6) 15 | 7 8 | 17 (LCD_D7) (SPI_DET) 34 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V + * ------ ------ + * EXP1 EXP2 + */ + +#define EXP1_01_PIN 149 +#define EXP1_02_PIN 13 +#define EXP1_03_PIN 21 +#define EXP1_04_PIN 4 +#define EXP1_05_PIN 0 +#define EXP1_06_PIN 16 +#define EXP1_07_PIN 15 +#define EXP1_08_PIN 17 + +#define EXP2_01_PIN 19 +#define EXP2_02_PIN 18 +#define EXP2_03_PIN 14 +#define EXP2_04_PIN 5 +#define EXP2_05_PIN 12 +#define EXP2_06_PIN 23 +#define EXP2_07_PIN 34 +#define EXP2_08_PIN -1 // RESET + +// +// MicroSD card +// +//#define SD_MOSI_PIN EXP2_06_PIN // uses esp32 default 23 +//#define SD_MISO_PIN EXP2_01_PIN // uses esp32 default 19 +//#define SD_SCK_PIN EXP2_02_PIN // uses esp32 default 18 +#define SDSS EXP2_04_PIN +#define SD_DETECT_PIN EXP2_07_PIN // IO34 default is SD_DET signal (Jump to SDDET) +#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers + +#if HAS_WIRED_LCD + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define LCD_BACKLIGHT_PIN -1 + + #if ENABLED(MKS_MINI_12864) + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define LCD_RESET_PIN -1 + #elif ENABLED(FYSETC_MINI_12864_2_1) + // MKS_MINI_12864_V3, BTT_MINI_12864_V1, FYSETC_MINI_12864_2_1 + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + #else + #define LCD_PINS_D4 EXP1_05_PIN + #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #endif + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 600 + #endif +#endif // HAS_WIRED_LCD diff --git a/src/pins/esp32/pins_MRR_ESPA.h b/src/pins/esp32/pins_MRR_ESPA.h new file mode 100644 index 0000000..e9e3db5 --- /dev/null +++ b/src/pins/esp32/pins_MRR_ESPA.h @@ -0,0 +1,58 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MRR ESPA pin assignments + * + * 3D printer control board based on the ESP32 microcontroller. + * Supports 4 stepper drivers, heated bed, single hotend. + */ + +#include "env_validate.h" + +#if EXTRUDERS > 1 || E_STEPPERS > 1 + #error "MRR ESPA only supports 1 E stepper." +#elif HAS_MULTI_HOTEND + #error "MRR ESPA only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "MRR ESPA" +#define BOARD_WEBSITE_URL "github.com/maplerainresearch/MRR_ESPA" + +#include "pins_ESPA_common.h" + +// +// Steppers +// +//#define X_CS_PIN 21 +//#define Y_CS_PIN 22 +//#define Z_CS_PIN 5 // SS_PIN +//#define E0_CS_PIN 21 + +// Hardware serial pins +// Add the following to Configuration.h or Configuration_adv.h to assign +// specific pins to hardware Serial1. +// Note: Serial2 can be defined using HARDWARE_SERIAL2_RX and HARDWARE_SERIAL2_TX but +// MRR ESPA does not have enough spare pins for such reassignment. +//#define HARDWARE_SERIAL1_RX 21 +//#define HARDWARE_SERIAL1_TX 22 diff --git a/src/pins/esp32/pins_MRR_ESPE.h b/src/pins/esp32/pins_MRR_ESPE.h new file mode 100644 index 0000000..f372de9 --- /dev/null +++ b/src/pins/esp32/pins_MRR_ESPE.h @@ -0,0 +1,164 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MRR ESPE pin assignments + * + * 3D printer control board based on the ESP32 microcontroller. + * Supports 5 stepper drivers (using I2S stepper stream), heated bed, + * single hotend, and LCD controller. + */ + +#include "env_validate.h" + +#if EXTRUDERS > 2 || E_STEPPERS > 2 + #error "MRR ESPE supports up to 2 E steppers." +#elif HAS_MULTI_HOTEND + #error "MRR ESPE only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "MRR ESPE" +#define BOARD_WEBSITE_URL "github.com/maplerainresearch/MRR_ESPE" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Limit Switches +// +#define X_STOP_PIN 35 +#define Y_STOP_PIN 32 +#define Z_STOP_PIN 33 + +// +// Enable I2S stepper stream +// +#define I2S_STEPPER_STREAM +#if ENABLED(I2S_STEPPER_STREAM) + #define I2S_WS 26 + #define I2S_BCK 25 + #define I2S_DATA 27 +#endif + +// +// Steppers +// +#define X_STEP_PIN 129 +#define X_DIR_PIN 130 +#define X_ENABLE_PIN 128 +//#define X_CS_PIN 21 + +#define Y_STEP_PIN 132 +#define Y_DIR_PIN 133 +#define Y_ENABLE_PIN 131 +//#define Y_CS_PIN 22 + +#define Z_STEP_PIN 135 +#define Z_DIR_PIN 136 +#define Z_ENABLE_PIN 134 +//#define Z_CS_PIN 5 // SS_PIN + +#define E0_STEP_PIN 138 +#define E0_DIR_PIN 139 +#define E0_ENABLE_PIN 137 +//#define E0_CS_PIN 21 + +#define E1_STEP_PIN 141 +#define E1_DIR_PIN 142 +#define E1_ENABLE_PIN 140 +//#define E1_CS_PIN 22 + +#define Z2_STEP_PIN 141 +#define Z2_DIR_PIN 142 +#define Z2_ENABLE_PIN 140 +//#define Z2_CS_PIN 5 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 36 // Analog Input +#define TEMP_1_PIN 34 // Analog Input +#define TEMP_BED_PIN 39 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 145 // 2 +#define FAN_PIN 146 // 15 +#define HEATER_BED_PIN 144 // 4 + +#define CONTROLLER_FAN_PIN 147 +//#define E0_AUTO_FAN_PIN 148 // need to update Configuration_adv.h @section extruder +//#define E1_AUTO_FAN_PIN 149 // need to update Configuration_adv.h @section extruder +#define FAN1_PIN 149 + +// +// MicroSD card +// +#define SD_MOSI_PIN 23 +#define SD_MISO_PIN 19 +#define SD_SCK_PIN 18 +#define SDSS 5 +#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +#if HAS_WIRED_LCD + + #define LCD_PINS_RS 13 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 16 + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN 151 + + #elif IS_RRD_FG_SC + + #define BEEPER_PIN 151 + + //#define LCD_PINS_D5 150 + //#define LCD_PINS_D6 152 + //#define LCD_PINS_D7 153 + + #else + + #error "Only CR10_STOCKDISPLAY and REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER are currently supported. Comment out this line to continue." + + #endif + + #define BTN_EN1 0 + #define BTN_EN2 12 + #define BTN_ENC 14 + +#endif // HAS_MARLINUI_U8GLIB + +// Hardware serial pins +// Add the following to Configuration.h or Configuration_adv.h to assign +// specific pins to hardware Serial1 and Serial2. +// Note: Serial2 can be defined using HARDWARE_SERIAL2_RX and HARDWARE_SERIAL2_TX but +// MRR ESPA does not have enough spare pins for such reassignment. +//#define HARDWARE_SERIAL1_RX 21 +//#define HARDWARE_SERIAL1_TX 22 +//#define HARDWARE_SERIAL2_RX 2 +//#define HARDWARE_SERIAL2_TX 4 diff --git a/src/pins/esp32/pins_PANDA_M4.h b/src/pins/esp32/pins_PANDA_M4.h new file mode 100644 index 0000000..5e2e72a --- /dev/null +++ b/src/pins/esp32/pins_PANDA_M4.h @@ -0,0 +1,38 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Panda M4 pin assignments + */ + +#define BOARD_INFO_NAME "Panda_M4" + +#include "pins_PANDA_common.h" + +// +// Steppers +// +#define X_ENABLE_PIN 115 +#define Y_ENABLE_PIN 114 +#define Z_ENABLE_PIN 113 +#define E0_ENABLE_PIN 112 diff --git a/src/pins/esp32/pins_PANDA_ZHU.h b/src/pins/esp32/pins_PANDA_ZHU.h new file mode 100644 index 0000000..4750057 --- /dev/null +++ b/src/pins/esp32/pins_PANDA_ZHU.h @@ -0,0 +1,61 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Panda ZHU pin assignments + */ + +#define BOARD_INFO_NAME "Panda_ZHU" + +#include "pins_PANDA_common.h" + +// +// Steppers +// +#define X_ENABLE_PIN 128 // Shared with all steppers +#define Y_ENABLE_PIN X_ENABLE_PIN +#define Z_ENABLE_PIN X_ENABLE_PIN +#define E0_ENABLE_PIN X_ENABLE_PIN + +//#define X_CS_PIN 0 +//#define Y_CS_PIN 13 +//#define Z_CS_PIN 5 // SS_PIN +//#define E0_CS_PIN 21 + +#define E1_STEP_PIN 115 +#define E1_DIR_PIN 114 +#define E1_ENABLE_PIN X_ENABLE_PIN + +#define E2_STEP_PIN 112 +#define E2_DIR_PIN 113 +#define E2_ENABLE_PIN X_ENABLE_PIN + +#define E3_STEP_PIN 110 +#define E3_DIR_PIN 111 +#define E3_ENABLE_PIN X_ENABLE_PIN + +#define E4_STEP_PIN 121 +#define E4_DIR_PIN 122 +#define E4_ENABLE_PIN X_ENABLE_PIN + +#define HEATER_1_PIN 123 diff --git a/src/pins/esp32/pins_PANDA_common.h b/src/pins/esp32/pins_PANDA_common.h new file mode 100644 index 0000000..afc9a78 --- /dev/null +++ b/src/pins/esp32/pins_PANDA_common.h @@ -0,0 +1,128 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Panda common pin assignments + */ + +#include "env_validate.h" + +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Servos +// +#define SERVO0_PIN 0 + +// +// Limit Switches +// +#define X_STOP_PIN 4 +#define Y_STOP_PIN 35 +#define Z_STOP_PIN 21 + +// +// Steppers +// +#define X_STEP_PIN 101 +#define X_DIR_PIN 100 + +#define Y_STEP_PIN 103 +#define Y_DIR_PIN 102 + +#define Z_STEP_PIN 105 +#define Z_DIR_PIN 104 + +#define E0_STEP_PIN 107 +#define E0_DIR_PIN 106 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 39 // Analog Input +#define TEMP_BED_PIN 36 // Analog Input + +#if ENABLED(MAX31856_PANDAPI) + #define MAX31856_CLK_PIN 29 + #define MAX31856_MISO_PIN 24 + #define MAX31856_MOSI_PIN 28 + #define MAX31856_CS_PIN 27 +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 108 +#define HEATER_BED_PIN 109 +#define FAN_PIN 118 // FAN0 +#define FAN1_PIN 119 // FAN1 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN 120 // FAN2 +#endif + +/** ------ ------ + * (MISO 19?) | 1 2 | (18 SCK?) (BEEPER) 129 | 1 2 | 12 (^ENC) + * (EN1) 33 | 3 4 | (5 SDSS?) (EN) 26 | 3 4 | 27 (RS) + * (EN2) 32 5 6 | (23 MOSI?) (D4) 14 | 5 6 -- + * (SDDET 2?) | 7 8 | (RESET) -- | 7 8 | -- + * -- | 9 10 | -- (GND) | 9 10 | (5V) + * ------ ------ + * EXP2 EXP1 + */ +#define EXP1_01_PIN 129 +#define EXP1_02_PIN 12 +#define EXP1_03_PIN 26 +#define EXP1_04_PIN 27 +#define EXP1_05_PIN 14 + +#define EXP2_01_PIN 19 // ? +#define EXP2_02_PIN 18 // ? +#define EXP2_03_PIN 33 +#define EXP2_04_PIN 5 // ? +#define EXP2_05_PIN 32 +#define EXP2_06_PIN 23 // ? +#define EXP2_07_PIN 2 // ? + +// +// SD Card +// +#if ENABLED(SDSUPPORT) + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN +#endif + +#if HAS_WIRED_LCD + #define BEEPER_PIN EXP1_01_PIN + + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN +#endif diff --git a/src/pins/esp32/pins_RESP32_CUSTOM.h b/src/pins/esp32/pins_RESP32_CUSTOM.h new file mode 100644 index 0000000..5d3f755 --- /dev/null +++ b/src/pins/esp32/pins_RESP32_CUSTOM.h @@ -0,0 +1,37 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Rutilea ESP32 (Tensilica Xtensa LX6) pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Rutilea ESP32" + +#include "pins_ESPA_common.h" + +// +// I2S (steppers & other output-only pins) +// +#define I2S_STEPPER_STREAM diff --git a/src/pins/linux/pins_RAMPS_LINUX.h b/src/pins/linux/pins_RAMPS_LINUX.h new file mode 100644 index 0000000..9e2eedd --- /dev/null +++ b/src/pins/linux/pins_RAMPS_LINUX.h @@ -0,0 +1,698 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega with RAMPS v1.4 (or v1.3) pin assignments + * + * Applies to the following boards: + * + * RAMPS_14_EFB (Hotend, Fan, Bed) + * RAMPS_14_EEB (Hotend0, Hotend1, Bed) + * RAMPS_14_EFF (Hotend, Fan0, Fan1) + * RAMPS_14_EEF (Hotend0, Hotend1, Fan) + * RAMPS_14_SF (Spindle, Controller Fan) + * + * RAMPS_13_EFB (Hotend, Fan, Bed) + * RAMPS_13_EEB (Hotend0, Hotend1, Bed) + * RAMPS_13_EFF (Hotend, Fan0, Fan1) + * RAMPS_13_EEF (Hotend0, Hotend1, Fan) + * RAMPS_13_SF (Spindle, Controller Fan) + * + * Other pins_MYBOARD.h files may override these defaults + * + * Differences between + * RAMPS_13 | RAMPS_14 + * 7 | 11 + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "RAMPS 1.4" +#endif + +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "SimRap 1.4" +#endif + +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Servos +// +#ifdef IS_RAMPS_13 + #define SERVO0_PIN 7 // RAMPS_13 // Will conflict with BTN_EN2 on LCD_I2C_VIKI +#else + #define SERVO0_PIN 11 +#endif +#define SERVO1_PIN 6 +#define SERVO2_PIN 5 +#ifndef SERVO3_PIN + #define SERVO3_PIN 4 +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#ifndef X_MAX_PIN + #define X_MAX_PIN 2 +#endif +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN 53 +#endif + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#ifndef Y_CS_PIN + #define Y_CS_PIN 49 +#endif + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 +#ifndef Z_CS_PIN + #define Z_CS_PIN 40 +#endif + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +#ifndef E0_CS_PIN + #define E0_CS_PIN 42 +#endif + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#ifndef E1_CS_PIN + #define E1_CS_PIN 44 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 1 // Analog Input +#define TEMP_BED_PIN 2 // Analog Input + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card +#else + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) +#endif + +// +// Heaters / Fans +// +#ifndef MOSFET_A_PIN + #define MOSFET_A_PIN 10 +#endif +#ifndef MOSFET_B_PIN + #define MOSFET_B_PIN 9 +#endif +#ifndef MOSFET_C_PIN + #define MOSFET_C_PIN 8 +#endif +#ifndef MOSFET_D_PIN + #define MOSFET_D_PIN -1 +#endif + +#define HEATER_0_PIN MOSFET_A_PIN + +#if FET_ORDER_EFB // Hotend, Fan, Bed + #define FAN_PIN MOSFET_B_PIN + #define HEATER_BED_PIN MOSFET_C_PIN +#elif FET_ORDER_EEF // Hotend, Hotend, Fan + #define HEATER_1_PIN MOSFET_B_PIN + #define FAN_PIN MOSFET_C_PIN +#elif FET_ORDER_EEB // Hotend, Hotend, Bed + #define HEATER_1_PIN MOSFET_B_PIN + #define HEATER_BED_PIN MOSFET_C_PIN +#elif FET_ORDER_EFF // Hotend, Fan, Fan + #define FAN_PIN MOSFET_B_PIN + #define FAN1_PIN MOSFET_C_PIN +#elif FET_ORDER_SF // Spindle, Fan + #define FAN_PIN MOSFET_C_PIN +#else // Non-specific are "EFB" (i.e., "EFBF" or "EFBE") + #define FAN_PIN MOSFET_B_PIN + #define HEATER_BED_PIN MOSFET_C_PIN + #if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #define FAN1_PIN MOSFET_D_PIN + #else + #define HEATER_1_PIN MOSFET_D_PIN + #endif +#endif + +#ifndef FAN_PIN + #define FAN_PIN 4 // IO pin. Buffer needed +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#define NEOPIXEL_PIN 71 + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 5 // Analog Input on AUX2 +#endif + +// define digital pin 4 for the filament runout sensor. Use the RAMPS 1.4 digital input 4 on the servos connector +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 21 +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN 12 +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN) + #if NUM_SERVOS <= 1 // Prefer the servo connector + #define CASE_LIGHT_PIN 6 // Hardware PWM + #elif HAS_FREE_AUX2_PINS // try to use AUX 2 + #define CASE_LIGHT_PIN 44 // Hardware PWM + #endif +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER && !PIN_EXISTS(SPINDLE_LASER_ENA) + #if !defined(NUM_SERVOS) || NUM_SERVOS == 0 // Prefer the servo connector + #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM + #define SPINDLE_DIR_PIN 5 + #elif HAS_FREE_AUX2_PINS // try to use AUX 2 + #define SPINDLE_LASER_ENA_PIN 40 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM + #define SPINDLE_DIR_PIN 65 + #endif +#endif + +// +// Průša i3 MK2 Multiplexer Support +// +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 40 // Z_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 42 // E0_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 44 // E1_CS_PIN + #endif +#endif + +/** + * Default pins for TMC software SPI + */ +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI 66 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO 44 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK 64 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + /** + * Software serial + */ + + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN 40 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN 63 + #endif + #ifndef X2_SERIAL_TX_PIN + #define X2_SERIAL_TX_PIN -1 + #endif + #ifndef X2_SERIAL_RX_PIN + #define X2_SERIAL_RX_PIN -1 + #endif + + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN 59 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN 64 + #endif + #ifndef Y2_SERIAL_TX_PIN + #define Y2_SERIAL_TX_PIN -1 + #endif + #ifndef Y2_SERIAL_RX_PIN + #define Y2_SERIAL_RX_PIN -1 + #endif + + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN 42 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN 65 + #endif + #ifndef Z2_SERIAL_TX_PIN + #define Z2_SERIAL_TX_PIN -1 + #endif + #ifndef Z2_SERIAL_RX_PIN + #define Z2_SERIAL_RX_PIN -1 + #endif + + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN 44 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN 66 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN -1 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN -1 + #endif + #ifndef E2_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN -1 + #endif + #ifndef E2_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN -1 + #endif + #ifndef E3_SERIAL_TX_PIN + #define E3_SERIAL_TX_PIN -1 + #endif + #ifndef E3_SERIAL_RX_PIN + #define E3_SERIAL_RX_PIN -1 + #endif + #ifndef E4_SERIAL_TX_PIN + #define E4_SERIAL_TX_PIN -1 + #endif + #ifndef E4_SERIAL_RX_PIN + #define E4_SERIAL_RX_PIN -1 + #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif +#endif + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +#if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI) + + #define TFT_A0_PIN 43 + #define TFT_CS_PIN 49 + #define TFT_DC_PIN 43 + #define TFT_SCK_PIN SD_SCK_PIN + #define TFT_MOSI_PIN SD_MOSI_PIN + #define TFT_MISO_PIN SD_MISO_PIN + #define LCD_USE_DMA_SPI + + #define BTN_EN1 40 + #define BTN_EN2 63 + #define BTN_ENC 59 + #define BEEPER_PIN 42 + + #define TOUCH_CS_PIN 33 + + #define SD_DETECT_PIN 41 + + #define HAS_SPI_FLASH 1 + #if HAS_SPI_FLASH + #define SPI_DEVICE 1 + #define SPI_FLASH_SIZE 0x1000000 // 16MB + #define SPI_FLASH_CS_PIN 31 + #define SPI_FLASH_MOSI_PIN SD_MOSI_PIN + #define SPI_FLASH_MISO_PIN SD_MISO_PIN + #define SPI_FLASH_SCK_PIN SD_SCK_PIN + #endif + + #define TFT_BUFFER_SIZE 0xFFFF + #ifndef TFT_DRIVER + #define TFT_DRIVER ST7796 + #endif + #ifndef TOUCH_SCREEN_CALIBRATION + #if ENABLED(TFT_RES_320x240) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 20525 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 15335 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X -1 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 0 + #endif + #elif ENABLED(TFT_RES_480x272) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 30715 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 17415 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 0 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -1 + #endif + #elif ENABLED(TFT_RES_480x320) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 30595 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 20415 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 2 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 1 + #endif + #endif + #endif + + #define BTN_BACK 70 + +#elif HAS_WIRED_LCD + + // + // LCD Display output pins + // + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define LCD_PINS_RS 49 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE 51 // SID (MOSI) + #define LCD_PINS_D4 52 // SCK (CLK) clock + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + #define LCD_PINS_RS 40 + #define LCD_PINS_ENABLE 42 + #define LCD_PINS_D4 65 + #define LCD_PINS_D5 66 + #define LCD_PINS_D6 44 + #define LCD_PINS_D7 64 + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS 27 + #define LCD_PINS_ENABLE 29 + #define LCD_PINS_D4 25 + + #if !IS_NEWPANEL + #define BEEPER_PIN 37 + #endif + + #elif ENABLED(ZONESTAR_LCD) + + #define LCD_PINS_RS 64 + #define LCD_PINS_ENABLE 44 + #define LCD_PINS_D4 63 + #define LCD_PINS_D5 40 + #define LCD_PINS_D6 42 + #define LCD_PINS_D7 65 + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + #define LCD_PINS_DC 25 // Set as output on init + #define LCD_PINS_RS 27 // Pull low for 1s to init + // DOGM SPI LCD Support + #define DOGLCD_CS 16 + #define DOGLCD_MOSI 17 + #define DOGLCD_SCK 23 + #define DOGLCD_A0 LCD_PINS_DC + #else + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #endif + + #define LCD_PINS_D7 29 + + #if !IS_NEWPANEL + #define BEEPER_PIN 33 + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN 38 + //#define SHIFT_LD_PIN 42 + //#define SHIFT_OUT_PIN 40 + //#define SHIFT_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + + #define BEEPER_PIN 37 + + #if ENABLED(CR10_STOCKDISPLAY) + #define BTN_EN1 17 + #define BTN_EN2 23 + #else + #define BTN_EN1 31 + #define BTN_EN2 33 + #endif + + #define BTN_ENC 35 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + #define LCD_BACKLIGHT_PIN 39 + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #define SD_DETECT_PIN 42 + + #elif ENABLED(LCD_I2C_PANELOLU2) + + #define BTN_EN1 47 + #define BTN_EN2 43 + #define BTN_ENC 32 + #define LCD_SDSS SDSS + #define KILL_PIN 41 + + #elif ENABLED(LCD_I2C_VIKI) + + #define BTN_EN1 22 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + #define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13. + #define BTN_ENC -1 + + #define LCD_SDSS SDSS + #define SD_DETECT_PIN 49 + + #elif EITHER(VIKI2, miniVIKI) + + #define DOGLCD_CS 45 + #define DOGLCD_A0 44 + + #define BEEPER_PIN 33 + #define STAT_LED_RED_PIN 32 + #define STAT_LED_BLUE_PIN 35 + + #define BTN_EN1 22 + #define BTN_EN2 7 + #define BTN_ENC 39 + + #define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board + #define KILL_PIN 31 + + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + #define DOGLCD_CS 29 + #define DOGLCD_A0 27 + + #define BEEPER_PIN 23 + #define LCD_BACKLIGHT_PIN 33 + + #define BTN_EN1 35 + #define BTN_EN2 37 + #define BTN_ENC 31 + + #define LCD_SDSS SDSS + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 27 + #define DOGLCD_CS 25 + + #define BEEPER_PIN 37 + // not connected to a pin + #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 + + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + + #define SD_DETECT_PIN 49 + #define KILL_PIN 64 + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(MINIPANEL) + + #define BEEPER_PIN 42 + // not connected to a pin + #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 + + #define DOGLCD_A0 44 + #define DOGLCD_CS 66 + + #define BTN_EN1 40 + #define BTN_EN2 63 + #define BTN_ENC 59 + + #define SD_DETECT_PIN 49 + #define KILL_PIN 64 + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(ZONESTAR_LCD) + + #define ADC_KEYPAD_PIN 12 + + #elif ENABLED(AZSMZ_12864) + + // Pins only defined for RAMPS_SMART currently + + #else + + // Beeper on AUX-4 + #define BEEPER_PIN 33 + + // Buttons are directly attached to AUX-2 + #if IS_RRW_KEYPAD + #define SHIFT_OUT_PIN 40 + #define SHIFT_CLK_PIN 44 + #define SHIFT_LD_PIN 42 + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #elif ENABLED(PANEL_ONE) + #define BTN_EN1 59 // AUX2 PIN 3 + #define BTN_EN2 63 // AUX2 PIN 4 + #define BTN_ENC 49 // AUX3 PIN 7 + #else + #define BTN_EN1 37 + #define BTN_EN2 35 + #define BTN_ENC 31 + #define SD_DETECT_PIN 41 + #endif + + #if ENABLED(G3D_PANEL) + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 + #endif + #endif + + // CUSTOM SIMULATOR INPUTS + #define BTN_BACK 70 + + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD diff --git a/src/pins/lpc1768/env_validate.h b/src/pins/lpc1768/env_validate.h new file mode 100644 index 0000000..adb3ea9 --- /dev/null +++ b/src/pins/lpc1768/env_validate.h @@ -0,0 +1,30 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if ENABLED(REQUIRE_LPC1769) && NOT_TARGET(MCU_LPC1769) + #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." +#elif DISABLED(REQUIRE_LPC1769) && NOT_TARGET(MCU_LPC1768) + #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." +#endif + +#undef REQUIRE_LPC1769 diff --git a/src/pins/lpc1768/pins_AZSMZ_MINI.h b/src/pins/lpc1768/pins_AZSMZ_MINI.h new file mode 100644 index 0000000..4d1dbec --- /dev/null +++ b/src/pins/lpc1768/pins_AZSMZ_MINI.h @@ -0,0 +1,159 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * AZSMZ MINI pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "AZSMZ Mini" + +// +// Servos +// +#define SERVO0_PIN P1_23 + +// +// Limit Switches +// +#define X_STOP_PIN P1_24 +#define Y_STOP_PIN P1_26 +#define Z_MIN_PIN P1_28 +#define Z_MAX_PIN P1_29 + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P0_04 + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P0_11 +#define Y_ENABLE_PIN P0_10 + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P0_20 +#define Z_ENABLE_PIN P0_19 + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P0_22 +#define E0_ENABLE_PIN P0_21 + +#define E1_STEP_PIN P2_08 +#define E1_DIR_PIN P2_13 +#define E1_ENABLE_PIN P4_29 + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_23_A0 // A0 (TH1) +#define TEMP_BED_PIN P0_24_A1 // A1 (TH2) +#define TEMP_1_PIN P0_25_A2 // A2 (TH3) + +// +// Heaters / Fans +// + +// EFB +#define HEATER_0_PIN P2_04 +#define HEATER_BED_PIN P2_05 +#ifndef FAN_PIN + #define FAN_PIN P2_07 +#endif +#define FAN1_PIN P0_26 + +#define LCD_SDSS P0_16 // LCD SD chip select + +#if ENABLED(AZSMZ_12864) + #define BEEPER_PIN P1_30 + #define DOGLCD_A0 P2_06 + #define DOGLCD_CS P1_22 + #define BTN_EN1 P4_28 + #define BTN_EN2 P1_27 + #define BTN_ENC P3_26 + #ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION LCD + #endif +#endif + +#if SD_CONNECTION_IS(LCD) + #define SD_SCK_PIN P0_15 + #define SD_MISO_PIN P0_17 + #define SD_MOSI_PIN P0_18 + #define SD_SS_PIN LCD_SDSS + #define SD_DETECT_PIN P3_25 +#elif SD_CONNECTION_IS(ONBOARD) + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +// +// Ethernet pins +// +#define REF_CLK P1_15 +#define ENET_MDIO P1_17 +#define ENET_MOC P1_16 +#define ENET_CRS P1_08 +#define ENET_RX_ER P1_14 +#define ENET_TX_EN P1_04 +#define ENET_RXD0 P1_09 +#define ENET_RXD1 P1_10 +#define ENET_TXD0 P1_00 +#define ENET_TXD1 P1_01 + +/** + * PWMs + * + * There are 6 PWMs. Each PWM can be assigned to one of two pins. + * + * SERVO2 does NOT have a PWM assigned to it. + * + * PWM1.1 DIO4 SERVO3_PIN FIL_RUNOUT_PIN 5V output, PWM + * PWM1.1 DIO26 E0_STEP_PIN + * PWM1.2 DIO11 SERVO0_PIN + * PWM1.2 DIO54 X_STEP_PIN + * PWM1.3 DIO6 SERVO1_PIN J5-1 + * PWM1.3 DIO60 Y_STEP_PIN + * PWM1.4 DIO53 SDSS(SSEL0) J3-5 AUX-3 + * PWM1.4 DIO46 Z_STEP_PIN + * PWM1.5 DIO3 X_MIN_PIN 10K PULLUP TO 3.3v, 1K SERIES + * PWM1.5 DIO9 MOSFET_B_PIN + * PWM1.6 DIO14 Y_MIN_PIN 10K PULLUP TO 3.3v, 1K SERIES + * PWM1.6 DIO10 MOSFET_A_PIN + */ + + /** + * Special pins + * D37 - not 5V tolerant + * D49 - not 5V tolerant + * D57 - open collector + * D58 - open collector + */ diff --git a/src/pins/lpc1768/pins_BIQU_B300_V1.0.h b/src/pins/lpc1768/pins_BIQU_B300_V1.0.h new file mode 100644 index 0000000..10a610f --- /dev/null +++ b/src/pins/lpc1768/pins_BIQU_B300_V1.0.h @@ -0,0 +1,180 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BIQU BQ111-A4 + * + * Applies to the following boards: + * + * BOARD_BIQU_BQ111_A4 (Hotend, Fan, Bed) + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BIQU Thunder B300 V1.0" +#endif + +// +// Limit Switches +// +#define X_MIN_PIN P1_24 // 10k pullup to 3.3V, 1K series +#define X_MAX_PIN P1_25 // 10k pullup to 3.3V, 1K series +#define Y_MIN_PIN P1_26 // 10k pullup to 3.3V, 1K series +#define Y_MAX_PIN P1_27 // 10k pullup to 3.3V, 1K series +#define Z_MIN_PIN P1_28 // 10k pullup to 3.3V, 1K series +#define Z_MAX_PIN P1_29 // 10k pullup to 3.3V, 1K series + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P0_04 +#ifndef X_CS_PIN + #define X_CS_PIN P1_15 // ETH +#endif + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P0_11 +#define Y_ENABLE_PIN P0_10 +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_14 // ETH +#endif + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P0_20 +#define Z_ENABLE_PIN P0_19 +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_16 // ETH +#endif + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P0_22 +#define E0_ENABLE_PIN P0_21 +#ifndef E0_CS_PIN + #define E0_CS_PIN P1_17 // ETH +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P0_18 // ETH + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P0_17 // ETH + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P0_15 // ETH + #endif +#endif + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_24_A1 // A0 (T0) +#define TEMP_BED_PIN P0_23_A0 // A1 (T1) + +// +// Heaters / Fans +// +#define HEATER_0_PIN P2_07 +#define HEATER_BED_PIN P2_05 +#ifndef FAN_PIN + #define FAN_PIN P2_04 +#endif + +// +// Unused +// +//#define PIN_P2_10 P2_10 // IBOOT-1 +//#define PIN_P0_27 P0_27 // Onboard SD Detect + +/** + * LCD / Controller + * + * REPRAP_DISCOUNT_SMART_CONTROLLER is not supported due to the lack of LCD_PINS_D5, + * LCD_PINS_D6 or LCD_PINS_D7 in the EXP1 connector. + * + * A remote SD card is not supported as the pins routed to EXP2 are the same as used + * for the onboard SD card, and a chip select signal is not provided for the remote + * SD card. + */ +#if HAS_WIRED_LCD + + #define BEEPER_PIN P1_31 // EXP1-1 + + #define BTN_EN1 P3_26 // EXP2-3 + #define BTN_EN2 P3_25 // EXP2-5 + #define BTN_ENC P1_30 // EXP1-2 + + #define SD_DETECT_PIN P0_27 // EXP2-7 + #define LCD_PINS_RS P0_16 // EXP1-4 + #define LCD_PINS_ENABLE P0_18 // (MOSI) EXP1-3 + #define LCD_PINS_D4 P0_15 // (SCK) EXP1-5 + + #if BOTH(HAS_MARLINUI_HD44780, IS_RRD_SC) + #error "REPRAP_DISCOUNT_SMART_CONTROLLER displays aren't supported by the BIQU B300 v1.0" + #endif + + #if ENABLED(SDSUPPORT) + #error "SDSUPPORT is not supported by the BIQU B300 v1.0 when an LCD controller is used" + #endif + +#endif // HAS_WIRED_LCD + +/** + * SD Card Reader + * + * Software SPI is used to interface with a stand-alone SD card reader connected to EXP1. + * Hardware SPI can't be used because P0_17 (MISO) is not brought out on this board. + */ +#if ENABLED(SDSUPPORT) + #define SD_SCK_PIN P0_15 // EXP1-5 + #define SD_MISO_PIN P0_16 // EXP1-4 + #define SD_MOSI_PIN P0_18 // EXP1-3 + #define SD_SS_PIN P1_30 // EXP1-2 + #define SDSS SD_SS_PIN +#endif + +/** + * PWMS + * + * There are 6 PWMS. Each PWM can be assigned to one of two pins. + * + * PWM1.1 P0_18 LCD_PINS_ENABLE + * PWM1.1 P2_0 X_STEP_PIN + * PWM1.2 P1_20 + * PWM1.2 P2_1 Y_STEP_PIN + * PWM1.3 P1_21 + * PWM1.3 P2_2 Z_STEP_PIN + * PWM1.4 P1_23 + * PWM1.4 P2_3 E0_STEP_PIN + * PWM1.5 P1_24 X_MIN_PIN + * PWM1.5 P2_4 FAN_PIN + * PWM1.6 P1_26 Y_MIN_PIN + * PWM1.6 P2_5 HEATER_BED_PIN + */ diff --git a/src/pins/lpc1768/pins_BIQU_BQ111_A4.h b/src/pins/lpc1768/pins_BIQU_BQ111_A4.h new file mode 100644 index 0000000..9215217 --- /dev/null +++ b/src/pins/lpc1768/pins_BIQU_BQ111_A4.h @@ -0,0 +1,149 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BIQU BQ111-A4 pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "BIQU BQ111-A4" + +// +// Limit Switches +// +#define X_MIN_PIN P1_24 // 10k pullup to 3.3V, 1K series +#define X_MAX_PIN P1_25 // 10k pullup to 3.3V, 1K series +#define Y_MIN_PIN P1_26 // 10k pullup to 3.3V, 1K series +#define Y_MAX_PIN P1_27 // 10k pullup to 3.3V, 1K series +#define Z_MIN_PIN P1_28 // 10k pullup to 3.3V, 1K series +#define Z_MAX_PIN P1_29 // 10k pullup to 3.3V, 1K series + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P0_04 + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P0_11 +#define Y_ENABLE_PIN P0_10 + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P0_20 +#define Z_ENABLE_PIN P0_19 + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P0_22 +#define E0_ENABLE_PIN P0_21 + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_23_A0 // A0 (T0) +#define TEMP_BED_PIN P0_24_A1 // A1 (T1) + +// +// Heaters / Fans +// +#define HEATER_0_PIN P2_07 +#define HEATER_BED_PIN P2_05 +#ifndef FAN_PIN + #define FAN_PIN P2_04 +#endif + +// +// Unused +// +//#define PIN_P2_10 P2_10 // IBOOT-1 +//#define PIN_P0_27 P0_27 // Onboard SD Detect + +/** + * LCD / Controller + * + * REPRAP_DISCOUNT_SMART_CONTROLLER is not supported due to the lack of LCD_PINS_D5, + * LCD_PINS_D6 or LCD_PINS_D7 in the EXP1 connector. + * + * A remote SD card is not supported as the pins routed to EXP2 are the same as used + * for the onboard SD card, and a chip select signal is not provided for the remote + * SD card. + */ +#if HAS_WIRED_LCD + + #define BEEPER_PIN P1_31 // EXP1-1 + + #define BTN_EN1 P3_26 // EXP2-3 + #define BTN_EN2 P3_25 // EXP2-5 + #define BTN_ENC P1_30 // EXP1-2 + + #define SD_DETECT_PIN P0_27 // EXP2-7 + #define LCD_PINS_RS P0_16 // EXP1-4 + #define LCD_PINS_ENABLE P0_18 // (MOSI) EXP1-3 + #define LCD_PINS_D4 P0_15 // (SCK) EXP1-5 + + #if BOTH(HAS_MARLINUI_HD44780, IS_RRD_SC) + #error "REPRAP_DISCOUNT_SMART_CONTROLLER displays aren't supported by the BIQU BQ111-A4" + #endif + + #if ENABLED(SDSUPPORT) + #error "SDSUPPORT is not supported by the BIQU BQ111-A4 when an LCD controller is used" + #endif + +#endif // HAS_WIRED_LCD + +/** + * SD Card Reader + * + * Software SPI is used to interface with a stand-alone SD card reader connected to EXP1. + * Hardware SPI can't be used because P0_17 (MISO) is not brought out on this board. + */ +#if ENABLED(SDSUPPORT) + + #define SD_SCK_PIN P0_15 // EXP1-5 + #define SD_MISO_PIN P0_16 // EXP1-4 + #define SD_MOSI_PIN P0_18 // EXP1-3 + #define SD_SS_PIN P1_30 // EXP1-2 + #define SDSS SD_SS_PIN + +#endif // SDSUPPORT + +/** + * PWMS + * + * There are 6 PWMS. Each PWM can be assigned to one of two pins. + * + * PWM1.1 P0_18 LCD_PINS_ENABLE + * PWM1.1 P2_0 X_STEP_PIN + * PWM1.2 P1_20 + * PWM1.2 P2_1 Y_STEP_PIN + * PWM1.3 P1_21 + * PWM1.3 P2_2 Z_STEP_PIN + * PWM1.4 P1_23 + * PWM1.4 P2_3 E0_STEP_PIN + * PWM1.5 P1_24 X_MIN_PIN + * PWM1.5 P2_4 FAN_PIN + * PWM1.6 P1_26 Y_MIN_PIN + * PWM1.6 P2_5 HEATER_BED_PIN + */ diff --git a/src/pins/lpc1768/pins_BTT_SKR_V1_1.h b/src/pins/lpc1768/pins_BTT_SKR_V1_1.h new file mode 100644 index 0000000..d112243 --- /dev/null +++ b/src/pins/lpc1768/pins_BTT_SKR_V1_1.h @@ -0,0 +1,255 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BigTreeTech SKR 1.1 pin assignments + */ + +#define BOARD_INFO_NAME "BTT SKR V1.1" + +// +// Limit Switches +// +#define X_MIN_PIN P1_29 +#define X_MAX_PIN P1_28 +#define Y_MIN_PIN P1_27 +#define Y_MAX_PIN P1_26 +#define Z_MIN_PIN P1_25 +#define Z_MAX_PIN P1_24 + +// +// Steppers +// +#define X_STEP_PIN P0_04 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P4_28 + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P2_02 +#define Y_ENABLE_PIN P2_00 + +#define Z_STEP_PIN P0_20 +#define Z_DIR_PIN P0_21 +#define Z_ENABLE_PIN P0_19 + +#define E0_STEP_PIN P0_11 +#define E0_DIR_PIN P2_13 +#define E0_ENABLE_PIN P2_12 + + +/** ------ ------ + * 1.30 | 1 2 | 2.11 0.17 | 1 2 | 0.15 + * 0.18 | 3 4 | 0.16 3.26 | 3 4 | 1.23 + * 0.15 5 6 | -- 3.25 5 6 | 0.18 + * -- | 7 8 | -- 1.31 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN P1_30 +#define EXP1_02_PIN P2_11 +#define EXP1_03_PIN P0_18 +#define EXP1_04_PIN P0_16 +#define EXP1_05_PIN P0_15 +#define EXP1_06_PIN -1 // NC +#define EXP1_07_PIN -1 // NC +#define EXP1_08_PIN -1 // NC + +#define EXP2_01_PIN P0_17 +#define EXP2_02_PIN P0_15 +#define EXP2_03_PIN P3_26 +#define EXP2_04_PIN P1_23 +#define EXP2_05_PIN P3_25 +#define EXP2_06_PIN P0_18 +#define EXP2_07_PIN P1_31 +#define EXP2_08_PIN -1 // RESET + +/** + * LCD / Controller + * + * As of 20 JAN 2019 only the REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER display has + * been tested with these settings. It can be connected to the SKR using standard cables + * via the EXP1 and EXP2 ports. Other displays may need a custom cable and/or changes to + * the pins defined below. + * + * The SD card on the LCD controller uses the same SPI signals as the LCD, resulting in + * garbage/lines on the LCD display during SD card access. The LCD code mitigates this + * by redrawing the screen after SD card accesses. + */ + +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + +#elif HAS_WIRED_LCD + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN + + #define LCD_SDSS EXP2_04_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP2_06_PIN + #define LCD_PINS_D4 EXP2_02_PIN + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_CS P2_06 + #define DOGLCD_A0 EXP1_04_PIN + #endif + +#endif // HAS_WIRED_LCD + +// +// SD Support +// +// MKS_MINI_12864 strongly prefers the SD card on the display and +// requires jumpers on the SKR V1.1 board as documented here: +// https://www.facebook.com/groups/505736576548648/permalink/630639874058317/ +#ifndef SDCARD_CONNECTION + #if ANY(MKS_MINI_12864, ENDER2_STOCKDISPLAY, IS_TFTGLCD_PANEL) + #define SDCARD_CONNECTION LCD + #else + #define SDCARD_CONNECTION ONBOARD + #endif +#endif + +// Trinamic driver support + +#if HAS_TRINAMIC_CONFIG + // Using TMC devices in intelligent mode requires extra connections to each device. Unfortunately + // the SKR does not have many free pins (especially if a display is in use). The SPI-based devices + // will require 3 connections (clock, mosi, miso), plus a chip select line (CS) for each driver. + // The UART-based devices require 2 pis per driver (one of which must be interrupt capable). + // The same SPI pins can be shared with the display/SD card reader, meaning SPI-based devices are + // probably a good choice for this board. + // + // SOFTWARE_DRIVER_ENABLE is a good option. It uses SPI to control the driver enable and allows the + // hardware ENABLE pins for each driver to be repurposed as SPI chip select. To use this mode the + // driver modules will probably need to be modified, removing the pin used for the enable line from + // the module and wiring this connection directly to GND (as is the case for TMC2130). + // Using this option and sharing all of the SPI pins allows 5 TMC2130 drivers to be used along with + // a REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER without requiring the use of any extra pins. + // + // Other options will probably require the use of any free pins and the TFT serial port or a + // different type of display (like the TFT), using the pins normally used for the display and encoder. + // Unfortunately, tests show it's not possible to use endstop and thermistor pins for chip-select. + // Sample settings are provided below, but only some have been tested. + // + // Another option is to share the enable and chip-select pins when using SPI. Several users have + // reported that this works. However, it's unlikely that this configuration will allow SPI communi- + // cation with the device when the drivers are active, meaning that some of the more advanced TMC + // options may not be available. + + // When using any TMC SPI-based drivers, software SPI is used + // because pins may be shared with the display or SD card. + #define TMC_USE_SW_SPI + #define TMC_SW_MOSI EXP2_06_PIN + #define TMC_SW_MISO EXP2_01_PIN + // To minimize pin usage use the same clock pin as the display/SD card reader. (May generate LCD noise.) + #define TMC_SW_SCK EXP2_02_PIN + // If pin 2_06 is unused, it can be used for the clock to avoid the LCD noise. + //#define TMC_SW_SCK P2_06 + + #if ENABLED(SOFTWARE_DRIVER_ENABLE) + + // Software enable allows the enable pins to be repurposed as chip-select pins. + // Note: Requires the driver modules to be modified to always be enabled with the enable pin removed. + #if AXIS_DRIVER_TYPE_X(TMC2130) + #define X_CS_PIN P4_28 + #undef X_ENABLE_PIN + #endif + + #if AXIS_DRIVER_TYPE_Y(TMC2130) + #define Y_CS_PIN P2_00 + #undef Y_ENABLE_PIN + #endif + + #if AXIS_DRIVER_TYPE_Z(TMC2130) + #define Z_CS_PIN P0_19 + #undef Z_ENABLE_PIN + #endif + + #if AXIS_DRIVER_TYPE_E0(TMC2130) + #define E0_CS_PIN P2_12 + #undef E0_ENABLE_PIN + #endif + + #if AXIS_DRIVER_TYPE_E1(TMC2130) + #define E1_CS_PIN P0_10 + #undef E1_ENABLE_PIN + #endif + + #else // !SOFTWARE_DRIVER_ENABLE + + // A chip-select pin is needed for each driver. + + // EXAMPLES + + // Example 1: No LCD attached or a TFT style display using the AUX header RX/TX pins. + // SDCARD_CONNECTION must not be 'LCD'. Nothing should be connected to EXP1/EXP2. + //#define SKR_USE_LCD_PINS_FOR_CS + #if ENABLED(SKR_USE_LCD_PINS_FOR_CS) + #define X_CS_PIN EXP2_04_PIN + #define Y_CS_PIN EXP2_03_PIN + #define Z_CS_PIN EXP1_02_PIN + #define E0_CS_PIN EXP2_05_PIN + #define E1_CS_PIN EXP2_07_PIN + #endif + + // Example 2: A REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER + // The SD card reader attached to the LCD (if present) can't be used because + // the pins will be in use. So SDCARD_CONNECTION must not be 'LCD'. + //#define SKR_USE_LCD_SD_CARD_PINS_FOR_CS + #if ENABLED(SKR_USE_LCD_SD_CARD_PINS_FOR_CS) + #define X_CS_PIN P0_02 + #define Y_CS_PIN P0_03 + #define Z_CS_PIN P2_06 + // We use SD_DETECT_PIN for E0 + #undef SD_DETECT_PIN + #define E0_CS_PIN EXP2_07_PIN + // We use LCD_SDSS pin for E1 + #undef LCD_SDSS + #define LCD_SDSS -1 + #define E1_CS_PIN EXP2_04_PIN + #endif + + // Example 3: Use the driver enable pins for chip-select. + // Commands must not be sent to the drivers when enabled. So certain + // advanced features (like driver monitoring) will not be available. + //#define SKR_USE_ENABLE_CS + #if ENABLED(SKR_USE_ENABLE_FOR_CS) + #define X_CS_PIN X_ENABLE_PIN + #define Y_CS_PIN Y_ENABLE_PIN + #define Z_CS_PIN Z_ENABLE_PIN + #define E0_CS_PIN E0_ENABLE_PIN + #define E1_CS_PIN E1_ENABLE_PIN + #endif + + #endif // SOFTWARE_DRIVER_ENABLE + +#endif + +// Include common SKR pins +#include "pins_BTT_SKR_common.h" diff --git a/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/src/pins/lpc1768/pins_BTT_SKR_V1_3.h new file mode 100644 index 0000000..031a42f --- /dev/null +++ b/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -0,0 +1,486 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BigTreeTech SKR 1.3 pin assignments + */ + +#define BOARD_INFO_NAME "BTT SKR V1.3" + +#define LPC1768_IS_SKRV1_3 +#define USES_DIAG_JUMPERS + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN P1_29 // X- +#define Y_DIAG_PIN P1_27 // Y- +#define Z_DIAG_PIN P1_25 // Z- +#define E0_DIAG_PIN P1_28 // X+ +#define E1_DIAG_PIN P1_26 // Y+ + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN P1_28 // X+ + #else + #define X_MIN_PIN P1_28 // X+ + #endif +#else + #define X_MIN_PIN P1_29 // X- + #define X_MAX_PIN P1_28 // X+ +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN P1_26 // Y+ + #else + #define Y_MIN_PIN P1_26 // Y+ + #endif +#else + #define Y_MIN_PIN P1_27 // Y- + #define Y_MAX_PIN P1_26 // Y+ +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN P1_24 // Z+ + #else + #define Z_MIN_PIN P1_24 // Z+ + #endif +#else + #define Z_MIN_PIN P1_25 // Z- + #define Z_MAX_PIN P1_24 // Z+ +#endif + +#define ONBOARD_ENDSTOPPULLUPS // Board has built-in pullups + +// +// Servos +// +#ifndef SERVO0_PIN + #define SERVO0_PIN P2_00 +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P1_24 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN P1_28 +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_02 +#define X_DIR_PIN P2_06 +#define X_ENABLE_PIN P2_01 +#ifndef X_CS_PIN + #define X_CS_PIN P1_17 +#endif + +#define Y_STEP_PIN P0_19 +#define Y_DIR_PIN P0_20 +#define Y_ENABLE_PIN P2_08 +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_15 +#endif + +#define Z_STEP_PIN P0_22 +#define Z_DIR_PIN P2_11 +#define Z_ENABLE_PIN P0_21 +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_10 +#endif + +#define E0_STEP_PIN P2_13 +#define E0_DIR_PIN P0_11 +#define E0_ENABLE_PIN P2_12 +#ifndef E0_CS_PIN + #define E0_CS_PIN P1_08 +#endif + +#ifndef E1_CS_PIN + #define E1_CS_PIN P1_01 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P4_28 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P0_05 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P0_04 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN P4_29 + #define X_SERIAL_RX_PIN P1_17 + + #define Y_SERIAL_TX_PIN P1_16 + #define Y_SERIAL_RX_PIN P1_15 + + #define Z_SERIAL_TX_PIN P1_14 + #define Z_SERIAL_RX_PIN P1_10 + + #define E0_SERIAL_TX_PIN P1_09 + #define E0_SERIAL_RX_PIN P1_08 + + #define E1_SERIAL_TX_PIN P1_04 + #define E1_SERIAL_RX_PIN P1_01 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +/** + * ------ ------ + * (BEEPER) 1.30 | 1 2 | 0.28 (BTN_ENC) (MISO) 0.17 | 1 2 | 0.15 (SCK) + * (LCD_EN) 1.18 | 3 4 | 1.19 (LCD_RS) (BTN_EN1) 3.26 | 3 4 | 0.16 (SD_SS) + * (LCD_D4) 1.20 5 6 | 1.21 (LCD_D5) (BTN_EN2) 3.25 5 6 | 0.18 (MOSI) + * (LCD_D6) 1.22 | 7 8 | 1.23 (LCD_D7) (SD_DETECT) 1.31 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN P1_30 +#define EXP1_02_PIN P0_28 +#define EXP1_03_PIN P1_18 +#define EXP1_04_PIN P1_19 +#define EXP1_05_PIN P1_20 +#define EXP1_06_PIN P1_21 +#define EXP1_07_PIN P1_22 +#define EXP1_08_PIN P1_23 + +#define EXP2_01_PIN P0_17 +#define EXP2_02_PIN P0_15 +#define EXP2_03_PIN P3_26 +#define EXP2_04_PIN P0_16 +#define EXP2_05_PIN P3_25 +#define EXP2_06_PIN P0_18 +#define EXP2_07_PIN P1_31 +#define EXP2_08_PIN -1 + +#if HAS_WIRED_LCD + #if ENABLED(ANET_FULL_GRAPHICS_LCD_ALT_WIRING) + #error "ANET_FULL_GRAPHICS_LCD_ALT_WIRING only applies to the ANET 1.0 board." + + #elif ENABLED(ANET_FULL_GRAPHICS_LCD) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ANET_FULL_GRAPHICS_LCD requires wiring modifications. See 'pins_BTT_SKR_V1_3.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * 1. Cut the tab off the LCD connector so it can be plugged into the "EXP1" connector the other way. + * 2. Swap the LCD's +5V (Pin2) and GND (Pin1) wires. (This is the critical part!) + * 3. Rewire the CLK Signal (LCD Pin9) to LCD Pin7. (LCD Pin9 remains open because it is open drain.) + * 4. A wire is needed to connect the Reset switch at J3 (LCD Pin7) to EXP2 (Pin3) on the board. + * + * !!! If you are unsure, ask for help! Your motherboard may be damaged in some circumstances !!! + * + * The ANET_FULL_GRAPHICS_LCD connector plug: + * + * BEFORE AFTER + * ------ ------ + * (CLK) | 1 2 | (BEEPER) (BEEPER) |10 9 | -- + * -- | 3 4 | (BTN_ENC) (BTN_ENC) | 8 7 | (CLK) + * (SID) 5 6 | (BTN_EN1) (BTN_EN1) 6 5 | (SID) + * (CS) | 7 8 | (BTN_EN2) (BTN_EN2) | 4 3 | (CS) + * GND | 9 10 | 5V GND | 2 1 | 5V + * ------ ------ + * LCD LCD + */ + + #define LCD_PINS_RS EXP1_08_PIN + + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN + + #define LCD_PINS_ENABLE EXP1_06_PIN + #define LCD_PINS_D4 EXP1_04_PIN + + #elif ENABLED(WYH_L12864) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! WYH_L12864 requires wiring modifications. See 'pins_BTT_SKR_V1_3.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * 1. Cut the tab off the LCD connector so it can be plugged into the "EXP1" connector the other way. + * 2. Swap the LCD's +5V (Pin2) and GND (Pin1) wires. (This is the critical part!) + * 3. Swap the LCD's MOSI (Pin9) and empty (Pin10) wires because Pin9 is open drain. + * + * !!! If you are unsure, ask for help! Your motherboard may be damaged in some circumstances !!! + * + * The WYH_L12864 connector plug: + * + * BEFORE AFTER + * ______ ______ + * | 1 2 | (MOSI) (MOSI) |10 9 | -- + * (BTN_ENC) | 3 4 | (SCK) (BTN_ENC) | 8 7 | (SCK) + * (BTN_EN1) 5 6 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 7 8 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 9 10 | GND GND | 2 1 | 5V + * ------ ------ + * LCD LCD + */ + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_04_PIN + #define DOGLCD_MOSI EXP1_01_PIN + #define LCD_BACKLIGHT_PIN -1 + + #elif ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN // (58) open-drain + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif HAS_ADC_BUTTONS + + #error "ADC BUTTONS do not work unmodified on SKR 1.3, The ADC ports cannot take more than 3.3v." + + #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI + + #define TFT_A0_PIN EXP1_08_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_RESET_PIN EXP1_04_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + + //#define TFT_RST_PIN EXP2_07_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + + #define BTN_EN2 EXP2_05_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + #define TFT_BUFFER_SIZE 2400 + + #ifndef TFT_WIDTH + #define TFT_WIDTH 480 + #endif + #ifndef TFT_HEIGHT + #define TFT_HEIGHT 320 + #endif + + #define LCD_READ_ID 0xD3 + #define LCD_USE_DMA_SPI + + #if ENABLED(TFT_CLASSIC_UI) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X -11386 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 8684 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 689 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -273 + #endif + #elif ENABLED(TFT_COLOR_UI) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X -16741 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 11258 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 1024 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -367 + #endif + #define TFT_BUFFER_SIZE 2400 + #endif + + #elif IS_TFTGLCD_PANEL + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + + #define SD_DETECT_PIN EXP2_07_PIN + + #else // !CR10_STOCKDISPLAY + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN // (31) J3-2 & AUX-4 + #define BTN_EN2 EXP2_05_PIN // (33) J3-4 & AUX-4 + #define BTN_ENC EXP1_02_PIN // (58) open-drain + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #define LCD_SDSS EXP2_04_PIN // (16) J3-7 & AUX-4 + #define SD_DETECT_PIN EXP2_07_PIN // (49) (NOT 5V tolerant) + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + #define LCD_BACKLIGHT_PIN -1 + + #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + + #else // !FYSETC_MINI_12864 + + #if ENABLED(MKS_MINI_12864) + + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + #elif ENABLED(ENDER2_STOCKDISPLAY) + + /** + * Creality Ender-2 display pinout + * ------ + * (SCK) P1_30 | 1 2 | P0_28 (BTN_ENC) + * (BTN_EN1) P1_18 | 3 4 | P1_19 (RESET) + * (BTN_EN2) P1_20 5 6 | P1_21 (LCD_A0) + * (LCD_CS) P1_22 | 7 8 | P1_23 (MOSI) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + #endif + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif // !FYSETC_MINI_12864 + + #endif // !CR10_STOCKDISPLAY + +#endif // HAS_WIRED_LCD + +#if NEED_TOUCH_PINS + #define TOUCH_CS_PIN EXP1_05_PIN + #define TOUCH_SCK_PIN EXP2_02_PIN + #define TOUCH_MOSI_PIN EXP2_06_PIN + #define TOUCH_MISO_PIN EXP2_01_PIN + #define TOUCH_INT_PIN EXP1_06_PIN +#endif + +/** + * Special pins + * P1_30 (37) (NOT 5V tolerant) + * P1_31 (49) (NOT 5V tolerant) + * P0_27 (57) (Open collector) + * P0_28 (58) (Open collector) + */ + +// Include common SKR pins +#include "pins_BTT_SKR_common.h" diff --git a/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/src/pins/lpc1768/pins_BTT_SKR_V1_4.h new file mode 100644 index 0000000..209529c --- /dev/null +++ b/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -0,0 +1,512 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BigTreeTech SKR 1.4 pin assignments + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR V1.4" +#endif + +#ifndef BOARD_CUSTOM_BUILD_FLAGS + #define BOARD_CUSTOM_BUILD_FLAGS -DLPC_PINCFG_UART3_P4_28 +#endif + +#define USES_DIAG_PINS + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + //#define I2C_EEPROM // EEPROM on I2C-0 + //#define SDCARD_EEPROM_EMULATION +#endif + +#if ENABLED(I2C_EEPROM) + #define MARLIN_EEPROM_SIZE 0x8000 // 32K +#elif ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800 // 2K +#endif + +// +// Servos +// +#define SERVO0_PIN P2_00 + +// +// TMC StallGuard DIAG pins +// +#define X_DIAG_PIN P1_29 // X-STOP +#define Y_DIAG_PIN P1_28 // Y-STOP +#define Z_DIAG_PIN P1_27 // Z-STOP +#define E0_DIAG_PIN P1_26 // E0DET +#define E1_DIAG_PIN P1_25 // E1DET + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN P1_26 // E0DET + #else + #define X_MIN_PIN P1_26 // E0DET + #endif +#elif ENABLED(X_DUAL_ENDSTOPS) + #ifndef X_MIN_PIN + #define X_MIN_PIN P1_29 // X-STOP + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN P1_26 // E0DET + #endif +#else + #define X_STOP_PIN P1_29 // X-STOP +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN P1_25 // E1DET + #else + #define Y_MIN_PIN P1_25 // E1DET + #endif +#elif ENABLED(Y_DUAL_ENDSTOPS) + #ifndef Y_MIN_PIN + #define Y_MIN_PIN P1_28 // Y-STOP + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN P1_25 // E1DET + #endif +#else + #define Y_STOP_PIN P1_28 // Y-STOP +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN P1_00 // PWRDET + #else + #define Z_MIN_PIN P1_00 // PWRDET + #endif +#elif ENABLED(Z_MULTI_ENDSTOPS) + #ifndef Z_MIN_PIN + #define Z_MIN_PIN P1_27 // Z-STOP + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN P1_00 // PWRDET + #endif +#else + #ifndef Z_STOP_PIN + #define Z_STOP_PIN P1_27 // Z-STOP + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P0_10 +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN P1_26 // E0DET +#define FIL_RUNOUT2_PIN P1_25 // E1DET + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN P1_00 // PWRDET +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN P1_00 // PWRDET +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_02 +#define X_DIR_PIN P2_06 +#define X_ENABLE_PIN P2_01 +#ifndef X_CS_PIN + #define X_CS_PIN P1_10 +#endif + +#define Y_STEP_PIN P0_19 +#define Y_DIR_PIN P0_20 +#define Y_ENABLE_PIN P2_08 +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_09 +#endif + +#define Z_STEP_PIN P0_22 +#define Z_DIR_PIN P2_11 +#define Z_ENABLE_PIN P0_21 +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_08 +#endif + +#define E0_STEP_PIN P2_13 +#define E0_DIR_PIN P0_11 +#define E0_ENABLE_PIN P2_12 +#ifndef E0_CS_PIN + #define E0_CS_PIN P1_04 +#endif + +#define E1_STEP_PIN P1_15 +#define E1_DIR_PIN P1_14 +#define E1_ENABLE_PIN P1_16 +#ifndef E1_CS_PIN + #define E1_CS_PIN P1_01 +#endif + +#define TEMP_1_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_1_PIN +#define TEMP_BED_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_BED_PIN + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P1_17 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P0_05 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P0_04 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN P1_10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN P1_09 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN P1_08 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN P1_04 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN P1_01 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +/** ------ ------ + * 1.30 | 1 2 | 0.28 0.17 | 1 2 | 0.15 + * 1.18 | 3 4 | 1.19 3.26 | 3 4 | 0.16 + * 1.20 5 6 | 1.21 3.25 5 6 | 0.18 + * 1.22 | 7 8 | 1.23 1.31 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN P1_30 +#define EXP1_02_PIN P0_28 +#define EXP1_03_PIN P1_18 +#define EXP1_04_PIN P1_19 +#define EXP1_05_PIN P1_20 +#define EXP1_06_PIN P1_21 +#define EXP1_07_PIN P1_22 +#define EXP1_08_PIN P1_23 + +#define EXP2_01_PIN P0_17 +#define EXP2_02_PIN P0_15 +#define EXP2_03_PIN P3_26 +#define EXP2_04_PIN P0_16 +#define EXP2_05_PIN P3_25 +#define EXP2_06_PIN P0_18 +#define EXP2_07_PIN P1_31 +#define EXP2_08_PIN -1 // RESET + +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + + // RET6 DWIN ENCODER LCD + #define BTN_ENC EXP1_05_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_06_PIN + #endif + +#elif HAS_WIRED_LCD + + #if ENABLED(ANET_FULL_GRAPHICS_LCD_ALT_WIRING) + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ANET_FULL_GRAPHICS_LCD_ALT_WIRING requires wiring modifications. See 'pins_BTT_SKR_V1_4.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * 1. Cut the tab off the LCD connector so it can be plugged into the "EXP1" connector the other way. + * 2. Swap the LCD's +5V (Pin2) and GND (Pin1) wires. (This is the critical part!) + * + * !!! If you are unsure, ask for help! Your motherboard may be damaged in some circumstances !!! + * + * The ANET_FULL_GRAPHICS_LCD_ALT_WIRING connector plug: + * + * BEFORE AFTER + * ------ ------ + * (BEEPER) | 1 2 | (CLK) (BEEPER) |10 9 | (CLK) + * (BTN_ENC) | 3 4 | -- (BTN_ENC) | 8 7 | -- + * (BTN_EN1) 5 6 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 7 8 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 9 10 | GND GND | 2 1 | 5V + * ------ ------ + * LCD LCD + */ + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP1_06_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_01_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define BEEPER_PIN EXP1_08_PIN + + #elif ENABLED(ANET_FULL_GRAPHICS_LCD) + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ANET_FULL_GRAPHICS_LCD requires wiring modifications. See 'pins_BTT_SKR_V1_4.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * 1. Cut the tab off the LCD connector so it can be plugged into the "EXP1" connector the other way. + * 2. Swap the LCD's +5V (Pin2) and GND (Pin1) wires. (This is the critical part!) + * 3. Rewire the CLK Signal (LCD Pin9) to LCD Pin7. (LCD Pin9 remains open because it is open drain.) + * 4. A wire is needed to connect the Reset switch at J3 (LCD Pin7) to EXP2 (Pin3) on the board. + * + * !!! If you are unsure, ask for help! Your motherboard may be damaged in some circumstances !!! + * + * The ANET_FULL_GRAPHICS_LCD connector plug: + * + * BEFORE AFTER + * ------ ------ + * (BEEPER) | 1 2 | (CLK) (BEEPER) |10 9 | -- + * (BTN_ENC) | 3 4 | -- (BTN_ENC) | 8 7 | (CLK) + * (BTN_EN1) 5 6 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 7 8 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 9 10 | GND GND | 2 1 | 5V + * ------ ------ + * LCD LCD + */ + + #define LCD_PINS_RS EXP1_08_PIN + + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN + + #define LCD_PINS_ENABLE EXP1_06_PIN + #define LCD_PINS_D4 EXP1_04_PIN + + #define BEEPER_PIN EXP1_01_PIN + + #elif ENABLED(CR10_STOCKDISPLAY) + #define BTN_ENC EXP1_02_PIN // (58) open-drain + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(ENDER2_STOCKDISPLAY) + + /** Creality Ender-2 display pinout + * ------ + * (SCK) 1.30 | 1 2 | 0.28 (BTN_ENC) + * (BTN_EN1) 1.18 | 3 4 | 1.19 (RESET) + * (BTN_EN2) 1.20 5 6 | 1.21 (LCD_A0) + * (LCD_RS) 1.22 | 7 8 | 1.23 (MOSI) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN + + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_A0_PIN EXP1_08_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_RESET_PIN EXP1_04_PIN + + #define LCD_USE_DMA_SPI + + #define TOUCH_INT_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_05_PIN + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + // SPI 1 + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + + #define TFT_BUFFER_SIZE 2400 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + + #define SD_DETECT_PIN EXP2_07_PIN + + #else + + #define BTN_ENC EXP1_02_PIN // (58) open-drain + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN // (31) J3-2 & AUX-4 + #define BTN_EN2 EXP2_05_PIN // (33) J3-4 & AUX-4 + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #define LCD_SDSS EXP2_04_PIN // (16) J3-7 & AUX-4 + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + #define LCD_BACKLIGHT_PIN -1 + + #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + + #else // !FYSETC_MINI_12864 + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define FORCE_SOFT_SPI + #endif + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN EXP1_08_PIN // Detect the presence of the encoder + #endif + + #endif + + #endif // !FYSETC_MINI_12864 + + #endif // HAS_MARLINUI_U8GLIB + +#endif // HAS_WIRED_LCD + +#if HAS_ADC_BUTTONS + #error "ADC BUTTONS do not work unmodified on SKR 1.4, The ADC ports cannot take more than 3.3v." +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN P1_24 +#endif + +/** + * Special pins + * P1_30 (37) (NOT 5V tolerant) + * P1_31 (49) (NOT 5V tolerant) + * P0_27 (57) (Open collector) + * P0_28 (58) (Open collector) + */ + +// +// Include common SKR pins +// +#include "pins_BTT_SKR_common.h" diff --git a/src/pins/lpc1768/pins_BTT_SKR_common.h b/src/pins/lpc1768/pins_BTT_SKR_common.h new file mode 100644 index 0000000..ec74cc6 --- /dev/null +++ b/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -0,0 +1,209 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +// If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION +// https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT +//#define BTT_MOTOR_EXPANSION + +#if BOTH(HAS_WIRED_LCD, BTT_MOTOR_EXPANSION) + #if EITHER(CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY) + #define EXP_MOT_USE_EXP2_ONLY 1 + #else + #error "You can't use both an LCD and a Motor Expansion Module on EXP1/EXP2 at the same time." + #endif +#endif + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// Steppers +// +#ifndef E1_STEP_PIN + #define E1_STEP_PIN P0_01 +#endif +#ifndef E1_DIR_PIN + #define E1_DIR_PIN P0_00 +#endif +#ifndef E1_ENABLE_PIN + #define E1_ENABLE_PIN P0_10 +#endif + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#ifndef TEMP_0_PIN + #define TEMP_0_PIN P0_24_A1 // A1 (T1) - (68) - TEMP_0_PIN +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_1_PIN +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_BED_PIN +#endif + +#if HOTENDS == 1 && !REDUNDANT_TEMP_MATCH(SOURCE, E1) + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif +#endif + +// CS, MISO, MOSI, and SCK for MAX Thermocouple SPI +#if HAS_MAX_TC + //#define TEMP_0_CS_PIN P... + //#define TEMP_0_MISO_PIN P... + //#define TEMP_0_MOSI_PIN P... + //#define TEMP_0_SCK_PIN P... + + //#define TEMP_1_CS_PIN P... + //#define TEMP_1_MISO_PIN P... + //#define TEMP_1_MOSI_PIN P... + //#define TEMP_1_SCK_PIN P... +#endif + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN P2_07 +#endif +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #ifndef FAN1_PIN + #define FAN1_PIN P2_04 + #endif +#else + #ifndef HEATER_1_PIN + #define HEATER_1_PIN P2_04 + #endif +#endif +#ifndef FAN_PIN + #define FAN_PIN P2_03 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN P2_05 +#endif + +// +// LCD / Controller +// +#if !defined(BEEPER_PIN) && HAS_WIRED_LCD && DISABLED(LCD_USE_I2C_BUZZER) + #define BEEPER_PIN P1_30 // (37) not 5V tolerant +#endif + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #if HAS_WIRED_LCD + #define SDCARD_CONNECTION LCD + #else + #define SDCARD_CONNECTION ONBOARD + #endif +#endif + +#if SD_CONNECTION_IS(LCD) && ENABLED(SKR_USE_LCD_SD_CARD_PINS_FOR_CS) + #error "SDCARD_CONNECTION must not be 'LCD' with SKR_USE_LCD_SD_CARD_PINS_FOR_CS." +#endif + +#if SD_CONNECTION_IS(LCD) + #define SD_SCK_PIN P0_15 + #define SD_MISO_PIN P0_17 + #define SD_MOSI_PIN P0_18 + #define SD_SS_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN + +#elif SD_CONNECTION_IS(ONBOARD) + #undef SD_DETECT_PIN + #define SD_DETECT_PIN P0_27 + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +#if ENABLED(BTT_MOTOR_EXPANSION) + /** + * ------ ------ + * (M3STP) | 1 2 | (M3DIR) (M3DIAG) | 1 2 | (M3RX) + * (M2STP) | 3 4 | (M2DIR) (M2DIAG) | 3 4 | (M2RX) + * (M1DIR) 5 6 | (M1STP) (M1DIAG) 5 6 | (M1RX) + * (M1EN) | 7 8 | -- (M3EN) | 7 8 | (M2EN) + * GND | 9 10 | -- GND | 9 10 | -- + * ------ ------ + * EXP2 EXP1 + * + * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN + */ + + // M1 on Driver Expansion Module + #define E2_STEP_PIN EXP2_06_PIN + #define E2_DIR_PIN EXP2_05_PIN + #define E2_ENABLE_PIN EXP2_07_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E2_DIAG_PIN EXP1_05_PIN + #define E2_CS_PIN EXP1_06_PIN + #if HAS_TMC_UART + #define E2_SERIAL_TX_PIN EXP1_06_PIN + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + #endif + #endif + + // M2 on Driver Expansion Module + #define E3_STEP_PIN EXP2_03_PIN + #define E3_DIR_PIN EXP2_04_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E3_ENABLE_PIN EXP1_08_PIN + #define E3_DIAG_PIN EXP1_03_PIN + #define E3_CS_PIN EXP1_04_PIN + #if HAS_TMC_UART + #define E3_SERIAL_TX_PIN EXP1_04_PIN + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + #endif + #else + #define E3_ENABLE_PIN EXP2_07_PIN + #endif + + // M3 on Driver Expansion Module + #define E4_STEP_PIN EXP2_01_PIN + #define E4_DIR_PIN EXP2_02_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E4_ENABLE_PIN EXP1_07_PIN + #define E4_DIAG_PIN EXP1_01_PIN + #define E4_CS_PIN EXP1_02_PIN + #if HAS_TMC_UART + #define E4_SERIAL_TX_PIN EXP1_02_PIN + #define E4_SERIAL_RX_PIN E4_SERIAL_TX_PIN + #endif + #else + #define E4_ENABLE_PIN EXP2_07_PIN + #endif + +#endif // BTT_MOTOR_EXPANSION diff --git a/src/pins/lpc1768/pins_EMOTRONIC.h b/src/pins/lpc1768/pins_EMOTRONIC.h new file mode 100644 index 0000000..6e1ea40 --- /dev/null +++ b/src/pins/lpc1768/pins_EMOTRONIC.h @@ -0,0 +1,149 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * eMotion-Tech eMotronic pin assignments + * + * Board pins<->features assignments are based on the + * Micro-Delta Rework printer default connections. + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "eMotronic" +#define BOARD_WEBSITE_URL "www.reprap-france.com/article/lemotronic-quesaco" + +// +// Limit Switches +// +#define X_STOP_PIN P1_22 // S0 +#define Y_STOP_PIN P1_23 // S1 +#define Z_STOP_PIN P1_24 // S2 +#define I_STOP_PIN P1_25 // S3 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P0_26 // S4 (opto) +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_02 // M3 +#define X_DIR_PIN P4_28 +#define X_ENABLE_PIN P4_29 + +#define Y_STEP_PIN P2_01 // M2 +#define Y_DIR_PIN P0_22 +#define Y_ENABLE_PIN P0_21 + +#define Z_STEP_PIN P2_00 // M1 +#define Z_DIR_PIN P3_26 +#define Z_ENABLE_PIN P3_25 + +#define E0_STEP_PIN P2_03 // M4 +#define E0_DIR_PIN P0_04 +#define E0_ENABLE_PIN P0_05 // Correct! + +#define E1_STEP_PIN P2_08 // M5 +#define E1_DIR_PIN P0_20 +#define E1_ENABLE_PIN P0_19 + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_24_A1 // A1 (TH1) +#define TEMP_1_PIN P0_23_A0 // A0 (TH0) +#define TEMP_BED_PIN P0_25_A2 // A2 (TH2) + +// +// Heaters / Fans +// +#define _H0_PIN P2_04 // (H0: 15A) + +#define HEATER_BED_PIN P2_05 // (H1: 10A shared) +#define HEATER_0_PIN P2_06 // (H2: 10A shared) +#define HEATER_1_PIN P2_07 // (H3: 10A shared) + +#define FAN_PIN P2_11 // (FAN0: 1A) +#define FAN1_PIN P2_13 // (FAN1: 1A) + +// +// Extension ports +// +#define EXP1_01_PIN P0_03 // RX0 +#define EXP1_02_PIN P0_02 // TX0 +#define EXP1_03_PIN P1_30 +#define EXP1_04_PIN P1_31 +#define EXP1_05_PIN P0_17 // MISO0 +#define EXP1_06_PIN P0_18 // MOSI0 +#define EXP1_07_PIN P0_15 // SCK0 +#define EXP1_08_PIN P0_16 // SSEL0 +#define EXP1_09_PIN P0_27 // SDA0 +#define EXP1_10_PIN P0_28 // SCL0 + +#define EXP2_01_PIN P0_10 +#define EXP2_02_PIN P0_11 +#define EXP2_03_PIN P0_00 // SDA1 +#define EXP2_04_PIN P0_01 // SCL1 +#define EXP2_05_PIN P1_28 +#define EXP2_06_PIN P1_29 +#define EXP2_07_PIN P1_26 +#define EXP2_08_PIN P1_27 + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define SD_SS_PIN P0_06 +#elif SD_CONNECTION_IS(LCD) + #define SD_SCK_PIN EXP1_07_PIN + #define SD_MISO_PIN EXP1_05_PIN + #define SD_MOSI_PIN EXP1_06_PIN + #define SD_SS_PIN EXP1_08_PIN + #define SD_DETECT_PIN EXP1_04_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +// +// LCD / Controller +// +#if ENABLED(EMOTION_TECH_LCD) + #define BEEPER_PIN EXP2_01_PIN + #define DOGLCD_A0 EXP2_06_PIN + #define DOGLCD_CS EXP2_04_PIN + #define DOGLCD_SCK EXP1_07_PIN + #define DOGLCD_MOSI EXP1_06_PIN + + #define BTN_EN1 EXP2_07_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP2_02_PIN +#endif diff --git a/src/pins/lpc1768/pins_GMARSH_X6_REV1.h b/src/pins/lpc1768/pins_GMARSH_X6_REV1.h new file mode 100644 index 0000000..39ab0bb --- /dev/null +++ b/src/pins/lpc1768/pins_GMARSH_X6_REV1.h @@ -0,0 +1,174 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * GMARSH X6 Rev.1 pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "GMARSH X6 REV1" + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// Enable 12MHz clock output on P1.27 pin to sync TMC2208 chip clocks +// +#define LPC1768_ENABLE_CLKOUT_12M + +// +// Servos +// +#define SERVO0_PIN P1_26 // PWM1[6] +#define SERVO1_PIN P1_18 // PWM1[1] + +// +// Limit Switches +// +#define X_MIN_PIN P0_00 +#define X_MAX_PIN P0_01 +#define Y_MIN_PIN P0_10 +#define Y_MAX_PIN P0_21 +#define Z_MIN_PIN P2_13 +#define Z_MAX_PIN P2_22 + +// +// Steppers +// + +#define X_STEP_PIN P1_01 +#define X_DIR_PIN P1_04 +#define X_ENABLE_PIN P0_26 + +#define Y_STEP_PIN P1_10 +#define Y_DIR_PIN P1_14 +#define Y_ENABLE_PIN P1_08 + +#define Z_STEP_PIN P1_17 +#define Z_DIR_PIN P4_29 +#define Z_ENABLE_PIN P1_15 + +#define E0_STEP_PIN P0_05 +#define E0_DIR_PIN P2_00 +#define E0_ENABLE_PIN P4_28 + +#define E1_STEP_PIN P2_03 +#define E1_DIR_PIN P2_04 +#define E1_ENABLE_PIN P2_01 + +#define E2_STEP_PIN P2_07 +#define E2_DIR_PIN P2_08 +#define E2_ENABLE_PIN P2_05 + +// +// TMC2208 UART pins +// +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN P1_00 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN P1_09 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN P1_16 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN P0_04 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN P2_02 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN P2_06 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#else + #error "TMC2208 UART configuration is required for GMarsh X6." +#endif + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_24_A1 // AD0[0] on P0_23 +#define TEMP_BED_PIN P0_23_A0 // AD0[1] on P0_24 + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P1_19 // Not a PWM pin, software PWM required +#define HEATER_0_PIN P3_26 // PWM1[3] +#define FAN_PIN P3_25 // Part cooling fan - connected to PWM1[2] +#define E0_AUTO_FAN_PIN P0_27 // Extruder cooling fan + +// +// Misc. Functions +// +#define LED_PIN P1_31 +#define POWER_MONITOR_VOLTAGE_PIN P0_25_A2 + +// +// LCD +// +#if IS_RRD_SC + #define BEEPER_PIN P0_19 + #define BTN_EN1 P1_23 + #define BTN_EN2 P1_24 + #define BTN_ENC P1_25 + #define LCD_PINS_RS P0_20 + #define LCD_PINS_ENABLE P0_21 + #define LCD_PINS_D4 P2_11 + #define LCD_PINS_D5 P0_22 + #define LCD_PINS_D6 P1_29 + #define LCD_PINS_D7 P1_28 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION LCD +#endif + +#if SD_CONNECTION_IS(LCD) + #define SD_SCK_PIN P0_15 + #define SD_MISO_PIN P0_17 + #define SD_MOSI_PIN P0_18 + #define SD_SS_PIN P0_16 + #define SD_DETECT_PIN P1_22 +#elif SD_CONNECTION_IS(ONBOARD) + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN +#endif diff --git a/src/pins/lpc1768/pins_MKS_SBASE.h b/src/pins/lpc1768/pins_MKS_SBASE.h new file mode 100644 index 0000000..cf12a98 --- /dev/null +++ b/src/pins/lpc1768/pins_MKS_SBASE.h @@ -0,0 +1,387 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Makerbase MKS SBASE pin assignments + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS SBASE" +#endif +#ifndef BOARD_WEBSITE_URL + #define BOARD_WEBSITE_URL "github.com/makerbase-mks/MKS-SBASE" +#endif + +#define LED_PIN P1_18 // Used as a status indicator +#define LED2_PIN P1_19 +#define LED3_PIN P1_20 +#define LED4_PIN P1_21 + +// +// Servos +// +#define SERVO0_PIN P1_23 // J8-3 (low jitter) +#define SERVO1_PIN P2_12 // J8-4 +#define SERVO2_PIN P2_11 // J8-5 +#define SERVO3_PIN P4_28 // J8-6 + +// +// Limit Switches - Not Interrupt Capable +// +#define X_MIN_PIN P1_24 // 10k pullup to 3.3V, 1K series +#define X_MAX_PIN P1_25 // 10k pullup to 3.3V, 1K series +#define Y_MIN_PIN P1_26 // 10k pullup to 3.3V, 1K series +#define Y_MAX_PIN P1_27 // 10k pullup to 3.3V, 1K series +#define Z_MIN_PIN P1_28 // The original Mks Sbase DIO19 has a 10k pullup to 3.3V or 5V, 1K series, so when using a Zprobe we must use DIO41 (J8 P1.22) +#define Z_MAX_PIN P1_29 // 10k pullup to 3.3V, 1K series + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P4_28 // Connector J8 +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P0_04 + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P0_11 +#define Y_ENABLE_PIN P0_10 + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P0_20 +#define Z_ENABLE_PIN P0_19 + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P0_22 +#define E0_ENABLE_PIN P0_21 + +#define E1_STEP_PIN P2_08 +#define E1_DIR_PIN P2_13 +#define E1_ENABLE_PIN P4_29 + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_BED_PIN P0_23_A0 // A0 (TH1) +#define TEMP_0_PIN P0_24_A1 // A1 (TH2) +#define TEMP_1_PIN P0_25_A2 // A2 (TH3) +#define TEMP_2_PIN P0_26_A3 // A3 (TH4) + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P2_05 +#define HEATER_0_PIN P2_07 +#define HEATER_1_PIN P2_06 +#ifndef FAN_PIN + #define FAN_PIN P2_04 +#endif + +// +// Connector J7 +// Note: These pins are all digitally shared with the EXP1/EXP2 Connector. +// Using them with an LCD connected or configured will lead to hangs & crashes. +// + +// 5V +// NC +// GND +#define PIN_P0_17 P0_17 +#define PIN_P0_16 P0_16 +#define PIN_P0_15 P0_15 + +// +// Connector J8 +// + +// GND +#define PIN_P1_22 P1_22 +#define PIN_P1_23 P1_23 // PWM Capable +#define PIN_P2_12 P2_12 // Interrupt Capable +#define PIN_P2_11 P2_11 // Interrupt Capable + +// +// Průša i3 MMU1 (Multi Material Multiplexer) Support +// +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN P1_23 // J8-3 + #define E_MUX1_PIN P2_12 // J8-4 + #define E_MUX2_PIN P2_11 // J8-5 +#endif + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #define PS_ON_PIN P0_25 // SERVO + #define KILL_PIN P1_29 // Z+ + #define KILL_PIN_STATE HIGH +#endif + +// +// Ethernet pins +// +#if !IS_ULTIPANEL + #define ENET_MDIO P1_17 // J12-4 + #define ENET_RX_ER P1_14 // J12-6 + #define ENET_RXD1 P1_10 // J12-8 +#endif + +#define ENET_MOC P1_16 // J12-3 +#define REF_CLK P1_15 // J12-5 +#define ENET_RXD0 P1_09 // J12-7 +#define ENET_CRS P1_08 // J12-9 +#define ENET_TX_EN P1_04 // J12-10 +#define ENET_TXD0 P1_00 // J12-11 +#define ENET_TXD1 P1_01 // J12-12 + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(CUSTOM_CABLE) + + /** + * A custom cable is needed. See the README file in the + * Marlin\src\config\examples\Mks\Sbase directory + * P0.27 is on EXP2 and the on-board SD card's socket. That means it can't be + * used as the SD_DETECT for the LCD's SD card. + * + * The best solution is to use the custom cable to connect the LCD's SD_DETECT + * to a pin NOT on EXP2. + * + * If you can't find a pin to use for the LCD's SD_DETECT then comment out + * SD_DETECT_PIN entirely and remove that wire from the the custom cable. + */ + #define SD_DETECT_PIN P2_11 // J8-5 (moved from EXP2 P0.27) + #define SD_SCK_PIN P1_22 // J8-2 (moved from EXP2 P0.7) + #define SD_MISO_PIN P1_23 // J8-3 (moved from EXP2 P0.8) + #define SD_MOSI_PIN P2_12 // J8-4 (moved from EXP2 P0.9) + #define SD_SS_PIN P0_28 + #define LPC_SOFTWARE_SPI // With a custom cable we need software SPI because the + // selected pins are not on a hardware SPI controller +#elif SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #if SD_CONNECTION_IS(LCD) + // Use standard cable and header, SPI and SD detect are shared with onboard SD card. + // Hardware SPI is used for both SD cards. The detect pin is shared between the + // LCD and onboard SD readers so we disable it. + #define SD_SS_PIN P0_28 + #else + #define SD_DETECT_PIN P0_27 + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN + #endif +#endif + +/** + * Smart LCD adapter + * + * The Smart LCD adapter can be used for the two 10 pin LCD controllers such as + * REPRAP_DISCOUNT_SMART_CONTROLLER. It can't be used for controllers that use + * DOGLCD_A0, DOGLCD_CS, LCD_PINS_D5, LCD_PINS_D6 or LCD_PINS_D7. A custom cable + * is needed to pick up 5V for the EXP1 connection. + * + * SD card on the LCD uses the same SPI signals as the LCD. This results in garbage/lines + * on the LCD display during accesses of the SD card. The menus/code has been arranged so + * that the garbage/lines are erased immediately after the SD card accesses are completed. + */ + +// +// LCD / Controller +// +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS P3_25 // EXP2.3 + #endif + + #if SD_CONNECTION_IS(LCD) + #define SD_DETECT_PIN P0_28 // EXP2.4 + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN P1_31 // EXP1.1 + #define BTN_ENC P1_30 // EXP1.2 + #define BTN_EN1 P3_26 // EXP2.5 + #define BTN_EN2 P3_25 // EXP2.3 + #define LCD_PINS_RS P0_16 // EXP1.4 + #define LCD_SDSS P0_28 // EXP2.4 + #define LCD_PINS_ENABLE P0_18 // EXP1.3 + #define LCD_PINS_D4 P0_15 // EXP1.5 + #if EITHER(VIKI2, miniVIKI) + #define DOGLCD_SCK SD_SCK_PIN + #define DOGLCD_MOSI SD_MOSI_PIN + #endif + + #if ENABLED(FYSETC_MINI_12864) + /** + * The FYSETC display can NOT use the SCK and MOSI pins on EXP2, so a + * special cable is needed to go between EXP2 on the FYSETC and the + * controller board's EXP2 and J8. It also means that a software SPI + * is needed to drive those pins. + * + * The FYSETC requires mode 3 SPI interface. + * + * Pins 6, 7 & 8 on EXP2 are no connects. That means a second special + * cable will be needed if the RGB LEDs are to be active. + */ + #define DOGLCD_CS LCD_PINS_ENABLE // EXP1.3 (LCD_EN on FYSETC schematic) + #define DOGLCD_A0 LCD_PINS_RS // EXP1.4 (LCD_A0 on FYSETC schematic) + #define DOGLCD_SCK P2_11 // J8-5 (SCK on FYSETC schematic) + #define DOGLCD_MOSI P4_28 // J8-6 (MOSI on FYSETC schematic) + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN P2_12 // J8-4 (LCD_D6 on FYSETC schematic) + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN P1_23 // J8-3 (LCD_D5 on FYSETC schematic) + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN P1_22 // J8-2 (LCD_D7 on FYSETC schematic) + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN P2_12 + #endif + + #elif ENABLED(MINIPANEL) + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #endif + +#endif // HAS_WIRED_LCD + +/** + * Example for trinamic drivers using the J8 connector on MKs Sbase. + * 2130s need 1 pin for each driver. 2208/2209s need 2 pins for serial control. + * This board does not have enough pins to use hardware serial. + */ + +#if HAS_DRIVER(TMC2130) + // J8 + #define X_CS_PIN P1_22 + #define Y_CS_PIN P1_23 + #define Z_CS_PIN P2_12 + #define E0_CS_PIN P2_11 + #define E1_CS_PIN P4_28 + + // Hardware SPI is on EXP2. See if you can make it work: + // https://github.com/makerbase-mks/MKS-SBASE/issues/25 + #define TMC_USE_SW_SPI + #if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P0_03 // AUX1 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P0_02 // AUX1 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P0_26 // TH4 + #endif + #endif + +#endif + +#if MB(MKS_SBASE) && HAS_TMC_UART + + /** + * TMC2208/TMC2209 stepper drivers + * + * The shortage of pins becomes apparent. + * Worst case you may have to give up the LCD + * RX pins need to be interrupt capable + */ + #define X_SERIAL_TX_PIN P1_22 // J8-2 + #define X_SERIAL_RX_PIN P2_12 // J8-4 Interrupt Capable + + #define Y_SERIAL_TX_PIN P1_23 // J8-3 + #define Y_SERIAL_RX_PIN P2_11 // J8-5 Interrupt Capable + + #define Z_SERIAL_TX_PIN P2_12 // J8-4 + #define Z_SERIAL_RX_PIN P0_25 // TH3 + + #define E0_SERIAL_TX_PIN P4_28 // J8-6 + #define E0_SERIAL_RX_PIN P0_26 // TH4 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// UNUSED +//#define PIN_P0_02 P0_02 // AUX1 (Interrupt Capable/ADC/Serial Port 0) +//#define PIN_P0_03 P0_03 // AUX1 (Interrupt Capable/ADC/Serial Port 0) + +/** + * PWMs + * + * There are 6 PWMs. Each PWM can be assigned to one of two pins. + * + * SERVO2 does NOT have a PWM assigned to it. + * + * PWM1.1 P1_18 SERVO3_PIN FIL_RUNOUT_PIN 5V output, PWM + * PWM1.1 P2_00 E0_STEP_PIN + * PWM1.2 P1_20 SERVO0_PIN + * PWM1.2 P2_01 X_STEP_PIN + * PWM1.3 P1_21 SERVO1_PIN J5-1 + * PWM1.3 P2_02 Y_STEP_PIN + * PWM1.4 P1_23 SDSS(SSEL0) J3-5 AUX-3 + * PWM1.4 P2_03 Z_STEP_PIN + * PWM1.5 P1_24 X_MIN_PIN 10K PULLUP TO 3.3v, 1K SERIES + * PWM1.5 P2_04 MOSFET_B_PIN + * PWM1.6 P1_26 Y_MIN_PIN 10K PULLUP TO 3.3v, 1K SERIES + * PWM1.6 P2_05 MOSFET_A_PIN + */ + +/** + * Special pins + * P1_30 - not 5V tolerant - EXP1 + * P1_31 - not 5V tolerant - EXP1 + * P0_27 - open collector - EXP2 + * P0_28 - open collector - EXP2 + */ + +/** + * Serial Ports + * P0_00 - Port 3 + * P0_01 - SD Card (Onboard) + * P0_10 - Port 2 + * P0_11 - Y_EN/Y_DIR + * P0_15 - Port 1 + * P0_16 - EXP1 + * P0_02 - Port 0 + * P0_03 - AUX1 + * P0_29 - Port -1 + * P0_30 - USB + */ diff --git a/src/pins/lpc1768/pins_MKS_SGEN_L.h b/src/pins/lpc1768/pins_MKS_SGEN_L.h new file mode 100644 index 0000000..4e9f98c --- /dev/null +++ b/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -0,0 +1,416 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Makerbase MKS SGEN-L pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "MKS SGen-L" +#define BOARD_WEBSITE_URL "github.com/makerbase-mks/MKS-SGEN_L" + +#define USES_DIAG_JUMPERS + +// +// Servos +// +#define SERVO0_PIN P1_23 // SERVO P1.23 +#define SERVO1_PIN P2_00 // SERVO P2.0 + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN P1_29 // X- +#define Y_DIAG_PIN P1_27 // Y- +#define Z_DIAG_PIN P1_25 // Z- +#define E0_DIAG_PIN P1_28 // X+ +#define E1_DIAG_PIN P1_26 // Y+ + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN P1_28 // X+ + #else + #define X_MIN_PIN P1_28 // X+ + #endif +#else + #define X_MIN_PIN P1_29 // X- + #define X_MAX_PIN P1_28 // X+ +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN P1_26 // Y+ + #else + #define Y_MIN_PIN P1_26 // Y+ + #endif +#else + #define Y_MIN_PIN P1_27 // Y- + #define Y_MAX_PIN P1_26 // Y+ +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN P1_24 // Z+ + #else + #define Z_MIN_PIN P1_24 // Z+ + #endif +#else + #define Z_MIN_PIN P1_25 // Z- + #define Z_MAX_PIN P1_24 // Z+ +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P1_24 +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_02 +#define X_DIR_PIN P2_03 +#define X_ENABLE_PIN P2_01 +#ifndef X_CS_PIN + #define X_CS_PIN P1_01 +#endif + +#define Y_STEP_PIN P0_19 +#define Y_DIR_PIN P0_20 +#define Y_ENABLE_PIN P2_08 +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_08 +#endif + +#define Z_STEP_PIN P0_22 +#define Z_DIR_PIN P2_11 +#define Z_ENABLE_PIN P0_21 +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_10 +#endif + +#define E0_STEP_PIN P2_13 +#define E0_DIR_PIN P0_11 +#define E0_ENABLE_PIN P2_12 +#ifndef E0_CS_PIN + #define E0_CS_PIN P1_15 +#endif + +#define E1_STEP_PIN P0_01 +#define E1_DIR_PIN P0_00 +#define E1_ENABLE_PIN P0_10 +#ifndef E1_CS_PIN + #define E1_CS_PIN P1_17 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P4_28 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P0_05 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P0_04 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN P1_04 + #define X_SERIAL_RX_PIN P1_01 + + #define Y_SERIAL_TX_PIN P1_09 + #define Y_SERIAL_RX_PIN P1_08 + + #define Z_SERIAL_TX_PIN P1_14 + #define Z_SERIAL_RX_PIN P1_10 + + #define E0_SERIAL_TX_PIN P1_16 + #define E0_SERIAL_RX_PIN P1_15 + + #define E1_SERIAL_TX_PIN P4_29 + #define E1_SERIAL_RX_PIN P1_17 + + #define Z2_SERIAL_TX_PIN P4_29 + #define Z2_SERIAL_RX_PIN P1_17 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif // HAS_TMC_UART + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_23_A0 // Analog Input A0 (TH1) +#define TEMP_BED_PIN P0_24_A1 // Analog Input A1 (TB) +#define TEMP_1_PIN P0_25_A2 // Analog Input A2 (TH2) + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P2_05 +#define HEATER_0_PIN P2_07 +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #ifndef FAN1_PIN + #define FAN1_PIN P2_06 + #endif +#else + #ifndef HEATER_1_PIN + #define HEATER_1_PIN P2_06 + #endif +#endif +#ifndef FAN_PIN + #define FAN_PIN P2_04 +#endif + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #define PS_ON_PIN P2_00 // SERVO1 + #define KILL_PIN P1_24 // Z+ + #define KILL_PIN_STATE HIGH +#endif + +// +// Misc. Functions +// +#define LED_PIN P1_18 // Used as a status indicator +#define LED2_PIN P1_19 +#define LED3_PIN P1_20 +#define LED4_PIN P1_21 + +/** ------ ------ + * (BEEPER) 1.31 | 1 2 | 1.30 (BTN_ENC) (MISO) 0.8 | 1 2 | 0.7 (SD_SCK) + * (LCD_EN) 0.18 | 3 4 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 3 4 | 0.28 (SD_CS2) + * (LCD_D4) 0.15 5 6 | 0.17 (LCD_D5) (BTN_EN2) 3.26 5 6 | 0.9 (SD_MOSI) + * (LCD_D6) 1.0 | 7 8 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN P1_31 +#define EXP1_02_PIN P1_30 +#define EXP1_03_PIN P0_18 +#define EXP1_04_PIN P0_16 +#define EXP1_05_PIN P0_15 +#define EXP1_06_PIN P0_17 +#define EXP1_07_PIN P1_00 +#define EXP1_08_PIN P1_22 + +#define EXP2_01_PIN P0_08 +#define EXP2_02_PIN P0_07 +#define EXP2_03_PIN P3_25 +#define EXP2_04_PIN P0_28 +#define EXP2_05_PIN P3_26 +#define EXP2_06_PIN P0_09 +#define EXP2_07_PIN P0_27 +#define EXP2_08_PIN -1 // RESET + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #if SD_CONNECTION_IS(ONBOARD) + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN + #else + #define SD_SS_PIN EXP2_04_PIN + #endif +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +#if HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_A0_PIN EXP1_08_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_RESET_PIN EXP1_04_PIN + + #define LCD_USE_DMA_SPI + + #define TOUCH_INT_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_05_PIN + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 + + // Disable any LCD related PINs config + #define LCD_PINS_ENABLE -1 + #define LCD_PINS_RS -1 + + #ifndef TFT_BUFFER_SIZE + #define TFT_BUFFER_SIZE 1200 + #endif + #ifndef TFT_QUEUE_SIZE + #define TFT_QUEUE_SIZE 6144 + #endif + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #elif IS_TFTGLCD_PANEL + + #undef BEEPER_PIN + #undef BTN_ENC + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + + #else + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_SDSS EXP2_04_PIN + + #if ENABLED(MKS_12864OLED_SSD1306) + + #define LCD_PINS_DC EXP1_06_PIN + #define DOGLCD_CS EXP1_04_PIN + #define DOGLCD_A0 LCD_PINS_DC + #define DOGLCD_SCK EXP1_05_PIN + #define DOGLCD_MOSI EXP1_03_PIN + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define KILL_PIN -1 // NC + + #else // !MKS_12864OLED_SSD1306 + + #define LCD_PINS_RS EXP1_04_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + #define LCD_BACKLIGHT_PIN -1 + + #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + + #else // !FYSETC_MINI_12864 + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #endif + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif // !FYSETC_MINI_12864 + + #endif // !MKS_12864OLED_SSD1306 + + #endif // !CR10_STOCKDISPLAY + +#endif // HAS_WIRED_LCD + +// +// Other Pins +// +//#define PIN_P0_02 P0_02 // AUX1 (Interrupt Capable/ADC/Serial Port 0) +//#define PIN_P0_03 P0_03 // AUX1 (Interrupt Capable/ADC/Serial Port 0) +//#define PS_ON_PIN P1_23 // SERVO0 P1.23 diff --git a/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/src/pins/lpc1768/pins_RAMPS_RE_ARM.h new file mode 100644 index 0000000..fe424c8 --- /dev/null +++ b/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -0,0 +1,495 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Re-ARM with RAMPS v1.4 pin assignments + * + * Applies to the following boards: + * + * RAMPS_14_EFB (Hotend, Fan, Bed) + * RAMPS_14_EEB (Hotend0, Hotend1, Bed) + * RAMPS_14_EFF (Hotend, Fan0, Fan1) + * RAMPS_14_EEF (Hotend0, Hotend1, Fan) + * RAMPS_14_SF (Spindle, Controller Fan) + */ + +// Numbers in parentheses () are the corresponding mega2560 pin numbers + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Re-ARM RAMPS 1.4" + +// +// Servos +// +#define SERVO0_PIN P1_20 // (11) +#define SERVO1_PIN P1_21 // ( 6) also on J5-1 +#define SERVO2_PIN P1_19 // ( 5) +#define SERVO3_PIN P1_18 // ( 4) 5V output + +// +// Limit Switches +// +#define X_MIN_PIN P1_24 // ( 3) 10k pullup to 3.3V, 1K series +#define X_MAX_PIN P1_25 // ( 2) 10k pullup to 3.3V, 1K series +#define Y_MIN_PIN P1_26 // (14) 10k pullup to 3.3V, 1K series +#define Y_MAX_PIN P1_27 // (15) 10k pullup to 3.3V, 1K series +#define Z_MIN_PIN P1_29 // (18) 10k pullup to 3.3V, 1K series +#define Z_MAX_PIN P1_28 // (19) 10k pullup to 3.3V, 1K series +#define ONBOARD_ENDSTOPPULLUPS // Board has built-in pullups + +// +// Steppers +// +#define X_STEP_PIN P2_01 // (54) +#define X_DIR_PIN P0_11 // (55) +#define X_ENABLE_PIN P0_10 // (38) +#ifndef X_CS_PIN + #define X_CS_PIN P1_01 // ETH +#endif + +#define Y_STEP_PIN P2_02 // (60) +#define Y_DIR_PIN P0_20 // (61) +#define Y_ENABLE_PIN P0_19 // (56) +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_04 // ETH +#endif + +#define Z_STEP_PIN P2_03 // (46) +#define Z_DIR_PIN P0_22 // (48) +#define Z_ENABLE_PIN P0_21 // (62) +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_10 // ETH +#endif + +#define E0_STEP_PIN P2_00 // (26) +#define E0_DIR_PIN P0_05 // (28) +#define E0_ENABLE_PIN P0_04 // (24) +#ifndef E0_CS_PIN + #define E0_CS_PIN P1_14 // ETH +#endif + +#define E1_STEP_PIN P2_08 // (36) +#define E1_DIR_PIN P2_13 // (34) +#define E1_ENABLE_PIN P4_29 // (30) +#ifndef E1_CS_PIN + #define E1_CS_PIN -1 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P1_00 // ETH + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P1_08 // ETH + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P1_09 // ETH + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + + + // P2_08 E1-Step + // P2_13 E1-Dir + + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN P0_01 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + #endif + + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN P0_00 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + #endif + + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN P2_13 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + #endif + + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN P2_08 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + #endif + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_0_PIN +#define TEMP_BED_PIN P0_24_A1 // A1 (T1) - (68) - TEMP_BED_PIN +#define TEMP_1_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_1_PIN +#define TEMP_2_PIN P0_26_A3 // A3 - (63) - J5-3 & AUX-2 +#define TEMP_3_PIN P1_30_A4 // A4 - (37) - BUZZER_PIN +//#define TEMP_4_PIN P1_31_A5 // A5 - (49) - SD_DETECT_PIN +//#define ?? P0_03_A6 // A6 - ( 0) - RXD0 - J4-4 & AUX-1 +#define FILWIDTH_PIN P0_02_A7 // A7 - ( 1) - TXD0 - J4-5 & AUX-1 + +// +// Heaters / Fans +// +#ifndef MOSFET_A_PIN + #define MOSFET_A_PIN P2_05 +#endif +#ifndef MOSFET_B_PIN + #define MOSFET_B_PIN P2_04 +#endif +#ifndef MOSFET_C_PIN + #define MOSFET_C_PIN P2_07 +#endif +#ifndef MOSFET_D_PIN + #define MOSFET_D_PIN -1 +#endif + +#define HEATER_0_PIN MOSFET_A_PIN + +#if FET_ORDER_EFB // Hotend, Fan, Bed + #define HEATER_BED_PIN MOSFET_C_PIN +#elif FET_ORDER_EEF // Hotend, Hotend, Fan + #define HEATER_1_PIN MOSFET_B_PIN +#elif FET_ORDER_EEB // Hotend, Hotend, Bed + #define HEATER_1_PIN MOSFET_B_PIN + #define HEATER_BED_PIN MOSFET_C_PIN +#elif FET_ORDER_EFF // Hotend, Fan, Fan + #define FAN1_PIN MOSFET_C_PIN +#elif DISABLED(FET_ORDER_SF) // Not Spindle, Fan (i.e., "EFBF" or "EFBE") + #define HEATER_BED_PIN MOSFET_C_PIN + #if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #define FAN1_PIN MOSFET_D_PIN + #else + #define HEATER_1_PIN MOSFET_D_PIN + #endif +#endif + +#ifndef FAN_PIN + #if EITHER(FET_ORDER_EFB, FET_ORDER_EFF) // Hotend, Fan, Bed or Hotend, Fan, Fan + #define FAN_PIN MOSFET_B_PIN + #elif EITHER(FET_ORDER_EEF, FET_ORDER_SF) // Hotend, Hotend, Fan or Spindle, Fan + #define FAN_PIN MOSFET_C_PIN + #elif FET_ORDER_EEB // Hotend, Hotend, Bed + #define FAN_PIN P1_18 // (4) IO pin. Buffer needed + #else // Non-specific are "EFB" (i.e., "EFBF" or "EFBE") + #define FAN_PIN MOSFET_B_PIN + #endif +#endif + +// +// Misc. Functions +// +#define LED_PIN P4_28 // (13) + +// define digital pin 5 for the filament runout sensor. Use the RAMPS 1.4 digital input 5 on the servos connector +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN P1_19 // (5) +#endif + +#define PS_ON_PIN P2_12 // (12) + +#if !defined(TEMP_0_CS_PIN) && !(HAS_Z_AXIS && Z_HOME_DIR) + #define TEMP_0_CS_PIN P1_28 +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !PIN_EXISTS(CASE_LIGHT) && !defined(SPINDLE_LASER_ENA_PIN) + #if !defined(NUM_SERVOS) || NUM_SERVOS < 4 // Try to use servo connector + #define CASE_LIGHT_PIN P1_18 // (4) MUST BE HARDWARE PWM + #endif +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// Use servo pins, if available +// +#if HAS_CUTTER && !PIN_EXISTS(SPINDLE_LASER_ENA) + #if NUM_SERVOS > 1 + #if ENABLED(SPINDLE_FEATURE) + #error "SPINDLE_FEATURE requires 3 free servo pins." + #else + #error "LASER_FEATURE requires 3 free servo pins." + #endif + #endif + #define SPINDLE_LASER_ENA_PIN SERVO1_PIN // (6) Pin should have a pullup/pulldown! + #define SPINDLE_LASER_PWM_PIN SERVO3_PIN // (4) MUST BE HARDWARE PWM + #define SPINDLE_DIR_PIN SERVO2_PIN // (5) +#endif + +// +// Průša i3 MK2 Multiplexer Support +// +#if HAS_PRUSA_MMU1 + #if SERIAL_PORT != 0 && SERIAL_PORT_2 != 0 + #define E_MUX0_PIN P0_03 // ( 0) Z_CS_PIN + #define E_MUX1_PIN P0_02 // ( 1) E0_CS_PIN + #endif + #define E_MUX2_PIN P0_26 // (63) E1_CS_PIN +#endif + +/** + * LCD / Controller + * + * All controllers can use J3 and J5 on the Re-ARM board. Custom cabling will be required. + * + * - https://github.com/wolfmanjm/universal-panel-adapter + * - https://panucattdevices.freshdesk.com/support/solutions/articles/1000243195-lcd-display-installation + */ + +/** + * Smart LCD adapter + * + * The Smart LCD adapter can be used for the two 10 pin LCD controllers such as + * REPRAP_DISCOUNT_SMART_CONTROLLER. It can't be used for controllers that use + * DOGLCD_A0, DOGLCD_CS, LCD_PINS_D5, LCD_PINS_D6 or LCD_PINS_D7. A custom cable + * is needed to pick up 5V for the EXP1 connection. + * + * SD card on the LCD uses the same SPI signals as the LCD. This results in garbage/lines + * on the LCD display during accesses of the SD card. The menus/code has been arranged so + * that the garbage/lines are erased immediately after the SD card accesses are completed. + */ + +#if ENABLED(CR10_STOCKDISPLAY) + + // Re-Arm can support Creality stock display without SD card reader and single cable on EXP3. + // Re-Arm J3 pins 1 (p1.31) & 2 (P3.26) are not used. Stock cable will need to have one + // 10-pin IDC connector trimmed or replaced with a 12-pin IDC connector to fit J3. + // Requires REVERSE_ENCODER_DIRECTION in Configuration.h + + #define BEEPER_PIN P2_11 // J3-3 & AUX-4 + + #define BTN_EN1 P0_16 // J3-7 & AUX-4 + #define BTN_EN2 P1_23 // J3-5 & AUX-4 + #define BTN_ENC P3_25 // J3-4 & AUX-4 + + #define LCD_PINS_RS P0_15 // J3-9 & AUX-4 (CS) + #define LCD_PINS_ENABLE P0_18 // J3-10 & AUX-3 (SID, MOSI) + #define LCD_PINS_D4 P2_06 // J3-8 & AUX-3 (SCK, CLK) + +#elif ENABLED(ZONESTAR_LCD) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ZONESTAR_LCD on REARM requires wiring modifications. NB. ADCs are not 5V tolerant. See 'pins_RAMPS_RE_ARM.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + +#elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS P3_26 // (31) J3-2 & AUX-4 + #endif + + #define SD_DETECT_PIN P1_31 // (49) J3-1 & AUX-3 (NOT 5V tolerant) + #define KILL_PIN P1_22 // (41) J5-4 & AUX-4 + +#elif HAS_WIRED_LCD + + #if ENABLED(FYSETC_MINI_12864) + #define BEEPER_PIN P1_01 + #define BTN_ENC P1_04 + #else + #define BEEPER_PIN P1_30 // (37) not 5V tolerant + #define BTN_ENC P2_11 // (35) J3-3 & AUX-4 + #endif + + #define BTN_EN1 P3_26 // (31) J3-2 & AUX-4 + #define BTN_EN2 P3_25 // (33) J3-4 & AUX-4 + + #define SD_DETECT_PIN P1_31 // (49) J3-1 & AUX-3 (NOT 5V tolerant) + #define KILL_PIN P1_22 // (41) J5-4 & AUX-4 + #define LCD_PINS_RS P0_16 // (16) J3-7 & AUX-4 + #define LCD_SDSS P1_23 // (53) J3-5 & AUX-3 + + #if IS_NEWPANEL + #if IS_RRW_KEYPAD + #define SHIFT_OUT_PIN P0_18 // (51) (MOSI) J3-10 & AUX-3 + #define SHIFT_CLK_PIN P0_15 // (52) (SCK) J3-9 & AUX-3 + #define SHIFT_LD_PIN P1_31 // (49) J3-1 & AUX-3 (NOT 5V tolerant) + #endif + #else + //#define SHIFT_CLK_PIN P3_26 // (31) J3-2 & AUX-4 + //#define SHIFT_LD_PIN P3_25 // (33) J3-4 & AUX-4 + //#define SHIFT_OUT_PIN P2_11 // (35) J3-3 & AUX-4 + //#define SHIFT_EN_PIN P1_22 // (41) J5-4 & AUX-4 + #endif + + #if EITHER(VIKI2, miniVIKI) + #define DOGLCD_CS P0_16 // (16) + #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 + #define DOGLCD_SCK SD_SCK_PIN + #define DOGLCD_MOSI SD_MOSI_PIN + + #define STAT_LED_BLUE_PIN P0_26 // (63) may change if cable changes + #define STAT_LED_RED_PIN P1_21 // ( 6) may change if cable changes + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #else + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_SCK P0_15 + #define DOGLCD_MOSI P0_18 + + // EXP1 on LCD adapter is not usable - using Ethernet connector instead + #define DOGLCD_CS P1_09 + #define DOGLCD_A0 P1_14 + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN P0_16 // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN P1_00 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN P1_01 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN P1_08 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN P1_00 + #endif + #else + #define DOGLCD_CS P0_26 // (63) J5-3 & AUX-2 + #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 + #endif + + #define LCD_BACKLIGHT_PIN P0_16 //(16) J3-7 & AUX-4 - only used on DOGLCD controllers + #define LCD_PINS_ENABLE P0_18 // (51) (MOSI) J3-10 & AUX-3 + #define LCD_PINS_D4 P0_15 // (52) (SCK) J3-9 & AUX-3 + #if IS_ULTIPANEL + #define LCD_PINS_D5 P1_17 // (71) ENET_MDIO + #define LCD_PINS_D6 P1_14 // (73) ENET_RX_ER + #define LCD_PINS_D7 P1_10 // (75) ENET_RXD1 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + #endif + + #if ENABLED(MINIPANEL) + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #endif + +#endif // HAS_WIRED_LCD + +// +// Ethernet pins +// +#if !IS_ULTIPANEL + #define ENET_MDIO P1_17 // (71) J12-4 + #define ENET_RX_ER P1_14 // (73) J12-6 + #define ENET_RXD1 P1_10 // (75) J12-8 +#endif +#define ENET_MOC P1_16 // (70) J12-3 +#define REF_CLK P1_15 // (72) J12-5 +#define ENET_RXD0 P1_09 // (74) J12-7 +#define ENET_CRS P1_08 // (76) J12-9 +#define ENET_TX_EN P1_04 // (77) J12-10 +#define ENET_TXD0 P1_00 // (78) J12-11 +#define ENET_TXD1 P1_01 // (79) J12-12 + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(LCD) + #define SD_SCK_PIN P0_15 // (52) system defined J3-9 & AUX-3 + #define SD_MISO_PIN P0_17 // (50) system defined J3-10 & AUX-3 + #define SD_MOSI_PIN P0_18 // (51) system defined J3-10 & AUX-3 + #define SD_SS_PIN P1_23 // (53) system defined J3-5 & AUX-3 (Sometimes called SDSS) - CS used by Marlin +#elif SD_CONNECTION_IS(ONBOARD) + #undef SD_DETECT_PIN + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +/** + * Fast PWMs + * + * The LPC1768's hardware PWM controller has 6 channels. Each channel + * can be setup to either control a dedicated pin directly or to generate + * an interrupt. The direct method's duty cycle is accurate to within a + * a microsecond. The interrupt method's average duty cycle has the + * the same accuracy but the individual cycles can vary because of higher + * priority interrupts. + * + * All Fast PWMs have a 50Hz rate. + * + * The following pins/signals use the direct method. All other pins use the + * the interrupt method. Note that SERVO2_PIN and MOSFET_C_PIN use the + * interrupt method. + * + * P1_20 (11) SERVO0_PIN + * P1_21 ( 6) SERVO1_PIN J5-1 + * P0_18 ( 4) SERVO3_PIN 5V output + * *P2_04 ( 9) MOSFET_B_PIN + * *P2_05 (10) MOSFET_A_PIN + * + * * - If used as a heater driver then a Fast PWM is NOT assigned. If used as + * a fan driver then enabling FAST_PWM_FAN assigns a Fast PWM to it. + */ + + /** + * Special pins + * P1_30 (37) (NOT 5V tolerant) + * P1_31 (49) (NOT 5V tolerant) + * P0_27 (57) (Open collector) + * P0_28 (58) (Open collector) + */ + +/** + * The following mega2560 pins are NOT available in a Re-ARM system: + * + * 7, 17, 22, 23, 25, 27, 29, 32, 39, 40, 42, 43, 44, 45, 47, 64, 65, 66 + */ diff --git a/src/pins/lpc1768/pins_SELENA_COMPACT.h b/src/pins/lpc1768/pins_SELENA_COMPACT.h new file mode 100644 index 0000000..2972ac7 --- /dev/null +++ b/src/pins/lpc1768/pins_SELENA_COMPACT.h @@ -0,0 +1,116 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Selena Compact pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Selena Compact" +#define BOARD_WEBSITE_URL "github.com/Ales2-k/Selena" + +// +// Servos +// +#define SERVO0_PIN P1_23 + +// +// Limit Switches +// +#define X_MIN_PIN P1_28 +#define X_MAX_PIN P1_25 +#define Y_STOP_PIN P2_11 +#define Z_STOP_PIN P1_27 +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P1_22 +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P0_04 + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P0_11 +#define Y_ENABLE_PIN P0_10 + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P0_20 +#define Z_ENABLE_PIN P0_19 + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P0_22 +#define E0_ENABLE_PIN P0_21 + +#define E1_STEP_PIN P2_08 +#define E1_DIR_PIN P2_13 +#define E1_ENABLE_PIN P4_29 + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_BED_PIN P0_23_A0 // A0 (TH1) +#define TEMP_0_PIN P0_24_A1 // A1 (TH2) +#define TEMP_1_PIN P0_25_A2 // A2 (TH3) + +// +// Heaters / Fans +// + +#define HEATER_BED_PIN P2_05 +#define HEATER_BED2_PIN P2_04 +#define HEATER_0_PIN P2_07 +#define HEATER_1_PIN P2_06 +#ifndef FAN_PIN + #define FAN_PIN P1_24 +#endif +#define FAN1_PIN P1_26 + +// +// Display +// + +#if IS_RRD_FG_SC + #define LCD_PINS_RS P0_16 + #define LCD_PINS_ENABLE P0_18 + #define LCD_PINS_D4 P0_15 + #define LCD_PINS_D5 P1_00 + #define LCD_PINS_D6 P1_01 + #define LCD_PINS_D7 P1_04 + #define BEEPER_PIN P1_31 + + #define BTN_EN1 P3_25 + #define BTN_EN2 P3_26 + #define BTN_ENC P1_30 + + #define SD_DETECT_PIN -1 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif // IS_RRD_FG_SC diff --git a/src/pins/lpc1769/env_validate.h b/src/pins/lpc1769/env_validate.h new file mode 100644 index 0000000..2e2b63d --- /dev/null +++ b/src/pins/lpc1769/env_validate.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(MCU_LPC1769) + #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." +#endif diff --git a/src/pins/lpc1769/pins_AZTEEG_X5_GT.h b/src/pins/lpc1769/pins_AZTEEG_X5_GT.h new file mode 100644 index 0000000..bc7cada --- /dev/null +++ b/src/pins/lpc1769/pins_AZTEEG_X5_GT.h @@ -0,0 +1,124 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Azteeg X5 GT pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Azteeg X5 GT" +#define BOARD_WEBSITE_URL "tinyurl.com/yx8tdqa3" + +// +// Servos +// +#define SERVO0_PIN P1_23 + +// +// Limit Switches +// +#define X_MIN_PIN P1_24 +#define X_MAX_PIN P1_27 +#define Y_MIN_PIN P1_25 +#define Y_MAX_PIN P1_28 +#define Z_MIN_PIN P1_26 +#define Z_MAX_PIN P1_29 + +// +// Steppers +// +#define X_STEP_PIN P2_01 +#define X_DIR_PIN P0_11 +#define X_ENABLE_PIN P0_10 +#ifndef X_CS_PIN + #define X_CS_PIN P0_10 // BSD2660 default +#endif + +#define Y_STEP_PIN P2_02 +#define Y_DIR_PIN P0_20 +#define Y_ENABLE_PIN P0_19 +#ifndef Y_CS_PIN + #define Y_CS_PIN P0_19 // BSD2660 default +#endif + +#define Z_STEP_PIN P2_03 +#define Z_DIR_PIN P0_22 +#define Z_ENABLE_PIN P0_21 +#ifndef Z_CS_PIN + #define Z_CS_PIN P0_21 // BSD2660 default +#endif + +#define E0_STEP_PIN P2_00 +#define E0_DIR_PIN P0_05 +#define E0_ENABLE_PIN P0_04 +#ifndef E0_CS_PIN + #define E0_CS_PIN P0_04 // BSD2660 default +#endif + +#define E1_STEP_PIN P2_08 +#define E1_DIR_PIN P2_13 +#define E1_ENABLE_PIN P4_29 +#ifndef E1_CS_PIN + #define E1_CS_PIN P4_29 // BSD2660 default +#endif + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_BED_PIN P0_23_A0 // A0 (TH1) +#define TEMP_0_PIN P0_24_A1 // A1 (TH2) +#define TEMP_1_PIN P0_25_A2 // A2 (TH3) + +// +// Heaters / Fans +// + +#define HEATER_BED_PIN P2_07 +#define HEATER_0_PIN P2_04 +#define HEATER_1_PIN P2_05 +#ifndef FAN_PIN + #define FAN_PIN P0_26 +#endif +#define FAN1_PIN P1_22 + +// +// Display +// + +#if EITHER(VIKI2, miniVIKI) + #define BEEPER_PIN P1_31 + #define DOGLCD_A0 P2_06 + #define DOGLCD_CS P0_16 + + #define BTN_EN1 P3_25 + #define BTN_EN2 P3_26 + #define BTN_ENC P2_11 + + #define SD_DETECT_PIN P1_18 + #define SDSS P1_21 + + #define STAT_LED_RED_PIN P1_19 + #define STAT_LED_BLUE_PIN P1_20 +#endif diff --git a/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h new file mode 100644 index 0000000..c33fe6e --- /dev/null +++ b/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -0,0 +1,211 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Azteeg X5 MINI pin assignments + */ +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Azteeg X5 MINI" +#endif +#define BOARD_WEBSITE_URL "tiny.cc/x5_mini" + +// +// LED +// +#define LED_PIN P1_18 +#define LED2_PIN P1_20 +#define LED3_PIN P1_19 +#define LED4_PIN P1_21 + +// +// Servos +// +#define SERVO0_PIN P1_29 + +// +// Limit Switches +// +#define X_STOP_PIN P1_24 +#define Y_STOP_PIN P1_26 +#define Z_STOP_PIN P1_28 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN P2_04 +#endif + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN P0_25_A2 // Analog Input (P0_25) +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_01 +#define X_DIR_PIN P0_11 +#define X_ENABLE_PIN P0_10 + +#define Y_STEP_PIN P2_02 +#define Y_DIR_PIN P0_20 +#define Y_ENABLE_PIN P0_19 + +#define Z_STEP_PIN P2_03 +#define Z_DIR_PIN P0_22 +#define Z_ENABLE_PIN P0_21 + +#define E0_STEP_PIN P2_00 +#define E0_DIR_PIN P0_05 +#define E0_ENABLE_PIN P0_04 + +// +// DIGIPOT slave addresses (7-bit unshifted) +// +#ifndef DIGIPOT_I2C_ADDRESS_A + #define DIGIPOT_I2C_ADDRESS_A 0x2C +#endif +#ifndef DIGIPOT_I2C_ADDRESS_B + #define DIGIPOT_I2C_ADDRESS_B 0x2E +#endif + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_BED_PIN P0_23_A0 // A0 (TH1) +#define TEMP_0_PIN P0_24_A1 // A1 (TH2) + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P2_07 +#define HEATER_0_PIN P2_05 +#ifndef FAN_PIN + #define FAN_PIN P0_26 +#endif +#define FAN1_PIN P1_25 + +// +// Display +// +#if HAS_WIRED_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + // Re-Arm can support Creality stock display without SD card reader and single cable on EXP3. + // Re-Arm J3 pins 1 (p1.31) & 2 (P3.26) are not used. Stock cable will need to have one + // 10-pin IDC connector trimmed or replaced with a 12-pin IDC connector to fit J3. + // Requires REVERSE_ENCODER_DIRECTION in Configuration.h + + #define BEEPER_PIN P2_11 // J3-3 & AUX-4 + + #define BTN_EN1 P0_16 // J3-7 & AUX-4 + #define BTN_EN2 P1_23 // J3-5 & AUX-4 + #define BTN_ENC P3_25 // J3-4 & AUX-4 + + #define LCD_PINS_RS P0_15 // J3-9 & AUX-4 (CS) + #define LCD_PINS_ENABLE P0_18 // J3-10 & AUX-3 (SID, MOSI) + #define LCD_PINS_D4 P2_06 // J3-8 & AUX-3 (SCK, CLK) + + #else + + #define BTN_EN1 P3_26 // (31) J3-2 & AUX-4 + #define BTN_EN2 P3_25 // (33) J3-4 & AUX-4 + #define BTN_ENC P2_11 // (35) J3-3 & AUX-4 + + #define SD_DETECT_PIN P1_31 // (49) not 5V tolerant J3-1 & AUX-3 + #define KILL_PIN P1_22 // (41) J5-4 & AUX-4 + #define LCD_PINS_RS P0_16 // (16) J3-7 & AUX-4 + #define LCD_SDSS P0_16 // (16) J3-7 & AUX-4 + #define LCD_BACKLIGHT_PIN P0_16 // (16) J3-7 & AUX-4 - only used on DOGLCD controllers + #define LCD_PINS_ENABLE P0_18 // (51) (MOSI) J3-10 & AUX-3 + #define LCD_PINS_D4 P0_15 // (52) (SCK) J3-9 & AUX-3 + + #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 + + #if IS_RRW_KEYPAD + #define SHIFT_OUT_PIN P0_18 // (51) (MOSI) J3-10 & AUX-3 + #define SHIFT_CLK_PIN P0_15 // (52) (SCK) J3-9 & AUX-3 + #define SHIFT_LD_PIN P1_31 // (49) not 5V tolerant J3-1 & AUX-3 + #elif !IS_NEWPANEL + //#define SHIFT_OUT_PIN P2_11 // (35) J3-3 & AUX-4 + //#define SHIFT_CLK_PIN P3_26 // (31) J3-2 & AUX-4 + //#define SHIFT_LD_PIN P3_25 // (33) J3-4 & AUX-4 + //#define SHIFT_EN_PIN P1_22 // (41) J5-4 & AUX-4 + #endif + + #if EITHER(VIKI2, miniVIKI) + #define BEEPER_PIN P1_30 // (37) may change if cable changes + #define DOGLCD_CS P0_26 // (63) J5-3 & AUX-2 + #define DOGLCD_SCK SD_SCK_PIN + #define DOGLCD_MOSI SD_MOSI_PIN + + #define STAT_LED_BLUE_PIN P0_26 // (63) may change if cable changes + #define STAT_LED_RED_PIN P1_21 // ( 6) may change if cable changes + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #else + #if IS_ULTIPANEL + #define LCD_PINS_D5 P1_17 // (71) ENET_MDIO + #define LCD_PINS_D6 P1_14 // (73) ENET_RX_ER + #define LCD_PINS_D7 P1_10 // (75) ENET_RXD1 + #endif + #define BEEPER_PIN P1_30 // (37) not 5V tolerant + #define DOGLCD_CS P0_16 // (16) + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #if ENABLED(MINIPANEL) + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #endif + + #endif + +#endif // HAS_WIRED_LCD + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(LCD) + #define SD_SCK_PIN P0_15 + #define SD_MISO_PIN P0_17 + #define SD_MOSI_PIN P0_18 + #define SD_SS_PIN P1_23 +#elif SD_CONNECTION_IS(ONBOARD) + #undef SD_DETECT_PIN + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif diff --git a/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h b/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h new file mode 100644 index 0000000..086bacb --- /dev/null +++ b/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h @@ -0,0 +1,42 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Azteeg X5 MINI WIFI pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Azteeg X5 MINI WIFI" + +// +// DIGIPOT slave addresses +// +#ifndef DIGIPOT_I2C_ADDRESS_A + #define DIGIPOT_I2C_ADDRESS_A 0x58 // shifted slave address for first DIGIPOT (0x58 <- 0x2C << 1) +#endif +#ifndef DIGIPOT_I2C_ADDRESS_B + #define DIGIPOT_I2C_ADDRESS_B 0x5C // shifted slave address for second DIGIPOT (0x5C <- 0x2E << 1) +#endif + +#include "pins_AZTEEG_X5_MINI.h" diff --git a/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h new file mode 100644 index 0000000..dbaafb8 --- /dev/null +++ b/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -0,0 +1,291 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BigTreeTech SKR E3 Turbo pin assignments + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR E3 Turbo" +#endif + +#define USES_DIAG_JUMPERS + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4K (AT24C32) + +// +// Servos +// +#define SERVO0_PIN P1_23 + +// +// TMC StallGuard DIAG pins +// +#define X_DIAG_PIN P1_29 // X-STOP +#define Y_DIAG_PIN P1_28 // Y-STOP +#define Z_DIAG_PIN P1_27 // Z-STOP +#define E0_DIAG_PIN P1_26 // E0DET +#define E1_DIAG_PIN P1_25 // E1DET + +// +// Limit Switches +#define X_STOP_PIN X_DIAG_PIN +#define Y_STOP_PIN Y_DIAG_PIN +#define Z_STOP_PIN Z_DIAG_PIN + +// +// Z Probe +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P1_22 +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN P1_26 // E0DET +#define FIL_RUNOUT2_PIN P1_25 // E1DET + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN P1_21 +#endif + +// LED driving pin +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN P1_24 +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN P1_20 // PWRDET +#endif + +// +// Steppers +// +#define X_STEP_PIN P1_04 +#define X_DIR_PIN P1_08 +#define X_ENABLE_PIN P1_00 +#ifndef X_CS_PIN + #define X_CS_PIN P1_01 +#endif + +#define Y_STEP_PIN P1_14 +#define Y_DIR_PIN P1_15 +#define Y_ENABLE_PIN P1_09 +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_10 +#endif + +#define Z_STEP_PIN P4_29 +#define Z_DIR_PIN P4_28 +#define Z_ENABLE_PIN P1_16 +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_17 +#endif + +#define E0_STEP_PIN P2_06 +#define E0_DIR_PIN P2_07 +#define E0_ENABLE_PIN P0_04 +#ifndef E0_CS_PIN + #define E0_CS_PIN P0_05 +#endif + +#define E1_STEP_PIN P2_11 +#define E1_DIR_PIN P2_12 +#define E1_ENABLE_PIN P0_21 +#ifndef E1_CS_PIN + #define E1_CS_PIN P0_22 +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + + #define X_SERIAL_TX_PIN P1_01 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN P1_10 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN P1_17 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN P0_05 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN P0_22 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// TMC Low Power Standby pins +// +#define X_STDBY_PIN P3_26 +#define Y_STDBY_PIN P3_25 +#define Z_STDBY_PIN P1_18 +#define E0_STDBY_PIN P1_19 +#define E1_STDBY_PIN P2_13 + +// +// Temperature Sensors +// +#define TEMP_0_PIN P0_24 +#define TEMP_1_PIN P0_23 +#define TEMP_BED_PIN P0_25 +#define TEMP_BOARD_PIN P1_30 // Onboard thermistor, NTC100K + +// +// Heaters / Fans +// +#define HEATER_0_PIN P2_03 // EXTRUDER 0 +#define HEATER_1_PIN P2_04 // EXTRUDER 1 +#define HEATER_BED_PIN P2_05 // BED +#define FAN_PIN P2_01 +#define FAN1_PIN P2_02 + +#ifndef CONTROLLER_FAN_PIN + #define CONTROLLER_FAN_PIN FAN1_PIN +#endif + +/** + * ------ + * (BEEPER) P2_08 | 1 2 | P0_16 (BTN_ENC) + * (BTN_EN1) P0_19 | 3 4 | RESET + * (BTN_EN2) P0_20 5 6 | P0_15 (LCD_D4) + * (LCD_RS) P0_17 | 7 8 | P0_18 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP + */ +#define EXP1_01_PIN P2_08 +#define EXP1_02_PIN P0_16 +#define EXP1_03_PIN P0_19 +#define EXP1_04_PIN -1 +#define EXP1_05_PIN P0_20 +#define EXP1_06_PIN P0_15 +#define EXP1_07_PIN P0_17 +#define EXP1_08_PIN P0_18 + +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! Ender-3 V2 display requires a custom cable with TX = P0_15, RX = P0_16. See 'pins_BTT_SKR_E3_TURBO.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * Ender 3 V2 display SKR E3 Turbo (EXP1) Ender 3 V2 display --> SKR E3 Turbo + * ------ ------ RX 3 --> 5 P0_15 + * -- | 1 2 | -- (BEEPER) P2_08 |10 9 | P0_16 (BTN_ENC) TX 4 --> 9 P0_16 + * (SKR_TX1) RX | 3 4 | TX (SKR_RX1) (BTN_EN1) P0_19 | 8 7 | RESET BEEPER 6 --> 10 P2_08 + * (BTN_ENC) ENT 5 6 | BEEPER (BTN_EN2) P0_20 6 5 | P0_15 (LCD_D4) + * (BTN_E2) B | 7 8 | A (BTN_E1) (LCD_RS) P0_17 | 4 3 | P0_18 (LCD_EN) + * GND | 9 10 | 5V GND | 2 1 | 5V + * ------ ------ + */ + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_05_PIN + +#elif HAS_WIRED_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN EXP1_01_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_E3_TURBO.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_02_PIN + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN + #define ADC_KEYPAD_PIN P1_23 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN + + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #else + + #error "Only ZONESTAR_LCD, MKS_MINI_12864, ENDER2_STOCKDISPLAY, and CR10_STOCKDISPLAY are currently supported on the BTT_SKR_E3_TURBO." + + #endif + +#endif // HAS_WIRED_LCD + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN P2_00 + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define SD_SS_PIN P0_06 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR E3 Turbo." +#endif diff --git a/src/pins/lpc1769/pins_BTT_SKR_V1_4_TURBO.h b/src/pins/lpc1769/pins_BTT_SKR_V1_4_TURBO.h new file mode 100644 index 0000000..7f428fc --- /dev/null +++ b/src/pins/lpc1769/pins_BTT_SKR_V1_4_TURBO.h @@ -0,0 +1,34 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BigTreeTech SKR 1.4 Turbo pin assignments + */ + +#define BOARD_INFO_NAME "BTT SKR V1.4 TURBO" + +// +// Include SKR 1.4 pins +// +#define REQUIRE_LPC1769 +#include "../lpc1768/pins_BTT_SKR_V1_4.h" // ... BTT_SKR_common diff --git a/src/pins/lpc1769/pins_COHESION3D_MINI.h b/src/pins/lpc1769/pins_COHESION3D_MINI.h new file mode 100644 index 0000000..237dfae --- /dev/null +++ b/src/pins/lpc1769/pins_COHESION3D_MINI.h @@ -0,0 +1,175 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Cohesion3D Mini pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Cohesion3D Mini" + +// +// Servos +// +#define SERVO0_PIN P1_23 + +// +// Limit Switches +// +#define X_MIN_PIN P1_24 // 10k pullup to 3.3V +#define X_MAX_PIN P1_25 // 10k pullup to 3.3V +#define Y_MIN_PIN P1_26 // 10k pullup to 3.3V +#define Y_MAX_PIN P1_27 // 10k pullup to 3.3V +#define Z_MIN_PIN P1_28 // 10k pullup to 3.3V +#define Z_MAX_PIN P1_29 // 10k pullup to 3.3V + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P0_04 +#define X_CS_PIN P1_10 // Ethernet Expansion - Pin 9 + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P0_11 +#define Y_ENABLE_PIN P0_10 +#define Y_CS_PIN P1_09 // Ethernet Expansion - Pin 10 + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P0_20 +#define Z_ENABLE_PIN P0_19 +#define Z_CS_PIN P1_00 // Ethernet Expansion - Pin 11 + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P0_22 +#define E0_ENABLE_PIN P0_21 +#define E0_CS_PIN P1_04 // Ethernet Expansion - Pin 12 + +// +// Default pins for TMC software SPI +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P1_16 // Ethernet Expansion - Pin 5 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P1_17 // Ethernet Expansion - Pin 6 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P1_08 // Ethernet Expansion - Pin 7 + #endif +#endif + +// +// Analog Inputs +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_23_A0 // P0_23 +#define TEMP_BED_PIN P0_24_A1 // P0_24 + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P2_05 +#define HEATER_0_PIN P2_07 // FET 1 +#ifndef FAN_PIN + #define FAN_PIN P2_06 // FET 3 +#endif + +// +// Auto fans +// +#define AUTO_FAN_PIN P2_04 // FET 4 +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN AUTO_FAN_PIN +#endif + +// +// Misc. Functions +// +#define LED_PIN P4_28 // Play LED + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + #undef HEATER_0_PIN + #define SPINDLE_LASER_ENA_PIN P2_07 // FET 1 + #undef HEATER_BED_PIN + #define SPINDLE_LASER_PWM_PIN P2_05 // Bed FET + #undef FAN_PIN + #define SPINDLE_DIR_PIN P2_06 // FET 3 +#endif + +// +// LCD / Controller +// +// LCD_PINS_D5, D6, and D7 are not present in the EXP1 connector, and will need to be +// defined to use the REPRAP_DISCOUNT_SMART_CONTROLLER. +// +// A remote SD card is currently not supported because the pins routed to the EXP2 +// connector are shared with the onboard SD card, and Marlin does not support reading +// G-code files from the onboard SD card. +// +#if HAS_WIRED_LCD + + #define BEEPER_PIN P0_27 // EXP2-7 - open drain + + #define BTN_EN1 P3_26 // EXP2-5 + #define BTN_EN2 P3_25 // EXP2-3 + #define BTN_ENC P1_30 // EXP1-2 + + #define LCD_PINS_RS P0_16 // EXP1-4 + #define LCD_SDSS P0_28 // EXP2-4 + #define LCD_PINS_ENABLE P0_18 // EXP1-3 + #define LCD_PINS_D4 P0_15 // EXP1-5 + + #define KILL_PIN P2_11 // EXP2-10 + + #if ENABLED(SDSUPPORT) + #error "SDSUPPORT is not currently supported by the Cohesion3D boards" + #endif + +#endif // HAS_WIRED_LCD + +// +// Ethernet pins +// +#define ENET_MDIO P1_17 +#define ENET_RX_ER P1_14 +#define ENET_RXD1 P1_10 +#define ENET_MOC P1_16 +#define REF_CLK P1_15 +#define ENET_RXD0 P1_09 +#define ENET_CRS P1_08 +#define ENET_TX_EN P1_04 +#define ENET_TXD0 P1_00 +#define ENET_TXD1 P1_01 diff --git a/src/pins/lpc1769/pins_COHESION3D_REMIX.h b/src/pins/lpc1769/pins_COHESION3D_REMIX.h new file mode 100644 index 0000000..ea2e0b7 --- /dev/null +++ b/src/pins/lpc1769/pins_COHESION3D_REMIX.h @@ -0,0 +1,286 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Cohesion3D ReMix pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Cohesion3D ReMix" + +// +// Servos +// +#define SERVO0_PIN P2_04 + +// +// Limit Switches +// +#define X_MIN_PIN P1_24 // 10k pullup to 3.3V +#define X_MAX_PIN P1_25 // 10k pullup to 3.3V +#define Y_MIN_PIN P1_26 // 10k pullup to 3.3V +#define Y_MAX_PIN P1_27 // 10k pullup to 3.3V +#define Z_MIN_PIN P1_28 // 10k pullup to 3.3V +#define Z_MAX_PIN P1_29 // 10k pullup to 3.3V + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P1_29 +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P0_04 +#define X_CS_PIN P1_10 // Ethernet Expansion - Pin 9 + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P0_11 +#define Y_ENABLE_PIN P0_10 +#define Y_CS_PIN P1_09 // Ethernet Expansion - Pin 10 + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P0_20 +#define Z_ENABLE_PIN P0_19 +#define Z_CS_PIN P1_00 // Ethernet Expansion - Pin 11 + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P0_22 +#define E0_ENABLE_PIN P0_21 +#define E0_CS_PIN P1_04 // Ethernet Expansion - Pin 12 + +#define E1_STEP_PIN P2_08 +#define E1_DIR_PIN P2_13 +#define E1_ENABLE_PIN P4_29 +#define E1_CS_PIN P1_01 // Ethernet Expansion - Pin 14 + +#define E2_STEP_PIN P1_20 +#define E2_DIR_PIN P1_19 +#define E2_ENABLE_PIN P1_21 +#define E2_CS_PIN P1_18 // FET 6 + +// +// Default pins for TMC software SPI +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P1_16 // Ethernet Expansion - Pin 5 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P1_17 // Ethernet Expansion - Pin 6 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P1_08 // Ethernet Expansion - Pin 7 + #endif +#endif + +// +// Analog Inputs +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_23_A0 +#define TEMP_BED_PIN P0_24_A1 +#define TEMP_1_PIN P0_25_A2 +#if ENABLED(FILAMENT_WIDTH_SENSOR) + #define FILWIDTH_PIN P0_26_A3 +#else + #define TEMP_2_PIN P0_26_A3 +#endif + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P2_05 +#define HEATER_0_PIN P2_07 // FET 1 +#define HEATER_1_PIN P1_23 // FET 2 +#define HEATER_2_PIN P1_22 // FET 3 +#ifndef FAN_PIN + #define FAN_PIN P2_06 // FET 4 +#endif + +// +// Auto fans +// +#if HOTENDS == 3 + #define AUTO_FAN_PIN P1_18 // FET 6 +#else + #define AUTO_FAN_PIN P1_22 // FET 3 +#endif +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN AUTO_FAN_PIN +#endif + +// +// Misc. Functions +// +#define LED_PIN P4_28 // Play LED + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + #undef HEATER_0_PIN + #undef HEATER_BED_PIN + #undef FAN_PIN + #define SPINDLE_LASER_ENA_PIN P2_07 // FET 1 + #define SPINDLE_LASER_PWM_PIN P2_05 // Bed FET + #define SPINDLE_DIR_PIN P2_06 // FET 4 +#endif + +// +// LCD / Controller +// +// LCD_PINS_D5, D6, and D7 are not present in the EXP1 connector, and will need to be +// defined to use the REPRAP_DISCOUNT_SMART_CONTROLLER. +// +// A remote SD card is currently not supported because the pins routed to the EXP2 +// connector are shared with the onboard SD card, and Marlin does not support that +// hardware configuration. +// + +#if ENABLED(FYSETC_MINI_12864) + + #define FORCE_SOFT_SPI // REQUIRED - results in LCD soft SPI mode 3 + + #define BEEPER_PIN P1_31 // EXP1-1 + #define BTN_ENC P1_30 // EXP1-2 + #define DOGLCD_CS P0_18 // EXP1-3 + #define DOGLCD_A0 P0_16 // EXP1-4 + #define LCD_RESET_PIN P0_15 // EXP1-5 + + // A custom cable is REQUIRED for EXP2 cable because the SCK & MOSI on the card's EXP2 are dedicated + // to the onboard SD card. All required EXP2 signals come from the Ethernet connector. Pin 1 of this + // connector is the one nearest the motor power connector. + #define DOGLCD_SCK P1_17 // EXP2-2 => Ethernet pin 5 (bottom, 3 from left) + #define BTN_EN2 P1_09 // EXP2-3 => Ethernet pin 9 (bottom, 5 from left) + #define BTN_EN1 P1_04 // EXP2-5 => Ethernet pin 11 (bottom, 6 from left) + #define DOGLCD_MOSI P1_01 // EXP2-6 => Ethernet pin 13 (bottom, 7 from left) + + // A custom EXP1 cable is required colored LEDs. Pins 1-5, 9, 10 of the cable go to pins 1-5, 9, 10 + // on the board's EXP1 connector. Pins 6, 7, and 8 of the EXP1 cable go to the Ethernet connector. + // Rev 1.2 displays do NOT require the RGB LEDs. 2.0 and 2.1 displays do require RGB. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN P1_16 // EXP1-6 => Ethernet pin 6 (top row, 3 from left) + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN P1_10 // EXP1-7 => Ethernet pin 10 (top row, 5 from left) + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN P1_00 // EXP1-8 => Ethernet pin 12 (top row, 6 from left) + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN P1_16 // EXP1-6 => Ethernet pin 6 (top row, 3 from left) + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN P1_31 // EXP1-1 + //#define SD_DETECT_PIN P0_27 // EXP2-7 + + #define BTN_EN1 P3_26 // EXP2-5 + #define BTN_EN2 P3_25 // EXP2-3 + #define BTN_ENC P1_30 // EXP1-2 + + #define LCD_PINS_RS P0_16 // EXP1-4 + #define LCD_SDSS P0_28 // EXP2-4 + #define LCD_PINS_ENABLE P0_18 // EXP1-3 + #define LCD_PINS_D4 P0_15 // EXP1-5 + + #define KILL_PIN P2_11 // EXP2-10 + +#endif // HAS_WIRED_LCD + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) + #define SD_SCK_PIN P0_07 // (52) system defined J3-9 & AUX-3 + #define SD_MISO_PIN P0_08 // (50) system defined J3-10 & AUX-3 + #define SD_MOSI_PIN P0_09 // (51) system defined J3-10 & AUX-3 + #if SD_CONNECTION_IS(LCD) + #define SD_SS_PIN P1_23 // (53) system defined J3-5 & AUX-3 (Sometimes called SDSS) - CS used by Marlin + #else + #undef SD_DETECT_PIN + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN + #endif +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +// +// Ethernet pins +// +//#define ENET_MDIO P1_17 // Ethernet pin 5 (bottom, 3 from left) +//#define ENET_RX_ER P1_14 +//#define ENET_RXD1 P1_10 // Ethernet pin 10 (top row, 5 from left) +//#define ENET_MOC P1_16 // Ethernet pin 6 (top row, 3 from left) +//#define REF_CLK P1_15 +//#define ENET_RXD0 P1_09 // Ethernet pin 9 (bottom, 5 from left) +//#define ENET_CRS P1_08 // Ethernet pin 8 (top row, 4 from left) - INPUT ONLY +//#define ENET_TX_EN P1_04 // Ethernet pin 11 (bottom, 6 from left) +//#define ENET_TXD0 P1_00 // Ethernet pin 12 (top row, 6 from left) +//#define ENET_TXD1 P1_01 // Ethernet pin 13 (bottom, 7 from left) + +/** + * EXP1 pins + * 1 - P1_31 + * 2 - P1_30 + * 3 - P0_18 + * 4 - P0_16 + * 5 - P0_15 + * 6 - N/C + * 7 - N/C + * 8 - P0_27 (also on EXP2-7) + * 9 - GND + * 10 - +5V + * + * + * EXP2 pins + * 1 - P0_08 + * 2 - P0_07 + * 3 - P3_26 + * 4 - P0_28 + * 5 - P3_25 + * 6 - P0_09 + * 7 - P0_27 (also on EXP1_8) + * 8 - P2_11 + * 9 - GND + * 10 - N/C + */ diff --git a/src/pins/lpc1769/pins_FLY_CDY.h b/src/pins/lpc1769/pins_FLY_CDY.h new file mode 100644 index 0000000..ec0b14a --- /dev/null +++ b/src/pins/lpc1769/pins_FLY_CDY.h @@ -0,0 +1,183 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * FLYmaker FLY-CDY pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "FLY-CDY" +#define BOARD_WEBSITE_URL "github.com/FLYmaker/FLY-CDY" + +// +// Servos +// +#define SERVO0_PIN P1_26 + +// +// Limit Switches +// + +#define X_MIN_PIN P1_29 // X- +#define X_MAX_PIN P1_28 // X+ +#define Y_MIN_PIN P1_27 // Y- +#define Y_MAX_PIN P1_25 // Y+ +#define Z_MIN_PIN P1_22 // Z- +#define Z_MAX_PIN P0_27 // Z+ + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P1_01 +#define X_ENABLE_PIN P1_00 +#ifndef X_CS_PIN + #define X_CS_PIN P1_04 +#endif + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P1_09 +#define Y_ENABLE_PIN P1_08 +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_10 +#endif + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P1_15 +#define Z_ENABLE_PIN P1_14 +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_16 +#endif + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P4_29 +#define E0_ENABLE_PIN P1_17 +#ifndef E0_CS_PIN + #define E0_CS_PIN P4_28 +#endif + +#define E1_STEP_PIN P2_04 +#define E1_DIR_PIN P2_11 +#define E1_ENABLE_PIN P0_04 +#ifndef E1_CS_PIN + #define E1_CS_PIN P2_12 +#endif + +#define E2_STEP_PIN P2_05 +#define E2_DIR_PIN P0_11 +#define E2_ENABLE_PIN P2_13 +#ifndef E2_CS_PIN + #define E2_CS_PIN P0_10 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P0_20 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P0_19 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P0_21 + #endif +#endif + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN P1_04 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN P1_10 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN P1_16 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN P4_28 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN P2_12 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN P0_10 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN P0_26_A3 // (T4) +#define TEMP_1_PIN P0_25_A2 // (T3) +#define TEMP_2_PIN P0_24_A1 // (T2) +#define TEMP_BED_PIN P0_23_A0 // (T1) + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P3_26 +#define HEATER_0_PIN P3_25 +#define HEATER_1_PIN P1_20 +#define HEATER_2_PIN P1_23 +#ifndef FAN_PIN + #define FAN_PIN P1_18 +#endif +#define FAN1_PIN P1_21 +#define FAN2_PIN P1_24 + +// +// LCD / Controller +// +#define BEEPER_PIN P2_07 +#define LCD_PINS_RS P2_10 +#define LCD_PINS_ENABLE P0_22 +#define LCD_PINS_D4 P1_19 +#define LCD_PINS_D5 P2_08 +#define LCD_PINS_D6 P1_30 +#define LCD_PINS_D7 P1_31 +#define BTN_EN1 P0_00 +#define BTN_EN2 P0_01 +#define BTN_ENC P0_28 + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_SS_PIN P0_06 + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define SD_DETECT_PIN P0_05 +#elif SD_CONNECTION_IS(LCD) + #define SD_SCK_PIN P0_15 + #define SD_MISO_PIN P0_17 + #define SD_MOSI_PIN P0_18 + #define SD_SS_PIN P0_16 + #define SD_DETECT_PIN P2_06 +#endif diff --git a/src/pins/lpc1769/pins_MKS_SGEN.h b/src/pins/lpc1769/pins_MKS_SGEN.h new file mode 100644 index 0000000..23bcecc --- /dev/null +++ b/src/pins/lpc1769/pins_MKS_SGEN.h @@ -0,0 +1,58 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS SGen pin assignments + * + * Pins diagram: + * https://github.com/makerbase-mks/MKS-SGen/blob/master/Hardware/MKS%20SGEN%20V1.0_001/MKS%20SGEN%20V1.0_001%20PIN.pdf + */ + +#define BOARD_INFO_NAME "MKS SGen" +#define BOARD_WEBSITE_URL "github.com/makerbase-mks/MKS-SGEN" + +#define REQUIRE_LPC1769 +#include "../lpc1768/pins_MKS_SBASE.h" + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + */ + #define X_SERIAL_TX_PIN P1_22 // J8-2 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN P1_23 // J8-3 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN P2_12 // J8-4 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN P2_11 // J8-5 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN P4_28 // J8-6 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif diff --git a/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h new file mode 100644 index 0000000..2f25d8b --- /dev/null +++ b/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -0,0 +1,453 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS SGen-L V2 pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "MKS SGEN_L V2" +#define BOARD_WEBSITE_URL "github.com/makerbase-mks" + +#define USES_DIAG_JUMPERS + +// +// EEPROM, MKS SGEN_L V2.0 hardware has 4K EEPROM on the board +// +#if NO_EEPROM_SELECTED + #define I2C_EEPROM // AT24C32 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Servos +// +#define SERVO0_PIN P1_23 // SERVO P1.23 +#define SERVO1_PIN P2_00 // SERVO P2.0 + +// +// Trinamic Stallguard pins, can connect or disconnect by jumpers cap on the board +// +#define X_DIAG_PIN P1_29 // X- +#define Y_DIAG_PIN P1_27 // Y- +#define Z_DIAG_PIN P1_25 // Z- +#define E0_DIAG_PIN P1_28 // X+ +#define E1_DIAG_PIN P1_26 // Y+ + +// +// Limit Switches +// +#if X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN P1_28 // X+ + #else + #define X_MIN_PIN P1_28 // X+ + #endif +#else + #define X_MIN_PIN P1_29 // X- + #define X_MAX_PIN P1_28 // X+ +#endif + +#if Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN P1_26 // Y+ + #else + #define Y_MIN_PIN P1_26 // Y+ + #endif +#else + #define Y_MIN_PIN P1_27 // Y- + #define Y_MAX_PIN P1_26 // Y+ +#endif + +#if Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN P1_24 // Z+ + #else + #define Z_MIN_PIN P1_24 // Z+ + #endif +#else + #define Z_MIN_PIN P1_25 // Z- + #define Z_MAX_PIN P1_24 // Z+ +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P1_24 +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN P1_28 // X+ +#define FIL_RUNOUT2_PIN P1_26 // Y+ + +// +// Steppers +// +#define X_STEP_PIN P2_02 +#define X_DIR_PIN P2_03 +#define X_ENABLE_PIN P2_01 +#ifndef X_CS_PIN + #define X_CS_PIN P1_01 +#endif + +#define Y_STEP_PIN P0_19 +#define Y_DIR_PIN P0_20 +#define Y_ENABLE_PIN P2_08 +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_08 +#endif + +#define Z_STEP_PIN P0_22 +#define Z_DIR_PIN P2_11 +#define Z_ENABLE_PIN P0_21 +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_10 +#endif + +#define E0_STEP_PIN P2_13 +#define E0_DIR_PIN P0_11 +#define E0_ENABLE_PIN P2_12 +#ifndef E0_CS_PIN + #define E0_CS_PIN P1_15 +#endif + +#define E1_STEP_PIN P1_09 +#define E1_DIR_PIN P1_14 +#define E1_ENABLE_PIN P0_10 +#ifndef E1_CS_PIN + #define E1_CS_PIN P1_17 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI P1_16 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO P0_05 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK P0_04 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN P1_01 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN P1_08 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN P1_10 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN P1_15 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN P1_17 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif // HAS_TMC_UART + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_23_A0 // Analog Input A0 (TH1) +#define TEMP_BED_PIN P0_24_A1 // Analog Input A1 (TB) +#define TEMP_1_PIN P0_25_A2 // Analog Input A2 (TH2) +#define TEMP_2_PIN P0_26_A3 // Analog Input A3 (P0.26, No pull up) + +#if HOTENDS == 1 && !REDUNDANT_TEMP_MATCH(SOURCE, E1) + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif +#endif + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P2_05 +#define HEATER_0_PIN P2_07 +#if HAS_MULTI_HOTEND + #ifndef HEATER_1_PIN + #define HEATER_1_PIN P2_06 + #endif +#else + #ifndef FAN2_PIN + #define FAN2_PIN P2_06 // HE1 for FAN3 + #endif +#endif +#ifndef FAN_PIN + #define FAN_PIN P2_04 // FAN1 +#endif +#ifndef FAN1_PIN + #define FAN1_PIN P1_04 // FAN2 +#endif + +// +// Misc. Functions +// +#define LED_PIN P1_18 // Used as a status indicator + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #define PS_ON_PIN P2_00 // SERVO1 + #define KILL_PIN P1_24 // Z+ + #define KILL_PIN_STATE HIGH +#endif + +// +// RGB LED +// +#if ENABLED(RGB_LED) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN P1_19 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN P1_20 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN P1_21 + #endif +#else + #define LED2_PIN P1_19 // Initialized by HAL/LPC1768/main.cpp + #define LED3_PIN P1_20 + #define LED4_PIN P1_21 +#endif + +/** ------ ------ + * (BEEPER) 1.31 | 1 2 | 1.30 (BTN_ENC) (MISO) 0.8 | 1 2 | 0.7 (SD_SCK) + * (LCD_EN) 0.18 | 3 4 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 3 4 | 0.28 (SD_CS2) + * (LCD_D4) 0.15 5 6 | 0.17 (LCD_D5) (BTN_EN2) 3.26 5 6 | 0.9 (SD_MOSI) + * (LCD_D6) 1.0 | 7 8 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 7 8 | RST + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN P1_31 +#define EXP1_02_PIN P1_30 +#define EXP1_03_PIN P0_18 +#define EXP1_04_PIN P0_16 +#define EXP1_05_PIN P0_15 +#define EXP1_06_PIN P0_17 +#define EXP1_07_PIN P1_00 +#define EXP1_08_PIN P1_22 + +#define EXP2_01_PIN P0_08 +#define EXP2_02_PIN P0_07 +#define EXP2_03_PIN P3_25 +#define EXP2_04_PIN P0_28 +#define EXP2_05_PIN P3_26 +#define EXP2_06_PIN P0_09 +#define EXP2_07_PIN P0_27 +#define EXP2_08_PIN -1 // RESET + +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + + #define SD_DETECT_PIN EXP2_07_PIN + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #else + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_SDSS EXP2_04_PIN + + #if ENABLED(MKS_12864OLED_SSD1306) + + #define LCD_PINS_DC EXP1_06_PIN + #define DOGLCD_CS EXP1_04_PIN + #define DOGLCD_A0 LCD_PINS_DC + #define DOGLCD_SCK EXP1_05_PIN + #define DOGLCD_MOSI EXP1_03_PIN + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define KILL_PIN -1 // NC + + #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI + + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_A0_PIN TFT_DC_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_RESET_PIN EXP1_04_PIN + + #define LCD_USE_DMA_SPI + + #define TOUCH_INT_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_05_PIN + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 + + // Disable any LCD related PINs config + #define LCD_PINS_ENABLE -1 + #define LCD_PINS_RS -1 + + #ifndef TFT_BUFFER_SIZE + #define TFT_BUFFER_SIZE 1200 + #endif + #ifndef TFT_QUEUE_SIZE + #define TFT_QUEUE_SIZE 6144 + #endif + + #else // !MKS_12864OLED_SSD1306 + + #define LCD_PINS_RS EXP1_04_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + #define LCD_BACKLIGHT_PIN -1 + + #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + + #else // !FYSETC_MINI_12864 + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #endif + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif // !FYSETC_MINI_12864 + + #endif // !MKS_12864OLED_SSD1306 + + #endif // !CR10_STOCKDISPLAY + +#endif // HAS_WIRED_LCD + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #if SD_CONNECTION_IS(ONBOARD) + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN + #else + #define SD_SS_PIN EXP2_04_PIN + #endif +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +// +// Other Pins +// +//#define PIN_P0_02 P0_02 // AUX1 (Interrupt Capable/ADC/Serial Port 0) +//#define PIN_P0_03 P0_03 // AUX1 (Interrupt Capable/ADC/Serial Port 0) +//#define PS_ON_PIN P1_23 // SERVO0 P1.23 diff --git a/src/pins/lpc1769/pins_SMOOTHIEBOARD.h b/src/pins/lpc1769/pins_SMOOTHIEBOARD.h new file mode 100644 index 0000000..cfaca16 --- /dev/null +++ b/src/pins/lpc1769/pins_SMOOTHIEBOARD.h @@ -0,0 +1,179 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Smoothieware Smoothieboard pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Smoothieboard" +#define BOARD_WEBSITE_URL "smoothieware.org/smoothieboard" + +// +// Servos +// +#define SERVO0_PIN P1_23 + +// +// Limit Switches +// +#define X_MIN_PIN P1_24 +#define X_MAX_PIN P1_25 +#define Y_MIN_PIN P1_26 +#define Y_MAX_PIN P1_27 +#define Z_MIN_PIN P1_28 +#define Z_MAX_PIN P1_29 + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P0_05 +#define X_ENABLE_PIN P0_04 + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P0_11 +#define Y_ENABLE_PIN P0_10 + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P0_20 +#define Z_ENABLE_PIN P0_19 + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P0_22 +#define E0_ENABLE_PIN P0_21 + +#define E1_STEP_PIN P2_08 +#define E1_DIR_PIN P2_13 +#define E1_ENABLE_PIN P4_29 + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_23_A0 // (T1) +#define TEMP_BED_PIN P0_24_A1 // (T2) +#define TEMP_1_PIN P0_25_A2 // (T3) +#define TEMP_2_PIN P0_26_A3 // (T4) + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P2_05 +#define HEATER_0_PIN P2_07 +#define HEATER_1_PIN P1_23 +#ifndef FAN_PIN + #define FAN_PIN P2_06 +#endif +#define FAN1_PIN P2_04 + +// +// LCD / Controller +// +#if EITHER(VIKI2, miniVIKI) + + #define BEEPER_PIN P1_31 + #define DOGLCD_A0 P2_11 + #define DOGLCD_CS P0_16 + + #define BTN_EN1 P3_25 + #define BTN_EN2 P3_26 + #define BTN_ENC P1_30 + + #define SD_DETECT_PIN P1_18 + #define SDSS P1_21 + + #define STAT_LED_RED_PIN P1_19 + #define STAT_LED_BLUE_PIN P1_20 + +#elif HAS_WIRED_LCD + + /** + * SD Support + * + * For the RRD GLCD it CANNOT share the same SPI as the LCD so it must be + * hooked up to the onboard SDCard SPI and use a spare pin for the SDCS. + * Also note that an external SDCard sharing the SPI port with the + * onboard/internal SDCard must be ejected before rebooting as the bootloader + * does not like the external card. NOTE Smoothie will not boot if the external + * sdcard is inserted in the RRD LCD sdcard slot at boot time, it must be + * inserted after it has booted. + */ + #define SD_DETECT_PIN P0_27 // EXP2 Pin 7 (SD_CD, SD_DET) + + #define SD_MISO_PIN P0_08 // EXP2 Pin 1 (PB3, SD_MISO) + #define SD_SCK_PIN P0_07 // EXP2 Pin 2 (SD_SCK) + #define SD_SS_PIN P0_28 // EXP2 Pin 4 (SD_CSEL, SD_CS) + #define SD_MOSI_PIN P0_09 // EXP2 Pin 6 (PB2, SD_MOSI) + + /** + * The Smoothieboard supports the REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER with either + * a custom cable with breakouts to the pins indicated below or the RRD GLCD Adapter board + * found at http://smoothieware.org/rrdglcdadapter + * + * Other links to information about setting up a display panel with Smoothieboard + * http://chibidibidiwah.wdfiles.com/local--files/panel/smoothieboard2sd.jpg + * http://smoothieware.org/panel + */ + #if IS_RRD_FG_SC + // EXP1 Pins + #define BEEPER_PIN P1_31 // EXP1 Pin 1 + #define BTN_ENC P1_30 // EXP1 Pin 2 + #define LCD_PINS_ENABLE P0_18 // EXP1 Pin 3 (MOSI) + #define LCD_PINS_RS P0_16 // EXP1 Pin 4 (CS) + #define LCD_PINS_D4 P0_15 // EXP1 Pin 5 (SCK) + // EXP2 Pins + #define BTN_EN2 P3_26 // EXP2 Pin 3 + #define BTN_EN1 P3_25 // EXP2 Pin 5 + + #elif IS_TFTGLCD_PANEL + + #define SD_DETECT_PIN P0_27 // EXP2 Pin 7 (SD_CD, SD_DET) + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS P3_26 // EXP2 Pin 3 + #endif + + #else + #error "Marlin's Smoothieboard support cannot drive your LCD." + #endif + +#endif + +/** + * I2C Digipots - MCP4451 + * Address 58 (2C << 1) + * Set from 0 - 127 with stop bit. + * (Ex. 3F << 1 | 1) + */ +#define DIGIPOTS_I2C_SCL P0_00 +#define DIGIPOTS_I2C_SDA_X P0_04 +#define DIGIPOTS_I2C_SDA_Y P0_10 +#define DIGIPOTS_I2C_SDA_Z P0_19 +#define DIGIPOTS_I2C_SDA_E0 P0_21 +#define DIGIPOTS_I2C_SDA_E1 P4_29 + +#ifndef DIGIPOT_I2C_ADDRESS_A + #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address (58 <- 2C << 1) +#endif diff --git a/src/pins/lpc1769/pins_TH3D_EZBOARD.h b/src/pins/lpc1769/pins_TH3D_EZBOARD.h new file mode 100644 index 0000000..f794e17 --- /dev/null +++ b/src/pins/lpc1769/pins_TH3D_EZBOARD.h @@ -0,0 +1,227 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * TH3D EZBoard pin assignments + */ + +#include "env_validate.h" + +//#define V3_EZABL_ON_SERVO // As in TH3D Firmware Config + +#define BOARD_INFO_NAME "TH3D EZBoard" +#define BOARD_WEBSITE_URL "th3dstudio.com" + +// +// Servos +// +#if ENABLED(V3_EZABL_ON_SERVO) + #define SERVO0_PIN -1 +#else + #define SERVO0_PIN P2_04 +#endif + +// +// Limit Switches +// +#define X_STOP_PIN P1_24 +#define Y_STOP_PIN P1_25 +#if ENABLED(V3_EZABL_ON_SERVO) + #define Z_STOP_PIN P2_04 +#else + #define Z_STOP_PIN P1_26 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN P1_27 +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_00 +#define X_DIR_PIN P1_16 +#define X_ENABLE_PIN P1_17 + +#define Y_STEP_PIN P2_01 +#define Y_DIR_PIN P1_10 +#define Y_ENABLE_PIN P1_09 + +#define Z_STEP_PIN P2_02 +#define Z_DIR_PIN P1_15 +#define Z_ENABLE_PIN P1_14 + +#define E0_STEP_PIN P2_03 +#define E0_DIR_PIN P1_04 +#define E0_ENABLE_PIN P1_08 + +#define E1_STEP_PIN P2_08 +#define E1_DIR_PIN P2_13 +#define E1_ENABLE_PIN P4_29 + +#if HAS_TMC_UART + // + // TMC220x stepper drivers + // + #define X_SERIAL_TX_PIN P0_04 + #define X_SERIAL_RX_PIN P0_05 + + #define Y_SERIAL_TX_PIN P0_10 + #define Y_SERIAL_RX_PIN P0_11 + + #define Z_SERIAL_TX_PIN P0_19 + #define Z_SERIAL_RX_PIN P0_20 + + #define E0_SERIAL_TX_PIN P0_22 + #define E0_SERIAL_RX_PIN P0_21 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temp Sensors +// 3.3V max when defined as an Analog Input! +// +#if TEMP_SENSOR_0 == 20 // PT100 Adapter + #define TEMP_0_PIN P0_02_A7 // Analog Input +#else + #define TEMP_0_PIN P0_23_A0 // Analog Input P0_23 +#endif + +#define TEMP_BED_PIN P0_24_A1 // Analog Input P0_24 + +// +// Heaters / Fans +// +#define HEATER_BED_PIN P2_05 +#define HEATER_0_PIN P2_07 +#ifndef FAN_PIN + #define FAN_PIN P2_06 +#endif +#define FAN1_PIN P1_22 + +// +// Auto fans +// +#define AUTO_FAN_PIN P1_22 // FET 3 +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN AUTO_FAN_PIN +#endif + +// +// SD Card +// + +#define SDCARD_CONNECTION ONBOARD + +//#define SD_DETECT_PIN P0_25 // SD_CD +#define SD_SCK_PIN P0_07 +#define SD_MISO_PIN P0_08 +#define SD_MOSI_PIN P0_09 +#define ONBOARD_SD_CS_PIN P0_06 +#define SD_SS_PIN ONBOARD_SD_CS_PIN + +// +// LCD / Controller +// + +/** + * ------ + * P1_31 | 1 2 | P1_30 + * P3_26 | 3 4 | P2_11 + * P3_25 5 6 | P0_15 + * P0_16 | 7 8 | P0_18 + * GND | 9 10 | 5V + * ------ + * EXP1 + * + * LCD_PINS_D5, D6, and D7 are not present in the EXP1 connector, and will need to be + * defined to use the REPRAP_DISCOUNT_SMART_CONTROLLER. + * + * A remote SD card is currently not supported because the pins routed to the EXP2 + * connector are shared with the onboard SD card. + */ +#define EXP1_01_PIN P1_31 +#define EXP1_02_PIN P1_30 +#define EXP1_03_PIN P3_26 +#define EXP1_04_PIN P2_11 +#define EXP1_05_PIN P3_25 +#define EXP1_06_PIN P0_15 +#define EXP1_07_PIN P0_16 +#define EXP1_08_PIN P0_18 + +#if ENABLED(CR10_STOCKDISPLAY) + /** ------ + * BEEPER | 1 2 | ENC + * EN1 | 3 4 | KILL + * EN2 5 6 | LCD_D4 + * LCD_RS | 7 8 | LCD_EN + * GND | 9 10 | 5V + * ------ + */ + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define KILL_PIN EXP1_04_PIN + +#elif ENABLED(MKS_MINI_12864) + /** ------ + * SCK | 1 2 | ENC + * EN1 | 3 4 | -- + * EN2 5 6 | A0 + * CS | 7 8 | MOSI + * GND | 9 10 | 5V + * ------ + */ + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN + #define LCD_CONTRAST_INIT 160 + #define LCD_CONTRAST_MIN 120 + #define LCD_CONTRAST_MAX 180 + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + +#elif HAS_WIRED_LCD + + #error "Only CR10_STOCKDISPLAY or MKS_MINI_12864 are supported with TH3D EZBoard." + +#endif + +#if EITHER(CR10_STOCKDISPLAY, MKS_MINI_12864) + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN +#endif diff --git a/src/pins/mega/env_validate.h b/src/pins/mega/env_validate.h new file mode 100644 index 0000000..97c52d4 --- /dev/null +++ b/src/pins/mega/env_validate.h @@ -0,0 +1,32 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(__AVR_ATmega2560__) + #if DISABLED(ALLOW_MEGA1280) + #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" + #elif NOT_TARGET(__AVR_ATmega1280__) + #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560 or 1280' in 'Tools > Board.'" + #endif +#endif + +#undef ALLOW_MEGA1280 diff --git a/src/pins/mega/pins_CHEAPTRONIC.h b/src/pins/mega/pins_CHEAPTRONIC.h new file mode 100644 index 0000000..8bcb263 --- /dev/null +++ b/src/pins/mega/pins_CHEAPTRONIC.h @@ -0,0 +1,78 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Cheaptronic v1.0 pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Cheaptronic v1.0" +// +// Limit Switches +// +#define X_STOP_PIN 3 +#define Y_STOP_PIN 2 +#define Z_STOP_PIN 5 + +// +// Steppers +// +#define X_STEP_PIN 14 +#define X_DIR_PIN 15 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 35 +#define Y_DIR_PIN 36 +#define Y_ENABLE_PIN 31 + +#define Z_STEP_PIN 40 +#define Z_DIR_PIN 41 +#define Z_ENABLE_PIN 37 + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 25 + +#define E1_STEP_PIN 33 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 + +// +// Temperature sensors +// +#define TEMP_0_PIN 15 // Analog Input +#define TEMP_1_PIN 14 // Analog Input +#define TEMP_BED_PIN 13 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 19 // EXTRUDER 1 +#define HEATER_1_PIN 23 // EXTRUDER 2 +#define HEATER_BED_PIN 22 + +// +// LCD / Controller +// +// Cheaptronic v1.0 doesn't support LCD diff --git a/src/pins/mega/pins_CHEAPTRONICv2.h b/src/pins/mega/pins_CHEAPTRONICv2.h new file mode 100644 index 0000000..0143897 --- /dev/null +++ b/src/pins/mega/pins_CHEAPTRONICv2.h @@ -0,0 +1,138 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Cheaptronic v2.0 pin assignments + * Built and sold by Michal Dyntar - RRO + * www.reprapobchod.cz + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Cheaptronic v2.0" + +// +// Limit Switches +// +#define X_MIN_PIN 30 +#define X_MAX_PIN 31 +#define Y_MIN_PIN 32 +#define Y_MAX_PIN 33 +#define Z_MIN_PIN 34 +#define Z_MAX_PIN 35 + +// +// Steppers +// +#define X_STEP_PIN 17 +#define X_DIR_PIN 16 +#define X_ENABLE_PIN 48 + +#define Y_STEP_PIN 54 +#define Y_DIR_PIN 47 +#define Y_ENABLE_PIN 55 + +#define Z_STEP_PIN 57 +#define Z_DIR_PIN 56 +#define Z_ENABLE_PIN 62 + +#define E0_STEP_PIN 23 +#define E0_DIR_PIN 22 +#define E0_ENABLE_PIN 24 + +#define E1_STEP_PIN 26 +#define E1_DIR_PIN 25 +#define E1_ENABLE_PIN 27 + +#define E2_STEP_PIN 29 +#define E2_DIR_PIN 28 +#define E2_ENABLE_PIN 39 + +// +// Temperature sensors +// +#define TEMP_0_PIN 15 +#define TEMP_1_PIN 13 +#define TEMP_2_PIN 14 +#define TEMP_3_PIN 11 // should be used for chamber temperature control +#define TEMP_BED_PIN 12 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 +#define HEATER_1_PIN 7 +#define HEATER_2_PIN 8 +#define HEATER_BED_PIN 9 +#ifndef FAN_PIN + #define FAN_PIN 3 +#endif +#define FAN2_PIN 58 // additional fan or light control output + +// +// Other board specific pins +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 37 // board input labeled as F-DET +#endif +#define Z_MIN_PROBE_PIN 36 // additional external board input labeled as E-SENS (should be used for Z-probe) +#define LED_PIN 13 +#define SPINDLE_ENABLE_PIN 4 // additional PWM pin 1 at JP1 connector - should be used for laser control too +#define EXT_2 5 // additional PWM pin 2 at JP1 connector +#define EXT_3 2 // additional PWM pin 3 at JP1 connector +#define PS_ON_PIN 45 +#define KILL_PIN 46 + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 11 // shared with TEMP_3 analog input +#endif + +// +// LCD / Controller +// +#define LCD_PINS_RS 19 +#define LCD_PINS_ENABLE 42 +#define LCD_PINS_D4 18 +#define LCD_PINS_D5 38 +#define LCD_PINS_D6 41 +#define LCD_PINS_D7 40 + +#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder +#endif + +// +// Beeper, SD Card, Encoder +// +#define BEEPER_PIN 44 + +#if ENABLED(SDSUPPORT) + #define SDSS 53 + #define SD_DETECT_PIN 49 +#endif + +#if IS_NEWPANEL + #define BTN_EN1 11 + #define BTN_EN2 12 + #define BTN_ENC 43 +#endif diff --git a/src/pins/mega/pins_CNCONTROLS_11.h b/src/pins/mega/pins_CNCONTROLS_11.h new file mode 100644 index 0000000..5f7a534 --- /dev/null +++ b/src/pins/mega/pins_CNCONTROLS_11.h @@ -0,0 +1,162 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * CartesioV11 pin assignments + */ + +#define ALLOW_MEGA1280 +#include "env_validate.h" + +#define BOARD_INFO_NAME "CN Controls V11" + +// +// Limit Switches +// +#define X_STOP_PIN 43 +#define Y_STOP_PIN 45 +#define Z_STOP_PIN 42 + +// +// Steppers +// +#define X_STEP_PIN 34 +#define X_DIR_PIN 36 +#define X_ENABLE_PIN 35 + +#define Y_STEP_PIN 37 +#define Y_DIR_PIN 39 +#define Y_ENABLE_PIN 38 + +#define Z_STEP_PIN 40 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 41 + +#define E0_STEP_PIN 29 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 3 + +#define E1_STEP_PIN 61 +#define E1_DIR_PIN 62 +#define E1_ENABLE_PIN 60 + +#define E2_STEP_PIN 15 +#define E2_DIR_PIN 14 +#define E2_ENABLE_PIN 16 + +#define E3_STEP_PIN 44 +#define E3_DIR_PIN 49 +#define E3_ENABLE_PIN 47 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 3 // Analog Input. 3 for tool2 -> 2 for chambertemp +#define TEMP_2_PIN 2 // Analog Input. 9 for tool3 -> 2 for chambertemp +#define TEMP_3_PIN 11 // Analog Input. 11 for tool4 -> 2 for chambertemp +#define TEMP_BED_PIN 1 // Analog Input + +#ifndef TEMP_CHAMBER_PIN + //#define TEMP_CHAMBER_PIN 2 // Analog Input +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 5 +#define HEATER_1_PIN 58 +#define HEATER_2_PIN 64 +#define HEATER_3_PIN 46 +#define HEATER_BED_PIN 2 + +#ifndef FAN_PIN + //#define FAN_PIN 7 // common PWM pin for all tools +#endif + +// +// Auto fans +// +#define AUTO_FAN_PIN 7 +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E3_AUTO_FAN_PIN + #define E3_AUTO_FAN_PIN AUTO_FAN_PIN +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define SD_DETECT_PIN 13 + +// Tools + +//#define TOOL_0_PIN 4 +//#define TOOL_1_PIN 59 +//#define TOOL_2_PIN 8 +//#define TOOL_3_PIN 30 +//#define TOOL_PWM_PIN 7 // common PWM pin for all tools + +// Common I/O + +//#define FIL_RUNOUT_PIN -1 +//#define PWM_1_PIN 11 +//#define PWM_2_PIN 10 +//#define SPARE_IO 12 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BEEPER_PIN 6 + + #define BTN_EN1 23 + #define BTN_EN2 25 + #define BTN_ENC 27 + + #if HAS_MARLINUI_U8GLIB + #define DOGLCD_A0 26 + #define DOGLCD_CS 24 + #define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h + #define DOGLCD_SCK -1 + #endif +#endif + +// Hardware buttons for manual movement of XYZ +#define SHIFT_OUT_PIN 19 +#define SHIFT_LD_PIN 18 +#define SHIFT_CLK_PIN 17 + +//#define UI1 31 +//#define UI2 22 + +#define STAT_LED_BLUE_PIN -1 +#define STAT_LED_RED_PIN 31 diff --git a/src/pins/mega/pins_CNCONTROLS_12.h b/src/pins/mega/pins_CNCONTROLS_12.h new file mode 100644 index 0000000..0aa0b59 --- /dev/null +++ b/src/pins/mega/pins_CNCONTROLS_12.h @@ -0,0 +1,169 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * CartesioV12 pin assignments + */ + +#define ALLOW_MEGA1280 +#include "env_validate.h" + +#define BOARD_INFO_NAME "CN Controls V12" + +// +// Limit Switches +// +#define X_STOP_PIN 19 +#define Y_STOP_PIN 22 +#define Z_STOP_PIN 23 + +// +// Steppers +// +#define X_STEP_PIN 25 +#define X_DIR_PIN 27 +#define X_ENABLE_PIN 26 + +#define Y_STEP_PIN 28 +#define Y_DIR_PIN 30 +#define Y_ENABLE_PIN 29 + +#define Z_STEP_PIN 31 +#define Z_DIR_PIN 33 +#define Z_ENABLE_PIN 32 + +#define E0_STEP_PIN 57 +#define E0_DIR_PIN 55 +#define E0_ENABLE_PIN 58 + +#define E1_STEP_PIN 61 +#define E1_DIR_PIN 62 +#define E1_ENABLE_PIN 60 + +#define E2_STEP_PIN 46 +#define E2_DIR_PIN 66 +#define E2_ENABLE_PIN 44 + +#define E3_STEP_PIN 45 +#define E3_DIR_PIN 69 +#define E3_ENABLE_PIN 47 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 9 // Analog Input. 9 for tool2 -> 13 for chambertemp +#define TEMP_2_PIN 13 // Analog Input. 10 for tool3 -> 13 for chambertemp +#define TEMP_3_PIN 11 // Analog Input. 11 for tool4 -> 13 for chambertemp +#define TEMP_BED_PIN 14 // Analog Input + +#ifndef TEMP_CHAMBER_PIN + //#define TEMP_CHAMBER_PIN 13 // Analog Input +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 11 +#define HEATER_1_PIN 9 +#define HEATER_2_PIN 6 +#define HEATER_3_PIN 3 +#define HEATER_BED_PIN 24 + +#ifndef FAN_PIN + #define FAN_PIN 5 // 5 is PWMtool3 -> 7 is common PWM pin for all tools +#endif + +// +// Auto fans +// +#define AUTO_FAN_PIN 7 +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E3_AUTO_FAN_PIN + #define E3_AUTO_FAN_PIN AUTO_FAN_PIN +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define SD_DETECT_PIN 15 + +// Tools + +//#define TOOL_0_PIN 56 +//#define TOOL_0_PWM_PIN 10 // red warning led at dual extruder +//#define TOOL_1_PIN 59 +//#define TOOL_1_PWM_PIN 8 // lights at dual extruder +//#define TOOL_2_PIN 4 +//#define TOOL_2_PWM_PIN 5 +//#define TOOL_3_PIN 14 +//#define TOOL_3_PWM_PIN 2 + +// Common I/O + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 18 +#endif +//#define PWM_1_PIN 12 +//#define PWM_2_PIN 13 +//#define SPARE_IO 17 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BEEPER_PIN 16 + + #define BTN_EN1 36 + #define BTN_EN2 34 + #define BTN_ENC 38 + + #if HAS_MARLINUI_U8GLIB + #define DOGLCD_A0 39 + #define DOGLCD_CS 35 + #define DOGLCD_MOSI 48 + #define DOGLCD_SCK 49 + #endif +#endif + +// Hardware buttons for manual movement of XYZ +#define SHIFT_OUT_PIN 42 +#define SHIFT_LD_PIN 41 +#define SHIFT_CLK_PIN 40 + +//#define UI1 43 +//#define UI2 37 + +#define STAT_LED_BLUE_PIN -1 +#define STAT_LED_RED_PIN 10 // TOOL_0_PWM_PIN + +#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 diff --git a/src/pins/mega/pins_CNCONTROLS_15.h b/src/pins/mega/pins_CNCONTROLS_15.h new file mode 100644 index 0000000..6de3b71 --- /dev/null +++ b/src/pins/mega/pins_CNCONTROLS_15.h @@ -0,0 +1,126 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * CNControls V15 for HMS434 pin assignments + */ + +#define ALLOW_MEGA1280 +#include "env_validate.h" + +#define BOARD_INFO_NAME "CN Controls V15" + +// +// Servos +// +#define SERVO0_PIN 6 + +// +// Limit Switches +// +#define X_STOP_PIN 34 +#define Y_STOP_PIN 39 +#define Z_STOP_PIN 62 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 49 +#endif + +// +// Steppers +// +#define X_STEP_PIN 14 +#define X_DIR_PIN 25 +#define X_ENABLE_PIN 26 + +#define Y_STEP_PIN 11 +#define Y_DIR_PIN 12 +#define Y_ENABLE_PIN 15 + +#define Z_STEP_PIN 24 +#define Z_DIR_PIN 27 +#define Z_ENABLE_PIN 28 + +#define E0_STEP_PIN 64 +#define E0_DIR_PIN 65 +#define E0_ENABLE_PIN 63 + +// +// Temperature Sensors +// Analog Inputs +// +#define TEMP_0_PIN 2 // Analog Input +#define TEMP_BED_PIN 4 // Analog Input + +#ifndef TEMP_CHAMBER_PIN + #define TEMP_CHAMBER_PIN 5 // Analog Input +#endif + +// +// Heaters +// +#define HEATER_0_PIN 4 +#define HEATER_BED_PIN 32 +#define HEATER_CHAMBER_PIN 33 + +// +// Fans +// +#define FAN_PIN 8 + +// +// Auto fans +// +#define AUTO_FAN_PIN 30 +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E3_AUTO_FAN_PIN + #define E3_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef CHAMBER_AUTO_FAN_PIN + //#define CHAMBER_AUTO_FAN_PIN 10 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define SD_DETECT_PIN 40 + +// Common I/O + +#define FIL_RUNOUT_PIN 9 +//#define FIL_RUNOUT_PIN 29 // encoder sensor +//#define PWM_1_PIN 12 +//#define PWM_2_PIN 13 +//#define SPARE_IO 17 +#define BEEPER_PIN 13 +#define STAT_LED_BLUE_PIN -1 +#define STAT_LED_RED_PIN 10 // 31 diff --git a/src/pins/mega/pins_EINSTART-S.h b/src/pins/mega/pins_EINSTART-S.h new file mode 100644 index 0000000..d42efe7 --- /dev/null +++ b/src/pins/mega/pins_EINSTART-S.h @@ -0,0 +1,112 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Einstart-S pin assignments + * PCB Silkscreen: 3DPrinterCon_v3.5 + */ + +#define ALLOW_MEGA1280 +#include "env_validate.h" + +#define BOARD_INFO_NAME "Einstart-S" + +// +// Limit Switches +// +#define X_STOP_PIN 44 +#define Y_STOP_PIN 43 +#define Z_STOP_PIN 42 + +// +// Steppers +// +#define X_STEP_PIN 76 +#define X_DIR_PIN 75 +#define X_ENABLE_PIN 73 + +#define Y_STEP_PIN 31 +#define Y_DIR_PIN 32 +#define Y_ENABLE_PIN 72 + +#define Z_STEP_PIN 34 +#define Z_DIR_PIN 35 +#define Z_ENABLE_PIN 33 + +#define E0_STEP_PIN 36 +#define E0_DIR_PIN 37 +#define E0_ENABLE_PIN 30 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_BED_PIN 1 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 83 +#define HEATER_BED_PIN 38 + +#define FAN_PIN 82 + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 4 + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +// +// LCD Display output pins +// + +// Requires #define U8GLIB_SH1106_EINSTART in Configuration.h +// u8glib constructor +// U8GLIB_SH1106_128X64 u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, LCD_PINS_DC, LCD_PINS_RS); + +#define LCD_PINS_DC 78 +#define LCD_PINS_RS 79 +// DOGM SPI LCD Support +#define DOGLCD_CS 3 +#define DOGLCD_MOSI 2 +#define DOGLCD_SCK 5 +#define DOGLCD_A0 2 + +// +// LCD Display input pins +// +#define BTN_UP 25 +#define BTN_DWN 26 +#define BTN_LFT 27 +#define BTN_RT 28 + +// 'OK' button +#define BTN_ENC 29 + +// Set Kill to right arrow, same as RIGID_PANEL +#define KILL_PIN 28 diff --git a/src/pins/mega/pins_ELEFU_3.h b/src/pins/mega/pins_ELEFU_3.h new file mode 100644 index 0000000..f5e146c --- /dev/null +++ b/src/pins/mega/pins_ELEFU_3.h @@ -0,0 +1,150 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Elefu RA Board Pin Assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Elefu Ra v3" + +// +// Limit Switches +// +#define X_MIN_PIN 35 +#define X_MAX_PIN 34 +#define Y_MIN_PIN 33 +#define Y_MAX_PIN 32 +#define Z_MIN_PIN 31 +#define Z_MAX_PIN 30 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 30 +#endif + +// +// Steppers +// +#define X_STEP_PIN 49 +#define X_DIR_PIN 13 +#define X_ENABLE_PIN 48 + +#define Y_STEP_PIN 11 +#define Y_DIR_PIN 9 +#define Y_ENABLE_PIN 12 + +#define Z_STEP_PIN 7 +#define Z_DIR_PIN 6 +#define Z_ENABLE_PIN 8 + +#define E0_STEP_PIN 40 +#define E0_DIR_PIN 41 +#define E0_ENABLE_PIN 37 + +#define E1_STEP_PIN 18 +#define E1_DIR_PIN 19 +#define E1_ENABLE_PIN 38 + +#define E2_STEP_PIN 43 +#define E2_DIR_PIN 47 +#define E2_ENABLE_PIN 42 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 3 // Analog Input +#define TEMP_1_PIN 2 // Analog Input +#define TEMP_2_PIN 1 // Analog Input +#define TEMP_BED_PIN 0 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 45 // 12V PWM1 +#define HEATER_1_PIN 46 // 12V PWM2 +#define HEATER_2_PIN 17 // 12V PWM3 +#define HEATER_BED_PIN 44 // DOUBLE 12V PWM + +#ifndef FAN_PIN + #define FAN_PIN 16 // 5V PWM +#endif + +// +// Misc. Functions +// +#define PS_ON_PIN 10 // Set to -1 if using a manual switch on the PWRSW Connector +#define SLEEP_WAKE_PIN 26 // This feature still needs work +#define PHOTOGRAPH_PIN 29 + +// +// LCD / Controller +// +#define BEEPER_PIN 36 + +#if ENABLED(RA_CONTROL_PANEL) + + #define SDSS 53 + #define SD_DETECT_PIN 28 + + #define BTN_EN1 14 + #define BTN_EN2 39 + #define BTN_ENC 15 + +#endif // RA_CONTROL_PANEL + +#if ENABLED(RA_DISCO) + // variables for which pins the TLC5947 is using + #define TLC_CLOCK_PIN 25 + #define TLC_BLANK_PIN 23 + #define TLC_XLAT_PIN 22 + #define TLC_DATA_PIN 24 + + // We also need to define pin to port number mapping for the 2560 to match the pins listed above. + // If you change the TLC pins, update this as well per the 2560 datasheet! This currently only works with the RA Board. + #define TLC_CLOCK_BIT 3 + #define TLC_CLOCK_PORT &PORTA + + #define TLC_BLANK_BIT 1 + #define TLC_BLANK_PORT &PORTA + + #define TLC_DATA_BIT 2 + #define TLC_DATA_PORT &PORTA + + #define TLC_XLAT_BIT 0 + #define TLC_XLAT_PORT &PORTA + + // Change this to match your situation. Lots of TLCs takes up the arduino SRAM very quickly, so be careful + // Leave it at at least 1 if you have enabled RA_LIGHTING + // The number of TLC5947 boards chained together for use with the animation, additional ones will repeat the animation on them, but are not individually addressable and mimic those before them. You can leave the default at 2 even if you only have 1 TLC5947 module. + #define NUM_TLCS 2 + + // These TRANS_ARRAY values let you change the order the LEDs on the lighting modules will animate for chase functions. + // Modify them according to your specific situation. + // NOTE: the array should be 8 long for every TLC you have. These defaults assume (2) TLCs. + #define TRANS_ARRAY { 0, 1, 2, 3, 4, 5, 6, 7, 15, 14, 13, 12, 11, 10, 9, 8 } // forward + //#define TRANS_ARRAY { 7, 6, 5, 4, 3, 2, 1, 0, 8, 9, 10, 11, 12, 13, 14, 15 } // backward +#endif // RA_DISCO diff --git a/src/pins/mega/pins_GT2560_REV_A.h b/src/pins/mega/pins_GT2560_REV_A.h new file mode 100644 index 0000000..99e8704 --- /dev/null +++ b/src/pins/mega/pins_GT2560_REV_A.h @@ -0,0 +1,169 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech GT2560 Revision A board pin assignments, based on the work of + * George Robles (https://georges3dprinters.com) and + * Richard Smith + */ + +#define ALLOW_MEGA1280 +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "GT2560 Rev.A" +#endif +#define DEFAULT_MACHINE_NAME "Prusa i3 Pro B" + +// +// Limit Switches +// +#define X_MIN_PIN 22 +#define X_MAX_PIN 24 +#define Y_MIN_PIN 26 +#define Y_MAX_PIN 28 +#define Z_MIN_PIN 30 + +#if ENABLED(BLTOUCH) + #if MB(GT2560_REV_A_PLUS) + #define SERVO0_PIN 11 + #define Z_MAX_PIN 32 + #else + #define SERVO0_PIN 32 + #define Z_MAX_PIN -1 + #endif +#else + #define Z_MAX_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 25 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 27 + +#define Y_STEP_PIN 31 +#define Y_DIR_PIN 33 +#define Y_ENABLE_PIN 29 + +#define Z_STEP_PIN 37 +#define Z_DIR_PIN 39 +#define Z_ENABLE_PIN 35 + +#define E0_STEP_PIN 43 +#define E0_DIR_PIN 45 +#define E0_ENABLE_PIN 41 + +#define E1_STEP_PIN 49 +#define E1_DIR_PIN 47 +#define E1_ENABLE_PIN 48 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 8 +#define TEMP_1_PIN 9 +#define TEMP_BED_PIN 10 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define HEATER_1_PIN 3 +#define HEATER_BED_PIN 4 +#ifndef FAN_PIN + #define FAN_PIN 7 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#define PS_ON_PIN 12 +#define SUICIDE_PIN 54 // Must be enabled at startup to keep power flowing +#define KILL_PIN -1 + +#if HAS_WIRED_LCD + + #define BEEPER_PIN 18 + + #if IS_NEWPANEL + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_A0 5 + #define DOGLCD_CS 21 + #define BTN_EN1 40 + #define BTN_EN2 42 + #elif ENABLED(FYSETC_MINI_12864) + // Disconnect EXP2-1 and EXP2-2, otherwise future firmware upload won't work. + #define DOGLCD_A0 20 + #define DOGLCD_CS 17 + + #define NEOPIXEL_PIN 21 + #define BTN_EN1 42 + #define BTN_EN2 40 + + #define LCD_RESET_PIN 16 + + #define LCD_CONTRAST_INIT 220 + + #define LCD_BACKLIGHT_PIN -1 + #else + #define LCD_PINS_RS 20 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 16 + #define LCD_PINS_D5 21 + #define LCD_PINS_D6 5 + #define LCD_PINS_D7 6 + #define BTN_EN1 42 + #define BTN_EN2 40 + #endif + + #define BTN_ENC 19 + #define SD_DETECT_PIN 38 + + #else // !IS_NEWPANEL + + #define SHIFT_CLK_PIN 38 + #define SHIFT_LD_PIN 42 + #define SHIFT_OUT_PIN 40 + #define SHIFT_EN_PIN 17 + + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 5 + #define LCD_PINS_D4 6 + #define LCD_PINS_D5 21 + #define LCD_PINS_D6 20 + #define LCD_PINS_D7 19 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #define SD_DETECT_PIN -1 + + #endif // !IS_NEWPANEL + +#endif // HAS_WIRED_LCD diff --git a/src/pins/mega/pins_GT2560_REV_A_PLUS.h b/src/pins/mega/pins_GT2560_REV_A_PLUS.h new file mode 100644 index 0000000..7e2ce20 --- /dev/null +++ b/src/pins/mega/pins_GT2560_REV_A_PLUS.h @@ -0,0 +1,34 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech GT2560 Revision A+ board pin assignments + */ + +#define BOARD_INFO_NAME "GT2560 Rev.A+" + +#include "pins_GT2560_REV_A.h" + +#if DISABLED(BLTOUCH) + #define SERVO0_PIN 32 +#endif diff --git a/src/pins/mega/pins_GT2560_REV_B.h b/src/pins/mega/pins_GT2560_REV_B.h new file mode 100644 index 0000000..be71ec4 --- /dev/null +++ b/src/pins/mega/pins_GT2560_REV_B.h @@ -0,0 +1,30 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Geeetech GT2560 Rev B Pins + */ + +#define BOARD_INFO_NAME "GT2560 Rev B" + +#include "pins_GT2560_V3.h" diff --git a/src/pins/mega/pins_GT2560_V3.h b/src/pins/mega/pins_GT2560_V3.h new file mode 100644 index 0000000..46b4ebf --- /dev/null +++ b/src/pins/mega/pins_GT2560_V3.h @@ -0,0 +1,217 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech GT2560 3.0/3.1 pin assignments + * + * Also GT2560 RevB and GT2560 4.0/4.1 + */ + +#define ALLOW_MEGA1280 +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "GT2560 3.x" +#endif + +// +// Servos +// +#define SERVO0_PIN 11 // 13 untested 3Dtouch + +// +// Limit Switches +// +#ifndef X_STOP_PIN + #ifndef X_MIN_PIN + #define X_MIN_PIN 24 + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN 22 + #endif +#endif +#ifndef Y_STOP_PIN + #ifndef Y_MIN_PIN + #define Y_MIN_PIN 28 + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN 26 + #endif +#endif +#ifndef Z_STOP_PIN + #ifndef Z_MIN_PIN + #define Z_MIN_PIN 30 + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN 32 + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 66 +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN 67 +#endif +#ifndef FIL_RUNOUT3_PIN + #define FIL_RUNOUT3_PIN 54 +#endif + +// +// Power Recovery +// +#define POWER_LOSS_PIN 69 // Pin to detect power loss +#define POWER_LOSS_STATE LOW + +// +// Steppers +// +#define X_STEP_PIN 37 +#define X_DIR_PIN 39 +#define X_ENABLE_PIN 35 + +#define Y_STEP_PIN 31 +#define Y_DIR_PIN 33 +#define Y_ENABLE_PIN 29 + +#define Z_STEP_PIN 25 +#define Z_DIR_PIN 23 +#define Z_ENABLE_PIN 27 + +#define E0_STEP_PIN 46 +#define E0_DIR_PIN 44 +#define E0_ENABLE_PIN 12 + +#define E1_STEP_PIN 49 +#define E1_DIR_PIN 47 +#define E1_ENABLE_PIN 48 + +#define E2_STEP_PIN 43 +#define E2_DIR_PIN 45 +#define E2_ENABLE_PIN 41 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 11 // Analog Input +#define TEMP_1_PIN 9 // Analog Input +#define TEMP_2_PIN 8 // Analog Input +#define TEMP_BED_PIN 10 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 3 +#define HEATER_2_PIN 2 +#define HEATER_BED_PIN 4 +#define FAN_PIN 9 +#define FAN1_PIN 8 +#define FAN2_PIN 7 + +// +// Misc. Functions +// +#define SD_DETECT_PIN 38 +#define SDSS 53 +#define LED_PIN 13 // Use 6 (case light) for external LED. 13 is internal (yellow) LED. +#define PS_ON_PIN 12 + +#if NUM_RUNOUT_SENSORS < 3 + #define SUICIDE_PIN 54 // This pin must be enabled at boot to keep power flowing +#endif + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 6 // 21 +#endif + +// +// LCD Controller +// +#define BEEPER_PIN 18 + +#if ENABLED(YHCB2004) + #ifndef YHCB2004_CLK + #define YHCB2004_CLK 5 + #define DIO52 YHCB2004_CLK + #endif + #ifndef YHCB2004_MOSI + #define YHCB2004_MOSI 21 + #define DIO50 YHCB2004_MOSI + #endif + #ifndef YHCB2004_MISO + #define YHCB2004_MISO 36 + #define DIO51 YHCB2004_MISO + #endif +#elif HAS_WIRED_LCD + #ifndef LCD_PINS_RS + #define LCD_PINS_RS 20 + #endif + #ifndef LCD_PINS_ENABLE + #define LCD_PINS_ENABLE 17 + #endif + #ifndef LCD_PINS_D4 + #define LCD_PINS_D4 16 + #endif + #ifndef LCD_PINS_D5 + #define LCD_PINS_D5 21 + #endif + #ifndef LCD_PINS_D6 + #define LCD_PINS_D6 5 + #endif + #ifndef LCD_PINS_D7 + #define LCD_PINS_D7 36 + #endif +#endif + +#if ENABLED(YHCB2004) + #ifndef BTN_EN1 + #define BTN_EN1 16 + #endif + #ifndef BTN_EN2 + #define BTN_EN2 17 + #endif + #ifndef BTN_ENC + #define BTN_ENC 19 + #endif +#elif IS_NEWPANEL + #ifndef BTN_EN1 + #define BTN_EN1 42 + #endif + #ifndef BTN_EN2 + #define BTN_EN2 40 + #endif + #ifndef BTN_ENC + #define BTN_ENC 19 + #endif +#endif diff --git a/src/pins/mega/pins_GT2560_V3_A20.h b/src/pins/mega/pins_GT2560_V3_A20.h new file mode 100644 index 0000000..986dd1c --- /dev/null +++ b/src/pins/mega/pins_GT2560_V3_A20.h @@ -0,0 +1,41 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech A20M board pin assignments + */ + +#define LCD_PINS_RS 5 +#define LCD_PINS_ENABLE 36 +#define LCD_PINS_D4 21 +#define LCD_PINS_D7 6 + +#define SPEAKER // The speaker can produce tones + +#if IS_NEWPANEL + #define BTN_EN1 16 + #define BTN_EN2 17 + #define BTN_ENC 19 +#endif + +#include "pins_GT2560_V3.h" diff --git a/src/pins/mega/pins_GT2560_V3_MC2.h b/src/pins/mega/pins_GT2560_V3_MC2.h new file mode 100644 index 0000000..e683d4d --- /dev/null +++ b/src/pins/mega/pins_GT2560_V3_MC2.h @@ -0,0 +1,35 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech GT2560 V 3.0 board pin assignments (for Mecreator 2) + */ + +#define BOARD_INFO_NAME "GT2560 V3.0 (MC2)" + +#define X_MIN_PIN 22 +#define X_MAX_PIN 24 +#define Y_MIN_PIN 26 +#define Y_MAX_PIN 28 + +#include "pins_GT2560_V3.h" diff --git a/src/pins/mega/pins_GT2560_V4.h b/src/pins/mega/pins_GT2560_V4.h new file mode 100644 index 0000000..6ac07b7 --- /dev/null +++ b/src/pins/mega/pins_GT2560_V4.h @@ -0,0 +1,30 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Geeetech GT2560 V4.X Pins + */ + +#define BOARD_INFO_NAME "GT2560 4.x" + +#include "pins_GT2560_V3.h" diff --git a/src/pins/mega/pins_GT2560_V4_A20.h b/src/pins/mega/pins_GT2560_V4_A20.h new file mode 100644 index 0000000..83a612e --- /dev/null +++ b/src/pins/mega/pins_GT2560_V4_A20.h @@ -0,0 +1,43 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Geeetech A20 GT2560 V4.x board pin assignments + */ + +#define BOARD_INFO_NAME "GT2560 4.x" + +#define LCD_PINS_RS 5 +#define LCD_PINS_ENABLE 36 +#define LCD_PINS_D4 21 +#define LCD_PINS_D7 6 + +#define SPEAKER // The speaker can produce tones + +#if IS_NEWPANEL + #define BTN_EN1 16 + #define BTN_EN2 17 + #define BTN_ENC 19 +#endif + +#include "pins_GT2560_V3.h" diff --git a/src/pins/mega/pins_HJC2560C_REV2.h b/src/pins/mega/pins_HJC2560C_REV2.h new file mode 100644 index 0000000..5c3b1dc --- /dev/null +++ b/src/pins/mega/pins_HJC2560C_REV2.h @@ -0,0 +1,171 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech HJC2560-C Rev 2.x board pin assignments + */ + +#include "env_validate.h" + +#define DEFAULT_MACHINE_NAME "ADIMLab Gantry v2" +#define BOARD_INFO_NAME "HJC2560-C" + +// +// Servos +// +//#ifndef SERVO0_PIN +// #define SERVO0_PIN 11 +//#endif + +// +// Limit Switches +// +#define X_STOP_PIN 22 +#define Y_STOP_PIN 26 +#define Z_STOP_PIN 29 +//#define EXP_STOP_PIN 28 + +// +// Steppers +// +#define X_STEP_PIN 25 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 27 + +#define Y_STEP_PIN 32 +#define Y_DIR_PIN 33 +#define Y_ENABLE_PIN 31 + +#define Z_STEP_PIN 35 +#define Z_DIR_PIN 36 +#define Z_ENABLE_PIN 34 + +#define E0_STEP_PIN 42 +#define E0_DIR_PIN 43 +#define E0_ENABLE_PIN 37 + +#define E1_STEP_PIN 49 +#define E1_DIR_PIN 47 +#define E1_ENABLE_PIN 48 + +#define MOTOR_CURRENT_PWM_XY_PIN 44 +#define MOTOR_CURRENT_PWM_Z_PIN 45 +#define MOTOR_CURRENT_PWM_E_PIN 46 +// Motor current PWM conversion, PWM value = MotorCurrentSetting * 255 / range +#ifndef MOTOR_CURRENT_PWM_RANGE + #define MOTOR_CURRENT_PWM_RANGE 2000 +#endif +#define DEFAULT_PWM_MOTOR_CURRENT { 1300, 1300, 1250 } + +// +// Temperature Sensors +// +#define TEMP_0_PIN 8 // Analog Input +#define TEMP_1_PIN 9 // Analog Input +#define TEMP_BED_PIN 10 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define HEATER_1_PIN 3 +#define HEATER_BED_PIN 4 + +#ifndef FAN_PIN + #define FAN_PIN 7 //默认不使用PWM_FAN冷却喷嘴,如果需要,则取消注释 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define SD_DETECT_PIN 39 +//#define LED_PIN 8 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 8 // 8 默认挤出机风扇作为Case LED,如果需要PWM FAN,则需要将FAN_PIN置为7,LED_PIN置为8 +#endif + +//#define SAFETY_TRIGGERED_PIN 28 // PIN to detect the safety circuit has triggered +//#define MAIN_VOLTAGE_MEASURE_PIN 14 // ANALOG PIN to measure the main voltage, with a 100k - 4k7 resitor divider. + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + #define SPINDLE_DIR_PIN 16 + #define SPINDLE_LASER_ENA_PIN 17 // Pin should have a pullup! + #define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #define BEEPER_PIN 18 + + #if IS_NEWPANEL + + #define LCD_PINS_RS 20 // LCD_CS + #define LCD_PINS_ENABLE 15 // LCD_SDA + #define LCD_PINS_D4 14 // LCD_SCK + + #if ENABLED(HJC_LCD_SMART_CONTROLLER) + #define LCD_BACKLIGHT_PIN 5 // LCD_Backlight + //#ifndef LCD_CONTRAST_PIN + // #define LCD_CONTRAST_PIN 5 // LCD_Contrast + //#endif + #ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 24 // Filament runout + #endif + #else + #define LCD_PINS_D5 21 + #define LCD_PINS_D6 5 + #define LCD_PINS_D7 6 + #endif + + #define BTN_EN1 41 + #define BTN_EN2 40 + #define BTN_ENC 19 + + #define SD_DETECT_PIN 39 + + #else + + // Buttons attached to a shift register + #define SHIFT_CLK_PIN 38 + #define SHIFT_LD_PIN 42 + #define SHIFT_OUT_PIN 40 + #define SHIFT_EN_PIN 17 + + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 5 + #define LCD_PINS_D4 6 + #define LCD_PINS_D5 21 + #define LCD_PINS_D6 20 + #define LCD_PINS_D7 19 + + #endif // !IS_NEWPANEL + +#endif // HAS_WIRED_LCD diff --git a/src/pins/mega/pins_INTAMSYS40.h b/src/pins/mega/pins_INTAMSYS40.h new file mode 100644 index 0000000..2e2a9b8 --- /dev/null +++ b/src/pins/mega/pins_INTAMSYS40.h @@ -0,0 +1,149 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Intamsys Funmat HT V4.0 Mainboard + * 4988 Drivers Tested + * 2208 version exists and may or may not work + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Intamsys 4.0" + +// +// Servos +// +#define SERVO0_PIN 12 // Uses High Temp Present Jumper Pin + +// +// Limit Switches +// +#define X_STOP_PIN 22 +#define Y_STOP_PIN 26 +#define Z_MIN_PIN 29 +#define Z_MAX_PIN 69 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 69 +#endif + +#define FIL_RUNOUT_PIN 10 + +// +// Steppers +// +#define X_STEP_PIN 25 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 27 // 44 + +#define Y_STEP_PIN 32 // 33 +#define Y_DIR_PIN 33 // 31, 32 +#define Y_ENABLE_PIN 31 // 32 + +#define Z_STEP_PIN 35 // 35 +#define Z_DIR_PIN 36 +#define Z_ENABLE_PIN 34 // 34 + +#define E0_STEP_PIN 42 +#define E0_DIR_PIN 43 +#define E0_ENABLE_PIN 37 + +#define E1_STEP_PIN 49 +#define E1_DIR_PIN 47 +#define E1_ENABLE_PIN 48 + +#define MOTOR_CURRENT_PWM_X_PIN 11 +#define MOTOR_CURRENT_PWM_Y_PIN 44 +#define MOTOR_CURRENT_PWM_Z_PIN 45 +#define MOTOR_CURRENT_PWM_E_PIN 46 + +// Motor current PWM conversion, PWM value = MotorCurrentSetting * 255 / range +#ifndef MOTOR_CURRENT_PWM_RANGE + #define MOTOR_CURRENT_PWM_RANGE 2000 +#endif +#define DEFAULT_PWM_MOTOR_CURRENT { 1300, 1300, 1250 } + +// +// Temperature Sensors +// +#define TEMP_0_PIN 8 // Analog Input D62 +#define TEMP_BED_PIN 10 // Analog Input D64 + +#define TEMP_CHAMBER_PIN 9 // Analog Input D63 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 // PWM +#define HEATER_BED_PIN 4 // PWM +#define HEATER_CHAMBER_PIN 3 // PWM +#define FAN_PIN 7 // PWM + +// +// Misc. Functions +// +#define SDSS 53 +#define SD_DETECT_PIN 39 + +#if ENABLED(CASE_LIGHT_ENABLE) + #define CASE_LIGHT_PIN 8 +#endif + +#if ENABLED(PSU_CONTROL) + #define PS_ON_PIN 38 // UPS Module +#endif + +// +// LCD Controller +// + +#define BEEPER_PIN 18 + +#if HAS_WIRED_LCD + #define LCD_PINS_RS 20 + #define LCD_PINS_ENABLE 30 + #define LCD_PINS_D4 14 + #define LCD_PINS_D5 21 + #define LCD_PINS_D6 5 + #define LCD_PINS_D7 6 + #define BTN_EN1 40 + #define BTN_EN2 41 + #define BTN_ENC 19 +#endif + +///////////////////// SPARE HEADERS ////////////// + +/** + * J25 + * 1 D54 + * 2 D55 + * 3 D56 + * 4 D57 + * 5 D58 + * 6 D59 + * 7 D60 + * 8 D61 + +Hotend High Temp Connected : D12 +*/ diff --git a/src/pins/mega/pins_LEAPFROG.h b/src/pins/mega/pins_LEAPFROG.h new file mode 100644 index 0000000..4700fd6 --- /dev/null +++ b/src/pins/mega/pins_LEAPFROG.h @@ -0,0 +1,91 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Leapfrog Driver board pin assignments + */ + +#define ALLOW_MEGA1280 +#include "env_validate.h" + +#define BOARD_INFO_NAME "Leapfrog" + +// +// Limit Switches +// +#define X_MIN_PIN 47 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 48 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 49 +#define Z_MAX_PIN -1 + +// +// Steppers +// +#define X_STEP_PIN 28 +#define X_DIR_PIN 63 +#define X_ENABLE_PIN 29 + +#define Y_STEP_PIN 14 // A6 +#define Y_DIR_PIN 15 // A0 +#define Y_ENABLE_PIN 39 + +#define Z_STEP_PIN 31 // A2 +#define Z_DIR_PIN 32 // A6 +#define Z_ENABLE_PIN 30 // A1 + +#define E0_STEP_PIN 34 // 34 +#define E0_DIR_PIN 35 // 35 +#define E0_ENABLE_PIN 33 // 33 + +#define E1_STEP_PIN 37 // 37 +#define E1_DIR_PIN 40 // 40 +#define E1_ENABLE_PIN 36 // 36 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // Analog Input (D27) +#define TEMP_1_PIN 15 // Analog Input (1) +#define TEMP_BED_PIN 14 // Analog Input (1,2 or I2C) + +// +// Heaters / Fans +// +#define HEATER_0_PIN 9 +#define HEATER_1_PIN 8 // 12 +#define HEATER_2_PIN 11 // 13 +#define HEATER_BED_PIN 10 // 14/15 + +#define FAN_PIN 7 + +// +// Misc. Functions +// +#define SDSS 11 +#define LED_PIN 13 +#define SOL1_PIN 16 +#define SOL2_PIN 17 + +/* Unused (1) (2) (3) 4 5 6 7 8 9 10 11 12 13 (14) (15) (16) 17 (18) (19) (20) (21) (22) (23) 24 (25) (26) (27) 28 (29) (30) (31) */ diff --git a/src/pins/mega/pins_LEAPFROG_XEED2015.h b/src/pins/mega/pins_LEAPFROG_XEED2015.h new file mode 100644 index 0000000..4a32472 --- /dev/null +++ b/src/pins/mega/pins_LEAPFROG_XEED2015.h @@ -0,0 +1,113 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Leapfrog Xeed Driver board pin assignments + * + * This board is used by other Leapfrog printers in addition to the Xeed, + * such as the Creatr HS and Bolt. The pin assignments vary wildly between + * printer models. As such this file is currently specific to the Xeed. + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Leapfrog Xeed 2015" + +// +// Limit Switches +// +#define X_STOP_PIN 47 // 'X Min' +#define Y_STOP_PIN 48 // 'Y Min' +#define Z_STOP_PIN 49 // 'Z Min' + +// +// Steppers +// The Xeed utilizes three Z-axis motors, which use the X, Y, and Z stepper connectors +// on the board. The X and Y steppers use external drivers, attached to signal-level +// Y-axis and X-axis connectors on the board, which map to distinct CPU pins from +// the on-board X/Y stepper drivers. +// + +// X-axis signal-level connector +#define X_STEP_PIN 65 +#define X_DIR_PIN 64 +#define X_ENABLE_PIN 66 // Not actually used on Xeed, could be repurposed + +// Y-axis signal-level connector +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 // Not actually used on Xeed, could be repurposed + +// ZMOT connector (Front Right Z Motor) +#define Z_STEP_PIN 31 +#define Z_DIR_PIN 32 +#define Z_ENABLE_PIN 30 + +// XMOT connector (Rear Z Motor) +#define Z2_STEP_PIN 28 +#define Z2_DIR_PIN 63 +#define Z2_ENABLE_PIN 29 + +// YMOT connector (Front Left Z Motor) +#define Z3_STEP_PIN 14 +#define Z3_DIR_PIN 15 +#define Z3_ENABLE_PIN 39 + +// EMOT2 connector +#define E0_STEP_PIN 37 +#define E0_DIR_PIN 40 +#define E0_ENABLE_PIN 36 + +// EMOT connector +#define E1_STEP_PIN 34 +#define E1_DIR_PIN 35 +#define E1_ENABLE_PIN 33 + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN 42 // ROT2 Connector +#define FIL_RUNOUT2_PIN 44 // ROT1 Connector + +// +// Temperature Sensors +// +#define TEMP_0_PIN 15 // T3 Connector +#define TEMP_1_PIN 13 // T1 Connector +#define TEMP_BED_PIN 14 // BED Connector (Between T1 and T3) + +// +// Heaters / Fans +// +#define HEATER_0_PIN 8 // Misc Connector, pins 3 and 4 (Out2) +#define HEATER_1_PIN 9 // Misc Connector, pins 5 and 6 (Out3) +#define HEATER_BED_PIN 6 // Misc Connector, pins 9(-) and 10(+) (OutA) + +#define FAN_PIN 10 // Misc Connector, pins 7(-) and 8 (+) (Out4) + +#define LED_PIN 13 + +#define SOL1_PIN 7 // Misc Connector, pins 1(-) and 2(+) (Out1) + +// Door Closed Sensor +//#define DOOR_PIN 45 // HM1 Connector diff --git a/src/pins/mega/pins_MALYAN_M180.h b/src/pins/mega/pins_MALYAN_M180.h new file mode 100644 index 0000000..19095a5 --- /dev/null +++ b/src/pins/mega/pins_MALYAN_M180.h @@ -0,0 +1,100 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Malyan M180 pin assignments + * Contributed by Timo Birnschein (timo.birnschein@microforge.de) + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Malyan M180 v.2" +// +// Limit Switches +// +#define X_STOP_PIN 48 +#define Y_STOP_PIN 46 +#define Z_STOP_PIN 42 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN -1 +#endif + +// +// Steppers +// +#define X_STEP_PIN 55 +#define X_DIR_PIN 54 +#define X_ENABLE_PIN 56 + +#define Y_STEP_PIN 59 +#define Y_DIR_PIN 58 +#define Y_ENABLE_PIN 60 + +#define Z_STEP_PIN 63 +#define Z_DIR_PIN 62 +#define Z_ENABLE_PIN 64 + +#define E0_STEP_PIN 25 +#define E0_DIR_PIN 24 +#define E0_ENABLE_PIN 26 + +#define E1_STEP_PIN 29 +#define E1_DIR_PIN 28 +#define E1_ENABLE_PIN 39 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN 15 // Analog Input + +// Extruder thermocouples 0 and 1 are read out by two separate ICs using +// SPI for MAX Thermocouple +// Uses a separate SPI bus +#define TEMP_0_CS_PIN 5 // E3 - CS0 +#define TEMP_0_SCK_PIN 78 // E2 - SCK +#define TEMP_0_MISO_PIN 3 // E5 - MISO +//#define TEMP_0_MOSI_PIN ... // For MAX31865 + +#define TEMP_1_CS_PIN 2 // E4 - CS1 +#define TEMP_1_SCK_PIN TEMP_0_SCK_PIN +#define TEMP_1_MISO_PIN TEMP_0_MISO_PIN +//#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 +#define HEATER_1_PIN 11 +#define HEATER_BED_PIN 45 + +#ifndef FAN_PIN + #define FAN_PIN 7 // M106 Sxxx command supported and tested. M107 as well. +#endif + +#ifndef FAN_PIN1 + #define FAN_PIN1 12 // Currently Unsupported by Marlin +#endif diff --git a/src/pins/mega/pins_MEGACONTROLLER.h b/src/pins/mega/pins_MEGACONTROLLER.h new file mode 100644 index 0000000..7ebef6e --- /dev/null +++ b/src/pins/mega/pins_MEGACONTROLLER.h @@ -0,0 +1,164 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Mega controller pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Mega Controller supports up to 2 hotends / E steppers." +#endif + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Mega Controller" + +// +// Servos +// +#define SERVO0_PIN 30 +#define SERVO1_PIN 31 +#define SERVO2_PIN 32 +#define SERVO3_PIN 33 + +// +// Limit Switches +// +#define X_MIN_PIN 43 +#define X_MAX_PIN 42 +#define Y_MIN_PIN 38 +#define Y_MAX_PIN 41 +#define Z_MIN_PIN 40 +#define Z_MAX_PIN 37 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 37 +#endif + +// +// Steppers +// +#define X_STEP_PIN 62 // A8 +#define X_DIR_PIN 63 // A9 +#define X_ENABLE_PIN 61 // A7 + +#define Y_STEP_PIN 65 // A11 +#define Y_DIR_PIN 66 // A12 +#define Y_ENABLE_PIN 64 // A10 + +#define Z_STEP_PIN 68 // A14 +#define Z_DIR_PIN 69 // A15 +#define Z_ENABLE_PIN 67 // A13 + +#define E0_STEP_PIN 23 +#define E0_DIR_PIN 24 +#define E0_ENABLE_PIN 22 + +#define E1_STEP_PIN 26 +#define E1_DIR_PIN 27 +#define E1_ENABLE_PIN 25 + +// +// Temperature Sensors +// +#if TEMP_SENSOR_0 == -1 + #define TEMP_0_PIN 4 // Analog Input +#else + #define TEMP_0_PIN 0 // Analog Input +#endif + +#if TEMP_SENSOR_1 == -1 + #define TEMP_1_PIN 5 // Analog Input +#else + #define TEMP_1_PIN 2 // Analog Input +#endif + +#define TEMP_2_PIN 3 // Analog Input + +#if TEMP_SENSOR_BED == -1 + #define TEMP_BED_PIN 6 // Analog Input +#else + #define TEMP_BED_PIN 1 // Analog Input +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 29 +#define HEATER_1_PIN 34 +#define HEATER_BED_PIN 28 + +#ifndef FAN_PIN + #define FAN_PIN 39 +#endif +#define FAN1_PIN 35 +#define FAN2_PIN 36 + +#ifndef CONTROLLER_FAN_PIN + #define CONTROLLER_FAN_PIN FAN2_PIN +#endif + +#define FAN_SOFT_PWM_REQUIRED + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 2 +#endif + +// +// LCD / Controller +// +#if ENABLED(MINIPANEL) + + #define BEEPER_PIN 46 + + #define DOGLCD_A0 47 + #define DOGLCD_CS 45 + #define LCD_BACKLIGHT_PIN 44 // backlight LED on PA3 + + #define KILL_PIN 12 + + #define BTN_EN1 48 + #define BTN_EN2 11 + #define BTN_ENC 10 + + #define SD_DETECT_PIN 49 + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + +#endif // MINIPANEL + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM +#define SPINDLE_LASER_ENA_PIN 7 // Pullup! +#define SPINDLE_DIR_PIN 8 diff --git a/src/pins/mega/pins_MEGATRONICS.h b/src/pins/mega/pins_MEGATRONICS.h new file mode 100644 index 0000000..ac0ba4e --- /dev/null +++ b/src/pins/mega/pins_MEGATRONICS.h @@ -0,0 +1,132 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MegaTronics pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Megatronics" +// +// Limit Switches +// +#define X_MIN_PIN 41 +#define X_MAX_PIN 37 +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 19 +#endif + +// +// Steppers +// +#define X_STEP_PIN 26 +#define X_DIR_PIN 28 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 60 // A6 +#define Y_DIR_PIN 61 // A7 +#define Y_ENABLE_PIN 22 + +#define Z_STEP_PIN 54 // A0 +#define Z_DIR_PIN 55 // A1 +#define Z_ENABLE_PIN 56 // A2 + +#define E0_STEP_PIN 31 +#define E0_DIR_PIN 32 +#define E0_ENABLE_PIN 38 + +#define E1_STEP_PIN 34 +#define E1_DIR_PIN 36 +#define E1_ENABLE_PIN 30 + +// +// Temperature Sensors +// +#if TEMP_SENSOR_0 == -1 + #define TEMP_0_PIN 8 // Analog Input +#else + #define TEMP_0_PIN 13 // Analog Input +#endif +#define TEMP_1_PIN 15 // Analog Input +#define TEMP_BED_PIN 14 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 9 +#define HEATER_1_PIN 8 +#define HEATER_BED_PIN 10 + +#ifndef FAN_PIN + #define FAN_PIN 7 // IO pin. Buffer needed +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#define PS_ON_PIN 12 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 2 +#endif + +// +// LCD / Controller +// +#define BEEPER_PIN 33 + +#if HAS_WIRED_LCD && IS_NEWPANEL + + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + + // Buttons directly attached to AUX-2 + #define BTN_EN1 59 + #define BTN_EN2 64 + #define BTN_ENC 43 + + #define SD_DETECT_PIN -1 // RAMPS doesn't use this + +#endif // HAS_WIRED_LCD && IS_NEWPANEL + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_PWM_PIN 3 // Hardware PWM +#define SPINDLE_LASER_ENA_PIN 4 // Pullup! +#define SPINDLE_DIR_PIN 11 diff --git a/src/pins/mega/pins_MEGATRONICS_2.h b/src/pins/mega/pins_MEGATRONICS_2.h new file mode 100644 index 0000000..e527035 --- /dev/null +++ b/src/pins/mega/pins_MEGATRONICS_2.h @@ -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 . + * + */ +#pragma once + +/** + * MegaTronics v2.0 pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Megatronics v2.0" +// +// Limit Switches +// +#define X_MIN_PIN 37 +#define X_MAX_PIN 40 +#define Y_MIN_PIN 41 +#define Y_MAX_PIN 38 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 19 +#endif + +// +// Steppers +// +#define X_STEP_PIN 26 +#define X_DIR_PIN 27 +#define X_ENABLE_PIN 25 + +#define Y_STEP_PIN 4 // A6 +#define Y_DIR_PIN 54 // A0 +#define Y_ENABLE_PIN 5 + +#define Z_STEP_PIN 56 // A2 +#define Z_DIR_PIN 60 // A6 +#define Z_ENABLE_PIN 55 // A1 + +#define E0_STEP_PIN 35 +#define E0_DIR_PIN 36 +#define E0_ENABLE_PIN 34 + +#define E1_STEP_PIN 29 +#define E1_DIR_PIN 39 +#define E1_ENABLE_PIN 28 + +#define E2_STEP_PIN 23 // ? schematic says 24 +#define E2_DIR_PIN 24 // ? schematic says 23 +#define E2_ENABLE_PIN 22 + +// +// Temperature Sensors +// +#if TEMP_SENSOR_0 == -1 + #define TEMP_0_PIN 4 // Analog Input +#else + #define TEMP_0_PIN 13 // Analog Input +#endif + +#if TEMP_SENSOR_1 == -1 + #define TEMP_1_PIN 8 // Analog Input +#else + #define TEMP_1_PIN 15 // Analog Input +#endif + +#if TEMP_SENSOR_BED == -1 + #define TEMP_BED_PIN 8 // Analog Input +#else + #define TEMP_BED_PIN 14 // Analog Input +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 9 +#define HEATER_1_PIN 8 +#define HEATER_BED_PIN 10 + +#ifndef FAN_PIN + #define FAN_PIN 7 +#endif +#define FAN1_PIN 6 + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#define PS_ON_PIN 12 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 2 +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_PWM_PIN 3 // Hardware PWM +#define SPINDLE_LASER_ENA_PIN 16 // Pullup! +#define SPINDLE_DIR_PIN 11 + +// +// LCD / Controller +// +#define BEEPER_PIN 64 + +#if HAS_WIRED_LCD + + #define LCD_PINS_RS 14 + #define LCD_PINS_ENABLE 15 + #define LCD_PINS_D4 30 + #define LCD_PINS_D5 31 + #define LCD_PINS_D6 32 + #define LCD_PINS_D7 33 + + #if IS_NEWPANEL + // Buttons are directly attached using keypad + #define BTN_EN1 61 + #define BTN_EN2 59 + #define BTN_ENC 43 + #else + // Buttons attached to shift register of reprapworld keypad v1.1 + #define SHIFT_CLK_PIN 63 + #define SHIFT_LD_PIN 42 + #define SHIFT_OUT_PIN 17 + #define SHIFT_EN_PIN 17 + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/mega/pins_MEGATRONICS_3.h b/src/pins/mega/pins_MEGATRONICS_3.h new file mode 100644 index 0000000..86aff16 --- /dev/null +++ b/src/pins/mega/pins_MEGATRONICS_3.h @@ -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 . + * + */ +#pragma once + +/** + * MegaTronics v3.0 / v3.1 / v3.2 pin assignments + */ + +#include "env_validate.h" + +#if MB(MEGATRONICS_32) + #define BOARD_INFO_NAME "Megatronics v3.2" +#elif MB(MEGATRONICS_31) + #define BOARD_INFO_NAME "Megatronics v3.1" +#else + #define BOARD_INFO_NAME "Megatronics v3.0" +#endif + +// +// Servos +// +#define SERVO0_PIN 46 // AUX3-6 +#define SERVO1_PIN 47 // AUX3-5 +#define SERVO2_PIN 48 // AUX3-4 +#define SERVO3_PIN 49 // AUX3-3 + +// +// Limit Switches +// +#define X_MIN_PIN 37 // No INT +#define X_MAX_PIN 40 // No INT +#define Y_MIN_PIN 41 // No INT +#define Y_MAX_PIN 38 // No INT +#define Z_MIN_PIN 18 // No INT +#define Z_MAX_PIN 19 // No INT + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 19 +#endif + +// +// Steppers +// +#define X_STEP_PIN 58 +#define X_DIR_PIN 57 +#define X_ENABLE_PIN 59 + +#if ENABLED(REPRAPWORLD_KEYPAD) && EXTRUDERS <= 2 + #define Y_ENABLE_PIN 23 + #define Y_STEP_PIN 22 + #define Y_DIR_PIN 60 +#else + #define Y_STEP_PIN 5 + #define Y_DIR_PIN 17 + #define Y_ENABLE_PIN 4 + + #define E2_STEP_PIN 22 + #define E2_DIR_PIN 60 + #define E2_ENABLE_PIN 23 +#endif + +#define Z_STEP_PIN 16 +#define Z_DIR_PIN 11 +#define Z_ENABLE_PIN 3 + +#define E0_STEP_PIN 28 +#define E0_DIR_PIN 27 +#define E0_ENABLE_PIN 29 + +#define E1_STEP_PIN 25 +#define E1_DIR_PIN 24 +#define E1_ENABLE_PIN 26 + +// +// Temperature Sensors +// +#if TEMP_SENSOR_0 == -1 + #define TEMP_0_PIN 11 // Analog Input +#else + #define TEMP_0_PIN 15 // Analog Input +#endif +#if TEMP_SENSOR_1 == -1 + #define TEMP_1_PIN 10 // Analog Input +#else + #define TEMP_1_PIN 13 // Analog Input +#endif +#if TEMP_SENSOR_2 == -1 + #define TEMP_2_PIN 9 // Analog Input +#else + #define TEMP_2_PIN 12 // Analog Input +#endif +#if TEMP_SENSOR_BED == -1 + #define TEMP_BED_PIN 8 // Analog Input +#else + #define TEMP_BED_PIN 14 // Analog Input +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define HEATER_1_PIN 9 +#define HEATER_2_PIN 8 +#define HEATER_BED_PIN 10 + +#ifndef FAN_PIN + #define FAN_PIN 6 +#endif +#define FAN1_PIN 7 + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#define PS_ON_PIN 12 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 45 // Try the keypad connector +#endif + +// +// LCD / Controller +// +#define BEEPER_PIN 61 + +#define BTN_EN1 44 +#define BTN_EN2 45 +#define BTN_ENC 33 + +#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define LCD_PINS_RS 56 // CS chip select / SS chip slave select + #define LCD_PINS_ENABLE 51 // SID (MOSI) + #define LCD_PINS_D4 52 // SCK (CLK) clock + #define SD_DETECT_PIN 35 + +#else + + #define LCD_PINS_RS 32 + #define LCD_PINS_ENABLE 31 + #define LCD_PINS_D4 14 + #define LCD_PINS_D5 30 + #define LCD_PINS_D6 39 + #define LCD_PINS_D7 15 + + #define SHIFT_CLK_PIN 43 + #define SHIFT_LD_PIN 35 + #define SHIFT_OUT_PIN 34 + #define SHIFT_EN_PIN 44 + + #if MB(MEGATRONICS_31, MEGATRONICS_32) + #define SD_DETECT_PIN 56 + #endif + +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if DISABLED(REPRAPWORLD_KEYPAD) // try to use the keypad connector first + #define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM + #define SPINDLE_LASER_ENA_PIN 43 // Pullup! + #define SPINDLE_DIR_PIN 42 +#elif EXTRUDERS <= 2 + // Hijack the last extruder so that we can get the PWM signal off the Y breakout + // Move Y to the E2 plug. This makes dual Y steppers harder + #define SPINDLE_LASER_PWM_PIN 4 // Hardware PWM + #define SPINDLE_LASER_ENA_PIN 17 // Pullup! + #define SPINDLE_DIR_PIN 5 +#endif diff --git a/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/src/pins/mega/pins_MIGHTYBOARD_REVE.h new file mode 100644 index 0000000..3bcece4 --- /dev/null +++ b/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -0,0 +1,278 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Mightyboard Rev.E pin assignments + * also works for Rev D boards. It's all rev E despite what the silk screen says + */ + +/** + * Rev B 2 JAN 2017 + * + * Added pin definitions for: + * M3, M4 & M5 spindle control commands + * case light + * + * Corrected pin assignment for EX2_HEAT_PIN pin. Changed it from 9 to 11. The port + * number (B5) agrees with the schematic but B5 is assigned to logical pin 11. + */ + +#define ALLOW_MEGA1280 +#include "env_validate.h" + +#define BOARD_INFO_NAME "Mightyboard" +#define DEFAULT_MACHINE_NAME "MB Replicator" + +// +// Servos +// +#define SERVO0_PIN 36 // C1 (1280-EX1) +#define SERVO1_PIN 37 // C0 (1280-EX2) +#define SERVO2_PIN 40 // G1 (1280-EX3) +#define SERVO3_PIN 41 // G0 (1280-EX4) + +// +// Limit Switches +// +#define X_MIN_PIN 49 // L0 +#define X_MAX_PIN 48 // L1 +#define Y_MIN_PIN 47 // L2 +#define Y_MAX_PIN 46 // L3 +#define Z_MIN_PIN 43 // L6 +#define Z_MAX_PIN 42 // L7 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 42 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 49 +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN 47 +#endif + +// +// Steppers +// +#define X_STEP_PIN 55 // F1 +#define X_DIR_PIN 54 // F0 +#define X_ENABLE_PIN 56 // F2 + +#define Y_STEP_PIN 59 // F5 +#define Y_DIR_PIN 58 // F4 +#define Y_ENABLE_PIN 60 // F6 + +#define Z_STEP_PIN 63 // K1 +#define Z_DIR_PIN 62 // K0 +#define Z_ENABLE_PIN 64 // K2 + +#define E0_STEP_PIN 25 // A3 +#define E0_DIR_PIN 24 // A2 +#define E0_ENABLE_PIN 26 // A4 + +#define E1_STEP_PIN 29 // A7 +#define E1_DIR_PIN 28 // A6 +#define E1_ENABLE_PIN 39 // G2 + +// +// I2C Digipots - MCP4018 +// Address 5E (2F << 1) +// Set from 0 - 127 with stop bit. +// (Ex. 3F << 1 | 1) +// +#define DIGIPOTS_I2C_SCL 76 // J5 +#define DIGIPOTS_I2C_SDA_X 57 // F3 +#define DIGIPOTS_I2C_SDA_Y 61 // F7 +#define DIGIPOTS_I2C_SDA_Z 65 // K3 +#define DIGIPOTS_I2C_SDA_E0 27 // A5 +#define DIGIPOTS_I2C_SDA_E1 77 // J6 + +#ifndef DIGIPOT_I2C_ADDRESS_A + #define DIGIPOT_I2C_ADDRESS_A 0x2F // unshifted slave address (5E <- 2F << 1) +#endif +#define DIGIPOT_ENABLE_I2C_PULLUPS // MightyBoard doesn't have hardware I2C pin pull-ups. + +// +// Temperature Sensors +// +// K7 - 69 / ADC15 - 15 +#define TEMP_BED_PIN 15 + +// SPI for MAX Thermocouple +// Uses a separate SPI bus +// +// 3 E5 DO (SO) +// 5 E3 CS1 +// 2 E4 CS2 +// 78 E2 SCK +// +#define TEMP_0_CS_PIN 5 // E3 +#define TEMP_0_SCK_PIN 78 // E2 +#define TEMP_0_MISO_PIN 3 // E5 +//#define TEMP_0_MOSI_PIN ... // For MAX31865 + +#define TEMP_1_CS_PIN 2 // E4 +#define TEMP_1_SCK_PIN TEMP_0_SCK_PIN +#define TEMP_1_MISO_PIN TEMP_0_MISO_PIN +//#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN + +// +// FET Pin Mapping - FET 1 is closest to the input power connector +// + +#define MOSFET_1_PIN 6 // Plug EX1 Pin 1-2 -> PH3 #15 -> Logical 06 +#define MOSFET_2_PIN 7 // Plug EX1 Pin 3-4 -> PH4 #16 -> Logical 07 +#define MOSFET_3_PIN 11 // Plug EX2 1-2 -> PB5 #24 -> Logical 11 +#define MOSFET_4_PIN 12 // Plug EX2 3-4 -> PB6 #25 -> Logical 12 +#define MOSFET_5_PIN 45 // Plug HBD 1-2 -> PL4 #39 -> Logical 45 +#define MOSFET_6_PIN 44 // Plug Extra 1-2 -> PL5 #40 -> Logical 44 (FET not soldered in all boards) + +// +// Heaters / Fans (24V) +// + +#define HEATER_0_PIN MOSFET_1_PIN // EX1 +#define HEATER_1_PIN MOSFET_3_PIN // EX2 +#define HEATER_BED_PIN MOSFET_5_PIN // HBP + +// EX1 FAN (Automatic Fans are disabled by default in Configuration_adv.h - comment that out for auto fans) +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN MOSFET_2_PIN +#else + #ifndef FAN_PIN + #define FAN_PIN MOSFET_2_PIN + #endif +#endif +// EX2 FAN (Automatic Fans are disabled by default in Configuration_adv.h - comment that out for auto fans) +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN MOSFET_4_PIN +#else + #ifndef FAN1_PIN + #define FAN1_PIN MOSFET_4_PIN + #endif +#endif + +// +// Misc. Functions +// +#define LED_PIN 13 // B7 +#define CUTOFF_RESET_PIN 16 // H1 +#define CUTOFF_TEST_PIN 17 // H0 +#define CUTOFF_SR_CHECK_PIN 70 // G4 (TOSC1) + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if IS_RRD_FG_SC + + #define LCD_PINS_RS 33 // C4: LCD-STROBE + #define LCD_PINS_ENABLE 72 // J2: LEFT + #define LCD_PINS_D4 35 // C2: LCD-CLK + #define LCD_PINS_D5 32 // C5: RLED + #define LCD_PINS_D6 34 // C3: LCD-DATA + #define LCD_PINS_D7 31 // C6: GLED + + #define BTN_EN2 75 // J4, UP + #define BTN_EN1 73 // J3, DOWN + //STOP button connected as KILL_PIN + #define KILL_PIN 14 // J1, RIGHT + //KILL - not connected + + #define BEEPER_PIN 8 // H5, SD_WP + + //on board leds + #define STAT_LED_RED_LED SERVO0_PIN // C1 (1280-EX1, DEBUG2) + #define STAT_LED_BLUE_PIN SERVO1_PIN // C0 (1280-EX2, DEBUG3) + + #else + // Replicator uses a 3-wire SR controller with HD44780 + #define SR_DATA_PIN 34 // C3 + #define SR_CLK_PIN 35 // C2 + #define SR_STROBE_PIN 33 // C4 + + #define BTN_UP 75 // J4 + #define BTN_DWN 73 // J3 + #define BTN_LFT 72 // J2 + #define BTN_RT 14 // J1 + + // Disable encoder + #undef BTN_EN1 + #undef BTN_EN2 + + #define BEEPER_PIN 4 // G5 + + #define STAT_LED_RED_PIN 32 // C5 + #define STAT_LED_BLUE_PIN 31 // C6 (Actually green) + + #endif + + #define BTN_CENTER 15 // J0 + #define BTN_ENC BTN_CENTER + +#endif // HAS_WIRED_LCD + +// +// SD Card +// +#define SDSS 53 // B0 +#define SD_DETECT_PIN 9 // H6 + +#if HAS_TMC_UART + /** + * TMC220x stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + #define X_HARDWARE_SERIAL Serial2 + #define Y_HARDWARE_SERIAL Serial1 + + /** + * Software serial + */ + + #define X_SERIAL_TX_PIN 16 + #define X_SERIAL_RX_PIN 17 + + #define Y_SERIAL_TX_PIN 18 + #define Y_SERIAL_RX_PIN 19 + + #define Z_SERIAL_TX_PIN 41 + #define Z_SERIAL_RX_PIN 66 + + #define E0_SERIAL_TX_PIN 40 + #define E0_SERIAL_RX_PIN 67 + + #define E1_SERIAL_TX_PIN 37 + #define E1_SERIAL_RX_PIN 68 + +#endif diff --git a/src/pins/mega/pins_MINITRONICS.h b/src/pins/mega/pins_MINITRONICS.h new file mode 100644 index 0000000..ec712a3 --- /dev/null +++ b/src/pins/mega/pins_MINITRONICS.h @@ -0,0 +1,142 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Minitronics v1.0/1.1 pin assignments + */ + +/** + * Rev B 2 JAN 2017 + * + * Added pin definitions for M3, M4 & M5 spindle control commands + */ + +#if NOT_TARGET(__AVR_ATmega1281__) + #error "Oops! Select 'Minitronics' in 'Tools > Board.'" +#elif HOTENDS > 2 || E_STEPPERS > 2 + #error "Minitronics supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Minitronics v1.0/1.1" +// +// Limit Switches +// +#define X_MIN_PIN 5 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 2 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 6 +#define Z_MAX_PIN -1 + +// +// Steppers +// +#define X_STEP_PIN 48 +#define X_DIR_PIN 47 +#define X_ENABLE_PIN 49 + +#define Y_STEP_PIN 39 // A6 +#define Y_DIR_PIN 40 // A0 +#define Y_ENABLE_PIN 38 + +#define Z_STEP_PIN 42 // A2 +#define Z_DIR_PIN 43 // A6 +#define Z_ENABLE_PIN 41 // A1 + +#define E0_STEP_PIN 45 +#define E0_DIR_PIN 44 +#define E0_ENABLE_PIN 27 + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 35 +#define E1_ENABLE_PIN 37 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 7 // Analog Input +#define TEMP_1_PIN 6 // Analog Input +#define TEMP_BED_PIN 6 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 7 // EXTRUDER 1 +#define HEATER_1_PIN 8 // EXTRUDER 2 +#define HEATER_BED_PIN 3 // BED + +#ifndef FAN_PIN + #define FAN_PIN 9 +#endif + +// +// Misc. Functions +// +#define SDSS 16 +#define LED_PIN 46 + +// +// LCD / Controller +// +#define BEEPER_PIN -1 + +#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define LCD_PINS_RS 15 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE 11 // SID (MOSI) + #define LCD_PINS_D4 10 // SCK (CLK) clock + + #define BTN_EN1 18 + #define BTN_EN2 17 + #define BTN_ENC 25 + + #define SD_DETECT_PIN 30 + +#else + + #define LCD_PINS_RS -1 + #define LCD_PINS_ENABLE -1 + + // Buttons are directly attached using keypad + #define BTN_EN1 -1 + #define BTN_EN2 -1 + #define BTN_ENC -1 + + #define SD_DETECT_PIN -1 // Minitronics doesn't use this +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER // assumes we're only doing CNC work (no 3D printing) + #undef HEATER_BED_PIN + #undef TEMP_BED_PIN // need to free up some pins but also need to + #undef TEMP_0_PIN // re-assign them (to unused pins) because Marlin + #undef TEMP_1_PIN // requires the presence of certain pins or else it + #define HEATER_BED_PIN 4 // won't compile + #define TEMP_BED_PIN 50 + #define TEMP_0_PIN 51 + #define SPINDLE_LASER_ENA_PIN 52 // using A6 because it already has a pullup + #define SPINDLE_LASER_PWM_PIN 3 // WARNING - LED & resistor pull up to +12/+24V stepper voltage + #define SPINDLE_DIR_PIN 53 +#endif diff --git a/src/pins/mega/pins_OVERLORD.h b/src/pins/mega/pins_OVERLORD.h new file mode 100644 index 0000000..f1062b4 --- /dev/null +++ b/src/pins/mega/pins_OVERLORD.h @@ -0,0 +1,144 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Dreammaker Overlord v1.1 pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Overlord supports up to 2 hotends / E steppers." +#endif + +#include "env_validate.h" + +#define BOARD_INFO_NAME "OVERLORD" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Limit Switches +// +#define X_STOP_PIN 24 +#define Y_STOP_PIN 28 +#define Z_MIN_PIN 46 +#define Z_MAX_PIN 32 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 46 // JP4, Tfeed1 +#endif + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 44 // JP3, Tfeed2 +#endif + +// +// Steppers +// +#define X_STEP_PIN 25 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 27 + +#define Y_STEP_PIN 31 +#define Y_DIR_PIN 33 +#define Y_ENABLE_PIN 29 + +#define Z_STEP_PIN 37 +#define Z_DIR_PIN 39 +#define Z_ENABLE_PIN 35 + +#define E0_STEP_PIN 43 +#define E0_DIR_PIN 45 +#define E0_ENABLE_PIN 41 + +#define E1_STEP_PIN 49 +#define E1_DIR_PIN 47 +#define E1_ENABLE_PIN 48 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 8 // Analog Input +#define TEMP_1_PIN 9 // Analog Input - Redundant temp sensor +#define TEMP_2_PIN 12 // Analog Input +#define TEMP_3_PIN 14 // Analog Input +#define TEMP_BED_PIN 10 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define HEATER_1_PIN 3 +#define HEATER_BED_PIN 4 + +#define FAN_PIN 7 // material cooling fan + +// +// SD Card +// +#define SDSS 53 +#define SD_DETECT_PIN 38 + +// +// Misc. Functions +// +#define LED_PIN 13 // On PCB status led +#define PS_ON_PIN 12 // For stepper/heater/fan power. Active HIGH. +#define POWER_LOSS_PIN 34 // Power check - whether hotends/steppers/fans have power + +#if ENABLED(BATTERY_STATUS_AVAILABLE) + #undef BATTERY_STATUS_PIN + #define BATTERY_STATUS_PIN 26 // Status of power loss battery, whether it is charged (low) or charging (high) +#endif +#if ENABLED(INPUT_VOLTAGE_AVAILABLE) + #undef VOLTAGE_DETECTION_PIN + #define VOLTAGE_DETECTION_PIN 11 // Analog Input - ADC Voltage level of main input +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + // OVERLORD OLED pins + #define LCD_PINS_RS 20 + #define LCD_PINS_D5 21 + #define LCD_PINS_ENABLE 15 + #define LCD_PINS_D4 14 + #define LCD_PINS_D6 5 + #define LCD_PINS_D7 6 + #ifndef LCD_RESET_PIN + #define LCD_RESET_PIN 5 // LCD_PINS_D6 + #endif +#endif + +#if IS_NEWPANEL + #define BTN_ENC 16 // Enter Pin + #define BTN_UP 19 // Button UP Pin + #define BTN_DWN 17 // Button DOWN Pin +#endif + +// Additional connectors/pins on the Overlord V1.X board +#define PCB_VERSION_PIN 22 +#define APPROACH_PIN 11 // JP7, Tpd +#define GATE_PIN 36 // Threshold, JP6, Tg diff --git a/src/pins/mega/pins_PICA.h b/src/pins/mega/pins_PICA.h new file mode 100644 index 0000000..0e29d8d --- /dev/null +++ b/src/pins/mega/pins_PICA.h @@ -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 . + * + */ +#pragma once + +/** + * Arduino Mega with PICA pin assignments + * + * PICA is Power, Interface, and Control Adapter and is open source hardware. + * See https://github.com/mjrice/PICA for schematics etc. + * + * Applies to PICA, PICA_REVB + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "PICA" +#endif + +/* +// Note that these are the "pins" that correspond to the analog inputs on the arduino mega. +// These are not the same as the physical pin numbers + AD0 = 54; AD1 = 55; AD2 = 56; AD3 = 57; + AD4 = 58; AD5 = 59; AD6 = 60; AD7 = 61; + AD8 = 62; AD9 = 63; AD10 = 64; AD11 = 65; + AD12 = 66; AD13 = 67; AD14 = 68; AD15 = 69; +*/ + +// +// Servos +// +#define SERVO0_PIN 3 +#define SERVO1_PIN 4 +#define SERVO2_PIN 5 + +// +// Limit Switches +// +#define X_MIN_PIN 14 +#define X_MAX_PIN 15 +#define Y_MIN_PIN 16 +#define Y_MAX_PIN 17 +#define Z_MIN_PIN 23 +#define Z_MAX_PIN 22 + +// +// Steppers +// +#define X_STEP_PIN 55 +#define X_DIR_PIN 54 +#define X_ENABLE_PIN 60 + +#define Y_STEP_PIN 57 +#define Y_DIR_PIN 56 +#define Y_ENABLE_PIN 61 + +#define Z_STEP_PIN 59 +#define Z_DIR_PIN 58 +#define Z_ENABLE_PIN 62 + +#define E0_STEP_PIN 67 +#define E0_DIR_PIN 24 +#define E0_ENABLE_PIN 26 + +#define E1_STEP_PIN 68 +#define E1_DIR_PIN 28 +#define E1_ENABLE_PIN 27 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 9 // Analog Input +#define TEMP_1_PIN 10 +#define TEMP_BED_PIN 10 +#define TEMP_2_PIN 11 +#define TEMP_3_PIN 12 + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN 10 // E0 +#endif +#ifndef HEATER_1_PIN + #define HEATER_1_PIN 2 // E1 +#endif +#define HEATER_BED_PIN 8 // HEAT-BED + +#ifndef FAN_PIN + #define FAN_PIN 9 +#endif +#ifndef FAN_2_PIN + #define FAN_2_PIN 7 +#endif + +#define SDPOWER_PIN -1 +#define LED_PIN -1 +#define PS_ON_PIN -1 +#define KILL_PIN -1 + +#define SSR_PIN 6 + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card +#else + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) +#endif + +// +// SD Support +// +#define SD_DETECT_PIN 49 +#define SDSS 53 + +// +// LCD / Controller +// +#define BEEPER_PIN 29 + +#if HAS_WIRED_LCD + #define LCD_PINS_RS 33 + #define LCD_PINS_ENABLE 30 + #define LCD_PINS_D4 35 + #define LCD_PINS_D5 32 + #define LCD_PINS_D6 37 + #define LCD_PINS_D7 36 + + #define BTN_EN1 47 + #define BTN_EN2 48 + #define BTN_ENC 31 + + #define LCD_SDSS 53 +#endif diff --git a/src/pins/mega/pins_PICAOLD.h b/src/pins/mega/pins_PICAOLD.h new file mode 100644 index 0000000..e19ea74 --- /dev/null +++ b/src/pins/mega/pins_PICAOLD.h @@ -0,0 +1,29 @@ +/** + * 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 . + * + */ +#pragma once + +#define HEATER_0_PIN 9 // E0 +#define HEATER_1_PIN 10 // E1 +#define FAN_PIN 11 +#define FAN2_PIN 12 + +#include "pins_PICA.h" diff --git a/src/pins/mega/pins_PROTONEER_CNC_SHIELD_V3.h b/src/pins/mega/pins_PROTONEER_CNC_SHIELD_V3.h new file mode 100644 index 0000000..f2e4d3d --- /dev/null +++ b/src/pins/mega/pins_PROTONEER_CNC_SHIELD_V3.h @@ -0,0 +1,77 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Protoneer v3.00 pin assignments + * + * This CNC shield has an UNO pinout and fits all Arduino-compatibles. + * + * Referenced docs: + * - https://blog.protoneer.co.nz/arduino-cnc-shield-v3-00-assembly-guide/ + * - https://blog.protoneer.co.nz/arduino-cnc-shield/ + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Protoneer CNC Shield v3.00" + +// +// Limit Switches +// +#define X_STOP_PIN 9 +#define Y_STOP_PIN 10 +#define Z_STOP_PIN 11 + +// +// Steppers +// +#define X_STEP_PIN 2 +#define X_DIR_PIN 5 +#define X_ENABLE_PIN 8 // Shared enable pin + +#define Y_STEP_PIN 3 +#define Y_DIR_PIN 6 +#define Y_ENABLE_PIN X_ENABLE_PIN + +#define Z_STEP_PIN 4 +#define Z_DIR_PIN 7 +#define Z_ENABLE_PIN X_ENABLE_PIN + +// Designated with letter "A" on BOARD +#define E0_STEP_PIN 12 +#define E0_DIR_PIN 13 +#define E0_ENABLE_PIN X_ENABLE_PIN + +// +// Temperature sensors - These could be any analog output not hidden by board +// +#define TEMP_0_PIN 8 // Analog Input +//#define TEMP_1_PIN 9 // Analog Input +//#define TEMP_BED_PIN 10 // Analog Input + +// +// Heaters / Fans - These could be any digital input not hidden by board +// +//#define HEATER_0_PIN 22 // EXTRUDER 1 +//#define HEATER_1_PIN 23 // EXTRUDER 2 +//#define HEATER_BED_PIN 24 diff --git a/src/pins/mega/pins_SILVER_GATE.h b/src/pins/mega/pins_SILVER_GATE.h new file mode 100644 index 0000000..c2ca5b3 --- /dev/null +++ b/src/pins/mega/pins_SILVER_GATE.h @@ -0,0 +1,102 @@ +/** + * 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 . + * + */ +#pragma once + +#if NOT_TARGET(__AVR_ATmega1281__, __AVR_ATmega2561__) + #error "Oops! Select 'Silvergate' in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "Silver Gate" + +#define X_STEP_PIN 43 +#define X_DIR_PIN 44 +#define X_ENABLE_PIN 42 +#define X_MIN_PIN 31 +#define X_MAX_PIN 34 + +#define Y_STEP_PIN 40 +#define Y_DIR_PIN 41 +#define Y_ENABLE_PIN 39 +#define Y_MIN_PIN 32 +#define Y_MAX_PIN 35 + +#define Z_STEP_PIN 13 +#define Z_DIR_PIN 38 +#define Z_ENABLE_PIN 14 +#define Z_MIN_PIN 33 +#define Z_MAX_PIN 36 + +#define E0_STEP_PIN 27 +#define E0_DIR_PIN 37 +#define E0_ENABLE_PIN 45 + +#define SDSS 16 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 34 // X_MAX unless overridden +#endif + +#ifndef FAN_PIN + #define FAN_PIN 5 +#endif + +#define HEATER_0_PIN 7 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN 3 +#endif + +#define CONTROLLER_FAN_PIN 2 + +#define TEMP_0_PIN 7 // Analog Input + +#define HEATER_BED_PIN 8 +#define TEMP_BED_PIN 6 + +#if HAS_WIRED_LCD + #if IS_U8GLIB_ST7920 // SPI GLCD 12864 ST7920 + #define LCD_PINS_RS 30 + #define LCD_PINS_ENABLE 20 + #define LCD_PINS_D4 25 + #define BEEPER_PIN 29 + #define BTN_EN1 19 + #define BTN_EN2 22 + #define BTN_ENC 24 + #define LCD_BACKLIGHT_PIN 6 + #if ENABLED(SILVER_GATE_GLCD_CONTROLLER) + #define KILL_PIN 21 + #define HOME_PIN 28 + #endif + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 250 + #define BOARD_ST7920_DELAY_3 0 + #endif +#endif + +#define SD_DETECT_PIN 15 + +#define STAT_LED_RED_PIN 23 +#define STAT_LED_BLUE_PIN 26 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 51 +#endif diff --git a/src/pins/mega/pins_WANHAO_ONEPLUS.h b/src/pins/mega/pins_WANHAO_ONEPLUS.h new file mode 100644 index 0000000..503dd9e --- /dev/null +++ b/src/pins/mega/pins_WANHAO_ONEPLUS.h @@ -0,0 +1,109 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Wanhao 0ne+ pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Wanhao i3 Mini 0ne+" +#define DEFAULT_MACHINE_NAME "i3 Mini" +#define BOARD_WEBSITE_URL "tinyurl.com/yyxw7se7" + +// +// Limit Switches +// +#define X_STOP_PIN 19 +#define Y_STOP_PIN 18 +#define Z_STOP_PIN 38 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 38 +#endif + +// +// Steppers +// +#define X_STEP_PIN 22 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 57 + +#define Y_STEP_PIN 25 +#define Y_DIR_PIN 26 +#define Y_ENABLE_PIN 24 + +#define Z_STEP_PIN 29 +#define Z_DIR_PIN 39 +#define Z_ENABLE_PIN 28 + +#define E0_STEP_PIN 55 +#define E0_DIR_PIN 56 +#define E0_ENABLE_PIN 54 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 +#define TEMP_BED_PIN 14 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 4 +#define HEATER_BED_PIN 44 +#define FAN_PIN 12 // IO pin. Buffer needed + +// +// SD Card +// +#define SD_DETECT_PIN 83 +#define SDSS 53 + +// +// Misc. Functions +// +#define BEEPER_PIN 37 +#define KILL_PIN 64 + +// +// LCD / Controller (Integrated MINIPANEL) +// +#if ENABLED(MINIPANEL) + #define DOGLCD_A0 40 + #define DOGLCD_CS 41 + #define LCD_BACKLIGHT_PIN 65 // Backlight LED on A11/D65 + #define LCD_RESET_PIN 27 + + #define BTN_EN1 2 + #define BTN_EN2 3 + #define BTN_ENC 5 + + // This display has adjustable contrast + #define LCD_CONTRAST_MIN 0 + #define LCD_CONTRAST_MAX 255 + #define LCD_CONTRAST_INIT LCD_CONTRAST_MAX +#endif diff --git a/src/pins/mega/pins_WEEDO_62A.h b/src/pins/mega/pins_WEEDO_62A.h new file mode 100644 index 0000000..4b3bf6a --- /dev/null +++ b/src/pins/mega/pins_WEEDO_62A.h @@ -0,0 +1,106 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Based on WEEDO 62A pin configuration + * Copyright (c) 2019 WEEDO3D Perron + */ + +#pragma once + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "WEEDO 62A" +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 40 +#define Y_MAX_PIN 41 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Steppers +// +#define X_STEP_PIN 26 +#define X_DIR_PIN 28 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 + +#define E0_STEP_PIN 54 +#define E0_DIR_PIN 55 +#define E0_ENABLE_PIN 38 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // ANALOG NUMBERING +#define TEMP_BED_PIN 14 // ANALOG NUMBERING + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 // EXTRUDER 1 +#define HEATER_BED_PIN 8 // BED +#define FAN_PIN 4 // IO pin. Buffer needed + +// +// Misc. Functions +// +#define PS_ON_PIN 12 +#define LED_PIN 13 + +// +// SD Support +// +#if ENABLED(SDSUPPORT) + #define SDSS 53 + #define SD_DETECT_PIN 49 +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BEEPER_PIN 37 + + #define DOGLCD_A0 27 + #define DOGLCD_CS 29 + #define LCD_RESET_PIN 25 + #define LCD_CONTRAST_INIT 255 + + #define BTN_EN1 33 + #define BTN_EN2 31 + #define BTN_ENC 35 +#endif diff --git a/src/pins/pins.h b/src/pins/pins.h new file mode 100644 index 0000000..38e73ad --- /dev/null +++ b/src/pins/pins.h @@ -0,0 +1,903 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * File: pins/pins.h + * + * Include pins definitions + * + * Pins numbering schemes: + * + * - Digital I/O pin number if used by READ/WRITE macros. (e.g., X_STEP_DIR) + * The FastIO headers map digital pins to their ports and functions. + * + * - Analog Input number if used by analogRead or DAC. (e.g., TEMP_n_PIN) + * These numbers are the same in any pin mapping. + */ + +#define MAX_E_STEPPERS 8 + +#if NONE(FET_ORDER_EEF, FET_ORDER_EEB, FET_ORDER_EFF, FET_ORDER_EFB, FET_ORDER_SF) + #if MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB) + #define FET_ORDER_EFB 1 + #elif MB(RAMPS_13_EEB, RAMPS_14_EEB, RAMPS_PLUS_EEB, RAMPS_14_RE_ARM_EEB, RAMPS_SMART_EEB, RAMPS_DUO_EEB, RAMPS4DUE_EEB) + #define FET_ORDER_EEB 1 + #elif MB(RAMPS_13_EFF, RAMPS_14_EFF, RAMPS_PLUS_EFF, RAMPS_14_RE_ARM_EFF, RAMPS_SMART_EFF, RAMPS_DUO_EFF, RAMPS4DUE_EFF) + #define FET_ORDER_EFF 1 + #elif MB(RAMPS_13_EEF, RAMPS_14_EEF, RAMPS_PLUS_EEF, RAMPS_14_RE_ARM_EEF, RAMPS_SMART_EEF, RAMPS_DUO_EEF, RAMPS4DUE_EEF) + #define FET_ORDER_EEF 1 + #elif MB(RAMPS_13_SF, RAMPS_14_SF, RAMPS_PLUS_SF, RAMPS_14_RE_ARM_SF, RAMPS_SMART_SF, RAMPS_DUO_SF, RAMPS4DUE_SF) + #define FET_ORDER_SF 1 + #elif HAS_MULTI_HOTEND || (HAS_EXTRUDERS && HAS_CUTTER) + #if TEMP_SENSOR_BED + #define FET_ORDER_EEB 1 + #else + #define FET_ORDER_EEF 1 + #endif + #elif TEMP_SENSOR_BED + #define FET_ORDER_EFB 1 + #else + #define FET_ORDER_EFF 1 + #endif +#endif + +#if !(BOTH(HAS_WIRED_LCD, IS_NEWPANEL) && ANY(PANEL_ONE, VIKI2, miniVIKI, WYH_L12864, MINIPANEL, REPRAPWORLD_KEYPAD)) + #define HAS_FREE_AUX2_PINS 1 +#endif + +// Test the target within the included pins file +#ifdef __MARLIN_DEPS__ + #define NOT_TARGET(V...) 0 +#else + #define NOT_TARGET(V...) NONE(V) +#endif + +// +// RAMPS 1.3 / 1.4 - ATmega1280, ATmega2560 +// + +#if MB(RAMPS_OLD) + #include "ramps/pins_RAMPS_OLD.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(RAMPS_13_EFB, RAMPS_13_EEB, RAMPS_13_EFF, RAMPS_13_EEF, RAMPS_13_SF) + #include "ramps/pins_RAMPS_13.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(RAMPS_14_EFB, RAMPS_14_EEB, RAMPS_14_EFF, RAMPS_14_EEF, RAMPS_14_SF) + #include "ramps/pins_RAMPS.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(RAMPS_PLUS_EFB, RAMPS_PLUS_EEB, RAMPS_PLUS_EFF, RAMPS_PLUS_EEF, RAMPS_PLUS_SF) + #include "ramps/pins_RAMPS_PLUS.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 + +// +// RAMPS Derivatives - ATmega1280, ATmega2560 +// + +#elif MB(3DRAG) + #include "ramps/pins_3DRAG.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(K8200) + #include "ramps/pins_K8200.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(K8400) + #include "ramps/pins_K8400.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(K8600) + #include "ramps/pins_K8600.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(K8800) + #include "ramps/pins_K8800.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(BAM_DICE) + #include "ramps/pins_RAMPS.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(BAM_DICE_DUE) + #include "ramps/pins_BAM_DICE_DUE.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(MKS_BASE) + #include "ramps/pins_MKS_BASE_10.h" // ATmega2560 env:mega2560 +#elif MB(MKS_BASE_14) + #include "ramps/pins_MKS_BASE_14.h" // ATmega2560 env:mega2560 +#elif MB(MKS_BASE_15) + #include "ramps/pins_MKS_BASE_15.h" // ATmega2560 env:mega2560 +#elif MB(MKS_BASE_16) + #include "ramps/pins_MKS_BASE_16.h" // ATmega2560 env:mega2560 +#elif MB(MKS_BASE_HEROIC) + #include "ramps/pins_MKS_BASE_HEROIC.h" // ATmega2560 env:mega2560 +#elif MB(MKS_GEN_13) + #include "ramps/pins_MKS_GEN_13.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(MKS_GEN_L) + #include "ramps/pins_MKS_GEN_L.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(KFB_2) + #include "ramps/pins_BIQU_KFB_2.h" // ATmega2560 env:mega2560 +#elif MB(ZRIB_V20) + #include "ramps/pins_ZRIB_V20.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(ZRIB_V52) + #include "ramps/pins_ZRIB_V52.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(ZRIB_V53) + #include "ramps/pins_ZRIB_V53.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(FELIX2) + #include "ramps/pins_FELIX2.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(RIGIDBOARD) + #include "ramps/pins_RIGIDBOARD.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(RIGIDBOARD_V2) + #include "ramps/pins_RIGIDBOARD_V2.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(SAINSMART_2IN1) + #include "ramps/pins_SAINSMART_2IN1.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(ULTIMAKER) + #include "ramps/pins_ULTIMAKER.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(ULTIMAKER_OLD) + #include "ramps/pins_ULTIMAKER_OLD.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(AZTEEG_X3) + #include "ramps/pins_AZTEEG_X3.h" // ATmega2560 env:mega2560 +#elif MB(AZTEEG_X3_PRO) + #include "ramps/pins_AZTEEG_X3_PRO.h" // ATmega2560 env:mega2560 +#elif MB(ULTIMAIN_2) + #include "ramps/pins_ULTIMAIN_2.h" // ATmega2560 env:mega2560ext +#elif MB(FORMBOT_RAPTOR) + #include "ramps/pins_FORMBOT_RAPTOR.h" // ATmega2560 env:mega2560 +#elif MB(FORMBOT_RAPTOR2) + #include "ramps/pins_FORMBOT_RAPTOR2.h" // ATmega2560 env:mega2560 +#elif MB(FORMBOT_TREX2PLUS) + #include "ramps/pins_FORMBOT_TREX2PLUS.h" // ATmega2560 env:mega2560 +#elif MB(FORMBOT_TREX3) + #include "ramps/pins_FORMBOT_TREX3.h" // ATmega2560 env:mega2560 +#elif MB(RUMBA) + #include "ramps/pins_RUMBA.h" // ATmega2560 env:mega2560 +#elif MB(RUMBA_RAISE3D) + #include "ramps/pins_RUMBA_RAISE3D.h" // ATmega2560 env:mega2560 +#elif MB(RL200) + #include "ramps/pins_RL200.h" // ATmega2560 env:mega2560 +#elif MB(BQ_ZUM_MEGA_3D) + #include "ramps/pins_BQ_ZUM_MEGA_3D.h" // ATmega2560 env:mega2560ext +#elif MB(MAKEBOARD_MINI) + #include "ramps/pins_MAKEBOARD_MINI.h" // ATmega2560 env:mega2560 +#elif MB(TRIGORILLA_13) + #include "ramps/pins_TRIGORILLA_13.h" // ATmega2560 env:mega2560 +#elif MB(TRIGORILLA_14, TRIGORILLA_14_11) + #include "ramps/pins_TRIGORILLA_14.h" // ATmega2560 env:mega2560 +#elif MB(RAMPS_ENDER_4) + #include "ramps/pins_RAMPS_ENDER_4.h" // ATmega2560 env:mega2560 +#elif MB(RAMPS_CREALITY) + #include "ramps/pins_RAMPS_CREALITY.h" // ATmega2560 env:mega2560 +#elif MB(DAGOMA_F5) + #include "ramps/pins_DAGOMA_F5.h" // ATmega2560 env:mega2560 +#elif MB(FYSETC_F6_13) + #include "ramps/pins_FYSETC_F6_13.h" // ATmega2560 env:FYSETC_F6 +#elif MB(FYSETC_F6_14) + #include "ramps/pins_FYSETC_F6_14.h" // ATmega2560 env:FYSETC_F6 +#elif MB(DUPLICATOR_I3_PLUS) + #include "ramps/pins_DUPLICATOR_I3_PLUS.h" // ATmega2560 env:mega2560 +#elif MB(VORON) + #include "ramps/pins_VORON.h" // ATmega2560 env:mega2560 +#elif MB(TRONXY_V3_1_0) + #include "ramps/pins_TRONXY_V3_1_0.h" // ATmega2560 env:mega2560 +#elif MB(Z_BOLT_X_SERIES) + #include "ramps/pins_Z_BOLT_X_SERIES.h" // ATmega2560 env:mega2560 +#elif MB(TT_OSCAR) + #include "ramps/pins_TT_OSCAR.h" // ATmega2560 env:mega2560 +#elif MB(TANGO) + #include "ramps/pins_TANGO.h" // ATmega2560 env:mega2560 +#elif MB(MKS_GEN_L_V2) + #include "ramps/pins_MKS_GEN_L_V2.h" // ATmega2560 env:mega2560 +#elif MB(COPYMASTER_3D) + #include "ramps/pins_COPYMASTER_3D.h" // ATmega2560 env:mega2560 +#elif MB(ORTUR_4) + #include "ramps/pins_ORTUR_4.h" // ATmega2560 env:mega2560 +#elif MB(TENLOG_D3_HERO) + #include "ramps/pins_TENLOG_D3_HERO.h" // ATmega2560 env:mega2560 +#elif MB(MKS_GEN_L_V21) + #include "ramps/pins_MKS_GEN_L_V21.h" // ATmega2560 env:mega2560 +#elif MB(RAMPS_S_12_EEFB, RAMPS_S_12_EEEB, RAMPS_S_12_EFFB) + #include "ramps/pins_RAMPS_S_12.h" // ATmega2560 env:mega2560 +#elif MB(LONGER3D_LK1_PRO, LONGER3D_LKx_PRO) + #include "ramps/pins_LONGER3D_LKx_PRO.h" // ATmega2560 env:mega2560 +#elif MB(PXMALION_CORE_I3) + #include "ramps/pins_PXMALION_CORE_I3.h" // ATmega2560 env:mega2560 + +// +// RAMBo and derivatives +// + +#elif MB(RAMBO) + #include "rambo/pins_RAMBO.h" // ATmega2560 env:rambo +#elif MB(MINIRAMBO, MINIRAMBO_10A) + #include "rambo/pins_MINIRAMBO.h" // ATmega2560 env:rambo +#elif MB(EINSY_RAMBO) + #include "rambo/pins_EINSY_RAMBO.h" // ATmega2560 env:rambo +#elif MB(EINSY_RETRO) + #include "rambo/pins_EINSY_RETRO.h" // ATmega2560 env:rambo +#elif MB(SCOOVO_X9H) + #include "rambo/pins_SCOOVO_X9H.h" // ATmega2560 env:rambo +#elif MB(RAMBO_THINKERV2) + #include "rambo/pins_RAMBO_THINKERV2.h" // ATmega2560 env:rambo + +// +// Other ATmega1280, ATmega2560 +// + +#elif MB(CNCONTROLS_11) + #include "mega/pins_CNCONTROLS_11.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(CNCONTROLS_12) + #include "mega/pins_CNCONTROLS_12.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(CNCONTROLS_15) + #include "mega/pins_CNCONTROLS_15.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(MIGHTYBOARD_REVE) + #include "mega/pins_MIGHTYBOARD_REVE.h" // ATmega2560, ATmega1280 env:mega2560ext env:mega1280 env:MightyBoard1280 env:MightyBoard2560 +#elif MB(CHEAPTRONIC) + #include "mega/pins_CHEAPTRONIC.h" // ATmega2560 env:mega2560 +#elif MB(CHEAPTRONIC_V2) + #include "mega/pins_CHEAPTRONICv2.h" // ATmega2560 env:mega2560 +#elif MB(MEGATRONICS) + #include "mega/pins_MEGATRONICS.h" // ATmega2560 env:mega2560 +#elif MB(MEGATRONICS_2) + #include "mega/pins_MEGATRONICS_2.h" // ATmega2560 env:mega2560 +#elif MB(MEGATRONICS_3, MEGATRONICS_31, MEGATRONICS_32) + #include "mega/pins_MEGATRONICS_3.h" // ATmega2560 env:mega2560 +#elif MB(ELEFU_3) + #include "mega/pins_ELEFU_3.h" // ATmega2560 env:mega2560 +#elif MB(LEAPFROG) + #include "mega/pins_LEAPFROG.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(MEGACONTROLLER) + #include "mega/pins_MEGACONTROLLER.h" // ATmega2560 env:mega2560 +#elif MB(GT2560_REV_A) + #include "mega/pins_GT2560_REV_A.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(GT2560_REV_A_PLUS) + #include "mega/pins_GT2560_REV_A_PLUS.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(GT2560_V3) + #include "mega/pins_GT2560_V3.h" // ATmega2560 env:mega2560 +#elif MB(GT2560_REV_B) + #include "mega/pins_GT2560_REV_B.h" // ATmega2560 env:mega2560 +#elif MB(GT2560_V4) + #include "mega/pins_GT2560_V4.h" // ATmega2560 env:mega2560 + #elif MB(GT2560_V4_A20) + #include "mega/pins_GT2560_V4_A20.h" // ATmega2560 env:mega2560 +#elif MB(GT2560_V3_MC2) + #include "mega/pins_GT2560_V3_MC2.h" // ATmega2560 env:mega2560 +#elif MB(GT2560_V3_A20) + #include "mega/pins_GT2560_V3_A20.h" // ATmega2560 env:mega2560 +#elif MB(EINSTART_S) + #include "mega/pins_EINSTART-S.h" // ATmega2560, ATmega1280 env:mega2560ext env:mega1280 +#elif MB(WANHAO_ONEPLUS) + #include "mega/pins_WANHAO_ONEPLUS.h" // ATmega2560 env:mega2560 +#elif MB(OVERLORD) + #include "mega/pins_OVERLORD.h" // ATmega2560 env:mega2560 +#elif MB(HJC2560C_REV1) + #include "mega/pins_HJC2560C_REV2.h" // ATmega2560 env:mega2560 +#elif MB(HJC2560C_REV2) + #include "mega/pins_HJC2560C_REV2.h" // ATmega2560 env:mega2560 +#elif MB(LEAPFROG_XEED2015) + #include "mega/pins_LEAPFROG_XEED2015.h" // ATmega2560 env:mega2560 +#elif MB(PICA) + #include "mega/pins_PICA.h" // ATmega2560 env:mega2560 +#elif MB(PICA_REVB) + #include "mega/pins_PICAOLD.h" // ATmega2560 env:mega2560 +#elif MB(INTAMSYS40) + #include "mega/pins_INTAMSYS40.h" // ATmega2560 env:mega2560 +#elif MB(MALYAN_M180) + #include "mega/pins_MALYAN_M180.h" // ATmega2560 env:mega2560 +#elif MB(PROTONEER_CNC_SHIELD_V3) + #include "mega/pins_PROTONEER_CNC_SHIELD_V3.h"// ATmega2560 env:mega2560 +#elif MB(WEEDO_62A) + #include "mega/pins_WEEDO_62A.h" // ATmega2560 env:mega2560 + +// +// ATmega1281, ATmega2561 +// + +#elif MB(MINITRONICS) + #include "mega/pins_MINITRONICS.h" // ATmega1281 env:mega1280 +#elif MB(SILVER_GATE) + #include "mega/pins_SILVER_GATE.h" // ATmega2561 env:mega2560 + +// +// Sanguinololu and Derivatives - ATmega644P, ATmega1284P +// + +#elif MB(SANGUINOLOLU_11) + #include "sanguino/pins_SANGUINOLOLU_11.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(SANGUINOLOLU_12) + #include "sanguino/pins_SANGUINOLOLU_12.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(MELZI) + #include "sanguino/pins_MELZI.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(MELZI_V2) + #include "sanguino/pins_MELZI_V2.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(MELZI_MAKR3D) + #include "sanguino/pins_MELZI_MAKR3D.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(MELZI_CREALITY) + #include "sanguino/pins_MELZI_CREALITY.h" // ATmega1284P env:melzi_optiboot_optimized env:melzi_optiboot env:melzi_optimized env:melzi +#elif MB(MELZI_MALYAN) + #include "sanguino/pins_MELZI_MALYAN.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(MELZI_TRONXY) + #include "sanguino/pins_MELZI_TRONXY.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(STB_11) + #include "sanguino/pins_STB_11.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(AZTEEG_X1) + #include "sanguino/pins_AZTEEG_X1.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(ZMIB_V2) + #include "sanguino/pins_ZMIB_V2.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p + +// +// Other ATmega644P, ATmega644, ATmega1284P +// + +#elif MB(GEN3_MONOLITHIC) + #include "sanguino/pins_GEN3_MONOLITHIC.h" // ATmega644P env:sanguino644p +#elif MB(GEN3_PLUS) + #include "sanguino/pins_GEN3_PLUS.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(GEN6) + #include "sanguino/pins_GEN6.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(GEN6_DELUXE) + #include "sanguino/pins_GEN6_DELUXE.h" // ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(GEN7_CUSTOM) + #include "sanguino/pins_GEN7_CUSTOM.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(GEN7_12) + #include "sanguino/pins_GEN7_12.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(GEN7_13) + #include "sanguino/pins_GEN7_13.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(GEN7_14) + #include "sanguino/pins_GEN7_14.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p +#elif MB(OMCA_A) + #include "sanguino/pins_OMCA_A.h" // ATmega644 env:sanguino644p +#elif MB(OMCA) + #include "sanguino/pins_OMCA.h" // ATmega644P, ATmega644 env:sanguino644p +#elif MB(ANET_10) + #include "sanguino/pins_ANET_10.h" // ATmega1284P env:sanguino1284p env:sanguino1284p_optimized env:melzi_optiboot +#elif MB(SETHI) + #include "sanguino/pins_SETHI.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p + +// +// Teensyduino - AT90USB1286, AT90USB1286P +// + +#elif MB(TEENSYLU) + #include "teensy2/pins_TEENSYLU.h" // AT90USB1286, AT90USB1286P env:at90usb1286_cdc +#elif MB(PRINTRBOARD) + #include "teensy2/pins_PRINTRBOARD.h" // AT90USB1286 env:at90usb1286_dfu +#elif MB(PRINTRBOARD_REVF) + #include "teensy2/pins_PRINTRBOARD_REVF.h" // AT90USB1286 env:at90usb1286_dfu +#elif MB(BRAINWAVE) + #include "teensy2/pins_BRAINWAVE.h" // AT90USB646 env:at90usb1286_cdc +#elif MB(BRAINWAVE_PRO) + #include "teensy2/pins_BRAINWAVE_PRO.h" // AT90USB1286 env:at90usb1286_cdc +#elif MB(SAV_MKI) + #include "teensy2/pins_SAV_MKI.h" // AT90USB1286 env:at90usb1286_cdc +#elif MB(TEENSY2) + #include "teensy2/pins_TEENSY2.h" // AT90USB1286 env:teensy20 +#elif MB(5DPRINT) + #include "teensy2/pins_5DPRINT.h" // AT90USB1286 env:at90usb1286_dfu + +// +// LPC1768 ARM Cortex M3 +// + +#elif MB(RAMPS_14_RE_ARM_EFB, RAMPS_14_RE_ARM_EEB, RAMPS_14_RE_ARM_EFF, RAMPS_14_RE_ARM_EEF, RAMPS_14_RE_ARM_SF) + #include "lpc1768/pins_RAMPS_RE_ARM.h" // LPC1768 env:LPC1768 +#elif MB(MKS_SBASE) + #include "lpc1768/pins_MKS_SBASE.h" // LPC1768 env:LPC1768 +#elif MB(MKS_SGEN_L) + #include "lpc1768/pins_MKS_SGEN_L.h" // LPC1768 env:LPC1768 +#elif MB(AZSMZ_MINI) + #include "lpc1768/pins_AZSMZ_MINI.h" // LPC1768 env:LPC1768 +#elif MB(BIQU_BQ111_A4) + #include "lpc1768/pins_BIQU_BQ111_A4.h" // LPC1768 env:LPC1768 +#elif MB(SELENA_COMPACT) + #include "lpc1768/pins_SELENA_COMPACT.h" // LPC1768 env:LPC1768 +#elif MB(BIQU_B300_V1_0) + #include "lpc1768/pins_BIQU_B300_V1.0.h" // LPC1768 env:LPC1768 +#elif MB(GMARSH_X6_REV1) + #include "lpc1768/pins_GMARSH_X6_REV1.h" // LPC1768 env:LPC1768 +#elif MB(BTT_SKR_V1_1) + #include "lpc1768/pins_BTT_SKR_V1_1.h" // LPC1768 env:LPC1768 +#elif MB(BTT_SKR_V1_3) + #include "lpc1768/pins_BTT_SKR_V1_3.h" // LPC1768 env:LPC1768 +#elif MB(BTT_SKR_V1_4) + #include "lpc1768/pins_BTT_SKR_V1_4.h" // LPC1768 env:LPC1768 +#elif MB(EMOTRONIC) + #include "lpc1768/pins_EMOTRONIC.h" // LPC1768 env:LPC1768 + +// +// LPC1769 ARM Cortex M3 +// + +#elif MB(MKS_SGEN) + #include "lpc1769/pins_MKS_SGEN.h" // LPC1769 env:LPC1769 +#elif MB(AZTEEG_X5_GT) + #include "lpc1769/pins_AZTEEG_X5_GT.h" // LPC1769 env:LPC1769 +#elif MB(AZTEEG_X5_MINI) + #include "lpc1769/pins_AZTEEG_X5_MINI.h" // LPC1769 env:LPC1769 +#elif MB(AZTEEG_X5_MINI_WIFI) + #include "lpc1769/pins_AZTEEG_X5_MINI_WIFI.h" // LPC1769 env:LPC1769 +#elif MB(COHESION3D_REMIX) + #include "lpc1769/pins_COHESION3D_REMIX.h" // LPC1769 env:LPC1769 +#elif MB(COHESION3D_MINI) + #include "lpc1769/pins_COHESION3D_MINI.h" // LPC1769 env:LPC1769 +#elif MB(SMOOTHIEBOARD) + #include "lpc1769/pins_SMOOTHIEBOARD.h" // LPC1769 env:LPC1769 +#elif MB(TH3D_EZBOARD) + #include "lpc1769/pins_TH3D_EZBOARD.h" // LPC1769 env:LPC1769 +#elif MB(BTT_SKR_V1_4_TURBO) + #include "lpc1769/pins_BTT_SKR_V1_4_TURBO.h" // LPC1769 env:LPC1769 +#elif MB(MKS_SGEN_L_V2) + #include "lpc1769/pins_MKS_SGEN_L_V2.h" // LPC1769 env:LPC1769 +#elif MB(BTT_SKR_E3_TURBO) + #include "lpc1769/pins_BTT_SKR_E3_TURBO.h" // LPC1769 env:LPC1769 +#elif MB(FLY_CDY) + #include "lpc1769/pins_FLY_CDY.h" // LPC1769 env:LPC1769 + +// +// Due (ATSAM) boards +// + +#elif MB(DUE3DOM) + #include "sam/pins_DUE3DOM.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(DUE3DOM_MINI) + #include "sam/pins_DUE3DOM_MINI.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(RADDS) + #include "sam/pins_RADDS.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(RURAMPS4D_11) + #include "sam/pins_RURAMPS4D_11.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(RURAMPS4D_13) + #include "sam/pins_RURAMPS4D_13.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(RAMPS_FD_V1) + #include "sam/pins_RAMPS_FD_V1.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(RAMPS_FD_V2) + #include "sam/pins_RAMPS_FD_V2.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(RAMPS_SMART_EFB, RAMPS_SMART_EEB, RAMPS_SMART_EFF, RAMPS_SMART_EEF, RAMPS_SMART_SF) + #include "sam/pins_RAMPS_SMART.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(RAMPS_DUO_EFB, RAMPS_DUO_EEB, RAMPS_DUO_EFF, RAMPS_DUO_EEF, RAMPS_DUO_SF) + #include "sam/pins_RAMPS_DUO.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(RAMPS4DUE_EFB, RAMPS4DUE_EEB, RAMPS4DUE_EFF, RAMPS4DUE_EEF, RAMPS4DUE_SF) + #include "sam/pins_RAMPS4DUE.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug +#elif MB(ULTRATRONICS_PRO) + #include "sam/pins_ULTRATRONICS_PRO.h" // SAM3X8E env:DUE env:DUE_debug +#elif MB(ARCHIM1) + #include "sam/pins_ARCHIM1.h" // SAM3X8E env:DUE_archim env:DUE_archim_debug +#elif MB(ARCHIM2) + #include "sam/pins_ARCHIM2.h" // SAM3X8E env:DUE_archim env:DUE_archim_debug +#elif MB(ALLIGATOR) + #include "sam/pins_ALLIGATOR_R2.h" // SAM3X8E env:DUE env:DUE_debug +#elif MB(CNCONTROLS_15D) + #include "sam/pins_CNCONTROLS_15D.h" // SAM3X8E env:DUE env:DUE_USB +#elif MB(KRATOS32) + #include "sam/pins_KRATOS32.h" // SAM3X8E env:DUE env:DUE_USB +#elif MB(PRINTRBOARD_G2) + #include "sam/pins_PRINTRBOARD_G2.h" // SAM3X8C env:DUE_USB +#elif MB(ADSK) + #include "sam/pins_ADSK.h" // SAM3X8C env:DUE env:DUE_debug + +// +// STM32 ARM Cortex-M0 +// +#elif MB(MALYAN_M200_V2) + #include "stm32f0/pins_MALYAN_M200_V2.h" // STM32F0 env:STM32F070RB_malyan env:STM32F070CB_malyan +#elif MB(MALYAN_M300) + #include "stm32f0/pins_MALYAN_M300.h" // STM32F070 env:malyan_M300 + +// +// STM32 ARM Cortex-M3 +// + +#elif MB(STM32F103RE) + #include "stm32f1/pins_STM32F1R.h" // STM32F103RE env:STM32F103RE env:STM32F103RE_maple +#elif MB(MALYAN_M200) + #include "stm32f1/pins_MALYAN_M200.h" // STM32F103CB env:STM32F103CB_malyan env:STM32F103CB_malyan_maple +#elif MB(STM3R_MINI) + #include "stm32f1/pins_STM3R_MINI.h" // STM32F103VE? env:STM32F103VE env:STM32F103RE_maple +#elif MB(GTM32_PRO_VB) + #include "stm32f1/pins_GTM32_PRO_VB.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple +#elif MB(GTM32_PRO_VD) + #include "stm32f1/pins_GTM32_PRO_VD.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple +#elif MB(GTM32_MINI) + #include "stm32f1/pins_GTM32_MINI.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple +#elif MB(GTM32_MINI_A30) + #include "stm32f1/pins_GTM32_MINI_A30.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple +#elif MB(GTM32_REV_B) + #include "stm32f1/pins_GTM32_REV_B.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple +#elif MB(MORPHEUS) + #include "stm32f1/pins_MORPHEUS.h" // STM32F103RE env:STM32F103RE env:STM32F103RE_maple +#elif MB(CHITU3D) + #include "stm32f1/pins_CHITU3D.h" // STM32F103ZE env:STM32F103ZE env:STM32F103RE_maple +#elif MB(MKS_ROBIN) + #include "stm32f1/pins_MKS_ROBIN.h" // STM32F1 env:mks_robin env:mks_robin_maple +#elif MB(MKS_ROBIN_MINI) + #include "stm32f1/pins_MKS_ROBIN_MINI.h" // STM32F1 env:mks_robin_mini env:mks_robin_mini_maple +#elif MB(MKS_ROBIN_NANO) + #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano35 env:mks_robin_nano35_maple +#elif MB(MKS_ROBIN_NANO_V2) + #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano35 env:mks_robin_nano35_maple +#elif MB(MKS_ROBIN_LITE) + #include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite env:mks_robin_lite_maple +#elif MB(MKS_ROBIN_LITE3) + #include "stm32f1/pins_MKS_ROBIN_LITE3.h" // STM32F1 env:mks_robin_lite3 env:mks_robin_lite3_maple +#elif MB(MKS_ROBIN_PRO) + #include "stm32f1/pins_MKS_ROBIN_PRO.h" // STM32F1 env:mks_robin_pro env:mks_robin_pro_maple +#elif MB(MKS_ROBIN_E3) + #include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3 env:mks_robin_e3_maple +#elif MB(MKS_ROBIN_E3_V1_1) + #include "stm32f1/pins_MKS_ROBIN_E3_V1_1.h" // STM32F1 env:mks_robin_e3 +#elif MB(MKS_ROBIN_E3D) + #include "stm32f1/pins_MKS_ROBIN_E3D.h" // STM32F1 env:mks_robin_e3 +#elif MB(MKS_ROBIN_E3D_V1_1) + #include "stm32f1/pins_MKS_ROBIN_E3D_V1_1.h" // STM32F1 env:mks_robin_e3 +#elif MB(MKS_ROBIN_E3P) + #include "stm32f1/pins_MKS_ROBIN_E3P.h" // STM32F1 env:mks_robin_e3p env:mks_robin_e3p_maple +#elif MB(BTT_SKR_MINI_V1_1) + #include "stm32f1/pins_BTT_SKR_MINI_V1_1.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple +#elif MB(BTT_SKR_MINI_E3_V1_0) + #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple +#elif MB(BTT_SKR_MINI_E3_V1_2) + #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple +#elif MB(BTT_SKR_MINI_E3_V2_0) + #include "stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple +#elif MB(BTT_SKR_MINI_E3_V3_0) + #include "stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h" // STM32G0 env:STM32G0B1RE_btt env:STM32G0B1RE_btt_xfer +#elif MB(BTT_SKR_MINI_MZ_V1_0) + #include "stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple +#elif MB(BTT_SKR_E3_DIP) + #include "stm32f1/pins_BTT_SKR_E3_DIP.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple +#elif MB(BTT_SKR_CR6) + #include "stm32f1/pins_BTT_SKR_CR6.h" // STM32F1 env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple +#elif MB(JGAURORA_A5S_A1) + #include "stm32f1/pins_JGAURORA_A5S_A1.h" // STM32F1 env:jgaurora_a5s_a1 env:jgaurora_a5s_a1_maple +#elif MB(FYSETC_AIO_II) + #include "stm32f1/pins_FYSETC_AIO_II.h" // STM32F1 env:STM32F103RC_fysetc env:STM32F103RC_fysetc_maple +#elif MB(FYSETC_CHEETAH) + #include "stm32f1/pins_FYSETC_CHEETAH.h" // STM32F1 env:STM32F103RC_fysetc env:STM32F103RC_fysetc_maple +#elif MB(FYSETC_CHEETAH_V12) + #include "stm32f1/pins_FYSETC_CHEETAH_V12.h" // STM32F1 env:STM32F103RC_fysetc env:STM32F103RC_fysetc_maple +#elif MB(LONGER3D_LK) + #include "stm32f1/pins_LONGER3D_LK.h" // STM32F1 env:STM32F103VE_longer env:STM32F103VE_longer_maple +#elif MB(CCROBOT_MEEB_3DP) + #include "stm32f1/pins_CCROBOT_MEEB_3DP.h" // STM32F1 env:STM32F103RC_meeb_maple +#elif MB(CHITU3D_V5) + #include "stm32f1/pins_CHITU3D_V5.h" // STM32F1 env:chitu_f103 env:chitu_f103_maple env:chitu_v5_gpio_init env:chitu_v5_gpio_init_maple +#elif MB(CHITU3D_V6) + #include "stm32f1/pins_CHITU3D_V6.h" // STM32F1 env:chitu_f103 env:chitu_f103_maple +#elif MB(CHITU3D_V9) + #include "stm32f1/pins_CHITU3D_V9.h" // STM32F1 env:chitu_f103 env:chitu_f103_maple +#elif MB(CREALITY_V4) + #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V4210) + #include "stm32f1/pins_CREALITY_V4210.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V425) + #include "stm32f1/pins_CREALITY_V425.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V422) + #include "stm32f1/pins_CREALITY_V422.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V423) + #include "stm32f1/pins_CREALITY_V423.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer +#elif MB(CREALITY_V427) + #include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V431, CREALITY_V431_A, CREALITY_V431_B, CREALITY_V431_C, CREALITY_V431_D) + #include "stm32f1/pins_CREALITY_V431.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V452) + #include "stm32f1/pins_CREALITY_V452.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V453) + #include "stm32f1/pins_CREALITY_V453.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V24S1) + #include "stm32f1/pins_CREALITY_V24S1.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V24S1_301) + #include "stm32f1/pins_CREALITY_V24S1_301.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V25S1) + #include "stm32f1/pins_CREALITY_V25S1.h" // STM32F1 env:STM32F103RE_creality_smartPro env:STM32F103RE_creality_smartPro_maple +#elif MB(TRIGORILLA_PRO) + #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro env:trigorilla_pro_maple +#elif MB(FLY_MINI) + #include "stm32f1/pins_FLY_MINI.h" // STM32F1 env:FLY_MINI env:FLY_MINI_maple +#elif MB(FLSUN_HISPEED) + #include "stm32f1/pins_FLSUN_HISPEED.h" // STM32F1 env:flsun_hispeedv1 +#elif MB(BEAST) + #include "stm32f1/pins_BEAST.h" // STM32F103VE? env:STM32F103VE env:STM32F103RE_maple +#elif MB(MINGDA_MPX_ARM_MINI) + #include "stm32f1/pins_MINGDA_MPX_ARM_MINI.h" // STM32F1 env:mingda_mpx_arm_mini +#elif MB(ZONESTAR_ZM3E2) + #include "stm32f1/pins_ZM3E2_V1_0.h" // STM32F1 env:STM32F103RC_ZM3E2_USB env:STM32F103RC_ZM3E2_USB_maple +#elif MB(ZONESTAR_ZM3E4) + #include "stm32f1/pins_ZM3E4_V1_0.h" // STM32F1 env:STM32F103VC_ZM3E4_USB env:STM32F103VC_ZM3E4_USB_maple +#elif MB(ZONESTAR_ZM3E4V2) + #include "stm32f1/pins_ZM3E4_V2_0.h" // STM32F1 env:STM32F103VE_ZM3E4V2_USB env:STM32F103VE_ZM3E4V2_USB_maple +#elif MB(ERYONE_ERY32_MINI) + #include "stm32f1/pins_ERYONE_ERY32_MINI.h" // STM32F103VET6 env:ERYONE_ERY32_MINI_maple +#elif MB(PANDA_PI_V29) + #include "stm32f1/pins_PANDA_PI_V29.h" // STM32F103RCT6 env:PANDA_PI_V29 + +// +// ARM Cortex-M4F +// + +#elif MB(TEENSY31_32) + #include "teensy3/pins_TEENSY31_32.h" // TEENSY31_32 env:teensy31 +#elif MB(TEENSY35_36) + #include "teensy3/pins_TEENSY35_36.h" // TEENSY35_36 env:teensy35 env:teensy36 + +// +// STM32 ARM Cortex-M4F +// + +#elif MB(ARMED) + #include "stm32f4/pins_ARMED.h" // STM32F4 env:ARMED +#elif MB(RUMBA32_V1_0, RUMBA32_V1_1) + #include "stm32f4/pins_RUMBA32_AUS3D.h" // STM32F4 env:rumba32 +#elif MB(RUMBA32_MKS) + #include "stm32f4/pins_RUMBA32_MKS.h" // STM32F4 env:rumba32 +#elif MB(RUMBA32_BTT) + #include "stm32f4/pins_RUMBA32_BTT.h" // STM32F4 env:rumba32 +#elif MB(BLACK_STM32F407VE) + #include "stm32f4/pins_BLACK_STM32F407VE.h" // STM32F4 env:STM32F407VE_black +#elif MB(STEVAL_3DP001V1) + #include "stm32f4/pins_STEVAL_3DP001V1.h" // STM32F4 env:STM32F401VE_STEVAL +#elif MB(BTT_SKR_PRO_V1_1) + #include "stm32f4/pins_BTT_SKR_PRO_V1_1.h" // STM32F4 env:BIGTREE_SKR_PRO env:BIGTREE_SKR_PRO_usb_flash_drive +#elif MB(BTT_SKR_PRO_V1_2) + #include "stm32f4/pins_BTT_SKR_PRO_V1_2.h" // STM32F4 env:BIGTREE_SKR_PRO env:BIGTREE_SKR_PRO_usb_flash_drive +#elif MB(BTT_GTR_V1_0) + #include "stm32f4/pins_BTT_GTR_V1_0.h" // STM32F4 env:BIGTREE_GTR_V1_0 env:BIGTREE_GTR_V1_0_usb_flash_drive +#elif MB(BTT_BTT002_V1_0) + #include "stm32f4/pins_BTT_BTT002_V1_0.h" // STM32F4 env:BIGTREE_BTT002 env:BIGTREE_BTT002_VET6 +#elif MB(BTT_E3_RRF) + #include "stm32f4/pins_BTT_E3_RRF.h" // STM32F4 env:BIGTREE_E3_RRF +#elif MB(BTT_SKR_V2_0_REV_A) + #include "stm32f4/pins_BTT_SKR_V2_0_REV_A.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB env:BIGTREE_SKR_2_USB_debug +#elif MB(BTT_SKR_V2_0_REV_B) + #include "stm32f4/pins_BTT_SKR_V2_0_REV_B.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB env:BIGTREE_SKR_2_USB_debug env:BIGTREE_SKR_2_F429 env:BIGTREE_SKR_2_F429_USB env:BIGTREE_SKR_2_F429_USB_debug +#elif MB(BTT_OCTOPUS_V1_0) + #include "stm32f4/pins_BTT_OCTOPUS_V1_0.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB +#elif MB(BTT_OCTOPUS_V1_1) + #include "stm32f4/pins_BTT_OCTOPUS_V1_1.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB +#elif MB(BTT_OCTOPUS_PRO_V1_0) + #include "stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB env:BIGTREE_OCTOPUS_PRO_V1_F429 env:BIGTREE_OCTOPUS_PRO_V1_F429_USB +#elif MB(LERDGE_K) + #include "stm32f4/pins_LERDGE_K.h" // STM32F4 env:LERDGEK env:LERDGEK_usb_flash_drive +#elif MB(LERDGE_S) + #include "stm32f4/pins_LERDGE_S.h" // STM32F4 env:LERDGES env:LERDGES_usb_flash_drive +#elif MB(LERDGE_X) + #include "stm32f4/pins_LERDGE_X.h" // STM32F4 env:LERDGEX env:LERDGEX_usb_flash_drive +#elif MB(VAKE403D) + #include "stm32f4/pins_VAKE403D.h" // STM32F4 +#elif MB(FYSETC_S6) + #include "stm32f4/pins_FYSETC_S6.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 +#elif MB(FYSETC_S6_V2_0) + #include "stm32f4/pins_FYSETC_S6_V2_0.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 +#elif MB(FYSETC_SPIDER) + #include "stm32f4/pins_FYSETC_SPIDER.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 +#elif MB(FYSETC_SPIDER_V2_2) + #include "stm32f4/pins_FYSETC_SPIDER_V2_2.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 +#elif MB(FLYF407ZG) + #include "stm32f4/pins_FLYF407ZG.h" // STM32F4 env:FLYF407ZG +#elif MB(MKS_ROBIN2) + #include "stm32f4/pins_MKS_ROBIN2.h" // STM32F4 env:MKS_ROBIN2 +#elif MB(MKS_ROBIN_PRO_V2) + #include "stm32f4/pins_MKS_ROBIN_PRO_V2.h" // STM32F4 env:mks_robin_pro2 +#elif MB(MKS_ROBIN_NANO_V3) + #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3 env:mks_robin_nano_v3_usb_flash_drive env:mks_robin_nano_v3_usb_flash_drive_msc +#elif MB(MKS_ROBIN_NANO_V3_1) + #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3_1 env:mks_robin_nano_v3_1_usb_flash_drive env:mks_robin_nano_v3_1_usb_flash_drive_msc +#elif MB(ANET_ET4) + #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_no_bootloader env:Anet_ET4_OpenBLT +#elif MB(ANET_ET4P) + #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_no_bootloader env:Anet_ET4_OpenBLT +#elif MB(FYSETC_CHEETAH_V20) + #include "stm32f4/pins_FYSETC_CHEETAH_V20.h" // STM32F4 env:FYSETC_CHEETAH_V20 +#elif MB(MKS_MONSTER8_V1) + #include "stm32f4/pins_MKS_MONSTER8_V1.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc +#elif MB(MKS_MONSTER8_V2) + #include "stm32f4/pins_MKS_MONSTER8_V2.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc +#elif MB(TH3D_EZBOARD_V2) + #include "stm32f4/pins_TH3D_EZBOARD_V2.h" // STM32F4 env:TH3D_EZBoard_V2_no_bootloader env:TH3D_EZBoard_V2_OpenBLT +#elif MB(OPULO_LUMEN_REV3) + #include "stm32f4/pins_OPULO_LUMEN_REV3.h" // STM32F4 env:Opulo_Lumen_REV3 +#elif MB(MKS_ROBIN_NANO_V1_3_F4) + #include "stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h" // STM32F4 env:mks_robin_nano_v1_3_f4 +#elif MB(MKS_EAGLE) + #include "stm32f4/pins_MKS_EAGLE.h" // STM32F4 env:mks_eagle +#elif MB(ARTILLERY_RUBY) + #include "stm32f4/pins_ARTILLERY_RUBY.h" // STM32F4 env:Artillery_Ruby +#elif MB(CREALITY_V24S1_301F4) + #include "stm32f4/pins_CREALITY_V24S1_301F4.h" // STM32F4 env:STM32F401RC_creality env:STM32F401RC_creality_jlink env:STM32F401RC_creality_stlink + +// +// ARM Cortex M7 +// + +#elif MB(REMRAM_V1) + #include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:REMRAM_V1 +#elif MB(NUCLEO_F767ZI) + #include "stm32f7/pins_NUCLEO_F767ZI.h" // STM32F7 env:NUCLEO_F767ZI +#elif MB(BTT_SKR_SE_BX_V2) + #include "stm32h7/pins_BTT_SKR_SE_BX_V2.h" // STM32H7 env:BTT_SKR_SE_BX +#elif MB(BTT_SKR_SE_BX_V3) + #include "stm32h7/pins_BTT_SKR_SE_BX_V3.h" // STM32H7 env:BTT_SKR_SE_BX +#elif MB(BTT_SKR_V3_0) + #include "stm32h7/pins_BTT_SKR_V3_0.h" // STM32H7 env:STM32H743Vx_btt +#elif MB(BTT_SKR_V3_0_EZ) + #include "stm32h7/pins_BTT_SKR_V3_0_EZ.h" // STM32H7 env:STM32H743Vx_btt +#elif MB(TEENSY41) + #include "teensy4/pins_TEENSY41.h" // Teensy-4.x env:teensy41 +#elif MB(T41U5XBB) + #include "teensy4/pins_T41U5XBB.h" // Teensy-4.x env:teensy41 + +// +// Espressif ESP32 +// + +#elif MB(ESPRESSIF_ESP32) + #include "esp32/pins_ESP32.h" // ESP32 env:esp32 +#elif MB(MRR_ESPA) + #include "esp32/pins_MRR_ESPA.h" // ESP32 env:esp32 +#elif MB(MRR_ESPE) + #include "esp32/pins_MRR_ESPE.h" // ESP32 env:esp32 +#elif MB(E4D_BOX) + #include "esp32/pins_E4D.h" // ESP32 env:esp32 +#elif MB(RESP32_CUSTOM) + #include "esp32/pins_RESP32_CUSTOM.h" // ESP32 env:esp32 +#elif MB(FYSETC_E4) + #include "esp32/pins_FYSETC_E4.h" // ESP32 env:FYSETC_E4 +#elif MB(PANDA_ZHU) + #include "esp32/pins_PANDA_ZHU.h" // ESP32 env:PANDA +#elif MB(PANDA_M4) + #include "esp32/pins_PANDA_M4.h" // ESP32 env:PANDA +#elif MB(MKS_TINYBEE) + #include "esp32/pins_MKS_TINYBEE.h" // ESP32 env:mks_tinybee +#elif MB(ENWI_ESPNP) + #include "esp32/pins_ENWI_ESPNP.h" // ESP32 env:esp32 + +// +// Adafruit Grand Central M4 (SAMD51 ARM Cortex-M4) +// + +#elif MB(AGCM4_RAMPS_144) + #include "samd/pins_RAMPS_144.h" // SAMD51 env:SAMD51_grandcentral_m4 +#elif MB(BRICOLEMON_V1_0) + #include "samd/pins_BRICOLEMON_V1_0.h" // SAMD51 env:SAMD51_grandcentral_m4 +#elif MB(BRICOLEMON_LITE_V1_0) + #include "samd/pins_BRICOLEMON_LITE_V1_0.h" // SAMD51 env:SAMD51_grandcentral_m4 + +// +// Custom board (with custom PIO env) +// + +#elif MB(CUSTOM) + #include "pins_custom.h" // env:custom + +// +// Linux Native Debug board +// + +#elif MB(LINUX_RAMPS) + #include "linux/pins_RAMPS_LINUX.h" // Native or Simulation lin:linux_native mac:simulator_macos_debug mac:simulator_macos_release win:simulator_windows lin:simulator_linux_debug lin:simulator_linux_release + +#else + + // + // Obsolete or unknown board + // + + #define BOARD_MKS_13 99900 + #define BOARD_TRIGORILLA 99901 + #define BOARD_RURAMPS4D 99902 + #define BOARD_FORMBOT_TREX2 99903 + #define BOARD_BIQU_SKR_V1_1 99904 + #define BOARD_STM32F1R 99905 + #define BOARD_STM32F103R 99906 + #define BOARD_ESP32 99907 + #define BOARD_STEVAL 99908 + #define BOARD_BIGTREE_SKR_V1_1 99909 + #define BOARD_BIGTREE_SKR_V1_3 99910 + #define BOARD_BIGTREE_SKR_V1_4 99911 + #define BOARD_BIGTREE_SKR_V1_4_TURBO 99912 + #define BOARD_BIGTREE_BTT002_V1_0 99913 + #define BOARD_BIGTREE_SKR_PRO_V1_1 99914 + #define BOARD_BIGTREE_SKR_MINI_V1_1 99915 + #define BOARD_BIGTREE_SKR_MINI_E3 99916 + #define BOARD_BIGTREE_SKR_E3_DIP 99917 + #define BOARD_RUMBA32 99918 + #define BOARD_RUMBA32_AUS3D 99919 + #define BOARD_RAMPS_DAGOMA 99920 + #define BOARD_RAMPS_LONGER3D_LK4PRO 99921 + #define BOARD_BTT_SKR_V2_0 99922 + #define BOARD_TH3D_EZBOARD_LITE_V2 99923 + #define BOARD_BTT_SKR_SE_BX 99924 + #define BOARD_MKS_MONSTER8 99925 + + #if MB(MKS_13) + #error "BOARD_MKS_13 has been renamed BOARD_MKS_GEN_13. Please update your configuration." + #elif MB(TRIGORILLA) + #error "BOARD_TRIGORILLA has been renamed BOARD_TRIGORILLA_13. Please update your configuration." + #elif MB(RURAMPS4D) + #error "BOARD_RURAMPS4D has been renamed BOARD_RURAMPS4D_11. Please update your configuration." + #elif MB(FORMBOT_TREX2) + #error "FORMBOT_TREX2 has been renamed BOARD_FORMBOT_TREX2PLUS. Please update your configuration." + #elif MB(BIQU_SKR_V1_1) + #error "BOARD_BIQU_SKR_V1_1 has been renamed BOARD_BTT_SKR_V1_1. Please update your configuration." + #elif MB(BIGTREE_SKR_V1_1) + #error "BOARD_BIGTREE_SKR_V1_1 has been renamed BOARD_BTT_SKR_V1_1. Please update your configuration." + #elif MB(BIGTREE_SKR_V1_2) + #error "BOARD_BIGTREE_SKR_V1_2 has been renamed BOARD_BTT_SKR_V1_2. Please update your configuration." + #elif MB(BIGTREE_SKR_V1_3) + #error "BOARD_BIGTREE_SKR_V1_3 has been renamed BOARD_BTT_SKR_V1_3. Please update your configuration." + #elif MB(BIGTREE_SKR_V1_4) + #error "BOARD_BIGTREE_SKR_V1_4 has been renamed BOARD_BTT_SKR_V1_4. Please update your configuration." + #elif MB(BIGTREE_SKR_V1_4_TURBO) + #error "BOARD_BIGTREE_SKR_V1_4_TURBO has been renamed BOARD_BTT_SKR_V1_4_TURBO. Please update your configuration." + #elif MB(BIGTREE_BTT002_V1_0) + #error "BOARD_BIGTREE_BTT002_V1_0 has been renamed BOARD_BTT_BTT002_V1_0. Please update your configuration." + #elif MB(BIGTREE_SKR_PRO_V1_1) + #error "BOARD_BIGTREE_SKR_PRO_V1_1 has been renamed BOARD_BTT_SKR_PRO_V1_1. Please update your configuration." + #elif MB(BIGTREE_SKR_MINI_V1_1) + #error "BOARD_BIGTREE_SKR_MINI_V1_1 has been renamed BOARD_BTT_SKR_MINI_V1_1. Please update your configuration." + #elif MB(BIGTREE_SKR_MINI_E3) + #error "BOARD_BIGTREE_SKR_MINI_E3 has been renamed BOARD_BTT_SKR_MINI_E3_V1_0. Please update your configuration." + #elif MB(BIGTREE_SKR_E3_DIP) + #error "BOARD_BIGTREE_SKR_E3_DIP has been renamed BOARD_BTT_SKR_E3_DIP. Please update your configuration." + #elif MB(STM32F1R) + #error "BOARD_STM32F1R has been renamed BOARD_STM32F103RE. Please update your configuration." + #elif MB(STM32F103R) + #error "BOARD_STM32F103R has been renamed BOARD_STM32F103RE. Please update your configuration." + #elif MOTHERBOARD == BOARD_ESP32 + #error "BOARD_ESP32 has been renamed BOARD_ESPRESSIF_ESP32. Please update your configuration." + #elif MB(STEVAL) + #error "BOARD_STEVAL has been renamed BOARD_STEVAL_3DP001V1. Please update your configuration." + #elif MB(RUMBA32) + #error "BOARD_RUMBA32 is now BOARD_RUMBA32_MKS or BOARD_RUMBA32_V1_0. Please update your configuration." + #elif MB(RUMBA32_AUS3D) + #error "BOARD_RUMBA32_AUS3D is now BOARD_RUMBA32_V1_0. Please update your configuration." + #elif MB(RAMPS_DAGOMA) + #error "BOARD_RAMPS_DAGOMA is now BOARD_DAGOMA_F5. Please update your configuration." + #elif MB(RAMPS_LONGER3D_LK4PRO) + #error "BOARD_RAMPS_LONGER3D_LK4PRO is now BOARD_LONGER3D_LKx_PRO. Please update your configuration." + #elif MB(BTT_SKR_V2_0) + #error "BOARD_BTT_SKR_V2_0 is now BOARD_BTT_SKR_V2_0_REV_A or BOARD_BTT_SKR_V2_0_REV_B. See https://bit.ly/3t5d9JQ for more information. Please update your configuration." + #elif MB(TH3D_EZBOARD_LITE_V2) + #error "BOARD_TH3D_EZBOARD_LITE_V2 is now BOARD_TH3D_EZBOARD_V2. Please update your configuration." + #elif MB(BTT_SKR_SE_BX) + #error "BOARD_BTT_SKR_SE_BX is now BOARD_BTT_SKR_SE_BX_V2 or BOARD_BTT_SKR_SE_BX_V3. Please update your configuration." + #elif MB(MKS_MONSTER8) + #error "BOARD_MKS_MONSTER8 is now BOARD_MKS_MONSTER8_V1 or BOARD_MKS_MONSTER8_V2. Please update your configuration." + #elif defined(MOTHERBOARD) + #error "Unknown MOTHERBOARD value set in Configuration.h." + #else + #error "MOTHERBOARD not defined! Use '#define MOTHERBOARD BOARD_...' in Configuration.h." + #endif + + #undef BOARD_MKS_13 + #undef BOARD_TRIGORILLA + #undef BOARD_RURAMPS4D + #undef BOARD_FORMBOT_TREX2 + #undef BOARD_BIQU_SKR_V1_1 + #undef BOARD_STM32F1R + #undef BOARD_STM32F103R + #undef BOARD_ESP32 + #undef BOARD_STEVAL + #undef BOARD_BIGTREE_SKR_V1_1 + #undef BOARD_BIGTREE_SKR_V1_3 + #undef BOARD_BIGTREE_SKR_V1_4 + #undef BOARD_BIGTREE_SKR_V1_4_TURBO + #undef BOARD_BIGTREE_BTT002_V1_0 + #undef BOARD_BIGTREE_SKR_PRO_V1_1 + #undef BOARD_BIGTREE_SKR_MINI_V1_1 + #undef BOARD_BIGTREE_SKR_MINI_E3 + #undef BOARD_BIGTREE_SKR_E3_DIP + #undef BOARD_RUMBA32 + #undef BOARD_RUMBA32_AUS3D + #undef BOARD_RAMPS_DAGOMA + #undef BOARD_RAMPS_LONGER3D_LK4PRO + #undef BOARD_BTT_SKR_V2_0 + #undef BOARD_TH3D_EZBOARD_LITE_V2 + #undef BOARD_BTT_SKR_SE_BX + #undef BOARD_MKS_MONSTER8 + +#endif + +// +// Post-process pins according to configured settings +// +#include "pins_postprocess.h" diff --git a/src/pins/pinsDebug.h b/src/pins/pinsDebug.h new file mode 100644 index 0000000..b662f09 --- /dev/null +++ b/src/pins/pinsDebug.h @@ -0,0 +1,293 @@ +/** + * 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 . + * + */ +#pragma once + +#include "../inc/MarlinConfig.h" + +#define MAX_NAME_LENGTH 39 // one place to specify the format of all the sources of names + // "-" left justify, "39" minimum width of name, pad with blanks + +/** + * This routine minimizes RAM usage by creating a FLASH resident array to + * store the pin names, pin numbers and analog/digital flag. + * + * Creating the array in FLASH is a two pass process. The first pass puts the + * name strings into FLASH. The second pass actually creates the array. + * + * Both passes use the same pin list. The list contains two macro names. The + * actual macro definitions are changed depending on which pass is being done. + */ + +// first pass - put the name strings into FLASH + +#define _ADD_PIN_2(PIN_NAME, ENTRY_NAME) static const char ENTRY_NAME[] PROGMEM = { PIN_NAME }; +#define _ADD_PIN(PIN_NAME, COUNTER) _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER) +#define REPORT_NAME_DIGITAL(COUNTER, NAME) _ADD_PIN(#NAME, COUNTER) +#define REPORT_NAME_ANALOG(COUNTER, NAME) _ADD_PIN(#NAME, COUNTER) + +#include "pinsDebug_list.h" +#line 48 + +// manually add pins that have names that are macros which don't play well with these macros +#if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768) + #if CONF_SERIAL_IS(0) + static const char RXD_NAME_0[] PROGMEM = { "RXD0" }; + static const char TXD_NAME_0[] PROGMEM = { "TXD0" }; + #endif + #if CONF_SERIAL_IS(1) + static const char RXD_NAME_1[] PROGMEM = { "RXD1" }; + static const char TXD_NAME_1[] PROGMEM = { "TXD1" }; + #endif + #if CONF_SERIAL_IS(2) + static const char RXD_NAME_2[] PROGMEM = { "RXD2" }; + static const char TXD_NAME_2[] PROGMEM = { "TXD2" }; + #endif + #if CONF_SERIAL_IS(3) + static const char RXD_NAME_3[] PROGMEM = { "RXD3" }; + static const char TXD_NAME_3[] PROGMEM = { "TXD3" }; + #endif +#endif + +///////////////////////////////////////////////////////////////////////////// + +// second pass - create the array + +#undef _ADD_PIN_2 +#undef _ADD_PIN +#undef REPORT_NAME_DIGITAL +#undef REPORT_NAME_ANALOG + +#define _ADD_PIN_2(ENTRY_NAME, NAME, IS_DIGITAL) { ENTRY_NAME, NAME, IS_DIGITAL }, +#define _ADD_PIN(NAME, COUNTER, IS_DIGITAL) _ADD_PIN_2(entry_NAME_##COUNTER, NAME, IS_DIGITAL) +#define REPORT_NAME_DIGITAL(COUNTER, NAME) _ADD_PIN(NAME, COUNTER, true) +#define REPORT_NAME_ANALOG(COUNTER, NAME) _ADD_PIN(analogInputToDigitalPin(NAME), COUNTER, false) + + +typedef struct { + PGM_P const name; + pin_t pin; + bool is_digital; +} PinInfo; + +const PinInfo pin_array[] PROGMEM = { + + /** + * [pin name] [pin number] [is digital or analog] 1 = digital, 0 = analog + * Each entry takes up 6 bytes in FLASH: + * 2 byte pointer to location of the name string + * 2 bytes containing the pin number + * analog pin numbers were converted to digital when the array was created + * 2 bytes containing the digital/analog bool flag + */ + + #if CONF_SERIAL_IS(0) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) + { RXD_NAME_0, 0, true }, + { TXD_NAME_0, 1, true }, + #elif AVR_ATmega1284_FAMILY + { RXD_NAME_0, 8, true }, + { TXD_NAME_0, 9, true }, + #elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03 + { RXD_NAME_0, 3, true }, + { TXD_NAME_0, 2, true }, + #endif + #endif + + #if CONF_SERIAL_IS(1) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) + { RXD_NAME_1, 19, true }, + { TXD_NAME_1, 18, true }, + #elif AVR_ATmega1284_FAMILY + { RXD_NAME_1, 10, true }, + { TXD_NAME_1, 11, true }, + #elif defined(TARGET_LPC1768) + #ifdef LPC_PINCFG_UART1_P2_00 // TX P2_00 RX P2_01 + { RXD_NAME_1, 0x41, true }, + { TXD_NAME_1, 0x40, true }, + #else // TX P0_15 RX P0_16 + { RXD_NAME_1, 16, true }, + { TXD_NAME_1, 15, true }, + #endif + #endif + #endif + + #if CONF_SERIAL_IS(2) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) + { RXD_NAME_2, 17, true }, + { TXD_NAME_2, 16, true }, + #elif defined(TARGET_LPC1768) + #ifdef LPC_PINCFG_UART2_P2_08 // TX P2_08 RX P2_09 + { RXD_NAME_2, 0x49, true }, + { TXD_NAME_2, 0x48, true }, + #else // TX P0_10 RX P0_11 + { RXD_NAME_2, 11, true }, + { TXD_NAME_2, 10, true }, + #endif + #endif + #endif + + #if CONF_SERIAL_IS(3) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) + { RXD_NAME_3, 15, true }, + { TXD_NAME_3, 14, true }, + #elif defined(TARGET_LPC1768) + #ifdef LPC_PINCFG_UART3_P0_25 // TX P0_25 RX P0_26 + { RXD_NAME_3, 0x1A, true }, + { TXD_NAME_3, 0x19, true }, + #elif defined(LPC_PINCFG_UART3_P4_28) // TX P4_28 RX P4_29 + { RXD_NAME_3, 0x9D, true }, + { TXD_NAME_3, 0x9C, true }, + #else // TX P0_00 RX P0_01 + { RXD_NAME_3, 1, true }, + { TXD_NAME_3, 0, true }, + #endif + #endif + #endif + + #include "pinsDebug_list.h" + #line 167 + +}; + +#include HAL_PATH(../HAL, pinsDebug.h) // get the correct support file for this CPU + +#ifndef M43_NEVER_TOUCH + #define M43_NEVER_TOUCH(Q) false +#endif + +static void print_input_or_output(const bool isout) { + SERIAL_ECHOPGM_P(isout ? PSTR("Output = ") : PSTR("Input = ")); +} + +// pretty report with PWM info +inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool extended=false, FSTR_P const start_string=nullptr) { + char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements + bool found = false, multi_name_pin = false; + + auto alt_pin_echo = [](const pin_t &pin) { + #if AVR_AT90USB1286_FAMILY + // Use FastIO for pins Teensy doesn't expose + if (pin == 46) { + print_input_or_output(IS_OUTPUT(46)); + SERIAL_CHAR('0' + READ(46)); + return false; + } + else if (pin == 47) { + print_input_or_output(IS_OUTPUT(47)); + SERIAL_CHAR('0' + READ(47)); + return false; + } + #endif + return true; + }; + + LOOP_L_N(x, COUNT(pin_array)) { // scan entire array and report all instances of this pin + if (GET_ARRAY_PIN(x) == pin) { + if (!found) { // report digital and analog pin number only on the first time through + if (start_string) SERIAL_ECHOF(start_string); + SERIAL_ECHOPGM("PIN: "); + PRINT_PIN(pin); + PRINT_PORT(pin); + if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) PRINT_PIN_ANALOG(pin); // analog pin number + else SERIAL_ECHO_SP(8); // add padding if not an analog pin + } + else { + SERIAL_CHAR('.'); + SERIAL_ECHO_SP(MULTI_NAME_PAD + (start_string ? strlen_P(FTOP(start_string)) : 0)); // add padding if not the first instance found + } + PRINT_ARRAY_NAME(x); + if (extended) { + if (pin_is_protected(pin) && !ignore) + SERIAL_ECHOPGM("protected "); + else { + if (alt_pin_echo(pin)) { + if (!GET_ARRAY_IS_DIGITAL(x)) { + sprintf_P(buffer, PSTR("Analog in = %5ld"), (long)analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin))); + SERIAL_ECHO(buffer); + } + else { + if (!GET_PINMODE(pin)) { + //pinMode(pin, INPUT_PULLUP); // make sure input isn't floating - stopped doing this + // because this could interfere with inductive/capacitive + // sensors (high impedance voltage divider) and with Pt100 amplifier + print_input_or_output(false); + SERIAL_ECHO(digitalRead_mod(pin)); + } + else if (pwm_status(pin)) { + // do nothing + } + else { + print_input_or_output(true); + SERIAL_ECHO(digitalRead_mod(pin)); + } + } + if (!multi_name_pin && extended) pwm_details(pin); // report PWM capabilities only on the first pass & only if doing an extended report + } + } + } + SERIAL_EOL(); + multi_name_pin = found; + found = true; + } // end of IF + } // end of for loop + + if (!found) { + if (start_string) SERIAL_ECHOF(start_string); + SERIAL_ECHOPGM("PIN: "); + PRINT_PIN(pin); + PRINT_PORT(pin); + if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) PRINT_PIN_ANALOG(pin); // analog pin number + else SERIAL_ECHO_SP(8); // add padding if not an analog pin + SERIAL_ECHOPGM(""); + if (extended) { + + if (alt_pin_echo(pin)) { + if (pwm_status(pin)) { + // do nothing + } + else if (GET_PINMODE(pin)) { + SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); + print_input_or_output(true); + SERIAL_ECHO(digitalRead_mod(pin)); + } + else { + if (IS_ANALOG(pin)) { + sprintf_P(buffer, PSTR(" Analog in = %5ld"), (long)analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin))); + SERIAL_ECHO(buffer); + SERIAL_ECHOPGM(" "); + } + else + SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); // add padding if not an analog pin + + print_input_or_output(false); + SERIAL_ECHO(digitalRead_mod(pin)); + } + //if (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin + if (extended) { + SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); + pwm_details(pin); // report PWM capabilities only if doing an extended report + } + } + } + SERIAL_EOL(); + } +} diff --git a/src/pins/pinsDebug_list.h b/src/pins/pinsDebug_list.h new file mode 100644 index 0000000..d7e84b9 --- /dev/null +++ b/src/pins/pinsDebug_list.h @@ -0,0 +1,1796 @@ +/** + * 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 . + * + */ + +// Please update this list when adding new pins to Marlin. +// The order doesn't matter. +// Following this pattern is a must. +// If the new pin name is over 28 characters long then pinsDebug.h will need to be modified. + +#if TARGET_LPC1768 + #define ANALOG_OK(PN) (WITHIN(PN, P0_02, P0_03) || WITHIN(PN, P0_23, P0_26) || WITHIN(PN, P1_30, P1_31)) +#else + #define ANALOG_OK(PN) WITHIN(PN, 0, NUM_ANALOG_INPUTS - 1) +#endif + +#line 35 // set __LINE__ to a known value for both passes + +// +// Analog Pin Assignments +// + +#define _EXISTS(PN,V...) (defined(PN##V) && PN##V >= 0) + +#if _EXISTS(EXT_AUX_A0) + #if ANALOG_OK(EXT_AUX_A0) + REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) +#endif +#endif +#if _EXISTS(EXT_AUX_A1) + #if ANALOG_OK(EXT_AUX_A0) + REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) + #endif +#endif +#if _EXISTS(EXT_AUX_A2) + #if ANALOG_OK(EXT_AUX_A0) + REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) + #endif +#endif +#if _EXISTS(EXT_AUX_A3) + #if ANALOG_OK(EXT_AUX_A0) + REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) + #endif +#endif +#if _EXISTS(EXT_AUX_A4) + #if ANALOG_OK(EXT_AUX_A0) + REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) + #endif +#endif +#if PIN_EXISTS(FILWIDTH) + #if ANALOG_OK(FILWIDTH_PIN) + REPORT_NAME_ANALOG(__LINE__, FILWIDTH_PIN) + #endif +#endif +#if PIN_EXISTS(MAIN_VOLTAGE_MEASURE) + #if ANALOG_OK(MAIN_VOLTAGE_MEASURE_PIN) + REPORT_NAME_ANALOG(__LINE__, MAIN_VOLTAGE_MEASURE_PIN) + #endif +#endif +#if PIN_EXISTS(POWER_MONITOR_CURRENT) + #if ANALOG_OK(POWER_MONITOR_CURRENT_PIN) + REPORT_NAME_ANALOG(__LINE__, POWER_MONITOR_CURRENT_PIN) + #endif +#endif +#if PIN_EXISTS(POWER_MONITOR_VOLTAGE) + #if ANALOG_OK(POWER_MONITOR_VOLTAGE_PIN) + REPORT_NAME_ANALOG(__LINE__, POWER_MONITOR_VOLTAGE_PIN) + #endif +#endif +#if !defined(ARDUINO_ARCH_SAM) && !defined(ARDUINO_ARCH_SAMD) // TC1 & TC2 are macros in the SAM/SAMD tool chain + #if _EXISTS(TC1) + #if ANALOG_OK(TC1) + REPORT_NAME_ANALOG(__LINE__, TC1) + #endif + #endif + #if _EXISTS(TC2) + #if ANALOG_OK(TC1) + REPORT_NAME_ANALOG(__LINE__, TC1) + #endif + #endif +#endif +#if PIN_EXISTS(TEMP_0) + #if ANALOG_OK(TEMP_0_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_0_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_1) + #if ANALOG_OK(TEMP_1_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_1_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_2) + #if ANALOG_OK(TEMP_2_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_2_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_3) + #if ANALOG_OK(TEMP_3_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_3_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_4) + #if ANALOG_OK(TEMP_4_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_4_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_5) + #if ANALOG_OK(TEMP_5_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_5_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_6) + #if ANALOG_OK(TEMP_6_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_6_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_7) + #if ANALOG_OK(TEMP_7_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_7_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_BED) + #if ANALOG_OK(TEMP_BED_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_BED_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_CHAMBER) + #if ANALOG_OK(TEMP_CHAMBER_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_CHAMBER_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_PROBE) + #if ANALOG_OK(TEMP_PROBE_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_PROBE_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_COOLER) + #if ANALOG_OK(TEMP_COOLER_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_COOLER_PIN) + #endif +#endif +#if PIN_EXISTS(TEMP_BOARD) + #if ANALOG_OK(TEMP_BOARD_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_BOARD_PIN) + #endif +#endif +#if PIN_EXISTS(ADC_KEYPAD) + #if ANALOG_OK(ADC_KEYPAD_PIN) + REPORT_NAME_ANALOG(__LINE__, ADC_KEYPAD_PIN) + #endif +#endif + +// +// Digital Pin Assignments +// + +#if _EXISTS(__FD) + REPORT_NAME_DIGITAL(__LINE__, __FD) +#endif +#if _EXISTS(__FS) + REPORT_NAME_DIGITAL(__LINE__, __FS) +#endif +#if _EXISTS(__GD) + REPORT_NAME_DIGITAL(__LINE__, __GD) +#endif +#if _EXISTS(__GS) + REPORT_NAME_DIGITAL(__LINE__, __GS) +#endif +#if PIN_EXISTS(AVR_MISO) + REPORT_NAME_DIGITAL(__LINE__, AVR_MISO_PIN) +#endif +#if PIN_EXISTS(AVR_MOSI) + REPORT_NAME_DIGITAL(__LINE__, AVR_MOSI_PIN) +#endif +#if PIN_EXISTS(AVR_SCK) + REPORT_NAME_DIGITAL(__LINE__, AVR_SCK_PIN) +#endif +#if PIN_EXISTS(ALARM) + REPORT_NAME_DIGITAL(__LINE__, ALARM_PIN) +#endif +#if PIN_EXISTS(AVR_SS) + REPORT_NAME_DIGITAL(__LINE__, AVR_SS_PIN) +#endif +#if PIN_EXISTS(BEEPER) + REPORT_NAME_DIGITAL(__LINE__, BEEPER_PIN) +#endif +#if _EXISTS(BTN_BACK) + REPORT_NAME_DIGITAL(__LINE__, BTN_BACK) +#endif +#if _EXISTS(BTN_CENTER) + REPORT_NAME_DIGITAL(__LINE__, BTN_CENTER) +#endif +#if _EXISTS(BTN_DOWN) + REPORT_NAME_DIGITAL(__LINE__, BTN_DOWN) +#endif +#if _EXISTS(BTN_DWN) + REPORT_NAME_DIGITAL(__LINE__, BTN_DWN) +#endif +#if _EXISTS(BTN_EN1) + REPORT_NAME_DIGITAL(__LINE__, BTN_EN1) +#endif +#if _EXISTS(BTN_EN2) + REPORT_NAME_DIGITAL(__LINE__, BTN_EN2) +#endif +#if _EXISTS(BTN_ENC_EN) + REPORT_NAME_DIGITAL(__LINE__, BTN_ENC_EN) +#endif +#if _EXISTS(BTN_ENC) + REPORT_NAME_DIGITAL(__LINE__, BTN_ENC) +#endif +#if _EXISTS(BTN_HOME) + REPORT_NAME_DIGITAL(__LINE__, BTN_HOME) +#endif +#if _EXISTS(BTN_LEFT) + REPORT_NAME_DIGITAL(__LINE__, BTN_LEFT) +#endif +#if _EXISTS(BTN_LFT) + REPORT_NAME_DIGITAL(__LINE__, BTN_LFT) +#endif +#if _EXISTS(BTN_RIGHT) + REPORT_NAME_DIGITAL(__LINE__, BTN_RIGHT) +#endif +#if _EXISTS(BTN_RT) + REPORT_NAME_DIGITAL(__LINE__, BTN_RT) +#endif +#if _EXISTS(BTN_UP) + REPORT_NAME_DIGITAL(__LINE__, BTN_UP) +#endif +#if PIN_EXISTS(JOY_X) + REPORT_NAME_DIGITAL(__LINE__, JOY_X_PIN) +#endif +#if PIN_EXISTS(JOY_Y) + REPORT_NAME_DIGITAL(__LINE__, JOY_Y_PIN) +#endif +#if PIN_EXISTS(JOY_Z) + REPORT_NAME_DIGITAL(__LINE__, JOY_Z_PIN) +#endif +#if PIN_EXISTS(JOY_EN) + REPORT_NAME_DIGITAL(__LINE__, JOY_EN_PIN) +#endif +#if PIN_EXISTS(BUTTON1) + REPORT_NAME_DIGITAL(__LINE__, BUTTON1_PIN) +#endif +#if PIN_EXISTS(BUTTON2) + REPORT_NAME_DIGITAL(__LINE__, BUTTON2_PIN) +#endif +#if PIN_EXISTS(BUTTON3) + REPORT_NAME_DIGITAL(__LINE__, BUTTON3_PIN) +#endif +#if PIN_EXISTS(BUTTON4) + REPORT_NAME_DIGITAL(__LINE__, BUTTON4_PIN) +#endif +#if PIN_EXISTS(BUTTON5) + REPORT_NAME_DIGITAL(__LINE__, BUTTON5_PIN) +#endif +#if PIN_EXISTS(BUTTON6) + REPORT_NAME_DIGITAL(__LINE__, BUTTON6_PIN) +#endif +#if PIN_EXISTS(BUTTON7) + REPORT_NAME_DIGITAL(__LINE__, BUTTON7_PIN) +#endif +#if PIN_EXISTS(BUTTON8) + REPORT_NAME_DIGITAL(__LINE__, BUTTON8_PIN) +#endif +#if PIN_EXISTS(BUTTON9) + REPORT_NAME_DIGITAL(__LINE__, BUTTON9_PIN) +#endif +#if PIN_EXISTS(BUTTON10) + REPORT_NAME_DIGITAL(__LINE__, BUTTON10_PIN) +#endif +#if PIN_EXISTS(BUTTON11) + REPORT_NAME_DIGITAL(__LINE__, BUTTON11_PIN) +#endif +#if PIN_EXISTS(BUTTON12) + REPORT_NAME_DIGITAL(__LINE__, BUTTON12_PIN) +#endif +#if PIN_EXISTS(BUTTON13) + REPORT_NAME_DIGITAL(__LINE__, BUTTON13_PIN) +#endif +#if PIN_EXISTS(BUTTON14) + REPORT_NAME_DIGITAL(__LINE__, BUTTON14_PIN) +#endif +#if PIN_EXISTS(BUTTON15) + REPORT_NAME_DIGITAL(__LINE__, BUTTON15_PIN) +#endif +#if PIN_EXISTS(BUTTON16) + REPORT_NAME_DIGITAL(__LINE__, BUTTON16_PIN) +#endif +#if PIN_EXISTS(BUTTON17) + REPORT_NAME_DIGITAL(__LINE__, BUTTON17_PIN) +#endif +#if PIN_EXISTS(BUTTON18) + REPORT_NAME_DIGITAL(__LINE__, BUTTON18_PIN) +#endif +#if PIN_EXISTS(BUTTON19) + REPORT_NAME_DIGITAL(__LINE__, BUTTON19_PIN) +#endif +#if PIN_EXISTS(BUTTON20) + REPORT_NAME_DIGITAL(__LINE__, BUTTON20_PIN) +#endif +#if PIN_EXISTS(BUTTON21) + REPORT_NAME_DIGITAL(__LINE__, BUTTON21_PIN) +#endif +#if PIN_EXISTS(BUTTON22) + REPORT_NAME_DIGITAL(__LINE__, BUTTON22_PIN) +#endif +#if PIN_EXISTS(BUTTON23) + REPORT_NAME_DIGITAL(__LINE__, BUTTON23_PIN) +#endif +#if PIN_EXISTS(BUTTON24) + REPORT_NAME_DIGITAL(__LINE__, BUTTON24_PIN) +#endif +#if PIN_EXISTS(BUTTON25) + REPORT_NAME_DIGITAL(__LINE__, BUTTON25_PIN) +#endif +#if PIN_EXISTS(CASE_LIGHT) + REPORT_NAME_DIGITAL(__LINE__, CASE_LIGHT_PIN) +#endif +#if PIN_EXISTS(CHAMBER_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, CHAMBER_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(CONTROLLER_FAN) + REPORT_NAME_DIGITAL(__LINE__, CONTROLLER_FAN_PIN) +#endif +#if PIN_EXISTS(COOLANT_FLOOD) + REPORT_NAME_DIGITAL(__LINE__, COOLANT_FLOOD_PIN) +#endif +#if PIN_EXISTS(COOLANT_MIST) + REPORT_NAME_DIGITAL(__LINE__, COOLANT_MIST_PIN) +#endif +#if PIN_EXISTS(CUTOFF_RESET) + REPORT_NAME_DIGITAL(__LINE__, CUTOFF_RESET_PIN) +#endif +#if PIN_EXISTS(CUTOFF_TEST) + REPORT_NAME_DIGITAL(__LINE__, CUTOFF_TEST_PIN) +#endif +#if _EXISTS(D57) + REPORT_NAME_DIGITAL(__LINE__, D57) +#endif +#if _EXISTS(D58) + REPORT_NAME_DIGITAL(__LINE__, D58) +#endif +#if PIN_EXISTS(DAC_DISABLE) + REPORT_NAME_DIGITAL(__LINE__, DAC_DISABLE_PIN) +#endif +#if PIN_EXISTS(DAC0_SYNC) + REPORT_NAME_DIGITAL(__LINE__, DAC0_SYNC_PIN) +#endif +#if PIN_EXISTS(DAC1_SYNC) + REPORT_NAME_DIGITAL(__LINE__, DAC1_SYNC_PIN) +#endif +#if PIN_EXISTS(DEBUG) + REPORT_NAME_DIGITAL(__LINE__, DEBUG_PIN) +#endif +#if _EXISTS(DIGIPOTS_I2C_SCL) + REPORT_NAME_DIGITAL(__LINE__, DIGIPOTS_I2C_SCL) +#endif +#if _EXISTS(DIGIPOTS_I2C_SDA_E0) + REPORT_NAME_DIGITAL(__LINE__, DIGIPOTS_I2C_SDA_E0) +#endif +#if _EXISTS(DIGIPOTS_I2C_SDA_E1) + REPORT_NAME_DIGITAL(__LINE__, DIGIPOTS_I2C_SDA_E1) +#endif +#if _EXISTS(DIGIPOTS_I2C_SDA_X) + REPORT_NAME_DIGITAL(__LINE__, DIGIPOTS_I2C_SDA_X) +#endif +#if _EXISTS(DIGIPOTS_I2C_SDA_Y) + REPORT_NAME_DIGITAL(__LINE__, DIGIPOTS_I2C_SDA_Y) +#endif +#if _EXISTS(DIGIPOTS_I2C_SDA_Z) + REPORT_NAME_DIGITAL(__LINE__, DIGIPOTS_I2C_SDA_Z) +#endif +#if PIN_EXISTS(DIGIPOTSS) + REPORT_NAME_DIGITAL(__LINE__, DIGIPOTSS_PIN) +#endif +#if PIN_EXISTS(LCD_RESET) + REPORT_NAME_DIGITAL(__LINE__, LCD_RESET_PIN) +#endif +#if _EXISTS(DOGLCD_A0) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_A0) +#endif +#if _EXISTS(DOGLCD_CS) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_CS) +#endif +#if _EXISTS(DOGLCD_MOSI) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_MOSI) +#endif +#if _EXISTS(DOGLCD_SCK) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_SCK) +#endif +#if _EXISTS(TMC_SW_MISO) + REPORT_NAME_DIGITAL(__LINE__, TMC_SW_MISO) +#endif +#if _EXISTS(TMC_SW_MOSI) + REPORT_NAME_DIGITAL(__LINE__, TMC_SW_MOSI) +#endif +#if _EXISTS(TMC_SW_SCK) + REPORT_NAME_DIGITAL(__LINE__, TMC_SW_SCK) +#endif +#if _EXISTS(TFTGLCD_CS) + REPORT_NAME_DIGITAL(__LINE__, TFTGLCD_CS) +#endif +#if PIN_EXISTS(E_MUX0) + REPORT_NAME_DIGITAL(__LINE__, E_MUX0_PIN) +#endif +#if PIN_EXISTS(E_MUX1) + REPORT_NAME_DIGITAL(__LINE__, E_MUX1_PIN) +#endif +#if PIN_EXISTS(E_MUX2) + REPORT_NAME_DIGITAL(__LINE__, E_MUX2_PIN) +#endif +#if PIN_EXISTS(E_STOP) + REPORT_NAME_DIGITAL(__LINE__, E_STOP_PIN) +#endif +#if PIN_EXISTS(E0_ATT) + REPORT_NAME_DIGITAL(__LINE__, E0_ATT_PIN) +#endif +#if PIN_EXISTS(E0_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E0_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E0_CS) + REPORT_NAME_DIGITAL(__LINE__, E0_CS_PIN) +#endif +#if PIN_EXISTS(E0_DIR) + REPORT_NAME_DIGITAL(__LINE__, E0_DIR_PIN) +#endif +#if PIN_EXISTS(E0_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, E0_ENABLE_PIN) +#endif +#if PIN_EXISTS(E0_MS1) + REPORT_NAME_DIGITAL(__LINE__, E0_MS1_PIN) +#endif +#if PIN_EXISTS(E0_MS2) + REPORT_NAME_DIGITAL(__LINE__, E0_MS2_PIN) +#endif +#if PIN_EXISTS(E0_MS3) + REPORT_NAME_DIGITAL(__LINE__, E0_MS3_PIN) +#endif +#if PIN_EXISTS(E0_STEP) + REPORT_NAME_DIGITAL(__LINE__, E0_STEP_PIN) +#endif +#if PIN_EXISTS(E0_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E0_STDBY_PIN) +#endif +#if PIN_EXISTS(E1_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E1_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E1_CS) + REPORT_NAME_DIGITAL(__LINE__, E1_CS_PIN) +#endif +#if PIN_EXISTS(E1_DIR) + REPORT_NAME_DIGITAL(__LINE__, E1_DIR_PIN) +#endif +#if PIN_EXISTS(E1_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, E1_ENABLE_PIN) +#endif +#if PIN_EXISTS(E1_MS1) + REPORT_NAME_DIGITAL(__LINE__, E1_MS1_PIN) +#endif +#if PIN_EXISTS(E1_MS2) + REPORT_NAME_DIGITAL(__LINE__, E1_MS2_PIN) +#endif +#if PIN_EXISTS(E1_MS3) + REPORT_NAME_DIGITAL(__LINE__, E1_MS3_PIN) +#endif +#if PIN_EXISTS(E1_STEP) + REPORT_NAME_DIGITAL(__LINE__, E1_STEP_PIN) +#endif +#if PIN_EXISTS(E1_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E1_STDBY_PIN) +#endif +#if PIN_EXISTS(E2_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E2_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E2_CS) + REPORT_NAME_DIGITAL(__LINE__, E2_CS_PIN) +#endif +#if PIN_EXISTS(E2_DIR) + REPORT_NAME_DIGITAL(__LINE__, E2_DIR_PIN) +#endif +#if PIN_EXISTS(E2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, E2_ENABLE_PIN) +#endif +#if PIN_EXISTS(E2_MS1) + REPORT_NAME_DIGITAL(__LINE__, E2_MS1_PIN) +#endif +#if PIN_EXISTS(E2_MS2) + REPORT_NAME_DIGITAL(__LINE__, E2_MS2_PIN) +#endif +#if PIN_EXISTS(E2_MS3) + REPORT_NAME_DIGITAL(__LINE__, E2_MS3_PIN) +#endif +#if PIN_EXISTS(E2_STEP) + REPORT_NAME_DIGITAL(__LINE__, E2_STEP_PIN) +#endif +#if PIN_EXISTS(E2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E2_STDBY_PIN) +#endif +#if PIN_EXISTS(E3_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E3_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E3_CS) + REPORT_NAME_DIGITAL(__LINE__, E3_CS_PIN) +#endif +#if PIN_EXISTS(E3_DIR) + REPORT_NAME_DIGITAL(__LINE__, E3_DIR_PIN) +#endif +#if PIN_EXISTS(E3_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, E3_ENABLE_PIN) +#endif +#if PIN_EXISTS(E3_MS1) + REPORT_NAME_DIGITAL(__LINE__, E3_MS1_PIN) +#endif +#if PIN_EXISTS(E3_MS2) + REPORT_NAME_DIGITAL(__LINE__, E3_MS2_PIN) +#endif +#if PIN_EXISTS(E3_MS3) + REPORT_NAME_DIGITAL(__LINE__, E3_MS3_PIN) +#endif +#if PIN_EXISTS(E3_STEP) + REPORT_NAME_DIGITAL(__LINE__, E3_STEP_PIN) +#endif +#if PIN_EXISTS(E3_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E3_STDBY_PIN) +#endif +#if PIN_EXISTS(E4_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E4_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E4_CS) + REPORT_NAME_DIGITAL(__LINE__, E4_CS_PIN) +#endif +#if PIN_EXISTS(E4_DIR) + REPORT_NAME_DIGITAL(__LINE__, E4_DIR_PIN) +#endif +#if PIN_EXISTS(E4_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, E4_ENABLE_PIN) +#endif +#if PIN_EXISTS(E4_MS1) + REPORT_NAME_DIGITAL(__LINE__, E4_MS1_PIN) +#endif +#if PIN_EXISTS(E4_MS2) + REPORT_NAME_DIGITAL(__LINE__, E4_MS2_PIN) +#endif +#if PIN_EXISTS(E4_MS3) + REPORT_NAME_DIGITAL(__LINE__, E4_MS3_PIN) +#endif +#if PIN_EXISTS(E4_STEP) + REPORT_NAME_DIGITAL(__LINE__, E4_STEP_PIN) +#endif +#if PIN_EXISTS(E4_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E4_STDBY_PIN) +#endif +#if PIN_EXISTS(E5_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E5_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E5_CS) + REPORT_NAME_DIGITAL(__LINE__, E5_CS_PIN) +#endif +#if PIN_EXISTS(E5_DIR) + REPORT_NAME_DIGITAL(__LINE__, E5_DIR_PIN) +#endif +#if PIN_EXISTS(E5_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, E5_ENABLE_PIN) +#endif +#if PIN_EXISTS(E5_MS1) + REPORT_NAME_DIGITAL(__LINE__, E5_MS1_PIN) +#endif +#if PIN_EXISTS(E5_MS2) + REPORT_NAME_DIGITAL(__LINE__, E5_MS2_PIN) +#endif +#if PIN_EXISTS(E5_MS3) + REPORT_NAME_DIGITAL(__LINE__, E5_MS3_PIN) +#endif +#if PIN_EXISTS(E5_STEP) + REPORT_NAME_DIGITAL(__LINE__, E5_STEP_PIN) +#endif +#if PIN_EXISTS(E5_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E5_STDBY_PIN) +#endif +#if PIN_EXISTS(E6_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E6_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E6_CS) + REPORT_NAME_DIGITAL(__LINE__, E6_CS_PIN) +#endif +#if PIN_EXISTS(E6_DIR) + REPORT_NAME_DIGITAL(__LINE__, E6_DIR_PIN) +#endif +#if PIN_EXISTS(E6_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, E6_ENABLE_PIN) +#endif +#if PIN_EXISTS(E6_MS1) + REPORT_NAME_DIGITAL(__LINE__, E6_MS1_PIN) +#endif +#if PIN_EXISTS(E6_MS2) + REPORT_NAME_DIGITAL(__LINE__, E6_MS2_PIN) +#endif +#if PIN_EXISTS(E6_MS3) + REPORT_NAME_DIGITAL(__LINE__, E6_MS3_PIN) +#endif +#if PIN_EXISTS(E6_STEP) + REPORT_NAME_DIGITAL(__LINE__, E6_STEP_PIN) +#endif +#if PIN_EXISTS(E6_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E6_STDBY_PIN) +#endif +#if PIN_EXISTS(E7_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E7_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E7_CS) + REPORT_NAME_DIGITAL(__LINE__, E7_CS_PIN) +#endif +#if PIN_EXISTS(E7_DIR) + REPORT_NAME_DIGITAL(__LINE__, E7_DIR_PIN) +#endif +#if PIN_EXISTS(E7_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, E7_ENABLE_PIN) +#endif +#if PIN_EXISTS(E7_MS1) + REPORT_NAME_DIGITAL(__LINE__, E7_MS1_PIN) +#endif +#if PIN_EXISTS(E7_MS2) + REPORT_NAME_DIGITAL(__LINE__, E7_MS2_PIN) +#endif +#if PIN_EXISTS(E7_MS3) + REPORT_NAME_DIGITAL(__LINE__, E7_MS3_PIN) +#endif +#if PIN_EXISTS(E7_STEP) + REPORT_NAME_DIGITAL(__LINE__, E7_STEP_PIN) +#endif +#if PIN_EXISTS(E7_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E7_STDBY_PIN) +#endif +#if _EXISTS(ENET_CRS) + REPORT_NAME_DIGITAL(__LINE__, ENET_CRS) +#endif +#if _EXISTS(ENET_MDIO) + REPORT_NAME_DIGITAL(__LINE__, ENET_MDIO) +#endif +#if _EXISTS(ENET_MOC) + REPORT_NAME_DIGITAL(__LINE__, ENET_MOC) +#endif +#if _EXISTS(ENET_RX_ER) + REPORT_NAME_DIGITAL(__LINE__, ENET_RX_ER) +#endif +#if _EXISTS(ENET_RXD0) + REPORT_NAME_DIGITAL(__LINE__, ENET_RXD0) +#endif +#if _EXISTS(ENET_RXD1) + REPORT_NAME_DIGITAL(__LINE__, ENET_RXD1) +#endif +#if _EXISTS(ENET_TX_EN) + REPORT_NAME_DIGITAL(__LINE__, ENET_TX_EN) +#endif +#if _EXISTS(ENET_TXD0) + REPORT_NAME_DIGITAL(__LINE__, ENET_TXD0) +#endif +#if _EXISTS(ENET_TXD1) + REPORT_NAME_DIGITAL(__LINE__, ENET_TXD1) +#endif +#if PIN_EXISTS(EXP_VOLTAGE_LEVEL) + REPORT_NAME_DIGITAL(__LINE__, EXP_VOLTAGE_LEVEL_PIN) +#endif + +#if _EXISTS(EXT_AUX_A0_IO) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_A0_IO) +#endif +#if _EXISTS(EXT_AUX_A1_IO) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_A1_IO) +#endif +#if _EXISTS(EXT_AUX_A2_IO) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_A2_IO) +#endif +#if _EXISTS(EXT_AUX_A3_IO) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_A3_IO) +#endif +#if _EXISTS(EXT_AUX_A4_IO) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_A4_IO) +#endif +#if _EXISTS(EXT_AUX_PWM_D24) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_PWM_D24) +#endif +#if _EXISTS(EXT_AUX_RX1_D2) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_RX1_D2) +#endif +#if _EXISTS(EXT_AUX_SCL_D0) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_SCL_D0) +#endif +#if _EXISTS(EXT_AUX_SDA_D1) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_SDA_D1) +#endif +#if _EXISTS(EXT_AUX_TX1_D3) + REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_TX1_D3) +#endif +#if _EXISTS(EXTRUDER_0_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, EXTRUDER_0_AUTO_FAN) +#endif +#if _EXISTS(EXTRUDER_1_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, EXTRUDER_1_AUTO_FAN) +#endif +#if PIN_EXISTS(FAN) + REPORT_NAME_DIGITAL(__LINE__, FAN_PIN) +#endif +#if PIN_EXISTS(FAN1) + REPORT_NAME_DIGITAL(__LINE__, FAN1_PIN) +#endif +#if PIN_EXISTS(FAN2) + REPORT_NAME_DIGITAL(__LINE__, FAN2_PIN) +#endif +#if PIN_EXISTS(FAN3) + REPORT_NAME_DIGITAL(__LINE__, FAN3_PIN) +#endif +#if PIN_EXISTS(FAN4) + REPORT_NAME_DIGITAL(__LINE__, FAN4_PIN) +#endif +#if PIN_EXISTS(FAN5) + REPORT_NAME_DIGITAL(__LINE__, FAN5_PIN) +#endif +#if PIN_EXISTS(FAN6) + REPORT_NAME_DIGITAL(__LINE__, FAN6_PIN) +#endif +#if PIN_EXISTS(FAN7) + REPORT_NAME_DIGITAL(__LINE__, FAN7_PIN) +#endif +#if PIN_EXISTS(FAN_MUX0) + REPORT_NAME_DIGITAL(__LINE__, FAN_MUX0_PIN) +#endif +#if PIN_EXISTS(FAN_MUX1) + REPORT_NAME_DIGITAL(__LINE__, FAN_MUX1_PIN) +#endif +#if PIN_EXISTS(FAN_MUX2) + REPORT_NAME_DIGITAL(__LINE__, FAN_MUX2_PIN) +#endif +#if PIN_EXISTS(POWER_LOSS) + REPORT_NAME_DIGITAL(__LINE__, POWER_LOSS_PIN) +#endif +#if PIN_EXISTS(SAFE_POWER) + REPORT_NAME_DIGITAL(__LINE__, SAFE_POWER_PIN) +#endif +#if PIN_EXISTS(FIL_RUNOUT) + REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT_PIN) +#endif +#if PIN_EXISTS(FIL_RUNOUT2) + REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT2_PIN) +#endif +#if PIN_EXISTS(FIL_RUNOUT3) + REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT3_PIN) +#endif +#if PIN_EXISTS(FIL_RUNOUT4) + REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT4_PIN) +#endif +#if PIN_EXISTS(FIL_RUNOUT5) + REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT5_PIN) +#endif +#if PIN_EXISTS(FIL_RUNOUT6) + REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT6_PIN) +#endif +#if PIN_EXISTS(FIL_RUNOUT7) + REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT7_PIN) +#endif +#if PIN_EXISTS(FIL_RUNOUT8) + REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT8_PIN) +#endif +#if PIN_EXISTS(HEATER_0) + REPORT_NAME_DIGITAL(__LINE__, HEATER_0_PIN) +#endif +#if PIN_EXISTS(HEATER_1) + REPORT_NAME_DIGITAL(__LINE__, HEATER_1_PIN) +#endif +#if PIN_EXISTS(HEATER_2) + REPORT_NAME_DIGITAL(__LINE__, HEATER_2_PIN) +#endif +#if PIN_EXISTS(HEATER_3) + REPORT_NAME_DIGITAL(__LINE__, HEATER_3_PIN) +#endif +#if PIN_EXISTS(HEATER_4) + REPORT_NAME_DIGITAL(__LINE__, HEATER_4_PIN) +#endif +#if PIN_EXISTS(HEATER_5) + REPORT_NAME_DIGITAL(__LINE__, HEATER_5_PIN) +#endif +#if PIN_EXISTS(HEATER_6) + REPORT_NAME_DIGITAL(__LINE__, HEATER_6_PIN) +#endif +#if PIN_EXISTS(HEATER_7) + REPORT_NAME_DIGITAL(__LINE__, HEATER_7_PIN) +#endif +#if PIN_EXISTS(HEATER_BED) + REPORT_NAME_DIGITAL(__LINE__, HEATER_BED_PIN) +#endif +#if PIN_EXISTS(HEATER_CHAMBER) + REPORT_NAME_DIGITAL(__LINE__, HEATER_CHAMBER_PIN) +#endif +#if PIN_EXISTS(COOLER) + REPORT_NAME_DIGITAL(__LINE__, COOLER_PIN) +#endif +#if PIN_EXISTS(HOME) + REPORT_NAME_DIGITAL(__LINE__, HOME_PIN) +#endif +#if PIN_EXISTS(I2C_SCL) + REPORT_NAME_DIGITAL(__LINE__, I2C_SCL_PIN) +#endif +#if PIN_EXISTS(I2C_SDA) + REPORT_NAME_DIGITAL(__LINE__, I2C_SDA_PIN) +#endif +#if HAS_KILL + REPORT_NAME_DIGITAL(__LINE__, KILL_PIN) +#endif +#if PIN_EXISTS(FREEZE) + REPORT_NAME_DIGITAL(__LINE__, FREEZE_PIN) +#endif +#if PIN_EXISTS(LCD_BACKLIGHT) + REPORT_NAME_DIGITAL(__LINE__, LCD_BACKLIGHT_PIN) +#endif +#if _EXISTS(LCD_PINS_D4) + REPORT_NAME_DIGITAL(__LINE__, LCD_PINS_D4) +#endif +#if _EXISTS(LCD_PINS_D5) + REPORT_NAME_DIGITAL(__LINE__, LCD_PINS_D5) +#endif +#if _EXISTS(LCD_PINS_D6) + REPORT_NAME_DIGITAL(__LINE__, LCD_PINS_D6) +#endif +#if _EXISTS(LCD_PINS_D7) + REPORT_NAME_DIGITAL(__LINE__, LCD_PINS_D7) +#endif +#if _EXISTS(LCD_PINS_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, LCD_PINS_ENABLE) +#endif +#if _EXISTS(LCD_PINS_RS) + REPORT_NAME_DIGITAL(__LINE__, LCD_PINS_RS) +#endif +#if _EXISTS(LCD_SDSS) + REPORT_NAME_DIGITAL(__LINE__, LCD_SDSS) +#endif +#if PIN_EXISTS(LED_GREEN) + REPORT_NAME_DIGITAL(__LINE__, LED_GREEN_PIN) +#endif +#if PIN_EXISTS(LED) + REPORT_NAME_DIGITAL(__LINE__, LED_PIN) +#endif +#if PIN_EXISTS(LED2) + REPORT_NAME_DIGITAL(__LINE__, LED2_PIN) +#endif +#if PIN_EXISTS(LED3) + REPORT_NAME_DIGITAL(__LINE__, LED3_PIN) +#endif +#if PIN_EXISTS(LED4) + REPORT_NAME_DIGITAL(__LINE__, LED4_PIN) +#endif +#if PIN_EXISTS(LED_RED) + REPORT_NAME_DIGITAL(__LINE__, LED_RED_PIN) +#endif +#if PIN_EXISTS(TEMP_0_CS) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_CS_PIN) +#endif +#if PIN_EXISTS(TEMP_0_SCK) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_SCK_PIN) +#endif +#if PIN_EXISTS(TEMP_0_MOSI) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_MOSI_PIN) +#endif +#if PIN_EXISTS(TEMP_0_MISO) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_MISO_PIN) +#endif +#if PIN_EXISTS(TEMP_1_CS) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_CS_PIN) +#endif +#if PIN_EXISTS(TEMP_1_SCK) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_SCK_PIN) +#endif +#if PIN_EXISTS(TEMP_1_MOSI) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_MOSI_PIN) +#endif +#if PIN_EXISTS(TEMP_1_MISO) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_MISO_PIN) +#endif +#if PIN_EXISTS(MAX7219_CLK) + REPORT_NAME_DIGITAL(__LINE__, MAX7219_CLK_PIN) +#endif +#if PIN_EXISTS(MAX7219_DIN) + REPORT_NAME_DIGITAL(__LINE__, MAX7219_DIN_PIN) +#endif +#if PIN_EXISTS(MAX7219_LOAD) + REPORT_NAME_DIGITAL(__LINE__, MAX7219_LOAD_PIN) +#endif + +//#if _EXISTS(MISO) +// REPORT_NAME_DIGITAL(__LINE__, MISO) +//#endif +#if PIN_EXISTS(MISO) + REPORT_NAME_DIGITAL(__LINE__, SD_MISO_PIN) +#endif +#if PIN_EXISTS(MOSFET_A) + REPORT_NAME_DIGITAL(__LINE__, MOSFET_A_PIN) +#endif +#if PIN_EXISTS(MOSFET_B) + REPORT_NAME_DIGITAL(__LINE__, MOSFET_B_PIN) +#endif +#if PIN_EXISTS(MOSFET_C) + REPORT_NAME_DIGITAL(__LINE__, MOSFET_C_PIN) +#endif +#if PIN_EXISTS(MOSFET_D) + REPORT_NAME_DIGITAL(__LINE__, MOSFET_D_PIN) +#endif +//#if _EXISTS(MOSI) +// REPORT_NAME_DIGITAL(__LINE__, MOSI) +//#endif +#if PIN_EXISTS(MOSI) + REPORT_NAME_DIGITAL(__LINE__, SD_MOSI_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E0_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E1_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_X) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_X_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Y_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_XY_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_X) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_X_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Y_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Z_PIN) +#endif +#if PIN_EXISTS(MOTOR_FAULT) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_FAULT_PIN) +#endif +#if PIN_EXISTS(PHOTOGRAPH) + REPORT_NAME_DIGITAL(__LINE__, PHOTOGRAPH_PIN) +#endif +#if PIN_EXISTS(CHDK) + REPORT_NAME_DIGITAL(__LINE__, CHDK_PIN) +#endif +#if PIN_EXISTS(PS_ON) + REPORT_NAME_DIGITAL(__LINE__, PS_ON_PIN) +#endif +#if PIN_EXISTS(PWM_1) + REPORT_NAME_DIGITAL(__LINE__, PWM_1_PIN) +#endif +#if PIN_EXISTS(PWM_2) + REPORT_NAME_DIGITAL(__LINE__, PWM_2_PIN) +#endif +#if _EXISTS(REF_CLK) + REPORT_NAME_DIGITAL(__LINE__, REF_CLK) +#endif +#if PIN_EXISTS(NEOPIXEL) + REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL_PIN) +#endif +#if PIN_EXISTS(NEOPIXEL2) + REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL2_PIN) +#endif +#if PIN_EXISTS(RGB_LED_R) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_R_PIN) +#endif +#if PIN_EXISTS(RGB_LED_G) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_G_PIN) +#endif +#if PIN_EXISTS(RGB_LED_B) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_B_PIN) +#endif +#if PIN_EXISTS(RGB_LED_W) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_W_PIN) +#endif +#if PIN_EXISTS(RX_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, RX_ENABLE_PIN) +#endif +#if PIN_EXISTS(SAFETY_TRIGGERED) + REPORT_NAME_DIGITAL(__LINE__, SAFETY_TRIGGERED_PIN) +#endif +//#if _EXISTS(SCK) +// REPORT_NAME_DIGITAL(__LINE__, SCK) +//#endif +#if PIN_EXISTS(SCK) + REPORT_NAME_DIGITAL(__LINE__, SD_SCK_PIN) +#endif +//#if _EXISTS(SCL) +// REPORT_NAME_DIGITAL(__LINE__, SCL) +//#endif +#if PIN_EXISTS(SD_DETECT) + REPORT_NAME_DIGITAL(__LINE__, SD_DETECT_PIN) +#endif +//#if _EXISTS(SDA) +// REPORT_NAME_DIGITAL(__LINE__, SDA) +//#endif +#if PIN_EXISTS(SDPOWER) + REPORT_NAME_DIGITAL(__LINE__, SDPOWER_PIN) +#endif +#if _EXISTS(SDSS) + REPORT_NAME_DIGITAL(__LINE__, SDSS) +#endif +#if _EXISTS(SERVO0) + REPORT_NAME_DIGITAL(__LINE__, SERVO0) +#endif +#if PIN_EXISTS(SERVO0) + REPORT_NAME_DIGITAL(__LINE__, SERVO0_PIN) +#endif +#if PIN_EXISTS(SERVO1) + REPORT_NAME_DIGITAL(__LINE__, SERVO1_PIN) +#endif +#if PIN_EXISTS(SERVO2) + REPORT_NAME_DIGITAL(__LINE__, SERVO2_PIN) +#endif +#if PIN_EXISTS(SERVO3) + REPORT_NAME_DIGITAL(__LINE__, SERVO3_PIN) +#endif +#if PIN_EXISTS(SHIFT_CLK) + REPORT_NAME_DIGITAL(__LINE__, SHIFT_CLK_PIN) +#endif +#if PIN_EXISTS(SHIFT_EN) + REPORT_NAME_DIGITAL(__LINE__, SHIFT_EN_PIN) +#endif +#if PIN_EXISTS(SHIFT_LD) + REPORT_NAME_DIGITAL(__LINE__, SHIFT_LD_PIN) +#endif +#if PIN_EXISTS(SHIFT_OUT) + REPORT_NAME_DIGITAL(__LINE__, SHIFT_OUT_PIN) +#endif +#if PIN_EXISTS(SLED) + REPORT_NAME_DIGITAL(__LINE__, SLED_PIN) +#endif +#if PIN_EXISTS(SLEEP_WAKE) + REPORT_NAME_DIGITAL(__LINE__, SLEEP_WAKE_PIN) +#endif +#if PIN_EXISTS(SOL0) + REPORT_NAME_DIGITAL(__LINE__, SOL0_PIN) +#endif +#if PIN_EXISTS(SOL1) + REPORT_NAME_DIGITAL(__LINE__, SOL1_PIN) +#endif +#if PIN_EXISTS(SOL2) + REPORT_NAME_DIGITAL(__LINE__, SOL2_PIN) +#endif +#if PIN_EXISTS(SOL3) + REPORT_NAME_DIGITAL(__LINE__, SOL3_PIN) +#endif +#if PIN_EXISTS(SOL4) + REPORT_NAME_DIGITAL(__LINE__, SOL4_PIN) +#endif +#if PIN_EXISTS(SOL5) + REPORT_NAME_DIGITAL(__LINE__, SOL5_PIN) +#endif +#if PIN_EXISTS(SOL6) + REPORT_NAME_DIGITAL(__LINE__, SOL6_PIN) +#endif +#if PIN_EXISTS(SOL7) + REPORT_NAME_DIGITAL(__LINE__, SOL7_PIN) +#endif +#if _EXISTS(SPARE_IO) + REPORT_NAME_DIGITAL(__LINE__, SPARE_IO) +#endif +#if PIN_EXISTS(SPI_EEPROM1_CS) + REPORT_NAME_DIGITAL(__LINE__, SPI_EEPROM1_CS_PIN) +#endif +#if PIN_EXISTS(SPI_EEPROM2_CS) + REPORT_NAME_DIGITAL(__LINE__, SPI_EEPROM2_CS_PIN) +#endif +#if PIN_EXISTS(SPI_FLASH_CS) + REPORT_NAME_DIGITAL(__LINE__, SPI_FLASH_CS_PIN) +#endif +#if PIN_EXISTS(SPINDLE_DIR) + REPORT_NAME_DIGITAL(__LINE__, SPINDLE_DIR_PIN) +#endif +#if PIN_EXISTS(SPINDLE_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, SPINDLE_ENABLE_PIN) +#endif +#if PIN_EXISTS(SPINDLE_LASER_ENA) + REPORT_NAME_DIGITAL(__LINE__, SPINDLE_LASER_ENA_PIN) +#endif +#if PIN_EXISTS(SPINDLE_LASER_PWM) + REPORT_NAME_DIGITAL(__LINE__, SPINDLE_LASER_PWM_PIN) +#endif +#if PIN_EXISTS(SR_CLK) + REPORT_NAME_DIGITAL(__LINE__, SR_CLK_PIN) +#endif +#if PIN_EXISTS(SR_DATA) + REPORT_NAME_DIGITAL(__LINE__, SR_DATA_PIN) +#endif +#if PIN_EXISTS(SR_STROBE) + REPORT_NAME_DIGITAL(__LINE__, SR_STROBE_PIN) +#endif +#if PIN_EXISTS(SS) + REPORT_NAME_DIGITAL(__LINE__, SD_SS_PIN) +#endif +#if PIN_EXISTS(STAT_LED_BLUE) + REPORT_NAME_DIGITAL(__LINE__, STAT_LED_BLUE_PIN) +#endif +#if _EXISTS(STAT_LED_RED_LED) + REPORT_NAME_DIGITAL(__LINE__, STAT_LED_RED_LED) +#endif +#if PIN_EXISTS(STAT_LED_RED) + REPORT_NAME_DIGITAL(__LINE__, STAT_LED_RED_PIN) +#endif +#if PIN_EXISTS(STEPPER_RESET) + REPORT_NAME_DIGITAL(__LINE__, STEPPER_RESET_PIN) +#endif +#if PIN_EXISTS(SUICIDE) + REPORT_NAME_DIGITAL(__LINE__, SUICIDE_PIN) +#endif +#if PIN_EXISTS(TLC_BLANK) + REPORT_NAME_DIGITAL(__LINE__, TLC_BLANK_PIN) +#endif +#if PIN_EXISTS(TLC_CLOCK) + REPORT_NAME_DIGITAL(__LINE__, TLC_CLOCK_PIN) +#endif +#if PIN_EXISTS(TLC_DATA) + REPORT_NAME_DIGITAL(__LINE__, TLC_DATA_PIN) +#endif +#if PIN_EXISTS(TLC_XLAT) + REPORT_NAME_DIGITAL(__LINE__, TLC_XLAT_PIN) +#endif +#if PIN_EXISTS(TOOL_0) + REPORT_NAME_DIGITAL(__LINE__, TOOL_0_PIN) +#endif +#if PIN_EXISTS(TOOL_0_PWM) + REPORT_NAME_DIGITAL(__LINE__, TOOL_0_PWM_PIN) +#endif +#if PIN_EXISTS(TOOL_1) + REPORT_NAME_DIGITAL(__LINE__, TOOL_1_PIN) +#endif +#if PIN_EXISTS(TOOL_1_PWM) + REPORT_NAME_DIGITAL(__LINE__, TOOL_1_PWM_PIN) +#endif +#if PIN_EXISTS(TOOL_2) + REPORT_NAME_DIGITAL(__LINE__, TOOL_2_PIN) +#endif +#if PIN_EXISTS(TOOL_2_PWM) + REPORT_NAME_DIGITAL(__LINE__, TOOL_2_PWM_PIN) +#endif +#if PIN_EXISTS(TOOL_3) + REPORT_NAME_DIGITAL(__LINE__, TOOL_3_PIN) +#endif +#if PIN_EXISTS(TOOL_3_PWM) + REPORT_NAME_DIGITAL(__LINE__, TOOL_3_PWM_PIN) +#endif +#if PIN_EXISTS(TOOL_PWM) + REPORT_NAME_DIGITAL(__LINE__, TOOL_PWM_PIN) +#endif +#if PIN_EXISTS(TX_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, TX_ENABLE_PIN) +#endif +#if _EXISTS(UI1) + REPORT_NAME_DIGITAL(__LINE__, UI1) +#endif +#if _EXISTS(UI2) + REPORT_NAME_DIGITAL(__LINE__, UI2) +#endif +#if _EXISTS(UNUSED_PWM) + REPORT_NAME_DIGITAL(__LINE__, UNUSED_PWM) +#endif +#if PIN_EXISTS(X_ATT) + REPORT_NAME_DIGITAL(__LINE__, X_ATT_PIN) +#endif +#if PIN_EXISTS(X_CS) + REPORT_NAME_DIGITAL(__LINE__, X_CS_PIN) +#endif +#if PIN_EXISTS(X_DIR) + REPORT_NAME_DIGITAL(__LINE__, X_DIR_PIN) +#endif +#if PIN_EXISTS(X_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, X_ENABLE_PIN) +#endif +#if PIN_EXISTS(X_MAX) + REPORT_NAME_DIGITAL(__LINE__, X_MAX_PIN) +#endif +#if PIN_EXISTS(X_MIN) + REPORT_NAME_DIGITAL(__LINE__, X_MIN_PIN) +#endif +#if PIN_EXISTS(X_DIAG) + REPORT_NAME_DIGITAL(__LINE__, X_DIAG_PIN) +#endif +#if PIN_EXISTS(X_MS1) + REPORT_NAME_DIGITAL(__LINE__, X_MS1_PIN) +#endif +#if PIN_EXISTS(X_MS2) + REPORT_NAME_DIGITAL(__LINE__, X_MS2_PIN) +#endif +#if PIN_EXISTS(X_MS3) + REPORT_NAME_DIGITAL(__LINE__, X_MS3_PIN) +#endif +#if PIN_EXISTS(X_STEP) + REPORT_NAME_DIGITAL(__LINE__, X_STEP_PIN) +#endif +#if PIN_EXISTS(X_STDBY) + REPORT_NAME_DIGITAL(__LINE__, X_STDBY_PIN) +#endif +#if PIN_EXISTS(X_STOP) + REPORT_NAME_DIGITAL(__LINE__, X_STOP_PIN) +#endif +#if PIN_EXISTS(X2_CS) + REPORT_NAME_DIGITAL(__LINE__, X2_CS_PIN) +#endif +#if PIN_EXISTS(X2_DIR) + REPORT_NAME_DIGITAL(__LINE__, X2_DIR_PIN) +#endif +#if PIN_EXISTS(X2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, X2_ENABLE_PIN) +#endif +#if PIN_EXISTS(X2_MAX) + REPORT_NAME_DIGITAL(__LINE__, X2_MAX_PIN) +#endif +#if PIN_EXISTS(X2_MIN) + REPORT_NAME_DIGITAL(__LINE__, X2_MIN_PIN) +#endif +#if PIN_EXISTS(X2_MS1) + REPORT_NAME_DIGITAL(__LINE__, X2_MS1_PIN) +#endif +#if PIN_EXISTS(X2_MS2) + REPORT_NAME_DIGITAL(__LINE__, X2_MS2_PIN) +#endif +#if PIN_EXISTS(X2_MS3) + REPORT_NAME_DIGITAL(__LINE__, X2_MS3_PIN) +#endif +#if PIN_EXISTS(X2_STEP) + REPORT_NAME_DIGITAL(__LINE__, X2_STEP_PIN) +#endif +#if PIN_EXISTS(Y_ATT) + REPORT_NAME_DIGITAL(__LINE__, Y_ATT_PIN) +#endif +#if PIN_EXISTS(Y_CS) + REPORT_NAME_DIGITAL(__LINE__, Y_CS_PIN) +#endif +#if PIN_EXISTS(Y_DIR) + REPORT_NAME_DIGITAL(__LINE__, Y_DIR_PIN) +#endif +#if PIN_EXISTS(Y_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Y_ENABLE_PIN) +#endif +#if PIN_EXISTS(Y_MAX) + REPORT_NAME_DIGITAL(__LINE__, Y_MAX_PIN) +#endif +#if PIN_EXISTS(Y_MIN) + REPORT_NAME_DIGITAL(__LINE__, Y_MIN_PIN) +#endif +#if PIN_EXISTS(Y_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Y_DIAG_PIN) +#endif +#if PIN_EXISTS(Y_MS1) + REPORT_NAME_DIGITAL(__LINE__, Y_MS1_PIN) +#endif +#if PIN_EXISTS(Y_MS2) + REPORT_NAME_DIGITAL(__LINE__, Y_MS2_PIN) +#endif +#if PIN_EXISTS(Y_MS3) + REPORT_NAME_DIGITAL(__LINE__, Y_MS3_PIN) +#endif +#if PIN_EXISTS(Y_STEP) + REPORT_NAME_DIGITAL(__LINE__, Y_STEP_PIN) +#endif +#if PIN_EXISTS(Y_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Y_STDBY_PIN) +#endif +#if PIN_EXISTS(Y_STOP) + REPORT_NAME_DIGITAL(__LINE__, Y_STOP_PIN) +#endif +#if PIN_EXISTS(Y2_CS) + REPORT_NAME_DIGITAL(__LINE__, Y2_CS_PIN) +#endif +#if PIN_EXISTS(Y2_DIR) + REPORT_NAME_DIGITAL(__LINE__, Y2_DIR_PIN) +#endif +#if PIN_EXISTS(Y2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Y2_ENABLE_PIN) +#endif +#if PIN_EXISTS(Y2_MAX) + REPORT_NAME_DIGITAL(__LINE__, Y2_MAX_PIN) +#endif +#if PIN_EXISTS(Y2_MIN) + REPORT_NAME_DIGITAL(__LINE__, Y2_MIN_PIN) +#endif +#if PIN_EXISTS(Y2_MS1) + REPORT_NAME_DIGITAL(__LINE__, Y2_MS1_PIN) +#endif +#if PIN_EXISTS(Y2_MS2) + REPORT_NAME_DIGITAL(__LINE__, Y2_MS2_PIN) +#endif +#if PIN_EXISTS(Y2_MS3) + REPORT_NAME_DIGITAL(__LINE__, Y2_MS3_PIN) +#endif +#if PIN_EXISTS(Y2_STEP) + REPORT_NAME_DIGITAL(__LINE__, Y2_STEP_PIN) +#endif +#if PIN_EXISTS(Z_ATT) + REPORT_NAME_DIGITAL(__LINE__, Z_ATT_PIN) +#endif +#if PIN_EXISTS(Z_CS) + REPORT_NAME_DIGITAL(__LINE__, Z_CS_PIN) +#endif +#if PIN_EXISTS(Z_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z_DIR_PIN) +#endif +#if PIN_EXISTS(Z_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z_MAX_PIN) +#endif +#if PIN_EXISTS(Z_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PIN) +#endif +#if PIN_EXISTS(Z_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z_DIAG_PIN) +#endif +#if PIN_EXISTS(Z_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z_MS1_PIN) +#endif +#if PIN_EXISTS(Z_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z_MS2_PIN) +#endif +#if PIN_EXISTS(Z_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z_MS3_PIN) +#endif +#if PIN_EXISTS(Z_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z_STEP_PIN) +#endif +#if PIN_EXISTS(Z_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z_STDBY_PIN) +#endif +#if PIN_EXISTS(Z_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z_STOP_PIN) +#endif +#if PIN_EXISTS(Z2_CS) + REPORT_NAME_DIGITAL(__LINE__, Z2_CS_PIN) +#endif +#if PIN_EXISTS(Z2_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z2_DIR_PIN) +#endif +#if PIN_EXISTS(Z2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z2_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z2_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z2_MAX_PIN) +#endif +#if PIN_EXISTS(Z2_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z2_MIN_PIN) +#endif +#if PIN_EXISTS(Z2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z2_DIAG_PIN) +#endif +#if PIN_EXISTS(Z2_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z2_MS1_PIN) +#endif +#if PIN_EXISTS(Z2_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z2_MS2_PIN) +#endif +#if PIN_EXISTS(Z2_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z2_MS3_PIN) +#endif +#if PIN_EXISTS(Z2_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z2_STEP_PIN) +#endif +#if PIN_EXISTS(Z2_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z2_STOP_PIN) +#endif +#if PIN_EXISTS(Z3_CS) + REPORT_NAME_DIGITAL(__LINE__, Z3_CS_PIN) +#endif +#if PIN_EXISTS(Z3_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z3_DIR_PIN) +#endif +#if PIN_EXISTS(Z3_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z3_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z3_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z3_MAX_PIN) +#endif +#if PIN_EXISTS(Z3_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z3_MIN_PIN) +#endif +#if PIN_EXISTS(Z3_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z3_MS1_PIN) +#endif +#if PIN_EXISTS(Z3_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z3_MS2_PIN) +#endif +#if PIN_EXISTS(Z3_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z3_MS3_PIN) +#endif +#if PIN_EXISTS(Z3_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z3_STEP_PIN) +#endif +#if PIN_EXISTS(Z4_CS) + REPORT_NAME_DIGITAL(__LINE__, Z4_CS_PIN) +#endif +#if PIN_EXISTS(Z4_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z4_DIR_PIN) +#endif +#if PIN_EXISTS(Z4_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z4_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z4_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z4_MAX_PIN) +#endif +#if PIN_EXISTS(Z4_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z4_MIN_PIN) +#endif +#if PIN_EXISTS(Z4_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z4_MS1_PIN) +#endif +#if PIN_EXISTS(Z4_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z4_MS2_PIN) +#endif +#if PIN_EXISTS(Z4_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z4_MS3_PIN) +#endif +#if PIN_EXISTS(Z4_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z4_STEP_PIN) +#endif +#if PIN_EXISTS(Z_MIN_PROBE) + REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PROBE_PIN) +#endif +#if PIN_EXISTS(PROBE_ACTIVATION_SWITCH) + REPORT_NAME_DIGITAL(__LINE__, PROBE_ACTIVATION_SWITCH_PIN) +#endif +#if PIN_EXISTS(PROBE_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, PROBE_ENABLE_PIN) +#endif +#if PIN_EXISTS(PROBE_TARE) + REPORT_NAME_DIGITAL(__LINE__, PROBE_TARE_PIN) +#endif +#if PIN_EXISTS(I_ATT) + REPORT_NAME_DIGITAL(__LINE__, I_ATT_PIN) +#endif +#if PIN_EXISTS(I_CS) + REPORT_NAME_DIGITAL(__LINE__, I_CS_PIN) +#endif +#if PIN_EXISTS(I_DIR) + REPORT_NAME_DIGITAL(__LINE__, I_DIR_PIN) +#endif +#if PIN_EXISTS(I_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, I_ENABLE_PIN) +#endif +#if PIN_EXISTS(I_MAX) + REPORT_NAME_DIGITAL(__LINE__, I_MAX_PIN) +#endif +#if PIN_EXISTS(I_MIN) + REPORT_NAME_DIGITAL(__LINE__, I_MIN_PIN) +#endif +#if PIN_EXISTS(I_MS1) + REPORT_NAME_DIGITAL(__LINE__, I_MS1_PIN) +#endif +#if PIN_EXISTS(I_MS2) + REPORT_NAME_DIGITAL(__LINE__, I_MS2_PIN) +#endif +#if PIN_EXISTS(I_MS3) + REPORT_NAME_DIGITAL(__LINE__, I_MS3_PIN) +#endif +#if PIN_EXISTS(I_STEP) + REPORT_NAME_DIGITAL(__LINE__, I_STEP_PIN) +#endif +#if PIN_EXISTS(I_STOP) + REPORT_NAME_DIGITAL(__LINE__, I_STOP_PIN) +#endif +#if PIN_EXISTS(J_ATT) + REPORT_NAME_DIGITAL(__LINE__, J_ATT_PIN) +#endif +#if PIN_EXISTS(J_CS) + REPORT_NAME_DIGITAL(__LINE__, J_CS_PIN) +#endif +#if PIN_EXISTS(J_DIR) + REPORT_NAME_DIGITAL(__LINE__, J_DIR_PIN) +#endif +#if PIN_EXISTS(J_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, J_ENABLE_PIN) +#endif +#if PIN_EXISTS(J_MAX) + REPORT_NAME_DIGITAL(__LINE__, J_MAX_PIN) +#endif +#if PIN_EXISTS(J_MIN) + REPORT_NAME_DIGITAL(__LINE__, J_MIN_PIN) +#endif +#if PIN_EXISTS(J_MS1) + REPORT_NAME_DIGITAL(__LINE__, J_MS1_PIN) +#endif +#if PIN_EXISTS(J_MS2) + REPORT_NAME_DIGITAL(__LINE__, J_MS2_PIN) +#endif +#if PIN_EXISTS(J_MS3) + REPORT_NAME_DIGITAL(__LINE__, J_MS3_PIN) +#endif +#if PIN_EXISTS(J_STEP) + REPORT_NAME_DIGITAL(__LINE__, J_STEP_PIN) +#endif +#if PIN_EXISTS(J_STOP) + REPORT_NAME_DIGITAL(__LINE__, J_STOP_PIN) +#endif +#if PIN_EXISTS(K_ATT) + REPORT_NAME_DIGITAL(__LINE__, K_ATT_PIN) +#endif +#if PIN_EXISTS(K_CS) + REPORT_NAME_DIGITAL(__LINE__, K_CS_PIN) +#endif +#if PIN_EXISTS(K_DIR) + REPORT_NAME_DIGITAL(__LINE__, K_DIR_PIN) +#endif +#if PIN_EXISTS(K_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, K_ENABLE_PIN) +#endif +#if PIN_EXISTS(K_MAX) + REPORT_NAME_DIGITAL(__LINE__, K_MAX_PIN) +#endif +#if PIN_EXISTS(K_MIN) + REPORT_NAME_DIGITAL(__LINE__, K_MIN_PIN) +#endif +#if PIN_EXISTS(K_MS1) + REPORT_NAME_DIGITAL(__LINE__, K_MS1_PIN) +#endif +#if PIN_EXISTS(K_MS2) + REPORT_NAME_DIGITAL(__LINE__, K_MS2_PIN) +#endif +#if PIN_EXISTS(K_MS3) + REPORT_NAME_DIGITAL(__LINE__, K_MS3_PIN) +#endif +#if PIN_EXISTS(K_STEP) + REPORT_NAME_DIGITAL(__LINE__, K_STEP_PIN) +#endif +#if PIN_EXISTS(K_STOP) + REPORT_NAME_DIGITAL(__LINE__, K_STOP_PIN) +#endif +#if PIN_EXISTS(ZRIB_V20_D6) + REPORT_NAME_DIGITAL(__LINE__, ZRIB_V20_D6_PIN) +#endif +#if PIN_EXISTS(ZRIB_V20_D9) + REPORT_NAME_DIGITAL(__LINE__, ZRIB_V20_D9_PIN) +#endif +#if PIN_EXISTS(X_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, X_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(X_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, X_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(X2_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, X2_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(X2_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, X2_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(Y_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, Y_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(Y_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, Y_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(Y2_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, Y2_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(Y2_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, Y2_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(Z_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, Z_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(Z_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, Z_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(Z2_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, Z2_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(Z2_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, Z2_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(Z3_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, Z3_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(Z3_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, Z3_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(Z4_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, Z4_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(Z4_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, Z4_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(I_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(I_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(J_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(J_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(K_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(K_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(E0_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E0_DIAG_PIN) +#endif +#if PIN_EXISTS(E0_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, E0_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(E0_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, E0_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(E1_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E1_DIAG_PIN) +#endif +#if PIN_EXISTS(E1_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, E1_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(E1_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, E1_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(E2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E2_DIAG_PIN) +#endif +#if PIN_EXISTS(E2_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, E2_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(E2_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, E2_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(E3_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E3_DIAG_PIN) +#endif +#if PIN_EXISTS(E3_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, E3_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(E3_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, E3_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(E4_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E4_DIAG_PIN) +#endif +#if PIN_EXISTS(E4_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, E4_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(E4_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, E4_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(E5_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E5_DIAG_PIN) +#endif +#if PIN_EXISTS(E5_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, E5_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(E5_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, E5_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(E6_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E6_DIAG_PIN) +#endif +#if PIN_EXISTS(E6_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, E6_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(E6_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, E6_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(E7_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E7_DIAG_PIN) +#endif +#if PIN_EXISTS(E7_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, E7_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(E7_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, E7_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(I_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(I_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(J_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(J_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(K_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(K_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(L6470_CHAIN_SCK) + REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SCK_PIN) +#endif +#if PIN_EXISTS(L6470_CHAIN_MISO) + REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MISO_PIN) +#endif +#if PIN_EXISTS(L6470_CHAIN_MOSI) + REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MOSI_PIN) +#endif +#if PIN_EXISTS(L6470_CHAIN_SS) + REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SS_PIN) +#endif +#if PIN_EXISTS(L6470_RESET_CHAIN) + REPORT_NAME_DIGITAL(__LINE__, L6470_RESET_CHAIN_PIN) +#endif +#if PIN_EXISTS(FET_SAFETY) + REPORT_NAME_DIGITAL(__LINE__, FET_SAFETY_PIN) +#endif +#if PIN_EXISTS(TOUCH_MISO) + REPORT_NAME_DIGITAL(__LINE__, TOUCH_MISO_PIN) +#endif +#if PIN_EXISTS(TOUCH_MOSI) + REPORT_NAME_DIGITAL(__LINE__, TOUCH_MOSI_PIN) +#endif +#if PIN_EXISTS(TOUCH_SCK) + REPORT_NAME_DIGITAL(__LINE__, TOUCH_SCK_PIN) +#endif +#if PIN_EXISTS(TOUCH_CS) + REPORT_NAME_DIGITAL(__LINE__, TOUCH_CS_PIN) +#endif +#if PIN_EXISTS(TOUCH_INT) + REPORT_NAME_DIGITAL(__LINE__, TOUCH_INT_PIN) +#endif +#if PIN_EXISTS(USB_CS) + REPORT_NAME_DIGITAL(__LINE__, USB_CS_PIN) +#endif +#if PIN_EXISTS(USB_INTR) + REPORT_NAME_DIGITAL(__LINE__, USB_INTR_PIN) +#endif +#if PIN_EXISTS(MMU2_RST) + REPORT_NAME_DIGITAL(__LINE__, MMU2_RST_PIN) +#endif +#if PIN_EXISTS(CALIBRATION) + REPORT_NAME_DIGITAL(__LINE__, CALIBRATION_PIN) +#endif +#if PIN_EXISTS(SMART_EFFECTOR_MOD) + REPORT_NAME_DIGITAL(__LINE__, SMART_EFFECTOR_MOD_PIN) +#endif +#if PIN_EXISTS(CLOSED_LOOP_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, CLOSED_LOOP_ENABLE_PIN) +#endif +#if PIN_EXISTS(CLOSED_LOOP_MOVE_COMPLETE) + REPORT_NAME_DIGITAL(__LINE__, CLOSED_LOOP_MOVE_COMPLETE_PIN) +#endif +#if PIN_EXISTS(ESP_WIFI_MODULE_RESET) + REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_RESET_PIN) +#endif +#if PIN_EXISTS(ESP_WIFI_MODULE_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_ENABLE_PIN) +#endif +#if PIN_EXISTS(ESP_WIFI_MODULE_GPIO0) + REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_GPIO0_PIN) +#endif +#if PIN_EXISTS(ESP_WIFI_MODULE_GPIO2) + REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_GPIO2_PIN) +#endif +// TFT PINS +#if PIN_EXISTS(TFT_CS) + REPORT_NAME_DIGITAL(__LINE__, TFT_CS_PIN) +#endif +#if PIN_EXISTS(TFT_A0) + REPORT_NAME_DIGITAL(__LINE__, TFT_A0_PIN) +#endif +#if PIN_EXISTS(TFT_DC) + REPORT_NAME_DIGITAL(__LINE__, TFT_DC_PIN) +#endif +#if PIN_EXISTS(TFT_MISO) + REPORT_NAME_DIGITAL(__LINE__, TFT_MISO_PIN) +#endif +#if PIN_EXISTS(TFT_BACKLIGHT) + REPORT_NAME_DIGITAL(__LINE__, TFT_BACKLIGHT_PIN) +#endif +#if PIN_EXISTS(TFT_RESET) + REPORT_NAME_DIGITAL(__LINE__, TFT_RESET_PIN) +#endif diff --git a/src/pins/pins_postprocess.h b/src/pins/pins_postprocess.h new file mode 100644 index 0000000..ab42c30 --- /dev/null +++ b/src/pins/pins_postprocess.h @@ -0,0 +1,1435 @@ +/** + * 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 . + * + */ +#pragma once + +// +// File: pins/pins_postprocess.h +// Post-process pins according to configured settings +// + +// Define certain undefined pins +#ifndef X_MS1_PIN + #define X_MS1_PIN -1 +#endif +#ifndef X_MS2_PIN + #define X_MS2_PIN -1 +#endif +#ifndef X_MS3_PIN + #define X_MS3_PIN -1 +#endif +#ifndef Y_MS1_PIN + #define Y_MS1_PIN -1 +#endif +#ifndef Y_MS2_PIN + #define Y_MS2_PIN -1 +#endif +#ifndef Y_MS3_PIN + #define Y_MS3_PIN -1 +#endif +#ifndef Z_MS1_PIN + #define Z_MS1_PIN -1 +#endif +#ifndef Z_MS2_PIN + #define Z_MS2_PIN -1 +#endif +#ifndef Z_MS3_PIN + #define Z_MS3_PIN -1 +#endif +#ifndef E0_MS1_PIN + #define E0_MS1_PIN -1 +#endif +#ifndef E0_MS2_PIN + #define E0_MS2_PIN -1 +#endif +#ifndef E0_MS3_PIN + #define E0_MS3_PIN -1 +#endif +#ifndef E1_MS1_PIN + #define E1_MS1_PIN -1 +#endif +#ifndef E1_MS2_PIN + #define E1_MS2_PIN -1 +#endif +#ifndef E1_MS3_PIN + #define E1_MS3_PIN -1 +#endif +#ifndef E2_MS1_PIN + #define E2_MS1_PIN -1 +#endif +#ifndef E2_MS2_PIN + #define E2_MS2_PIN -1 +#endif +#ifndef E2_MS3_PIN + #define E2_MS3_PIN -1 +#endif +#ifndef E3_MS1_PIN + #define E3_MS1_PIN -1 +#endif +#ifndef E3_MS2_PIN + #define E3_MS2_PIN -1 +#endif +#ifndef E3_MS3_PIN + #define E3_MS3_PIN -1 +#endif +#ifndef E4_MS1_PIN + #define E4_MS1_PIN -1 +#endif +#ifndef E4_MS2_PIN + #define E4_MS2_PIN -1 +#endif +#ifndef E4_MS3_PIN + #define E4_MS3_PIN -1 +#endif +#ifndef E5_MS1_PIN + #define E5_MS1_PIN -1 +#endif +#ifndef E5_MS2_PIN + #define E5_MS2_PIN -1 +#endif +#ifndef E5_MS3_PIN + #define E5_MS3_PIN -1 +#endif +#ifndef E6_MS1_PIN + #define E6_MS1_PIN -1 +#endif +#ifndef E6_MS2_PIN + #define E6_MS2_PIN -1 +#endif +#ifndef E6_MS3_PIN + #define E6_MS3_PIN -1 +#endif +#ifndef E7_MS1_PIN + #define E7_MS1_PIN -1 +#endif +#ifndef E7_MS2_PIN + #define E7_MS2_PIN -1 +#endif +#ifndef E7_MS3_PIN + #define E7_MS3_PIN -1 +#endif + +#ifndef E0_STEP_PIN + #define E0_STEP_PIN -1 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN -1 +#endif +#ifndef E0_ENABLE_PIN + #define E0_ENABLE_PIN -1 +#endif +#ifndef E1_STEP_PIN + #define E1_STEP_PIN -1 +#endif +#ifndef E1_DIR_PIN + #define E1_DIR_PIN -1 +#endif +#ifndef E1_ENABLE_PIN + #define E1_ENABLE_PIN -1 +#endif +#ifndef E2_STEP_PIN + #define E2_STEP_PIN -1 +#endif +#ifndef E2_DIR_PIN + #define E2_DIR_PIN -1 +#endif +#ifndef E2_ENABLE_PIN + #define E2_ENABLE_PIN -1 +#endif +#ifndef E3_STEP_PIN + #define E3_STEP_PIN -1 +#endif +#ifndef E3_DIR_PIN + #define E3_DIR_PIN -1 +#endif +#ifndef E3_ENABLE_PIN + #define E3_ENABLE_PIN -1 +#endif +#ifndef E4_STEP_PIN + #define E4_STEP_PIN -1 +#endif +#ifndef E4_DIR_PIN + #define E4_DIR_PIN -1 +#endif +#ifndef E4_ENABLE_PIN + #define E4_ENABLE_PIN -1 +#endif +#ifndef E5_STEP_PIN + #define E5_STEP_PIN -1 +#endif +#ifndef E5_DIR_PIN + #define E5_DIR_PIN -1 +#endif +#ifndef E5_ENABLE_PIN + #define E5_ENABLE_PIN -1 +#endif +#ifndef E6_STEP_PIN + #define E6_STEP_PIN -1 +#endif +#ifndef E6_DIR_PIN + #define E6_DIR_PIN -1 +#endif +#ifndef E6_ENABLE_PIN + #define E6_ENABLE_PIN -1 +#endif +#ifndef E7_STEP_PIN + #define E7_STEP_PIN -1 +#endif +#ifndef E7_DIR_PIN + #define E7_DIR_PIN -1 +#endif +#ifndef E7_ENABLE_PIN + #define E7_ENABLE_PIN -1 +#endif + +// +// Destroy unused CS pins +// +#if !AXIS_HAS_SPI(X) + #undef X_CS_PIN +#endif +#if !AXIS_HAS_SPI(Y) + #undef Y_CS_PIN +#endif +#if !AXIS_HAS_SPI(Z) + #undef Z_CS_PIN +#endif +#if !AXIS_HAS_SPI(I) + #undef I_CS_PIN +#endif +#if !AXIS_HAS_SPI(J) + #undef J_CS_PIN +#endif +#if !AXIS_HAS_SPI(K) + #undef K_CS_PIN +#endif +#if E_STEPPERS && !AXIS_HAS_SPI(E0) + #undef E0_CS_PIN +#endif +#if E_STEPPERS > 1 && !AXIS_HAS_SPI(E1) + #undef E1_CS_PIN +#endif +#if E_STEPPERS > 2 && !AXIS_HAS_SPI(E2) + #undef E2_CS_PIN +#endif +#if E_STEPPERS > 3 && !AXIS_HAS_SPI(E3) + #undef E3_CS_PIN +#endif +#if E_STEPPERS > 4 && !AXIS_HAS_SPI(E4) + #undef E4_CS_PIN +#endif +#if E_STEPPERS > 5 && !AXIS_HAS_SPI(E5) + #undef E5_CS_PIN +#endif +#if E_STEPPERS > 6 && !AXIS_HAS_SPI(E6) + #undef E6_CS_PIN +#endif +#if E_STEPPERS > 7 && !AXIS_HAS_SPI(E7) + #undef E7_CS_PIN +#endif + +#ifndef X_CS_PIN + #define X_CS_PIN -1 +#endif +#ifndef Y_CS_PIN + #define Y_CS_PIN -1 +#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN -1 +#endif +#ifndef I_CS_PIN + #define I_CS_PIN -1 +#endif +#ifndef J_CS_PIN + #define J_CS_PIN -1 +#endif +#ifndef K_CS_PIN + #define K_CS_PIN -1 +#endif +#ifndef E0_CS_PIN + #define E0_CS_PIN -1 +#endif +#ifndef E1_CS_PIN + #define E1_CS_PIN -1 +#endif +#ifndef E2_CS_PIN + #define E2_CS_PIN -1 +#endif +#ifndef E3_CS_PIN + #define E3_CS_PIN -1 +#endif +#ifndef E4_CS_PIN + #define E4_CS_PIN -1 +#endif +#ifndef E5_CS_PIN + #define E5_CS_PIN -1 +#endif +#ifndef E6_CS_PIN + #define E6_CS_PIN -1 +#endif +#ifndef E7_CS_PIN + #define E7_CS_PIN -1 +#endif + +#ifndef FAN_PIN + #define FAN_PIN -1 +#endif +#define FAN0_PIN FAN_PIN +#ifndef FAN1_PIN + #define FAN1_PIN -1 +#endif +#ifndef FAN2_PIN + #define FAN2_PIN -1 +#endif +#ifndef CONTROLLER_FAN_PIN + #define CONTROLLER_FAN_PIN -1 +#endif + +#ifndef FANMUX0_PIN + #define FANMUX0_PIN -1 +#endif +#ifndef FANMUX1_PIN + #define FANMUX1_PIN -1 +#endif +#ifndef FANMUX2_PIN + #define FANMUX2_PIN -1 +#endif + +#ifndef HEATER_0_PIN + #define HEATER_0_PIN -1 +#endif +#ifndef HEATER_1_PIN + #define HEATER_1_PIN -1 +#endif +#ifndef HEATER_2_PIN + #define HEATER_2_PIN -1 +#endif +#ifndef HEATER_3_PIN + #define HEATER_3_PIN -1 +#endif +#ifndef HEATER_4_PIN + #define HEATER_4_PIN -1 +#endif +#ifndef HEATER_5_PIN + #define HEATER_5_PIN -1 +#endif +#ifndef HEATER_6_PIN + #define HEATER_6_PIN -1 +#endif +#ifndef HEATER_7_PIN + #define HEATER_7_PIN -1 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN -1 +#endif + +#ifndef TEMP_0_PIN + #define TEMP_0_PIN -1 +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN -1 +#endif +#ifndef TEMP_2_PIN + #define TEMP_2_PIN -1 +#endif +#ifndef TEMP_3_PIN + #define TEMP_3_PIN -1 +#endif +#ifndef TEMP_4_PIN + #define TEMP_4_PIN -1 +#endif +#ifndef TEMP_5_PIN + #define TEMP_5_PIN -1 +#endif +#ifndef TEMP_6_PIN + #define TEMP_6_PIN -1 +#endif +#ifndef TEMP_7_PIN + #define TEMP_7_PIN -1 +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN -1 +#endif + +#ifndef SD_DETECT_PIN + #define SD_DETECT_PIN -1 +#endif +#ifndef SDPOWER_PIN + #define SDPOWER_PIN -1 +#endif +#ifndef SDSS + #define SDSS -1 +#endif +#ifndef LED_PIN + #define LED_PIN -1 +#endif +#if DISABLED(PSU_CONTROL) || !defined(PS_ON_PIN) + #undef PS_ON_PIN + #define PS_ON_PIN -1 +#endif +#ifndef KILL_PIN + #define KILL_PIN -1 +#endif +#ifndef SUICIDE_PIN + #define SUICIDE_PIN -1 +#endif +#ifndef SUICIDE_PIN_STATE + #define SUICIDE_PIN_STATE LOW +#endif + +#ifndef NUM_SERVO_PLUGS + #define NUM_SERVO_PLUGS 4 +#endif + +// +// Assign endstop pins for boards with only 3 connectors +// +#ifdef X_STOP_PIN + #if X_HOME_TO_MIN + #define X_MIN_PIN X_STOP_PIN + #ifndef X_MAX_PIN + #define X_MAX_PIN -1 + #endif + #else + #define X_MAX_PIN X_STOP_PIN + #ifndef X_MIN_PIN + #define X_MIN_PIN -1 + #endif + #endif +#elif X_HOME_TO_MIN + #define X_STOP_PIN X_MIN_PIN +#else + #define X_STOP_PIN X_MAX_PIN +#endif +#if !defined(X2_USE_ENDSTOP) && ENABLED(X_DUAL_ENDSTOPS) && PIN_EXISTS(X_STOP) + #define X2_USE_ENDSTOP _XSTOP_ +#endif + +#if HAS_Y_AXIS + #ifdef Y_STOP_PIN + #if Y_HOME_TO_MIN + #define Y_MIN_PIN Y_STOP_PIN + #ifndef Y_MAX_PIN + #define Y_MAX_PIN -1 + #endif + #else + #define Y_MAX_PIN Y_STOP_PIN + #ifndef Y_MIN_PIN + #define Y_MIN_PIN -1 + #endif + #endif + #elif Y_HOME_TO_MIN + #define Y_STOP_PIN Y_MIN_PIN + #else + #define Y_STOP_PIN Y_MAX_PIN + #endif + #if !defined(Y2_USE_ENDSTOP) && ENABLED(Y_DUAL_ENDSTOPS) && PIN_EXISTS(Y_STOP) + #define Y2_USE_ENDSTOP _YSTOP_ + #endif +#endif + +#if HAS_Z_AXIS + #ifdef Z_STOP_PIN + #if Z_HOME_TO_MIN + #define Z_MIN_PIN Z_STOP_PIN + #ifndef Z_MAX_PIN + #define Z_MAX_PIN -1 + #endif + #else + #define Z_MAX_PIN Z_STOP_PIN + #ifndef Z_MIN_PIN + #define Z_MIN_PIN -1 + #endif + #endif + #elif Z_HOME_TO_MIN + #define Z_STOP_PIN Z_MIN_PIN + #else + #define Z_STOP_PIN Z_MAX_PIN + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) && PIN_EXISTS(Z_STOP) + #ifndef Z2_USE_ENDSTOP + #define Z2_USE_ENDSTOP _ZSTOP_ + #endif + #if NUM_Z_STEPPERS >= 3 && !defined(Z3_USE_ENDSTOP) + #define Z3_USE_ENDSTOP _ZSTOP_ + #endif + #if NUM_Z_STEPPERS >= 4 && !defined(Z4_USE_ENDSTOP) + #define Z4_USE_ENDSTOP _ZSTOP_ + #endif + #endif +#endif + +#if HAS_I_AXIS + #ifdef I_STOP_PIN + #if I_HOME_TO_MIN + #define I_MIN_PIN I_STOP_PIN + #ifndef I_MAX_PIN + #define I_MAX_PIN -1 + #endif + #else + #define I_MAX_PIN I_STOP_PIN + #ifndef I_MIN_PIN + #define I_MIN_PIN -1 + #endif + #endif + #elif I_HOME_TO_MIN + #define I_STOP_PIN I_MIN_PIN + #else + #define I_STOP_PIN I_MAX_PIN + #endif +#else + #undef I_MIN_PIN + #undef I_MAX_PIN +#endif + +#if HAS_J_AXIS + #ifdef J_STOP_PIN + #if J_HOME_TO_MIN + #define J_MIN_PIN J_STOP_PIN + #ifndef J_MAX_PIN + #define J_MAX_PIN -1 + #endif + #else + #define J_MAX_PIN J_STOP_PIN + #ifndef J_MIN_PIN + #define J_MIN_PIN -1 + #endif + #endif + #elif J_HOME_TO_MIN + #define J_STOP_PIN J_MIN_PIN + #else + #define J_STOP_PIN J_MAX_PIN + #endif +#else + #undef J_MIN_PIN + #undef J_MAX_PIN +#endif + +#if HAS_K_AXIS + #ifdef K_STOP_PIN + #if K_HOME_TO_MIN + #define K_MIN_PIN K_STOP_PIN + #ifndef K_MAX_PIN + #define K_MAX_PIN -1 + #endif + #else + #define K_MAX_PIN K_STOP_PIN + #ifndef K_MIN_PIN + #define K_MIN_PIN -1 + #endif + #endif + #elif K_HOME_TO_MIN + #define K_STOP_PIN K_MIN_PIN + #else + #define K_STOP_PIN K_MAX_PIN + #endif +#else + #undef K_MIN_PIN + #undef K_MAX_PIN +#endif + +// Filament Sensor first pin alias +#if HAS_FILAMENT_SENSOR + #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN // Filament Sensor first pin alias +#else + #undef FIL_RUNOUT_PIN + #undef FIL_RUNOUT1_PIN +#endif + +#if NUM_RUNOUT_SENSORS < 2 + #undef FIL_RUNOUT2_PIN +#endif + +#ifndef LCD_PINS_D4 + #define LCD_PINS_D4 -1 +#endif + +#if HAS_MARLINUI_HD44780 || TOUCH_UI_ULTIPANEL + #ifndef LCD_PINS_D5 + #define LCD_PINS_D5 -1 + #endif + #ifndef LCD_PINS_D6 + #define LCD_PINS_D6 -1 + #endif + #ifndef LCD_PINS_D7 + #define LCD_PINS_D7 -1 + #endif +#endif + +/** + * Auto-Assignment for Dual X, Dual Y, Multi-Z Steppers + * + * By default X2 is assigned to the next open E plug + * on the board, then in order, Y2, Z2, Z3. These can be + * overridden in Configuration.h or Configuration_adv.h. + */ + +#define __PEXI(p,q) PIN_EXISTS(E##p##_##q) +#define _PEXI(p,q) __PEXI(p,q) +#define __EPIN(p,q) E##p##_##q##_PIN +#define _EPIN(p,q) __EPIN(p,q) +#define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN) +#define _En_DIAG_(p) _E##p##_DIAG_ + +// The E0/E1 steppers are always used for Dual E +#if ENABLED(E_DUAL_STEPPER_DRIVERS) + #ifndef E1_STEP_PIN + #error "No E1 stepper available for E_DUAL_STEPPER_DRIVERS!" + #endif + #define X2_E_INDEX INCREMENT(E_STEPPERS) +#else + #define X2_E_INDEX E_STEPPERS +#endif + +#if HAS_X2_STEPPER && !defined(X2_DIAG_PIN) && !defined(X2_STEP_PIN) && !PIN_EXISTS(X2_CS_PIN) + #define Y2_E_INDEX INCREMENT(X2_E_INDEX) +#else + #define Y2_E_INDEX X2_E_INDEX +#endif + +// The X2 axis, if any, should be the next open extruder port +#if HAS_X2_STEPPER + #ifndef X2_STEP_PIN + #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP) + #define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR) + #define X2_ENABLE_PIN _EPIN(X2_E_INDEX, ENABLE) + #if X2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(X2_STEP) + #error "No E stepper plug left for X2!" + #else + #define AUTO_ASSIGNED_X2_STEPPER 1 + #endif + #endif + #ifndef X2_MS1_PIN + #define X2_MS1_PIN _EPIN(X2_E_INDEX, MS1) + #if PIN_EXISTS(X2_MS1) + #define AUTO_ASSIGNED_X2_MS1 1 + #endif + #endif + #ifndef X2_MS2_PIN + #define X2_MS2_PIN _EPIN(X2_E_INDEX, MS2) + #if PIN_EXISTS(X2_MS2) + #define AUTO_ASSIGNED_X2_MS2 1 + #endif + #endif + #ifndef X2_MS3_PIN + #define X2_MS3_PIN _EPIN(X2_E_INDEX, MS3) + #if PIN_EXISTS(X2_MS3) + #define AUTO_ASSIGNED_X2_MS3 1 + #endif + #endif + #if AXIS_HAS_SPI(X2) && !defined(X2_CS_PIN) + #define X2_CS_PIN _EPIN(X2_E_INDEX, CS) + #if PIN_EXISTS(X2_CS) + #define AUTO_ASSIGNED_X2_CS 1 + #endif + #endif + #if AXIS_HAS_UART(X2) + #ifndef X2_SERIAL_TX_PIN + #define X2_SERIAL_TX_PIN _EPIN(X2_E_INDEX, SERIAL_TX) + #endif + #ifndef X2_SERIAL_RX_PIN + #define X2_SERIAL_RX_PIN _EPIN(X2_E_INDEX, SERIAL_RX) + #endif + #endif + + // + // Auto-assign pins for stallGuard sensorless homing + // + #if !defined(X2_DIAG_PIN) && !defined(X2_USE_ENDSTOP) && defined(X2_STALL_SENSITIVITY) && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG) + #define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG) + #if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file... + #define X2_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(X2, Y_MIN) + #define X2_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(X2, Z_MIN) + #define X2_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(X2, X_MAX) + #define X2_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(X2, Y_MAX) + #define X2_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(X2, Z_MAX) + #define X2_USE_ENDSTOP _ZMAX_ + #else // Otherwise pick the next free En_DIAG_PIN directly + #define X2_USE_ENDSTOP _En_DIAG_(X2_E_INDEX) + #endif + #define AUTO_ASSIGNED_X2_DIAG 1 + #undef X2_DIAG_PIN // Defined in Conditionals_post.h based on X2_USE_ENDSTOP + #endif +#endif + +#ifndef X2_CS_PIN + #define X2_CS_PIN -1 +#endif +#ifndef X2_MS1_PIN + #define X2_MS1_PIN -1 +#endif +#ifndef X2_MS2_PIN + #define X2_MS2_PIN -1 +#endif +#ifndef X2_MS3_PIN + #define X2_MS3_PIN -1 +#endif + +#if HAS_DUAL_Y_STEPPERS && !defined(Y2_DIAG_PIN) && !defined(Y2_STEP_PIN) && !PIN_EXISTS(Y2_CS_PIN) + #define Z2_E_INDEX INCREMENT(Y2_E_INDEX) +#else + #define Z2_E_INDEX Y2_E_INDEX +#endif + +// The Y2 axis, if any, should be the next open extruder port +#if HAS_DUAL_Y_STEPPERS + #ifndef Y2_STEP_PIN + #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP) + #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR) + #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE) + #if Y2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Y2_STEP) + #error "No E stepper plug left for Y2!" + #else + #define AUTO_ASSIGNED_Y2_STEPPER 1 + #endif + #endif + #ifndef Y2_MS1_PIN + #define Y2_MS1_PIN _EPIN(Y2_E_INDEX, MS1) + #if PIN_EXISTS(Y2_MS1) + #define AUTO_ASSIGNED_Y2_MS1 1 + #endif + #endif + #ifndef Y2_MS2_PIN + #define Y2_MS2_PIN _EPIN(Y2_E_INDEX, MS2) + #if PIN_EXISTS(Y2_MS2) + #define AUTO_ASSIGNED_Y2_MS2 1 + #endif + #endif + #ifndef Y2_MS3_PIN + #define Y2_MS3_PIN _EPIN(Y2_E_INDEX, MS3) + #if PIN_EXISTS(Y2_MS3) + #define AUTO_ASSIGNED_Y2_MS3 1 + #endif + #endif + #if AXIS_HAS_SPI(Y2) && !defined(Y2_CS_PIN) + #define Y2_CS_PIN _EPIN(Y2_E_INDEX, CS) + #if PIN_EXISTS(Y2_CS) + #define AUTO_ASSIGNED_Y2_CS 1 + #endif + #endif + #if AXIS_HAS_UART(Y2) + #ifndef Y2_SERIAL_TX_PIN + #define Y2_SERIAL_TX_PIN _EPIN(Y2_E_INDEX, SERIAL_TX) + #endif + #ifndef Y2_SERIAL_RX_PIN + #define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(Y2_DIAG_PIN) && !defined(Y2_USE_ENDSTOP) && defined(Y2_STALL_SENSITIVITY) && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG) + #define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG) + #if DIAG_REMAPPED(Y2, X_MIN) + #define Y2_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(Y2, Y_MIN) + #define Y2_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(Y2, Z_MIN) + #define Y2_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(Y2, X_MAX) + #define Y2_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(Y2, Y_MAX) + #define Y2_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(Y2, Z_MAX) + #define Y2_USE_ENDSTOP _ZMAX_ + #else + #define Y2_USE_ENDSTOP _En_DIAG_(Y2_E_INDEX) + #endif + #define AUTO_ASSIGNED_Y2_DIAG 1 + #undef Y2_DIAG_PIN // Defined in Conditionals_post.h based on Y2_USE_ENDSTOP + #endif +#endif + +#ifndef Y2_CS_PIN + #define Y2_CS_PIN -1 +#endif +#ifndef Y2_MS1_PIN + #define Y2_MS1_PIN -1 +#endif +#ifndef Y2_MS2_PIN + #define Y2_MS2_PIN -1 +#endif +#ifndef Y2_MS3_PIN + #define Y2_MS3_PIN -1 +#endif + +#if NUM_Z_STEPPERS >= 2 && !defined(Z2_DIAG_PIN) && !defined(Z2_STEP_PIN) && !PIN_EXISTS(Z2_CS_PIN) + #define Z3_E_INDEX INCREMENT(Z2_E_INDEX) +#else + #define Z3_E_INDEX Z2_E_INDEX +#endif + +// The Z2 axis, if any, should be the next open extruder port +#if NUM_Z_STEPPERS >= 2 + #ifndef Z2_STEP_PIN + #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP) + #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR) + #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE) + #if Z2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z2_STEP) + #error "No E stepper plug left for Z2!" + #else + #define AUTO_ASSIGNED_Z2_STEPPER 1 + #endif + #endif + #ifndef Z2_MS1_PIN + #define Z2_MS1_PIN _EPIN(Z2_E_INDEX, MS1) + #if PIN_EXISTS(Z2_MS1) + #define AUTO_ASSIGNED_Z2_MS1 1 + #endif + #endif + #ifndef Z2_MS2_PIN + #define Z2_MS2_PIN _EPIN(Z2_E_INDEX, MS2) + #if PIN_EXISTS(Z2_MS2) + #define AUTO_ASSIGNED_Z2_MS2 1 + #endif + #endif + #ifndef Z2_MS3_PIN + #define Z2_MS3_PIN _EPIN(Z2_E_INDEX, MS3) + #if PIN_EXISTS(Z2_MS3) + #define AUTO_ASSIGNED_Z2_MS3 1 + #endif + #endif + #if AXIS_HAS_SPI(Z2) && !defined(Z2_CS_PIN) + #define Z2_CS_PIN _EPIN(Z2_E_INDEX, CS) + #if PIN_EXISTS(Z2_CS) + #define AUTO_ASSIGNED_Z2_CS 1 + #endif + #endif + #if AXIS_HAS_UART(Z2) + #ifndef Z2_SERIAL_TX_PIN + #define Z2_SERIAL_TX_PIN _EPIN(Z2_E_INDEX, SERIAL_TX) + #endif + #ifndef Z2_SERIAL_RX_PIN + #define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(Z2_DIAG_PIN) && !defined(Z2_USE_ENDSTOP) && defined(Z2_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && _PEXI(Z2_E_INDEX, DIAG) + #define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG) + #if DIAG_REMAPPED(Z2, X_MIN) + #define Z2_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(Z2, Y_MIN) + #define Z2_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(Z2, Z_MIN) + #define Z2_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(Z2, X_MAX) + #define Z2_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(Z2, Y_MAX) + #define Z2_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(Z2, Z_MAX) + #define Z2_USE_ENDSTOP _ZMAX_ + #else + #define Z2_USE_ENDSTOP _En_DIAG_(Z2_E_INDEX) + #endif + #define AUTO_ASSIGNED_Z2_DIAG 1 + #undef Z2_DIAG_PIN // Defined in Conditionals_post.h based on Z2_USE_ENDSTOP + #endif +#endif + +#ifndef Z2_CS_PIN + #define Z2_CS_PIN -1 +#endif +#ifndef Z2_MS1_PIN + #define Z2_MS1_PIN -1 +#endif +#ifndef Z2_MS2_PIN + #define Z2_MS2_PIN -1 +#endif +#ifndef Z2_MS3_PIN + #define Z2_MS3_PIN -1 +#endif + +#if NUM_Z_STEPPERS >= 3 && !defined(Z3_DIAG_PIN) && !defined(Z3_STEP_PIN) && !PIN_EXISTS(Z3_CS_PIN) + #define Z4_E_INDEX INCREMENT(Z3_E_INDEX) +#else + #define Z4_E_INDEX Z3_E_INDEX +#endif + +// The Z3 axis, if any, should be the next open extruder port +#if NUM_Z_STEPPERS >= 3 + #ifndef Z3_STEP_PIN + #define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP) + #define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR) + #define Z3_ENABLE_PIN _EPIN(Z3_E_INDEX, ENABLE) + #if Z3_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z3_STEP) + #error "No E stepper plug left for Z3!" + #else + #define AUTO_ASSIGNED_Z3_STEPPER 1 + #endif + #endif + #if AXIS_HAS_SPI(Z3) && !defined(Z3_CS_PIN) + #define Z3_CS_PIN _EPIN(Z3_E_INDEX, CS) + #if PIN_EXISTS(Z3_CS) + #define AUTO_ASSIGNED_Z3_CS 1 + #endif + #endif + #ifndef Z3_MS1_PIN + #define Z3_MS1_PIN _EPIN(Z3_E_INDEX, MS1) + #if PIN_EXISTS(Z3_MS1) + #define AUTO_ASSIGNED_Z3_MS1 1 + #endif + #endif + #ifndef Z3_MS2_PIN + #define Z3_MS2_PIN _EPIN(Z3_E_INDEX, MS2) + #if PIN_EXISTS(Z3_MS2) + #define AUTO_ASSIGNED_Z3_MS2 1 + #endif + #endif + #ifndef Z3_MS3_PIN + #define Z3_MS3_PIN _EPIN(Z3_E_INDEX, MS3) + #if PIN_EXISTS(Z3_MS3) + #define AUTO_ASSIGNED_Z3_MS3 1 + #endif + #endif + #if AXIS_HAS_UART(Z3) + #ifndef Z3_SERIAL_TX_PIN + #define Z3_SERIAL_TX_PIN _EPIN(Z3_E_INDEX, SERIAL_TX) + #endif + #ifndef Z3_SERIAL_RX_PIN + #define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(Z3_DIAG_PIN) && !defined(Z3_USE_ENDSTOP) && defined(Z3_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && _PEXI(Z3_E_INDEX, DIAG) + #define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG) + #if DIAG_REMAPPED(Z3, X_MIN) + #define Z3_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(Z3, Y_MIN) + #define Z3_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(Z3, Z_MIN) + #define Z3_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(Z3, X_MAX) + #define Z3_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(Z3, Y_MAX) + #define Z3_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(Z3, Z_MAX) + #define Z3_USE_ENDSTOP _ZMAX_ + #else + #define Z3_USE_ENDSTOP _En_DIAG_(Z3_E_INDEX) + #endif + #define AUTO_ASSIGNED_Z3_DIAG 1 + #undef Z3_DIAG_PIN // Defined in Conditionals_post.h based on Z3_USE_ENDSTOP + #endif +#endif + +#ifndef Z3_CS_PIN + #define Z3_CS_PIN -1 +#endif +#ifndef Z3_MS1_PIN + #define Z3_MS1_PIN -1 +#endif +#ifndef Z3_MS2_PIN + #define Z3_MS2_PIN -1 +#endif +#ifndef Z3_MS3_PIN + #define Z3_MS3_PIN -1 +#endif + +#if NUM_Z_STEPPERS >= 4 && !defined(Z4_DIAG_PIN) && !defined(Z4_STEP_PIN) && !PIN_EXISTS(Z4_CS_PIN) + #define I_E_INDEX INCREMENT(Z4_E_INDEX) +#else + #define I_E_INDEX Z4_E_INDEX +#endif + +// The Z4 axis, if any, should be the next open extruder port +#if NUM_Z_STEPPERS >= 4 + #ifndef Z4_STEP_PIN + #define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP) + #define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR) + #define Z4_ENABLE_PIN _EPIN(Z4_E_INDEX, ENABLE) + #if Z4_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z4_STEP) + #error "No E stepper plug left for Z4!" + #else + #define AUTO_ASSIGNED_Z4_STEPPER 1 + #endif + #endif + #if AXIS_HAS_SPI(Z4) && !defined(Z4_CS_PIN) + #define Z4_CS_PIN _EPIN(Z4_E_INDEX, CS) + #if PIN_EXISTS(Z4_CS) + #define AUTO_ASSIGNED_Z4_CS 1 + #endif + #endif + #ifndef Z4_MS1_PIN + #define Z4_MS1_PIN _EPIN(Z4_E_INDEX, MS1) + #if PIN_EXISTS(Z4_MS1) + #define AUTO_ASSIGNED_Z4_MS1 1 + #endif + #endif + #ifndef Z4_MS2_PIN + #define Z4_MS2_PIN _EPIN(Z4_E_INDEX, MS2) + #if PIN_EXISTS(Z4_MS2) + #define AUTO_ASSIGNED_Z4_MS2 1 + #endif + #endif + #ifndef Z4_MS3_PIN + #define Z4_MS3_PIN _EPIN(Z4_E_INDEX, MS3) + #if PIN_EXISTS(Z4_MS3) + #define AUTO_ASSIGNED_Z4_MS3 1 + #endif + #endif + #if AXIS_HAS_UART(Z4) + #ifndef Z4_SERIAL_TX_PIN + #define Z4_SERIAL_TX_PIN _EPIN(Z4_E_INDEX, SERIAL_TX) + #endif + #ifndef Z4_SERIAL_RX_PIN + #define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(Z4_DIAG_PIN) && !defined(Z4_USE_ENDSTOP) && defined(Z4_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && _PEXI(Z4_E_INDEX, DIAG) + #define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG) + #if DIAG_REMAPPED(Z4, X_MIN) + #define Z4_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(Z4, Y_MIN) + #define Z4_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(Z4, Z_MIN) + #define Z4_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(Z4, X_MAX) + #define Z4_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(Z4, Y_MAX) + #define Z4_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(Z4, Z_MAX) + #define Z4_USE_ENDSTOP _ZMAX_ + #else + #define Z4_USE_ENDSTOP _En_DIAG_(Z4_E_INDEX) + #endif + #define AUTO_ASSIGNED_Z4_DIAG 1 + #undef Z4_DIAG_PIN // Defined in Conditionals_post.h based on Z4_USE_ENDSTOP + #endif +#endif + +#ifndef Z4_CS_PIN + #define Z4_CS_PIN -1 +#endif +#ifndef Z4_MS1_PIN + #define Z4_MS1_PIN -1 +#endif +#ifndef Z4_MS2_PIN + #define Z4_MS2_PIN -1 +#endif +#ifndef Z4_MS3_PIN + #define Z4_MS3_PIN -1 +#endif + +#if HAS_I_AXIS && !defined(I_DIAG_PIN) && !defined(I_STEP_PIN) && !PIN_EXISTS(I_CS_PIN) + #define J_E_INDEX INCREMENT(I_E_INDEX) +#else + #define J_E_INDEX I_E_INDEX +#endif + +// The I axis, if any, should be the next open extruder port +#if HAS_I_AXIS + #ifndef I_STEP_PIN + #define I_STEP_PIN _EPIN(I_E_INDEX, STEP) + #define I_DIR_PIN _EPIN(I_E_INDEX, DIR) + #define I_ENABLE_PIN _EPIN(I_E_INDEX, ENABLE) + #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(I_STEP) + #error "No E stepper plug left for I!" + #else + #define AUTO_ASSIGNED_I_STEPPER 1 + #endif + #endif + #if AXIS_HAS_SPI(I) && !defined(I_CS_PIN) + #define I_CS_PIN _EPIN(I_E_INDEX, CS) + #if PIN_EXISTS(I_CS) + #define AUTO_ASSIGNED_I_CS 1 + #endif + #endif + #ifndef I_MS1_PIN + #define I_MS1_PIN _EPIN(I_E_INDEX, MS1) + #if PIN_EXISTS(I_MS1) + #define AUTO_ASSIGNED_I_MS1 1 + #endif + #endif + #ifndef I_MS2_PIN + #define I_MS2_PIN _EPIN(I_E_INDEX, MS2) + #if PIN_EXISTS(I_MS2) + #define AUTO_ASSIGNED_I_MS2 1 + #endif + #endif + #ifndef I_MS3_PIN + #define I_MS3_PIN _EPIN(I_E_INDEX, MS3) + #if PIN_EXISTS(I_MS3) + #define AUTO_ASSIGNED_I_MS3 1 + #endif + #endif + #if AXIS_HAS_UART(I) + #ifndef I_SERIAL_TX_PIN + #define I_SERIAL_TX_PIN _EPIN(I_E_INDEX, SERIAL_TX) + #endif + #ifndef I_SERIAL_RX_PIN + #define I_SERIAL_RX_PIN _EPIN(I_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(I_DIAG_PIN) && !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG) + #define I_DIAG_PIN _EPIN(I_E_INDEX, DIAG) + #if DIAG_REMAPPED(I, X_MIN) + #define I_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(I, Y_MIN) + #define I_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(I, Z_MIN) + #define I_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(I, X_MAX) + #define I_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(I, Y_MAX) + #define I_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(I, Z_MAX) + #define I_USE_ENDSTOP _ZMAX_ + #else + #define I_USE_ENDSTOP _En_DIAG_(I_E_INDEX) + #endif + #define AUTO_ASSIGNED_I_DIAG 1 + #undef I_DIAG_PIN // Defined in Conditionals_post.h based on I_USE_ENDSTOP + #endif +#endif + +#ifndef I_CS_PIN + #define I_CS_PIN -1 +#endif +#ifndef I_MS1_PIN + #define I_MS1_PIN -1 +#endif +#ifndef I_MS2_PIN + #define I_MS2_PIN -1 +#endif +#ifndef I_MS3_PIN + #define I_MS3_PIN -1 +#endif + +#if HAS_J_AXIS && !defined(J_DIAG_PIN) && !defined(J_STEP_PIN) && !PIN_EXISTS(J_CS_PIN) + #define K_E_INDEX INCREMENT(J_E_INDEX) +#else + #define K_E_INDEX J_E_INDEX +#endif + +// The J axis, if any, should be the next open extruder port +#if HAS_J_AXIS + #ifndef J_STEP_PIN + #define J_STEP_PIN _EPIN(J_E_INDEX, STEP) + #define J_DIR_PIN _EPIN(J_E_INDEX, DIR) + #define J_ENABLE_PIN _EPIN(J_E_INDEX, ENABLE) + #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(J_STEP) + #error "No E stepper plug left for J!" + #else + #define AUTO_ASSIGNED_J_STEPPER 1 + #endif + #endif + #if AXIS_HAS_SPI(J) && !defined(J_CS_PIN) + #define J_CS_PIN _EPIN(J_E_INDEX, CS) + #if PIN_EXISTS(J_CS) + #define AUTO_ASSIGNED_J_CS 1 + #endif + #endif + #ifndef J_MS1_PIN + #define J_MS1_PIN _EPIN(J_E_INDEX, MS1) + #if PIN_EXISTS(J_MS1) + #define AUTO_ASSIGNED_J_MS1 1 + #endif + #endif + #ifndef J_MS2_PIN + #define J_MS2_PIN _EPIN(J_E_INDEX, MS2) + #if PIN_EXISTS(J_MS2) + #define AUTO_ASSIGNED_J_MS2 1 + #endif + #endif + #ifndef J_MS3_PIN + #define J_MS3_PIN _EPIN(J_E_INDEX, MS3) + #if PIN_EXISTS(J_MS3) + #define AUTO_ASSIGNED_J_MS3 1 + #endif + #endif + #if AXIS_HAS_UART(J) + #ifndef J_SERIAL_TX_PIN + #define J_SERIAL_TX_PIN _EPIN(J_E_INDEX, SERIAL_TX) + #endif + #ifndef J_SERIAL_RX_PIN + #define J_SERIAL_RX_PIN _EPIN(J_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(J_DIAG_PIN) && !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG) + #define J_DIAG_PIN _EPIN(J_E_INDEX, DIAG) + #if DIAG_REMAPPED(J, X_MIN) + #define J_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(J, Y_MIN) + #define J_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(J, Z_MIN) + #define J_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(J, X_MAX) + #define J_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(J, Y_MAX) + #define J_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(I, Z_MAX) + #define J_USE_ENDSTOP _ZMAX_ + #else + #define J_USE_ENDSTOP _En_DIAG_(J_E_INDEX) + #endif + #define AUTO_ASSIGNED_J_DIAG 1 + #undef J_DIAG_PIN // Defined in Conditionals_post.h based on J_USE_ENDSTOP + #endif +#endif + +#ifndef J_CS_PIN + #define J_CS_PIN -1 +#endif +#ifndef J_MS1_PIN + #define J_MS1_PIN -1 +#endif +#ifndef J_MS2_PIN + #define J_MS2_PIN -1 +#endif +#ifndef J_MS3_PIN + #define J_MS3_PIN -1 +#endif + +// The K axis, if any, should be the next open extruder port +#if HAS_K_AXIS + #ifndef K_STEP_PIN + #define K_STEP_PIN _EPIN(K_E_INDEX, STEP) + #define K_DIR_PIN _EPIN(K_E_INDEX, DIR) + #define K_ENABLE_PIN _EPIN(K_E_INDEX, ENABLE) + #if K_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(K_STEP) + #error "No E stepper plug left for K!" + #else + #define AUTO_ASSIGNED_K_STEPPER 1 + #endif + #endif + #if AXIS_HAS_SPI(K) && !defined(K_CS_PIN) + #define K_CS_PIN _EPIN(K_E_INDEX, CS) + #if PIN_EXISTS(K_CS) + #define AUTO_ASSIGNED_K_CS 1 + #endif + #endif + #ifndef K_MS1_PIN + #define K_MS1_PIN _EPIN(K_E_INDEX, MS1) + #if PIN_EXISTS(K_MS1) + #define AUTO_ASSIGNED_K_MS1 1 + #endif + #endif + #ifndef K_MS2_PIN + #define K_MS2_PIN _EPIN(K_E_INDEX, MS2) + #if PIN_EXISTS(K_MS2) + #define AUTO_ASSIGNED_K_MS2 1 + #endif + #endif + #ifndef K_MS3_PIN + #define K_MS3_PIN _EPIN(K_E_INDEX, MS3) + #if PIN_EXISTS(K_MS3) + #define AUTO_ASSIGNED_K_MS3 1 + #endif + #endif + #if AXIS_HAS_UART(K) + #ifndef K_SERIAL_TX_PIN + #define K_SERIAL_TX_PIN _EPIN(K_E_INDEX, SERIAL_TX) + #endif + #ifndef K_SERIAL_RX_PIN + #define K_SERIAL_RX_PIN _EPIN(K_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(K_DIAG_PIN) && !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG) + #define K_DIAG_PIN _EPIN(K_E_INDEX, DIAG) + #if DIAG_REMAPPED(K, X_MIN) + #define K_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(K, Y_MIN) + #define K_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(K, Z_MIN) + #define K_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(K, X_MAX) + #define K_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(K, Y_MAX) + #define K_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(K, Z_MAX) + #define K_USE_ENDSTOP _ZMAX_ + #else + #define K_USE_ENDSTOP _En_DIAG_(K_E_INDEX) + #endif + #define AUTO_ASSIGNED_K_DIAG 1 + #undef K_DIAG_PIN // Defined in Conditionals_post.h based on K_USE_ENDSTOP + #endif +#endif + +#ifndef K_CS_PIN + #define K_CS_PIN -1 +#endif +#ifndef K_MS1_PIN + #define K_MS1_PIN -1 +#endif +#ifndef K_MS2_PIN + #define K_MS2_PIN -1 +#endif +#ifndef K_MS3_PIN + #define K_MS3_PIN -1 +#endif + +// +// Disable unused endstop / probe pins +// +#define _STOP_IN_USE(N) (X2_USE_ENDSTOP == N || Y2_USE_ENDSTOP == N || Z2_USE_ENDSTOP == N || Z3_USE_ENDSTOP == N || Z4_USE_ENDSTOP == N) +#if !defined(USE_XMAX_PLUG) && _STOP_IN_USE(_XMAX_) + #define USE_XMAX_PLUG +#endif +#if !defined(USE_YMAX_PLUG) && _STOP_IN_USE(_YMAX_) + #define USE_YMAX_PLUG +#endif +#if !defined(USE_ZMAX_PLUG) && _STOP_IN_USE(_ZMAX_) + #define USE_ZMAX_PLUG +#endif +#if !defined(USE_XMIN_PLUG) && _STOP_IN_USE(_XMIN_) + #define USE_XMIN_PLUG +#endif +#if !defined(USE_YMIN_PLUG) && _STOP_IN_USE(_YMIN_) + #define USE_YMIN_PLUG +#endif +#if !defined(USE_ZMIN_PLUG) && _STOP_IN_USE(_ZMIN_) + #define USE_ZMIN_PLUG +#endif +#undef _STOP_IN_USE +#if !USES_Z_MIN_PROBE_PIN + #undef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN -1 +#endif +#if DISABLED(USE_XMIN_PLUG) + #undef X_MIN_PIN + #define X_MIN_PIN -1 +#endif +#if DISABLED(USE_XMAX_PLUG) + #undef X_MAX_PIN + #define X_MAX_PIN -1 +#endif +#if NONE(USE_XMIN_PLUG, USE_XMAX_PLUG) + #undef X_STOP_PIN +#endif +#if DISABLED(USE_YMIN_PLUG) + #undef Y_MIN_PIN + #define Y_MIN_PIN -1 +#endif +#if DISABLED(USE_YMAX_PLUG) + #undef Y_MAX_PIN + #define Y_MAX_PIN -1 +#endif +#if NONE(USE_YMIN_PLUG, USE_YMAX_PLUG) + #undef Y_STOP_PIN +#endif +#if DISABLED(USE_ZMIN_PLUG) + #undef Z_MIN_PIN + #define Z_MIN_PIN -1 +#endif +#if DISABLED(USE_ZMAX_PLUG) + #undef Z_MAX_PIN + #define Z_MAX_PIN -1 +#endif +#if NONE(USE_ZMIN_PLUG, USE_ZMAX_PLUG) + #undef Z_STOP_PIN +#endif +#if DISABLED(USE_IMIN_PLUG) + #undef I_MIN_PIN + #define I_MIN_PIN -1 +#endif +#if DISABLED(USE_IMAX_PLUG) + #undef I_MAX_PIN + #define I_MAX_PIN -1 +#endif +#if NONE(USE_IMIN_PLUG, USE_IMAX_PLUG) + #undef I_STOP_PIN +#endif +#if DISABLED(USE_JMIN_PLUG) + #undef J_MIN_PIN + #define J_MIN_PIN -1 +#endif +#if DISABLED(USE_JMAX_PLUG) + #undef J_MAX_PIN + #define J_MAX_PIN -1 +#endif +#if NONE(USE_JMIN_PLUG, USE_JMAX_PLUG) + #undef J_STOP_PIN +#endif +#if DISABLED(USE_KMIN_PLUG) + #undef K_MIN_PIN + #define K_MIN_PIN -1 +#endif +#if DISABLED(USE_KMAX_PLUG) + #undef K_MAX_PIN + #define K_MAX_PIN -1 +#endif +#if NONE(USE_KMIN_PLUG, USE_KMAX_PLUG) + #undef K_STOP_PIN +#endif + +#if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MAX + #undef X2_MIN_PIN +#endif +#if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MIN + #undef X2_MAX_PIN +#endif +#if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MAX + #undef Y2_MIN_PIN +#endif +#if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MIN + #undef Y2_MAX_PIN +#endif +#if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MAX + #undef Z2_MIN_PIN +#endif +#if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MIN + #undef Z2_MAX_PIN +#endif +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 3 || Z_HOME_TO_MAX + #undef Z3_MIN_PIN +#endif +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 3 || Z_HOME_TO_MIN + #undef Z3_MAX_PIN +#endif +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 4 || Z_HOME_TO_MAX + #undef Z4_MIN_PIN +#endif +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 4 || Z_HOME_TO_MIN + #undef Z4_MAX_PIN +#endif + +// +// Default DOGLCD SPI delays +// +#if !IS_U8GLIB_ST7920 + #undef ST7920_DELAY_1 + #undef ST7920_DELAY_2 + #undef ST7920_DELAY_3 + #undef LCD_ST7920_DELAY_1 + #undef LCD_ST7920_DELAY_2 + #undef LCD_ST7920_DELAY_3 + #undef BOARD_ST7920_DELAY_1 + #undef BOARD_ST7920_DELAY_2 + #undef BOARD_ST7920_DELAY_3 + #undef CPU_ST7920_DELAY_1 + #undef CPU_ST7920_DELAY_2 + #undef CPU_ST7920_DELAY_3 +#endif + +#if !NEED_CASE_LIGHT_PIN + #undef CASE_LIGHT_PIN +#endif + +#undef HAS_FREE_AUX2_PINS +#undef DIAG_REMAPPED diff --git a/src/pins/rambo/env_validate.h b/src/pins/rambo/env_validate.h new file mode 100644 index 0000000..84cf839 --- /dev/null +++ b/src/pins/rambo/env_validate.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(__AVR_ATmega2560__) + #error "Oops! Select 'Arduino Mega 2560 or Rambo' in 'Tools > Board.'" +#endif diff --git a/src/pins/rambo/pins_EINSY_RAMBO.h b/src/pins/rambo/pins_EINSY_RAMBO.h new file mode 100644 index 0000000..9150bf1 --- /dev/null +++ b/src/pins/rambo/pins_EINSY_RAMBO.h @@ -0,0 +1,216 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Einsy-Rambo pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Einsy Rambo" +#define DEFAULT_MACHINE_NAME "Prusa MK3" + +//#define MK3_FAN_PINS + +// +// TMC2130 Configuration_adv defaults for EinsyRambo +// +#if !AXIS_DRIVER_TYPE_X(TMC2130) || !AXIS_DRIVER_TYPE_Y(TMC2130) || !AXIS_DRIVER_TYPE_Z(TMC2130) || !AXIS_DRIVER_TYPE_E0(TMC2130) + #error "You must set ([XYZ]|E0)_DRIVER_TYPE to TMC2130 in Configuration.h for EinsyRambo." +#endif + +// TMC2130 Diag Pins (currently just for reference) +#define X_DIAG_PIN 64 +#define Y_DIAG_PIN 69 +#define Z_DIAG_PIN 68 +#define E0_DIAG_PIN 65 + +// +// Limit Switches +// +// Only use Diag Pins when SENSORLESS_HOMING is enabled for the TMC2130 drivers. +// Otherwise use a physical endstop based configuration. +// +// SERVO0_PIN and Z_MIN_PIN configuration for BLTOUCH sensor when combined with SENSORLESS_HOMING. +// + +#if DISABLED(SENSORLESS_HOMING) + + #define X_STOP_PIN 12 + #define Y_STOP_PIN 11 + #define Z_STOP_PIN 10 + +#else + + #define X_STOP_PIN X_DIAG_PIN + #define Y_STOP_PIN Y_DIAG_PIN + + #if ENABLED(BLTOUCH) + #define Z_STOP_PIN 11 // Y-MIN + #define SERVO0_PIN 10 // Z-MIN + #else + #define Z_STOP_PIN 10 + #endif + +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 10 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 62 +#endif + +// +// Steppers +// +#define X_STEP_PIN 37 +#define X_DIR_PIN 49 +#define X_ENABLE_PIN 29 +#define X_CS_PIN 41 + +#define Y_STEP_PIN 36 +#define Y_DIR_PIN 48 +#define Y_ENABLE_PIN 28 +#define Y_CS_PIN 39 + +#define Z_STEP_PIN 35 +#define Z_DIR_PIN 47 +#define Z_ENABLE_PIN 27 +#define Z_CS_PIN 67 + +#define E0_STEP_PIN 34 +#define E0_DIR_PIN 43 +#define E0_ENABLE_PIN 26 +#define E0_CS_PIN 66 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input, Header J2 +#define TEMP_1_PIN 1 // Analog Input, Header J3 +#define TEMP_BOARD_PIN 91 // Onboard thermistor, 100k TDK NTCG104LH104JT1 +#define TEMP_BED_PIN 2 // Analog Input, Header J6 +#define TEMP_PROBE_PIN 3 // Analog Input, Header J15 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 3 +#define HEATER_BED_PIN 4 + +#ifndef FAN_PIN + #ifdef MK3_FAN_PINS + #define FAN_PIN 6 + #else + #define FAN_PIN 8 + #endif +#endif + +#ifndef FAN1_PIN + #ifdef MK3_FAN_PINS + #define FAN1_PIN -1 + #else + #define FAN1_PIN 6 + #endif +#endif + +// +// Misc. Functions +// +#define SDSS 77 +#define LED_PIN 13 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 9 +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +// use P1 connector for spindle pins +#define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM +#define SPINDLE_LASER_ENA_PIN 18 // Pullup! +#define SPINDLE_DIR_PIN 19 + +// +// Průša i3 MK2 Multiplexer Support +// +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD || TOUCH_UI_ULTIPANEL + + #define KILL_PIN 32 + + #if IS_ULTIPANEL || TOUCH_UI_ULTIPANEL + + #if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS 85 + #define LCD_PINS_ENABLE 71 + #define LCD_PINS_D4 70 + #define BTN_EN1 61 + #define BTN_EN2 59 + #else + #define LCD_PINS_RS 82 + #define LCD_PINS_ENABLE 61 + #define LCD_PINS_D4 59 + #define LCD_PINS_D5 70 + #define LCD_PINS_D6 85 + #define LCD_PINS_D7 71 + #define BTN_EN1 14 + #define BTN_EN2 72 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #define BTN_ENC 9 // AUX-2 + #define BEEPER_PIN 84 // AUX-4 + #define SD_DETECT_PIN 15 + + #endif // IS_ULTIPANEL || TOUCH_UI_ULTIPANEL +#endif // HAS_WIRED_LCD + +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 250 + #define BOARD_ST7920_DELAY_3 0 +#endif + +#undef MK3_FAN_PINS diff --git a/src/pins/rambo/pins_EINSY_RETRO.h b/src/pins/rambo/pins_EINSY_RETRO.h new file mode 100644 index 0000000..413eb8c --- /dev/null +++ b/src/pins/rambo/pins_EINSY_RETRO.h @@ -0,0 +1,210 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Einsy-Retro pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Einsy Retro" + +// +// TMC2130 Configuration_adv defaults for EinsyRetro +// +#if !AXIS_DRIVER_TYPE_X(TMC2130) || !AXIS_DRIVER_TYPE_Y(TMC2130) || !AXIS_DRIVER_TYPE_Z(TMC2130) || !AXIS_DRIVER_TYPE_E0(TMC2130) + #error "You must set ([XYZ]|E0)_DRIVER_TYPE to TMC2130 in Configuration.h for EinsyRetro." +#endif + +// TMC2130 Diag Pins +#define X_DIAG_PIN 64 +#define Y_DIAG_PIN 69 +#define Z_DIAG_PIN 68 +#define E0_DIAG_PIN 65 + +// +// Limit Switches +// +// Only use Diag Pins when SENSORLESS_HOMING is enabled for the TMC2130 drivers. +// Otherwise use a physical endstop based configuration. +// +// SERVO0_PIN and Z_MIN_PIN configuration for BLTOUCH sensor when combined with SENSORLESS_HOMING. +// + +#if DISABLED(SENSORLESS_HOMING) + + #define X_MIN_PIN 12 // X- + #define Y_MIN_PIN 11 // Y- + #define X_MAX_PIN 81 // X+ + #define Y_MAX_PIN 57 // Y+ + +#else + + #if X_HOME_TO_MIN + #define X_MIN_PIN X_DIAG_PIN + #define X_MAX_PIN 81 // X+ + #else + #define X_MIN_PIN 12 // X- + #define X_MAX_PIN X_DIAG_PIN + #endif + + #if Y_HOME_TO_MIN + #define Y_MIN_PIN Y_DIAG_PIN + #define Y_MAX_PIN 57 // Y+ + #else + #define Y_MIN_PIN 11 // Y- + #define Y_MAX_PIN Y_DIAG_PIN + #endif + + #if ENABLED(BLTOUCH) + #define Z_MIN_PIN 11 // Y- + #define SERVO0_PIN 10 // Z- + #endif + +#endif + +#define Z_MAX_PIN 7 +#ifndef Z_MIN_PIN + #define Z_MIN_PIN 10 // Z- +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 10 +#endif + +// +// Steppers +// +#define X_STEP_PIN 37 +#define X_DIR_PIN 49 +#define X_ENABLE_PIN 29 +#define X_CS_PIN 41 + +#define Y_STEP_PIN 36 +#define Y_DIR_PIN 48 +#define Y_ENABLE_PIN 28 +#define Y_CS_PIN 39 + +#define Z_STEP_PIN 35 +#define Z_DIR_PIN 47 +#define Z_ENABLE_PIN 27 +#define Z_CS_PIN 67 + +#define E0_STEP_PIN 34 +#define E0_DIR_PIN 43 +#define E0_ENABLE_PIN 26 +#define E0_CS_PIN 66 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 1 // Analog Input +#define TEMP_BED_PIN 2 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 3 +#define HEATER_BED_PIN 4 + +#ifndef FAN_PIN + #define FAN_PIN 8 +#endif +#define FAN1_PIN 6 + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 9 +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +// use P1 connector for spindle pins +#define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM +#define SPINDLE_LASER_ENA_PIN 18 // Pullup! +#define SPINDLE_DIR_PIN 19 + +// +// Průša i3 MK2 Multiplexer Support +// +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#endif + +// +// LCD / Controller +// +#if ANY(HAS_WIRED_LCD, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) + + #define KILL_PIN 32 + + #if ANY(IS_ULTIPANEL, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) + + #if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS 85 + #define LCD_PINS_ENABLE 71 + #define LCD_PINS_D4 70 + #define BTN_EN1 18 + #define BTN_EN2 19 + #else + #define LCD_PINS_RS 82 + #define LCD_PINS_ENABLE 18 // On 0.6b, use 61 + #define LCD_PINS_D4 19 // On 0.6b, use 59 + #define LCD_PINS_D5 70 + #define LCD_PINS_D6 85 + #define LCD_PINS_D7 71 + #define BTN_EN1 14 + #define BTN_EN2 72 + #endif + + #define BTN_ENC 9 // AUX-2 + #define BEEPER_PIN 84 // AUX-4 + + #define SD_DETECT_PIN 15 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif // IS_ULTIPANEL || TOUCH_UI_ULTIPANEL || TOUCH_UI_FTDI_EVE + +#endif // HAS_WIRED_LCD || TOUCH_UI_ULTIPANEL || TOUCH_UI_FTDI_EVE + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 250 + #define BOARD_ST7920_DELAY_3 0 +#endif diff --git a/src/pins/rambo/pins_MINIRAMBO.h b/src/pins/rambo/pins_MINIRAMBO.h new file mode 100644 index 0000000..31d44f2 --- /dev/null +++ b/src/pins/rambo/pins_MINIRAMBO.h @@ -0,0 +1,202 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Mini-RAMBo pin assignments + */ + +#include "env_validate.h" + +#if MB(MINIRAMBO_10A) + #define BOARD_INFO_NAME "Mini RAMBo 1.0a" +#else + #define BOARD_INFO_NAME "Mini RAMBo" +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 12 +#define X_MAX_PIN 30 +#define Y_MIN_PIN 11 +#define Y_MAX_PIN 24 +#define Z_MIN_PIN 10 +#define Z_MAX_PIN 23 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 23 +#endif + +// +// Steppers +// +#define X_STEP_PIN 37 +#define X_DIR_PIN 48 +#define X_ENABLE_PIN 29 + +#define Y_STEP_PIN 36 +#define Y_DIR_PIN 49 +#define Y_ENABLE_PIN 28 + +#define Z_STEP_PIN 35 +#define Z_DIR_PIN 47 +#define Z_ENABLE_PIN 27 + +#define E0_STEP_PIN 34 +#define E0_DIR_PIN 43 +#define E0_ENABLE_PIN 26 + +// Microstepping pins +#define X_MS1_PIN 40 +#define X_MS2_PIN 41 +#define Y_MS1_PIN 69 +#define Y_MS2_PIN 39 +#define Z_MS1_PIN 68 +#define Z_MS2_PIN 67 +#define E0_MS1_PIN 65 +#define E0_MS2_PIN 66 + +#define MOTOR_CURRENT_PWM_XY_PIN 46 +#define MOTOR_CURRENT_PWM_Z_PIN 45 +#define MOTOR_CURRENT_PWM_E_PIN 44 +// Motor current PWM conversion, PWM value = MotorCurrentSetting * 255 / range +#ifndef MOTOR_CURRENT_PWM_RANGE + #define MOTOR_CURRENT_PWM_RANGE 2000 +#endif +#define DEFAULT_PWM_MOTOR_CURRENT {1300, 1300, 1250} + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 1 // Analog Input +#define TEMP_BED_PIN 2 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 3 +#define HEATER_1_PIN 7 +#if !MB(MINIRAMBO_10A) + #define HEATER_2_PIN 6 +#endif +#define HEATER_BED_PIN 4 + +#ifndef FAN_PIN + #define FAN_PIN 8 +#endif +#define FAN1_PIN 6 + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#if !MB(MINIRAMBO_10A) + #define CASE_LIGHT_PIN 9 +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +// use P1 connector for spindle pins +#define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM +#define SPINDLE_LASER_ENA_PIN 18 // Pullup! +#define SPINDLE_DIR_PIN 19 + +// +// Průša i3 MK2 Multiplexer Support +// +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #if !MB(MINIRAMBO_10A) + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 + #endif +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD || TOUCH_UI_ULTIPANEL + + #if !MB(MINIRAMBO_10A) + #define KILL_PIN 32 + #endif + + #if IS_ULTIPANEL || TOUCH_UI_ULTIPANEL + + #if MB(MINIRAMBO_10A) + + #define BEEPER_PIN 78 + + #define BTN_EN1 80 + #define BTN_EN2 73 + #define BTN_ENC 21 + + #define LCD_PINS_RS 38 + #define LCD_PINS_ENABLE 5 + #define LCD_PINS_D4 14 + #define LCD_PINS_D5 15 + #define LCD_PINS_D6 32 + #define LCD_PINS_D7 31 + + #define SD_DETECT_PIN 72 + + #else // !MINIRAMBO_10A + + // AUX-4 + #define BEEPER_PIN 84 + + // AUX-2 + #define BTN_EN1 14 + #define BTN_EN2 72 + #define BTN_ENC 9 + + #define LCD_PINS_RS 82 + #define LCD_PINS_ENABLE 18 + #define LCD_PINS_D4 19 + #define LCD_PINS_D5 70 + #define LCD_PINS_D6 85 + #define LCD_PINS_D7 71 + + #define SD_DETECT_PIN 15 + + #endif // !MINIRAMBO_10A + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif // IS_ULTIPANEL || TOUCH_UI_ULTIPANEL + +#endif // HAS_WIRED_LCD || TOUCH_UI_ULTIPANEL + +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 250 + #define BOARD_ST7920_DELAY_3 0 +#endif diff --git a/src/pins/rambo/pins_RAMBO.h b/src/pins/rambo/pins_RAMBO.h new file mode 100644 index 0000000..cb7a059 --- /dev/null +++ b/src/pins/rambo/pins_RAMBO.h @@ -0,0 +1,280 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * IMPORTANT NOTE: + * Rambo users should be sure to compile Marlin using either the RAMBo + * board type if using the Arduino IDE - available via the link below - or + * the 'rambo' environment if using platformio, by specifying '-e rambo' on + * the command line or by changing the value of the 'env_default' variable to + * 'rambo' in the supplied platformio.ini. + * + * If you don't compile using the proper board type, the RAMBo's extended + * pins will likely be unavailable and accessories/addons may not work. + * + * Instructions for installing the Arduino RAMBo board type for the + * Arduino IDE are available at: + * https://reprap.org/wiki/Rambo_firmware + */ + +/** + * Rambo pin assignments + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Rambo" +#endif + +// +// Servos +// +#ifndef SERVO0_PIN + #define SERVO0_PIN 22 // Motor header MX1 +#endif +#define SERVO1_PIN 23 // Motor header MX2 +#ifndef SERVO2_PIN + #define SERVO2_PIN 24 // Motor header MX3 +#endif +#define SERVO3_PIN 5 // PWM header pin 5 + +// +// Limit Switches +// +#define X_MIN_PIN 12 +#define X_MAX_PIN 24 +#define Y_MIN_PIN 11 +#define Y_MAX_PIN 23 +#ifndef Z_MIN_PIN + #define Z_MIN_PIN 10 +#endif +#define Z_MAX_PIN 30 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 30 +#endif + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 5 +#endif + +// +// Steppers +// +#define X_STEP_PIN 37 +#define X_DIR_PIN 48 +#define X_ENABLE_PIN 29 + +#define Y_STEP_PIN 36 +#define Y_DIR_PIN 49 +#define Y_ENABLE_PIN 28 + +#define Z_STEP_PIN 35 +#define Z_DIR_PIN 47 +#define Z_ENABLE_PIN 27 + +#define E0_STEP_PIN 34 +#define E0_DIR_PIN 43 +#define E0_ENABLE_PIN 26 + +#define E1_STEP_PIN 33 +#define E1_DIR_PIN 42 +#define E1_ENABLE_PIN 25 + +// Microstepping pins - Mapping not from fastio.h (?) +#define X_MS1_PIN 40 +#define X_MS2_PIN 41 +#define Y_MS1_PIN 69 +#define Y_MS2_PIN 39 +#define Z_MS1_PIN 68 +#define Z_MS2_PIN 67 +#define E0_MS1_PIN 65 +#define E0_MS2_PIN 66 +#define E1_MS1_PIN 63 +#define E1_MS2_PIN 64 + +#define DIGIPOTSS_PIN 38 +#define DIGIPOT_CHANNELS { 4, 5, 3, 0, 1 } // X Y Z E0 E1 digipot channels to stepper driver mapping +#ifndef DIGIPOT_MOTOR_CURRENT + #define DIGIPOT_MOTOR_CURRENT { 135,135,135,135,135 } // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 1 // Analog Input +#define TEMP_BED_PIN 2 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 9 +#define HEATER_1_PIN 7 +#define HEATER_2_PIN 6 +#define HEATER_BED_PIN 3 + +#ifndef FAN_PIN + #define FAN_PIN 8 +#endif +#ifndef FAN1_PIN + #define FAN1_PIN 6 +#endif +#ifndef FAN2_PIN + #define FAN2_PIN 2 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#define PS_ON_PIN 4 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 46 +#endif + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 3 // Analog Input +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_PWM_PIN 45 // Hardware PWM +#define SPINDLE_LASER_ENA_PIN 31 // Pullup! +#define SPINDLE_DIR_PIN 32 + +// +// SPI for MAX Thermocouple +// +#ifndef TEMP_0_CS_PIN + #define TEMP_0_CS_PIN 32 // SPINDLE_DIR_PIN / STAT_LED_BLUE_PIN +#endif + +// +// M7/M8/M9 - Coolant Control +// +#define COOLANT_MIST_PIN 22 +#define COOLANT_FLOOD_PIN 44 + +// +// Průša i3 MK2 Multiplexer Support +// +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 84 // 84 in MK2 Firmware +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD || TOUCH_UI_ULTIPANEL + + #define KILL_PIN 80 + + #if IS_ULTIPANEL || TOUCH_UI_ULTIPANEL + + #define LCD_PINS_RS 70 + #define LCD_PINS_ENABLE 71 + #define LCD_PINS_D4 72 + #define LCD_PINS_D5 73 + #define LCD_PINS_D6 74 + #define LCD_PINS_D7 75 + + #if EITHER(VIKI2, miniVIKI) + #define BEEPER_PIN 44 + // NB: Panucatt's Viki 2.0 wiring diagram (v1.2) indicates that the + // beeper/buzzer is connected to pin 33; however, the pin used in the + // diagram is actually pin 44, so this is correct. + + #define DOGLCD_A0 70 + #define DOGLCD_CS 71 + + #define BTN_EN1 85 + #define BTN_EN2 84 + #define BTN_ENC 83 + + #define SD_DETECT_PIN -1 // Pin 72 if using easy adapter board + + #define STAT_LED_RED_PIN 22 + #define STAT_LED_BLUE_PIN 32 + + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #else // !VIKI2 && !miniVIKI + + #define BEEPER_PIN 79 // AUX-4 + + // AUX-2 + #ifndef BTN_EN1 + #define BTN_EN1 76 + #endif + #ifndef BTN_EN2 + #define BTN_EN2 77 + #endif + #define BTN_ENC 78 + + #define SD_DETECT_PIN 81 + + #endif // !VIKI2 && !miniVIKI + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #else // !IS_NEWPANEL - old style panel with shift register + + // No Beeper added + #define BEEPER_PIN 33 + + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN 38 + //#define SHIFT_LD_PIN 42 + //#define SHIFT_OUT_PIN 40 + //#define SHIFT_EN_PIN 17 + + #define LCD_PINS_RS 75 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + + #endif // !IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 0 + #define BOARD_ST7920_DELAY_3 0 +#endif diff --git a/src/pins/rambo/pins_RAMBO_THINKERV2.h b/src/pins/rambo/pins_RAMBO_THINKERV2.h new file mode 100644 index 0000000..278a5bf --- /dev/null +++ b/src/pins/rambo/pins_RAMBO_THINKERV2.h @@ -0,0 +1,60 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Rambo ThinkerV2 pin assignments + */ + +#define BOARD_INFO_NAME "Rambo ThinkerV2" + +#define SERVO0_PIN 4 // Motor header MX1 +#define SERVO2_PIN -1 // Motor header MX3 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 10 +#endif + +// Support BLTouch and fixed probes +#if ENABLED(BLTOUCH) + #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #define Z_MIN_PIN 22 + #elif !defined(Z_MIN_PROBE_PIN) + #define Z_MIN_PROBE_PIN 22 + #endif +#elif ENABLED(FIX_MOUNTED_PROBE) + #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #define Z_MIN_PIN 4 + #elif !defined(Z_MIN_PROBE_PIN) + #define Z_MIN_PROBE_PIN 4 + #endif +#endif + +// Eryone has the fan pins reversed +#define FAN1_PIN 2 +#define FAN2_PIN 6 + +// Encoder +#define BTN_EN1 64 +#define BTN_EN2 63 + +#include "pins_RAMBO.h" diff --git a/src/pins/rambo/pins_SCOOVO_X9H.h b/src/pins/rambo/pins_SCOOVO_X9H.h new file mode 100644 index 0000000..533284a --- /dev/null +++ b/src/pins/rambo/pins_SCOOVO_X9H.h @@ -0,0 +1,158 @@ +/** + * 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 . + * + */ +#pragma once + +/************************************************ + * Rambo pin assignments MODIFIED FOR Scoovo X9H + ************************************************/ + +#include "env_target.h" + +#define BOARD_INFO_NAME "Scoovo X9H" + +// +// Servos +// +#define SERVO0_PIN 22 // Motor header MX1 +#define SERVO1_PIN 23 // Motor header MX2 +#define SERVO2_PIN 24 // Motor header MX3 +#define SERVO3_PIN 5 // PWM header pin 5 + +// +// Limit Switches +// +#define X_MIN_PIN 12 +#define X_MAX_PIN 24 +#define Y_MIN_PIN 11 +#define Y_MAX_PIN 23 +#define Z_MIN_PIN 10 +#define Z_MAX_PIN 30 + +// +// Z Probe (when not Z_MIN_IN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 30 +#endif + +// +// Steppers +// +#define X_STEP_PIN 37 +#define X_DIR_PIN 48 +#define X_ENABLE_PIN 29 + +#define Y_STEP_PIN 36 +#define Y_DIR_PIN 49 +#define Y_ENABLE_PIN 28 + +#define Z_STEP_PIN 35 +#define Z_DIR_PIN 47 +#define Z_ENABLE_PIN 27 + +#define E0_STEP_PIN 34 +#define E0_DIR_PIN 43 +#define E0_ENABLE_PIN 26 + +#define E1_STEP_PIN 33 +#define E1_DIR_PIN 42 +#define E1_ENABLE_PIN 25 + +// Microstepping pins - Mapping not from fastio.h (?) +#define X_MS1_PIN 40 +#define X_MS2_PIN 41 +#define Y_MS1_PIN 69 +#define Y_MS2_PIN 39 +#define Z_MS1_PIN 68 +#define Z_MS2_PIN 67 +#define E0_MS1_PIN 65 +#define E0_MS2_PIN 66 +#define E1_MS1_PIN 63 +#define E1_MS2_PIN 64 + +#define DIGIPOTSS_PIN 38 +#define DIGIPOT_CHANNELS { 4, 5, 3, 0, 1 } // X Y Z E0 E1 digipot channels to stepper driver mapping + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_BED_PIN 7 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 9 +#define HEATER_1_PIN 7 +#define HEATER_BED_PIN 3 + +#ifndef FAN_PIN + #define FAN_PIN 8 +#endif +#define FAN1_PIN 6 +#define FAN2_PIN 2 + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#define PS_ON_PIN 4 + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 3 // Analog Input +#endif + +// +// LCD / Controller +// +#define LCD_PINS_RS 70 // Ext2_5 +#define LCD_PINS_ENABLE 71 // Ext2_7 +#define LCD_PINS_D4 72 // Ext2_9 ? +#define LCD_PINS_D5 73 // Ext2_11 ? +#define LCD_PINS_D6 74 // Ext2_13 +#define LCD_PINS_D7 75 // Ext2_15 ? +#define BEEPER_PIN -1 + +#define BTN_HOME 80 // Ext_16 +#define BTN_CENTER 81 // Ext_14 +#define BTN_ENC BTN_CENTER +#define BTN_RIGHT 82 // Ext_12 +#define BTN_LEFT 83 // Ext_10 +#define BTN_UP 84 // Ext2_8 +#define BTN_DOWN 85 // Ext2_6 + +#define HOME_PIN BTN_HOME + +#if EITHER(VIKI2, miniVIKI) + #define BEEPER_PIN 44 + // Pins for DOGM SPI LCD Support + #define DOGLCD_A0 70 + #define DOGLCD_CS 71 + + #define SD_DETECT_PIN -1 // Pin 72 if using easy adapter board + + #define STAT_LED_RED_PIN 22 + #define STAT_LED_BLUE_PIN 32 + + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 +#endif diff --git a/src/pins/ramps/env_validate.h b/src/pins/ramps/env_validate.h new file mode 100644 index 0000000..6006a78 --- /dev/null +++ b/src/pins/ramps/env_validate.h @@ -0,0 +1,35 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if ENABLED(ALLOW_SAM3X8E) + #if NOT_TARGET(__SAM3X8E__, __AVR_ATmega2560__) + #error "Oops! Select 'Arduino Due' or 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" + #endif +#elif ENABLED(REQUIRE_MEGA2560) && NOT_TARGET(__AVR_ATmega2560__) + #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" +#elif DISABLED(REQUIRE_MEGA2560) && NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) + #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560 or 1280' in 'Tools > Board.'" +#endif + +#undef ALLOW_SAM3X8E +#undef REQUIRE_MEGA2560 diff --git a/src/pins/ramps/pins_3DRAG.h b/src/pins/ramps/pins_3DRAG.h new file mode 100644 index 0000000..6f5b775 --- /dev/null +++ b/src/pins/ramps/pins_3DRAG.h @@ -0,0 +1,173 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * 3DRAG (and K8200 / K8400) Arduino Mega with RAMPS v1.4 pin assignments + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "3Drag" +#endif + +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#endif + +#ifndef DEFAULT_SOURCE_CODE_URL + #define DEFAULT_SOURCE_CODE_URL "3dprint.elettronicain.it" +#endif + +// +// Limit Switches +// +#define Z_STOP_PIN 18 + +// +// Steppers +// +#if HAS_CUTTER + #define Z_DIR_PIN 28 + #define Z_ENABLE_PIN 24 + #define Z_STEP_PIN 26 +#else + #define Z_ENABLE_PIN 63 +#endif + +#if HAS_CUTTER && !HAS_EXTRUDERS + #define E0_DIR_PIN -1 + #define E0_ENABLE_PIN -1 + #define E0_STEP_PIN -1 +#endif + +// +// Heaters / Fans +// +#define MOSFET_B_PIN 8 +#define MOSFET_C_PIN 9 +#define MOSFET_D_PIN 12 + +// +// Misc. Functions +// +#define SDSS 25 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN -1 // Hardware PWM but one is not available on expansion header +#endif + +/** + * M3/M4/M5 - Spindle/Laser Control + * + * If you want to control the speed of your spindle then you'll have + * have to sacrifce the Extruder and pull some signals off the Z stepper + * driver socket. + * + * The following assumes: + * - the Z stepper driver socket is empty + * - the extruder driver socket has a driver board plugged into it + * - the Z stepper wires are attached the the extruder connector + * + * If you want to keep the extruder AND don't have a LCD display then + * you can still control the power on/off and spindle direction. + * + * Where to get spindle signals + * + * stepper signal socket name socket name + * ------- + * SPINDLE_LASER_ENA_PIN /ENABLE O| |O VMOT + * MS1 O| |O GND + * MS2 O| |O 2B + * MS3 O| |O 2A + * /RESET O| |O 1A + * /SLEEP O| |O 1B + * SPINDLE_LASER_PWM_PIN STEP O| |O VDD + * SPINDLE_DIR_PIN DIR O| |O GND + * ------- + * + * Note: Socket names vary from vendor to vendor + */ +#if HAS_CUTTER + #if !HAS_EXTRUDERS + #define SPINDLE_LASER_PWM_PIN 46 // Hardware PWM + #define SPINDLE_LASER_ENA_PIN 62 // Pullup! + #define SPINDLE_DIR_PIN 48 + #elif !BOTH(HAS_WIRED_LCD, IS_NEWPANEL) // Use expansion header if no LCD in use + #define SPINDLE_LASER_ENA_PIN 16 // Pullup or pulldown! + #define SPINDLE_DIR_PIN 17 + #if !NUM_SERVOS // Use servo connector if possible + #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM + #elif HAS_FREE_AUX2_PINS + #define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM + #endif + #endif +#endif + +#include "pins_RAMPS.h" + +// +// Heaters / Fans +// +#define HEATER_2_PIN 6 + +#undef SD_DETECT_PIN +#define SD_DETECT_PIN 53 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD && IS_NEWPANEL + #undef BEEPER_PIN + + // TODO: Remap EXP1/2 based on adapter + #undef LCD_PINS_RS + #undef LCD_PINS_ENABLE + #undef LCD_PINS_D4 + #undef LCD_PINS_D5 + #undef LCD_PINS_D6 + #undef LCD_PINS_D7 + #define LCD_PINS_RS 27 + #define LCD_PINS_ENABLE 29 + #define LCD_PINS_D4 37 + #define LCD_PINS_D5 35 + #define LCD_PINS_D6 33 + #define LCD_PINS_D7 31 + + // Buttons + #undef BTN_EN1 + #undef BTN_EN2 + #undef BTN_ENC + #define BTN_EN1 16 + #define BTN_EN2 17 + #define BTN_ENC 23 + +#else + + #define BEEPER_PIN 33 + +#endif // HAS_WIRED_LCD && IS_NEWPANEL + +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 188 + #define BOARD_ST7920_DELAY_3 0 +#endif diff --git a/src/pins/ramps/pins_AZTEEG_X3.h b/src/pins/ramps/pins_AZTEEG_X3.h new file mode 100644 index 0000000..31adea4 --- /dev/null +++ b/src/pins/ramps/pins_AZTEEG_X3.h @@ -0,0 +1,97 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * AZTEEG_X3 Arduino Mega with RAMPS v1.4 pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Azteeg X3 supports up to 2 hotends / E steppers." +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !PIN_EXISTS(CASE_LIGHT) + #define CASE_LIGHT_PIN 6 // Define before RAMPS pins include +#endif +#define BOARD_INFO_NAME "Azteeg X3" + +// +// Servos +// +#define SERVO0_PIN 44 // SERVO1 port +#define SERVO1_PIN 55 // SERVO2 port + +#include "pins_RAMPS_13.h" // ... RAMPS + +// +// LCD / Controller +// +#undef STAT_LED_RED_PIN +#undef STAT_LED_BLUE_PIN + +#if EITHER(VIKI2, miniVIKI) + + #undef DOGLCD_A0 + #undef DOGLCD_CS + #undef BTN_ENC + #define DOGLCD_A0 31 + #define DOGLCD_CS 32 + #define BTN_ENC 12 + + #define STAT_LED_RED_PIN 64 + #define STAT_LED_BLUE_PIN 63 + +#else + + #define STAT_LED_RED_PIN 6 + #define STAT_LED_BLUE_PIN 11 + +#endif + +// +// Misc +// +#if ENABLED(CASE_LIGHT_ENABLE) && PINS_EXIST(CASE_LIGHT, STAT_LED_RED) && STAT_LED_RED_PIN == CASE_LIGHT_PIN + #undef STAT_LED_RED_PIN +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#undef SPINDLE_LASER_PWM_PIN // Definitions in pins_RAMPS.h are no good with the AzteegX3 board +#undef SPINDLE_LASER_ENA_PIN +#undef SPINDLE_DIR_PIN + +#if HAS_CUTTER + #undef SDA // use EXP3 header + #undef SCL + #if SERVO0_PIN == 7 + #undef SERVO0_PIN + #define SERVO0_PIN 11 + #endif + #define SPINDLE_LASER_PWM_PIN 7 // Hardware PWM + #define SPINDLE_LASER_ENA_PIN 20 // Pullup! + #define SPINDLE_DIR_PIN 21 +#endif diff --git a/src/pins/ramps/pins_AZTEEG_X3_PRO.h b/src/pins/ramps/pins_AZTEEG_X3_PRO.h new file mode 100644 index 0000000..24266bb --- /dev/null +++ b/src/pins/ramps/pins_AZTEEG_X3_PRO.h @@ -0,0 +1,178 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * AZTEEG_X3_PRO (Arduino Mega) pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 5 || E_STEPPERS > 5 + #error "Azteeg X3 Pro supports up to 5 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Azteeg X3 Pro" + +// +// RAMPS pins overrides +// + +// +// Servos +// +// Tested this pin with bed leveling on a Delta with 1 servo. +// Physical wire attachment on EXT1: GND, 5V, D47. +// +#define SERVO0_PIN 47 + +// +// Limit Switches +// +#define X_STOP_PIN 3 +#define Y_STOP_PIN 14 +#define Z_STOP_PIN 18 + +#ifndef FAN_PIN + #define FAN_PIN 6 +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !PIN_EXISTS(CASE_LIGHT) + #define CASE_LIGHT_PIN 44 +#endif + +// +// Import RAMPS 1.4 pins +// +#include "pins_RAMPS.h" + +// DIGIPOT slave addresses +#ifndef DIGIPOT_I2C_ADDRESS_A + #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for first DIGIPOT 0x2C (0x58 <- 0x2C << 1) +#endif +#ifndef DIGIPOT_I2C_ADDRESS_B + #define DIGIPOT_I2C_ADDRESS_B 0x2E // unshifted slave address for second DIGIPOT 0x2E (0x5C <- 0x2E << 1) +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 18 +#endif + +// +// Steppers +// +#define E2_STEP_PIN 23 +#define E2_DIR_PIN 25 +#define E2_ENABLE_PIN 40 + +#define E3_STEP_PIN 27 +#define E3_DIR_PIN 29 +#define E3_ENABLE_PIN 41 + +#define E4_STEP_PIN 43 +#define E4_DIR_PIN 37 +#define E4_ENABLE_PIN 42 + +// +// Temperature Sensors +// +#define TEMP_2_PIN 12 // Analog Input +#define TEMP_3_PIN 11 // Analog Input +#define TEMP_4_PIN 10 // Analog Input +#define TC1 4 // Analog Input (Thermo couple on Azteeg X3Pro) +#define TC2 5 // Analog Input (Thermo couple on Azteeg X3Pro) + +// +// Heaters / Fans +// +#define HEATER_2_PIN 16 +#define HEATER_3_PIN 17 +#define HEATER_4_PIN 4 +#define HEATER_5_PIN 5 +#define HEATER_6_PIN 6 +#define HEATER_7_PIN 11 + +#ifndef CONTROLLER_FAN_PIN + #define CONTROLLER_FAN_PIN 4 // Pin used for the fan to cool motherboard (-1 to disable) +#endif + +// +// Auto fans +// +#define AUTO_FAN_PIN 5 +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E3_AUTO_FAN_PIN + #define E3_AUTO_FAN_PIN AUTO_FAN_PIN +#endif + +// +// LCD / Controller +// +#undef BEEPER_PIN +#define BEEPER_PIN 33 + +#if EITHER(VIKI2, miniVIKI) + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 49 // For easy adapter board + #undef BEEPER_PIN + #define BEEPER_PIN 12 // 33 isn't physically available to the LCD display +#else + #define STAT_LED_RED_PIN 32 + #define STAT_LED_BLUE_PIN 35 +#endif + +// +// Misc. Functions +// +#if ENABLED(CASE_LIGHT_ENABLE) && PIN_EXISTS(CASE_LIGHT) && defined(DOGLCD_A0) && DOGLCD_A0 == CASE_LIGHT_PIN + #undef DOGLCD_A0 // Steal pin 44 for the case light; if you have a Viki2 and have connected it + #define DOGLCD_A0 57 // following the Panucatt wiring diagram, you may need to tweak these pin assignments + // as the wiring diagram uses pin 44 for DOGLCD_A0. +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#undef SPINDLE_LASER_PWM_PIN // Definitions in pins_RAMPS.h are no good with the AzteegX3pro board +#undef SPINDLE_LASER_ENA_PIN +#undef SPINDLE_DIR_PIN + +#if HAS_CUTTER // EXP2 header + #if EITHER(VIKI2, miniVIKI) + #define BTN_EN2 31 // Pin 7 needed for Spindle PWM + #endif + #define SPINDLE_LASER_PWM_PIN 7 // Hardware PWM + #define SPINDLE_LASER_ENA_PIN 20 // Pullup! + #define SPINDLE_DIR_PIN 21 +#endif diff --git a/src/pins/ramps/pins_BAM_DICE_DUE.h b/src/pins/ramps/pins_BAM_DICE_DUE.h new file mode 100644 index 0000000..fa622ff --- /dev/null +++ b/src/pins/ramps/pins_BAM_DICE_DUE.h @@ -0,0 +1,47 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BAM&DICE Due (Arduino Mega) pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "2PrintBeta Due supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "2PrintBeta Due" + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_ENA_PIN 66 // Pullup or pulldown! +#define SPINDLE_DIR_PIN 67 +#define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM + +// +// Temperature Sensors +// +#define TEMP_0_PIN 9 // Analog Input +#define TEMP_1_PIN 11 // Analog Input + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_BIQU_KFB_2.h b/src/pins/ramps/pins_BIQU_KFB_2.h new file mode 100644 index 0000000..58a62fb --- /dev/null +++ b/src/pins/ramps/pins_BIQU_KFB_2.h @@ -0,0 +1,40 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * KFB 2.0 – Arduino Mega2560 with RAMPS v1.4 pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "KFB 2.0 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "KFB 2.0" + +// +// Heaters / Fans +// +// Power outputs BEEF or BEFF +#define MOSFET_D_PIN 7 + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h b/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h new file mode 100644 index 0000000..4a54b85 --- /dev/null +++ b/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h @@ -0,0 +1,126 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * bq ZUM Mega 3D board definition + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#define BOARD_INFO_NAME "ZUM Mega 3D" + +// +// Limit Switches +// +#define X_MAX_PIN 79 + +// This board has headers for Z-min, Z-max and IND_S_5V *but* as the bq team +// decided to ship the printer only with the probe and no additional Z-min +// endstop and the instruction manual advises the user to connect the probe to +// IND_S_5V the option Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN will not work. +#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #define Z_MIN_PIN 19 // IND_S_5V + #define Z_MAX_PIN 18 // Z-MIN Label +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 19 // IND_S_5V +#endif + +// +// Steppers +// +#define Z_ENABLE_PIN 77 + +#define DIGIPOTSS_PIN 22 +#define DIGIPOT_CHANNELS { 4, 5, 3, 0, 1 } + +// +// Temperature Sensors +// +#define TEMP_1_PIN 14 // Analog Input +#define TEMP_BED_PIN 15 // Analog Input + +// +// Heaters / Fans +// +#define MOSFET_A_PIN 9 +#define MOSFET_B_PIN 12 +#define MOSFET_C_PIN 10 +#define MOSFET_D_PIN 7 + +// +// Auto fans +// +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN 11 +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN 6 +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN 6 +#endif +#ifndef E3_AUTO_FAN_PIN + #define E3_AUTO_FAN_PIN 6 +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_ENA_PIN 40 // Pullup or pulldown! +#define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM +#define SPINDLE_DIR_PIN 42 + +// +// Misc. Functions +// +#define PS_ON_PIN 81 // External Power Supply + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 44 // Hardware PWM +#endif + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 0 + #define BOARD_ST7920_DELAY_3 189 +#endif + +// +// Import RAMPS 1.3 pins +// +#include "pins_RAMPS_13.h" // ... RAMPS + +// +// Used by the Hephestos 2 heated bed upgrade kit +// +#if ENABLED(HEPHESTOS2_HEATED_BED_KIT) + #undef HEATER_BED_PIN + #define HEATER_BED_PIN 8 +#endif diff --git a/src/pins/ramps/pins_COPYMASTER_3D.h b/src/pins/ramps/pins_COPYMASTER_3D.h new file mode 100644 index 0000000..0209410 --- /dev/null +++ b/src/pins/ramps/pins_COPYMASTER_3D.h @@ -0,0 +1,34 @@ +/** + * 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 . + * + */ +#pragma once + +#define BOARD_INFO_NAME "Copymaster 3D RAMPS" + +#define Z_STEP_PIN 47 +#define Y_MAX_PIN 14 +#define FIL_RUNOUT_PIN 15 +#define SD_DETECT_PIN 66 + +// +// Import RAMPS 1.4 pins +// +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_DAGOMA_F5.h b/src/pins/ramps/pins_DAGOMA_F5.h new file mode 100644 index 0000000..e1bd2ec --- /dev/null +++ b/src/pins/ramps/pins_DAGOMA_F5.h @@ -0,0 +1,66 @@ +/** + * 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 . + * + */ +#pragma once + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Dagoma3D F5 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Dagoma3D F5" + +// +// Endstops +// +#define X_STOP_PIN 2 +#define Y_STOP_PIN 3 +#define Z_STOP_PIN 15 + +#define FIL_RUNOUT_PIN 39 +#if EXTRUDERS > 1 + #define FIL_RUNOUT2_PIN 14 +#endif + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 250 + #define BOARD_ST7920_DELAY_3 250 +#endif + +// +// DAC steppers +// +#define HAS_MOTOR_CURRENT_DAC 1 + +#define DAC_STEPPER_ORDER { 0, 1, 2, 3 } + +#define DAC_STEPPER_SENSE 0.11 +#define DAC_STEPPER_ADDRESS 0 +#define DAC_STEPPER_MAX 4096 +#define DAC_STEPPER_VREF 1 +#define DAC_STEPPER_GAIN 0 +#define DAC_OR_ADDRESS 0x00 + +// +// Import default RAMPS 1.4 pins +// +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h b/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h new file mode 100644 index 0000000..1a4b83f --- /dev/null +++ b/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h @@ -0,0 +1,183 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Wanhao Duplicator i3 Plus pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#define BOARD_INFO_NAME "Duplicator i3 Plus" + +// +// Limit Switches +// +#define X_STOP_PIN 54 // PF0 / A0 +#define Y_STOP_PIN 24 // PA2 / AD2 +#define Z_MIN_PIN 23 // PA1 / AD1 +#define Z_MAX_PIN 25 // PA3 / AD3 +#define SERVO0_PIN 40 // PG1 / !RD + +// +// Steppers +// +#define X_STEP_PIN 61 // PF7 / A7 +#define X_DIR_PIN 62 // PK0 / A8 +#define X_ENABLE_PIN 60 // PF6 / A6 + +#define Y_STEP_PIN 64 // PK2 / A10 +#define Y_DIR_PIN 65 // PK3 / A11 +#define Y_ENABLE_PIN 63 // PK1 / A9 + +#define Z_STEP_PIN 67 // PK5 / A13 +#define Z_DIR_PIN 69 // PK7 / A15 +#define Z_ENABLE_PIN 66 // PK4 / A12 +#define Z_MIN_PROBE_PIN 25 // PA3 / AD3 + +#define E0_STEP_PIN 58 // PF4 / A4 +#define E0_DIR_PIN 59 // PF5 / A5 +#define E0_ENABLE_PIN 57 // PF3 / A3 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // PF1 / A1 Analog +#define TEMP_BED_PIN 14 // PK6 / A14 Analog + +// +// Heaters / Fans +// +#define HEATER_0_PIN 4 // PG5 / PWM4 +#define HEATER_BED_PIN 3 // PE5 / PWM3 + +#define FAN_PIN 5 // PE3 / PWM5 + +// +// Misc. Functions +// +#define SDSS 53 // PB0 / SS +#define LED_PIN 13 // PB7 / PWM13 + +#define SD_MISO_PIN 50 // PB3 +#define SD_MOSI_PIN 51 // PB2 +#define SD_SCK_PIN 52 // PB1 + +// +// LCDs and Controllers +// +#if HAS_WIRED_LCD + #if ENABLED(ZONESTAR_LCD) + #define LCD_PINS_RS 2 + #define LCD_PINS_ENABLE 36 + #define LCD_PINS_D4 37 + #define LCD_PINS_D5 34 + #define LCD_PINS_D6 35 + #define LCD_PINS_D7 32 + #define ADC_KEYPAD_PIN 12 // Analog + #endif +#endif + +/** + * == EXT connector == + * + * 2 4 6 8 10 + * #---------------# + * #2 | ° ° ° ° ° | + * #1 | ° ° ° ° ° | + * #---------------# + * 1 3 5 7 9 + * + * ################################## + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################## + * # 1 | 52 / PG1 (!RD) | 40 # + * # 2 | 95 / PF2 (A2) | 56 # + * # 3 | 54 / PC1 (A9) | 36 # + * # 4 | 53 / PC0 (A8) | 37 # + * # 5 | 56 / PC3 (A11) | 34 # + * # 6 | 55 / PC2 (A10) | 35 # + * # 7 | 58 / PC5 (A13) | 32 # + * # 8 | 57 / PC4 (A12) | 33 # + * # 9 | GND | - # + * # 10 | VCC | + # + * ################################## + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * == Z-probe connector == + * + * 1 2 3 + * #---------# + * | ° ° ° | + * #---------# + * + * ################################## + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################## + * # 1 | 24V or 5V | + # + * # 2 | 75 / PA3 (AD3) | 25 # + * # 3 | GND | - # + * ################################## + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * == Y-endstop == == Z-endstop == == Bed temperature == + * + * 1 2 1 2 1 2 + * #------# #------# #------# + * | ° ° | | ° ° | | ° ° | + * #------# #------# #------# + * + * ############### Y ################ ############### Z ################ ############## BED ############### + * # Pin | ATMEGA2560 Pin | Arduino # # Pin | ATMEGA2560 Pin | Arduino # # Pin | ATMEGA2560 Pin | Arduino # + * ################################## ################################## ################################## + * # 1 | GND | - # # 1 | GND | - # # 1 | GND | - # + * # 2 | 76 / PA2 (AD2) | 24 # # 2 | 77 / PA1 (AD1) | 23 # # 2 |83 / PK6 (ADC14)| 14 # + * ################################## ################################## ################################## + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * == SPI connector == + * + * 5 3 1 + * #---------# + * | ° ° ° | + * | ° ° ° | + * #---------# + * 6 4 2 + * + * ################################## + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################## + * # 1 | 22 / PB3 (MISO)| 50 # + * # 2 | VCC | + # + * # 3 | 20 / PB1 (SCK) | 52 # + * # 4 | 21 / PB2 (MOSI)| 51 # + * # 5 | 30 / !RESET | RESET # + * # 6 | GND | - # + * ################################## + * + * Pictogram by Ludy https://github.com/Ludy87 + * See: https://sebastien.andrivet.com/en/posts/wanhao-duplicator-i3-plus-3d-printer/ + */ diff --git a/src/pins/ramps/pins_FELIX2.h b/src/pins/ramps/pins_FELIX2.h new file mode 100644 index 0000000..3e7849d --- /dev/null +++ b/src/pins/ramps/pins_FELIX2.h @@ -0,0 +1,63 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * FELIXprinters v2.0/3.0 (RAMPS v1.4) pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Felix 2.0+ supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Felix 2.0+" + +// +// Heaters / Fans +// +// Power outputs EFBF or EFBE +#define MOSFET_D_PIN 7 + +#include "pins_RAMPS.h" + +// +// Misc. Functions +// +#define SDPOWER_PIN 1 + +#define PS_ON_PIN 12 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD && IS_NEWPANEL + + #define SD_DETECT_PIN 6 + +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#undef SPINDLE_LASER_PWM_PIN // Definitions in pins_RAMPS.h are not valid with this board +#undef SPINDLE_LASER_ENA_PIN +#undef SPINDLE_DIR_PIN diff --git a/src/pins/ramps/pins_FORMBOT_RAPTOR.h b/src/pins/ramps/pins_FORMBOT_RAPTOR.h new file mode 100644 index 0000000..a6791ff --- /dev/null +++ b/src/pins/ramps/pins_FORMBOT_RAPTOR.h @@ -0,0 +1,181 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Formbot Raptor pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "Formbot supports up to 3 hotends / E steppers." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Formbot Raptor" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#endif + +// +// Servos +// +#define SERVO0_PIN 11 +#define SERVO1_PIN 6 +#define SERVO2_PIN 5 + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#ifndef X_MAX_PIN + #define X_MAX_PIN 2 +#endif +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN 53 +#endif + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#ifndef Y_CS_PIN + #define Y_CS_PIN 49 +#endif + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 +#ifndef Z_CS_PIN + #define Z_CS_PIN 40 +#endif + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +#ifndef E0_CS_PIN + #define E0_CS_PIN 42 +#endif + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#ifndef E1_CS_PIN + #define E1_CS_PIN 44 +#endif + +#define E2_STEP_PIN 42 +#define E2_DIR_PIN 43 +#define E2_ENABLE_PIN 44 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // Analog Input +#define TEMP_1_PIN 15 // Analog Input +#define TEMP_BED_PIN 14 // Analog Input + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card +#else + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 +#define HEATER_BED_PIN 8 + +#ifndef FAN_PIN + #define FAN_PIN 9 +#endif + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 57 +#endif + +#if !HAS_FILAMENT_SENSOR + #define FAN1_PIN 4 +#endif + +// +// Misc. Functions +// +#ifndef SDSS + #define SDSS 53 +#endif +#define LED_PIN 13 +#define LED4_PIN 5 + +// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector +#define FILWIDTH_PIN 5 // Analog Input + +#ifndef PS_ON_PIN + #define PS_ON_PIN 12 +#endif + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 5 +#endif + +// +// LCD / Controller +// +// Formbot only supports REPRAP_DISCOUNT_SMART_CONTROLLER +// +#if IS_RRD_SC + #define BEEPER_PIN 37 + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 +#endif diff --git a/src/pins/ramps/pins_FORMBOT_RAPTOR2.h b/src/pins/ramps/pins_FORMBOT_RAPTOR2.h new file mode 100644 index 0000000..4fb10bf --- /dev/null +++ b/src/pins/ramps/pins_FORMBOT_RAPTOR2.h @@ -0,0 +1,74 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Formbot Raptor 2 pin assignments + */ + +#define BOARD_INFO_NAME "Formbot Raptor2" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +#define FAN_PIN 6 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 22 +#endif + +#include "pins_FORMBOT_RAPTOR.h" + +#define GREEDY_PANEL ANY(PANEL_ONE, VIKI2, miniVIKI, MINIPANEL, REPRAPWORLD_KEYPAD) + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER && !PIN_EXISTS(SPINDLE_LASER_ENA) + #if !NUM_SERVOS // Try to use servo connector first + #define SPINDLE_LASER_ENA_PIN 6 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 4 // Hardware PWM + #define SPINDLE_DIR_PIN 5 + #elif !GREEDY_PANEL // Try to use AUX2 + #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM + #define SPINDLE_DIR_PIN 65 + #endif +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !PIN_EXISTS(CASE_LIGHT) + #if NUM_SERVOS <= 1 // Try to use servo connector first + #define CASE_LIGHT_PIN 6 // Hardware PWM + #elif !GREEDY_PANEL // Try to use AUX2 + #define CASE_LIGHT_PIN 44 // Hardware PWM + #endif +#endif + +#undef GREEDY_PANEL + +#if ENABLED(CASE_LIGHT_ENABLE) && PIN_EXISTS(CASE_LIGHT) && (CASE_LIGHT_PIN == SPINDLE_LASER_ENA_PIN || CASE_LIGHT_PIN == SPINDLE_LASER_PWM_PIN) + #error "CASE_LIGHT_PIN conflicts with a Spindle / Laser pin." +#endif + +#if HAS_MARLINUI_U8GLIB + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 +#endif diff --git a/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h b/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h new file mode 100644 index 0000000..17d3abc --- /dev/null +++ b/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h @@ -0,0 +1,189 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Formbot pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Formbot supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Formbot" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Servos +// +#define SERVO0_PIN 11 +#define SERVO1_PIN -1 // was 6 +#define SERVO2_PIN -1 // was 5 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#ifndef X_MAX_PIN + #define X_MAX_PIN 2 +#endif +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN 53 +#endif + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#ifndef Y_CS_PIN + #define Y_CS_PIN 49 +#endif + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 +#ifndef Z_CS_PIN + #define Z_CS_PIN 40 +#endif + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +#ifndef E0_CS_PIN + #define E0_CS_PIN 42 +#endif + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#ifndef E1_CS_PIN + #define E1_CS_PIN 44 +#endif + +#define E2_STEP_PIN 42 +#define E2_DIR_PIN 43 +#define E2_ENABLE_PIN 44 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // Analog Input +#define TEMP_1_PIN 15 // Analog Input +#define TEMP_BED_PIN 3 // Analog Input + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card +#else + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 +#define HEATER_BED_PIN 58 + +#define FAN_PIN 9 + +#if HAS_FILAMENT_SENSOR + #define FIL_RUNOUT_PIN 4 + //#define FIL_RUNOUT2_PIN -1 +#else + // Though defined as a fan pin, it is utilized as a dedicated laser pin by Formbot. + #define FAN1_PIN 4 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#ifndef LED_PIN + #define LED_PIN 13 // The Formbot v 1 board has almost no unassigned pins on it. The Board's LED +#endif // is a good place to get a signal to control the Max7219 LED Matrix. + +// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector +#define FILWIDTH_PIN 5 // Analog Input + +#ifndef PS_ON_PIN + #define PS_ON_PIN 12 +#endif + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 8 +#endif + +// +// LCD / Controller +// +// Formbot only supports REPRAP_DISCOUNT_SMART_CONTROLLER +// +#if IS_RRD_SC + #ifndef BEEPER_PIN + #define BEEPER_PIN 37 + #endif + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + #define SD_DETECT_PIN 49 + + // Allow MAX7219 to steal the KILL pin + #if !defined(KILL_PIN) && MAX7219_CLK_PIN != 41 && MAX7219_DIN_PIN != 41 && MAX7219_LOAD_PIN != 41 + #define KILL_PIN 41 + #endif + + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 +#endif + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 200 + #define BOARD_ST7920_DELAY_2 200 + #define BOARD_ST7920_DELAY_3 200 +#endif diff --git a/src/pins/ramps/pins_FORMBOT_TREX3.h b/src/pins/ramps/pins_FORMBOT_TREX3.h new file mode 100644 index 0000000..e23a639 --- /dev/null +++ b/src/pins/ramps/pins_FORMBOT_TREX3.h @@ -0,0 +1,187 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Formbot pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Formbot supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Formbot" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Servos +// +#define SERVO0_PIN 11 +#define SERVO1_PIN -1 // was 6 +#define SERVO2_PIN -1 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#ifndef X_MAX_PIN + #define X_MAX_PIN 2 +#endif +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN 53 +#endif + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#ifndef Y_CS_PIN + #define Y_CS_PIN 49 +#endif + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 +#ifndef Z_CS_PIN + #define Z_CS_PIN 40 +#endif + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +#ifndef E0_CS_PIN + #define E0_CS_PIN 42 +#endif + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#ifndef E1_CS_PIN + #define E1_CS_PIN 44 +#endif + +#if HAS_X2_STEPPER + #define X2_STEP_PIN 42 + #define X2_DIR_PIN 43 + #define X2_ENABLE_PIN 44 +#else + #define E2_STEP_PIN 42 + #define E2_DIR_PIN 43 + #define E2_ENABLE_PIN 44 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // Analog Input +#define TEMP_1_PIN 15 // Analog Input +#define TEMP_BED_PIN 14 // Analog Input + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card +#else + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 +#define HEATER_BED_PIN 8 + +#define FAN_PIN 9 +#define FAN1_PIN 12 + +#define FIL_RUNOUT_PIN 22 +#define FIL_RUNOUT2_PIN 21 + +// +// Misc. Functions +// +#define SDSS 53 + +#ifndef LED_PIN + #define LED_PIN 13 +#endif + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 5 +#endif + +#define SPINDLE_LASER_PWM_PIN -1 // Hardware PWM +#define SPINDLE_LASER_ENA_PIN 4 // Pullup! + +// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector +#define FILWIDTH_PIN 5 // Analog Input + +// +// LCD / Controller +// +// Formbot only supports REPRAP_DISCOUNT_SMART_CONTROLLER +// +#if IS_RRD_SC + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + #define SD_DETECT_PIN 49 + #ifndef KILL_PIN + #define KILL_PIN 41 + #endif + #ifndef BEEPER_PIN + #define BEEPER_PIN 37 + #endif +#endif + +#if HAS_MARLINUI_U8GLIB + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 +#endif diff --git a/src/pins/ramps/pins_FYSETC_F6_13.h b/src/pins/ramps/pins_FYSETC_F6_13.h new file mode 100644 index 0000000..b8de260 --- /dev/null +++ b/src/pins/ramps/pins_FYSETC_F6_13.h @@ -0,0 +1,301 @@ +/** + * 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 . + * + */ +#pragma once + +// +// FYSETC F6 1.3 (and 1.4) pin assignments +// + +#if NOT_TARGET(__AVR_ATmega2560__) + #error "Oops! Select 'FYSETC F6' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "FYSETC F6 1.3" +#endif + +#define RESET_PIN 30 +#define SPI_FLASH_CS_PIN 83 + +// +// Servos +// +#define SERVO0_PIN 13 +#define SERVO1_PIN 11 // (PS_ON_PIN) +#define SERVO2_PIN 10 // (FIL_RUNOUT_PIN) +#define SERVO3_PIN 4 // (RGB_LED_G_PIN) + +// +// Limit Switches +// +#define X_MIN_PIN 63 +#define X_MAX_PIN 64 +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 12 +#ifndef Z_MAX_PIN + #define Z_MAX_PIN 9 +#endif + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN SERVO2_PIN +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 9 // Servos pin +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN 70 +#endif + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#ifndef Y_CS_PIN + #define Y_CS_PIN 39 +#endif + +#define Z_STEP_PIN 43 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 58 +#ifndef Z_CS_PIN + #define Z_CS_PIN 74 +#endif + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +#ifndef E0_CS_PIN + #define E0_CS_PIN 47 +#endif + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#ifndef E1_CS_PIN + #define E1_CS_PIN 32 +#endif + +#define E2_STEP_PIN 59 +#define E2_DIR_PIN 57 +#define E2_ENABLE_PIN 40 +#ifndef E2_CS_PIN + #define E2_CS_PIN 42 +#endif + +// +// Sensorless homing DIAG pin is not directly connected to the MCU. Close +// the jumper next to the limit switch socket when using sensorless homing. +// + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Software serial communication pins. + * At the moment, F6 rx pins are not pc interrupt pins + */ + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN 72 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN -1 // 71 + #endif + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN 75 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN -1 // 73 + #endif + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN 79 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN -1 // 78 + #endif + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN 77 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN -1 // 76 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN 81 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN -1 // 80 + #endif + #ifndef E2_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN 82 + #endif + #ifndef E2_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN -1 // 22 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 12 // Analog Input +#define TEMP_1_PIN 13 // Analog Input +#define TEMP_2_PIN 14 // Analog Input +#define TEMP_BED_PIN 15 // Analog Input + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 9 // Analog Input on X+ endstop +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 5 +#define HEATER_1_PIN 6 +#define HEATER_2_PIN 7 +#define HEATER_BED_PIN 8 + +#define FAN_PIN 44 +#define FAN1_PIN 45 +#define FAN2_PIN 46 + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#define KILL_PIN 41 + +#ifndef PS_ON_PIN + #define PS_ON_PIN SERVO1_PIN +#endif + +/** + * ----- ----- + * 5V/D41 | · · | GND 5V | · · | GND + * RESET | · · | D49 (SD_DETECT) (LCD_D7) D29 | · · | D27 (LCD_D6) + * (MOSI) D51 | · · D33 (BTN_EN2) (LCD_D5) D25 | · · D23 (LCD_D4) + * (SD_SS) D53 | · · | D31 (BTN_EN1) (LCD_RS) D16 | · · | D17 (LCD_EN) + * (SCK) D52 | · · | D50 (MISO) (BTN_ENC) D35 | · · | D37 (BEEPER) + * ----- ----- + * EXP2 EXP1 + */ + +// +// LCDs and Controllers +// +#define SD_DETECT_PIN 49 + +#if ENABLED(FYSETC_242_OLED_12864) + #define BTN_EN1 37 + #define BTN_EN2 29 + #define BTN_ENC 35 + #define BEEPER_PIN 31 + + #define LCD_PINS_DC 25 + #define LCD_PINS_RS 33 + #define DOGLCD_CS 16 + #define DOGLCD_MOSI 23 + #define DOGLCD_SCK 17 + #define DOGLCD_A0 LCD_PINS_DC + + #undef KILL_PIN + #define NEOPIXEL_PIN 27 + +#else + #define BEEPER_PIN 37 + + #if ENABLED(FYSETC_MINI_12864) + // + // See https://wiki.fysetc.com/Mini12864_Panel/ + // + #define DOGLCD_A0 16 + #define DOGLCD_CS 17 + + #if ENABLED(FYSETC_GENERIC_12864_1_1) + #define LCD_BACKLIGHT_PIN 27 + #endif + + #define LCD_RESET_PIN 23 // Must be high or open for LCD to operate normally. + // Seems to work best if left open. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN 25 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN 27 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN 29 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN 25 + #endif + + #elif HAS_MARLINUI_U8GLIB || HAS_MARLINUI_HD44780 + + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_CS 25 + #define DOGLCD_A0 27 + #endif + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #if IS_NEWPANEL + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + #endif +#endif + +#ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN 3 +#endif +#ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN 4 +#endif +#ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN 9 +#endif +#ifndef RGB_LED_W_PIN + #define RGB_LED_W_PIN -1 +#endif diff --git a/src/pins/ramps/pins_FYSETC_F6_14.h b/src/pins/ramps/pins_FYSETC_F6_14.h new file mode 100644 index 0000000..1fc2415 --- /dev/null +++ b/src/pins/ramps/pins_FYSETC_F6_14.h @@ -0,0 +1,55 @@ +/** + * 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 . + * + */ +#pragma once + +// +// FYSETC F6 v1.4 pin assignments +// + +#define BOARD_INFO_NAME "FYSETC F6 1.4" + +#define Z_MAX_PIN 2 + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + */ + #define X_SERIAL_TX_PIN 71 + #define X_SERIAL_RX_PIN 72 + + #define Y_SERIAL_TX_PIN 78 + #define Y_SERIAL_RX_PIN 73 + + #define Z_SERIAL_TX_PIN 79 + #define Z_SERIAL_RX_PIN 75 + + #define E0_SERIAL_TX_PIN 81 + #define E0_SERIAL_RX_PIN 77 + + #define E1_SERIAL_TX_PIN 80 + #define E1_SERIAL_RX_PIN 76 + + #define E2_SERIAL_TX_PIN 82 + #define E2_SERIAL_RX_PIN 62 +#endif + +#include "pins_FYSETC_F6_13.h" diff --git a/src/pins/ramps/pins_K8200.h b/src/pins/ramps/pins_K8200.h new file mode 100644 index 0000000..395e1cc --- /dev/null +++ b/src/pins/ramps/pins_K8200.h @@ -0,0 +1,33 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * K8200 Arduino Mega with RAMPS v1.3 pin assignments + * Identical to 3DRAG + */ + +#define BOARD_INFO_NAME "Velleman K8200" +#define DEFAULT_MACHINE_NAME "K8200" +#define DEFAULT_SOURCE_CODE_URL "github.com/CONSULitAS/Marlin-K8200" + +#include "pins_3DRAG.h" // ... RAMPS diff --git a/src/pins/ramps/pins_K8400.h b/src/pins/ramps/pins_K8400.h new file mode 100644 index 0000000..36c438a --- /dev/null +++ b/src/pins/ramps/pins_K8400.h @@ -0,0 +1,66 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Velleman K8400 (Vertex) + * 3DRAG clone + * + * K8400 has some minor differences over a normal 3Drag: + * - No X/Y max endstops + * - Second extruder step pin has moved + * - No power supply control + * - Second heater has moved pin + */ + +#define BOARD_INFO_NAME "K8400" +#define DEFAULT_MACHINE_NAME "Vertex" + +// +// Steppers +// +#if HAS_CUTTER + #define Z_STEP_PIN 32 +#endif + +#define E1_STEP_PIN 32 + +// +// Limit Switches +// +#define X_STOP_PIN 3 +#define Y_STOP_PIN 14 + +#include "pins_3DRAG.h" // ... RAMPS + +// +// Heaters / Fans +// +#undef HEATER_1_PIN +#define HEATER_1_PIN 11 + +// +// Misc. Functions +// +#undef PS_ON_PIN +#undef KILL_PIN +#undef SD_DETECT_PIN diff --git a/src/pins/ramps/pins_K8600.h b/src/pins/ramps/pins_K8600.h new file mode 100644 index 0000000..a9613e8 --- /dev/null +++ b/src/pins/ramps/pins_K8600.h @@ -0,0 +1,100 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * VERTEX NANO Arduino Mega with RAMPS EFB v1.4 pin assignments. + */ + +#if HAS_MULTI_HOTEND + #error "K8600 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "K8600" +#define DEFAULT_MACHINE_NAME "Vertex Nano" + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define Y_MAX_PIN 14 +#define Z_MAX_PIN 18 +#define Z_MIN_PIN -1 + +// +// Steppers +// +#define Z_ENABLE_PIN 63 + +// +// Heaters / Fans +// +#define FAN_PIN 8 + +// +// Misc. Functions +// +#define SDSS 25 +#define CASE_LIGHT_PIN 7 + +// +// Other RAMPS pins +// +#include "pins_RAMPS.h" + +// +// Heaters / Fans +// +#undef HEATER_BED_PIN + +// +// LCD / Controller +// +#if HAS_WIRED_LCD && IS_NEWPANEL + #undef BEEPER_PIN + + #undef LCD_PINS_RS + #undef LCD_PINS_ENABLE + #undef LCD_PINS_D4 + #undef LCD_PINS_D5 + #undef LCD_PINS_D6 + #undef LCD_PINS_D7 + #define LCD_PINS_RS 27 + #define LCD_PINS_ENABLE 29 + #define LCD_PINS_D4 37 + #define LCD_PINS_D5 35 + #define LCD_PINS_D6 33 + #define LCD_PINS_D7 31 + + // Buttons + #undef BTN_EN1 + #undef BTN_EN2 + #undef BTN_ENC + #define BTN_EN1 17 + #define BTN_EN2 16 + #define BTN_ENC 23 + +#else + + #define BEEPER_PIN 33 + +#endif diff --git a/src/pins/ramps/pins_K8800.h b/src/pins/ramps/pins_K8800.h new file mode 100644 index 0000000..17bb59f --- /dev/null +++ b/src/pins/ramps/pins_K8800.h @@ -0,0 +1,116 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Velleman K8800 (Vertex) + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "K8800" +#define DEFAULT_MACHINE_NAME "Vertex Delta" + +// +// Limit Switches +// +#define X_STOP_PIN 3 +#define Y_STOP_PIN 14 +#define Z_STOP_PIN 66 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 68 +#endif + +#define FIL_RUNOUT_PIN 69 // PK7 + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 63 + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define FAN_PIN 8 +#define CONTROLLER_FAN_PIN 9 + +// +// Misc. Functions +// +#define KILL_PIN 20 // PD1 +#define CASE_LIGHT_PIN 7 + +// +// SD Card +// +#define SDSS 25 +#define SD_DETECT_PIN 21 // PD0 + +// +// LCD / Controller +// +#define BEEPER_PIN 6 + +#if HAS_WIRED_LCD + + #define LCD_SDSS 53 + + #define DOGLCD_CS 29 + #define DOGLCD_A0 27 + + #define LCD_PINS_RS 27 + #define LCD_PINS_ENABLE 29 + #define LCD_PINS_D4 37 + #define LCD_PINS_D5 35 + #define LCD_PINS_D6 33 + #define LCD_PINS_D7 31 + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #if IS_NEWPANEL + #define BTN_EN1 17 + #define BTN_EN2 16 + #define BTN_ENC 23 + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/src/pins/ramps/pins_LONGER3D_LKx_PRO.h new file mode 100644 index 0000000..af1d33c --- /dev/null +++ b/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -0,0 +1,121 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Longer3D LK1/LK4/LK5 Pro board pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Longer3D LGT KIT V1.0 only supports 1 hotend / E stepper." +#endif + +#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || SERIAL_PORT_3 == 1 + #warning "Serial 1 is originally reserved to DGUS LCD." +#endif +#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || SERIAL_PORT_3 == 2 || LCD_SERIAL_PORT == 2 + #warning "Serial 2 has no connector. Hardware changes may be required to use it." +#endif +#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || SERIAL_PORT_3 == 3 || LCD_SERIAL_PORT == 3 + #define CHANGE_Y_LIMIT_PINS + #warning "Serial 3 is originally reserved to Y limit switches. Hardware changes are required to use it." +#endif + +// Custom flags and defines for the build +//#define BOARD_CUSTOM_BUILD_FLAGS -D__FOO__ + +#define BOARD_INFO_NAME "LGT KIT V1.0" + +// +// Servos +// +#if !MB(LONGER3D_LK1_PRO) + #define SERVO0_PIN 7 +#endif +#define SERVO1_PIN -1 +#define SERVO2_PIN -1 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_STOP_PIN 3 + +#ifdef CHANGE_Y_LIMIT_PINS + #define Y_STOP_PIN 37 +#else + #define Y_MIN_PIN 14 + #define Y_MAX_PIN 15 +#endif + +#if !MB(LONGER3D_LK1_PRO) + #ifdef CHANGE_Y_LIMIT_PINS + #define Z_STOP_PIN 35 + #else + #define Z_MIN_PIN 35 + #define Z_MAX_PIN 37 + #endif +#else + #define Z_MIN_PIN 11 + #define Z_MAX_PIN 37 +#endif + +#undef CHANGE_Y_LIMIT_PINS + +// +// Steppers - No E1 pins +// +#define E1_STEP_PIN -1 +#define E1_DIR_PIN -1 +#define E1_ENABLE_PIN -1 +#define E1_CS_PIN -1 + +// +// Z Probe (when not Z_MIN_PIN) +// +#define Z_MIN_PROBE_PIN -1 + +// +// Temperature Sensors +// +#define TEMP_1_PIN -1 + +// +// Průša i3 MK2 Multiplexer Support +// +#if HAS_PRUSA_MMU1 + #define E_MUX2_PIN -1 +#endif + +// +// Misc. Functions +// +#define SD_DETECT_PIN 49 +#define FIL_RUNOUT_PIN 2 + +// +// Other RAMPS 1.3 pins +// +#include "pins_RAMPS_13.h" // ... RAMPS diff --git a/src/pins/ramps/pins_MAKEBOARD_MINI.h b/src/pins/ramps/pins_MAKEBOARD_MINI.h new file mode 100644 index 0000000..a42dba8 --- /dev/null +++ b/src/pins/ramps/pins_MAKEBOARD_MINI.h @@ -0,0 +1,33 @@ +/** + * 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 . + * + */ +#pragma once + +#define BOARD_INFO_NAME "MAKEboard Mini" + +// +// Only 3 Limit Switch plugs on Micromake C1 +// +#define X_STOP_PIN 2 +#define Y_STOP_PIN 15 +#define Z_STOP_PIN 19 + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_MKS_BASE_10.h b/src/pins/ramps/pins_MKS_BASE_10.h new file mode 100644 index 0000000..64efa46 --- /dev/null +++ b/src/pins/ramps/pins_MKS_BASE_10.h @@ -0,0 +1,37 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS BASE 1.0 – Arduino Mega2560 with RAMPS v1.4 pin assignments + * + * Rev B - Override pin definitions for CASE_LIGHT and M3/M4/M5 spindle control + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS BASE 1.0 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS BASE 1.0" +#define MKS_BASE_VERSION 10 + +#include "pins_MKS_BASE_common.h" // ... RAMPS diff --git a/src/pins/ramps/pins_MKS_BASE_14.h b/src/pins/ramps/pins_MKS_BASE_14.h new file mode 100644 index 0000000..7e2a722 --- /dev/null +++ b/src/pins/ramps/pins_MKS_BASE_14.h @@ -0,0 +1,170 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS BASE 1.4 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS BASE 1.4" +#define MKS_BASE_VERSION 14 + +// +// Heaters / Fans +// +#define FAN_PIN 9 // PH6 ** Pin18 ** PWM9 + +// Other Mods + +#define SERVO3_PIN 12 // PB6 ** Pin25 ** D12 +#define PS_ON_PIN 2 // X+ // PE4 ** Pin6 ** PWM2 **MUST BE HARDWARE PWM +#define FILWIDTH_PIN 15 // Y+ // PJ0 ** Pin63 ** USART3_RX **Pin should have a pullup! +#define FIL_RUNOUT_PIN 19 // Z+ // PD2 ** Pin45 ** USART1_RX + +#ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN 50 +#endif +#ifndef RGB_LED_R_PIN + #define RGB_LED_G_PIN 51 +#endif +#ifndef RGB_LED_R_PIN + #define RGB_LED_B_PIN 52 +#endif + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 11 // PB5 ** Pin24 ** PWM11 +#endif + +#include "pins_MKS_BASE_common.h" // ... RAMPS + +/* + Available connectors on MKS BASE v1.4 + + ======= + | GND | + |-----| E0 + | 10 | (10) PB4 ** Pin23 ** PWM10 + |-----| + | GND | + |-----| E1 + | 7 | ( 7) PH4 ** Pin16 ** PWM7 + |-----| + | GND | + |-----| FAN + | 9 | ( 9) PH6 ** Pin18 ** PWM9 + ======= + + ======= + | GND | + |-----| Heated Bed + | 8 | ( 8) PH5 ** Pin17 ** PWM8 + ======= + + ========== + | 12-24V | + |--------| Power + | GND | + ========== + + XS3 Connector + ================= + | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 + |----|-----|----| + | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 + ================= + + Servos Connector + ================= + | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 + |----|-----|----| + | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 + ================= + + ICSP + ================= + | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI + |----|----|-----| + | 50 | 52 | RST | (50) PB3 ** Pin22 ** SPI_MISO + ================= (52) PB1 ** Pin20 ** SPI_SCK + + XS6/AUX-1 Connector + ====================== + | 5V | GND | NC | 20 | (20) PD1 ** Pin44 ** I2C_SDA + |----|-----|----|----| + | 50 | 51 | 52 | 21 | (50) PB3 ** Pin22 ** SPI_MISO + ====================== (51) PB2 ** Pin21 ** SPI_MOSI + (52) PB1 ** Pin20 ** SPI_SCK + (21) PD0 ** Pin43 ** I2C_SCL + + Temperature + ================================== + | GND | 69 | GND | 68 | GND | 67 | + ================================== + (69) PK7 ** Pin82 ** A15 + (68) PK6 ** Pin83 ** A14 + (67) PK5 ** Pin84 ** A13 + + Limit Switches + ============ + | 2 | GND | X+ ( 2) PE4 ** Pin6 ** PWM2 + |----|-----| + | 3 | GND | X- ( 3) PE5 ** Pin7 ** PWM3 + |----|-----| + | 15 | GND | Y+ (15) PJ0 ** Pin63 ** USART3_RX + |----|-----| + | 14 | GND | Y- (14) PJ1 ** Pin64 ** USART3_TX + |----|-----| + | 19 | GND | Z+ (19) PD2 ** Pin45 ** USART1_RX + |----|-----| + | 18 | GND | Z- (18) PD3 ** Pin46 ** USART1_TX + ============ + + EXP1 + ============ + | 37 | 35 | (37) PC0 ** Pin53 ** D37 + |-----|----| (35) PC2 ** Pin55 ** D35 + | 17 | 16 | (17) PH0 ** Pin12 ** USART2_RX + |-----|----| (16) PH1 ** Pin13 ** USART2_TX + | 23 | 25 | (23) PA1 ** Pin77 ** D23 + |-----|----| (25) PA3 ** Pin75 ** D25 + | 27 | 29 | (27) PA5 ** Pin73 ** D27 + |-----|----| (29) PA7 ** Pin71 ** D29 + | GND | 5V | + ============ + + EXP2 + ============ + | 50 | 52 | (50) PB3 ** Pin22 ** SPI_MISO + |-----|----| (52) PB1 ** Pin20 ** SPI_SCK + | 31 | 53 | (31) PC6 ** Pin59 ** D31 + |-----|----| (53) PB0 ** Pin19 ** SPI_SS + | 33 | 51 | (33) PC4 ** Pin57 ** D33 + |-----|----| (51) PB2 ** Pin21 ** SPI_MOSI + | 49 | 41 | (49) PL0 ** Pin35 ** D49 + |-----|----| (41) PG0 ** Pin51 ** D41 + | GND | NC | + ============ +*/ diff --git a/src/pins/ramps/pins_MKS_BASE_15.h b/src/pins/ramps/pins_MKS_BASE_15.h new file mode 100644 index 0000000..5fedd3f --- /dev/null +++ b/src/pins/ramps/pins_MKS_BASE_15.h @@ -0,0 +1,35 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS BASE v1.5 with A4982 stepper drivers and digital micro-stepping + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS BASE 1.5 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS BASE 1.5" +#define MKS_BASE_VERSION 15 + +#include "pins_MKS_BASE_common.h" // ... RAMPS diff --git a/src/pins/ramps/pins_MKS_BASE_16.h b/src/pins/ramps/pins_MKS_BASE_16.h new file mode 100644 index 0000000..63e0b51 --- /dev/null +++ b/src/pins/ramps/pins_MKS_BASE_16.h @@ -0,0 +1,59 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * 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 . + * + */ +#pragma once + +/** + * MKS BASE v1.6 with A4982 stepper drivers and digital micro-stepping + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS BASE 1.6 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS BASE 1.6" +#define MKS_BASE_VERSION 16 + +// +// Servos +// +#define SERVO1_PIN 12 // Digital 12 / Pin 25 + +// +// Omitted RAMPS pins +// +#ifndef SERVO2_PIN + #define SERVO2_PIN -1 +#endif +#ifndef SERVO3_PIN + #define SERVO3_PIN -1 +#endif +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN -1 +#endif +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN -1 +#endif +#ifndef PS_ON_PIN + #define PS_ON_PIN -1 +#endif + +#include "pins_MKS_BASE_common.h" // ... RAMPS diff --git a/src/pins/ramps/pins_MKS_BASE_HEROIC.h b/src/pins/ramps/pins_MKS_BASE_HEROIC.h new file mode 100644 index 0000000..973f924 --- /dev/null +++ b/src/pins/ramps/pins_MKS_BASE_HEROIC.h @@ -0,0 +1,36 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS BASE with Heroic HR4982 stepper drivers + */ + +#include "pins_MKS_BASE_15.h" // ... MKS_BASE_common ... RAMPS + +/** + * Some new boards use HR4982 (Heroic) instead of the A4982 (Allegro) stepper drivers. + * Most the functionality is similar, the HR variant obviously doesn't work with diode + * smoothers (no fast decay). And the Heroic has a 128 µStepping mode where the A4982 + * is doing quarter steps (MS1=0, MS2=1). + */ +#define HEROIC_STEPPER_DRIVERS diff --git a/src/pins/ramps/pins_MKS_BASE_common.h b/src/pins/ramps/pins_MKS_BASE_common.h new file mode 100644 index 0000000..9047a4b --- /dev/null +++ b/src/pins/ramps/pins_MKS_BASE_common.h @@ -0,0 +1,75 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS BASE – Arduino Mega2560 with RAMPS pin assignments + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS BASE" +#endif + +#if MKS_BASE_VERSION >= 14 + // + // Heaters / Fans + // + // Power outputs EFBF or EFBE + #define MOSFET_D_PIN 7 + + // + // M3/M4/M5 - Spindle/Laser Control + // + #if HAS_CUTTER + #define SPINDLE_LASER_PWM_PIN 2 // Hardware PWM + #define SPINDLE_LASER_ENA_PIN 15 // Pullup! + #define SPINDLE_DIR_PIN 19 + #endif + + #ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 2 + #endif + +#endif + +// +// Microstepping pins +// +#if MKS_BASE_VERSION >= 14 // |===== 1.4 =====|===== 1.5+ =====| + #define X_MS1_PIN 5 // PE3 | Pin 5 | PWM5 | | D3 | SERVO2_PIN + #define X_MS2_PIN 6 // PH3 | Pin 15 | PWM6 | Pin 14 | D6 | SERVO1_PIN + #define Y_MS1_PIN 59 // PF5 | Pin 92 | A5 | | | + #define Y_MS2_PIN 58 // PF4 | Pin 93 | A4 | | | + #define Z_MS1_PIN 22 // PA0 | Pin 78 | D22 | | | + #define Z_MS2_PIN 39 // PG2 | Pin 70 | D39 | | | + #if MKS_BASE_VERSION == 14 + #define E0_MS1_PIN 64 // PK2 | Pin 87 | A10 | | | + #define E0_MS2_PIN 63 // PK1 | Pin 88 | A9 | | | + #else + #define E0_MS1_PIN 63 // PK1 | | | Pin 86 | A9 | + #define E0_MS2_PIN 64 // PK2 | | | Pin 87 | A10 | + #endif + #define E1_MS1_PIN 57 // PF3 | Pin 94 | A3 | Pin 93 | A3 | + #define E1_MS2_PIN 4 // PG5 | Pin 1 | PWM4 | | D4 | SERVO3_PIN +#endif + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_MKS_GEN_13.h b/src/pins/ramps/pins_MKS_GEN_13.h new file mode 100644 index 0000000..7a8c99e --- /dev/null +++ b/src/pins/ramps/pins_MKS_GEN_13.h @@ -0,0 +1,130 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega with RAMPS v1.4 adjusted pin assignments + * + * MKS GEN v1.3 (Extruder, Fan, Bed) + * MKS GEN v1.3 (Extruder, Extruder, Fan, Bed) + * MKS GEN v1.4 (Extruder, Fan, Bed) + * MKS GEN v1.4 (Extruder, Extruder, Fan, Bed) + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS GEN 1.3/1.4 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS GEN >= v1.3" + +// +// Heaters / Fans +// +// Power outputs EFBF or EFBE +#define MOSFET_D_PIN 7 + +// +// PSU / SERVO +// +// If PSU_CONTROL is specified, always hijack Servo 3 +// +#if ENABLED(PSU_CONTROL) + #define SERVO3_PIN -1 + #define PS_ON_PIN 4 +#endif + +#include "pins_RAMPS.h" + +#undef EXP2_08_PIN +#define EXP2_08_PIN -1 // RESET + +// +// LCD / Controller +// +#if EITHER(VIKI2, miniVIKI) + /** + * VIKI2 Has two groups of wires with... + * + * +Vin + Input supply, requires 120ma for LCD and mSD card + * GND Ground Pin + * MOSI Data input for LCD and SD + * MISO Data output for SD + * SCK Clock for LCD and SD + * AO Reg. Sel for LCD + * LCS Chip Select for LCD + * SDCS Chip Select for SD + * SDCD Card Detect pin for SD + * ENCA Encoder output A + * ENCB Encoder output B + * ENCBTN Encoder button switch + * + * BTN Panel mounted button switch + * BUZZER Piezo buzzer + * BLUE-LED Blue LED ring pin (3 to 5v, mosfet buffered) + * RED-LED Red LED ring pin (3 to 5v, mosfet buffered) + * + * This configuration uses the following arrangement: + * + * ------ ------ + * ENCB | 1 2 | ENCA MISO | 1 2 | SCK + * BLUE_LED | 3 4 | RED_LED ENCBTN | 3 4 | SDCS + * KILL 5 6 | BEEPER 5 6 | MOSI + * A0 | 7 8 | LCD_CS SDCD | 7 8 | + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ + #undef SD_DETECT_PIN + #undef BTN_EN1 + #undef BTN_EN2 + #undef BTN_ENC + #undef DOGLCD_A0 + #undef DOGLCD_CS + #undef BEEPER_PIN + #undef KILL_PIN + #undef STAT_LED_RED_PIN + #undef STAT_LED_BLUE_PIN + + // + // VIKI2 12-wire lead + // + #define SD_DETECT_PIN EXP2_07_PIN // SDCD orange/white + #define BTN_EN1 EXP1_02_PIN // ENCA white + #define BTN_EN2 EXP1_01_PIN // ENCB green + #define BTN_ENC EXP2_03_PIN // ENCBTN purple + #define DOGLCD_A0 EXP1_07_PIN // A0 brown + #define DOGLCD_CS EXP1_08_PIN // LCS green/white + + // EXP2_01_PIN gray MISO + // EXP2_06_PIN yellow MOSI + // EXP2_02_PIN orange SCK + + //#define SDSS EXP2_04_PIN // SDCS blue + + // + // VIKI2 4-wire lead + // + #define KILL_PIN EXP1_05_PIN // BTN blue + #define BEEPER_PIN EXP1_06_PIN // BUZZER green + #define STAT_LED_RED_PIN EXP1_04_PIN // RED-LED yellow + #define STAT_LED_BLUE_PIN EXP1_03_PIN // BLUE-LED white +#endif diff --git a/src/pins/ramps/pins_MKS_GEN_L.h b/src/pins/ramps/pins_MKS_GEN_L.h new file mode 100644 index 0000000..ca1f133 --- /dev/null +++ b/src/pins/ramps/pins_MKS_GEN_L.h @@ -0,0 +1,59 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * 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 . + * + */ +#pragma once + +/** + * MKS GEN L – Arduino Mega2560 with RAMPS v1.4 pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS GEN L supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS GEN L" + +// +// Heaters / Fans +// +// Power outputs EFBF or EFBE +#define MOSFET_D_PIN 7 + +// Hotend, Hotend, Bed + Fan on D9 +#if FET_ORDER_EEB + #define MOSFET_B_PIN 7 + #define FAN_PIN 9 +#endif + +// +// CS Pins wired to avoid conflict with the LCD +// See https://www.thingiverse.com/asset:66604 +// + +#ifndef X_CS_PIN + #define X_CS_PIN 59 +#endif + +#ifndef Y_CS_PIN + #define Y_CS_PIN 63 +#endif + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_MKS_GEN_L_V2.h b/src/pins/ramps/pins_MKS_GEN_L_V2.h new file mode 100644 index 0000000..0378b16 --- /dev/null +++ b/src/pins/ramps/pins_MKS_GEN_L_V2.h @@ -0,0 +1,89 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS GEN L V2 – Arduino Mega2560 with RAMPS v1.4 pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS GEN L V2 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS GEN L V2" + +// +// Heaters / Fans +// +// Power outputs EFBF or EFBE +#define MOSFET_D_PIN 7 + +// +// CS Pins wired to avoid conflict with the LCD +// See https://www.thingiverse.com/asset:66604 +// + +#ifndef X_CS_PIN + #define X_CS_PIN 63 +#endif + +#ifndef Y_CS_PIN + #define Y_CS_PIN 64 +#endif + +#ifndef Z_CS_PIN + #define Z_CS_PIN 65 +#endif + +#ifndef E0_CS_PIN + #define E0_CS_PIN 66 +#endif + +#ifndef E1_CS_PIN + #define E1_CS_PIN 21 +#endif + +// TMC2130 Diag Pins (currently just for reference) +#define X_DIAG_PIN 3 +#define Y_DIAG_PIN 14 +#define Z_DIAG_PIN 18 +#define E0_DIAG_PIN 2 +#define E1_DIAG_PIN 15 + +#ifndef SERVO1_PIN + #define SERVO1_PIN 12 +#endif +#ifndef SERVO2_PIN + #define SERVO2_PIN 39 +#endif +#ifndef SERVO3_PIN + #define SERVO3_PIN 32 +#endif + +#ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN 20 +#endif +#ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN 21 +#endif + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_MKS_GEN_L_V21.h b/src/pins/ramps/pins_MKS_GEN_L_V21.h new file mode 100644 index 0000000..bc58d0f --- /dev/null +++ b/src/pins/ramps/pins_MKS_GEN_L_V21.h @@ -0,0 +1,85 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS GEN L V2 – Arduino Mega2560 with RAMPS v1.4 pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS GEN L V2.1 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS GEN L V2.1" + +// +// Heaters / Fans +// +// Power outputs EFBF or EFBE +// #define MOSFET_D_PIN 7 + +// +// CS Pins wired to avoid conflict with the LCD +// See https://www.thingiverse.com/asset:66604 +// + +#ifndef X_CS_PIN + #define X_CS_PIN 63 +#endif +#ifndef Y_CS_PIN + #define Y_CS_PIN 64 +#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN 65 +#endif +#ifndef E0_CS_PIN + #define E0_CS_PIN 66 +#endif +#ifndef E1_CS_PIN + #define E1_CS_PIN 12 +#endif + +// TMC2130 Diag Pins (currently just for reference) +#define X_DIAG_PIN 3 +#define Y_DIAG_PIN 14 +#define Z_DIAG_PIN 18 +#define E0_DIAG_PIN 2 +#define E1_DIAG_PIN 15 + +#ifndef SERVO1_PIN + #define SERVO1_PIN 21 +#endif +#ifndef SERVO2_PIN + #define SERVO2_PIN 39 +#endif +#ifndef SERVO3_PIN + #define SERVO3_PIN 32 +#endif + +#ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN 20 +#endif +#ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN 12 +#endif + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_ORTUR_4.h b/src/pins/ramps/pins_ORTUR_4.h new file mode 100644 index 0000000..bc86c1a --- /dev/null +++ b/src/pins/ramps/pins_ORTUR_4.h @@ -0,0 +1,105 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Ortur 4 Arduino Mega based on RAMPS v1.4 pin assignments + */ + +#define BOARD_INFO_NAME "Ortur 4.3" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Servos +// +#define SERVO0_PIN 29 + +// +// Limit Switches +// +#define X_MAX_PIN 18 +#define Z_MIN_PIN 63 + +#define Z_MIN_PROBE_PIN 2 +#define FIL_RUNOUT_PIN 59 + +// +// Steppers +// +#define E0_STEP_PIN 36 +#define E0_DIR_PIN 34 +#define E0_ENABLE_PIN 30 +#define E0_CS_PIN 44 + +#define E1_STEP_PIN 26 +#define E1_DIR_PIN 28 +#define E1_ENABLE_PIN 24 +#define E1_CS_PIN 42 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 15 // Analog Input +#define TEMP_1_PIN 13 // Analog Input + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN 59 + #define X_SERIAL_RX_PIN 63 + + #define Y_SERIAL_TX_PIN 64 + #define Y_SERIAL_RX_PIN 40 + + #define Z_SERIAL_TX_PIN 44 + #define Z_SERIAL_RX_PIN 42 + + #define E0_SERIAL_TX_PIN 66 + #define E0_SERIAL_RX_PIN 65 +#endif + +#include "pins_RAMPS.h" + +// +// LCD / Controller +// +#if IS_RRD_FG_SC + #undef BEEPER_PIN + #define BEEPER_PIN 35 + + #undef LCD_PINS_RS + #undef LCD_PINS_ENABLE + #undef LCD_PINS_D4 + #define LCD_PINS_RS 27 + #define LCD_PINS_ENABLE 23 + #define LCD_PINS_D4 37 + + #undef LCD_SDSS + #undef SD_DETECT_PIN + #define LCD_SDSS 53 + #define SD_DETECT_PIN 49 + + #undef BTN_EN1 + #undef BTN_EN2 + #undef BTN_ENC + #define BTN_EN1 29 + #define BTN_EN2 25 + #define BTN_ENC 16 +#endif diff --git a/src/pins/ramps/pins_PXMALION_CORE_I3.h b/src/pins/ramps/pins_PXMALION_CORE_I3.h new file mode 100644 index 0000000..12c40c7 --- /dev/null +++ b/src/pins/ramps/pins_PXMALION_CORE_I3.h @@ -0,0 +1,86 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Pxmalion Core i3 - https://github.com/Pxmalion + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Core i3" +#endif + +// +// Servos +// +#define SERVO0_PIN 51 +#define SERVO1_PIN -1 +#define SERVO2_PIN -1 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_STOP_PIN 3 +#define Y_STOP_PIN 2 +#define Z_MIN_PIN 19 +#define Z_MAX_PIN 18 + +// TODO: Filament Runout Sensor +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN -1 +#endif + +// +// Steppers +// +#define X_CS_PIN -1 +#define Y_CS_PIN -1 +#define Z_CS_PIN -1 +#define E0_CS_PIN -1 +#define E1_CS_PIN -1 + +// +// Heaters / Fans +// +#define FET_ORDER_EFB +#ifndef MOSFET_A_PIN + #define MOSFET_A_PIN 8 +#endif +#ifndef MOSFET_B_PIN + #define MOSFET_B_PIN 7 +#endif +#ifndef MOSFET_C_PIN + #define MOSFET_C_PIN 9 +#endif + +// +// Misc. Functions +// +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN -1 // Analog Input +#endif + +#define PS_ON_PIN 11 + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_RAMPS.h b/src/pins/ramps/pins_RAMPS.h new file mode 100644 index 0000000..43903d1 --- /dev/null +++ b/src/pins/ramps/pins_RAMPS.h @@ -0,0 +1,916 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega with RAMPS v1.4 (or v1.3) pin assignments + * + * Applies to the following boards: + * + * RAMPS_14_EFB (Hotend, Fan, Bed) + * RAMPS_14_EEB (Hotend0, Hotend1, Bed) + * RAMPS_14_EFF (Hotend, Fan0, Fan1) + * RAMPS_14_EEF (Hotend0, Hotend1, Fan) + * RAMPS_14_SF (Spindle, Controller Fan) + * + * RAMPS_13_EFB (Hotend, Fan, Bed) + * RAMPS_13_EEB (Hotend0, Hotend1, Bed) + * RAMPS_13_EFF (Hotend, Fan0, Fan1) + * RAMPS_13_EEF (Hotend0, Hotend1, Fan) + * RAMPS_13_SF (Spindle, Controller Fan) + * + * Other pins_MYBOARD.h files may override these defaults + * + * Differences between + * RAMPS_13 | RAMPS_14 + * 7 | 11 + */ + +#if ENABLED(AZSMZ_12864) && DISABLED(ALLOW_SAM3X8E) + #error "No pins defined for RAMPS with AZSMZ_12864." +#endif + +#include "env_validate.h" + +// Custom flags and defines for the build +//#define BOARD_CUSTOM_BUILD_FLAGS -D__FOO__ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "RAMPS 1.4" +#endif + +// +// Servos +// +#ifndef SERVO0_PIN + #ifdef IS_RAMPS_13 + #define SERVO0_PIN 7 + #else + #define SERVO0_PIN 11 + #endif +#endif +#ifndef SERVO1_PIN + #define SERVO1_PIN 6 +#endif +#ifndef SERVO2_PIN + #define SERVO2_PIN 5 +#endif +#ifndef SERVO3_PIN + #define SERVO3_PIN 4 +#endif + +// +// Limit Switches +// +#ifndef X_STOP_PIN + #ifndef X_MIN_PIN + #define X_MIN_PIN 3 + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN 2 + #endif +#endif +#ifndef Y_STOP_PIN + #ifndef Y_MIN_PIN + #define Y_MIN_PIN 14 + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN 15 + #endif +#endif +#ifndef Z_STOP_PIN + #ifndef Z_MIN_PIN + #define Z_MIN_PIN 18 + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN 19 + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN 53 +#endif + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#ifndef Y_CS_PIN + #define Y_CS_PIN 49 +#endif + +#ifndef Z_STEP_PIN + #define Z_STEP_PIN 46 +#endif +#ifndef Z_DIR_PIN + #define Z_DIR_PIN 48 +#endif +#ifndef Z_ENABLE_PIN + #define Z_ENABLE_PIN 62 +#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN 40 +#endif + +#ifndef E0_STEP_PIN + #define E0_STEP_PIN 26 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN 28 +#endif +#ifndef E0_ENABLE_PIN + #define E0_ENABLE_PIN 24 +#endif +#ifndef E0_CS_PIN + #define E0_CS_PIN 42 +#endif + +#ifndef E1_STEP_PIN + #define E1_STEP_PIN 36 +#endif +#ifndef E1_DIR_PIN + #define E1_DIR_PIN 34 +#endif +#ifndef E1_ENABLE_PIN + #define E1_ENABLE_PIN 30 +#endif +#ifndef E1_CS_PIN + #define E1_CS_PIN 44 +#endif + +// +// Temperature Sensors +// +#ifndef TEMP_0_PIN + #define TEMP_0_PIN 13 // Analog Input +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN 15 // Analog Input +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN 14 // Analog Input +#endif + +// +// SPI for MAX Thermocouple +// +#ifndef TEMP_0_CS_PIN + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card (SDSS) or 49 (SD_DETECT_PIN) +#endif + +// +// Heaters / Fans +// +/* #ifndef MOSFET_A_PIN + #define MOSFET_A_PIN 10 +#endif +#ifndef MOSFET_B_PIN + #define MOSFET_B_PIN 9 +#endif +#ifndef MOSFET_C_PIN + #define MOSFET_C_PIN 8 +#endif +#ifndef MOSFET_D_PIN + #define MOSFET_D_PIN -1 +#endif + +#define HEATER_0_PIN MOSFET_A_PIN + +#if FET_ORDER_EFB // Hotend, Fan, Bed + #define HEATER_BED_PIN MOSFET_C_PIN +#elif FET_ORDER_EEF // Hotend, Hotend, Fan + #define HEATER_1_PIN MOSFET_B_PIN +#elif FET_ORDER_EEB // Hotend, Hotend, Bed + #define HEATER_1_PIN MOSFET_B_PIN + #define HEATER_BED_PIN MOSFET_C_PIN +#elif FET_ORDER_EFF // Hotend, Fan, Fan + #define FAN1_PIN MOSFET_C_PIN +#elif DISABLED(FET_ORDER_SF) // Not Spindle, Fan (i.e., "EFBF" or "EFBE") + #define HEATER_BED_PIN MOSFET_C_PIN + #if EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) + #define HEATER_1_PIN MOSFET_D_PIN + #else + #define FAN1_PIN MOSFET_D_PIN + #endif +#endif + +#ifndef FAN_PIN + #if EITHER(FET_ORDER_EFB, FET_ORDER_EFF) // Hotend, Fan, Bed or Hotend, Fan, Fan + #define FAN_PIN MOSFET_B_PIN + #elif EITHER(FET_ORDER_EEF, FET_ORDER_SF) // Hotend, Hotend, Fan or Spindle, Fan + #define FAN_PIN MOSFET_C_PIN + #elif FET_ORDER_EEB // Hotend, Hotend, Bed + #define FAN_PIN 4 // IO pin. Buffer needed + #else // Non-specific are "EFB" (i.e., "EFBF" or "EFBE") + #define FAN_PIN MOSFET_B_PIN + #endif +#endif */ + +#define FAN_PIN 4 +#define FAN1_PIN 9 +#define HEATER_BED_PIN 8 +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 + +// +// Misc. Functions +// +#ifndef SDSS + #define SDSS AUX3_06_PIN +#endif +#define LED_PIN 13 + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 5 // Analog Input on AUX2 +#endif + +// RAMPS 1.4 DIO 4 on the servos connector +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 4 +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN 12 +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN) + #if NUM_SERVOS <= 1 // Prefer the servo connector + #define CASE_LIGHT_PIN 6 // Hardware PWM + #elif HAS_FREE_AUX2_PINS + #define CASE_LIGHT_PIN 44 // Hardware PWM + #endif +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN) + #if NUM_SERVOS < 2 // Use servo connector if possible + #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! + #ifndef SPINDLE_LASER_PWM_PIN + #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM + #endif + #define SPINDLE_DIR_PIN 5 + #elif HAS_FREE_AUX2_PINS + #define SPINDLE_LASER_ENA_PIN 40 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM + #define SPINDLE_DIR_PIN 65 + #else + #error "No auto-assignable Spindle/Laser pins available." + #endif +#endif + +// +// TMC software SPI +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI 66 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO 44 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK 64 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + * + * Serial2 -- AUX-4 Pin 18 (D16 TX2) and AUX-4 Pin 17 (D17 RX2) + * Serial1 -- Pins D18 and D19 are used for Z-MIN and Z-MAX + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN 40 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN 63 + #endif + #ifndef X2_SERIAL_TX_PIN + #define X2_SERIAL_TX_PIN -1 + #endif + #ifndef X2_SERIAL_RX_PIN + #define X2_SERIAL_RX_PIN -1 + #endif + + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN 59 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN 64 + #endif + #ifndef Y2_SERIAL_TX_PIN + #define Y2_SERIAL_TX_PIN -1 + #endif + #ifndef Y2_SERIAL_RX_PIN + #define Y2_SERIAL_RX_PIN -1 + #endif + + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN 42 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN 65 + #endif + #ifndef Z2_SERIAL_TX_PIN + #define Z2_SERIAL_TX_PIN -1 + #endif + #ifndef Z2_SERIAL_RX_PIN + #define Z2_SERIAL_RX_PIN -1 + #endif + + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN 44 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN 66 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN -1 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN -1 + #endif + #ifndef E2_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN -1 + #endif + #ifndef E2_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN -1 + #endif + #ifndef E3_SERIAL_TX_PIN + #define E3_SERIAL_TX_PIN -1 + #endif + #ifndef E3_SERIAL_RX_PIN + #define E3_SERIAL_RX_PIN -1 + #endif + #ifndef E4_SERIAL_TX_PIN + #define E4_SERIAL_TX_PIN -1 + #endif + #ifndef E4_SERIAL_RX_PIN + #define E4_SERIAL_RX_PIN -1 + #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif +#endif + +// +// Průša i3 MK2 Multiplexer Support +// +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 40 // Z_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 42 // E0_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 44 // E1_CS_PIN + #endif +#endif + +// +// AUX1 5V GND D2 D1 +// 2 4 6 8 +// 1 3 5 7 +// 5V GND A3 A4 +// +#define AUX1_05_PIN 57 // (A3) +#define AUX1_06_PIN 2 +#define AUX1_07_PIN 58 // (A4) +#define AUX1_08_PIN 1 + +// +// AUX2 GND A9 D40 D42 A11 +// 2 4 6 8 10 +// 1 3 5 7 9 +// VCC A5 A10 D44 A12 +// +#define AUX2_03_PIN 59 // (A5) +#define AUX2_04_PIN 63 // (A9) +#define AUX2_05_PIN 64 // (A10) +#define AUX2_06_PIN 40 +#define AUX2_07_PIN 44 +#define AUX2_08_PIN 42 +#define AUX2_09_PIN 66 // (A12) +#define AUX2_10_PIN 65 // (A11) + +// +// AUX3 GND D52 D50 5V +// 7 5 3 1 +// 8 6 4 2 +// NC D53 D51 D49 +// +#define AUX3_02_PIN 49 +#define AUX3_03_PIN 50 +#define AUX3_04_PIN 51 +#define AUX3_05_PIN 52 +#define AUX3_06_PIN 53 + +// +// AUX4 5V GND D32 D47 D45 D43 D41 D39 D37 D35 D33 D31 D29 D27 D25 D23 D17 D16 +// +#define AUX4_03_PIN 32 +#define AUX4_04_PIN 47 +#define AUX4_05_PIN 45 +#define AUX4_06_PIN 43 +#define AUX4_07_PIN 41 +#define AUX4_08_PIN 39 +#define AUX4_09_PIN 37 +#define AUX4_10_PIN 35 +#define AUX4_11_PIN 33 +#define AUX4_12_PIN 31 +#define AUX4_13_PIN 29 +#define AUX4_14_PIN 27 +#define AUX4_15_PIN 25 +#define AUX4_16_PIN 23 +#define AUX4_17_PIN 17 +#define AUX4_18_PIN 16 + +/** + * LCD adapters come in different variants. The socket keys can be + * on either side, and may be backwards on some boards / displays. + */ +#ifndef EXP1_08_PIN + + #define EXP1_03_PIN AUX4_17_PIN + #define EXP1_04_PIN AUX4_18_PIN + #define EXP1_05_PIN AUX4_16_PIN + #define EXP1_06_PIN AUX4_15_PIN + #define EXP1_07_PIN AUX4_14_PIN + #define EXP1_08_PIN AUX4_13_PIN + + #define EXP2_01_PIN AUX3_03_PIN + #define EXP2_02_PIN AUX3_05_PIN + #define EXP2_04_PIN AUX3_06_PIN + #define EXP2_06_PIN AUX3_04_PIN + #define EXP2_07_PIN AUX3_02_PIN + + #if ENABLED(G3D_PANEL) + /** Gadgets3D Smart Adapter + * ------ ------ + * 4-11 | 1 2 | 4-12 (MISO) 3-03 | 1 2 | 3-05 (SCK) + * 4-17 | 3 4 | 4-18 4-10 | 3 4 | 3-06 + * 4-16 5 6 | 4-15 4-09 5 6 | 3-04 (MOSI) + * 4-14 | 7 8 | 4-13 3-02 | 7 8 | 4-07 + * (GND) 4-02 | 9 10 | 4-01 (5V) -- | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ + #define EXP1_01_PIN AUX4_11_PIN + #define EXP1_02_PIN AUX4_12_PIN + + #define EXP2_03_PIN AUX4_10_PIN + #define EXP2_05_PIN AUX4_09_PIN + #define EXP2_08_PIN AUX4_07_PIN + + #else + + /** Smart Adapter (c) RRD + * ------ ------ + * 4-09 | 1 2 | 4-10 (MISO) 3-03 | 1 2 | 3-05 (SCK) + * 4-17 | 3 4 | 4-18 4-12 | 3 4 | 3-06 + * 4-16 5 6 | 4-15 4-11 5 6 | 3-04 (MOSI) + * 4-14 | 7 8 | 4-13 3-02 | 7 8 | 4-07 + * (GND) 3-07 | 9 10 | 3-01 (5V) (GND) 3-07 | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ + #define EXP1_01_PIN AUX4_09_PIN + #define EXP1_02_PIN AUX4_10_PIN + + #if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + #define EXP2_03_PIN AUX4_11_PIN + #define EXP2_05_PIN AUX4_12_PIN + #define EXP2_08_PIN -1 // RESET + #else + #define EXP2_03_PIN AUX4_12_PIN + #define EXP2_05_PIN AUX4_11_PIN + #define EXP2_08_PIN AUX4_07_PIN + #endif + + #endif + +#endif + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +#if HAS_WIRED_LCD + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + // + // LCD Display output pins + // + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define LCD_PINS_RS EXP2_07_PIN // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE EXP2_06_PIN // SID (MOSI) + #define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + #define LCD_PINS_RS AUX2_06_PIN + #define LCD_PINS_ENABLE AUX2_08_PIN + #define LCD_PINS_D4 AUX2_10_PIN + #define LCD_PINS_D5 AUX2_09_PIN + #define LCD_PINS_D6 AUX2_07_PIN + #define LCD_PINS_D7 AUX2_05_PIN + + #elif ENABLED(TFTGLCD_PANEL_SPI) + + #define TFTGLCD_CS EXP2_05_PIN + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP1_01_PIN + #endif + + #elif ENABLED(ZONESTAR_LCD) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ZONESTAR_LCD on RAMPS requires wiring modifications. It plugs into AUX2 but GND and 5V need to be swapped. See 'pins_RAMPS.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define LCD_PINS_RS AUX2_05_PIN + #define LCD_PINS_ENABLE AUX2_07_PIN + #define LCD_PINS_D4 AUX2_04_PIN + #define LCD_PINS_D5 AUX2_06_PIN + #define LCD_PINS_D6 AUX2_08_PIN + #define LCD_PINS_D7 AUX2_10_PIN + + #elif ENABLED(AZSMZ_12864) + + // Pins only defined for RAMPS_SMART currently + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + #define LCD_PINS_DC EXP1_06_PIN // Set as output on init + #define LCD_PINS_RS EXP1_07_PIN // Pull low for 1s to init + // DOGM SPI LCD Support + #define DOGLCD_A0 LCD_PINS_DC + #define DOGLCD_CS EXP1_04_PIN + #define DOGLCD_MOSI EXP1_03_PIN + #define DOGLCD_SCK EXP1_05_PIN + #else + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #endif + + #define LCD_PINS_D7 EXP1_08_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP2_05_PIN + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN 38 + //#define SHIFT_LD_PIN AUX2_08_PIN + //#define SHIFT_OUT_PIN AUX2_06_PIN + //#define SHIFT_EN_PIN EXP1_03_PIN + #endif + + #endif + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN EXP1_01_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #else + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #endif + + #define BTN_ENC EXP1_02_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif + #ifndef KILL_PIN + #define KILL_PIN EXP2_08_PIN + #endif + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + #define LCD_BACKLIGHT_PIN AUX4_08_PIN + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define BTN_EN1 AUX2_05_PIN + #define BTN_EN2 AUX2_03_PIN + #define BTN_ENC AUX2_04_PIN + #define SD_DETECT_PIN AUX2_08_PIN + + #elif ENABLED(LCD_I2C_PANELOLU2) + + #define BTN_EN1 AUX4_04_PIN + #define BTN_EN2 AUX4_06_PIN + #define BTN_ENC AUX4_03_PIN + #define LCD_SDSS SDSS + #define KILL_PIN EXP2_08_PIN + + #elif ENABLED(LCD_I2C_VIKI) + + #define BTN_EN1 AUX2_06_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains AUX2-06 and AUX2-08. + #define BTN_EN2 AUX2_08_PIN + #define BTN_ENC -1 + + #define LCD_SDSS SDSS + #define SD_DETECT_PIN EXP2_07_PIN + + #elif EITHER(VIKI2, miniVIKI) + + #define DOGLCD_CS AUX4_05_PIN + #define DOGLCD_A0 AUX2_07_PIN + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #define BEEPER_PIN EXP2_05_PIN + #define STAT_LED_RED_PIN AUX4_03_PIN + #define STAT_LED_BLUE_PIN EXP1_02_PIN + + #define BTN_EN1 22 + #define BTN_EN2 7 + #define BTN_ENC AUX4_08_PIN + + #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + #define KILL_PIN EXP2_03_PIN + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_07_PIN + + #define BEEPER_PIN EXP1_05_PIN + #define LCD_BACKLIGHT_PIN EXP2_05_PIN + + #define BTN_EN1 EXP1_02_PIN + #define BTN_EN2 EXP1_01_PIN + #define BTN_ENC EXP2_03_PIN + + #define LCD_SDSS SDSS + #define SD_DETECT_PIN EXP2_07_PIN + #define KILL_PIN EXP2_08_PIN + + #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif + + #ifndef KILL_PIN + #define KILL_PIN EXP2_08_PIN + #endif + + #if ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + + // not connected to a pin + #define LCD_BACKLIGHT_PIN -1 // 65 (MKS mini12864 can't adjust backlight by software!) + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #elif ENABLED(FYSETC_MINI_12864) + + // From https://wiki.fysetc.com/Mini12864_Panel/ + + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN + + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + + #endif + + #elif ENABLED(MINIPANEL) + + #define BEEPER_PIN AUX2_08_PIN + #define LCD_BACKLIGHT_PIN AUX2_10_PIN + + #define DOGLCD_A0 AUX2_07_PIN + #define DOGLCD_CS AUX2_09_PIN + + #define BTN_EN1 AUX2_06_PIN + #define BTN_EN2 AUX2_04_PIN + #define BTN_ENC AUX2_03_PIN + + #define SD_DETECT_PIN AUX3_02_PIN + #define KILL_PIN AUX2_05_PIN + + #elif ENABLED(ZONESTAR_LCD) + + #define ADC_KEYPAD_PIN 12 + + #elif ENABLED(AZSMZ_12864) + + // Pins only defined for RAMPS_SMART currently + + #elif ENABLED(G3D_PANEL) + + #define BEEPER_PIN EXP1_01_PIN + + #define SD_DETECT_PIN EXP2_07_PIN + #define KILL_PIN EXP2_08_PIN + + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN + + #elif IS_TFTGLCD_PANEL + + #define SD_DETECT_PIN EXP2_07_PIN + + #else + + #define BEEPER_PIN EXP2_05_PIN + + #if ENABLED(PANEL_ONE) // Buttons connect directly to AUX-2 + #define BTN_EN1 AUX2_03_PIN + #define BTN_EN2 AUX2_04_PIN + #define BTN_ENC AUX3_02_PIN + #else + #define BTN_EN1 EXP1_01_PIN + #define BTN_EN2 EXP1_02_PIN + #define BTN_ENC EXP2_03_PIN + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +#if IS_RRW_KEYPAD && !HAS_ADC_BUTTONS + #define SHIFT_OUT_PIN AUX2_06_PIN + #define SHIFT_CLK_PIN AUX2_07_PIN + #define SHIFT_LD_PIN AUX2_08_PIN + #ifndef BTN_EN1 + #define BTN_EN1 AUX2_05_PIN + #endif + #ifndef BTN_EN2 + #define BTN_EN2 AUX2_03_PIN + #endif + #ifndef BTN_ENC + #define BTN_ENC AUX2_04_PIN + #endif +#endif + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_RAMPS.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * FYSETC TFT-81050 display pinout + * + * Board Display + * ------ ------ + * (MISO) 50 | 1 2 | 52 (SCK) 5V |10 9 | GND + * (LCD_CS) 33 | 3 4 | 53 (SD_CS) RESET | 8 7 | (SD_DET) + * 31 5 6 | 51 (MOSI) (MOSI) 6 5 | (LCD_CS) + * (SD_DET) 49 | 7 8 | RESET (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | -- (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP2 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * ---------------------------------- + * EXP2-1 <--diode--- EXP1-1 MISO + * EXP2-2 ----------- EXP1-2 SCK + * EXP2-4 ----------- EXP1-3 MOD_RST + * EXP2-4 ----------- EXP1-4 SD_CS + * EXP2-3 ----------- EXP1-5 LCD_CS + * EXP2-6 ----------- EXP1-6 MOSI + * EXP2-7 ----------- EXP1-7 SD DET + * EXP2-8 ----------- EXP1-8 RESET + * EXP2-1 ----------- EXP1-9 MISO->GND + * EXP1-10 ---------- EXP1-10 5V + * + * NOTE: The MISO pin should not get a 5V signal. + * To fix, insert a 1N4148 diode in the MISO line. + */ + + #define BEEPER_PIN EXP1_01_PIN + + #define SD_DETECT_PIN EXP2_07_PIN + + #define CLCD_MOD_RESET EXP2_05_PIN + #define CLCD_SPI_CS EXP2_03_PIN + +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 diff --git a/src/pins/ramps/pins_RAMPS_13.h b/src/pins/ramps/pins_RAMPS_13.h new file mode 100644 index 0000000..6e7c8cb --- /dev/null +++ b/src/pins/ramps/pins_RAMPS_13.h @@ -0,0 +1,42 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega with RAMPS v1.3 pin assignments + * + * Applies to the following boards: + * + * RAMPS_13_EFB (Extruder, Fan, Bed) + * RAMPS_13_EEB (Extruder, Extruder, Bed) + * RAMPS_13_EFF (Extruder, Fan, Fan) + * RAMPS_13_EEF (Extruder, Extruder, Fan) + * RAMPS_13_SF (Spindle, Controller Fan) + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "RAMPS 1.3" +#endif + +#define IS_RAMPS_13 + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_RAMPS_CREALITY.h b/src/pins/ramps/pins_RAMPS_CREALITY.h new file mode 100644 index 0000000..3d5f5d6 --- /dev/null +++ b/src/pins/ramps/pins_RAMPS_CREALITY.h @@ -0,0 +1,72 @@ +/** + * 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 . + * + */ +#pragma once + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Creality RAMPS supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Creality3D RAMPS" + +// +// Heaters / Fans +// +#define MOSFET_B_PIN 7 // For HEATER_1_PIN ("EEF" or "EEB") +#define FAN_PIN 9 + +#define FIL_RUNOUT_PIN 2 +#if NUM_RUNOUT_SENSORS >= 2 + #define FIL_RUNOUT2_PIN 15 // Creality CR-X can use dual runout sensors +#endif + +#ifndef SD_DETECT_PIN + #if SD_CONNECTION_IS(ONBOARD) + //#define HAS_ONBOARD_SD_DETECT // If the SD_DETECT_PIN is wired up + #endif + #if ENABLED(HAS_ONBOARD_SD_DETECT) || !SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN 49 + #endif +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN 40 // Used by CR2020 Industrial series +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) + #define CASE_LIGHT_PIN 65 +#endif + +#include "pins_RAMPS.h" + +#ifndef BEEPER_PIN + #define BEEPER_PIN 37 // Always define beeper pin so Play Tone works with ExtUI +#endif + +#define EXP1_PIN 65 // A11 - Used by CR2020 Industrial series for case +#define EXP2_PIN 66 // A12 +#define EXP3_PIN 11 // SERVO0_PIN +#define EXP4_PIN 12 // PS_ON_PIN + +#define SUICIDE_PIN 12 // Used by CR2020 Industrial series +#ifndef SUICIDE_PIN_STATE + #define SUICIDE_PIN_STATE HIGH +#endif diff --git a/src/pins/ramps/pins_RAMPS_ENDER_4.h b/src/pins/ramps/pins_RAMPS_ENDER_4.h new file mode 100644 index 0000000..8f9148b --- /dev/null +++ b/src/pins/ramps/pins_RAMPS_ENDER_4.h @@ -0,0 +1,41 @@ +/** + * 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 . + * + */ +#pragma once + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Ender-4 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Ender-4" + +#include "pins_RAMPS.h" + +// The board only has one PWM fan connector. The others are 12V always-on. +// The default config uses this pin to control the brightness of the LED +// band (case light). Thus the hotend and controller fans are always-on. + +#if ENABLED(CASE_LIGHT_ENABLE) + #undef FAN_PIN + #ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN MOSFET_B_PIN + #endif +#endif diff --git a/src/pins/ramps/pins_RAMPS_OLD.h b/src/pins/ramps/pins_RAMPS_OLD.h new file mode 100644 index 0000000..9747666 --- /dev/null +++ b/src/pins/ramps/pins_RAMPS_OLD.h @@ -0,0 +1,117 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega with RAMPS v1.0, v1.1, v1.2 pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "RAMPS <1.2" + +// Uncomment the following line for RAMPS v1.0 +//#define RAMPS_V_1_0 + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 16 +#define Y_MAX_PIN 17 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 19 +#endif + +// +// Steppers +// +#define X_STEP_PIN 26 +#define X_DIR_PIN 28 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 38 +#define Y_DIR_PIN 40 +#define Y_ENABLE_PIN 36 + +#define Z_STEP_PIN 44 +#define Z_DIR_PIN 46 +#define Z_ENABLE_PIN 42 + +#define E0_STEP_PIN 32 +#define E0_DIR_PIN 34 +#define E0_ENABLE_PIN 30 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 2 // Analog Input +#define TEMP_BED_PIN 1 // Analog Input + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card +#else + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) +#endif + +// +// Heaters / Fans +// +#if ENABLED(RAMPS_V_1_0) + #define HEATER_0_PIN 12 + #define HEATER_BED_PIN -1 + #ifndef FAN_PIN + #define FAN_PIN 11 + #endif +#else // RAMPS_V_1_1 or RAMPS_V_1_2 + #define HEATER_0_PIN 10 + #define HEATER_BED_PIN 8 + #ifndef FAN_PIN + #define FAN_PIN 9 + #endif +#endif + +// +// Misc. Functions +// +#define SDPOWER_PIN 48 +#define SDSS 53 +#define LED_PIN 13 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 45 // Hardware PWM +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_ENA_PIN 41 // Pullup or pulldown! +#define SPINDLE_LASER_PWM_PIN 45 // Hardware PWM +#define SPINDLE_DIR_PIN 43 diff --git a/src/pins/ramps/pins_RAMPS_PLUS.h b/src/pins/ramps/pins_RAMPS_PLUS.h new file mode 100644 index 0000000..8ccb14c --- /dev/null +++ b/src/pins/ramps/pins_RAMPS_PLUS.h @@ -0,0 +1,94 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega with RAMPS v1.4Plus, also known as 3DYMY version, pin assignments + * + * Applies to the following boards: + * + * RAMPS_PLUS_EFB (Extruder, Fan, Bed) + * RAMPS_PLUS_EEB (Extruder, Extruder, Bed) + * RAMPS_PLUS_EFF (Extruder, Fan, Fan) + * RAMPS_PLUS_EEF (Extruder, Extruder, Fan) + * RAMPS_PLUS_SF (Spindle, Controller Fan) + * + * Differences from RAMPS v1.4: + * - Swap heater E0 with E1 + * - Swap pins 8 and 10. Bed/Fan/Hotend as labeled on the board are on pins 8/9/10. + * - Change EXP1/2 pins + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "RAMPS 1.4 Plus" + +#define MOSFET_A_PIN 8 +#define MOSFET_C_PIN 10 + +// +// Steppers +// +#define X_CS_PIN -1 +#define Y_CS_PIN -1 +#define Z_CS_PIN -1 + +// Swap E0 / E1 on 3DYMY +#define E0_STEP_PIN 36 +#define E0_DIR_PIN 34 +#define E0_ENABLE_PIN 30 +#define E0_CS_PIN -1 + +#define E1_STEP_PIN 26 +#define E1_DIR_PIN 28 +#define E1_ENABLE_PIN 24 +#define E1_CS_PIN -1 + +/** 3DYMY Expansion Headers + * ------ ------ + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 52 (SCK) + * 31 | 3 4 | 41 29 | 3 4 | 53 + * 33 5 6 | 23 25 5 6 | 51 (MOSI) + * 42 | 7 8 | 44 49 | 7 8 | 27 + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN 37 +#define EXP1_02_PIN 35 +#define EXP1_03_PIN 31 +#define EXP1_04_PIN 41 +#define EXP1_05_PIN 33 +#define EXP1_06_PIN 23 +#define EXP1_07_PIN 42 +#define EXP1_08_PIN 44 + +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 29 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 25 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 49 +#define EXP2_08_PIN 27 + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_RAMPS_S_12.h b/src/pins/ramps/pins_RAMPS_S_12.h new file mode 100644 index 0000000..f41573b --- /dev/null +++ b/src/pins/ramps/pins_RAMPS_S_12.h @@ -0,0 +1,280 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega with RAMPS-S v1.2 by Sakul.cz pin assignments + * Written by Michal Rábek + * + * Applies to the following boards: + * + * BOARD_RAMPS_S_12_EEFB Ramps S 1.2 (Hotend0, Hotend1, Fan, Bed) + * BOARD_RAMPS_S_12_EEEB Ramps S 1.2 (Hotend0, Hotend1, Hotend2, Bed) + * BOARD_RAMPS_S_12_EFFB Ramps S 1.2 (Hotend, Fan0, Fan1, Bed) + * + * Other pins_MYBOARD.h files may override these defaults + */ + +#include "env_validate.h" + +// Custom flags and defines for the build +//#define BOARD_CUSTOM_BUILD_FLAGS -D__FOO__ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "RAMPS S 1.2" +#endif + +// +// Servos +// +#ifndef SERVO0_PIN + #define SERVO0_PIN 10 +#endif +#ifndef SERVO1_PIN + #define SERVO1_PIN 11 +#endif +#ifndef SERVO2_PIN + #define SERVO2_PIN 12 +#endif +#ifndef SERVO3_PIN + #define SERVO3_PIN 44 +#endif + +// +// Limit Switches +// +#ifndef X_STOP_PIN + #ifndef X_MIN_PIN + #define X_MIN_PIN 37 + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN 36 + #endif +#endif +#ifndef Y_STOP_PIN + #ifndef Y_MIN_PIN + #define Y_MIN_PIN 35 + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN 34 + #endif +#endif +#ifndef Z_STOP_PIN + #ifndef Z_MIN_PIN + #define Z_MIN_PIN 33 + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN 32 + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 5 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 44 // RAMPS_S S3 on the servos connector +#endif + +// +// Steppers +// +#define X_STEP_PIN 17 +#define X_DIR_PIN 16 +#define X_ENABLE_PIN 48 + +#define Y_STEP_PIN 54 +#define Y_DIR_PIN 47 +#define Y_ENABLE_PIN 55 + +#ifndef Z_STEP_PIN + #define Z_STEP_PIN 57 +#endif +#define Z_DIR_PIN 56 +#define Z_ENABLE_PIN 62 + +#define E0_STEP_PIN 23 +#define E0_DIR_PIN 22 +#define E0_ENABLE_PIN 24 + +#define E1_STEP_PIN 26 +#define E1_DIR_PIN 25 +#define E1_ENABLE_PIN 27 + +#define E2_STEP_PIN 29 +#define E2_DIR_PIN 28 +#define E2_ENABLE_PIN 39 + +// +// Temperature Sensors +// +#ifndef TEMP_0_PIN + #define TEMP_0_PIN 15 // Analog Input +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN 14 // Analog Input +#endif +#ifndef TEMP_2_PIN + #define TEMP_2_PIN 13 // Analog Input +#endif +#ifndef TEMP_3_PIN + #define TEMP_3_PIN 12 // Analog Input +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN 11 // Analog Input +#endif + +// +// Heaters / Fans +// +#ifndef MOSFET_D_PIN + #define MOSFET_D_PIN -1 +#endif +#ifndef RAMPS_S_HE_0 + #define RAMPS_S_HE_0 2 +#endif +#ifndef RAMPS_S_HE_1 + #define RAMPS_S_HE_1 3 +#endif +#ifndef RAMPS_S_HE_2 + #define RAMPS_S_HE_2 6 +#endif + +#define HEATER_BED_PIN 9 + +#define HEATER_0_PIN RAMPS_S_HE_0 + +#if MB(RAMPS_S_12_EEFB) // Hotend0, Hotend1, Fan, Bed + #define HEATER_1_PIN RAMPS_S_HE_1 + #define FAN_PIN RAMPS_S_HE_2 +#elif MB(RAMPS_S_12_EEEB) // Hotend0, Hotend1, Hotend2, Bed + #define HEATER_1_PIN RAMPS_S_HE_1 + #define HEATER_2_PIN RAMPS_S_HE_2 +#elif MB(RAMPS_S_12_EFFB) // Hotend, Fan0, Fan1, Bed + #define FAN_PIN RAMPS_S_HE_1 + #define FAN1_PIN RAMPS_S_HE_2 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 + +#ifndef KILL_PIN + #define KILL_PIN 46 +#endif + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 60 // Analog Input on EXTEND +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN 12 // RAMPS_S S2 on the servos connector +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN) + #if NUM_SERVOS <= 1 // Prefer the servo connector + #define CASE_LIGHT_PIN 12 // Hardware PWM (RAMPS_S S1 on the servos connector) + #elif HAS_FREE_AUX2_PINS + #define CASE_LIGHT_PIN 44 // Hardware PWM + #endif +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN) + #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM + #define SPINDLE_DIR_PIN 5 +#endif + +// +// TMC software SPI +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI 51 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO 50 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK 53 + #endif +#endif + +// +// Průša i3 MK2 Multiplexer Support +// +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 29 // E2_STEP_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 28 // E2_DIR_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 39 // E2_ENABLE_PIN + #endif +#endif + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +// +// LCD Display output pins +// +#if HAS_WIRED_LCD + #define BEEPER_PIN 45 + #define LCD_PINS_RS 19 + #define LCD_PINS_ENABLE 49 + #define LCD_PINS_D4 18 + #define LCD_PINS_D5 30 + #define LCD_PINS_D6 41 + #define LCD_PINS_D7 31 + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN 38 + #endif + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif + +// +// LCD Display input pins +// +#if IS_NEWPANEL + #define BTN_EN1 40 + #define BTN_EN2 42 + #define BTN_ENC 43 +#endif diff --git a/src/pins/ramps/pins_RIGIDBOARD.h b/src/pins/ramps/pins_RIGIDBOARD.h new file mode 100644 index 0000000..2d68577 --- /dev/null +++ b/src/pins/ramps/pins_RIGIDBOARD.h @@ -0,0 +1,129 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * RIGIDBOARD Arduino Mega with RAMPS v1.4 pin assignments + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "RigidBoard" +#endif + +// +// Steppers +// RigidBot swaps E0 / E1 plugs vs RAMPS 1.3 +// +#define E0_STEP_PIN 36 +#define E0_DIR_PIN 34 +#define E0_ENABLE_PIN 30 + +#define E1_STEP_PIN 26 +#define E1_DIR_PIN 28 +#define E1_ENABLE_PIN 24 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 19 // Z-MAX pin J14 End Stops +#endif + +// +// MOSFET changes +// +#define MOSFET_A_PIN 9 // EXTRUDER 1 +#define MOSFET_B_PIN 8 // FAN (by default) +#define MOSFET_D_PIN 12 // EXTRUDER 2 or FAN + +#include "pins_RAMPS.h" + +#define STEPPER_RESET_PIN 41 // Stepper drivers have a reset on RigidBot + +// +// Temperature Sensors +// +#undef TEMP_0_PIN +#undef TEMP_1_PIN +#undef TEMP_BED_PIN +#define TEMP_0_PIN 14 // Analog Input +#define TEMP_1_PIN 13 // Analog Input +#define TEMP_BED_PIN 15 // Analog Input + +// SPI for MAX Thermocouple +#undef TEMP_0_CS_PIN +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 53 // Don't use pin 53 if there is even the remote possibility of using Display/SD card +#else + #define TEMP_0_CS_PIN 49 // Don't use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present +#endif + +// +// Heaters / Fans +// +#undef HEATER_BED_PIN +#define HEATER_BED_PIN 10 + +#ifndef FAN_PIN + #define FAN_PIN 8 // Same as RAMPS_13_EEF +#endif + +// +// Misc. Functions +// +#undef PS_ON_PIN + +// +// LCD / Controller +// +// LCD Panel options for the RigidBoard +#if ENABLED(RIGIDBOT_PANEL) + + #undef BEEPER_PIN + #define BEEPER_PIN -1 + + // Direction buttons + #define BTN_UP 37 + #define BTN_DWN 35 + #define BTN_LFT 33 + #define BTN_RT 32 + + // 'R' button + #undef BTN_ENC + #define BTN_ENC 31 + + // Disable encoder + #undef BTN_EN1 + #undef BTN_EN2 + + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 22 + +#elif IS_RRD_SC + + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 22 + + #undef KILL_PIN + #define KILL_PIN 32 + +#endif diff --git a/src/pins/ramps/pins_RIGIDBOARD_V2.h b/src/pins/ramps/pins_RIGIDBOARD_V2.h new file mode 100644 index 0000000..8242f1a --- /dev/null +++ b/src/pins/ramps/pins_RIGIDBOARD_V2.h @@ -0,0 +1,52 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * RIGIDBOARD V2 Arduino Mega with RAMPS v1.4 pin assignments + */ + +#define BOARD_INFO_NAME "RigidBoard V2" + +#include "pins_RIGIDBOARD.h" // ... RAMPS + +// +// Steppers +// + +// I2C based DAC like on the Printrboard REVF +#define HAS_MOTOR_CURRENT_DAC 1 + +// Channels available for DAC, For Rigidboard there are 4 +#define DAC_STEPPER_ORDER { 0, 1, 2, 3 } + +#define DAC_STEPPER_SENSE 0.05 // sense resistors on rigidboard stepper chips are .05 value +#define DAC_STEPPER_ADDRESS 0 +#define DAC_STEPPER_MAX 4096 // was 5000 but max allowable value is actually 4096 +#define DAC_STEPPER_VREF 1 // internal Vref, gain 2x = 4.096V +#define DAC_STEPPER_GAIN 1 // value of 1 here sets gain of 2 +#define DAC_DISABLE_PIN 42 // set low to enable DAC +#define DAC_OR_ADDRESS 0x01 + +#ifndef DAC_MOTOR_CURRENT_DEFAULT + #define DAC_MOTOR_CURRENT_DEFAULT { 70, 80, 90, 80 } // Default drive percent - X, Y, Z, E axis +#endif diff --git a/src/pins/ramps/pins_RL200.h b/src/pins/ramps/pins_RL200.h new file mode 100644 index 0000000..00fb39a --- /dev/null +++ b/src/pins/ramps/pins_RL200.h @@ -0,0 +1,52 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Rapide Lite 200 v1 (RUMBA clone) pin assignments. Has slightly different assignment for + * extruder motors due to dual Z motors. Pinout therefore based on pins_RUMBA.h. + */ + +#define BOARD_INFO_NAME "RL200" +#define DEFAULT_MACHINE_NAME "Rapide Lite 200" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "RL200v1 supports up to 2 hotends / E steppers." +#elif NUM_Z_STEPPERS != 2 + #error "RL200 uses dual Z stepper motors. Z_DRIVER_TYPE and Z2_DRIVER_TYPE must be defined." +#elif !(AXIS_DRIVER_TYPE_X(DRV8825) && AXIS_DRIVER_TYPE_Y(DRV8825) && AXIS_DRIVER_TYPE_Z(DRV8825) && AXIS_DRIVER_TYPE_Z2(DRV8825) && AXIS_DRIVER_TYPE_E0(DRV8825)) + #error "You must set ([XYZ]|Z2|E0)_DRIVER_TYPE to DRV8825 in Configuration.h for RL200." +#endif + +#define E0_STEP_PIN 26 // (RUMBA E1 pins) +#define E0_DIR_PIN 25 +#define E0_ENABLE_PIN 27 + +#define E1_STEP_PIN 29 // (RUMBA E2 pins) +#define E1_DIR_PIN 28 +#define E1_ENABLE_PIN 39 + +#define Z2_STEP_PIN 23 // (RUMBA E0 pins) +#define Z2_DIR_PIN 22 +#define Z2_ENABLE_PIN 24 + +#include "pins_RUMBA.h" diff --git a/src/pins/ramps/pins_RUMBA.h b/src/pins/ramps/pins_RUMBA.h new file mode 100644 index 0000000..eb049c4 --- /dev/null +++ b/src/pins/ramps/pins_RUMBA.h @@ -0,0 +1,250 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * RUMBA pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "RUMBA supports up to 3 hotends / E steppers." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Rumba" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#endif + +// +// Servos +// +#define SERVO0_PIN 5 + +// +// Limit Switches +// +#ifndef X_MIN_PIN + #define X_MIN_PIN 37 +#endif +#ifndef X_MIN_PIN + #define X_MIN_PIN 37 +#endif +#ifndef X_MAX_PIN + #define X_MAX_PIN 36 +#endif +#ifndef Y_MIN_PIN + #define Y_MIN_PIN 35 +#endif +#ifndef Y_MAX_PIN + #define Y_MAX_PIN 34 +#endif +#ifndef Z_MIN_PIN + #define Z_MIN_PIN 33 +#endif +#ifndef Z_MAX_PIN + #define Z_MAX_PIN 32 +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 17 +#define X_DIR_PIN 16 +#define X_ENABLE_PIN 48 + +#define Y_STEP_PIN 54 +#define Y_DIR_PIN 47 +#define Y_ENABLE_PIN 55 + +#define Z_STEP_PIN 57 +#define Z_DIR_PIN 56 +#define Z_ENABLE_PIN 62 + +#ifndef E0_STEP_PIN + #define E0_STEP_PIN 23 + #define E0_DIR_PIN 22 + #define E0_ENABLE_PIN 24 +#endif + +#ifndef E1_STEP_PIN + #define E1_STEP_PIN 26 + #define E1_DIR_PIN 25 + #define E1_ENABLE_PIN 27 +#endif + +#if E1_STEP_PIN != 29 + #define E2_STEP_PIN 29 + #define E2_DIR_PIN 28 + #define E2_ENABLE_PIN 39 +#endif + +// +// Temperature Sensors +// +#ifndef TEMP_0_PIN + #if TEMP_SENSOR_0 == -1 + #define TEMP_0_PIN 6 // Analog Input (connector *K1* on RUMBA thermocouple ADD ON is used) + #else + #define TEMP_0_PIN 15 // Analog Input (default connector for thermistor *T0* on rumba board is used) + #endif +#endif + +#ifndef TEMP_1_PIN + #if TEMP_SENSOR_1 == -1 + #define TEMP_1_PIN 5 // Analog Input (connector *K2* on RUMBA thermocouple ADD ON is used) + #else + #define TEMP_1_PIN 14 // Analog Input (default connector for thermistor *T1* on rumba board is used) + #endif +#endif + +#if TEMP_SENSOR_2 == -1 + #define TEMP_2_PIN 7 // Analog Input (connector *K3* on RUMBA thermocouple ADD ON is used <-- this can't be used when TEMP_SENSOR_BED is defined as thermocouple) +#else + #define TEMP_2_PIN 13 // Analog Input (default connector for thermistor *T2* on rumba board is used) +#endif + +// Optional for extruder 4 or chamber: +//#define TEMP_X_PIN 12 // Analog Input (default connector for thermistor *T3* on rumba board is used) + +#ifndef TEMP_CHAMBER_PIN + //#define TEMP_CHAMBER_PIN 12 // Analog Input (default connector for thermistor *T3* on rumba board is used) +#endif + +#if TEMP_SENSOR_BED == -1 + #define TEMP_BED_PIN 7 // Analog Input (connector *K3* on RUMBA thermocouple ADD ON is used <-- this can't be used when TEMP_SENSOR_2 is defined as thermocouple) +#else + #define TEMP_BED_PIN 11 // Analog Input (default connector for thermistor *THB* on rumba board is used) +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define HEATER_1_PIN 3 +#define HEATER_2_PIN 6 +#define HEATER_3_PIN 8 +#define HEATER_BED_PIN 9 + +#ifndef FAN_PIN + #define FAN_PIN 7 +#endif +#ifndef FAN1_PIN + #define FAN1_PIN 8 +#endif + +// +// Misc. Functions +// +#define LED_PIN 13 +#define PS_ON_PIN 45 +#define KILL_PIN 46 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 45 +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#ifndef SPINDLE_LASER_PWM_PIN + #define SPINDLE_LASER_PWM_PIN 4 // Hardware PWM. Pin 4 interrupts OC0* and OC1* always in use? +#endif +#ifndef SPINDLE_LASER_ENA_PIN + #define SPINDLE_LASER_ENA_PIN 14 // Pullup! +#endif +#ifndef SPINDLE_DIR_PIN + #define SPINDLE_DIR_PIN 15 +#endif + +// +// LCD / Controller +// +#if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + #define LCD_PINS_DC 38 // Set as output on init + #define LCD_PINS_RS 41 // Pull low for 1s to init + // DOGM SPI LCD Support + #define DOGLCD_CS 19 + #define DOGLCD_MOSI 42 + #define DOGLCD_SCK 18 + #define DOGLCD_A0 LCD_PINS_DC +#elif ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS 42 + #define DOGLCD_A0 19 + #define DOGLCD_MOSI 51 + #define DOGLCD_SCK 52 + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN 18 // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN 41 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN 38 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN 40 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN 38 + #endif + +#else + #define LCD_PINS_RS 19 + #define LCD_PINS_ENABLE 42 + #define LCD_PINS_D4 18 + #define LCD_PINS_D5 38 + #define LCD_PINS_D6 41 +#endif + +#define LCD_PINS_D7 40 + +// +// Beeper, SD Card, Encoder +// +#define BEEPER_PIN 44 + +#if ENABLED(SDSUPPORT) + #define SDSS 53 + #define SD_DETECT_PIN 49 +#endif + +#if IS_NEWPANEL + #define BTN_EN1 11 + #define BTN_EN2 12 + #define BTN_ENC 43 +#endif diff --git a/src/pins/ramps/pins_RUMBA_RAISE3D.h b/src/pins/ramps/pins_RUMBA_RAISE3D.h new file mode 100644 index 0000000..3994261 --- /dev/null +++ b/src/pins/ramps/pins_RUMBA_RAISE3D.h @@ -0,0 +1,31 @@ +/** + * 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 . + * + */ +#pragma once + +#define BOARD_INFO_NAME "Raise3D Rumba" +#define DEFAULT_MACHINE_NAME "Raise3D N Series" + +// Raise3D uses thermocouples on the standard input pins +#define TEMP_0_PIN 15 // Analog Input +#define TEMP_1_PIN 14 // Analog Input + +#include "pins_RUMBA.h" diff --git a/src/pins/ramps/pins_SAINSMART_2IN1.h b/src/pins/ramps/pins_SAINSMART_2IN1.h new file mode 100644 index 0000000..d25029a --- /dev/null +++ b/src/pins/ramps/pins_SAINSMART_2IN1.h @@ -0,0 +1,42 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Sainsmart 2-in-1 pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Sainsmart 2-in-1 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Sainsmart" + +// +// Heaters / Fans +// +#define MOSFET_A_PIN 9 // E +#define MOSFET_B_PIN 7 // F PART FAN in front of board next to Extruder heat + // MOSFET_C_PIN 8 // B +#define MOSFET_D_PIN 10 // F / E + +#include "pins_RAMPS.h" diff --git a/src/pins/ramps/pins_TANGO.h b/src/pins/ramps/pins_TANGO.h new file mode 100644 index 0000000..451d2f8 --- /dev/null +++ b/src/pins/ramps/pins_TANGO.h @@ -0,0 +1,53 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BIQU Tango pin assignments + */ + +#define BOARD_INFO_NAME "Tango" + +#define FAN_PIN 8 +#define FAN1_PIN -1 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN 7 +#endif + +#ifndef TEMP_0_PIN + #if TEMP_SENSOR_0 == -1 + #define TEMP_0_PIN 10 // Analog Input (connector *K1* on Tango thermocouple ADD ON is used) + #else + #define TEMP_0_PIN 15 // Analog Input (default connector for thermistor *T0* on rumba board is used) + #endif +#endif + +#ifndef TEMP_1_PIN + #if TEMP_SENSOR_1 == -1 + #define TEMP_1_PIN 9 // Analog Input (connector *K2* on Tango thermocouple ADD ON is used) + #else + #define TEMP_1_PIN 14 // Analog Input (default connector for thermistor *T1* on rumba board is used) + #endif +#endif + +#include "pins_RUMBA.h" diff --git a/src/pins/ramps/pins_TENLOG_D3_HERO.h b/src/pins/ramps/pins_TENLOG_D3_HERO.h new file mode 100644 index 0000000..b11487b --- /dev/null +++ b/src/pins/ramps/pins_TENLOG_D3_HERO.h @@ -0,0 +1,187 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Tenlog pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Tenlog supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Tenlog D3 Hero" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Servos +// +#define SERVO0_PIN 11 +#define SERVO1_PIN 6 +#define SERVO2_PIN -1 // Original pin 5 used for hotend fans +#define SERVO3_PIN 4 + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 14 +//#define Y_MAX_PIN 15 // Connected to "DJ" plug on extruder heads +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 15 // Ramps is normally 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +//#ifndef X_CS_PIN + //#define X_CS_PIN 53 +//#endif + +#define X2_STEP_PIN 36 +#define X2_DIR_PIN 34 +#define X2_ENABLE_PIN 30 +//#ifndef X2_CS_PIN + //#define X2_CS_PIN 53 +//#endif + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +//#ifndef Y_CS_PIN + //#define Y_CS_PIN 49 +//#endif + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 +//#ifndef Z_CS_PIN + //#define Z_CS_PIN 40 +//#endif + +#define Z2_STEP_PIN 65 +#define Z2_DIR_PIN 66 +#define Z2_ENABLE_PIN 64 +//#ifndef Z2_CS_PIN + //#define Z2_CS_PIN 40 +//#endif + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +//#ifndef E0_CS_PIN + //define E0_CS_PIN 42 +//#endif + +#define E1_STEP_PIN 57 +#define E1_DIR_PIN 58 +#define E1_ENABLE_PIN 59 +//#ifndef E1_CS_PIN + //define E1_CS_PIN 44 +//#endif + +//#define E2_STEP_PIN 42 +//#define E2_DIR_PIN 43 +//#define E2_ENABLE_PIN 44 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // Analog Input +#define TEMP_1_PIN 15 // Analog Input +#define TEMP_BED_PIN 14 // Analog Input + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN -1 // Don't use 53 if using Display/SD card +#else + #define TEMP_0_CS_PIN -1 // Don't use 49 (SD_DETECT_PIN) +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 11 +#define HEATER_BED_PIN 8 + +#define FAN_PIN 9 +#define FAN1_PIN 5 // Normally this would be a servo pin + +// XXX Runout support unknown? +//#define NUM_RUNOUT_SENSORS 0 +//#define FIL_RUNOUT_PIN 22 +//#define FIL_RUNOUT2_PIN 21 + +// +// Misc. Functions +// +//#define PS_ON_PIN 40 // The M80/M81 PSU pin for boards v2.1-2.3 +//#define CASE_LIGHT_PIN 5 +#define SDSS 53 +//#ifndef LED_PIN + //#define LED_PIN 13 +//#endif + +//#define SPINDLE_LASER_PWM_PIN -1 // Hardware PWM +//#define SPINDLE_LASER_ENA_PIN 4 // Pullup! + +// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector +//#define FILWIDTH_PIN 5 // Analog Input + +// +// LCD / Controller +// + +//#if IS_RRD_SC + +#define LCD_PINS_RS -1 +#define LCD_PINS_ENABLE -1 +#define LCD_PINS_D4 -1 +#define LCD_PINS_D5 -1 +#define LCD_PINS_D6 -1 +#define LCD_PINS_D7 -1 +//#define BTN_EN1 31 +//#define BTN_EN2 33 +//#define BTN_ENC 35 +#define SD_DETECT_PIN 49 +//#ifndef KILL_PIN + //#define KILL_PIN 41 +//#endif +//#ifndef BEEPER_PIN +#define BEEPER_PIN -1 +//#endif + +//#endif // IS_RRD_SC diff --git a/src/pins/ramps/pins_TRIGORILLA_13.h b/src/pins/ramps/pins_TRIGORILLA_13.h new file mode 100644 index 0000000..71dfb8c --- /dev/null +++ b/src/pins/ramps/pins_TRIGORILLA_13.h @@ -0,0 +1,43 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega with RAMPS v1.3 for Anycubic + */ + +#define BOARD_INFO_NAME "Anycubic RAMPS 1.3" + +#define MOSFET_B_PIN 44 + +#define E1_STEP_PIN -1 +#define E1_DIR_PIN -1 +#define E1_ENABLE_PIN -1 +#define E1_CS_PIN -1 + +#define FAN2_PIN 9 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN 9 +#endif + +#include "pins_RAMPS_13.h" // ... RAMPS diff --git a/src/pins/ramps/pins_TRIGORILLA_14.h b/src/pins/ramps/pins_TRIGORILLA_14.h new file mode 100644 index 0000000..b685ff0 --- /dev/null +++ b/src/pins/ramps/pins_TRIGORILLA_14.h @@ -0,0 +1,147 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega with RAMPS v1.4 for Anycubic + */ + +#define BOARD_INFO_NAME "Anycubic RAMPS 1.4" + +// +// Servos +// +#if MB(TRIGORILLA_14_11) + #define SERVO0_PIN 5 + #define SERVO1_PIN 4 + #define SERVO2_PIN 11 + #define SERVO3_PIN 6 +#endif + +// +// PWM FETS +// +#if EITHER(FET_ORDER_EEF, FET_ORDER_EEB) + #define MOSFET_B_PIN 45 // HEATER1 +#elif FET_ORDER_EFB + #define MOSFET_B_PIN 9 // FAN0 +#else + #define MOSFET_B_PIN 7 // FAN1 +#endif + +#if FET_ORDER_EEB + #define MOSFET_C_PIN 8 // BED +#elif FET_ORDER_EFB + #if DISABLED(ANYCUBIC_LCD_CHIRON) + #define MOSFET_C_PIN 8 + #else + #define MOSFET_C_PIN 45 + #endif +#else // EEF, EFF + #define MOSFET_C_PIN 9 +#endif + +#if FET_ORDER_EEB + #define FAN_PIN 9 // Override pin 4 in pins_RAMPS.h +#endif + +// +// Heaters / Fans +// +#if ANY(FET_ORDER_EEF, FET_ORDER_EEB, FET_ORDER_EFB) + #define FAN1_PIN 7 +#endif +#define FAN2_PIN 44 +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN 44 // Used in Anycubic Kossel example config +#endif +#if ENABLED(ANYCUBIC_LCD_I3MEGA) + #define CONTROLLER_FAN_PIN 7 +#endif + +// +// AnyCubic standard pin mappings +// +// On most printers, endstops are NOT all wired to the appropriate pins on the Trigorilla board. +// For instance, on a Chiron, Y axis goes to an aux connector. +// There are also other things that have been wired in creative ways. +// To enable PIN definitions for a specific printer model, #define the appropriate symbol after +// MOTHERBOARD in Configuration.h + +// +// Limit Switches +// +//#define ANYCUBIC_4_MAX_PRO_ENDSTOPS + +#if ENABLED(ANYCUBIC_4_MAX_PRO_ENDSTOPS) + #define X_MAX_PIN 43 + #define Y_STOP_PIN 19 +#elif EITHER(ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_I3MEGA) + #define Y_STOP_PIN 42 + #define Z2_MIN_PIN 43 + #ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 2 + #endif + #ifndef FIL_RUNOUT_PIN + #if ENABLED(ANYCUBIC_LCD_CHIRON) + #define FIL_RUNOUT_PIN 33 + #else + #define FIL_RUNOUT_PIN 19 + #endif + #endif + #define BEEPER_PIN 31 + #define SD_DETECT_PIN 49 +#endif + +#include "pins_RAMPS.h" + +// +// AnyCubic made the following changes to 1.1.0-RC8 +// If these are appropriate for your LCD let us know. +// +#if 0 && HAS_WIRED_LCD + + // LCD Display output pins + #if BOTH(IS_NEWPANEL, PANEL_ONE) + #undef LCD_PINS_D6 + #define LCD_PINS_D6 57 + #endif + + // LCD Display input pins + #if IS_NEWPANEL + #if EITHER(VIKI2, miniVIKI) + #undef DOGLCD_A0 + #define DOGLCD_A0 23 + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + #undef BEEPER_PIN + #define BEEPER_PIN 33 + #undef LCD_BACKLIGHT_PIN + #define LCD_BACKLIGHT_PIN 67 + #endif + #elif ENABLED(MINIPANEL) + #undef BEEPER_PIN + #define BEEPER_PIN 33 + #undef DOGLCD_A0 + #define DOGLCD_A0 42 + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/ramps/pins_TRONXY_V3_1_0.h b/src/pins/ramps/pins_TRONXY_V3_1_0.h new file mode 100644 index 0000000..04c6af6 --- /dev/null +++ b/src/pins/ramps/pins_TRONXY_V3_1_0.h @@ -0,0 +1,280 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega for Tronxy X5S-2E, etc. + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "TRONXY-V3-1.0 supports up to 2 hotends/E steppers." +#endif + +#define BOARD_INFO_NAME "TRONXY-V3-1.0" + +// +// Servos +// +#define SERVO1_PIN 12 // 2560 PIN 25/PB6 + +// +// Import RAMPS 1.4 pins +// +#include "pins_RAMPS.h" + +/** + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * ===== AUX-1 connector ===== + * + * 2 4 6 8 + * #----------------# + * #2 | ° ° ° ° | + * #1 | ° ° ° ° | + * NOTCH #------ ------# + * 1 3 5 7 + * + * ################################### + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################### + * # 1 | VCC | + # + * # 2 | VCC | + # + * # 3 | GND | - # + * # 4 | GND | - # + * # 5 | N/C | # + * # 6 | 3 / PE1 (TXD0) | D1 # + * # 7 | N/C | # + * # 8 | 2 / PE0 (RXD0) | D0 # + * ################################### + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * ===== Limit Switch connectors ===== + * + * ############## X+ ################# + * X+ # Pin | ATMEGA2560 Pin | Arduino # + * 1 2 3 ################################### + * #- --- -# # 1 | 6 / PE4 (INT4) | D2 # + * | ° ° ° | # 2 | GND | - # + * #-------# # 3 | VCC | + # + * ################################### + * + * ############## X- ################# + * X- # Pin | ATMEGA2560 Pin | Arduino # + * 1 2 3 ################################### + * #- --- -# # 1 | 7 / PE5 (INT5) | D3 # + * | ° ° ° | # 2 | GND | - # + * #-------# # 3 | VCC | + # + * ################################### + * + * ############## Y+ ################# + * Y+ # Pin | ATMEGA2560 Pin | Arduino # + * 1 2 3 ################################### + * #- --- -# # 1 | 63/PJ0 (PCINT9) | D15 # + * | ° ° ° | # 2 | GND | - # + * #-------# # 3 | VCC | + # + * ################################### + * + * ############## Y- ################# + * Y- # Pin | ATMEGA2560 Pin | Arduino # + * 1 2 3 ################################### + * #- --- -# # 1 | 64/PJ1 (PCINT10)| D14 # + * | ° ° ° | # 2 | GND | - # + * #-------# # 3 | VCC | + # + * ################################### + * + * ############## Z+ ################# + * Z+ # Pin | ATMEGA2560 Pin | Arduino # + * 1 2 3 ################################### + * #- --- -# # 1 | 45 / PD2 (INT2) | D19 # + * | ° ° ° | # 2 | GND | - # + * #-------# # 3 | VCC | + # + * ################################### + * + * ############## Z- ################# + * Z- # Pin | ATMEGA2560 Pin | Arduino # + * 1 2 3 ################################### + * #- --- -# # 1 | 46 / PD3 (INT3) | D18 # + * | ° ° ° | # 2 | GND | - # + * #-------# # 3 | VCC | + # + * ################################### + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * ===== EXP1/EXP2 connectors ===== + * + * (NOTE ORDER) EXP2 EXP1 + * 2 4 6 8 10 2 4 6 8 10 + * #-------------------# #-------------------# + * #2 | ° ° ° ° ° | #2 | ° ° ° ° ° | + * #1 | ° ° ° ° ° | #1 | ° ° ° ° ° | + * NOTCH #-------- -------# NOTCH #-------- -------# + * 1 3 5 7 9 1 3 5 7 9 + * + * ############# EXP1 ################ + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################### + * # 1 | 53 / PC0 | D37 # + * # 2 | 55 / PC2 | D35 # + * # 3 | 12 / PH0 (RXD2) | D17 # + * # 4 | 13 / PH1 (TXD2) | D16 # + * # 5 | 77 / PA1 | D23 # + * # 6 | 75 / PA3 | D25 # + * # 7 | 73 / PA5 | D27 # + * # 8 | 71 / PA7 | D29 # + * # 9 | GND | - # + * # 10 | VCC | + # + * ################################### + * + * ############# EXP2 ################ + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################### + * # 1 | 22 / PB3 (MISO) | D50 # + * # 2 | 20 / PB1 (SCK) | D52 # + * # 3 | 59 / PC6 | D31 # + * # 4 | N/C | # + * # 5 | 57 / PC4 | D33 # + * # 6 | 21 / PB2 (MOSI) | D51 # + * # 7 | N/C | # + * # 8 | 30 / !RESET | RESET # + * # 9 | GND | - # + * # 10 | 51 / PG0 | D41 # + * ################################### + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * ===== ICSP connector ===== + * + * 2 4 6 + * #---------# + * | ° ° ° | + * | ° ° ° | + * #---------# + * 1 3 5 + * + * ################################## + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################## + * # 1 | 22 / PB3 (MISO)| 50 # + * # 2 | VCC | + # + * # 3 | 20 / PB1 (SCK) | 52 # + * # 4 | 21 / PB2 (MOSI)| 51 # + * # 5 | 30 / !RESET | RESET # + * # 6 | GND | - # + * ################################## + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * ===== SERVOS connector ===== + * + * 2 4 6 + * #---------# + * | ° ° ° | + * | ° ° ° | + * #---------# + * 1 3 5 + * + * ################################## + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################## + * # 1 | 25 / PB6 (OC1B)| D12 # + * # 2 | 24 / PB5 (OC1A)| D11 # + * # 3 | GND | - # + * # 4 | GND | - # + * # 5 | VCC | + # + * # 6 | VCC | + # + * ################################## + * + * NOTE: Pins 1 and 2 are the ones closest to the "L" and "PWR" LEDs. + * + * NOTE: Check servo wiring before connecting, for example: + * + Airtronics (non-Z) use: Red = +; Black = -; Black & White, White or Orange = signal. + * + Airtronics-Z use: Red = +; Black = -; Blue = signal. + * + Futaba use: Red = +; Black = -; White = signal. + * + Hitec use: Red = +; Black = -; Yellow = signal. + * + JR use: Red = +; Brown = -; Orange = signal. + * + * NOTE: Test your servo limits: + * Due to effects of component tolerances and/or age, the usable range of S-values for individual servos may be less than the settable 0-255 range. For example: + * 1. One servo may have a fully usable range of M280 P0 S0 through M280 P0 S255. + * 2. A different servo (of the same brand and model) may have a usable range of only M280 P0 S0 through M280 P0 S165 after which you experience binding. + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * ===== Thermistor connectors ===== + * + * (NOTE ORDER) TH2 TH1 TB + * 1 2 1 2 1 2 + * #- -# #- -# #- -# + * | ° ° | | ° ° | | ° ° | + * #-----# #-----# #-----# + * + * ############## TB ################# + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################### + * # 1 | GND | - # + * # 2 | 83 / PK6 (ADC14)| A14 # + * ################################### + * + * ############## TH1 ################ + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################### + * # 1 | GND | - # + * # 2 | 84 / PK5 (ADC13)| A13 # + * ################################### + * + * ############## TH2 ################ + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################### + * # 1 | GND | - # + * # 2 | 82 / PK7 (ADC15)| A15 # + * ################################### + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + * + * ===== XS3 connector ===== + * + * 2 4 6 + * #---------# + * | ° ° ° | + * | ° ° ° | + * #---------# + * 1 3 5 + * + * ################################## + * # Pin | ATMEGA2560 Pin | Arduino # + * ################################## + * # 1 | 85 / ADC12 | A12 # + * # 2 | 86 / ADC11 | A11 # + * # 3 | GND | - # + * # 4 | GND | - # + * # 5 | VCC | + # + * # 6 | VCC | + # + * ################################## + * + * NOTE: Pins 1 and 2 are the ones closest to the "L" and "PWR" LEDs. + * + * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + */ diff --git a/src/pins/ramps/pins_TT_OSCAR.h b/src/pins/ramps/pins_TT_OSCAR.h new file mode 100644 index 0000000..f81cc60 --- /dev/null +++ b/src/pins/ramps/pins_TT_OSCAR.h @@ -0,0 +1,509 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#if HOTENDS > 5 || E_STEPPERS > 5 + #error "TTOSCAR supports up to 5 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "TT OSCAR" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Servos +// +#define SERVO0_PIN 11 +#define SERVO1_PIN 12 +#define SERVO2_PIN 5 +#define SERVO3_PIN 4 + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN SERVO3_PIN +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#define X_CS_PIN 57 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#define Y_CS_PIN 58 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 +#define Z_CS_PIN 53 + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +#define E0_CS_PIN 49 + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#define E1_CS_PIN E0_CS_PIN + +#define E2_STEP_PIN 63 +#define E2_DIR_PIN 22 +#define E2_ENABLE_PIN 59 +#define E2_CS_PIN E0_CS_PIN + +#define E3_STEP_PIN 32 +#define E3_DIR_PIN 40 +#define E3_ENABLE_PIN 39 +#define E3_CS_PIN E0_CS_PIN + +#define E4_STEP_PIN 43 +#define E4_DIR_PIN 42 +#define E4_ENABLE_PIN 47 +#define E4_CS_PIN E0_CS_PIN + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN -1 // 59 + #define X_SERIAL_RX_PIN -1 // 63 + #define X2_SERIAL_TX_PIN -1 + #define X2_SERIAL_RX_PIN -1 + + #define Y_SERIAL_TX_PIN -1 // 64 + #define Y_SERIAL_RX_PIN -1 // 40 + #define Y2_SERIAL_TX_PIN -1 + #define Y2_SERIAL_RX_PIN -1 + + #define Z_SERIAL_TX_PIN -1 // 44 + #define Z_SERIAL_RX_PIN -1 // 42 + #define Z2_SERIAL_TX_PIN -1 + #define Z2_SERIAL_RX_PIN -1 + + #define E0_SERIAL_TX_PIN -1 // 66 + #define E0_SERIAL_RX_PIN -1 // 65 + #define E1_SERIAL_TX_PIN -1 + #define E1_SERIAL_RX_PIN -1 + #define E2_SERIAL_TX_PIN -1 + #define E2_SERIAL_RX_PIN -1 + #define E3_SERIAL_TX_PIN -1 + #define E3_SERIAL_RX_PIN -1 + #define E4_SERIAL_TX_PIN -1 + #define E4_SERIAL_RX_PIN -1 + #define E5_SERIAL_RX_PIN -1 + #define E6_SERIAL_RX_PIN -1 + #define E7_SERIAL_RX_PIN -1 +#endif + +// +// Default pins for TMC software SPI +// +//#if ENABLED(TMC_USE_SW_SPI) +// #ifndef TMC_SW_MOSI +// #define TMC_SW_MOSI 66 +// #endif +// #ifndef TMC_SW_MISO +// #define TMC_SW_MISO 44 +// #endif +// #ifndef TMC_SW_SCK +// #define TMC_SW_SCK 64 +// #endif +//#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 +#define TEMP_1_PIN 15 +#define TEMP_2_PIN 10 +#define TEMP_3_PIN 11 +#define TEMP_BED_PIN 14 + +#if TEMP_SENSOR_CHAMBER > 0 + #define TEMP_CHAMBER_PIN 12 +#else + #define TEMP_4_PIN 12 +#endif + +// SPI for MAX Thermocouple +//#if DISABLED(SDSUPPORT) +// #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card +//#else +// #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) +//#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 +#define HEATER_2_PIN 44 +#define HEATER_BED_PIN 8 + +#define FAN_PIN 9 + +#if EXTRUDERS >= 5 + #define HEATER_4_PIN 6 +#else + #define FAN1_PIN 6 +#endif + +#if EXTRUDERS >= 4 + #define HEATER_3_PIN 45 +#else + #define FAN2_PIN 45 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 + +//#ifndef FILWIDTH_PIN +// #define FILWIDTH_PIN 5 // Analog Input +//#endif + +// DIO 4 (Servos plug) for the runout sensor. +//#define FIL_RUNOUT_PIN SERVO3_PIN + +#ifndef PS_ON_PIN + #define PS_ON_PIN 12 +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER && !PIN_EXISTS(SPINDLE_LASER_ENA) + #if !NUM_SERVOS // Prefer the servo connector + #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM + #define SPINDLE_DIR_PIN 5 + #elif HAS_FREE_AUX2_PINS // Try to use AUX 2 + #define SPINDLE_LASER_ENA_PIN 40 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM + #define SPINDLE_DIR_PIN 65 + #endif +#endif + +// +// Case Light +// +#if ENABLED(CASE_LIGHT_ENABLE) && !PIN_EXISTS(CASE_LIGHT) && !defined(SPINDLE_LASER_ENA_PIN) + #if !NUM_SERVOS // Prefer the servo connector + #define CASE_LIGHT_PIN 6 // Hardware PWM + #elif HAS_FREE_AUX2_PINS // Try to use AUX 2 + #define CASE_LIGHT_PIN 44 // Hardware PWM + #endif +#endif + +// +// Průša i3 MK2 Multiplexer Support +// +#if 0 && HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 58 // Y_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 53 // Z_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 49 // En_CS_PIN + #endif +#endif + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +#if HAS_WIRED_LCD + + // + // LCD Display output pins + // + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define LCD_PINS_RS 49 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE 51 // SID (MOSI) + #define LCD_PINS_D4 52 // SCK (CLK) clock + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + #define LCD_PINS_RS 40 + #define LCD_PINS_ENABLE 42 + #define LCD_PINS_D4 65 + #define LCD_PINS_D5 66 + #define LCD_PINS_D6 44 + #define LCD_PINS_D7 64 + + #elif ENABLED(ZONESTAR_LCD) + + #define LCD_PINS_RS 64 + #define LCD_PINS_ENABLE 44 + #define LCD_PINS_D4 63 + #define LCD_PINS_D5 40 + #define LCD_PINS_D6 42 + #define LCD_PINS_D7 65 + #define ADC_KEYPAD_PIN 12 + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS 27 + #define LCD_PINS_ENABLE 29 + #define LCD_PINS_D4 25 + + #if !IS_NEWPANEL + #define BEEPER_PIN 37 + #endif + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + #define LCD_PINS_DC 25 // Set as output on init + #define LCD_PINS_RS 27 // Pull low for 1s to init + // DOGM SPI LCD Support + #define DOGLCD_CS 16 + #define DOGLCD_MOSI 17 + #define DOGLCD_SCK 23 + #define DOGLCD_A0 LCD_PINS_DC + #else + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #endif + + #define LCD_PINS_D7 29 + + #if !IS_NEWPANEL + #define BEEPER_PIN 33 + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN 38 + //#define SHIFT_LD_PIN 42 + //#define SHIFT_OUT_PIN 40 + //#define SHIFT_EN_PIN 17 + #endif + + #endif + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN 37 + + #if ENABLED(CR10_STOCKDISPLAY) + #define BTN_EN1 17 + #define BTN_EN2 23 + #else + #define BTN_EN1 31 + #define BTN_EN2 33 + #endif + + #define BTN_ENC 35 + #define SD_DETECT_PIN 49 + //#define KILL_PIN 41 + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + #define LCD_BACKLIGHT_PIN 39 + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #define SD_DETECT_PIN 42 + + #elif ENABLED(LCD_I2C_PANELOLU2) + + #define BTN_EN1 47 + #define BTN_EN2 43 + #define BTN_ENC 32 + #define LCD_SDSS 53 + //#define KILL_PIN 41 + + #elif ENABLED(LCD_I2C_VIKI) + + #define BTN_EN1 22 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + #define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13. + #define BTN_ENC -1 + + #define LCD_SDSS 53 + #define SD_DETECT_PIN 49 + + #elif EITHER(VIKI2, miniVIKI) + + #define DOGLCD_CS 45 + #define DOGLCD_A0 44 + + #define BEEPER_PIN 33 + #define STAT_LED_RED_PIN 32 + #define STAT_LED_BLUE_PIN 35 + + #define BTN_EN1 22 + #define BTN_EN2 7 + #define BTN_ENC 39 + + #define SDSS 53 + #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + //#define KILL_PIN 31 + + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + #define DOGLCD_CS 29 + #define DOGLCD_A0 27 + + #define BEEPER_PIN 23 + #define LCD_BACKLIGHT_PIN 33 + + #define BTN_EN1 35 + #define BTN_EN2 37 + #define BTN_ENC 31 + + #define LCD_SDSS 53 + #define SD_DETECT_PIN 49 + //#define KILL_PIN 41 + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 27 + #define DOGLCD_CS 25 + + #define BEEPER_PIN 37 + + #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 + + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + //#define SDSS 53 + #define SD_DETECT_PIN 49 + //#define KILL_PIN 64 + + //#define LCD_CONTRAST_INIT 190 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(MINIPANEL) + + #define BEEPER_PIN 42 + // not connected to a pin + #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 + + #define DOGLCD_A0 44 + #define DOGLCD_CS 66 + + #define BTN_EN1 40 + #define BTN_EN2 63 + #define BTN_ENC 59 + + #define SDSS 53 + #define SD_DETECT_PIN 49 + //#define KILL_PIN 64 + + //#define LCD_CONTRAST_INIT 190 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #else + + // Beeper on AUX-4 + #define BEEPER_PIN 33 + + // Buttons are directly attached to AUX-2 + #if IS_RRW_KEYPAD + #define SHIFT_OUT_PIN 40 + #define SHIFT_CLK_PIN 44 + #define SHIFT_LD_PIN 42 + #define BTN_EN1 64 + #define BTN_EN2 59 + #define BTN_ENC 63 + #elif ENABLED(PANEL_ONE) + #define BTN_EN1 59 // AUX2 PIN 3 + #define BTN_EN2 63 // AUX2 PIN 4 + #define BTN_ENC 49 // AUX3 PIN 7 + #else + #define BTN_EN1 37 + #define BTN_EN2 35 + #define BTN_ENC 31 + #endif + + #if ENABLED(G3D_PANEL) + #define SD_DETECT_PIN 49 + //#define KILL_PIN 41 + #endif + + #endif + + #endif // IS_NEWPANEL + +#endif diff --git a/src/pins/ramps/pins_ULTIMAIN_2.h b/src/pins/ramps/pins_ULTIMAIN_2.h new file mode 100644 index 0000000..128f197 --- /dev/null +++ b/src/pins/ramps/pins_ULTIMAIN_2.h @@ -0,0 +1,141 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Ultiboard v2.0 pin assignments + */ + +/** + * Rev B 2 JAN 2017 + * + * Added pin definitions for: + * M3, M4 & M5 spindle control commands + * case light + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#define BOARD_INFO_NAME "Ultimaker 2.x" +#define DEFAULT_MACHINE_NAME "Ultimaker" +#define DEFAULT_SOURCE_CODE_URL "github.com/Ultimaker/Marlin" + +// +// Limit Switches +// +#define X_STOP_PIN 22 +#define Y_STOP_PIN 26 +#define Z_STOP_PIN 29 + +// +// Steppers +// +#define X_STEP_PIN 25 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 27 + +#define Y_STEP_PIN 32 +#define Y_DIR_PIN 33 +#define Y_ENABLE_PIN 31 + +#define Z_STEP_PIN 35 +#define Z_DIR_PIN 36 +#define Z_ENABLE_PIN 34 + +#define E0_STEP_PIN 42 +#define E0_DIR_PIN 43 +#define E0_ENABLE_PIN 37 + +#define E1_STEP_PIN 49 +#define E1_DIR_PIN 47 +#define E1_ENABLE_PIN 48 + +#define MOTOR_CURRENT_PWM_XY_PIN 44 +#define MOTOR_CURRENT_PWM_Z_PIN 45 +#define MOTOR_CURRENT_PWM_E_PIN 46 +// Motor current PWM conversion, PWM value = MotorCurrentSetting * 255 / range +#ifndef MOTOR_CURRENT_PWM_RANGE + #define MOTOR_CURRENT_PWM_RANGE 2000 +#endif +#define DEFAULT_PWM_MOTOR_CURRENT {1300, 1300, 1250} + +// +// Temperature Sensors +// +#define TEMP_0_PIN 8 // Analog Input +#define TEMP_1_PIN 9 // Analog Input +#define TEMP_BED_PIN 10 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define HEATER_1_PIN 3 +#define HEATER_BED_PIN 4 + +#ifndef FAN_PIN + #define FAN_PIN 7 +#endif + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN 77 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define SD_DETECT_PIN 39 +#define LED_PIN 8 +#define SAFETY_TRIGGERED_PIN 28 // PIN to detect the safety circuit has triggered +#define MAIN_VOLTAGE_MEASURE_PIN 14 // ANALOG PIN to measure the main voltage, with a 100k - 4k7 resitor divider. + +// +// LCD / Controller +// +#define BEEPER_PIN 18 + +#define LCD_PINS_RS 20 +#define LCD_PINS_ENABLE 15 +#define LCD_PINS_D4 14 +#define LCD_PINS_D5 21 +#define LCD_PINS_D6 5 +#define LCD_PINS_D7 6 + +// Buttons are directly attached +#define BTN_EN1 40 +#define BTN_EN2 41 +#define BTN_ENC 19 + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER // use the LED_PIN for spindle speed control or case light + #undef LED_PIN + #define SPINDLE_DIR_PIN 16 + #define SPINDLE_LASER_ENA_PIN 17 // Pullup! + #define SPINDLE_LASER_PWM_PIN 8 // Hardware PWM +#else + #undef LED_PIN + #define CASE_LIGHT_PIN 8 +#endif diff --git a/src/pins/ramps/pins_ULTIMAKER.h b/src/pins/ramps/pins_ULTIMAKER.h new file mode 100644 index 0000000..0bc04d9 --- /dev/null +++ b/src/pins/ramps/pins_ULTIMAKER.h @@ -0,0 +1,166 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Ultimaker pin assignments + */ + +/** + * Rev B 2 JAN 2017 + * + * Added pin definitions for: + * M3, M4 & M5 spindle control commands + * case light + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Ultimaker" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#define DEFAULT_SOURCE_CODE_URL "github.com/Ultimaker/Marlin" + +// +// Servos +// +#define SERVO0_PIN 11 + +// +// Limit Switches +// +#define X_MIN_PIN 22 +#define X_MAX_PIN 24 +#define Y_MIN_PIN 26 +#define Y_MAX_PIN 28 +#define Z_MIN_PIN 30 +#define Z_MAX_PIN 32 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 25 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 27 + +#define Y_STEP_PIN 31 +#define Y_DIR_PIN 33 +#define Y_ENABLE_PIN 29 + +#define Z_STEP_PIN 37 +#define Z_DIR_PIN 39 +#define Z_ENABLE_PIN 35 + +#define E0_STEP_PIN 43 +#define E0_DIR_PIN 45 +#define E0_ENABLE_PIN 41 + +#define E1_STEP_PIN 49 +#define E1_DIR_PIN 47 +#define E1_ENABLE_PIN 48 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 8 // Analog Input +#define TEMP_1_PIN 9 // Analog Input +#define TEMP_BED_PIN 10 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define HEATER_1_PIN 3 +#define HEATER_BED_PIN 4 + +#ifndef FAN_PIN + #define FAN_PIN 7 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 +#define PS_ON_PIN 12 +#define SUICIDE_PIN 54 // PIN that has to be turned on right after start, to keep power flowing. + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 8 +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #define BEEPER_PIN 18 + + #if IS_NEWPANEL + + #define LCD_PINS_RS 20 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 16 + #define LCD_PINS_D5 21 + #define LCD_PINS_D6 5 + #define LCD_PINS_D7 6 + + // Buttons directly attached + #define BTN_EN1 40 + #define BTN_EN2 42 + #define BTN_ENC 19 + + #define SD_DETECT_PIN 38 + + #else // !IS_NEWPANEL - Old style panel with shift register + + // Buttons attached to a shift register + #define SHIFT_CLK_PIN 38 + #define SHIFT_LD_PIN 42 + #define SHIFT_OUT_PIN 40 + #define SHIFT_EN_PIN 17 + + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 5 + #define LCD_PINS_D4 6 + #define LCD_PINS_D5 21 + #define LCD_PINS_D6 20 + #define LCD_PINS_D7 19 + + #define SD_DETECT_PIN -1 + + #endif // !IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM +#define SPINDLE_LASER_ENA_PIN 10 // Pullup! +#define SPINDLE_DIR_PIN 11 // use the EXP3 PWM header diff --git a/src/pins/ramps/pins_ULTIMAKER_OLD.h b/src/pins/ramps/pins_ULTIMAKER_OLD.h new file mode 100644 index 0000000..146c519 --- /dev/null +++ b/src/pins/ramps/pins_ULTIMAKER_OLD.h @@ -0,0 +1,272 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Ultimaker pin assignments (Old electronics) + */ + +/** + * Rev B 3 JAN 2017 + * + * Details on pin definitions for M3, M4 & M5 spindle control commands and for + * the CASE_LIGHT_PIN are at the end of this file. + * + * This started out as an attempt to add pin definitions for M3, M4 & M5 spindle + * control commands but quickly turned into a head scratcher as the sources for + * the revisions provided inconsistent information. + * + * As best I can determine: + * 1.5.3 boards should use the pins_ULTIMAKER.h file which means the BOARD_INFO_NAME + * define in this file should say 1.5.3 rather than 1.5.4 + * This file is meant for 1.1 - 1.3 boards. + * The endstops for the 1.0 boards use different definitions than on the 1.1 - 1.3 + * boards. + * + * I've added sections that have the 1.0 and 1.5.3 + endstop definitions so you can + * easily switch if needed. I've also copied over the 1.5.3 + LCD definitions. + * + * To be 100% sure of the board you have: + * 1. In Configuration_adv.h enable "PINS_DEBUGGING" + * 2. Compile & uploade + * 3. Enter the command "M43 W1 I1". This command will report that pin nmumber and + * name of any pin that changes state. + * 4. Using a 1k (approximately) resistor pull the endstops and some of the LCD pins + * to ground and see what is reported. + * 5. If the reported pin doesn't match the file then try a different board revision + * and repeat steps 2 - 5 + */ + +#define BOARD_REV_1_1_TO_1_3 +//#define BOARD_REV_1_0 +//#define BOARD_REV_1_5 + +#include "env_validate.h" + +#ifdef BOARD_REV_1_1_TO_1_3 + #define BOARD_INFO_NAME "Ultimaker 1.1-1.3" +#elif defined(BOARD_REV_1_0) + #define BOARD_INFO_NAME "Ultimaker 1.0" +#elif defined(BOARD_REV_1_5) + #define BOARD_INFO_NAME "Ultimaker 1.5" +#else + #define BOARD_INFO_NAME "Ultimaker 1.5.4+" +#endif +#define DEFAULT_MACHINE_NAME "Ultimaker" +#define DEFAULT_SOURCE_CODE_URL "github.com/Ultimaker/Marlin" + +// +// Limit Switches +// +#if ENABLED(BOARD_REV_1_1_TO_1_3) + #define X_MIN_PIN 15 // SW1 + #define X_MAX_PIN 14 // SW2 + #define Y_MIN_PIN 17 // SW3 + #define Y_MAX_PIN 16 // SW4 + #define Z_MIN_PIN 19 // SW5 + #define Z_MAX_PIN 18 // SW6 +#endif + +#if ENABLED(BOARD_REV_1_0) + #if HAS_CUTTER + #define X_STOP_PIN 13 // SW1 (didn't change) - also has a useable hardware PWM + #define Y_STOP_PIN 12 // SW2 + #define Z_STOP_PIN 11 // SW3 + #else + #define X_MIN_PIN 13 // SW1 + #define X_MAX_PIN 12 // SW2 + #define Y_MIN_PIN 11 // SW3 + #define Y_MAX_PIN 10 // SW4 + #define Z_MIN_PIN 9 // SW5 + #define Z_MAX_PIN 8 // SW6 + #endif +#endif + +#if ENABLED(BOARD_REV_1_5) + #define X_MIN_PIN 22 + #define X_MAX_PIN 24 + #define Y_MIN_PIN 26 + #define Y_MAX_PIN 28 + #define Z_MIN_PIN 30 + #define Z_MAX_PIN 32 +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#if !defined(Z_MIN_PROBE_PIN) && !BOTH(HAS_CUTTER, BOARD_REV_1_0) + #define Z_MIN_PROBE_PIN Z_MAX_PIN +#endif + +// +// Steppers +// +#define X_STEP_PIN 25 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 27 + +#define Y_STEP_PIN 31 +#define Y_DIR_PIN 33 +#define Y_ENABLE_PIN 29 + +#define Z_STEP_PIN 37 +#define Z_DIR_PIN 39 +#define Z_ENABLE_PIN 35 + +#if BOTH(HAS_CUTTER, BOARD_REV_1_1_TO_1_3) && EXTRUDERS == 1 + // Move E0 to the spare and get Spindle/Laser signals from E0 + #define E0_STEP_PIN 49 + #define E0_DIR_PIN 47 + #define E0_ENABLE_PIN 48 +#else + #define E0_STEP_PIN 43 + #define E0_DIR_PIN 45 + #define E0_ENABLE_PIN 41 + + #define E1_STEP_PIN 49 + #define E1_DIR_PIN 47 + #define E1_ENABLE_PIN 48 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 8 // Analog Input +#define TEMP_1_PIN 1 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +//#define HEATER_1_PIN 3 // used for case light Rev A said "1" +#define HEATER_BED_PIN 4 + +// +// LCD / Controller +// +#if EITHER(BOARD_REV_1_0, BOARD_REV_1_1_TO_1_3) + + #define LCD_PINS_RS 24 + #define LCD_PINS_ENABLE 22 + #define LCD_PINS_D4 36 + #define LCD_PINS_D5 34 + #define LCD_PINS_D6 32 + #define LCD_PINS_D7 30 + +#elif BOTH(BOARD_REV_1_5, HAS_WIRED_LCD) + + #define BEEPER_PIN 18 + + #if IS_NEWPANEL + + #define LCD_PINS_RS 20 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 16 + #define LCD_PINS_D5 21 + #define LCD_PINS_D6 5 + #define LCD_PINS_D7 6 + + // Buttons directly attached + #define BTN_EN1 40 + #define BTN_EN2 42 + #define BTN_ENC 19 + + #define SD_DETECT_PIN 38 + + #else // !IS_NEWPANEL - Old style panel with shift register + + // Buttons attached to a shift register + #define SHIFT_CLK_PIN 38 + #define SHIFT_LD_PIN 42 + #define SHIFT_OUT_PIN 40 + #define SHIFT_EN_PIN 17 + + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 5 + #define LCD_PINS_D4 6 + #define LCD_PINS_D5 21 + #define LCD_PINS_D6 20 + #define LCD_PINS_D7 19 + + #endif // !IS_NEWPANEL + +#endif + +// +// case light - see spindle section for more info on available hardware PWMs +// +#if !PIN_EXISTS(CASE_LIGHT) && ENABLED(BOARD_REV_1_5) + #define CASE_LIGHT_PIN 7 // use PWM - MUST BE HARDWARE PWM +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + #if EITHER(BOARD_REV_1_0, BOARD_REV_1_5) // Use the last three SW positions + #define SPINDLE_DIR_PIN 10 // 1.0: SW4 1.5: EXP3-6 ("10") + #define SPINDLE_LASER_PWM_PIN 9 // 1.0: SW5 1.5: EXP3-7 ( "9") .. MUST BE HARDWARE PWM + #define SPINDLE_LASER_ENA_PIN 8 // 1.0: SW6 1.5: EXP3-8 ( "8") .. Pin should have a pullup! + #elif ENABLED(BOARD_REV_1_1_TO_1_3) + /** + * Only four hardware PWMs physically connected to anything on these boards: + * + * HEATER_0_PIN 2 silkscreen varies - usually "PWM 1" or "HEATER1" + * HEATER_1_PIN 3 silkscreen varies - usually "PWM 2" or "HEATER2" + * HEATER_BED_PIN 4 silkscreen varies - usually "PWM 3" or "HEATED BED" + * E0_DIR_PIN 45 + * + * If one of the heaters is used then special precautions will usually be needed. + * They have an LED and resistor pullup to +24V which could damage 3.3V-5V ICs. + */ + #if EXTRUDERS == 1 + #define SPINDLE_DIR_PIN 43 + #define SPINDLE_LASER_PWM_PIN 45 // Hardware PWM + #define SPINDLE_LASER_ENA_PIN 41 // Pullup! + #elif TEMP_SENSOR_BED == 0 // Can't use E0 so see if HEATER_BED_PIN is available + #undef HEATER_BED_PIN + #define SPINDLE_DIR_PIN 38 // Probably pin 4 on 10 pin connector closest to the E0 socket + #define SPINDLE_LASER_PWM_PIN 4 // Hardware PWM - Special precautions usually needed. + #define SPINDLE_LASER_ENA_PIN 40 // Pullup! (Probably pin 6 on the 10-pin + // connector closest to the E0 socket) + #endif + #endif +#endif + +/** + * Where to get the spindle signals on the E0 socket + * + * spindle signal socket name socket name + * ------- + * SPINDLE_LASER_ENA_PIN /ENABLE *| |O VMOT + * MS1 O| |O GND + * MS2 O| |O 2B + * MS3 O| |O 2A + * /RESET O| |O 1A + * /SLEEP O| |O 1B + * SPINDLE_DIR_PIN STEP O| |O VDD + * SPINDLE_LASER_PWM_PIN DIR O| |O GND + * ------- + * * - pin closest to MS1, MS2 & MS3 jumpers on the board + * + * Note: Socket names vary from vendor to vendor. + */ diff --git a/src/pins/ramps/pins_VORON.h b/src/pins/ramps/pins_VORON.h new file mode 100644 index 0000000..9390381 --- /dev/null +++ b/src/pins/ramps/pins_VORON.h @@ -0,0 +1,55 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * VORON Design v2 pin assignments + * See https://github.com/mzbotreprap/VORON/blob/master/Firmware/Marlin/pins_RAMPS_VORON.h + */ + +#define BOARD_INFO_NAME "VORON Design v2" + +#define MOSFET_C_PIN 11 + +#include "pins_RAMPS.h" + +// +// Heaters / Fans +// +#undef FAN_PIN +#define FAN_PIN 5 // Using the pin for the controller fan since controller fan is always on. +#define CONTROLLER_FAN_PIN 8 + +// +// Auto fans +// +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN 6 // Servo pin 6 for E3D Fan +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN 6 // Servo pin 6 for E3D Fan (same pin for both extruders since it's the same fan) +#endif + +// +// LCDs and Controllers +// +#undef BEEPER_PIN diff --git a/src/pins/ramps/pins_ZRIB_V20.h b/src/pins/ramps/pins_ZRIB_V20.h new file mode 100644 index 0000000..e9328ca --- /dev/null +++ b/src/pins/ramps/pins_ZRIB_V20.h @@ -0,0 +1,87 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * ZRIB V2.0 & V3.0 pin assignments + * V2 and V3 Boards only differ in USB controller, nothing affecting the pins. + */ + +#include "pins_MKS_GEN_13.h" // ... RAMPS + +#define ZRIB_V20_D6_PIN 6 // Fan +#define ZRIB_V20_D9_PIN 9 // Fan2 +#define ZRIB_V20_A10_PIN 10 +#define ZRIB_V20_D16_PIN 16 +#define ZRIB_V20_D17_PIN 17 +#define ZRIB_V20_D23_PIN 23 +#define ZRIB_V20_D25_PIN 25 +#define ZRIB_V20_D27_PIN 27 +#define ZRIB_V20_D29_PIN 29 +#define ZRIB_V20_D37_PIN 37 + +// +// Auto fans +// +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN ZRIB_V20_D6_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN ZRIB_V20_D6_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN ZRIB_V20_D6_PIN +#endif +#ifndef E3_AUTO_FAN_PIN + #define E3_AUTO_FAN_PIN ZRIB_V20_D6_PIN +#endif + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 11 // Analog Input +#endif + +#if ENABLED(ZONESTAR_LCD) + #undef LCD_PINS_RS + #undef LCD_PINS_ENABLE + #undef LCD_PINS_D4 + #undef LCD_PINS_D5 + #undef LCD_PINS_D6 + #undef LCD_PINS_D7 + #undef ADC_KEYPAD_PIN + #undef BEEPER_PIN + + #undef SHIFT_OUT_PIN + #undef SHIFT_CLK_PIN + #undef SHIFT_LD_PIN + #undef BTN_EN1 + #undef BTN_EN2 + #undef BTN_ENC + + #define LCD_PINS_RS ZRIB_V20_D16_PIN + #define LCD_PINS_ENABLE ZRIB_V20_D17_PIN + #define LCD_PINS_D4 ZRIB_V20_D23_PIN + #define LCD_PINS_D5 ZRIB_V20_D25_PIN + #define LCD_PINS_D6 ZRIB_V20_D27_PIN + #define LCD_PINS_D7 ZRIB_V20_D29_PIN + #define ADC_KEYPAD_PIN ZRIB_V20_A10_PIN + #define BEEPER_PIN ZRIB_V20_D37_PIN +#endif diff --git a/src/pins/ramps/pins_ZRIB_V52.h b/src/pins/ramps/pins_ZRIB_V52.h new file mode 100644 index 0000000..2df789c --- /dev/null +++ b/src/pins/ramps/pins_ZRIB_V52.h @@ -0,0 +1,159 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * ZRIB V5.2 Based on MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "ZRIB V5.2 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "ZRIB V5.2" + +#define MKS_BASE_VERSION 14 + +// +// Heaters / Fans +// +#define HEATER_1_PIN 7 +#define FAN_PIN 9 // PH6 ** Pin18 ** PWM9 +#define FAN1_PIN 6 + +// +// Extra Extruder / Stepper for V5.2 +// +#define E2_STEP_PIN 4 +#define E2_DIR_PIN 5 +#define E2_ENABLE_PIN 22 + +#include "pins_MKS_BASE_common.h" // ... RAMPS + +/** + * Available connectors on MKS BASE v1.4 (Basically same as ZRIB V5.2) + * + * ======= + * | GND | + * |-----| E0 + * | 10 | (10) PB4 ** Pin23 ** PWM10 + * |-----| + * | GND | + * |-----| E1 + * | 7 | ( 7) PH4 ** Pin16 ** PWM7 + * |-----| + * | GND | + * |-----| FAN + * | 9 | ( 9) PH6 ** Pin18 ** PWM9 + * ======= + * + * ======= + * | GND | + * |-----| Heated Bed + * | 8 | ( 8) PH5 ** Pin17 ** PWM8 + * ======= + * + * ========== + * | 12-24V | + * |--------| Power + * | GND | + * ========== + * + * XS3 Connector + * ================= + * | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 + * |----|-----|----| + * | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 + * ================= + * + * Servos Connector + * ================= + * | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 + * |----|-----|----| + * | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 + * ================= + * + * ICSP + * ================= + * | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI + * |----|----|-----| + * | 50 | 52 | RST | (50) PB3 ** Pin22 ** SPI_MISO + * ================= (52) PB1 ** Pin20 ** SPI_SCK + * + * XS6/AUX-1 Connector + * ====================== + * | 5V | GND | NC | 20 | (20) PD1 ** Pin44 ** I2C_SDA + * |----|-----|----|----| + * | 50 | 51 | 52 | 21 | (50) PB3 ** Pin22 ** SPI_MISO + * ====================== (51) PB2 ** Pin21 ** SPI_MOSI + * (52) PB1 ** Pin20 ** SPI_SCK + * (21) PD0 ** Pin43 ** I2C_SCL + * + * Temperature + * ================================== + * | GND | 69 | GND | 68 | GND | 67 | + * ================================== + * (69) PK7 ** Pin82 ** A15 + * (68) PK6 ** Pin83 ** A14 + * (67) PK5 ** Pin84 ** A13 + * + * Limit Switches + * ============ + * | 2 | GND | X+ ( 2) PE4 ** Pin6 ** PWM2 + * |----|-----| + * | 3 | GND | X- ( 3) PE5 ** Pin7 ** PWM3 + * |----|-----| + * | 15 | GND | Y+ (15) PJ0 ** Pin63 ** USART3_RX + * |----|-----| + * | 14 | GND | Y- (14) PJ1 ** Pin64 ** USART3_TX + * |----|-----| + * | 19 | GND | Z+ (19) PD2 ** Pin45 ** USART1_RX + * |----|-----| + * | 18 | GND | Z- (18) PD3 ** Pin46 ** USART1_TX + * ============ + * + * EXP1 + * ============ + * | 37 | 35 | (37) PC0 ** Pin53 ** D37 + * |-----|----| (35) PC2 ** Pin55 ** D35 + * | 17 | 16 | (17) PH0 ** Pin12 ** USART2_RX + * |-----|----| (16) PH1 ** Pin13 ** USART2_TX + * | 23 | 25 | (23) PA1 ** Pin77 ** D23 + * |-----|----| (25) PA3 ** Pin75 ** D25 + * | 27 | 29 | (27) PA5 ** Pin73 ** D27 + * |-----|----| (29) PA7 ** Pin71 ** D29 + * | GND | 5V | + * ============ + * + * EXP2 + * ============ + * | 50 | 52 | (50) PB3 ** Pin22 ** SPI_MISO + * |-----|----| (52) PB1 ** Pin20 ** SPI_SCK + * | 31 | 53 | (31) PC6 ** Pin59 ** D31 + * |-----|----| (53) PB0 ** Pin19 ** SPI_SS + * | 33 | 51 | (33) PC4 ** Pin57 ** D33 + * |-----|----| (51) PB2 ** Pin21 ** SPI_MOSI + * | 49 | 41 | (49) PL0 ** Pin35 ** D49 + * |-----|----| (41) PG0 ** Pin51 ** D41 + * | GND | NC | + * ============ + */ diff --git a/src/pins/ramps/pins_ZRIB_V53.h b/src/pins/ramps/pins_ZRIB_V53.h new file mode 100644 index 0000000..cae71f7 --- /dev/null +++ b/src/pins/ramps/pins_ZRIB_V53.h @@ -0,0 +1,511 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * ZRIB V5.3 Based on MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + */ + +#include "env_validate.h" + +#if HOTENDS > 2 + #error "ZRIB V5.3 supports up to 2 hotends." +#elif E_STEPPERS > 3 + #error "ZRIB V5.3 supports up to 3 E steppers." +#endif + +#define BOARD_INFO_NAME "ZRIB V5.3" + +// +// PIN 12 Connector +// +#define PIN_12_PIN 12 + +// +// XS1 Connector +// +#define XS1_01_PIN 42 +#define XS1_03_PIN 43 +#define XS1_05_PIN 44 +#define XS1_07_PIN 45 +#define XS1_08_PIN 47 + +// +// XS6 Connector +// +#define XS6_01_PIN 20 +#define XS6_03_PIN 52 +#define XS6_05_PIN 51 +#define XS6_07_PIN 50 +#define XS6_08_PIN 21 + +// +// Servos / XS3 Connector +// +#ifndef SERVO0_PIN + #define SERVO0_PIN 11 // Analog Output +#endif +#ifndef SERVO1_PIN + #define SERVO1_PIN 12 // Analog Output +#endif + +// +// Limit Switches +// +#ifndef X_STOP_PIN + #ifndef X_MIN_PIN + #define X_MIN_PIN 3 + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN 2 + #endif +#endif +#ifndef Y_STOP_PIN + #ifndef Y_MIN_PIN + #define Y_MIN_PIN 14 + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN 15 + #endif +#endif +#ifndef Z_STOP_PIN + #ifndef Z_MIN_PIN + #define Z_MIN_PIN 18 + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN 19 + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 19 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 + +#if NUM_Z_STEPPERS == 2 + #define Z2_STEP_PIN 26 // E0 connector + #define Z2_DIR_PIN 28 + #define Z2_ENABLE_PIN 24 + + #define E0_STEP_PIN 36 // E1 connector + #define E0_DIR_PIN 34 + #define E0_ENABLE_PIN 30 + + #define E1_STEP_PIN 4 // E2 connector + #define E1_DIR_PIN 5 + #define E1_ENABLE_PIN 22 +#else + #define E0_STEP_PIN 26 + #define E0_DIR_PIN 28 + #define E0_ENABLE_PIN 24 + + #define E1_STEP_PIN 36 + #define E1_DIR_PIN 34 + #define E1_ENABLE_PIN 30 + + #define E2_STEP_PIN 4 + #define E2_DIR_PIN 5 + #define E2_ENABLE_PIN 22 +#endif + +// +// Temperature Sensors +// +#ifndef TEMP_0_PIN + #define TEMP_0_PIN 13 // Analog Input +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN 15 // Analog Input +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN 14 // Analog Input +#endif + +// +// Heaters / Fans Connectors +// + +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 +#define FAN_PIN 9 +#define HEATER_BED_PIN 8 +#define FAN1_PIN 6 + +// +// Misc. Functions +// +#ifndef SDSS + #define SDSS 53 +#endif + +#define LED_PIN 13 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN XS1_01_PIN +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN XS1_03_PIN +#endif + +#if HAS_TMC_UART + /** + * TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + * + * Serial2 -- AUX-4 Pin 18 (D16 TX2) and AUX-4 Pin 17 (D17 RX2) + * Serial1 -- Pins D18 and D19 are used for Z-MIN and Z-MAX + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN PIN_12_PIN + #endif + #ifndef X2_SERIAL_TX_PIN + #define X2_SERIAL_TX_PIN -1 + #endif + #ifndef X2_SERIAL_RX_PIN + #define X2_SERIAL_RX_PIN -1 + #endif + + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN PIN_12_PIN + #endif + #ifndef Y2_SERIAL_TX_PIN + #define Y2_SERIAL_TX_PIN -1 + #endif + #ifndef Y2_SERIAL_RX_PIN + #define Y2_SERIAL_RX_PIN -1 + #endif + + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN PIN_12_PIN + #endif + #ifndef Z2_SERIAL_TX_PIN + #define Z2_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef Z2_SERIAL_RX_PIN + #define Z2_SERIAL_RX_PIN PIN_12_PIN + #endif + + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN -1 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN -1 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN -1 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN -1 + #endif + #ifndef E2_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN -1 + #endif + #ifndef E2_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN -1 + #endif + #ifndef E3_SERIAL_TX_PIN + #define E3_SERIAL_TX_PIN -1 + #endif + #ifndef E3_SERIAL_RX_PIN + #define E3_SERIAL_RX_PIN -1 + #endif + #ifndef E4_SERIAL_TX_PIN + #define E4_SERIAL_TX_PIN -1 + #endif + #ifndef E4_SERIAL_RX_PIN + #define E4_SERIAL_RX_PIN -1 + #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif +#endif + +/** + * LCD adapter. NOTE: These come in two variants. The socket keys can be + * on either side, and may be backwards on some displays. + * ------ ------ + * D37 | 1 2 | D35 (MISO) D50 | 1 2 | D52 (SCK) + * D17 | 3 4 | D16 D31 | 3 4 | D53 + * D23 6 5 D25 D33 6 5 D51 (MOSI) + * D27 | 7 8 | D29 D49 | 7 8 | D41 + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ + +#ifndef EXP1_08_PIN + #define EXP1_01_PIN 37 + #define EXP1_02_PIN 35 + #define EXP1_03_PIN 17 + #define EXP1_04_PIN 16 + #define EXP1_05_PIN 23 + #define EXP1_06_PIN 25 + #define EXP1_07_PIN 27 + #define EXP1_08_PIN 29 + + #define EXP2_01_PIN XS6_07_PIN + #define EXP2_02_PIN XS6_03_PIN + #define EXP2_03_PIN 31 + #define EXP2_04_PIN 53 + #define EXP2_05_PIN 33 + #define EXP2_06_PIN XS6_05_PIN + #define EXP2_07_PIN 49 + #define EXP2_08_PIN 41 +#endif + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +#if ENABLED(ZONESTAR_12864LCD) + #define LCDSCREEN_NAME "ZONESTAR LCD12864" + #define LCD_SDSS 16 + #define LCD_PINS_RS 16 // ST7920_CS_PIN LCD_PIN_RS (PIN4 of LCD module) + #define LCD_PINS_ENABLE 23 // ST7920_DAT_PIN LCD_PIN_R/W (PIN5 of LCD module) + #define LCD_PINS_D4 17 // ST7920_CLK_PIN LCD_PIN_ENABLE (PIN6 of LCD module) + #define BTN_EN2 25 + #define BTN_EN1 27 + #define BTN_ENC 29 + #define BEEPER_PIN 37 + #define KILL_PIN 35 +#elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define LCDSCREEN_NAME "Reprap LCD12864" + // Use EXP1 & EXP2 connector + #define LCD_PINS_RS 16 // ST7920_CS_PIN LCD_PIN_RS + #define LCD_PINS_ENABLE 17 // ST7920_DAT_PIN LCD_PIN_ENABLE + #define LCD_PINS_D4 23 // ST7920_CLK_PIN LCD_PIN_R/W + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + #define BEEPER_PIN 37 + #define KILL_PIN 41 +#endif + +//================================================================================ +// OLED 128x64 +//================================================================================ + +#if EITHER(ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) + #define LCDSCREEN_NAME "ZONESTAR 12864OLED" + #define LCD_SDSS 16 + #define LCD_PINS_RS 23 // RESET Pull low for 1s to init + #define LCD_PINS_DC 17 + #define DOGLCD_CS 16 // CS + #define BTN_EN2 25 + #define BTN_EN1 27 + #define BTN_ENC 29 + #define BEEPER_PIN -1 + #define KILL_PIN -1 + #if EITHER(OLED_HW_IIC, OLED_HW_SPI) + #error "Oops! You must choose SW SPI for ZRIB V53 board and connect the OLED screen to EXP1 connector." + #else // SW_SPI + #define DOGLCD_A0 LCD_PINS_DC + #define DOGLCD_MOSI 35 // SDA + #define DOGLCD_SCK 37 // SCK + #endif +#endif // OLED 128x64 + +//================================================================================ +// LCD 2004 KEYPAD +//================================================================================ + +#if ENABLED(ZONESTAR_LCD) + #define LCDSCREEN_NAME "LCD2004 ADCKEY" + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define ADC_KEYPAD_PIN 10 // A10 for ADCKEY + #define BEEPER_PIN EXP1_01_PIN +#endif + +/** + * ZRIB V5.3 Main Board + * + * Available connectors on ZRIB V5.3 + * + * ======= + * | GND | + * |-----| E0 + * | 10 | (10) PB4 ** Pin23 ** PWM10 + * |-----| + * | GND | + * |-----| E1 + * | 7 | ( 7) PH4 ** Pin16 ** PWM7 + * |-----| + * | GND | + * |-----| FAN + * | 9 | ( 9) PH6 ** Pin18 ** PWM9 + * ======= + * ======= + * | GND | + * |-----| Heated Bed + * | 8 | ( 8) PH5 ** Pin17 ** PWM8 + * ======= + * ========== + * | 12-24V | + * |--------| Power + * | GND | + * ========== + * XS3 Connector + * ================= + * | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 + * |----|-----|----| + * | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 + * ================= + * XS3/Servos Connector + * ================= + * | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 + * |----|-----|----| + * | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 + * ================= + * ICSP + * ================= + * | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI + * |----|----|-----| + * | 50 | 52 | RST | (50) PB3 ** Pin22 ** SPI_MISO + * ================= (52) PB1 ** Pin20 ** SPI_SCK + * XS6 Connector + * ====================== + * | 5V | GND | NC | 20 | (20) PD1 ** Pin44 ** I2C_SDA + * |----|-----|----|----| + * | 50 | 51 | 52 | 21 | (50) PB3 ** Pin22 ** SPI_MISO + * ====================== (51) PB2 ** Pin21 ** SPI_MOSI + * (52) PB1 ** Pin20 ** SPI_SCK + * (21) PD0 ** Pin43 ** I2C_SCL + * XS1 Connector + * ====================== + * | 5V | GND | NC | 47 | (47) PL2 ** Pin37 ** D47 + * |----|-----|----|----| + * | 42 | 43 | 44 | 45 | (45) PL4 ** Pin39 ** D45 + * ====================== (44) PL5 ** Pin40 ** D44 + * (43) PL6 ** Pin41 ** D43 + * (42) PL7 ** Pin42 ** D42 + * Temperature + * ================================== + * | GND | 69 | GND | 68 | GND | 67 | + * ================================== + * (69) PK7 ** Pin82 ** A15 + * (68) PK6 ** Pin83 ** A14 + * (67) PK5 ** Pin84 ** A13 + * Limit Switches + * ============ + * | 2 | GND | X+ ( 2) PE4 ** Pin6 ** PWM2 + * |----|-----| + * | 3 | GND | X- ( 3) PE5 ** Pin7 ** PWM3 + * |----|-----| + * | 15 | GND | Y+ (15) PJ0 ** Pin63 ** USART3_RX + * |----|-----| + * | 14 | GND | Y- (14) PJ1 ** Pin64 ** USART3_TX + * |----|-----| + * | 19 | GND | Z+ (19) PD2 ** Pin45 ** USART1_RX + * |----|-----| + * | 18 | GND | Z- (18) PD3 ** Pin46 ** USART1_TX + * ============ + * EXP1 + * ============ + * | 37 | 35 | (37) PC0 ** Pin53 ** D37 + * |-----|----| (35) PC2 ** Pin55 ** D35 + * | 17 | 16 | (17) PH0 ** Pin12 ** USART2_RX + * |-----|----| (16) PH1 ** Pin13 ** USART2_TX + * | 23 | 25 | (23) PA1 ** Pin77 ** D23 + * |-----|----| (25) PA3 ** Pin75 ** D25 + * | 27 | 29 | (27) PA5 ** Pin73 ** D27 + * |-----|----| (29) PA7 ** Pin71 ** D29 + * | GND | 5V | + * ============ + * EXP2 + * ============ + * | 50 | 52 | (50) PB3 ** Pin22 ** SPI_MISO + * |-----|----| (52) PB1 ** Pin20 ** SPI_SCK + * | 31 | 53 | (31) PC6 ** Pin59 ** D31 + * |-----|----| (53) PB0 ** Pin19 ** SPI_SS + * | 33 | 51 | (33) PC4 ** Pin57 ** D33 + * |-----|----| (51) PB2 ** Pin21 ** SPI_MOSI + * | 49 | 41 | (49) PL0 ** Pin35 ** D49 + * |-----|----| (41) PG0 ** Pin51 ** D41 + * | GND | NC | + * ============ + * + * PIN 12 + * ====== + * | 12 | (12) PB6 ** Pin25 ** D12 + * ====== +*/ diff --git a/src/pins/ramps/pins_Z_BOLT_X_SERIES.h b/src/pins/ramps/pins_Z_BOLT_X_SERIES.h new file mode 100644 index 0000000..b68e3ed --- /dev/null +++ b/src/pins/ramps/pins_Z_BOLT_X_SERIES.h @@ -0,0 +1,303 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Z-Bolt X Series board – based on Arduino Mega2560 + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 4 || E_STEPPERS > 4 + #error "Z-Bolt X Series supports up to 4 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Z-Bolt X Series" + +// +// Servos +// +#ifndef SERVO0_PIN + #define SERVO0_PIN 11 +#endif +#ifndef SERVO3_PIN + #define SERVO3_PIN 4 +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#ifndef X_MAX_PIN + #define X_MAX_PIN 2 +#endif +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN -1 +#endif + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#ifndef Y_CS_PIN + #define Y_CS_PIN -1 +#endif + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 +#ifndef Z_CS_PIN + #define Z_CS_PIN -1 +#endif + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +#ifndef E0_CS_PIN + #define E0_CS_PIN -1 +#endif + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#ifndef E1_CS_PIN + #define E1_CS_PIN -1 +#endif + +// Red +#define E2_STEP_PIN 42 +#define E2_DIR_PIN 40 +#define E2_ENABLE_PIN 65 +#ifndef E2_CS_PIN + #define E2_CS_PIN -1 +#endif + +// Black +#define E3_STEP_PIN 44 +#define E3_DIR_PIN 64 +#define E3_ENABLE_PIN 66 +#ifndef E3_CS_PIN + #define E3_CS_PIN -1 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // Analog Input +#define TEMP_1_PIN 15 // Analog Input +#define TEMP_2_PIN 5 // Analog Input (BLACK) +#define TEMP_3_PIN 9 // Analog Input (RED) +#define TEMP_BED_PIN 14 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 +#define HEATER_2_PIN 6 +#define HEATER_3_PIN 5 +#define HEATER_BED_PIN 8 + +#define FAN_PIN 9 + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 5 // Analog Input on AUX2 +#endif + +// Оn the servos connector +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 4 +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN 12 +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN) + #if NUM_SERVOS <= 1 // Prefer the servo connector + #define CASE_LIGHT_PIN 6 // Hardware PWM + #elif HAS_FREE_AUX2_PINS + #define CASE_LIGHT_PIN 44 // Hardware PWM + #endif +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER && !PIN_EXISTS(SPINDLE_LASER_ENA) + #if !defined(NUM_SERVOS) || NUM_SERVOS == 0 // Prefer the servo connector + #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM + #define SPINDLE_DIR_PIN 5 + #elif HAS_FREE_AUX2_PINS + #define SPINDLE_LASER_ENA_PIN 40 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM + #define SPINDLE_DIR_PIN 65 + #endif +#endif + +// +// TMC software SPI +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI 66 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO 44 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK 64 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC220x stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN 40 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN 63 + #endif + #ifndef X2_SERIAL_TX_PIN + #define X2_SERIAL_TX_PIN -1 + #endif + #ifndef X2_SERIAL_RX_PIN + #define X2_SERIAL_RX_PIN -1 + #endif + + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN 59 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN 64 + #endif + #ifndef Y2_SERIAL_TX_PIN + #define Y2_SERIAL_TX_PIN -1 + #endif + #ifndef Y2_SERIAL_RX_PIN + #define Y2_SERIAL_RX_PIN -1 + #endif + + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN 42 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN 65 + #endif + #ifndef Z2_SERIAL_TX_PIN + #define Z2_SERIAL_TX_PIN -1 + #endif + #ifndef Z2_SERIAL_RX_PIN + #define Z2_SERIAL_RX_PIN -1 + #endif + + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN 44 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN 66 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN -1 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN -1 + #endif + #ifndef E2_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN -1 + #endif + #ifndef E2_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN -1 + #endif + #ifndef E3_SERIAL_TX_PIN + #define E3_SERIAL_TX_PIN -1 + #endif + #ifndef E3_SERIAL_RX_PIN + #define E3_SERIAL_RX_PIN -1 + #endif + #ifndef E4_SERIAL_TX_PIN + #define E4_SERIAL_TX_PIN -1 + #endif + #ifndef E4_SERIAL_RX_PIN + #define E4_SERIAL_RX_PIN -1 + #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif +#endif diff --git a/src/pins/sam/env_validate.h b/src/pins/sam/env_validate.h new file mode 100644 index 0000000..09bcd13 --- /dev/null +++ b/src/pins/sam/env_validate.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if BOTH(ALLOW_MEGA1280, ALLOW_MEGA2560) && NOT_TARGET(__SAM3X8E__, __AVR_ATmega1280__, __AVR_ATmega2560__) + #error "Oops! Select 'Arduino Due or Mega' in 'Tools > Board.'" +#elif ENABLED(ALLOW_MEGA2560) && NOT_TARGET(__SAM3X8E__, __AVR_ATmega2560__) + #error "Oops! Select 'Arduino Due or Mega' in 'Tools > Board.'" +#elif ENABLED(ALLOW_MEGA1280) && NOT_TARGET(__SAM3X8E__, __AVR_ATmega1280__) + #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" +#endif + +#undef ALLOW_MEGA1280 +#undef ALLOW_MEGA2560 diff --git a/src/pins/sam/pins_ADSK.h b/src/pins/sam/pins_ADSK.h new file mode 100644 index 0000000..425d6d4 --- /dev/null +++ b/src/pins/sam/pins_ADSK.h @@ -0,0 +1,207 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino DUE Shield Kit (ADSK) pin assignments + */ + +#define BOARD_INFO_NAME "ADSK" + +#define ALLOW_MEGA1280 +#define ALLOW_MEGA2560 +#include "env_validate.h" + +/* CNC shield modifications: +FROM THE BOTTOM CUT THE 5V PIN THAT GOES TO ARDUINO!!! +On the top put jumper between 5V and 3V3 pins, + jumper between D12 and A.STEP, jumper between D13 and A.DIR +*/ + +/* CNC shield 3D printer connections: +X,Y,Z steppers as normal +A stepper for E0 extruder +(X-)&(GND) - X limit +(Y-)&(GND) - Y limit +(Z-)&(GND) - Z limit +(Abort)&(GND) - Extruder thermistor (also require pullup resistor 4.7K between "Abort" and + Vcc (now "5V" on the board but actual 3.3V because of jumper)) +(Hold)&(GND) - Bed thermistor (also require pullup resistor 4.7K between "Hold" and + Vcc (now "5V" on the board but actual 3.3V because of jumper)) +(CoolEn) - 3.3v signal to control extruder heater MOSFET +(Resume) - 3.3v signal to control heatbed MOSFET +(SDA) - 3.3v signal to control extruder fan +(SCL) - 3.3v signal to control extruder cooling fan +*/ + +/* CNC Shield pinout +"Name on the board": DUE pin +"Abort": Analog pin 0 or Digital pin 54 +"Hold": Analog pin 1 or Digital pin 55 +"Resume": Analog pin 2 or Digital pin 56 +"CoolEn": Analog pin 3 or Digital pin 57 +"SDA": Analog pin 4 or Digital pin 58 +"SCL": Analog pin 5 or Digital pin 59 +"E-STOP": Reset pin +"RX": Digital pin 0 +"TX": Digital pin 1 +"X.STEP": Digital pin 2 +"Y.STEP": Digital pin 3 +"Z.STEP": Digital pin 4 +"X.DIR": Digital pin 5 +"Y.DIR": Digital pin 6 +"Z.DIR": Digital pin 7 +"EN": Digital pin 8 +"X+","X-": Digital pin 9 +"Y+","Y-": Digital pin 10 +"Z+","Z-": Digital pin 11 +"SpinEn": Digital pin 12 -> will be connected to A.STEP with jumper +"SpinDir": Digital pin 13 -> will be connected to A.DIR with jumper +*/ + +// +// Servos +// +#define SERVO0_PIN 61 // Analog pin 7, Digital pin 61 + +// +// Limit Switches +// +#define X_STOP_PIN 9 +#define Y_STOP_PIN 10 +#define Z_STOP_PIN 11 + +#define Z_MIN_PROBE_PIN 62 // Analog pin 8, Digital pin 62 + +// +// Steppers +// +#define X_STEP_PIN 2 +#define X_DIR_PIN 5 +#define X_ENABLE_PIN 8 + +#define Y_STEP_PIN 3 +#define Y_DIR_PIN 6 +#define Y_ENABLE_PIN 8 + +#define Z_STEP_PIN 4 +#define Z_DIR_PIN 7 +#define Z_ENABLE_PIN 8 + +#define E0_STEP_PIN 12 +#define E0_DIR_PIN 13 +#define E0_ENABLE_PIN 8 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 55 // "Hold": Analog pin 1, Digital pin 55 +#define HEATER_BED_PIN 57 // "CoolEn": Analog pin 3, Digital pin 57 +#define FAN_PIN 54 // "Abort": Analog pin 0, Digital pin 54 +#undef E0_AUTO_FAN_PIN +#define E0_AUTO_FAN_PIN 56 // "Resume": Analog pin 2, Digital pin 56 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 4 // "SDA": Analog pin 4, Digital pin 58 +#define TEMP_BED_PIN 5 // "SCL": Analog pin 5, Digital pin 59 + +// +// Misc. Functions +// +#define SDSS 52 + +#if ENABLED(ZONESTAR_LCD) + + /** + * The 2004 LCD should be powered with 5V. + * The next LCD pins RS,D4,D5,D6,D7 have internal pull-ups to 5V and as result the 5V will be on these pins. + * Luckily these internal pull-ups have really high resistance and adding 33K pull-down resistors will create + * simple voltage divider that will bring the voltage down just slightly below 3.3V. + * + * This LCD also has buttons that connected to the same ADC pin with different voltage divider combinations. + * On the LCD panel there is internal pull-up resistor of the 4.7K connected to 5V. + * Connecting another 4.7K pull-down resistor between ADC pin and the GND + * will result in scaled values for voltage dividers and will bring them down to be always below 3.3V. + * + * For 2004 LCD to work with 3.3V board like Arduino DUE the next required: + * Pull-down resistors of 33K between each of LCD pins RS,D4,D5,D6,D7 and the GND. + * Pull-down resistor of 4.7K between ADC_KEYPAD_PIN and the GND + * + * All these modifications will still work with 5V based boards but require proper scaled ADC values + */ + + #ifdef __SAM3X8E__ + #define AREF_VOLTS 3.3 + #else + #define AREF_VOLTS 5.0 + #endif + + // + // LCD / Controller + // + #define LCD_PINS_ENABLE 14 + #define LCD_PINS_RS 15 + #define LCD_PINS_D4 16 + #define LCD_PINS_D5 17 + #define LCD_PINS_D6 18 + #define LCD_PINS_D7 19 + #define ADC_KEYPAD_PIN 6 //60 // Analog pin 6, Digital pin 60 + + /** + * The below defines will scale all the values to work properly on both + * 5V (Mega) and 3.3V (DUE) boards with all pull-up resistors added for 3.3V + */ + + #define ADC_BUTTONS_VALUE_SCALE (5.0/AREF_VOLTS) // The LCD module pullup voltage is 5.0V but ADC reference voltage is 3.3V + + #define ADC_BUTTONS_R_PULLDOWN 4.7 // Moves voltage down to be below 3.3V instead of 5V + // the resistors values will be scaled because of 4.7K pulldown parallel resistor + #define _ADC_BUTTONS_R_SCALED(R) ((R) * (ADC_BUTTONS_R_PULLDOWN) / ((R) + ADC_BUTTONS_R_PULLDOWN)) + + // buttons pullup resistor + #define ADC_BUTTONS_R_PULLUP 4.7 // the resistor on the 2004 LCD panel + // buttons resistors with scaled values because of parallel pulldown resistor + #define ADC_BUTTONS_LEFT_R_PULLDOWN _ADC_BUTTONS_R_SCALED(0.47) + #define ADC_BUTTONS_RIGHT_R_PULLDOWN _ADC_BUTTONS_R_SCALED(4.7) + #define ADC_BUTTONS_UP_R_PULLDOWN _ADC_BUTTONS_R_SCALED(1.0) + #define ADC_BUTTONS_DOWN_R_PULLDOWN _ADC_BUTTONS_R_SCALED(10.0) + #define ADC_BUTTONS_MIDDLE_R_PULLDOWN _ADC_BUTTONS_R_SCALED(2.2) + +#endif // ZONESTAR_LCD + +/** + * RJ45 8 pins extruder connector + * + * 1 - GND (Please do not connect to the same GND as extruder heater to prevent ground offset voltage) + * 2 - thermistor + * 3 - SERVO PWM + * 4 - extruder heater + * 5 - FAN (print cooling) + * 6 - FAN (extruder cooling) + * 7 - Probe signal + * 8 - 5V + * + * Standard ethernet pairs: 1&2, 3&6, 4&5, 7&8 + * Use CAT7 cable to have all pairs shielded + */ diff --git a/src/pins/sam/pins_ALLIGATOR_R2.h b/src/pins/sam/pins_ALLIGATOR_R2.h new file mode 100644 index 0000000..70c3853 --- /dev/null +++ b/src/pins/sam/pins_ALLIGATOR_R2.h @@ -0,0 +1,157 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Alligator Board R2 + * https://reprap.org/wiki/Alligator_Board + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Alligator Board R2" + +// +// Servos +// +#define SERVO0_PIN 36 +#define SERVO1_PIN 40 +#define SERVO2_PIN 41 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_MIN_PIN 33 // PC1 +#define X_MAX_PIN 34 // PC2 +#define Y_MIN_PIN 35 // PC3 +#define Y_MAX_PIN 37 // PC5 +#define Z_MIN_PIN 38 // PC6 +#define Z_MAX_PIN 39 // PC7 + +// +// Steppers +// +#define X_STEP_PIN 96 // PB24 +#define X_DIR_PIN 2 // PB25 +#define X_ENABLE_PIN 24 // PA15, motor RESET pin + +#define Y_STEP_PIN 94 // PB22 +#define Y_DIR_PIN 95 // PB23 +#define Y_ENABLE_PIN 24 // PA15, motor RESET pin + +#define Z_STEP_PIN 98 // PC27 +#define Z_DIR_PIN 3 // PC28 +#define Z_ENABLE_PIN 24 // PA15, motor RESET pin + +#define E0_STEP_PIN 5 // PC25 +#define E0_DIR_PIN 4 // PC26 +#define E0_ENABLE_PIN 24 // PA15, motor RESET pin + +#define E1_STEP_PIN 28 // PD3 on piggy +#define E1_DIR_PIN 27 // PD2 on piggy +#define E1_ENABLE_PIN 24 // PA15, motor RESET pin + +#define E2_STEP_PIN 11 // PD7 on piggy +#define E2_DIR_PIN 29 // PD6 on piggy +#define E2_ENABLE_PIN 24 // PA15, motor RESET pin + +#define E3_STEP_PIN 30 // PD9 on piggy +#define E3_DIR_PIN 12 // PD8 on piggy +#define E3_ENABLE_PIN 24 // PA15, motor RESET pin + +// Microstepping pins - Mapping not from fastio.h (?) +#define X_MS1_PIN 99 // PC10 +#define Y_MS1_PIN 10 // PC29 +#define Z_MS1_PIN 44 // PC19 +#define E0_MS1_PIN 45 // PC18 + +//#define MOTOR_FAULT_PIN 22 // PB26 , motor X-Y-Z-E0 motor FAULT + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // Analog Input (PA24) +#define TEMP_1_PIN 2 // Analog Input (PA23 on piggy) +#define TEMP_2_PIN 3 // Analog Input (PA22 on piggy) +#define TEMP_3_PIN 4 // Analog Input (PA6 on piggy) +#define TEMP_BED_PIN 0 // Analog Input (PA16) + +// +// Heaters / Fans +// +// Note that on the Due pin A0 on the board is channel 2 on the ARM chip +#define HEATER_0_PIN 68 // PA1 +#define HEATER_1_PIN 8 // PC22 on piggy +#define HEATER_2_PIN 9 // PC21 on piggy +#define HEATER_3_PIN 97 // PC20 on piggy +#define HEATER_BED_PIN 69 // PA0 + +#ifndef FAN_PIN + #define FAN_PIN 92 // PA5 +#endif +#define FAN1_PIN 31 // PA7 + +// +// Misc. Functions +// +#define SDSS 77 // PA28 +#define SD_DETECT_PIN 87 // PA29 +#define LED_RED_PIN 40 // PC8 +#define LED_GREEN_PIN 41 // PC9 + +#define EXP_VOLTAGE_LEVEL_PIN 65 + +#define SPI_CHAN_DAC 1 + +#define DAC0_SYNC_PIN 53 // PB14 +#define DAC1_SYNC_PIN 6 // PC24 + +// 64K SPI EEPROM +#define SPI_EEPROM +#define SPI_CHAN_EEPROM1 2 +#define SPI_EEPROM1_CS_PIN 25 // PD0 + +// 2K SPI EEPROM +#define SPI_EEPROM2_CS_PIN 26 // PD1 + +// FLASH SPI +// 32Mb +#define SPI_FLASH_CS_PIN 23 // PA14 + +// +// LCD / Controller +// +#if IS_RRD_FG_SC + #define LCD_PINS_RS 18 + #define LCD_PINS_ENABLE 15 + #define LCD_PINS_D4 19 + #define BEEPER_PIN 64 + #undef UI_VOLTAGE_LEVEL + #define UI_VOLTAGE_LEVEL 1 +#endif + +#if IS_NEWPANEL + #define BTN_EN1 14 + #define BTN_EN2 16 + #define BTN_ENC 17 +#endif diff --git a/src/pins/sam/pins_ARCHIM1.h b/src/pins/sam/pins_ARCHIM1.h new file mode 100644 index 0000000..d9f1dcb --- /dev/null +++ b/src/pins/sam/pins_ARCHIM1.h @@ -0,0 +1,205 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * ARCHIM1 pin assignment + * + * The Archim 1.0 board requires Arduino Archim addons installed. + * + * - Add the following URL to Arduino IDE's Additional Board Manager URLs: + * https://raw.githubusercontent.com/ultimachine/ArduinoAddons/master/package_ultimachine_index.json + * + * - In the Arduino IDE Board Manager search for Archim and install the package. + * + * - Change your target board to "Archim". + * + * Further information on the UltiMachine website... + * https://github.com/ultimachine/Archim/wiki + */ + +#if NOT_TARGET(__SAM3X8E__) + #error "Oops! Select 'Archim' in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "Archim 1.0" + +// +// Timers +// +#define MF_TIMER_STEP 3 +#define HAL_STEP_TIMER_ISR() void TC3_Handler() + +// +// Items marked * have been altered from Archim v1.0 +// + +// +// Servos +// +#define SERVO0_PIN 20 // D20 PB12 (Header J20 20) +#define SERVO1_PIN 21 // D21 PB13 (Header J20 19) + +// +// Limit Switches +// +#define X_MIN_PIN 14 // PD4 MIN ES1 +#define X_MAX_PIN 32 // PD10 MAX ES1 +#define Y_MIN_PIN 29 // PD6 MIN ES2 +#define Y_MAX_PIN 15 // PD5 MAX ES2 +#define Z_MIN_PIN 31 // PA7 MIN ES3 +#define Z_MAX_PIN 30 // PD9 MAX ES3 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 66 // D66 PB15 (Header J20 15) +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN 67 // D67 PB16 (Header J20 16) +#endif + +// +// Steppers +// +#define X_STEP_PIN 40 // PC8 STEP1 * +#define X_DIR_PIN 59 // PA4 DIR1 * +#define X_ENABLE_PIN 41 // PC9 EN1 + +#define Y_STEP_PIN 49 // PC14 STEP2 * +#define Y_DIR_PIN 47 // PC16 DIR2 * +#define Y_ENABLE_PIN 48 // PC15 EN2 * + +#define Z_STEP_PIN 36 // PC4 STEP Z * +#define Z_DIR_PIN 107 // PB10 DIR Z * +#define Z_ENABLE_PIN 96 // PC10 EN Z -AddOns * + +#define E0_STEP_PIN 78 // PB23 STEP3 * +#define E0_DIR_PIN 22 // PB26 DIR3 * +#define E0_ENABLE_PIN 97 // PB24 EN3 -Addons * + +#define E1_STEP_PIN 26 // PD1 STEP4 * +#define E1_DIR_PIN 27 // PD2 DIR4 * +#define E1_ENABLE_PIN 28 // PD3 EN4 * + +// Microstepping mode pins * +#define X_MS1_PIN 39 // PC7 MOD0E1 - As listed in schematic +#define X_MS2_PIN 38 // PC6 MOD1E1 +#define X_MS3_PIN 37 // PC5 MOD2E1 + +#define Y_MS1_PIN 50 // PC13 MODE0E2 +#define Y_MS2_PIN 51 // PC12 MODE1E2 +#define Y_MS3_PIN 92 // PC11 MODE2E2 - AddOns + +#define Z_MS1_PIN 44 // PC19 MOD0E Z +#define Z_MS2_PIN 45 // PC18 MOD1E Z +#define Z_MS3_PIN 46 // PC17 MOD2E Z + +#define E0_MS1_PIN 105 // PB22 MOD0E3 - AddOns +#define E0_MS2_PIN 106 // PC27 MOD1E3 - AddOns +#define E0_MS3_PIN 104 // PC20 MOD2E3 - AddOns + +#define E1_MS1_PIN 25 // PD0 MOD0E4 +#define E1_MS2_PIN 18 // PA11 MOD1E4 +#define E1_MS3_PIN 19 // PA10 MOD2E4 + +// Motor current PWM pins * +#define MOTOR_CURRENT_PWM_X_PIN 58 // PA6 X-REF TIOB2 +#define MOTOR_CURRENT_PWM_Y_PIN 12 // PD8 Y-REF TIOB8 +#define MOTOR_CURRENT_PWM_Z_PIN 10 // PC29 Z-REF TIOB7 +#define MOTOR_CURRENT_PWM_E0_PIN 3 // PC28 E1-REF TIOA7 +#define MOTOR_CURRENT_PWM_E1_PIN 11 // PD7 E2-REF TIOA8 + +#define MOTOR_CURRENT_PWM_RANGE 2750 // (3.3 Volts * 100000 Ohms) / (100000 Ohms + 20000 Ohms) = 2.75 Volts (max vref) +#define DEFAULT_PWM_MOTOR_CURRENT { 1000, 1000, 1000 } //, 1000, 1000} // X Y Z E0 E1, 1000 = 1000mAh + +// +// Temperature Sensors +// +#define TEMP_0_PIN 10 // D10 PB19 THERM AN1 * +#define TEMP_1_PIN 9 // D9 PB18 THERM AN2 * +#define TEMP_2_PIN 8 // D8 PB17 THERM AN4 * +#define TEMP_BED_PIN 11 // D11 PB20 THERM AN3 * + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 // D6 PC24 FET_PWM3 +#define HEATER_1_PIN 7 // D7 PC23 FET_PWM4 +#define HEATER_2_PIN 8 // D8 PC22 FET_PWM5 +#define HEATER_BED_PIN 9 // D9 PC21 BED_PWM + +#ifndef FAN_PIN + #define FAN_PIN 4 // D4 PC26 FET_PWM1 +#endif +#define FAN1_PIN 5 // D5 PC25 FET_PWM2 + +// +// Misc. Functions +// + +// Internal MicroSD card reader on the PCB +#define INT_SCK_PIN 42 // D42 PA19/MCCK +#define INT_MISO_PIN 43 // D43 PA20/MCCDA +#define INT_MOSI_PIN 73 // D73 PA21/MCDA0 +#define INT_SDSS 55 // D55 PA24/MCDA3 + +// External SD card reader on SC2 +#define SD_SCK_PIN 76 // D76 PA27 +#define SD_MISO_PIN 74 // D74 PA25 +#define SD_MOSI_PIN 75 // D75 PA26 +#define SDSS 87 // D87 PA29 + +// 2MB SPI Flash +#define SPI_FLASH_SS 52 // D52 PB21 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BEEPER_PIN 23 // D24 PA15_CTS1 + #define LCD_PINS_RS 17 // D17 PA12_RXD1 + #define LCD_PINS_ENABLE 24 // D23 PA14_RTS1 + #define LCD_PINS_D4 69 // D69 PA0_CANTX0 + #define LCD_PINS_D5 54 // D54 PA16_SCK1 + #define LCD_PINS_D6 68 // D68 PA1_CANRX0 + #define LCD_PINS_D7 34 // D34 PC2_PWML0 + + #define SD_DETECT_PIN 2 // D2 PB25_TIOA0 + + #if IS_NEWPANEL + // Buttons on AUX-2 + #define BTN_EN1 60 // D60 PA3_TIOB1 + #define BTN_EN2 13 // D13 PB27_TIOB0 + #define BTN_ENC 16 // D16 PA13_TXD1 + #endif // IS_NEWPANEL + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/sam/pins_ARCHIM2.h b/src/pins/sam/pins_ARCHIM2.h new file mode 100644 index 0000000..310dd8e --- /dev/null +++ b/src/pins/sam/pins_ARCHIM2.h @@ -0,0 +1,262 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * ARCHIM2 pin assignment + * + * The Archim 2.0 board requires Arduino Archim addons installed. + * + * - Add the following URL to Arduino IDE's Additional Board Manager URLs: + * https://raw.githubusercontent.com/ultimachine/ArduinoAddons/master/package_ultimachine_index.json + * + * - In the Arduino IDE Board Manager search for Archim and install the package. + * + * - Change your target board to "Archim". + * + * Further information on the UltiMachine website... + * https://github.com/ultimachine/Archim/wiki + */ + +#if NOT_TARGET(__SAM3X8E__) + #error "Oops! Select 'Archim' in 'Tools > Board.'" +#elif DISABLED(TMC_USE_SW_SPI) + #error "Archim2 requires Software SPI. Enable TMC_USE_SW_SPI in Configuration_adv.h." +#endif + +#define BOARD_INFO_NAME "Archim 2.0" + +// +// Items marked * have been altered from Archim v1.0 +// + +// +// Servos +// +#define SERVO0_PIN 20 // D20 PB12 (Header J20 20) +#define SERVO1_PIN 21 // D21 PB13 (Header J20 19) + +// +// Limit Switches +// + +#if ENABLED(SENSORLESS_HOMING) + + // Only use Diag Pins when SENSORLESS_HOMING is enabled for the TMC2130 drivers. + // Otherwise use a physical endstop based configuration. + + // TMC2130 Diag Pins + #define X_DIAG_PIN 59 // PA4 + #define Y_DIAG_PIN 48 // PC15 + #define Z_DIAG_PIN 36 // PC4 + #define E0_DIAG_PIN 78 // PB23 + #define E1_DIAG_PIN 25 // PD0 + + #if X_HOME_TO_MIN + #define X_MIN_PIN X_DIAG_PIN + #define X_MAX_PIN 32 + #else + #define X_MIN_PIN 14 + #define X_MAX_PIN X_DIAG_PIN + #endif + + #if Y_HOME_TO_MIN + #define Y_MIN_PIN Y_DIAG_PIN + #define Y_MAX_PIN 15 + #else + #define Y_MIN_PIN 29 + #define Y_MAX_PIN Y_DIAG_PIN + #endif + +#else + + #define X_MIN_PIN 14 // PD4 MIN ES1 + #define X_MAX_PIN 32 // PD10 MAX ES1 + #define Y_MIN_PIN 29 // PD6 MIN ES2 + #define Y_MAX_PIN 15 // PD5 MAX ES2 + +#endif + +#define Z_MIN_PIN 31 // PA7 MIN ES3 +#define Z_MAX_PIN 30 // PD9 MAX ES3 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 38 // PC6 X-STEP * +#define X_DIR_PIN 37 // PC5 X-DIR * +#define X_ENABLE_PIN 41 // PC9 EN1 +#ifndef X_CS_PIN + #define X_CS_PIN 39 // PC7 X_nCS +#endif + +#define Y_STEP_PIN 51 // PC12 Y-STEP * +#define Y_DIR_PIN 92 // PC11 Y-DIR -AddOns * +#define Y_ENABLE_PIN 49 // PC14 Y-EN * +#ifndef Y_CS_PIN + #define Y_CS_PIN 50 // PC13 Y_nCS +#endif + +#define Z_STEP_PIN 46 // PC17 Z-STEP * +#define Z_DIR_PIN 47 // PC16 Z-DIR * +#define Z_ENABLE_PIN 44 // PC19 Z-END * +#ifndef Z_CS_PIN + #define Z_CS_PIN 45 // PC18 Z_nCS +#endif + +#define E0_STEP_PIN 107 // PB10 E1-STEP -AddOns * +#define E0_DIR_PIN 96 // PC10 E1-DIR -AddOns * +#define E0_ENABLE_PIN 105 // PB22 E1-EN -AddOns * +#ifndef E0_CS_PIN + #define E0_CS_PIN 104 // PC20 E1_nCS -AddOns * +#endif + +#define E1_STEP_PIN 22 // PB26 E2_STEP * +#define E1_DIR_PIN 97 // PB24 E2_DIR -AddOns * +#define E1_ENABLE_PIN 18 // PA11 E2-EN +#ifndef E1_CS_PIN + #define E1_CS_PIN 19 // PA10 E2_nCS +#endif + +// +// Software SPI pins for TMC2130 stepper drivers. +// Required for the Archim2 board. +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI 28 // PD3 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO 26 // PD1 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK 27 // PD2 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 10 // D10 PB19 THERM AN1 * +#define TEMP_1_PIN 9 // D9 PB18 THERM AN2 * +#define TEMP_2_PIN 8 // D8 PB17 THERM AN4 * +#define TEMP_BED_PIN 11 // D11 PB20 THERM AN3 * + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 // D6 PC24 FET_PWM3 +#define HEATER_1_PIN 7 // D7 PC23 FET_PWM4 +#define HEATER_2_PIN 8 // D8 PC22 FET_PWM5 +#define HEATER_BED_PIN 9 // D9 PC21 BED_PWM + +#ifndef FAN_PIN + #define FAN_PIN 4 // D4 PC26 FET_PWM1 +#endif +#define FAN1_PIN 5 // D5 PC25 FET_PWM2 + +// +// Misc. Functions +// + +// Internal MicroSD card reader on the PCB +#define INT_SCK_PIN 42 // D42 PA19/MCCK +#define INT_MISO_PIN 43 // D43 PA20/MCCDA +#define INT_MOSI_PIN 73 // D73 PA21/MCDA0 +#define INT_SDSS 55 // D55 PA24/MCDA3 + +// External SD card reader on SC2 +#define SD_SCK_PIN 76 // D76 PA27 +#define SD_MISO_PIN 74 // D74 PA25 +#define SD_MOSI_PIN 75 // D75 PA26 +#define SDSS 87 // D87 PA29 + +// Unused Digital GPIO J20 Pins +#define GPIO_PB1_J20_5 94 // D94 PB1 (Header J20 5) +#define GPIO_PB0_J20_6 95 // D95 PB0 (Header J20 6) +#define GPIO_PB3_J20_7 103 // D103 PB3 (Header J20 7) +#define GPIO_PB2_J20_8 93 // D93 PB2 (Header J20 8) +#define GPIO_PB6_J20_9 99 // D99 PB6 (Header J20 9) +#define GPIO_PB5_J20_10 101 // D101 PB5 (Header J20 10) +#define GPIO_PB8_J20_11 100 // D100 PB8 (Header J20 11) +#define GPIO_PB4_J20_12 102 // D102 PB4 (Header J20 12) +#define GPIO_PB9_J20_13 108 // D108 PB9 (Header J20 13) +#define GPIO_PB7_J20_14 98 // D98 PB7 (Header J20 14) +#define GPIO_PB15_J20_15 66 // D66 PB15 (Header J20 15) +#define GPIO_PB16_J20_16 67 // D67 PB16 (Header J20 16) +#define GPIO_PB14_J20_17 53 // D53 PB14 (Header J20 17) +#define GPIO_PA18_J20_21 71 // D71 PA17 (Header J20 21) +#define GPIO_PA17_J20_22 70 // D70 PA17 (Header J20 22) + +// Case Light + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN GPIO_PB1_J20_5 +#endif + +// 2MB SPI Flash +#define SPI_FLASH_SS 52 // D52 PB21 + +// +// Filament Runout Sensor +// + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN GPIO_PB15_J20_15 +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN GPIO_PB16_J20_16 +#endif + +// +// LCD / Controller +// +#if ANY(HAS_WIRED_LCD, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) + #define BEEPER_PIN 23 // D24 PA15_CTS1 + #define LCD_PINS_RS 17 // D17 PA12_RXD1 + #define LCD_PINS_ENABLE 24 // D23 PA14_RTS1 + #define LCD_PINS_D4 69 // D69 PA0_CANTX0 + #define LCD_PINS_D5 54 // D54 PA16_SCK1 + #define LCD_PINS_D6 68 // D68 PA1_CANRX0 + #define LCD_PINS_D7 34 // D34 PC2_PWML0 +#endif + +#if ANY(IS_ULTIPANEL, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) + // Buttons on AUX-2 + #define BTN_EN1 60 // D60 PA3_TIOB1 + #define BTN_EN2 13 // D13 PB27_TIOB0 + #define BTN_ENC 16 // D16 PA13_TXD1 // the click +#endif + +#if ANY(HAS_WIRED_LCD, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE, USB_FLASH_DRIVE_SUPPORT) + #define SD_DETECT_PIN 2 // D2 PB25_TIOA0 + #if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #define DISABLE_DUE_SD_MMC + #endif +#endif diff --git a/src/pins/sam/pins_CNCONTROLS_15D.h b/src/pins/sam/pins_CNCONTROLS_15D.h new file mode 100644 index 0000000..d44f649 --- /dev/null +++ b/src/pins/sam/pins_CNCONTROLS_15D.h @@ -0,0 +1,137 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * CNControls V15 for HMS434 with DUE pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "CN Controls V15D" + +// +// Servos +// +#define SERVO0_PIN 6 + +// +// Limit Switches +// +#define X_STOP_PIN 34 +#define Y_STOP_PIN 39 +#define Z_STOP_PIN 62 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 49 +#endif + +// +// Steppers +// +#define X_STEP_PIN 14 +#define X_DIR_PIN 25 +#define X_ENABLE_PIN 26 + +#define Y_STEP_PIN 11 +#define Y_DIR_PIN 12 +#define Y_ENABLE_PIN 15 + +#define Z_STEP_PIN 24 +#define Z_DIR_PIN 27 +#define Z_ENABLE_PIN 28 + +#define E0_STEP_PIN 64 +#define E0_DIR_PIN 65 +#define E0_ENABLE_PIN 63 + +#define E1_STEP_PIN 8 +#define E1_DIR_PIN 7 +#define E1_ENABLE_PIN 29 + +// +// Temperature Sensors +// Analog Inputs +// +#define TEMP_0_PIN 1 +#define TEMP_1_PIN 2 +#define TEMP_BED_PIN 4 + +#ifndef TEMP_CHAMBER_PIN + #define TEMP_CHAMBER_PIN 5 +#endif + +// +// Heaters +// +#define HEATER_0_PIN 3 +#define HEATER_1_PIN 4 +#define HEATER_BED_PIN 32 +#define HEATER_CHAMBER_PIN 33 + +// +// Fans +// +//#define FAN_PIN 8 + +// +// Auto fans +// +#define AUTO_FAN_PIN 30 +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E3_AUTO_FAN_PIN + #define E3_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef CHAMBER_AUTO_FAN_PIN + #define CHAMBER_AUTO_FAN_PIN 10 +#endif + +// +// SD card +// +#define SD_SCK_PIN 76 +#define SD_MISO_PIN 74 +#define SD_MOSI_PIN 75 +#define SDSS 53 +#define SD_DETECT_PIN 40 + +// Common I/O + +//#define PWM_1_PIN 6 // probe +//#define PWM_2_PIN 13 +//#define SPARE_IO 17 +#define BEEPER_PIN 13 +#define STAT_LED_BLUE_PIN -1 +#define STAT_LED_RED_PIN 31 + +// G425 CALIBRATION_GCODE default pin +#ifndef CALIBRATION_PIN + #define CALIBRATION_PIN 66 +#endif diff --git a/src/pins/sam/pins_DUE3DOM.h b/src/pins/sam/pins_DUE3DOM.h new file mode 100644 index 0000000..81eca3e --- /dev/null +++ b/src/pins/sam/pins_DUE3DOM.h @@ -0,0 +1,171 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * DUE3DOM pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "DUE3DOM" + +// +// Servos +// +#define SERVO0_PIN 5 +#define SERVO1_PIN 6 +#define SERVO2_PIN 13 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_MIN_PIN 38 +#define X_MAX_PIN 36 +#define Y_MIN_PIN 34 +#define Y_MAX_PIN 32 +#define Z_MIN_PIN 30 +#define Z_MAX_PIN 28 + +// +// Steppers +// +#define X_STEP_PIN 2 +#define X_DIR_PIN 3 +#define X_ENABLE_PIN 22 + +#define Y_STEP_PIN 17 +#define Y_DIR_PIN 16 +#define Y_ENABLE_PIN 26 + +#define Z_STEP_PIN 61 // Z1 STP +#define Z_DIR_PIN 60 // Z1 DIR +#define Z_ENABLE_PIN 15 // Z1 ENA + +#define E0_STEP_PIN 64 // Z2 STP +#define E0_DIR_PIN 63 // Z2 DIR +#define E0_ENABLE_PIN 62 // Z2 ENA + +#define E1_STEP_PIN 51 // E1 STP +#define E1_DIR_PIN 53 // E1 DIR +#define E1_ENABLE_PIN 65 // E1 ENA + +#define E2_STEP_PIN 24 // E2 STP +#define E2_DIR_PIN 23 // E2 DIR +#define E2_ENABLE_PIN 49 // E2 ENA + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input (HOTEND0 thermistor) +#define TEMP_1_PIN 2 // Analog Input (HOTEND1 thermistor) +#define TEMP_2_PIN 5 // Analog Input (unused) +#define TEMP_BED_PIN 1 // Analog Input (BED thermistor) + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN -1 +#else + #define TEMP_0_CS_PIN -1 +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 7 // HOTEND0 MOSFET +#define HEATER_1_PIN 8 // HOTEND1 MOSFET +#define HEATER_BED_PIN 39 // BED MOSFET + +#ifndef FAN_PIN + #define FAN_PIN 11 // FAN1 header on board - PRINT FAN +#endif +#define FAN1_PIN 9 // FAN2 header on board - CONTROLLER FAN +#define FAN2_PIN 12 // FAN3 header on board - EXTRUDER0 FAN + +// +// Misc. Functions +// +#define SDSS 4 +#define PS_ON_PIN 40 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #define LCD_PINS_RS 42 + #define LCD_PINS_ENABLE 43 + #define LCD_PINS_D4 44 + #define LCD_PINS_D5 45 + #define LCD_PINS_D6 46 + #define LCD_PINS_D7 47 + + #if IS_RRD_SC + + #define BEEPER_PIN 41 + + #define BTN_EN1 50 + #define BTN_EN2 52 + #define BTN_ENC 48 + + #define SD_DETECT_PIN 14 + + #elif ENABLED(RADDS_DISPLAY) + + #define BEEPER_PIN 41 + + #define BTN_EN1 50 + #define BTN_EN2 52 + #define BTN_ENC 48 + + #define BTN_BACK 71 + + #define SD_DETECT_PIN 14 + + #elif HAS_U8GLIB_I2C_OLED + + #define BTN_EN1 50 + #define BTN_EN2 52 + #define BTN_ENC 48 + #define BEEPER_PIN 41 + #define LCD_SDSS 4 + #define SD_DETECT_PIN 14 + + #elif ENABLED(SPARK_FULL_GRAPHICS) + + #define LCD_PINS_D4 29 + #define LCD_PINS_ENABLE 27 + #define LCD_PINS_RS 25 + + #define BTN_EN1 35 + #define BTN_EN2 33 + #define BTN_ENC 37 + + #define BEEPER_PIN -1 + #endif // SPARK_FULL_GRAPHICS + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/sam/pins_DUE3DOM_MINI.h b/src/pins/sam/pins_DUE3DOM_MINI.h new file mode 100644 index 0000000..7754fa9 --- /dev/null +++ b/src/pins/sam/pins_DUE3DOM_MINI.h @@ -0,0 +1,172 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * DUE3DOM MINI pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "DUE3DOM MINI" + +// +// Servos +// +#define SERVO0_PIN 5 +#define SERVO1_PIN 6 +#define SERVO2_PIN 8 // 4-pin header FAN0 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_STOP_PIN 38 +#define Y_STOP_PIN 34 +#define Z_STOP_PIN 30 + +// +// Steppers +// +#define X_STEP_PIN 17 +#define X_DIR_PIN 16 +#define X_ENABLE_PIN 22 + +#define Y_STEP_PIN 2 +#define Y_DIR_PIN 3 +#define Y_ENABLE_PIN 26 + +#define Z_STEP_PIN 64 +#define Z_DIR_PIN 63 +#define Z_ENABLE_PIN 15 + +#define E0_STEP_PIN 61 +#define E0_DIR_PIN 60 +#define E0_ENABLE_PIN 62 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input (HOTEND0 thermistor) +#define TEMP_1_PIN 2 // Analog Input (unused) +#define TEMP_BED_PIN 1 // Analog Input (BED thermistor) +#define TEMP_BOARD_PIN 5 // Analog Input (OnBoard thermistor beta 3950) + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 53 +#else + #define TEMP_0_CS_PIN 53 +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 13 // HOTEND0 MOSFET +#define HEATER_BED_PIN 7 // BED MOSFET + +#ifndef FAN_PIN + #define FAN_PIN 11 // FAN1 header on board - PRINT FAN +#endif +#define FAN1_PIN 12 // FAN2 header on board - CONTROLLER FAN +#define FAN2_PIN 9 // FAN3 header on board - EXTRUDER0 FAN +//#define FAN3_PIN 8 // FAN0 4-pin header on board + +// +// Misc. Functions +// +#define SDSS 4 +#define PS_ON_PIN 40 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #define LCD_PINS_RS 42 + #define LCD_PINS_ENABLE 43 + #define LCD_PINS_D4 44 + #define LCD_PINS_D5 45 + #define LCD_PINS_D6 46 + #define LCD_PINS_D7 47 + + #if IS_RRD_SC + + #define BEEPER_PIN 41 + + #define BTN_EN1 50 + #define BTN_EN2 52 + #define BTN_ENC 48 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #define SD_DETECT_PIN 14 + + #elif ENABLED(RADDS_DISPLAY) + + #define BEEPER_PIN 41 + + #define BTN_EN1 50 + #define BTN_EN2 52 + #define BTN_ENC 48 + + #define BTN_BACK 71 + + #define SD_DETECT_PIN 14 + + #elif HAS_U8GLIB_I2C_OLED + + #define BTN_EN1 50 + #define BTN_EN2 52 + #define BTN_ENC 48 + #define BEEPER_PIN 41 + #define LCD_SDSS SDSS + #define SD_DETECT_PIN 14 + + #elif ENABLED(SPARK_FULL_GRAPHICS) + + #define LCD_PINS_D4 29 + #define LCD_PINS_ENABLE 27 + #define LCD_PINS_RS 25 + + #define BTN_EN1 35 + #define BTN_EN2 33 + #define BTN_ENC 37 + + #define BEEPER_PIN -1 + + #elif ENABLED(MINIPANEL) + + #define BTN_EN1 52 + #define BTN_EN2 50 + #define BTN_ENC 48 + #define LCD_SDSS SDSS + #define SD_DETECT_PIN 14 + #define BEEPER_PIN 41 + #define DOGLCD_A0 46 + #define DOGLCD_CS 45 + + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/sam/pins_KRATOS32.h b/src/pins/sam/pins_KRATOS32.h new file mode 100644 index 0000000..f7867f9 --- /dev/null +++ b/src/pins/sam/pins_KRATOS32.h @@ -0,0 +1,179 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * KRATOS32 + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "K.3D KRATOS32" + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x1F400 // 16K +#endif + +// +// Servos +// +#define SERVO0_PIN 6 +#define SERVO1_PIN 5 +#define SERVO2_PIN 39 +#define SERVO3_PIN 40 // CAMERA_PIN (extended to the top of the LCD module) +#define SERVO4_PIN 45 // FIL_RUNOUT_PIN + +// +// Limit Switches +// +#define X_MIN_PIN 28 +#define X_MAX_PIN 34 +#define Y_MIN_PIN 30 +#define Y_MAX_PIN 36 +#define Z_MIN_PIN 32 +#define Z_MAX_PIN 38 + +// +// Steppers +// +#define X_STEP_PIN 24 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 26 +#ifndef X_CS_PIN + #define X_CS_PIN 25 +#endif + +#define Y_STEP_PIN 17 +#define Y_DIR_PIN 16 +#define Y_ENABLE_PIN 22 +#ifndef Y_CS_PIN + #define Y_CS_PIN 27 +#endif + +#define Z_STEP_PIN 2 +#define Z_DIR_PIN 3 +#define Z_ENABLE_PIN 15 +#ifndef Z_CS_PIN + #define Z_CS_PIN 29 +#endif + +#define E0_STEP_PIN 61 +#define E0_DIR_PIN 60 +#define E0_ENABLE_PIN 62 +#ifndef E0_CS_PIN + #define E0_CS_PIN 31 +#endif + +#define E1_STEP_PIN 64 +#define E1_DIR_PIN 63 +#define E1_ENABLE_PIN 65 +#ifndef E1_CS_PIN + #define E1_CS_PIN 37 +#endif + +#define E2_STEP_PIN 68 +#define E2_DIR_PIN 67 +#define E2_ENABLE_PIN 69 +#ifndef E2_CS_PIN + #define E2_CS_PIN 35 +#endif + +#define E3_STEP_PIN 51 +#define E3_DIR_PIN 53 +#define E3_ENABLE_PIN 49 +#ifndef E3_CS_PIN + #define E3_CS_PIN 33 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 1 // Analog Input +#define TEMP_2_PIN 2 // Analog Input +#define TEMP_3_PIN 3 // Analog Input +#define TEMP_BED_PIN 4 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 13 +#define HEATER_1_PIN 12 +#define HEATER_2_PIN 11 +#define HEATER_3_PIN 10 +#define HEATER_BED_PIN 7 // BED + +#ifndef FAN_PIN + #define FAN_PIN 9 +#endif +#define FAN1_PIN 8 + +// +// Misc. Functions +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 45 // SERVO4_PIN +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN 59 +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #define BTN_EN1 48 + #define BTN_EN2 50 + #define BTN_ENC 46 + + #define SDSS 4 + #define SD_DETECT_PIN 14 + + #define BEEPER_PIN 41 + #define KILL_PIN 66 + + #if IS_RRD_FG_SC + + #define LCD_PINS_RS 42 + #define LCD_PINS_ENABLE 43 + #define LCD_PINS_D4 44 + + #define BTN_BACK 52 + + #elif ENABLED(K3D_242_OLED_CONTROLLER) + + #define LCD_PINS_DC 44 + #define LCD_PINS_RS 42 + #define DOGLCD_CS 52 + #define DOGLCD_MOSI 43 + #define DOGLCD_SCK 47 + #define DOGLCD_A0 LCD_PINS_DC + + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/sam/pins_PRINTRBOARD_G2.h b/src/pins/sam/pins_PRINTRBOARD_G2.h new file mode 100644 index 0000000..aa01a92 --- /dev/null +++ b/src/pins/sam/pins_PRINTRBOARD_G2.h @@ -0,0 +1,171 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * PRINTRBOARD_G2 + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Printrboard G2" +#endif + +// +// Servos +// +//#define SERVO0_PIN -1 +//#define SERVO1_PIN -1 + +// +// Limit Switches +// +#define X_STOP_PIN 22 // PB26 +#define Y_STOP_PIN 18 // PA11 +#define Z_STOP_PIN 19 // PA10 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 22 +#endif + +#ifndef FIL_RUNOUT_PIN + //#define FIL_RUNOUT_PIN 57 // PA22 +#endif +#ifndef FIL_RUNOUT2_PIN + //#define FIL_RUNOUT2_PIN 21 // PB13 +#endif + +// +// LED defines +// +//#define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) +//#define NEOPIXEL_PIN 20 // LED driving pin on motherboard +//#define NEOPIXEL_PIXELS 3 // Number of LEDs in the strip +//#define SDA0 20 // PB12 NeoPixel pin I2C data +//#define SCL0 21 // PB13 I2C clock + +// D0_12 #REF! (INDICATOR_LED) +// B28 JTAG-CLK +// B31 JTAG_TMS /SWD_DIO +//A18 INTERRUPT_OUT +//A12 USART_RX not used +//A13 USART_TX not used +//A14 UART_RTS +//A15 UART_CTS +//PB2 Unassigned +//PB4 to PB9 Unassigned +//#define UART_RX_PIN 0 // PA8 "RX0" +//#define UART_TX_PIN 1 // PA9 "TX0" +//#define UART_RTS_PIN 23 // PA14 +//#define UART_CTS_PIN 24 // PA15 + +// +// Steppers +// +#define Z_STEP_PIN 73 // PA21 MOTOR 1 +#define Z_DIR_PIN 75 // PA26 +#define Z_ENABLE_PIN 74 // PA25 + +#define X_STEP_PIN 66 // PB15 MOTOR 2 +#define X_DIR_PIN 54 // PA16 +#define X_ENABLE_PIN 67 // PB16 + +#define Y_STEP_PIN 34 // PA29 MOTOR 3 +#define Y_DIR_PIN 35 // PB1 +#define Y_ENABLE_PIN 36 // PB0 + +#define E0_STEP_PIN 53 // PB14 MOTOR 4 +#define E0_DIR_PIN 78 // PB23 +#define E0_ENABLE_PIN 37 // PB22 + +// Microstepping mode pins +#define Z_MS1_PIN 52 // PB21 MODE0 MOTOR 1 +#define Z_MS2_PIN 52 // PB21 MODE1 +#define Z_MS3_PIN 65 // PB20 MODE2 + +#define X_MS1_PIN 43 // PA20 MODE0 MOTOR 2 +#define X_MS2_PIN 43 // PA20 MODE1 +#define X_MS3_PIN 42 // PA19 MODE2 + +#define Y_MS1_PIN 77 // PA28 MODE0 MOTOR 3 +#define Y_MS2_PIN 77 // PA28 MODE1 +#define Y_MS3_PIN 76 // PA27 MODE2 + +#define E0_MS1_PIN 38 // PB11 MODE0 MOTOR 4 +#define E0_MS2_PIN 38 // PB11 MODE1 +#define E0_MS3_PIN 39 // PB10 MODE2 + +// Motor current PWM pins +#define MOTOR_CURRENT_PWM_X_PIN 62 // PB17 MOTOR 1 +#define MOTOR_CURRENT_PWM_Z_PIN 63 // PB18 MOTOR 2 +#define MOTOR_CURRENT_PWM_Y_PIN 64 // PB19 MOTOR 3 +#define MOTOR_CURRENT_PWM_E_PIN 61 // PA2 MOTOR 4 + +#define DEFAULT_PWM_MOTOR_CURRENT { 300, 400, 1000} // XY Z E0, 1000 = 1000mAh + +// +// Temperature Sensors +// +#define TEMP_0_PIN 2 // digital 56 PA23 +#define TEMP_BED_PIN 5 // digital 59 PA4 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 40 // PA5 +#define HEATER_BED_PIN 41 // PB24 + +#ifndef FAN_PIN + #define FAN_PIN 13 // PB27 Fan1A +#endif +#define FAN1_PIN 58 // PA6 Fan1B + +#define FET_SAFETY_PIN 31 // PA7 must be pulsed low every 50 mS or FETs are turned off +#define FET_SAFETY_DELAY 50 // 50 mS delay between pulses +#define FET_SAFETY_INVERTED true // true - negative going pulse of 2 uS + +///////////////////////////////////////////////////////// + +#define SD_MISO_PIN 68 // set to unused pins for now +#define SD_MOSI_PIN 69 // set to unused pins for now +#define SD_SCK_PIN 70 // set to unused pins for now +#define SDSS 71 // set to unused pins for now + +/** + * G2 uses 8 pins that are not available in the DUE environment: + * 34 PA29 - Y_STEP_PIN + * 35 PB1 - Y_DIR_PIN + * 36 PB0 - Y_ENABLE_PIN + * 37 PB22 - E0_ENABLE_PIN + * 38 PB11 - E0_MS1_PIN - normally used by the USB native port + * 39 PB10 - E0_MS3_PIN - normally used by the USB native port + * 40 PA5 - HEATER_0_PIN + * 41 PB24 - HEATER_BED_PIN + * + * None of these are in the arduino_due_x variant so digitalWrite and digitalRead can't be used on them. + * + * They can be accessed via FASTIO functions WRITE, READ, OUT_WRITE, OUTPUT, ... + */ diff --git a/src/pins/sam/pins_RADDS.h b/src/pins/sam/pins_RADDS.h new file mode 100644 index 0000000..af24014 --- /dev/null +++ b/src/pins/sam/pins_RADDS.h @@ -0,0 +1,296 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * RADDS + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "RADDS" + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x2000 // 8K +#endif + +// +// Servos +// +#if !HAS_CUTTER + #define SERVO0_PIN 5 +#endif +#define SERVO1_PIN 6 +#define SERVO2_PIN 39 +#define SERVO3_PIN 40 + +// +// Limit Switches +// +#define X_MIN_PIN 28 +#define X_MAX_PIN 34 +#define Y_MIN_PIN 30 +#define Y_MAX_PIN 36 +#define Z_MIN_PIN 32 +#define Z_MAX_PIN 38 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 38 +#endif + +// +// Steppers +// +#define X_STEP_PIN 24 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 26 +#ifndef X_CS_PIN + #define X_CS_PIN 25 +#endif + +#define Y_STEP_PIN 17 +#define Y_DIR_PIN 16 +#define Y_ENABLE_PIN 22 +#ifndef Y_CS_PIN + #define Y_CS_PIN 27 +#endif + +#define Z_STEP_PIN 2 +#define Z_DIR_PIN 3 +#define Z_ENABLE_PIN 15 +#ifndef Z_CS_PIN + #define Z_CS_PIN 29 +#endif + +#define E0_STEP_PIN 61 +#define E0_DIR_PIN 60 +#define E0_ENABLE_PIN 62 +#ifndef E0_CS_PIN + #define E0_CS_PIN 31 +#endif + +#define E1_STEP_PIN 64 +#define E1_DIR_PIN 63 +#define E1_ENABLE_PIN 65 +#ifndef E1_CS_PIN + #define E1_CS_PIN 33 +#endif + +#define E2_STEP_PIN 51 +#define E2_DIR_PIN 53 +#define E2_ENABLE_PIN 49 +#ifndef E2_CS_PIN + #define E2_CS_PIN 35 +#endif + +/** + * RADDS Extension Board V2 / V3 + * http://doku.radds.org/dokumentation/extension-board + */ +//#define RADDS_EXTENSION 2 +#if RADDS_EXTENSION >= 2 + #define E3_DIR_PIN 33 + #define E3_STEP_PIN 35 + #define E3_ENABLE_PIN 37 + #ifndef E3_CS_PIN + #define E3_CS_PIN 6 + #endif + + #if RADDS_EXTENSION == 3 + + #define E4_DIR_PIN 27 + #define E4_STEP_PIN 29 + #define E4_ENABLE_PIN 31 + #ifndef E4_CS_PIN + #define E4_CS_PIN 39 + #endif + + #define E5_DIR_PIN 66 + #define E5_STEP_PIN 67 + #define E5_ENABLE_PIN 68 + #ifndef E5_CS_PIN + #define E5_CS_PIN 6 + #endif + + #define RADDS_EXT_MSI_PIN 69 + + #define BOARD_INIT() OUT_WRITE(RADDS_EXT_VDD_PIN, HIGH) + + #else + + #define E4_DIR_PIN 27 + #define E4_STEP_PIN 29 + #define E4_ENABLE_PIN 31 + #ifndef E4_CS_PIN + #define E4_CS_PIN 39 + #endif + + // E3 and E4 share the same MSx pins + #define E3_MS1_PIN 67 + #define E4_MS1_PIN 67 + #define E3_MS2_PIN 68 + #define E4_MS2_PIN 68 + #define E3_MS3_PIN 69 + #define E4_MS3_PIN 69 + + #define RADDS_EXT_VDD2_PIN 66 + + #define BOARD_INIT() do{ OUT_WRITE(RADDS_EXT_VDD_PIN, HIGH); OUT_WRITE(RADDS_EXT_VDD2_PIN, HIGH); }while(0) + + #endif + + #define RADDS_EXT_VDD_PIN 25 + +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 1 // Analog Input +#define TEMP_2_PIN 2 // Analog Input +#define TEMP_3_PIN 3 // Analog Input +#define TEMP_4_PIN 5 // dummy so will compile when PINS_DEBUGGING is enabled +#define TEMP_BED_PIN 4 // Analog Input + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 53 +#else + #define TEMP_0_CS_PIN 49 +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 13 +#define HEATER_1_PIN 12 +#define HEATER_2_PIN 11 +#if !HAS_CUTTER + #define HEATER_BED_PIN 7 // BED +#endif + +#ifndef FAN_PIN + #define FAN_PIN 9 +#endif +#define FAN1_PIN 8 + +// +// Misc. Functions +// +#define SD_DETECT_PIN 14 +#define PS_ON_PIN 40 // SERVO3_PIN + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 39 // SERVO2_PIN +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + #if !NUM_SERVOS + #define SPINDLE_LASER_PWM_PIN 5 // SERVO0_PIN + #endif + #define SPINDLE_LASER_ENA_PIN 7 // HEATER_BED_PIN - Pullup/down! +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if ENABLED(RADDS_DISPLAY) + + #define LCD_PINS_RS 42 + #define LCD_PINS_ENABLE 43 + #define LCD_PINS_D4 44 + #define LCD_PINS_D5 45 + #define LCD_PINS_D6 46 + #define LCD_PINS_D7 47 + + #define BEEPER_PIN 41 + + #define BTN_EN1 50 + #define BTN_EN2 52 + #define BTN_ENC 48 + + #define BTN_BACK 71 + + #define SDSS 10 + #define SD_DETECT_PIN 14 + + #elif IS_RRD_FG_SC + + // The REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER requires + // an adapter such as https://www.thingiverse.com/thing:1740725 + + #define LCD_PINS_RS 42 + #define LCD_PINS_ENABLE 43 + #define LCD_PINS_D4 44 + + #define BEEPER_PIN 41 + + #define BTN_EN1 50 + #define BTN_EN2 52 + #define BTN_ENC 48 + + #define SDSS 10 + #define SD_DETECT_PIN 14 + + #elif HAS_U8GLIB_I2C_OLED + + #define BTN_EN1 50 + #define BTN_EN2 52 + #define BTN_ENC 48 + #define BEEPER_PIN 41 + #define LCD_SDSS 10 + #define SD_DETECT_PIN 14 + + #elif ENABLED(SPARK_FULL_GRAPHICS) + + #define LCD_PINS_D4 29 + #define LCD_PINS_ENABLE 27 + #define LCD_PINS_RS 25 + + #define BTN_EN1 35 + #define BTN_EN2 33 + #define BTN_ENC 37 + + #endif // SPARK_FULL_GRAPHICS + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN 47 // Detect the presence of the encoder + #endif + +#endif // HAS_WIRED_LCD + +#ifndef SDSS + #define SDSS 4 +#endif diff --git a/src/pins/sam/pins_RAMPS4DUE.h b/src/pins/sam/pins_RAMPS4DUE.h new file mode 100644 index 0000000..6d9d06a --- /dev/null +++ b/src/pins/sam/pins_RAMPS4DUE.h @@ -0,0 +1,52 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega or Due with RAMPS4DUE pin assignments + * + * Applies to the following boards: + * + * RAMPS4DUE_EFB (Hotend, Fan, Bed) + * RAMPS4DUE_EEB (Hotend0, Hotend1, Bed) + * RAMPS4DUE_EFF (Hotend, Fan0, Fan1) + * RAMPS4DUE_EEF (Hotend0, Hotend1, Fan) + * RAMPS4DUE_SF (Spindle, Controller Fan) + * + * Differences between + * RAMPS_14 | RAMPS4DUE + * A13 | A9/D63 (shares the same pin with AUX2_4PIN) + * A14 | A10/D64 (shares the same pin with AUX2_5PIN) + * A15 | NC + */ + +#define ALLOW_SAM3X8E +#define BOARD_INFO_NAME "RAMPS4DUE" + +// +// Temperature Sensors +// +#define TEMP_0_PIN 9 // Analog Input +#define TEMP_1_PIN -1 // Analog Input +#define TEMP_BED_PIN 10 // Analog Input + +#include "../ramps/pins_RAMPS.h" diff --git a/src/pins/sam/pins_RAMPS_DUO.h b/src/pins/sam/pins_RAMPS_DUO.h new file mode 100644 index 0000000..5b2b2f0 --- /dev/null +++ b/src/pins/sam/pins_RAMPS_DUO.h @@ -0,0 +1,131 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega or Due with RAMPS Duo pin assignments + * + * Applies to the following boards: + * + * RAMPS_DUO_EFB (Hotend, Fan, Bed) + * RAMPS_DUO_EEB (Hotend0, Hotend1, Bed) + * RAMPS_DUO_EFF (Hotend, Fan0, Fan1) + * RAMPS_DUO_EEF (Hotend0, Hotend1, Fan) + * RAMPS_DUO_SF (Spindle, Controller Fan) + * + * Differences between + * RAMPS_14 | RAMPS_DUO + * A9/D63 | A12/D66 + * A10/D64 | A13/D67 + * A11/D65 | A14/D68 + * A12/D66 | A15/D69 + * A13 | A9 + * A14 | A10 + * A15 | A11 + */ + +#define BOARD_INFO_NAME "RAMPS Duo" + +#define ALLOW_SAM3X8E +#include "../ramps/pins_RAMPS.h" + +// +// Temperature Sensors +// +#undef TEMP_0_PIN +#define TEMP_0_PIN 9 // Analog Input + +#undef TEMP_1_PIN +#define TEMP_1_PIN 11 // Analog Input + +#undef TEMP_BED_PIN +#define TEMP_BED_PIN 10 // Analog Input + +// SPI for MAX Thermocouple +#undef TEMP_0_CS_PIN +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 69 // Don't use 53 if using Display/SD card +#else + #define TEMP_0_CS_PIN 69 // Don't use 49 (SD_DETECT_PIN) +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if BOTH(IS_NEWPANEL, PANEL_ONE) + #undef LCD_PINS_D4 + #define LCD_PINS_D4 68 + + #undef LCD_PINS_D5 + #define LCD_PINS_D5 69 + + #undef LCD_PINS_D7 + #define LCD_PINS_D7 67 + #endif + + #if IS_NEWPANEL + + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #undef BTN_EN1 + #define BTN_EN1 67 + + #undef BTN_ENC + #define BTN_ENC 66 + + #elif ENABLED(MINIPANEL) + + #undef DOGLCD_CS + #define DOGLCD_CS 69 + + #undef LCD_BACKLIGHT_PIN + #define LCD_BACKLIGHT_PIN 68 // backlight LED on A14/D68 + + #undef KILL_PIN + #define KILL_PIN 67 + + #undef BTN_EN2 + #define BTN_EN2 66 + + #else + + #if IS_RRW_KEYPAD + #undef BTN_EN1 + #define BTN_EN1 67 // encoder + + #undef BTN_ENC + #define BTN_ENC 66 // enter button + #elif ENABLED(PANEL_ONE) + #undef BTN_EN2 + #define BTN_EN2 66 // AUX2 PIN 4 + #endif + #endif + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD diff --git a/src/pins/sam/pins_RAMPS_FD_V1.h b/src/pins/sam/pins_RAMPS_FD_V1.h new file mode 100644 index 0000000..00eba99 --- /dev/null +++ b/src/pins/sam/pins_RAMPS_FD_V1.h @@ -0,0 +1,264 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * RAMPS-FD + * + * No EEPROM + * Use 4k7 thermistor tables + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "RAMPS-FD v1" +#endif + +#define INVERTED_HEATER_PINS +#define INVERTED_BED_PINS +#define INVERTED_FAN_PINS + +// +// Servos +// +#define SERVO0_PIN 7 +#define SERVO1_PIN 6 +#define SERVO2_PIN 5 +#define SERVO3_PIN 3 + +// +// Limit Switches +// +#define X_MIN_PIN 22 +#define X_MAX_PIN 30 +#define Y_MIN_PIN 24 +#define Y_MAX_PIN 38 +#define Z_MIN_PIN 26 +#define Z_MAX_PIN 34 + +// +// Steppers +// +#define X_STEP_PIN 63 +#define X_DIR_PIN 62 +#define X_ENABLE_PIN 48 +#ifndef X_CS_PIN + #define X_CS_PIN 68 +#endif + +#define Y_STEP_PIN 65 +#define Y_DIR_PIN 64 +#define Y_ENABLE_PIN 46 +#ifndef Y_CS_PIN + #define Y_CS_PIN 60 +#endif + +#define Z_STEP_PIN 67 +#define Z_DIR_PIN 66 +#define Z_ENABLE_PIN 44 +#ifndef Z_CS_PIN + #define Z_CS_PIN 58 +#endif + +#define E0_STEP_PIN 36 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 42 +#ifndef E0_CS_PIN + #define E0_CS_PIN 67 +#endif + +#define E1_STEP_PIN 43 +#define E1_DIR_PIN 41 +#define E1_ENABLE_PIN 39 +#ifndef E1_CS_PIN + #define E1_CS_PIN 61 +#endif + +#define E2_STEP_PIN 32 +#define E2_DIR_PIN 47 +#define E2_ENABLE_PIN 45 +#ifndef E2_CS_PIN + #define E2_CS_PIN 59 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // Analog Input +#define TEMP_1_PIN 2 // Analog Input +#define TEMP_2_PIN 3 // Analog Input +#define TEMP_BED_PIN 0 // Analog Input + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 53 +#else + #define TEMP_0_CS_PIN 49 +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 9 +#define HEATER_1_PIN 10 +#define HEATER_2_PIN 11 +#define HEATER_BED_PIN 8 + +#ifndef FAN_PIN + #define FAN_PIN 12 +#endif + +// +// Misc. Functions +// +#define SDSS 4 +#define LED_PIN 13 + +/** ------ ------ + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 76 (SCK) + * 29 | 3 4 | 27 (EN2) 31 | 3 4 | 4 (SD_SS) + * 25 5 6 | 23 (EN1) 33 5 6 | 75 (MOSI) + * 16 | 7 8 | 17 (SDD) 49 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN 37 +#define EXP1_02_PIN 35 +#define EXP1_03_PIN 29 +#define EXP1_04_PIN 27 +#define EXP1_05_PIN 25 +#define EXP1_06_PIN 23 +#define EXP1_07_PIN 16 +#define EXP1_08_PIN 17 + +#define EXP2_01_PIN 74 +#define EXP2_02_PIN 76 +#define EXP2_03_PIN 31 +#define EXP2_04_PIN 4 +#define EXP2_05_PIN 33 +#define EXP2_06_PIN 75 +#define EXP2_07_PIN 49 +#define EXP2_08_PIN -1 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + // ramps-fd lcd adaptor + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN + #define SD_DETECT_PIN EXP2_07_PIN + + #if IS_NEWPANEL + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #endif + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS LCD_PINS_ENABLE + #define DOGLCD_A0 LCD_PINS_RS + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_05_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_04_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_03_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_05_PIN + #endif + + #elif IS_NEWPANEL + + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_D7 EXP1_03_PIN + + #if ENABLED(MINIPANEL) + #define DOGLCD_CS EXP1_05_PIN + #define DOGLCD_A0 EXP1_04_PIN + #endif + + #endif + + #if EITHER(VIKI2, miniVIKI) + #define DOGLCD_A0 EXP1_07_PIN + #define KILL_PIN 51 + #define STAT_LED_BLUE_PIN EXP1_03_PIN + #define STAT_LED_RED_PIN EXP1_06_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_SCK EXP2_02_PIN // SCK_PIN - Required for DUE Hardware SPI + #define DOGLCD_MOSI EXP2_06_PIN // MOSI_PIN + #define DOGLCD_MISO EXP2_01_PIN // MISO_PIN + #endif + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif // HAS_WIRED_LCD + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HOTENDS < 3 && HAS_CUTTER && !PIN_EXISTS(SPINDLE_LASER_ENA) + #define SPINDLE_LASER_ENA_PIN 45 // Use E2 ENA + #define SPINDLE_LASER_PWM_PIN 12 // Hardware PWM + #define SPINDLE_DIR_PIN 47 // Use E2 DIR +#endif diff --git a/src/pins/sam/pins_RAMPS_FD_V2.h b/src/pins/sam/pins_RAMPS_FD_V2.h new file mode 100644 index 0000000..55a42b2 --- /dev/null +++ b/src/pins/sam/pins_RAMPS_FD_V2.h @@ -0,0 +1,52 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * RAMPS-FD v2 + * + * EEPROM supported + * Use 1k thermistor tables + */ + +#define BOARD_INFO_NAME "RAMPS-FD v2" + +#ifndef E0_CS_PIN + #define E0_CS_PIN 69 // moved from A13 to A15 on v2.2, if not earlier +#endif + +#include "pins_RAMPS_FD_V1.h" + +#undef INVERTED_HEATER_PINS +#undef INVERTED_BED_PINS +#undef INVERTED_FAN_PINS + +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x10000 // 64K in a 24C512 + +#ifndef PS_ON_PIN + #define PS_ON_PIN 12 +#endif + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 5 // Analog Input on AUX2 +#endif diff --git a/src/pins/sam/pins_RAMPS_SMART.h b/src/pins/sam/pins_RAMPS_SMART.h new file mode 100644 index 0000000..b02ddef --- /dev/null +++ b/src/pins/sam/pins_RAMPS_SMART.h @@ -0,0 +1,142 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Due with RAMPS-SMART pin assignments + * + * Applies to the following boards: + * + * RAMPS_SMART_EFB (Hotend, Fan, Bed) + * RAMPS_SMART_EEB (Hotend0, Hotend1, Bed) + * RAMPS_SMART_EFF (Hotend, Fan0, Fan1) + * RAMPS_SMART_EEF (Hotend0, Hotend1, Fan) + * RAMPS_SMART_SF (Spindle, Controller Fan) + * + * Differences between + * RAMPS_14 | RAMPS-SMART + * NONE | D16 (Additional AUX-3 pin(AUX3_2PIN), shares the same pin with AUX4_18PIN) + * NONE | D17 (Additional AUX-3 pin(AUX3_1PIN), shares the same pin with AUX4_17PIN) + * D0 | NONE + * D1 | NONE + * A3/D57 | NONE + * A4/D58 | NONE + * A5/D59 | A3/D57 + * A9/D63 | A4/D58 + * A10/D64 | A5/D59 + * A11/D65 | D66 + * A12/D66 | D67 + * A13 | A9 + * A14 | A10 + * A15 | A11 + * + * + * REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER works fine connected to AUX-4 with + * Smart Adapter, but requires removing the AUX3 pin header on the adapter to fit. + * To use the SD card reader, wire its pins to AUX-3 (and use Software SPI). + * + * To use Hardware SPI for SD, the SDSS pin must be set to 52 instead of 53. + * Hardware SPI also requires additional wiring because the board doesn't pass + * the 6-pin SPI header from the DUE board. + * (Search the web for "Arduino DUE Board Pinout" to see the correct header.) + */ + +#define BOARD_INFO_NAME "RAMPS-SMART" + +// I2C EEPROM with 4K of space +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4K + +// See EEPROM device datasheet for the following values. These are for 24xx256 +#define EEPROM_DEVICE_ADDRESS 0x50 // 7 bit i2c address (without R/W bit) +#define EEPROM_WRITE_DELAY 7 // page write time in milliseconds (docs say 5ms but that is too short) +//#define EEPROM_PAGE_SIZE 64 // page write buffer size +//#define TWI_CLOCK_FREQ 400000 +//#define EEPROM_ADDRSZ_BYTES TWI_MMR_IADRSZ_2_BYTE // TWI_MMR_IADRSZ_1_BYTE for 1 byte, or TWI_MMR_IADRSZ_2_BYTE for 2 byte +//#define EEPROM_AVAILABLE EEPROM_I2C + +// +// Temperature Sensors +// +#define TEMP_0_PIN 9 // Analog Input +#define TEMP_1_PIN 10 // Analog Input +#define TEMP_BED_PIN 11 // Analog Input + +// SPI for MAX Thermocouple +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 67 // Don't use 53 if using Display/SD card +#else + #define TEMP_0_CS_PIN 67 // Don't use 49 (SD_DETECT_PIN) +#endif + +#define SDA_PIN 20 +#define SCL_PIN 21 +#define RESET_PIN 42 // Resets the board if the jumper is attached + +// +// LCD / Controller +// +#if ENABLED(AZSMZ_12864) + + // Support for AZSMZ 12864 LCD with SD Card 3D printer smart controller control panel + #define BEEPER_PIN 66 // Smart RAMPS 1.42 pinout diagram on RepRap WIKI erroneously says this should be pin 65 + #define DOGLCD_A0 59 + #define DOGLCD_CS 44 + #define BTN_EN1 58 + #define BTN_EN2 40 + #define BTN_ENC 67 // Smart RAMPS 1.42 pinout diagram on RepRap WIKI erroneously says this should be pin 66 + #define SD_DETECT_PIN 49 // Pin 49 for display sd interface, 72 for easy adapter board + #define KILL_PIN 42 + +#else + + /** ------ ------ + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 52 (SCK) + * 31 | 3 4 | 41 29 | 3 4 | 53 + * 33 5 6 | 23 25 5 6 | 51 (MOSI) + * 42 | 7 8 | 44 49 | 7 8 | 27 + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ + #define EXP1_01_PIN 37 + #define EXP1_02_PIN 35 + #define EXP1_03_PIN 31 + #define EXP1_04_PIN 41 + #define EXP1_05_PIN 33 + #define EXP1_06_PIN 23 + #define EXP1_07_PIN 42 + #define EXP1_08_PIN 44 + + #define EXP2_01_PIN 50 + #define EXP2_02_PIN 52 + #define EXP2_03_PIN 29 + #define EXP2_04_PIN 53 + #define EXP2_05_PIN 25 + #define EXP2_06_PIN 51 + #define EXP2_07_PIN 49 + #define EXP2_08_PIN 27 + +#endif + +#define ALLOW_SAM3X8E +#include "../ramps/pins_RAMPS.h" diff --git a/src/pins/sam/pins_RURAMPS4D_11.h b/src/pins/sam/pins_RURAMPS4D_11.h new file mode 100644 index 0000000..f8ea65a --- /dev/null +++ b/src/pins/sam/pins_RURAMPS4D_11.h @@ -0,0 +1,292 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Mega? or Due with RuRAMPS4DUE pin assignments + * Ported by sys0724 & Vynt + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "RuRAMPS4Due v1.1" + +// +// Servos +// +#define SERVO0_PIN 5 +#define SERVO1_PIN 3 + +// +// Limit Switches +// +#define X_MIN_PIN 45 +#define X_MAX_PIN 39 +#define Y_MIN_PIN 46 +#define Y_MAX_PIN 41 +#define Z_MIN_PIN 47 +#define Z_MAX_PIN 43 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 43 +#endif + +// +// Steppers +// +#define X_STEP_PIN 37 // Support Extension Board +#define X_DIR_PIN 36 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN -1 +#endif + +#define Y_STEP_PIN 32 // Support Extension Board +#define Y_DIR_PIN 35 +#define Y_ENABLE_PIN 34 +#ifndef Y_CS_PIN + #define Y_CS_PIN -1 +#endif + +#define Z_STEP_PIN 30 // Support Extension Board +#define Z_DIR_PIN 2 +#define Z_ENABLE_PIN 33 +#ifndef Z_CS_PIN + #define Z_CS_PIN -1 +#endif + +#define E0_STEP_PIN 29 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 31 +#ifndef E0_CS_PIN + #define E0_CS_PIN -1 +#endif + +#define E1_STEP_PIN 22 +#define E1_DIR_PIN 24 +#define E1_ENABLE_PIN 26 +#ifndef E1_CS_PIN + #define E1_CS_PIN -1 +#endif + +#define E2_STEP_PIN 25 +#define E2_DIR_PIN 23 +#define E2_ENABLE_PIN 27 +#ifndef E2_CS_PIN + #define E2_CS_PIN -1 +#endif + +#define E3_STEP_PIN 15 // Only For Extension Board +#define E3_DIR_PIN 14 +#define E3_ENABLE_PIN 61 +#ifndef E3_CS_PIN + #define E3_CS_PIN -1 +#endif + +// For Future: Microstepping pins - Mapping not from fastio.h (?) +//#define E3_MS1_PIN ? +//#define E3_MS2_PIN ? +//#define E3_MS3_PIN ? + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN Y_MIN_PIN +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 13 +#define HEATER_1_PIN 12 +#define HEATER_2_PIN 11 +#define HEATER_BED_PIN 7 // BED H1 + +#ifndef FAN_PIN + #define FAN_PIN 9 +#endif +#define FAN1_PIN 8 +#define CONTROLLER_FAN_PIN -1 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // ANALOG A0 +#define TEMP_1_PIN 1 // ANALOG A1 +#define TEMP_2_PIN 2 // ANALOG A2 +#define TEMP_3_PIN 3 // ANALOG A3 +#define TEMP_BED_PIN 4 // ANALOG A4 + +// The thermocouple uses Analog pins +#if ENABLED(VER_WITH_THERMOCOUPLE) // Defined in Configuration.h + #define TEMP_4_PIN 5 // A5 + #define TEMP_5_PIN 6 // A6 (Marlin 2.0 not support) +#endif + +// SPI for MAX Thermocouple +/* +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN EXP1_08_PIN +#else + #define TEMP_0_CS_PIN 49 +#endif +*/ + +// +// Misc. Functions +// +#define SDSS 4 // 4,10,52 if using HW SPI. +#define LED_PIN -1 // 13 - HEATER_0_PIN +#define PS_ON_PIN -1 // 65 + +// MKS TFT / Nextion Use internal USART-1 +#define TFT_LCD_MODULE_COM 1 +#define TFT_LCD_MODULE_BAUDRATE 115600 + +// ESP WiFi Use internal USART-2 +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115600 +#define ESP_WIFI_MODULE_RESET_PIN -1 +#define PIGGY_GPIO_PIN -1 + +// +// EEPROM +// +#define MARLIN_EEPROM_SIZE 0x8000 // 32K (24lc256) +#define I2C_EEPROM // EEPROM on I2C-0 +//#define EEPROM_SD // EEPROM on SDCARD +//#define SPI_EEPROM // EEPROM on SPI-0 +//#define SPI_CHAN_EEPROM1 ? +//#define SPI_EEPROM1_CS_PIN ? +// 2K EEPROM +//#define SPI_EEPROM2_CS_PIN ? +// 32Mb FLASH +//#define SPI_FLASH_CS_PIN ? + +/** + * ------ ------ + * (BEEPER) 62 | 1 2 | 40 (BTN_ENC) (MISO) 74 | 1 2 | 76 (SCK) + * (LCD_EN) 64 | 3 4 | 63 (LCD_RS) (BTN_EN1) 44 | 3 4 | 10 (SD_SS) + * (LCD_D4) 48 | 5 6 50 (LCD_D5) (BTN_EN2) 42 | 5 6 75 (MOSI) + * (LCD_D6) 52 | 7 8 | 53 (LCD_D7) (SD_DETECT) 51 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN 62 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 64 +#define EXP1_04_PIN 63 +#define EXP1_05_PIN 48 +#define EXP1_06_PIN 50 +#define EXP1_07_PIN 52 +#define EXP1_08_PIN 53 + +#define EXP2_01_PIN 74 // MISO +#define EXP2_02_PIN 76 // SCK +#define EXP2_03_PIN 44 +#define EXP2_04_PIN 10 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 75 // MOSI +#define EXP2_07_PIN 51 +#define EXP2_08_PIN -1 // RESET + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif + + #if EITHER(RADDS_DISPLAY, IS_RRD_SC) + + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + + #elif IS_RRD_FG_SC + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + + #elif HAS_U8GLIB_I2C_OLED + + #define BEEPER_PIN EXP1_01_PIN + #define LCD_SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN + + #elif ENABLED(FYSETC_MINI_12864) + + #define BEEPER_PIN EXP1_01_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN // D5 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN // D6 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN // D7 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN // D5 + #endif + + #elif ENABLED(SPARK_FULL_GRAPHICS) + + //http://doku.radds.org/dokumentation/other-electronics/sparklcd/ + #error "Oops! SPARK_FULL_GRAPHICS not supported with RURAMPS4D." + //#define LCD_PINS_D4 29 //? + //#define LCD_PINS_ENABLE 27 //? + //#define LCD_PINS_RS 25 //? + //#define BTN_EN1 35 //? + //#define BTN_EN2 33 //? + //#define BTN_ENC 37 //? + + #endif // SPARK_FULL_GRAPHICS + + #if IS_NEWPANEL + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN + #endif + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/sam/pins_RURAMPS4D_13.h b/src/pins/sam/pins_RURAMPS4D_13.h new file mode 100644 index 0000000..58cb3f7 --- /dev/null +++ b/src/pins/sam/pins_RURAMPS4D_13.h @@ -0,0 +1,277 @@ +/** + * 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 . + * + * Ported sys0724 & Vynt + */ +#pragma once + +/** + * Arduino Mega? or Due with RuRAMPS4DUE pin assignments + * + * Applies to the following boards: + * RURAMPS4DUE (Hotend0, Hotend1, Hotend2, Fan0, Fan1, Bed) + * + * Differences between + * RADDS | RuRAMPS4DUE + * | + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "RuRAMPS4Due v1.3" + +// +// Servos +// +#define SERVO0_PIN 5 +#define SERVO1_PIN 3 + +// +// Limit Switches +// +#define X_MIN_PIN 45 +#define X_MAX_PIN 39 +#define Y_MIN_PIN 46 +#define Y_MAX_PIN 41 +#define Z_MIN_PIN 47 +#define Z_MAX_PIN 43 + +// +// Steppers +// +#define X_STEP_PIN 37 // Support Extension Board +#define X_DIR_PIN 36 +#define X_ENABLE_PIN 31 +#ifndef X_CS_PIN + #define X_CS_PIN 38 +#endif + +#define Y_STEP_PIN 32 // Support Extension Board +#define Y_DIR_PIN 35 +#define Y_ENABLE_PIN 31 +#ifndef Y_CS_PIN + #define Y_CS_PIN 34 +#endif + +#define Z_STEP_PIN 30 // Support Extension Board +#define Z_DIR_PIN 2 +#define Z_ENABLE_PIN 31 +#ifndef Z_CS_PIN + #define Z_CS_PIN 10 +#endif + +#define E0_STEP_PIN 29 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 33 +#ifndef E0_CS_PIN + #define E0_CS_PIN 14 +#endif + +#define E1_STEP_PIN 22 +#define E1_DIR_PIN 24 +#define E1_ENABLE_PIN 26 +#ifndef E1_CS_PIN + #define E1_CS_PIN 15 +#endif + +#define E2_STEP_PIN 25 +#define E2_DIR_PIN 23 +#define E2_ENABLE_PIN 27 +#ifndef E2_CS_PIN + #define E2_CS_PIN 61 +#endif + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 49 +#endif + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN Y_MIN_PIN +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 13 +#define HEATER_1_PIN 12 +#define HEATER_2_PIN 11 +#define HEATER_BED_PIN 7 // BED H1 + +#define FAN_PIN 9 +#define FAN1_PIN 8 +#define CONTROLLER_FAN_PIN -1 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // ANALOG A0 +#define TEMP_1_PIN 1 // ANALOG A1 +#define TEMP_2_PIN 2 // ANALOG A2 +#define TEMP_3_PIN 3 // ANALOG A3 +#define TEMP_BED_PIN 4 // ANALOG A4 + +// The thermocouple uses Analog pins +#if ENABLED(VER_WITH_THERMOCOUPLE) // Defined in Configuration.h + #define TEMP_4_PIN 5 // A5 + #define TEMP_5_PIN 6 // A6 (Marlin 2.0 not support) +#endif + +// SPI for MAX Thermocouple +/* +#if DISABLED(SDSUPPORT) + #define TEMP_0_CS_PIN 53 +#else + #define TEMP_0_CS_PIN 49 +#endif +*/ + +// +// Misc. Functions +// +#define SDSS 4 // 4,10,52 if using HW SPI. +#define LED_PIN -1 // 13 - HEATER_0_PIN +#define PS_ON_PIN -1 // 65 + +// MKS TFT / Nextion Use internal USART-1 +#define TFT_LCD_MODULE_COM 1 +#define TFT_LCD_MODULE_BAUDRATE 115200 + +// ESP WiFi Use internal USART-2 +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115200 +#define ESP_WIFI_MODULE_RESET_PIN -1 +#define PIGGY_GPIO_PIN -1 + +// +// EEPROM +// +#define MARLIN_EEPROM_SIZE 0x8000 // 32K (24lc256) +#define I2C_EEPROM // EEPROM on I2C-0 +//#define EEPROM_SD // EEPROM on SDCARD +//#define SPI_EEPROM // EEPROM on SPI-0 +//#define SPI_CHAN_EEPROM1 ? +//#define SPI_EEPROM1_CS_PIN ? +// 2K EEPROM +//#define SPI_EEPROM2_CS_PIN ? +// 32Mb FLASH +//#define SPI_FLASH_CS_PIN ? + +/** + * ------ ------ + * (BEEPER) 62 | 1 2 | 40 (BTN_ENC) (MISO) 74 | 1 2 | 76 (SCK) + * (LCD_EN) 64 | 3 4 | 63 (LCD_RS) (BTN_EN1) 44 | 3 4 | 10 (SD_SS) + * (LCD_D4) 48 | 5 6 50 (LCD_D5) (BTN_EN2) 42 | 5 6 75 (MOSI) + * (LCD_D6) 52 | 7 8 | 53 (LCD_D7) (SD_DETECT) 51 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN 62 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 64 +#define EXP1_04_PIN 63 +#define EXP1_05_PIN 48 +#define EXP1_06_PIN 50 +#define EXP1_07_PIN 52 +#define EXP1_08_PIN 53 + +#define EXP2_01_PIN 74 // MISO +#define EXP2_02_PIN 76 // SCK +#define EXP2_03_PIN 44 +#define EXP2_04_PIN 10 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 75 // MOSI +#define EXP2_07_PIN 51 +#define EXP2_08_PIN -1 // RESET + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif + + #if EITHER(RADDS_DISPLAY, IS_RRD_SC) + + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + + #elif IS_RRD_FG_SC + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + + #elif HAS_U8GLIB_I2C_OLED + + #define BEEPER_PIN EXP1_01_PIN + #define LCD_SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN + + #elif ENABLED(FYSETC_MINI_12864) + + #define BEEPER_PIN EXP1_01_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN // D5 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN // D6 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN // D7 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN // D5 + #endif + + #elif ENABLED(MKS_MINI_12864) + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + + #define SD_DETECT_PIN EXP2_07_PIN + + #endif + + #if IS_NEWPANEL + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN + #endif + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/sam/pins_ULTRATRONICS_PRO.h b/src/pins/sam/pins_ULTRATRONICS_PRO.h new file mode 100644 index 0000000..fd30c2b --- /dev/null +++ b/src/pins/sam/pins_ULTRATRONICS_PRO.h @@ -0,0 +1,176 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * ReprapWorld ULTRATRONICS v1.0 + * https://reprapworld.com/documentation/datasheet_ultratronics10_05.pdf + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Ultratronics v1.0" + +// +// Servos +// +#if NUM_SERVOS > 0 + #define SERVO0_PIN 11 + #if NUM_SERVOS > 1 + #define SERVO1_PIN 12 + #endif +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 31 +#define X_MAX_PIN 30 +#define Y_MIN_PIN 12 +#define Y_MAX_PIN 11 +#define Z_MIN_PIN 29 +#define Z_MAX_PIN 28 + +// +// Steppers +// +#define X_STEP_PIN 35 +#define X_DIR_PIN 34 +#define X_ENABLE_PIN 37 +#ifndef X_CS_PIN + #define X_CS_PIN 18 +#endif + +#define Y_STEP_PIN 22 +#define Y_DIR_PIN 23 +#define Y_ENABLE_PIN 33 +#ifndef Y_CS_PIN + #define Y_CS_PIN 19 +#endif + +#define Z_STEP_PIN 25 +#define Z_DIR_PIN 26 +#define Z_ENABLE_PIN 24 +#ifndef Z_CS_PIN + #define Z_CS_PIN 16 +#endif + +#define E0_STEP_PIN 47 +#define E0_DIR_PIN 46 +#define E0_ENABLE_PIN 48 +#ifndef E0_CS_PIN + #define E0_CS_PIN 17 +#endif + +#define E1_STEP_PIN 44 +#define E1_DIR_PIN 36 +#define E1_ENABLE_PIN 45 +#ifndef E1_CS_PIN + #define E1_CS_PIN -1 +#endif + +#define E2_STEP_PIN 42 +#define E2_DIR_PIN 41 +#define E2_ENABLE_PIN 43 +#ifndef E2_CS_PIN + #define E2_CS_PIN -1 +#endif + +#define E3_STEP_PIN 39 +#define E3_DIR_PIN 38 +#define E3_ENABLE_PIN 40 +#ifndef E3_CS_PIN + #define E3_CS_PIN -1 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 2 // Analog Input +#define TEMP_2_PIN 3 // Analog Input +#define TEMP_3_PIN 4 // Analog Input +#define TEMP_BED_PIN 1 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 3 +#define HEATER_1_PIN 8 +#define HEATER_2_PIN 7 +#define HEATER_3_PIN 9 +#define HEATER_BED_PIN 2 + +#ifndef FAN_PIN + #define FAN_PIN 6 +#endif +#define FAN2_PIN 5 + +// +// Misc. Functions +// +#define SDSS 59 +#define SD_DETECT_PIN 60 +#define LED_PIN 13 +#define PS_ON_PIN 32 + +// +// SPI Buses +// + +#define DAC0_SYNC_PIN 53 // PB14 +#define SPI_CHAN_DAC 1 + +#define SPI_CHAN_EEPROM1 -1 +#define SPI_EEPROM1_CS_PIN -1 +#define SPI_EEPROM2_CS_PIN -1 +#define SPI_FLASH_CS_PIN -1 + +#define SD_SCK_PIN 76 +#define SD_MISO_PIN 74 +#define SD_MOSI_PIN 75 + +// SPI for MAX Thermocouple +#define TEMP_0_CS_PIN 65 +#define TEMP_1_CS_PIN 52 +#define TEMP_2_CS_PIN 50 +#define TEMP_3_CS_PIN 51 + +#define ENC424_SS 61 + +// +// LCD / Controller +// + +#define BEEPER_PIN 27 + +#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define LCD_PINS_RS A8 // CS chip select / SS chip slave select + #define LCD_PINS_ENABLE MOSI // SID (MOSI) + #define LCD_PINS_D4 SCK // SCK (CLK) clock + + #define BTN_EN1 20 + #define BTN_EN2 21 + #define BTN_ENC 64 + +#endif // REPRAPWORLD_GRAPHICAL_LCD diff --git a/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h b/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h new file mode 100644 index 0000000..a3f98e3 --- /dev/null +++ b/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h @@ -0,0 +1,616 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * BRICOLEMON LITE Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. + * This board its a 3.3V LOGIC Board, following the ADAFRUIT example, all of the board is open source. + * Schematic: Refer to the Bricolemon + * 3DSTEP: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon%20Lite/LC_BG_002_PCB_V1I4.step + * PinDemux: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/PinDEMUX.xlsx + * + * NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1 + */ + +#if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) + #error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BRICOLEMON LITE V1.0" // , Lemoncrest & BricoGeek collaboration. +#endif + +/** + * EEPROM EMULATION: Works with some bugs already, but the board needs an I2C EEPROM memory soldered on. + */ +//#define FLASH_EEPROM_EMULATION +#define I2C_EEPROM // EEPROM on I2C-0 +#define MARLIN_EEPROM_SIZE 0x10000 // 64K (CAT24C512) + +// This is another option to emulate an EEPROM, but it's more efficient to not lose the data in the first place. +//#define SDCARD_EEPROM_EMULATION + +// +// BLTOUCH PIN: This pin is the signal pin for the BLTOUCH sensor. +// +#define SERVO0_PIN 33 // BLTouch PWM + +// +// Limit Switches +// +#define X_STOP_PIN 10 +#define Y_STOP_PIN 11 +#define Z_STOP_PIN 12 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 12 +#endif + +// +// Steppers +// +#define X_STEP_PIN 3 +#define X_DIR_PIN 22 +#define X_ENABLE_PIN 26 + +#define Y_STEP_PIN 4 +#define Y_DIR_PIN 23 +#define Y_ENABLE_PIN 27 + +#define Z_STEP_PIN 5 +#define Z_DIR_PIN 24 +#define Z_ENABLE_PIN 28 + +#define E0_STEP_PIN 2 +#define E0_DIR_PIN 25 +#define E0_ENABLE_PIN 29 + +// Filament runout. You may choose to use this pin for some other purpose. It's a normal GPIO that can be configured as I/O. +// For example, a switch to detect any kind of behavior, Power supply pin .... etc. +#define FIL_RUNOUT_PIN 32 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 +#define TEMP_BED_PIN 3 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 +#define HEATER_BED_PIN 7 +#define FAN_PIN 8 +#define FAN1_PIN 9 + +// +// LCD / Controller +// + +/** + * Bricolemon Expansion connectors + * + * ------ ------ + * VCC | 1 2 | GND KILL | 1 2 | GND + * LCD7 | 3 4 | LCDD6 RESET | 3 4 | SD_DETECT + * LCD5 | 5 6 LCDD4 MOSI | 5 6 BTN_EN1 + * LCDRS | 7 8 | LCDDE SS | 7 8 | BTN_EN2 + * BTN_ENCODER | 9 10 | BEEPER SCLK | 9 10 | MISO + * ------ ------ + * EXP1 EXP2 + * + *- This extra connector is for a serial display like the MKS TFT. + * MKS TFT + * ------ + * RX0 | . . | NC + * TX0 | . . NC + * GND | . . GND + * 5B | . . | 5V + * ------ + * + *- Special mapping of EXP1 to EXP3 to work with Ender displays. + * + * Enable CR10_STOCKDISPLAY in Configuration.h and connect EXP1 to the display EXP3 with this mapping. + * ------ + * VCC | 1 2 | GND + * LCDDE | 3 4 | LCDRS + * LCDD4 | 5 6 BTN_EN2 + * RESET | 7 8 | BTN_EN1 + * BTN_ENCODER | 9 10 | BEEPER + * ------ + * + *- Digital pinout reference of the Bricolemon for advanced users/configurations. + * + * ------ ------ + * VCC | 1 2 | GND D49 | 1 2 | GND + * D39 | 3 4 | D38 RST | 3 4 | D44 + * D37 | 5 6 D36 D51 | 5 6 D42 + * D34 | 7 8 | D35 D53 | 7 8 | D43 + * D40 | 9 10 | D41 D52 | 9 10 | D50 + * ------ ------ + * EXP1 EXP2 + * + *- Pin table overview + * LCD--- SPI--- + * LCD4 36 MISO 50 + * LCD5 37 SS 53 + * LCD6 38 SCKL 52 + * LCD7 39 MOSI 51 + * LCDRS 34 BEEPER + * LCDDE 35 BEEP 41 + * ENCODER--- SD-CARD--- + * BTN_EN1 42 + * BTN_EN2 43 SD_DETECT 44 + * BTN_ENCODER 40 KILL_PIN 49 + */ + +#define EXP1_01_PIN 41 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 35 +#define EXP1_04_PIN 34 +#define EXP1_05_PIN 36 +#define EXP1_06_PIN 37 +#define EXP1_07_PIN 38 +#define EXP1_08_PIN 39 + +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 43 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 44 +#define EXP2_10_PIN 49 + +#if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_01_PIN EXP1_01_PIN + #define EXP3_02_PIN EXP1_02_PIN + #define EXP3_03_PIN EXP1_03_PIN + #define EXP3_04_PIN EXP1_04_PIN + #define EXP3_05_PIN EXP1_05_PIN + #define EXP3_06_PIN EXP1_06_PIN + #define EXP3_07_PIN EXP1_07_PIN + #define EXP3_08_PIN EXP1_08_PIN +#endif + +/************************************/ +/***** Configurations Section ******/ +/************************************/ + +/** + * This section starts with the pins_RAMPS_144.h as example, after if you need any new + * display, you could use normal duponts and connect it with with the scheme showed before. + * Tested: + * - Ender 3 Old display (Character LCD) + * - Ender 3 New Serial DWING Display + * - Reprap Display + * - Ender 5 New Serial Display + * - Any Reprap character display like + */ + +#if HAS_WIRED_LCD + + // + // LCD Display output pins + // + #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + + #if LCD_SERIAL_PORT != 1 + #error "LCD_SERIAL_PORT should be 1 for this display." + #endif + + // DWIN Encoder + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_04_PIN + + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_01_PIN + #undef SPEAKER + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define LCD_PINS_RS EXP2_10_PIN // CS chip select /SS chip slave select + //#define LCD_PINS_ENABLE EXP2_06_PIN // SID (MOSI) + //#define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + // TO TEST + //#define LCD_PINS_RS EXP1_02_PIN + //#define LCD_PINS_ENABLE EXP2_05_PIN + //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 + //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 + //#define LCD_PINS_D6 EXP2_07_PIN + //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + // TO TEST + #define LCD_PINS_RS EXP3_04_PIN + #define LCD_PINS_ENABLE EXP3_03_PIN + #define LCD_PINS_D4 EXP3_05_PIN + + #if !IS_NEWPANEL + // TO TEST + //#define BEEPER_PIN EXP3_05_PIN + #endif + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 + //#define LCD_PINS_ENABLE EXP2_07_PIN + //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 + //#define LCD_PINS_D5 EXP1_02_PIN + //#define LCD_PINS_D6 EXP2_05_PIN + //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + // TO TEST + //#define LCD_PINS_DC 25 // Set as output on init + //#define LCD_PINS_RS 27 // Pull low for 1s to init + // DOGM SPI LCD Support + //#define DOGLCD_CS 16 + //#define DOGLCD_MOSI 17 + //#define DOGLCD_SCK 23 + //#define DOGLCD_A0 LCD_PINS_DC + + + #else + // Definitions for any standard Display + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #endif + + #define LCD_PINS_D7 EXP1_08_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP1_01_PIN + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN EXP1_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN EXP1_01_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + // TO TEST + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_06_PIN + + #else + // Definitions for any standard Display + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + + #define BTN_ENC EXP1_02_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif + #define KILL_PIN EXP2_10_PIN + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + //#define LCD_BACKLIGHT_PIN EXP1_08_PIN // TO TEST + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 + //#define SD_DETECT_PIN EXP2_05_PIN + + #elif ENABLED(LCD_I2C_PANELOLU2) + + // TO TEST + //#define BTN_EN1 47 + //#define BTN_EN2 EXP2_03_PIN + //#define BTN_ENC 32 + //#define LCD_SDSS SDSS + //#define KILL_PIN EXP1_01_PIN + + #elif ENABLED(LCD_I2C_VIKI) + + // TO TEST + //#define BTN_EN1 EXP1_02_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_05_PIN + //#define BTN_ENC -1 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_10_PIN + + #elif EITHER(VIKI2, miniVIKI) + + // TO TEST + //#define DOGLCD_CS 45 + //#define DOGLCD_A0 EXP2_07_PIN + //#define LCD_SCREEN_ROT_180 + + //#define BEEPER_PIN 33 + //#define STAT_LED_RED_PIN 32 + //#define STAT_LED_BLUE_PIN EXP1_03_PIN + + //#define BTN_EN1 22 + //#define BTN_EN2 7 + //#define BTN_ENC EXP1_08_PIN + + //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + //#define KILL_PIN 31 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + // TO TEST + //#define DOGLCD_CS 29 + //#define DOGLCD_A0 27 + + //#define BEEPER_PIN 23 + //#define LCD_BACKLIGHT_PIN 33 + + //#define BTN_EN1 EXP1_03_PIN + //#define BTN_EN2 EXP1_06_PIN + //#define BTN_ENC 31 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN + + #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) + + // TO TEST + //#define BEEPER_PIN EXP1_06_PIN + //#define BTN_ENC EXP1_03_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + + //#ifndef KILL_PIN + // #define KILL_PIN EXP1_01_PIN + //#endif + + #if ENABLED(MKS_MINI_12864) + + // TO TEST + //#define DOGLCD_A0 27 + //#define DOGLCD_CS 25 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define BTN_EN1 31 + //#define BTN_EN2 33 + + #elif ENABLED(FYSETC_MINI_12864) + + // From https://wiki.fysetc.com/Mini12864_Panel/ + + // TO TEST + //#define DOGLCD_A0 16 + //#define DOGLCD_CS 17 + + //#define BTN_EN1 33 + //#define BTN_EN2 31 + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + //#define LCD_RESET_PIN 23 // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + // TO TEST + //#define RGB_LED_R_PIN 25 + #endif + #ifndef RGB_LED_G_PIN + // TO TEST + //#define RGB_LED_G_PIN 27 + #endif + #ifndef RGB_LED_B_PIN + // TO TEST + //#define RGB_LED_B_PIN 29 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + // TO TEST + //#define NEOPIXEL_PIN 25 + #endif + + #endif + + #elif ENABLED(MINIPANEL) + + // TO TEST + //#define BEEPER_PIN EXP2_05_PIN + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define DOGLCD_A0 EXP2_07_PIN + //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + //#define BTN_EN1 EXP1_02_PIN + //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 + //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 + + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define ADC_KEYPAD_PIN 12 + + #elif ENABLED(AZSMZ_12864) + + // TO TEST + + #else + + // Beeper on AUX-4 + //#define BEEPER_PIN 33 + + // Buttons are directly attached to AUX-2 + #if IS_RRW_KEYPAD + // TO TEST + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_CLK_PIN EXP2_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 + #elif ENABLED(PANEL_ONE) + // TO TEST + //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) + //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) + //#define BTN_ENC EXP2_10_PIN // AUX3 PIN 7 + #else + // TO TEST + //#define BTN_EN1 EXP1_06_PIN + //#define BTN_EN2 EXP1_03_PIN + //#define BTN_ENC 31 + #endif + + #if ENABLED(G3D_PANEL) + // TO TEST + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// +// SD Support +// + +/** + * Bricolemon has an SD slot, but to change it to your LCD or Custom, set the option to one of the following: + * + * LCD - Use the SD drive in the external LCD controller. + * ONBOARD - Use the SD drive on the control board. + * CUSTOM_CABLE - Use a custom cable to access the SD (as defined in a pins file). + * + * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ] + */ + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDSS 83 + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 95 +#else + #define SDSS EXP2_04_PIN +#endif + +#if HAS_TMC_UART + /** + * Address for the UART Configuration of the TMC2209. Override in Configuration files. + * To test TMC2209 Steppers enable TMC_DEBUG in Configuration_adv.h and test the M122 command with voltage on the steppers. + */ + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0b00 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 0b01 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 0b10 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0b11 + #endif + + /** + * TMC2208/TMC2209 stepper drivers + * It seems to work perfectly fine on Software Serial, if an advanced user wants to test, you could use the SAMD51 Serial1 and Serial 2. Be careful with the Sercom configurations. + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + + // This is the stable default value after testing, but, higher UART rates could be configured, remeber to test the Steppers with the M122 command to check if everything works. + #define TMC_BAUD_RATE 250000 + + // + // Software serial + // + #define X_SERIAL_TX_PIN 0 + #define X_SERIAL_RX_PIN 1 + + #define Y_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define Z_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Z_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E0_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define E0_SERIAL_RX_PIN X_SERIAL_RX_PIN + +#endif diff --git a/src/pins/samd/pins_BRICOLEMON_V1_0.h b/src/pins/samd/pins_BRICOLEMON_V1_0.h new file mode 100644 index 0000000..2343dbc --- /dev/null +++ b/src/pins/samd/pins_BRICOLEMON_V1_0.h @@ -0,0 +1,676 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * BRICOLEMON Board. Based on ATSAMD51 (AGCM4), bootloader and credits by ADAFRUIT. + */ + +#if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) + #error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BRICOLEMON V1.0" // , Lemoncrest & BricoGeek collaboration. +#endif + +/** + * BRICOLEMON Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. + * This board its a 3.3V LOGIC Board, following the ADAFRUIT example, all of the board is open source. + * Schematic: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/EsquemaBricolemon_REVB.pdf + * 3DSTEP: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/BricolemonREVB.step + * PinDemux: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/PinDEMUX.xlsx + * + * NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1 + */ + +/** + * EEPROM EMULATION: Works with some bugs already, but the board needs an I2C EEPROM memory soldered on. + */ +//#define FLASH_EEPROM_EMULATION +#define I2C_EEPROM // EEPROM on I2C-0 +#define MARLIN_EEPROM_SIZE 0x10000 // 64K (CAT24C512) + +//This its another option to emulate an EEPROM, but its more efficient to dont loose the data the first One. +//#define SDCARD_EEPROM_EMULATION + +// +// BLTouch +// +#define SERVO0_PIN 33 // BLTouch PWM + +// +// Limit Switches +// +#define X_STOP_PIN 10 +#define Y_STOP_PIN 11 +#define Z_STOP_PIN 12 + +/** + * NOTE: Useful if extra TMC2209 are to be used as independent axes. + * We need to configure the new digital PIN, for this we could configure on the board the extra pin of this stepper, for example as a MIN_PIN/MAX_PIN. This pin is the D14. + */ +//#define Z2_STOP_PIN 14 +//#define X2_STOP_PIN 14 +//#define Y2_STOP_PIN 14 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 12 +#endif + +// +// Steppers +// +#define X_STEP_PIN 3 +#define X_DIR_PIN 22 +#define X_ENABLE_PIN 26 + +#define Y_STEP_PIN 4 +#define Y_DIR_PIN 23 +#define Y_ENABLE_PIN 27 + +#define Z_STEP_PIN 5 +#define Z_DIR_PIN 24 +#define Z_ENABLE_PIN 28 + +#define E0_STEP_PIN 2 +#define E0_DIR_PIN 25 +#define E0_ENABLE_PIN 29 + +#define E1_STEP_PIN 13 +#define E1_DIR_PIN 46 +#define E1_ENABLE_PIN 47 + +// Filament runout. You may choose to use this pin for some other purpose. It's a normal GPIO that can be configured as I/O. +// For example, a switch to detect any kind of behavior, Power supply pin .... etc. +#define FIL_RUNOUT_PIN 32 + +// This board have the option to use an extra TMC2209 stepper, one of the use could be as a second extruder. +#if EXTRUDERS < 2 + // TODO: Corregir aquí que cuando tenemos dos extrusores o lo que sea, utiliza los endstop que le sobran, osea los max, no hay Z2_endstop + #if NUM_Z_STEPPERS > 1 + #define Z2_STOP_PIN 14 + #endif +#else + // If we want to configure the extra stepper as a Extruder, we should have undef all of the extra motors. + #undef X2_DRIVER_TYPE + #undef Y2_DRIVER_TYPE + #undef Z2_DRIVER_TYPE + #undef Z3_DRIVER_TYPE + #undef Z4_DRIVER_TYPE + + // Si tenemos más de un extrusor lo que hacemos es definir el nuevo extrusor así como sus pines + // Acordarse de definir el #define TEMP_SENSOR_1, ya que este contiene el tipo de sonda del extrusor E1 + + #define FIL_RUNOUT2_PIN 14 + +#endif + +// +// Extruder / Bed +// + +// Temperature Sensors +#define TEMP_0_PIN 1 + +// You could use one of the ADC for a temp chamber if you don't use the second extruder, for example. +#if TEMP_SENSOR_CHAMBER > 0 + #define TEMP_CHAMBER_PIN 3 +#else + #define TEMP_1_PIN 3 +#endif + +#define TEMP_BED_PIN 2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 +#define HEATER_1_PIN 45 +#define HEATER_BED_PIN 7 + +// The board has 4 PWM fans, use and configure as desired +#define FAN_PIN 8 +#define FAN1_PIN 9 +#define FAN2_PIN 30 +#define FAN3_PIN 31 + +// +// LCD / Controller +// + +/** + * Bricolemon Expansion connectors + * + * ------ ------ + * VCC | 1 2 | GND KILL | 1 2 | GND + * LCD7 | 3 4 | LCDD6 RESET | 3 4 | SD_DETECT + * LCD5 | 5 6 LCDD4 MOSI | 5 6 BTN_EN1 + * LCDRS | 7 8 | LCDDE SS | 7 8 | BTN_EN2 + * BTN_ENCODER | 9 10 | BEEPER SCLK | 9 10 | MISO + * ------ ------ + * EXP1 EXP2 + * + *- This extra connector is for a serial display like the MKS TFT. + * MKS TFT + * ------ + * RX0 | . . | NC + * TX0 | . . NC + * GND | . . GND + * 5B | . . | 5V + * ------ + * + *- Special mapping of EXP1 to EXP3 to work with Ender displays. + * + * Enable CR10_STOCKDISPLAY in Configuration.h and connect EXP1 to the display EXP3 with this mapping. + * ------ + * VCC | 1 2 | GND + * LCDDE | 3 4 | LCDRS + * LCDD4 | 5 6 BTN_EN2 + * RESET | 7 8 | BTN_EN1 + * BTN_ENCODER | 9 10 | BEEPER + * ------ + * + *- Digital pinout reference of the Bricolemon for advanced users/configurations. + * + * ------ ------ + * VCC | 1 2 | GND D49 | 1 2 | GND + * D39 | 3 4 | D38 RST | 3 4 | D44 + * D37 | 5 6 D36 D51 | 5 6 D42 + * D34 | 7 8 | D35 D53 | 7 8 | D43 + * D40 | 9 10 | D41 D52 | 9 10 | D50 + * ------ ------ + * EXP1 EXP2 + * + *- Pin table overview + * LCD--- SPI--- + * LCD4 36 MISO 50 + * LCD5 37 SS 53 + * LCD6 38 SCKL 52 + * LCD7 39 MOSI 51 + * LCDRS 34 BEEPER + * LCDDE 35 BEEP 41 + * ENCODER--- SD-CARD--- + * BTN_EN1 42 SD_DETECT 44 + * BTN_EN2 43 KILL_PIN 49 + * BTN_ENCODER 40 + */ + +#define EXP1_01_PIN 41 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 35 +#define EXP1_04_PIN 34 +#define EXP1_05_PIN 36 +#define EXP1_06_PIN 37 +#define EXP1_07_PIN 38 +#define EXP1_08_PIN 39 + +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 43 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 44 +#define EXP2_10_PIN 49 + +#if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_01_PIN EXP1_01_PIN + #define EXP3_02_PIN EXP1_02_PIN + #define EXP3_03_PIN EXP1_03_PIN + #define EXP3_04_PIN EXP1_04_PIN + #define EXP3_05_PIN EXP1_05_PIN + #define EXP3_06_PIN EXP1_06_PIN + #define EXP3_07_PIN EXP1_07_PIN + #define EXP3_08_PIN EXP1_08_PIN +#endif + +/************************************/ +/***** Configurations Section ******/ +/************************************/ + +/** + * This sections starts with the pins_RAMPS_144.h as example, after if you need any new + * display, you could use normal duponts and connect it with with the scheme showed before. + * Tested: + * - Ender 3 Old display (Character LCD) + * - Ender 3 New Serial DWING Display + * - Reprap Display + * - Ender 5 New Serial Display + * - Any Reprap character display like + */ + +#if HAS_WIRED_LCD + + // + // LCD Display output pins + // + + #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + + #if LCD_SERIAL_PORT != 1 + #error "LCD_SERIAL_PORT should be 1 for this display." + #endif + + // DWIN Encoder + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_04_PIN + + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_01_PIN + #undef SPEAKER + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define LCD_PINS_RS EXP2_10_PIN // CS chip select /SS chip slave select + //#define LCD_PINS_ENABLE EXP2_06_PIN // SID (MOSI) + //#define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + // TO TEST + //#define LCD_PINS_RS EXP1_02_PIN + //#define LCD_PINS_ENABLE EXP2_05_PIN + //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 + //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 + //#define LCD_PINS_D6 EXP2_07_PIN + //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + // TO TEST + #define LCD_PINS_RS EXP3_04_PIN + #define LCD_PINS_ENABLE EXP3_03_PIN + #define LCD_PINS_D4 EXP3_05_PIN + + #if !IS_NEWPANEL + // TO TEST + //#define BEEPER_PIN EXP3_05_PIN + #endif + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 + //#define LCD_PINS_ENABLE EXP2_07_PIN + //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 + //#define LCD_PINS_D5 EXP1_02_PIN + //#define LCD_PINS_D6 EXP2_05_PIN + //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + // TO TEST + //#define LCD_PINS_DC 25 // Set as output on init + //#define LCD_PINS_RS 27 // Pull low for 1s to init + // DOGM SPI LCD Support + //#define DOGLCD_CS 16 + //#define DOGLCD_MOSI 17 + //#define DOGLCD_SCK 23 + //#define DOGLCD_A0 LCD_PINS_DC + + #else + // Definitions for any standard Display + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #endif + + #define LCD_PINS_D7 EXP1_08_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP1_01_PIN + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN EXP1_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN EXP1_01_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + // TO TEST + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #else + // Definitions fpr any standard Display + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + + #define BTN_ENC EXP1_02_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif + #define KILL_PIN EXP2_10_PIN + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + //#define LCD_BACKLIGHT_PIN EXP1_08_PIN // TO TEST + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 + //#define SD_DETECT_PIN EXP2_05_PIN + + #elif ENABLED(LCD_I2C_PANELOLU2) + + // TO TEST + //#define BTN_EN1 47 + //#define BTN_EN2 EXP2_03_PIN + //#define BTN_ENC 32 + //#define LCD_SDSS SDSS + //#define KILL_PIN EXP1_01_PIN + + #elif ENABLED(LCD_I2C_VIKI) + + // TO TEST + //#define BTN_EN1 EXP1_02_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_05_PIN + //#define BTN_ENC -1 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_10_PIN + + #elif EITHER(VIKI2, miniVIKI) + + // TO TEST + //#define DOGLCD_CS 45 + //#define DOGLCD_A0 EXP2_07_PIN + //#define LCD_SCREEN_ROT_180 + + //#define BEEPER_PIN 33 + //#define STAT_LED_RED_PIN 32 + //#define STAT_LED_BLUE_PIN EXP1_03_PIN + + //#define BTN_EN1 22 + //#define BTN_EN2 7 + //#define BTN_ENC EXP1_08_PIN + + //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + //#define KILL_PIN 31 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + // TO TEST + //#define DOGLCD_CS 29 + //#define DOGLCD_A0 27 + + //#define BEEPER_PIN 23 + //#define LCD_BACKLIGHT_PIN 33 + + //#define BTN_EN1 EXP1_03_PIN + //#define BTN_EN2 EXP1_06_PIN + //#define BTN_ENC 31 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN + + #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) + + // TO TEST + //#define BEEPER_PIN EXP1_06_PIN + //#define BTN_ENC EXP1_03_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + + //#ifndef KILL_PIN + // #define KILL_PIN EXP1_01_PIN + //#endif + + #if ENABLED(MKS_MINI_12864) + + // TO TEST + //#define DOGLCD_A0 27 + //#define DOGLCD_CS 25 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define BTN_EN1 31 + //#define BTN_EN2 33 + + #elif ENABLED(FYSETC_MINI_12864) + + // From https://wiki.fysetc.com/Mini12864_Panel/ + + // TO TEST + //#define DOGLCD_A0 16 + //#define DOGLCD_CS 17 + + //#define BTN_EN1 33 + //#define BTN_EN2 31 + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + //#define LCD_RESET_PIN 23 // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + // TO TEST + //#define RGB_LED_R_PIN 25 + #endif + #ifndef RGB_LED_G_PIN + // TO TEST + //#define RGB_LED_G_PIN 27 + #endif + #ifndef RGB_LED_B_PIN + // TO TEST + //#define RGB_LED_B_PIN 29 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + // TO TEST + //#define NEOPIXEL_PIN 25 + #endif + + #endif + + #elif ENABLED(MINIPANEL) + + // TO TEST + //#define BEEPER_PIN EXP2_05_PIN + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define DOGLCD_A0 EXP2_07_PIN + //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + //#define BTN_EN1 EXP1_02_PIN + //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 + //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 + + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define ADC_KEYPAD_PIN 12 + + #elif ENABLED(AZSMZ_12864) + + // TO TEST + + #else + + // Beeper on AUX-4 + //#define BEEPER_PIN 33 + + // Buttons are directly attached to AUX-2 + #if IS_RRW_KEYPAD + // TO TEST + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_CLK_PIN EXP2_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 + #elif ENABLED(PANEL_ONE) + // TO TEST + //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) + //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) + //#define BTN_ENC EXP2_10_PIN // AUX3 PIN 7 + #else + // TO TEST + //#define BTN_EN1 EXP1_06_PIN + //#define BTN_EN2 EXP1_03_PIN + //#define BTN_ENC 31 + #endif + + #if ENABLED(G3D_PANEL) + // TO TEST + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// +// SD Support +// + +/** + * Bricolemon has an SD slot, but to change it to your LCD or Custom, set the option to one of the following: + * + * LCD - Use the SD drive in the external LCD controller. + * ONBOARD - Use the SD drive on the control board. + * CUSTOM_CABLE - Use a custom cable to access the SD (as defined in a pins file). + * + * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ] + */ + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDSS 83 + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 95 +#else + #define SDSS EXP2_04_PIN +#endif + +#if HAS_TMC_UART + + /** + * Address for the UART Configuration of the TMC2209. Override in Configuration files. + * To test TMC2209 Steppers enable TMC_DEBUG in Configuration_adv.h and test the M122 command with voltage on the steppers. + */ + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0b00 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 0b01 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 0b10 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0b11 + #endif + #ifndef E1_SLAVE_ADDRESS + #define E1_SLAVE_ADDRESS 0b00 + #endif + + /** + * TMC2208/TMC2209 stepper drivers + * It seems to work perfectly fine on Software Serial, if an advanced user wants to test, you could use the SAMD51 Serial1 and Serial 2. Be careful with the Sercom configurations. + * Steppers 1,2,3,4 (X,Y,Z,E0) are on the Serial1, Sercom (RX = 0, TX = 1), extra stepper 5 (E1 or any axis you want) is on Serial2, Sercom (RX = 17, TX = 16) + */ + + //#define X_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial2 + + #define TMC_BAUD_RATE 250000 + + // + // Software serial + // + #define X_SERIAL_TX_PIN 0 + #define X_SERIAL_RX_PIN 1 + + #define Y_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define Z_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Z_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E0_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define E0_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E1_SERIAL_TX_PIN 17 + #define E1_SERIAL_RX_PIN 16 + +#endif diff --git a/src/pins/samd/pins_RAMPS_144.h b/src/pins/samd/pins_RAMPS_144.h new file mode 100644 index 0000000..2c42506 --- /dev/null +++ b/src/pins/samd/pins_RAMPS_144.h @@ -0,0 +1,571 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * AGCM4 with RAMPS v1.4.4 pin assignments + */ + +#if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) + #error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "AGCM4 RAMPS 1.4.4" +#endif + +// +// Servos +// +#define SERVO0_PIN 11 +#define SERVO1_PIN 6 +#define SERVO2_PIN 5 +#define SERVO3_PIN 4 + +// +// EEPROM +// +//#define QSPI_EEPROM // Use AGCM4 onboard QSPI EEPROM (Uses 4K of RAM) +#define I2C_EEPROM // EEPROM on I2C-0 +#define MARLIN_EEPROM_SIZE 0x8000 // 32K (24lc256) + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 18 +#endif + +// +// Steppers +// +#define X_STEP_PIN 67 // Mega/Due:54 - AGCM4:67 +#define X_DIR_PIN 68 // Mega/Due:55 - AGCM4:68 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN 47 +#endif + +#define Y_STEP_PIN 73 // Mega/Due:60 - AGCM4:73 +#define Y_DIR_PIN 74 // Mega/Due:61 - AGCM4:74 +#define Y_ENABLE_PIN 69 // Mega/Due:56 - AGCM4:69 +#ifndef Y_CS_PIN + #define Y_CS_PIN 45 +#endif + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 54 // Mega/Due:62 - AGCM4:54 +#ifndef Z_CS_PIN + #define Z_CS_PIN 32 +#endif + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +#ifndef E0_CS_PIN + #define E0_CS_PIN 43 +#endif + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#ifndef E1_CS_PIN + #define E1_CS_PIN 22 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 +#if TEMP_SENSOR_BED + #define TEMP_BED_PIN 14 +#else + #define TEMP_1_PIN 14 +#endif +#define TEMP_CHAMBER_PIN 15 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#if TEMP_SENSOR_BED + #define HEATER_BED_PIN 8 +#else + #define HEATER_1_PIN 8 +#endif +#define FAN_PIN 9 +#define FAN1_PIN 7 +#define FAN2_PIN 12 + +// +// Misc. Functions +// +#define LED_PIN 13 + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 5 // Analog Input on AUX2 +#endif + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 70 +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN 39 +#endif + +#if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN) + #if NUM_SERVOS <= 1 // Prefer the servo connector + #define CASE_LIGHT_PIN 6 // Hardware PWM + #endif +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN) + #if !NUM_SERVOS // Use servo connector if possible + #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM + #define SPINDLE_DIR_PIN 5 + #else + #error "No auto-assignable Spindle/Laser pins available." + #endif +#endif + +// +// TMC software SPI +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI 58 // Mega/Due:66 - AGCM4:58 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO 44 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK 56 // Mega/Due:64 - AGCM4:56 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN 47 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + #endif + #ifndef X2_SERIAL_TX_PIN + #define X2_SERIAL_TX_PIN -1 + #endif + #ifndef X2_SERIAL_RX_PIN + #define X2_SERIAL_RX_PIN X2_SERIAL_TX_PIN + #endif + + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN 45 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + #endif + #ifndef Y2_SERIAL_TX_PIN + #define Y2_SERIAL_TX_PIN -1 + #endif + #ifndef Y2_SERIAL_RX_PIN + #define Y2_SERIAL_RX_PIN Y2_SERIAL_TX_PIN + #endif + + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN 32 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + #endif + #ifndef Z2_SERIAL_TX_PIN + #define Z2_SERIAL_TX_PIN 22 + #endif + #ifndef Z2_SERIAL_RX_PIN + #define Z2_SERIAL_RX_PIN Z2_SERIAL_TX_PIN + #endif + + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN 43 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN -1 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + #endif +#endif + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDSS 83 + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 95 +#else + #define SDSS 53 +#endif + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +#if HAS_WIRED_LCD + + // + // LCD Display output pins + // + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define LCD_PINS_RS 49 // CS chip select /SS chip slave select + //#define LCD_PINS_ENABLE 51 // SID (MOSI) + //#define LCD_PINS_D4 52 // SCK (CLK) clock + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + // TO TEST + //#define LCD_PINS_RS 40 + //#define LCD_PINS_ENABLE 42 + //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 + //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 + //#define LCD_PINS_D6 44 + //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + // TO TEST + //#define LCD_PINS_RS 27 + //#define LCD_PINS_ENABLE 29 + //#define LCD_PINS_D4 25 + + #if !IS_NEWPANEL + // TO TEST + //#define BEEPER_PIN 37 + #endif + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 + //#define LCD_PINS_ENABLE 44 + //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 + //#define LCD_PINS_D5 40 + //#define LCD_PINS_D6 42 + //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + // TO TEST + //#define LCD_PINS_DC 25 // Set as output on init + //#define LCD_PINS_RS 27 // Pull low for 1s to init + // DOGM SPI LCD Support + //#define DOGLCD_CS 16 + //#define DOGLCD_MOSI 17 + //#define DOGLCD_SCK 23 + //#define DOGLCD_A0 LCD_PINS_DC + #else + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #endif + + #define LCD_PINS_D7 29 + + #if !IS_NEWPANEL + #define BEEPER_PIN 33 + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN 38 + //#define SHIFT_LD_PIN 42 + //#define SHIFT_OUT_PIN 40 + //#define SHIFT_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN 37 + + #if ENABLED(CR10_STOCKDISPLAY) + // TO TEST + //#define BTN_EN1 17 + //#define BTN_EN2 23 + #else + #define BTN_EN1 31 + #define BTN_EN2 33 + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + + #define BTN_ENC 35 + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN 49 + #endif + #define KILL_PIN 41 + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + //#define LCD_BACKLIGHT_PIN 39 // TO TEST + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 + //#define SD_DETECT_PIN 42 + + #elif ENABLED(LCD_I2C_PANELOLU2) + + // TO TEST + //#define BTN_EN1 47 + //#define BTN_EN2 43 + //#define BTN_ENC 32 + //#define LCD_SDSS SDSS + //#define KILL_PIN 41 + + #elif ENABLED(LCD_I2C_VIKI) + + // TO TEST + //#define BTN_EN1 40 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 42 + //#define BTN_ENC -1 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN 49 + + #elif EITHER(VIKI2, miniVIKI) + + // TO TEST + //#define DOGLCD_CS 45 + //#define DOGLCD_A0 44 + + //#define BEEPER_PIN 33 + //#define STAT_LED_RED_PIN 32 + //#define STAT_LED_BLUE_PIN 35 + + //#define BTN_EN1 22 + //#define BTN_EN2 7 + //#define BTN_ENC 39 + + //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + //#define KILL_PIN 31 + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + // TO TEST + //#define DOGLCD_CS 29 + //#define DOGLCD_A0 27 + + //#define BEEPER_PIN 23 + //#define LCD_BACKLIGHT_PIN 33 + + //#define BTN_EN1 35 + //#define BTN_EN2 37 + //#define BTN_ENC 31 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN 49 + //#define KILL_PIN 41 + + #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) + + // TO TEST + //#define BEEPER_PIN 37 + //#define BTN_ENC 35 + //#define SD_DETECT_PIN 49 + + //#ifndef KILL_PIN + // #define KILL_PIN 41 + //#endif + + #if ENABLED(MKS_MINI_12864) + + // TO TEST + //#define DOGLCD_A0 27 + //#define DOGLCD_CS 25 + + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define BTN_EN1 31 + //#define BTN_EN2 33 + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(FYSETC_MINI_12864) + + // From https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8 + + // TO TEST + //#define DOGLCD_A0 16 + //#define DOGLCD_CS 17 + + //#define BTN_EN1 33 + //#define BTN_EN2 31 + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + //#define LCD_RESET_PIN 23 // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + // TO TEST + //#define RGB_LED_R_PIN 25 + #endif + #ifndef RGB_LED_G_PIN + // TO TEST + //#define RGB_LED_G_PIN 27 + #endif + #ifndef RGB_LED_B_PIN + // TO TEST + //#define RGB_LED_B_PIN 29 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + // TO TEST + //#define NEOPIXEL_PIN 25 + #endif + + #endif + + #elif ENABLED(MINIPANEL) + + // TO TEST + //#define BEEPER_PIN 42 + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define DOGLCD_A0 44 + //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 + + //#define BTN_EN1 40 + //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 + //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 + + //#define SD_DETECT_PIN 49 + //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define ADC_KEYPAD_PIN 12 + + #elif ENABLED(AZSMZ_12864) + + // TO TEST + + #else + + // Beeper on AUX-4 + //#define BEEPER_PIN 33 + + // Buttons are directly attached to AUX-2 + #if IS_RRW_KEYPAD + // TO TEST + //#define SHIFT_OUT_PIN 40 + //#define SHIFT_CLK_PIN 44 + //#define SHIFT_LD_PIN 42 + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 + #elif ENABLED(PANEL_ONE) + // TO TEST + //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) + //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) + //#define BTN_ENC 49 // AUX3 PIN 7 + #else + // TO TEST + //#define BTN_EN1 37 + //#define BTN_EN2 35 + //#define BTN_ENC 31 + #endif + + #if ENABLED(G3D_PANEL) + // TO TEST + //#define SD_DETECT_PIN 49 + //#define KILL_PIN 41 + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD diff --git a/src/pins/sanguino/env_validate.h b/src/pins/sanguino/env_validate.h new file mode 100644 index 0000000..d229b6f --- /dev/null +++ b/src/pins/sanguino/env_validate.h @@ -0,0 +1,42 @@ + /** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if ENABLED(ALLOW_MEGA644) + #if NOT_TARGET(__AVR_ATmega644__, __AVR_ATmega644P__, __AVR_ATmega1284P__) + #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644', 'ATmega644P', or 'ATmega1284P' in 'Tools > Processor.'" + #endif +#elif ENABLED(ALLOW_MEGA644P) + #if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) + #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644P' or 'ATmega1284P' in 'Tools > Processor.'" + #endif +#elif ENABLED(REQUIRE_MEGA644P) + #if NOT_TARGET(__AVR_ATmega644P__) + #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega644P' in 'Tools > Processor.'" + #endif +#elif NOT_TARGET(__AVR_ATmega1284P__) + #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'melzi' or 'melzi_optiboot.')" +#endif + +#undef ALLOW_MEGA644 +#undef ALLOW_MEGA644P +#undef REQUIRE_MEGA644P diff --git a/src/pins/sanguino/pins_ANET_10.h b/src/pins/sanguino/pins_ANET_10.h new file mode 100644 index 0000000..bd69e16 --- /dev/null +++ b/src/pins/sanguino/pins_ANET_10.h @@ -0,0 +1,305 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Anet V1.0 board pin assignments + */ + +/** + * Rev B 16 JUN 2017 + * + * 1) no longer uses Sanguino files to define some of the pins + * 2) added pointers to useable Arduino IDE extensions + */ + +/** + * The standard Arduino IDE extension (board manager) for this board + * is located at https://github.com/SkyNet3D/anet-board. + * + * Installation instructions are on that page. + * + * After copying the files to the appropriate location, restart Arduino and + * you'll see "Anet V1.0" and "Anet V1.0 (Optiboot)" in the boards list. + * + * "Anet V1.0" uses the bootloader that was installed on the board when + * it shipped from the factory. + * + * "Anet V1.0 (Optiboot)" frees up another 3K of FLASH. You'll need to burn + * a new bootloader to the board to be able to automatically download a + * compiled image. + */ + +/** + * Another usable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +/** + * To burn a new bootloader: + * + * 1. Connect your programmer to the board. + * 2. In the Arduino IDE select the board and then select the programmer. + * 3. In the Arduino IDE click on "burn bootloader". Don't worry about the "verify failed at 1F000" error message. + * 4. The programmer is no longer needed. Remove it. + */ + +/** + * Additional info: + * + * Anet Schematics - https://github.com/ralf-e/ANET-3D-Board-V1.0 + * Wiring RRDFG Smart Controller - https://www.thingiverse.com/thing:2103748 + * SkyNet3D Anet software development - https://github.com/SkyNet3D/Marlin/ + * Anet Users / Skynet SW on Facebook - https://www.facebook.com/skynet3ddevelopment/ + * + * Many thanks to Hans Raaf (@oderwat) for developing the Anet-specific software and supporting the Anet community. + */ + +/** + * OptiBoot Bootloader: + * Optiboot is an alternative bootloader that can be flashed on the board to free up space for a larger firmware build. + * See https://github.com/Optiboot/optiboot for more information. + * + * Install Marlin with Arduino IDE: + * For a board with the stock bootloader, select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' + * For a board with OptiBoot, select 'Sanguino (Optiboot)' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' + * + * Install Marlin with PlatformIO IDE: + * (NOTE: You can set a default build environment by editing the value of 'default_env' in 'platformio.ini'. + * For the best user experience install the "Auto Build Marlin" extension.) + * For a board with the stock bootloader use Build / Upload under the 'sanguino1284p' or 'sanguino1284p_optimized' target. + * For a board with OptiBoot, use Build / Upload under the 'melzi_optiboot' target. + */ + +#if NOT_TARGET(__AVR_ATmega1284P__) + #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'sanguino1284p' or 'sanguino1284p_optimized'. With optiboot, use 'melzi_optiboot.')" +#endif + +#define BOARD_INFO_NAME "Anet 1.0" + +// +// Limit Switches +// +#define X_STOP_PIN 18 +#define Y_STOP_PIN 19 +#define Z_STOP_PIN 20 + +// +// Steppers +// +#define X_STEP_PIN 15 +#define X_DIR_PIN 21 +#define X_ENABLE_PIN 14 + +#define Y_STEP_PIN 22 +#define Y_DIR_PIN 23 +#define Y_ENABLE_PIN 14 + +#define Z_STEP_PIN 3 +#define Z_DIR_PIN 2 +#define Z_ENABLE_PIN 26 + +#define E0_STEP_PIN 1 +#define E0_DIR_PIN 0 +#define E0_ENABLE_PIN 14 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 7 // Analog Input (pin 33 extruder) +#define TEMP_BED_PIN 6 // Analog Input (pin 34 bed) + +// +// Heaters / Fans +// +#define HEATER_0_PIN 13 // (extruder) +#define HEATER_BED_PIN 12 // (bed) + +#ifndef FAN_PIN + #define FAN_PIN 4 +#endif + +// +// Misc. Functions +// +#define SDSS 31 +#define LED_PIN -1 + +/** + * LCD / Controller + * + * Only the following displays are supported: + * ZONESTAR_LCD + * ANET_FULL_GRAPHICS_LCD(_ALT_WIRING)? + * REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER + */ + +#if HAS_WIRED_LCD + + #define LCD_SDSS 28 + + #if HAS_ADC_BUTTONS + + #define SERVO0_PIN 27 // free for BLTouch/3D-Touch + #define LCD_PINS_RS 28 + #define LCD_PINS_ENABLE 29 + #define LCD_PINS_D4 10 + #define LCD_PINS_D5 11 + #define LCD_PINS_D6 16 + #define LCD_PINS_D7 17 + #define ADC_KEYPAD_PIN 1 + + #elif IS_RRD_FG_SC + + // Pin definitions for the Anet A6 Full Graphics display and the RepRapDiscount Full Graphics + // display using an adapter board // https://go.aisler.net/benlye/anet-lcd-adapter/pcb + // See below for alternative pin definitions for use with https://www.thingiverse.com/thing:2103748 + + #if ENABLED(ANET_FULL_GRAPHICS_LCD_ALT_WIRING) + #define SERVO0_PIN 30 + #define BEEPER_PIN 27 + #define LCD_PINS_RS 29 + #define LCD_PINS_ENABLE 16 + #define LCD_PINS_D4 11 + #define BTN_EN1 28 + #define BTN_EN2 10 + #define BTN_ENC 17 + #define BOARD_ST7920_DELAY_1 250 + #define BOARD_ST7920_DELAY_2 250 + #define BOARD_ST7920_DELAY_3 250 + #else + #define SERVO0_PIN 29 // free for BLTouch/3D-Touch + #define BEEPER_PIN 17 + #define LCD_PINS_RS 27 + #define LCD_PINS_ENABLE 28 + #define LCD_PINS_D4 30 + #define BTN_EN1 11 + #define BTN_EN2 10 + #define BTN_ENC 16 + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 63 + #define BOARD_ST7920_DELAY_3 125 + #endif + + #endif + +#else + #define SERVO0_PIN 27 +#endif + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN SERVO0_PIN +#endif + +/** + * ==================================================================== + * =============== Alternative RepRapDiscount Wiring ================== + * ==================================================================== + * + * An alternative wiring scheme for the RepRapDiscount Full Graphics Display is + * published by oderwat on Thingiverse at https://www.thingiverse.com/thing:2103748. + * + * Using that adapter requires changing the pin definition as follows: + * #define SERVO0_PIN 27 // free for BLTouch/3D-Touch + * #define BEEPER_PIN 28 + * #define LCD_PINS_RS 30 + * #define LCD_PINS_ENABLE 29 + * #define LCD_PINS_D4 17 + * + * The BLTouch pin becomes LCD:3 + */ + +/** + * ==================================================================== + * ===================== LCD PINOUTS ================================== + * ==================================================================== + * + * Anet V1.0 controller | ZONESTAR_LCD | ANET_FULL_ | RepRapDiscount Full | Thingiverse RepRap wiring + * physical logical alt | | GRAPHICS_LCD | Graphics Display Wiring | https://www.thingiverse + * pin pin functions | | | | .com/thing:2103748 + *------------------------------------------------------------------------------------------------------------------------ + * ANET-J3.1 8 *** | N/A | J3_TX *** | | + * ANET-J3.2 9 *** | N/A | J3_RX *** | | + * ANET-J3.3 6 MISO | N/A | MISO *** | EXP2.1 MISO | EXP2.1 MISO + * ANET-J3.4 +5V | N/A | +5V | | + * ANET-J3.5 7 SCK | N/A | SCK *** | EXP2.2 SCK | EXP2.2 SCK + * ANET-J3.6 5 MOSI | N/A | MOSI *** | EXP2.6 MOSI | EXP2.6 MOSI + * ANET-J3.7 !RESET | N/A | button | EXP2.8 panel button | EXP2.8 panel button + * ANET-J3.8 GND | N/A | GND | EXP2.9 GND | EXP2.9 GND + * ANET-J3.9 4 Don't use | N/A | N/C | | + * ANET-J3.10 +3.3V | N/A | +3.3V *** | | + * | | | | + * | | | | + * ANET-LCD.1 GND | GND | GND | EXP1.9 GND | EXP1.9 GND + * ANET-LCD.2 +5V | +5V | +5V | EXP1.10 +5V | EXP1.10 +5V + * ANET-LCD.3 27 A4 | N/C * | LCD_PINS_RS | EXP1.4 LCD_PINS_RS | EXP2.4 SDSS or N/C * + * ANET-LCD.4 10 | LCD_PINS_D4 | BTN_EN2 | EXP2.3 BTN_EN2 | EXP2.3 BTN_EN2 + * ANET-LCD.5 28 A3 | LCD_PINS_RS | LCD_PINS_ENABLE | EXP1.3 LCD_PINS_ENABLE | EXP1.1 BEEPER_PIN + * ANET-LCD.6 11 | LCD_PINS_D5 | BTN_EN1 | EXP2.5 BTN_EN1 | EXP2.5 BTN_EN1 + * ANET-LCD.7 29 A2 | LCD_PINS_ENABLE | N/C * | EXP2.4 SDSS or N/C * | EXP1.3 LCD_PINS_ENABLE + * ANET-LCD.8 16 SCL | LCD_PINS_D6 | BTN_ENC | EXP1.2 BTN_ENC | EXP1.2 BTN_ENC + * ANET-LCD.9 30 A1 | ADC_KEYPAD_PIN ** | LCD_PINS_D4 | EXP1.5 LCD_PINS_D4 | EXP1.4 LCD_PINS_RS + * ANET-LCD.10 17 SDA | LCD_PINS_D7 | BEEPER_PIN | EXP1.1 BEEPER_PIN | EXP1.5 LCD_PINS_D4 + * + * N/C * - if not connected to the LCD can be used for BLTouch servo input + * ** - analog pin -WITHOUT a pullup + * *** - only connected to something if the Bluetooth module is populated + */ + +/** + * REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER + * physical pin function + * EXP1.1 BEEPER + * EXP1.2 BTN_ENC + * EXP1.3 LCD_PINS_ENABLE + * EXP1.4 LCD_PINS_RS + * EXP1.5 LCD_PINS_D4 + * EXP1.6 LCD_PINS_D5 (not used) + * EXP1.7 LCD_PINS_D6 (not used) + * EXP1.8 LCD_PINS_D7 (not used) + * EXP1.9 GND + * EXP1.10 VCC + * + * + * EXP2.1 MISO + * EXP2.2 SCK + * EXP2.3 BTN_EN2 + * EXP2.4 SDSS + * EXP2.5 BTN_EN1 + * EXP2.6 MOSI + * EXP2.7 SD_DETECT_PIN + * EXP2.8 button + * EXP2.9 GND + * EXP2.10 NC + */ diff --git a/src/pins/sanguino/pins_AZTEEG_X1.h b/src/pins/sanguino/pins_AZTEEG_X1.h new file mode 100644 index 0000000..3edb14e --- /dev/null +++ b/src/pins/sanguino/pins_AZTEEG_X1.h @@ -0,0 +1,30 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Azteeg X1 pin assignments + */ + +#define BOARD_INFO_NAME "Azteeg X1" + +#include "pins_SANGUINOLOLU_12.h" // ... SANGUINOLOLU_11 diff --git a/src/pins/sanguino/pins_GEN3_MONOLITHIC.h b/src/pins/sanguino/pins_GEN3_MONOLITHIC.h new file mode 100644 index 0000000..1343739 --- /dev/null +++ b/src/pins/sanguino/pins_GEN3_MONOLITHIC.h @@ -0,0 +1,98 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Gen3 Monolithic Electronics pin assignments + */ + +/** + * Rev B 26 DEC 2016 + * + * added pointer to a current Arduino IDE extension + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#define REQUIRE_MEGA644P +#include "env_validate.h" + +#define BOARD_INFO_NAME "Gen3 Monolithic" +#define DEBUG_PIN 0 + +// +// Limit Switches +// +#define X_STOP_PIN 20 +#define Y_STOP_PIN 25 +#define Z_STOP_PIN 30 + +// +// Steppers +// +#define X_STEP_PIN 15 +#define X_DIR_PIN 18 +#define X_ENABLE_PIN 24 // actually uses Y_enable_pin + +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 // shared with X_enable_pin + +#define Z_STEP_PIN 27 +#define Z_DIR_PIN 28 +#define Z_ENABLE_PIN 29 + +#define E0_STEP_PIN 12 +#define E0_DIR_PIN 17 +#define E0_ENABLE_PIN 3 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input + +// +// Heaters +// +#define HEATER_0_PIN 16 + +// +// Misc. Functions +// +#define PS_ON_PIN 14 // Alex, does this work on the card? + +// Alex extras from Gen3+ diff --git a/src/pins/sanguino/pins_GEN3_PLUS.h b/src/pins/sanguino/pins_GEN3_PLUS.h new file mode 100644 index 0000000..7cab1bd --- /dev/null +++ b/src/pins/sanguino/pins_GEN3_PLUS.h @@ -0,0 +1,98 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Gen3+ pin assignments + */ + +/** + * Rev B 26 DEC 2016 + * + * added pointer to a current Arduino IDE extension + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the SANGUINO board and then select the CPU. + */ + +#define ALLOW_MEGA644P +#include "env_validate.h" + +#define BOARD_INFO_NAME "Gen3+" + +// +// Limit Switches +// +#define X_STOP_PIN 20 +#define Y_STOP_PIN 25 +#define Z_STOP_PIN 30 + +// +// Steppers +// +#define X_STEP_PIN 15 +#define X_DIR_PIN 18 +#define X_ENABLE_PIN 19 + +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 + +#define Z_STEP_PIN 27 +#define Z_DIR_PIN 28 +#define Z_ENABLE_PIN 29 + +#define E0_STEP_PIN 17 +#define E0_DIR_PIN 21 +#define E0_ENABLE_PIN 13 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input (pin 33 extruder) +#define TEMP_BED_PIN 5 // Analog Input (pin 34 bed) + +// +// Heaters +// +#define HEATER_0_PIN 12 +#define HEATER_BED_PIN 16 + +// +// Misc. Functions +// +#define SDSS 4 +#define PS_ON_PIN 14 diff --git a/src/pins/sanguino/pins_GEN6.h b/src/pins/sanguino/pins_GEN6.h new file mode 100644 index 0000000..51e8200 --- /dev/null +++ b/src/pins/sanguino/pins_GEN6.h @@ -0,0 +1,120 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Gen6 pin assignments + */ + + /** + * Rev B 26 DEC 2016 + * + * 1) added pointer to a current Arduino IDE extension + * 2) added support for M3, M4 & M5 spindle control commands + * 3) added case light pin definition + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#define ALLOW_MEGA644P +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Gen6" +#endif + +// +// Limit Switches +// +#define X_STOP_PIN 20 +#define Y_STOP_PIN 25 +#define Z_STOP_PIN 30 + +// +// Steppers +// +#define X_STEP_PIN 15 +#define X_DIR_PIN 18 +#define X_ENABLE_PIN 19 + +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 + +#define Z_STEP_PIN 27 +#define Z_DIR_PIN 28 +#define Z_ENABLE_PIN 29 + +#define E0_STEP_PIN 4 // Edited @ EJE Electronics 20100715 +#define E0_DIR_PIN 2 // Edited @ EJE Electronics 20100715 +#define E0_ENABLE_PIN 3 // Added @ EJE Electronics 20100715 + +// +// Temperature Sensor +// +#define TEMP_0_PIN 5 // Analog Input + +// +// Heaters +// +#define HEATER_0_PIN 14 // changed @ rkoeppl 20110410 + +#if !MB(GEN6) + #define HEATER_BED_PIN 1 // changed @ rkoeppl 20110410 + #define TEMP_BED_PIN 0 // Analog Input +#endif + +// +// Misc. Functions +// +#define SDSS 17 +#define DEBUG_PIN 0 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 16 // Hardware PWM +#endif + +// RS485 pins +#define TX_ENABLE_PIN 12 +#define RX_ENABLE_PIN 13 + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_ENA_PIN 5 // Pullup or pulldown! +#define SPINDLE_LASER_PWM_PIN 16 // Hardware PWM +#define SPINDLE_DIR_PIN 6 diff --git a/src/pins/sanguino/pins_GEN6_DELUXE.h b/src/pins/sanguino/pins_GEN6_DELUXE.h new file mode 100644 index 0000000..9c63570 --- /dev/null +++ b/src/pins/sanguino/pins_GEN6_DELUXE.h @@ -0,0 +1,54 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Gen6 Deluxe pin assignments + */ + +/** + * Rev B 26 DEC 2016 + * + * added pointer to a current Arduino IDE extension + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the SANGUINO board and then select the CPU. + */ + + +#define BOARD_INFO_NAME "Gen6 Deluxe" + +#include "pins_GEN6.h" diff --git a/src/pins/sanguino/pins_GEN7_12.h b/src/pins/sanguino/pins_GEN7_12.h new file mode 100644 index 0000000..0834da7 --- /dev/null +++ b/src/pins/sanguino/pins_GEN7_12.h @@ -0,0 +1,146 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Gen7 v1.1, v1.2, v1.3 pin assignments + */ + + /** + * Rev B 26 DEC 2016 + * + * 1) added pointer to a current Arduino IDE extension + * 2) added support for M3, M4 & M5 spindle control commands + * 3) added case light pin definition + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#define ALLOW_MEGA644 +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Gen7 v1.1 / 1.2" +#endif + +#ifndef GEN7_VERSION + #define GEN7_VERSION 12 // v1.x +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 7 +#define Y_MIN_PIN 5 +#define Z_MIN_PIN 1 +#define Z_MAX_PIN 0 +#define Y_MAX_PIN 2 +#define X_MAX_PIN 6 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 0 +#endif + +// +// Steppers +// +#define X_STEP_PIN 19 +#define X_DIR_PIN 18 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 + +#define Z_STEP_PIN 26 +#define Z_DIR_PIN 25 +#define Z_ENABLE_PIN 24 + +#define E0_STEP_PIN 28 +#define E0_DIR_PIN 27 +#define E0_ENABLE_PIN 24 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // Analog Input +#define TEMP_BED_PIN 2 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 4 +#define HEATER_BED_PIN 3 + +#if !defined(FAN_PIN) && GEN7_VERSION < 13 // Gen7 v1.3 removed the fan pin + #define FAN_PIN 31 +#endif + +// +// Misc. Functions +// +#define PS_ON_PIN 15 + +#if GEN7_VERSION < 13 + #define CASE_LIGHT_PIN 16 // Hardware PWM +#else // Gen7 v1.3 removed the I2C connector & signals so need to get PWM off the PC power supply header + #define CASE_LIGHT_PIN 15 // Hardware PWM +#endif + +// All these generations of Gen7 supply thermistor power +// via PS_ON, so ignore bad thermistor readings +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#define DEBUG_PIN 0 + +// RS485 pins +#define TX_ENABLE_PIN 12 +#define RX_ENABLE_PIN 13 + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_ENA_PIN 10 // Pullup or pulldown! +#define SPINDLE_DIR_PIN 11 +#if GEN7_VERSION < 13 + #define SPINDLE_LASER_PWM_PIN 16 // Hardware PWM +#else // Gen7 v1.3 removed the I2C connector & signals so need to get PWM off the PC power supply header + #define SPINDLE_LASER_PWM_PIN 15 // Hardware PWM +#endif diff --git a/src/pins/sanguino/pins_GEN7_13.h b/src/pins/sanguino/pins_GEN7_13.h new file mode 100644 index 0000000..55881aa --- /dev/null +++ b/src/pins/sanguino/pins_GEN7_13.h @@ -0,0 +1,54 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Gen7 v1.3 pin assignments + */ + +/** + * Rev B 26 DEC 2016 + * + * added pointer to a current Arduino IDE extension + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#define BOARD_INFO_NAME "Gen7 v1.3" + +#define GEN7_VERSION 13 // v1.3 +#include "pins_GEN7_12.h" diff --git a/src/pins/sanguino/pins_GEN7_14.h b/src/pins/sanguino/pins_GEN7_14.h new file mode 100644 index 0000000..97bfdd2 --- /dev/null +++ b/src/pins/sanguino/pins_GEN7_14.h @@ -0,0 +1,119 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Gen7 v1.4 pin assignments + */ + +/** + * Rev B 26 DEC 2016 + * + * 1) added pointer to a current Arduino IDE extension + * 2) added support for M3, M4 & M5 spindle control commands + * 3) added case light pin definition + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#define ALLOW_MEGA644 +#include "env_validate.h" + +#define BOARD_INFO_NAME "Gen7 v1.4" + +#define GEN7_VERSION 14 // v1.4 + +// +// Limit switches +// +#define X_STOP_PIN 0 +#define Y_STOP_PIN 1 +#define Z_STOP_PIN 2 + +// +// Steppers +// +#define X_STEP_PIN 29 +#define X_DIR_PIN 28 +#define X_ENABLE_PIN 25 + +#define Y_STEP_PIN 27 +#define Y_DIR_PIN 26 +#define Y_ENABLE_PIN 25 + +#define Z_STEP_PIN 23 +#define Z_DIR_PIN 22 +#define Z_ENABLE_PIN 25 + +#define E0_STEP_PIN 19 +#define E0_DIR_PIN 18 +#define E0_ENABLE_PIN 25 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // Analog Input +#define TEMP_BED_PIN 0 // Analog Input + +// +// Heaters +// +#define HEATER_0_PIN 4 +#define HEATER_BED_PIN 3 + +// +// Misc. Functions +// +#define PS_ON_PIN 15 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 15 // Hardware PWM +#endif + +// A pin for debugging +#define DEBUG_PIN 0 + +// RS485 pins +#define TX_ENABLE_PIN 12 +#define RX_ENABLE_PIN 13 + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_ENA_PIN 20 // Pullup or pulldown! +#define SPINDLE_LASER_PWM_PIN 16 // Hardware PWM +#define SPINDLE_DIR_PIN 21 diff --git a/src/pins/sanguino/pins_GEN7_CUSTOM.h b/src/pins/sanguino/pins_GEN7_CUSTOM.h new file mode 100644 index 0000000..6d7678e --- /dev/null +++ b/src/pins/sanguino/pins_GEN7_CUSTOM.h @@ -0,0 +1,139 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Gen7 Alfons3 board pin assignments + * + * These Pins are assigned for the modified GEN7 Board from Alfons3. + * Please review the pins and adjust them for your needs. + */ + +/** + * Rev B 26 DEC 2016 + * + * 1) added pointer to a current Arduino IDE extension + * 2) added support for M3, M4 & M5 spindle control commands + * 3) added case light pin definition + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#define ALLOW_MEGA644 +#include "env_validate.h" + +#define BOARD_INFO_NAME "Gen7 Custom" + +// +// Limit Switches +// +#define X_STOP_PIN 0 +#define Y_STOP_PIN 1 +#define Z_STOP_PIN 2 + +// +// Steppers +// +#define X_STEP_PIN 21 // different from standard GEN7 +#define X_DIR_PIN 20 // different from standard GEN7 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 + +#define Z_STEP_PIN 26 +#define Z_DIR_PIN 25 +#define Z_ENABLE_PIN 24 + +#define E0_STEP_PIN 28 +#define E0_DIR_PIN 27 +#define E0_ENABLE_PIN 24 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 2 // Analog Input +#define TEMP_BED_PIN 1 // Analog Input (pin 34 bed) + +// +// Heaters +// +#define HEATER_0_PIN 4 +#define HEATER_BED_PIN 3 // (bed) + +// +// Misc. Functions +// +#define SDSS 31 // SCL pin of I2C header || CS Pin for SD Card support +#define PS_ON_PIN 19 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 15 // Hardware PWM +#endif + +// A pin for debugging +#define DEBUG_PIN -1 + +// +// LCD / Controller +// +#define BEEPER_PIN -1 + +// 4bit LCD Support +#define LCD_PINS_RS 18 +#define LCD_PINS_ENABLE 17 +#define LCD_PINS_D4 16 +#define LCD_PINS_D5 15 +#define LCD_PINS_D6 13 +#define LCD_PINS_D7 14 + +// Buttons are directly attached +#define BTN_EN1 11 +#define BTN_EN2 10 +#define BTN_ENC 12 + +// RS485 pins +//#define TX_ENABLE_PIN 12 +//#define RX_ENABLE_PIN 13 + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_ENA_PIN 5 // Pullup or pulldown! +#define SPINDLE_LASER_PWM_PIN 16 // Hardware PWM +#define SPINDLE_DIR_PIN 6 diff --git a/src/pins/sanguino/pins_MELZI.h b/src/pins/sanguino/pins_MELZI.h new file mode 100644 index 0000000..e24636c --- /dev/null +++ b/src/pins/sanguino/pins_MELZI.h @@ -0,0 +1,47 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Melzi pin assignments + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Melzi" +#endif + +#define IS_MELZI 1 + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 0 + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 188 + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 0 + #endif +#endif + +#include "pins_SANGUINOLOLU_12.h" // ... SANGUINOLOLU_11 diff --git a/src/pins/sanguino/pins_MELZI_CREALITY.h b/src/pins/sanguino/pins_MELZI_CREALITY.h new file mode 100644 index 0000000..83aa531 --- /dev/null +++ b/src/pins/sanguino/pins_MELZI_CREALITY.h @@ -0,0 +1,141 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Melzi (Creality) pin assignments + * + * The Creality board needs a bootloader installed before Marlin can be uploaded. + * If you don't have a chip programmer you can use a spare Arduino plus a few + * electronic components to write the bootloader. + * + * See https://www.instructables.com/id/Burn-Arduino-Bootloader-with-Arduino-MEGA/ + * + * Schematic: https://bit.ly/2XOnsWb + */ + +#define BOARD_INFO_NAME "Melzi (Creality)" + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 +#endif + +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 + +// +// For the stock CR-10 enable CR10_STOCKDISPLAY in Configuration.h +// +#undef LCD_SDSS +#undef LED_PIN +#undef LCD_PINS_RS +#undef LCD_PINS_ENABLE +#undef LCD_PINS_D4 +#undef LCD_PINS_D5 +#undef LCD_PINS_D6 +#undef LCD_PINS_D7 + +#define LCD_SDSS 31 // Smart Controller SD card reader (rather than the Melzi) +#define LCD_PINS_RS 28 // ST9720 CS +#define LCD_PINS_ENABLE 17 // ST9720 DAT +#define LCD_PINS_D4 30 // ST9720 CLK + +#if ENABLED(BLTOUCH) + #ifndef SERVO0_PIN + #define SERVO0_PIN 27 + #endif + #if SERVO0_PIN == BEEPER_PIN + #undef BEEPER_PIN + #endif +#elif HAS_FILAMENT_SENSOR + #ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 27 + #endif + #if FIL_RUNOUT_PIN == BEEPER_PIN + #undef BEEPER_PIN + #endif +#endif + +#if ENABLED(MINIPANEL) + #undef DOGLCD_CS + #define DOGLCD_CS LCD_PINS_RS +#endif + +/** + PIN: 0 Port: B0 E0_DIR_PIN protected + PIN: 1 Port: B1 E0_STEP_PIN protected + PIN: 2 Port: B2 Z_DIR_PIN protected + PIN: 3 Port: B3 Z_STEP_PIN protected + PIN: 4 Port: B4 AVR_SS_PIN protected + . FAN_PIN protected + . SD_SS_PIN protected + PIN: 5 Port: B5 AVR_MOSI_PIN Output = 1 + . SD_MOSI_PIN Output = 1 + PIN: 6 Port: B6 AVR_MISO_PIN Input = 0 TIMER3A PWM: 0 WGM: 1 COM3A: 0 CS: 3 TCCR3A: 1 TCCR3B: 3 TIMSK3: 0 + . SD_MISO_PIN Input = 0 + PIN: 7 Port: B7 AVR_SCK_PIN Output = 0 TIMER3B PWM: 0 WGM: 1 COM3B: 0 CS: 3 TCCR3A: 1 TCCR3B: 3 TIMSK3: 0 + . SD_SCK_PIN Output = 0 + PIN: 8 Port: D0 RXD Input = 1 + PIN: 9 Port: D1 TXD Input = 0 + PIN: 10 Port: D2 BTN_EN2 Input = 1 + PIN: 11 Port: D3 BTN_EN1 Input = 1 + PIN: 12 Port: D4 HEATER_BED_PIN protected + PIN: 13 Port: D5 HEATER_0_PIN protected + PIN: 14 Port: D6 E0_ENABLE_PIN protected + . X_ENABLE_PIN protected + . Y_ENABLE_PIN protected + PIN: 15 Port: D7 X_STEP_PIN protected + PIN: 16 Port: C0 BTN_ENC Input = 1 + . SCL Input = 1 + PIN: 17 Port: C1 LCD_PINS_ENABLE Output = 0 + . SDA Output = 0 + PIN: 18 Port: C2 X_MIN_PIN protected + . X_STOP_PIN protected + PIN: 19 Port: C3 Y_MIN_PIN protected + . Y_STOP_PIN protected + PIN: 20 Port: C4 Z_MIN_PIN protected + . Z_STOP_PIN protected + PIN: 21 Port: C5 X_DIR_PIN protected + PIN: 22 Port: C6 Y_STEP_PIN protected + PIN: 23 Port: C7 Y_DIR_PIN protected + PIN: 24 Port: A7 TEMP_0_PIN protected + PIN: 25 Port: A6 TEMP_BED_PIN protected + PIN: 26 Port: A5 Z_ENABLE_PIN protected + PIN: 27 Port: A4 BEEPER_PIN Output = 0 + PIN: 28 Port: A3 LCD_PINS_RS Output = 0 + PIN: 29 Port: A2 Input = 0 + PIN: 30 Port: A1 LCD_PINS_D4 Output = 1 + PIN: 31 Port: A0 SDSS Output = 1 +*/ + +/** + * EXP1 Connector EXP1 as CR10 STOCKDISPLAY + * ------ ------ + * PA4 | 1 2 | PC0 BEEPER_PIN | 1 2 | BTN_ENC + * PD3 | 3 4 | RESET BTN_EN1 | 3 4 | RESET + * PD2 5 6 | PA1 BTN_EN2 5 6 | LCD_PINS_D4 (ST9720 CLK) + * PA3 | 7 8 | PC1 (ST9720 CS) LCD_PINS_RS | 7 8 | LCD_PINS_ENABLE (ST9720 DAT) + * GND | 9 10 | 5V GND | 9 10 | 5V + * ------ ------ + */ diff --git a/src/pins/sanguino/pins_MELZI_MAKR3D.h b/src/pins/sanguino/pins_MELZI_MAKR3D.h new file mode 100644 index 0000000..447eca7 --- /dev/null +++ b/src/pins/sanguino/pins_MELZI_MAKR3D.h @@ -0,0 +1,29 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Melzi with ATmega1284 (MaKr3d version) pin assignments + */ + +#define BOARD_INFO_NAME "Melzi (ATmega1284)" +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 diff --git a/src/pins/sanguino/pins_MELZI_MALYAN.h b/src/pins/sanguino/pins_MELZI_MALYAN.h new file mode 100644 index 0000000..a0421dc --- /dev/null +++ b/src/pins/sanguino/pins_MELZI_MALYAN.h @@ -0,0 +1,45 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Melzi (Malyan M150) pin assignments + */ + +#define BOARD_INFO_NAME "Melzi (Malyan)" + +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 + +#undef LCD_SDSS +#undef LCD_PINS_RS +#undef LCD_PINS_ENABLE +#undef LCD_PINS_D4 +#undef BTN_EN1 +#undef BTN_EN2 +#undef BTN_ENC + +#define LCD_PINS_RS 17 // ST9720 CS +#define LCD_PINS_ENABLE 16 // ST9720 DAT +#define LCD_PINS_D4 11 // ST9720 CLK +#define BTN_EN1 30 +#define BTN_EN2 29 +#define BTN_ENC 28 diff --git a/src/pins/sanguino/pins_MELZI_TRONXY.h b/src/pins/sanguino/pins_MELZI_TRONXY.h new file mode 100644 index 0000000..3f7b367 --- /dev/null +++ b/src/pins/sanguino/pins_MELZI_TRONXY.h @@ -0,0 +1,60 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Melzi pin assignments + */ + +#define BOARD_INFO_NAME "Melzi (Tronxy)" + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 0 +#endif + +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 + +#undef Z_ENABLE_PIN +#undef LCD_PINS_RS +#undef LCD_PINS_ENABLE +#undef LCD_PINS_D4 +#undef LCD_PINS_D5 +#undef LCD_PINS_D6 +#undef LCD_PINS_D7 +#undef BTN_EN1 +#undef BTN_EN2 +#undef BTN_ENC +#undef LCD_SDSS + +#define Z_ENABLE_PIN 14 +#define LCD_PINS_RS 30 +#define LCD_PINS_ENABLE 28 +#define LCD_PINS_D4 16 +#define LCD_PINS_D5 17 +#define LCD_PINS_D6 27 +#define LCD_PINS_D7 29 +#define BTN_EN1 10 +#define BTN_EN2 11 +#define BTN_ENC 26 diff --git a/src/pins/sanguino/pins_MELZI_V2.h b/src/pins/sanguino/pins_MELZI_V2.h new file mode 100644 index 0000000..e49eb57 --- /dev/null +++ b/src/pins/sanguino/pins_MELZI_V2.h @@ -0,0 +1,37 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Melzi V2.0 as found at https://www.reprap.org/wiki/Melzi + */ + +#define BOARD_INFO_NAME "Melzi V2" + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 0 + #define BOARD_ST7920_DELAY_2 400 + #define BOARD_ST7920_DELAY_3 0 +#endif + +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 diff --git a/src/pins/sanguino/pins_OMCA.h b/src/pins/sanguino/pins_OMCA.h new file mode 100644 index 0000000..7f18283 --- /dev/null +++ b/src/pins/sanguino/pins_OMCA.h @@ -0,0 +1,149 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Open Motion controller with enable based extruders (Final!) + * + * ATmega644 + * + * +---\/---+ + * (D 0) PB0 1| |40 PA0 (AI 0 / D31) + * (D 1) PB1 2| |39 PA1 (AI 1 / D30) + * INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29) + * PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28) + * PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27) + * MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26) + * MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25) + * SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24) + * RST 9| |32 AREF + * VCC 10| |31 GND + * GND 11| |30 AVCC + * XTAL2 12| |29 PC7 (D 23) + * XTAL1 13| |28 PC6 (D 22) + * RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI + * TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO + * INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS + * INT1 TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK + * PWM (D 12) PD4 18| |23 PC1 (D 17) SDA + * PWM (D 13) PD5 19| |22 PC0 (D 16) SCL + * PWM (D 14) PD6 20| |21 PD7 (D 15) PWM + * +--------+ + * + * REF http://sanguino.wikidot.com/hardware + */ + +/** + * Rev B 26 DEC 2016 + * + * added pointer to a current Arduino IDE extension + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at http://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega644__) + #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega644' or 'ATmega644P' in 'Tools > Processor.'" +#endif + +#define BOARD_INFO_NAME "Final OMCA" + +// +// Limit Switches +// +#define X_STOP_PIN 0 +#define Y_STOP_PIN 1 +#define Z_STOP_PIN 2 + +// +// Steppers +// +#define X_STEP_PIN 26 +#define X_DIR_PIN 25 +#define X_ENABLE_PIN 10 + +#define Y_STEP_PIN 28 +#define Y_DIR_PIN 27 +#define Y_ENABLE_PIN 10 + +#define Z_STEP_PIN 23 +#define Z_DIR_PIN 22 +#define Z_ENABLE_PIN 10 + +#define E0_STEP_PIN 24 +#define E0_DIR_PIN 21 +#define E0_ENABLE_PIN 10 + +#define E1_STEP_PIN -1 // 21 +#define E1_DIR_PIN -1 // 20 +#define E1_ENABLE_PIN -1 // 19 + +#define E2_STEP_PIN -1 // 21 +#define E2_DIR_PIN -1 // 20 +#define E2_ENABLE_PIN -1 // 18 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 1 // Analog Input +#define TEMP_BED_PIN 2 // Analog Input (1,2 or I2C) + +// +// Heaters / Fans +// +#define HEATER_0_PIN 3 // DONE PWM on RIGHT connector +#define HEATER_BED_PIN 4 + +#ifndef FAN_PIN + #define FAN_PIN 14 // PWM on MIDDLE connector +#endif + +// +// Misc. Functions +// +#define SDSS 11 + +#define I2C_SCL_PIN 16 +#define I2C_SDA_PIN 17 + +// future proofing +#define __FS 20 +#define __FD 19 +#define __GS 18 +#define __GD 13 + +#define UNUSED_PWM 14 // PWM on LEFT connector diff --git a/src/pins/sanguino/pins_OMCA_A.h b/src/pins/sanguino/pins_OMCA_A.h new file mode 100644 index 0000000..a3ceb76 --- /dev/null +++ b/src/pins/sanguino/pins_OMCA_A.h @@ -0,0 +1,135 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Open Motion controller with enable based extruders (Alpha!) + * + * ATmega644 + * + * +---\/---+ + * (D 0) PB0 1| |40 PA0 (AI 0 / D31) + * (D 1) PB1 2| |39 PA1 (AI 1 / D30) + * INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29) + * PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28) + * PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27) + * MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26) + * MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25) + * SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24) + * RST 9| |32 AREF + * VCC 10| |31 GND + * GND 11| |30 AVCC + * XTAL2 12| |29 PC7 (D 23) + * XTAL1 13| |28 PC6 (D 22) + * RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI + * TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO + * INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS + * INT1 TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK + * PWM (D 12) PD4 18| |23 PC1 (D 17) SDA + * PWM (D 13) PD5 19| |22 PC0 (D 16) SCL + * PWM (D 14) PD6 20| |21 PD7 (D 15) PWM + * +--------+ + */ + +/** + * Rev B 26 DEC 2016 + * + * added pointer to a current Arduino IDE extension + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#if NOT_TARGET(__AVR_ATmega644__) + #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega644' in 'Tools > Processor.'" +#endif + +#define BOARD_INFO_NAME "Alpha OMCA" + +// +// Limit Switches +// +#define X_STOP_PIN 0 +#define Y_STOP_PIN 1 +#define Z_STOP_PIN 2 + +// +// Steppers +// +#define X_STEP_PIN 21 +#define X_DIR_PIN 20 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 + +#define Z_STEP_PIN 26 +#define Z_DIR_PIN 25 +#define Z_ENABLE_PIN 24 + +#define E0_STEP_PIN 28 +#define E0_DIR_PIN 27 +#define E0_ENABLE_PIN 24 + +#define E1_STEP_PIN -1 // 19 +#define E1_DIR_PIN -1 // 18 +#define E1_ENABLE_PIN 24 + +#define E2_STEP_PIN -1 // 17 +#define E2_DIR_PIN -1 // 16 +#define E2_ENABLE_PIN 24 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input (D27) + +// +// Heaters / Fans +// +#define HEATER_0_PIN 4 + +#ifndef FAN_PIN + #define FAN_PIN 3 +#endif + +// +// Misc. Functions +// +#define SDSS 11 + +/* Unused (1) (2) (3) 4 5 6 7 8 9 10 11 12 13 (14) (15) (16) 17 (18) (19) (20) (21) (22) (23) 24 (25) (26) (27) 28 (29) (30) (31) */ diff --git a/src/pins/sanguino/pins_SANGUINOLOLU_11.h b/src/pins/sanguino/pins_SANGUINOLOLU_11.h new file mode 100644 index 0000000..5fe0d38 --- /dev/null +++ b/src/pins/sanguino/pins_SANGUINOLOLU_11.h @@ -0,0 +1,316 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Sanguinololu board pin assignments + */ + +/** + * Rev B 26 DEC 2016 + * + * 1) added pointer to a current Arduino IDE extension + * 2) added support for M3, M4 & M5 spindle control commands + * 3) added case light pin definition + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#define ALLOW_MEGA644P +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Sanguinololu <1.2" +#endif + +// +// Limit Switches +// +#define X_STOP_PIN 18 +#define Y_STOP_PIN 19 +#define Z_STOP_PIN 20 + +// +// Steppers +// +#define X_STEP_PIN 15 +#define X_DIR_PIN 21 + +#define Y_STEP_PIN 22 +#define Y_DIR_PIN 23 + +#define Z_STEP_PIN 3 +#define Z_DIR_PIN 2 + +#define E0_STEP_PIN 1 +#define E0_DIR_PIN 0 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 7 // Analog Input (pin 33 extruder) +#define TEMP_BED_PIN 6 // Analog Input (pin 34 bed) + +// +// Heaters / Fans +// +#define HEATER_0_PIN 13 // (extruder) + +#if ENABLED(SANGUINOLOLU_V_1_2) + + #define HEATER_BED_PIN 12 // (bed) + #define X_ENABLE_PIN 14 + #define Y_ENABLE_PIN 14 + #define Z_ENABLE_PIN 26 + #define E0_ENABLE_PIN 14 + + #if !defined(FAN_PIN) && ENABLED(LCD_I2C_PANELOLU2) + #define FAN_PIN 4 // Uses Transistor1 (PWM) on Panelolu2's Sanguino Adapter Board to drive the fan + #endif + +#else + + #define HEATER_BED_PIN 14 // (bed) + #define X_ENABLE_PIN 4 + #define Y_ENABLE_PIN 4 + #define Z_ENABLE_PIN 4 + #define E0_ENABLE_PIN 4 + +#endif + +#if !defined(FAN_PIN) && (MB(AZTEEG_X1, STB_11) || IS_MELZI) + #define FAN_PIN 4 // Works for Panelolu2 too +#endif + +// +// Misc. Functions +// + +/** + * In some versions of the Sanguino libraries the pin + * definitions are wrong, with SDSS = 24 and LED_PIN = 28 (Melzi). + * If you encounter issues with these pins, upgrade your + * Sanguino libraries! See #368. + */ +//#define SDSS 24 +#define SDSS 31 + +#if IS_MELZI + #define LED_PIN 27 +#elif MB(STB_11) + #define LCD_BACKLIGHT_PIN 17 // LCD backlight LED +#endif + +#if !HAS_CUTTER && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(HAS_WIRED_LCD, IS_NEWPANEL) // try to use IO Header + #define CASE_LIGHT_PIN 4 // Hardware PWM - see if IO Header is available +#endif + +/** + * Sanguinololu 1.4 AUX pins: + * + * PWM TX1 RX1 SDA SCL + * 12V 5V D12 D11 D10 D17 D16 + * GND GND D31 D30 D29 D28 D27 + * A4 A3 A2 A1 A0 + */ + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #define SD_DETECT_PIN -1 + + #if HAS_MARLINUI_U8GLIB + + #if ENABLED(LCD_FOR_MELZI) + + #define LCD_PINS_RS 17 + #define LCD_PINS_ENABLE 16 + #define LCD_PINS_D4 11 + #define KILL_PIN 10 + #define BEEPER_PIN 27 + + #elif IS_U8GLIB_ST7920 // SPI GLCD 12864 ST7920 ( like [www.digole.com] ) For Melzi V2.0 + + #if IS_MELZI + #define LCD_PINS_RS 30 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE 29 // SID (MOSI) + #define LCD_PINS_D4 17 // SCK (CLK) clock + // Pin 27 is taken by LED_PIN, but Melzi LED does nothing with + // Marlin so this can be used for BEEPER_PIN. You can use this pin + // with M42 instead of BEEPER_PIN. + #define BEEPER_PIN 27 + #else // Sanguinololu >=1.3 + #define LCD_PINS_RS 4 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 30 + #define LCD_PINS_D5 29 + #define LCD_PINS_D6 28 + #define LCD_PINS_D7 27 + #endif + + #else + + #define DOGLCD_A0 30 + + #if ENABLED(MAKRPANEL) + + #define BEEPER_PIN 29 + #define DOGLCD_CS 17 + #define LCD_BACKLIGHT_PIN 28 // PA3 + + #elif IS_MELZI + + #define BEEPER_PIN 27 + #define DOGLCD_CS 28 + + #else // !MAKRPANEL + + #define DOGLCD_CS 29 + + #endif + + #endif + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(ZONESTAR_LCD) // For the Tronxy Melzi boards + + #define LCD_PINS_RS 28 + #define LCD_PINS_ENABLE 29 + #define LCD_PINS_D4 10 + #define LCD_PINS_D5 11 + #define LCD_PINS_D6 16 + #define LCD_PINS_D7 17 + + #else + + #define LCD_PINS_RS 4 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 30 + #define LCD_PINS_D5 29 + #define LCD_PINS_D6 28 + #define LCD_PINS_D7 27 + + #endif + + #if ENABLED(LCD_FOR_MELZI) + + #define BTN_ENC 28 + #define BTN_EN1 29 + #define BTN_EN2 30 + + #elif ENABLED(ZONESTAR_LCD) // For the Tronxy Melzi boards + + #define ADC_KEYPAD_PIN 1 + #define BTN_EN1 -1 + #define BTN_EN2 -1 + + #elif ENABLED(LCD_I2C_PANELOLU2) + + #if IS_MELZI + #define BTN_ENC 29 + #define LCD_SDSS 30 // Panelolu2 SD card reader rather than the Melzi + #else + #define BTN_ENC 30 + #endif + + #else // !LCD_FOR_MELZI && !ZONESTAR_LCD && !LCD_I2C_PANELOLU2 + + #define BTN_ENC 16 + #define LCD_SDSS 28 // Smart Controller SD card reader rather than the Melzi + + #endif + + #if IS_NEWPANEL && !defined(BTN_EN1) + #define BTN_EN1 11 + #define BTN_EN2 10 + #endif + +#endif // HAS_WIRED_LCD + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + #if !MB(AZTEEG_X1) && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(HAS_WIRED_LCD, IS_NEWPANEL) // try to use IO Header + + #define SPINDLE_LASER_ENA_PIN 10 // Pullup or pulldown! + #define SPINDLE_LASER_PWM_PIN 4 // Hardware PWM + #define SPINDLE_DIR_PIN 11 + + #elif !MB(MELZI) // use X stepper motor socket + + /** + * To control the spindle speed and have an LCD you must sacrifice + * the Extruder and pull some signals off the X stepper driver socket. + * + * The following assumes: + * - The X stepper driver socket is empty + * - The extruder driver socket has a driver board plugged into it + * - The X stepper wires are attached the the extruder connector + */ + + /** + * Where to get the spindle signals + * + * spindle signal socket name socket name + * ------- + * /ENABLE O| |O VMOT + * MS1 O| |O GND + * MS2 O| |O 2B + * MS3 O| |O 2A + * /RESET O| |O 1A + * /SLEEP O| |O 1B + * SPINDLE_LASER_PWM_PIN STEP O| |O VDD + * SPINDLE_LASER_ENA_PIN DIR O| |O GND + * ------- + * + * Note: Socket names vary from vendor to vendor. + */ + #undef X_DIR_PIN + #undef X_ENABLE_PIN + #undef X_STEP_PIN + #define X_DIR_PIN 0 + #define X_ENABLE_PIN 14 + #define X_STEP_PIN 1 + #define SPINDLE_LASER_PWM_PIN 15 // Hardware PWM + #define SPINDLE_LASER_ENA_PIN 21 // Pullup! + #define SPINDLE_DIR_PIN -1 // No pin available on the socket for the direction pin + #endif +#endif diff --git a/src/pins/sanguino/pins_SANGUINOLOLU_12.h b/src/pins/sanguino/pins_SANGUINOLOLU_12.h new file mode 100644 index 0000000..c5c8b4f --- /dev/null +++ b/src/pins/sanguino/pins_SANGUINOLOLU_12.h @@ -0,0 +1,42 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Sanguinololu V1.2 pin assignments + * + * Applies to the following boards: + * + * AZTEEG_X1 + * MELZI + * MELZI_CREALITY + * MELZI_MAKR3D + * SANGUINOLOLU_12 + * STB_11 + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Sanguinololu 1.2" +#endif + +#define SANGUINOLOLU_V_1_2 +#include "pins_SANGUINOLOLU_11.h" diff --git a/src/pins/sanguino/pins_SETHI.h b/src/pins/sanguino/pins_SETHI.h new file mode 100644 index 0000000..a2240b3 --- /dev/null +++ b/src/pins/sanguino/pins_SETHI.h @@ -0,0 +1,123 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Sethi 3D_1 pin assignments - www.sethi3d.com.br + */ + +/** + * Rev B 26 DEC 2016 + * + * added pointer to a current Arduino IDE extension + * this assumes that this board uses the Sanguino pin map + */ + +/** + * A useable Arduino IDE extension (board manager) can be found at + * https://github.com/Lauszus/Sanguino + * + * This extension has been tested on Arduino 1.6.12 & 1.8.0 + * + * Here's the JSON path: + * https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json + * + * When installing select 1.0.2 + * + * Installation instructions can be found at https://learn.sparkfun.com/pages/CustomBoardsArduino + * Just use the above JSON URL instead of Sparkfun's JSON. + * + * Once installed select the Sanguino board and then select the CPU. + */ + +#define ALLOW_MEGA644 +#include "env_validate.h" + +#define BOARD_INFO_NAME "Sethi 3D_1" + +#ifndef GEN7_VERSION + #define GEN7_VERSION 12 // v1.x +#endif + +// +// Limit Switches +// +#define X_STOP_PIN 2 +#define Y_STOP_PIN 0 +#define Z_MIN_PIN 1 +#define Z_MAX_PIN 0 + +// +// Steppers +// +#define X_STEP_PIN 19 +#define X_DIR_PIN 18 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 22 +#define Y_ENABLE_PIN 24 + +#define Z_STEP_PIN 26 +#define Z_DIR_PIN 25 +#define Z_ENABLE_PIN 24 + +#define E0_STEP_PIN 28 +#define E0_DIR_PIN 27 +#define E0_ENABLE_PIN 24 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // Analog Input +#define TEMP_BED_PIN 2 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 4 +#define HEATER_BED_PIN 3 + +#ifndef FAN_PIN + #if GEN7_VERSION >= 13 + // Gen7 v1.3 removed the fan pin + #define FAN_PIN -1 + #else + #define FAN_PIN 31 + #endif +#endif + +// +// Misc. Functions +// +#define PS_ON_PIN 15 + +// All these generations of Gen7 supply thermistor power +// via PS_ON, so ignore bad thermistor readings +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// our pin for debugging. +#define DEBUG_PIN 0 + +// our RS485 pins +#define TX_ENABLE_PIN 12 +#define RX_ENABLE_PIN 13 diff --git a/src/pins/sanguino/pins_STB_11.h b/src/pins/sanguino/pins_STB_11.h new file mode 100644 index 0000000..ea36211 --- /dev/null +++ b/src/pins/sanguino/pins_STB_11.h @@ -0,0 +1,30 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * STB V1.1 pin assignments + */ + +#define BOARD_INFO_NAME "STB V1.1" + +#include "pins_SANGUINOLOLU_12.h" // ... SANGUINOLOLU_11 diff --git a/src/pins/sanguino/pins_ZMIB_V2.h b/src/pins/sanguino/pins_ZMIB_V2.h new file mode 100644 index 0000000..4e8731c --- /dev/null +++ b/src/pins/sanguino/pins_ZMIB_V2.h @@ -0,0 +1,232 @@ +/** + * 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 . + * + */ +#pragma once + +#define ALLOW_MEGA644P +#include "env_validate.h" + +#define BOARD_INFO_NAME "Zonestar ZMIB_V2" +#define BOARD_WEBSITE_URL "www.aliexpress.com/item/32957490744.html" + +#define IS_ZMIB_V2 + +/** + * ZMIB pin assignments + * + * The ZMIB board needs a bootloader installed before Marlin can be uploaded. + * If you don't have a chip programmer you can use a spare Arduino plus a few + * electronic components to write the bootloader. + * + * See http://www.instructables.com/id/Burn-Arduino-Bootloader-with-Arduino-MEGA/ + */ + +/** + * PIN: 0 Port: B0 HEATER_0_PIN + * PIN: 1 Port: B1 HEATER_BED_PIN + * PIN: 2 Port: B2 EXP1_4(BTN_EN2) + * PIN: 3 Port: B3 V1: SD_DETECT_PIN + * PIN: 3 Port: B3 V2: EXP1_6 + * PIN: 4 Port: B4 SDSS + * PIN: 4 Port: B4 V1: EXP1_6 + * PIN: 5 Port: B5 AVR_MOSI_PIN + * . SD_MOSI_PIN + * PIN: 6 Port: B6 AVR_MISO_PIN + * . EXP1_9(SD_MISO_PIN) + * PIN: 7 Port: B7 AVR_SCK_PIN + * . EXP1_10(SD_SCK_PIN) + * PIN: 8 Port: D0 RXD + * PIN: 9 Port: D1 TXD + * PIN: 10 Port: D2 EXP1_8 + * PIN: 11 Port: D3 EXP1_7 + * PIN: 12 Port: D4 EXP1_5(BTN_EN1) + * PIN: 13 Port: D5 Z_MIN_PIN + * PIN: 14 Port: D6 E1_DIR_PIN + * PIN: 15 Port: D7 E1_STEP_PIN + * PIN: 16 Port: C0 Z_DIR_PIN + * PIN: 17 Port: C1 Z_STEP_PIN + * PIN: 18 Port: C2 Y_MIN_PIN + * PIN: 19 Port: C3 Y_DIR_PIN + * PIN: 20 Port: C4 Y_STEP_PIN + * PIN: 21 Port: C5 X_MIN_PIN + * PIN: 22 Port: C6 X_DIR_PIN + * PIN: 23 Port: C7 X_STEP_PIN + * PIN: 24 Port: A7 X_ENABLE_PIN + * Y_ENABLE_PIN + * Z_ENABLE_PIN + * E0_ENABLE_PIN + * E1_ENABLE_PIN + * PIN: 25 Port: A6 FIL_RUNOUT_PIN + * PIN: 26 Port: A5 E0_DIR_PIN + * PIN: 27 Port: A4 E0_STEP_PIN + * PIN: 28 Port: A3 FAN_PIN + * PIN: 29 Port: A2 EXP1_3(BTN_ENC) + * ADC_KEY_PIN + * PIN: 30 Port: A1 TEMP_0_PIN + * PIN: 31 Port: A0 TEMP_BED_PIN + */ + +// +// Limit Switches +// +#define X_MIN_PIN 21 +#define Y_MIN_PIN 18 + +#if EITHER(Z6S_ZFAULT, Z6BS_ZFAULT) + #define Z_MIN_PIN 25 +#else + #define Z_MIN_PIN 13 +#endif + +// +// Steppers +// +#define X_STEP_PIN 23 +#define X_DIR_PIN 22 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 20 +#define Y_DIR_PIN 19 +#define Y_ENABLE_PIN 24 + +#if EITHER(Z6S_ZFAULT, Z6BS_ZFAULT) + #define Z_STEP_PIN 27 + #define Z_DIR_PIN 26 +#else + #define Z_STEP_PIN 17 + #define Z_DIR_PIN 16 +#endif + +#define Z_ENABLE_PIN 24 + +#if EITHER(Z6S_ZFAULT, Z6BS_ZFAULT) + #define E0_STEP_PIN 15 + #define E0_DIR_PIN 14 +#else + #define E0_STEP_PIN 27 + #define E0_DIR_PIN 26 +#endif + +#define E0_ENABLE_PIN 24 + +#define E1_STEP_PIN 15 +#define E1_DIR_PIN 14 +#define E1_ENABLE_PIN 24 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // Analog Input +#define TEMP_BED_PIN 0 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 0 +#define HEATER_BED_PIN 1 +#define FAN_PIN 28 +#define FAN1_PIN -1 + +// +// Filament Runout Sensor +// +#if EITHER(Z6S_ZFAULT, Z6BS_ZFAULT) + #define FIL_RUNOUT_PIN 13 +#else + #define FIL_RUNOUT_PIN 25 // Z-MIN +#endif + +// +// SD card +// +#if ENABLED(SDSUPPORT) + #define SDSS 4 +#endif +#define SD_DETECT_PIN -1 + +/** EXP1 + * ------ + * (MOSI) D5 | 1 2 | D7 (SCK) + * (CS) D11 | 3 4 | D10 (DC/D4) + * (EN2) D12 5 6 | D4 or D3 (EN/RS) + * (ENC) D29 | 7 8 | D2 (EN1) + * (GND) | 9 10 | (5V) + * ------ + */ +#define EXP1_01_PIN 5 +#define EXP1_02_PIN 7 +#define EXP1_03_PIN 11 +#define EXP1_04_PIN 10 +#define EXP1_05_PIN 12 +#ifndef IS_ZMIB_V2 + #define EXP1_06_PIN 4 // ZMIB V1 +#else + #define EXP1_06_PIN 3 // ZMIB V2 +#endif +#define EXP1_07_PIN 29 +#define EXP1_08_PIN 2 + +#if ENABLED(ZONESTAR_12864LCD) + // + // LCD 128x64 + // + #define LCDSCREEN_NAME "ZONESTAR_12864LCD" + #define FORCE_SOFT_SPI + //#define LCD_SDSS EXP1_03_PIN + #define LCD_PINS_RS EXP1_03_PIN // ST7920_CS_PIN (LCD module pin 4) + #define LCD_PINS_ENABLE EXP1_06_PIN // ST7920_DAT_PIN (LCD module pin 5) + #define LCD_PINS_D4 EXP1_04_PIN // ST7920_CLK_PIN (LCD module pin 6) + + #define BOARD_ST7920_DELAY_1 DELAY_2_NOP + #define BOARD_ST7920_DELAY_2 DELAY_2_NOP + #define BOARD_ST7920_DELAY_3 DELAY_2_NOP + +#elif EITHER(ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) + // + // OLED 128x64 + // + #define LCDSCREEN_NAME "ZONESTAR 12864OLED" + #define FORCE_SOFT_SPI + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN + + #if ENABLED(OLED_HW_IIC) + #error "Oops! can't choose HW IIC for ZMIB board!!" + #else + #define DOGLCD_A0 LCD_PINS_DC + #if DISABLED(OLED_HW_SPI) + #define DOGLCD_MOSI AVR_MOSI_PIN // Software SPI + #define DOGLCD_SCK AVR_SCK_PIN + #endif + #endif +#endif + +// +// All the above are also RRDSC with rotary encoder +// +#if IS_RRD_SC + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_07_PIN + #define BEEPER_PIN -1 + #define KILL_PIN -1 +#endif diff --git a/src/pins/sensitive_pins.h b/src/pins/sensitive_pins.h new file mode 100644 index 0000000..07634da --- /dev/null +++ b/src/pins/sensitive_pins.h @@ -0,0 +1,896 @@ +/** + * 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 . + * + */ +#pragma once + +// +// Prepare a list of protected pins for M42/M43 +// + +#if PIN_EXISTS(X_MIN) + #define _X_MIN X_MIN_PIN, +#else + #define _X_MIN +#endif +#if PIN_EXISTS(X_MAX) + #define _X_MAX X_MAX_PIN, +#else + #define _X_MAX +#endif +#if PIN_EXISTS(X_CS) && AXIS_HAS_SPI(X) + #define _X_CS X_CS_PIN, +#else + #define _X_CS +#endif +#if PIN_EXISTS(X_MS1) + #define _X_MS1 X_MS1_PIN, +#else + #define _X_MS1 +#endif +#if PIN_EXISTS(X_MS2) + #define _X_MS2 X_MS2_PIN, +#else + #define _X_MS2 +#endif +#if PIN_EXISTS(X_MS3) + #define _X_MS3 X_MS3_PIN, +#else + #define _X_MS3 +#endif +#if PIN_EXISTS(X_ENABLE) + #define _X_ENABLE_PIN X_ENABLE_PIN, +#else + #define _X_ENABLE_PIN +#endif + +#define _X_PINS X_STEP_PIN, X_DIR_PIN, _X_ENABLE_PIN _X_MIN _X_MAX _X_MS1 _X_MS2 _X_MS3 _X_CS + +#if HAS_Y_AXIS + + #if PIN_EXISTS(Y_MIN) + #define _Y_MIN Y_MIN_PIN, + #else + #define _Y_MIN + #endif + #if PIN_EXISTS(Y_MAX) + #define _Y_MAX Y_MAX_PIN, + #else + #define _Y_MAX + #endif + #if PIN_EXISTS(Y_CS) && AXIS_HAS_SPI(Y) + #define _Y_CS Y_CS_PIN, + #else + #define _Y_CS + #endif + #if PIN_EXISTS(Y_MS1) + #define _Y_MS1 Y_MS1_PIN, + #else + #define _Y_MS1 + #endif + #if PIN_EXISTS(Y_MS2) + #define _Y_MS2 Y_MS2_PIN, + #else + #define _Y_MS2 + #endif + #if PIN_EXISTS(Y_MS3) + #define _Y_MS3 Y_MS3_PIN, + #else + #define _Y_MS3 + #endif + #if PIN_EXISTS(Y_ENABLE) + #define _Y_ENABLE_PIN Y_ENABLE_PIN, + #else + #define _Y_ENABLE_PIN + #endif + + #define _Y_PINS Y_STEP_PIN, Y_DIR_PIN, _Y_ENABLE_PIN _Y_MIN _Y_MAX _Y_MS1 _Y_MS2 _Y_MS3 _Y_CS + +#else + + #define _Y_PINS + +#endif + +#if HAS_Z_AXIS + + #if PIN_EXISTS(Z_MIN) + #define _Z_MIN Z_MIN_PIN, + #else + #define _Z_MIN + #endif + #if PIN_EXISTS(Z_MAX) + #define _Z_MAX Z_MAX_PIN, + #else + #define _Z_MAX + #endif + #if PIN_EXISTS(Z_CS) && AXIS_HAS_SPI(Z) + #define _Z_CS Z_CS_PIN, + #else + #define _Z_CS + #endif + #if PIN_EXISTS(Z_MS1) + #define _Z_MS1 Z_MS1_PIN, + #else + #define _Z_MS1 + #endif + #if PIN_EXISTS(Z_MS2) + #define _Z_MS2 Z_MS2_PIN, + #else + #define _Z_MS2 + #endif + #if PIN_EXISTS(Z_MS3) + #define _Z_MS3 Z_MS3_PIN, + #else + #define _Z_MS3 + #endif + #if PIN_EXISTS(Z_ENABLE) + #define _Z_ENABLE_PIN Z_ENABLE_PIN, + #else + #define _Z_ENABLE_PIN + #endif + + #define _Z_PINS Z_STEP_PIN, Z_DIR_PIN, _Z_ENABLE_PIN _Z_MIN _Z_MAX _Z_MS1 _Z_MS2 _Z_MS3 _Z_CS + +#else + + #define _Z_PINS + +#endif + +#if HAS_I_AXIS + + #if PIN_EXISTS(I_MIN) + #define _I_MIN I_MIN_PIN, + #else + #define _I_MIN + #endif + #if PIN_EXISTS(I_MAX) + #define _I_MAX I_MAX_PIN, + #else + #define _I_MAX + #endif + #if PIN_EXISTS(I_CS) && AXIS_HAS_SPI(I) + #define _I_CS I_CS_PIN, + #else + #define _I_CS + #endif + #if PIN_EXISTS(I_MS1) + #define _I_MS1 I_MS1_PIN, + #else + #define _I_MS1 + #endif + #if PIN_EXISTS(I_MS2) + #define _I_MS2 I_MS2_PIN, + #else + #define _I_MS2 + #endif + #if PIN_EXISTS(I_MS3) + #define _I_MS3 I_MS3_PIN, + #else + #define _I_MS3 + #endif + #if PIN_EXISTS(I_ENABLE) + #define _I_ENABLE_PIN I_ENABLE_PIN, + #else + #define _I_ENABLE_PIN + #endif + + #define _I_PINS I_STEP_PIN, I_DIR_PIN, _I_ENABLE_PIN _I_MIN _I_MAX _I_MS1 _I_MS2 _I_MS3 _I_CS + +#else + + #define _I_PINS + +#endif + +#if HAS_J_AXIS + + #if PIN_EXISTS(J_MIN) + #define _J_MIN J_MIN_PIN, + #else + #define _J_MIN + #endif + #if PIN_EXISTS(J_MAX) + #define _J_MAX J_MAX_PIN, + #else + #define _J_MAX + #endif + #if PIN_EXISTS(J_CS) && AXIS_HAS_SPI(J) + #define _J_CS J_CS_PIN, + #else + #define _J_CS + #endif + #if PIN_EXISTS(J_MS1) + #define _J_MS1 J_MS1_PIN, + #else + #define _J_MS1 + #endif + #if PIN_EXISTS(J_MS2) + #define _J_MS2 J_MS2_PIN, + #else + #define _J_MS2 + #endif + #if PIN_EXISTS(J_MS3) + #define _J_MS3 J_MS3_PIN, + #else + #define _J_MS3 + #endif + #if PIN_EXISTS(J_ENABLE) + #define _J_ENABLE_PIN J_ENABLE_PIN, + #else + #define _J_ENABLE_PIN + #endif + + #define _J_PINS J_STEP_PIN, J_DIR_PIN, _J_ENABLE_PIN _J_MIN _J_MAX _J_MS1 _J_MS2 _J_MS3 _J_CS + +#else + + #define _J_PINS + +#endif + +#if HAS_K_AXIS + + #if PIN_EXISTS(K_MIN) + #define _K_MIN K_MIN_PIN, + #else + #define _K_MIN + #endif + #if PIN_EXISTS(K_MAX) + #define _K_MAX K_MAX_PIN, + #else + #define _K_MAX + #endif + #if PIN_EXISTS(K_CS) && AXIS_HAS_SPI(K) + #define _K_CS K_CS_PIN, + #else + #define _K_CS + #endif + #if PIN_EXISTS(K_MS1) + #define _K_MS1 K_MS1_PIN, + #else + #define _K_MS1 + #endif + #if PIN_EXISTS(K_MS2) + #define _K_MS2 K_MS2_PIN, + #else + #define _K_MS2 + #endif + #if PIN_EXISTS(K_MS3) + #define _K_MS3 K_MS3_PIN, + #else + #define _K_MS3 + #endif + #if PIN_EXISTS(K_ENABLE) + #define _K_ENABLE_PIN K_ENABLE_PIN, + #else + #define _K_ENABLE_PIN + #endif + + #define _K_PINS K_STEP_PIN, K_DIR_PIN, _K_ENABLE_PIN _K_MIN _K_MAX _K_MS1 _K_MS2 _K_MS3 _K_CS + +#else + + #define _K_PINS + +#endif + +// +// Extruder Chip Select, Digital Micro-steps +// + +// Mixing stepper, Switching stepper, or regular stepper +#define E_NEEDED(N) (ENABLED(MIXING_EXTRUDER) && MIXING_STEPPERS > N) \ + || (ENABLED(SWITCHING_EXTRUDER) && E_STEPPERS > N) \ + || (NONE(SWITCHING_EXTRUDER, MIXING_EXTRUDER) && EXTRUDERS > N) + +#define _E0_CS +#define _E0_MS1 +#define _E0_MS2 +#define _E0_MS3 + +#if E_NEEDED(0) + #if PIN_EXISTS(E0_CS) && AXIS_HAS_SPI(E0) + #undef _E0_CS + #define _E0_CS E0_CS_PIN, + #endif + #if PIN_EXISTS(E0_MS1) + #undef _E0_MS1 + #define _E0_MS1 E0_MS1_PIN, + #endif + #if PIN_EXISTS(E0_MS2) + #undef _E0_MS2 + #define _E0_MS2 E0_MS2_PIN, + #endif + #if PIN_EXISTS(E0_MS3) + #undef _E0_MS3 + #define _E0_MS3 E0_MS3_PIN, + #endif +#endif + +#define _E1_CS +#define _E1_MS1 +#define _E1_MS2 +#define _E1_MS3 + +#if E_NEEDED(1) + #if PIN_EXISTS(E1_CS) && AXIS_HAS_SPI(E1) + #undef _E1_CS + #define _E1_CS E1_CS_PIN, + #endif + #if PIN_EXISTS(E1_MS1) + #undef _E1_MS1 + #define _E1_MS1 E1_MS1_PIN, + #endif + #if PIN_EXISTS(E1_MS2) + #undef _E1_MS2 + #define _E1_MS2 E1_MS2_PIN, + #endif + #if PIN_EXISTS(E1_MS3) + #undef _E1_MS3 + #define _E1_MS3 E1_MS3_PIN, + #endif +#endif + +#define _E2_CS +#define _E2_MS1 +#define _E2_MS2 +#define _E2_MS3 + +#if E_NEEDED(2) + #if PIN_EXISTS(E2_CS) && AXIS_HAS_SPI(E2) + #undef _E2_CS + #define _E2_CS E2_CS_PIN, + #endif + #if PIN_EXISTS(E2_MS1) + #undef _E2_MS1 + #define _E2_MS1 E2_MS1_PIN, + #endif + #if PIN_EXISTS(E2_MS2) + #undef _E2_MS2 + #define _E2_MS2 E2_MS2_PIN, + #endif + #if PIN_EXISTS(E2_MS3) + #undef _E2_MS3 + #define _E2_MS3 E2_MS3_PIN, + #endif +#endif + +#define _E3_CS +#define _E3_MS1 +#define _E3_MS2 +#define _E3_MS3 + +#if E_NEEDED(3) + #if PIN_EXISTS(E3_CS) && AXIS_HAS_SPI(E3) + #undef _E3_CS + #define _E3_CS E3_CS_PIN, + #endif + #if PIN_EXISTS(E3_MS1) + #undef _E3_MS1 + #define _E3_MS1 E3_MS1_PIN, + #endif + #if PIN_EXISTS(E3_MS2) + #undef _E3_MS2 + #define _E3_MS2 E3_MS2_PIN, + #endif + #if PIN_EXISTS(E3_MS3) + #undef _E3_MS3 + #define _E3_MS3 E3_MS3_PIN, + #endif +#endif + +#define _E4_CS +#define _E4_MS1 +#define _E4_MS2 +#define _E4_MS3 + +#if E_NEEDED(4) + #if PIN_EXISTS(E4_CS) && AXIS_HAS_SPI(E4) + #undef _E4_CS + #define _E4_CS E4_CS_PIN, + #endif + #if PIN_EXISTS(E4_MS1) + #undef _E4_MS1 + #define _E4_MS1 E4_MS1_PIN, + #endif + #if PIN_EXISTS(E4_MS2) + #undef _E4_MS2 + #define _E4_MS2 E4_MS2_PIN, + #endif + #if PIN_EXISTS(E4_MS3) + #undef _E4_MS3 + #define _E4_MS3 E4_MS3_PIN, + #endif +#endif + +#define _E5_CS +#define _E5_MS1 +#define _E5_MS2 +#define _E5_MS3 + +#if E_NEEDED(5) + #if PIN_EXISTS(E5_CS) && AXIS_HAS_SPI(E5) + #undef _E5_CS + #define _E5_CS E5_CS_PIN, + #endif + #if PIN_EXISTS(E5_MS1) + #undef _E5_MS1 + #define _E5_MS1 E5_MS1_PIN, + #endif + #if PIN_EXISTS(E5_MS2) + #undef _E5_MS2 + #define _E5_MS2 E5_MS2_PIN, + #endif + #if PIN_EXISTS(E5_MS3) + #undef _E5_MS3 + #define _E5_MS3 E5_MS3_PIN, + #endif +#endif + +#define _E6_CS +#define _E6_MS1 +#define _E6_MS2 +#define _E6_MS3 + +#if E_NEEDED(6) + #if PIN_EXISTS(E6_CS) && AXIS_HAS_SPI(E6) + #undef _E6_CS + #define _E6_CS E6_CS_PIN, + #endif + #if PIN_EXISTS(E6_MS2) + #undef _E6_MS2 + #define _E6_MS2 E6_MS2_PIN, + #endif + #if PIN_EXISTS(E6_MS3) + #undef _E6_MS3 + #define _E6_MS3 E6_MS3_PIN, + #endif + #if PIN_EXISTS(E6_MS4) + #undef _E6_MS4 + #define _E6_MS4 E6_MS4_PIN, + #endif +#endif + +#define _E7_CS +#define _E7_MS1 +#define _E7_MS2 +#define _E7_MS3 + +#if E_NEEDED(7) + #if PIN_EXISTS(E7_CS) && AXIS_HAS_SPI(E7) + #undef _E7_CS + #define _E7_CS E7_CS_PIN, + #endif + #if PIN_EXISTS(E7_MS3) + #undef _E7_MS3 + #define _E7_MS3 E7_MS3_PIN, + #endif + #if PIN_EXISTS(E7_MS4) + #undef _E7_MS4 + #define _E7_MS4 E7_MS4_PIN, + #endif + #if PIN_EXISTS(E7_MS5) + #undef _E7_MS5 + #define _E7_MS5 E7_MS5_PIN, + #endif +#endif + +// +// E Steppers +// + +#define _E0_PINS +#define _E1_PINS +#define _E2_PINS +#define _E3_PINS +#define _E4_PINS +#define _E5_PINS +#define _E6_PINS +#define _E7_PINS + +#if HAS_EXTRUDERS + #undef _E0_PINS + #define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, _E0_CS _E0_MS1 _E0_MS2 _E0_MS3 +#endif + +#if ENABLED(SWITCHING_EXTRUDER) + // Tools 0 and 1 use E0 + #if EXTRUDERS > 2 // Tools 2 and 3 use E1 + #undef _E1_PINS + #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, _E1_CS _E1_MS1 _E1_MS2 _E1_MS3 + #if EXTRUDERS > 4 // Tools 4 and 5 use E2 + #undef _E2_PINS + #define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, _E2_CS _E2_MS1 _E2_MS2 _E2_MS3 + #endif + #endif + +#elif EITHER(HAS_MULTI_EXTRUDER, MIXING_EXTRUDER) + + #undef _E1_PINS + #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, _E1_CS _E1_MS1 _E1_MS2 _E1_MS3 + #if EXTRUDERS > 2 || (ENABLED(MIXING_EXTRUDER) && MIXING_STEPPERS > 2) + #undef _E2_PINS + #define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, _E2_CS _E2_MS1 _E2_MS2 _E2_MS3 + #if EXTRUDERS > 3 || (ENABLED(MIXING_EXTRUDER) && MIXING_STEPPERS > 3) + #undef _E3_PINS + #define _E3_PINS E3_STEP_PIN, E3_DIR_PIN, E3_ENABLE_PIN, _E3_CS _E3_MS1 _E3_MS2 _E3_MS3 + #if EXTRUDERS > 4 || (ENABLED(MIXING_EXTRUDER) && MIXING_STEPPERS > 4) + #undef _E4_PINS + #define _E4_PINS E4_STEP_PIN, E4_DIR_PIN, E4_ENABLE_PIN, _E4_CS _E4_MS1 _E4_MS2 _E4_MS3 + #if EXTRUDERS > 5 || (ENABLED(MIXING_EXTRUDER) && MIXING_STEPPERS > 5) + #undef _E5_PINS + #define _E5_PINS E5_STEP_PIN, E5_DIR_PIN, E5_ENABLE_PIN, _E5_CS _E5_MS1 _E5_MS2 _E5_MS3 + #if EXTRUDERS > 6 || (ENABLED(MIXING_EXTRUDER) && MIXING_STEPPERS > 6) + #undef _E6_PINS + #define _E6_PINS E6_STEP_PIN, E6_DIR_PIN, E6_ENABLE_PIN, _E6_CS _E6_MS1 _E6_MS2 _E6_MS3 + #if EXTRUDERS > 7 || (ENABLED(MIXING_EXTRUDER) && MIXING_STEPPERS > 7) + #undef _E7_PINS + #define _E7_PINS E7_STEP_PIN, E7_DIR_PIN, E7_ENABLE_PIN, _E7_CS _E7_MS1 _E7_MS2 _E7_MS3 + #endif // EXTRUDERS > 7 || MIXING_EXTRUDER > 7 + #endif // EXTRUDERS > 6 || MIXING_EXTRUDER > 6 + #endif // EXTRUDERS > 5 || MIXING_EXTRUDER > 5 + #endif // EXTRUDERS > 4 || MIXING_EXTRUDER > 4 + #endif // EXTRUDERS > 3 || MIXING_EXTRUDER > 3 + #endif // EXTRUDERS > 2 || MIXING_EXTRUDER > 2 + +#endif // HAS_MULTI_EXTRUDER || MIXING_EXTRUDER + +// +// Heaters, Fans, Temp Sensors +// + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN -1 +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN -1 +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN -1 +#endif +#ifndef E3_AUTO_FAN_PIN + #define E3_AUTO_FAN_PIN -1 +#endif +#ifndef E4_AUTO_FAN_PIN + #define E4_AUTO_FAN_PIN -1 +#endif +#ifndef E5_AUTO_FAN_PIN + #define E5_AUTO_FAN_PIN -1 +#endif +#ifndef E6_AUTO_FAN_PIN + #define E6_AUTO_FAN_PIN -1 +#endif +#ifndef E7_AUTO_FAN_PIN + #define E7_AUTO_FAN_PIN -1 +#endif + +#define _H0_PINS +#define _H1_PINS +#define _H2_PINS +#define _H3_PINS +#define _H4_PINS +#define _H5_PINS +#define _H6_PINS +#define _H7_PINS + +#define DIO_PIN(P) TERN(TARGET_LPC1768, P, analogInputToDigitalPin(P)) + +#if HAS_HOTEND + #undef _H0_PINS + #define _H0_PINS HEATER_0_PIN, E0_AUTO_FAN_PIN, DIO_PIN(TEMP_0_PIN), + #if HAS_MULTI_HOTEND + #undef _H1_PINS + #define _H1_PINS HEATER_1_PIN, E1_AUTO_FAN_PIN, DIO_PIN(TEMP_1_PIN), + #if HOTENDS > 2 + #undef _H2_PINS + #define _H2_PINS HEATER_2_PIN, E2_AUTO_FAN_PIN, DIO_PIN(TEMP_2_PIN), + #if HOTENDS > 3 + #undef _H3_PINS + #define _H3_PINS HEATER_3_PIN, E3_AUTO_FAN_PIN, DIO_PIN(TEMP_3_PIN), + #if HOTENDS > 4 + #undef _H4_PINS + #define _H4_PINS HEATER_4_PIN, E4_AUTO_FAN_PIN, DIO_PIN(TEMP_4_PIN), + #if HOTENDS > 5 + #undef _H5_PINS + #define _H5_PINS HEATER_5_PIN, E5_AUTO_FAN_PIN, DIO_PIN(TEMP_5_PIN), + #if HOTENDS > 6 + #undef _H6_PINS + #define _H6_PINS HEATER_6_PIN, E6_AUTO_FAN_PIN, DIO_PIN(TEMP_6_PIN), + #if HOTENDS > 7 + #undef _H7_PINS + #define _H7_PINS HEATER_7_PIN, E7_AUTO_FAN_PIN, DIO_PIN(TEMP_7_PIN), + #endif // HOTENDS > 7 + #endif // HOTENDS > 6 + #endif // HOTENDS > 5 + #endif // HOTENDS > 4 + #endif // HOTENDS > 3 + #endif // HOTENDS > 2 + #endif // HAS_MULTI_HOTEND +#endif // HOTENDS + +// +// Dual X, Dual Y, Multi-Z +// Chip Select and Digital Micro-stepping +// + +#if HAS_X2_STEPPER + #if PIN_EXISTS(X2_CS) && AXIS_HAS_SPI(X2) + #define _X2_CS X2_CS_PIN, + #else + #define _X2_CS + #endif + #if PIN_EXISTS(X2_MS1) + #define _X2_MS1 X2_MS1_PIN, + #else + #define _X2_MS1 + #endif + #if PIN_EXISTS(X2_MS2) + #define _X2_MS2 X2_MS2_PIN, + #else + #define _X2_MS2 + #endif + #if PIN_EXISTS(X2_MS3) + #define _X2_MS3 X2_MS3_PIN, + #else + #define _X2_MS3 + #endif + #define _X2_PINS X2_STEP_PIN, X2_DIR_PIN, X2_ENABLE_PIN, _X2_CS _X2_MS1 _X2_MS2 _X2_MS3 +#else + #define _X2_PINS +#endif + +#if HAS_DUAL_Y_STEPPERS + #if PIN_EXISTS(Y2_CS) && AXIS_HAS_SPI(Y2) + #define _Y2_CS Y2_CS_PIN, + #else + #define _Y2_CS + #endif + #if PIN_EXISTS(Y2_MS1) + #define _Y2_MS1 Y2_MS1_PIN, + #else + #define _Y2_MS1 + #endif + #if PIN_EXISTS(Y2_MS2) + #define _Y2_MS2 Y2_MS2_PIN, + #else + #define _Y2_MS2 + #endif + #if PIN_EXISTS(Y2_MS3) + #define _Y2_MS3 Y2_MS3_PIN, + #else + #define _Y2_MS3 + #endif + #define _Y2_PINS Y2_STEP_PIN, Y2_DIR_PIN, Y2_ENABLE_PIN, _Y2_CS _Y2_MS1 _Y2_MS2 _Y2_MS3 +#else + #define _Y2_PINS +#endif + +#if NUM_Z_STEPPERS >= 2 + #if PIN_EXISTS(Z2_CS) && AXIS_HAS_SPI(Z2) + #define _Z2_CS Z2_CS_PIN, + #else + #define _Z2_CS + #endif + #if PIN_EXISTS(Z2_MS1) + #define _Z2_MS1 Z2_MS1_PIN, + #else + #define _Z2_MS1 + #endif + #if PIN_EXISTS(Z2_MS2) + #define _Z2_MS2 Z2_MS2_PIN, + #else + #define _Z2_MS2 + #endif + #if PIN_EXISTS(Z2_MS3) + #define _Z2_MS3 Z2_MS3_PIN, + #else + #define _Z2_MS3 + #endif + #define _Z2_PINS Z2_STEP_PIN, Z2_DIR_PIN, Z2_ENABLE_PIN, _Z2_CS _Z2_MS1 _Z2_MS2 _Z2_MS3 +#else + #define _Z2_PINS +#endif + +#if NUM_Z_STEPPERS >= 3 + #if PIN_EXISTS(Z3_CS) && AXIS_HAS_SPI(Z3) + #define _Z3_CS Z3_CS_PIN, + #else + #define _Z3_CS + #endif + #if PIN_EXISTS(Z3_MS1) + #define _Z3_MS1 Z3_MS1_PIN, + #else + #define _Z3_MS1 + #endif + #if PIN_EXISTS(Z3_MS2) + #define _Z3_MS2 Z3_MS2_PIN, + #else + #define _Z3_MS2 + #endif + #if PIN_EXISTS(Z3_MS3) + #define _Z3_MS3 Z3_MS3_PIN, + #else + #define _Z3_MS3 + #endif + #define _Z3_PINS Z3_STEP_PIN, Z3_DIR_PIN, Z3_ENABLE_PIN, _Z3_CS _Z3_MS1 _Z3_MS2 _Z3_MS3 +#else + #define _Z3_PINS +#endif + +#if NUM_Z_STEPPERS >= 4 + #if PIN_EXISTS(Z4_CS) && AXIS_HAS_SPI(Z4) + #define _Z4_CS Z4_CS_PIN, + #else + #define _Z4_CS + #endif + #if PIN_EXISTS(Z4_MS1) + #define _Z4_MS1 Z4_MS1_PIN, + #else + #define _Z4_MS1 + #endif + #if PIN_EXISTS(Z4_MS2) + #define _Z4_MS2 Z4_MS2_PIN, + #else + #define _Z4_MS2 + #endif + #if PIN_EXISTS(Z4_MS3) + #define _Z4_MS3 Z4_MS3_PIN, + #else + #define _Z4_MS3 + #endif + #define _Z4_PINS Z4_STEP_PIN, Z4_DIR_PIN, Z4_ENABLE_PIN, _Z4_CS _Z4_MS1 _Z4_MS2 _Z4_MS3 +#else + #define _Z4_PINS +#endif + +// +// Generate the final Sensitive Pins array, +// keeping the array as small as possible. +// + +#if PIN_EXISTS(PS_ON) + #define _PS_ON PS_ON_PIN, +#else + #define _PS_ON +#endif + +#if HAS_BED_PROBE && PIN_EXISTS(Z_MIN_PROBE) + #define _Z_PROBE Z_MIN_PROBE_PIN, +#else + #define _Z_PROBE +#endif + +#if PIN_EXISTS(FAN) + #define _FAN0 FAN_PIN, +#else + #define _FAN0 +#endif +#if PIN_EXISTS(FAN1) + #define _FAN1 FAN1_PIN, +#else + #define _FAN1 +#endif +#if PIN_EXISTS(FAN2) + #define _FAN2 FAN2_PIN, +#else + #define _FAN2 +#endif +#if PIN_EXISTS(FAN3) + #define _FAN3 FAN3_PIN, +#else + #define _FAN3 +#endif +#if PIN_EXISTS(FAN4) + #define _FAN4 FAN4_PIN, +#else + #define _FAN4 +#endif +#if PIN_EXISTS(FAN5) + #define _FAN5 FAN5_PIN, +#else + #define _FAN5 +#endif +#if PIN_EXISTS(FAN6) + #define _FAN6 FAN6_PIN, +#else + #define _FAN6 +#endif +#if PIN_EXISTS(FAN7) + #define _FAN7 FAN7_PIN, +#else + #define _FAN7 +#endif +#if PIN_EXISTS(CONTROLLER_FAN) + #define _FANC CONTROLLER_FAN_PIN, +#else + #define _FANC +#endif + +#if TEMP_SENSOR_BED && PINS_EXIST(TEMP_BED, HEATER_BED) + #define _BED_PINS HEATER_BED_PIN, DIO_PIN(TEMP_BED_PIN), +#else + #define _BED_PINS +#endif + +#if TEMP_SENSOR_CHAMBER && PIN_EXISTS(TEMP_CHAMBER) + #define _CHAMBER_TEMP DIO_PIN(TEMP_CHAMBER_PIN), +#else + #define _CHAMBER_TEMP +#endif +#if TEMP_SENSOR_CHAMBER && PINS_EXIST(TEMP_CHAMBER, HEATER_CHAMBER) + #define _CHAMBER_HEATER HEATER_CHAMBER_PIN, +#else + #define _CHAMBER_HEATER +#endif +#if TEMP_SENSOR_CHAMBER && PINS_EXIST(TEMP_CHAMBER, CHAMBER_AUTO_FAN) + #define _CHAMBER_FAN CHAMBER_AUTO_FAN_PIN, +#else + #define _CHAMBER_FAN +#endif + +#if TEMP_SENSOR_COOLER && PIN_EXISTS(TEMP_COOLER) + #define _COOLER_TEMP DIO_PIN(TEMP_COOLER_PIN), +#else + #define _COOLER_TEMP +#endif +#if TEMP_SENSOR_COOLER && PIN_EXISTS(COOLER) + #define _COOLER COOLER_PIN, +#else + #define _COOLER +#endif +#if TEMP_SENSOR_COOLER && PINS_EXIST(TEMP_COOLER, COOLER_AUTO_FAN) + #define _COOLER_FAN COOLER_AUTO_FAN_PIN, +#else + #define _COOLER_FAN +#endif + +#ifndef HAL_SENSITIVE_PINS + #define HAL_SENSITIVE_PINS +#endif + +#ifdef RUNTIME_ONLY_ANALOG_TO_DIGITAL + #define _SP_END +#else + #define _SP_END -2 + + // Move a regular pin in front to the end + template + struct OnlyPins : OnlyPins { }; + + // Remove a -1 from the front + template + struct OnlyPins<-1, D...> : OnlyPins { }; + + // Remove -2 from the front, emit the rest, cease propagation + template + struct OnlyPins<_SP_END, D...> { static constexpr size_t size = sizeof...(D); static constexpr pin_t table[sizeof...(D)] PROGMEM = { D... }; }; +#endif + +#define SENSITIVE_PINS \ + _X_PINS _Y_PINS _Z_PINS _I_PINS _J_PINS _K_PINS \ + _X2_PINS _Y2_PINS _Z2_PINS _Z3_PINS _Z4_PINS _Z_PROBE \ + _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS _E5_PINS _E6_PINS _E7_PINS \ + _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS _H5_PINS _H6_PINS _H7_PINS \ + _PS_ON _FAN0 _FAN1 _FAN2 _FAN3 _FAN4 _FAN5 _FAN6 _FAN7 _FANC \ + _BED_PINS _CHAMBER_TEMP _CHAMBER_HEATER _CHAMBER_FAN \ + _COOLER_TEMP _COOLER _COOLER_FAN HAL_SENSITIVE_PINS \ + _SP_END diff --git a/src/pins/stm32f0/pins_MALYAN_M200_V2.h b/src/pins/stm32f0/pins_MALYAN_M200_V2.h new file mode 100644 index 0000000..178c873 --- /dev/null +++ b/src/pins/stm32f0/pins_MALYAN_M200_V2.h @@ -0,0 +1,30 @@ +/** + * 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 . + * + */ +#pragma once + +#if NOT_TARGET(STM32F0xx) + #error "Oops! Select an STM32F0 board in your IDE." +#endif + +#define BOARD_INFO_NAME "Malyan M200 V2" + +#include "../stm32f1/pins_MALYAN_M200.h" diff --git a/src/pins/stm32f0/pins_MALYAN_M300.h b/src/pins/stm32f0/pins_MALYAN_M300.h new file mode 100644 index 0000000..d38d4bb --- /dev/null +++ b/src/pins/stm32f0/pins_MALYAN_M300.h @@ -0,0 +1,90 @@ +/** + * 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 . + * + */ +#pragma once + +#if NOT_TARGET(__STM32F1__, STM32F1xx, STM32F0xx) + #error "Oops! Select a 'Malyan M300' board in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "Malyan M300" + +// +// EEPROM Emulation +// +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + #ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x800U // 2K + #endif +#endif + +// +// SD CARD SPI +// +#define SDSS SD_SS_PIN + +// +// Timers +// +#define STEP_TIMER 6 +#define TEMP_TIMER 7 + +// +// Limit Switches +// +#define X_MAX_PIN PC13 +#define Y_MAX_PIN PC14 +#define Z_MAX_PIN PC15 +#define Z_MIN_PIN PB7 + +// +// Steppers +// +#define X_STEP_PIN PB14 +#define X_DIR_PIN PB13 +#define X_ENABLE_PIN PB10 + +#define Y_STEP_PIN PB12 +#define Y_DIR_PIN PB11 +#define Y_ENABLE_PIN PB10 + +#define Z_STEP_PIN PB2 +#define Z_DIR_PIN PB1 +#define Z_ENABLE_PIN PB10 + +#define E0_STEP_PIN PA7 +#define E0_DIR_PIN PA6 +#define E0_ENABLE_PIN PB0 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input (HOTEND0 thermistor) +#define TEMP_BED_PIN PA4 // Analog Input (BED thermistor) + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA1 // HOTEND0 MOSFET +#define HEATER_BED_PIN PA5 // BED MOSFET + +#define AUTO_FAN_PIN PA8 diff --git a/src/pins/stm32f1/env_validate.h b/src/pins/stm32f1/env_validate.h new file mode 100644 index 0000000..2d32542 --- /dev/null +++ b/src/pins/stm32f1/env_validate.h @@ -0,0 +1,32 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(__STM32F1__, STM32F1) + #if DISABLED(ALLOW_STM32F4) + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" + #elif NOT_TARGET(STM32F4) + #error "Oops! Select an STM32F4 board in 'Tools > Board.'" + #endif +#endif + +#undef ALLOW_STM32F4 diff --git a/src/pins/stm32f1/pins_BEAST.h b/src/pins/stm32f1/pins_BEAST.h new file mode 100644 index 0000000..4dafe2f --- /dev/null +++ b/src/pins/stm32f1/pins_BEAST.h @@ -0,0 +1,145 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +/** + * 21017 Victor Perez Marlin for stm32f1 test + */ + +#define BOARD_INFO_NAME "Beast STM32" +#define DEFAULT_MACHINE_NAME "STM32F103RET6" + +// Enable I2C_EEPROM for testing +#define I2C_EEPROM + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// Limit Switches +// +#define X_STOP_PIN PD5 +#define Y_STOP_PIN PD6 +#define Z_STOP_PIN PD7 + +// +// Steppers +// +#define X_STEP_PIN PE0 +#define X_DIR_PIN PE1 +#define X_ENABLE_PIN PC0 + +#define Y_STEP_PIN PE2 +#define Y_DIR_PIN PE3 +#define Y_ENABLE_PIN PC1 + +#define Z_STEP_PIN PE4 +#define Z_DIR_PIN PE5 +#define Z_ENABLE_PIN PC2 + +#define E0_STEP_PIN PE6 +#define E0_DIR_PIN PE7 +#define E0_ENABLE_PIN PC3 + +/** + * TODO: Currently using same Enable pin to all steppers. + */ + +#define E1_STEP_PIN PE8 +#define E1_DIR_PIN PE9 +#define E1_ENABLE_PIN PC4 + +#define E2_STEP_PIN PE10 +#define E2_DIR_PIN PE11 +#define E2_ENABLE_PIN PC5 + +// +// Misc. Functions +// +#define SDSS PA15 +#define LED_PIN PB2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PD12 // EXTRUDER 1 +#define HEATER_1_PIN PD13 +#define HEATER_2_PIN PD14 + +#define HEATER_BED_PIN PB9 // BED + +#ifndef FAN_PIN + #define FAN_PIN PB10 +#endif + +#define FAN_SOFT_PWM_REQUIRED + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA0 // Analog Input +#define TEMP_0_PIN PA1 // Analog Input +#define TEMP_1_PIN PA2 // Analog Input +#define TEMP_2_PIN PA3 // Analog Input + +// +// LCD Pins +// +#if HAS_WIRED_LCD + + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + #error "REPRAPWORLD_GRAPHICAL_LCD is not supported." + #else + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE PD2 + #define LCD_PINS_D4 PB12 + #define LCD_PINS_D5 PB13 + #define LCD_PINS_D6 PB14 + #define LCD_PINS_D7 PB15 + #if !IS_NEWPANEL + #error "Non-NEWPANEL LCD is not supported." + #endif + #endif + + #if IS_NEWPANEL + #if IS_RRD_SC + #error "RRD Smart Controller is not supported." + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + #error "REPRAPWORLD_GRAPHICAL_LCD is not supported." + #elif ENABLED(LCD_I2C_PANELOLU2) + #error "LCD_I2C_PANELOLU2 is not supported." + #elif ENABLED(LCD_I2C_VIKI) + #error "LCD_I2C_VIKI is not supported." + #elif EITHER(VIKI2, miniVIKI) + #error "VIKI2 / miniVIKI is not supported." + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." + #elif ENABLED(MINIPANEL) + #error "MINIPANEL is not supported." + #else + #error "Other generic NEWPANEL LCD is not supported." + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD diff --git a/src/pins/stm32f1/pins_BTT_SKR_CR6.h b/src/pins/stm32f1/pins_BTT_SKR_CR6.h new file mode 100644 index 0000000..e3e91ff --- /dev/null +++ b/src/pins/stm32f1/pins_BTT_SKR_CR6.h @@ -0,0 +1,186 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * BigTreeTech SKR CR-6 (STM32F103RET6) board pin assignments + */ + +#define DEFAULT_MACHINE_NAME "Creality3D" +#define BOARD_INFO_NAME "BTT SKR CR-6" + +#include "env_validate.h" + +// +// Release PB4 (Z_STEP_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// USB connect control +// +#define USB_CONNECT_PIN PA14 +#define USB_CONNECT_INVERTING false + +// +// EEPROM +// + +#if NO_EEPROM_SELECTED + #define I2C_EEPROM +#endif + +#if ENABLED(I2C_EEPROM) + #define IIC_EEPROM_SDA PB7 + #define IIC_EEPROM_SCL PB6 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#elif ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Limit Switches +// + +#define X_STOP_PIN PC0 +#define Y_STOP_PIN PC1 +#define Z_STOP_PIN PC14 // Endstop or Probe + +#define FIL_RUNOUT_PIN PC15 + +// +// Probe +// +#ifndef PROBE_TARE_PIN + #define PROBE_TARE_PIN PA1 +#endif + +#if ENABLED(PROBE_ACTIVATION_SWITCH) + #ifndef PROBE_ACTIVATION_SWITCH_PIN + #define PROBE_ACTIVATION_SWITCH_PIN PC2 // Optoswitch to Enable Z Probe + #endif +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PB14 +#define X_STEP_PIN PB13 +#define X_DIR_PIN PB12 + +#define Y_ENABLE_PIN PB11 +#define Y_STEP_PIN PB10 +#define Y_DIR_PIN PB2 + +#define Z_ENABLE_PIN PB1 +#define Z_STEP_PIN PB0 +#define Z_DIR_PIN PC5 + +#define E0_ENABLE_PIN PD2 +#define E0_STEP_PIN PB3 +#define E0_DIR_PIN PB4 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // TH1 +#define TEMP_BED_PIN PC3 // TB1 + +// +// Heaters / Fans +// + +#define HEATER_0_PIN PC8 // HEATER1 +#define HEATER_BED_PIN PC9 // HOT BED + +#define FAN_PIN PC6 // FAN +#define FAN_SOFT_PWM_REQUIRED + +#define CONTROLLER_FAN_PIN PC7 + +// +// LCD / Controller +// +#if ENABLED(CR10_STOCKDISPLAY) + #define BTN_ENC PA15 + #define BTN_EN1 PA9 + #define BTN_EN2 PA10 + + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE PB15 + #define LCD_PINS_D4 PB9 + + #define BEEPER_PIN PB5 +#endif + +#if HAS_TMC_UART + /** + * TMC2209 stepper drivers + * Hardware serial communication ports. + */ + #define X_HARDWARE_SERIAL MSerial4 + #define Y_HARDWARE_SERIAL MSerial4 + #define Z_HARDWARE_SERIAL MSerial4 + #define E0_HARDWARE_SERIAL MSerial4 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 1 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 2 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + +// +// SD Card +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN PC4 + #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card + #define SDSS ONBOARD_SD_CS_PIN +#endif + +// +// Misc. Functions +// +#define CASE_LIGHT_PIN PA13 + +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA8 +#endif + +#define SUICIDE_PIN PC13 +#ifndef SUICIDE_PIN_STATE + #define SUICIDE_PIN_STATE LOW +#endif diff --git a/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h new file mode 100644 index 0000000..f9c9de4 --- /dev/null +++ b/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -0,0 +1,292 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "BTT SKR E3 DIP V1.x" + +// Release PB3/PB4 (TMC_SW Pins) from JTAG pins +#define DISABLE_JTAG + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +// +// Servos +// +#define SERVO0_PIN PA1 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PC1 // X-STOP +#define Y_STOP_PIN PC0 // Y-STOP +#define Z_STOP_PIN PC15 // Z-STOP + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PC14 // PROBE + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC2 // E0-STOP +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC7 +#define X_STEP_PIN PC6 +#define X_DIR_PIN PB15 +#ifndef X_CS_PIN + #define X_CS_PIN PC10 +#endif + +#define Y_ENABLE_PIN PB14 +#define Y_STEP_PIN PB13 +#define Y_DIR_PIN PB12 +#ifndef Y_CS_PIN + #define Y_CS_PIN PC11 +#endif + +#define Z_ENABLE_PIN PB11 +#define Z_STEP_PIN PB10 +#define Z_DIR_PIN PB2 +#ifndef Z_CS_PIN + #define Z_CS_PIN PC12 +#endif + +#define E0_ENABLE_PIN PB1 +#define E0_STEP_PIN PB0 +#define E0_DIR_PIN PC5 +#ifndef E0_CS_PIN + #define E0_CS_PIN PD2 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB5 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB4 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB3 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC11 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD2 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input "TH0" +#define TEMP_BED_PIN PC3 // Analog Input "TB0" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC8 // "HE" +#define HEATER_BED_PIN PC9 // "HB" +#define FAN_PIN PA8 // "FAN0" + +// +// USB connect control +// +#define USB_CONNECT_PIN PC13 +#define USB_CONNECT_INVERTING false + +/** + * ------ + * (BEEPER) PA15 | 1 2 | PB6 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PB7 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + +#if HAS_WIRED_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN PA15 + + #define BTN_ENC PB6 + #define BTN_EN1 PA9 + #define BTN_EN2 PA10 + + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE PB7 + #define LCD_PINS_D4 PB9 + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_DIP.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define LCD_PINS_RS PB9 + #define LCD_PINS_ENABLE PB6 + #define LCD_PINS_D4 PB8 + #define LCD_PINS_D5 PA10 + #define LCD_PINS_D6 PA9 + #define LCD_PINS_D7 PA15 + #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + /** Creality Ender-2 display pinout + * ------ + * (SCK) PA15 | 1 2 | PB6 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_A0) + * (LCD_RS) PB8 | 7 8 | PB7 (MOSI) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + + #define BTN_ENC PB6 + #define BTN_EN1 PA9 + #define BTN_EN2 PA10 + + #define DOGLCD_CS PB8 + #define DOGLCD_A0 PB9 + #define DOGLCD_SCK PA15 + #define DOGLCD_MOSI PB7 + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and MKS_LCD12864A/B are currently supported on the BIGTREE_SKR_E3_DIP." + #endif + +#endif // HAS_WIRED_LCD + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_E3_DIP.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** FYSETC TFT TFT81050 display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PA15 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (MOSI) 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 7 8 | PB7 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SP11-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN PB6 + + #define CLCD_MOD_RESET PA9 + #define CLCD_SPI_CS PB8 + +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN PC4 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 +#elif SD_CONNECTION_IS(LCD) && BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + #define SD_DETECT_PIN PA15 + #define SD_SS_PIN PA10 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR E3 DIP." +#endif + +#define ONBOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card +#define SDSS ONBOARD_SD_CS_PIN diff --git a/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h b/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h new file mode 100644 index 0000000..a09da02 --- /dev/null +++ b/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h @@ -0,0 +1,51 @@ +/** + * 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 . + * + */ +#pragma once + +#include "pins_BTT_SKR_MINI_E3_common.h" + +#define BOARD_INFO_NAME "BTT SKR Mini E3 V1.0" + +/** + * TMC220x stepper drivers + * Hardware serial communication ports. + */ +#if HAS_TMC_UART + #define X_HARDWARE_SERIAL MSerial4 + #define Y_HARDWARE_SERIAL MSerial4 + #define Z_HARDWARE_SERIAL MSerial4 + #define E0_HARDWARE_SERIAL MSerial4 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif diff --git a/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h b/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h new file mode 100644 index 0000000..44d4f23 --- /dev/null +++ b/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h @@ -0,0 +1,50 @@ +/** + * 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 . + * + */ +#pragma once + +#include "pins_BTT_SKR_MINI_E3_common.h" + +#define BOARD_INFO_NAME "BTT SKR Mini E3 V1.2" + +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PC7 // LED driving pin +#endif + +/** + * TMC2208/TMC2209 stepper drivers + */ +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PB15 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC6 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC10 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PC11 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif diff --git a/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h new file mode 100644 index 0000000..b5fddc4 --- /dev/null +++ b/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -0,0 +1,84 @@ +/** + * 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 . + * + */ +#pragma once + +#define SKR_MINI_E3_V2 + +#define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 + +// Onboard I2C EEPROM +#if NO_EEPROM_SELECTED + #define I2C_EEPROM + #define SOFT_I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x1000 // 4K + #define I2C_SDA_PIN PB7 + #define I2C_SCL_PIN PB6 + #undef NO_EEPROM_SELECTED +#endif + +#include "pins_BTT_SKR_MINI_E3_common.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR Mini E3 V2.0" +#endif + +// Release PA13/PA14 (led, usb control) from SWD pins +#define DISABLE_DEBUG + +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA8 // LED driving pin +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN PC13 // Power Supply Control +#endif + +#define FAN1_PIN PC7 + +#ifndef CONTROLLER_FAN_PIN + #define CONTROLLER_FAN_PIN FAN1_PIN +#endif + +#if HAS_TMC_UART + /** + * TMC220x stepper drivers + * Hardware serial communication ports + */ + #define X_HARDWARE_SERIAL MSerial4 + #define Y_HARDWARE_SERIAL MSerial4 + #define Z_HARDWARE_SERIAL MSerial4 + #define E0_HARDWARE_SERIAL MSerial4 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif diff --git a/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h new file mode 100644 index 0000000..537e905 --- /dev/null +++ b/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -0,0 +1,386 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +// Release PB3/PB4 (E0 STP/DIR) from JTAG pins +#define DISABLE_JTAG + +#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +// +// Servos +// +#define SERVO0_PIN PA1 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PC0 // X-STOP +#define Y_STOP_PIN PC1 // Y-STOP +#define Z_STOP_PIN PC2 // Z-STOP + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PC14 // PROBE + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // E0-STOP +#endif + +// +// Power-loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC12 // Power Loss Detection: PWR-DET +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PB14 +#define X_STEP_PIN PB13 +#define X_DIR_PIN PB12 + +#define Y_ENABLE_PIN PB11 +#define Y_STEP_PIN PB10 +#define Y_DIR_PIN PB2 + +#define Z_ENABLE_PIN PB1 +#define Z_STEP_PIN PB0 +#define Z_DIR_PIN PC5 + +#define E0_ENABLE_PIN PD2 +#define E0_STEP_PIN PB3 +#define E0_DIR_PIN PB4 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input "TH0" +#define TEMP_BED_PIN PC3 // Analog Input "TB0" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC8 // "HE" +#define HEATER_BED_PIN PC9 // "HB" + +#ifdef SKR_MINI_E3_V2 + #define FAN_PIN PC6 +#else + #define FAN_PIN PA8 // "FAN0" +#endif + +// +// USB connect control +// +#ifdef SKR_MINI_E3_V2 + #define USB_CONNECT_PIN PA14 +#else + #define USB_CONNECT_PIN PC13 +#endif + +#define USB_CONNECT_INVERTING false + +/** + * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 + * ------ ------ + * (BEEPER) PB5 | 1 2 | PB6 (BTN_ENC) (BEEPER) PB5 | 1 2 | PA15 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PB7 (LCD_EN) (LCD_RS) PB8 | 7 8 | PB15 (LCD_EN) + * GND | 9 10 | 5V GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP1 + */ +#ifdef SKR_MINI_E3_V2 + #define EXP1_02_PIN PA15 + #define EXP1_08_PIN PB15 +#else + #define EXP1_02_PIN PB6 + #define EXP1_08_PIN PB7 +#endif + +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + /** + * ------ ------ ------ + * (ENT) | 1 2 | (BEEP) |10 9 | |10 9 | + * (RX) | 3 4 | (RX) | 8 7 | (TX) RX | 8 7 | TX + * (TX) 5 6 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP + * (B) | 7 8 | (A) (B) | 4 3 | (A) B | 4 3 | A + * GND | 9 10 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * ------ ------ ------ + * EXP1 DWIN DWIN (plug) + * + * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on. + */ + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! Ender-3 V2 display requires a custom cable. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define BEEPER_PIN EXP1_02_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 PB8 + #define BTN_ENC PB5 + +#elif HAS_WIRED_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN PB5 + #define BTN_ENC EXP1_02_PIN + + #define BTN_EN1 PA9 + #define BTN_EN2 PA10 + + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 PB9 + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define LCD_PINS_RS PB9 + #define LCD_PINS_ENABLE EXP1_02_PIN + #define LCD_PINS_D4 PB8 + #define LCD_PINS_D5 PA10 + #define LCD_PINS_D6 PA9 + #define LCD_PINS_D7 PB5 + #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 PA9 + #define BTN_EN2 PA10 + + #define DOGLCD_CS PB8 + #define DOGLCD_A0 PB9 + #define DOGLCD_SCK PB5 + #define DOGLCD_MOSI EXP1_08_PIN + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * TFTGLCD_PANEL_SPI display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PB5 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET -- | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (MOSI) | 6 5 | -- + * (LCD_CS) PB8 | 7 8 | PB7 (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- n/c + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- n/c + * EXP1-3 ----------- EXP1-3 LCD_CS + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET + */ + + #define TFTGLCD_CS PA9 + + #endif + + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 display pinout + * + * Board Display + * ------ ------ + * PB5 | 1 2 | PA15 (BEEP) |10 9 | BTN_ENC + * PA9 | 3 4 | RESET LCD_CS | 8 7 | LCD A0 + * PA10 | 5 6 | PB9 LCD_RST | 6 5 | RED + * PB8 | 7 8 | PB15 (GREEN) | 4 3 | (BLUE) + * GND | 9 10 | 5V GND | 2 1 | 5V + * ------ ------ + * EXP1 EXP1 + * + * --- ------ + * RST | 1 | (MISO) |10 9 | SCK + * (RX2) PA2 | 2 | BTN_EN1 | 8 7 | (SS) + * (TX2) PA3 | 3 | BTN_EN2 | 6 5 | MOSI + * GND | 4 | (CD) | 4 3 | (RST) + * 5V | 5 | (GND) | 2 1 | (KILL) + * --- ------ + * TFT EXP2 + * + * Needs custom cable: + * + * Board Display + * + * EXP1-10 ---------- EXP1-1 5V + * EXP1-9 ----------- EXP1-2 GND + * EXP1-8 ----------- EXP2-6 EN2 + * EXP1-7 ----------- EXP1-5 RED + * EXP1-6 ----------- EXP2-8 EN1 + * EXP1-5 ----------- EXP1-6 LCD_RST + * EXP1-4 ----------- n/c + * EXP1-3 ----------- EXP1-8 LCD_CS + * EXP1-2 ----------- EXP1-9 ENC + * EXP1-1 ----------- EXP1-7 LCD_A0 + * + * TFT-2 ----------- EXP2-9 SCK + * TFT-3 ----------- EXP2-5 MOSI + * + * for backlight configuration see steps 2 (V2.1) and 3 in https://wiki.fysetc.com/Mini12864_Panel/ + */ + + #define LCD_PINS_RS PA9 // CS + #define LCD_PINS_ENABLE PA3 // MOSI + #define LCD_BACKLIGHT_PIN -1 + #define NEOPIXEL_PIN PB8 + #define LCD_CONTRAST 255 + #define LCD_RESET_PIN PA10 + + #define DOGLCD_CS PA9 + #define DOGLCD_A0 PB5 + #define DOGLCD_SCK PA2 + #define DOGLCD_MOSI PA3 + + #define BTN_ENC PA15 + #define BTN_EN1 PB9 + #define BTN_EN2 PB15 + + #define FORCE_SOFT_SPI + + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, TFTGLCD_PANEL_(SPI|I2C), FYSETC_MINI_12864_2_1, MKS_MINI_12864_V3, and BTT_MINI_12864_V1 are currently supported on the BIGTREE_SKR_MINI_E3." + #endif + +#endif // HAS_WIRED_LCD + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * FYSETC TFT TFT81050 display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PB5 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 7 8 | PB7 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN EXP1_02_PIN + + #define CLCD_MOD_RESET PA9 + #define CLCD_SPI_CS PB8 + +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN PC4 +#elif SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL) + #define SD_DETECT_PIN PB5 + #define SD_SS_PIN PA10 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." +#endif + +#define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1... +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card + +#define ENABLE_SPI1 +#define SDSS ONBOARD_SD_CS_PIN +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 diff --git a/src/pins/stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h b/src/pins/stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h new file mode 100644 index 0000000..8133955 --- /dev/null +++ b/src/pins/stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h @@ -0,0 +1,26 @@ +/** + * 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 . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT SKR Mini MZ V1.0" + +#include "pins_BTT_SKR_MINI_E3_V2_0.h" // ... BTT_SKR_MINI_E3_common diff --git a/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h new file mode 100644 index 0000000..4e343fa --- /dev/null +++ b/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -0,0 +1,257 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "BTT SKR Mini V1.1" + +//#define DISABLE_DEBUG +#define DISABLE_JTAG + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +// +// Limit Switches +// +#define X_MIN_PIN PC2 +#define X_MAX_PIN PA2 +#define Y_MIN_PIN PC1 +#define Y_MAX_PIN PA1 +#define Z_MIN_PIN PC0 +#define Z_MAX_PIN PC3 + +// +// Steppers +// + +#define X_STEP_PIN PC6 +#define X_DIR_PIN PC7 +#define X_ENABLE_PIN PB15 + +#define Y_STEP_PIN PB13 +#define Y_DIR_PIN PB14 +#define Y_ENABLE_PIN PB12 + +#define Z_STEP_PIN PB10 +#define Z_DIR_PIN PB11 +#define Z_ENABLE_PIN PB2 + +#define E0_STEP_PIN PC5 +#define E0_DIR_PIN PB0 +#define E0_ENABLE_PIN PC4 + +#if ENABLED(TMC_USE_SW_SPI) // Shared with EXP2 + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB3 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB4 + #endif + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB5 + #endif +#endif + +#if HAS_TMC_UART // Shared with EXP1 + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC11 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PC14 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA8 +#define FAN_PIN PC8 +#define HEATER_BED_PIN PC9 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PB1 // Analog Input +#define TEMP_0_PIN PA0 // Analog Input + +/** ------ ------ + * (BEEPER) PC10 | 1 2 | PC11 (BTN_ENC) (MISO) PB4 | 1 2 | PB3 (SCK) + * (LCD_EN) PB6 | 3 4 | PC12 (LCD_RS) (BTN_EN1) PD2 | 3 4 | PA15 (SD_SS) + * (LCD_D4) PC13 5 6 | PB7 (LCD_D5) (BTN_EN2) PB8 5 6 | PB5 (MOSI) + * (LCD_D6) PC15 | 7 8 | PC14 (LCD_D7) (SD_DETECT) PB9 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC10 +#define EXP1_02_PIN PC11 +#define EXP1_03_PIN PB6 +#define EXP1_04_PIN PC12 +#define EXP1_05_PIN PC13 +#define EXP1_06_PIN PB7 +#define EXP1_07_PIN PC15 +#define EXP1_08_PIN PC14 + +#define EXP2_01_PIN PB4 +#define EXP2_02_PIN PB3 +#define EXP2_03_PIN PD2 +#define EXP2_04_PIN PA15 +#define EXP2_05_PIN PB8 +#define EXP2_06_PIN PB5 +#define EXP2_07_PIN PB9 +#define EXP2_08_PIN -1 // RESET + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif IS_TFTGLCD_PANEL + + #undef BEEPER_PIN + #undef BTN_ENC + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + + #define SD_DETECT_PIN EXP2_07_PIN + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + + #if ENABLED(FYSETC_MINI_12864) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + #define FORCE_SOFT_SPI // SPI MODE3 + + #define LED_PIN EXP1_06_PIN // red pwm + //#define LED_PIN EXP1_07_PIN // green + //#define LED_PIN EXP1_08_PIN // blue + + //#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + // #ifndef RGB_LED_R_PIN + // #define RGB_LED_R_PIN EXP1_06_PIN + // #endif + // #ifndef RGB_LED_G_PIN + // #define RGB_LED_G_PIN EXP1_07_PIN + // #endif + // #ifndef RGB_LED_B_PIN + // #define RGB_LED_B_PIN EXP1_08_PIN + // #endif + //#elif ENABLED(FYSETC_MINI_12864_2_1) + // #define NEOPIXEL_PIN EXP1_06_PIN + //#endif + + #else // !FYSETC_MINI_12864 + + #define LCD_PINS_D4 EXP1_05_PIN + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif // !FYSETC_MINI_12864 + + // Alter timing for graphical display + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 + #endif + + #endif + +#endif // HAS_WIRED_LCD + +// +// SD Card +// + +// By default the onboard SD is enabled. +// Change SDCARD_CONNECTION from 'ONBOARD' to 'LCD' for an external (LCD module) SD +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(LCD) + #define SPI_DEVICE 3 + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_SS_PIN EXP2_04_PIN +#elif SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN PA3 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_SS_PIN PA4 +#endif +#define ONBOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card diff --git a/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h new file mode 100644 index 0000000..c73544b --- /dev/null +++ b/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -0,0 +1,185 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "CCROBOT-ONLINE MEEB_3DP only supports 1 hotend / E stepper." +#endif + +// https://github.com/ccrobot-online/MEEB_3DP +// Pin assignments for 32-bit MEEB_3DP +#define BOARD_INFO_NAME "CCROBOT-ONLINE MEEB_3DP" +#define DEFAULT_MACHINE_NAME "STM32F103RCT6" +#define BOARD_WEBSITE_URL "ccrobot-online.com" + +// +// Release PB4 from JTAG NRST role +// +#define DISABLE_JTAG + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE 0x800U // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Servos +// +#define SERVO0_PIN PA1 + +// +// Limit Switches +// +#define X_STOP_PIN PC0 +#define Y_STOP_PIN PC1 +#define Z_STOP_PIN PC2 + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PC15 // "PROBE" + +// +// TMC2208 stepper drivers +// +#define X_ENABLE_PIN PB4 +#define X_STEP_PIN PC12 +#define X_DIR_PIN PC11 + +#define Y_ENABLE_PIN PC10 +#define Y_STEP_PIN PB14 +#define Y_DIR_PIN PB13 + +#define Z_ENABLE_PIN PB12 +#define Z_STEP_PIN PB2 +#define Z_DIR_PIN PB1 + +#define E0_ENABLE_PIN PB0 +#define E0_STEP_PIN PA6 +#define E0_DIR_PIN PA5 + +#if HAS_TMC_UART + // Stepper drivers Serial UART + #define X_SERIAL_TX_PIN PB3 + #define X_SERIAL_RX_PIN PD2 + + #define Y_SERIAL_TX_PIN PA15 + #define Y_SERIAL_RX_PIN PC6 + + #define Z_SERIAL_TX_PIN PB11 + #define Z_SERIAL_RX_PIN PB10 + + #define E0_SERIAL_TX_PIN PC5 + #define E0_SERIAL_RX_PIN PC4 +#endif + +// Reduce baud rate to improve software serial reliability +#define TMC_BAUD_RATE 19200 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // TH0 +#define TEMP_BED_PIN PC3 // THB + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC8 // HEATER0 +#define HEATER_BED_PIN PC9 // HOT BED + +#define FAN_PIN PA7 // FAN (fan2 on board) model cool fan +#define FAN1_PIN PA8 // FAN (fan0 on board) e0 cool fan +#define FAN2_PIN PB9 // FAN (fan1 on board) controller cool fan + +// One NeoPixel onboard and a connector for other NeoPixels +#define NEOPIXEL_PIN PC7 // The NEOPIXEL LED driving pin + +/** + * ------ + * PB5 | 1 2 | PB6 + * PA2 | 3 4 | RESET + * PA3 5 6 | PB8 + * PB7 | 7 8 | PA4 + * GND | 9 10 | VCC5 + * ------ + * EXP1 + */ +#define EXP1_01_PIN PB5 +#define EXP1_02_PIN PB6 +#define EXP1_03_PIN PA2 +#define EXP1_04_PIN -1 // RESET +#define EXP1_05_PIN PA3 +#define EXP1_06_PIN PB8 +#define EXP1_07_PIN PB7 +#define EXP1_08_PIN PA4 + +// +// LCD / Controller +// +#if ENABLED(CR10_STOCKDISPLAY) + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN + + #define LCD_PINS_RS EXP1_07_PIN // CS -- SOFT SPI for ENDER3 LCD + #define LCD_PINS_D4 EXP1_06_PIN // SCLK + #define LCD_PINS_ENABLE EXP1_08_PIN // DATA MOSI +#endif + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 +#endif + +// +// Camera +// +#define CHDK_PIN PB15 + +#if 0 + +// +// SD-NAND +// +#if SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN -1 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_SS_PIN PA4 +#endif + +#define ONBOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PA4 // Chip select for SD-NAND + +#endif diff --git a/src/pins/stm32f1/pins_CHITU3D.h b/src/pins/stm32f1/pins_CHITU3D.h new file mode 100644 index 0000000..3b66096 --- /dev/null +++ b/src/pins/stm32f1/pins_CHITU3D.h @@ -0,0 +1,265 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +/** + * 2017 Victor Perez Marlin for stm32f1 test + */ + +#define BOARD_INFO_NAME "Chitu3D" +#define DEFAULT_MACHINE_NAME "STM32F103RET6" + +#define BOARD_NO_NATIVE_USB + +// Enable I2C_EEPROM for testing +//#define I2C_EEPROM + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// Limit Switches +// +#define X_STOP_PIN PG10 +#define Y_STOP_PIN PA12 +#define Z_STOP_PIN PA14 + +// +// Steppers +// +#define X_STEP_PIN PE5 +#define X_DIR_PIN PE6 +#define X_ENABLE_PIN PC13 + +#define Y_STEP_PIN PE2 +#define Y_DIR_PIN PE3 +#define Y_ENABLE_PIN PE4 + +#define Z_STEP_PIN PB9 +#define Z_DIR_PIN PE0 +#define Z_ENABLE_PIN PE1 + +#define E0_STEP_PIN PB4 +#define E0_DIR_PIN PB5 +#define E0_ENABLE_PIN PB8 + +// +// Misc. Functions +// +#define SDSS -1 +#define LED_PIN -1 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN PA8 // 8 +#endif + +#define PS_ON_PIN -1 +#define KILL_PIN PD6 // LED strip 24v + +// +// Heaters / Fans +// +#define HEATER_0_PIN PD12 // HOT-END +#define HEATER_BED_PIN PG11 // HOT-BED + +#ifndef FAN_PIN + #define FAN_PIN PG14 // MAIN BOARD FAN +#endif + +#define FAN_SOFT_PWM_REQUIRED + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA1 // Analog Input +#define TEMP_BED_PIN PA0 // Analog Input + +// +// LCD Pins +// +#if HAS_WIRED_LCD + + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + #define LCD_PINS_RS PD1 // 49 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE PD3 // 51 // SID (MOSI) + #define LCD_PINS_D4 PD4 // 52 // SCK (CLK) clock + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE PD2 + #define LCD_PINS_D4 PB12 + #define LCD_PINS_D5 PB13 + #define LCD_PINS_D6 PB14 + #define LCD_PINS_D7 PB15 + #else + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE PD2 + #define LCD_PINS_D4 PB12 + #define LCD_PINS_D5 PB13 + #define LCD_PINS_D6 PB14 + #define LCD_PINS_D7 PB15 + #if !IS_NEWPANEL + #define BEEPER_PIN PC1 // 33 + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN PC6 // 38 + //#define SHIFT_LD_PIN PC10 // 42 + //#define SHIFT_OUT_PIN PC8 // 40 + //#define SHIFT_EN_PIN PA1 // 17 + #endif + #endif + + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN PC5 + + #define BTN_EN1 PB15 // 31 + #define BTN_EN2 PC1 // 33 + #define BTN_ENC PC3 // 35 + + #define SD_DETECT_PIN PD1 // 49 + #define KILL_PIN PC9 // 41 + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + #define LCD_BACKLIGHT_PIN PC7 // 39 + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define BTN_EN1 PE0 // 64 + #define BTN_EN2 PD11 // 59 + #define BTN_ENC PD15 // 63 + #define SD_DETECT_PIN PC10 // 42 + + #elif ENABLED(LCD_I2C_PANELOLU2) + + #define BTN_EN1 PC15 // 47 + #define BTN_EN2 PC11 // 43 + #define BTN_ENC PC0 // 32 + #define LCD_SDSS PD5 // 53 + #define SD_DETECT_PIN -1 + #define KILL_PIN PC9 // 41 + + #elif ENABLED(LCD_I2C_VIKI) + + #define BTN_EN1 PB6 // 22 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + #define BTN_EN2 PA7 // 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13. + + #define BTN_ENC -1 + #define LCD_SDSS PD5 // 53 + #define SD_DETECT_PIN PD1 // 49 + + #elif EITHER(VIKI2, miniVIKI) + + #define BEEPER_PIN PC1 // 33 + + // Pins for DOGM SPI LCD Support + #define DOGLCD_A0 PC12 // 44 + #define DOGLCD_CS PC13 // 45 + + #define BTN_EN1 PB6 // 22 + #define BTN_EN2 PA7 // 7 + #define BTN_ENC PC7 // 39 + + #define SDSS PD5 // 53 + #define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board + + #define KILL_PIN PB15 // 31 + + #define STAT_LED_RED_PIN PC0 // 32 + #define STAT_LED_BLUE_PIN PC3 // 35 + + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + #define BTN_EN1 PC3 // 35 + #define BTN_EN2 PC5 // 37 + #define BTN_ENC PB15 // 31 + #define SD_DETECT_PIN PD1 // 49 + #define LCD_SDSS PD5 // 53 + #define KILL_PIN PC9 // 41 + #define BEEPER_PIN PB7 // 23 + #define DOGLCD_CS PB13 // 29 + #define DOGLCD_A0 PB11 // 27 + #define LCD_BACKLIGHT_PIN PC1 // 33 + + #elif ENABLED(MINIPANEL) + + #define BEEPER_PIN PC10 // 42 + // Pins for DOGM SPI LCD Support + #define DOGLCD_A0 PC12 // 44 + #define DOGLCD_CS PE2 // 66 + #define LCD_BACKLIGHT_PIN PE1 // 65 // backlight LED on A11/D65 + #define SDSS PD5 // 53 + + #define KILL_PIN PE0 // 64 + + // The encoder and click button + #define BTN_EN1 PC8 // 40 + #define BTN_EN2 PD15 // 63 + #define BTN_ENC PD11 // 59 + // not connected to a pin + #define SD_DETECT_PIN PD1 // 49 + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #else + + // Beeper on AUX-4 + #define BEEPER_PIN PC1 // 33 + + // Buttons directly attached to AUX-2 + #if IS_RRW_KEYPAD + #define BTN_EN1 PE0 // 64 + #define BTN_EN2 PD11 // 59 + #define BTN_ENC PD15 // 63 + #define SHIFT_OUT_PIN PC8 // 40 + #define SHIFT_CLK_PIN PC12 // 44 + #define SHIFT_LD_PIN PC10 // 42 + #elif ENABLED(PANEL_ONE) + #define BTN_EN1 PD11 // 59 // AUX2 PIN 3 + #define BTN_EN2 PD15 // 63 // AUX2 PIN 4 + #define BTN_ENC PD1 // 49 // AUX3 PIN 7 + #else + #define BTN_EN1 PC5 // 37 + #define BTN_EN2 PC3 // 35 + #define BTN_ENC PB15 // 31 + #endif + + #if ENABLED(G3D_PANEL) + #define SD_DETECT_PIN PD1 // 49 + #define KILL_PIN PC9 // 41 + #else + //#define SD_DETECT_PIN -1 // Ramps doesn't use this + #endif + + #endif + #endif // IS_NEWPANEL + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/stm32f1/pins_CHITU3D_V5.h b/src/pins/stm32f1/pins_CHITU3D_V5.h new file mode 100644 index 0000000..53b6797 --- /dev/null +++ b/src/pins/stm32f1/pins_CHITU3D_V5.h @@ -0,0 +1,28 @@ +/** + * 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 . + * + */ +#pragma once + +#define BOARD_INFO_NAME "Chitu3D V5" + +#define Z_STOP_PIN PA14 + +#include "pins_CHITU3D_common.h" diff --git a/src/pins/stm32f1/pins_CHITU3D_V6.h b/src/pins/stm32f1/pins_CHITU3D_V6.h new file mode 100644 index 0000000..b76ef52 --- /dev/null +++ b/src/pins/stm32f1/pins_CHITU3D_V6.h @@ -0,0 +1,34 @@ +/** + * 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 . + * + */ +#pragma once + +#define BOARD_INFO_NAME "Chitu3D V6" + +#define Z2_ENABLE_PIN PF3 +#define Z2_STEP_PIN PF5 +#define Z2_DIR_PIN PF1 + +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN PF13 +#endif + +#include "pins_CHITU3D_common.h" diff --git a/src/pins/stm32f1/pins_CHITU3D_V9.h b/src/pins/stm32f1/pins_CHITU3D_V9.h new file mode 100644 index 0000000..0d02e1d --- /dev/null +++ b/src/pins/stm32f1/pins_CHITU3D_V9.h @@ -0,0 +1,40 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "Chitu3D V9" + +#define Z_STOP_PIN PA14 + +#define Z2_ENABLE_PIN PF3 +#define Z2_STEP_PIN PF5 +#define Z2_DIR_PIN PF1 +#define Z2_STOP_PIN PA13 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PG9 +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN PF13 +#endif + +#include "pins_CHITU3D_common.h" diff --git a/src/pins/stm32f1/pins_CHITU3D_common.h b/src/pins/stm32f1/pins_CHITU3D_common.h new file mode 100644 index 0000000..bc41e97 --- /dev/null +++ b/src/pins/stm32f1/pins_CHITU3D_common.h @@ -0,0 +1,177 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Chitu3D" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "STM32F103ZET6" +#endif + +#define BOARD_NO_NATIVE_USB +#define DISABLE_JTAG + +// +// EEPROM +// + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) + #define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE) + #define EEPROM_PAGE_SIZE (0x800U) // 2K, but will use 2x more (4K) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#else + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2K, require this amount of RAM +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PG10 +#define Y_STOP_PIN PA12 +#ifndef Z_STOP_PIN + #define Z_STOP_PIN PG9 +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC13 +#define X_STEP_PIN PE5 +#define X_DIR_PIN PE6 + +#define Y_ENABLE_PIN PE4 +#define Y_STEP_PIN PE2 +#define Y_DIR_PIN PE3 + +#define Z_ENABLE_PIN PE1 +#define Z_STEP_PIN PB9 +#define Z_DIR_PIN PE0 + +#define E0_ENABLE_PIN PB8 +#define E0_STEP_PIN PB4 +#define E0_DIR_PIN PB5 + +#define E1_ENABLE_PIN PG8 +#define E1_STEP_PIN PC7 +#define E1_DIR_PIN PC6 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA1 // TH1 Analog Input +#define TEMP_BED_PIN PA0 // TB1 Analog Input + +// +// Heaters +// +#define HEATER_0_PIN PG12 // HEATER1 +#define HEATER_BED_PIN PG11 // HOT BED +//#define HEATER_BED_INVERTING true + +// +// Fans +// +#define CONTROLLER_FAN_PIN PD6 // BOARD FAN +#define FAN_PIN PG13 // FAN +#define FAN2_PIN PG14 + +// +// Misc +// +#define BEEPER_PIN PB0 +//#define LED_PIN PD3 +//#define POWER_LOSS_PIN PG2 // PG4 PW_DET + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA15 // MT_DET +#endif + +// SPI Flash +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x200000 // 2MB +#endif + +// SPI 2 +#define SPI_FLASH_CS_PIN PB12 +#define SPI_FLASH_MOSI_PIN PB15 +#define SPI_FLASH_MISO_PIN PB14 +#define SPI_FLASH_SCK_PIN PB13 + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #define TOUCH_CS_PIN PB7 // SPI1_NSS + #define TOUCH_SCK_PIN PA5 // SPI1_SCK + #define TOUCH_MISO_PIN PA6 // SPI1_MISO + #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI + + #define TFT_RESET_PIN PF11 + #define TFT_BACKLIGHT_PIN PD13 + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PD7 + #define FSMC_RS_PIN PD11 + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN +#endif + +#if HAS_TFT_LVGL_UI + // LVGL + #define HAS_SPI_FLASH_FONT 1 + #define HAS_GCODE_PREVIEW 1 + #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0 + #define HAS_LANG_SELECT_SCREEN 1 + #define HAS_BAK_VIEW_IN_FLASH 0 + #define HAS_LOGO_IN_FLASH 0 +#elif ENABLED(TFT_COLOR_UI) + // Color UI + #define TFT_BUFFER_SIZE 14400 +#endif + +// SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available +// so SPI2 is required. +#define SPI_DEVICE 2 +#define SD_SCK_PIN PB13 +#define SD_MISO_PIN PB14 +#define SD_MOSI_PIN PB15 +#define SD_SS_PIN PB12 + +// +// SD Card +// +#define SDIO_SUPPORT +#define SD_DETECT_PIN -1 // PF0, but it isn't connected +#define SDIO_CLOCK 4500000 +#define SDIO_READ_RETRIES 16 diff --git a/src/pins/stm32f1/pins_CREALITY_V24S1.h b/src/pins/stm32f1/pins_CREALITY_V24S1.h new file mode 100644 index 0000000..0d2ad83 --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V24S1.h @@ -0,0 +1,36 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Creality v2.4.S1 (STM32F103RE / STM32F103RC) v101 as found in the Ender 7 + */ + +#define BOARD_INFO_NAME "Creality v2.4.S1 V101" +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Heaters +// +#define HEATER_BED_PIN PA15 // HOT BED + +#include "pins_CREALITY_V4.h" diff --git a/src/pins/stm32f1/pins_CREALITY_V24S1_301.h b/src/pins/stm32f1/pins_CREALITY_V24S1_301.h new file mode 100644 index 0000000..53953f9 --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V24S1_301.h @@ -0,0 +1,94 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Creality V24S1_301 (STM32F103RE / STM32F103RC) board pin assignments as found on Ender 3 S1. + * Also supports the STM32F4 version of the board with identical pin mapping. + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality v24S1 only supports 1 hotend / E stepper." +#endif + +#if BOTH(BLTOUCH, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #error "Disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN when using BLTOUCH with Creality V24S1-301." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Creality V24S1-301" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "Ender 3 S1" +#endif + +// +// Servos +// +#if !defined(SERVO0_PIN) && !defined(HAS_PIN_27_BOARD) + #define SERVO0_PIN PC13 // BLTouch OUT +#endif + +// +// Limit Switches +// +#define Z_STOP_PIN PA15 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PC14 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // "Pulled-high" +#endif + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PA7 // HOT BED +#define FAN1_PIN PC0 // extruder fan + +// +// SD Card +// +#define ONBOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PA4 // SDSS + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + //#define HEATER_0_PIN -1 + //#define HEATER_BED_PIN -1 + #define FAN_PIN -1 + #define SPINDLE_LASER_ENA_PIN PC0 // FET 1 + #define SPINDLE_LASER_PWM_PIN PC0 // Bed FET + #define SPINDLE_DIR_PIN PC0 // FET 4 + #define LASER_SOFT_PWM_PIN PC0 +#endif + +#include "pins_CREALITY_V4.h" diff --git a/src/pins/stm32f1/pins_CREALITY_V25S1.h b/src/pins/stm32f1/pins_CREALITY_V25S1.h new file mode 100644 index 0000000..a0152a5 --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V25S1.h @@ -0,0 +1,152 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Creality v2.5.S1 (STM32F103RE / STM32F103RC) as found in the CR-10 Smart Pro + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality V2.5.S1 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Creality v2.5.S1" +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + //#define SDCARD_EEPROM_EMULATION + //#define FLASH_EEPROM_EMULATION +#endif + +#if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) +#elif EITHER(SDCARD_EEPROM_EMULATION, FLASH_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800 // 2K +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PC4 +#define Y_STOP_PIN PC5 + +#if ENABLED(BLTOUCH) + #define Z_STOP_PIN -1 + #define SERVO0_PIN PC14 // BLTouch OUT PIN + #ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PC15 // BLTouch IN PIN + #endif +#else + #define Z_STOP_PIN PC15 + #if ENABLED(PROBE_ACTIVATION_SWITCH) + #define PROBE_TARE_PIN PC14 + #define PROBE_ACTIVATION_SWITCH_PIN PB2 + #endif +#endif + +// +// Filament Runout Sensor +// +#if ENABLED(FILAMENT_RUNOUT_SENSOR) + #define FIL_RUNOUT_PIN PA15 // "Pulled-high" +#endif + +// +// Steppers +// +#define X_STEP_PIN PB8 +#define X_DIR_PIN PB7 +#define X_ENABLE_PIN PC3 + +#define Y_STEP_PIN PB6 +#define Y_DIR_PIN PB5 +#define Y_ENABLE_PIN X_ENABLE_PIN + +#define Z_STEP_PIN PB4 +#define Z_DIR_PIN PB3 +#define Z_ENABLE_PIN X_ENABLE_PIN + +#define E0_STEP_PIN PC2 +#define E0_DIR_PIN PB9 +#define E0_ENABLE_PIN X_ENABLE_PIN + +// +// Temperature Sensors +// +#define TEMP_0_PIN PB1 // TH1 +#define TEMP_BED_PIN PB0 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB14 // HEATER1 +#define HEATER_BED_PIN PB13 // HOT BED + +#define FAN_PIN PB15 // FAN +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PC13 // FAN +#endif +#define FAN_SOFT_PWM_REQUIRED + +// +// SD Card +// +#define SD_DETECT_PIN PC7 +#define SDCARD_CONNECTION ONBOARD +#define ON_BOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PC12 // SDSS +#define SDIO_SUPPORT +#define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer + +// +// Misc. Functions +// +#define CASE_LIGHT_PIN PA7 + +// +// Suicide Power +// +#define PS_ON_PIN PA0 +#define MOTOR_CIRCUIT_PIN PA1 + +// +// Motor Protect +// +#define MOTOR_PROTECT_PIN PC0 + +// +// WiFi Reset +// +#define RESET_WIFI_PIN PB12 diff --git a/src/pins/stm32f1/pins_CREALITY_V4.h b/src/pins/stm32f1/pins_CREALITY_V4.h new file mode 100644 index 0000000..5a3e733 --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V4.h @@ -0,0 +1,251 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Creality 4.2.x (STM32F103RE / STM32F103RC) board pin assignments + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality v4 only supports 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Creality V4" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "Ender 3 V2" +#endif + +#define BOARD_NO_NATIVE_USB + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#ifndef DISABLE_DEBUG + #define DISABLE_DEBUG +#endif + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + //#define SDCARD_EEPROM_EMULATION +#endif + +#if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) +#elif ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800 // 2K +#endif + +// +// Servos +// +#ifndef SERVO0_PIN + #ifndef HAS_PIN_27_BOARD + #define SERVO0_PIN PB0 // BLTouch OUT + #else + #define SERVO0_PIN PC6 + #endif +#endif + +// +// Limit Switches +// +#ifndef X_STOP_PIN + #define X_STOP_PIN PA5 +#endif +#ifndef Y_STOP_PIN + #define Y_STOP_PIN PA6 +#endif +#ifndef Z_STOP_PIN + #define Z_STOP_PIN PA7 +#endif + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB1 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA4 // "Pulled-high" +#endif + +// +// Steppers +// +#ifndef X_STEP_PIN + #define X_STEP_PIN PC2 +#endif +#ifndef X_DIR_PIN + #define X_DIR_PIN PB9 +#endif +#define X_ENABLE_PIN PC3 // Shared + +#ifndef Y_STEP_PIN + #define Y_STEP_PIN PB8 +#endif +#ifndef Y_DIR_PIN + #define Y_DIR_PIN PB7 +#endif +#define Y_ENABLE_PIN X_ENABLE_PIN + +#ifndef Z_STEP_PIN + #define Z_STEP_PIN PB6 +#endif +#ifndef Z_DIR_PIN + #define Z_DIR_PIN PB5 +#endif +#define Z_ENABLE_PIN X_ENABLE_PIN + +#ifndef E0_STEP_PIN + #define E0_STEP_PIN PB4 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN PB3 +#endif +#define E0_ENABLE_PIN X_ENABLE_PIN + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC5 // TH1 +#define TEMP_BED_PIN PC4 // TB1 + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PA1 // HEATER1 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PA2 // HOT BED +#endif +#ifndef FAN_PIN + #define FAN_PIN PA0 // FAN +#endif +#define FAN_SOFT_PWM_REQUIRED + +// +// SD Card +// +#define SD_DETECT_PIN PC7 +#define SDCARD_CONNECTION ONBOARD +#define SDIO_SUPPORT +#define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer + +#if ENABLED(CR10_STOCKDISPLAY) + + #if ENABLED(RET6_12864_LCD) + + /** + * RET6 12864 LCD + * ------ + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PE8 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + #define EXP1_01_PIN PC6 + #define EXP1_02_PIN PB2 + #define EXP1_03_PIN PB10 + #define EXP1_04_PIN PE8 + #define EXP1_05_PIN PB14 + #define EXP1_06_PIN PB13 + #define EXP1_07_PIN PB12 + #define EXP1_08_PIN PB15 + + #ifndef HAS_PIN_27_BOARD + #define BEEPER_PIN EXP1_01_PIN + #endif + + #elif ENABLED(VET6_12864_LCD) + + /** + * VET6 12864 LCD + * ------ + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + #define EXP1_01_PIN -1 + #define EXP1_02_PIN PC5 + #define EXP1_03_PIN PB10 + #define EXP1_04_PIN -1 + #define EXP1_05_PIN PA6 + #define EXP1_06_PIN PA5 + #define EXP1_07_PIN PA4 + #define EXP1_08_PIN PA7 + + #else + #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." + #endif + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + +#elif ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, DWIN_VET6_CREALITY_LCD) + + #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + // RET6 DWIN ENCODER LCD + #define EXP1_05_PIN PB14 + #define EXP1_06_PIN PB13 + #define EXP1_07_PIN PB12 + #define EXP1_08_PIN PB15 + //#define LCD_LED_PIN PB2 + #else + // VET6 DWIN ENCODER LCD + #define EXP1_05_PIN PA6 + #define EXP1_06_PIN PA5 + #define EXP1_07_PIN PA4 + #define EXP1_08_PIN PA7 + #endif + + #define BTN_ENC EXP1_05_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_06_PIN + #endif + +#endif diff --git a/src/pins/stm32f1/pins_CREALITY_V4210.h b/src/pins/stm32f1/pins_CREALITY_V4210.h new file mode 100644 index 0000000..86ede84 --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V4210.h @@ -0,0 +1,227 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * CREALITY 4.2.10 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality v4.2.10 only supports 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Creality V4.2.10" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "3DPrintMill" +#endif + +#define BOARD_NO_NATIVE_USB + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 +#endif +#if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) +#else + #define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX + #define MARLIN_EEPROM_SIZE 0x800 // 2K +#endif + +// +// Servos +// +#define SERVO0_PIN PB0 // BLTouch OUT + +// +// Limit Switches +// +#define X_STOP_PIN PA3 +#define Y_STOP_PIN PA7 +#define Z_STOP_PIN PA5 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PA5 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA6 // "Pulled-high" +#endif + +// +// Steppers +// +#ifndef X_STEP_PIN + #define X_STEP_PIN PC2 +#endif +#ifndef X_DIR_PIN + #define X_DIR_PIN PB9 +#endif +#define X_ENABLE_PIN PC3 + +#ifndef Y_STEP_PIN + #define Y_STEP_PIN PB8 +#endif +#ifndef Y_DIR_PIN + #define Y_DIR_PIN PB7 +#endif +#define Y_ENABLE_PIN X_ENABLE_PIN + +#ifndef Z_STEP_PIN + #define Z_STEP_PIN PB6 +#endif +#ifndef Z_DIR_PIN + #define Z_DIR_PIN PB5 +#endif +#define Z_ENABLE_PIN X_ENABLE_PIN + +#ifndef E0_STEP_PIN + #define E0_STEP_PIN PB4 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN PB3 +#endif +#define E0_ENABLE_PIN X_ENABLE_PIN + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC5 // TH1 +#define TEMP_BED_PIN PC4 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA0 // HEATER1 +#define HEATER_BED_PIN PA1 // HOT BED + +#define FAN_PIN PA2 // FAN +#define FAN_SOFT_PWM_REQUIRED + +// +// SD Card +// +#define SD_DETECT_PIN PC7 +#define SDCARD_CONNECTION ONBOARD +#define ONBOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PA4 // SDSS +#define SDIO_SUPPORT +#define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer + +#if ENABLED(CR10_STOCKDISPLAY) + + #if ENABLED(RET6_12864_LCD) + + /** + * RET6 12864 LCD + * ------ + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PE8 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + #define EXP1_01_PIN PC6 + #define EXP1_02_PIN PB2 + #define EXP1_03_PIN PB10 + #define EXP1_04_PIN PE8 + #define EXP1_05_PIN PB14 + #define EXP1_06_PIN PB13 + #define EXP1_07_PIN PB12 + #define EXP1_08_PIN PB15 + + #define BEEPER_PIN EXP1_01_PIN + + #elif ENABLED(VET6_12864_LCD) + + /** + * VET6 12864 LCD + * ------ + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + #define EXP1_01_PIN -1 + #define EXP1_02_PIN PC5 + #define EXP1_03_PIN PB10 + #define EXP1_04_PIN -1 + #define EXP1_05_PIN PA6 + #define EXP1_06_PIN PA5 + #define EXP1_07_PIN PA4 + #define EXP1_08_PIN PA7 + + #else + #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." + #endif + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + +#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + + // RET6 DWIN ENCODER LCD + #define BTN_ENC PB14 + #define BTN_EN1 PB15 + #define BTN_EN2 PB12 + + //#define LCD_LED_PIN PB2 + #ifndef BEEPER_PIN + #define BEEPER_PIN PB13 + #endif + +#elif ENABLED(DWIN_VET6_CREALITY_LCD) + + // VET6 DWIN ENCODER LCD + #define BTN_ENC PA6 + #define BTN_EN1 PA7 + #define BTN_EN2 PA4 + + #define BEEPER_PIN PA5 + +#endif diff --git a/src/pins/stm32f1/pins_CREALITY_V422.h b/src/pins/stm32f1/pins_CREALITY_V422.h new file mode 100644 index 0000000..5499adb --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V422.h @@ -0,0 +1,31 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * CREALITY v4.2.2 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#define BOARD_INFO_NAME "Creality v4.2.2" +#define DEFAULT_MACHINE_NAME "Creality3D" + +#include "pins_CREALITY_V4.h" diff --git a/src/pins/stm32f1/pins_CREALITY_V423.h b/src/pins/stm32f1/pins_CREALITY_V423.h new file mode 100644 index 0000000..c174b0e --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V423.h @@ -0,0 +1,44 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * CREALITY v4.2.3 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#define BOARD_INFO_NAME "Creality v4.2.3" +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Heaters +// +#define HEATER_BED_PIN PB10 // HOT BED + +#include "pins_CREALITY_V4.h" + +// +// Encoder +// +#if BTN_EN1 == PB10 + #undef BTN_EN1 + #define BTN_EN1 PA2 // Rotary Encoder +#endif diff --git a/src/pins/stm32f1/pins_CREALITY_V425.h b/src/pins/stm32f1/pins_CREALITY_V425.h new file mode 100644 index 0000000..46f437e --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V425.h @@ -0,0 +1,77 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * CREALITY 4.2.5 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality v4.2.5 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Creality V4.2.5" +#define DEFAULT_MACHINE_NAME "CR200B" + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + #undef NO_EEPROM_SELECTED +#elif DISABLED(IIC_BL24CXX_EEPROM) + #define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX +#endif + +// +// Servos +// +#define SERVO0_PIN PB1 // BLTouch OUT + +// +// Limit Switches +// +#define X_STOP_PIN PA3 +#define Y_STOP_PIN PA4 +#define Z_STOP_PIN PA5 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB0 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA6 // "Pulled-high" +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA0 // HEATER1 +#define HEATER_BED_PIN PA1 // HOT BED +#define FAN_PIN PA2 // FAN + +#include "pins_CREALITY_V4.h" diff --git a/src/pins/stm32f1/pins_CREALITY_V427.h b/src/pins/stm32f1/pins_CREALITY_V427.h new file mode 100644 index 0000000..077f4c7 --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V427.h @@ -0,0 +1,45 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * CREALITY v4.2.7 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#define BOARD_INFO_NAME "Creality v4.2.7" +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Steppers +// +#define X_STEP_PIN PB9 +#define X_DIR_PIN PC2 +#define Y_STEP_PIN PB7 + +#define Y_DIR_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB6 + +#define E0_STEP_PIN PB3 +#define E0_DIR_PIN PB4 + +#include "pins_CREALITY_V4.h" diff --git a/src/pins/stm32f1/pins_CREALITY_V431.h b/src/pins/stm32f1/pins_CREALITY_V431.h new file mode 100644 index 0000000..9226b53 --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V431.h @@ -0,0 +1,51 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * CREALITY v4.3.1 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#define BOARD_INFO_NAME "Creality v4.3.1" +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Steppers +// +#if MB(CREALITY_V431, CREALITY_V431_A, CREALITY_V431_B) + + #define X_STEP_PIN PB8 + #define X_DIR_PIN PB7 + + #define Y_STEP_PIN PC2 + #define Y_DIR_PIN PB9 + +#endif + +#if MB(CREALITY_V431_B, CREALITY_V431_C) + + #define E0_STEP_PIN PB3 + #define E0_DIR_PIN PB4 + +#endif + +#include "pins_CREALITY_V4.h" diff --git a/src/pins/stm32f1/pins_CREALITY_V452.h b/src/pins/stm32f1/pins_CREALITY_V452.h new file mode 100644 index 0000000..4f57f8a --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V452.h @@ -0,0 +1,44 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Creality v4.5.2 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality v4.5.2 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Creality v4.5.2" + +#define HEATER_0_PIN PA1 // HEATER1 +#define HEATER_BED_PIN PA2 // HOT BED +#define FAN_PIN PA0 // FAN + +#if ENABLED(PROBE_ACTIVATION_SWITCH) + #ifndef PROBE_ACTIVATION_SWITCH_PIN + #define PROBE_ACTIVATION_SWITCH_PIN PC6 // Optoswitch to Enable Z Probe + #endif +#endif + +#include "pins_CREALITY_V45x.h" diff --git a/src/pins/stm32f1/pins_CREALITY_V453.h b/src/pins/stm32f1/pins_CREALITY_V453.h new file mode 100644 index 0000000..6a0fa4f --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V453.h @@ -0,0 +1,44 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Creality v4.5.3 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality v4.5.3 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Creality v4.5.3" + +#define HEATER_0_PIN PB14 // HEATER1 +#define HEATER_BED_PIN PB13 // HOT BED +#define FAN_PIN PB15 // FAN + +#if ENABLED(PROBE_ACTIVATION_SWITCH) + #ifndef PROBE_ACTIVATION_SWITCH_PIN + #define PROBE_ACTIVATION_SWITCH_PIN PB2 // Optoswitch to Enable Z Probe + #endif +#endif + +#include "pins_CREALITY_V45x.h" diff --git a/src/pins/stm32f1/pins_CREALITY_V45x.h b/src/pins/stm32f1/pins_CREALITY_V45x.h new file mode 100644 index 0000000..a9ff02d --- /dev/null +++ b/src/pins/stm32f1/pins_CREALITY_V45x.h @@ -0,0 +1,114 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Creality v4.5.2 and v4.5.3 (STM32F103RET6) board pin assignments + */ + +#include "env_validate.h" + +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Release PB4 (Z_STEP_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +#define BOARD_NO_NATIVE_USB + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + //#define SDCARD_EEPROM_EMULATION +#endif + +#if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) +#elif ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800 // 2K +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PC4 +#define Y_STOP_PIN PC5 +#define Z_STOP_PIN PA4 + +#define FIL_RUNOUT_PIN PA7 + +// +// Probe +// +#ifndef PROBE_TARE_PIN + #define PROBE_TARE_PIN PA5 +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC3 +#define X_STEP_PIN PB8 +#define X_DIR_PIN PB7 + +#define Y_ENABLE_PIN PC3 +#define Y_STEP_PIN PB6 +#define Y_DIR_PIN PB5 + +#define Z_ENABLE_PIN PC3 +#define Z_STEP_PIN PB4 +#define Z_DIR_PIN PB3 + +#define E0_ENABLE_PIN PC3 +#define E0_STEP_PIN PC2 +#define E0_DIR_PIN PB9 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PB1 // TH1 +#define TEMP_BED_PIN PB0 // TB1 + +// +// Heaters / Fans +// + +#define FAN_SOFT_PWM_REQUIRED + +// +// SD Card +// +#define SD_DETECT_PIN PC7 +#define NO_SD_HOST_DRIVE // SD is only seen by the printer + +#define SDIO_SUPPORT // Extra added by Creality +#define SDIO_CLOCK 6000000 // In original source code overridden by Creality in sdio.h + +// +// Misc. Functions +// +#define CASE_LIGHT_PIN PA6 diff --git a/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h b/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h new file mode 100644 index 0000000..08c9500 --- /dev/null +++ b/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h @@ -0,0 +1,196 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Eryone Ery32 mini (STM32F103VET6) board pin assignments + */ + +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Eryone Ery32 mini supports up to 2 hotends / E steppers." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "ERYONE Ery32 mini" +#endif + +//#define DISABLE_DEBUG +#define DISABLE_JTAG +//#define ENABLE_SPI3 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) +#endif + +// +// Servos +// +#define SERVO0_PIN PA12 + +// +// Limit Switches +// +#define X_STOP_PIN PD8 +#define Y_STOP_PIN PD15 +#define Z_MIN_PIN PA11 +//#define Z_MAX_PIN PB1 + +// +// Steppers +// +#define X_STEP_PIN PB15 +#define X_DIR_PIN PB14 +#define X_ENABLE_PIN PD10 + +#define Y_STEP_PIN PD14 +#define Y_DIR_PIN PD13 +#define Y_ENABLE_PIN PC6 + +#define Z_STEP_PIN PC8 +#define Z_DIR_PIN PC7 +#define Z_ENABLE_PIN PA8 + +#define E0_STEP_PIN PE13 +#define E0_DIR_PIN PE14 +#define E0_ENABLE_PIN PB13 + +//#define E1_STEP_PIN PD13 +//#define E1_DIR_PIN PD12 +//#define E1_ENABLE_PIN PC6 + +// +// Heaters 0,1 / Fans / Bed +// +#define HEATER_0_PIN PD11 + +#if ENABLED(FET_ORDER_EFB) // Hotend, Fan, Bed + #define HEATER_BED_PIN PD12 +#elif ENABLED(FET_ORDER_EEF) // Hotend, Hotend, Fan + #define HEATER_1_PIN PD4 +#elif ENABLED(FET_ORDER_EEB) // Hotend, Hotend, Bed + #define HEATER_1_PIN PD4 + #define HEATER_BED_PIN PD12 +#elif ENABLED(FET_ORDER_EFF) // Hotend, Fan, Fan + #define FAN1_PIN PD12 +#elif DISABLED(FET_ORDER_SF) // Not Spindle, Fan (i.e., "EFBF" or "EFBE") + #define HEATER_BED_PIN PD12 + #if EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) + #define HEATER_1_PIN PB9 + #else + #define FAN1_PIN PB9 + #endif +#endif + +#ifndef FAN_PIN + #if EITHER(FET_ORDER_EFB, FET_ORDER_EFF) // Hotend, Fan, Bed or Hotend, Fan, Fan + #define FAN_PIN PB5 + #elif EITHER(FET_ORDER_EEF, FET_ORDER_SF) // Hotend, Hotend, Fan or Spindle, Fan + #define FAN_PIN PD12 + #elif ENABLED(FET_ORDER_EEB) // Hotend, Hotend, Bed + #define FAN_PIN -1 // IO pin. Buffer needed + #else // Non-specific are "EFB" (i.e., "EFBF" or "EFBE") + #define FAN_PIN PB5 + #endif +#endif + +#define FAN_SOFT_PWM_REQUIRED + +// +// Misc. Functions +// +//#define PS_ON_PIN PB9 + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + #define X_HARDWARE_SERIAL MSerial4 + #define Y_HARDWARE_SERIAL MSerial4 + #define Z_HARDWARE_SERIAL MSerial4 + #define E0_HARDWARE_SERIAL MSerial4 + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 2 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 3 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0 + #endif +#endif +// +// Temperature Sensors +// +#define TEMP_BED_PIN PC2 //TB +#define TEMP_0_PIN PC1 //TH1 +//#define TEMP_1_PIN PC3 //TH2 +#define TEMP_BOARD_PIN PC3 +#ifndef TEMP_SENSOR_BOARD + #define TEMP_SENSOR_BOARD 13 +#endif +#define FIL_RUNOUT_PIN PA10 // MT_DET + +// +// LCD Pins +// +#if HAS_WIRED_LCD + #define BEEPER_PIN PE12 + #define BTN_ENC PE11 + #define LCD_PINS_ENABLE PE10 + #define LCD_PINS_RS PE9 + #define BTN_EN1 PE4 + #define BTN_EN2 PE3 + #define LCD_PINS_D4 PE8 + #define LCD_PINS_D5 PE7 + #define LCD_PINS_D6 PB2 + #define LCD_PINS_D7 PB1 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #define BOARD_ST7920_DELAY_1 50 + #define BOARD_ST7920_DELAY_2 50 + #define BOARD_ST7920_DELAY_3 50 + +#endif // HAS_WIRED_LCD + +// +// SD Card +// +#define ENABLE_SPI1 +#define SD_DETECT_PIN PA4 +#define SCK_PIN PA5 +#define MISO_PIN PA6 +#define MOSI_PIN PA7 +#define SS_PIN PC4 diff --git a/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/src/pins/stm32f1/pins_FLSUN_HISPEED.h new file mode 100644 index 0000000..dd621eb --- /dev/null +++ b/src/pins/stm32f1/pins_FLSUN_HISPEED.h @@ -0,0 +1,328 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * FLSUN HiSpeed V1 (STM32F103VET6) board pin assignments + * FLSun Hispeed (clone MKS_Robin_miniV2) board. + * + * MKS Robin Mini USB uses UART3 (PB10-TX, PB11-RX) + * #define SERIAL_PORT_2 3 + */ + +#if NOT_TARGET(__STM32F1__, STM32F1xx) + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#elif HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "FLSUN HiSpeedV1 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "FLSun HiSpeedV1" +#define BOARD_WEBSITE_URL "github.com/Foxies-CSTL" + +#define BOARD_NO_NATIVE_USB + +// Avoid conflict with TIMER_SERVO when using the STM32 HAL +#define TEMP_TIMER 5 + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +// +// SPI +// Note: FLSun Hispeed (clone MKS_Robin_miniV2) board is using SPI2 interface. +// +#define SD_SCK_PIN PB13 // SPI2 +#define SD_MISO_PIN PB14 // SPI2 +#define SD_MOSI_PIN PB15 // SPI2 +#define SPI_DEVICE 2 + +// SPI Flash +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + // SPI 2 + #define SPI_FLASH_CS_PIN PB12 // SPI2_NSS / Flash chip-select + #define SPI_FLASH_MOSI_PIN PB15 + #define SPI_FLASH_MISO_PIN PB14 + #define SPI_FLASH_SCK_PIN PB13 + #define SPI_FLASH_SIZE 0x1000000 // 16MB +#endif + +// +// Servos +// +//#define SERVO0_PIN PA8 // use IO0 to enable BLTOUCH support/remove Mks_Wifi + +// +// Limit Switches +// +#define X_STOP_PIN PA15 // -X +#define Y_STOP_PIN PA12 // -Y +#define Z_MIN_PIN PA11 // -Z +#define Z_MAX_PIN PC4 // +Z + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA4 // MT_DET +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PE4 // X_EN +#define X_STEP_PIN PE3 // X_STEP +#define X_DIR_PIN PE2 // X_DIR + +#define Y_ENABLE_PIN PE1 // Y_EN +#define Y_STEP_PIN PE0 // Y_STEP +#define Y_DIR_PIN PB9 // Y_DIR + +#define Z_ENABLE_PIN PB8 // Z_EN +#define Z_STEP_PIN PB5 // Z_STEP +#define Z_DIR_PIN PB4 // Z_DIR + +#define E0_ENABLE_PIN PB3 // E0_EN +#define E0_STEP_PIN PD6 // E0_STEP +#define E0_DIR_PIN PD3 // E0_DIR + +/** + * FLSUN Hi-Speed has no hard-wired UART pins for TMC drivers. + * Several wiring options are provided below, defaulting to + * to the most compatible. + */ +#if HAS_TMC_UART + // SoftwareSerial with one pin per driver + // Compatible with TMC2208 and TMC2209 drivers + #define X_SERIAL_TX_PIN PA10 // RXD1 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN PA9 // TXD1 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN PC7 // IO1 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + #define TMC_BAUD_RATE 19200 +#else + // Motor current PWM pins + #define MOTOR_CURRENT_PWM_XY_PIN PA6 // VREF2/3 CONTROL XY + #define MOTOR_CURRENT_PWM_Z_PIN PA7 // VREF4 CONTROL Z + #define MOTOR_CURRENT_PWM_RANGE 1500 // (255 * (1000mA / 65535)) * 257 = 1000 is equal 1.6v Vref in turn equal 1Amp + #ifndef DEFAULT_PWM_MOTOR_CURRENT + #define DEFAULT_PWM_MOTOR_CURRENT { 800, 800, 800 } + #endif + + /** + * MKS Robin_Wifi or another ESP8266 module + * + * __ESP(M1)__ -J1- + * GND| 15 | | 08 |+3v3 (22) RXD1 (PA10) + * | 16 | | 07 |MOSI (21) TXD1 (PA9) Active LOW, probably OK to leave floating + * IO2| 17 | | 06 |MISO (19) IO1 (PC7) Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) + * IO0| 18 | | 05 |CLK (18) IO0 (PA8) Must be HIGH (ESP3D software configures this with a pullup so OK to leave as floating) + * IO1| 19 | | 03 |EN (03) WIFI_EN Must be HIGH for module to run + * | nc | | nc | (01) WIFI_CTRL (PA5) + * RX| 21 | | nc | + * TX| 22 | | 01 |RST + *  ̄ ̄ AE ̄ ̄ + */ + // Module ESP-WIFI + #define ESP_WIFI_MODULE_COM 2 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this + #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 + #define ESP_WIFI_MODULE_RESET_PIN PA5 // WIFI CTRL/RST + #define ESP_WIFI_MODULE_ENABLE_PIN -1 + #define ESP_WIFI_MODULE_TXD_PIN PA9 // MKS or ESP WIFI RX PIN + #define ESP_WIFI_MODULE_RXD_PIN PA10 // MKS or ESP WIFI TX PIN +#endif + +// +// EXTRUDER +// +#if AXIS_DRIVER_TYPE_E0(TMC2208) || AXIS_DRIVER_TYPE_E0(TMC2209) + #define E0_SERIAL_TX_PIN PA8 // IO0 + #define E0_SERIAL_RX_PIN PA8 // IO0 + #define TMC_BAUD_RATE 19200 +#else + // Motor current PWM pins + #define MOTOR_CURRENT_PWM_E_PIN PB0 // VREF1 CONTROL E + #define MOTOR_CURRENT_PWM_RANGE 1500 // (255 * (1000mA / 65535)) * 257 = 1000 is equal 1.6v Vref in turn equal 1Amp + #ifndef DEFAULT_PWM_MOTOR_CURRENT + #define DEFAULT_PWM_MOTOR_CURRENT { 800, 800, 800 } + #endif +#endif + +// +// Temperature Sensors (THM) +// +#define TEMP_0_PIN PC1 // TEMP_E0 +#define TEMP_BED_PIN PC0 // TEMP_BED + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC3 // HEATER_E0 +#define HEATER_BED_PIN PA0 // HEATER_BED-WKUP + +#define FAN_PIN PB1 // E_FAN + +// +// Misc. Functions +// +#if ENABLED(BACKUP_POWER_SUPPLY) + #define POWER_LOSS_PIN PA2 // PW_DET (UPS) MKSPWC +#else + //#define POWER_LOSS_PIN PA1 // PW_SO +#endif + +/** + * Connector J2 + * ------- + * DIO O|1 2|O 3v3 + * CSK O|3 5|O GND + * RST O|5 6|O GND + * ------- + */ +//#define SW_DIO PA13 +//#define SW_CLK PA14 +//#define SW_RST NRST // (14) + +// +// Power Supply Control +// +#if ENABLED(PSU_CONTROL) + #define KILL_PIN PA2 // PW_DET + #define KILL_PIN_STATE HIGH + //#define PS_ON_PIN PA3 // PW_CN /PW_OFF +#endif + +#if HAS_TFT_LVGL_UI + #define MT_DET_1_PIN PA4 // MT_DET + #define MT_DET_2_PIN PE6 + #define MT_DET_PIN_STATE LOW +#endif + +// +// LED / NEOPixel +// +//#define LED_PIN PB2 // BOOT1 + +#if ENABLED(NEOPIXEL_LED) + #define LED_PWM PC7 // IO1 + #ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN LED_PWM // USED WIFI IO0/IO1 PIN + #endif +#endif + +// +// SD Card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +// Use the on-board card socket labeled SD_Extender +#if SD_CONNECTION_IS(CUSTOM_CABLE) + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #define SD_SS_PIN -1 + #define SD_DETECT_PIN PD12 // SD_CD (if -1 no detection) +#else + #define SDIO_SUPPORT + #define SDIO_CLOCK 4500000 // 4.5 MHz + #define SDIO_READ_RETRIES 16 + #define ONBOARD_SPI_DEVICE 1 // SPI1 + #define ONBOARD_SD_CS_PIN PC11 + #define SD_DETECT_PIN -1 // SD_CD (-1 active refresh) +#endif + +// +// LCD / Controller +// +#ifndef BEEPER_PIN + #define BEEPER_PIN PC5 +#endif + +#if ENABLED(SPEAKER) && BEEPER_PIN == PC5 + #error "FLSun HiSpeed default BEEPER_PIN is not a SPEAKER." +#endif + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + /** + * Note: MKS Robin TFT screens use various TFT controllers + * Supported screens are based on the ILI9341, ST7789V and ILI9328 (320x240) + * ILI9488 is not supported + * Define init sequences for other screens in u8g_dev_tft_320x240_upscale_from_128x64.cpp + * + * If the screen stays white, disable 'LCD_RESET_PIN' + * to let the bootloader init the screen. + * + * Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu + * because Marlin uses the reset as a failsafe to revive a glitchy LCD. + */ + //#define TFT_RESET_PIN PC6 // FSMC_RST + #define TFT_BACKLIGHT_PIN PD13 + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define FSMC_CS_PIN PD7 // NE4 + #define FSMC_RS_PIN PD11 // A0 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #ifdef TFT_CLASSIC_UI + #define TFT_MARLINBG_COLOR 0x3186 // Grey + #define TFT_MARLINUI_COLOR 0xC7B6 // Green + #define TFT_BTARROWS_COLOR 0xDEE6 // Yellow + #define TFT_BTOKMENU_COLOR 0x145F // Cyan + #endif + #define TFT_BUFFER_SIZE 14400 + +#elif HAS_GRAPHICAL_TFT + + #define TFT_RESET_PIN PC6 + #define TFT_BACKLIGHT_PIN PD13 + #define TFT_CS_PIN PD7 // NE4 + #define TFT_RS_PIN PD11 // A0 + +#endif + +#if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PC2 // SPI2_NSS + #define TOUCH_SCK_PIN PB13 // SPI2_SCK + #define TOUCH_MISO_PIN PB14 // SPI2_MISO + #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + #define TOUCH_INT_PIN -1 +#endif diff --git a/src/pins/stm32f1/pins_FLY_MINI.h b/src/pins/stm32f1/pins_FLY_MINI.h new file mode 100644 index 0000000..f39850f --- /dev/null +++ b/src/pins/stm32f1/pins_FLY_MINI.h @@ -0,0 +1,190 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "FLY_MINI" +#define BOARD_WEBSITE_URL "github.com/FLYmaker/FLY-MINI" +#define DISABLE_JTAG + +// +// Flash EEPROM Emulation +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE 0x800 // 2K + #define EEPROM_START_ADDRESS (0x8000000 + 256 * 1024 - 2 * EEPROM_PAGE_SIZE) // 256K firmware space + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#endif + +// +// Servos +// +#define SERVO0_PIN PA8 + +// +// Limit Switches +// +#define X_MIN_PIN PC12 +#define X_MAX_PIN PC11 +#define Y_MIN_PIN PC10 +#define Y_MAX_PIN PA15 +#define Z_MIN_PIN PA14 +#define Z_MAX_PIN PA13 + +// +// Steppers +// +#define X_STEP_PIN PB1 +#define X_DIR_PIN PB2 +#define X_ENABLE_PIN PB10 +#ifndef X_CS_PIN + #define X_CS_PIN PB0 +#endif + +#define Y_STEP_PIN PA2 +#define Y_DIR_PIN PC4 +#define Y_ENABLE_PIN PC5 +#ifndef Y_CS_PIN + #define Y_CS_PIN PA7 +#endif + +#define Z_STEP_PIN PA3 +#define Z_DIR_PIN PA5 +#define Z_ENABLE_PIN PA6 +#ifndef Z_CS_PIN + #define Z_CS_PIN PA4 +#endif + +#define E0_STEP_PIN PA1 +#define E0_DIR_PIN PC3 +#define E0_ENABLE_PIN PA0 +#ifndef E0_CS_PIN + #define E0_CS_PIN PC2 +#endif + +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI EXP2_06_PIN + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO EXP2_01_PIN + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK EXP2_02_PIN + #endif +#endif + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PB0 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN PA7 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN PA4 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN PC2 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC6 +#define HEATER_BED_PIN PC7 +#ifndef FAN_PIN + #define FAN_PIN PC8 +#endif +#define FAN1_PIN PC9 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PC0 // Analog Input +#define TEMP_0_PIN PC1 // Analog Input + +/** ------ ------ + * (BEEPER) PC14 | 1 2 | PC13 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SD_SCK) + * (LCD_EN) PB9 | 3 4 | PB8 (LCD_RS) (BTN_EN1) PB3 | 3 4 | PB12 (SD_CS2) + * (LCD_D4) PB7 5 6 | PB6 (LCD_D5) (BTN_EN2) PD2 5 6 | PB15 (SD_MOSI) + * (LCD_D6) PB5 | 7 8 | PB4 (LCD_D7) (SD_DETECT) PB11 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC14 +#define EXP1_02_PIN PC13 +#define EXP1_03_PIN PB9 +#define EXP1_04_PIN PB8 +#define EXP1_05_PIN PB7 +#define EXP1_06_PIN PB6 +#define EXP1_07_PIN PB5 +#define EXP1_08_PIN PB4 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PB3 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PD2 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PB11 +#define EXP2_08_PIN -1 // RESET + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #define SPI_DEVICE 2 + #define SD_SS_PIN EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + + #define SDSS SD_SS_PIN + #define SD_DETECT_PIN EXP2_07_PIN + + #define BEEPER_PIN EXP1_01_PIN + + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + // Alter timing for graphical display + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 715 + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/src/pins/stm32f1/pins_FYSETC_AIO_II.h new file mode 100644 index 0000000..9250ee1 --- /dev/null +++ b/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -0,0 +1,207 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "FYSETC AIO II" +#define BOARD_WEBSITE_URL "fysetc.com" + +#define BOARD_NO_NATIVE_USB +#define RESET_STEPPERS_ON_MEDIA_INSERT +#define DISABLE_JTAG + +#define pins_v2_20190128 // new pins define + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// Flash EEPROM Emulation +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PA1 +#define Y_STOP_PIN PA0 +#define Z_STOP_PIN PB14 + +// +// Filament runout +// +#ifdef pins_v2_20190128 + #define FIL_RUNOUT_PIN PB15 +#else + #define FIL_RUNOUT_PIN PB5 +#endif + +// +// Steppers +// +#define X_STEP_PIN PB8 +#define X_DIR_PIN PB9 +#define X_ENABLE_PIN PA8 + +#define Y_STEP_PIN PB2 +#ifdef pins_v2_20190128 + #define Y_DIR_PIN PB3 +#else + #define Y_DIR_PIN PB0 +#endif +#define Y_ENABLE_PIN PB1 + +#define Z_STEP_PIN PC0 +#define Z_DIR_PIN PC1 +#define Z_ENABLE_PIN PC2 + +#define E0_STEP_PIN PC15 +#define E0_DIR_PIN PC14 +#define E0_ENABLE_PIN PC13 + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + */ + + // Hardware serial with switch + #define X_HARDWARE_SERIAL MSerial2 + #define Y_HARDWARE_SERIAL MSerial2 + #define Z_HARDWARE_SERIAL MSerial2 + #define E0_HARDWARE_SERIAL MSerial2 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 1 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 2 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif + + // The 4xTMC2209 module doesn't have a serial multiplexer and + // needs to set *_SLAVE_ADDRESS in Configuration_adv.h for X,Y,Z,E0 + #if HAS_DRIVER(TMC2208) + #define TMC_SERIAL_MULTIPLEXER + #define SERIAL_MUL_PIN1 PB13 + #define SERIAL_MUL_PIN2 PB12 + #endif + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Stepper current PWM +// +#ifndef MOTOR_CURRENT_PWM_RANGE + #define MOTOR_CURRENT_PWM_RANGE 1500 // origin:2000 +#endif +#define DEFAULT_PWM_MOTOR_CURRENT { 500, 500, 400 } // origin: {1300,1300,1250} + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC7 +#define HEATER_BED_PIN PC6 +#ifndef FAN_PIN + #define FAN_PIN PC8 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PC5 // Analog Input +#define TEMP_0_PIN PC4 // Analog Input + +// +// Misc. Functions +// +#define SDSS PA4 + +// +// LCD Pins +// +#if HAS_WIRED_LCD + + #define BEEPER_PIN PC9 + + #if HAS_MARLINUI_U8GLIB + + #define DOGLCD_A0 PA15 + #ifdef pins_v2_20190128 + #define DOGLCD_CS PB5 + #else + #define DOGLCD_CS PB7 + #endif + + //#define LCD_CONTRAST_INIT 190 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #endif + + // not connected to a pin + #define SD_DETECT_PIN PC3 + + #if IS_NEWPANEL + // The encoder and click button + #define BTN_EN1 PC10 + #define BTN_EN2 PC11 + #define BTN_ENC PC12 + #endif + + #ifdef pins_v2_20190128 + #define LCD_RESET_PIN PB4 + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB0 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB6 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB7 + #endif + #else + #define LCD_RESET_PIN PB6 + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB3 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB4 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB5 + #endif + #endif + +#endif diff --git a/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/src/pins/stm32f1/pins_FYSETC_CHEETAH.h new file mode 100644 index 0000000..e59e8ae --- /dev/null +++ b/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -0,0 +1,200 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#define DEFAULT_MACHINE_NAME "3D Printer" + +#define BOARD_INFO_NAME "FYSETC Cheetah" +#define BOARD_WEBSITE_URL "fysetc.com" + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#define BOARD_NO_NATIVE_USB +#define RESET_STEPPERS_ON_MEDIA_INSERT +#define DISABLE_JTAG + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +// +// Servos +// +#define SERVO0_PIN PA0 + +// +// Limit Switches +// +#define X_STOP_PIN PA1 +#define Y_STOP_PIN PB4 +#define Z_STOP_PIN PA15 + +// +// Filament runout +// +#define FIL_RUNOUT_PIN PB5 + +// +// Steppers +// +#define X_STEP_PIN PB8 +#define X_DIR_PIN PB9 +#define X_ENABLE_PIN PA8 + +#define Y_STEP_PIN PB2 +#define Y_DIR_PIN PB3 +#define Y_ENABLE_PIN PB1 + +#define Z_STEP_PIN PC0 +#define Z_DIR_PIN PC1 +#define Z_ENABLE_PIN PC2 + +#define E0_STEP_PIN PC15 +#define E0_DIR_PIN PC14 +#define E0_ENABLE_PIN PC13 + +#if HAS_TMC_UART + #define X_HARDWARE_SERIAL MSerial2 + #define Y_HARDWARE_SERIAL MSerial2 + #define Z_HARDWARE_SERIAL MSerial2 + #define E0_HARDWARE_SERIAL MSerial2 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 1 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 2 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC6 +#define HEATER_BED_PIN PC7 +#ifndef FAN_PIN + #define FAN_PIN PC8 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PC5 // Analog Input +#define TEMP_0_PIN PC4 // Analog Input + +// +// Misc. Functions +// +#define SDSS PA4 +#define SD_DETECT_PIN PC3 + +#ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB0 +#endif +#ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB7 +#endif +#ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB6 +#endif + +/** + * EXP1 pinout for the LCD according to FYSETC's Cheetah board schematic + * ------ + * (BEEPER) PC9 | 1 2 | PC12 (BTN_ENC) + * (BTN_EN2) PC11 | 3 4 | PB14 (LCD_RS / MISO) + * (BTN_EN1) PC10 5 6 | PB13 (SCK) + * (LCD_EN) PB12 | 7 8 | PB15 (MOSI) + * GND | 9 10 | 5V + * ------ + * EXP1 + * + * Notes: + * - The pin-numbers match the connector correctly and are not in reverse order like on the Ender-3 board. + * - Functionally the pins are assigned in the same order as on the Ender-3 board. + * - Pin 4 on the Cheetah board is assigned to an I/O, it is assigned to RESET on the Ender-3 board. + */ +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PC12 +#define EXP1_03_PIN PC11 +#define EXP1_04_PIN PB14 +#define EXP1_05_PIN PC10 +#define EXP1_06_PIN PB13 +#define EXP1_07_PIN PB12 +#define EXP1_08_PIN PB15 + +#if HAS_WIRED_LCD + #define BEEPER_PIN EXP1_01_PIN + + #if HAS_MARLINUI_U8GLIB + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_SCK EXP1_06_PIN + #define DOGLCD_MOSI EXP1_08_PIN + + #if EITHER(FYSETC_MINI_12864, U8GLIB_ST7920) + #define FORCE_SOFT_SPI + #endif + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #endif + + #define LCD_PINS_RS EXP1_07_PIN // CS -- SOFT SPI for ENDER3 LCD + #define LCD_PINS_D4 EXP1_06_PIN // SCLK + #define LCD_PINS_ENABLE EXP1_08_PIN // DATA MOSI + + //#define LCD_CONTRAST_INIT 190 + + #if IS_NEWPANEL + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_03_PIN + #define BTN_ENC EXP1_02_PIN + #endif +#endif + +#if ENABLED(TOUCH_UI_FTDI_EVE) + #define BEEPER_PIN EXP1_01_PIN + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN + + //#define CLCD_USE_SOFT_SPI // the Cheetah can use hardware-SPI so we do not really need this + + #if ENABLED(CLCD_USE_SOFT_SPI) + #define CLCD_SOFT_SPI_MOSI EXP1_08_PIN + #define CLCD_SOFT_SPI_MISO EXP1_04_PIN + #define CLCD_SOFT_SPI_SCLK EXP1_06_PIN + #else + #define CLCD_SPI_BUS 2 + #endif +#endif diff --git a/src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h b/src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h new file mode 100644 index 0000000..120d6d6 --- /dev/null +++ b/src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h @@ -0,0 +1,59 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#include "pins_FYSETC_CHEETAH.h" + +#undef X_HARDWARE_SERIAL +#undef Y_HARDWARE_SERIAL +#undef Z_HARDWARE_SERIAL +#undef E0_HARDWARE_SERIAL + +#undef RGB_LED_R_PIN +#undef RGB_LED_G_PIN +#undef RGB_LED_B_PIN + +#define FAN1_PIN PB0 // Fan1 + +#if HAS_TMC_UART + + /** + * TMC2208/TMC2209 stepper drivers + */ + + #define X_SERIAL_TX_PIN PA11 + #define X_SERIAL_RX_PIN PA12 + + #define Y_SERIAL_TX_PIN PB6 + #define Y_SERIAL_RX_PIN PB7 + + #define Z_SERIAL_TX_PIN PB10 + #define Z_SERIAL_RX_PIN PB11 + + #define E0_SERIAL_TX_PIN PA2 + #define E0_SERIAL_RX_PIN PA3 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif diff --git a/src/pins/stm32f1/pins_GTM32_MINI.h b/src/pins/stm32f1/pins_GTM32_MINI.h new file mode 100644 index 0000000..5515132 --- /dev/null +++ b/src/pins/stm32f1/pins_GTM32_MINI.h @@ -0,0 +1,235 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech GTM32 Mini board pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "GTM32 Pro VB" +#define DEFAULT_MACHINE_NAME "STM32F103VET6" + +#define BOARD_NO_NATIVE_USB + +//#define DISABLE_DEBUG + +// +// It is required to disable JTAG function because its pins are +// used as GPIO to drive the Y axis stepper. +// DO NOT ENABLE! +// +#define DISABLE_JTAG + +// +// If you don't need the SWDIO functionality (any more), you may +// disable SWD here to regain PA13/PA14 pins for other use. +// +//#define DISABLE_JTAGSWD + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// Enable EEPROM Emulation for this board as it doesn't have EEPROM +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Limit Switches +// +#define X_MIN_PIN PE5 // ENDSTOPS 15,17 +#define X_MAX_PIN PE4 // ENDSTOPS 16,18 +#define Y_MIN_PIN PE3 // ENDSTOPS 9,11 +#define Y_MAX_PIN PE2 // ENDSTOPS 10,12 +#define Z_MIN_PIN PE1 // ENDSTOPS 3,5 +#define Z_MAX_PIN PE0 // ENDSTOPS 4,6 + +// +// Steppers +// +#define X_STEP_PIN PC6 +#define X_DIR_PIN PD13 +#define X_ENABLE_PIN PA8 + +#define Y_STEP_PIN PA12 +#define Y_DIR_PIN PA11 +#define Y_ENABLE_PIN PA15 + +#define Z_STEP_PIN PD6 +#define Z_DIR_PIN PD3 +#define Z_ENABLE_PIN PB3 + +// Extruder stepper pins +// NOTE: Numbering here is made according to EXT connector numbers, +// the FANx_PWM line numbering in the schematics is reverse. +// That is, E0_*_PIN are the E2_* lines connected to E2_A1 step +// stick that drives the EXT0 output on the board. +// +#define E0_STEP_PIN PC14 +#define E0_DIR_PIN PC13 +#define E0_ENABLE_PIN PC15 + +#define E1_STEP_PIN PA0 +#define E1_DIR_PIN PB6 +#define E1_ENABLE_PIN PA1 + +#define E2_STEP_PIN PB2 +#define E2_DIR_PIN PB11 +#define E2_ENABLE_PIN PC4 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB0 // EXT0 port +#define HEATER_1_PIN PB5 // EXT1 port +#define HEATER_2_PIN PB4 // EXT2 port +#define HEATER_BED_PIN PB1 // CON2X3 hotbed port + +// +// These are FAN PWM pins on EXT0..EXT2 connectors. +// +//#define FAN_PIN PB9 // EXT0 port +#define FAN1_PIN PB8 // EXT1 port +#define FAN2_PIN PB7 // EXT2 port + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PB9 // EXT0 port, used as main extruder fan +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC2 // EXT0 port +#define TEMP_1_PIN PC1 // EXT1 port +#define TEMP_2_PIN PC0 // EXT2 port +#define TEMP_BED_PIN PC3 // CON2X3 hotbed port + +// +// Misc. Functions +// +#define LED_PWM PD12 // External LED, pin 2 on LED labeled connector + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if IS_RRD_SC + // + // LCD display on J2 FFC40 + // Geeetech's LCD2004A Control Panel is very much like + // RepRapDiscount Smart Controller, but adds an FFC40 connector + // + #define LCD_PINS_RS PE6 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE PE14 // SID (MOSI) + #define LCD_PINS_D4 PD8 // SCK (CLK) clock + #define LCD_PINS_D5 PD9 + #define LCD_PINS_D6 PD10 + #define LCD_PINS_D7 PE15 + + #else + // + // Serial LCDs can be implemented in ExtUI + // + //#define LCD_UART_TX PD8 + //#define LCD_UART_RX PD9 + #endif + + // Alter timing for graphical display + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 715 + #endif + +#endif // HAS_WIRED_LCD + +#if IS_RRD_SC + // + // Geeetech's LCD2004A Control Panel is very much like + // RepRapDiscount Smart Controller, but adds an FFC40 connector + // connected with a flat wire to J2 connector on the board. + // + #define BTN_EN1 PE8 + #define BTN_EN2 PE9 + #define BTN_ENC PE13 + + #define GTM32_PRO_VB_USE_LCD_BEEPER + #define GTM32_PRO_VB_USE_EXT_SDCARD +#endif + +// +// Beeper +// +#ifdef GTM32_PRO_VB_USE_LCD_BEEPER + // This is pin 32 on J2 FFC40 and pin, goes to the beeper + // on Geeetech's version of RepRapDiscount Smart Controller + // (e.g., on Rostock 301) + #define BEEPER_PIN PE12 +#else + // This is the beeper on the board itself + #define BEEPER_PIN PB10 +#endif + +/** + * The on-board TF_CARD_SOCKET microSD card socket has no SD Detect pin wired. + * + * The FFC10 (SD_CARD) connector has the same pins as those routed to the FFC40 (J2) + * connector, which usually go to the SD Card slot on the Geeetech version of the + * RepRapDiscount Smart Controller. Both connectors have the card detect signal. + * + * The on-board SD card and the external card (on either SD_CARD or J2) are two + * separate devices and can work simultaneously. Unfortunately, Marlin only supports + * a single SPI Flash device (as of 2019-07-05) so only one is enabled here. + */ +#if ENABLED(GTM32_PRO_VB_USE_EXT_SDCARD) + // + // SD Card on RepRapDiscount Smart Controller (J2) or on SD_CARD connector + // + #define SD_SS_PIN PC11 + #define SD_SCK_PIN PC12 + #define SD_MOSI_PIN PD2 + #define SD_MISO_PIN PC8 + #define SD_DETECT_PIN PC7 +#else + // + // Use the on-board card socket labeled TF_CARD_SOCKET + // + #define SD_SS_PIN PA4 + #define SD_SCK_PIN PA5 + #define SD_MOSI_PIN PA7 + #define SD_MISO_PIN PA6 + #define SD_DETECT_PIN -1 // Card detect is not connected +#endif + +#define SDSS SD_SS_PIN + +// +// ESP WiFi can be soldered to J9 connector which is wired to USART2. +// Must define WIFISUPPORT in Configuration.h for the printer. +// +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115200 +#define ESP_WIFI_MODULE_RESET_PIN -1 diff --git a/src/pins/stm32f1/pins_GTM32_MINI_A30.h b/src/pins/stm32f1/pins_GTM32_MINI_A30.h new file mode 100644 index 0000000..dc23680 --- /dev/null +++ b/src/pins/stm32f1/pins_GTM32_MINI_A30.h @@ -0,0 +1,229 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech GTM32 Mini A30 board pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "GTM32 Pro VB" +#define DEFAULT_MACHINE_NAME "STM32F103VET6" + +#define BOARD_NO_NATIVE_USB + +//#define DISABLE_DEBUG + +// +// It is required to disable JTAG function because its pins are +// used as GPIO to drive the Y axis stepper. +// DO NOT ENABLE! +// +#define DISABLE_JTAG + +// +// If you don't need the SWDIO functionality (any more), you may +// disable SWD here to regain PA13/PA14 pins for other use. +// +//#define DISABLE_JTAGSWD + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// Enable EEPROM Emulation for this board as it doesn't have EEPROM +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Limit Switches +// +#define X_MIN_PIN PE5 // ENDSTOPS 15,17 +#define X_MAX_PIN PE4 // ENDSTOPS 16,18 +#define Y_MIN_PIN PE3 // ENDSTOPS 9,11 +#define Y_MAX_PIN PE2 // ENDSTOPS 10,12 +#define Z_MIN_PIN PE0 // ENDSTOPS 3,5 +#define Z_MAX_PIN PE1 // ENDSTOPS 4,6 + +// +// Steppers +// +#define X_STEP_PIN PC6 +#define X_DIR_PIN PD13 +#define X_ENABLE_PIN PA8 + +#define Y_STEP_PIN PA12 +#define Y_DIR_PIN PA11 +#define Y_ENABLE_PIN PA15 + +#define Z_STEP_PIN PD6 +#define Z_DIR_PIN PD3 +#define Z_ENABLE_PIN PB3 + +// Extruder stepper pins +// NOTE: Numbering here is made according to EXT connector numbers, +// the FANx_PWM line numbering in the schematics is reverse. +// That is, E0_*_PIN are the E2_* lines connected to E2_A1 step +// stick that drives the EXT0 output on the board. +// +#define E0_STEP_PIN PC14 +#define E0_DIR_PIN PC13 +#define E0_ENABLE_PIN PC15 + +#define E1_STEP_PIN PA0 +#define E1_DIR_PIN PB6 +#define E1_ENABLE_PIN PA1 + +#define E2_STEP_PIN PB2 +#define E2_DIR_PIN PB11 +#define E2_ENABLE_PIN PC4 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB0 // EXT0 port +#define HEATER_1_PIN PB5 // EXT1 port +#define HEATER_2_PIN PB4 // EXT2 port +#define HEATER_BED_PIN PB1 // CON2X3 hotbed port + +// +// These are FAN PWM pins on EXT0..EXT2 connectors. +// +//#define FAN_PIN PB9 // EXT0 port +#define FAN1_PIN PB8 // EXT1 port +#define FAN2_PIN PB7 // EXT2 port + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PB9 // EXT0 port, used as main extruder fan +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC2 // EXT0 port +#define TEMP_1_PIN PC1 // EXT1 port +#define TEMP_2_PIN PC0 // EXT2 port +#define TEMP_BED_PIN PC3 // CON2X3 hotbed port + +// +// Misc. Functions +// +#define LED_PWM PD12 // External LED, pin 2 on LED labeled connector + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if IS_RRD_SC + // + // LCD display on J2 FFC40 + // Geeetech's LCD2004A Control Panel is very much like + // RepRapDiscount Smart Controller, but adds an FFC40 connector + // connected with a flat wire to J2 connector on the board. + // + #define LCD_PINS_RS PE6 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE PE14 // SID (MOSI) + #define LCD_PINS_D4 PD8 // SCK (CLK) clock + #define LCD_PINS_D5 PD9 + #define LCD_PINS_D6 PD10 + #define LCD_PINS_D7 PE15 + + #define BTN_EN1 PE8 + #define BTN_EN2 PE9 + #define BTN_ENC PE13 + + #define GTM32_PRO_VB_USE_LCD_BEEPER + #define GTM32_PRO_VB_USE_EXT_SDCARD + + #else + // + // Serial LCDs can be implemented in ExtUI + // + //#define LCD_UART_TX PD8 + //#define LCD_UART_RX PD9 + #endif + + // Alter timing for graphical display + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 715 + #endif + +#endif // HAS_WIRED_LCD + +// +// Beeper +// +#ifdef GTM32_PRO_VB_USE_LCD_BEEPER + // This is pin 32 on J2 FFC40 and pin, goes to the beeper + // on Geeetech's version of RepRapDiscount Smart Controller + // (e.g. on Rostock 301) + #define BEEPER_PIN PE12 +#else + // This is the beeper on the board itself + #define BEEPER_PIN PB10 +#endif + +/** + * The on-board TF_CARD_SOCKET microSD card socket has no SD Detect pin wired. + * + * The FFC10 (SD_CARD) connector has the same pins as those routed to the FFC40 (J2) + * connector, which usually go to the SD Card slot on the Geeetech version of the + * RepRapDiscount Smart Controller. Both connectors have the card detect signal. + * + * The on-board SD card and the external card (on either SD_CARD or J2) are two + * separate devices and can work simultaneously. Unfortunately, Marlin only supports + * a single SPI Flash device (as of 2019-07-05) so only one is enabled here. + */ +#if ENABLED(GTM32_PRO_VB_USE_EXT_SDCARD) + // + // SD Card on RepRapDiscount Smart Controller (J2) or on SD_CARD connector + // + #define SD_SS_PIN PC11 + #define SD_SCK_PIN PC12 + #define SD_MOSI_PIN PD2 + #define SD_MISO_PIN PC8 + #define SD_DETECT_PIN PC7 +#else + // + // Use the on-board card socket labeled TF_CARD_SOCKET + // + #define SD_SS_PIN PA4 + #define SD_SCK_PIN PA5 + #define SD_MOSI_PIN PA7 + #define SD_MISO_PIN PA6 + #define SD_DETECT_PIN -1 // Card detect is not connected +#endif + +#define SDSS SD_SS_PIN + +// +// ESP WiFi can be soldered to J9 connector which is wired to USART2. +// Must define WIFISUPPORT in Configuration.h for the printer. +// +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115200 +#define ESP_WIFI_MODULE_RESET_PIN -1 diff --git a/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/src/pins/stm32f1/pins_GTM32_PRO_VB.h new file mode 100644 index 0000000..4b5d38e --- /dev/null +++ b/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -0,0 +1,240 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech GTM32 Pro VB board pin assignments + * http://www.geeetech.com/wiki/index.php/File:Hardware_GTM32_PRO_VB.pdf + * + * Also applies to GTM32 Pro VD + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "GTM32 Pro VB" +#endif +#define DEFAULT_MACHINE_NAME "STM32F103VET6" + +#define BOARD_NO_NATIVE_USB + +//#define DISABLE_DEBUG + +// +// It is required to disable JTAG function because its pins are +// used as GPIO to drive the Y axis stepper. +// DO NOT ENABLE! +// +#define DISABLE_JTAG + +// +// If you don't need the SWDIO functionality (any more), you may +// disable SWD here to regain PA13/PA14 pins for other use. +// +//#define DISABLE_JTAGSWD + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// Enable EEPROM Emulation for this board as it doesn't have EEPROM +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Limit Switches +// +#define X_MIN_PIN PE5 // ENDSTOPS 15,17 +#define X_MAX_PIN PE4 // ENDSTOPS 16,18 +#define Y_MIN_PIN PE3 // ENDSTOPS 9,11 +#define Y_MAX_PIN PE2 // ENDSTOPS 10,12 +#define Z_MIN_PIN PE1 // ENDSTOPS 3,5 +#define Z_MAX_PIN PE0 // ENDSTOPS 4,6 + +// +// Steppers +// +#define X_STEP_PIN PC6 +#define X_DIR_PIN PD13 +#define X_ENABLE_PIN PA8 + +#define Y_STEP_PIN PA12 +#define Y_DIR_PIN PA11 +#define Y_ENABLE_PIN PA15 + +#define Z_STEP_PIN PD6 +#define Z_DIR_PIN PD3 +#define Z_ENABLE_PIN PB3 + +// Extruder stepper pins +// NOTE: Numbering here is made according to EXT connector numbers, +// the FANx_PWM line numbering in the schematics is reverse. +// That is, E0_*_PIN are the E2_* lines connected to E2_A1 step +// stick that drives the EXT0 output on the board. +// +#define E0_STEP_PIN PC14 +#define E0_DIR_PIN PC13 +#define E0_ENABLE_PIN PC15 + +#define E1_STEP_PIN PA0 +#define E1_DIR_PIN PB6 +#define E1_ENABLE_PIN PA1 + +#define E2_STEP_PIN PB2 +#define E2_DIR_PIN PB11 +#define E2_ENABLE_PIN PC4 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB0 // EXT0 port +#define HEATER_1_PIN PB5 // EXT1 port +#define HEATER_2_PIN PB4 // EXT2 port +#define HEATER_BED_PIN PB1 // CON2X3 hotbed port + +// +// These are FAN PWM pins on EXT0..EXT2 connectors. +// +//#define FAN_PIN PB9 // EXT0 port +#define FAN1_PIN PB8 // EXT1 port +#define FAN2_PIN PB7 // EXT2 port + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PB9 // EXT0 port, used as main extruder fan +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC2 // EXT0 port +#define TEMP_1_PIN PC1 // EXT1 port +#define TEMP_2_PIN PC0 // EXT2 port +#define TEMP_BED_PIN PC3 // CON2X3 hotbed port + +// +// Misc. Functions +// +#define LED_PWM PD12 // External LED, pin 2 on LED labeled connector + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if IS_RRD_SC + // + // LCD display on J2 FFC40 + // Geeetech's LCD2004A Control Panel is very much like + // RepRapDiscount Smart Controller, but adds an FFC40 connector + // + #define LCD_PINS_RS PE6 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE PE14 // SID (MOSI) + #define LCD_PINS_D4 PD8 // SCK (CLK) clock + #define LCD_PINS_D5 PD9 + #define LCD_PINS_D6 PD10 + #define LCD_PINS_D7 PE15 + + #else + // + // Serial LCDs can be implemented in ExtUI + // + //#define LCD_UART_TX PD8 + //#define LCD_UART_RX PD9 + #endif + + // Alter timing for graphical display + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 715 + #endif + +#endif // HAS_WIRED_LCD + +#if IS_RRD_SC + // + // Geeetech's LCD2004A Control Panel is very much like + // RepRapDiscount Smart Controller, but adds an FFC40 connector + // connected with a flat wire to J2 connector on the board. + // + #define BTN_EN1 PE8 + #define BTN_EN2 PE9 + #define BTN_ENC PE13 + + #define GTM32_PRO_VB_USE_LCD_BEEPER + #define GTM32_PRO_VB_USE_EXT_SDCARD +#endif + +// +// Beeper +// +#ifdef GTM32_PRO_VB_USE_LCD_BEEPER + // This is pin 32 on J2 FFC40 and pin, goes to the beeper + // on Geeetech's version of RepRapDiscount Smart Controller + // (e.g. on Rostock 301) + #define BEEPER_PIN PE12 +#else + // This is the beeper on the board itself + #define BEEPER_PIN PB10 +#endif + +/** + * The on-board TF_CARD_SOCKET microSD card socket has no SD Detect pin wired. + * + * The FFC10 (SD_CARD) connector has the same pins as those routed to the FFC40 (J2) + * connector, which usually go to the SD Card slot on the Geeetech version of the + * RepRapDiscount Smart Controller. Both connectors have the card detect signal. + * + * The on-board SD card and the external card (on either SD_CARD or J2) are two + * separate devices and can work simultaneously. Unfortunately, Marlin only supports + * a single SPI Flash device (as of 2019-07-05) so only one is enabled here. + */ +#if ENABLED(GTM32_PRO_VB_USE_EXT_SDCARD) + // + // SD Card on RepRapDiscount Smart Controller (J2) or on SD_CARD connector + // + #define SD_SS_PIN PC11 + #define SD_SCK_PIN PC12 + #define SD_MOSI_PIN PD2 + #define SD_MISO_PIN PC8 + #define SD_DETECT_PIN PC7 +#else + // + // Use the on-board card socket labeled TF_CARD_SOCKET + // + #define SD_SS_PIN PA4 + #define SD_SCK_PIN PA5 + #define SD_MOSI_PIN PA7 + #define SD_MISO_PIN PA6 + #define SD_DETECT_PIN -1 // Card detect is not connected +#endif + +#define SDSS SD_SS_PIN + +// +// ESP WiFi can be soldered to J9 connector which is wired to USART2. +// Must define WIFISUPPORT in Configuration.h for the printer. +// +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115200 +#define ESP_WIFI_MODULE_RESET_PIN -1 diff --git a/src/pins/stm32f1/pins_GTM32_PRO_VD.h b/src/pins/stm32f1/pins_GTM32_PRO_VD.h new file mode 100644 index 0000000..fb8c73c --- /dev/null +++ b/src/pins/stm32f1/pins_GTM32_PRO_VD.h @@ -0,0 +1,30 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Geeetech GTM32 Pro VD board pin assignments + */ + +#define BOARD_INFO_NAME "GTM32 Pro VD" + +#include "pins_GTM32_PRO_VB.h" diff --git a/src/pins/stm32f1/pins_GTM32_REV_B.h b/src/pins/stm32f1/pins_GTM32_REV_B.h new file mode 100644 index 0000000..968d9cb --- /dev/null +++ b/src/pins/stm32f1/pins_GTM32_REV_B.h @@ -0,0 +1,232 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Geeetech GTM32 Rev. B board pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "GTM32 Rev B" +#define DEFAULT_MACHINE_NAME "M201" + +#define BOARD_NO_NATIVE_USB + +//#define DISABLE_DEBUG + +// +// It is required to disable JTAG function because its pins are +// used as GPIO to drive the Y axis stepper. +// DO NOT ENABLE! +// +#define DISABLE_JTAG + +// +// If you don't need the SWDIO functionality (any more), you may +// disable SWD here to regain PA13/PA14 pins for other use. +// +//#define DISABLE_JTAGSWD + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// Enable EEPROM Emulation for this board as it doesn't have EEPROM +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Limit Switches +// +#define X_MIN_PIN PE5 // ENDSTOPS 15,17 +#define X_MAX_PIN PE4 // ENDSTOPS 16,18 +#define Y_MIN_PIN PE3 // ENDSTOPS 9,11 +#define Y_MAX_PIN PE2 // ENDSTOPS 10,12 +#define Z_MIN_PIN PE1 // ENDSTOPS 3,5 +#define Z_MAX_PIN PE0 // ENDSTOPS 4,6 + +// +// Steppers +// +#define X_STEP_PIN PC6 +#define X_DIR_PIN PD13 +#define X_ENABLE_PIN PA8 + +#define Y_STEP_PIN PA12 +#define Y_DIR_PIN PA11 +#define Y_ENABLE_PIN PA15 + +#define Z_STEP_PIN PD6 +#define Z_DIR_PIN PD3 +#define Z_ENABLE_PIN PB3 + +// Extruder stepper pins +// NOTE: Numbering here is made according to EXT connector numbers, +// the FANx_PWM line numbering in the schematics is reverse. +// That is, E0_*_PIN are the E2_* lines connected to E2_A1 step +// stick that drives the EXT0 output on the board. +// +#define E0_STEP_PIN PC14 +#define E0_DIR_PIN PC13 +#define E0_ENABLE_PIN PC15 + +#define E1_STEP_PIN PA0 +#define E1_DIR_PIN PB6 +#define E1_ENABLE_PIN PA1 + +#define E2_STEP_PIN PB2 +#define E2_DIR_PIN PB11 +#define E2_ENABLE_PIN PC4 + +// +// Heaters / Fans - INFO: Extruders ports are in reverse order. Pin numbers here differ from schematic. Original firmware assumes heater, fan and temp sensor on port EXT0 PB0, PB9, PC2. +// +#define HEATER_0_PIN PB0 // EXT0 port. +#define HEATER_1_PIN PB5 // EXT1 port +#define HEATER_2_PIN PB4 // EXT2 port +#define HEATER_BED_PIN PB1 // CON2X3 hotbed port + +// +// These are FAN PWM pins on EXT0..EXT2 connectors. +// +//#define FAN_PIN PB9 // EXT0 port +#define FAN1_PIN PB8 // EXT1 port +#define FAN2_PIN PB7 // EXT2 port + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PB9 // EXT0 port, used as main extruder fan +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC2 // EXT0 port +#define TEMP_1_PIN PC1 // EXT1 port +#define TEMP_2_PIN PC0 // EXT2 port +#define TEMP_BED_PIN PC3 // CON2X3 hotbed port + +// +// Misc. Functions +// +#define LED_PWM PD12 // External LED, pin 2 on LED labeled connector + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if IS_RRD_SC + + // + // LCD display on J2 FFC40 + // Geeetech's LCD2004A Control Panel is very much like + // RepRapDiscount Smart Controller, but adds an FFC40 connector + // connected with a flat wire to J2 connector on the board. + // + #define LCD_PINS_RS PA12 // CS chip select /SS chip slave select + // RW is hardwired to VSS + #define LCD_PINS_ENABLE PC7 // SID (MOSI) + #define LCD_PINS_D4 PD1 // SCK (CLK) clock + #define LCD_PINS_D5 PD4 + #define LCD_PINS_D6 PD5 + #define LCD_PINS_D7 PD7 + + #define BTN_EN1 PE8 + #define BTN_EN2 PE9 + #define BTN_ENC PE13 + + //#define GTM32_PRO_VB_USE_LCD_BEEPER + #define GTM32_PRO_VB_USE_EXT_SDCARD + + #else + // + // Serial LCDs can be implemented in ExtUI + // + //#define LCD_UART_TX PD8 + //#define LCD_UART_RX PD9 + #endif + + // Alter timing for graphical display + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 715 + #endif + +#endif // HAS_WIRED_LCD + +// +// Beeper +// +#ifdef GTM32_PRO_VB_USE_LCD_BEEPER + // This is pin 32 on J2 FFC40 and pin, goes to the beeper + // on Geeetech's version of RepRapDiscount Smart Controller + // (e.g. on Rostock 301) + #define BEEPER_PIN PE12 +#else + // This is the beeper on the board itself + #define BEEPER_PIN PB10 +#endif + +/** + * The on-board TF_CARD_SOCKET microSD card socket has no SD Detect pin wired. + * + * The FFC10 (SD_CARD) connector has the same pins as those routed to the FFC40 (J2) + * connector, which usually go to the SD Card slot on the Geeetech version of the + * RepRapDiscount Smart Controller. Both connectors have the card detect signal. + * + * The on-board SD card and the external card (on either SD_CARD or J2) are two + * separate devices and can work simultaneously. Unfortunately, Marlin only supports + * a single SPI Flash device (as of 2019-07-05) so only one is enabled here. + */ +#if ENABLED(GTM32_PRO_VB_USE_EXT_SDCARD) + // + // SD Card on RepRapDiscount Smart Controller (J2) or on SD_CARD connector + // + #define SD_SS_PIN PB12 // PC11 + #define SD_SCK_PIN PB13 // PC12 // PC1 + #define SD_MOSI_PIN PB15 // PD2 // PD2 + #define SD_MISO_PIN PB14 // PC8 + #define SD_DETECT_PIN PC7 + +#else + // + // Use the on-board card socket labeled TF_CARD_SOCKET + // + #define SD_SS_PIN PA4 + #define SD_SCK_PIN PA5 + #define SD_MOSI_PIN PA7 + #define SD_MISO_PIN PA6 // PA6 + #define SD_DETECT_PIN -1 // Card detect is not connected +#endif + +#define SDSS SD_SS_PIN + +// +// ESP WiFi can be soldered to J9 connector which is wired to USART2. +// Must define WIFISUPPORT in Configuration.h for the printer. +// +#define ESP_WIFI_MODULE_COM 2 +#define ESP_WIFI_MODULE_BAUDRATE 115200 +#define ESP_WIFI_MODULE_RESET_PIN -1 diff --git a/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h new file mode 100644 index 0000000..d3cf3e5 --- /dev/null +++ b/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -0,0 +1,147 @@ +/** + * 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 . + * + */ +#pragma once + + /** + * ╦╔═╗╔═╗┬ ┬┬─┐┌─┐┬─┐┌─┐╔═╗┌─┐┬─┐┬ ┬┌┬┐ ┌─┐┌─┐┌┬┐ + * ║║ ╦╠═╣│ │├┬┘│ │├┬┘├─┤╠╣ │ │├┬┘│ ││││ │ │ ││││ + * ╚╝╚═╝╩ ╩└─┘┴└─└─┘┴└─┴ ┴╚ └─┘┴└─└─┘┴ ┴o└─┘└─┘┴ ┴ + * Pin assignments for 32-bit JGAurora A5S & A1 + * + * https://jgaurorawiki.com/_media/jgaurora_a5s_a1_pinout.png + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "JGAurora A5S A1 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "JGAurora A5S A1" + +#define BOARD_NO_NATIVE_USB + +#ifndef STM32_XL_DENSITY + #define STM32_XL_DENSITY +#endif + +//#define MCU_STM32F103ZE // not yet required + +// Enable EEPROM Emulation for this board, so that we don't overwrite factory data +#if NO_EEPROM_SELECTED + //#define I2C_EEPROM // AT24C64 + //#define FLASH_EEPROM_EMULATION +#endif + +#if ENABLED(I2C_EEPROM) + //#define MARLIN_EEPROM_SIZE 0x8000UL // 32K +#elif ENABLED(FLASH_EEPROM_EMULATION) + //#define MARLIN_EEPROM_SIZE 0x1000UL // 4K + //#define MARLIN_EEPROM_SIZE (EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE) * 2UL) +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PC6 +#define Y_STOP_PIN PG8 +#define Z_STOP_PIN PG7 +//#define X_MAX_PIN PC5 +//#define Y_MAX_PIN PC4 +//#define Z_MAX_PIN PB0 + +// +// Steppers +// +#define X_STEP_PIN PD6 +#define X_DIR_PIN PD3 +#define X_ENABLE_PIN PG9 + +#define Y_STEP_PIN PG12 +#define Y_DIR_PIN PG11 +#define Y_ENABLE_PIN PG13 + +#define Z_STEP_PIN PG15 +#define Z_DIR_PIN PG14 +#define Z_ENABLE_PIN PB8 + +#define E0_STEP_PIN PE2 +#define E0_DIR_PIN PB9 +#define E0_ENABLE_PIN PE3 + +#define E1_STEP_PIN PE5 +#define E1_DIR_PIN PE4 +#define E1_ENABLE_PIN PE6 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC2 +#define TEMP_BED_PIN PC1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA2 +#define HEATER_BED_PIN PA3 + +#define FAN_PIN PA1 + +#define FIL_RUNOUT_PIN PC7 + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #define LCD_BACKLIGHT_PIN PF11 + #define FSMC_CS_PIN PD7 + #define FSMC_RS_PIN PG0 + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN +#endif + +// +// SD Card +// +#define SD_DETECT_PIN PF10 + +// +// Misc. +// +#define BEEPER_PIN PC3 // use PB7 to shut up if desired +#define LED_PIN PC13 + +// +// Touch support +// +#if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PA4 + #define TOUCH_INT_PIN PC4 + #define TOUCH_MISO_PIN PA6 + #define TOUCH_MOSI_PIN PA7 + #define TOUCH_SCK_PIN PA5 +#endif diff --git a/src/pins/stm32f1/pins_LONGER3D_LK.h b/src/pins/stm32f1/pins_LONGER3D_LK.h new file mode 100644 index 0000000..e6d3174 --- /dev/null +++ b/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -0,0 +1,212 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Longer3D LK1/LK2 & Alfawise U20/U30 (STM32F103VET6) board pin assignments + */ + +#if NOT_TARGET(__STM32F1__, STM32F1xx) + #error "Oops! Select a STM32F1 board in 'Tools > Board.'" +#elif HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Longer3D only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Longer3D" + +#define BOARD_NO_NATIVE_USB + +//#define DISABLE_DEBUG // We still want to debug with STLINK... +#define DISABLE_JTAG // We free the jtag pins (PA15) but keep STLINK + // Release PB4 (STEP_X_PIN) from JTAG NRST role. +// +// Limit Switches +// +#define X_MIN_PIN PC1 // pin 16 +#define X_MAX_PIN PC0 // pin 15 (Filament sensor on Alfawise setup) +#define Y_MIN_PIN PC15 // pin 9 +#define Y_MAX_PIN PC14 // pin 8 (Unused in stock Alfawise setup) +#define Z_MIN_PIN PE6 // pin 5 Standard Endstop or Z_Probe endstop function +#define Z_MAX_PIN PE5 // pin 4 (Unused in stock Alfawise setup) + // May be used for BLTouch Servo function on older variants (<= V08) +#define ONBOARD_ENDSTOPPULLUPS + +// +// Filament Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC0 // XMAX plug on PCB used as filament runout sensor on Alfawise boards (inverting true) +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PB5 // pin 91 +#define X_STEP_PIN PB4 // pin 90 +#define X_DIR_PIN PB3 // pin 89 + +#define Y_ENABLE_PIN PB8 // pin 95 +#define Y_STEP_PIN PB7 // pin 93 +#define Y_DIR_PIN PB6 // pin 92 + +#define Z_ENABLE_PIN PE1 // pin 98 +#define Z_STEP_PIN PE0 // pin 97 +#define Z_DIR_PIN PB9 // pin 96 + +#define E0_ENABLE_PIN PE4 // pin 3 +#define E0_STEP_PIN PE3 // pin 2 +#define E0_DIR_PIN PE2 // pin 1 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // pin 23 (Nozzle 100K/3950 thermistor) +#define TEMP_BED_PIN PA1 // pin 24 (Hot Bed 100K/3950 thermistor) + +// +// Heaters / Fans +// +#define HEATER_0_PIN PD3 // pin 84 (Nozzle Heat Mosfet) +#define HEATER_BED_PIN PA8 // pin 67 (Hot Bed Mosfet) + +#define FAN_PIN PA15 // pin 77 (4cm Fan) + +#if TERN(MAPLE_STM32F1, ENABLED(FAN_SOFT_PWM), ENABLED(FAST_PWM_FAN)) && FAN_MIN_PWM < 5 // Required to avoid issues with heating or STLink + #error "FAN_MIN_PWM must be 5 or higher." // Fan will not start in 1-30 range +#endif + +#if defined(MAPLE_STM32F1) || DISABLED(FAST_PWM_FAN) // STM32 HAL required to allow TIMER2 Hardware PWM + #define FAN_SOFT_PWM_REQUIRED +#else + #if FAST_PWM_FAN_FREQUENCY <= 1000 // Default 1000 is noisy, max 65K (uint16) + #error "FAST_PWM_FAN_FREQUENCY must be greater than 1000." + #elif FAST_PWM_FAN_FREQUENCY > 65535 + #error "FAST_PWM_FAN_FREQUENCY must be less than 65536." + #endif +#endif + +//#define BEEPER_PIN PD13 // pin 60 (Servo PWM output 5V/GND on Board V0G+) made for BL-Touch sensor + // Can drive a PC Buzzer, if connected between PWM and 5V pins + +#define LED_PIN PC2 // pin 17 + +// Longer3D board mosfets are passing by default +// Avoid nozzle heat and fan start before serial init +#define BOARD_OPENDRAIN_MOSFETS + +#define BOARD_PREINIT() { \ + OUT_WRITE_OD(HEATER_0_PIN, 0); \ + OUT_WRITE_OD(HEATER_BED_PIN, 0); \ + OUT_WRITE_OD(FAN_PIN, 0); \ +} + +// +// PWM for a servo probe +// Other servo devices are not supported on this board! +// +#if HAS_Z_SERVO_PROBE + #define SERVO0_PIN PD13 // Open drain PWM pin on the V0G (GND or floating 5V) + #define SERVO0_PWM_OD // Comment this if using PE5 + + //#define SERVO0_PIN PE5 // Pulled up PWM pin on the V08 (3.3V or 0) + //#undef Z_MAX_PIN // Uncomment if using ZMAX connector (PE5) +#endif + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PD7 // pin 88 = FSMC_NE1 + #define FSMC_RS_PIN PD11 // pin 58 A16 Register. Only one address needed + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define TFT_RESET_PIN PC4 // pin 33 + #define TFT_BACKLIGHT_PIN PD12 // pin 59 + #define TFT_BACKLIGHT_PWM 150 // Brightness with alt. TIM4 chan 1 (1-255) + + #define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h + #define DOGLCD_SCK -1 + + // Buffer for Color UI + #define TFT_BUFFER_SIZE 3200 +#endif + +#if defined(TFT_BACKLIGHT_PWM) && !defined(MAPLE_STM32F1) + #define HAS_LCD_BRIGHTNESS 1 + #define LCD_BRIGHTNESS_DEFAULT TFT_BACKLIGHT_PWM +#endif + +#if ENABLED(SDIO_SUPPORT) + #define SD_SS_PIN -1 // else SDSS set to PA4 in M43 (spi_pins.h) +#endif + +/** + * Note: Alfawise U20/U30 boards DON'T use SPI2, as the hardware designer + * mixed up MOSI and MISO pins. SPI is managed in SW, and needs pins + * declared below. + */ +#if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PB12 // pin 51 SPI2_NSS + #define TOUCH_SCK_PIN PB13 // pin 52 + #define TOUCH_MOSI_PIN PB14 // pin 53 (Inverted MOSI/MISO = No HW SPI2) + #define TOUCH_MISO_PIN PB15 // pin 54 + #define TOUCH_INT_PIN PC6 // pin 63 (PenIRQ coming from ADS7843) +#endif + +// +// Persistent Storage +// If no option is selected below the SD Card will be used +// +#if NO_EEPROM_SELECTED + //#define SPI_EEPROM + //#define HAS_SPI_FLASH 1 // need MARLIN_DEV_MODE for M993/M994 eeprom backup tests + #define FLASH_EEPROM_EMULATION +#endif + +#if ENABLED(SPI_EEPROM) + // SPI1 EEPROM Winbond W25Q64 (8MB/64Mbits) + #define SPI_CHAN_EEPROM1 1 + #define SPI_EEPROM1_CS_PIN PC5 // pin 34 + #define EEPROM_SCK_PIN BOARD_SPI1_SCK_PIN // PA5 pin 30 + #define EEPROM_MISO_PIN BOARD_SPI1_MISO_PIN // PA6 pin 31 + #define EEPROM_MOSI_PIN BOARD_SPI1_MOSI_PIN // PA7 pin 32 + #define EEPROM_PAGE_SIZE 0x1000U // 4K (from datasheet) + #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64K for now... +#elif HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x40000U // limit to 256K (M993 will reboot with 512) + #define SPI_FLASH_CS_PIN PC5 + #define SPI_FLASH_MOSI_PIN PA7 + #define SPI_FLASH_MISO_PIN PA6 + #define SPI_FLASH_SCK_PIN PA5 +#elif ENABLED(FLASH_EEPROM_EMULATION) + // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) +#else + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2K, require this amount of RAM +#endif diff --git a/src/pins/stm32f1/pins_MALYAN_M200.h b/src/pins/stm32f1/pins_MALYAN_M200.h new file mode 100644 index 0000000..94e5340 --- /dev/null +++ b/src/pins/stm32f1/pins_MALYAN_M200.h @@ -0,0 +1,95 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MALYAN M200 pin assignments + */ + +#if NOT_TARGET(__STM32F1__, STM32F1xx, STM32F0xx) + #error "Oops! Select an STM32 board in your IDE." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Malyan M200" +#endif + +// Prevents hanging from an extra watchdog init +#define DISABLE_WATCHDOG_INIT + +// Assume Flash EEPROM +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION +#endif + +#define SDSS SD_SS_PIN // Also in HAL/STM32F1/spi_pins.h + +// Based on PWM timer usage, we have to use these timers and soft PWM for the fans +// On STM32F103: +// PB3, PB6, PB7, and PB8 can be used with pwm, which rules out TIM2 and TIM4. +// On STM32F070, 16 and 17 are in use, but 1 and 3 are available. +#define STEP_TIMER 1 +#define TEMP_TIMER 3 + +// +// Limit Switches +// +#define X_STOP_PIN PB4 +#define Y_STOP_PIN PA15 +#define Z_STOP_PIN PB5 + +// +// Steppers +// +// X & Y enable are the same +#define X_STEP_PIN PB14 +#define X_DIR_PIN PB15 +#define X_ENABLE_PIN PA8 + +#define Y_STEP_PIN PB12 +#define Y_DIR_PIN PB13 +#define Y_ENABLE_PIN PA8 + +#define Z_STEP_PIN PB10 +#define Z_DIR_PIN PB2 +#define Z_ENABLE_PIN PB11 + +#define E0_STEP_PIN PB0 +#define E0_DIR_PIN PC13 +#define E0_ENABLE_PIN PB1 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input (HOTEND0 thermistor) +#define TEMP_BED_PIN PA1 // Analog Input (BED thermistor) + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB6 // HOTEND0 MOSFET +#define HEATER_BED_PIN PB7 // BED MOSFET + +#define MALYAN_FAN1_PIN PB8 // FAN1 header on board - PRINT FAN +#define MALYAN_FAN2_PIN PB3 // FAN2 header on board - CONTROLLER FAN + +#define FAN1_PIN MALYAN_FAN2_PIN diff --git a/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h b/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h new file mode 100644 index 0000000..f157c8e --- /dev/null +++ b/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h @@ -0,0 +1,161 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MPX ARM MINI (STM32F103ZET6) board pin assignments + */ + +#if NOT_TARGET(STM32F1, STM32F1xx) + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#elif HOTENDS > 1 || E_STEPPERS > 1 + #error "MPX ARM Mini only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Mingda MPX ARM Mini" + +#define BOARD_NO_NATIVE_USB +#define DISABLE_DEBUG + +// +// EEPROM +// + +/* +//Mingda used an unknown EEPROM chip ATMLH753, so I turned on the emulation below. +//It is connected to EEPROM PB6 PB7 + +#define I2C_EEPROM +#undef NO_EEPROM_SELECTED +#define MARLIN_EEPROM_SIZE 0x1000 // 4K +#define USE_SHARED_EEPROM 1 // Use Platform-independent Arduino functions for I2C EEPROM +#define E2END 0xFFFF // EEPROM end address AT24C256 (32kB) +*/ + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE 0x800U // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +#define SPI_DEVICE 2 + +// +// Limit Switches +// +#define X_MIN_PIN PD6 +#define X_MAX_PIN PG15 // To double check +#define Y_MIN_PIN PG9 +#define Y_MAX_PIN PG14 // To double check +#define Z_MIN_PIN PG10 +#define Z_MAX_PIN PG13 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PG11 +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PD13 +#define X_STEP_PIN PD12 +#define X_DIR_PIN PD11 + +#define Y_ENABLE_PIN PG4 +#define Y_STEP_PIN PG3 +#define Y_DIR_PIN PG2 + +#define Z_ENABLE_PIN PG7 +#define Z_STEP_PIN PG6 +#define Z_DIR_PIN PG5 + +#define E0_ENABLE_PIN PC7 +#define E0_STEP_PIN PC6 +#define E0_DIR_PIN PG8 + +// +// Temperature Sensors +// +//#define TEMP_0_PIN PF6 // THERM_E0 +//#define TEMP_0_PIN PB3 // E0 K+ +#define TEMP_BED_PIN PF7 // THERM_BED + +#define TEMP_0_CS_PIN PB5 +#define TEMP_0_SCK_PIN PB3 +#define TEMP_0_MISO_PIN PB4 +#define TEMP_0_MOSI_PIN PA14 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB0 +#define HEATER_BED_PIN PB1 + +#define FAN_PIN PA0 // FAN + +// +// SD Card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#define SDIO_SUPPORT +#define SDIO_CLOCK 4500000 // 4.5 MHz +#define SDIO_READ_RETRIES 16 + +#define SD_DETECT_PIN PC5 +#define ONBOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PC10 + +// +// LCD / Controller +// +#define BEEPER_PIN PE4 + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #define TFT_RESET_PIN PF15 + #define TFT_BACKLIGHT_PIN PF11 + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PD7 // NE4 + #define FSMC_RS_PIN PG0 // A0 + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 +#endif + +#if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PA4 // SPI1_NSS + #define TOUCH_SCK_PIN PA5 // SPI1_SCK + #define TOUCH_MISO_PIN PA6 // SPI1_MISO + #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI +#endif diff --git a/src/pins/stm32f1/pins_MKS_ROBIN.h b/src/pins/stm32f1/pins_MKS_ROBIN.h new file mode 100644 index 0000000..2c147eb --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -0,0 +1,282 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin (STM32F103ZET6) board pin assignments + * https://github.com/makerbase-mks/MKS-Robin/tree/master/MKS%20Robin/Hardware + */ + +#if NOT_TARGET(STM32F1, STM32F1xx) + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#elif HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS Robin supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS Robin" + +#define BOARD_NO_NATIVE_USB + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_JTAG + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #ifdef ARDUINO_ARCH_STM32 + #define FLASH_EEPROM_EMULATION + #else + #define SDCARD_EEPROM_EMULATION + #endif +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) +#endif + +// +// Servos +// +#define SERVO0_PIN PC3 // XS1 - 5 +#define SERVO1_PIN PA1 // XS1 - 6 +#define SERVO2_PIN PF9 // XS2 - 5 +#define SERVO3_PIN PF8 // XS2 - 6 + +// +// Limit Switches +// +#define X_MIN_PIN PB12 +#define X_MAX_PIN PB0 +#define Y_MIN_PIN PC5 +#define Y_MAX_PIN PC4 +#define Z_MIN_PIN PA4 +#define Z_MAX_PIN PF7 + +// +// Steppers +// +#define X_ENABLE_PIN PB9 +#define X_STEP_PIN PB8 +#define X_DIR_PIN PB5 + +#define Y_ENABLE_PIN PB4 +#define Y_STEP_PIN PG15 +#define Y_DIR_PIN PG10 + +#define Z_ENABLE_PIN PD7 +#define Z_STEP_PIN PD3 +#define Z_DIR_PIN PG14 + +#define E0_ENABLE_PIN PG13 +#define E0_STEP_PIN PG8 +#define E0_DIR_PIN PA15 + +#define E1_ENABLE_PIN PA12 +#define E1_STEP_PIN PA11 +#define E1_DIR_PIN PA8 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH1 +#define TEMP_1_PIN PC2 // TH2 +#define TEMP_BED_PIN PC0 // TB1 + +// +// Heaters +// +#define HEATER_0_PIN PC7 // HEATER1 +#define HEATER_1_PIN PA6 // HEATER2 +#define HEATER_BED_PIN PC6 // HOT BED + +// +// Fan +// +#define FAN_PIN PA7 // FAN + +// +// Thermocouples +// +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PF11 // MT_DET + +// +// Power loss detection +// +#define POWER_LOSS_PIN PA2 // PW_DET + +// +// Power supply control +// +#define PS_ON_PIN PA3 // PW_OFF + +// +// Piezzoelectric speaker +// +#define BEEPER_PIN PC13 + +// +// Activity LED +// +#define LED_PIN PB2 + +// +// ESP12-S Wi-Fi module +// +#define WIFI_IO0_PIN PG1 + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + /** + * Note: MKS Robin TFT screens use various TFT controllers + * Supported screens are based on the ILI9341, ST7789V and ILI9328 (320x240) + * ILI9488 is not supported + * Define init sequences for other screens in u8g_dev_tft_320x240_upscale_from_128x64.cpp + * + * If the screen stays white, disable 'TFT_RESET_PIN' + * to let the bootloader init the screen. + * + * Setting an 'TFT_RESET_PIN' may cause a flicker when entering the LCD menu + * because Marlin uses the reset as a failsafe to revive a glitchy LCD. + */ + #define TFT_RESET_PIN PF6 + #define TFT_BACKLIGHT_PIN PG11 + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PG12 // NE4 + #define FSMC_RS_PIN PF0 // A0 + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 + #define TFT_BUFFER_SIZE 14400 +#endif + +#if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PB1 // SPI2_NSS + #define TOUCH_SCK_PIN PB13 // SPI2_SCK + #define TOUCH_MISO_PIN PB14 // SPI2_MISO + #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + #define TOUCH_INT_PIN -1 +#endif + +// SPI2 is shared by LCD touch driver and flash +// SPI1(PA7) & SPI3(PB5) not available +#define SPI_DEVICE 2 + +#define SDIO_SUPPORT +#define SDIO_CLOCK 4500000 +#define SDIO_READ_RETRIES 16 +#if ENABLED(SDIO_SUPPORT) + #define SD_SCK_PIN PB13 // SPI2 + #define SD_MISO_PIN PB14 // SPI2 + #define SD_MOSI_PIN PB15 // SPI2 + /** + * MKS Robin has a few hardware revisions + * https://github.com/makerbase-mks/MKS-Robin/tree/master/MKS%20Robin/Hardware + * + * MKS Robin <= V2.3 have no SD_DETECT_PIN. + * MKS Robin >= V2.4 have SD_DETECT_PIN on PF12. + * + * Uncomment here or add SD_DETECT_PIN to Configuration.h. + */ + //#define SD_DETECT_PIN -1 + //#define SD_DETECT_PIN PF12 // SD_CD +#else + // SD as custom software SPI (SDIO pins) + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #define SD_SS_PIN -1 + #define ONBOARD_SD_CS_PIN PC11 + #define SDSS PD2 + #define SD_DETECT_PIN -1 +#endif + +// +// Trinamic TMC2208/2209 UART +// +#if HAS_TMC_UART + /** + * This board does not have dedicated TMC UART pins. Custom wiring is needed. + * You may uncomment one of the options below, or add it to your Configuration.h. + * + * When using up to four TMC2209 drivers, hardware serial is recommended on + * MSerial0 or MSerial1. + * + * When using TMC2208 or more than four drivers, SoftwareSerial will be needed, + * to provide dedicated pins for each drier. + */ + + //#define TMC_HARDWARE_SERIAL + #if ENABLED(TMC_HARDWARE_SERIAL) + #define X_HARDWARE_SERIAL MSerial0 + #define X2_HARDWARE_SERIAL MSerial0 + #define Y_HARDWARE_SERIAL MSerial0 + #define Y2_HARDWARE_SERIAL MSerial0 + #define Z_HARDWARE_SERIAL MSerial0 + #define Z2_HARDWARE_SERIAL MSerial0 + #define E0_HARDWARE_SERIAL MSerial0 + #define E1_HARDWARE_SERIAL MSerial0 + #endif + + //#define TMC_SOFTWARE_SERIAL + #if ENABLED(TMC_SOFTWARE_SERIAL) + #define X_SERIAL_TX_PIN PF8 // SERVO3_PIN -- XS2 - 6 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN PF9 // SERVO2_PIN -- XS2 - 5 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN PA1 // SERVO1_PIN -- XS1 - 6 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN PC3 // SERVO0_PIN -- XS1 - 5 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + #define TMC_BAUD_RATE 19200 + #endif +#endif + +// +// W25Q64 64Mb (8MB) SPI flash +// +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x800000 // 8MB + #define SPI_FLASH_CS_PIN PG9 + #define SPI_FLASH_MOSI_PIN PB15 + #define SPI_FLASH_MISO_PIN PB14 + #define SPI_FLASH_SCK_PIN PB13 +#endif diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_E3.h b/src/pins/stm32f1/pins_MKS_ROBIN_E3.h new file mode 100644 index 0000000..448e62a --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_E3.h @@ -0,0 +1,36 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin E3 (STM32F103RCT6) board pin assignments + */ + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "MKS Robin E3 only supports 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS Robin E3" +#endif + +#include "pins_MKS_ROBIN_E3_common.h" diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h b/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h new file mode 100644 index 0000000..77c2b79 --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h @@ -0,0 +1,67 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin E3D (STM32F103RCT6) board pin assignments + */ + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "MKS Robin E3D only supports 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS Robin E3D" +#endif + +// +// Steppers +// +#ifndef X_CS_PIN + #define X_CS_PIN PC7 +#endif +#ifndef Y_CS_PIN + #define Y_CS_PIN PD2 +#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN PC12 +#endif +#ifndef E0_CS_PIN + #define E0_CS_PIN PC11 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB15 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB14 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB13 + #endif +#endif + +#include "pins_MKS_ROBIN_E3_common.h" diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_E3D_V1_1.h b/src/pins/stm32f1/pins_MKS_ROBIN_E3D_V1_1.h new file mode 100644 index 0000000..2ad68a0 --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_E3D_V1_1.h @@ -0,0 +1,67 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin E3D v1.1 (STM32F103RCT6) board pin assignments + */ + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "MKS Robin E3D v1.1 only supports 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS Robin E3D V1.1" +#endif + +// +// Steppers +// +#ifndef X_CS_PIN + #define X_CS_PIN PC7 +#endif +#ifndef Y_CS_PIN + #define Y_CS_PIN PD2 +#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN PC12 +#endif +#ifndef E0_CS_PIN + #define E0_CS_PIN PC11 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB15 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB14 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB13 + #endif +#endif + +#include "pins_MKS_ROBIN_E3_V1_1_common.h" // ... MKS_ROBIN_E3_common diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h new file mode 100644 index 0000000..b8f6f6a --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -0,0 +1,395 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin nano (STM32F103VET6) board pin assignments + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "MKS Robin E3P only supports 1 hotend / E stepper." +#elif HAS_FSMC_TFT + #error "MKS Robin E3P doesn't support FSMC-based TFT displays." +#endif + +#define BOARD_INFO_NAME "MKS Robin E3P" + +#define BOARD_NO_NATIVE_USB +#define MKS_HARDWARE_TEST_ONLY_E0 + +// Avoid conflict with TIMER_SERVO when using the STM32 HAL +#define TEMP_TIMER 5 + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// EEPROM +// +//#define FLASH_EEPROM_EMULATION +//#define SDCARD_EEPROM_EMULATION + +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #define I2C_EEPROM // EEPROM on I2C-0 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Note: MKS Robin board is using SPI2 interface. +// +#define SPI_DEVICE 2 + +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + +// +// Limit Switches +// +#define X_DIAG_PIN PA15 +#define Y_DIAG_PIN PA12 +#define Z_DIAG_PIN PA11 +#define E0_DIAG_PIN PC4 + +#define X_STOP_PIN PA15 +#define Y_STOP_PIN PA12 +#define Z_MIN_PIN PA11 +#define Z_MAX_PIN PC4 + +// +// Steppers +// +#define X_ENABLE_PIN PE4 +#define X_STEP_PIN PE3 +#define X_DIR_PIN PE2 +#ifndef X_CS_PIN + #define X_CS_PIN PD5 +#endif + +#define Y_ENABLE_PIN PE1 +#define Y_STEP_PIN PE0 +#define Y_DIR_PIN PB9 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD7 +#endif + +#define Z_ENABLE_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB4 +#ifndef Z_CS_PIN + #define Z_CS_PIN PD4 +#endif + +#define E0_ENABLE_PIN PB3 +#define E0_STEP_PIN PD6 +#define E0_DIR_PIN PD3 +#ifndef E0_CS_PIN + #define E0_CS_PIN PD9 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PD14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PD1 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PD0 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN PD5 + #define X_SERIAL_RX_PIN PD5 + + #define Y_SERIAL_TX_PIN PD7 + #define Y_SERIAL_RX_PIN PD7 + + #define Z_SERIAL_TX_PIN PD4 + #define Z_SERIAL_RX_PIN PD4 + + #define E0_SERIAL_TX_PIN PD9 + #define E0_SERIAL_RX_PIN PD9 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif // HAS_TMC_UART + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH1 +#define TEMP_BED_PIN PC0 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC3 // HEATER1 +#define HEATER_BED_PIN PA0 // HOT BED + +#define FAN_PIN PB1 // FAN + +// +// Misc. Functions +// +#if HAS_TFT_LVGL_UI + #if ENABLED(MKS_PWC) + #define SUICIDE_PIN PB2 + #define SUICIDE_PIN_STATE LOW + #define KILL_PIN PA2 + #define KILL_PIN_STATE HIGH + #endif + + #define MT_DET_1_PIN PA4 + #define MT_DET_PIN_STATE LOW + + #define WIFI_IO0_PIN PC13 + #define WIFI_IO1_PIN PC7 + #define WIFI_RESET_PIN PE9 + + #if ENABLED(MKS_TEST) + #define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET + #define MKS_TEST_PS_ON_PIN PB0 // PW_OFF + #endif +#else + //#define POWER_LOSS_PIN PA2 // PW_DET + //#define PS_ON_PIN PB2 // PW_OFF + #define FIL_RUNOUT_PIN PA4 +#endif + +//#define LED_PIN PB2 + +/** + * ------ ------ + * PC5 | 1 2 | PE13 PA6 | 1 2 | PA5 + * PD13 | 3 4 | PC6 PE8 | 3 4 | PE10 + * PE14 | 5 6 PE15 PE11 | 5 6 PA7 + * PD11 | 7 8 | PD10 PE12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PE13 +#define EXP1_03_PIN PD13 +#define EXP1_04_PIN PC6 +#define EXP1_05_PIN PE14 +#define EXP1_06_PIN PE15 +#define EXP1_07_PIN PD11 +#define EXP1_08_PIN PD10 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE8 +#define EXP2_04_PIN PE10 +#define EXP2_05_PIN PE11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PE12 +#define EXP2_08_PIN -1 + +// +// SD Card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT + #define SDIO_CLOCK 4500000 // 4.5 MHz + #define SD_DETECT_PIN PD12 + #define ONBOARD_SD_CS_PIN PC11 +#elif SD_CONNECTION_IS(LCD) + #define ENABLE_SPI1 + #define SDSS EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN +#endif + +// +// LCD / Controller +// + +/** + * Note: MKS Robin TFT screens use various TFT controllers. + * If the screen stays white, disable 'LCD_RESET_PIN' + * to let the bootloader init the screen. + */ + +#if HAS_SPI_TFT + + // Shared SPI TFT + + #define LCD_BACKLIGHT_PIN EXP1_03_PIN + + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN + + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN EXP1_04_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + #define LCD_USE_DMA_SPI + +#endif + +#if ENABLED(TFT_CLASSIC_UI) + // Emulated DOGM SPI + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN +#elif ENABLED(TFT_COLOR_UI) + #define TFT_BUFFER_SIZE 14400 +#endif + +#if HAS_WIRED_LCD && !HAS_SPI_TFT + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define LCD_BACKLIGHT_PIN -1 + + #if ENABLED(MKS_MINI_12864) + + // MKS MINI12864 and MKS LCD12864B + // If using MKS LCD12864A (Need to remove RPK2 resistor) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define PIN_SPI_SCK EXP2_02_PIN + #define PIN_TFT_MISO EXP2_01_PIN + #define PIN_TFT_MOSI EXP2_06_PIN + #define TFTGLCD_CS EXP2_03_PIN + #endif + + #ifndef BEEPER_PIN + #define BEEPER_PIN -1 + #endif + + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 DOGLCD_A0 + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #else // !MKS_MINI_12864 + + #define LCD_PINS_D4 EXP1_05_PIN + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 + + #endif // !MKS_MINI_12864 + +#endif // HAS_WIRED_LCD && !HAS_SPI_TFT + +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x1000000 // 16MB + #define SPI_FLASH_CS_PIN PB12 + #define SPI_FLASH_MOSI_PIN PB15 + #define SPI_FLASH_MISO_PIN PB14 + #define SPI_FLASH_SCK_PIN PB13 +#endif + +#ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_01_PIN +#endif + +#if ENABLED(SPEAKER) && BEEPER_PIN == PC5 + #error "MKS Robin nano default BEEPER_PIN is not a SPEAKER." +#endif diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1.h b/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1.h new file mode 100644 index 0000000..13677b4 --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1.h @@ -0,0 +1,36 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin E3 v1.1 (STM32F103RCT6) board pin assignments + */ + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "MKS Robin E3 v1.1 only supports 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS Robin E3 V1.1" +#endif + +#include "pins_MKS_ROBIN_E3_V1_1_common.h" // ... MKS_ROBIN_E3_common diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1_common.h b/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1_common.h new file mode 100644 index 0000000..31e034e --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1_common.h @@ -0,0 +1,39 @@ +/** + * 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 . + * + */ +#pragma once + +// +// EEPROM +// +// Onboard I2C EEPROM +#if NO_EEPROM_SELECTED + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x1000// 4K + #undef NO_EEPROM_SELECTED +#endif + +#define Z_STEP_PIN PC14 +#define Z_DIR_PIN PC15 + +#define BTN_ENC_EN -1 + +#include "pins_MKS_ROBIN_E3_common.h" diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h new file mode 100644 index 0000000..642c97b --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -0,0 +1,265 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin E3 & E3D (STM32F103RCT6) common board pin assignments + */ + +#include "env_validate.h" + +#define BOARD_WEBSITE_URL "github.com/makerbase-mks" + +#define BOARD_NO_NATIVE_USB +#define USES_DIAG_JUMPERS + +//#define DISABLE_DEBUG +#define DISABLE_JTAG + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +// +// Servos +// +#define SERVO0_PIN PA3 + +// +// Limit Switches +// +#define X_STOP_PIN PA12 +#define Y_STOP_PIN PA11 +#define Z_STOP_PIN PC6 + +// +// Z Probe +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB1 +#endif + +// +// Steppers +// +#define X_STEP_PIN PC0 +#define X_DIR_PIN PB2 +#define X_ENABLE_PIN PC13 + +#define Y_STEP_PIN PC2 +#define Y_DIR_PIN PB9 +#define Y_ENABLE_PIN PB12 + +#ifndef Z_STEP_PIN + #define Z_STEP_PIN PB7 +#endif +#ifndef Z_DIR_PIN + #define Z_DIR_PIN PB6 +#endif +#define Z_ENABLE_PIN PB8 + +#define E0_STEP_PIN PB4 +#define E0_DIR_PIN PB3 +#define E0_ENABLE_PIN PB5 + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + + #define X_SERIAL_TX_PIN PC7 + #define X_SERIAL_RX_PIN PC7 + + #define Y_SERIAL_TX_PIN PD2 + #define Y_SERIAL_RX_PIN PD2 + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN PC12 + + #define E0_SERIAL_TX_PIN PC11 + #define E0_SERIAL_RX_PIN PC11 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Heaters 0,1 / Fans / Bed +// +#define HEATER_0_PIN PC9 +#define FAN_PIN PA8 +#define HEATER_BED_PIN PC8 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA1 // TB +#define TEMP_0_PIN PA0 // TH1 + +#define FIL_RUNOUT_PIN PB10 // MT_DET + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #define PS_ON_PIN PA14 // PW_OFF + #define KILL_PIN PB10 // PW_DET + #define KILL_PIN_STATE HIGH +#endif + +/** + * ------ ------ ------ + * (BEEPER) PC1 | 1 2 | PC3 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SD_SCK) (BEEPER) PC1 | 1 2 | PC3 (BTN_ENC) + * (LCD_EN) PA4 | 3 4 | PA5 (LCD_RS) (BTN_EN1) PB11 | 3 4 | PA15 (SD_SS) (BTN_EN1) PB11 | 3 4 | RESET + * (LCD_D4) PA6 5 6 | PA7 (LCD_D5) (BTN_EN2) PB0 5 6 | PB15 (SD_MOSI) (BTN_EN2) PB0 5 6 | PA6 (LCD_D4) + * (LCD_D6) PC4 | 7 8 | PC5 (LCD_D7) (SD_DETECT) PC10 | 7 8 | RESET (LCD_RS) PA5 | 7 8 | PA4 (LCD_EN) + * GND | 9 10 | 5V GND | 9 10 | -- GND | 9 10 | 5V + * ------ ------ ------ + * EXP1 EXP2 "Ender-3 EXP1" + */ +#define EXP1_01_PIN PC1 +#define EXP1_02_PIN PC3 +#define EXP1_03_PIN PA4 +#define EXP1_04_PIN PA5 +#define EXP1_05_PIN PA6 +#define EXP1_06_PIN PA7 +#define EXP1_07_PIN PC4 +#define EXP1_08_PIN PC5 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PB11 +#define EXP2_04_PIN PA15 +#define EXP2_05_PIN PB0 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PC10 +#define EXP2_08_PIN -1 // RESET + +// "Ender-3 EXP1" +#define EXP3_01_PIN PC1 +#define EXP3_02_PIN PC3 +#define EXP3_03_PIN PB11 +#define EXP3_04_PIN -1 // RESET +#define EXP3_05_PIN PB0 +#define EXP3_06_PIN PA6 +#define EXP3_07_PIN PA5 +#define EXP3_08_PIN PA4 + +#if HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 LCD_PINS_DC + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define FORCE_SOFT_SPI + #define SOFTWARE_SPI + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #else + + #define LCD_PINS_D4 EXP1_05_PIN + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if !defined(BTN_ENC_EN) && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif // !MKS_MINI_12864 + +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 125 + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 125 + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 125 + #endif +#endif + +// LED driving pin +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA2 +#endif + +// +// SD Card +// +#define SDCARD_CONNECTION ONBOARD +#define SPI_DEVICE 2 +#define ONBOARD_SPI_DEVICE 2 +#define SDSS SD_SS_PIN +#define ONBOARD_SD_CS_PIN SD_SS_PIN +#define SD_DETECT_PIN PC10 // EXP2_07_PIN +#define NO_SD_HOST_DRIVE + +// TODO: This is the only way to set SPI for SD on STM32 (for now) +#define ENABLE_SPI2 +#define SD_SCK_PIN EXP2_02_PIN +#define SD_MISO_PIN EXP2_01_PIN +#define SD_MOSI_PIN EXP2_06_PIN +#define SD_SS_PIN EXP2_04_PIN diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h new file mode 100644 index 0000000..7ead6aa --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -0,0 +1,175 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "MKS Robin Lite only supports 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS Robin Lite" +#endif +#define BOARD_WEBSITE_URL "github.com/makerbase-mks" + +#define BOARD_NO_NATIVE_USB + +//#define DISABLE_DEBUG +#define DISABLE_JTAG + +// +// Limit Switches +// +#define X_STOP_PIN PC13 +#define Y_STOP_PIN PC0 +#define Z_MIN_PIN PC12 +#define Z_MAX_PIN PB9 + +// +// Steppers +// +#define X_STEP_PIN PC6 +#define X_DIR_PIN PB12 +#define X_ENABLE_PIN PB10 + +#define Y_STEP_PIN PB11 +#define Y_DIR_PIN PB2 +#define Y_ENABLE_PIN PB10 + +#define Z_STEP_PIN PB1 +#define Z_DIR_PIN PC5 +#define Z_ENABLE_PIN PB10 + +#define E0_STEP_PIN PC4 +#define E0_DIR_PIN PA5 +#define E0_ENABLE_PIN PA4 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC9 +#define FAN_PIN PA8 +#define HEATER_BED_PIN PC8 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA1 +#define TEMP_0_PIN PA0 + +#define FIL_RUNOUT_PIN PB8 // MT_DET + +/** ------ + * (BEEPER) PD2 | 1 2 | PB3 (BTN_ENC) + * (BTN_EN1) PB5 | 3 4 | PA11 (RESET?) + * (BTN_EN2) PB4 5 6 | PC1 (LCD_D4) + * (LCD_RS) PC3 | 7 8 | PC2 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * "E3" EXP1 + */ +#define EXP3_01_PIN PD2 +#define EXP3_02_PIN PB3 +#define EXP3_03_PIN PB5 +#define EXP3_04_PIN PA11 // RESET? +#define EXP3_05_PIN PB4 +#define EXP3_06_PIN PC1 +#define EXP3_07_PIN PC3 +#define EXP3_08_PIN PC2 +#define EXP3_09_PIN -1 // GND +#define EXP3_10_PIN -1 // 5V + +// +// LCD Pins +// +#if HAS_WIRED_LCD + #define BEEPER_PIN EXP3_01_PIN + #define BTN_ENC EXP3_02_PIN + #define LCD_PINS_RS EXP3_07_PIN + + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN + + #define LCD_PINS_ENABLE EXP3_08_PIN + + #if ENABLED(MKS_MINI_12864) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 EXP3_06_PIN + #define DOGLCD_CS EXP3_08_PIN + #define DOGLCD_SCK PB13 + #define DOGLCD_MOSI PB15 + + #else // !MKS_MINI_12864 + + #define LCD_PINS_D4 EXP3_06_PIN + #if IS_ULTIPANEL + #define LCD_PINS_D5 -1 + #define LCD_PINS_D6 -1 + #define LCD_PINS_D7 -1 + #endif + + #endif // !MKS_MINI_12864 + + // Alter timing for graphical display + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 + #endif + +#endif // HAS_WIRED_LCD + +// Motor current PWM pins +#define MOTOR_CURRENT_PWM_XY_PIN PB0 +#define MOTOR_CURRENT_PWM_Z_PIN PA7 +#define MOTOR_CURRENT_PWM_E_PIN PA6 +#define MOTOR_CURRENT_PWM_RANGE (65535/10/3.3) // (255 * (1000mA / 65535)) * 257 = 1000 is equal 1.6v Vref in turn equal 1Amp +#define DEFAULT_PWM_MOTOR_CURRENT { 1000, 1000, 1000 } // 1.05Amp per driver, here is XY, Z and E. This values determined empirically. + +// +// SD Card +// +#define SD_DETECT_PIN PC10 + +// +// SPI +// +#define SPI_DEVICE 2 +#define SD_SCK_PIN PB13 +#define SD_MISO_PIN PB14 +#define SD_MOSI_PIN PB15 +#define SD_SS_PIN PA15 + +// EXP1 replace LCD with keys for EasyThreeD ET4000+ Mainboard +#if ENABLED(EASYTHREED_UI) + #define BTN_HOME EXP3_07_PIN // INPUT_PULLUP (unused) + #define BTN_FEED EXP3_02_PIN // Run E Forward + #define BTN_RETRACT EXP3_03_PIN // Run E Backward + #define BTN_PRINT EXP3_04_PIN // Start File Print + #define BTN_HOME_GND EXP3_08_PIN // OUTPUT (LOW) + #define BTN_FEED_GND EXP3_05_PIN // OUTPUT (LOW) + #define BTN_RETRACT_GND EXP3_06_PIN // OUTPUT (LOW) + #define EASYTHREED_LED_PIN EXP3_01_PIN // Indicator LED +#endif diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h b/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h new file mode 100644 index 0000000..b1aaa53 --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h @@ -0,0 +1,159 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin Lite 3 (STM32F103RCT6) board pin assignments + */ + +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS Robin Lite3 supports up to 2 hotends / E steppers." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS Robin Lite3" +#endif +#define BOARD_WEBSITE_URL "github.com/makerbase-mks" + +#define BOARD_NO_NATIVE_USB + +//#define DISABLE_DEBUG +#define DISABLE_JTAG + +// +// Servos +// +#define SERVO0_PIN PA3 + +// +// Limit Switches +// +#define X_STOP_PIN PA12 +#define Y_STOP_PIN PA11 +#define Z_MIN_PIN PC6 +#define Z_MAX_PIN PB1 + +// +// Steppers +// +#define X_STEP_PIN PC0 +#define X_DIR_PIN PB2 +#define X_ENABLE_PIN PC13 + +#define Y_STEP_PIN PC2 +#define Y_DIR_PIN PB9 +#define Y_ENABLE_PIN PB12 + +#define Z_STEP_PIN PB7 +#define Z_DIR_PIN PB6 +#define Z_ENABLE_PIN PB8 + +#define E0_STEP_PIN PB4 +#define E0_DIR_PIN PB3 +#define E0_ENABLE_PIN PB5 + +#define E1_STEP_PIN PC12 +#define E1_DIR_PIN PC11 +#define E1_ENABLE_PIN PD2 + +// +// Heaters 0,1 / Fans / Bed +// +#define HEATER_0_PIN PC9 +#define HEATER_1_PIN PC7 +#define FAN_PIN PA8 +#define HEATER_BED_PIN PC8 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA1 // TB +#define TEMP_0_PIN PA0 // TH1 +#define TEMP_1_PIN PA2 // TH2 + +#define FIL_RUNOUT_PIN PB10 // MT_DET + +// +// LCD Pins +// +#if HAS_WIRED_LCD + + #define BEEPER_PIN PC1 + #define BTN_ENC PC3 + #define LCD_PINS_ENABLE PA4 + #define LCD_PINS_RS PA5 + #define BTN_EN1 PB11 + #define BTN_EN2 PB0 + + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 PC4 + #define DOGLCD_CS PA7 + #define DOGLCD_SCK PB13 + #define DOGLCD_MOSI PB15 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS PB11 + #endif + + #else // !MKS_MINI_12864 + + #define LCD_PINS_D4 PA6 + #if IS_ULTIPANEL + #define LCD_PINS_D5 PA7 + #define LCD_PINS_D6 PC4 + #define LCD_PINS_D7 PC5 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif // !MKS_MINI_12864 + + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 + +#endif // HAS_WIRED_LCD + +// +// SD Card +// +#define SD_DETECT_PIN PC10 + +// +// SPI +// +#define SPI_DEVICE 2 +#define SD_SCK_PIN PB13 +#define SD_MISO_PIN PB14 +#define SD_MOSI_PIN PB15 +#define SD_SS_PIN PA15 diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h new file mode 100644 index 0000000..0bfc7f5 --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -0,0 +1,206 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin mini (STM32F103VET6) board pin assignments + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "MKS Robin mini only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "MKS Robin Mini" + +#define BOARD_NO_NATIVE_USB + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +#define SPI_DEVICE 2 + +// +// Servos +// +#ifndef SERVO0_PIN + #define SERVO0_PIN PA8 // Enable BLTOUCH support on IO0 (WIFI connector) +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PA15 +#define Y_STOP_PIN PA12 +#define Z_MIN_PIN PA11 +#define Z_MAX_PIN PC4 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA4 // MT_DET +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PE4 +#define X_STEP_PIN PE3 +#define X_DIR_PIN PE2 + +#define Y_ENABLE_PIN PE1 +#define Y_STEP_PIN PE0 +#define Y_DIR_PIN PB9 + +#define Z_ENABLE_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB4 + +#define E0_ENABLE_PIN PB3 +#define E0_STEP_PIN PD6 +#define E0_DIR_PIN PD3 + +// Motor current PWM pins +#define MOTOR_CURRENT_PWM_XY_PIN PA6 +#define MOTOR_CURRENT_PWM_Z_PIN PA7 +#define MOTOR_CURRENT_PWM_E_PIN PB0 +#define MOTOR_CURRENT_PWM_RANGE 1500 // (255 * (1000mA / 65535)) * 257 = 1000 is equal 1.6v Vref in turn equal 1Amp +#ifndef DEFAULT_PWM_MOTOR_CURRENT + #define DEFAULT_PWM_MOTOR_CURRENT { 800, 800, 800 } +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH1 +#define TEMP_BED_PIN PC0 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC3 +#define HEATER_BED_PIN PA0 + +#define FAN_PIN PB1 // FAN + +// +// Misc. Functions +// +#define POWER_LOSS_PIN PA2 // PW_DET +#define PS_ON_PIN PA3 // PW_OFF + +#if HAS_TFT_LVGL_UI + #define MT_DET_1_PIN PA4 // MT_DET + #define MT_DET_PIN_STATE LOW +#endif + +#define WIFI_IO0_PIN PC13 + +// +// SD Card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#define SDIO_SUPPORT +#define SDIO_CLOCK 4500000 // 4.5 MHz +#define SD_DETECT_PIN PD12 +#define ONBOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PC11 + +// +// LCD / Controller +// +#define BEEPER_PIN PC5 + +/** + * Note: MKS Robin TFT screens use various TFT controllers. + * If the screen stays white, disable 'LCD_RESET_PIN' + * to let the bootloader init the screen. + */ +#if EITHER(HAS_FSMC_GRAPHICAL_TFT, TFT_320x240) + #define FSMC_CS_PIN PD7 // NE4 + #define FSMC_RS_PIN PD11 // A0 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define LCD_RESET_PIN PC6 // FSMC_RST + #define LCD_BACKLIGHT_PIN PD13 +#endif + +#if BOTH(NEED_TOUCH_PINS, HAS_FSMC_GRAPHICAL_TFT) || ENABLED(TFT_320x240) + #define TOUCH_CS_PIN PC2 // SPI2_NSS + #define TOUCH_SCK_PIN PB13 // SPI2_SCK + #define TOUCH_MISO_PIN PB14 // SPI2_MISO + #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI +#endif + +#if ENABLED(TFT_320x240) // TFT32/28 + #define TFT_DRIVER ILI9341 + #define TFT_BUFFER_SIZE 14400 + #define ILI9341_COLOR_RGB + // YV for normal screen mounting + #define ILI9341_ORIENTATION ILI9341_MADCTL_MY | ILI9341_MADCTL_MV + // XV for 180° rotated screen mounting + //#define ILI9341_ORIENTATION ILI9341_MADCTL_MX | ILI9341_MADCTL_MV +#endif + +#if ENABLED(TOUCH_SCREEN) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 12033 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y -9047 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X -30 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 254 + #endif +#endif + +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x1000000 // 16MB + #define SPI_FLASH_CS_PIN PB12 // Flash chip-select + #define SPI_FLASH_MOSI_PIN PB15 + #define SPI_FLASH_MISO_PIN PB14 + #define SPI_FLASH_SCK_PIN PB13 +#endif diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h new file mode 100644 index 0000000..115058a --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -0,0 +1,51 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin nano (STM32F103VET6) board pin assignments + * https://github.com/makerbase-mks/MKS-Robin-Nano-V1.X/tree/master/hardware + */ + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#define BOARD_INFO_NAME "MKS Robin Nano" + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_JTAG + +// +// Thermocouples +// +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 + +//#define LED_PIN PB2 + +#include "pins_MKS_ROBIN_NANO_common.h" + +#if HAS_TFT_LVGL_UI && FAN1_PIN != PB0 && HEATER_1_PIN != PB0 + #define BOARD_INIT() OUT_WRITE(PB0, LOW) +#endif diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h new file mode 100644 index 0000000..9ce5d27 --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -0,0 +1,395 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin nano (STM32F103VET6) board pin assignments + */ + +#if NOT_TARGET(__STM32F1__, STM32F1) + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#elif HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS Robin nano supports up to 2 hotends / E steppers." +#elif HAS_FSMC_TFT + #error "MKS Robin nano v2 doesn't support FSMC-based TFT displays." +#endif + +#define BOARD_INFO_NAME "MKS Robin nano V2.0" + +#define BOARD_NO_NATIVE_USB +#define USES_DIAG_PINS + +// Avoid conflict with TIMER_SERVO when using the STM32 HAL +#define TEMP_TIMER 5 + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// EEPROM +// +//#define FLASH_EEPROM_EMULATION +//#define SDCARD_EEPROM_EMULATION + +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #define I2C_EEPROM // EEPROM on I2C-0 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Note: MKS Robin board is using SPI2 interface. +// +#define SPI_DEVICE 2 + +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + +// +// Limit Switches +// +#define X_DIAG_PIN PA15 +#define Y_DIAG_PIN PA12 +#define Z_DIAG_PIN PA11 +#define E0_DIAG_PIN PC4 +#define E1_DIAG_PIN PE7 + +#define X_STOP_PIN PA15 +#define Y_STOP_PIN PA12 +#define Z_MIN_PIN PA11 +#define Z_MAX_PIN PC4 + +// +// Steppers +// +#define X_ENABLE_PIN PE4 +#define X_STEP_PIN PE3 +#define X_DIR_PIN PE2 +#ifndef X_CS_PIN + #define X_CS_PIN PD5 +#endif + +#define Y_ENABLE_PIN PE1 +#define Y_STEP_PIN PE0 +#define Y_DIR_PIN PB9 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD7 +#endif + +#define Z_ENABLE_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB4 +#ifndef Z_CS_PIN + #define Z_CS_PIN PD4 +#endif + +#define E0_ENABLE_PIN PB3 +#define E0_STEP_PIN PD6 +#define E0_DIR_PIN PD3 +#ifndef E0_CS_PIN + #define E0_CS_PIN PD9 +#endif + +#define E1_ENABLE_PIN PA3 +#define E1_STEP_PIN PD15 +#define E1_DIR_PIN PA1 +#ifndef E1_CS_PIN + #define E1_CS_PIN PD8 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PD14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PD1 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PD0 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + //#define E1_HARDWARE_SERIAL MSerial1 + + #define X_SERIAL_TX_PIN PD5 + #define X_SERIAL_RX_PIN PD5 + + #define Y_SERIAL_TX_PIN PD7 + #define Y_SERIAL_RX_PIN PD7 + + #define Z_SERIAL_TX_PIN PD4 + #define Z_SERIAL_RX_PIN PD4 + + #define E0_SERIAL_TX_PIN PD9 + #define E0_SERIAL_RX_PIN PD9 + + #define E1_SERIAL_TX_PIN PD8 + #define E1_SERIAL_RX_PIN PD8 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif // HAS_TMC_UART + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH1 +#define TEMP_1_PIN PC2 // TH2 +#define TEMP_BED_PIN PC0 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC3 // HEATER1 +#define HEATER_1_PIN PB0 // HEATER2 +#define HEATER_BED_PIN PA0 // HOT BED + +#define FAN_PIN PB1 // FAN + +// +// Thermocouples +// +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #if ENABLED(TFT_LVGL_UI) + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif + #undef MKS_PWC + #define SUICIDE_PIN PB2 + #define SUICIDE_PIN_STATE LOW + #else + #define PS_ON_PIN PB2 // PW_OFF + #endif + #define KILL_PIN PA2 + #define KILL_PIN_STATE HIGH +#endif + +// +// Misc. Functions +// +#if HAS_TFT_LVGL_UI + #define MT_DET_1_PIN PA4 + #define MT_DET_2_PIN PE6 + #define MT_DET_PIN_STATE LOW + + #define WIFI_IO0_PIN PC13 + #define WIFI_IO1_PIN PC7 + #define WIFI_RESET_PIN PE9 + + #if ENABLED(MKS_TEST) + #define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET + #define MKS_TEST_PS_ON_PIN PB2 // PW_OFF + #endif +#else + //#define POWER_LOSS_PIN PA2 // PW_DET + //#define PS_ON_PIN PB2 // PW_OFF + #define FIL_RUNOUT_PIN PA4 + #define FIL_RUNOUT2_PIN PE6 +#endif + +//#define LED_PIN PB2 + +// +// SD Card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT + #define SDIO_CLOCK 4500000 // 4.5 MHz + #define SD_DETECT_PIN PD12 + #define ONBOARD_SD_CS_PIN PC11 +#elif SD_CONNECTION_IS(LCD) + #define ENABLE_SPI1 + #define SDSS PE10 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_DETECT_PIN PE12 +#endif + +// +// LCD / Controller +// + +/** + * Note: MKS Robin TFT screens use various TFT controllers. + * If the screen stays white, disable 'LCD_RESET_PIN' + * to let the bootloader init the screen. + */ + +#if HAS_SPI_TFT + + // Shared SPI TFT + + #define LCD_BACKLIGHT_PIN PD13 + + #define TOUCH_CS_PIN PE14 // SPI1_NSS + #define TOUCH_SCK_PIN PA5 // SPI1_SCK + #define TOUCH_MISO_PIN PA6 // SPI1_MISO + #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI + + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 + #define BTN_ENC PE13 + + #define TFT_CS_PIN PD11 + #define TFT_SCK_PIN PA5 + #define TFT_MISO_PIN PA6 + #define TFT_MOSI_PIN PA7 + #define TFT_DC_PIN PD10 + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN PC6 + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + #define LCD_USE_DMA_SPI + +#endif + +#if ENABLED(TFT_CLASSIC_UI) + // Emulated DOGM SPI + #define LCD_PINS_ENABLE PD13 + #define LCD_PINS_RS PC6 + #define BTN_ENC PE13 + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 +#elif ENABLED(TFT_COLOR_UI) + #define TFT_BUFFER_SIZE 14400 +#endif + +#if HAS_WIRED_LCD && !HAS_SPI_TFT + #define BEEPER_PIN PC5 + #define BTN_ENC PE13 + #define LCD_PINS_ENABLE PD13 + #define LCD_PINS_RS PC6 + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 + #define LCD_BACKLIGHT_PIN -1 + + #if ENABLED(MKS_MINI_12864) + + // MKS MINI12864 and MKS LCD12864B + // If using MKS LCD12864A (Need to remove RPK2 resistor) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 PD11 + #define DOGLCD_CS PE15 + #define DOGLCD_SCK PA5 + #define DOGLCD_MOSI PA7 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define PIN_SPI_SCK PA5 + #define PIN_TFT_MISO PA6 + #define PIN_TFT_MOSI PA7 + #define TFTGLCD_CS PE8 + #endif + + #ifndef BEEPER_PIN + #define BEEPER_PIN -1 + #endif + + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define LCD_PINS_DC PC6 + #define DOGLCD_CS PD13 + #define DOGLCD_A0 DOGLCD_A0 + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN PE14 + #define NEOPIXEL_PIN PE15 + #define DOGLCD_MOSI PA7 + #define DOGLCD_SCK PA5 + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #else // !MKS_MINI_12864 + + #define LCD_PINS_D4 PE14 + #if IS_ULTIPANEL + #define LCD_PINS_D5 PE15 + #define LCD_PINS_D6 PD11 + #define LCD_PINS_D7 PD10 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 + #endif + + #endif // !MKS_MINI_12864 + +#endif // HAS_WIRED_LCD && !HAS_SPI_TFT + +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x1000000 // 16MB + #define SPI_FLASH_CS_PIN PB12 + #define SPI_FLASH_MOSI_PIN PB15 + #define SPI_FLASH_MISO_PIN PB14 + #define SPI_FLASH_SCK_PIN PB13 +#endif + +#ifndef BEEPER_PIN + #define BEEPER_PIN PC5 +#endif + +#if ENABLED(SPEAKER) && BEEPER_PIN == PC5 + #error "MKS Robin nano default BEEPER_PIN is not a SPEAKER." +#endif diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h b/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h new file mode 100644 index 0000000..0eb7bbd --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h @@ -0,0 +1,211 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * MKS Robin Nano board common pin assignments + */ + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS Robin nano boards support up to 2 hotends / E steppers." +#endif + +#define BOARD_NO_NATIVE_USB + +// Avoid conflict with TIMER_SERVO when using the STM32 HAL +#define TEMP_TIMER 5 + +// +// EEPROM +// +#if ENABLED(SRAM_EEPROM_EMULATION) + #undef NO_EEPROM_SELECTED +#endif +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +#define SPI_DEVICE 2 + +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + +// +// Limit Switches +// +#define X_STOP_PIN PA15 +#define Y_STOP_PIN PA12 +#define Z_MIN_PIN PA11 +#define Z_MAX_PIN PC4 + +// +// Steppers +// +#define X_ENABLE_PIN PE4 +#define X_STEP_PIN PE3 +#define X_DIR_PIN PE2 + +#define Y_ENABLE_PIN PE1 +#define Y_STEP_PIN PE0 +#define Y_DIR_PIN PB9 + +#define Z_ENABLE_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB4 + +#define E0_ENABLE_PIN PB3 +#define E0_STEP_PIN PD6 +#define E0_DIR_PIN PD3 + +#define E1_ENABLE_PIN PA3 +#define E1_STEP_PIN PA6 +#define E1_DIR_PIN PA1 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH1 +#define TEMP_1_PIN PC2 // TH2 +#define TEMP_BED_PIN PC0 // TB1 + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PC3 +#endif +#ifndef FAN_PIN + #define FAN_PIN PB1 // FAN +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PA0 +#endif + +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #ifndef FAN1_PIN + #define FAN1_PIN PB0 + #endif +#elif !defined(HEATER_1_PIN) + #define HEATER_1_PIN PB0 +#endif + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #if ENABLED(TFT_LVGL_UI) + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif + #undef MKS_PWC + #define SUICIDE_PIN PB2 + #define SUICIDE_PIN_STATE LOW + #else + #define PS_ON_PIN PB2 // PW_OFF + #endif + #define KILL_PIN PA2 + #define KILL_PIN_STATE HIGH +#endif + +// +// Misc. Functions +// +#if HAS_TFT_LVGL_UI + #define MT_DET_1_PIN PA4 + #define MT_DET_2_PIN PE6 + #define MT_DET_PIN_STATE LOW + + #define WIFI_IO0_PIN PC13 + #define WIFI_IO1_PIN PC7 + #define WIFI_RESET_PIN PA5 +#else + //#define POWER_LOSS_PIN PA2 // PW_DET + //#define PS_ON_PIN PB2 // PW_OFF + #define FIL_RUNOUT_PIN PA4 + #define FIL_RUNOUT2_PIN PE6 +#endif + +// +// SD Card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#define SDIO_SUPPORT +#define SDIO_CLOCK 4500000 // 4.5 MHz +#define SD_DETECT_PIN PD12 +#define ONBOARD_SD_CS_PIN PC11 + +// +// LCD / Controller +// +#define BEEPER_PIN PC5 + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + /** + * Note: MKS Robin TFT screens use various TFT controllers. + * If the screen stays white, disable 'TFT_RESET_PIN' + * to let the bootloader init the screen. + */ + #define TFT_RESET_PIN PC6 // FSMC_RST + #define TFT_BACKLIGHT_PIN PD13 + + #define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h + #define DOGLCD_SCK -1 + + #define TOUCH_CS_PIN PA7 // SPI2_NSS + #define TOUCH_SCK_PIN PB13 // SPI2_SCK + #define TOUCH_MISO_PIN PB14 // SPI2_MISO + #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN PD7 + #define FSMC_RS_PIN PD11 + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 + + #define TFT_BUFFER_SIZE 14400 +#endif + +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x1000000 // 16MB + #define SPI_FLASH_CS_PIN PB12 + #define SPI_FLASH_MOSI_PIN PB15 + #define SPI_FLASH_MISO_PIN PB14 + #define SPI_FLASH_SCK_PIN PB13 +#endif diff --git a/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h new file mode 100644 index 0000000..1db2d0c --- /dev/null +++ b/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -0,0 +1,318 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * MKS Robin pro (STM32F103ZET6) board pin assignments + */ + +#include "env_validate.h" + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "MKS Robin pro supports up to 3 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS Robin pro" + +#define BOARD_NO_NATIVE_USB + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// Note: MKS Robin board is using SPI2 interface. +// +#define SPI_DEVICE 2 + +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + +// +// Limit Switches +// +#define X_MIN_PIN PA15 +#define X_MAX_PIN PG7 +#define Y_MIN_PIN PA12 +#define Y_MAX_PIN PG8 +#define Z_MIN_PIN PA11 +#define Z_MAX_PIN PC4 + +// +// Steppers +// +#define X_ENABLE_PIN PE4 +#define X_STEP_PIN PE3 +#define X_DIR_PIN PE2 +#ifndef X_CS_PIN + #define X_CS_PIN PF8 +#endif + +#define Y_ENABLE_PIN PE1 +#define Y_STEP_PIN PE0 +#define Y_DIR_PIN PB9 +#ifndef Y_CS_PIN + #define Y_CS_PIN PF3 +#endif + +#define Z_ENABLE_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB4 +#ifndef Z_CS_PIN + #define Z_CS_PIN PF6 +#endif + +#define E0_ENABLE_PIN PB3 +#define E0_STEP_PIN PD6 +#define E0_DIR_PIN PD3 +#ifndef E0_CS_PIN + #define E0_CS_PIN PG15 +#endif + +#define E1_ENABLE_PIN PA3 +#define E1_STEP_PIN PA6 +#define E1_DIR_PIN PA1 +#ifndef E1_CS_PIN + #define E1_CS_PIN PG10 +#endif + +#define E2_ENABLE_PIN PF0 +#define E2_STEP_PIN PF2 +#define E2_DIR_PIN PF1 +#ifndef E2_CS_PIN + #define E2_CS_PIN PG9 +#endif +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB15 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB14 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB13 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + //#define E1_HARDWARE_SERIAL MSerial1 + //#define E2_HARDWARE_SERIAL MSerial1 + + #define X_SERIAL_TX_PIN PF7 + #define X_SERIAL_RX_PIN PF8 + + #define Y_SERIAL_TX_PIN PF4 + #define Y_SERIAL_RX_PIN PF3 + + #define Z_SERIAL_TX_PIN PF5 + #define Z_SERIAL_RX_PIN PF6 + + #define E0_SERIAL_TX_PIN PG13 + #define E0_SERIAL_RX_PIN PG15 + + #define E1_SERIAL_TX_PIN PG12 + #define E1_SERIAL_RX_PIN PG10 + + #define E2_SERIAL_TX_PIN PC13 + #define E2_SERIAL_RX_PIN PG9 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH1 +#define TEMP_1_PIN PC2 // TH2 +#define TEMP_2_PIN PC3 // TH3 +#define TEMP_BED_PIN PC0 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PF10 // +HE0- +#define HEATER_1_PIN PB0 // +HE1- +#define HEATER_2_PIN PF9 // +HE2- +#define HEATER_BED_PIN PA0 // +HOT-BED- +#define FAN_PIN PB1 // +FAN- + +/** + * Note: MKS Robin Pro board is using SPI2 interface. Make sure your stm32duino library is configured accordingly + */ +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PF11 // TC2 - CS2 + +#define POWER_LOSS_PIN PA2 // PW_DET +#define FIL_RUNOUT_PIN PA4 // MT_DET1 +#define FIL_RUNOUT2_PIN PE6 // MT_DET2 +#define FIL_RUNOUT3_PIN PG14 // MT_DET3 + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #if ENABLED(TFT_LVGL_UI) + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif + #undef MKS_PWC + #define SUICIDE_PIN PG11 + #define SUICIDE_PIN_STATE LOW + #else + #define PS_ON_PIN PG11 // PW_OFF + #endif + #define KILL_PIN PA2 + #define KILL_PIN_STATE HIGH +#endif + +// +// SD Card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(LCD) + #define SD_DETECT_PIN PG3 + #define SD_SCK_PIN PB13 + #define SD_MISO_PIN PB14 + #define SD_MOSI_PIN PB15 + #define SD_SS_PIN PG6 +#elif SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT + #define SD_DETECT_PIN PD12 + #define ONBOARD_SD_CS_PIN PC11 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + /** + * Note: MKS Robin TFT screens use various TFT controllers. + * If the screen stays white, disable 'LCD_RESET_PIN' + * to let the bootloader init the screen. + */ + #define TFT_RESET_PIN LCD_RESET_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + + #define FSMC_CS_PIN PD7 // NE4 + #define FSMC_RS_PIN PD11 // A0 + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define LCD_RESET_PIN PC6 + #define LCD_BACKLIGHT_PIN PD13 + + #define TFT_BUFFER_SIZE 14400 + + #if NEED_TOUCH_PINS + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 + #define TOUCH_CS_PIN PA7 // SPI2_NSS + #define TOUCH_SCK_PIN PB13 // SPI2_SCK + #define TOUCH_MISO_PIN PB14 // SPI2_MISO + #define TOUCH_MOSI_PIN PB15 // SPI2_MOSI + #else + #define BEEPER_PIN PC5 + #define BTN_ENC PG2 + #define BTN_EN1 PG5 + #define BTN_EN2 PG4 + #endif + +#elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS PG5 + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN PC5 + #define BTN_ENC PG2 + #define LCD_PINS_ENABLE PG0 + #define LCD_PINS_RS PG1 + #define BTN_EN1 PG5 + #define BTN_EN2 PG4 + + // MKS MINI12864 and MKS LCD12864B. If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 PF12 + #define DOGLCD_CS PF15 + #define DOGLCD_SCK PB13 + #define DOGLCD_MOSI PB15 + + #else // !MKS_MINI_12864 && !ENDER2_STOCKDISPLAY + + #define LCD_PINS_D4 PF14 + #if IS_ULTIPANEL + #define LCD_PINS_D5 PF15 + #define LCD_PINS_D6 PF12 + #define LCD_PINS_D7 PF13 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif // !MKS_MINI_12864 && !ENDER2_STOCKDISPLAY + +#endif + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 125 + #define BOARD_ST7920_DELAY_3 125 +#endif + +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x1000000 // 16MB + #define SPI_FLASH_CS_PIN PB12 // Flash chip-select + #define SPI_FLASH_MOSI_PIN PB15 + #define SPI_FLASH_MISO_PIN PB14 + #define SPI_FLASH_SCK_PIN PB13 +#endif diff --git a/src/pins/stm32f1/pins_MORPHEUS.h b/src/pins/stm32f1/pins_MORPHEUS.h new file mode 100644 index 0000000..87919c1 --- /dev/null +++ b/src/pins/stm32f1/pins_MORPHEUS.h @@ -0,0 +1,93 @@ +/** + * 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 . + * + */ +#pragma once + + /** + * 2017 Victor Perez Marlin for stm32f1 test + * 2018 Modified by Pablo Crespo for Morpheus Board (https://github.com/pscrespo/Morpheus-STM32) + */ + +/** + * MORPHEUS Board pin assignments + */ + +#if NOT_TARGET(__STM32F1__, STM32F1xx) + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "Bluepill based board" + +// +// Limit Switches +// +#define X_STOP_PIN PB14 +#define Y_STOP_PIN PB13 +#define Z_STOP_PIN PB12 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB9 +#endif + +// +// Steppers +// +// X & Y enable are the same +#define X_STEP_PIN PB7 +#define X_DIR_PIN PB6 +#define X_ENABLE_PIN PB8 + +#define Y_STEP_PIN PB5 +#define Y_DIR_PIN PB4 +#define Y_ENABLE_PIN PB8 + +#define Z_STEP_PIN PA15 +#define Z_DIR_PIN PA10 +#define Z_ENABLE_PIN PB3 + +#define E0_STEP_PIN PA8 +#define E0_DIR_PIN PB15 +#define E0_ENABLE_PIN PA9 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PB1 // Analog Input (HOTEND thermistor) +#define TEMP_BED_PIN PB0 // Analog Input (BED thermistor) + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA2 // HOTEND MOSFET +#define HEATER_BED_PIN PA0 // BED MOSFET + +#define FAN_PIN PA1 // FAN1 header on board - PRINT FAN + +// +// Misc. +// +#define LED_PIN PC13 +#define SDSS PA3 +#define TFTGLCD_CS PA4 +#define SD_DETECT_PIN PC14 diff --git a/src/pins/stm32f1/pins_PANDA_PI_V29.h b/src/pins/stm32f1/pins_PANDA_PI_V29.h new file mode 100644 index 0000000..5a82fbc --- /dev/null +++ b/src/pins/stm32f1/pins_PANDA_PI_V29.h @@ -0,0 +1,224 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "PANDA PI V2.9" + +// Release PB3/PB4 (TMC_SW Pins) from JTAG pins +#define DISABLE_JTAG + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +// +// Servos +// +#define SERVO0_PIN PA11 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PA3 // X-STOP +#define Y_STOP_PIN PC9 // Y-STOP +#define Z_STOP_PIN PA1 // Z-STOP + +// +// Z Probe must be this pin +// +//#define Z_MIN_PROBE_PIN PA1 // PROBE + +// +// Filament Runout Sensor +// +//#ifndef FIL_RUNOUT_PIN +// #define FIL_RUNOUT_PIN PC2 // E0-STOP +//#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC12 +#define X_STEP_PIN PC11 +#define X_DIR_PIN PB6 + +#define Y_ENABLE_PIN PC12 +#define Y_STEP_PIN PB5 +#define Y_DIR_PIN PB4 + +#define Z_ENABLE_PIN PC12 +#define Z_STEP_PIN PB3 +#define Z_DIR_PIN PA15 + +#define E0_ENABLE_PIN PC12 +#define E0_STEP_PIN PB15 +#define E0_DIR_PIN PB14 + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB5 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB4 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB3 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC11 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD2 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PB0 // Analog Input "TH0" +#define TEMP_BED_PIN PB1 // Analog Input "TB0" +#define TEMP_1_PIN PA2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB12 // "HE" +#define HEATER_BED_PIN PB13 // "HB" +#define FAN_PIN PA8 // "FAN0" +#define HEATER_1_PIN PA12 + +// +// SD Support +// +#define ONBOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card +#define SDSS ONBOARD_SD_CS_PIN + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif +#if SD_CONNECTION_IS(ONBOARD) + //#define SD_DETECT_PIN PA4 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR E3 DIP." +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BTN_ENC PA0 + #define BTN_EN1 PC4 + #define BTN_EN2 PC5 + + #define LCD_PINS_RS PC0 + #define LCD_PINS_ENABLE PC2 + #define LCD_PINS_D4 PC1 +#endif + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_PANDA_PI_V29.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** FYSETC TFT TFT81050 display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PA15 | 1 2 | PB6 (BEEPER) (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (MOD_RESET) PA9 | 3 4 | RESET MOD_RESET | 3 4 | SD_CS + * (SD_CS) PA10 5 6 | PB9 (FREE) LCD_CS | 5 6 MOSI (SPI1-MOSI) + * (LCD_CS) PB8 | 7 8 | PB7 (FREE) SD_DET | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SP11-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN PB6 + + #define CLCD_MOD_RESET PA9 + #define CLCD_SPI_CS PB8 + + #if SD_CONNECTION_IS(LCD) && BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + #define SD_DETECT_PIN PA15 + #define SD_SS_PIN PA10 + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN PC3 + +#endif diff --git a/src/pins/stm32f1/pins_STM32F1R.h b/src/pins/stm32f1/pins_STM32F1R.h new file mode 100644 index 0000000..634cadc --- /dev/null +++ b/src/pins/stm32f1/pins_STM32F1R.h @@ -0,0 +1,138 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +/** + * 21017 Victor Perez Marlin for stm32f1 test + */ + +#define BOARD_INFO_NAME "Misc. STM32F1R" +#define DEFAULT_MACHINE_NAME "STM32F103RET6" + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// Limit Switches +// +#define X_STOP_PIN PB3 +#define Y_STOP_PIN PB4 +#define Z_STOP_PIN PB5 + +// +// Steppers +// +#define X_STEP_PIN PC0 +#define X_DIR_PIN PC1 +#define X_ENABLE_PIN PA8 + +#define Y_STEP_PIN PC2 +#define Y_DIR_PIN PC3 +#define Y_ENABLE_PIN PA8 + +#define Z_STEP_PIN PC4 +#define Z_DIR_PIN PC5 +#define Z_ENABLE_PIN PA8 + +#define E0_STEP_PIN PC6 +#define E0_DIR_PIN PC7 +#define E0_ENABLE_PIN PA8 + +/** + * TODO: Currently using same Enable pin to all steppers. + */ + +#define E1_STEP_PIN PC8 +#define E1_DIR_PIN PC9 +#define E1_ENABLE_PIN PA8 + +#define E2_STEP_PIN PC10 +#define E2_DIR_PIN PC11 +#define E2_ENABLE_PIN PA8 + +// +// Misc. Functions +// +#define SDSS PA4 +#define LED_PIN PD2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB0 // EXTRUDER 1 +#define HEATER_1_PIN PB1 + +#define HEATER_BED_PIN PA3 // BED + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA0 // Analog Input +#define TEMP_0_PIN PA1 // Analog Input +#define TEMP_1_PIN PA2 // Analog Input + +// +// LCD Pins +// +#if HAS_WIRED_LCD + + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + #error "REPRAPWORLD_GRAPHICAL_LCD is not supported." + #else + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE PD2 + #define LCD_PINS_D4 PB12 + #define LCD_PINS_D5 PB13 + #define LCD_PINS_D6 PB14 + #define LCD_PINS_D7 PB15 + #if !IS_NEWPANEL + #error "Non-NEWPANEL LCD is not supported." + #endif + #endif + + #if IS_NEWPANEL + #if IS_RRD_SC + #error "RRD Smart Controller is not supported." + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + #error "REPRAPWORLD_GRAPHICAL_LCD is not supported." + #elif ENABLED(LCD_I2C_PANELOLU2) + #error "LCD_I2C_PANELOLU2 is not supported." + #elif ENABLED(LCD_I2C_VIKI) + #error "LCD_I2C_VIKI is not supported." + #elif EITHER(VIKI2, miniVIKI) + #error "VIKI2 / miniVIKI is not supported." + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." + #elif ENABLED(MINIPANEL) + #error "MINIPANEL is not supported." + #else + #error "Other generic NEWPANEL LCD is not supported." + #endif + #endif + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/stm32f1/pins_STM3R_MINI.h b/src/pins/stm32f1/pins_STM3R_MINI.h new file mode 100644 index 0000000..eee7dbf --- /dev/null +++ b/src/pins/stm32f1/pins_STM3R_MINI.h @@ -0,0 +1,159 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +/** + * 10 Dec 2017 Victor Perez Marlin for stm32f1 test + */ + +#define BOARD_INFO_NAME "STM3R Mini" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// Enable I2C_EEPROM for testing +#define I2C_EEPROM + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// Limit Switches +// +#define X_STOP_PIN PD0 +#define Y_STOP_PIN PD1 +#define Z_STOP_PIN PD4 + +// +// Steppers +// +#define X_STEP_PIN PE1 +#define X_DIR_PIN PE0 +#define X_ENABLE_PIN PC0 + +#define Y_STEP_PIN PE3 +#define Y_DIR_PIN PE2 +#define Y_ENABLE_PIN PC1 + +#define Z_STEP_PIN PE5 +#define Z_DIR_PIN PE4 +#define Z_ENABLE_PIN PC2 + +#define E0_STEP_PIN PE7 +#define E0_DIR_PIN PE6 +#define E0_ENABLE_PIN PC3 + +#define E1_STEP_PIN PE9 +#define E1_DIR_PIN PE8 +#define E1_ENABLE_PIN PC4 + +#define E2_STEP_PIN PE11 +#define E2_DIR_PIN PE10 +#define E2_ENABLE_PIN PC5 + +// +// Misc. Functions +// +#define SDSS PA15 +#define LED_PIN PB2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PD12 // EXTRUDER 1 +//#define HEATER_1_PIN PD13 + +#define HEATER_BED_PIN PB9 // BED +//#define HEATER_BED2_PIN -1 // BED2 +//#define HEATER_BED3_PIN -1 // BED3 + +#ifndef FAN_PIN + #define FAN_PIN PD14 +#endif +#define FAN1_PIN PD13 + +#define FAN_SOFT_PWM_REQUIRED + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA0 +#define TEMP_0_PIN PA1 +#define TEMP_1_PIN PA2 +#define TEMP_2_PIN PA3 + +// Laser control +#if HAS_CUTTER + #define SPINDLE_LASER_PWM_PIN PB8 + #define SPINDLE_LASER_ENA_PIN PD5 +#endif + +// +// LCD Pins +// +#if HAS_WIRED_LCD + + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + #error "REPRAPWORLD_GRAPHICAL_LCD is not supported." + #else + #define LCD_PINS_RS PB8 + #define LCD_PINS_ENABLE PD2 + #define LCD_PINS_D4 PB12 + #define LCD_PINS_D5 PB13 + #define LCD_PINS_D6 PB14 + #define LCD_PINS_D7 PB15 + #if !IS_NEWPANEL + #error "Non-NEWPANEL LCD is not supported." + #endif + #endif + + #if NEED_TOUCH_PINS + + #define TOUCH_CS_PIN PB12 // SPI2_NSS + #define TOUCH_SCK_PIN PB13 + #define TOUCH_MOSI_PIN PB14 + #define TOUCH_MISO_PIN PB15 + #define TOUCH_INT_PIN PC6 // (PenIRQ coming from ADS7843) + + #elif IS_NEWPANEL + + #if IS_RRD_SC + #error "RRD Smart Controller is not supported." + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + #error "REPRAPWORLD_GRAPHICAL_LCD is not supported." + #elif ENABLED(LCD_I2C_PANELOLU2) + #error "LCD_I2C_PANELOLU2 is not supported." + #elif ENABLED(LCD_I2C_VIKI) + #error "LCD_I2C_VIKI is not supported." + #elif EITHER(VIKI2, miniVIKI) + #error "VIKI2 / miniVIKI is not supported." + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." + #elif ENABLED(MINIPANEL) + #error "MINIPANEL is not supported." + #else + #error "Other generic NEWPANEL LCD is not supported." + #endif + + #endif + +#endif // HAS_WIRED_LCD diff --git a/src/pins/stm32f1/pins_TRIGORILLA_PRO.h b/src/pins/stm32f1/pins_TRIGORILLA_PRO.h new file mode 100644 index 0000000..73f61c1 --- /dev/null +++ b/src/pins/stm32f1/pins_TRIGORILLA_PRO.h @@ -0,0 +1,208 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * ANYCUBIC Trigorilla Pro (STM32F103ZET6) board pin assignments. + * It is the same used by the Tronxy X5SA thanks to ftoz1 for sharing it + * https://github.com/MarlinFirmware/Marlin/issues/14655 + * https://github.com/MarlinFirmware/Marlin/files/3401484/x5sa-main_board-2.pdf + */ + +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Trigorilla Pro supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Trigorilla Pro" + +#define BOARD_NO_NATIVE_USB + +#define DISABLE_JTAG + +//#define SWAPPED_Z_PLUGS + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION +#endif +#if ENABLED(FLASH_EEPROM_EMULATION) + // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) + #define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE) + #define EEPROM_PAGE_SIZE (0x800U) // 2K, but will use 2x more (4K) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#else + #define MARLIN_EEPROM_SIZE (0x800U) // On SD, Limit to 2K, require this amount of RAM +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PG10 +#define Y_STOP_PIN PA12 +#ifndef Z_MIN_PIN + #ifdef SWAPPED_Z_PLUGS + #define Z_MIN_PIN PA14 + #else + #define Z_MIN_PIN PA13 + #endif +#endif +#ifndef Z_MAX_PIN + #ifdef SWAPPED_Z_PLUGS + #define Z_MAX_PIN PA13 + #else + #define Z_MAX_PIN PA14 + #endif +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC13 +#define X_STEP_PIN PE5 +#define X_DIR_PIN PE6 + +#define Y_ENABLE_PIN PE4 +#define Y_STEP_PIN PE2 +#define Y_DIR_PIN PE3 + +#define Z_ENABLE_PIN PE1 +#define Z_STEP_PIN PB9 +#define Z_DIR_PIN PE0 + +#define E0_ENABLE_PIN PB8 +#define E0_STEP_PIN PB4 +#define E0_DIR_PIN PB5 + +#define E1_ENABLE_PIN PG8 +#define E1_STEP_PIN PC7 +#define E1_DIR_PIN PC6 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA1 // TH1 +#define TEMP_BED_PIN PA0 // TB1 + +// +// Heaters +// +#define HEATER_0_PIN PG12 // HEATER1 +#define HEATER_BED_PIN PG11 // HOT BED +#define HEATER_BED_INVERTING true + +// +// Fans +// +#define CONTROLLER_FAN_PIN PD6 // FAN +#define FAN_PIN PG13 // FAN +#define FAN1_PIN PG14 // FAN + +// +// Misc +// +#define BEEPER_PIN PB0 +#define LED_PIN PD3 +//#define POWER_LOSS_PIN PG2 // PG4 PW_DET +#define FIL_RUNOUT_PIN PA15 // MT_DET + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + /** + * Note: MKS Robin TFT screens use various TFT controllers + * Supported screens are based on the ILI9341, ST7789V and ILI9328 (320x240) + * ILI9488 is not supported. + * Define init sequences for other screens in u8g_dev_tft_320x240_upscale_from_128x64.cpp + * + * If the screen stays white, disable 'LCD_RESET_PIN' to let the bootloader init the screen. + * + * Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu + * because Marlin uses the reset as a failsafe to revive a glitchy LCD. + */ + #define TFT_RESET_PIN PF11 + #define TFT_BACKLIGHT_PIN PD13 + + #define FSMC_CS_PIN PD7 // NE4 + #define FSMC_RS_PIN PD11 // A0 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define ANYCUBIC_TFT35 +#else + #define LCD_RESET_PIN PF11 + #define LCD_BACKLIGHT_PIN PD13 +#endif + +// XPT2046 Touch Screen calibration +#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X -17181 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 11434 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 501 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -9 + #endif +#endif + +#if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PB7 // SPI2_NSS + #define TOUCH_SCK_PIN PA5 // SPI2_SCK + #define TOUCH_MISO_PIN PA6 // SPI2_MISO + #define TOUCH_MOSI_PIN PA7 // SPI2_MOSI +#endif + +// SPI1(PA7) & SPI3(PB5) not available +#define SPI_DEVICE 2 + +#if ENABLED(SDIO_SUPPORT) + #define SD_SCK_PIN PB13 // SPI2 ok + #define SD_MISO_PIN PB14 // SPI2 ok + #define SD_MOSI_PIN PB15 // SPI2 ok + #define SD_SS_PIN PC11 // PB12 is X- ok + #define SD_DETECT_PIN -1 // SD_CD ok +#else + // SD as custom software SPI (SDIO pins) + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #define SD_SS_PIN -1 + #define ONBOARD_SD_CS_PIN PC11 + #define SDSS PD2 + #define SD_DETECT_PIN -1 +#endif + +#undef SWAPPED_Z_PLUGS diff --git a/src/pins/stm32f1/pins_ZM3E2_V1_0.h b/src/pins/stm32f1/pins_ZM3E2_V1_0.h new file mode 100644 index 0000000..1347a14 --- /dev/null +++ b/src/pins/stm32f1/pins_ZM3E2_V1_0.h @@ -0,0 +1,235 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "ZONESTAR ZM3E2 V1.0" + +#define DISABLE_DEBUG +//#define DISABLE_JTAG + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800) // 2K + #define EEPROM_START_ADDRESS (0x08000000 + (STM32_FLASH_SIZE) * 1024 - 2 * EEPROM_PAGE_SIZE) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +//============================================================================= +// Zonestar ZM3E2 V1.0 (STM32F103RCT6) board pin assignments +//============================================================================= +// PA0 PWR_HOLD | PB0 BEEP | PC0 HEATER_0 +// PA1 FAN_PIN | PB1 KILL | PC1 HEATER_BED +// PA2 TX2 | PB2 LCD_SDA | PC2 TEMP_BED +// PA3 RX2 | PB3 E1_EN | PC3 TEMP_E0 +// PA4 SD_CS | PB4 Z_STOP | PC4 SD_DETECT +// PA5 SD_SCK | PB5 Z_DIR | PC5 BTN_EN2 +// PA6 SD_MISO | PB6 Z_STEP | PC6 FAN1 +// PA7 SD_MOSI | PB7 Z_EN | PC7 FIL_RUNOUT +// PA8 X_DIR | PB8 Y_STEP | PC8 X_EN +// PA9 LCD_RS | PB9 Y_DIR | PC9 X_STEP +// PA10 LCD_SCK | PB10 BTN_ENC | PC10 Z_MIN_PROBE_PIN +// PA11 USB_D- | PB11 BTN_EN1 | PC11 FIL_RUNOUT2 +// PA12 USB_D+ | PB12 LED | PC12 E1_DIR +// PA13 MS1 | PB13 E0_EN | PC13 Y_STOP +// PA14 MS2 | PB14 E0_STEP | PC14 Y_EN +// PA15 PWM | PB15 E0_DIR | PC15 X_STOP +// PD0 NC +// PD1 NC +// PD2 E1_STEP + +//============================================================================= +// EXP1 connector +// MARK I/O ZONESTAR_12864LCD ZONESTAR_12864OLED +// 10 MOSI PB1 KILL SDA +// 9 SCK PB0 BEEP SCK +// 8 TX1 PA9 DOGLCD_CS CS +// 7 RX1 PA10 DOGLCD_SCK DC +// 6 ENA PC5 BTN_EN2 KNOB_ENB +// 5 DAT PB2 DOGLCD_MOSI RESET +// 4 TX3 PB10 BTN_ENC KNOB_ENC +// 3 RX3 PB11 BTN_EN1 KNOB_ENA +// 2 +5V +// 1 GND + +#define EXP1_01_PIN PB1 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN PA10 +#define EXP1_05_PIN PC5 +#define EXP1_06_PIN PB2 +#define EXP1_07_PIN PB10 +#define EXP1_08_PIN PB11 + +// AUX1 connector +// 1 +5V +// 2 TX2 PA2 UART2_TX +// 3 RX2 PA3 UART2_RX +// 4 GND + +// AUX2 connector to BLTouch +// 1 +5V +// 2 SEN PC10 +// 3 PWM PA15 +// 4 GND +//============================================================================= + +// +// Servos +// +#define SERVO0_PIN PA15 + +// +// Limit Switches +// +#define X_STOP_PIN PC15 +#define Y_STOP_PIN PC13 +#define Z_STOP_PIN PB4 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PC10 // BLTouch (3DTouch) +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PC7 // E0_SW +//#define FIL_RUNOUT2_PIN PC11 // E1_SW + +// +// Steppers +// +#define MS1_PIN PA13 +#define MS2_PIN PA14 + +#define X_STEP_PIN PC9 +#define X_DIR_PIN PA8 +#define X_ENABLE_PIN PC8 + +#define Y_STEP_PIN PB8 +#define Y_DIR_PIN PB9 +#define Y_ENABLE_PIN PC14 + +#define Z_STEP_PIN PB6 +#define Z_DIR_PIN PB5 +#define Z_ENABLE_PIN PB7 + +#define E0_STEP_PIN PB14 +#define E0_DIR_PIN PB15 +#define E0_ENABLE_PIN PB13 + +#define E1_STEP_PIN PD2 +#define E1_DIR_PIN PC12 +#define E1_ENABLE_PIN PB3 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC0 // EXTRUDER 1 +#define HEATER_BED_PIN PC1 // BED + +#define FAN1_PIN PC6 +#define FAN_PIN PA1 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PC2 // Analog Input +#define TEMP_0_PIN PC3 // Analog Input + +#define LED_PIN PB12 +//#define KILL_PIN PB1 // @EXP1 +#define SUICIDE_PIN PA0 + +// +// SD card +// +#define ENABLE_SPI1 +#define SD_DETECT_PIN PC4 +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 +#define SD_SS_PIN PA4 + +// +// LCD Pins +// +#if ENABLED(ZONESTAR_12864LCD) + + //================================================================================ + // LCD 128x64 + //================================================================================ + // EXP1 connector + // MARK I/O ZONESTAR_12864LCD + // 10 MOSI PB1 KILL + // 9 SCK PB0 BEEP + // 8 TX1 PA9 LCD_PINS_RS + // 7 RX1 PA10 LCD_PINS_D4 + // 6 ENA PC5 BTN_EN2 + // 5 DAT PB2 LCD_PINS_ENABLE + // 4 TX3 PB10 BTN_ENC + // 3 RX3 PB11 BTN_EN1 + // 2 +5V + // 1 GND + + #define LCDSCREEN_NAME "ZONESTAR LCD12864" + #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_06_PIN + #define LCD_PINS_D4 EXP1_04_PIN + //#define KILL_PIN EXP1_01_PIN + #define BEEPER_PIN EXP1_02_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_07_PIN + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 200 + #define BOARD_ST7920_DELAY_3 125 + +#elif EITHER(ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) + + //================================================================================ + // OLED 128x64 + //================================================================================ + // 10 MOSI PB1 OLED_SDA + // 9 SCK PB0 OLED_SCK + // 8 TX1 PA9 OLED_CS + // 7 RX1 PA10 OLED_DC + // 6 ENA PC5 KNOB_ENA + // 5 DAT PB2 OLED_RESET + // 4 TX3 PB10 KNOB_ENC + // 3 RX3 PB11 KNOB_ENB + + #define FORCE_SOFT_SPI + #define LCDSCREEN_NAME "ZONESTAR 12864OLED" + #define LCD_PINS_RS EXP1_06_PIN // = LCD_RESET_PIN + #define LCD_PINS_DC EXP1_04_PIN // DC + #define DOGLCD_CS EXP1_03_PIN // CS + #define DOGLCD_A0 LCD_PINS_DC + #define DOGLCD_MOSI EXP1_01_PIN // SDA + #define DOGLCD_SCK EXP1_02_PIN // SCK + // Encoder + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_07_PIN + +#endif diff --git a/src/pins/stm32f1/pins_ZM3E4_V1_0.h b/src/pins/stm32f1/pins_ZM3E4_V1_0.h new file mode 100644 index 0000000..9618b3a --- /dev/null +++ b/src/pins/stm32f1/pins_ZM3E4_V1_0.h @@ -0,0 +1,356 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "ZONESTAR ZM3E4 V1.0" + +//#define DISABLE_DEBUG +#define DISABLE_JTAG + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800) // 2K + #define EEPROM_START_ADDRESS (0x08000000 + (STM32_FLASH_SIZE) * 1024 - 2 * EEPROM_PAGE_SIZE) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +//#define OPTION_DUALZ_DRIVE +//#define OPTION_Z2_ENDSTOP +//#define SWITCH_EXTRUDER_SEQUENCE + +//============================================================================= +// Zonestar ZM3E4 V1.0 (STM32F103VCT6) board pin assignments +//============================================================================= +// PA0 | PB0 HEAT_1 | PC0 AXU_SDA +// PA1 | PB1 FAN1 | PC1 TEMP_E1 +// PA2 HEAT_BED | PB2 BOOT1 | PC2 TEMP_E0 +// PA3 PWR_HOLD | PB3 SPI3_SCK | PC3 TEMP_BED +// PA4 SD_CS | PB4 SPI3_MISO | PC4 SD_DETECT +// PA5 SD_SCK | PB5 SPI3_MOSI | PC5 HEAT_0 +// PA6 SD_MISO | PB6 SERVO3 | PC6 E1_STEP +// PA7 SD_MOSI | PB7 SERVO2 | PC7 E1_EN +// PA8 X_DIR | PB8 FAN2/SERVO1 | PC8 FIL_RUNOUT_PIN +// PA9 UART1_RX | PB9 SERVO0 | PC9 E0_DIR +// PA10 UART1_TX | PB10 TX3 | PC10 E0_EN +// PA11 USB_D- | PB11 RX3 | PC11 Z2_EN +// PA12 USB_D+ | PB12 LED | PC12 Z2_STEP +// PA13 SWD_SDO | PB13 Z1_MAX | PC13 X_MIN +// PA14 SWD_SCK | PB14 Y_MAX | PC14 WIFI_RST +// PA15 SPI3_CS | PB15 PWR_DET | PC15 WIFI_CS +// PD0 Z2_DIR | PE0 Y_EN +// PD1 Z2_MIN | PE1 Y_STEP +// PD2 Z1_EN | PE2 Y_DIR +// PD3 Z1_STEP | PE3 Y_MIN +// PD4 Z1_DIR | PE4 X_DIR +// PD5 WIFI_RXD | PE5 X_STEP +// PD6 WIFI_TXD | PE6 X_EN +// PD7 Z1_MIN | PE7 AXU_SCL +// PD8 X_MAX | PE8 BTN_EN1 +// PD9 E3_DIR | PE9 LCD_SCK +// PD10 E3_STEP | PE10 LCD_MOSI +// PD11 E3_EN | PE11 BEEPER +// PD12 E2_DIR | PE12 LCD_EN +// PD13 E2_STEP | PE13 KILL +// PD14 E2_EN | PE14 BTN_EN2 +// PD15 E1_DIR | PE15 BTN_ENC +//============================================================================= + +// EXP1 connector +// MARK I/O ZONESTAR_LCD12864 REPRAPDISCOUNT_LCD12864 +// 10 RS PE13 KILL BTN_ENC +// 9 BP PE11 BEEP BEEP +// 8 EN PE12 DOGLCD_CS LCDRS +// 7 MOSI PE10 DOGLCD_SCK LCDE +// 6 EN1 PE8 BTN_EN1 NC +// 5 SCK PE9 DOGLCD_MOSI LCD4 +// 4 ENC PE15 BTN_ENC NC +// 3 EN2 PE14 BTN_EN2 NC +// 2 +5V +5V +// 1 GND GND + +#define EXP1_01_PIN PE13 +#define EXP1_02_PIN PE11 +#define EXP1_03_PIN PE12 +#define EXP1_04_PIN PE10 +#define EXP1_05_PIN PE8 +#define EXP1_06_PIN PE9 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE14 + +// EXP2 connector +// MARK I/O ZONESTAR_LCD12864 REPRAPDISCOUNT_LCD12864 +// 10 +// 9 +// 8 RX0 PA9 UART1_RX +// 7 TX0 PA10 UART1_TX BTN_EN2 +// 6 CS3 PA15 +// 5 MISO3 PB4 BTN_EN1 +// 4 MOSI3 PB5 KILL +// 3 SCK3 PB3 +// 2 +5V +5V +// 1 GND GND + +#define EXP2_03_PIN PA9 +#define EXP2_04_PIN PA10 +#define EXP2_05_PIN PA15 +#define EXP2_06_PIN PB4 +#define EXP2_07_PIN PB5 +#define EXP2_08_PIN PB3 + +// AUX1 connector +// 1 +5V +// 2 GND +// 3 RX3 PB11 UART3_RX +// 4 TX3 PB10 UART3_TX +// 5 SCL PE7 +// 6 SDA PC0 + +// WiFi +// 1 +5V +// 2 GND +// 3 WIFI_TXD PD5 UART2_RX +// 4 WIFI_RXD PD6 UART2_TX +// 5 WIFI_RST PC14 +// 6 WIFI_CS PC15 +//============================================================================= + +// +// Servos +// +#define SERVO0_PIN PB9 +#define SERVO2_PIN PB7 +#define SERVO3_PIN PB6 + +// +// Limit Switches +// +#define X_MIN_PIN PC13 +#define X_MAX_PIN PD8 +#define Y_MIN_PIN PE3 +#define Y_MAX_PIN PB14 +#define Z_MIN_PIN PD7 +#define Z_MAX_PIN PB13 + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC8 +#endif + +// +// Steppers +// +#if ENABLED(COREXY) + #define X_ENABLE_PIN PE0 + #define X_STEP_PIN PE1 + #define X_DIR_PIN PE2 + + #define Y_ENABLE_PIN PE6 + #define Y_STEP_PIN PE5 + #define Y_DIR_PIN PE4 +#else + #define X_ENABLE_PIN PE6 + #define X_STEP_PIN PE5 + #define X_DIR_PIN PE4 + + #define Y_ENABLE_PIN PE0 + #define Y_STEP_PIN PE1 + #define Y_DIR_PIN PE2 +#endif + +#define Z_ENABLE_PIN PD2 +#define Z_STEP_PIN PD3 +#define Z_DIR_PIN PD4 + +#ifdef OPTION_DUALZ_DRIVE + #define Z2_ENABLE_PIN PC11 + #define Z2_STEP_PIN PC12 + #define Z2_DIR_PIN PD0 +#endif + +#ifdef OPTION_Z2_ENDSTOP + #define Z2_MIN_PIN PD1 + #define Z2_MAX_PIN PB12 +#endif + +#ifdef SWITCH_EXTRUDER_SEQUENCE + #define E3_ENABLE_PIN PC10 + #define E3_STEP_PIN PA8 + #define E3_DIR_PIN PC9 + + #define E2_STEP_PIN PC6 + #define E2_DIR_PIN PD15 + #define E2_ENABLE_PIN PC7 + + #define E1_STEP_PIN PD13 + #define E1_DIR_PIN PD12 + #define E1_ENABLE_PIN PD14 + + #define E0_STEP_PIN PD10 + #define E0_DIR_PIN PD9 + #define E0_ENABLE_PIN PD11 +#else + #define E0_ENABLE_PIN PC10 + #define E0_STEP_PIN PA8 + #define E0_DIR_PIN PC9 + + #define E1_STEP_PIN PC6 + #define E1_DIR_PIN PD15 + #define E1_ENABLE_PIN PC7 + + #define E2_STEP_PIN PD13 + #define E2_DIR_PIN PD12 + #define E2_ENABLE_PIN PD14 + + #define E3_STEP_PIN PD10 + #define E3_DIR_PIN PD9 + #define E3_ENABLE_PIN PD11 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC2 // TH0 +#define TEMP_BED_PIN PC3 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC5 // HEATER0 +#define HEATER_BED_PIN PA2 // HOT BED + +#if ENABLED(OPTION_CHAMBER) + #define TEMP_CHAMBER_PIN PC1 + #define HEATER_CHAMBER_PIN PB0 +#else + #define TEMP_1_PIN PC1 // TH1 + #define HEATER_1_PIN PB0 // HEATER1 +#endif + +#define FAN_PIN PB1 // FAN1 +#define FAN1_PIN PB8 // FAN2 + +// +// Misc. Functions +// + +//#define POWER_LOSS_PIN PB15 +#define LED_PIN PA0 +#define SUICIDE_PIN PA3 + +// +// SD card +// +#define ENABLE_SPI1 +#define SD_DETECT_PIN PC4 +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 +#define SD_SS_PIN PA4 + +// WiFi Functions +#define WIFI_RST PC15 +#define WIFI_EN PC14 + +// +// LCD / Controller +// +#if ENABLED(ZONESTAR_12864LCD) + #define LCDSCREEN_NAME "ZONESTAR LCD12864" + #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP1_06_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP1_04_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN -1 // EXP1_01_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_08_PIN + #define BTN_ENC EXP1_07_PIN +#elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define LCDSCREEN_NAME "REPRAPDISCOUNT LCD12864" + #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP1_04_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP1_06_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN EXP2_07_PIN + #define BTN_EN1 EXP2_06_PIN + #define BTN_EN2 EXP2_04_PIN + #define BTN_ENC EXP1_01_PIN +#elif ENABLED(ZONESTAR_DWIN_LCD) + // Connect to EXP2 connector + #define LCDSCREEN_NAME "ZONESTAR DWIN LCD" + #define BEEPER_PIN EXP2_05_PIN + #define KILL_PIN PC0 + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_07_PIN + #define BTN_ENC EXP2_06_PIN +#endif + +#if ENABLED(ZONESTAR_LCD2004_KNOB) + #define LCDSCREEN_NAME "LCD2004 KNOB" + #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_04_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_08_PIN + #define LCD_PINS_D7 EXP1_07_PIN + #define BTN_EN1 EXP2_04_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_01_PIN + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN EXP2_07_PIN +#elif ENABLED(ZONESTAR_LCD2004_ADCKEY) + #define LCDSCREEN_NAME "LCD2004 5KEY" + #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_04_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_08_PIN + #define LCD_PINS_D7 EXP1_07_PIN + #define ADC_KEYPAD_PIN PC0 // PIN6 of AUX1 +#endif + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 250 + #define BOARD_ST7920_DELAY_3 125 +#endif + +// Remap SERVO0 PIN for BLTouch +#if ENABLED(BLTOUCH_ON_EXP1) + // BLTouch connected to EXP1 + #define BLTOUCH_PROBE_PIN EXP1_05_PIN + #define BLTOUCH_GND_PIN EXP1_07_PIN + #undef SERVO0_PIN + #define SERVO0_PIN EXP1_08_PIN +#elif ENABLED(BLTOUCH_ON_EXP2) + // BLTouch connected to EXP2 + #define BLTOUCH_PROBE_PIN EXP2_08_PIN + #define BLTOUCH_GND_PIN EXP2_07_PIN + #undef SERVO0_PIN + #define SERVO0_PIN EXP2_05_PIN +#else + #define BLTOUCH_PROBE_PIN PB13 +#endif diff --git a/src/pins/stm32f1/pins_ZM3E4_V2_0.h b/src/pins/stm32f1/pins_ZM3E4_V2_0.h new file mode 100644 index 0000000..d1d8a4c --- /dev/null +++ b/src/pins/stm32f1/pins_ZM3E4_V2_0.h @@ -0,0 +1,329 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "ZONESTAR ZM3E4 V2.0" + +//#define DISABLE_DEBUG +#define DISABLE_JTAG + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800) // 2K + #define EEPROM_START_ADDRESS (0x08000000 + (STM32_FLASH_SIZE) * 1024 - 2 * EEPROM_PAGE_SIZE) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +//#define OPTION_DUALZ_DRIVE +//#define OPTION_Z2_ENDSTOP +//#define OPTION_REPEAT_PRINTING +//#define SWITCH_EXTRUDER_SEQUENCE + +//============================================================================= +// Zonestar ZM3E4 V2.0 (STM32F103VET6) board pin assignments +//============================================================================= +// PA0 | PB0 HEAT_1 | PC0 AUX_SDA +// PA1 | PB1 FAN1 | PC1 TEMP_E1 +// PA2 HEAT_BED | PB2 BOOT1 | PC2 TEMP_E0 +// PA3 PWR_HOLD | PB3 SPI3_SCK | PC3 TEMP_BED +// PA4 SD_CS | PB4 SPI3_MISO | PC4 SD_DETECT +// PA5 SD_SCK | PB5 SPI3_MOSI | PC5 HEAT_0 +// PA6 SD_MISO | PB6 SERVO3 | PC6 E1_STEP +// PA7 SD_MOSI | PB7 SERVO2 | PC7 E1_EN +// PA8 X_DIR | PB8 FAN2/SERVO1 | PC8 FIL_RUNOUT_PIN +// PA9 UART1_RX | PB9 SERVO0 | PC9 E0_DIR +// PA10 UART1_TX | PB10 TX3 | PC10 E0_EN +// PA11 USB_D- | PB11 RX3 | PC11 Z2_EN +// PA12 USB_D+ | PB12 LED | PC12 Z2_STEP +// PA13 SWD_SDO | PB13 Z1_MAX | PC13 X_MIN +// PA14 SWD_SCK | PB14 Y_MAX | PC14 WIFI_RST +// PA15 SPI3_CS | PB15 PWR_DET | PC15 WIFI_CS +// PD0 Z2_DIR | PE0 Y_EN +// PD1 Z2_MIN | PE1 Y_STEP +// PD2 Z1_EN | PE2 Y_DIR +// PD3 Z1_STEP | PE3 Y_MIN +// PD4 Z1_DIR | PE4 X_DIR +// PD5 WIFI_RXD | PE5 X_STEP +// PD6 WIFI_TXD | PE6 X_EN +// PD7 Z1_MIN | PE7 AUX_SCL +// PD8 X_MAX | PE8 BTN_EN1 +// PD9 E3_DIR | PE9 LCD_SCK +// PD10 E3_STEP | PE10 LCD_MOSI +// PD11 E3_EN | PE11 BEEPER +// PD12 E2_DIR | PE12 LCD_EN +// PD13 E2_STEP | PE13 KILL +// PD14 E2_EN | PE14 BTN_EN2 +// PD15 E1_DIR | PE15 BTN_ENC + +//============================================================================= +// EXP1 connector +// MARK I/O ZONESTAR_LCD12864 REPRAPDISCOUNT_LCD12864 +// 10 RS PE13 KILL BTN_ENC +// 9 BP PE11 BEEP BEEP +// 8 EN PE12 DOGLCD_CS LCDRS +// 7 MOSI PE10 DOGLCD_SCK LCDE +// 6 EN1 PE8 BTN_EN1 NC +// 5 SCK PE9 DOGLCD_MOSI LCD4 +// 4 ENC PE15 BTN_ENC NC +// 3 EN2 PE14 BTN_EN2 NC +// 2 +5V +// 1 GND + +#define EXP1_01_PIN PE13 +#define EXP1_02_PIN PE11 +#define EXP1_03_PIN PE12 +#define EXP1_04_PIN PE10 +#define EXP1_05_PIN PE8 +#define EXP1_06_PIN PE9 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE14 + +// EXP2 connector +// MARK I/O ZONESTAR_LCD12864 REPRAPDISCOUNT_LCD12864 +// 10 SDA PC0 +// 9 SCL PE7 +// 8 RX1 PA9 UART1_RX +// 7 TX1 PA10 UART1_TX BTN_EN2 +// 6 CS3 PA15 +// 5 MISO3 PB4 BTN_EN1 +// 4 MOSI3 PB5 KILL +// 3 SCK3 PB3 +// 2 +5V +// 1 GND + +#define EXP2_01_PIN PC0 +#define EXP2_02_PIN PE7 +#define EXP2_03_PIN PA9 +#define EXP2_04_PIN PA10 +#define EXP2_05_PIN PA15 +#define EXP2_06_PIN PB4 +#define EXP2_07_PIN PB5 +#define EXP2_08_PIN PB3 + +// AUX1 connector +// 1 +5V +// 2 GND +// 3 RX3 PB11 UART3_RX +// 4 TX3 PB10 UART3_TX +// 5 SCL PE7 +// 6 SDA PC0 + +// WiFi +// 1 +5V +// 2 GND +// 3 WIFI_TXD PD5 UART2_RX +// 4 WIFI_RXD PD6 UART2_TX +// 5 WIFI_RST PC14 +// 6 WIFI_CS PC15 +//============================================================================= + +// +// Servos +// +#define SERVO0_PIN PB9 +//#define SERVO1_PIN PB8 +#define SERVO2_PIN PB7 +#define SERVO3_PIN PB6 + +// +// Limit Switches +// +#define X_MIN_PIN PC13 +#define Y_MIN_PIN PE3 +#define Z_MIN_PIN PD7 +#define X_MAX_PIN PD8 +#define Y_MAX_PIN PB14 +#define Z_MAX_PIN PB13 + +#ifdef OPTION_Z2_ENDSTOP + #define Z2_MIN_PIN PD1 + #define Z2_MAX_PIN PB12 +#endif + +// +// Steppers +// +#if ENABLED(COREXY) + #define X_ENABLE_PIN PE0 + #define X_STEP_PIN PE1 + #define X_DIR_PIN PE2 + + #define Y_ENABLE_PIN PE6 + #define Y_STEP_PIN PE5 + #define Y_DIR_PIN PE4 +#else + #define X_ENABLE_PIN PE6 + #define X_STEP_PIN PE5 + #define X_DIR_PIN PE4 + + #define Y_ENABLE_PIN PE0 + #define Y_STEP_PIN PE1 + #define Y_DIR_PIN PE2 +#endif + +#define Z_ENABLE_PIN PD2 +#define Z_STEP_PIN PD3 +#define Z_DIR_PIN PD4 + +#ifdef OPTION_DUALZ_DRIVE + #define Z2_ENABLE_PIN PC11 + #define Z2_STEP_PIN PC12 + #define Z2_DIR_PIN PD0 +#endif + +#ifdef OPTION_REPEAT_PRINTING + #define REPRINT_STOP_PIN PD8 // X_MAX_PIN + #define FORWARD_PIN PA13 + #define BACK_PIN PA14 +#endif + +#ifdef SWITCH_EXTRUDER_SEQUENCE + #define E3_ENABLE_PIN PC10 + #define E3_STEP_PIN PA8 + #define E3_DIR_PIN PC9 + + #define E2_STEP_PIN PC6 + #define E2_DIR_PIN PD15 + #define E2_ENABLE_PIN PC7 + + #define E1_STEP_PIN PD13 + #define E1_DIR_PIN PD12 + #define E1_ENABLE_PIN PD14 + + #define E0_STEP_PIN PD10 + #define E0_DIR_PIN PD9 + #define E0_ENABLE_PIN PD11 +#else + #define E0_ENABLE_PIN PC10 + #define E0_STEP_PIN PA8 + #define E0_DIR_PIN PC9 + + #define E1_STEP_PIN PC6 + #define E1_DIR_PIN PD15 + #define E1_ENABLE_PIN PC7 + + #define E2_STEP_PIN PD13 + #define E2_DIR_PIN PD12 + #define E2_ENABLE_PIN PD14 + + #define E3_STEP_PIN PD10 + #define E3_DIR_PIN PD9 + #define E3_ENABLE_PIN PD11 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC2 // TH0 +//#define TEMP_1_PIN PC1 // TH1 +#define TEMP_BED_PIN PC3 // TB1 + +// +// Heaters +// +#define HEATER_0_PIN PC5 // HEATER0 +//#define HEATER_1_PIN PB0 // HEATER1 +#define HEATER_BED_PIN PA2 // HOT BED + +// +// Fans +// +#define FAN_PIN PB1 // FAN1 +#define FAN1_PIN PB8 // FAN2 + +// +// Misc. Functions +// +//#define POWER_LOSS_PIN PB15 +#define LED_PIN PA0 +#define SUICIDE_PIN PA3 +#define FIL_RUNOUT_PIN PC8 + +// +// SD card +// +#define ENABLE_SPI1 +#define SD_DETECT_PIN PC4 +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 +#define SD_SS_PIN PA4 + +// WiFi Functions +#define WIFI_RST PC15 +#define WIFI_EN PC14 + +#if ENABLED(ZONESTAR_12864LCD) + #define LCDSCREEN_NAME "ZONESTAR LCD12864" + #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP1_06_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP1_04_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN -1 // EXP1_01_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_08_PIN + #define BTN_ENC EXP1_07_PIN +#elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define LCDSCREEN_NAME "REPRAPDISCOUNT LCD12864" + #define LCD_PINS_RS EXP2_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP2_06_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP2_04_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP2_01_PIN + #define KILL_PIN EXP2_02_PIN + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP2_07_PIN +#elif ENABLED(ZONESTAR_DWIN_LCD) + // Connect to EXP2 connector + #define LCDSCREEN_NAME "ZONESTAR DWIN LCD" + #define BEEPER_PIN EXP2_05_PIN // PE11 + #define KILL_PIN -1 // EXP1_01_PIN + #define BTN_EN2 EXP2_07_PIN // PE8 + #define BTN_EN1 EXP2_08_PIN // PE14 + #define BTN_ENC EXP2_06_PIN // PE15 +#endif + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 200 // Tclk_fall <200ns + #define BOARD_ST7920_DELAY_2 250 // Tdata_width >200ns + #define BOARD_ST7920_DELAY_3 200 // Tclk_rise <200ns +#endif + +// Remap SERVO0 PIN for BLTouch +#if ENABLED(BLTOUCH_ON_EXP1) + // BLTouch connected to EXP1 + #define BLTOUCH_PROBE_PIN EXP1_05_PIN + #define BLTOUCH_GND_PIN EXP1_07_PIN + #undef SERVO0_PIN + #define SERVO0_PIN EXP1_08_PIN +#elif ENABLED(BLTOUCH_ON_EXP2) + // BLTouch connected to EXP2 + #define BLTOUCH_PROBE_PIN EXP2_08_PIN + #define BLTOUCH_GND_PIN EXP2_07_PIN + #undef SERVO0_PIN + #define SERVO0_PIN EXP2_05_PIN +#else + #define BLTOUCH_PROBE_PIN PB13 // Z1_MAX +#endif diff --git a/src/pins/stm32f4/env_validate.h b/src/pins/stm32f4/env_validate.h new file mode 100644 index 0000000..c01401f --- /dev/null +++ b/src/pins/stm32f4/env_validate.h @@ -0,0 +1,28 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(STM32F4) && (DISABLED(ALLOW_STM32DUINO) || NOT_TARGET(STM32F4xx)) + #error "Oops! Select an STM32F4 board in 'Tools > Board.'" +#endif + +#undef ALLOW_STM32DUINO diff --git a/src/pins/stm32f4/pins_ANET_ET4.h b/src/pins/stm32f4/pins_ANET_ET4.h new file mode 100644 index 0000000..01ca456 --- /dev/null +++ b/src/pins/stm32f4/pins_ANET_ET4.h @@ -0,0 +1,218 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Anet ET4 only supports 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Anet ET4 1.x" +#endif + +// +// EEPROM +// + +// Use one of these or SDCard-based Emulation will be used +#if NO_EEPROM_SELECTED + //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation + //#define IIC_BL24CXX_EEPROM // Use I2C EEPROM onboard IC (AT24C04C, Size 4K, PageSize 16B) +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#elif ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PB11 + #define IIC_EEPROM_SCL PB10 + #define EEPROM_DEVICE_ADDRESS 0xA0 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PC13 +#define Y_STOP_PIN PE12 +#define Z_STOP_PIN PE11 + +// +// Z Probe +// +#if ENABLED(BLTOUCH) + #error "You will need to use 24V to 5V converter and remove one resistor and capacitor from the motherboard. See https://bit.ly/3xg9cXO for more information. Comment out this line to proceed at your own risk." + #define SERVO0_PIN PC3 +#elif !defined(Z_MIN_PROBE_PIN) + #define Z_MIN_PROBE_PIN PC3 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA2 +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PA8 +#endif + +// +// LED PIN +// +#define LED_PIN PD12 + +// +// Steppers +// +#define X_STEP_PIN PB6 +#define X_DIR_PIN PB5 +#define X_ENABLE_PIN PB7 + +#define Y_STEP_PIN PB3 +#define Y_DIR_PIN PD6 +#define Y_ENABLE_PIN PB4 + +#define Z_STEP_PIN PA12 +#define Z_DIR_PIN PA11 +#define Z_ENABLE_PIN PA15 + +#define E0_STEP_PIN PB9 +#define E0_DIR_PIN PB8 +#define E0_ENABLE_PIN PE0 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA1 +#define TEMP_BED_PIN PA4 + +// +// Heaters +// +#define HEATER_0_PIN PA0 +#define HEATER_BED_PIN PE2 + +// +// Fans +// +#define FAN_PIN PE3 // Layer fan +#define FAN1_PIN PE1 // Hotend fan + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN +#endif + +// +// LCD / Controller +// +#if HAS_SPI_TFT || HAS_FSMC_TFT + #define TFT_RESET_PIN PE6 + #define TFT_CS_PIN PD7 + #define TFT_RS_PIN PD13 + + #if HAS_FSMC_TFT + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_CS_PIN TFT_CS_PIN + #define FSMC_RS_PIN TFT_RS_PIN + #define TFT_INTERFACE_FSMC_8BIT + #endif +#endif + +// +// Touch Screen +// https://ldm-systems.ru/f/doc/catalog/HY-TFT-2,8/XPT2046.pdf +// +#if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PB2 + #define TOUCH_SCK_PIN PB0 + #define TOUCH_MOSI_PIN PE5 + #define TOUCH_MISO_PIN PE4 + #define TOUCH_INT_PIN PB1 +#endif + +#if ENABLED(ANET_ET5_TFT35) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 17125 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y -11307 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X -26 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 337 + #endif + #ifndef TOUCH_ORIENTATION + #define TOUCH_ORIENTATION TOUCH_PORTRAIT + #endif +#elif ENABLED(ANET_ET4_TFT28) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X -11838 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 8776 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 333 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -17 + #endif + #ifndef TOUCH_ORIENTATION + #define TOUCH_ORIENTATION TOUCH_PORTRAIT + #endif +#endif + +// +// SD Card +// +//#define SDIO_SUPPORT + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION CUSTOM_CABLE +#endif + +#if ENABLED(SDSUPPORT) + + #if DISABLED(SDIO_SUPPORT) + #define SOFTWARE_SPI + #define SDSS PC11 + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #endif + + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN PD3 + #endif + +#endif diff --git a/src/pins/stm32f4/pins_ANET_ET4P.h b/src/pins/stm32f4/pins_ANET_ET4P.h new file mode 100644 index 0000000..bad5b8f --- /dev/null +++ b/src/pins/stm32f4/pins_ANET_ET4P.h @@ -0,0 +1,33 @@ +/** + * 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 . + * + */ +#pragma once + +#define BOARD_INFO_NAME "Anet ET4P 1.x" + +// +// TMC2208 Configuration_adv defaults for Anet ET4P-MB_V1.x +// +#if !AXIS_DRIVER_TYPE_X(TMC2208_STANDALONE) || !AXIS_DRIVER_TYPE_Y(TMC2208_STANDALONE) || !AXIS_DRIVER_TYPE_Z(TMC2208_STANDALONE) || !AXIS_DRIVER_TYPE_E0(TMC2208_STANDALONE) + #error "ANET_ET4P requires ([XYZ]|E0)_DRIVER_TYPE set to TMC2208_STANDALONE." +#endif + +#include "pins_ANET_ET4.h" diff --git a/src/pins/stm32f4/pins_ARMED.h b/src/pins/stm32f4/pins_ARMED.h new file mode 100644 index 0000000..d08d3fb --- /dev/null +++ b/src/pins/stm32f4/pins_ARMED.h @@ -0,0 +1,228 @@ +/** + * 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://github.com/ktand/Armed + +#pragma once + +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Arm'ed supports up to 2 hotends / E steppers." +#endif + +#ifndef ARMED_V1_0 + #define ARMED_V1_1 +#endif + +#undef BOARD_INFO_NAME // Defined on the command line by Arduino Core STM32 +#define BOARD_INFO_NAME "Arm'ed" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +#if NO_EEPROM_SELECTED + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PE0 +#define Y_STOP_PIN PE1 +#define Z_STOP_PIN PE14 + +// +// Z Probe (when not Z_MIN_PIN) +// +//#ifndef Z_MIN_PROBE_PIN +// #define Z_MIN_PROBE_PIN PA4 +//#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA3 +#endif + +// +// Steppers +// + +#ifdef ARMED_SWAP_X_E1 + #define X_STEP_PIN PE4 + #define X_DIR_PIN PE2 + #define X_ENABLE_PIN PE3 + #define X_CS_PIN PE5 +#else + #define X_STEP_PIN PD3 + #define X_DIR_PIN PD2 + #define X_ENABLE_PIN PD0 + #define X_CS_PIN PD1 +#endif + +#define Y_STEP_PIN PE11 +#define Y_DIR_PIN PE10 +#define Y_ENABLE_PIN PE13 +#define Y_CS_PIN PE12 + +#define Z_STEP_PIN PD6 +#define Z_DIR_PIN PD7 +#define Z_ENABLE_PIN PD4 +#define Z_CS_PIN PD5 + +#define E0_STEP_PIN PB5 +#define E0_DIR_PIN PB6 +#ifdef ARMED_V1_1 + #define E0_ENABLE_PIN PC12 +#else + #define E0_ENABLE_PIN PB3 +#endif +#define E0_CS_PIN PB4 + +#ifdef ARMED_SWAP_X_E1 + #define E1_STEP_PIN PD3 + #define E1_DIR_PIN PD2 + #define E1_ENABLE_PIN PD0 + #define E1_CS_PIN PD1 +#else + #define E1_STEP_PIN PE4 + #define E1_DIR_PIN PE2 + #define E1_ENABLE_PIN PE3 + #define E1_CS_PIN PE5 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC0 // Analog Input +#define TEMP_1_PIN PC1 // Analog Input +#define TEMP_BED_PIN PC2 // Analog Input + +#if HOTENDS == 1 && TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN PC1 +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA1 // Hardware PWM +#define HEATER_1_PIN PA2 // Hardware PWM +#define HEATER_BED_PIN PA0 // Hardware PWM + +#define FAN_PIN PC6 // Hardware PWM, Part cooling fan +#define FAN1_PIN PC7 // Hardware PWM, Extruder fan +#define FAN2_PIN PC8 // Hardware PWM, Controller fan + +// +// Misc functions +// +#define SDSS PE7 +#define LED_PIN PB7 // Heart beat +#define PS_ON_PIN PA10 +#define KILL_PIN PA8 +#define PWR_LOSS PA4 // Power loss / nAC_FAULT + +// +// LCD / Controller +// +#define SD_DETECT_PIN PA15 +#define BEEPER_PIN PC9 + +#if ENABLED(FYSETC_MINI_12864) + // + // See https://wiki.fysetc.com/Mini12864_Panel/ + // + #define DOGLCD_A0 PE9 + #define DOGLCD_CS PE8 + + #define LCD_BACKLIGHT_PIN -1 + + #define LCD_RESET_PIN PB12 // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB13 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB14 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB15 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN PB13 + #endif +#else + #define LCD_PINS_RS PE9 + #define LCD_PINS_ENABLE PE8 + #define LCD_PINS_D4 PB12 + #define LCD_PINS_D5 PB13 + #define LCD_PINS_D6 PB14 + #define LCD_PINS_D7 PB15 + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_CS PB13 + #define DOGLCD_A0 PB14 + #endif +#endif + +#define BTN_EN1 PC4 +#define BTN_EN2 PC5 +#define BTN_ENC PC3 + +// +// Extension pins +// +#define EXT0_PIN PB0 +#define EXT1_PIN PB1 +#define EXT2_PIN PB2 +#define EXT3_PIN PD8 +#define EXT4_PIN PD9 +#define EXT5_PIN PD10 +#define EXT6_PIN PD11 +#define EXT7_PIN PD12 +#define EXT8_PIN PB10 +#define EXT9_PIN PB11 + +#if HAS_TMC_UART + // TMC2208/TMC2209 stepper drivers + #define X_SERIAL_TX_PIN EXT0_PIN + #define X_SERIAL_RX_PIN EXT0_PIN + + #define Y_SERIAL_TX_PIN EXT1_PIN + #define Y_SERIAL_RX_PIN EXT1_PIN + + #define Z_SERIAL_TX_PIN EXT2_PIN + #define Z_SERIAL_RX_PIN EXT2_PIN + + #define E0_SERIAL_TX_PIN EXT3_PIN + #define E0_SERIAL_RX_PIN EXT3_PIN + + #define E1_SERIAL_RX_PIN EXT4_PIN + #define E1_SERIAL_TX_PIN EXT4_PIN + + #define Z2_SERIAL_RX_PIN EXT4_PIN + #define Z2_SERIAL_TX_PIN EXT4_PIN + + #define TMC_BAUD_RATE 19200 +#endif diff --git a/src/pins/stm32f4/pins_ARTILLERY_RUBY.h b/src/pins/stm32f4/pins_ARTILLERY_RUBY.h new file mode 100644 index 0000000..47d009c --- /dev/null +++ b/src/pins/stm32f4/pins_ARTILLERY_RUBY.h @@ -0,0 +1,184 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "Artillery Ruby only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Artillery Ruby" + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + //#define I2C_EEPROM +#endif +//#define E2END 0xFFF // 4K + +#define HAL_TIMER_RATE F_CPU + +// +// Limit Switches +// +#if (X_HOME_DIR == 1) + #define X_MIN_PIN -1 + #define X_MAX_PIN PA2 +#else + #define X_MIN_PIN PA2 + #define X_MAX_PIN -1 +#endif +#if (Y_HOME_DIR == 1) + #define Y_MIN_PIN -1 + #define Y_MAX_PIN PA1 +#else + #define Y_MIN_PIN PA1 + #define Y_MAX_PIN -1 +#endif +#if (Z_HOME_DIR == 1) + #define Z_MIN_PIN PC2 + #define Z_MAX_PIN PA0 +#else + #define Z_MIN_PIN PA0 + #define Z_MAX_PIN PC2 +#endif + +// +// Steppers +// +#define X_STEP_PIN PB14 +#define X_DIR_PIN PB13 +#define X_ENABLE_PIN PB15 + +#define Y_STEP_PIN PB10 +#define Y_DIR_PIN PB2 +#define Y_ENABLE_PIN PB12 + +#define Z_STEP_PIN PB0 +#define Z_DIR_PIN PC5 +#define Z_ENABLE_PIN PB1 + +#define E0_STEP_PIN PA7 +#define E0_DIR_PIN PA6 +#define E0_ENABLE_PIN PC4 + +#define E1_STEP_PIN PA4 +#define E1_DIR_PIN PA3 +#define E1_ENABLE_PIN PA5 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC0 +#define TEMP_BED_PIN PC1 + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PC9 // Heater0 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PA8 // Hotbed +#endif +#ifndef FAN_PIN + #define FAN_PIN PC8 // Fan0 +#endif +#ifndef FAN1_PIN + #define FAN1_PIN PC7 // Fan1 +#endif +#ifndef FAN2_PIN + #define FAN2_PIN PC6 // Fan2 +#endif + +// +// Servos +// +#define SERVO0_PIN PC3 + +// +// SPI +// +#define SCK_PIN PC10 +#define MISO_PIN PC11 +#define MOSI_PIN PC12 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + #define LCD_PINS_DC PB8 // Set as output on init + #define LCD_PINS_RS PB9 // Pull low for 1s to init + // DOGM SPI LCD Support + #define DOGLCD_CS PC15 + #define DOGLCD_MOSI PB6 + #define DOGLCD_SCK PB5 + #define DOGLCD_A0 LCD_PINS_DC + #elif ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS PB6 + #define DOGLCD_A0 PC15 + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN PB5 // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB9 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB8 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB7 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN PB9 + #endif + + #define LCD_CONTRAST_INIT 255 + #else + #define LCD_PINS_RS PC15 + #define LCD_PINS_ENABLE PB6 + #define LCD_PINS_D4 PB5 + #define LCD_PINS_D5 PB9 + #define LCD_PINS_D6 PB8 + #endif + + #define LCD_PINS_D7 PB7 + + // + // Beeper, SD Card, Encoder + // + #define BEEPER_PIN PC13 + + #if ENABLED(SDSUPPORT) + #define SDSS PA15 + #define SD_DETECT_PIN PD2 + #endif + + #define BTN_EN1 PB4 + #define BTN_EN2 PB3 + #define BTN_ENC PC14 +#endif diff --git a/src/pins/stm32f4/pins_BLACK_STM32F407VE.h b/src/pins/stm32f4/pins_BLACK_STM32F407VE.h new file mode 100644 index 0000000..c49abca --- /dev/null +++ b/src/pins/stm32f4/pins_BLACK_STM32F407VE.h @@ -0,0 +1,156 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * STM32F407VET6 with RAMPS-like shield + * 'Black' STM32F407VET6 board - https://www.stm32duino.com/viewtopic.php?t=485 + * Shield - https://github.com/jmz52/Hardware + */ + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Black STM32F4VET6 supports up to 2 hotends / E steppers." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Black STM32F4VET6" +#endif + +#define DEFAULT_MACHINE_NAME "STM32F407VET6" + +//#define I2C_EEPROM +#define SRAM_EEPROM_EMULATION +#define MARLIN_EEPROM_SIZE 0x2000 // 8K + +// +// Servos +// +#define SERVO0_PIN PC6 +#define SERVO1_PIN PC7 + +// +// Limit Switches +// +#define X_MIN_PIN PC13 +#define X_MAX_PIN PA15 +#define Y_MIN_PIN PA5 +#define Y_MAX_PIN PD12 +#define Z_MIN_PIN PD14 +#define Z_MAX_PIN PD15 + +// +// Steppers +// +#define X_STEP_PIN PC4 +#define X_DIR_PIN PA4 +#define X_ENABLE_PIN PE7 + +#define Y_STEP_PIN PE5 +#define Y_DIR_PIN PE2 +#define Y_ENABLE_PIN PE6 + +#define Z_STEP_PIN PD5 +#define Z_DIR_PIN PD3 +#define Z_ENABLE_PIN PD6 + +#define E0_STEP_PIN PD7 +#define E0_DIR_PIN PD0 +#define E0_ENABLE_PIN PB9 + +#define E1_STEP_PIN PE0 +#define E1_DIR_PIN PE1 +#define E1_ENABLE_PIN PB8 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC0 // T0 +#define TEMP_1_PIN PC1 // T1 +#define TEMP_BED_PIN PC2 // TB + +#ifndef TEMP_CHAMBER_PIN + #define TEMP_CHAMBER_PIN PC3 // TC +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA2 // Heater0 +#define HEATER_1_PIN PA3 // Heater1 +#define HEATER_BED_PIN PA1 // Hotbed + +#define FAN_PIN PE9 // Fan0 +#define FAN1_PIN PE11 // Fan1 +#define FAN2_PIN PE13 // Fan2 +#define FAN3_PIN PE14 // Fan3 + +// +// Misc. Functions +// +#define LED_PIN PA6 +//#define LED_PIN PA7 +#define KILL_PIN PB1 + +// +// LCD / Controller +// +//#define SD_DETECT_PIN PC5 +//#define SD_DETECT_PIN PA8 // SDIO SD_DETECT_PIN, external SDIO card reader only + +#define BEEPER_PIN PD10 +#define LCD_PINS_RS PE15 +#define LCD_PINS_ENABLE PD8 +#define LCD_PINS_D4 PE10 +#define LCD_PINS_D5 PE12 +#define LCD_PINS_D6 PD1 +#define LCD_PINS_D7 PE8 +#define BTN_ENC PD9 +#define BTN_EN1 PD4 +#define BTN_EN2 PD13 + +#define DOGLCD_CS LCD_PINS_D5 +#define DOGLCD_A0 LCD_PINS_D6 + +#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder +#endif + +// +// Onboard SD support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT // Use SDIO for onboard SD + #if DISABLED(SDIO_SUPPORT) + #define SOFTWARE_SPI // Use soft SPI for onboard SD + #define SDSS PC11 + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #endif +#endif diff --git a/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h new file mode 100644 index 0000000..2147dd9 --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -0,0 +1,336 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "BIGTREE BTT002 V1.0 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "BTT BTT002 V1.0" + +//#define MK3_FAN_PINS + +#define USES_DIAG_PINS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// Use one of these or SDCard-based Emulation will be used +#if NO_EEPROM_SELECTED + //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PD3 +#define Y_STOP_PIN PD2 +#define Z_STOP_PIN PD1 // Shares J4 connector with PC3 + +// +// Z Probe must be this pin +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PD1 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA15 +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PD4 +#endif + +// +// Steppers +// +#define X_STEP_PIN PA9 +#define X_DIR_PIN PA10 +#define X_ENABLE_PIN PA8 +#ifndef X_CS_PIN + #define X_CS_PIN PE2 +#endif + +#define Y_STEP_PIN PC8 +#define Y_DIR_PIN PC9 +#define Y_ENABLE_PIN PC7 + #ifndef Y_CS_PIN + #define Y_CS_PIN PE3 +#endif + +#define Z_STEP_PIN PD15 +#define Z_DIR_PIN PC6 +#define Z_ENABLE_PIN PD14 +#ifndef Z_CS_PIN + #define Z_CS_PIN PE4 +#endif + +#define E0_STEP_PIN PD12 +#define E0_DIR_PIN PD13 +#define E0_ENABLE_PIN PD11 +#ifndef E0_CS_PIN + #define E0_CS_PIN PD7 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB15 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB14 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB13 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN PE2 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE4 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD7 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA2 // T0 <-> E0 +#define TEMP_1_PIN PA0 // T1 <-> E1 +#define TEMP_BOARD_PIN PC2 // Onboard thermistor, NTC100K +#define TEMP_BED_PIN PA1 // T2 <-> Bed +#define TEMP_PROBE_PIN PC3 // Shares J4 connector with PD1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PE6 // Heater0 +#define HEATER_BED_PIN PE5 // Hotbed + +#ifndef FAN_PIN + #ifdef MK3_FAN_PINS + #define FAN_PIN PB8 // Fan1 + #else + #define FAN_PIN PB9 // Fan0 + #endif +#endif + +#ifndef FAN1_PIN + #ifdef MK3_FAN_PINS + #define FAN1_PIN PB9 // Fan0 + #else + #define FAN1_PIN PB8 // Fan1 + #endif +#endif + +#ifndef E0_FAN_TACHO_PIN + #ifdef MK3_FAN_PINS + #define E0_FAN_TACHO_PIN PE1 // Fan1 + #else + #define E0_FAN_TACHO_PIN PE0 // Fan0 + #endif +#endif + +/** + * ---------------------------------BTT002 V1.0--------------------------------- + * ------ ------ | + * (BEEPER) PE7 | 1 2 | PB1 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) | + * (LCD_EN) PE9 | 3 4 | PE8 (LCD_RS) (BTN_EN1) PC5 | 3 4 | PA4 (SD_SS) | + * (LCD_D4) PE10 5 6 | PE11 (LCD_D5) (BTN_EN2) PB0 5 6 | PA7 (MOSI) | + * (LCD_D6) PE12 | 7 8 | PE13 (LCD_D7) (SD_DET) PC4 | 7 8 | RESET | + * GND | 9 10 | 5V GND | 9 10 | PA3 | + * ------ ------ | + * EXP1 EXP2 | + * ------------------------------------------------------------------------------ + */ +#define EXP1_01_PIN PE7 +#define EXP1_02_PIN PB1 +#define EXP1_03_PIN PE9 +#define EXP1_04_PIN PE8 +#define EXP1_05_PIN PE10 +#define EXP1_06_PIN PE11 +#define EXP1_07_PIN PE12 +#define EXP1_08_PIN PE13 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PC5 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB0 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC4 +#define EXP2_08_PIN -1 +#define EXP2_10_PIN PA3 + +// HAL SPI1 pins +#define SD_SCK_PIN EXP2_02_PIN // SPI1 SCLK +#define SD_SS_PIN EXP2_04_PIN // SPI1 SSEL +#define SD_MISO_PIN EXP2_01_PIN // SPI1 MISO +#define SD_MOSI_PIN EXP2_06_PIN // SPI1 MOSI + +#define SDSS EXP2_04_PIN + +// +// LCDs and Controllers +// +#if HAS_WIRED_LCD + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #define SD_DETECT_PIN EXP2_07_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_MISO EXP2_01_PIN + #define DOGLCD_SCK EXP2_02_PIN + + #define LCD_BACKLIGHT_PIN -1 + + #define FORCE_SOFT_SPI + + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + #endif + + // Alter timing for graphical display + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 600 + #endif + +#endif // HAS_WIRED_LCD + +// +// RGB LEDs +// +#ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB5 +#endif +#ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB4 +#endif +#ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB3 +#endif +#ifndef RGB_LED_W_PIN + #define RGB_LED_W_PIN -1 +#endif diff --git a/src/pins/stm32f4/pins_BTT_E3_RRF.h b/src/pins/stm32f4/pins_BTT_E3_RRF.h new file mode 100644 index 0000000..c29949e --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_E3_RRF.h @@ -0,0 +1,420 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(STM32F4) + #error "Oops! Select an STM32F4 board in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT E3 RRF" +#endif + +#define USES_DIAG_JUMPERS + +// Add-on board for IDEX conversion +//#define BTT_E3_RRF_IDEX_BOARD + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4K + +// +// Servos +// +#define SERVO0_PIN PB0 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PC0 // X-STOP +#define Y_STOP_PIN PC1 // Y-STOP +#define Z_STOP_PIN PC2 // Z-STOP + +#if ENABLED(BTT_E3_RRF_IDEX_BOARD) + #if X2_USE_ENDSTOP == _XMAX_ + #define X_MAX_PIN FPC2_PIN // X2-STOP + #elif X2_USE_ENDSTOP == _XMIN_ + #define X_MIN_PIN FPC2_PIN // X2-STOP + #endif +#endif + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PC5 // PROBE + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC3 // E0-STOP +#endif + +#if !defined(FIL1_RUNOUT2_PIN) && ENABLED(BTT_E3_RRF_IDEX_BOARD) + #define FIL_RUNOUT2_PIN FPC3_PIN // E1-STOP +#endif + +// +// Power-loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PE0 // Power Loss Detection: PWR-DET +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PD7 +#define X_STEP_PIN PD5 +#define X_DIR_PIN PD4 + +#define Y_ENABLE_PIN PD3 +#define Y_STEP_PIN PD0 +#define Y_DIR_PIN PA15 + +#define Z_ENABLE_PIN PD14 +#define Z_STEP_PIN PC6 +#define Z_DIR_PIN PC7 + +#define E0_ENABLE_PIN PD10 +#define E0_STEP_PIN PD12 +#define E0_DIR_PIN PD13 + +#if ENABLED(BTT_E3_RRF_IDEX_BOARD) + #define E1_ENABLE_PIN FPC7_PIN // E1EN + #define E1_STEP_PIN FPC5_PIN // E1STP + #define E1_DIR_PIN FPC4_PIN // E1DIR + + #define X2_ENABLE_PIN FPC13_PIN // X2EN + #define X2_STEP_PIN FPC11_PIN // X2STP + #define X2_DIR_PIN FPC10_PIN // X2DIR +#endif + +/** + * TMC2208/TMC2209 stepper drivers + */ +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PD6 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PD1 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PD15 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD11 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #if ENABLED(BTT_E3_RRF_IDEX_BOARD) + #define X2_SERIAL_TX_PIN FPC12_PIN // X2UART + #define X2_SERIAL_RX_PIN X2_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN FPC6_PIN // E1UART + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + #endif + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA1 // Analog Input "TB" +#define TEMP_0_PIN PA0 // Analog Input "TH0" + +#if ENABLED(BTT_E3_RRF_IDEX_BOARD) + #define TEMP_1_PIN FPC9_PIN // Analog Input "TH1" + #define PT100_PIN FPC8_PIN // Analog Input "PT100" (INA826) +#endif + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PB4 // "HB" +#define HEATER_0_PIN PB3 // "HE0" + +#if ENABLED(BTT_E3_RRF_IDEX_BOARD) + #define HEATER_1_PIN FPC16_PIN // "HE1" +#endif + +#define FAN_PIN PB5 // "FAN0" + +#ifndef CONTROLLER_FAN_PIN + #define CONTROLLER_FAN_PIN PB6 // "FAN1" +#endif + +#if ENABLED(BTT_E3_RRF_IDEX_BOARD) + #define FAN1_PIN FPC15_PIN // "FAN0" in IDEX board + #define FAN2_PIN FPC14_PIN // "FAN1" in IDEX board +#else + //#define FAN1_PIN PB6 // "FAN1" +#endif + +// +// Misc. Functions +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PB7 // LED driving pin +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN PE1 // Power Supply Control +#endif + +/** + * BTT E3 RRF + * ------ + * (BEEPER) PE8 | 1 2 | PE9 (BTN_ENC) + * (BTN_EN1) PE7 | 3 4 | RESET + * (BTN_EN2) PB2 5 6 | PE10 (LCD_D4) + * (LCD_RS) PB1 | 7 8 | PE11 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + +#if HAS_WIRED_LCD + + #if EITHER(CR10_STOCKDISPLAY, LCD_FOR_MELZI) + + #define BEEPER_PIN PE8 + + #define BTN_ENC PE9 + #define BTN_EN1 PE7 + #define BTN_EN2 PB2 + + #define LCD_PINS_RS PB1 + #define LCD_PINS_ENABLE PE11 + #define LCD_PINS_D4 PE10 + + #if ENABLED(LCD_FOR_MELZI) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD_FOR_MELZI requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** LCD_FOR_MELZI display pinout + * + * BTT E3 RRF Display Ribbon + * ------ ------ + * (BEEPER) PE8 | 1 2 | PE9 (BTN_ENC) GND |10 9 | 5V + * (BTN_EN1) PE7 | 3 4 | RESET BEEPER | 8 7 | ESTOP (RESET) + * (BTN_EN2) PB2 5 6 | PE10 (LCD_D4) (BTN_ENC) ENC_BTN | 6 5 | LCD_SCLK (LCD_D4) + * (LCD_RS) PB1 | 7 8 | PE11 (LCD_EN) (BTN_EN2) ENC_A | 4 3 | LCD_DATA (LCD_EN) + * GND | 9 10 | 5V (BTN_EN1) ENC_B | 2 1 | LCD_CS (LCD_RS) + * ------ ------ + * EXP1 LCD + * + * Needs custom cable: + * + * Board Adapter Display Ribbon (coming from display) + * ---------------------------------- + * EXP1-10 ---------- LCD-9 5V + * EXP1-9 ----------- LCD-10 GND + * EXP1-8 ----------- LCD-3 LCD_EN + * EXP1-7 ----------- LCD-1 LCD_RS + * EXP1-6 ----------- LCD-5 LCD_D4 + * EXP1-5 ----------- LCD-4 EN2 + * EXP1-4 ----------- LCD-7 RESET + * EXP1-3 ----------- LCD-2 EN1 + * EXP1-2 ----------- LCD-6 BTN + * EXP1-1 ----------- LCD-8 BEEPER + */ + + #endif + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define LCD_PINS_RS PE10 + #define LCD_PINS_ENABLE PE9 + #define LCD_PINS_D4 PB1 + #define LCD_PINS_D5 PB2 + #define LCD_PINS_D6 PE7 + #define LCD_PINS_D7 PE8 + #define ADC_KEYPAD_PIN PB0 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_ENC PE9 + #define BTN_EN1 PE7 + #define BTN_EN2 PB2 + + #define DOGLCD_CS PB1 + #define DOGLCD_A0 PE10 + #define DOGLCD_SCK PE8 + #define DOGLCD_MOSI PE11 + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * TFTGLCD_PANEL_SPI display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PE8 | 1 2 | PE9 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PE7 | 3 4 | RESET -- | 8 7 | (SD_DET) + * (SD_CS) PB2 5 6 | PE10 (MOSI) 6 5 | -- + * (LCD_CS) PB1 | 7 8 | PE11 (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- n/c + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- n/c + * EXP1-3 ----------- EXP1-3 LCD_CS + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET + */ + + #define TFTGLCD_CS PE7 + + #endif + + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, LCD_FOR_MELZI, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BTT_E3_RRF." + #endif + + // Alter timing for graphical display + #if ENABLED(LCD_FOR_MELZI) // LCD_FOR_MELZI default timing is too fast. This works but may be reduced. + #define BOARD_ST7920_DELAY_1 200 + #define BOARD_ST7920_DELAY_2 400 + #define BOARD_ST7920_DELAY_3 1200 + #elif IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 600 + #endif + +#endif // HAS_WIRED_LCD + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** FYSETC TFT TFT81050 display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PE8 | 1 2 | PE9 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PE7 | 3 4 | RESET RESET | 8 7 | (SD_DET) + * (SD_CS) PB2 5 6 | PE10 (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB1 | 7 8 | PE11 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN PE9 + + #define CLCD_MOD_RESET PE7 + #define CLCD_SPI_CS PB1 + +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT // Use SDIO for onboard SD + //#define SDIO_CLOCK 48000000 + #define SD_DETECT_PIN PC4 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with BTT E3 RRF." +#endif + +// +// WIFI +// + +#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_RESET_PIN PA4 +#define ESP_WIFI_MODULE_ENABLE_PIN PA5 +#define ESP_WIFI_MODULE_GPIO0_PIN PA6 + +#if ENABLED(BTT_E3_RRF_IDEX_BOARD) + #define FPC2_PIN PB11 + #define FPC3_PIN PB10 + #define FPC4_PIN PE12 + #define FPC5_PIN PE13 + #define FPC6_PIN PE14 + #define FPC7_PIN PE15 + #define FPC8_PIN PA3 + #define FPC9_PIN PA2 + #define FPC10_PIN PA8 + #define FPC11_PIN PC15 + #define FPC12_PIN PC14 + #define FPC13_PIN PC13 + #define FPC14_PIN PE6 + #define FPC15_PIN PE5 + #define FPC16_PIN PE4 + #define FPC17_PIN PE3 +#endif diff --git a/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/src/pins/stm32f4/pins_BTT_GTR_V1_0.h new file mode 100644 index 0000000..fe03ec8 --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -0,0 +1,494 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#if E_STEPPERS > MAX_E_STEPPERS + #error "Marlin extruder/hotends limit! Increase MAX_E_STEPPERS to continue." +#elif HOTENDS > 8 || E_STEPPERS > 8 + #error "BIGTREE GTR V1.0 supports up to 8 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "BTT GTR V1.0" + +#define USES_DIAG_JUMPERS +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support +#define M5_EXTENDER // The M5 extender is attached + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x2000 // 8K (24C64) + +// +// Servos +// +#define SERVO0_PIN PB11 // BLTOUCH +#define SOL0_PIN PC7 // Toolchanger + +#if ENABLED(TOOL_SENSOR) + #define TOOL_SENSOR1_PIN PH6 + #define TOOL_SENSOR2_PIN PI4 + //#define TOOL_SENSOR3_PIN PF4 +#else + #define PS_ON_PIN PH6 +#endif + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PF2 // X- +#define Y_DIAG_PIN PC13 // Y- +#define Z_DIAG_PIN PE0 // Z- +#define E0_DIAG_PIN PG14 // X+ +#define E1_DIAG_PIN PG9 // Y+ +#define E2_DIAG_PIN PD3 // Z+ + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN E0_DIAG_PIN // X+ + #else + #define X_MIN_PIN E0_DIAG_PIN // X+ + #endif +#else + #define X_MIN_PIN X_DIAG_PIN // X- + #define X_MAX_PIN E0_DIAG_PIN // X+ +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN E1_DIAG_PIN // Y+ + #else + #define Y_MIN_PIN E1_DIAG_PIN // Y+ + #endif +#else + #define Y_MIN_PIN Y_DIAG_PIN // Y- + #define Y_MAX_PIN E1_DIAG_PIN // Y+ +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN E2_DIAG_PIN // Z+ + #else + #define Z_MIN_PIN E2_DIAG_PIN // Z+ + #endif +#else + #define Z_MIN_PIN Z_DIAG_PIN // Z- + #define Z_MAX_PIN E2_DIAG_PIN // Z+ +#endif + +// +// Pins on the extender +// +#if ENABLED(M5_EXTENDER) + #define X2_STOP_PIN PI4 // M5 M1_STOP + #define Y2_STOP_PIN PF12 // M5 M5_STOP + #define Z2_STOP_PIN PF4 // M5 M2_STOP + #define Z3_STOP_PIN PI7 // M5 M4_STOP + #define Z4_STOP_PIN PF6 // M5 M3_STOP +#endif + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PH11 // Z Probe must be PH11 +#endif + +// +// Steppers +// +#define X_STEP_PIN PC15 +#define X_DIR_PIN PF0 +#define X_ENABLE_PIN PF1 +#ifndef X_CS_PIN + #define X_CS_PIN PC14 +#endif + +#define Y_STEP_PIN PE3 +#define Y_DIR_PIN PE2 +#define Y_ENABLE_PIN PE4 +#ifndef Y_CS_PIN + #define Y_CS_PIN PE1 +#endif + +#define Z_STEP_PIN PB8 +#define Z_DIR_PIN PB7 // PB7 +#define Z_ENABLE_PIN PB9 +#ifndef Z_CS_PIN + #define Z_CS_PIN PB5 +#endif + +#define E0_STEP_PIN PG12 +#define E0_DIR_PIN PG11 +#define E0_ENABLE_PIN PG13 +#ifndef E0_CS_PIN + #define E0_CS_PIN PG10 +#endif + +#define E1_STEP_PIN PD6 +#define E1_DIR_PIN PD5 +#define E1_ENABLE_PIN PD7 +#ifndef E1_CS_PIN + #define E1_CS_PIN PD4 +#endif + +#define E2_STEP_PIN PD1 +#define E2_DIR_PIN PD0 +#define E2_ENABLE_PIN PD2 +#ifndef E2_CS_PIN + #define E2_CS_PIN PC12 +#endif + +#if ENABLED(M5_EXTENDER) + + #define E3_STEP_PIN PF3 + #define E3_DIR_PIN PG3 + #define E3_ENABLE_PIN PF8 + #ifndef E3_CS_PIN + #define E3_CS_PIN PG4 + #endif + + #define E4_STEP_PIN PD14 + #define E4_DIR_PIN PD11 + #define E4_ENABLE_PIN PG2 + #ifndef E4_CS_PIN + #define E4_CS_PIN PE15 + #endif + + #define E5_STEP_PIN PE12 + #define E5_DIR_PIN PE10 + #define E5_ENABLE_PIN PF14 + #ifndef E5_CS_PIN + #define E5_CS_PIN PE7 + #endif + + #define E6_STEP_PIN PG0 + #define E6_DIR_PIN PG1 + #define E6_ENABLE_PIN PE8 + #ifndef E6_CS_PIN + #define E6_CS_PIN PF15 + #endif + + #define E7_STEP_PIN PH12 + #define E7_DIR_PIN PH15 + #define E7_ENABLE_PIN PI0 + #ifndef E7_CS_PIN + #define E7_CS_PIN PH14 + #endif + +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PG15 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB6 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB3 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 // M5 MOTOR 1 + //#define E4_HARDWARE_SERIAL Serial1 // M5 MOTOR 2 + //#define E5_HARDWARE_SERIAL Serial1 // M5 MOTOR 3 + //#define E6_HARDWARE_SERIAL Serial1 // M5 MOTOR 4 + //#define E7_HARDWARE_SERIAL Serial1 // M5 MOTOR 5 + + #define X_SERIAL_TX_PIN PC14 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PE1 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PB5 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PG10 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD4 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PC12 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + #if ENABLED(M5_EXTENDER) + #define E3_SERIAL_TX_PIN PG4 + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + #define E4_SERIAL_TX_PIN PE15 + #define E4_SERIAL_RX_PIN E4_SERIAL_TX_PIN + + #define E5_SERIAL_TX_PIN PE7 + #define E5_SERIAL_RX_PIN E5_SERIAL_TX_PIN + + #define E6_SERIAL_TX_PIN PF15 + #define E6_SERIAL_RX_PIN E6_SERIAL_TX_PIN + + #define E7_SERIAL_TX_PIN PH14 + #define E7_SERIAL_RX_PIN E7_SERIAL_TX_PIN + #endif + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // T1 <-> E0 +#define TEMP_1_PIN PC2 // T2 <-> E1 +#define TEMP_2_PIN PC3 // T3 <-> E2 + +#if ENABLED(M5_EXTENDER) + #define TEMP_3_PIN PA3 // M5 TEMP1 + #define TEMP_4_PIN PF9 // M5 TEMP2 + #define TEMP_5_PIN PF10 // M5 TEMP3 + #define TEMP_6_PIN PF7 // M5 TEMP4 + #define TEMP_7_PIN PF5 // M5 TEMP5 +#endif + +#define TEMP_BED_PIN PC0 // T0 <-> Bed + +// SPI for MAX Thermocouple +// Uses a separate SPI bus +// If you have a two-way thermocouple, you can customize two TEMP_x_CS_PIN pins (x:0~1) + +#define TEMP_0_CS_PIN PH9 // GTR K-TEMP +#define TEMP_0_SCK_PIN PI1 // SCK +#define TEMP_0_MISO_PIN PI2 // MISO +//#define TEMP_0_MOSI_PIN ... // For MAX31865 + +#define TEMP_1_CS_PIN PH2 // M5 K-TEMP +#define TEMP_1_SCK_PIN TEMP_0_SCK_PIN +#define TEMP_1_MISO_PIN TEMP_0_MISO_PIN +//#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB1 // Heater0 +#define HEATER_1_PIN PA1 // Heater1 +#define HEATER_2_PIN PB0 // Heater2 + +#if ENABLED(M5_EXTENDER) + #define HEATER_3_PIN PD15 // M5 HEAT1 + #define HEATER_4_PIN PD13 // M5 HEAT2 + #define HEATER_5_PIN PD12 // M5 HEAT3 + #define HEATER_6_PIN PE13 // M5 HEAT4 + #define HEATER_7_PIN PI6 // M5 HEAT5 +#endif + +#define HEATER_BED_PIN PA2 // Hotbed + +#define FAN_PIN PE5 // Fan0 +#define FAN1_PIN PE6 // Fan1 +#define FAN2_PIN PC8 // Fan2 + +#if ENABLED(M5_EXTENDER) + #define FAN3_PIN PI5 // M5 FAN1 + #define FAN4_PIN PE9 // M5 FAN2 + #define FAN5_PIN PE11 // M5 FAN3 + //#define FAN6_PIN PC9 // M5 FAN4 + //#define FAN7_PIN PE14 // M5 FAN5 +#endif + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +// +// By default the LCD SD (SPI2) is enabled +// Onboard SD is on a completely separate SPI bus, and requires +// overriding pins to access. +// +#if SD_CONNECTION_IS(LCD) + + #define SD_DETECT_PIN EXP2_07_PIN + #define SDSS EXP2_04_PIN + +#elif SD_CONNECTION_IS(ONBOARD) + + #define SDSS PA4 + #define SD_SS_PIN SDSS + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_DETECT_PIN PC4 + +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" +#endif + +/** + * ------ ------ + * (BEEPER) PC11 | 1 2 | PA15 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SCK) + * (LCD_EN) PC10 | 3 4 | PA8 (LCD_RS) (BTN_EN1) PD10 | 3 4 | PB12 (SD_SS) + * (LCD_D4) PG8 5 6 | PG7 (LCD_D5) (BTN_EN2) PH10 5 6 | PB15 (MOSI) + * (LCD_D6) PG6 | 7 8 | PG5 (LCD_D7) (SD_DETECT) PB10 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC11 +#define EXP1_02_PIN PA15 +#define EXP1_03_PIN PC10 +#define EXP1_04_PIN PA8 +#define EXP1_05_PIN PG8 +#define EXP1_06_PIN PG7 +#define EXP1_07_PIN PG6 +#define EXP1_08_PIN PG5 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PD10 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PH10 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PB10 + +// +// LCDs and Controllers +// +#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) + + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + +#elif HAS_WIRED_LCD + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(MKS_MINI_12864) + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #if SD_CONNECTION_IS(ONBOARD) + #define SOFTWARE_SPI + #endif + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + + #if SD_CONNECTION_IS(ONBOARD) + #define SOFTWARE_SPI + #endif + + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif + + // Alter timing for graphical display + #if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 90 + #define BOARD_ST7920_DELAY_3 600 + #endif + +#endif // HAS_WIRED_LCD + +#undef TP +#undef M5_EXTENDER diff --git a/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h b/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h new file mode 100644 index 0000000..dd8812f --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h @@ -0,0 +1,44 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT OCTOPUS PRO V1.0" + +// +// Temperature Sensors +// +#if TEMP_SENSOR_0 == -5 + #define TEMP_0_CS_PIN PF8 // Max31865 CS + #define TEMP_0_SCK_PIN PA5 + #define TEMP_0_MISO_PIN PA6 + #define TEMP_0_MOSI_PIN PA7 + #define SOFTWARE_SPI // Max31865 and LCD SD share a set of SPIs, Set SD to softwareSPI for Max31865 + #define FORCE_SOFT_SPI +#else + #define TEMP_0_PIN PF4 // TH0 +#endif + +#if !defined(Z_MIN_PROBE_PIN) && DISABLED(BLTOUCH) + #define Z_MIN_PROBE_PIN PC5 // Probe (Proximity switch) port +#endif + +#include "pins_BTT_OCTOPUS_V1_common.h" diff --git a/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h b/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h new file mode 100644 index 0000000..c2f02d0 --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h @@ -0,0 +1,35 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT OCTOPUS V1.0" + +// +// Temperature Sensors +// +#if TEMP_SENSOR_0 == 20 + #define TEMP_0_PIN PF8 // PT100 Connector +#else + #define TEMP_0_PIN PF4 // TH0 +#endif + +#include "pins_BTT_OCTOPUS_V1_common.h" diff --git a/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_1.h b/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_1.h new file mode 100644 index 0000000..daa0e8f --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_1.h @@ -0,0 +1,35 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT OCTOPUS V1.1" + +// +// Temperature Sensors +// +#if TEMP_SENSOR_0 == 20 + #define TEMP_0_PIN PF8 // PT100 Connector +#else + #define TEMP_0_PIN PF4 // TH0 +#endif + +#include "pins_BTT_OCTOPUS_V1_common.h" diff --git a/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h b/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h new file mode 100644 index 0000000..9ff9f6a --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -0,0 +1,545 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support +#define USES_DIAG_JUMPERS + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (AT24C32) +#define I2C_SCL_PIN PB8 +#define I2C_SDA_PIN PB9 + +// Avoid conflict with TIMER_TONE +#define STEP_TIMER 10 + +// +// Servos +// +#define SERVO0_PIN PB6 + +// +// Misc. Functions +// +#define LED_PIN PA13 + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PG6 // X-STOP +#define Y_DIAG_PIN PG9 // Y-STOP +#define Z_DIAG_PIN PG10 // Z-STOP +#define Z2_DIAG_PIN PG11 // Z2-STOP +#define E0_DIAG_PIN PG12 // E0DET +#define E1_DIAG_PIN PG13 // E1DET +#define E2_DIAG_PIN PG14 // E2DET +#define E3_DIAG_PIN PG15 // E3DET + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB7 +#endif + +// +// Check for additional used endstop pins +// +#if HAS_EXTRA_ENDSTOPS + #define _ENDSTOP_IS_ANY(ES) X2_USE_ENDSTOP == ES || Y2_USE_ENDSTOP == ES || Z2_USE_ENDSTOP == ES || Z3_USE_ENDSTOP == ES || Z4_USE_ENDSTOP == ES + #if _ENDSTOP_IS_ANY(_XMIN_) || _ENDSTOP_IS_ANY(_XMAX_) + #define NEEDS_X_MINMAX 1 + #endif + #if _ENDSTOP_IS_ANY(_YMIN_) || _ENDSTOP_IS_ANY(_YMAX_) + #define NEEDS_Y_MINMAX 1 + #endif + #if _ENDSTOP_IS_ANY(_ZMIN_) || _ENDSTOP_IS_ANY(_ZMAX_) + #define NEEDS_Z_MINMAX 1 + #endif + #undef _ENDSTOP_IS_ANY +#endif + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN E0_DIAG_PIN // E0DET + #else + #define X_MIN_PIN E0_DIAG_PIN // E0DET + #endif +#elif EITHER(DUAL_X_CARRIAGE, NEEDS_X_MINMAX) + #ifndef X_MIN_PIN + #define X_MIN_PIN X_DIAG_PIN // X-STOP + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN E0_DIAG_PIN // E0DET + #endif +#else + #define X_STOP_PIN X_DIAG_PIN // X-STOP +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN E1_DIAG_PIN // E1DET + #else + #define Y_MIN_PIN E1_DIAG_PIN // E1DET + #endif +#elif NEEDS_Y_MINMAX + #ifndef Y_MIN_PIN + #define Y_MIN_PIN Y_DIAG_PIN // Y-STOP + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN E1_DIAG_PIN // E1DET + #endif +#else + #define Y_STOP_PIN Y_DIAG_PIN // Y-STOP +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN E2_DIAG_PIN // PWRDET + #else + #define Z_MIN_PIN E2_DIAG_PIN // PWRDET + #endif +#elif NEEDS_Z_MINMAX + #ifndef Z_MIN_PIN + #define Z_MIN_PIN Z_DIAG_PIN // Z-STOP + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN E2_DIAG_PIN // PWRDET + #endif +#else + #define Z_STOP_PIN Z_DIAG_PIN // Z-STOP +#endif + +#undef NEEDS_X_MINMAX +#undef NEEDS_Y_MINMAX +#undef NEEDS_Z_MINMAX + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PG12 // E0DET +#define FIL_RUNOUT2_PIN PG13 // E1DET +#define FIL_RUNOUT3_PIN PG14 // E2DET +#define FIL_RUNOUT4_PIN PG15 // E3DET + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN PE11 // PS-ON +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC0 // PWRDET +#endif + +// +// Steppers +// +#define X_STEP_PIN PF13 // MOTOR 0 +#define X_DIR_PIN PF12 +#define X_ENABLE_PIN PF14 +#ifndef X_CS_PIN + #define X_CS_PIN PC4 +#endif + +#define Y_STEP_PIN PG0 // MOTOR 1 +#define Y_DIR_PIN PG1 +#define Y_ENABLE_PIN PF15 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD11 +#endif + +#define Z_STEP_PIN PF11 // MOTOR 2 +#define Z_DIR_PIN PG3 +#define Z_ENABLE_PIN PG5 +#ifndef Z_CS_PIN + #define Z_CS_PIN PC6 +#endif + +#define Z2_STEP_PIN PG4 // MOTOR 3 +#define Z2_DIR_PIN PC1 +#define Z2_ENABLE_PIN PA0 +#ifndef Z2_CS_PIN + #define Z2_CS_PIN PC7 +#endif + +#define E0_STEP_PIN PF9 // MOTOR 4 +#define E0_DIR_PIN PF10 +#define E0_ENABLE_PIN PG2 +#ifndef E0_CS_PIN + #define E0_CS_PIN PF2 +#endif + +#define E1_STEP_PIN PC13 // MOTOR 5 +#define E1_DIR_PIN PF0 +#define E1_ENABLE_PIN PF1 +#ifndef E1_CS_PIN + #define E1_CS_PIN PE4 +#endif + +#define E2_STEP_PIN PE2 // MOTOR 6 +#define E2_DIR_PIN PE3 +#define E2_ENABLE_PIN PD4 +#ifndef E2_CS_PIN + + #define E2_CS_PIN PE1 +#endif + +#define E3_STEP_PIN PE6 // MOTOR 7 +#define E3_DIR_PIN PA14 +#define E3_ENABLE_PIN PE0 +#ifndef E3_CS_PIN + #define E3_CS_PIN PD3 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PF3 // TB +#define TEMP_1_PIN PF5 // TH1 +#define TEMP_2_PIN PF6 // TH2 +#define TEMP_3_PIN PF7 // TH3 + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PA1 // Hotbed +#define HEATER_0_PIN PA2 // Heater0 +#define HEATER_1_PIN PA3 // Heater1 +#define HEATER_2_PIN PB10 // Heater2 +#define HEATER_3_PIN PB11 // Heater3 + +#define FAN_PIN PA8 // Fan0 +#define FAN1_PIN PE5 // Fan1 +#define FAN2_PIN PD12 // Fan2 +#define FAN3_PIN PD13 // Fan3 +#define FAN4_PIN PD14 // Fan4 +#define FAN5_PIN PD15 // Fan5 + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #if HAS_WIRED_LCD + #define SDCARD_CONNECTION LCD + #else + #define SDCARD_CONNECTION ONBOARD + #endif +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PA7 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PA6 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PA5 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN PC4 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PD11 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC6 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define Z2_SERIAL_TX_PIN PC7 + #define Z2_SERIAL_RX_PIN Z2_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PF2 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PE4 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PE1 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + #define E3_SERIAL_TX_PIN PD3 + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +/** ------ ------ + * (BEEPER) PE8 | 1 2 | PE7 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PE9 | 3 4 | PE10 (LCD_RS) (BTN_EN1) PB2 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PE12 5 6 | PE13 (LCD_D5) (BTN_EN2) PB1 5 6 | PA7 (MOSI) + * (LCD_D6) PE14 | 7 8 | PE15 (LCD_D7) (SD_DETECT) PC15 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PE8 +#define EXP1_02_PIN PE7 +#define EXP1_03_PIN PE9 +#define EXP1_04_PIN PE10 +#define EXP1_05_PIN PE12 +#define EXP1_06_PIN PE13 +#define EXP1_07_PIN PE14 +#define EXP1_08_PIN PE15 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PB1 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB2 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC15 +#define EXP2_08_PIN -1 + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT // Use SDIO for onboard SD + #ifndef SD_DETECT_STATE + #define SD_DETECT_STATE HIGH + #elif SD_DETECT_STATE == LOW + #error "BOARD_BTT_OCTOPUS_V1_0 onboard SD requires SD_DETECT_STATE set to HIGH." + #endif + #define SD_DETECT_PIN PC14 +#elif SD_CONNECTION_IS(LCD) + + #define SDSS PA4 + #define SD_SS_PIN SDSS + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_DETECT_PIN PC15 + +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" +#endif + +#if ENABLED(BTT_MOTOR_EXPANSION) + /** + * ------ ------ + * M3DIAG | 1 2 | M3RX M3STP | 1 2 | M3DIR + * M2DIAG | 3 4 | M2RX M2STP | 3 4 | M2DIR + * M1DIAG 5 6 | M1RX M1DIR 5 6 | M1STP + * M3EN | 7 8 | M2EN M1EN | 7 8 | -- + * GND | 9 10 | -- GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ + + // M1 on Driver Expansion Module + #define E4_STEP_PIN EXP2_06_PIN + #define E4_DIR_PIN EXP2_05_PIN + #define E4_ENABLE_PIN EXP2_07_PIN + #define E4_DIAG_PIN EXP1_05_PIN + #define E4_CS_PIN EXP1_06_PIN + #if HAS_TMC_UART + #define E4_SERIAL_TX_PIN EXP1_06_PIN + #define E4_SERIAL_RX_PIN E4_SERIAL_TX_PIN + #endif + + // M2 on Driver Expansion Module + #define E5_STEP_PIN EXP2_03_PIN + #define E5_DIR_PIN EXP2_04_PIN + #define E5_ENABLE_PIN EXP1_08_PIN + #define E5_DIAG_PIN EXP1_03_PIN + #define E5_CS_PIN EXP1_04_PIN + #if HAS_TMC_UART + #define E5_SERIAL_TX_PIN EXP1_04_PIN + #define E5_SERIAL_RX_PIN E5_SERIAL_TX_PIN + #endif + + // M3 on Driver Expansion Module + #define E6_STEP_PIN EXP2_01_PIN + #define E6_DIR_PIN EXP2_02_PIN + #define E6_ENABLE_PIN EXP1_07_PIN + #define E6_DIAG_PIN EXP1_01_PIN + #define E6_CS_PIN EXP1_02_PIN + #if HAS_TMC_UART + #define E6_SERIAL_TX_PIN EXP1_02_PIN + #define E6_SERIAL_RX_PIN E6_SERIAL_TX_PIN + #endif + +#endif // BTT_MOTOR_EXPANSION + +// +// LCDs and Controllers +// +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 120 + #define BOARD_ST7920_DELAY_2 80 + #define BOARD_ST7920_DELAY_3 580 +#endif + +#if HAS_SPI_TFT + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PB0 +#endif + +// +// WIFI +// + +/** + * ------- + * GND | 9 | | 8 | 3.3V + * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) + * 3.3V | 11 | | 6 | PB14 (ESP-MISO) + * (ESP-IO0) PD7 | 12 | | 5 | PB13 (ESP-CLK) + * (ESP-IO4) PD10 | 13 | | 4 | -- + * -- | 14 | | 3 | PE15 (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | -- + * (ESP-TX) PD9 | 16 | | 1 | PE14 (ESP-RST) + * ------- + * WIFI + */ +#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_RESET_PIN PG7 +#define ESP_WIFI_MODULE_ENABLE_PIN PG8 +#define ESP_WIFI_MODULE_GPIO0_PIN PD7 +#define ESP_WIFI_MODULE_GPIO4_PIN PD10 diff --git a/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h b/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h new file mode 100644 index 0000000..8a91883 --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h @@ -0,0 +1,30 @@ +/** + * 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 . + * + */ +#pragma once + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "BIGTREE SKR Pro V1.1 supports up to 3 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "BTT SKR Pro V1.1" + +#include "pins_BTT_SKR_PRO_common.h" diff --git a/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_2.h b/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_2.h new file mode 100644 index 0000000..c88483f --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_2.h @@ -0,0 +1,30 @@ +/** + * 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 . + * + */ +#pragma once + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "BIGTREE SKR Pro V1.2 supports up to 3 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "BTT SKR Pro V1.2" + +#include "pins_BTT_SKR_PRO_common.h" diff --git a/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h new file mode 100644 index 0000000..78a137b --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -0,0 +1,568 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#define USES_DIAG_JUMPERS + +// If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION +// https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT +//#define BTT_MOTOR_EXPANSION + +#if BOTH(HAS_WIRED_LCD, BTT_MOTOR_EXPANSION) + #if EITHER(CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY) + #define EXP_MOT_USE_EXP2_ONLY 1 + #else + #error "You can't use both an LCD and a Motor Expansion Module on EXP1/EXP2 at the same time." + #endif +#endif + +// Use one of these or SDCard-based Emulation will be used +#if NO_EEPROM_SELECTED + //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#endif + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support + +// +// Servos +// +#define SERVO0_PIN PA1 +#define SERVO1_PIN PC9 + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PB10 // X- +#define Y_DIAG_PIN PE12 // Y- +#define Z_DIAG_PIN PG8 // Z- +#define E0_DIAG_PIN PE15 // E0 +#define E1_DIAG_PIN PE10 // E1 +#define E2_DIAG_PIN PG5 // E2 + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN PE15 // E0 + #else + #define X_MIN_PIN PE15 // E0 + #endif +#else + #define X_MIN_PIN PB10 // X- + #define X_MAX_PIN PE15 // E0 +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN PE10 // E1 + #else + #define Y_MIN_PIN PE10 // E1 + #endif +#else + #define Y_MIN_PIN PE12 // Y- + #define Y_MAX_PIN PE10 // E1 +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN PG5 // E2 + #else + #define Z_MIN_PIN PG5 // E2 + #endif +#else + #define Z_MIN_PIN PG8 // Z- + #define Z_MAX_PIN PG5 // E2 +#endif + +// +// Z Probe must be this pin +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PA2 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PE15 +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN PE10 +#endif +#ifndef FIL_RUNOUT3_PIN + #define FIL_RUNOUT3_PIN PG5 +#endif + +// +// Steppers +// +#define X_STEP_PIN PE9 +#define X_DIR_PIN PF1 +#define X_ENABLE_PIN PF2 +#ifndef X_CS_PIN + #define X_CS_PIN PA15 +#endif + +#define Y_STEP_PIN PE11 +#define Y_DIR_PIN PE8 +#define Y_ENABLE_PIN PD7 +#ifndef Y_CS_PIN + #define Y_CS_PIN PB8 +#endif + +#define Z_STEP_PIN PE13 +#define Z_DIR_PIN PC2 +#define Z_ENABLE_PIN PC0 +#ifndef Z_CS_PIN + #define Z_CS_PIN PB9 +#endif + +#define E0_STEP_PIN PE14 +#define E0_DIR_PIN PA0 +#define E0_ENABLE_PIN PC3 +#ifndef E0_CS_PIN + #define E0_CS_PIN PB3 +#endif + +#define E1_STEP_PIN PD15 +#define E1_DIR_PIN PE7 +#define E1_ENABLE_PIN PA3 +#ifndef E1_CS_PIN + #define E1_CS_PIN PG15 +#endif + +#define E2_STEP_PIN PD13 +#define E2_DIR_PIN PG9 +#define E2_ENABLE_PIN PF0 +#ifndef E2_CS_PIN + #define E2_CS_PIN PG12 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PC12 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PC11 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PC10 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN PC13 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE1 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD4 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD1 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PD6 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// Use ADC pins without pullup for sensors that don't need a pullup. +// +#if TEMP_SENSOR_0_IS_AD8495 || TEMP_SENSOR_0 == 20 + #define TEMP_0_PIN PF8 +#else + #define TEMP_0_PIN PF4 // T1 <-> E0 +#endif +#if TEMP_SENSOR_1_IS_AD8495 || TEMP_SENSOR_1 == 20 + #define TEMP_1_PIN PF9 +#else + #define TEMP_1_PIN PF5 // T2 <-> E1 +#endif +#if TEMP_SENSOR_2_IS_AD8495 || TEMP_SENSOR_2 == 20 + #define TEMP_2_PIN PF10 +#else + #define TEMP_2_PIN PF6 // T3 <-> E2 +#endif +#if TEMP_SENSOR_BED_IS_AD8495 || TEMP_SENSOR_BED == 20 + #define TEMP_BED_PIN PF7 +#else + #define TEMP_BED_PIN PF3 // T0 <-> Bed +#endif + +#if TEMP_SENSOR_PROBE && !defined(TEMP_PROBE_PIN) + #if TEMP_SENSOR_PROBE_IS_AD8495 || TEMP_SENSOR_PROBE == 20 + #if HOTENDS == 2 + #define TEMP_PROBE_PIN PF10 + #elif HOTENDS < 2 + #define TEMP_PROBE_PIN PF9 + #endif + #else + #if HOTENDS == 2 + #define TEMP_PROBE_PIN TEMP_2_PIN + #elif HOTENDS < 2 + #define TEMP_PROBE_PIN TEMP_1_PIN + #endif + #endif +#endif + +#if TEMP_SENSOR_CHAMBER && !defined(TEMP_CHAMBER_PIN) + #if TEMP_SENSOR_CHAMBER_IS_AD8495 || TEMP_SENSOR_CHAMBER == 20 + #define TEMP_CHAMBER_PIN PF10 + #else + #define TEMP_CHAMBER_PIN TEMP_2_PIN + #endif +#endif + +// +// Heaters +// +#define HEATER_0_PIN PB1 // Heater0 +#define HEATER_1_PIN PD14 // Heater1 +#if TEMP_SENSOR_CHAMBER && HOTENDS < 3 + #define HEATER_CHAMBER_PIN PB0 // Heater2 +#else + #define HEATER_2_PIN PB0 // Heater2 +#endif +#define HEATER_BED_PIN PD12 // Hotbed + +// +// Fans +// +#define FAN_PIN PC8 // Fan0 +#define FAN1_PIN PE5 // Fan1 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN +#endif + +#if !defined(CONTROLLER_FAN_PIN) && ENABLED(USE_CONTROLLER_FAN) && HOTENDS < 2 + #define CONTROLLER_FAN_PIN PE6 // Fan2 +#else + #define FAN2_PIN PE6 // Fan2 +#endif + +// +// Misc. Functions +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +/** ------ ------ + * (BEEPER) PG4 | 1 2 | PA8 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SCK) + * (LCD_EN) PD11 | 3 4 | PD10 (LCD_RS) (BTN_EN1) PG10 | 3 4 | PB12 (SD_SS) + * (LCD_D4) PG2 5 6 | PG3 (LCD_D5) (BTN_EN2) PF11 5 6 | PB15 (MOSI) + * (LCD_D6) PG6 | 7 8 | PG7 (LCD_D7) (SD_DETECT) PF12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PG4 +#define EXP1_02_PIN PA8 +#define EXP1_03_PIN PD11 +#define EXP1_04_PIN PD10 +#define EXP1_05_PIN PG2 +#define EXP1_06_PIN PG3 +#define EXP1_07_PIN PG6 +#define EXP1_08_PIN PG7 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PG10 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PF11 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PF12 +#define EXP2_08_PIN -1 + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(LCD) + + #define SD_DETECT_PIN EXP2_07_PIN + #define SDSS EXP2_04_PIN + +#elif SD_CONNECTION_IS(ONBOARD) + + // The SKR Pro's ONBOARD SD interface is on SPI1. + // Due to a pull resistor on the clock line, it needs to use SPI Data Mode 3 to + // function with Hardware SPI. This is not currently configurable in the HAL, + // so force Software SPI to work around this issue. + #define SOFTWARE_SPI + #define SDSS PA4 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PB5 + #define SD_DETECT_PIN PB11 + +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" +#endif + +#if ENABLED(BTT_MOTOR_EXPANSION) + /** ----- ----- + * -- | . . | GND -- | . . | GND + * -- | . . | M1EN M2EN | . . | M3EN + * M1STP | . . M1DIR M1RX | . . M1DIAG + * M2DIR | . . | M2STP M2RX | . . | M2DIAG + * M3DIR | . . | M3STP M3RX | . . | M3DIAG + * ----- ----- + * EXP2 EXP1 + * + * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN + */ + + // M1 on Driver Expansion Module + #define E3_STEP_PIN EXP2_06_PIN + #define E3_DIR_PIN EXP2_05_PIN + #define E3_ENABLE_PIN EXP2_07_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E3_DIAG_PIN EXP1_05_PIN + #define E3_CS_PIN EXP1_06_PIN + #if HAS_TMC_UART + #define E3_SERIAL_TX_PIN EXP1_06_PIN + #define E3_SERIAL_RX_PIN EXP1_06_PIN + #endif + #endif + + // M2 on Driver Expansion Module + #define E4_STEP_PIN EXP2_03_PIN + #define E4_DIR_PIN EXP2_04_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E4_ENABLE_PIN EXP1_08_PIN + #define E4_DIAG_PIN EXP1_03_PIN + #define E4_CS_PIN EXP1_04_PIN + #if HAS_TMC_UART + #define E4_SERIAL_TX_PIN EXP1_04_PIN + #define E4_SERIAL_RX_PIN EXP1_04_PIN + #endif + #else + #define E4_ENABLE_PIN EXP2_07_PIN + #endif + + // M3 on Driver Expansion Module + #define E5_STEP_PIN EXP2_01_PIN + #define E5_DIR_PIN EXP2_02_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E5_ENABLE_PIN EXP1_07_PIN + #define E5_DIAG_PIN EXP1_01_PIN + #define E5_CS_PIN EXP1_02_PIN + #if HAS_TMC_UART + #define E5_SERIAL_TX_PIN EXP1_02_PIN + #define E5_SERIAL_RX_PIN EXP1_02_PIN + #endif + #else + #define E5_ENABLE_PIN EXP2_07_PIN + #endif + +#endif // BTT_MOTOR_EXPANSION + +// +// LCDs and Controllers +// +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #elif ENABLED(WYH_L12864) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! WYH_L12864 requires wiring modifications. See 'pins_BTT_SKR_PRO_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * 1. Cut the tab off the LCD connector so it can be plugged into the "EXP1" connector the other way. + * 2. Swap the LCD's +5V (Pin2) and GND (Pin1) wires. + * + * !!! If you are unsure, ask for help! Your motherboard may be damaged in some circumstances !!! + * + * The WYH_L12864 connector plug: + * + * BEFORE AFTER + * ------ ------ + * -- | 1 2 | MOSI -- | 1 2 | MOSI + * BTN_ENC | 3 4 | SCK BTN_ENC | 3 4 | SCK + * BTN_EN1 | 5 6 SID BTN_EN1 | 5 6 SID + * BTN_EN2 | 7 8 | CS BTN_EN2 | 7 8 | CS + * 5V | 9 10 | GND GND | 9 10 | 5V + * ------ ------ + * LCD LCD + */ + #undef BEEPER_PIN + #undef BTN_ENC + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_04_PIN + #define DOGLCD_MOSI EXP1_02_PIN + #define LCD_BACKLIGHT_PIN -1 + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif + +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 125 + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 90 + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 600 + #endif +#endif + +// +// WIFI +// + +/** + * ------ + * RX | 8 7 | 3.3V GPIO0 PF14 ... Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) + * GPIO0 | 6 5 | Reset GPIO2 PF15 ... must be high (ESP3D software configures this with a pullup so OK to leave as floating) + * GPIO2 | 4 3 | Enable Reset PG0 ... active low, probably OK to leave floating + * GND | 2 1 | TX Enable PG1 ... Must be high for module to run + * ------ + * W1 + */ +#define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_RESET_PIN PG0 +#define ESP_WIFI_MODULE_ENABLE_PIN PG1 +#define ESP_WIFI_MODULE_GPIO0_PIN PF14 +#define ESP_WIFI_MODULE_GPIO2_PIN PF15 diff --git a/src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_A.h b/src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_A.h new file mode 100644 index 0000000..be9580e --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_A.h @@ -0,0 +1,29 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT SKR V2 Rev.A" + +#error "SKR V2 Rev.A requires modification or drivers may be damaged. See https://bit.ly/3t5d9JQ for more information. Comment out this line to continue." +#define DISABLE_DRIVER_SAFE_POWER_PROTECT + +#include "pins_BTT_SKR_V2_0_common.h" diff --git a/src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_B.h b/src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_B.h new file mode 100644 index 0000000..b83f41b --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_SKR_V2_0_REV_B.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT SKR V2 Rev.B" + +#include "pins_BTT_SKR_V2_0_common.h" diff --git a/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h b/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h new file mode 100644 index 0000000..7ac9156 --- /dev/null +++ b/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h @@ -0,0 +1,580 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#define USES_DIAG_JUMPERS + +// If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION +// https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT +//#define BTT_MOTOR_EXPANSION + +#if BOTH(HAS_WIRED_LCD, BTT_MOTOR_EXPANSION) + #if EITHER(CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY) + #define EXP_MOT_USE_EXP2_ONLY 1 + #else + #error "You can't use both an LCD and a Motor Expansion Module on EXP1/EXP2 at the same time." + #endif +#endif + +// Use one of these or SDCard-based Emulation will be used +#if NO_EEPROM_SELECTED + //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#endif + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support + +// Avoid conflict with TIMER_TONE +#define STEP_TIMER 10 + +// +// Servos +// +#define SERVO0_PIN PE5 + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PC1 // X-STOP +#define Y_DIAG_PIN PC3 // Y-STOP +#define Z_DIAG_PIN PC0 // Z-STOP +#define E0_DIAG_PIN PC2 // E0DET +#define E1_DIAG_PIN PA0 // E1DET + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN PC2 // E0DET + #else + #define X_MIN_PIN PC2 // E0DET + #endif +#elif ENABLED(X_DUAL_ENDSTOPS) + #ifndef X_MIN_PIN + #define X_MIN_PIN PC1 // X-STOP + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN PC2 // E0DET + #endif +#else + #define X_STOP_PIN PC1 // X-STOP +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN PA0 // E1DET + #else + #define Y_MIN_PIN PA0 // E1DET + #endif +#elif ENABLED(Y_DUAL_ENDSTOPS) + #ifndef Y_MIN_PIN + #define Y_MIN_PIN PC3 // Y-STOP + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN PA0 // E1DET + #endif +#else + #define Y_STOP_PIN PC3 // Y-STOP +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN PC15 // PWRDET + #else + #define Z_MIN_PIN PC15 // PWRDET + #endif +#elif ENABLED(Z_MULTI_ENDSTOPS) + #ifndef Z_MIN_PIN + #define Z_MIN_PIN PC0 // Z-STOP + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN PC15 // PWRDET + #endif +#else + #ifndef Z_STOP_PIN + #define Z_STOP_PIN PC0 // Z-STOP + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PE4 +#endif + +// +// Probe enable +// +#if ENABLED(PROBE_ENABLE_DISABLE) + #ifndef PROBE_ENABLE_PIN + #define PROBE_ENABLE_PIN SERVO0_PIN + #endif +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PC2 // E0DET +#define FIL_RUNOUT2_PIN PA0 // E1DET + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN PE8 // PS-ON +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC15 // PWRDET +#endif + +// +// Control pin of driver/heater/fan power supply +// +#define SAFE_POWER_PIN PC13 + +// +// Steppers +// +#define X_STEP_PIN PE2 +#define X_DIR_PIN PE1 +#define X_ENABLE_PIN PE3 +#ifndef X_CS_PIN + #define X_CS_PIN PE0 +#endif + +#define Y_STEP_PIN PD5 +#define Y_DIR_PIN PD4 +#define Y_ENABLE_PIN PD6 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD3 +#endif + +#define Z_STEP_PIN PA15 +#define Z_DIR_PIN PA8 +#define Z_ENABLE_PIN PD1 +#ifndef Z_CS_PIN + #define Z_CS_PIN PD0 +#endif + +#ifndef E0_STEP_PIN + #define E0_STEP_PIN PD15 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN PD14 +#endif +#ifndef E0_ENABLE_PIN + #define E0_ENABLE_PIN PC7 +#endif +#ifndef E0_CS_PIN + #define E0_CS_PIN PC6 +#endif + +#ifndef E1_STEP_PIN + #define E1_STEP_PIN PD11 +#endif +#ifndef E1_DIR_PIN + #define E1_DIR_PIN PD10 +#endif +#ifndef E1_ENABLE_PIN + #define E1_ENABLE_PIN PD13 +#endif +#ifndef E1_CS_PIN + #define E1_CS_PIN PD12 +#endif + +// +// Temperature Sensors +// +#ifndef TEMP_0_PIN + #define TEMP_0_PIN PA2 // TH0 +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN PA3 // TH1 +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN PA1 // TB +#endif + +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif +#endif + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PB3 // Heater0 +#endif +#ifndef HEATER_1_PIN + #define HEATER_1_PIN PB4 // Heater1 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PD7 // Hotbed +#endif +#ifndef FAN_PIN + #define FAN_PIN PB7 // Fan0 +#endif + +#if HAS_CUTTER + #ifndef SPINDLE_LASER_PWM_PIN + #define SPINDLE_LASER_PWM_PIN PB5 + #endif + #ifndef SPINDLE_LASER_ENA_PIN + #define SPINDLE_LASER_ENA_PIN PB6 + #endif +#else + #ifndef FAN1_PIN + #define FAN1_PIN PB6 // Fan1 + #endif + #ifndef FAN2_PIN + #define FAN2_PIN PB5 // Fan2 + #endif +#endif // SPINDLE_FEATURE || LASER_FEATURE + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PE14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PA14 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PE15 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + // + // Software serial + // + #define X_SERIAL_TX_PIN PE0 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PD3 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PD0 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PC6 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD12 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// SD Connection +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +/** + * ------ ------ + * (BEEPER) PC5 | 1 2 | PB0 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PB1 | 3 4 | PE9 (LCD_RS) (BTN_EN1) PE7 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PE10 | 5 6 PE11 (LCD_D5) (BTN_EN2) PB2 | 5 6 PA7 (MOSI) + * (LCD_D6) PE12 | 7 8 | PE13 (LCD_D7) (SD_DETECT) PC4 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PB1 +#define EXP1_04_PIN PE9 +#define EXP1_05_PIN PE10 +#define EXP1_06_PIN PE11 +#define EXP1_07_PIN PE12 +#define EXP1_08_PIN PE13 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE7 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB2 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC4 +#define EXP2_08_PIN -1 + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(LCD) + #define SDSS EXP2_04_PIN + #define SD_SS_PIN SDSS + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN +#elif SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT // Use SDIO for onboard SD +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +#if ENABLED(BTT_MOTOR_EXPANSION) + /** ----- ----- + * -- | . . | GND -- | . . | GND + * -- | . . | M1EN M2EN | . . | M3EN + * M1STP | . . M1DIR M1RX | . . M1DIAG + * M2DIR | . . | M2STP M2RX | . . | M2DIAG + * M3DIR | . . | M3STP M3RX | . . | M3DIAG + * ----- ----- + * EXP2 EXP1 + * + * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN + */ + + // M1 on Driver Expansion Module + #define E2_STEP_PIN EXP2_06_PIN + #define E2_DIR_PIN EXP2_05_PIN + #define E2_ENABLE_PIN EXP2_07_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E2_DIAG_PIN EXP1_05_PIN + #define E2_CS_PIN EXP1_06_PIN + #if HAS_TMC_UART + #define E2_SERIAL_TX_PIN EXP1_06_PIN + #define E2_SERIAL_RX_PIN EXP1_06_PIN + #endif + #endif + + // M2 on Driver Expansion Module + #define E3_STEP_PIN EXP2_03_PIN + #define E3_DIR_PIN EXP2_04_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E3_ENABLE_PIN EXP1_08_PIN + #define E3_DIAG_PIN EXP1_03_PIN + #define E3_CS_PIN EXP1_04_PIN + #if HAS_TMC_UART + #define E3_SERIAL_TX_PIN EXP1_04_PIN + #define E3_SERIAL_RX_PIN EXP1_04_PIN + #endif + #else + #define E3_ENABLE_PIN EXP2_07_PIN + #endif + + // M3 on Driver Expansion Module + #define E4_STEP_PIN EXP2_01_PIN + #define E4_DIR_PIN EXP2_02_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E4_ENABLE_PIN EXP1_07_PIN + #define E4_DIAG_PIN EXP1_01_PIN + #define E4_CS_PIN EXP1_02_PIN + #if HAS_TMC_UART + #define E4_SERIAL_TX_PIN EXP1_02_PIN + #define E4_SERIAL_RX_PIN EXP1_02_PIN + #endif + #else + #define E4_ENABLE_PIN EXP2_07_PIN + #endif + +#endif // BTT_MOTOR_EXPANSION + +// +// LCDs and Controllers +// +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif + +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 120 + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 80 + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 580 + #endif +#endif + +#if HAS_SPI_TFT + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN + + // + // e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE) + // + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PE6 +#endif + +// +// WIFI +// + +/** + * ------- + * GND | 9 | | 8 | 3.3V + * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) + * 3.3V | 11 | | 6 | PB14 (ESP-MISO) + * (ESP-IO0) PB10 | 12 | | 5 | PB13 (ESP-CLK) + * (ESP-IO4) PB11 | 13 | | 4 | -- + * -- | 14 | | 3 | 3.3V (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | -- + * (ESP-TX) PD9 | 16 | | 1 | PC14 (ESP-RST) + * ------- + * WIFI + */ +#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_RESET_PIN PC14 +#define ESP_WIFI_MODULE_GPIO0_PIN PB10 +#define ESP_WIFI_MODULE_GPIO4_PIN PB11 diff --git a/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h b/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h new file mode 100644 index 0000000..883640d --- /dev/null +++ b/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h @@ -0,0 +1,38 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Creality V24S1_301F4 (STM32F401RC) board pin assignments as found on Ender 3 S1. + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Creality V24S1-301F4" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "Ender-3 S1 F4" +#endif + +#define DISABLE_DEBUG false // DISABLE_(DEBUG|JTAG) is not supported for STM32F4. +#define ALLOW_STM32F4 + +#include "../stm32f1/pins_CREALITY_V24S1_301.h" diff --git a/src/pins/stm32f4/pins_FLYF407ZG.h b/src/pins/stm32f4/pins_FLYF407ZG.h new file mode 100644 index 0000000..8d5e094 --- /dev/null +++ b/src/pins/stm32f4/pins_FLYF407ZG.h @@ -0,0 +1,312 @@ +/** + * 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 . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 6 || E_STEPPERS > 6 + #error "FLYF407ZG supports up to 6 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "FLYF407ZG" +#define BOARD_WEBSITE_URL "github.com/FLYmaker/FLYF407ZG" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// Avoid conflict with fans and TIMER_TONE +#define TEMP_TIMER 3 +#define STEP_TIMER 5 + +// +// EEPROM Emulation +// +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + //#define SRAM_EEPROM_EMULATION + //#define I2C_EEPROM +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across + // the 128kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#elif ENABLED(I2C_EEPROM) + #define MARLIN_EEPROM_SIZE 0x2000 // 8K +#endif + +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Servos +// +#define SERVO0_PIN PE11 + +// +// Limit Switches +// +#define X_MIN_PIN PC3 +#define X_MAX_PIN PC2 +#define Y_MIN_PIN PF2 +#define Y_MAX_PIN PF1 +#define Z_MIN_PIN PF0 +#define Z_MAX_PIN PC15 + +// +// Z Probe (when not Z_MIN_PIN) +// +#define Z_MIN_PROBE_PIN PC14 // Z3_PIN + +// +// Steppers +// + +#define X_STEP_PIN PB9 +#define X_DIR_PIN PE0 +#define X_ENABLE_PIN PE1 +#ifndef X_CS_PIN + #define X_CS_PIN PG13 +#endif + +#define Y_STEP_PIN PB8 +#define Y_DIR_PIN PG11 +#define Y_ENABLE_PIN PG12 +#ifndef Y_CS_PIN + #define Y_CS_PIN PG10 +#endif + +#define Z_STEP_PIN PA8 +#define Z_DIR_PIN PD6 +#define Z_ENABLE_PIN PD7 +#ifndef Z_CS_PIN + #define Z_CS_PIN PD5 +#endif + +#define E0_STEP_PIN PC7 +#define E0_DIR_PIN PD3 +#define E0_ENABLE_PIN PD4 +#ifndef E0_CS_PIN + #define E0_CS_PIN PD1 +#endif + +#define E1_STEP_PIN PC6 +#define E1_DIR_PIN PA15 +#define E1_ENABLE_PIN PD0 +#ifndef E1_CS_PIN + #define E1_CS_PIN PA14 +#endif + +#define E2_STEP_PIN PD15 +#define E2_DIR_PIN PG7 +#define E2_ENABLE_PIN PG8 +#ifndef E2_CS_PIN + #define E2_CS_PIN PG6 +#endif + +#define E3_STEP_PIN PD14 +#define E3_DIR_PIN PG4 +#define E3_ENABLE_PIN PG5 +#ifndef E3_CS_PIN + #define E3_CS_PIN PG3 +#endif + +#define E4_STEP_PIN PD13 +#define E4_DIR_PIN PD11 +#define E4_ENABLE_PIN PG2 +#ifndef E4_CS_PIN + #define E4_CS_PIN PD10 +#endif + +#define E5_STEP_PIN PD12 +#define E5_DIR_PIN PD8 +#define E5_ENABLE_PIN PD9 +#ifndef E5_CS_PIN + #define E5_CS_PIN PB12 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input +#define TEMP_1_PIN PC1 // Analog Input +#define TEMP_2_PIN PC0 // Analog Input +#define TEMP_3_PIN PF10 // Analog Input +#define TEMP_4_PIN PF5 // Analog Input +#define TEMP_5_PIN PF4 // Analog Input +#define TEMP_BED_PIN PF3 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN PF7 +#define HEATER_1_PIN PF6 +#define HEATER_2_PIN PE6 +#define HEATER_3_PIN PE5 +#define HEATER_4_PIN PE4 +#define HEATER_5_PIN PE3 +#define HEATER_BED_PIN PE2 + +#ifndef FAN_PIN + #define FAN_PIN PF8 +#endif +#define FAN1_PIN PF9 +#define FAN2_PIN PA2 +#define FAN3_PIN PA1 +#define FAN4_PIN PE13 +#define FAN5_PIN PB11 + +/** + * ------ ------ + * PB10 | 1 2 | PE15 PB14 | 1 2 | PB13 + * PE14 | 3 4 | PE12 PC5 | 3 4 | PF11 + * PE10 5 6 | PE9 PC4 5 6 | PB15 + * PE8 | 7 8 | PE7 PB2 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PB10 +#define EXP1_02_PIN PE15 +#define EXP1_03_PIN PE14 +#define EXP1_04_PIN PE12 +#define EXP1_05_PIN PE10 +#define EXP1_06_PIN PE9 +#define EXP1_07_PIN PE8 +#define EXP1_08_PIN PE7 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PC5 +#define EXP2_04_PIN PF11 +#define EXP2_05_PIN PC4 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PB2 +#define EXP2_08_PIN -1 // RESET + +// +// Onboard SD support +// +//#define SD_CARD_DETECT_PIN PC13 + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + + #define SDIO_SUPPORT // Use SDIO for onboard SD + + #if DISABLED(SDIO_SUPPORT) + #define SOFTWARE_SPI // Use soft SPI for onboard SD + #define SDSS PC11 + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #endif + +#elif SD_CONNECTION_IS(LCD) + + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN + +#endif + +// +// Trinamic Software SPI +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_SCK + #define TMC_SW_SCK EXP2_02_PIN + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO EXP2_01_PIN + #endif + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI EXP2_06_PIN + #endif +#endif + +// +// Trinamic Software Serial +// + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PG13 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PG10 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PD5 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD1 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PA14 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PG6 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + #define E3_SERIAL_TX_PIN PG3 + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + #define E4_SERIAL_TX_PIN PD10 + #define E4_SERIAL_RX_PIN E4_SERIAL_TX_PIN + + #define E5_SERIAL_TX_PIN PB12 + #define E5_SERIAL_RX_PIN E5_SERIAL_TX_PIN +#endif + +// +// LCD / Controller +// +#if IS_RRD_SC + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN +#endif + +// +// Filament runout +// + +#define FIL_RUNOUT_PIN PA3 + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 715 +#endif diff --git a/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h b/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h new file mode 100644 index 0000000..32ec518 --- /dev/null +++ b/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h @@ -0,0 +1,259 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#define DEFAULT_MACHINE_NAME "3D Printer" + +#define BOARD_INFO_NAME "FYSETC Cheetah V2.0" +#define BOARD_WEBSITE_URL "fysetc.com" + +// USB Flash Drive support +//#define HAS_OTG_USB_HOST_SUPPORT + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define FLASH_EEPROM_LEVELING + + #define FLASH_SECTOR 1 + #define FLASH_UNIT_SIZE 0x4000 // 16k + #define FLASH_ADDRESS_START 0x8004000 +#endif + +// +// Z Probe +// +#if ENABLED(BLTOUCH) + #error "You need to set jumper to 5v for Bltouch, then comment out this line to proceed." + #define SERVO0_PIN PA0 +#elif !defined(Z_MIN_PROBE_PIN) + #define Z_MIN_PROBE_PIN PA0 +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PB4 +#define Y_STOP_PIN PC8 +#define Z_STOP_PIN PB1 + +// +// Filament runout +// +#define FIL_RUNOUT_PIN PB5 + +// +// Steppers +// +#define X_STEP_PIN PC0 +#define X_DIR_PIN PC1 +#define X_ENABLE_PIN PA8 + +#define Y_STEP_PIN PC14 +#define Y_DIR_PIN PC13 +#define Y_ENABLE_PIN PC15 + +#define Z_STEP_PIN PB9 +#define Z_DIR_PIN PB8 +#define Z_ENABLE_PIN PC2 + +#define E0_STEP_PIN PB2 +#define E0_DIR_PIN PA15 +#define E0_ENABLE_PIN PD2 + +#if HAS_TMC_UART + #define X_HARDWARE_SERIAL Serial2 + #define Y_HARDWARE_SERIAL Serial2 + #define Z_HARDWARE_SERIAL Serial2 + #define E0_HARDWARE_SERIAL Serial2 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC6 +#define HEATER_BED_PIN PC7 +#ifndef FAN_PIN + #define FAN_PIN PA14 +#endif +#define FAN1_PIN PA13 +#define FAN2_PIN PA1 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PC5 // Analog Input +#define TEMP_0_PIN PC4 // Analog Input + +// +// Misc. Functions +// +#define SDSS PA4 +#define SD_DETECT_PIN PC3 + +#ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB0 +#endif +#ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB7 +#endif +#ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB6 +#endif + +/** + * ------ ------ + * (SD_MISO) PA6 | 1 2 | PA5 (SD_SCK) (BEEPER) PC9 | 1 2 | PC12 (BTN_ENC) + * (BTN_EN1) PC10 | 3 4 | PA4 (SD_SS) (LCD_EN) PB15 | 3 4 | PB12 (LCD_RS) + * (BTN_EN2) PC11 5 6 | PA7 (SD_MOSI) (LCD_D4) PB13 5 6 | PB14 (LCD_D5) + * (SD_DETECT) PC3 | 7 8 | RESET (LCD_D6) PB6 | 7 8 | PB7 (LCD_D7) + * GND | 9 10 | 5V GND | 9 10 | 5V + * ------ ------ + * EXP2 EXP1 + */ + +/** + * ------ + * 5V | 1 2 | GND + * (LCD_EN/MOSI) PB15 | 3 4 | PB12 (LCD_RS) + * (LCD_D4/SCK) PB13 5 6 | PC11 (BTN_EN2) + * (LCD_D5/MISO) PB14 | 7 8 | PC10 (BTN_EN1) + * (BTN_ENC) PC12 | 9 10 | PC9 (BEEPER) + * ------ + * EXP3 + */ + +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PC12 +#define EXP1_03_PIN PB15 +#define EXP1_04_PIN PB12 +#define EXP1_05_PIN PB13 +#define EXP1_06_PIN PB14 +#define EXP1_07_PIN PB6 +#define EXP1_08_PIN PB7 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PC10 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PC11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC3 +#define EXP2_08_PIN -1 + +#if HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif + +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 600 +#endif + +#if ENABLED(TOUCH_UI_FTDI_EVE) + #define BEEPER_PIN EXP1_01_PIN + #define CLCD_MOD_RESET EXP2_03_PIN + #define CLCD_SPI_CS EXP2_05_PIN +#endif diff --git a/src/pins/stm32f4/pins_FYSETC_S6.h b/src/pins/stm32f4/pins_FYSETC_S6.h new file mode 100644 index 0000000..fca181c --- /dev/null +++ b/src/pins/stm32f4/pins_FYSETC_S6.h @@ -0,0 +1,340 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "FYSETC S6 supports up to 3 hotends / E steppers." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "FYSETC S6" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#endif + +// Avoid conflict with TIMER_TONE defined in variant +#define STEP_TIMER 10 + +// +// EEPROM Emulation +// +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + //#define I2C_EEPROM +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#elif ENABLED(I2C_EEPROM) + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Servos +// +#ifndef SERVO0_PIN + #define SERVO0_PIN PA3 +#endif + +// +// Limit Switches +// +#define X_MIN_PIN PB14 +#define X_MAX_PIN PA1 +#define Y_MIN_PIN PB13 +#define Y_MAX_PIN PA2 +#define Z_MIN_PIN PA0 +#define Z_MAX_PIN PA3 + +// +// Filament Sensor +// share with X_MAX_PIN +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA1 +#endif + +// +// Steppers +// +#define X_STEP_PIN PE11 +#define X_DIR_PIN PE10 +#ifndef X_ENABLE_PIN + #define X_ENABLE_PIN PE12 +#endif +#define X_CS_PIN PE7 + +#define Y_STEP_PIN PD8 +#define Y_DIR_PIN PB12 +#define Y_ENABLE_PIN PD9 +#define Y_CS_PIN PE15 + +#define Z_STEP_PIN PD14 +#define Z_DIR_PIN PD13 +#define Z_ENABLE_PIN PD15 +#define Z_CS_PIN PD10 + +#define E0_STEP_PIN PD5 +#define E0_DIR_PIN PD6 +#define E0_ENABLE_PIN PD4 +#define E0_CS_PIN PD7 + +#define E1_STEP_PIN PE6 +#define E1_DIR_PIN PC13 +#define E1_ENABLE_PIN PE5 +#define E1_CS_PIN PC14 + +#define E2_STEP_PIN PE2 +#define E2_DIR_PIN PE4 +#define E2_ENABLE_PIN PE3 +#define E2_CS_PIN PC15 + +#if HAS_TMC_UART + // + // TMC2208/TMC2209 stepper drivers + // + + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN PE9 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN PE8 + #endif + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN PE14 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN PE13 + #endif + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN PD11 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN PD12 + #endif + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN PD3 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN PA15 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN PC4 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN PC5 + #endif + #ifndef E2_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN PE1 + #endif + #ifndef E2_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN PE0 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC0 +#define TEMP_1_PIN PC1 +#define TEMP_2_PIN PC2 +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN PC3 +#endif + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PB3 +#endif +#ifndef HEATER_1_PIN + #define HEATER_1_PIN PB4 +#endif +#ifndef HEATER_2_PIN + #define HEATER_2_PIN PB15 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PC8 +#endif + +#ifndef FAN_PIN + #define FAN_PIN PB0 +#endif +#ifndef FAN1_PIN + #define FAN1_PIN PB1 +#endif +#define FAN2_PIN PB2 + +// +// Misc. Functions +// +//#define LED_PIN PB14 +//#define PS_ON_PIN PE11 +//#define KILL_PIN PC5 + +/** + * ------ ------ + * PC9 | 1 2 | PA8 PA6 | 1 2 | PA5 + * PC11 | 3 4 | PD2 PC6 | 3 4 | PA4 + * PC10 5 6 | PC12 PC7 5 6 | PA7 + * PD0 | 7 8 | PD1 PB10 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PA8 +#define EXP1_03_PIN PC11 +#define EXP1_04_PIN PD2 +#define EXP1_05_PIN PC10 +#define EXP1_06_PIN PC12 +#define EXP1_07_PIN PD0 +#define EXP1_08_PIN PD1 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PC6 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PC7 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PB10 +#define EXP2_08_PIN -1 // RESET + +// +// SPI / SD Card +// +#define SD_SCK_PIN EXP2_02_PIN +#define SD_MISO_PIN EXP2_01_PIN +#define SD_MOSI_PIN EXP2_06_PIN + +#define SDSS EXP2_04_PIN +#define SD_DETECT_PIN EXP2_07_PIN + +// +// LCD / Controller +// +#if ENABLED(FYSETC_242_OLED_12864) + + #define BTN_EN1 EXP1_01_PIN + #define BTN_EN2 EXP1_08_PIN + #define BTN_ENC EXP1_02_PIN + + #define BEEPER_PIN EXP2_03_PIN + + #define LCD_PINS_DC EXP1_06_PIN + #define LCD_PINS_RS EXP2_05_PIN // LCD_RST + #define DOGLCD_CS EXP1_04_PIN + #define DOGLCD_MOSI EXP1_05_PIN + #define DOGLCD_SCK EXP1_03_PIN + #define DOGLCD_A0 LCD_PINS_DC + #define FORCE_SOFT_SPI + + #define KILL_PIN -1 // NC + #define NEOPIXEL_PIN EXP1_07_PIN + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_SDSS EXP2_04_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + // See https://wiki.fysetc.com/Mini12864_Panel + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #if ENABLED(FYSETC_GENERIC_12864_1_1) + #define LCD_BACKLIGHT_PIN EXP1_07_PIN + #endif + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + + #endif + +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 640 +#endif + +#ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB6 +#endif +#ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB5 +#endif +#ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB7 +#endif +#ifndef RGB_LED_W_PIN + #define RGB_LED_W_PIN -1 +#endif diff --git a/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h b/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h new file mode 100644 index 0000000..a9ce138 --- /dev/null +++ b/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h @@ -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 . + * + */ +#pragma once + +#define BOARD_INFO_NAME "FYSETC S6 2.0" + +// +// EEPROM Emulation +// +#if NO_EEPROM_SELECTED + #undef NO_EEPROM_SELECTED + //#define FLASH_EEPROM_EMULATION + #define I2C_EEPROM +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PE9 + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PE8 + #define X_SERIAL_RX_PIN PE8 + #define Y_SERIAL_TX_PIN PC4 + #define Y_SERIAL_RX_PIN PC4 + #define Z_SERIAL_TX_PIN PD12 + #define Z_SERIAL_RX_PIN PD12 + #define E0_SERIAL_TX_PIN PA15 + #define E0_SERIAL_RX_PIN PA15 + #define E1_SERIAL_TX_PIN PC5 + #define E1_SERIAL_RX_PIN PC5 + #define E2_SERIAL_TX_PIN PE0 + #define E2_SERIAL_RX_PIN PE0 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#define TMC_USE_SW_SPI +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PE14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PE13 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PE12 + #endif +#endif + +#include "pins_FYSETC_S6.h" diff --git a/src/pins/stm32f4/pins_FYSETC_SPIDER.h b/src/pins/stm32f4/pins_FYSETC_SPIDER.h new file mode 100644 index 0000000..009bfb2 --- /dev/null +++ b/src/pins/stm32f4/pins_FYSETC_SPIDER.h @@ -0,0 +1,123 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "FYSETC SPIDER" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#endif + +// +// EEPROM Emulation +// +#if NO_EEPROM_SELECTED + #undef NO_EEPROM_SELECTED + //#define FLASH_EEPROM_EMULATION + //#define SRAM_EEPROM_EMULATION + #define I2C_EEPROM +#endif + +#if ENABLED(I2C_EEPROM) + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Steppers +// +#define X2_STEP_PIN PD12 +#define X2_DIR_PIN PC4 +#define X2_ENABLE_PIN PE8 +#define X2_CS_PIN PA15 + +#define Z2_STEP_PIN PE1 +#define Z2_DIR_PIN PE0 +#define Z2_ENABLE_PIN PC5 +#define Z2_CS_PIN PD11 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB15 +#define HEATER_1_PIN PC8 +#define HEATER_2_PIN PB3 +#define HEATER_BED_PIN PB4 + +// +// Steppers +// +#define X_ENABLE_PIN PE9 + +// +// Servos +// Z_MAX_PIN only works in input mode +// +#define SERVO0_PIN PA2 + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PE7 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define X2_SERIAL_TX_PIN PA15 + #define X2_SERIAL_RX_PIN X2_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PE15 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PD10 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define Z2_SERIAL_TX_PIN PD11 + #define Z2_SERIAL_RX_PIN Z2_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD7 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PC14 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PC15 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#define TMC_USE_SW_SPI +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PE14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PE13 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PE12 + #endif +#endif + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "FYSETC SPIDER supports up to 3 hotends / E steppers." +#else + #include "pins_FYSETC_S6.h" +#endif diff --git a/src/pins/stm32f4/pins_FYSETC_SPIDER_V2_2.h b/src/pins/stm32f4/pins_FYSETC_SPIDER_V2_2.h new file mode 100644 index 0000000..50a19fa --- /dev/null +++ b/src/pins/stm32f4/pins_FYSETC_SPIDER_V2_2.h @@ -0,0 +1,34 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "FYSETC SPIDER V22" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +#define TEMP_3_PIN PC3 +#define TEMP_4_PIN PB1 +#define TEMP_BED_PIN PB0 + +#define FAN_PIN PA13 +#define FAN1_PIN PA14 + +#include "pins_FYSETC_SPIDER.h" diff --git a/src/pins/stm32f4/pins_LERDGE_K.h b/src/pins/stm32f4/pins_LERDGE_K.h new file mode 100644 index 0000000..6c6f8d2 --- /dev/null +++ b/src/pins/stm32f4/pins_LERDGE_K.h @@ -0,0 +1,272 @@ +/** + * 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 . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "LERDGE K supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Lerdge K" +#define DEFAULT_MACHINE_NAME "LERDGE" + +// EEPROM +#if NO_EEPROM_SELECTED + #define I2C_EEPROM + #define SOFT_I2C_EEPROM // Force the use of Software I2C + #define I2C_SCL_PIN PG14 + #define I2C_SDA_PIN PG13 + #define MARLIN_EEPROM_SIZE 0x10000 +#endif + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support + +// +// Servos +// +#define SERVO0_PIN PB11 + +// +// Limit Switches +// +#define X_STOP_PIN PG3 +#define Y_STOP_PIN PG4 +#define Z_STOP_PIN PG5 + +// +// Z Probe (when not Z_MIN_PIN) +// +//#ifndef Z_MIN_PROBE_PIN +// #define Z_MIN_PROBE_PIN PG6 +//#endif + +// +// Filament runout +// +#define FIL_RUNOUT_PIN PE5 +#define FIL_RUNOUT2_PIN PE6 + +// +// Steppers +// +#define X_STEP_PIN PG1 +#define X_DIR_PIN PB10 +#define X_ENABLE_PIN PG0 +//#ifndef X_CS_PIN +// #define X_CS_PIN PB2 +//#endif + +#define Y_STEP_PIN PF14 +#define Y_DIR_PIN PF15 +#define Y_ENABLE_PIN PF13 +//#ifndef Y_CS_PIN +// #define Y_CS_PIN PE2 +//#endif + +#define Z_STEP_PIN PF11 +#define Z_DIR_PIN PF12 +#define Z_ENABLE_PIN PC5 +//#ifndef Z_CS_PIN +// #define Z_CS_PIN PE3 +//#endif + +#define E0_STEP_PIN PC14 +#define E0_DIR_PIN PC13 +#define E0_ENABLE_PIN PC15 +//#ifndef E0_CS_PIN +// #define E0_CS_PIN PE4 +//#endif + +#define E1_STEP_PIN PF1 +#define E1_DIR_PIN PF0 +#define E1_ENABLE_PIN PF2 +//#ifndef E1_CS_PIN +// #define E1_CS_PIN PE1 +//#endif + +//#define Z2_STEP_PIN PF4 +//#define Z2_DIR_PIN PF3 +//#define Z2_ENABLE_PIN PF5 +//#define Z2_STOP_PIN PG2 +//#ifndef Z2_CS_PIN +// #define Z2_CS_PIN PE0 +//#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + */ + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN PB2 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + #endif + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN PE2 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + #endif + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN PE3 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + #endif + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN PE4 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN PE1 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + #endif + // Ex-motor can be any... X2/Y2/Z2 or E2 + #ifndef EX_SERIAL_TX_PIN + #define EX_SERIAL_TX_PIN PE0 + #endif + #ifndef EX_SERIAL_RX_PIN + #define EX_SERIAL_RX_PIN EX_SERIAL_TX_PIN + #endif + //#define Z2_SERIAL_RX_PIN EX_SERIAL_RX_PIN + //#define Z2_SERIAL_TX_PIN EX_SERIAL_TX_PIN + //#define E2_SERIAL_RX_PIN EX_SERIAL_RX_PIN + //#define E2_SERIAL_TX_PIN EX_SERIAL_TX_PIN + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // Analog Input +#define TEMP_1_PIN PC2 // Analog Input +#define TEMP_BED_PIN PC0 // Analog Input + +// Lergde-K can choose thermocouple/thermistor mode in software. +// For use with thermistors, these pins must be OUT/LOW. +// This is done automatically. +#define TEMP_0_TR_ENABLE_PIN PF10 +#define TEMP_1_TR_ENABLE_PIN PF9 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA1 +#define HEATER_1_PIN PA0 +#define HEATER_BED_PIN PA2 + +#ifndef FAN_PIN + #define FAN_PIN PF7 +#endif + +#define FAN1_PIN PF6 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PB1 +#endif + +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN PB0 +#endif + +#define CONTROLLER_FAN_PIN PF8 + +// +// LED / Lighting +// +#define LED_PIN PA15 // Status LED +//#define CASE_LIGHT_PIN PB6 // LED Ribbon Connector (PWM TIM4_CH1) +//#define NEOPIXEL_PIN -1 +#ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB8 // swap R and G pin for compatibility with real wires +#endif +#ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB7 +#endif +#ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB9 +#endif + +// +// SD support +// +#define SDIO_SUPPORT +#define SDIO_CLOCK 4800000 +#define SD_DETECT_PIN PA8 +#if DISABLED(SDIO_SUPPORT) + #define SOFTWARE_SPI + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #define SD_SS_PIN PC11 + #define SDSS PC11 +#endif + +// +// Misc. Functions +// +#define PS_ON_PIN PA4 +#define KILL_PIN -1 +#define POWER_LOSS_PIN PA4 // Power-loss / nAC_FAULT + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #ifndef TFT_DRIVER + #define TFT_DRIVER ST7796 + #endif + #define ST7796S_INVERTED + + #define TFT_RESET_PIN PD6 + #define TFT_BACKLIGHT_PIN PD3 + + #define FSMC_CS_PIN PD7 + #define FSMC_RS_PIN PD11 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define TOUCH_CS_PIN PG15 + #define TOUCH_SCK_PIN PB3 + #define TOUCH_MOSI_PIN PB5 + #define TOUCH_MISO_PIN PB4 + #define TOUCH_INT_PIN PG12 +#endif + +#if IS_NEWPANEL + #define BEEPER_PIN PC7 + #define BTN_EN1 PG11 + #define BTN_EN2 PG10 + #define BTN_ENC PG9 + #ifndef ENCODER_STEPS_PER_MENU_ITEM + #define ENCODER_STEPS_PER_MENU_ITEM 2 + #endif +#endif diff --git a/src/pins/stm32f4/pins_LERDGE_S.h b/src/pins/stm32f4/pins_LERDGE_S.h new file mode 100644 index 0000000..376c2f3 --- /dev/null +++ b/src/pins/stm32f4/pins_LERDGE_S.h @@ -0,0 +1,232 @@ +/** + * 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 . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "LERDGE S supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Lerdge S" +#define DEFAULT_MACHINE_NAME "LERDGE" + +#define STEP_TIMER 4 +#define TEMP_TIMER 2 + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support + +// +// Servos +// +#define SERVO0_PIN PD12 +//#define SERVO1_PIN -1 + +// +// Limit Switches +// +#define X_MIN_PIN PG9 +#define Y_MIN_PIN PG10 +#define Z_MIN_PIN PG11 + +#define X_MAX_PIN PG12 +#define Y_MAX_PIN PG13 +#define Z_MAX_PIN PG14 + +// +// Filament runout +// +#define FIL_RUNOUT_PIN PC5 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PG8 +#endif + +// +// Steppers +// +#define X_STEP_PIN PF7 +#define X_DIR_PIN PF8 +#define X_ENABLE_PIN PF6 + +#define Y_STEP_PIN PF10 +#define Y_DIR_PIN PF11 +#define Y_ENABLE_PIN PF9 + +#define Z_STEP_PIN PF13 +#define Z_DIR_PIN PF14 +#define Z_ENABLE_PIN PF12 + +#define E0_STEP_PIN PG0 +#define E0_DIR_PIN PG1 +#define E0_ENABLE_PIN PF15 + +#define E1_STEP_PIN PG3 +#define E1_DIR_PIN PG4 +#define E1_ENABLE_PIN PG2 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC0 // See below for activation of thermistor readings +#define TEMP_1_PIN PC1 // See below for activation of thermistor readings +#define TEMP_BED_PIN PC3 + +// Lergde-S can choose thermocouple/thermistor mode in software. +// For use with thermistors, these pins must be OUT/LOW. +// This is done automatically. +#define TEMP_0_TR_ENABLE_PIN PF3 +#define TEMP_1_TR_ENABLE_PIN PF4 + +// MAX6675 Cold-Junction-Compensated K-Thermocouple to Digital Converter (0°C to +1024°C) +// https://datasheets.maximintegrated.com/en/ds/MAX6675.pdf + +#define TEMP_0_CS_PIN PC4 // max6675 datasheet: /CS pin, found with multimeter, not tested and likely wrong +#define TEMP_0_SCK_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested +#define TEMP_0_MISO_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested + +// Expansion board with second max6675 +// Warning: Some boards leave the slot unpopulated. + +//#define TEMP_1_CS_PIN PF1 // max6675 datasheet: /CS pin, found with multimeter, not tested +//#define TEMP_1_SCK_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested +//#define TEMP_1_MISO_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA0 +#define HEATER_1_PIN PA1 +#define HEATER_BED_PIN PA3 + +#define FAN_PIN PA15 // heater 0 fan 1 +#define FAN1_PIN PB10 // heater 1 fan 2 +#define FAN2_PIN PF5 // heater 0 fan 2 and heater 1 fan 1 (two sockets, switched together) + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PF5 +#endif + +// +// Průša i3 MK2 Multi Material Multiplexer Support +// +#if HAS_PRUSA_MMU1 + //#define E_MUX0_PIN -1 + //#define E_MUX1_PIN -1 +#endif + +// +// LED / Lighting +// +//Lerdge-S board has two LED connectors (this is the one on the mainboard) +#define CASE_LIGHT_PIN PC7 + +//on the dual extrusion addon board is a RGB connector +#define RGB_LED_R_PIN PC7 // Shared with the mainboard LED light connector (CASE_LIGHT_PIN) +#define RGB_LED_G_PIN PB0 +#define RGB_LED_B_PIN PB1 + +// +// Misc. Functions +// +#define LED_PIN PC6 // Mainboard soldered green LED +#define PS_ON_PIN PB2 // Board has a power module connector +#define KILL_PIN -1 // There is no reset button on the LCD +#define POWER_LOSS_PIN -1 // PB2 could be used for this as well + +// +// SD support +// +#define SDIO_SUPPORT +#define SDIO_CLOCK 4800000 +#define SD_DETECT_PIN PG15 +#if DISABLED(SDIO_SUPPORT) + #define SOFTWARE_SPI + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #define SD_SS_PIN PC11 + #define SDSS PC11 +#endif + +// +// Persistent Storage +// If no option is selected below the SD Card will be used +// Prefer the I2C option (F-RAM) to store Marlin settings, SPI option is not working yet + +//#define SPI_EEPROM +//#define I2C_EEPROM + +#if ENABLED(SPI_EEPROM) // SPI EEPROM Winbond W25Q128 (128Mbits) https://www.pjrc.com/teensy/W25Q128FV.pdf + #define SPI_CHAN_EEPROM1 1 + #define SPI_EEPROM1_CS_PIN PB12 // datasheet: /CS pin, found with multimeter, not tested + #define EEPROM_SCK_PIN PB13 // datasheet: CLK pin, found with multimeter, not tested + #define EEPROM_MISO_PIN PB14 // datasheet: DO pin, found with multimeter, not tested + #define EEPROM_MOSI_PIN PB15 // datasheet: DI pin, found with multimeter, not tested + #define EEPROM_PAGE_SIZE 0x1000U // 4K (from datasheet) + #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64K for now... +#elif ENABLED(I2C_EEPROM) // FM24CL64BG (CYP1813) 64Kbit F-RAM + #define SOFT_I2C_EEPROM // Force the use of Software I2C + #define I2C_SDA_PIN PG13 + #define I2C_SCL_PIN PG14 // To be confirmed on the Lerdge S, but probably same as the K + #define MARLIN_EEPROM_SIZE 0x2000U // 8K +#else + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2K, require this amount of RAM +#endif + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #ifndef TFT_DRIVER + #define TFT_DRIVER ST7796 + #endif + #define ST7796S_INVERTED + + #define TFT_RESET_PIN PD6 + #define TFT_BACKLIGHT_PIN PD3 + + #define FSMC_CS_PIN PD7 + #define FSMC_RS_PIN PD11 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define TOUCH_CS_PIN PB6 + #define TOUCH_SCK_PIN PB3 + #define TOUCH_MOSI_PIN PB5 + #define TOUCH_MISO_PIN PB4 +#endif + +#if IS_NEWPANEL + #define BEEPER_PIN PD13 + #define BTN_EN1 PC15 + #define BTN_EN2 PC14 + #define BTN_ENC PC13 + #ifndef ENCODER_STEPS_PER_MENU_ITEM + #define ENCODER_STEPS_PER_MENU_ITEM 2 + #endif +#endif diff --git a/src/pins/stm32f4/pins_LERDGE_X.h b/src/pins/stm32f4/pins_LERDGE_X.h new file mode 100644 index 0000000..6325697 --- /dev/null +++ b/src/pins/stm32f4/pins_LERDGE_X.h @@ -0,0 +1,175 @@ +/** + * 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 . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "LERDGE X only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Lerdge X" +#define DEFAULT_MACHINE_NAME "LERDGE" + +#define STEP_TIMER 4 +#define TEMP_TIMER 2 + +#define I2C_EEPROM +#define I2C_SCL_PIN PB8 +#define I2C_SDA_PIN PB9 +#define MARLIN_EEPROM_SIZE 0x10000 // FM24CL64 F-RAM 64K (8Kx8) + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support + +// +// Servos +// +//#define SERVO0_PIN PD13 + +// +// Limit Switches +// +#define X_STOP_PIN PB12 +#define Y_STOP_PIN PB13 +#define Z_STOP_PIN PB14 + +// +// Filament runout +// +#define FIL_RUNOUT_PIN PE1 + +// +// Z Probe (when not Z_MIN_PIN) +// +//#ifndef Z_MIN_PROBE_PIN +// #define Z_MIN_PROBE_PIN PB15 +//#endif + +// +// Steppers +// +#define X_STEP_PIN PB10 +#define X_DIR_PIN PB2 +#define X_ENABLE_PIN PB11 + +#define Y_STEP_PIN PB0 +#define Y_DIR_PIN PC5 +#define Y_ENABLE_PIN PB1 + +#define Z_STEP_PIN PA7 +#define Z_DIR_PIN PA6 +#define Z_ENABLE_PIN PC4 + +#define E0_STEP_PIN PA4 +#define E0_DIR_PIN PA3 +#define E0_ENABLE_PIN PA5 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC0 // Analog Input +#define TEMP_1_PIN -1 // Analog Input +#define TEMP_BED_PIN PC1 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA1 +#define HEATER_1_PIN -1 +#define HEATER_BED_PIN PA2 + +//#ifndef FAN_PIN +// #define FAN_PIN PC15 +//#endif +#define FAN1_PIN PC15 +#define FAN2_PIN PA0 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PC15 // FAN1_PIN +#endif + +// +// LED / Lighting +// +//#define CASE_LIGHT_PIN_CI -1 +//#define CASE_LIGHT_PIN_DO -1 +//#define NEOPIXEL_PIN -1 + +// +// SD support (On board) +// +#define SDIO_SUPPORT +#define SD_DETECT_PIN PA8 +#define SDIO_CLOCK 4800000 +#if DISABLED(SDIO_SUPPORT) + #define SOFTWARE_SPI + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #define SD_SS_PIN PC11 + #define SDSS PC11 +#endif + +// +// Misc. Functions +// +#define LED_PIN PC7 // Alive +#define PS_ON_PIN -1 +#define KILL_PIN -1 + +// Lerdge supports auto-power off and power loss sense through a single pin. +#define POWER_LOSS_PIN PC14 // Power-loss / nAC_FAULT + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #ifndef TFT_DRIVER + #define TFT_DRIVER ST7796 + #endif + #define ST7796S_INVERTED + + #define FSMC_CS_PIN PD7 + #define FSMC_RS_PIN PD11 + + #define TFT_RESET_PIN PD6 + #define TFT_BACKLIGHT_PIN PD3 + + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define TOUCH_CS_PIN PB6 + #define TOUCH_SCK_PIN PB3 + #define TOUCH_MOSI_PIN PB5 + #define TOUCH_MISO_PIN PB4 +#endif + +#if IS_NEWPANEL + #define BEEPER_PIN PD12 + #define BTN_EN1 PE4 + #define BTN_EN2 PE3 + #define BTN_ENC PE2 + #ifndef ENCODER_STEPS_PER_MENU_ITEM + #define ENCODER_STEPS_PER_MENU_ITEM 2 + #endif +#endif diff --git a/src/pins/stm32f4/pins_MKS_EAGLE.h b/src/pins/stm32f4/pins_MKS_EAGLE.h new file mode 100644 index 0000000..ecea8e1 --- /dev/null +++ b/src/pins/stm32f4/pins_MKS_EAGLE.h @@ -0,0 +1,35 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS Eagle supports up to 2 hotends / E steppers." +#elif HAS_FSMC_TFT + #error "MKS Eagle doesn't support FSMC-based TFT displays." +#endif + +#define BOARD_INFO_NAME "MKS Eagle" + +#include "pins_MKS_ROBIN_NANO_V3_common.h" diff --git a/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h b/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h new file mode 100644 index 0000000..7163625 --- /dev/null +++ b/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h @@ -0,0 +1,51 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "MKS Monster8 V1" + +// +// Limit Switches +// +#define X_MAX_PIN PA13 +#define Y_MAX_PIN PC5 + +// +// Steppers +// +#define E4_ENABLE_PIN PD14 // Driver7 + +// +// Misc. Functions +// +#define PW_DET PC5 // Y+ +#define PW_OFF PB12 // Z+ +#define MT_DET_1_PIN PW_DET +#define MT_DET_2_PIN PW_OFF +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN MT_DET_1_PIN +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN MT_DET_2_PIN +#endif + +#include "pins_MKS_MONSTER8_common.h" diff --git a/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h b/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h new file mode 100644 index 0000000..9c01299 --- /dev/null +++ b/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h @@ -0,0 +1,57 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "MKS Monster8 V2" + +// +// Steppers +// +#define E4_ENABLE_PIN PB6 // Driver7 + +// +// Misc. Functions +// +#define PW_DET PA13 // MT_DET +#define PW_OFF PB12 // Z+ +#define MT_DET_1_PIN PW_DET +#define MT_DET_2_PIN PW_OFF +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN MT_DET_1_PIN +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN MT_DET_2_PIN +#endif + +// +// MKS WIFI MODULE +// +//#define WIFI_SERIAL 1// USART1 +#if ENABLED(MKS_WIFI_MODULE) + #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN + #define WIFI_RESET_PIN PD14 // MKS ESP WIFI RESET PIN +#endif + +#define NEOPIXEL_PIN PC5 + +#include "pins_MKS_MONSTER8_common.h" diff --git a/src/pins/stm32f4/pins_MKS_MONSTER8_common.h b/src/pins/stm32f4/pins_MKS_MONSTER8_common.h new file mode 100644 index 0000000..8a9b722 --- /dev/null +++ b/src/pins/stm32f4/pins_MKS_MONSTER8_common.h @@ -0,0 +1,368 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 3 || E_STEPPERS > 5 + #error "MKS Monster supports up to 3 hotends and 5 E steppers." +#elif HAS_FSMC_TFT + #error "MKS Monster doesn't support FSMC-based TFT displays." +#endif + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support +#define USES_DIAG_JUMPERS + +//#define DISABLE_DEBUG + +// Avoid conflict with TIMER_TONE +#define STEP_TIMER 10 + +// Use one of these or SDCard-based Emulation will be used +//#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation +//#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#define I2C_EEPROM // Need use jumpers set i2c for EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4K +#define I2C_SCL_PIN PB8 // I2C_SCL and CAN_RX +#define I2C_SDA_PIN PB9 // I2C_SDA and CAN_TX + +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + +// +// Limit Switches for diag signals +// +#define X_DIAG_PIN PA14 // Driver0 diag signal is connected to X- +#define Y_DIAG_PIN PA15 // Driver1 diag signal is connected to Y- +#define Z_DIAG_PIN PB13 // Driver2 diag signal is connected to Z- +#define E0_DIAG_PIN PA13 // Driver3 diag signal is connected to X+ +#define E1_DIAG_PIN PC5 // Driver4 diag signal is connected to Y+ +#define E2_DIAG_PIN PB12 // Driver5 diag signal is connected to Z+ +#define E3_DIAG_PIN -1 // Driver6 diag signal is not connected +#define E4_DIAG_PIN -1 // Driver7 diag signal is not connected + +// Limit Switches for endstops +#define X_MIN_PIN PA14 +#define Y_MIN_PIN PA15 +#define Z_MIN_PIN PB13 +#define Z_MAX_PIN PB12 + +// +// Steppers +// +#define X_ENABLE_PIN PC15 // Driver0 +#define X_STEP_PIN PC14 +#define X_DIR_PIN PC13 +#ifndef X_CS_PIN + #define X_CS_PIN PE6 +#endif + +#define Y_ENABLE_PIN PC15 // Driver1 +#define Y_STEP_PIN PE5 +#define Y_DIR_PIN PE4 +#ifndef Y_CS_PIN + #define Y_CS_PIN PE3 +#endif + +#define Z_ENABLE_PIN PE2 // Driver2 +#define Z_STEP_PIN PE1 +#define Z_DIR_PIN PE0 +#ifndef Z_CS_PIN + #define Z_CS_PIN PB7 +#endif + +#define E0_ENABLE_PIN PB6 // Driver3 +#define E0_STEP_PIN PB5 +#define E0_DIR_PIN PB4 +#ifndef E0_CS_PIN + #define E0_CS_PIN PB3 +#endif + +#define E1_ENABLE_PIN PD7 // Driver4 +#define E1_STEP_PIN PD6 +#define E1_DIR_PIN PD5 +#ifndef E1_CS_PIN + #define E1_CS_PIN PD4 +#endif + +#define E2_ENABLE_PIN PD3 // Driver5 +#define E2_STEP_PIN PD2 +#define E2_DIR_PIN PD1 +#ifndef E2_CS_PIN + #define E2_CS_PIN PD0 +#endif + +#define E3_ENABLE_PIN PC8 // Driver6 +#define E3_STEP_PIN PC7 +#define E3_DIR_PIN PC6 +#ifndef E3_CS_PIN + #define E3_CS_PIN PD15 +#endif + +#define E4_STEP_PIN PD13 // Driver7 +#define E4_DIR_PIN PD12 +#ifndef E4_CS_PIN + #define E4_CS_PIN PD11 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// This board only supports SW SPI for stepper drivers +// +#if HAS_TMC_SPI + #define TMC_USE_SW_SPI +#endif +#if ENABLED(TMC_USE_SW_SPI) + #if !defined(TMC_SW_MOSI) || TMC_SW_MOSI == -1 + #define TMC_SW_MOSI PE14 + #endif + #if !defined(TMC_SW_MISO) || TMC_SW_MISO == -1 + #define TMC_SW_MISO PE13 + #endif + #if !defined(TMC_SW_SCK) || TMC_SW_SCK == -1 + #define TMC_SW_SCK PE12 + #endif +#endif + +#if HAS_TMC_UART + // + // Software serial + // No Hardware serial for steppers + // + #define X_SERIAL_TX_PIN PE6 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PB7 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PB3 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD4 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PD0 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + #define E3_SERIAL_TX_PIN PD15 + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + #define E4_SERIAL_TX_PIN PD11 + #define E4_SERIAL_RX_PIN E4_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH0 +#define TEMP_1_PIN PC2 // TH1 +#define TEMP_2_PIN PC3 // TH2 +#define TEMP_BED_PIN PC0 // TB + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB1 // HE0 +#define HEATER_1_PIN PB0 // HE1 +#define HEATER_2_PIN PA3 // HE2 +#define HEATER_BED_PIN PB10 // H-BED + +#define FAN_PIN PA2 // FAN0 +#define FAN1_PIN PA1 // FAN1 +#define FAN2_PIN PA0 // FAN2 + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #define PS_ON_PIN PW_OFF + #define KILL_PIN PW_DET + #define KILL_PIN_STATE HIGH +#endif + +// Random Info +#define USB_SERIAL -1 // USB Serial + +/** + * ------ ------ + * (BEEPER) PB2 | 1 2 | PE10 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) + * (LCD_EN) PE11 | 3 4 | PD10 (LCD_RS) (BTN_EN1) PE9 | 3 4 | PA4 (SPI1 CS) + * (LCD_D4) PD9 5 6 | PD8 (LCD_D5) (BTN_EN2) PE8 5 6 | PA7 (SPI1 MOSI) + * (LCD_D6) PE15 | 7 8 | PE7 (LCD_D7) (SPI1_RS) PB11 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PB2 +#define EXP1_02_PIN PE10 +#define EXP1_03_PIN PE11 +#define EXP1_04_PIN PD10 +#define EXP1_05_PIN PD9 +#define EXP1_06_PIN PD8 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE7 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE9 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PE8 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PB11 +#define EXP2_08_PIN -1 // RESET + +#if ENABLED(SDSUPPORT) + #ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD + #endif + #if SD_CONNECTION_IS(ONBOARD) + #define ENABLE_SPI3 + #define SD_SS_PIN -1 + #define SDSS PC9 + #define SD_SCK_PIN PC10 + #define SD_MISO_PIN PC11 + #define SD_MOSI_PIN PC12 + #define SD_DETECT_PIN PC4 // SD_DETECT_PIN doesn't work with NO_SD_HOST_DRIVE disabled + #elif SD_CONNECTION_IS(LCD) + #define ENABLE_SPI1 + #define SDSS EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif +#endif + +#if EITHER(TFT_COLOR_UI, TFT_CLASSIC_UI) + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN EXP1_04_PIN + + #define LCD_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + #ifndef TFT_WIDTH + #define TFT_WIDTH 480 + #endif + #ifndef TFT_HEIGHT + #define TFT_HEIGHT 320 + #endif + + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI + + #define LCD_READ_ID 0xD3 + #define LCD_USE_DMA_SPI + + #define TFT_BUFFER_SIZE 14400 + + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X -17253 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 11579 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 514 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -24 + #endif + #ifndef TOUCH_ORIENTATION + #define TOUCH_ORIENTATION TOUCH_LANDSCAPE + #endif + +#elif HAS_WIRED_LCD + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_BACKLIGHT_PIN -1 + + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + + #define ENABLE_SPI1 + #define FORCE_SOFT_SPI + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + //#define LCD_BACKLIGHT_PIN -1 + //#define LCD_RESET_PIN -1 + + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 LCD_PINS_DC + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #else + + #define LCD_PINS_D4 EXP1_05_PIN + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #endif + + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 600 + + #endif // !MKS_MINI_12864 + +#endif // HAS_WIRED_LCD + +#if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, HAS_WIRED_LCD) + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN +#endif diff --git a/src/pins/stm32f4/pins_MKS_ROBIN2.h b/src/pins/stm32f4/pins_MKS_ROBIN2.h new file mode 100644 index 0000000..2274d0c --- /dev/null +++ b/src/pins/stm32f4/pins_MKS_ROBIN2.h @@ -0,0 +1,101 @@ +/** + * 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 . + * + */ +#pragma once + +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS_ROBIN2 supports up to 2 hotends / E steppers." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS_ROBIN2" +#endif + +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#endif + +#define SRAM_EEPROM_EMULATION + +// +// Limit Switches +// +#define X_MIN_PIN PG8 +#define X_MAX_PIN PG7 +#define Y_MIN_PIN PG6 +#define Y_MAX_PIN PG5 +#define Z_MIN_PIN PG4 +#define Z_MAX_PIN PG3 + +// +// Servos +// +#define SERVO0_PIN PB0 // XS2-5 +#define SERVO1_PIN PF7 // XS1-5 +#define SERVO2_PIN PF8 // XS1-6 + +// +// Steppers +// +#define X_STEP_PIN PE6 +#define X_DIR_PIN PE5 +#define X_ENABLE_PIN PC13 + +#define Y_STEP_PIN PE3 +#define Y_DIR_PIN PE2 +#define Y_ENABLE_PIN PE4 + +#define Z_STEP_PIN PE0 +#define Z_DIR_PIN PB9 +#define Z_ENABLE_PIN PE1 + +#define E0_STEP_PIN PG10 +#define E0_DIR_PIN PG9 +#define E0_ENABLE_PIN PB8 + +#define E1_STEP_PIN PD3 +#define E1_DIR_PIN PA15 +#define E1_ENABLE_PIN PD6 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // T1 <-> E0 +#define TEMP_1_PIN PC2 // T2 <-> E1 +#define TEMP_BED_PIN PC0 // T0 <-> Bed + +// +// Heaters / Fans +// +#define HEATER_0_PIN PF3 // Heater0 +#define HEATER_1_PIN PF2 // Heater1 +#define HEATER_BED_PIN PF4 // Hotbed +#define FAN_PIN PA7 // Fan0 + +// +// Misc. Functions +// +#define SDSS -1 // PB12 + +#define SD_DETECT_PIN PF9 +#define BEEPER_PIN PG2 diff --git a/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h b/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h new file mode 100644 index 0000000..3cba69a --- /dev/null +++ b/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h @@ -0,0 +1,45 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * MKS Robin nano V1.3 (STM32F407VET6) board pin assignments + * https://github.com/makerbase-mks/MKS-Robin-Nano-V1.X/tree/master/hardware + */ + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#define BOARD_INFO_NAME "MKS Robin Nano V1.3" + +// +// EEPROM +// Use one of these or SDCard-based Emulation will be used +// +#if NO_EEPROM_SELECTED + //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation + //#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#endif + +#define LED_PIN PB1 + +#include "../stm32f1/pins_MKS_ROBIN_NANO_common.h" diff --git a/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h new file mode 100644 index 0000000..32d8a47 --- /dev/null +++ b/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -0,0 +1,72 @@ +/** + * 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 . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS Robin Nano V3 supports up to 2 hotends / E steppers." +#elif HAS_FSMC_TFT + #error "MKS Robin Nano V3 doesn't support FSMC-based TFT displays." +#endif + +#define BOARD_INFO_NAME "MKS Robin Nano V3" + +#define USES_DIAG_JUMPERS + +#ifndef X_CS_PIN + #define X_CS_PIN PD5 +#endif +#ifndef Y_CS_PIN + #define Y_CS_PIN PD7 +#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN PD4 +#endif +#ifndef E0_CS_PIN + #define E0_CS_PIN PD9 +#endif +#ifndef E1_CS_PIN + #define E1_CS_PIN PD8 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// This board only supports SW SPI for stepper drivers +// +#if HAS_TMC_SPI + #define TMC_USE_SW_SPI +#endif +#if ENABLED(TMC_USE_SW_SPI) + #if !defined(TMC_SW_MOSI) || TMC_SW_MOSI == -1 + #define TMC_SW_MOSI PD14 + #endif + #if !defined(TMC_SW_MISO) || TMC_SW_MISO == -1 + #define TMC_SW_MISO PD1 + #endif + #if !defined(TMC_SW_SCK) || TMC_SW_SCK == -1 + #define TMC_SW_SCK PD0 + #endif +#endif + +#include "pins_MKS_ROBIN_NANO_V3_common.h" diff --git a/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h b/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h new file mode 100644 index 0000000..4ac64ae --- /dev/null +++ b/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h @@ -0,0 +1,391 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +// +// MKS Robin Nano V3, MKS Eagle pinmap +// + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support + +// Avoid conflict with TIMER_TONE +#define STEP_TIMER 10 + +// Use one of these or SDCard-based Emulation will be used +//#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation +//#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x1000 // 4K + #define I2C_SCL_PIN PB6 + #define I2C_SDA_PIN PB7 +#endif + +// +// Release PB4 (Z_DIR_PIN) from JTAG NRST role +// +//#define DISABLE_DEBUG + +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + +// +// Limit Switches +// +#define X_DIAG_PIN PA15 +#define Y_DIAG_PIN PD2 +#define Z_DIAG_PIN PC8 +#define E0_DIAG_PIN PC4 +#define E1_DIAG_PIN PE7 + +#define X_STOP_PIN X_DIAG_PIN +#define Y_STOP_PIN Y_DIAG_PIN +#define Z_MIN_PIN Z_DIAG_PIN +#define Z_MAX_PIN E0_DIAG_PIN + +// +// Steppers +// +#define X_ENABLE_PIN PE4 +#define X_STEP_PIN PE3 +#define X_DIR_PIN PE2 + +#define Y_ENABLE_PIN PE1 +#define Y_STEP_PIN PE0 +#define Y_DIR_PIN PB9 + +#define Z_ENABLE_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB4 + +#define E0_ENABLE_PIN PB3 +#define E0_STEP_PIN PD6 +#define E0_DIR_PIN PD3 + +#define E1_ENABLE_PIN PA3 +#define E1_STEP_PIN PD15 +#define E1_DIR_PIN PA1 + +#if HAS_TMC_UART + // + // Software serial + // No Hardware serial for steppers + // + #define X_SERIAL_TX_PIN PD5 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PD7 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PD4 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD9 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD8 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH1 +#define TEMP_1_PIN PA2 // TH2 +#define TEMP_BED_PIN PC0 // TB1 + +#if HOTENDS == 1 && !REDUNDANT_TEMP_MATCH(SOURCE, E1) + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PE5 // HEATER1 +#define HEATER_1_PIN PB0 // HEATER2 +#define HEATER_BED_PIN PA0 // HOT BED + +#define FAN_PIN PC14 // FAN +#define FAN1_PIN PB1 // FAN1 + +// +// Thermocouples +// +//#define TEMP_0_CS_PIN HEATER_0_PIN // TC1 - CS1 +//#define TEMP_0_CS_PIN HEATER_1_PIN // TC2 - CS2 + +// +// Misc. Functions +// +#if HAS_TFT_LVGL_UI + #define MT_DET_1_PIN PA4 // MT_DET + #define MT_DET_2_PIN PE6 + #define MT_DET_PIN_STATE LOW +#endif + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA4 +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN PE6 +#endif + +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PA13 // PW_DET +#endif + +//#define SUICIDE_PIN PB2 +//#define LED_PIN PB2 +//#define KILL_PIN PA2 +//#define KILL_PIN_STATE LOW + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #if ENABLED(TFT_LVGL_UI) + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif + #undef MKS_PWC + #define SUICIDE_PIN PB2 + #define SUICIDE_PIN_STATE LOW + #else + #define PS_ON_PIN PB2 // PW_OFF + #endif + #define KILL_PIN PA13 // PW_DET + #define KILL_PIN_STATE HIGH +#endif + +// Random Info +#define USB_SERIAL -1 // USB Serial +#define WIFI_SERIAL 3 // USART3 +#define MKS_WIFI_MODULE_SERIAL 1 // USART1 +#define MKS_WIFI_MODULE_SPI 2 // SPI2 + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +// MKS WIFI MODULE +#if ENABLED(MKS_WIFI_MODULE) + #define WIFI_IO0_PIN PC13 + #define WIFI_IO1_PIN PC7 + #define WIFI_RESET_PIN PE9 +#endif + +// MKS TEST +#if ENABLED(MKS_TEST) + #define MKS_TEST_POWER_LOSS_PIN PA13 // PW_DET + #define MKS_TEST_PS_ON_PIN PB2 // PW_OFF +#endif + +// +// Onboard SD card +// +// detect pin doesn't work when ONBOARD and NO_SD_HOST_DRIVE disabled +#if SD_CONNECTION_IS(ONBOARD) + #define ENABLE_SPI3 + #define SD_SS_PIN -1 + #define SDSS PC9 + #define SD_SCK_PIN PC10 + #define SD_MISO_PIN PC11 + #define SD_MOSI_PIN PC12 + #define SD_DETECT_PIN PD12 +#endif + +#define SPI_FLASH +#if ENABLED(SPI_FLASH) + #define HAS_SPI_FLASH 1 + #define SPI_DEVICE 2 + #define SPI_FLASH_SIZE 0x1000000 + #define SPI_FLASH_CS_PIN PB12 + #define SPI_FLASH_MOSI_PIN PC3 + #define SPI_FLASH_MISO_PIN PC2 + #define SPI_FLASH_SCK_PIN PB13 +#endif + +/** + * ------ ------ + * (BEEPER) PC5 | 1 2 | PE13 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) + * (LCD_EN) PD13 | 3 4 | PC6 (LCD_RS) (BTN_EN1) PE8 | 3 4 | PE10 (SPI1 CS) + * (LCD_D4) PE14 5 6 | PE15 (LCD_D5) (BTN_EN2) PE11 5 6 | PA7 (SPI1 MOSI) + * (LCD_D6) PD11 | 7 8 | PD10 (LCD_D7) (SPI1_RS) PE12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PE13 +#define EXP1_03_PIN PD13 +#define EXP1_04_PIN PC6 +#define EXP1_05_PIN PE14 +#define EXP1_06_PIN PE15 +#define EXP1_07_PIN PD11 +#define EXP1_08_PIN PD10 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE8 +#define EXP2_04_PIN PE10 +#define EXP2_05_PIN PE11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PE12 +#define EXP2_08_PIN -1 // RESET + +// +// SPI SD Card +// +#if SD_CONNECTION_IS(LCD) + #define ENABLE_SPI1 + #define SDSS EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN +#endif + +// +// LCD / Controller +// +#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN EXP1_04_PIN + + #define LCD_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + #ifndef TFT_WIDTH + #define TFT_WIDTH 480 + #endif + #ifndef TFT_HEIGHT + #define TFT_HEIGHT 320 + #endif + + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI + + #define LCD_READ_ID 0xD3 + #define LCD_USE_DMA_SPI + + #define TFT_BUFFER_SIZE 14400 + + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X -17253 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 11579 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 514 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -24 + #endif + #ifndef TOUCH_ORIENTATION + #define TOUCH_ORIENTATION TOUCH_LANDSCAPE + #endif + +#elif HAS_WIRED_LCD + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_BACKLIGHT_PIN -1 + + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + //#define LCD_BACKLIGHT_PIN -1 + //#define LCD_RESET_PIN -1 + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + //#define DOGLCD_SCK EXP2_02_PIN + //#define DOGLCD_MOSI EXP2_06_PIN + + // Required for MKS_MINI_12864 with this board + //#define MKS_LCD12864B + //#undef SHOW_BOOTSCREEN + + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 LCD_PINS_DC + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #if SD_CONNECTION_IS(ONBOARD) + #define FORCE_SOFT_SPI + #endif + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #else // !MKS_MINI_12864 + + #define LCD_PINS_D4 EXP1_05_PIN + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #endif + + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 600 + + #endif // !MKS_MINI_12864 + +#endif // HAS_WIRED_LCD + +#if HAS_TFT_LVGL_UI + // Enable SPI DMA, this requires button pins, thus no buttons. Default is DISABLED. + //#define USE_SPI_DMA_TC +#endif + +#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI, HAS_WIRED_LCD) + #define BEEPER_PIN EXP1_01_PIN + #if DISABLED(USE_SPI_DMA_TC) + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN + #endif +#endif diff --git a/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h new file mode 100644 index 0000000..7e08caa --- /dev/null +++ b/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -0,0 +1,378 @@ +/** + * 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 . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "MKS Robin Nano V3 supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS Robin PRO V2" + +// Avoid conflict with TIMER_TONE +#define STEP_TIMER 10 + +// Use one of these or SDCard-based Emulation will be used +//#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation +//#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4K + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +//#define DISABLE_DEBUG + +// +// Note: MKS Robin board is using SPI2 interface. +// +//#define SPI_MODULE 2 + +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + +// +// Limit Switches +// +#define X_DIAG_PIN PA15 +#define Y_DIAG_PIN PA12 +#define Z_DIAG_PIN PA11 +#define E0_DIAG_PIN PC4 +#define E1_DIAG_PIN PE7 + +#define X_STOP_PIN PA15 +#define Y_STOP_PIN PA12 +#define Z_MIN_PIN PA11 +#define Z_MAX_PIN PC4 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA4 // MT_DET +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PE4 +#define X_STEP_PIN PE3 +#define X_DIR_PIN PE2 +#ifndef X_CS_PIN + #define X_CS_PIN PD5 +#endif + +#define Y_ENABLE_PIN PE1 +#define Y_STEP_PIN PE0 +#define Y_DIR_PIN PB9 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD7 +#endif + +#define Z_ENABLE_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB4 +#ifndef Z_CS_PIN + #define Z_CS_PIN PD4 +#endif + +#define E0_ENABLE_PIN PB3 +#define E0_STEP_PIN PD6 +#define E0_DIR_PIN PD3 +#ifndef E0_CS_PIN + #define E0_CS_PIN PD9 +#endif + +#define E1_ENABLE_PIN PA3 +#define E1_STEP_PIN PD15 +#define E1_DIR_PIN PA1 +#ifndef E1_CS_PIN + #define E1_CS_PIN PD8 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PD14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PD1 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PD0 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN PD5 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PD7 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PD4 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD9 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD8 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif // HAS_TMC_UART + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH1 +#define TEMP_1_PIN PC2 // TH2 +#define TEMP_BED_PIN PC0 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC3 // HEATER1 +#define HEATER_1_PIN PB0 // HEATER2 +#define HEATER_BED_PIN PA0 // HOT BED + +#define FAN_PIN PB1 // FAN + +// +// Thermocouples +// +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 + +// +// Misc. Functions +// +//#define POWER_LOSS_PIN PA2 // PW_DET +//#define PS_ON_PIN PA3 // PW_OFF + +// +// Power Supply Control +// +#if ENABLED(MKS_PWC) + #define SUICIDE_PIN PB2 + #define KILL_PIN PA2 + #define KILL_PIN_STATE LOW +#else + #define LED_PIN PB2 +#endif + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +//#define USE_NEW_SPI_API 1 + +// +// Onboard SD card +// NOT compatible with LCD +// +// Detect pin doesn't work when ONBOARD and NO_SD_HOST_DRIVE disabled +#if SD_CONNECTION_IS(ONBOARD) + #if USE_NEW_SPI_API + #define SD_SPI MARLIN_SPI(HardwareSPI3, PC9) + #else + #define ENABLE_SPI3 + #define SD_SS_PIN -1 + #define SDSS PC9 + #define SD_SCK_PIN PC10 + #define SD_MISO_PIN PC11 + #define SD_MOSI_PIN PC12 + #endif + #define SD_DETECT_PIN PD12 +#endif + +/** ------ ------ + * (BEEPER) PC5 | 1 2 | PE13 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) + * (LCD_EN) PD13 | 3 4 | PC6 (LCD_RS) (BTN_EN1) PE8 | 3 4 | PE10 (SPI1 CS) + * (LCD_D4) PE14 5 6 | PE15 (LCD_D5) (BTN_EN2) PE11 5 6 | PA7 (SPI1 MOSI) + * (LCD_D6) PD11 | 7 8 | PD10 (LCD_D7) (SPI DET) PE12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PE13 +#define EXP1_03_PIN PD13 +#define EXP1_04_PIN PC6 +#define EXP1_05_PIN PE14 +#define EXP1_06_PIN PE15 +#define EXP1_07_PIN PD11 +#define EXP1_08_PIN PD10 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE8 +#define EXP2_04_PIN PE10 +#define EXP2_05_PIN PE11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PE12 +#define EXP2_08_PIN -1 // RESET + +// +// LCD SD +// +/* +#if SD_CONNECTION_IS(LCD) + #define ENABLE_SPI1 + #define SDSS EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN +#endif +*/ + +// +// LCD / Controller +#define SPI_FLASH +#define HAS_SPI_FLASH 1 +#define SPI_DEVICE 2 +#define SPI_FLASH_SIZE 0x1000000 +#if ENABLED(SPI_FLASH) + #define SPI_FLASH_CS_PIN PB12 + #define SPI_FLASH_MOSI_PIN PB15 + #define SPI_FLASH_MISO_PIN PB14 + #define SPI_FLASH_SCK_PIN PB13 +#endif + +#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X -17253 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 11579 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 514 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -24 + #endif + #ifndef TOUCH_ORIENTATION + #define TOUCH_ORIENTATION TOUCH_LANDSCAPE + #endif + + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN EXP1_04_PIN + #define LCD_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + #ifndef TFT_WIDTH + #define TFT_WIDTH 480 + #endif + #ifndef TFT_HEIGHT + #define TFT_HEIGHT 320 + #endif + + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #define LCD_READ_ID 0xD3 + #define LCD_USE_DMA_SPI + + //#define TFT_DRIVER ST7796 + #define TFT_BUFFER_SIZE 14400 + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define LCD_BACKLIGHT_PIN -1 + + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + #if ENABLED(MKS_MINI_12864) + //#define LCD_BACKLIGHT_PIN -1 + //#define LCD_RESET_PIN -1 + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + //#define DOGLCD_SCK EXP2_02_PIN + //#define DOGLCD_MOSI EXP2_06_PIN + + // Required for MKS_MINI_12864 with this board + //#define MKS_LCD12864B + //#undef SHOW_BOOTSCREEN + + #else // !MKS_MINI_12864 + + #define LCD_PINS_D4 EXP1_05_PIN + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #endif + + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 600 + + #endif // !MKS_MINI_12864 + +#endif // HAS_WIRED_LCD diff --git a/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h b/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h new file mode 100644 index 0000000..36dde88 --- /dev/null +++ b/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h @@ -0,0 +1,206 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * STM32F407VET6 on Opulo Lumen PnP Rev3 + * Website - https://opulo.io/ + */ + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#define BOARD_INFO_NAME "Opulo Lumen REV3" +#define DEFAULT_MACHINE_NAME "Opulo Pick-and-Place" + +/** + * By default, the extra stepper motor configuration is: + * I = Left Head + * J = Right Head + * K = Auxiliary (Conveyor belt) + */ + +#define SRAM_EEPROM_EMULATION +#define MARLIN_EEPROM_SIZE 0x2000 // 8K + +// I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) +#define HAS_MCP3426_ADC + +// +// Servos +// +#define SERVO0_PIN PB10 +#define SERVO1_PIN PB11 + +// +// Limit Switches +// +#define X_STOP_PIN PC6 +#define Y_STOP_PIN PD15 +#define Z_STOP_PIN PD14 + +// None of these require limit switches by default, so we leave these commented +// here for your reference. +//#define I_MIN_PIN PA8 +//#define I_MAX_PIN PA8 +//#define J_MIN_PIN PD13 +//#define J_MAX_PIN PD13 +//#define K_MIN_PIN PC9 +//#define K_MAX_PIN PC9 + +// +// Steppers +// +#define X_STEP_PIN PB15 +#define X_DIR_PIN PB14 +#define X_ENABLE_PIN PD9 + +#define Y_STEP_PIN PE15 +#define Y_DIR_PIN PE14 +#define Y_ENABLE_PIN PB13 + +#define Z_STEP_PIN PE7 +#define Z_DIR_PIN PB1 +#define Z_ENABLE_PIN PE9 + +#define I_STEP_PIN PC4 +#define I_DIR_PIN PA4 +#define I_ENABLE_PIN PB0 + +#define J_STEP_PIN PE11 +#define J_DIR_PIN PE10 +#define J_ENABLE_PIN PE13 + +#define K_STEP_PIN PD6 +#define K_DIR_PIN PD7 +#define K_ENABLE_PIN PA3 + +#if HAS_TMC_SPI + /** + * Make sure to configure the jumpers on the back side of the Mobo according to + * this diagram: https://github.com/MarlinFirmware/Marlin/pull/23851 + */ + #error "SPI drivers require a custom jumper configuration, see comment above! Comment out this line to continue." + + #if AXIS_HAS_SPI(X) + #define X_CS_PIN PD8 + #endif + #if AXIS_HAS_SPI(Y) + #define Y_CS_PIN PB12 + #endif + #if AXIS_HAS_SPI(Z) + #define Z_CS_PIN PE8 + #endif + #if AXIS_HAS_SPI(I) + #define I_CS_PIN PC5 + #endif + #if AXIS_HAS_SPI(J) + #define J_CS_PIN PE12 + #endif + #if AXIS_HAS_SPI(K) + #define K_CS_PIN PA2 + #endif + +#elif HAS_TMC_UART + + #define X_SERIAL_TX_PIN PD8 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PB12 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE8 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define I_SERIAL_TX_PIN PC5 + #define I_SERIAL_RX_PIN I_SERIAL_TX_PIN + + #define J_SERIAL_TX_PIN PE12 + #define J_SERIAL_RX_PIN J_SERIAL_TX_PIN + + #define K_SERIAL_TX_PIN PA2 + #define K_SERIAL_RX_PIN K_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 + +#endif + +// +// Heaters / Fans +// +#define FAN_PIN PE2 +#define FAN1_PIN PE3 +#define FAN2_PIN PE4 +#define FAN3_PIN PE5 + +#define FAN_SOFT_PWM_REQUIRED + +// +// Neopixel +// +#define NEOPIXEL_PIN PC7 +#define NEOPIXEL2_PIN PC8 + +// +// SPI +// +#define MISO_PIN PB4 +#define MOSI_PIN PB5 +#define SCK_PIN PB3 + +#define TMC_SW_MISO MISO_PIN +#define TMC_SW_MOSI MOSI_PIN +#define TMC_SW_SCK SCK_PIN + +// +// I2C +// +#define I2C_SDA_PIN PB7 +#define I2C_SCL_PIN PB6 + +/** + * The index mobo rev03 has 3 aux ports. We define them here so they may be used + * in other places and to make sure someone doesn't have to go look up the pinout + * in the board files. Each 12 pin aux port has this pinout: + * + * VDC 1 2 GND + * 3.3V 3 4 SCL (I2C_SCL_PIN) + * PWM1 5 6 SDA (I2C_SDA_PIN) + * PWM2 7 8 CIPO (MISO_PIN) + * A1 9 10 COPI (MOSI_PIN) + * A2 11 12 SCK (SCK_PIN) + */ +#define INDEX_AUX1_PWM1 PA15 +#define INDEX_AUX1_PWM2 PA5 +#define INDEX_AUX1_A1 PC0 +#define INDEX_AUX1_A2 PC1 + +#define INDEX_AUX2_PWM1 PA6 +#define INDEX_AUX2_PWM2 PA7 +#define INDEX_AUX2_A1 PC2 +#define INDEX_AUX2_A2 PC3 + +#define INDEX_AUX3_PWM1 PB8 +#define INDEX_AUX3_PWM2 PB9 +#define INDEX_AUX3_A1 PA0 +#define INDEX_AUX3_A2 PA1 diff --git a/src/pins/stm32f4/pins_RUMBA32_AUS3D.h b/src/pins/stm32f4/pins_RUMBA32_AUS3D.h new file mode 100644 index 0000000..e926a2b --- /dev/null +++ b/src/pins/stm32f4/pins_RUMBA32_AUS3D.h @@ -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 . + * + */ +#pragma once + +/** + * Pin assignments for the RUMBA32 + * + * https://aus3d.com.au/rumba32 + * https://github.com/Aus3D/RUMBA32 + */ + +#define BOARD_INFO_NAME "RUMBA32" + +#if NO_EEPROM_SELECTED + #if MB(RUMBA32_V1_0) + #define FLASH_EEPROM_EMULATION + #define MARLIN_EEPROM_SIZE 0x1000 // 4K + #elif MB(RUMBA32_V1_1) + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x2000 // 8K (24LC64T-I/OT) + #endif +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#endif + +#include "pins_RUMBA32_common.h" + +#if MB(RUMBA32_V1_1) + + #define SERVO0_PIN PA15 + + #if HAS_TMC_UART + // + // TMC2208/TMC2209 stepper drivers - Software Serial is used according to below pins + // + #define X_SERIAL_TX_PIN PA14 + #define X_SERIAL_RX_PIN PC14 + + #define Y_SERIAL_TX_PIN PA13 + #define Y_SERIAL_RX_PIN PE4 + + #define Z_SERIAL_TX_PIN PB10 + #define Z_SERIAL_RX_PIN PE0 + + #define E0_SERIAL_TX_PIN PD11 + #define E0_SERIAL_RX_PIN PC13 + + #define E1_SERIAL_TX_PIN PB3 + #define E1_SERIAL_RX_PIN PD5 + + #define E2_SERIAL_TX_PIN PB4 + #define E2_SERIAL_RX_PIN PD1 + #endif +#endif diff --git a/src/pins/stm32f4/pins_RUMBA32_BTT.h b/src/pins/stm32f4/pins_RUMBA32_BTT.h new file mode 100644 index 0000000..2f3e121 --- /dev/null +++ b/src/pins/stm32f4/pins_RUMBA32_BTT.h @@ -0,0 +1,67 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * No official schematics have been found. + * But these differences where noted in https://github.com/bigtreetech/Rumba32/issues/1 + */ + +#define BOARD_INFO_NAME "RUMBA32 (BTT)" + +#if NO_EEPROM_SELECTED + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x1000 // 4K (24LC32AT-I/OT) +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#endif + +#include "pins_RUMBA32_common.h" + +#define SERVO0_PIN PA15 // Pin is not broken out, is a test point only. + +#if HAS_TMC_UART + // + // TMC2208/TMC2209 Software Serial + // + #define X_SERIAL_TX_PIN PC14 // BTT Rumba32 only uses 1 pin for UART + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PE4 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE0 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PC13 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD5 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PD1 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN +#endif diff --git a/src/pins/stm32f4/pins_RUMBA32_MKS.h b/src/pins/stm32f4/pins_RUMBA32_MKS.h new file mode 100644 index 0000000..3833a3a --- /dev/null +++ b/src/pins/stm32f4/pins_RUMBA32_MKS.h @@ -0,0 +1,87 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Pin assignments for the MKS RUMBA32 + * + * https://github.com/makerbase-mks/MKS-RUMBA32 + * + * The MKS and Aus3D versions have the same pinout but the MKS version + * has some added resistors and LEDs. The resistors needed for the + * TMC2208/9 UART interface are among the additions. Also added were + * connectors and resistors dedicated to the TMC2130 sensorless homing + * interface. + */ + +#define BOARD_INFO_NAME "MKS RUMBA32" + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#endif + +#include "pins_RUMBA32_common.h" + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN PA3 + #define X_SERIAL_RX_PIN PC14 + + #define Y_SERIAL_TX_PIN PA4 + #define Y_SERIAL_RX_PIN PE4 + + #define Z_SERIAL_TX_PIN PD13 + #define Z_SERIAL_RX_PIN PE0 + + #define E0_SERIAL_TX_PIN PD14 + #define E0_SERIAL_RX_PIN PC13 + + #define E1_SERIAL_TX_PIN PD15 + #define E1_SERIAL_RX_PIN PD5 + + #define E2_SERIAL_TX_PIN PD12 + #define E2_SERIAL_RX_PIN PD1 +#endif diff --git a/src/pins/stm32f4/pins_RUMBA32_common.h b/src/pins/stm32f4/pins_RUMBA32_common.h new file mode 100644 index 0000000..12871be --- /dev/null +++ b/src/pins/stm32f4/pins_RUMBA32_common.h @@ -0,0 +1,179 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Common pin assignments for all RUMBA32 boards + */ + +#include "env_validate.h" + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "RUMBA32 boards support up to 3 hotends / E steppers." +#endif + +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// Use soft PWM for fans - PWM is not working properly when paired with STM32 Arduino Core v1.7.0 +// This can be removed when Core version is updated and PWM behaviour is fixed. +#define FAN_SOFT_PWM_REQUIRED + +// +// Configure Timers +// TIM6 is used for TONE +// TIM7 is used for SERVO +// TIMER_SERIAL defaults to TIM7 and must be overridden in the platformio.h file if SERVO will also be used. +// This will be difficult to solve from the Arduino IDE, without modifying the RUMBA32 variant +// included with the STM32 framework. + +#define STEP_TIMER 10 +#define TEMP_TIMER 14 + +// +// Limit Switches +// +#define X_MIN_PIN PB12 +#define X_MAX_PIN PB13 +#define Y_MIN_PIN PB15 +#define Y_MAX_PIN PD8 +#define Z_MIN_PIN PD9 +#define Z_MAX_PIN PD10 + +// +// Steppers +// +#define X_STEP_PIN PA0 +#define X_DIR_PIN PC15 +#define X_ENABLE_PIN PC11 +#define X_CS_PIN PC14 + +#define Y_STEP_PIN PE5 +#define Y_DIR_PIN PE6 +#define Y_ENABLE_PIN PE3 +#define Y_CS_PIN PE4 + +#define Z_STEP_PIN PE1 +#define Z_DIR_PIN PE2 +#define Z_ENABLE_PIN PB7 +#define Z_CS_PIN PE0 + +#define E0_STEP_PIN PB5 +#define E0_DIR_PIN PB6 +#define E0_ENABLE_PIN PC12 +#define E0_CS_PIN PC13 + +#define E1_STEP_PIN PD6 +#define E1_DIR_PIN PD7 +#define E1_ENABLE_PIN PD4 +#define E1_CS_PIN PD5 + +#define E2_STEP_PIN PD2 +#define E2_DIR_PIN PD3 +#define E2_ENABLE_PIN PD0 +#define E2_CS_PIN PD1 + +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PA7 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PA6 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PA5 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC4 +#define TEMP_1_PIN PC3 +#define TEMP_2_PIN PC2 +#define TEMP_3_PIN PC1 +#define TEMP_BED_PIN PC0 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC6 +#define HEATER_1_PIN PC7 +#define HEATER_2_PIN PC8 +#define HEATER_BED_PIN PA1 + +#define FAN_PIN PC9 +#define FAN1_PIN PA8 + +// +// SPI +// +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 + +// +// Misc. Functions +// +#define LED_PIN PB14 +#define PS_ON_PIN PE11 +#define KILL_PIN PC5 + +#define SDSS PA2 +#define SD_DETECT_PIN PB0 +#define BEEPER_PIN PE8 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #define BTN_EN1 PB2 + #define BTN_EN2 PB1 + #define BTN_ENC PE7 + + #define LCD_PINS_RS PE10 + #define LCD_PINS_ENABLE PE9 + #define LCD_PINS_D4 PE12 + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_CS PE13 + #define DOGLCD_A0 PE14 + #endif + + #if IS_ULTIPANEL + #define LCD_PINS_D5 PE13 + #define LCD_PINS_D6 PE14 + #define LCD_PINS_D7 PE15 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 640 +#endif diff --git a/src/pins/stm32f4/pins_STEVAL_3DP001V1.h b/src/pins/stm32f4/pins_STEVAL_3DP001V1.h new file mode 100644 index 0000000..0b527a6 --- /dev/null +++ b/src/pins/stm32f4/pins_STEVAL_3DP001V1.h @@ -0,0 +1,325 @@ +/** + * 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 . + * + */ +#pragma once + +// Source: https://github.com/stm32duino/Arduino_Core_STM32/blob/master/variants/ST3DP001_EVAL/variant.cpp + +/** + * HOW TO COMPILE + * + * PlatformIO - Use the STM32F401VE_STEVAL environment (or the "Auto Build Marlin" extension). + * + * Arduino - Tested with 1.8.10 + * Install library per https://github.com/stm32duino/Arduino_Core_STM32 + * Make the following selections under the TOOL menu in the Arduino IDE + * Board: "3D printer boards" + * Board part number: "STEVAL-3DP001V1" + * U(S)ART support: "Enabled (generic "Serial")" + * USB support (if available): "CDC (no generic "Serial")" + * Optimize: "Smallest (-Os default)" + * C Runtime Library: "newlib Nano (default)" + */ + +#include "env_validate.h" + +#ifndef MACHINE_NAME + #define MACHINE_NAME "STEVAL-3DP001V1" +#endif + +// +// Limit Switches +// +#define X_MIN_PIN PD8 // X_STOP +#define Y_MIN_PIN PD9 // Y_STOP +#define Z_MIN_PIN PD10 // Z_STOP + +#define X_MAX_PIN PD0 // W_STOP +#define Y_MAX_PIN PA8 // V_STOP +#define Z_MAX_PIN PD11 // U_STOP + +// +// Z Probe (when not Z_MIN_PIN) +// +//#ifndef Z_MIN_PROBE_PIN +// #define Z_MIN_PROBE_PIN PA4 // SPI1_CS +//#endif + +// +// Filament runout +// +//#define FIL_RUNOUT_PIN PA3 // BED_THERMISTOR_3 + +// +// Steppers +// + +#define X_STEP_PIN PE14 // X_PWM +#define X_DIR_PIN PE15 // X_DIR +#define X_ENABLE_PIN PE13 // X_RESET +#define X_CS_PIN PA4 // SPI1_CS + +#define Y_STEP_PIN PB10 // Y_PWM +#define Y_DIR_PIN PE9 // Y_DIR +#define Y_ENABLE_PIN PE10 // Y_RESET +#define Y_CS_PIN PA4 // SPI1_CS + +#define Z_STEP_PIN PC6 // Z_PWM +#define Z_DIR_PIN PC0 // Z_DIR +#define Z_ENABLE_PIN PC15 // Z_RESET +#define Z_CS_PIN PA4 // SPI1_CS + +#define E0_STEP_PIN PD12 // E1_PW +#define E0_DIR_PIN PC13 // E1_DIR +#define E0_ENABLE_PIN PC14 // E1_RESET +#define E0_CS_PIN PA4 // SPI1_CS + +#define E1_STEP_PIN PE5 // E2_PWM +#define E1_DIR_PIN PE6 // E2_DIR +#define E1_ENABLE_PIN PE4 // E2_RESET +#define E1_CS_PIN PA4 // SPI1_CS + +#define E2_STEP_PIN PB8 // E3_PWM +#define E2_DIR_PIN PE2 // E3_DIR +#define E2_ENABLE_PIN PE3 // E3_RESET +#define E2_CS_PIN PA4 // SPI1_CS + +// needed to pass a sanity check +#define X2_CS_PIN PA4 // SPI1_CS +#define Y2_CS_PIN PA4 // SPI1_CS +#define Z2_CS_PIN PA4 // SPI1_CS +#define Z3_CS_PIN PA4 // SPI1_CS +#define E3_CS_PIN PA4 // SPI1_CS +#define E4_CS_PIN PA4 // SPI1_CS +#define E5_CS_PIN PA4 // SPI1_CS + +#if HAS_L64XX + #define L6470_CHAIN_SCK_PIN PA5 // SPI1_SCK + #define L6470_CHAIN_MISO_PIN PA6 // SPI1_MISO + #define L6470_CHAIN_MOSI_PIN PA7 // SPI1_MOSI + #define L6470_CHAIN_SS_PIN PA4 // SPI1_CS + + //#define SD_SCK_PIN L6470_CHAIN_SCK_PIN + //#define SD_MISO_PIN L6470_CHAIN_MISO_PIN + //#define SD_MOSI_PIN L6470_CHAIN_MOSI_PIN +#else + //#define SD_SCK_PIN PB13 // SPI2_SCK + //#define SD_MISO_PIN PB14 // SPI2_MISO + //#define SD_MOSI_PIN PB15 // SPI2_MOSI +#endif + +/** + * Macro to reset/enable L6474 stepper drivers + * + * IMPORTANT - To disable (bypass) L6474s, install the corresponding + * resistors (R11 - R17) and change the "V" to "0" for the + * corresponding pins here: + */ +#define ENABLE_RESET_L64XX_CHIPS(V) do{ OUT_WRITE(X_ENABLE_PIN, V); \ + OUT_WRITE(Y_ENABLE_PIN, V); \ + OUT_WRITE(Z_ENABLE_PIN, V); \ + OUT_WRITE(E0_ENABLE_PIN,V); \ + OUT_WRITE(E1_ENABLE_PIN,V); \ + OUT_WRITE(E2_ENABLE_PIN,V); \ + }while(0) + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input 3 +#define TEMP_1_PIN PA1 // Analog Input 4 +#define TEMP_2_PIN PA2 // Analog Input 5 +#define TEMP_BED_PIN PC2 // Analog Input 0 +#define TEMP_BED_1_PIN PC3 // Analog Input 1 +#define TEMP_BED_2_PIN PA3 // Analog Input 2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC7 // E1_HEAT_PWM +#define HEATER_1_PIN PB0 // E2_HEAT_PWM +#define HEATER_2_PIN PB1 // E3_HEAT_PWM +#define HEATER_BED_PIN PD14 // BED_HEAT_1 FET +#define HEATER_BED_1_PIN PD13 // BED_HEAT_2 FET +#define HEATER_BED_2_PIN PD15 // BED_HEAT_3 FET + +#define FAN_PIN PC4 // E1_FAN PWM pin, Part cooling fan FET +#define FAN1_PIN PC5 // E2_FAN PWM pin, Extruder fan FET +#define FAN2_PIN PE8 // E3_FAN PWM pin, Controller fan FET + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PC5 // FAN1_PIN +#endif + +// +// Misc functions +// +#define LED_PIN -1 // PE1 Green LED Heartbeat +#define PS_ON_PIN -1 +#define KILL_PIN -1 +#define POWER_LOSS_PIN -1 // PWR_LOSS / nAC_FAULT + +// +// LCD / Controller +// +//#define SD_DETECT_PIN PA15 // SD_CARD_DETECT +//#define BEEPER_PIN PC9 // SDIO_D1 +//#define LCD_PINS_RS PE9 // Y_DIR +//#define LCD_PINS_ENABLE PE8 // E3_FAN +//#define LCD_PINS_D4 PB12 // SPI2_CS +//#define LCD_PINS_D5 PB13 // SPI2_SCK +//#define LCD_PINS_D6 PB14 // SPI2_MISO +//#define LCD_PINS_D7 PB15 // SPI2_MOSI +//#define BTN_EN1 PC4 // E1_FAN +//#define BTN_EN2 PC5 // E2_FAN +//#define BTN_ENC PC3 // BED_THERMISTOR_2 + +// +// Extension pins +// +//#define EXT0_PIN PB0 // E2_HEAT +//#define EXT1_PIN PB1 // E3_HEAT +//#define EXT2_PIN PB2 // not used (tied to ground) +//#define EXT3_PIN PD8 // X_STOP +//#define EXT4_PIN PD9 // Y_STOP +//#define EXT5_PIN PD10 // Z_STOP +//#define EXT6_PIN PD11 // U_STOP +//#define EXT7_PIN PD12 // E1_PWM +//#define EXT8_PIN PB10 // Y_PWM + +// WIFI +// PD3 CTS +// PD4 RTS +// PD5 TX +// PD6 RX +// PB5 WIFI_WAKEUP +// PE11 WIFI_RESET +// PE12 WIFI_BOOT + +// I2C USER +// PB7 SDA +// PB6 SCL + +// JTAG +// PA13 JTAG_TMS/SWDIO +// PA14 JTAG_TCK/SWCLK +// PB3 JTAG_TDO/SWO + +// +// Onboard SD support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + + #define SDIO_SUPPORT // Use SDIO for onboard SD + #if DISABLED(SDIO_SUPPORT) + #define SOFTWARE_SPI // Use soft SPI for onboard SD + #define SDSS PC11 + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 + #endif + + //#define SD_DETECT_PIN PA15 + +#endif + +#ifndef SDSS + #define SDSS PA4 // SPI1_CS +#endif + +// OTG +// PA11 OTG_DM +// PA12 OTG_DP + +// USER_PINS +// PD7 USER3 +// PB9 USER1 +// PE0 USER2 +// PB4 USER4 + +// USERKET +// PE7 USER_BUTTON + +// PA9 TX +// PA10 RX + +// IR/PROBE +// PD1 IR_OUT +// PC1 IR_ON + +/** + * Logical pin vs. port/pin cross reference + * + * PA0 E1_THERMISTOR PD0 W_STOP + * PA1 E2_THERMISTOR PD1 IR_OUT + * PA2 E3_THERMISTOR PD2 SDIO_CMD + * PA3 BED_THERMISTOR_3 PD3 CTS + * PA4 SPI1_CS PD4 RTS + * PA5 SPI1_SCK PD5 TX + * PA6 SPI1_MISO PD6 RX + * PA7 SPI1_MOSI PD7 USER3 + * PA8 V_STOP PD8 X_STOP + * PA9 TX PD9 Y_STOP + * PA10 RX PD10 Z_STOP + * PA11 OTG_DM PD11 U_STOP + * PA12 OTG_DP PD12 E1_PWM + * PA13 JTAG_TMS/SWDIO PD13 BED_HEAT_2 + * PA14 JTAG_TCK/SWCLK PD14 BED_HEAT_1 + * PA15 SD_CARD_DETECT PD15 BED_HEAT_3 + * + * PB0 E2_HEAT_PWM PE0 USER2 + * PB1 E3_HEAT_PWM PE1 STATUS_LED + * PB2 --- PE2 E3_DIR + * PB3 JTAG_TDO/SWO PE3 E3_RESET + * PB4 USER4 PE4 E2_RESET + * PB5 WIFI_WAKEUP PE5 E2_PWM + * PB6 SCL PE6 E2_DIR + * PB7 SDA PE7 USER_BUTTON + * PB8 E3_PWM PE8 E3_FAN + * PB9 USER1 PE9 Y_DIR + * PB10 Y_PWM PE10 Y_RESET + * PB11 --- PE11 WIFI_RESET + * PB12 SPI2_CS PE12 WIFI_BOOT + * PB13 SPI2_SCK PE13 X_RESET + * PB14 SPI2_MISO PE14 X_PWM + * PB15 SPI2_MOSI PE15 X_DIR + * + * PC0 Z_DIR + * PC1 IR_ON + * PC2 BED_THERMISTOR_1 + * PC3 BED_THERMISTOR_2 + * PC4 E1_FAN + * PC5 E2_FAN + * PC6 Z_PWM + * PC7 E1_HEAT_PWM + * PC8 SDIO_D0 + * PC9 SDIO_D1 + * PC10 SDIO_D2 + * PC11 SDIO_D3 + * PC12 SDIO_CK + * PC13 E1_DIR + * PC14 E1_RESET + * PC15 Z_RESET + */ diff --git a/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h b/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h new file mode 100644 index 0000000..1a75a85 --- /dev/null +++ b/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h @@ -0,0 +1,275 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#define BOARD_INFO_NAME "TH3D EZBoard V2" +#define BOARD_WEBSITE_URL "th3dstudio.com" + +//#define V3_EZABL_ON_SERVO // As in TH3D Firmware Config + +#define DISABLE_JTAGSWD // Disabling J-tag and Debug via SWD + +// Onboard I2C EEPROM +#if NO_EEPROM_SELECTED + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x1000 // 4K + #define I2C_SCL_PIN PB6 + #define I2C_SDA_PIN PB7 + #undef NO_EEPROM_SELECTED +#endif + +// +// Neopixels +// +#define NEOPIXEL_PIN PA8 + +// +// Servos +// +#if ENABLED(V3_EZABL_ON_SERVO) + #define SERVO0_PIN -1 +#else + #define SERVO0_PIN PA2 +#endif + +// +// Limit Switches +// +#if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING) + // Sensorless homing pins + #if ENABLED(X_AXIS_SENSORLESS_HOMING) + #define X_STOP_PIN PB4 + #else + #define X_STOP_PIN PC1 + #endif + + #if ENABLED(Y_AXIS_SENSORLESS_HOMING) + #define Y_STOP_PIN PB9 + #else + #define Y_STOP_PIN PC2 + #endif + + //#define Z_STOP_PIN PC15 // Don't use sensorless homing on Z! + + #define E_STOP_PIN PB10 +#else + // Standard Endstop Pins + #define X_STOP_PIN PC1 + #define Y_STOP_PIN PC2 +#endif + +#if ENABLED(V3_EZABL_ON_SERVO) + #define Z_STOP_PIN PA2 +#else + #define Z_STOP_PIN PC3 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC0 +#endif + +// +// Steppers +// +#define X_STEP_PIN PB3 +#define X_DIR_PIN PD2 +#define X_ENABLE_PIN PB5 + +#define Y_STEP_PIN PB8 +#define Y_DIR_PIN PC13 +#define Y_ENABLE_PIN PC12 + +#define Z_STEP_PIN PA3 +#define Z_DIR_PIN PB1 +#define Z_ENABLE_PIN PC14 + +#define E0_STEP_PIN PA15 +#define E0_DIR_PIN PB11 +#define E0_ENABLE_PIN PB2 + +#if HAS_TMC_UART + // + // Hardware Serial on UART4, Single Wire, 0-3 addresses + // + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN PC11 + + #define Y_SERIAL_TX_PIN PC10 + #define Y_SERIAL_RX_PIN PC11 + + #define Z_SERIAL_TX_PIN PC10 + #define Z_SERIAL_RX_PIN PC11 + + #define E0_SERIAL_TX_PIN PC10 + #define E0_SERIAL_RX_PIN PC11 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 1 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 2 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + +// +// Temp Sensors +// 3.3V max when defined as an Analog Input! +// +#define TEMP_0_PIN PA1 // Analog Input PA1 +#define TEMP_BED_PIN PA0 // Analog Input PA0 + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PC9 +#define HEATER_0_PIN PC8 +#ifndef FAN_PIN + #define FAN_PIN PC6 +#endif +#define FAN1_PIN PC7 + +// +// Auto fans +// +#define AUTO_FAN_PIN PC7 +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN AUTO_FAN_PIN +#endif +#ifndef E2_AUTO_FAN_PIN + #define E2_AUTO_FAN_PIN AUTO_FAN_PIN +#endif + +// +// SD Card +// + +#define SDCARD_CONNECTION ONBOARD + +//#define SOFTWARE_SPI +#define CUSTOM_SPI_PINS +#define SDSS PA4 +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 +#define SD_SS_PIN SDSS +//#define SD_DETECT_PIN -1 +//#define ONBOARD_SD_CS_PIN SDSS + +// +// LCD / Controller +// + +/** + * ------ + * PA14 | 1 2 | PB0 + * PC4 | 3 4 | -- + * PC5 | 5 6 PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + * EXP1 + * + * LCD_PINS_D5, D6, and D7 are not present in the EXP1 connector, and will need to be + * defined to use the REPRAP_DISCOUNT_SMART_CONTROLLER. + * + * A remote SD card is currently not supported because the pins routed to the EXP2 + * connector are shared with the onboard SD card. + */ +#define EXP1_01_PIN PA14 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PC4 +//#define EXP1_04_PIN -1 +#define EXP1_05_PIN PC5 +#define EXP1_06_PIN PB13 +#define EXP1_07_PIN PB12 +#define EXP1_08_PIN PB15 + +#if ENABLED(CR10_STOCKDISPLAY) + /** ------ + * BEEPER | 1 2 | ENC + * EN1 | 3 4 | RESET + * EN2 | 5 6 LCD_D4 + * LCD_RS | 7 8 | LCD_EN + * GND | 9 10 | 5V + * ------ + */ + #ifdef DISABLE_JTAGSWD + #define BEEPER_PIN EXP1_01_PIN // Not connected in dev board + #endif + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + //#define KILL_PIN -1 + + #define BOARD_ST7920_DELAY_1 600 + #define BOARD_ST7920_DELAY_2 750 + #define BOARD_ST7920_DELAY_3 750 + +#elif ENABLED(MKS_MINI_12864) + /** ------ + * SCK | 1 2 | ENC + * EN1 | 3 4 | -- + * EN2 | 5 6 A0 + * CS | 7 8 | MOSI + * GND | 9 10 | 5V + * ------ + */ + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN + #define LCD_CONTRAST_INIT 160 + #define LCD_CONTRAST_MIN 120 + #define LCD_CONTRAST_MAX 180 + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + +#elif HAS_WIRED_LCD + + #error "Only CR10_STOCKDISPLAY or MKS_MINI_12864 are supported with TH3D EZBoard V2." + +#endif + +#if EITHER(CR10_STOCKDISPLAY, MKS_MINI_12864) + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN +#endif diff --git a/src/pins/stm32f4/pins_VAKE403D.h b/src/pins/stm32f4/pins_VAKE403D.h new file mode 100644 index 0000000..21ab9d0 --- /dev/null +++ b/src/pins/stm32f4/pins_VAKE403D.h @@ -0,0 +1,226 @@ +/** + * 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 . + * + */ +#pragma once + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "STM32F4 VAkE supports up to 2 hotends / E steppers." +#endif + +#define DEFAULT_MACHINE_NAME "STM32F446VET6" +#define BOARD_INFO_NAME "STM32F4 VAkE" + +//#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4K + +// +// Servos +// +//#define SERVO0_PIN PE13 +//#define SERVO1_PIN PE14 + +// +// Limit Switches +// +#define X_STOP_PIN PE10 +#define Y_STOP_PIN PE9 +#define Z_STOP_PIN PE8 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PA4 +#endif + +// +// Filament runout +// +#define FIL_RUNOUT_PIN PA3 + +// +// Steppers +// + +#define STEPPER_ENABLE_PIN PB2 + +#define X_STEP_PIN PC6 // X_STEP +#define X_DIR_PIN PC7 // X_DIR +#define X_ENABLE_PIN PB2 // +#ifndef X_CS_PIN + #define X_CS_PIN PC8 // X_CS +#endif + +#define Y_STEP_PIN PD9 // Y_STEP +#define Y_DIR_PIN PD10 // Y_DIR +#define Y_ENABLE_PIN PB2 // +#ifndef Y_CS_PIN + #define Y_CS_PIN PD11 // Y_CS +#endif + +#define Z_STEP_PIN PE15 // Z_STEP +#define Z_DIR_PIN PB10 // Z_DIR +#define Z_ENABLE_PIN PB2 +#ifndef Z_CS_PIN + #define Z_CS_PIN PD8 +#endif + +#define E0_STEP_PIN PB1 +#define E0_DIR_PIN PB13 +#define E0_ENABLE_PIN PB2 +#ifndef E0_CS_PIN + #define E0_CS_PIN PE11 +#endif + +#define E1_STEP_PIN PC4 +#define E1_DIR_PIN PC5 +#define E1_ENABLE_PIN PB2 +#ifndef E1_CS_PIN + #define E1_CS_PIN PB0 +#endif + +#define SD_SCK_PIN PE12 // PA5 // SPI1 for SD card +#define SD_MISO_PIN PE13 // PA6 +#define SD_MOSI_PIN PE14 // PA7 + +// added for SD card : optional or not ??? +//#define SD_CHIP_SELECT_PIN SDSS // The default chip select pin for the SD card is SS. +// The following three pins must not be redefined for hardware SPI. +//#define SPI_MOSI_PIN SD_MOSI_PIN // SPI Master Out Slave In pin +//#define SPI_MISO_PIN SD_MISO_PIN // SPI Master In Slave Out pin +//#define SPI_SCK_PIN SD_SCK_PIN // SPI Clock pin + +// +// Temperature Sensors (Analog inputs) +// + +#define TEMP_0_PIN PC0 // Analog Input +#define TEMP_1_PIN PC1 // Analog Input +#define TEMP_2_PIN PC2 // Analog Input +#define TEMP_3_PIN PC3 // Analog Input +#define TEMP_BED_PIN PC3 // Analog Input + +// +// Heaters / Fans +// + +#define HEATER_0_PIN PD15 +#define HEATER_1_PIN PD14 +#define HEATER_BED_PIN PD12 + +#ifndef FAN_PIN + #define FAN_PIN PD13 +#endif +#define FAN1_PIN PB5 // PA0 +#define FAN2_PIN PB4 // PA1 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PD13 +#endif + +// +// Misc. Functions +// + +//#define CASE_LIGHT_PIN_CI PF13 +//#define CASE_LIGHT_PIN_DO PF14 +//#define NEOPIXEL_PIN PF13 + +// +// Průša i3 MK2 Multi Material Multiplexer Support +// +#if HAS_PRUSA_MMU1 + //#define E_MUX0_PIN PG3 + //#define E_MUX1_PIN PG4 +#endif + +#define LED_PIN PB14 // Alive +#define PS_ON_PIN PE0 +#define KILL_PIN PD5 +#define POWER_LOSS_PIN PA4 // ?? Power loss / nAC_FAULT + +#if ENABLED(SDSUPPORT) + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SS_PIN PB15 // USD_CS -> CS for onboard SD +#endif + +/** + * ------ ------ + * PC9 | 1 2 | PB12 ? | 1 2 | ? + * PD7 | 3 4 | PC12 PD6 | 3 4 | ? + * PD1 | 5 6 PD2 PD0 | 5 6 ? + * PD3 | 7 8 | PD4 PB7 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PB12 +#define EXP1_03_PIN PD7 +#define EXP1_04_PIN PC12 +#define EXP1_05_PIN PD1 +#define EXP1_06_PIN PD2 +#define EXP1_07_PIN PD3 +#define EXP1_08_PIN PD4 + +//#define EXP2_01_PIN ? +//#define EXP2_02_PIN ? +#define EXP2_03_PIN PD6 +//#define EXP2_04_PIN ? +#define EXP2_05_PIN PD0 +//#define EXP2_06_PIN ? +#define EXP2_07_PIN PB7 +#define EXP2_08_PIN -1 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #if ENABLED(SDSUPPORT) + #define SDSS PB6 // CS for SD card in LCD + #endif + + #define BEEPER_PIN EXP1_01_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + +#endif + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 96 + #define BOARD_ST7920_DELAY_2 48 + #define BOARD_ST7920_DELAY_3 715 +#endif diff --git a/src/pins/stm32f7/pins_NUCLEO_F767ZI.h b/src/pins/stm32f7/pins_NUCLEO_F767ZI.h new file mode 100644 index 0000000..48f986e --- /dev/null +++ b/src/pins/stm32f7/pins_NUCLEO_F767ZI.h @@ -0,0 +1,197 @@ +/** + * 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 . + * + */ +#pragma once + +#if NOT_TARGET(STM32F767xx) + #error "Oops! Select an STM32F767 environment" +#endif + +#define BOARD_INFO_NAME "NUCLEO-F767ZI" +#define DEFAULT_MACHINE_NAME "Prototype Board" + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + // Not yet supported on F7 hardware + //#define FLASH_EEPROM_LEVELING +#endif + +/** + * Timer assignments + * + * TIM1 - + * TIM2 - Hardware PWM (Fan/Heater Pins) + * TIM3 - Hardware PWM (Servo Pins) + * TIM4 - STEP_TIMER (Marlin) + * TIM5 - + * TIM6 - TIMER_TONE (variant.h) + * TIM7 - TIMER_SERVO (variant.h) + * TIM9 - TIMER_SERIAL (platformio.ini) + * TIM10 - For some reason trips Watchdog when used for SW Serial + * TIM11 - + * TIM12 - + * TIM13 - + * TIM14 - TEMP_TIMER (Marlin) + * + */ +#define STEP_TIMER 4 +#define TEMP_TIMER 14 + +/** + * These pin assignments are arbitrary and intending for testing purposes. + * Assignments may not be ideal, and not every assignment has been tested. + * Proceed at your own risk. + * _CN7_ + * (X_STEP) PC6 | · · | PB8 (X_EN) + * (X_DIR) PB15 | · · | PB9 (X_CS) + * (LCD_D4) PB13 | · · | AVDD + * _CN8_ PB12 | · · | GND + * -- | · · | PC8 (HEATER_0) PA15 | · · | PA5 (SCLK) + * IOREF | · · | PC9 (BEEPER) PC7 | · · | PA6 (MISO) + * RESET | · · | PC10 (SERVO1_PIN) PB5 | · · | PA7 (MOSI) + * +3.3V | · · | PC11 (HEATER_BED) PB3 | · · | PD14 (SD_DETECT) + * +5V | · · | PC12 (SDSS) PA4 | · · | PD15 (LCD_ENABLE) + * GND | · · | PD2 (SERVO0_PIN) PB4 | · · | PF12 (LCD_RS) + * GND | · · | PG2  ̄ ̄ ̄ + * VIN | · · | PG3 + *  ̄ ̄ ̄ _CN10 + * AVDD | · · | PF13 (BTN_EN1) + * _CN9_ AGND | · · | PE9 (BTN_EN2) + * (TEMP_0) PA3 | · · | PD7 GND | · · | PE11 (BTN_ENC) + * (TEMP_BED) PC0 | · · | PD6 PB1 | · · | PF14 + * PC3 | · · | PD5 PC2 | · · | PE13 + * PF3 | · · | PD4 PF4 | · · | PF15 + * PF5 | · · | PD3 (E_STEP) PB6 | · · | PG14 (E_EN) + * PF10 | · · | GND (E_DIR) PB2 | · · | PG9 (E_CS) + * -- | · · | PE2 GND | · · | PE8 + * PA7 | · · | PE4 PD13 | · · | PE7 + * PF2 | · · | PE5 PD12 | · · | GND + * (Y_STEP) PF1 | · · | PE6 (Y_EN) (Z_STEP) PD11 | · · | PE10 (Z_EN) + * (Y_DIR) PF0 | · · | PE3 (Y_CS) (Z_DIR) PE2 | · · | PE12 (Z_CS) + * GND | · · | PF8 GND | · · | PE14 + * (Z_MAX) PD0 | · · | PF7 (X_MIN) PA0 | · · | PE15 + * (Z_MIN) PD1 | · · | PF9 (X_MAX) PB0 | · · | PB10 (FAN) + * (Y_MAX) PG0 | · · | PG1 (Y_MIN) PE0 | · · | PB11 (FAN1) + *  ̄ ̄ ̄  ̄ ̄ ̄ ̄ + */ + +#define X_MIN_PIN PF7 +#define X_MAX_PIN PF9 +#define Y_MIN_PIN PG1 +#define Y_MAX_PIN PG0 +#define Z_MIN_PIN PD1 +#define Z_MAX_PIN PD0 + +// +// Steppers +// +#define X_STEP_PIN PC6 +#define X_DIR_PIN PB15 +#define X_ENABLE_PIN PB8 +#define X_CS_PIN PB9 + +#define Y_STEP_PIN PF1 +#define Y_DIR_PIN PF0 +#define Y_ENABLE_PIN PE6 +#define Y_CS_PIN PE3 + +#define Z_STEP_PIN PD11 +#define Z_DIR_PIN PE2 +#define Z_ENABLE_PIN PE10 +#define Z_CS_PIN PE12 + +#define E0_STEP_PIN PB6 +#define E0_DIR_PIN PB2 +#define E0_ENABLE_PIN PG14 +#define E0_CS_PIN PG9 + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PB9 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PG9 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA3 +#define TEMP_BED_PIN PC0 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA15 // PWM Capable, TIM2_CH1 +#define HEATER_BED_PIN PB3 // PWM Capable, TIM2_CH2 + +#ifndef FAN_PIN + #define FAN_PIN PB10 // PWM Capable, TIM2_CH3 +#endif +#define FAN1_PIN PB11 // PWM Capable, TIM2_CH4 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN +#endif + +// +// Servos +// +#define SERVO0_PIN PB4 // PWM Capable, TIM3_CH1 +#define SERVO1_PIN PB5 // PWM Capable, TIM3_CH2 + +// SPI for external SD Card (Not entirely sure this will work) +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 +#define SD_SS_PIN PA4 +#define SDSS PA4 + +#define LED_PIN LED_BLUE + +// +// LCD / Controller +// +#if IS_RRD_FG_SC + #define BEEPER_PIN PC7 // LCD_BEEPER + #define BTN_ENC PE11 // BTN_ENC + #define SD_DETECT_PIN PD14 + #define LCD_PINS_RS PF12 // LCD_RS + #define LCD_PINS_ENABLE PD15 // LCD_EN + #define LCD_PINS_D4 PB13 // LCD_D4 + #define BTN_EN1 PF13 // BTN_EN1 + #define BTN_EN2 PE9 // BTN_EN2 + + #define BOARD_ST7920_DELAY_1 125 + #define BOARD_ST7920_DELAY_2 63 + #define BOARD_ST7920_DELAY_3 780 +#endif diff --git a/src/pins/stm32f7/pins_REMRAM_V1.h b/src/pins/stm32f7/pins_REMRAM_V1.h new file mode 100644 index 0000000..c4feba6 --- /dev/null +++ b/src/pins/stm32f7/pins_REMRAM_V1.h @@ -0,0 +1,136 @@ +/** + * 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 . + * + */ +#pragma once + +#if NOT_TARGET(STM32F7xx) + #error "Oops! Select an STM32F7 board in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "RemRam v1" +#define DEFAULT_MACHINE_NAME "RemRam" + +#if NO_EEPROM_SELECTED + #define SRAM_EEPROM_EMULATION // Emulate the EEPROM using Backup SRAM +#endif + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "RemRam only supports 1 hotend / E stepper." +#endif + +// +// Limit Switches +// +#if DISABLED(SENSORLESS_HOMING) + #define X_MIN_PIN 58 + #define X_MAX_PIN 59 + #define Y_MIN_PIN 60 + #define Y_MAX_PIN 61 + #define Z_MAX_PIN 63 +#else + #define X_STOP_PIN 36 + #define Y_STOP_PIN 39 + #define Z_MAX_PIN 42 +#endif +#define Z_MIN_PIN 62 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 26 // EXT_D1 +#endif + +// +// Steppers +// +#define X_STEP_PIN 22 +#define X_DIR_PIN 35 +#define X_ENABLE_PIN 34 +#define X_CS_PIN 14 + +#define Y_STEP_PIN 23 +#define Y_DIR_PIN 38 +#define Y_ENABLE_PIN 37 +#define Y_CS_PIN 15 + +#define Z_STEP_PIN 24 +#define Z_DIR_PIN 41 +#define Z_ENABLE_PIN 40 +#define Z_CS_PIN 16 + +#define E0_STEP_PIN 25 +#define E0_DIR_PIN 44 +#define E0_ENABLE_PIN 43 +#define E0_CS_PIN 10 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 64 // THERM_1 +#define TEMP_1_PIN 65 // THERM_2 +#define TEMP_BED_PIN 66 // THERM_3 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 33 +#define HEATER_BED_PIN 31 + +#ifndef FAN_PIN + #define FAN_PIN 30 // "FAN1" +#endif +#define FAN1_PIN 32 // "FAN2" + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN 32 +#endif + +// +// Servos +// +#define SERVO0_PIN 26 // PWM_EXT1 +#define SERVO1_PIN 27 // PWM_EXT2 + +#define SDSS 57 // Onboard SD card reader +//#define SDSS 9 // LCD SD card reader +#define LED_PIN 21 // STATUS_LED + +// +// LCD / Controller +// +#define SD_DETECT_PIN 56 // SD_CARD_DET +#define BEEPER_PIN 46 // LCD_BEEPER +#define LCD_PINS_RS 49 // LCD_RS +#define LCD_PINS_ENABLE 48 // LCD_EN +#define LCD_PINS_D4 50 // LCD_D4 +#define LCD_PINS_D5 51 // LCD_D5 +#define LCD_PINS_D6 52 // LCD_D6 +#define LCD_PINS_D7 53 // LCD_D7 +#define BTN_EN1 54 // BTN_EN1 +#define BTN_EN2 55 // BTN_EN2 +#define BTN_ENC 47 // BTN_ENC + +// +// Timers +// + +#define STEP_TIMER 2 diff --git a/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h b/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h new file mode 100644 index 0000000..956cb71 --- /dev/null +++ b/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h @@ -0,0 +1,439 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +//#define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR Mini E3 V3.0" +#endif + +#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#define LED_PIN PD8 + +// Onboard I2C EEPROM +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #undef NO_EEPROM_SELECTED + #define I2C_EEPROM + #define SOFT_I2C_EEPROM // Force the use of Software I2C + #define I2C_SCL_PIN PB6 + #define I2C_SDA_PIN PB7 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// Servos +// +#define SERVO0_PIN PA1 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PC0 // X-STOP +#define Y_STOP_PIN PC1 // Y-STOP +#define Z_STOP_PIN PC2 // Z-STOP + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PC14 // PROBE + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // E0-STOP +#endif + +// +// Power-loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC12 // Power Loss Detection: PWR-DET +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN PC13 // Power Supply Control +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PB14 +#define X_STEP_PIN PB13 +#define X_DIR_PIN PB12 + +#define Y_ENABLE_PIN PB11 +#define Y_STEP_PIN PB10 +#define Y_DIR_PIN PB2 + +#define Z_ENABLE_PIN PB1 +#define Z_STEP_PIN PB0 +#define Z_DIR_PIN PC5 + +#define E0_ENABLE_PIN PD1 +#define E0_STEP_PIN PB3 +#define E0_DIR_PIN PB4 + +#if HAS_TMC_UART + /** + * TMC220x stepper drivers + * Hardware serial communication ports + */ + #define X_HARDWARE_SERIAL MSerial4 + #define Y_HARDWARE_SERIAL MSerial4 + #define Z_HARDWARE_SERIAL MSerial4 + #define E0_HARDWARE_SERIAL MSerial4 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input "TH0" +#define TEMP_BED_PIN PC4 // Analog Input "TB0" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC8 // "HE" +#define HEATER_BED_PIN PC9 // "HB" +#define FAN_PIN PC6 // "FAN0" +#define FAN1_PIN PC7 // "FAN1" +#define FAN2_PIN PB15 // "FAN2" + +/** + * SKR Mini E3 V3.0 + * ------ + * (BEEPER) PB5 | 1 2 | PA15 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PD6 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ +#define EXP1_01_PIN PB5 +#define EXP1_02_PIN PA15 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN -1 +#define EXP1_05_PIN PA10 +#define EXP1_06_PIN PB9 +#define EXP1_07_PIN PB8 +#define EXP1_08_PIN PD6 +#define EXP1_09_PIN -1 +#define EXP1_10_PIN -1 + +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + /** + * ------ ------ ------ + * (ENT) | 1 2 | (BEEP) |10 9 | |10 9 | + * (RX) | 3 4 | (RX) | 8 7 | (TX) RX | 8 7 | TX + * (TX) 5 6 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP + * (B) | 7 8 | (A) (B) | 4 3 | (A) B | 4 3 | A + * GND | 9 10 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * ------ ------ ------ + * EXP1 DWIN DWIN (plug) + * + * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on. + */ + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! DWIN_CREALITY_LCD requires a custom cable, see diagram above this line. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define BEEPER_PIN EXP1_02_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_01_PIN + +#elif HAS_WIRED_LCD + + #if ENABLED(SKR_MINI_SCREEN_ADAPTER) + /** https://github.com/VoronDesign/Voron-Hardware/tree/master/SKR-Mini_Screen_Adaptor/SRK%20Mini%20E3%20V3.0 + * + * SKR Mini E3 V3.0 SKR Mini Screen Adaptor + * ------ ------ + * 5V | 1 2 | GND MISO | 1 2 | SCK + * CS | 3 4 | SCK (EN1) PA10 | 3 4 | -- + * MOSI | 5 6 | MISO (EN2) PA9 5 6 | MOSI + * 3V3 | 7 8 | GND -- | 7 8 | -- + * ------ GND | 9 10| RESET (Kill) + * SPI ------ + * EXP2 + * + * ------ ------ + * PB5 | 1 2 | PA15 -- | 1 2 | PB5 (BTN_ENC) + * PA9 | 3 4 | RESET (LCD CS) PB8 | 3 4 | PD6 (LCD_A0) + * PA10 5 6 | PB9 (RESET) PB9 5 6 | PA15 (DIN) + * PB8 | 7 8 | PD6 -- | 7 8 | -- + * GND | 9 10| 5V GND | 9 10| 5V + * ------ ------ + * EXP1 EXP1 + */ + #if ENABLED(FYSETC_MINI_12864_2_1) + #define BTN_ENC EXP1_01_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BEEPER_PIN -1 + #define LCD_RESET_PIN EXP1_06_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_08_PIN + #define DOGLCD_SCK PA5 + #define DOGLCD_MOSI PA7 + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + #define NEOPIXEL_PIN EXP1_02_PIN + #else + #error "Only CR10_FYSETC_MINI_12864_2_1 and compatibles are currently supported on the BIGTREE_SKR_MINI_E3 with SKR_MINI_SCREEN_ADAPTER" + #endif + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_02_PIN + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN + #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * TFTGLCD_PANEL_SPI display pinout + * + * Board Display + * ------ ------ + * (BEEPER) PB6 | 1 2 | PB5 (SD_DET) 5V |10 9 | GND + * RESET | 3 4 | PA9 (MOD_RESET) -- | 8 7 | (SD_DET) + * PB9 5 6 | PA10 (SD_CS) (MOSI) | 6 5 | -- + * PB7 | 7 8 | PB8 (LCD_CS) (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Display + * + * EXP1-10 ----------- EXP1-10 5V + * EXP1-9 ------------ EXP1-9 GND + * SPI1-4 ------------ EXP1-6 MOSI + * EXP1-7 ------------ n/c + * SPI1-3 ------------ EXP1-2 SCK + * EXP1-5 ------------ EXP1-4 SD_CS + * EXP1-4 ------------ n/c + * EXP1-3 ------------ EXP1-3 LCD_CS + * SPI1-1 ------------ EXP1-1 MISO + * EXP1-1 ------------ EXP1-7 SD_DET + */ + + #define TFTGLCD_CS EXP1_03_PIN + + #endif + + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_V3_0.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning" + #endif + + /** + * + * Board Display + * ------ ------ + * (EN2) PB5 | 1 2 | PA15(BTN_ENC) 5V |10 9 | GND + * (LCD_CS) PA9 | 3 4 | RST (RESET) -- | 8 7 | -- + * (LCD_A0) PA10 5 6 | PB9 (EN1) (DIN) | 6 5 (RESET) + * (LCD_SCK)PB8 | 7 8 | PD6 (MOSI) (LCD_A0) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (BTN_ENC) | 2 1 | -- + * ------ ------ + * EXP1 EXP1 + * + * ------ + * -- |10 9 | -- + * --- (RESET) | 8 7 | -- + * | 3 | (MOSI) | 6 5 (EN2) + * | 2 | (DIN) -- | 4 3 | (EN1) + * | 1 | (LCD_SCK)| 2 1 | -- + * --- ------ + * Neopixel EXP2 + * + * Needs custom cable. Connect EN2-EN2, LCD_CS-LCD_CS and so on. + * + * Check the index/notch position twice!!! + * On BTT boards pins from IDC10 connector are numbered in unusual order. + */ + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_06_PIN + #define BTN_EN2 EXP1_01_PIN + #define BEEPER_PIN -1 + + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_05_PIN + #define DOGLCD_SCK EXP1_07_PIN + #define DOGLCD_MOSI EXP1_08_PIN + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, FYSETC_MINI_12864_2_1, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." + #endif + + #endif // SKR_MINI_SCREEN_ADAPTER + +#endif // HAS_WIRED_LCD + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * FYSETC TFT TFT81050 display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PB5 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (FREE) (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 7 8 | PB7 (FREE) (SD_CS) | 4 3 | (MOD_RESET) + * 5V | 9 10 | GND (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * ---------------------------------- + * EXP1-10 ----------- EXP1-10 5V + * EXP1-9 ------------ EXP1-9 GND + * SPI1-4 ------------ EXP1-6 MOSI + * EXP1-7 ------------ EXP1-5 LCD_CS + * SPI1-3 ------------ EXP1-2 SCK + * EXP1-5 ------------ EXP1-4 SD_CS + * EXP1-4 ------------ EXP1-8 RESET + * EXP1-3 ------------ EXP1-3 MOD_RST + * SPI1-1 ------------ EXP1-1 MISO + * EXP1-1 ------------ EXP1-7 SD_DET + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN EXP1_02_PIN + + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN PC3 +#elif SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL) + #define SD_DETECT_PIN EXP1_01_PIN + #define SD_SS_PIN EXP1_05_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." +#endif + +#define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1... +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card + +#define ENABLE_SPI1 +#define SDSS ONBOARD_SD_CS_PIN +#define SD_SS_PIN ONBOARD_SD_CS_PIN +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 + +// +// Default NEOPIXEL_PIN +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA8 // LED driving pin +#endif diff --git a/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h b/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h new file mode 100644 index 0000000..8be6dad --- /dev/null +++ b/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h @@ -0,0 +1,28 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT SKR SE BX V2.0" + +#define SAFE_POWER_PIN PI11 + +#include "pins_BTT_SKR_SE_BX_common.h" diff --git a/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h b/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h new file mode 100644 index 0000000..8d8143e --- /dev/null +++ b/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT SKR SE BX V3.0" + +#include "pins_BTT_SKR_SE_BX_common.h" diff --git a/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h b/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h new file mode 100644 index 0000000..1ee7846 --- /dev/null +++ b/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h @@ -0,0 +1,234 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(STM32H7) + #error "Oops! Select an STM32H7 board in 'Tools > Board.'" +#endif + +#define DEFAULT_MACHINE_NAME "Biqu BX" + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4K (24C32) + +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support +//#define SWD_DEBUG // Use pins PA13 and PA14 on STM32H7 for the SWD debugger + +// +// Limit Switches +// +#define X_MIN_PIN PB11 +#define X_MAX_PIN PD13 +#define Y_MIN_PIN PB12 +#define Y_MAX_PIN PB13 +#define Z_MIN_PIN PD12 +#define Z_MAX_PIN PD11 + +#define FIL_RUNOUT_PIN PD13 +#define FIL_RUNOUT2_PIN PB13 + +#ifndef SWD_DEBUG + #define LED_PIN PA13 + #define BEEPER_PIN PA14 +#endif + +#define POWER_MONITOR_PIN PB0 +#define RPI_POWER_PIN PE5 + +#define SERVO0_PIN PA2 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PH2 // Probe +#endif + +// +// Steppers +// +#define X_STEP_PIN PG13 +#define X_DIR_PIN PG12 +#define X_ENABLE_PIN PG14 +#define X_CS_PIN PG10 + +#define Y_STEP_PIN PB3 +#define Y_DIR_PIN PD3 +#define Y_ENABLE_PIN PB4 +#define Y_CS_PIN PD4 + +#define Z_STEP_PIN PD7 +#define Z_DIR_PIN PD6 +#define Z_ENABLE_PIN PG9 +#define Z_CS_PIN PD5 + +#define E0_STEP_PIN PC14 +#define E0_DIR_PIN PC13 +#define E0_ENABLE_PIN PC15 +#define E0_CS_PIN PI8 + +#define E1_STEP_PIN PA8 +#define E1_DIR_PIN PC9 +#define E1_ENABLE_PIN PD2 +#define E1_CS_PIN PC8 + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PC6 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PG3 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PC7 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + //#define E5_HARDWARE_SERIAL Serial1 + //#define E6_HARDWARE_SERIAL Serial1 + //#define E7_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN PG10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PD4 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PD5 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PI8 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PC8 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PH4 // TH0 +#define TEMP_1_PIN PA3 // TH1 +#define TEMP_BED_PIN PH5 // TB + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC4 +#define HEATER_1_PIN PC5 +#define HEATER_BED_PIN PA4 + +#define FAN_PIN PA5 // "FAN0" +#define FAN1_PIN PA6 // "FAN1" +#define FAN2_PIN PA7 // "FAN2" + +#define NEOPIXEL_PIN PH3 +#define NEOPIXEL2_PIN PB1 + +#if HAS_LTDC_TFT + + // LTDC_LCD Timing + #define LTDC_LCD_CLK 50 // LTDC clock frequency = 50Mhz + #define LTDC_LCD_HSYNC 30 // Horizontal synchronization + #define LTDC_LCD_HBP 114 // Horizontal back porch + #define LTDC_LCD_HFP 16 // Horizontal front porch + #define LTDC_LCD_VSYNC 3 // Vertical synchronization + #define LTDC_LCD_VBP 32 // Vertical back porch + #define LTDC_LCD_VFP 10 // Vertical front porch + + #define TFT_BACKLIGHT_PIN PB5 + #define LCD_DE_PIN PF10 + #define LCD_CLK_PIN PG7 + #define LCD_VSYNC_PIN PI9 + #define LCD_HSYNC_PIN PI10 + #define LCD_R7_PIN PG6 // R5 + #define LCD_R6_PIN PH12 + #define LCD_R5_PIN PH11 + #define LCD_R4_PIN PH10 + #define LCD_R3_PIN PH9 + #define LCD_G7_PIN PI2 // G6 + #define LCD_G6_PIN PI1 + #define LCD_G5_PIN PI0 + #define LCD_G4_PIN PH15 + #define LCD_G3_PIN PH14 + #define LCD_G2_PIN PH13 + #define LCD_B7_PIN PI7 // B5 + #define LCD_B6_PIN PI6 + #define LCD_B5_PIN PI5 + #define LCD_B4_PIN PI4 + #define LCD_B3_PIN PG11 + + // GT911 Capacitive Touch Sensor + #if ENABLED(TFT_TOUCH_DEVICE_GT911) + #define GT911_RST_PIN PE4 + #define GT911_INT_PIN PE3 + #define GT911_SW_I2C_SCL_PIN PE2 + #define GT911_SW_I2C_SDA_PIN PE6 + #endif + +#endif + +#if IS_NEWPANEL + #define BTN_EN1 PH6 + #define BTN_EN2 PH7 + #define BTN_ENC PH8 +#endif + +// +// SD card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#define SOFTWARE_SPI +#define SDSS PA15 +#define SD_SS_PIN SDSS +#define SD_SCK_PIN PC10 +#define SD_MISO_PIN PC11 +#define SD_MOSI_PIN PC12 +#define SD_DETECT_PIN PI3 diff --git a/src/pins/stm32h7/pins_BTT_SKR_V3_0.h b/src/pins/stm32h7/pins_BTT_SKR_V3_0.h new file mode 100644 index 0000000..d835486 --- /dev/null +++ b/src/pins/stm32h7/pins_BTT_SKR_V3_0.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT SKR V3" + +#include "pins_BTT_SKR_V3_0_common.h" diff --git a/src/pins/stm32h7/pins_BTT_SKR_V3_0_EZ.h b/src/pins/stm32h7/pins_BTT_SKR_V3_0_EZ.h new file mode 100644 index 0000000..003f20f --- /dev/null +++ b/src/pins/stm32h7/pins_BTT_SKR_V3_0_EZ.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT SKR V3 EZ" + +#include "pins_BTT_SKR_V3_0_common.h" diff --git a/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h b/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h new file mode 100644 index 0000000..24376d6 --- /dev/null +++ b/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h @@ -0,0 +1,569 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(STM32H7) + #error "Oops! Select an STM32H7 board in 'Tools > Board.'" +#endif + +// If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION +// https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT +//#define BTT_MOTOR_EXPANSION + +#if BOTH(HAS_WIRED_LCD, BTT_MOTOR_EXPANSION) + #if EITHER(CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY) + #define EXP_MOT_USE_EXP2_ONLY 1 + #else + #error "You can't use both an LCD and a Motor Expansion Module on EXP1/EXP2 at the same time." + #endif +#endif + +#define USES_DIAG_JUMPERS + +// Onboard I2C EEPROM +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #undef NO_EEPROM_SELECTED + #define I2C_EEPROM + #define SOFT_I2C_EEPROM // Force the use of Software I2C + #define I2C_SCL_PIN PA14 + #define I2C_SDA_PIN PA13 + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +// +// Servos +// +#define SERVO0_PIN PE5 + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PC1 // X-STOP +#define Y_DIAG_PIN PC3 // Y-STOP +#define Z_DIAG_PIN PC0 // Z-STOP +#define E0_DIAG_PIN PC2 // E0DET +#define E1_DIAG_PIN PA0 // E1DET + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN PC2 // E0DET + #else + #define X_MIN_PIN PC2 // E0DET + #endif +#elif ENABLED(X_DUAL_ENDSTOPS) + #ifndef X_MIN_PIN + #define X_MIN_PIN PC1 // X-STOP + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN PC2 // E0DET + #endif +#else + #define X_STOP_PIN PC1 // X-STOP +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN PA0 // E1DET + #else + #define Y_MIN_PIN PA0 // E1DET + #endif +#elif ENABLED(Y_DUAL_ENDSTOPS) + #ifndef Y_MIN_PIN + #define Y_MIN_PIN PC3 // Y-STOP + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN PA0 // E1DET + #endif +#else + #define Y_STOP_PIN PC3 // Y-STOP +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN PC15 // PWRDET + #else + #define Z_MIN_PIN PC15 // PWRDET + #endif +#elif ENABLED(Z_MULTI_ENDSTOPS) + #ifndef Z_MIN_PIN + #define Z_MIN_PIN PC0 // Z-STOP + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN PC15 // PWRDET + #endif +#else + #ifndef Z_STOP_PIN + #define Z_STOP_PIN PC0 // Z-STOP + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PC13 +#endif + +// +// Probe enable +// +#if ENABLED(PROBE_ENABLE_DISABLE) + #ifndef PROBE_ENABLE_PIN + #define PROBE_ENABLE_PIN SERVO0_PIN + #endif +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PC2 // E0DET +#define FIL_RUNOUT2_PIN PA0 // E1DET + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN PE4 // PS-ON +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC15 // PWRDET +#endif + +// +// Steppers +// +#define X_STEP_PIN PD4 +#define X_DIR_PIN PD3 +#define X_ENABLE_PIN PD6 +#ifndef X_CS_PIN + #define X_CS_PIN PD5 +#endif + +#define Y_STEP_PIN PA15 +#define Y_DIR_PIN PA8 +#define Y_ENABLE_PIN PD1 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD0 +#endif + +#define Z_STEP_PIN PE2 +#define Z_DIR_PIN PE3 +#define Z_ENABLE_PIN PE0 +#ifndef Z_CS_PIN + #define Z_CS_PIN PE1 +#endif + +#ifndef E0_STEP_PIN + #define E0_STEP_PIN PD15 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN PD14 +#endif +#ifndef E0_ENABLE_PIN + #define E0_ENABLE_PIN PC7 +#endif +#ifndef E0_CS_PIN + #define E0_CS_PIN PC6 +#endif + +#ifndef E1_STEP_PIN + #define E1_STEP_PIN PD11 +#endif +#ifndef E1_DIR_PIN + #define E1_DIR_PIN PD10 +#endif +#ifndef E1_ENABLE_PIN + #define E1_ENABLE_PIN PD13 +#endif +#ifndef E1_CS_PIN + #define E1_CS_PIN PD12 +#endif + +// +// Temperature Sensors +// +#ifndef TEMP_0_PIN + #define TEMP_0_PIN PA2 // TH0 +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN PA3 // TH1 +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN PA1 // TB +#endif + +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif +#endif + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PB3 // Heater0 +#endif +#ifndef HEATER_1_PIN + #define HEATER_1_PIN PB4 // Heater1 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PD7 // Hotbed +#endif +#ifndef FAN_PIN + #define FAN_PIN PB7 // Fan0 +#endif + +#if HAS_CUTTER + #ifndef SPINDLE_LASER_PWM_PIN + #define SPINDLE_LASER_PWM_PIN PB5 + #endif + #ifndef SPINDLE_LASER_ENA_PIN + #define SPINDLE_LASER_ENA_PIN PB6 + #endif +#else + #ifndef FAN1_PIN + #define FAN1_PIN PB6 // Fan1 + #endif + #ifndef FAN2_PIN + #define FAN2_PIN PB5 // Fan2 + #endif +#endif // SPINDLE_FEATURE || LASER_FEATURE + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PE13 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PE15 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PE14 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + // + // Software serial + // + #define X_SERIAL_TX_PIN PD5 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PD0 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE1 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PC6 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD12 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// SD Connection +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +/** + * ------ ------ + * (BEEPER) PC5 | 1 2 | PB0 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PB1 | 3 4 | PE8 (LCD_RS) (BTN_EN1) PE7 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PE9 | 5 6 PE10 (LCD_D5) (BTN_EN2) PB2 | 5 6 PA7 (MOSI) + * (LCD_D6) PE11 | 7 8 | PE12 (LCD_D7) (SD_DETECT) PC4 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PB1 +#define EXP1_04_PIN PE8 +#define EXP1_05_PIN PE9 +#define EXP1_06_PIN PE10 +#define EXP1_07_PIN PE11 +#define EXP1_08_PIN PE12 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE7 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB2 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC4 +#define EXP2_08_PIN -1 + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(LCD) + #define SDSS EXP2_04_PIN + #define SD_SS_PIN SDSS + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN +#elif SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT + #define SDIO_CLOCK 24000000 // 24MHz +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +#if ENABLED(BTT_MOTOR_EXPANSION) + /** ------ ------ + * M3DIAG | 1 2 | M3RX M3STP | 1 2 | M3DIR + * M2DIAG | 3 4 | M2RX M2STP | 3 4 | M2DIR + * M1DIAG 5 6 | M1RX M1DIR 5 6 | M1STP + * M3EN | 7 8 | M2EN M1EN | 7 8 | -- + * GND | 9 10 | -- GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + * + * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN + */ + + // M1 on Driver Expansion Module + #define E2_STEP_PIN EXP2_06_PIN + #define E2_DIR_PIN EXP2_05_PIN + #define E2_ENABLE_PIN EXP2_07_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E2_DIAG_PIN EXP1_05_PIN + #define E2_CS_PIN EXP1_06_PIN + #if HAS_TMC_UART + #define E2_SERIAL_TX_PIN EXP1_06_PIN + #define E2_SERIAL_RX_PIN EXP1_06_PIN + #endif + #endif + + // M2 on Driver Expansion Module + #define E3_STEP_PIN EXP2_03_PIN + #define E3_DIR_PIN EXP2_04_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E3_ENABLE_PIN EXP1_08_PIN + #define E3_DIAG_PIN EXP1_03_PIN + #define E3_CS_PIN EXP1_04_PIN + #if HAS_TMC_UART + #define E3_SERIAL_TX_PIN EXP1_04_PIN + #define E3_SERIAL_RX_PIN EXP1_04_PIN + #endif + #else + #define E3_ENABLE_PIN EXP2_07_PIN + #endif + + // M3 on Driver Expansion Module + #define E4_STEP_PIN EXP2_01_PIN + #define E4_DIR_PIN EXP2_02_PIN + #if !EXP_MOT_USE_EXP2_ONLY + #define E4_ENABLE_PIN EXP1_07_PIN + #define E4_DIAG_PIN EXP1_01_PIN + #define E4_CS_PIN EXP1_02_PIN + #if HAS_TMC_UART + #define E4_SERIAL_TX_PIN EXP1_02_PIN + #define E4_SERIAL_RX_PIN EXP1_02_PIN + #endif + #else + #define E4_ENABLE_PIN EXP2_07_PIN + #endif + +#endif // BTT_MOTOR_EXPANSION + +// +// LCDs and Controllers +// +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif + +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 120 + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 80 + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 580 + #endif +#endif + +#if HAS_SPI_TFT + // + // e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE) + // + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PE6 +#endif + +// +// WIFI +// + +/** + * ------- + * GND | 9 | | 8 | 3.3V + * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) + * 3.3V | 11 | | 6 | PB14 (ESP-MISO) + * (ESP-IO0) PB10 | 12 | | 5 | PB13 (ESP-CLK) + * (ESP-IO4) PB11 | 13 | | 4 | -- + * -- | 14 | | 3 | 3.3V (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | -- + * (ESP-TX) PD9 | 16 | | 1 | PC14 (ESP-RST) + * ------- + * WIFI + */ +#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_RESET_PIN PC14 +#define ESP_WIFI_MODULE_GPIO0_PIN PB10 +#define ESP_WIFI_MODULE_GPIO4_PIN PB11 diff --git a/src/pins/teensy2/env_validate.h b/src/pins/teensy2/env_validate.h new file mode 100644 index 0000000..5f0ea4f --- /dev/null +++ b/src/pins/teensy2/env_validate.h @@ -0,0 +1,28 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(__AVR_AT90USB1286__) && (DISABLED(ALLOW_AT90USB1286P) || NOT_TARGET(__AVR_AT90USB1286P__)) + #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" +#endif + +#undef ALLOW_AT90USB1286P diff --git a/src/pins/teensy2/pins_5DPRINT.h b/src/pins/teensy2/pins_5DPRINT.h new file mode 100644 index 0000000..6e1f9c0 --- /dev/null +++ b/src/pins/teensy2/pins_5DPRINT.h @@ -0,0 +1,146 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Rev B 2 JUN 2017 + * + * Converted to Arduino pin numbering + */ + +/** + * There are two Arduino IDE extensions that are compatible with this board + * and with the mainstream Marlin software. + * + * Teensyduino - https://www.pjrc.com/teensy/teensyduino.html + * Select Teensy++ 2.0 in Arduino IDE from the 'Tools > Board' menu + * + * Installation instructions are at the above URL. Don't bother loading the + * libraries - they are not used with the Marlin software. + * + * Printrboard - https://github.com/scwimbush/Printrboard-HID-Arduino-IDE-Support + * + * Installation: + * + * 1. Go to the above URL, click on the "Clone or Download" button and then + * click on "Download ZIP" button. + * 2. Unzip the file, find the "printrboard" directory and then copy it to the + * hardware directory in Arduino. The Arduino hardware directory will probably + * be located in a path similar to this: C:\Program Files (x86)\Arduino\hardware. + * 3. Restart Arduino. + * 4. Select "Printrboard" from the 'Tools > Board' menu. + * + * Teensyduino is the most popular option. Printrboard is used if your board doesn't have + * the Teensyduino bootloader on it. + */ + +/** + * To burn the bootloader that comes with Printrboard: + * + * 1. Connect your programmer to the board. + * 2. In the Arduino IDE select "Printrboard" and then select the programmer. + * 3. In the Arduino IDE click on "burn bootloader". Don't worry about the "verify failed at 1F000" error message. + * 4. The programmer is no longer needed. Remove it. + */ + +/** + * 5DPrint D8 Driver board pin assignments + * + * https://bitbucket.org/makible/5dprint-d8-controller-board + */ + +#include "env_validate.h" + +#define DEFAULT_MACHINE_NAME "Makibox" +#define BOARD_INFO_NAME "5DPrint D8" + +// +// Servos +// +#define SERVO0_PIN 41 +#define SERVO1_PIN 42 +#define SERVO2_PIN 43 +#define SERVO3_PIN 44 + +// +// Limit Switches +// +#define X_STOP_PIN 37 // E5 +#define Y_STOP_PIN 36 // E4 +#define Z_STOP_PIN 19 // E7 + +// +// Steppers +// +#define X_STEP_PIN 28 // A0 +#define X_DIR_PIN 29 // A1 +#define X_ENABLE_PIN 17 // C7 + +#define Y_STEP_PIN 30 // A2 +#define Y_DIR_PIN 31 // A3 +#define Y_ENABLE_PIN 13 // C3 + +#define Z_STEP_PIN 32 // A4 +#define Z_DIR_PIN 33 // A5 +#define Z_ENABLE_PIN 12 // C2 + +#define E0_STEP_PIN 34 // A6 +#define E0_DIR_PIN 35 // A7 +#define E0_ENABLE_PIN 11 // C1 + +// +// Digital Microstepping +// +#define X_MS1_PIN 25 // B5 +#define X_MS2_PIN 26 // B6 +#define Y_MS1_PIN 9 // E1 +#define Y_MS2_PIN 8 // E0 +#define Z_MS1_PIN 7 // D7 +#define Z_MS2_PIN 6 // D6 +#define E0_MS1_PIN 5 // D5 +#define E0_MS2_PIN 4 // D4 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // F1 Analog Input +#define TEMP_BED_PIN 0 // F0 Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 15 // C5 +#define HEATER_BED_PIN 14 // C4 + +#ifndef FAN_PIN + #define FAN_PIN 16 // C6 PWM3A +#endif + +// +// Misc. Functions +// +#define SDSS 20 // B0 + +//DIGIPOTS slave addresses +#ifndef DIGIPOT_I2C_ADDRESS_A + #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for DIGIPOT 0x2C (0x58 <- 0x2C << 1) +#endif diff --git a/src/pins/teensy2/pins_BRAINWAVE.h b/src/pins/teensy2/pins_BRAINWAVE.h new file mode 100644 index 0000000..cdcc249 --- /dev/null +++ b/src/pins/teensy2/pins_BRAINWAVE.h @@ -0,0 +1,126 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Brainwave 1.0 pin assignments (AT90USB646) + * + * Requires hardware bundle for Arduino: + * https://github.com/unrepentantgeek/brainwave-arduino + */ + +/** + * Rev B 16 JAN 2017 + * + * Added pointer to a currently available Arduino IDE extension that will + * allow this board to use the latest Marlin software + */ + +/** + * Rev C 2 JUN 2017 + * + * Converted to Arduino pin numbering + */ + +/** + * Marlin_AT90USB - https://github.com/Bob-the-Kuhn/Marlin_AT90USB + * This is the only known IDE extension that is compatible with the pin definitions + * in this file, Adrduino 1.6.12 and the latest mainstream Marlin software. + * + * "Marlin_AT90USB" makes PWM0A available rather than the usual PWM1C. These PWMs share + * the same physical pin. Marlin uses TIMER1 to generate interrupts and sets it up such + * that PWM1A, PWM1B & PWM1C can't be used. + * + * Installation: + * + * 1. In the Arduino IDE, under Files -> Preferences paste the following URL + * https://rawgit.com/Bob-the-Kuhn/Marlin_AT90USB/master/package_MARLIN_AT90USB_index.json + * 2. Under Tools > Board -> Boards manager, scroll to the bottom, click on MARLIN_AT90USB + * and then click on "Install" + * 3. Select "AT90USB646_TEENSYPP" from the 'Tools > Board' menu. + */ + +/** + * To burn the bootloader that comes with Marlin_AT90USB: + * + * 1. Connect your programmer to the board. + * 2. In Arduino IDE select "AT90USB646_TEENSYPP" and then select the programmer. + * 3. In Arduino IDE click on "burn bootloader". Don't worry about the "verify failed at 1F000" error message. + * 4. The programmer is no longer needed. Remove it. + */ + +#if NOT_TARGET(__AVR_AT90USB646__) + #error "Oops! Select 'Brainwave' in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "Brainwave" + +// +// Limit Switches +// +#define X_STOP_PIN 35 // A7 +#define Y_STOP_PIN 34 // A6 +#define Z_STOP_PIN 33 // A5 + +// +// Steppers +// +#define X_STEP_PIN 3 // D3 +#define X_DIR_PIN 5 // D5 +#define X_ENABLE_PIN 4 // D4 +#define X_ATT_PIN 2 // D2 + +#define Y_STEP_PIN 7 // D7 +#define Y_DIR_PIN 9 // E1 +#define Y_ENABLE_PIN 8 // E0 +#define Y_ATT_PIN 6 // D6 + +#define Z_STEP_PIN 11 // C1 +#define Z_DIR_PIN 13 // C3 +#define Z_ENABLE_PIN 12 // C2 +#define Z_ATT_PIN 10 // C0 + +#define E0_STEP_PIN 15 // C5 +#define E0_DIR_PIN 17 // C7 +#define E0_ENABLE_PIN 16 // C6 +#define E0_ATT_PIN 14 // C4 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 7 // F7 Analog Input +#define TEMP_BED_PIN 6 // F6 Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 32 // A4 Extruder +#define HEATER_BED_PIN 18 // E6 Bed + +#ifndef FAN_PIN + #define FAN_PIN 31 // A3 Fan +#endif + +// +// Misc. Functions +// +#define LED_PIN 19 // E7 diff --git a/src/pins/teensy2/pins_BRAINWAVE_PRO.h b/src/pins/teensy2/pins_BRAINWAVE_PRO.h new file mode 100644 index 0000000..319130e --- /dev/null +++ b/src/pins/teensy2/pins_BRAINWAVE_PRO.h @@ -0,0 +1,136 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Brainwave Pro pin assignments (AT90USB1286) + * + * Requires hardware bundle for Arduino: + * https://github.com/unrepentantgeek/brainwave-arduino + */ + +/** + * Rev B 16 JAN 2017 + * + * Added pointers to currently available Arduino IDE extensions that will + * allow this board to use the latest Marlin software + * + * + * Rev C 2 JUN 2017 + * + * Converted to Arduino pin numbering + */ + +/** + * There are two Arduino IDE extensions that are compatible with this board + * and with the mainstream Marlin software. + * + * Teensyduino - https://www.pjrc.com/teensy/teensyduino.html + * Select Teensy++ 2.0 in Arduino IDE from the 'Tools > Board' menu + * + * Installation instructions are at the above URL. Don't bother loading the + * libraries - they are not used with the Marlin software. + * + * Printrboard - https://github.com/scwimbush/Printrboard-HID-Arduino-IDE-Support + * + * Installation: + * + * 1. Go to the above URL, click on the "Clone or Download" button and then + * click on "Download ZIP" button. + * 2. Unzip the file, find the "printrboard" directory and then copy it to the + * hardware directory in Arduino. The Arduino hardware directory will probably + * be located in a path similar to this: C:\Program Files (x86)\Arduino\hardware. + * 3. Restart Arduino. + * 4. Select "Printrboard" from the 'Tools > Board' menu. + * + * Teensyduino is the most popular option. Printrboard is used if your board doesn't have + * the Teensyduino bootloader on it. + */ + +/** + * To burn the bootloader that comes with Printrboard: + * + * 1. Connect your programmer to the board. + * 2. In the Arduino IDE select "Printrboard" and then select the programmer. + * 3. In the Arduino IDE click on "burn bootloader". Don't worry about the "verify failed at 1F000" error message. + * 4. The programmer is no longer needed. Remove it. + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Brainwave Pro" + +// +// Limit Switches +// +#define X_STOP_PIN 45 // F7 +#define Y_STOP_PIN 12 // C2 +#define Z_STOP_PIN 36 // E4 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 11 // C1 +#endif + +// +// Steppers +// +#define X_STEP_PIN 9 // E1 +#define X_DIR_PIN 8 // E0 +#define X_ENABLE_PIN 23 // B3 + +#define Y_STEP_PIN 7 // D7 +#define Y_DIR_PIN 6 // D6 +#define Y_ENABLE_PIN 20 // B0 + +#define Z_STEP_PIN 5 // D5 +#define Z_DIR_PIN 4 // D4 +#define Z_ENABLE_PIN 37 // E5 + +#define E0_STEP_PIN 47 // E3 +#define E0_DIR_PIN 46 // E2 +#define E0_ENABLE_PIN 25 // B5 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 2 // F2 Analog Input +#define TEMP_1_PIN 1 // F1 Analog Input +#define TEMP_BED_PIN 0 // F0 Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 27 // B7 +#define HEATER_BED_PIN 26 // B6 Bed +#ifndef FAN_PIN + #define FAN_PIN 16 // C6 Fan, PWM3A +#endif + +// +// Misc. Functions +// +#define SDSS 20 // B0 +#define SD_DETECT_PIN 24 // B4 +#define LED_PIN 13 // C3 diff --git a/src/pins/teensy2/pins_PRINTRBOARD.h b/src/pins/teensy2/pins_PRINTRBOARD.h new file mode 100644 index 0000000..ddf0d53 --- /dev/null +++ b/src/pins/teensy2/pins_PRINTRBOARD.h @@ -0,0 +1,170 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Rev B 2 JUN 2017 + * + * Converted to Arduino pin numbering + */ + +/** + * There are two Arduino IDE extensions that are compatible with this board + * and with the mainstream Marlin software. + * + * Teensyduino - https://www.pjrc.com/teensy/teensyduino.html + * Select Teensy++ 2.0 in Arduino IDE from the 'Tools > Board' menu + * + * Installation instructions are at the above URL. Don't bother loading the + * libraries - they are not used with the Marlin software. + * + * Printrboard - https://github.com/scwimbush/Printrboard-HID-Arduino-IDE-Support + * + * Installation: + * + * 1. Go to the above URL, click on the "Clone or Download" button and then + * click on "Download ZIP" button. + * 2. Unzip the file, find the "printrboard" directory and then copy it to the + * hardware directory in Arduino. The Arduino hardware directory will probably + * be located in a path similar to this: C:\Program Files (x86)\Arduino\hardware. + * 3. Restart Arduino. + * 4. Select "Printrboard" from the 'Tools > Board' menu. + * + * Teensyduino is the most popular option. Printrboard is used if your board doesn't have + * the Teensyduino bootloader on it. + */ + +/** + * To burn the bootloader that comes with Printrboard: + * + * 1. Connect your programmer to the board. + * 2. In the Arduino IDE select "Printrboard" and then select the programmer. + * 3. In the Arduino IDE click on "burn bootloader". Don't worry about the "verify failed at 1F000" error message. + * 4. The programmer is no longer needed. Remove it. + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Printrboard" + +// Disable JTAG pins so they can be used for the Extrudrboard +#define DISABLE_JTAG + +// +// Limit Switches +// +#define X_STOP_PIN 47 // E3 +#define Y_STOP_PIN 20 // B0 SS +#define Z_STOP_PIN 36 // E4 + +// +// Steppers +// +#define X_STEP_PIN 28 // A0 +#define X_DIR_PIN 29 // A1 +#define X_ENABLE_PIN 19 // E7 + +#define Y_STEP_PIN 30 // A2 +#define Y_DIR_PIN 31 // A3 +#define Y_ENABLE_PIN 18 // E6 + +#define Z_STEP_PIN 32 // A4 +#define Z_DIR_PIN 33 // A5 +#define Z_ENABLE_PIN 17 // C7 + +#define E0_STEP_PIN 34 // A6 +#define E0_DIR_PIN 35 // A7 +#define E0_ENABLE_PIN 13 // C3 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // Analog Input +#define TEMP_BED_PIN 0 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 15 // C5 PWM3B - Extruder +#define HEATER_1_PIN 44 // F6 +#define HEATER_2_PIN 45 // F7 +#define HEATER_BED_PIN 14 // C4 PWM3C + +#ifndef FAN_PIN + #define FAN_PIN 16 // C6 PWM3A +#endif + +// +// Misc. Functions +// +#define FILWIDTH_PIN 2 // Analog Input + +// +// LCD / Controller +// +#if HAS_WIRED_LCD && IS_NEWPANEL + + #define LCD_PINS_RS 9 // E1 JP11-11 + #define LCD_PINS_ENABLE 8 // E0 JP11-10 + #define LCD_PINS_D4 7 // D7 JP11-8 + #define LCD_PINS_D5 6 // D6 JP11-7 + #define LCD_PINS_D6 5 // D5 JP11-6 + #define LCD_PINS_D7 4 // D4 JP11-5 + + #if EITHER(VIKI2, miniVIKI) + #define BEEPER_PIN 8 // E0 JP11-10 + + #define DOGLCD_A0 40 // F2 JP2-2 + #define DOGLCD_CS 41 // F3 JP2-4 + + #define BTN_EN1 2 // D2 TX1 JP2-5 + #define BTN_EN2 3 // D3 RX1 JP2-7 + #define BTN_ENC 45 // F7 TDI JP2-12 + + #define SDSS 43 // F5 TMS JP2-8 + + #define STAT_LED_RED_PIN 12 // C2 JP11-14 + #define STAT_LED_BLUE_PIN 10 // C0 JP11-12 + + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(LCD_I2C_PANELOLU2) + + #define BTN_EN1 3 // D3 RX1 JP2-7 + #define BTN_EN2 2 // D2 TX1 JP2-5 + #define BTN_ENC 41 // F3 JP2-4 + + #define SDSS 38 // F0 B-THERM connector - use SD card on Panelolu2 + + #else + + #define BTN_EN1 10 // C0 JP11-12 + #define BTN_EN2 11 // C1 JP11-13 + #define BTN_ENC 12 // C2 JP11-14 + + #endif + +#endif // HAS_WIRED_LCD && IS_NEWPANEL + +#ifndef SDSS + #define SDSS 26 // B6 SDCS +#endif diff --git a/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/src/pins/teensy2/pins_PRINTRBOARD_REVF.h new file mode 100644 index 0000000..1867398 --- /dev/null +++ b/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -0,0 +1,280 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Rev B 2 JUN 2017 + * + * Converted to Arduino pin numbering + */ + +/** + * There are two Arduino IDE extensions that are compatible with this board + * and with the mainstream Marlin software. + * + * Teensyduino - https://www.pjrc.com/teensy/teensyduino.html + * Installation - https://www.pjrc.com/teensy/td_download.html + * + * Select Teensy++ 2.0 in Arduino IDE from the 'Tools > Board' menu + * + * Note: With Teensyduino extension, the Arduino IDE will report 130048 bytes of program storage space available, + * but there is actually only 122880 bytes due to the larger DFU bootloader shipped by default on all Printrboard RevF. + * + * Printrboard - https://github.com/scwimbush/Printrboard-HID-Arduino-IDE-Support + * + * Installation: + * + * 1. Go to the above URL, click on the "Clone or Download" button and then + * click on "Download ZIP" button. + * 2. Unzip the file, find the "printrboard" directory and then copy it to the + * hardware directory in Arduino. The Arduino hardware directory will probably + * be located in a path similar to this: C:\Program Files (x86)\Arduino\hardware. + * 3. Restart Arduino. + * 4. Select "Printrboard" from the 'Tools > Board' menu. + * + * Teensyduino is the most popular and easiest option. + */ + +/** + * To burn the bootloader that comes with Printrboard HID extension: + * + * 1. Connect your programmer to the board. + * 2. In the Arduino IDE select "Printrboard" and then select the programmer. + * 3. In the Arduino IDE click on "burn bootloader". Don't worry about the "verify failed at 1F000" error message. + * 4. The programmer is no longer needed. Remove it. + */ + +#include "env_validate.h" + +#if !defined(__MARLIN_DEPS__) && !defined(USBCON) + #error "USBCON should be defined by the platform for this board." +#endif + +#define BOARD_INFO_NAME "Printrboard Rev.F" + +// Disable JTAG pins so EXP1 pins work correctly +// (Its pins are used for the Extrudrboard and filament sensor, for example). +#define DISABLE_JTAG + +/** + * Note that REV F6 of the Printrboard stole the A HOTEND pin and + * reassigned it to a second fan for the extruder heater. It's + * recommended that you swap the A and B outputs on the Extrudrboard + * so EXTRUDERS=2 will still work on F6, using B for E1/HEATER_1/TEMP_1. + * See https://printrbot.zendesk.com/hc/en-us/articles/115003072346 + * + * If you have REV F6 you probably also want to set E0_AUTO_FAN_PIN + * to PRINTRBOARD_F6_HEATER_FAN_PIN (44). + * + * Define NO_EXTRUDRBOARD if you don't have an EXTRUDRBOARD and wish to + * reassign different functions to EXP1. + * + * Define NO_EXTRUDRBOARD_OUTPUT_SWAP if you have a REV F5 or lower and + * want to use EXTRUDRBOARD A for E1 and EXTRUDRBOARD B for E2. + */ +//#define NO_EXTRUDRBOARD +//#define NO_EXTRUDRBOARD_OUTPUT_SWAP + +// +// Limit Switches +// +#define X_STOP_PIN 47 // E3 +#define Y_STOP_PIN 24 // B4 PWM2A +#define Z_STOP_PIN 36 // E4 + +// +// Steppers +// +#define X_STEP_PIN 28 // A0 +#define X_DIR_PIN 29 // A1 +#define X_ENABLE_PIN 19 // E7 + +#define Y_STEP_PIN 30 // A2 +#define Y_DIR_PIN 31 // A3 +#define Y_ENABLE_PIN 18 // E6 + +#define Z_STEP_PIN 32 // A4 +#define Z_DIR_PIN 33 // A5 +#define Z_ENABLE_PIN 17 // C7 + +#define E0_STEP_PIN 34 // A6 +#define E0_DIR_PIN 35 // A7 +#define E0_ENABLE_PIN 13 // C3 + +#if DISABLED(NO_EXTRUDRBOARD) +#if DISABLED(NO_EXTRUDRBOARD_OUTPUT_SWAP) + #define E1_STEP_PIN 25 // B5 + #define E1_DIR_PIN 37 // E5 + #define E1_ENABLE_PIN 42 // F4 + + #define E2_STEP_PIN 2 // D2 + #define E2_DIR_PIN 3 // D3 + #define E2_ENABLE_PIN 43 // F5 +#else + #define E1_STEP_PIN 2 // D2 + #define E1_DIR_PIN 3 // D3 + #define E1_ENABLE_PIN 43 // F5 + + #define E2_STEP_PIN 25 // B5 + #define E2_DIR_PIN 37 // E5 + #define E2_ENABLE_PIN 42 // F4 +#endif +#endif // NO_EXTRUDRBOARD + +// Enable control of stepper motor currents with the I2C based MCP4728 DAC used on Printrboard REVF +#define HAS_MOTOR_CURRENT_DAC 1 + +// Set default drive strength percents if not already defined - X, Y, Z, E axis +#ifndef DAC_MOTOR_CURRENT_DEFAULT + #define DAC_MOTOR_CURRENT_DEFAULT { 70, 70, 50, 70 } +#endif + +// Number of channels available for DAC +#define DAC_STEPPER_ORDER { 3, 2, 1, 0 } + +#define DAC_STEPPER_SENSE 0.11 +#define DAC_STEPPER_ADDRESS 0 +#define DAC_STEPPER_MAX 3520 +#define DAC_STEPPER_VREF 1 // internal Vref, gain 1x = 2.048V +#define DAC_STEPPER_GAIN 0 +#define DAC_OR_ADDRESS 0x00 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 // Analog Input (Extruder) +#define TEMP_BED_PIN 0 // Analog Input (Bed) + +#if DISABLED(NO_EXTRUDRBOARD) +#if DISABLED(NO_EXTRUDRBOARD_OUTPUT_SWAP) + #define TEMP_1_PIN 2 // Analog Input (Extrudrboard A THERM) + #define TEMP_2_PIN 3 // Analog Input (Extrudrboard B THERM) +#else + #define TEMP_1_PIN 3 // Analog Input (Extrudrboard B THERM) + #define TEMP_2_PIN 2 // Analog Input (Extrudrboard A THERM) +#endif +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 15 // C5 PWM3B - Extruder +#define HEATER_BED_PIN 14 // C4 PWM3C + +#if DISABLED(NO_EXTRUDRBOARD) +#if DISABLED(NO_EXTRUDRBOARD_OUTPUT_SWAP) + #define HEATER_1_PIN 44 // F6 - Extrudrboard A HOTEND + #define HEATER_2_PIN 45 // F7 - Extrudrboard B HOTEND +#else + #define HEATER_1_PIN 45 // F7 - Extrudrboard B HOTEND + #define HEATER_2_PIN 44 // F6 - Extrudrboard A HOTEND +#endif +#endif + +#ifndef FAN_PIN + #define FAN_PIN 16 // C6 PWM3A +#endif + +// +// LCD / Controller +// +//#define USE_INTERNAL_SD + +#if HAS_WIRED_LCD + #define LCD_PINS_RS 9 // E1 JP11-11 + #define LCD_PINS_ENABLE 8 // E0 JP11-10 + #define LCD_PINS_D4 7 // D7 JP11-8 + #define LCD_PINS_D5 6 // D6 JP11-7 + #define LCD_PINS_D6 5 // D5 JP11-6 + #define LCD_PINS_D7 4 // D4 JP11-5 + + #if EITHER(VIKI2, miniVIKI) + + #define BEEPER_PIN 8 // E0 JP11-10 + #define DOGLCD_A0 40 // F2 JP2-2 + #define DOGLCD_CS 41 // F3 JP2-4 + + #define BTN_EN1 2 // D2 TX1 JP2-5 + #define BTN_EN2 3 // D3 RX1 JP2-7 + #define BTN_ENC 45 // F7 TDI JP2-12 + + #define SDSS 3 // F5 TMS JP2-8 + + #define STAT_LED_RED_PIN 12 // C2 JP11-14 + #define STAT_LED_BLUE_PIN 10 // C0 JP11-12 + + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + + #elif ENABLED(MINIPANEL) + + #if DISABLED(USE_INTERNAL_SD) + // PIN FASTIO PIN# ATUSB90 PIN# Teensy2.0++ PIN# Printrboard RevF Conn. MKSLCD12864 PIN# + #define SDSS 11 // 36 C1 EXP2-13 EXP2-07 + #define SD_DETECT_PIN 9 // 34 E1 EXP2-11 EXP2-04 + #endif + + // PIN FASTIO PIN# ATUSB90 PIN# Teensy2.0++ PIN# Printrboard RevF Conn. MKSLCD12864 PIN# + #define DOGLCD_A0 4 // 29 D4 EXP2-05 EXP1-04 + #define DOGLCD_CS 5 // 30 D5 EXP2-06 EXP1-05 + #define BTN_ENC 6 // 31 D6 EXP2-07 EXP1-09 + #define BEEPER_PIN 7 // 32 D7 EXP2-08 EXP1-10 + #define KILL_PIN 8 // 33 E0 EXP2-10 EXP2-03 + #define BTN_EN1 10 // 35 C0 EXP2-12 EXP2-06 + #define BTN_EN2 12 // 37 C2 EXP2-14 EXP2-08 + //#define LCD_BACKLIGHT_PIN 43 // 56 F5 EXP1-12 Not Implemented + //#define SCK 21 // 11 B1 ICSP-04 EXP2-09 + //#define MOSI 22 // 12 B2 ICSP-03 EXP2-05 + //#define MISO 23 // 13 B3 ICSP-06 EXP2-05 + + // Alter timing for graphical display + #define BOARD_ST7920_DELAY_1 313 + #define BOARD_ST7920_DELAY_2 313 + #define BOARD_ST7920_DELAY_3 313 + + #else + + #define BTN_EN1 10 // C0 JP11-12 + #define BTN_EN2 11 // C1 JP11-13 + #define BTN_ENC 12 // C2 JP11-14 + + #endif + +#endif + +// +// Misc. Functions +// +// PIN FASTIO PIN# ATUSB90 PIN# Teensy2.0++ PIN# Printrboard RevF Conn. +#ifndef SDSS + #define SDSS 20 // 10 B0 +#endif + +/** + * This is EXP1-2, which is also the TEMP_A_PIN for the Extrudrboard. + * If using w/ Extrudrboard, cut off pin 2 on the Extrudrboard male + * connector to ensure this is disconnected from the A THERM pullups. + * You probably want to set EXTRUDERS=2 and swap the Extrudrboard outputs, + * which will let you use Channel B on the Extrudrboard as E1. + */ +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 2 // Analog Input +#endif diff --git a/src/pins/teensy2/pins_SAV_MKI.h b/src/pins/teensy2/pins_SAV_MKI.h new file mode 100644 index 0000000..cdba535 --- /dev/null +++ b/src/pins/teensy2/pins_SAV_MKI.h @@ -0,0 +1,183 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Rev B 2 JUN 2017 + * + * Converted to Arduino pin numbering + */ + +/** + * There are two Arduino IDE extensions that are compatible with this board + * and with the mainstream Marlin software. + * + * Teensyduino - https://www.pjrc.com/teensy/teensyduino.html + * Select Teensy++ 2.0 in Arduino IDE from the 'Tools > Board' menu + * + * Installation instructions are at the above URL. Don't bother loading the + * libraries - they are not used with the Marlin software. + * + * Printrboard - https://github.com/scwimbush/Printrboard-HID-Arduino-IDE-Support + * + * Installation: + * + * 1. Go to the above URL, click on the "Clone or Download" button and then + * click on "Download ZIP" button. + * 2. Unzip the file, find the "printrboard" directory and then copy it to the + * hardware directory in Arduino. The Arduino hardware directory will probably + * be located in a path similar to this: C:\Program Files (x86)\Arduino\hardware. + * 3. Restart Arduino. + * 4. Select "Printrboard" from the 'Tools > Board' menu. + * + * Teensyduino is the most popular option. Printrboard is used if your board doesn't have + * the Teensyduino bootloader on it. + */ + +/** + * To burn the bootloader that comes with Printrboard: + * + * 1. Connect your programmer to the board. + * 2. In the Arduino IDE select "Printrboard" and then select the programmer. + * 3. In the Arduino IDE click on "burn bootloader". Don't worry about the "verify failed at 1F000" error message. + * 4. The programmer is no longer needed. Remove it. + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "SAV MkI" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#define DEFAULT_SOURCE_CODE_URL "tinyurl.com/onru38b" + +// +// Servos +// +#define SERVO0_PIN 39 // F1 In teensy's pin definition for pinMode (in servo.cpp) + +// +// Limit Switches +// +#define X_STOP_PIN 25 // B5 +#define Y_STOP_PIN 26 // B6 +//#define Z_STOP_PIN 27 // B7 +#define Z_STOP_PIN 36 // E4 For inductive sensor. +//#define E_STOP_PIN 36 // E4 + +// +// Steppers +// +#define X_STEP_PIN 28 // A0 +#define X_DIR_PIN 29 // A1 +#define X_ENABLE_PIN 19 // E7 + +#define Y_STEP_PIN 30 // A2 +#define Y_DIR_PIN 31 // A3 +#define Y_ENABLE_PIN 18 // E6 + +#define Z_STEP_PIN 32 // A4 +#define Z_DIR_PIN 33 // A5 +#define Z_ENABLE_PIN 17 // C7 + +#define E0_STEP_PIN 34 // A6 +#define E0_DIR_PIN 35 // A7 +#define E0_ENABLE_PIN 13 // C3 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 7 // F7 Analog Input (Extruder) +#define TEMP_BED_PIN 6 // F6 Analog Input (Bed) + +// +// Heaters / Fans +// +#define HEATER_0_PIN 15 // C5 PWM3B - Extruder +#define HEATER_BED_PIN 14 // C4 PWM3C - Bed + +#ifndef FAN_PIN + #define FAN_PIN 16 // C6 PWM3A +#endif + +// +// Misc. Functions +// +#define SDSS 20 // B0 + +// Extension header pin mapping +// ---------------------------- +// SCL (I2C)-D0 A0 (An), IO +// SDA (I2C)-D1 A1 (An), IO +// RX1-D2 A2 (An), IO +// TX1-D3 A3 (An), IO +// PWM-D24 A4 (An), IO +// 5V GND +// 12V GND +#define EXT_AUX_SCL_D0 0 // D0 PWM0B +#define EXT_AUX_SDA_D1 1 // D1 +#define EXT_AUX_RX1_D2 2 // D2 +#define EXT_AUX_TX1_D3 3 // D3 +#define EXT_AUX_PWM_D24 24 // B4 PWM2A +#define EXT_AUX_A0 0 // F0 Analog Input +#define EXT_AUX_A0_IO 38 // F0 Digital IO +#define EXT_AUX_A1 1 // F1 Analog Input +#define EXT_AUX_A1_IO 39 // F1 Digital IO +#define EXT_AUX_A2 2 // F2 Analog Input +#define EXT_AUX_A2_IO 40 // F2 Digital IO +#define EXT_AUX_A3 3 // F3 Analog Input +#define EXT_AUX_A3_IO 41 // F3 Digital IO +#define EXT_AUX_A4 4 // F4 Analog Input +#define EXT_AUX_A4_IO 42 // F4 Digital IO + +// +// LCD / Controller +// +#define BEEPER_PIN -1 +#define LCD_PINS_RS -1 +#define LCD_PINS_ENABLE -1 + +#if ENABLED(SAV_3DLCD) + // For LCD SHIFT register LCD + #define SR_DATA_PIN EXT_AUX_SDA_D1 + #define SR_CLK_PIN EXT_AUX_SCL_D0 +#endif + +#if EITHER(SAV_3DLCD, SAV_3DGLCD) + + #define BTN_EN1 EXT_AUX_A1_IO + #define BTN_EN2 EXT_AUX_A0_IO + #define BTN_ENC EXT_AUX_PWM_D24 + + #define KILL_PIN EXT_AUX_A2_IO + #define HOME_PIN EXT_AUX_A4_IO + +#else // Use the expansion header for spindle control + + // + // M3/M4/M5 - Spindle/Laser Control + // + #define SPINDLE_LASER_PWM_PIN 24 // B4 PWM2A + #define SPINDLE_LASER_ENA_PIN 39 // F1 Pin should have a pullup! + #define SPINDLE_DIR_PIN 40 // F2 + + #define CASE_LIGHT_PIN 0 // D0 PWM0B + +#endif diff --git a/src/pins/teensy2/pins_TEENSY2.h b/src/pins/teensy2/pins_TEENSY2.h new file mode 100644 index 0000000..efb409b --- /dev/null +++ b/src/pins/teensy2/pins_TEENSY2.h @@ -0,0 +1,186 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Rev B 2 JUN 2017 + * + * Converted to Arduino pin numbering + */ + +/** + * There are two Arduino IDE extensions that are compatible with this board + * and with the mainstream Marlin software. + * + * Teensyduino - https://www.pjrc.com/teensy/teensyduino.html + * Select Teensy++ 2.0 in Arduino IDE from the 'Tools > Board' menu + * + * Installation instructions are at the above URL. Don't bother loading the + * libraries - they are not used with the Marlin software. + * + * Printrboard - https://github.com/scwimbush/Printrboard-HID-Arduino-IDE-Support + * + * Installation: + * + * 1. Go to the above URL, click on the "Clone or Download" button and then + * click on "Download ZIP" button. + * 2. Unzip the file, find the "printrboard" directory and then copy it to the + * hardware directory in Arduino. The Arduino hardware directory will probably + * be located in a path similar to this: C:\Program Files (x86)\Arduino\hardware. + * 3. Restart Arduino. + * 4. Select "Printrboard" from the 'Tools > Board' menu. + * + * Teensyduino is the most popular option. Printrboard is used if your board doesn't have + * the Teensyduino bootloader on it. + */ + +/** + * To burn the bootloader that comes with Printrboard: + * + * 1. Connect your programmer to the board. + * 2. In the Arduino IDE select "Printrboard" and then select the programmer. + * 3. In the Arduino IDE click on "burn bootloader". Don't worry about the "verify failed at 1F000" error message. + * 4. The programmer is no longer needed. Remove it. + */ + +/** + * Teensy++ 2.0 Breadboard pin assignments (AT90USB1286) + * Requires the Teensyduino software with Teensy++ 2.0 selected in Arduino IDE! + * https://www.pjrc.com/teensy/teensyduino.html + * See https://reprap.org/wiki/Printrboard for more info + * + * CLI build: HARDWARE_MOTHERBOARD=84 make + * + * DaveX plan for Teensylu/printrboard-type pinouts for a TeensyBreadboard: + * (ref teensylu & sprinter) + * + * USB + * GND GND |-----#####-----| +5V ATX +5SB + * ATX PS_ON PWM 27 |b7 ##### b6| 26 PWM* Stepper Enable + * PWM 0 |d0 b5| 25 PWM* + * PWM 1 |d1 b4| 24 PWM + * X_MIN 2 |d2 b3| 23 MISO_PIN + * Y_MIN 3 |d3 b2| 22 MOSI_PIN + * Z_MIN 4 |d4 * * b1| 21 SCK_PIN + * 5 |d5 e e b0| 20 SDSS + * LED 6 |d6 5 4 e7| 19 + * 7 |d7 e6| 18 + * LCD RS 8 |e0 | GND + * LCD EN 9 |e1 a4 a0 R| AREF + * LCD D4 10 |c0 a5 a1 f0| 38 A0 ENC_1 + * LCD D5 11 |c1 a6 a2 f1| 39 A1 ENC_2 + * LCD D6 12 |c2 a7 a3 f2| 40 A2 ENC_CLK + * LCD D6 13 |c3 f3| 41 A3 + * Bed Heat PWM 14 |c4 V G R f4| 42 A4 + * Extruder Heat PWM 15 |c5 c n S f5| 43 A5 + * Fan PWM 16 |c6 c d T f6| 44 A6 Bed TC + * 17 |c7 * * * f7| 45 A7 Extruder TC * 4.7k * +5 + * ----------------- + * + * Interior E4: 36, INT4 + * Interior E5: 37, INT5 + * Interior PA0-7: 28-35 -- Printrboard and Teensylu use these pins for step & direction: + * T++ PA Signal Marlin + * + * Z STEP 32 a4 a0 28 X STEP + * Z DIR 33 a5 a1 29 X DIR + * E STEP 34 a6 a2 30 Y STEP + * E DIR 35 a7 a3 31 Y DIR + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Teensy++2.0" + +// +// Limit Switches +// +#define X_STOP_PIN 2 // D2 +#define Y_STOP_PIN 3 // D3 +#define Z_STOP_PIN 4 // D4 + +// +// Steppers +// +#define X_STEP_PIN 28 // A0 Marlin +#define X_DIR_PIN 29 // A1 Marlin +#define X_ENABLE_PIN 26 // B6 + +#define Y_STEP_PIN 30 // A2 Marlin +#define Y_DIR_PIN 31 // A3 +#define Y_ENABLE_PIN 26 // B6 Shared w/x + +#define Z_STEP_PIN 32 // A4 +#define Z_DIR_PIN 33 // A5 +#define Z_ENABLE_PIN 26 // B6 Shared w/x + +#define E0_STEP_PIN 34 // A6 +#define E0_DIR_PIN 35 // A7 +#define E0_ENABLE_PIN 26 // B6 Shared w/x + +// +// Temperature Sensors +// +#define TEMP_0_PIN 7 // F7 Analog Input (Extruder) +#define TEMP_BED_PIN 6 // F6 Analog Input (Bed) + +// +// Heaters / Fans +// +#define HEATER_0_PIN 15 // C5 PWM3B Extruder +#define HEATER_BED_PIN 14 // C4 PWM3C +#ifndef FAN_PIN + #define FAN_PIN 16 // C6 PWM3A Fan +#endif + +// +// Misc. Functions +// +#define SDSS 20 // B0 +#define LED_PIN 6 // D6 +#define PS_ON_PIN 27 // B7 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 1 // D1 PWM2B MUST BE HARDWARE PWM +#endif + +// +// LCD / Controller +// +#if IS_ULTIPANEL + #define LCD_PINS_RS 8 // E0 + #define LCD_PINS_ENABLE 9 // E1 + #define LCD_PINS_D4 10 // C0 + #define LCD_PINS_D5 11 // C1 + #define LCD_PINS_D6 12 // C2 + #define LCD_PINS_D7 13 // C3 + #define BTN_EN1 38 // F0 + #define BTN_EN2 39 // F1 + #define BTN_ENC 40 // F2 +#endif + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_ENA_PIN 5 // D5 Pin should have a pullup! +#define SPINDLE_LASER_PWM_PIN 0 // D0 PWM0B MUST BE HARDWARE PWM +#define SPINDLE_DIR_PIN 7 // D7 diff --git a/src/pins/teensy2/pins_TEENSYLU.h b/src/pins/teensy2/pins_TEENSYLU.h new file mode 100644 index 0000000..ab72247 --- /dev/null +++ b/src/pins/teensy2/pins_TEENSYLU.h @@ -0,0 +1,168 @@ +/** + * 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 . + */ +#pragma once + +/** + * Rev C 2 JUN 2017 + * + * Converted to Arduino pin numbering + */ + +/** + * There are two Arduino IDE extensions that are compatible with this board + * and with the mainstream Marlin software. All have been used with Arduino 1.6.12 + * + * Teensyduino - https://www.pjrc.com/teensy/teensyduino.html + * Select Teensy++ 2.0 in Arduino IDE from the 'Tools > Board' menu + * + * Installation instructions are at the above URL. Don't bother loading the + * libraries - they are not used with the Marlin software. + * + * Printrboard - https://github.com/scwimbush/Printrboard-HID-Arduino-IDE-Support + * This is basically Teensyduino but with a bootloader that can handle image sizes + * larger than 64K. + * + * Installation: + * + * 1. Go to the above URL, click on the "Clone or Download" button and then + * click on "Download ZIP" button. + * 2. Unzip the file, find the "printrboard" directory and then copy it to the + * hardware directory in Arduino. The Arduino hardware directory will probably + * be located in a path similar to this: C:\Program Files (x86)\Arduino\hardware. + * 3. Restart Arduino. + * 4. Select "Printrboard" from the 'Tools > Board' menu. + * + * Teensyduino is the most popular option. Printrboard is used if your board doesn't have + * the Teensyduino bootloader on it. + */ + +/** + * To burn the bootloader that comes with Printrboard: + * + * 1. Connect your programmer to the board. + * 2. In the Arduino IDE select "Printrboard" and then select the programmer. + * 3. In the Arduino IDE click on "burn bootloader". Don't worry about the "verify failed at 1F000" error message. + * 4. The programmer is no longer needed. Remove it. + */ + + /** + * SILKSCREEN ERROR + * + * The silkscreen for the endstops do NOT match the schematic. The silkscreen SHOULD + * read (from left to right) X-STOP, Y-STOP, Z-STOP & E-STOP. The silkscreen actually + * reads E-STOP, X-STOP, Y-STOP & Z-STOP. + * + * The pin assignments in this file match the silkscreen. + */ + +#define ALLOW_AT90USB1286P +#include "env_validate.h" + +#if NOT_TARGET(__AVR_AT90USB1286__, __AVR_AT90USB1286P__) + #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "Teensylu" + +// +// Limit Switch definitions that match the SCHEMATIC +// +//#define X_STOP_PIN 25 // B5 +//#define Y_STOP_PIN 26 // B6 +//#define Z_STOP_PIN 27 // B7 +//#define E_STOP_PIN 36 // E4 + +// +// Limit Switch definitions that match the SILKSCREEN +// +#define X_STOP_PIN 26 // B6 +#define Y_STOP_PIN 27 // B7 +#define Z_STOP_PIN 36 // E4 +//#define E_STOP_PIN 25 // B5 + +// +// Steppers +// +#define X_STEP_PIN 28 // A0 +#define X_DIR_PIN 29 // A1 +#define X_ENABLE_PIN 19 // E7 + +#define Y_STEP_PIN 30 // A2 +#define Y_DIR_PIN 31 // A3 +#define Y_ENABLE_PIN 18 // E6 + +#define Z_STEP_PIN 32 // A4 +#define Z_DIR_PIN 33 // A5 +#define Z_ENABLE_PIN 17 // C7 + +#define E0_STEP_PIN 34 // A6 +#define E0_DIR_PIN 35 // A7 +#define E0_ENABLE_PIN 13 // C3 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 7 // Analog Input (Extruder) +#define TEMP_BED_PIN 6 // Analog Input (Bed) + +// +// Heaters / Fans +// +#define HEATER_0_PIN 15 // C5 PWM3B - Extruder +#define HEATER_BED_PIN 14 // C4 PWM3C + +#ifndef FAN_PIN + #define FAN_PIN 16 // C6 PWM3A +#endif + +// +// Misc. Functions +// +#define SDSS 20 // B0 JP31-6 + +#ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 0 // D0 IO-14 PWM0B +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD && IS_NEWPANEL + + #define BEEPER_PIN -1 + + #if ENABLED(LCD_I2C_PANELOLU2) + #define BTN_EN1 3 // D3 IO-8 + #define BTN_EN2 2 // D2 IO-10 + #define BTN_ENC 41 // F3 IO-7 + #define SDSS 38 // F0 IO-13 use SD card on Panelolu2 + #endif + + #define SD_DETECT_PIN -1 + +#endif // HAS_WIRED_LCD && IS_NEWPANEL + +// +// M3/M4/M5 - Spindle/Laser Control +// +#define SPINDLE_LASER_PWM_PIN 24 // B4 IO-3 PWM2A - MUST BE HARDWARE PWM +#define SPINDLE_LASER_ENA_PIN 39 // F1 IO-11 - Pin should have a pullup! +#define SPINDLE_DIR_PIN 40 // F2 IO-9 diff --git a/src/pins/teensy3/pins_TEENSY31_32.h b/src/pins/teensy3/pins_TEENSY31_32.h new file mode 100644 index 0000000..0edb5cb --- /dev/null +++ b/src/pins/teensy3/pins_TEENSY31_32.h @@ -0,0 +1,112 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Teensy 3.1 (MK20DX256) and Teensy 3.2 (MK20DX256) Breadboard pin assignments + * Requires the Teensyduino software with Teensy 3.1 or Teensy 3.2 selected in Arduino IDE! + * https://www.pjrc.com/teensy/teensyduino.html + */ + +#if NOT_TARGET(IS_TEENSY_31_32) + #error "Oops! Select 'Teensy 3.1' or 'Teensy 3.2' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Teensy3.2" +#endif + +// +// Limit Switches +// +#define X_STOP_PIN 3 +#define Y_STOP_PIN 4 +#define Z_STOP_PIN 5 + +// +// Steppers +// +#define X_STEP_PIN 5 +#define X_DIR_PIN 6 +#define X_ENABLE_PIN 2 + +#define Y_STEP_PIN 7 +#define Y_DIR_PIN 8 +#define Y_ENABLE_PIN 2 + +#define Z_STEP_PIN 9 +#define Z_DIR_PIN 10 +#define Z_ENABLE_PIN 2 + +#define E0_STEP_PIN 11 +#define E0_DIR_PIN 12 +#define E0_ENABLE_PIN 2 + +//#define E1_STEP_PIN 33 +//#define E1_DIR_PIN 34 +//#define E1_ENABLE_PIN 35 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 20 +//#define HEATER_1_PIN 36 +#define HEATER_BED_PIN 21 +#ifndef FAN_PIN + #define FAN_PIN 22 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 14 // Analog Input - Extruder 2 => A2 +//#define TEMP_1_PIN 0 // Analog Input +#define TEMP_BED_PIN 15 // Analog Input - Bed + +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 6 // Analog Input +#endif + +// +// Misc. Functions +// +#define LED_PIN 13 +//#define SOL1_PIN 28 +//#define SDSS 16 // 8 + +// +// LCD / Controller +// + +/* +#if HAS_WIRED_LCD + #define LCD_PINS_RS 40 + #define LCD_PINS_ENABLE 41 + #define LCD_PINS_D4 42 + #define LCD_PINS_D5 43 + #define LCD_PINS_D6 44 + #define LCD_PINS_D7 45 + #define BTN_EN1 46 + #define BTN_EN2 47 + #define BTN_ENC 48 +#endif +*/ diff --git a/src/pins/teensy3/pins_TEENSY35_36.h b/src/pins/teensy3/pins_TEENSY35_36.h new file mode 100644 index 0000000..71c3485 --- /dev/null +++ b/src/pins/teensy3/pins_TEENSY35_36.h @@ -0,0 +1,152 @@ +/** + * 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 . + * + */ +#pragma once + +/**************************************************************************************** +* Teensy 3.5 (MK64FX512) and Teensy 3.6 (MK66FX1M0) Breadboard pin assignments +* Requires the Teensyduino software with Teensy 3.5 or Teensy 3.6 selected in Arduino IDE! +* https://www.pjrc.com/teensy/teensyduino.html +****************************************************************************************/ + +#if NOT_TARGET(IS_TEENSY_35_36) + #error "Oops! Select 'Teensy 3.5' or 'Teensy 3.6' in 'Tools > Board.'" +#endif + +#if IS_TEENSY35 + #define BOARD_INFO_NAME "Teensy3.5" +#elif IS_TEENSY36 + #define BOARD_INFO_NAME "Teensy3.6" +#endif + +/** + * Plan for Teensy 3.5 and Teensy 3.6: + * USB + * GND |-----#####-----| VIN 5V + * X_STEP_PIN MOSI1 RX1 0 | ##### | Analog GND + * X_DIR_PIN MISO1 TX1 1 | | 3.3V + * Y_STEP_PIN PWM 2 | *NC AREF* | 23 A9 PWM + * Y_DIR_PIN SCL2 CAN0TX PWM 3 | *A26 A10* | 22 A8 PWM + * Z_STEP_PIN SDA2 CAN0RX PWM 4 | *A25 A11* | 21 A7 PWM CS0 MOSI1 RX1 + * Z_DIR_PIN MISO1 TX1 PWM 5 | *GND * * 57 | 20 A6 PWM CS0 SCK1 FILWIDTH_PIN + * X_ENABLE_PIN PWM 6 | *GND * * 56 | 19 A5 SCL0 E0_STEP_PIN + * Y_ENABLE_PIN SCL0 MOSI0 RX3 PWM 7 | * * 55 | 18 A4 SDA0 E0_DIR_PIN + * Z_ENABLE_PIN SDA0 MISO0 TX3 PWM 8 | * * 54 | 17 A3 SDA0 E0_ENABLE_PIN + * CS0 RX2 PWM 9 | | 16 A2 SCL0 TEMP_0_PIN + * CS0 TX2 PWM 10 | | 15 A1 CS0 TEMP_BED_PIN + * X_STOP_PIN MOSI0 11 | | 14 A0 PWM CS0 TEMP_1_PIN + * Y_STOP_PIN MISO0 12 | | 13 LED SCK0 LED_PIN + * 3.3V | | GND + * Z_STOP_PIN 24 | 40 * * 53 | A22 DAC1 + * AUX2 25 | 41 * * 52 | A21 DAC0 + * AUX2 FAN_PIN SCL2 TX1 26 | 42 * * 51 | 39 A20 MISO0 SDSS + * AUX2 Z-PROBE PWR SCK0 RX1 27 | * * * * * | 38 A19 PWM SDA1 + * AUX2 SOL1_PIN MOSI0 28 | 43 * * 50 | 37 A18 PWM SCL1 + * D10 CONTROLLER_FAN_PIN CAN0TX PWM 29 | 44 * * 49 | 36 A17 PWM + * D9 HEATER_0_PIN CAN0RX PWM 30 | 45 * * 48 | 35 A16 PWM E1_ENABLE_PIN + * D8 HEATER_BED_PIN CS1 RX4 A12 31 | 46 * * 47 | 34 A15 PWM SDA0 RX5 E1_DIR_PIN + * SCK1 TX4 A13 32 |__GND_*_*_3.3V_| 33 A14 PWM SCL0 TX5 E1_STEP_PIN + * + * Interior pins: + * LCD_PINS_RS 40 * * 53 SCK2 + * LCD_PINS_ENABLE 41 * * 52 MOSI2 + * LCD_PINS_D4 42 * * 51 MISO2 + * LCD_PINS_D5 CS2 43 * * 50 A24 + * LCD_PINS_D6 MOSI2 44 * * 49 A23 + * LCD_PINS_D7 MISO2 45 * * 48 TX6 SDA0 BTN_ENC + * BTN_EN1 SCK2 46 * * 47 RX6 SCL0 BTN_EN2 + * GND * * 3.3V + */ + +// +// Limit Switches +// +#define X_STOP_PIN 24 +#define Y_STOP_PIN 26 +#define Z_STOP_PIN 28 + +// +// Steppers +// +#define X_STEP_PIN 22 +#define X_DIR_PIN 21 +#define X_ENABLE_PIN 39 + +#define Y_STEP_PIN 19 +#define Y_DIR_PIN 18 +#define Y_ENABLE_PIN 20 + +#define Z_STEP_PIN 38 +#define Z_DIR_PIN 37 +#define Z_ENABLE_PIN 17 + +#define E0_STEP_PIN 31 +#define E0_DIR_PIN 30 +#define E0_ENABLE_PIN 32 + +#define E1_STEP_PIN 33 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 35 + +#define HEATER_0_PIN 30 +#define HEATER_1_PIN 36 +#define HEATER_BED_PIN 31 +#ifndef FAN_PIN + #define FAN_PIN 2 +#endif + +#define TEMP_0_PIN 2 // Extruder / Analog pin numbering: 2 => A2 +#define TEMP_1_PIN 0 +#define TEMP_BED_PIN 1 // Bed / Analog pin numbering + +// +// Misc. Functions +// +#define LED_PIN 13 +#define PS_ON_PIN 1 +#define FILWIDTH_PIN 6 +#define SOL1_PIN 28 + +// +// SD Card +// +#define SDSS 39 // 8 + +#if HAS_WIRED_LCD + #define LCD_PINS_RS 40 + #define LCD_PINS_ENABLE 41 + #define LCD_PINS_D4 42 + #define LCD_PINS_D5 43 + #define LCD_PINS_D6 44 + #define LCD_PINS_D7 45 +#endif + +#if IS_NEWPANEL + #define BTN_EN1 46 + #define BTN_EN2 47 + #define BTN_ENC 48 +#endif + +#if IS_RRW_KEYPAD + #define SHIFT_OUT_PIN 40 + #define SHIFT_CLK_PIN 44 + #define SHIFT_LD_PIN 42 +#endif diff --git a/src/pins/teensy4/pins_T41U5XBB.h b/src/pins/teensy4/pins_T41U5XBB.h new file mode 100644 index 0000000..5f62bb0 --- /dev/null +++ b/src/pins/teensy4/pins_T41U5XBB.h @@ -0,0 +1,126 @@ +/** + * 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 . + * + */ +#pragma once + +/**************************************************************************************** +* Teensy 4.1 (IMXRT1062) Breadboard pin assignments +* Requires the Teensyduino software with Teensy 4.1 selected in Arduino IDE! +* https://www.pjrc.com/teensy/teensyduino.html +****************************************************************************************/ + +#if NOT_TARGET(IS_TEENSY41) + #error "Oops! Select 'Teensy 4.1' in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "Teensy4.1" + +/** + * Plan for Teensy 4.0 and Teensy 4.1: + * USB + * GND |-----#####-----| VIN (3.65 TO 5.5V) + * RX1 CS1 RX1 PWM 0 | ##### | GND + * TX1 MISO1 TX1 PWM 1 | | 3.3V + * STPX PWM 2 | | 23 A9 PWM + * DIRX PWM 3 | | 22 A8 PWM LIMZ + * STPY PWM 4 | | 21 A7 RX5 LIMY + * DIRY PWM 5 | | 20 A6 TX5 LIMX + * STPZ PWM 6 | | 19 A5 PWM SCL0 COOL + * DIRZ RX2 PWM 7 | | 18 A4 PWM SDA0 MIST + * STPA TX2 PWM 8 | | 17 A3 RX4 SDA1 CYST + * DIRA PWM 9 | | 16 A2 TX4 SCL1 EHOLD + * STEN PWM 10 | | 15 A1 PWM RX3 PRB + * SPDI MOSI0 PWM 11 | | 14 A0 PWM TX3 PANIC + * SPEN MISO0 PWM 12 | | 13 LED PWM SCK0 SPWM + * 3.3V | | GND + * SCL PWM 24 | | 41 A17 KPSTR + * SDA PWM 25 | | 40 A16 STENY + * STPB MOSI1 26 | | 39 A15 MISO1 STENZ + * DIRB SCK1 27 | * * * * * | 38 A14 STENA + * LIMB RX7 PWM 28 | | 37 PWM STENB + * DOOR TX7 PWM 29 | | 36 PWM ST0 + * ST1 30 | | 35 TX8 ST3 + * AUX0 31 | SDCARD | 34 RX8 ST2 + * AUX1 32 |_______________| 33 PWM AUX2 + */ + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +// +// Servos +// +#define SERVO0_PIN 24 +#define SERVO1_PIN 25 + +// +// Limit Switches +// +#define X_STOP_PIN 20 +#define Y_STOP_PIN 21 +#define Z_STOP_PIN 22 + +// +// Steppers +// +#define X_STEP_PIN 2 +#define X_DIR_PIN 3 +#define X_ENABLE_PIN 10 +//#define X_CS_PIN 30 + +#define Y_STEP_PIN 4 +#define Y_DIR_PIN 5 +#define Y_ENABLE_PIN 40 +//#define Y_CS_PIN 31 + +#define Z_STEP_PIN 6 +#define Z_DIR_PIN 7 +#define Z_ENABLE_PIN 39 +//#define Z_CS_PIN 32 + +#define E0_STEP_PIN 8 +#define E0_DIR_PIN 9 +#define E0_ENABLE_PIN 38 + +#define E1_STEP_PIN 26 +#define E1_DIR_PIN 27 +#define E1_ENABLE_PIN 37 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 31 +#define HEATER_1_PIN 32 +#define HEATER_BED_PIN 33 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 5 // Extruder / Analog pin numbering: 2 => A2 +#define TEMP_1_PIN 4 +#define TEMP_BED_PIN 15 // Bed / Analog pin numbering + +// +// Misc. Functions +// +#define LED_PIN 13 +#define SOL0_PIN 17 diff --git a/src/pins/teensy4/pins_TEENSY41.h b/src/pins/teensy4/pins_TEENSY41.h new file mode 100644 index 0000000..21a1ff6 --- /dev/null +++ b/src/pins/teensy4/pins_TEENSY41.h @@ -0,0 +1,131 @@ +/** + * 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 . + * + */ +#pragma once + +/**************************************************************************************** +* Teensy 4.1 (IMXRT1062) Breadboard pin assignments +* Requires the Teensyduino software with Teensy 4.1 selected in Arduino IDE! +* https://www.pjrc.com/teensy/teensyduino.html +****************************************************************************************/ + +#if NOT_TARGET(IS_TEENSY41) + #error "Oops! Select 'Teensy 4.1' in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "Teensy4.1" + +/** + * Plan for Teensy 4.0 and Teensy 4.1: + * USB + * GND |-----#####-----| VIN (3.65 TO 5.5V) + * X_STEP_PIN CS1 RX1 PWM 0 | ##### | GND + * X_DIR_PIN MISO1 TX1 PWM 1 | | 3.3V + * Y_STEP_PIN PWM 2 | | 23 A9 PWM SERVO1_PIN + * Y_DIR_PIN PWM 3 | | 22 A8 PWM SERVO0_PIN + * Z_STEP_PIN PWM 4 | | 21 A7 RX5 + * Z_DIR_PIN PWM 5 | | 20 A6 TX5 FILWIDTH_PIN + * X_ENABLE_PIN PWM 6 | | 19 A5 PWM SCL0 + * Y_ENABLE_PIN RX2 PWM 7 | | 18 A4 PWM SDA0 HEATER_1_PIN + * Z_ENABLE_PIN TX2 PWM 8 | | 17 A3 RX4 SDA1 + * E0_STEP_PIN PWM 9 | | 16 A2 TX4 SCL1 TEMP_0_PIN + * E0_DIR_PIN PWM 10 | | 15 A1 PWM RX3 TEMP_BED_PIN + * MOSI_PIN MOSI0 PWM 11 | | 14 A0 PWM TX3 TEMP_1_PIN + * MISO_PIN MISO0 PWM 12 | | 13 LED PWM SCK0 SCK_PIN + * 3.3V | | GND + * Z_STOP_PIN PWM 24 | | 41 A17 + * E0_ENABLE_PIN PWM 25 | | 40 A16 + * FAN_PIN MOSI1 26 | | 39 A15 MISO1 X_STOP_PIN + * Z-PROBE PWR SCK1 27 | * * * * * | 38 A14 Y_STOP_PIN + * SOL1_PIN RX7 PWM 28 | | 37 PWM HEATER_0_PIN + * FAN_PIN TX7 PWM 29 | | 36 PWM HEATER_BED_PIN + * X_CS_PIN 30 | | 35 TX8 E1_ENABLE_PIN + * y_CS_PIN 31 | SDCARD | 34 RX8 E1_DIR_PIN + * Z_CS_PIN 32 |_______________| 33 PWM E1_STEP_PIN + */ + +// +// Servos +// +#define SERVO0_PIN 22 +#define SERVO1_PIN 23 + +// +// Limit Switches +// +#define X_STOP_PIN 39 +#define Y_STOP_PIN 38 +#define Z_STOP_PIN 24 + +// +// Steppers +// +#define X_STEP_PIN 0 +#define X_DIR_PIN 1 +#define X_ENABLE_PIN 6 +//#define X_CS_PIN 30 + +#define Y_STEP_PIN 2 +#define Y_DIR_PIN 3 +#define Y_ENABLE_PIN 7 +//#define Y_CS_PIN 31 + +#define Z_STEP_PIN 4 +#define Z_DIR_PIN 5 +#define Z_ENABLE_PIN 8 +//#define Z_CS_PIN 32 + +#define E0_STEP_PIN 9 +#define E0_DIR_PIN 10 +#define E0_ENABLE_PIN 25 + +#define E1_STEP_PIN 33 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 35 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 37 +#define HEATER_1_PIN 18 +#define HEATER_BED_PIN 36 +#ifndef FAN_PIN + #define FAN_PIN 29 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 2 // Extruder / Analog pin numbering: 2 => A2 +#define TEMP_1_PIN 0 +#define TEMP_BED_PIN 1 // Bed / Analog pin numbering + +// +// Misc. Functions +// +#define LED_PIN 13 +#define SOL0_PIN 28 +//#define PS_ON_PIN 1 +//#define FILWIDTH_PIN 6 // A6 + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif diff --git a/src/sd/Sd2Card.cpp b/src/sd/Sd2Card.cpp new file mode 100644 index 0000000..2d84c95 --- /dev/null +++ b/src/sd/Sd2Card.cpp @@ -0,0 +1,681 @@ +/** + * 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 . + * + */ + +/** + * Arduino Sd2Card Library + * Copyright (c) 2009 by William Greiman + * Updated with backports of the latest SdFat library from the same author + * + * This file is part of the Arduino Sd2Card Library + */ + +#include "../inc/MarlinConfig.h" + +#if NEED_SD2CARD_SPI + +/* Enable FAST CRC computations - You can trade speed for FLASH space if + * needed by disabling the following define */ +#define FAST_CRC 1 + +#include "Sd2Card.h" + +#include "../MarlinCore.h" + +#if ENABLED(SD_CHECK_AND_RETRY) + static bool crcSupported = true; + + #ifdef FAST_CRC + static const uint8_t crctab7[] PROGMEM = { + 0x00,0x09,0x12,0x1B,0x24,0x2D,0x36,0x3F,0x48,0x41,0x5A,0x53,0x6C,0x65,0x7E,0x77, + 0x19,0x10,0x0B,0x02,0x3D,0x34,0x2F,0x26,0x51,0x58,0x43,0x4A,0x75,0x7C,0x67,0x6E, + 0x32,0x3B,0x20,0x29,0x16,0x1F,0x04,0x0D,0x7A,0x73,0x68,0x61,0x5E,0x57,0x4C,0x45, + 0x2B,0x22,0x39,0x30,0x0F,0x06,0x1D,0x14,0x63,0x6A,0x71,0x78,0x47,0x4E,0x55,0x5C, + 0x64,0x6D,0x76,0x7F,0x40,0x49,0x52,0x5B,0x2C,0x25,0x3E,0x37,0x08,0x01,0x1A,0x13, + 0x7D,0x74,0x6F,0x66,0x59,0x50,0x4B,0x42,0x35,0x3C,0x27,0x2E,0x11,0x18,0x03,0x0A, + 0x56,0x5F,0x44,0x4D,0x72,0x7B,0x60,0x69,0x1E,0x17,0x0C,0x05,0x3A,0x33,0x28,0x21, + 0x4F,0x46,0x5D,0x54,0x6B,0x62,0x79,0x70,0x07,0x0E,0x15,0x1C,0x23,0x2A,0x31,0x38, + 0x41,0x48,0x53,0x5A,0x65,0x6C,0x77,0x7E,0x09,0x00,0x1B,0x12,0x2D,0x24,0x3F,0x36, + 0x58,0x51,0x4A,0x43,0x7C,0x75,0x6E,0x67,0x10,0x19,0x02,0x0B,0x34,0x3D,0x26,0x2F, + 0x73,0x7A,0x61,0x68,0x57,0x5E,0x45,0x4C,0x3B,0x32,0x29,0x20,0x1F,0x16,0x0D,0x04, + 0x6A,0x63,0x78,0x71,0x4E,0x47,0x5C,0x55,0x22,0x2B,0x30,0x39,0x06,0x0F,0x14,0x1D, + 0x25,0x2C,0x37,0x3E,0x01,0x08,0x13,0x1A,0x6D,0x64,0x7F,0x76,0x49,0x40,0x5B,0x52, + 0x3C,0x35,0x2E,0x27,0x18,0x11,0x0A,0x03,0x74,0x7D,0x66,0x6F,0x50,0x59,0x42,0x4B, + 0x17,0x1E,0x05,0x0C,0x33,0x3A,0x21,0x28,0x5F,0x56,0x4D,0x44,0x7B,0x72,0x69,0x60, + 0x0E,0x07,0x1C,0x15,0x2A,0x23,0x38,0x31,0x46,0x4F,0x54,0x5D,0x62,0x6B,0x70,0x79 + }; + + static uint8_t CRC7(const uint8_t *data, uint8_t n) { + uint8_t crc = 0; + while (n > 0) { + crc = pgm_read_byte(&crctab7[ (crc << 1) ^ *data++ ]); + n--; + } + return (crc << 1) | 1; + } + #else + static uint8_t CRC7(const uint8_t *data, uint8_t n) { + uint8_t crc = 0; + LOOP_L_N(i, n) { + uint8_t d = data[i]; + d ^= crc << 1; + if (d & 0x80) d ^= 9; + crc = d ^ (crc & 0x78) ^ (crc << 4) ^ ((crc >> 3) & 15); + crc &= 0x7F; + } + crc = (crc << 1) ^ (crc << 4) ^ (crc & 0x70) ^ ((crc >> 3) & 0x0F); + return crc | 1; + } + #endif +#endif + +// Send command and return error code. Return zero for OK +uint8_t DiskIODriver_SPI_SD::cardCommand(const uint8_t cmd, const uint32_t arg) { + + #if ENABLED(SDCARD_COMMANDS_SPLIT) + if (cmd != CMD12) chipDeselect(); + #endif + + // Select card + chipSelect(); + + // Wait up to 300 ms if busy + waitNotBusy(SD_WRITE_TIMEOUT); + + uint8_t *pa = (uint8_t *)(&arg); + + #if ENABLED(SD_CHECK_AND_RETRY) + + // Form message + uint8_t d[6] = {(uint8_t) (cmd | 0x40), pa[3], pa[2], pa[1], pa[0] }; + + // Add crc + d[5] = CRC7(d, 5); + + // Send message + LOOP_L_N(k, 6) spiSend(d[k]); + + #else + // Send command + spiSend(cmd | 0x40); + + // Send argument + for (int8_t i = 3; i >= 0; i--) spiSend(pa[i]); + + // Send CRC - correct for CMD0 with arg zero or CMD8 with arg 0X1AA + spiSend(cmd == CMD0 ? 0X95 : 0X87); + #endif + + // Skip stuff byte for stop read + if (cmd == CMD12) spiRec(); + + // Wait for response + for (uint8_t i = 0; ((status_ = spiRec()) & 0x80) && i != 0xFF; i++) { /* Intentionally left empty */ } + return status_; +} + +/** + * Determine the size of an SD flash memory card. + * + * \return The number of 512 byte data blocks in the card + * or zero if an error occurs. + */ +uint32_t DiskIODriver_SPI_SD::cardSize() { + csd_t csd; + if (!readCSD(&csd)) return 0; + if (csd.v1.csd_ver == 0) { + uint8_t read_bl_len = csd.v1.read_bl_len; + uint16_t c_size = (csd.v1.c_size_high << 10) + | (csd.v1.c_size_mid << 2) | csd.v1.c_size_low; + uint8_t c_size_mult = (csd.v1.c_size_mult_high << 1) + | csd.v1.c_size_mult_low; + return (uint32_t)(c_size + 1) << (c_size_mult + read_bl_len - 7); + } + else if (csd.v2.csd_ver == 1) { + uint32_t c_size = ((uint32_t)csd.v2.c_size_high << 16) + | (csd.v2.c_size_mid << 8) | csd.v2.c_size_low; + return (c_size + 1) << 10; + } + else { + error(SD_CARD_ERROR_BAD_CSD); + return 0; + } +} + +void DiskIODriver_SPI_SD::chipDeselect() { + extDigitalWrite(chipSelectPin_, HIGH); + spiSend(0xFF); // Ensure MISO goes high impedance +} + +void DiskIODriver_SPI_SD::chipSelect() { + spiInit(spiRate_); + extDigitalWrite(chipSelectPin_, LOW); +} + +/** + * Erase a range of blocks. + * + * \param[in] firstBlock The address of the first block in the range. + * \param[in] lastBlock The address of the last block in the range. + * + * \note This function requests the SD card to do a flash erase for a + * range of blocks. The data on the card after an erase operation is + * either 0 or 1, depends on the card vendor. The card must support + * single block erase. + * + * \return true for success, false for failure. + */ +bool DiskIODriver_SPI_SD::erase(uint32_t firstBlock, uint32_t lastBlock) { + if (ENABLED(SDCARD_READONLY)) return false; + + csd_t csd; + if (!readCSD(&csd)) goto FAIL; + + // check for single block erase + if (!csd.v1.erase_blk_en) { + // erase size mask + uint8_t m = (csd.v1.sector_size_high << 1) | csd.v1.sector_size_low; + if ((firstBlock & m) != 0 || ((lastBlock + 1) & m) != 0) { + // error card can't erase specified area + error(SD_CARD_ERROR_ERASE_SINGLE_BLOCK); + goto FAIL; + } + } + if (type_ != SD_CARD_TYPE_SDHC) { firstBlock <<= 9; lastBlock <<= 9; } + if (cardCommand(CMD32, firstBlock) || cardCommand(CMD33, lastBlock) || cardCommand(CMD38, 0)) { + error(SD_CARD_ERROR_ERASE); + goto FAIL; + } + if (!waitNotBusy(SD_ERASE_TIMEOUT)) { + error(SD_CARD_ERROR_ERASE_TIMEOUT); + goto FAIL; + } + chipDeselect(); + return true; + FAIL: + chipDeselect(); + return false; +} + +/** + * Determine if card supports single block erase. + * + * \return true if single block erase is supported. + * false if single block erase is not supported. + */ +bool DiskIODriver_SPI_SD::eraseSingleBlockEnable() { + csd_t csd; + return readCSD(&csd) ? csd.v1.erase_blk_en : false; +} + +/** + * Initialize an SD flash memory card. + * + * \param[in] sckRateID SPI clock rate selector. See setSckRate(). + * \param[in] chipSelectPin SD chip select pin number. + * + * \return true for success, false for failure. + * The reason for failure can be determined by calling errorCode() and errorData(). + */ +bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPin) { + #if IS_TEENSY_35_36 || IS_TEENSY_40_41 + chipSelectPin_ = BUILTIN_SDCARD; + const uint8_t ret = SDHC_CardInit(); + type_ = SDHC_CardGetType(); + return (ret == 0); + #endif + + errorCode_ = type_ = 0; + chipSelectPin_ = chipSelectPin; + // 16-bit init start time allows over a minute + const millis_t init_timeout = millis() + SD_INIT_TIMEOUT; + uint32_t arg; + + hal.watchdog_refresh(); // In case init takes too long + + // Set pin modes + #if ENABLED(ZONESTAR_12864OLED) + if (chipSelectPin_ != DOGLCD_CS) { + SET_OUTPUT(DOGLCD_CS); + WRITE(DOGLCD_CS, HIGH); + } + #else + extDigitalWrite(chipSelectPin_, HIGH); // For some CPUs pinMode can write the wrong data so init desired data value first + pinMode(chipSelectPin_, OUTPUT); // Solution for #8746 by @benlye + #endif + spiBegin(); + + // Set SCK rate for initialization commands + spiRate_ = SPI_SD_INIT_RATE; + spiInit(spiRate_); + + // Must supply min of 74 clock cycles with CS high. + LOOP_L_N(i, 10) spiSend(0xFF); + + hal.watchdog_refresh(); // In case init takes too long + + // Command to go idle in SPI mode + while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) { + if (ELAPSED(millis(), init_timeout)) { + error(SD_CARD_ERROR_CMD0); + goto FAIL; + } + } + + #if ENABLED(SD_CHECK_AND_RETRY) + crcSupported = (cardCommand(CMD59, 1) == R1_IDLE_STATE); + #endif + + hal.watchdog_refresh(); // In case init takes too long + + // check SD version + for (;;) { + if (cardCommand(CMD8, 0x1AA) == (R1_ILLEGAL_COMMAND | R1_IDLE_STATE)) { + type(SD_CARD_TYPE_SD1); + break; + } + + // Get the last byte of r7 response + LOOP_L_N(i, 4) status_ = spiRec(); + if (status_ == 0xAA) { + type(SD_CARD_TYPE_SD2); + break; + } + + if (ELAPSED(millis(), init_timeout)) { + error(SD_CARD_ERROR_CMD8); + goto FAIL; + } + } + + hal.watchdog_refresh(); // In case init takes too long + + // Initialize card and send host supports SDHC if SD2 + arg = type() == SD_CARD_TYPE_SD2 ? 0x40000000 : 0; + while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) { + // Check for timeout + if (ELAPSED(millis(), init_timeout)) { + error(SD_CARD_ERROR_ACMD41); + goto FAIL; + } + } + // If SD2 read OCR register to check for SDHC card + if (type() == SD_CARD_TYPE_SD2) { + if (cardCommand(CMD58, 0)) { + error(SD_CARD_ERROR_CMD58); + goto FAIL; + } + if ((spiRec() & 0xC0) == 0xC0) type(SD_CARD_TYPE_SDHC); + // Discard rest of ocr - contains allowed voltage range + LOOP_L_N(i, 3) spiRec(); + } + chipDeselect(); + + ready = true; + return setSckRate(sckRateID); + + FAIL: + chipDeselect(); + ready = false; + return false; +} + +/** + * Read a 512 byte block from an SD card. + * + * \param[in] blockNumber Logical block to be read. + * \param[out] dst Pointer to the location that will receive the data. + * \return true for success, false for failure. + */ +bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t *dst) { + #if IS_TEENSY_35_36 || IS_TEENSY_40_41 + return 0 == SDHC_CardReadBlock(dst, blockNumber); + #endif + + if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; // Use address if not SDHC card + + #if ENABLED(SD_CHECK_AND_RETRY) + uint8_t retryCnt = 3; + for (;;) { + if (cardCommand(CMD17, blockNumber)) + error(SD_CARD_ERROR_CMD17); + else if (readData(dst, 512)) + return true; + + chipDeselect(); + if (!--retryCnt) break; + + cardCommand(CMD12, 0); // Try sending a stop command, ignore the result. + errorCode_ = 0; + } + return false; + #else + if (cardCommand(CMD17, blockNumber)) { + error(SD_CARD_ERROR_CMD17); + chipDeselect(); + return false; + } + else + return readData(dst, 512); + #endif +} + +/** + * Read one data block in a multiple block read sequence + * + * \param[in] dst Pointer to the location for the data to be read. + * + * \return true for success, false for failure. + */ +bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { + chipSelect(); + return readData(dst, 512); +} + +#if ENABLED(SD_CHECK_AND_RETRY) + #ifdef FAST_CRC + static const uint16_t crctab16[] PROGMEM = { + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, + 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, + 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, + 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, + 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, + 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, + 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, + 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, + 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, + 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, + 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, + 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, + 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, + 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, + 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, + 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, + 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, + 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, + 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, + 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, + 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, + 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, + 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 + }; + // faster CRC-CCITT + // uses the x^16,x^12,x^5,x^1 polynomial. + static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { + uint16_t crc = 0; + for (size_t i = 0; i < n; i++) + crc = pgm_read_word(&crctab16[(crc >> 8 ^ data[i]) & 0xFF]) ^ (crc << 8); + return crc; + } + + #else + + // slower CRC-CCITT + // uses the x^16,x^12,x^5,x^1 polynomial. + static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { + uint16_t crc = 0; + for (size_t i = 0; i < n; i++) { + crc = (uint8_t)(crc >> 8) | (crc << 8); + crc ^= data[i]; + crc ^= (uint8_t)(crc & 0xFF) >> 4; + crc ^= crc << 12; + crc ^= (crc & 0xFF) << 5; + } + return crc; + } + + #endif + +#endif // SD_CHECK_AND_RETRY + +bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) { + bool success = false; + + const millis_t read_timeout = millis() + SD_READ_TIMEOUT; + while ((status_ = spiRec()) == 0xFF) { // Wait for start block token + if (ELAPSED(millis(), read_timeout)) { + error(SD_CARD_ERROR_READ_TIMEOUT); + goto FAIL; + } + } + + if (status_ == DATA_START_BLOCK) { + spiRead(dst, count); // Transfer data + + const uint16_t recvCrc = (spiRec() << 8) | spiRec(); + #if ENABLED(SD_CHECK_AND_RETRY) + success = !crcSupported || recvCrc == CRC_CCITT(dst, count); + if (!success) error(SD_CARD_ERROR_READ_CRC); + #else + success = true; + UNUSED(recvCrc); + #endif + } + else + error(SD_CARD_ERROR_READ); + + FAIL: + chipDeselect(); + return success; +} + +/** read CID or CSR register */ +bool DiskIODriver_SPI_SD::readRegister(const uint8_t cmd, void *buf) { + uint8_t *dst = reinterpret_cast(buf); + if (cardCommand(cmd, 0)) { + error(SD_CARD_ERROR_READ_REG); + chipDeselect(); + return false; + } + return readData(dst, 16); +} + +/** + * Start a read multiple blocks sequence. + * + * \param[in] blockNumber Address of first block in sequence. + * + * \note This function is used with readData() and readStop() for optimized + * multiple block reads. SPI chipSelect must be low for the entire sequence. + * + * \return true for success, false for failure. + */ +bool DiskIODriver_SPI_SD::readStart(uint32_t blockNumber) { + if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; + + const bool success = !cardCommand(CMD18, blockNumber); + if (!success) error(SD_CARD_ERROR_CMD18); + chipDeselect(); + return success; +} + +/** + * End a read multiple blocks sequence. + * + * \return true for success, false for failure. + */ +bool DiskIODriver_SPI_SD::readStop() { + chipSelect(); + const bool success = !cardCommand(CMD12, 0); + if (!success) error(SD_CARD_ERROR_CMD12); + chipDeselect(); + return success; +} + +/** + * Set the SPI clock rate. + * + * \param[in] sckRateID A value in the range [0, 6]. + * + * The SPI clock will be set to F_CPU/pow(2, 1 + sckRateID). The maximum + * SPI rate is F_CPU/2 for \a sckRateID = 0 and the minimum rate is F_CPU/128 + * for \a scsRateID = 6. + * + * \return The value one, true, is returned for success and the value zero, + * false, is returned for an invalid value of \a sckRateID. + */ +bool DiskIODriver_SPI_SD::setSckRate(const uint8_t sckRateID) { + const bool success = (sckRateID <= 6); + if (success) spiRate_ = sckRateID; else error(SD_CARD_ERROR_SCK_RATE); + return success; +} + +/** + * Wait for card to become not-busy + * \param[in] timeout_ms Timeout to abort. + * \return true for success, false for timeout. + */ +bool DiskIODriver_SPI_SD::waitNotBusy(const millis_t timeout_ms) { + const millis_t wait_timeout = millis() + timeout_ms; + while (spiRec() != 0xFF) if (ELAPSED(millis(), wait_timeout)) return false; + return true; +} + +void DiskIODriver_SPI_SD::error(const uint8_t code) { errorCode_ = code; } + +/** + * Write a 512 byte block to an SD card. + * + * \param[in] blockNumber Logical block to be written. + * \param[in] src Pointer to the location of the data to be written. + * \return true for success, false for failure. + */ +bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t *src) { + if (ENABLED(SDCARD_READONLY)) return false; + + #if IS_TEENSY_35_36 || IS_TEENSY_40_41 + return 0 == SDHC_CardWriteBlock(src, blockNumber); + #endif + + bool success = false; + if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; // Use address if not SDHC card + if (!cardCommand(CMD24, blockNumber)) { + if (writeData(DATA_START_BLOCK, src)) { + if (waitNotBusy(SD_WRITE_TIMEOUT)) { // Wait for flashing to complete + success = !(cardCommand(CMD13, 0) || spiRec()); // Response is r2 so get and check two bytes for nonzero + if (!success) error(SD_CARD_ERROR_WRITE_PROGRAMMING); + } + else + error(SD_CARD_ERROR_WRITE_TIMEOUT); + } + } + else + error(SD_CARD_ERROR_CMD24); + + chipDeselect(); + return success; +} + +/** + * Write one data block in a multiple block write sequence + * \param[in] src Pointer to the location of the data to be written. + * \return true for success, false for failure. + */ +bool DiskIODriver_SPI_SD::writeData(const uint8_t *src) { + if (ENABLED(SDCARD_READONLY)) return false; + + bool success = true; + chipSelect(); + // Wait for previous write to finish + if (!waitNotBusy(SD_WRITE_TIMEOUT) || !writeData(WRITE_MULTIPLE_TOKEN, src)) { + error(SD_CARD_ERROR_WRITE_MULTIPLE); + success = false; + } + chipDeselect(); + return success; +} + +// Send one block of data for write block or write multiple blocks +bool DiskIODriver_SPI_SD::writeData(const uint8_t token, const uint8_t *src) { + if (ENABLED(SDCARD_READONLY)) return false; + + const uint16_t crc = TERN(SD_CHECK_AND_RETRY, CRC_CCITT(src, 512), 0xFFFF); + spiSendBlock(token, src); + spiSend(crc >> 8); + spiSend(crc & 0xFF); + + status_ = spiRec(); + if ((status_ & DATA_RES_MASK) != DATA_RES_ACCEPTED) { + error(SD_CARD_ERROR_WRITE); + chipDeselect(); + return false; + } + return true; +} + +/** + * Start a write multiple blocks sequence. + * + * \param[in] blockNumber Address of first block in sequence. + * \param[in] eraseCount The number of blocks to be pre-erased. + * + * \note This function is used with writeData() and writeStop() + * for optimized multiple block writes. + * + * \return true for success, false for failure. + */ +bool DiskIODriver_SPI_SD::writeStart(uint32_t blockNumber, const uint32_t eraseCount) { + if (ENABLED(SDCARD_READONLY)) return false; + + bool success = false; + if (!cardAcmd(ACMD23, eraseCount)) { // Send pre-erase count + if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; // Use address if not SDHC card + success = !cardCommand(CMD25, blockNumber); + if (!success) error(SD_CARD_ERROR_CMD25); + } + else + error(SD_CARD_ERROR_ACMD23); + + chipDeselect(); + return success; +} + +/** + * End a write multiple blocks sequence. + * + * \return true for success, false for failure. + */ +bool DiskIODriver_SPI_SD::writeStop() { + if (ENABLED(SDCARD_READONLY)) return false; + + bool success = false; + chipSelect(); + if (waitNotBusy(SD_WRITE_TIMEOUT)) { + spiSend(STOP_TRAN_TOKEN); + success = waitNotBusy(SD_WRITE_TIMEOUT); + } + else + error(SD_CARD_ERROR_STOP_TRAN); + + chipDeselect(); + return success; +} + +#endif // NEED_SD2CARD_SPI diff --git a/src/sd/Sd2Card.h b/src/sd/Sd2Card.h new file mode 100644 index 0000000..e0dce02 --- /dev/null +++ b/src/sd/Sd2Card.h @@ -0,0 +1,197 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * \file + * \brief Sd2Card class for V2 SD/SDHC cards + */ + +/** + * Arduino Sd2Card Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include "SdFatConfig.h" +#include "SdInfo.h" +#include "disk_io_driver.h" + +#include + +uint16_t const SD_INIT_TIMEOUT = 2000, // (ms) Init timeout + SD_ERASE_TIMEOUT = 10000, // (ms) Erase timeout + SD_READ_TIMEOUT = 300, // (ms) Read timeout + SD_WRITE_TIMEOUT = 600; // (ms) Write timeout + +// SD card errors +typedef enum : uint8_t { + SD_CARD_ERROR_CMD0 = 0x01, // Timeout error for command CMD0 (initialize card in SPI mode) + SD_CARD_ERROR_CMD8 = 0x02, // CMD8 was not accepted - not a valid SD card + SD_CARD_ERROR_CMD12 = 0x03, // Card returned an error response for CMD12 (write stop) + SD_CARD_ERROR_CMD17 = 0x04, // Card returned an error response for CMD17 (read block) + SD_CARD_ERROR_CMD18 = 0x05, // Card returned an error response for CMD18 (read multiple block) + SD_CARD_ERROR_CMD24 = 0x06, // Card returned an error response for CMD24 (write block) + SD_CARD_ERROR_CMD25 = 0x07, // WRITE_MULTIPLE_BLOCKS command failed + SD_CARD_ERROR_CMD58 = 0x08, // Card returned an error response for CMD58 (read OCR) + SD_CARD_ERROR_ACMD23 = 0x09, // SET_WR_BLK_ERASE_COUNT failed + SD_CARD_ERROR_ACMD41 = 0x0A, // ACMD41 initialization process timeout + SD_CARD_ERROR_BAD_CSD = 0x0B, // Card returned a bad CSR version field + SD_CARD_ERROR_ERASE = 0x0C, // Erase block group command failed + SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0x0D, // Card not capable of single block erase + SD_CARD_ERROR_ERASE_TIMEOUT = 0x0E, // Erase sequence timed out + SD_CARD_ERROR_READ = 0x0F, // Card returned an error token instead of read data + SD_CARD_ERROR_READ_REG = 0x10, // Read CID or CSD failed + SD_CARD_ERROR_READ_TIMEOUT = 0x11, // Timeout while waiting for start of read data + SD_CARD_ERROR_STOP_TRAN = 0x12, // Card did not accept STOP_TRAN_TOKEN + SD_CARD_ERROR_WRITE = 0x13, // Card returned an error token as a response to a write operation + SD_CARD_ERROR_WRITE_BLOCK_ZERO = 0x14, // REMOVE - not used ... attempt to write protected block zero + SD_CARD_ERROR_WRITE_MULTIPLE = 0x15, // Card did not go ready for a multiple block write + SD_CARD_ERROR_WRITE_PROGRAMMING = 0x16, // Card returned an error to a CMD13 status check after a write + SD_CARD_ERROR_WRITE_TIMEOUT = 0x17, // Timeout occurred during write programming + SD_CARD_ERROR_SCK_RATE = 0x18, // Incorrect rate selected + SD_CARD_ERROR_INIT_NOT_CALLED = 0x19, // Init() not called + // 0x1A is unused now, it was: card returned an error for CMD59 (CRC_ON_OFF) + SD_CARD_ERROR_READ_CRC = 0x1B // Invalid read CRC +} sd_error_code_t; + +// card types +uint8_t const SD_CARD_TYPE_SD1 = 1, // Standard capacity V1 SD card + SD_CARD_TYPE_SD2 = 2, // Standard capacity V2 SD card + SD_CARD_TYPE_SDHC = 3; // High Capacity SD card + +/** + * Define SOFTWARE_SPI to use bit-bang SPI + */ +#if EITHER(MEGA_SOFT_SPI, USE_SOFTWARE_SPI) + #define SOFTWARE_SPI +#endif + +#if IS_TEENSY_35_36 || IS_TEENSY_40_41 + #include "NXP_SDHC.h" + #define BUILTIN_SDCARD 254 +#endif + +/** + * \class Sd2Card + * \brief Raw access to SD and SDHC flash memory cards. + */ +class DiskIODriver_SPI_SD : public DiskIODriver { +public: + + DiskIODriver_SPI_SD() : errorCode_(SD_CARD_ERROR_INIT_NOT_CALLED), type_(0) {} + + bool erase(uint32_t firstBlock, uint32_t lastBlock); + bool eraseSingleBlockEnable(); + + /** + * Set SD error code. + * \param[in] code value for error code. + */ + void error(const uint8_t code); + + /** + * \return error code for last error. See Sd2Card.h for a list of error codes. + */ + inline int errorCode() const { return errorCode_; } + + /** \return error data for last error. */ + inline int errorData() const { return status_; } + + /** + * Initialize an SD flash memory card with default clock rate and chip + * select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin). + * + * \return true for success or false for failure. + */ + bool init(const uint8_t sckRateID, const pin_t chipSelectPin) override; + + bool setSckRate(const uint8_t sckRateID); + + /** + * Return the card type: SD V1, SD V2 or SDHC + * \return 0 - SD V1, 1 - SD V2, or 3 - SDHC. + */ + int type() const { return type_; } + + /** + * Read a card's CID register. The CID contains card identification + * information such as Manufacturer ID, Product name, Product serial + * number and Manufacturing date. + * + * \param[out] cid pointer to area for returned data. + * + * \return true for success or false for failure. + */ + bool readCID(cid_t *cid) { return readRegister(CMD10, cid); } + + /** + * Read a card's CSD register. The CSD contains Card-Specific Data that + * provides information regarding access to the card's contents. + * + * \param[out] csd pointer to area for returned data. + * + * \return true for success or false for failure. + */ + inline bool readCSD(csd_t *csd) override { return readRegister(CMD9, csd); } + + bool readData(uint8_t *dst) override; + bool readStart(uint32_t blockNumber) override; + bool readStop() override; + + bool writeData(const uint8_t *src) override; + bool writeStart(const uint32_t blockNumber, const uint32_t eraseCount) override; + bool writeStop() override; + + bool readBlock(uint32_t block, uint8_t *dst) override; + bool writeBlock(uint32_t blockNumber, const uint8_t *src) override; + + uint32_t cardSize() override; + + bool isReady() override { return ready; }; + + void idle() override {} + +private: + bool ready = false; + uint8_t chipSelectPin_, + errorCode_, + spiRate_, + status_, + type_; + + // private functions + inline uint8_t cardAcmd(const uint8_t cmd, const uint32_t arg) { + cardCommand(CMD55, 0); + return cardCommand(cmd, arg); + } + uint8_t cardCommand(const uint8_t cmd, const uint32_t arg); + + bool readData(uint8_t *dst, const uint16_t count); + bool readRegister(const uint8_t cmd, void *buf); + void chipDeselect(); + void chipSelect(); + inline void type(const uint8_t value) { type_ = value; } + bool waitNotBusy(const millis_t timeout_ms); + bool writeData(const uint8_t token, const uint8_t *src); +}; diff --git a/src/sd/Sd2Card_sdio.h b/src/sd/Sd2Card_sdio.h new file mode 100644 index 0000000..cc29f5d --- /dev/null +++ b/src/sd/Sd2Card_sdio.h @@ -0,0 +1,59 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * 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 . + * + */ +#pragma once + +#include "../inc/MarlinConfig.h" + +#include "SdInfo.h" +#include "disk_io_driver.h" + +bool SDIO_Init(); +bool SDIO_ReadBlock(uint32_t block, uint8_t *dst); +bool SDIO_WriteBlock(uint32_t block, const uint8_t *src); +bool SDIO_IsReady(); +uint32_t SDIO_GetCardSize(); + +class DiskIODriver_SDIO : public DiskIODriver { + public: + bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=0) override { return SDIO_Init(); } + + bool readCSD(csd_t *csd) override { return false; } + + bool readStart(const uint32_t block) override { curBlock = block; return true; } + bool readData(uint8_t *dst) override { return readBlock(curBlock++, dst); } + bool readStop() override { curBlock = -1; return true; } + + bool writeStart(const uint32_t block, const uint32_t) override { curBlock = block; return true; } + bool writeData(const uint8_t *src) override { return writeBlock(curBlock++, src); } + bool writeStop() override { curBlock = -1; return true; } + + bool readBlock(uint32_t block, uint8_t *dst) override { return SDIO_ReadBlock(block, dst); } + bool writeBlock(uint32_t block, const uint8_t *src) override { return SDIO_WriteBlock(block, src); } + + uint32_t cardSize() override { return SDIO_GetCardSize(); } + + bool isReady() override { return SDIO_IsReady(); } + + void idle() override {} + private: + uint32_t curBlock; +}; diff --git a/src/sd/SdBaseFile.cpp b/src/sd/SdBaseFile.cpp new file mode 100644 index 0000000..1c1e0c7 --- /dev/null +++ b/src/sd/SdBaseFile.cpp @@ -0,0 +1,2236 @@ +/** + * 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 . + * + */ + +#if __GNUC__ > 8 + #pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif + +/** + * sd/SdBaseFile.cpp + * + * Arduino SdFat Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include "../inc/MarlinConfig.h" + +#if ENABLED(SDSUPPORT) + +#include "SdBaseFile.h" + +#include "../MarlinCore.h" +SdBaseFile *SdBaseFile::cwd_ = 0; // Pointer to Current Working Directory + +// callback function for date/time +void (*SdBaseFile::dateTime_)(uint16_t *date, uint16_t *time) = 0; + +// add a cluster to a file +bool SdBaseFile::addCluster() { + if (ENABLED(SDCARD_READONLY)) return false; + + if (!vol_->allocContiguous(1, &curCluster_)) return false; + + // if first cluster of file link to directory entry + if (firstCluster_ == 0) { + firstCluster_ = curCluster_; + flags_ |= F_FILE_DIR_DIRTY; + } + return true; +} + +// Add a cluster to a directory file and zero the cluster. +// return with first block of cluster in the cache +bool SdBaseFile::addDirCluster() { + if (ENABLED(SDCARD_READONLY)) return false; + + uint32_t block; + // max folder size + if (fileSize_ / sizeof(dir_t) >= 0xFFFF) return false; + + if (!addCluster()) return false; + if (!vol_->cacheFlush()) return false; + + block = vol_->clusterStartBlock(curCluster_); + + // set cache to first block of cluster + vol_->cacheSetBlockNumber(block, true); + + // zero first block of cluster + memset(vol_->cacheBuffer_.data, 0, 512); + + // zero rest of cluster + for (uint8_t i = 1; i < vol_->blocksPerCluster_; i++) { + if (!vol_->writeBlock(block + i, vol_->cacheBuffer_.data)) return false; + } + // Increase directory file size by cluster size + fileSize_ += 512UL << vol_->clusterSizeShift_; + return true; +} + +// cache a file's directory entry +// cache the current "dirBlock_" and return the entry at index "dirIndex_" +// return pointer to cached entry or null for failure +dir_t* SdBaseFile::cacheDirEntry(uint8_t action) { + if (!vol_->cacheRawBlock(dirBlock_, action)) return nullptr; + return vol_->cache()->dir + dirIndex_; +} + +/** + * Close a file and force cached data and directory information + * to be written to the storage device. + * + * \return true for success, false for failure. + * Reasons for failure include no file is open or an I/O error. + */ +bool SdBaseFile::close() { + bool rtn = sync(); + type_ = FAT_FILE_TYPE_CLOSED; + return rtn; +} + +/** + * Check for contiguous file and return its raw block range. + * + * \param[out] bgnBlock the first block address for the file. + * \param[out] endBlock the last block address for the file. + * + * \return true for success, false for failure. + * Reasons for failure include file is not contiguous, file has zero length + * or an I/O error occurred. + */ +bool SdBaseFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock) { + // error if no blocks + if (firstCluster_ == 0) return false; + + for (uint32_t c = firstCluster_; ; c++) { + uint32_t next; + if (!vol_->fatGet(c, &next)) return false; + + // check for contiguous + if (next != (c + 1)) { + // error if not end of chain + if (!vol_->isEOC(next)) return false; + *bgnBlock = vol_->clusterStartBlock(firstCluster_); + *endBlock = vol_->clusterStartBlock(c) + + vol_->blocksPerCluster_ - 1; + return true; + } + } + return false; +} + +/** + * Create and open a new contiguous file of a specified size. + * + * \note This function only supports short DOS 8.3 names. + * See open() for more information. + * + * \param[in] dirFile The directory where the file will be created. + * \param[in] path A path with a valid DOS 8.3 file name. + * \param[in] size The desired file size. + * + * \return true for success, false for failure. + * Reasons for failure include \a path contains + * an invalid DOS 8.3 file name, the FAT volume has not been initialized, + * a file is already open, the file already exists, the root + * directory is full or an I/O error. + */ +bool SdBaseFile::createContiguous(SdBaseFile *dirFile, const char *path, uint32_t size) { + if (ENABLED(SDCARD_READONLY)) return false; + + uint32_t count; + // don't allow zero length file + if (size == 0) return false; + if (!open(dirFile, path, O_CREAT | O_EXCL | O_RDWR)) return false; + + // calculate number of clusters needed + count = ((size - 1) >> (vol_->clusterSizeShift_ + 9)) + 1; + + // allocate clusters + if (!vol_->allocContiguous(count, &firstCluster_)) { + remove(); + return false; + } + fileSize_ = size; + + // insure sync() will update dir entry + flags_ |= F_FILE_DIR_DIRTY; + + return sync(); +} + +/** + * Return a file's directory entry. + * + * \param[out] dir Location for return of the file's directory entry. + * + * \return true for success, false for failure. + */ +bool SdBaseFile::dirEntry(dir_t *dir) { + // make sure fields on SD are correct + if (!sync()) return false; + + // read entry + dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_READ); + if (!p) return false; + + // copy to caller's struct + memcpy(dir, p, sizeof(dir_t)); + return true; +} + +/** + * Format the name field of \a dir into the 13 byte array + * \a name in standard 8.3 short name format. + * + * \param[in] dir The directory structure containing the name. + * \param[out] name A 13 byte char array for the formatted name. + */ +void SdBaseFile::dirName(const dir_t &dir, char *name) { + uint8_t j = 0; + LOOP_L_N(i, 11) { + if (dir.name[i] == ' ')continue; + if (i == 8) name[j++] = '.'; + name[j++] = dir.name[i]; + } + name[j] = 0; +} + +/** + * Test for the existence of a file in a directory + * + * \param[in] name Name of the file to be tested for. + * + * The calling instance must be an open directory file. + * + * dirFile.exists("TOFIND.TXT") searches for "TOFIND.TXT" in the directory + * dirFile. + * + * \return true if the file exists else false. + */ +bool SdBaseFile::exists(const char *name) { + SdBaseFile file; + return file.open(this, name, O_READ); +} + +/** + * Get a string from a file. + * + * fgets() reads bytes from a file into the array pointed to by \a str, until + * \a num - 1 bytes are read, or a delimiter is read and transferred to \a str, + * or end-of-file is encountered. The string is then terminated + * with a null byte. + * + * fgets() deletes CR, '\\r', from the string. This insures only a '\\n' + * terminates the string for Windows text files which use CRLF for newline. + * + * \param[out] str Pointer to the array where the string is stored. + * \param[in] num Maximum number of characters to be read + * (including the final null byte). Usually the length + * of the array \a str is used. + * \param[in] delim Optional set of delimiters. The default is "\n". + * + * \return For success fgets() returns the length of the string in \a str. + * If no data is read, fgets() returns zero for EOF or -1 if an error occurred. + **/ +int16_t SdBaseFile::fgets(char *str, int16_t num, char *delim) { + char ch; + int16_t n = 0; + int16_t r = -1; + while ((n + 1) < num && (r = read(&ch, 1)) == 1) { + // delete CR + if (ch == '\r') continue; + str[n++] = ch; + if (!delim) { + if (ch == '\n') break; + } + else { + if (strchr(delim, ch)) break; + } + } + if (r < 0) { + // read error + return -1; + } + str[n] = '\0'; + return n; +} + +/** + * Get a file's name + * + * \param[out] name An array of 13 characters for the file's name. + * + * \return true for success, false for failure. + */ +bool SdBaseFile::getDosName(char * const name) { + if (!isOpen()) return false; + + if (isRoot()) { + name[0] = '/'; + name[1] = '\0'; + return true; + } + // cache entry + dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_READ); + if (!p) return false; + + // format name + dirName(*p, name); + return true; +} + +void SdBaseFile::getpos(filepos_t *pos) { + pos->position = curPosition_; + pos->cluster = curCluster_; +} + +/** + * List directory contents. + * + * \param[in] pr Print stream for list. + * + * \param[in] flags The inclusive OR of + * + * LS_DATE - %Print file modification date + * + * LS_SIZE - %Print file size. + * + * LS_R - Recursive list of subdirectories. + * + * \param[in] indent Amount of space before file name. Used for recursive + * list to indicate subdirectory level. + */ +void SdBaseFile::ls(uint8_t flags, uint8_t indent) { + rewind(); + int8_t status; + while ((status = lsPrintNext(flags, indent))) { + if (status > 1 && (flags & LS_R)) { + uint16_t index = curPosition() / 32 - 1; + SdBaseFile s; + if (s.open(this, index, O_READ)) s.ls(flags, indent + 2); + seekSet(32 * (index + 1)); + } + } +} + +// saves 32 bytes on stack for ls recursion +// return 0 - EOF, 1 - normal file, or 2 - directory +int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) { + dir_t dir; + uint8_t w = 0; + + while (1) { + if (read(&dir, sizeof(dir)) != sizeof(dir)) return 0; + if (dir.name[0] == DIR_NAME_FREE) return 0; + + // skip deleted entry and entries for . and .. + if (dir.name[0] != DIR_NAME_DELETED && dir.name[0] != '.' + && DIR_IS_FILE_OR_SUBDIR(&dir)) break; + } + // indent for dir level + LOOP_L_N(i, indent) SERIAL_CHAR(' '); + + // print name + LOOP_L_N(i, 11) { + if (dir.name[i] == ' ')continue; + if (i == 8) { + SERIAL_CHAR('.'); + w++; + } + SERIAL_CHAR(dir.name[i]); + w++; + } + if (DIR_IS_SUBDIR(&dir)) { + SERIAL_CHAR('/'); + w++; + } + if (flags & (LS_DATE | LS_SIZE)) { + while (w++ < 14) SERIAL_CHAR(' '); + } + // print modify date/time if requested + if (flags & LS_DATE) { + SERIAL_CHAR(' '); + printFatDate(dir.lastWriteDate); + SERIAL_CHAR(' '); + printFatTime(dir.lastWriteTime); + } + // print size if requested + if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) { + SERIAL_CHAR(' '); + SERIAL_ECHO(dir.fileSize); + } + SERIAL_EOL(); + return DIR_IS_FILE(&dir) ? 1 : 2; +} + +/** + * Calculate a checksum for an 8.3 filename + * + * \param name The 8.3 file name to calculate + * + * \return The checksum byte + */ +uint8_t lfn_checksum(const uint8_t *name) { + uint8_t sum = 0; + for (uint8_t i = 11; i; i--) + sum = ((sum & 1) << 7) + (sum >> 1) + *name++; + return sum; +} + +// Format directory name field from a 8.3 name string +bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char **ptr) { + uint8_t n = 7, // Max index until a dot is found + i = 11; + while (i) name[--i] = ' '; // Set whole FILENAME.EXT to spaces + while (*str && *str != '/') { // For each character, until nul or '/' + uint8_t c = *str++; // Get char and advance + if (c == '.') { // For a dot... + if (n == 10) return false; // Already moved the max index? fail! + n = 10; // Move the max index for full 8.3 name + i = 8; // Move up to the extension place + } + else { + // Fail for illegal characters + PGM_P p = PSTR("|<>^+=?/[];,*\"\\"); + while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; + if (i > n || c < 0x21 || c == 0x7F) return false; // Check size, non-printable characters + name[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name + } + } + *ptr = str; // Set passed pointer to the end + return name[0] != ' '; // Return true if any name was set +} + +/** + * Make a new directory. + * + * \param[in] parent An open SdFat instance for the directory that will contain + * the new directory. + * + * \param[in] path A path with a valid 8.3 DOS name for the new directory. + * + * \param[in] pFlag Create missing parent directories if true. + * + * \return true for success, false for failure. + * Reasons for failure include this file is already open, \a parent is not a + * directory, \a path is invalid or already exists in \a parent. + */ +bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { + if (ENABLED(SDCARD_READONLY)) return false; + + uint8_t dname[11]; + SdBaseFile dir1, dir2; + SdBaseFile *sub = &dir1; + SdBaseFile *start = parent; + + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + uint8_t dlname[LONG_FILENAME_LENGTH]; + #endif + + if (!parent || isOpen()) return false; + + if (*path == '/') { + while (*path == '/') path++; + if (!parent->isRoot()) { + if (!dir2.openRoot(parent->vol_)) return false; + parent = &dir2; + } + } + + for (;;) { + if (!TERN(LONG_FILENAME_WRITE_SUPPORT, parsePath(path, dname, dlname, &path), make83Name(path, dname, &path))) return false; + while (*path == '/') path++; + if (!*path) break; + if (!sub->open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), O_READ)) { + if (!pFlag || !sub->mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname))) + return false; + } + if (parent != start) parent->close(); + parent = sub; + sub = parent != &dir1 ? &dir1 : &dir2; + } + return mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname)); +} + +bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) +) { + if (ENABLED(SDCARD_READONLY)) return false; + + if (!parent->isDir()) return false; + + // create a normal file + if (!open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), O_CREAT | O_EXCL | O_RDWR)) return false; + + // convert file to directory + flags_ = O_READ; + type_ = FAT_FILE_TYPE_SUBDIR; + + // allocate and zero first cluster + if (!addDirCluster()) return false; + + // force entry to SD + if (!sync()) return false; + + // cache entry - should already be in cache due to sync() call + dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!p) return false; + + // change directory entry attribute + p->attributes = DIR_ATT_DIRECTORY; + + // make entry for '.' + dir_t d; + memcpy(&d, p, sizeof(d)); + d.name[0] = '.'; + LOOP_S_L_N(i, 1, 11) d.name[i] = ' '; + + // cache block for '.' and '..' + uint32_t block = vol_->clusterStartBlock(firstCluster_); + if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) return false; + + // copy '.' to block + memcpy(&vol_->cache()->dir[0], &d, sizeof(d)); + + // make entry for '..' + d.name[1] = '.'; + if (parent->isRoot()) { + d.firstClusterLow = 0; + d.firstClusterHigh = 0; + } + else { + d.firstClusterLow = parent->firstCluster_ & 0xFFFF; + d.firstClusterHigh = parent->firstCluster_ >> 16; + } + // copy '..' to block + memcpy(&vol_->cache()->dir[1], &d, sizeof(d)); + + // write first block + return vol_->cacheFlush(); +} + +/** + * Open a file in the current working directory. + * + * \param[in] path A path with a valid 8.3 DOS name for a file to be opened. + * + * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive + * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t). + * + * \return true for success, false for failure. + */ +bool SdBaseFile::open(const char *path, uint8_t oflag) { + return open(cwd_, path, oflag); +} + +/** + * Open a file or directory by name. + * + * \param[in] dirFile An open SdFat instance for the directory containing the + * file to be opened. + * + * \param[in] path A path with a valid 8.3 DOS name for a file to be opened. + * + * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive + * OR of flags from the following list + * + * O_READ - Open for reading. + * + * O_RDONLY - Same as O_READ. + * + * O_WRITE - Open for writing. + * + * O_WRONLY - Same as O_WRITE. + * + * O_RDWR - Open for reading and writing. + * + * O_APPEND - If set, the file offset shall be set to the end of the + * file prior to each write. + * + * O_AT_END - Set the initial position at the end of the file. + * + * O_CREAT - If the file exists, this flag has no effect except as noted + * under O_EXCL below. Otherwise, the file shall be created + * + * O_EXCL - If O_CREAT and O_EXCL are set, open() shall fail if the file exists. + * + * O_SYNC - Call sync() after each write. This flag should not be used with + * write(uint8_t), write_P(PGM_P), writeln_P(PGM_P), or the Arduino Print class. + * These functions do character at a time writes so sync() will be called + * after each byte. + * + * O_TRUNC - If the file exists and is a regular file, and the file is + * successfully opened and is not read only, its length shall be truncated to 0. + * + * WARNING: A given file must not be opened by more than one SdBaseFile object + * of file corruption may occur. + * + * \note Directory files must be opened read only. Write and truncation is + * not allowed for directory files. + * + * \return true for success, false for failure. + * Reasons for failure include this file is already open, \a dirFile is not + * a directory, \a path is invalid, the file does not exist + * or can't be opened in the access mode specified by oflag. + */ +bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) { + uint8_t dname[11]; + SdBaseFile dir1, dir2; + SdBaseFile *parent = dirFile, *sub = &dir1; + + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + uint8_t dlname[LONG_FILENAME_LENGTH]; + #endif + + if (!dirFile || isOpen()) return false; + + if (*path == '/') { // Path starts with '/' + if (!dirFile->isRoot()) { // Is the passed dirFile the root? + if (!dir2.openRoot(dirFile->vol_)) return false; // Get the root in dir2, if possible + parent = &dir2; // Change 'parent' to point at the root dir + } + while (*path == '/') path++; // Skip all leading slashes + } + + for (;;) { + if (!TERN(LONG_FILENAME_WRITE_SUPPORT, parsePath(path, dname, dlname, &path), make83Name(path, dname, &path))) return false; + while (*path == '/') path++; + if (!*path) break; + if (TERN0(LONG_FILENAME_WRITE_SUPPORT, !sub->open(parent, dname, dlname, O_READ))) return false; + if (parent != dirFile) parent->close(); + parent = sub; + sub = parent != &dir1 ? &dir1 : &dir2; + } + return open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), oflag); +} + +// open with filename in dname and long filename in dlname +bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) + , uint8_t oflag +) { + bool emptyFound = false, fileFound = false; + uint8_t index = 0; + dir_t *p; + + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + // LFN - Long File Name support + const bool useLFN = dlname[0] != 0; + bool lfnFileFound = false; + vfat_t *pvFat; + uint8_t emptyCount = 0, + emptyIndex = 0, + reqEntriesNum = useLFN ? getLFNEntriesNum((char*)dlname) + 1 : 1, + lfnNameLength = useLFN ? strlen((char*)dlname) : 0, + lfnName[LONG_FILENAME_LENGTH], + lfnSequenceNumber = 0, + lfnChecksum = 0; + #endif + + // Rewind this dir + vol_ = dirFile->vol_; + dirFile->rewind(); + + // search for file + while (dirFile->curPosition_ < dirFile->fileSize_) { + // Get absolute index position + index = (dirFile->curPosition_ >> 5) IF_DISABLED(LONG_FILENAME_WRITE_SUPPORT, & 0x0F); + + // Get next entry + if (!(p = dirFile->readDirCache())) return false; + + // Check empty status: Is entry empty? + if (p->name[0] == DIR_NAME_FREE || p->name[0] == DIR_NAME_DELETED) { + // Count the contiguous available entries in which (eventually) fit the new dir entry, if it's a write operation + if (!emptyFound) { + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + if (emptyCount == 0) emptyIndex = index; + // Incr empty entries counter + // If found the required empty entries, mark it + if (++emptyCount == reqEntriesNum) { + dirBlock_ = dirFile->vol_->cacheBlockNumber(); + dirIndex_ = index & 0xF; + emptyFound = true; + } + #else + dirBlock_ = dirFile->vol_->cacheBlockNumber(); + dirIndex_ = index; + emptyFound = true; + #endif + } + // Done if no entries follow + if (p->name[0] == DIR_NAME_FREE) break; + } + else { // Entry not empty + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + // Reset empty counter + if (!emptyFound) emptyCount = 0; + // Search for SFN or LFN? + if (!useLFN) { + // Check using SFN: file found? + if (!memcmp(dname, p->name, 11)) { + fileFound = true; + break; + } + } + else { + // Check using LFN: LFN not found? continue search for LFN + if (!lfnFileFound) { + // Is this dir a LFN? + if (isDirLFN(p)) { + // Get VFat dir entry + pvFat = (vfat_t *) p; + // Get checksum from the last entry of the sequence + if (pvFat->sequenceNumber & 0x40) lfnChecksum = pvFat->checksum; + // Get LFN sequence number + lfnSequenceNumber = pvFat->sequenceNumber & 0x1F; + if WITHIN(lfnSequenceNumber, 1, reqEntriesNum) { + // Check checksum for all other entries with the starting checksum fetched before + if (lfnChecksum == pvFat->checksum) { + // Set chunk of LFN from VFAT entry into lfnName + getLFNName(pvFat, (char *)lfnName, lfnSequenceNumber); + // LFN found? + if (!strncasecmp((char*)dlname, (char*)lfnName, lfnNameLength)) lfnFileFound = true; + } + } + } + } + else { // Complete LFN found, check for related SFN + // Check if only the SFN checksum match because the filename may be different due to different truncation methods + if (!isDirLFN(p) && (lfnChecksum == lfn_checksum(p->name))) { + fileFound = true; + break; + } + else lfnFileFound = false; // SFN not valid for the LFN found, reset LFN FileFound + } + } + #else + + if (!memcmp(dname, p->name, 11)) { + fileFound = true; + break; + } + + #endif // LONG_FILENAME_WRITE_SUPPORT + } + } + + if (fileFound) { + // don't open existing file if O_EXCL + if (oflag & O_EXCL) return false; + TERN_(LONG_FILENAME_WRITE_SUPPORT, index &= 0xF); + } + else { + // don't create unless O_CREAT and O_WRITE + if ((oflag & (O_CREAT | O_WRITE)) != (O_CREAT | O_WRITE)) return false; + + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + + // Use bookmark index if found empty entries + if (emptyFound) index = emptyIndex; + + // Make room for needed entries + while (emptyCount < reqEntriesNum) { + p = dirFile->readDirCache(); + if (!p) break; + emptyCount++; + } + while (emptyCount < reqEntriesNum) { + if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) return false; + // add and zero cluster for dirFile - first cluster is in cache for write + if (!dirFile->addDirCluster()) return false; + emptyCount += dirFile->vol_->blocksPerCluster() * 16; + } + + // Move to 1st entry to write + if (!dirFile->seekSet(32 * index)) return false; + + // Dir entries write loop: [LFN] + SFN(1) + LOOP_L_N(dirWriteIdx, reqEntriesNum) { + index = (dirFile->curPosition_ / 32) & 0xF; + p = dirFile->readDirCache(); + // LFN or SFN Entry? + if (dirWriteIdx < reqEntriesNum - 1) { + // Write LFN Entries + pvFat = (vfat_t *) p; + // initialize as empty file + memset(pvFat, 0, sizeof(*pvFat)); + lfnSequenceNumber = (reqEntriesNum - dirWriteIdx - 1) & 0x1F; + pvFat->attributes = DIR_ATT_LONG_NAME; + pvFat->checksum = lfn_checksum(dname); + // Set sequence number and mark as last LFN entry if it's the 1st loop + pvFat->sequenceNumber = lfnSequenceNumber | (dirWriteIdx == 0 ? 0x40 : 0); + // Set LFN name block + setLFNName(pvFat, (char*)dlname, lfnSequenceNumber); + } + else { + // Write SFN Entry + // initialize as empty file + memset(p, 0, sizeof(*p)); + memcpy(p->name, dname, 11); + + // set timestamps + if (dateTime_) { + // call user date/time function + dateTime_(&p->creationDate, &p->creationTime); + } + else { + // use default date/time + p->creationDate = FAT_DEFAULT_DATE; + p->creationTime = FAT_DEFAULT_TIME; + } + p->lastAccessDate = p->creationDate; + p->lastWriteDate = p->creationDate; + p->lastWriteTime = p->creationTime; + } + + // write entry to SD + dirFile->vol_->cacheSetDirty(); + if (!dirFile->vol_->cacheFlush()) return false; + } + + #else // !LONG_FILENAME_WRITE_SUPPORT + + if (emptyFound) { + index = dirIndex_; + p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!p) return false; + } + else { + if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) return false; + + // add and zero cluster for dirFile - first cluster is in cache for write + if (!dirFile->addDirCluster()) return false; + + // use first entry in cluster + p = dirFile->vol_->cache()->dir; + index = 0; + } + + // initialize as empty file + memset(p, 0, sizeof(*p)); + memcpy(p->name, dname, 11); + + // set timestamps + if (dateTime_) { + // call user date/time function + dateTime_(&p->creationDate, &p->creationTime); + } + else { + // use default date/time + p->creationDate = FAT_DEFAULT_DATE; + p->creationTime = FAT_DEFAULT_TIME; + } + + p->lastAccessDate = p->creationDate; + p->lastWriteDate = p->creationDate; + p->lastWriteTime = p->creationTime; + + // write entry to SD + if (!dirFile->vol_->cacheFlush()) return false; + + #endif // !LONG_FILENAME_WRITE_SUPPORT + + } + // open entry in cache + return openCachedEntry(index, oflag); +} + +/** + * Open a file by index. + * + * \param[in] dirFile An open SdFat instance for the directory. + * + * \param[in] index The \a index of the directory entry for the file to be + * opened. The value for \a index is (directory file position)/32. + * + * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive + * OR of flags O_READ, O_WRITE, O_TRUNC, and O_SYNC. + * + * See open() by path for definition of flags. + * \return true for success or false for failure. + */ +bool SdBaseFile::open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag) { + vol_ = dirFile->vol_; + + // error if already open + if (isOpen() || !dirFile) return false; + + // don't open existing file if O_EXCL - user call error + if (oflag & O_EXCL) return false; + + // seek to location of entry + if (!dirFile->seekSet(32 * index)) return false; + + // read entry into cache + dir_t *p = dirFile->readDirCache(); + if (!p) return false; + + // error if empty slot or '.' or '..' + if (p->name[0] == DIR_NAME_FREE || + p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') { + return false; + } + // open cached entry + return openCachedEntry(index & 0xF, oflag); +} + +// open a cached directory entry. Assumes vol_ is initialized +bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) { + dir_t *p; + + #if ENABLED(SDCARD_READONLY) + if (oflag & (O_WRITE | O_CREAT | O_TRUNC)) goto FAIL; + #endif + + // location of entry in cache + p = &vol_->cache()->dir[dirIndex]; + + // write or truncate is an error for a directory or read-only file + if (p->attributes & (DIR_ATT_READ_ONLY | DIR_ATT_DIRECTORY)) { + if (oflag & (O_WRITE | O_TRUNC)) goto FAIL; + } + // remember location of directory entry on SD + dirBlock_ = vol_->cacheBlockNumber(); + dirIndex_ = dirIndex; + + // copy first cluster number for directory fields + firstCluster_ = (uint32_t)p->firstClusterHigh << 16; + firstCluster_ |= p->firstClusterLow; + + // make sure it is a normal file or subdirectory + if (DIR_IS_FILE(p)) { + fileSize_ = p->fileSize; + type_ = FAT_FILE_TYPE_NORMAL; + } + else if (DIR_IS_SUBDIR(p)) { + if (!vol_->chainSize(firstCluster_, &fileSize_)) goto FAIL; + type_ = FAT_FILE_TYPE_SUBDIR; + } + else + goto FAIL; + + // save open flags for read/write + flags_ = oflag & F_OFLAG; + + // set to start of file + curCluster_ = 0; + curPosition_ = 0; + if ((oflag & O_TRUNC) && !truncate(0)) return false; + return oflag & O_AT_END ? seekEnd(0) : true; + + FAIL: + type_ = FAT_FILE_TYPE_CLOSED; + return false; +} + +/** + * Open the next file or subdirectory in a directory. + * + * \param[in] dirFile An open SdFat instance for the directory containing the + * file to be opened. + * + * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive + * OR of flags O_READ, O_WRITE, O_TRUNC, and O_SYNC. + * + * See open() by path for definition of flags. + * \return true for success or false for failure. + */ +bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { + if (!dirFile) return false; + + // error if already open + if (isOpen()) return false; + + vol_ = dirFile->vol_; + + while (1) { + uint8_t index = 0xF & (dirFile->curPosition_ >> 5); + + // read entry into cache + dir_t *p = dirFile->readDirCache(); + if (!p) return false; + + // done if last entry + if (p->name[0] == DIR_NAME_FREE) return false; + + // skip empty slot or '.' or '..' + if (p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') { + continue; + } + // must be file or dir + if (DIR_IS_FILE_OR_SUBDIR(p)) { + return openCachedEntry(index, oflag); + } + } + return false; +} + +#if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + + /** + * Check if dir is a long file name entry (LFN) + * + * \param[in] dir Parent of this directory will be opened. Must not be root. + * \return true if the dir is a long file name entry (LFN) + */ + bool SdBaseFile::isDirLFN(const dir_t* dir) { + if (DIR_IS_LONG_NAME(dir)) { + vfat_t *VFAT = (vfat_t*)dir; + // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0 + if ((VFAT->firstClusterLow == 0) && WITHIN((VFAT->sequenceNumber & 0x1F), 1, MAX_VFAT_ENTRIES)) return true; + } + return false; + } + + /** + * Check if dirname string is a long file name (LFN) + * + * \param[in] dirname The string to check + * \return true if the dirname is a long file name (LFN) + * \return false if the dirname is a short file name 8.3 (SFN) + */ + bool SdBaseFile::isDirNameLFN(const char *dirname) { + uint8_t length = strlen(dirname); + uint8_t idx = length; + bool dotFound = false; + if (idx > 12) return true; // LFN due to filename length > 12 ("filename.ext") + // Check dot(s) position + while (idx) { + if (dirname[--idx] == '.') { + if (!dotFound) { + // Last dot (extension) is allowed only + // in position [1..8] from start or [0..3] from end for SFN else it's a LFN + // A filename starting with "." is a LFN (eg. ".file" ->in SFN-> "file~1 ") + // A filename ending with "." is a SFN (if length <= 9) (eg. "file." ->in SFN-> "file ") + if (idx > 8 || idx == 0 || (length - idx - 1) > 3) return true; // LFN due to dot extension position + dotFound = true; + } + else { + // Found another dot, is a LFN + return true; + } + } + } + // If no dots found, the filename must be of max 8 characters + if ((!dotFound) && length > 8) return true; // LFN due to max filename (without extension) length + return false; + } + + /** + * Parse path and return 8.3 format and LFN filenames (if the parsed path is a LFN) + * The SFN is without dot ("FILENAMEEXT") + * The LFN is complete ("Filename.ext") + */ + bool SdBaseFile::parsePath(const char *path, uint8_t *name, uint8_t *lname, const char **ptrNextPath) { + // Init randomizer for SFN generation + randomSeed(millis()); + // Parse the LFN + uint8_t ilfn = 0; + bool lastDotFound = false; + const char *pLastDot = 0; + const char *lfnpath = path; + uint8_t c; + + while (*lfnpath && *lfnpath != '/') { + if (ilfn == LONG_FILENAME_LENGTH - 1) return false; // Name too long + c = *lfnpath++; // Get char and advance + // Fail for illegal characters + PGM_P p = PSTR("|<>^+=?/[];:,*\"\\"); + while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; // Check reserved characters + if (c < 0x20 || c == 0x7F) return false; // Check non-printable characters + if (c == '.' && (lfnpath - 1) > path) { // Skip dot '.' check in 1st position + // Save last dot pointer (skip if starts with '.') + pLastDot = lfnpath - 1; + lastDotFound = true; + } + lname[ilfn++] = c; // Set LFN character + } + // Terminate LFN + lname[ilfn] = 0; + + // Parse/generate 8.3 SFN. Will take + // until 8 characters for the filename part + // until 3 characters for the extension part (if exists) + // Add 4 more characters if name part < 3 + // Add '~cnt' characters if it's a LFN + const bool isLFN = isDirNameLFN((char*)lname); + + uint8_t n = isLFN ? 5 : 7, // Max index for each component of the file: + // starting with 7 or 5 (if LFN) + // switch to 10 for extension if the last dot is found + i = 11; + while (i) name[--i] = ' '; // Set whole FILENAMEEXT to spaces + while (*path && *path != '/') { + c = *path++; // Get char and advance + // Skip spaces and dots (if it's not the last dot) + if (c == ' ') continue; + if (c == '.' && (!lastDotFound || (lastDotFound && path < pLastDot))) continue; + // Fail for illegal characters + PGM_P p = PSTR("|<>^+=?/[];:,*\"\\"); + while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; // Check reserved characters + if (c < 0x21 || c == 0x7F) return false; // Check non-printable characters + // Is last dot? + if (c == '.') { + // Switch to extension part + n = 10; + i = 8; + } + // If in valid range add the character + else if (i <= n) // Check size for 8.3 format + name[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name + } + // If it's a LFN then the SFN always need: + // - A minimal of 3 characters (otherwise 4 chars are added) + // - The '~cnt' at the end + if (isLFN) { + // Get the 1st free character + uint8_t iFree = 0; + while (1) if (name[iFree++] == ' ' || iFree == 11) break; + iFree--; + // Check minimal length + if (iFree < 3) { + // Append 4 extra characters + name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(0,24) + 'A'; + name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(0,24) + 'A'; + } + // Append '~cnt' characters + if (iFree > 5) iFree = 5; // Force the append in the last 3 characters of name part + name[iFree++] = '~'; + name[iFree++] = random(1,9) + '0'; + name[iFree++] = random(1,9) + '0'; + } + + // Check if LFN is needed + if (!isLFN) lname[0] = 0; // Zero LFN + *ptrNextPath = path; // Set passed pointer to the end + return name[0] != ' '; // Return true if any name was set + } + + /** + * Get the LFN filename block from a dir. Get the block in lname at startOffset + */ + void SdBaseFile::getLFNName(vfat_t *pFatDir, char *lname, uint8_t sequenceNumber) { + uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH; + LOOP_L_N(i, FILENAME_LENGTH) { + const uint16_t utf16_ch = (i >= 11) ? pFatDir->name3[i - 11] : (i >= 5) ? pFatDir->name2[i - 5] : pFatDir->name1[i]; + #if ENABLED(UTF_FILENAME_SUPPORT) + // We can't reconvert to UTF-8 here as UTF-8 is variable-size encoding, but joining LFN blocks + // needs static bytes addressing. So here just store full UTF-16LE words to re-convert later. + uint16_t idx = (startOffset + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding + lname[idx] = utf16_ch & 0xFF; + lname[idx + 1] = (utf16_ch >> 8) & 0xFF; + #else + // Replace all multibyte characters to '_' + lname[startOffset + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); + #endif + } + } + + /** + * Set the LFN filename block lname to a dir. Put the block based on sequence number + */ + void SdBaseFile::setLFNName(vfat_t *pFatDir, char *lname, uint8_t sequenceNumber) { + uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH; + uint8_t nameLength = strlen(lname); + LOOP_L_N(i, FILENAME_LENGTH) { + uint16_t ch = 0; + if ((startOffset + i) < nameLength) + ch = lname[startOffset + i]; + else if ((startOffset + i) > nameLength) + ch = 0xFFFF; + // Set char + if (i < 5) + pFatDir->name1[i] = ch; + else if (i < 11) + pFatDir->name2[i - 5] = ch; + else + pFatDir->name3[i - 11] = ch; + } + } + +#endif // LONG_FILENAME_WRITE_SUPPORT + +#if 0 +/** + * Open a directory's parent directory. + * + * \param[in] dir Parent of this directory will be opened. Must not be root. + * + * \return true for success, false for failure. + */ +bool SdBaseFile::openParent(SdBaseFile *dir) { + dir_t entry; + SdBaseFile file; + uint32_t c; + uint32_t cluster; + uint32_t lbn; + // error if already open or dir is root or dir is not a directory + if (isOpen() || !dir || dir->isRoot() || !dir->isDir()) return false; + vol_ = dir->vol_; + // position to '..' + if (!dir->seekSet(32)) return false; + // read '..' entry + if (dir->read(&entry, sizeof(entry)) != 32) return false; + // verify it is '..' + if (entry.name[0] != '.' || entry.name[1] != '.') return false; + // start cluster for '..' + cluster = entry.firstClusterLow; + cluster |= (uint32_t)entry.firstClusterHigh << 16; + if (cluster == 0) return openRoot(vol_); + // start block for '..' + lbn = vol_->clusterStartBlock(cluster); + // first block of parent dir + if (!vol_->cacheRawBlock(lbn, SdVolume::CACHE_FOR_READ)) return false; + + dir_t *p = &vol_->cacheBuffer_.dir[1]; + // verify name for '../..' + if (p->name[0] != '.' || p->name[1] != '.') return false; + // '..' is pointer to first cluster of parent. open '../..' to find parent + if (p->firstClusterHigh == 0 && p->firstClusterLow == 0) { + if (!file.openRoot(dir->volume())) return false; + } + else if (!file.openCachedEntry(1, O_READ)) + return false; + + // search for parent in '../..' + do { + if (file.readDir(&entry, nullptr) != 32) return false; + c = entry.firstClusterLow; + c |= (uint32_t)entry.firstClusterHigh << 16; + } while (c != cluster); + + // open parent + return open(&file, file.curPosition() / 32 - 1, O_READ); +} +#endif + +/** + * Open a volume's root directory. + * + * \param[in] vol The FAT volume containing the root directory to be opened. + * + * \return true for success, false for failure. + * Reasons for failure include the file is already open, the FAT volume has + * not been initialized or it a FAT12 volume. + */ +bool SdBaseFile::openRoot(SdVolume *vol) { + // error if file is already open + if (isOpen()) return false; + + if (vol->fatType() == 16 || (FAT12_SUPPORT && vol->fatType() == 12)) { + type_ = FAT_FILE_TYPE_ROOT_FIXED; + firstCluster_ = 0; + fileSize_ = 32 * vol->rootDirEntryCount(); + } + else if (vol->fatType() == 32) { + type_ = FAT_FILE_TYPE_ROOT32; + firstCluster_ = vol->rootDirStart(); + if (!vol->chainSize(firstCluster_, &fileSize_)) return false; + } + else // volume is not initialized, invalid, or FAT12 without support + return false; + + vol_ = vol; + // read only + flags_ = O_READ; + + // set to start of file + curCluster_ = curPosition_ = 0; + + // root has no directory entry + dirBlock_ = dirIndex_ = 0; + return true; +} + +/** + * Return the next available byte without consuming it. + * + * \return The byte if no error and not at eof else -1; + */ +int SdBaseFile::peek() { + filepos_t pos; + getpos(&pos); + int c = read(); + if (c >= 0) setpos(&pos); + return c; +} + +// print uint8_t with width 2 +static void print2u(const uint8_t v) { + if (v < 10) SERIAL_CHAR('0'); + SERIAL_ECHO(v); +} + +/** + * %Print a directory date field to Serial. + * + * Format is yyyy-mm-dd. + * + * \param[in] fatDate The date field from a directory entry. + */ + + +/** + * %Print a directory date field. + * + * Format is yyyy-mm-dd. + * + * \param[in] pr Print stream for output. + * \param[in] fatDate The date field from a directory entry. + */ +void SdBaseFile::printFatDate(uint16_t fatDate) { + SERIAL_ECHO(FAT_YEAR(fatDate)); + SERIAL_CHAR('-'); + print2u(FAT_MONTH(fatDate)); + SERIAL_CHAR('-'); + print2u(FAT_DAY(fatDate)); +} + + +/** + * %Print a directory time field. + * + * Format is hh:mm:ss. + * + * \param[in] pr Print stream for output. + * \param[in] fatTime The time field from a directory entry. + */ +void SdBaseFile::printFatTime(uint16_t fatTime) { + print2u(FAT_HOUR(fatTime)); + SERIAL_CHAR(':'); + print2u(FAT_MINUTE(fatTime)); + SERIAL_CHAR(':'); + print2u(FAT_SECOND(fatTime)); +} + +/** + * Print a file's name to Serial + * + * \return true for success, false for failure. + */ +bool SdBaseFile::printName() { + char name[FILENAME_LENGTH]; + if (!getDosName(name)) return false; + SERIAL_ECHO(name); + return true; +} + +/** + * Read the next byte from a file. + * + * \return For success read returns the next byte in the file as an int. + * If an error occurs or end of file is reached -1 is returned. + */ +int16_t SdBaseFile::read() { + uint8_t b; + return read(&b, 1) == 1 ? b : -1; +} + +/** + * Read data from a file starting at the current position. + * + * \param[out] buf Pointer to the location that will receive the data. + * + * \param[in] nbyte Maximum number of bytes to read. + * + * \return For success read() returns the number of bytes read. + * A value less than \a nbyte, including zero, will be returned + * if end of file is reached. + * If an error occurs, read() returns -1. Possible errors include + * read() called before a file has been opened, corrupt file system + * or an I/O error occurred. + */ +int16_t SdBaseFile::read(void *buf, uint16_t nbyte) { + uint8_t *dst = reinterpret_cast(buf); + uint16_t offset, toRead; + uint32_t block; // raw device block number + + // error if not open or write only + if (!isOpen() || !(flags_ & O_READ)) return -1; + + // max bytes left in file + NOMORE(nbyte, fileSize_ - curPosition_); + + // amount left to read + toRead = nbyte; + while (toRead > 0) { + offset = curPosition_ & 0x1FF; // offset in block + if (type_ == FAT_FILE_TYPE_ROOT_FIXED) { + block = vol_->rootDirStart() + (curPosition_ >> 9); + } + else { + uint8_t blockOfCluster = vol_->blockOfCluster(curPosition_); + if (offset == 0 && blockOfCluster == 0) { + // start of new cluster + if (curPosition_ == 0) + curCluster_ = firstCluster_; // use first cluster in file + else if (!vol_->fatGet(curCluster_, &curCluster_)) // get next cluster from FAT + return -1; + } + block = vol_->clusterStartBlock(curCluster_) + blockOfCluster; + } + uint16_t n = toRead; + + // amount to be read from current block + NOMORE(n, 512 - offset); + + // no buffering needed if n == 512 + if (n == 512 && block != vol_->cacheBlockNumber()) { + if (!vol_->readBlock(block, dst)) return -1; + } + else { + // read block to cache and copy data to caller + if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_READ)) return -1; + uint8_t *src = vol_->cache()->data + offset; + memcpy(dst, src, n); + } + dst += n; + curPosition_ += n; + toRead -= n; + } + return nbyte; +} + +/** + * Read the next entry in a directory. + * + * \param[out] dir The dir_t struct that will receive the data. + * + * \return For success readDir() returns the number of bytes read. + * A value of zero will be returned if end of file is reached. + * If an error occurs, readDir() returns -1. Possible errors include + * readDir() called before a directory has been opened, this is not + * a directory file or an I/O error occurred. + */ +int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) { + int16_t n; + // if not a directory file or miss-positioned return an error + if (!isDir() || (0x1F & curPosition_)) return -1; + + #define INVALIDATE_LONGNAME() (longFilename[0] = longFilename[1] = '\0') + + // If we have a longFilename buffer, mark it as invalid. + // If a long filename is found it will be filled automatically. + if (longFilename) INVALIDATE_LONGNAME(); + + uint8_t checksum_error = 0xFF, checksum = 0; + + while (1) { + + n = read(dir, sizeof(dir_t)); + if (n != sizeof(dir_t)) return n ? -1 : 0; + + // Last entry if DIR_NAME_FREE + if (dir->name[0] == DIR_NAME_FREE) return 0; + + // Skip deleted entry and entry for . and .. + if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.') { + if (longFilename) INVALIDATE_LONGNAME(); // Invalidate erased file long name, if any + continue; + } + + if (longFilename) { + // Fill the long filename if we have a long filename entry. + // Long filename entries are stored before the short filename. + if (DIR_IS_LONG_NAME(dir)) { + vfat_t *VFAT = (vfat_t*)dir; + // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0 + if (VFAT->firstClusterLow == 0) { + const uint8_t seq = VFAT->sequenceNumber & 0x1F; + if (WITHIN(seq, 1, MAX_VFAT_ENTRIES)) { + if (seq == 1) { + checksum = VFAT->checksum; + checksum_error = 0; + } + else if (checksum != VFAT->checksum) // orphan detected + checksum_error = 1; + + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + + getLFNName(VFAT, longFilename, seq); // Get chunk of LFN from VFAT entry + + #else // !LONG_FILENAME_WRITE_SUPPORT + + n = (seq - 1) * (FILENAME_LENGTH); + + LOOP_L_N(i, FILENAME_LENGTH) { + const uint16_t utf16_ch = (i >= 11) ? VFAT->name3[i - 11] : (i >= 5) ? VFAT->name2[i - 5] : VFAT->name1[i]; + #if ENABLED(UTF_FILENAME_SUPPORT) + // We can't reconvert to UTF-8 here as UTF-8 is variable-size encoding, but joining LFN blocks + // needs static bytes addressing. So here just store full UTF-16LE words to re-convert later. + uint16_t idx = (n + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding + longFilename[idx] = utf16_ch & 0xFF; + longFilename[idx + 1] = (utf16_ch >> 8) & 0xFF; + #else + // Replace all multibyte characters to '_' + longFilename[n + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); + #endif + } + + #endif // !LONG_FILENAME_WRITE_SUPPORT + + // If this VFAT entry is the last one, add a NUL terminator at the end of the string + if (VFAT->sequenceNumber & 0x40) + longFilename[LONG_FILENAME_CHARSIZE * TERN(LONG_FILENAME_WRITE_SUPPORT, seq * FILENAME_LENGTH, (n + FILENAME_LENGTH))] = '\0'; + } + } + } + else { + if (!checksum_error && lfn_checksum(dir->name) != checksum) checksum_error = 1; // orphan detected + if (checksum_error) INVALIDATE_LONGNAME(); + } + } + + // Post-process normal file or subdirectory longname, if any + if (DIR_IS_FILE_OR_SUBDIR(dir)) { + #if ENABLED(UTF_FILENAME_SUPPORT) + #if LONG_FILENAME_CHARSIZE > 2 + // Add warning for developers for currently not supported 3-byte cases (Conversion series of 2-byte + // codepoints to 3-byte in-place will break the rest of filename) + #error "Currently filename re-encoding is done in-place. It may break the remaining chars to use 3-byte codepoints." + #endif + + // Is there a long filename to decode? + if (longFilename) { + // Reset n to the start of the long name + n = 0; + for (uint16_t idx = 0; idx < (LONG_FILENAME_LENGTH) / 2; idx += 2) { // idx is fixed since FAT LFN always contains UTF-16LE encoding + const uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1] << 8); + if (0xD800 == (utf16_ch & 0xF800)) // Surrogate pair - encode as '_' + longFilename[n++] = '_'; + else if (0 == (utf16_ch & 0xFF80)) // Encode as 1-byte UTF-8 char + longFilename[n++] = utf16_ch & 0x007F; + else if (0 == (utf16_ch & 0xF800)) { // Encode as 2-byte UTF-8 char + longFilename[n++] = 0xC0 | ((utf16_ch >> 6) & 0x1F); + longFilename[n++] = 0x80 | ( utf16_ch & 0x3F); + } + else { + #if LONG_FILENAME_CHARSIZE > 2 // Encode as 3-byte UTF-8 char + longFilename[n++] = 0xE0 | ((utf16_ch >> 12) & 0x0F); + longFilename[n++] = 0xC0 | ((utf16_ch >> 6) & 0x3F); + longFilename[n++] = 0xC0 | ( utf16_ch & 0x3F); + #else // Encode as '_' + longFilename[n++] = '_'; + #endif + } + if (0 == utf16_ch) break; // End of filename + } // idx + } // longFilename + #endif + return n; + } // DIR_IS_FILE_OR_SUBDIR + } +} + +// Read next directory entry into the cache +// Assumes file is correctly positioned +dir_t* SdBaseFile::readDirCache() { + uint8_t i; + // error if not directory + if (!isDir()) return 0; + + // index of entry in cache + i = (curPosition_ >> 5) & 0xF; + + // use read to locate and cache block + if (read() < 0) return 0; + + // advance to next entry + curPosition_ += 31; + + // return pointer to entry + return vol_->cache()->dir + i; +} + +/** + * Remove a file. + * + * The directory entry and all data for the file are deleted. + * + * \note This function should not be used to delete the 8.3 version of a + * file that has a long name. For example if a file has the long name + * "New Text Document.txt" you should not delete the 8.3 name "NEWTEX~1.TXT". + * + * \return true for success, false for failure. + * Reasons for failure include the file read-only, is a directory, + * or an I/O error occurred. + */ +bool SdBaseFile::remove() { + if (ENABLED(SDCARD_READONLY)) return false; + + // free any clusters - will fail if read-only or directory + if (!truncate(0)) return false; + + // cache directory entry + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!d) return false; + + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + // get SFN checksum before name rewrite (needed for LFN deletion) + const uint8_t sfn_checksum = lfn_checksum(d->name); + #endif + + // mark entry deleted + d->name[0] = DIR_NAME_DELETED; + + // set this file closed + type_ = FAT_FILE_TYPE_CLOSED; + + // write entry to SD + #if DISABLED(LONG_FILENAME_WRITE_SUPPORT) + + return vol_->cacheFlush(); + + #else // LONG_FILENAME_WRITE_SUPPORT + + flags_ = 0; + + if (!vol_->cacheFlush()) return false; + + // Check if the entry has a LFN + bool lastEntry = false; + // loop back to search for any LFN entries related to this file + LOOP_S_LE_N(sequenceNumber, 1, MAX_VFAT_ENTRIES) { + dirIndex_ = (dirIndex_ - 1) & 0xF; + if (dirBlock_ == 0) break; + if (dirIndex_ == 0xF) dirBlock_--; + dir_t *dir = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!dir) return false; + + // check for valid LFN: not deleted, not top dirs (".", ".."), must be a LFN + if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.' || !isDirLFN(dir)) break; + // check coherent LFN: checksum and sequenceNumber must match + vfat_t* dirlfn = (vfat_t*) dir; + if (dirlfn->checksum != sfn_checksum || (dirlfn->sequenceNumber & 0x1F) != sequenceNumber) break; // orphan entry + // is last entry of LFN ? + lastEntry = (dirlfn->sequenceNumber & 0x40); + // mark as deleted + dirlfn->sequenceNumber = DIR_NAME_DELETED; + // Flush to SD + if (!vol_->cacheFlush()) return false; + // exit on last entry of LFN deleted + if (lastEntry) break; + } + + // Restore current index + //if (!seekSet(32UL * dirIndex_)) return false; + //dirIndex_ += prevDirIndex; + + return true; + + #endif // LONG_FILENAME_WRITE_SUPPORT +} + +/** + * Remove a file. + * + * The directory entry and all data for the file are deleted. + * + * \param[in] dirFile The directory that contains the file. + * \param[in] path Path for the file to be removed. + * + * \note This function should not be used to delete the 8.3 version of a + * file that has a long name. For example if a file has the long name + * "New Text Document.txt" you should not delete the 8.3 name "NEWTEX~1.TXT". + * + * \return true for success, false for failure. + * Reasons for failure include the file is a directory, is read only, + * \a dirFile is not a directory, \a path is not found + * or an I/O error occurred. + */ +bool SdBaseFile::remove(SdBaseFile *dirFile, const char *path) { + if (ENABLED(SDCARD_READONLY)) return false; + + SdBaseFile file; + return file.open(dirFile, path, O_WRITE) ? file.remove() : false; +} + +/** + * Rename a file or subdirectory. + * + * \param[in] dirFile Directory for the new path. + * \param[in] newPath New path name for the file/directory. + * + * \return true for success, false for failure. + * Reasons for failure include \a dirFile is not open or is not a directory + * file, newPath is invalid or already exists, or an I/O error occurs. + */ +bool SdBaseFile::rename(SdBaseFile *dirFile, const char *newPath) { + if (ENABLED(SDCARD_READONLY)) return false; + + uint32_t dirCluster = 0; + + // must be an open file or subdirectory + if (!(isFile() || isSubDir())) return false; + + // can't move file + if (vol_ != dirFile->vol_) return false; + + // sync() and cache directory entry + sync(); + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!d) return false; + + // save directory entry + dir_t entry; + memcpy(&entry, d, sizeof(entry)); + + // mark entry deleted + d->name[0] = DIR_NAME_DELETED; + + // make directory entry for new path + SdBaseFile file; + if (isFile()) { + if (!file.open(dirFile, newPath, O_CREAT | O_EXCL | O_WRITE)) { + goto restore; + } + } + else { + // don't create missing path prefix components + if (!file.mkdir(dirFile, newPath, false)) { + goto restore; + } + // save cluster containing new dot dot + dirCluster = file.firstCluster_; + } + // change to new directory entry + dirBlock_ = file.dirBlock_; + dirIndex_ = file.dirIndex_; + + // mark closed to avoid possible destructor close call + file.type_ = FAT_FILE_TYPE_CLOSED; + + // cache new directory entry + d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!d) return false; + + // copy all but name field to new directory entry + memcpy(&d->attributes, &entry.attributes, sizeof(entry) - sizeof(d->name)); + + // update dot dot if directory + if (dirCluster) { + // get new dot dot + uint32_t block = vol_->clusterStartBlock(dirCluster); + if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_READ)) return false; + memcpy(&entry, &vol_->cache()->dir[1], sizeof(entry)); + + // free unused cluster + if (!vol_->freeChain(dirCluster)) return false; + + // store new dot dot + block = vol_->clusterStartBlock(firstCluster_); + if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) return false; + memcpy(&vol_->cache()->dir[1], &entry, sizeof(entry)); + } + return vol_->cacheFlush(); + +restore: + if ((d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE))) { + // restore entry + d->name[0] = entry.name[0]; + vol_->cacheFlush(); + } + return false; +} + +/** + * Remove a directory file. + * + * The directory file will be removed only if it is empty and is not the + * root directory. rmdir() follows DOS and Windows and ignores the + * read-only attribute for the directory. + * + * \note This function should not be used to delete the 8.3 version of a + * directory that has a long name. For example if a directory has the + * long name "New folder" you should not delete the 8.3 name "NEWFOL~1". + * + * \return true for success, false for failure. + * Reasons for failure include the file is not a directory, is the root + * directory, is not empty, or an I/O error occurred. + */ +bool SdBaseFile::rmdir() { + if (ENABLED(SDCARD_READONLY)) return false; + + // must be open subdirectory + if (!isSubDir()) return false; + + rewind(); + + // make sure directory is empty + while (curPosition_ < fileSize_) { + dir_t *p = readDirCache(); + if (!p) return false; + // done if past last used entry + if (p->name[0] == DIR_NAME_FREE) break; + // skip empty slot, '.' or '..' + if (p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') continue; + // error not empty + if (DIR_IS_FILE_OR_SUBDIR(p)) return false; + } + // convert empty directory to normal file for remove + type_ = FAT_FILE_TYPE_NORMAL; + flags_ |= O_WRITE; + return remove(); +} + +/** + * Recursively delete a directory and all contained files. + * + * This is like the Unix/Linux 'rm -rf *' if called with the root directory + * hence the name. + * + * Warning - This will remove all contents of the directory including + * subdirectories. The directory will then be removed if it is not root. + * The read-only attribute for files will be ignored. + * + * \note This function should not be used to delete the 8.3 version of + * a directory that has a long name. See remove() and rmdir(). + * + * \return true for success, false for failure. + */ +bool SdBaseFile::rmRfStar() { + if (ENABLED(SDCARD_READONLY)) return false; + + uint32_t index; + SdBaseFile f; + rewind(); + while (curPosition_ < fileSize_) { + // remember position + index = curPosition_ / 32; + + dir_t *p = readDirCache(); + if (!p) return false; + + // done if past last entry + if (p->name[0] == DIR_NAME_FREE) break; + + // skip empty slot or '.' or '..' + if (p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') continue; + + // skip if part of long file name or volume label in root + if (!DIR_IS_FILE_OR_SUBDIR(p)) continue; + + if (!f.open(this, index, O_READ)) return false; + if (f.isSubDir()) { + // recursively delete + if (!f.rmRfStar()) return false; + } + else { + // ignore read-only + f.flags_ |= O_WRITE; + if (!f.remove()) return false; + } + // position to next entry if required + if (curPosition_ != (32 * (index + 1))) { + if (!seekSet(32 * (index + 1))) return false; + } + } + // don't try to delete root + if (!isRoot()) { + if (!rmdir()) return false; + } + return true; +} + +/** + * Create a file object and open it in the current working directory. + * + * \param[in] path A path with a valid 8.3 DOS name for a file to be opened. + * + * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive + * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t). + */ +SdBaseFile::SdBaseFile(const char *path, uint8_t oflag) { + type_ = FAT_FILE_TYPE_CLOSED; + writeError = false; + open(path, oflag); +} + +/** + * Sets a file's position. + * + * \param[in] pos The new position in bytes from the beginning of the file. + * + * \return true for success, false for failure. + */ +bool SdBaseFile::seekSet(const uint32_t pos) { + uint32_t nCur, nNew; + // error if file not open or seek past end of file + if (!isOpen() || pos > fileSize_) return false; + + if (type_ == FAT_FILE_TYPE_ROOT_FIXED) { + curPosition_ = pos; + return true; + } + if (pos == 0) { + curCluster_ = curPosition_ = 0; // set position to start of file + return true; + } + + // calculate cluster index for cur and new position + nCur = (curPosition_ - 1) >> (vol_->clusterSizeShift_ + 9); + nNew = (pos - 1) >> (vol_->clusterSizeShift_ + 9); + + if (nNew < nCur || curPosition_ == 0) + curCluster_ = firstCluster_; // must follow chain from first cluster + else + nNew -= nCur; // advance from curPosition + + while (nNew--) + if (!vol_->fatGet(curCluster_, &curCluster_)) return false; + + curPosition_ = pos; + return true; +} + +void SdBaseFile::setpos(filepos_t *pos) { + curPosition_ = pos->position; + curCluster_ = pos->cluster; +} + +/** + * The sync() call causes all modified data and directory fields + * to be written to the storage device. + * + * \return true for success, false for failure. + * Reasons for failure include a call to sync() before a file has been + * opened or an I/O error. + */ +bool SdBaseFile::sync() { + // only allow open files and directories + if (ENABLED(SDCARD_READONLY) || !isOpen()) goto FAIL; + + if (flags_ & F_FILE_DIR_DIRTY) { + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + // check for deleted by another open file object + if (!d || d->name[0] == DIR_NAME_DELETED) goto FAIL; + + // do not set filesize for dir files + if (!isDir()) d->fileSize = fileSize_; + + // update first cluster fields + d->firstClusterLow = firstCluster_ & 0xFFFF; + d->firstClusterHigh = firstCluster_ >> 16; + + // set modify time if user supplied a callback date/time function + if (dateTime_) { + dateTime_(&d->lastWriteDate, &d->lastWriteTime); + d->lastAccessDate = d->lastWriteDate; + } + // clear directory dirty + flags_ &= ~F_FILE_DIR_DIRTY; + } + return vol_->cacheFlush(); + + FAIL: + writeError = true; + return false; +} + +/** + * Copy a file's timestamps + * + * \param[in] file File to copy timestamps from. + * + * \note + * Modify and access timestamps may be overwritten if a date time callback + * function has been set by dateTimeCallback(). + * + * \return true for success, false for failure. + */ +bool SdBaseFile::timestamp(SdBaseFile *file) { + dir_t dir; + + // get timestamps + if (!file->dirEntry(&dir)) return false; + + // update directory fields + if (!sync()) return false; + + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!d) return false; + + // copy timestamps + d->lastAccessDate = dir.lastAccessDate; + d->creationDate = dir.creationDate; + d->creationTime = dir.creationTime; + d->creationTimeTenths = dir.creationTimeTenths; + d->lastWriteDate = dir.lastWriteDate; + d->lastWriteTime = dir.lastWriteTime; + + // write back entry + return vol_->cacheFlush(); +} + +/** + * Set a file's timestamps in its directory entry. + * + * \param[in] flags Values for \a flags are constructed by a bitwise-inclusive + * OR of flags from the following list + * + * T_ACCESS - Set the file's last access date. + * + * T_CREATE - Set the file's creation date and time. + * + * T_WRITE - Set the file's last write/modification date and time. + * + * \param[in] year Valid range 1980 - 2107 inclusive. + * + * \param[in] month Valid range 1 - 12 inclusive. + * + * \param[in] day Valid range 1 - 31 inclusive. + * + * \param[in] hour Valid range 0 - 23 inclusive. + * + * \param[in] minute Valid range 0 - 59 inclusive. + * + * \param[in] second Valid range 0 - 59 inclusive + * + * \note It is possible to set an invalid date since there is no check for + * the number of days in a month. + * + * \note + * Modify and access timestamps may be overwritten if a date time callback + * function has been set by dateTimeCallback(). + * + * \return true for success, false for failure. + */ +bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month, + uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) { + if (ENABLED(SDCARD_READONLY)) return false; + + uint16_t dirDate, dirTime; + + if (!isOpen() + || year < 1980 + || year > 2107 + || month < 1 + || month > 12 + || day < 1 + || day > 31 + || hour > 23 + || minute > 59 + || second > 59) { + return false; + } + // update directory entry + if (!sync()) return false; + + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!d) return false; + + dirDate = FAT_DATE(year, month, day); + dirTime = FAT_TIME(hour, minute, second); + if (flags & T_ACCESS) { + d->lastAccessDate = dirDate; + } + if (flags & T_CREATE) { + d->creationDate = dirDate; + d->creationTime = dirTime; + // seems to be units of 1/100 second not 1/10 as Microsoft states + d->creationTimeTenths = second & 1 ? 100 : 0; + } + if (flags & T_WRITE) { + d->lastWriteDate = dirDate; + d->lastWriteTime = dirTime; + } + return vol_->cacheFlush(); +} + +/** + * Truncate a file to a specified length. The current file position + * will be maintained if it is less than or equal to \a length otherwise + * it will be set to end of file. + * + * \param[in] length The desired length for the file. + * + * \return true for success, false for failure. + * Reasons for failure include file is read only, file is a directory, + * \a length is greater than the current file size or an I/O error occurs. + */ +bool SdBaseFile::truncate(uint32_t length) { + if (ENABLED(SDCARD_READONLY)) return false; + + uint32_t newPos; + // error if not a normal file or read-only + if (!isFile() || !(flags_ & O_WRITE)) return false; + + // error if length is greater than current size + if (length > fileSize_) return false; + + // fileSize and length are zero - nothing to do + if (fileSize_ == 0) return true; + + // remember position for seek after truncation + newPos = curPosition_ > length ? length : curPosition_; + + // position to last cluster in truncated file + if (!seekSet(length)) return false; + + if (length == 0) { + // free all clusters + if (!vol_->freeChain(firstCluster_)) return false; + firstCluster_ = 0; + } + else { + uint32_t toFree; + if (!vol_->fatGet(curCluster_, &toFree)) return false; + + if (!vol_->isEOC(toFree)) { + // free extra clusters + if (!vol_->freeChain(toFree)) return false; + + // current cluster is end of chain + if (!vol_->fatPutEOC(curCluster_)) return false; + } + } + fileSize_ = length; + + // need to update directory entry + flags_ |= F_FILE_DIR_DIRTY; + + if (!sync()) return false; + + // set file to correct position + return seekSet(newPos); +} + +/** + * Write data to an open file. + * + * \note Data is moved to the cache but may not be written to the + * storage device until sync() is called. + * + * \param[in] buf Pointer to the location of the data to be written. + * + * \param[in] nbyte Number of bytes to write. + * + * \return For success write() returns the number of bytes written, always + * \a nbyte. If an error occurs, write() returns -1. Possible errors + * include write() is called before a file has been opened, write is called + * for a read-only file, device is full, a corrupt file system or an I/O error. + */ +int16_t SdBaseFile::write(const void *buf, uint16_t nbyte) { + #if ENABLED(SDCARD_READONLY) + writeError = true; return -1; + #endif + + // convert void* to uint8_t* - must be before goto statements + const uint8_t *src = reinterpret_cast(buf); + + // number of bytes left to write - must be before goto statements + uint16_t nToWrite = nbyte; + + // error if not a normal file or is read-only + if (!isFile() || !(flags_ & O_WRITE)) goto FAIL; + + // seek to end of file if append flag + if ((flags_ & O_APPEND) && curPosition_ != fileSize_) { + if (!seekEnd()) goto FAIL; + } + + while (nToWrite > 0) { + uint8_t blockOfCluster = vol_->blockOfCluster(curPosition_); + uint16_t blockOffset = curPosition_ & 0x1FF; + if (blockOfCluster == 0 && blockOffset == 0) { + // start of new cluster + if (curCluster_ == 0) { + if (firstCluster_ == 0) { + // allocate first cluster of file + if (!addCluster()) goto FAIL; + } + else { + curCluster_ = firstCluster_; + } + } + else { + uint32_t next; + if (!vol_->fatGet(curCluster_, &next)) goto FAIL; + if (vol_->isEOC(next)) { + // add cluster if at end of chain + if (!addCluster()) goto FAIL; + } + else { + curCluster_ = next; + } + } + } + // max space in block + uint16_t n = 512 - blockOffset; + + // lesser of space and amount to write + NOMORE(n, nToWrite); + + // block for data write + uint32_t block = vol_->clusterStartBlock(curCluster_) + blockOfCluster; + if (n == 512) { + // full block - don't need to use cache + if (vol_->cacheBlockNumber() == block) { + // invalidate cache if block is in cache + vol_->cacheSetBlockNumber(0xFFFFFFFF, false); + } + if (!vol_->writeBlock(block, src)) goto FAIL; + } + else { + if (blockOffset == 0 && curPosition_ >= fileSize_) { + // start of new block don't need to read into cache + if (!vol_->cacheFlush()) goto FAIL; + // set cache dirty and SD address of block + vol_->cacheSetBlockNumber(block, true); + } + else { + // rewrite part of block + if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) goto FAIL; + } + uint8_t *dst = vol_->cache()->data + blockOffset; + memcpy(dst, src, n); + } + curPosition_ += n; + src += n; + nToWrite -= n; + } + if (curPosition_ > fileSize_) { + // update fileSize and insure sync will update dir entry + fileSize_ = curPosition_; + flags_ |= F_FILE_DIR_DIRTY; + } + else if (dateTime_ && nbyte) { + // insure sync will update modified date and time + flags_ |= F_FILE_DIR_DIRTY; + } + + if (flags_ & O_SYNC) { + if (!sync()) goto FAIL; + } + return nbyte; + + FAIL: + // return for write error + writeError = true; + return -1; +} + +#endif // SDSUPPORT diff --git a/src/sd/SdBaseFile.h b/src/sd/SdBaseFile.h new file mode 100644 index 0000000..bda44c6 --- /dev/null +++ b/src/sd/SdBaseFile.h @@ -0,0 +1,402 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * sd/SdBaseFile.h + * + * Arduino SdFat Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include "SdFatConfig.h" +#include "SdVolume.h" + +#include + +/** + * \struct filepos_t + * \brief internal type for istream + * do not use in user apps + */ +struct filepos_t { + uint32_t position; // stream byte position + uint32_t cluster; // cluster of position + filepos_t() : position(0), cluster(0) {} +}; + +// use the gnu style oflag in open() +uint8_t const O_READ = 0x01, // open() oflag for reading + O_RDONLY = O_READ, // open() oflag - same as O_IN + O_WRITE = 0x02, // open() oflag for write + O_WRONLY = O_WRITE, // open() oflag - same as O_WRITE + O_RDWR = (O_READ | O_WRITE), // open() oflag for reading and writing + O_ACCMODE = (O_READ | O_WRITE), // open() oflag mask for access modes + O_APPEND = 0x04, // The file offset shall be set to the end of the file prior to each write. + O_SYNC = 0x08, // Synchronous writes - call sync() after each write + O_TRUNC = 0x10, // Truncate the file to zero length + O_AT_END = 0x20, // Set the initial position at the end of the file + O_CREAT = 0x40, // Create the file if nonexistent + O_EXCL = 0x80; // If O_CREAT and O_EXCL are set, open() shall fail if the file exists + +// SdBaseFile class static and const definitions + +// flags for ls() +uint8_t const LS_DATE = 1, // ls() flag to print modify date + LS_SIZE = 2, // ls() flag to print file size + LS_R = 4; // ls() flag for recursive list of subdirectories + + +// flags for timestamp +uint8_t const T_ACCESS = 1, // Set the file's last access date + T_CREATE = 2, // Set the file's creation date and time + T_WRITE = 4; // Set the file's write date and time + +// values for type_ +uint8_t const FAT_FILE_TYPE_CLOSED = 0, // This file has not been opened. + FAT_FILE_TYPE_NORMAL = 1, // A normal file + FAT_FILE_TYPE_ROOT_FIXED = 2, // A FAT12 or FAT16 root directory + FAT_FILE_TYPE_ROOT32 = 3, // A FAT32 root directory + FAT_FILE_TYPE_SUBDIR = 4, // A subdirectory file + FAT_FILE_TYPE_MIN_DIR = FAT_FILE_TYPE_ROOT_FIXED; // Test value for directory type + +/** + * date field for FAT directory entry + * \param[in] year [1980,2107] + * \param[in] month [1,12] + * \param[in] day [1,31] + * + * \return Packed date for dir_t entry. + */ +static inline uint16_t FAT_DATE(uint16_t year, uint8_t month, uint8_t day) { return (year - 1980) << 9 | month << 5 | day; } + +/** + * year part of FAT directory date field + * \param[in] fatDate Date in packed dir format. + * + * \return Extracted year [1980,2107] + */ +static inline uint16_t FAT_YEAR(uint16_t fatDate) { return 1980 + (fatDate >> 9); } + +/** + * month part of FAT directory date field + * \param[in] fatDate Date in packed dir format. + * + * \return Extracted month [1,12] + */ +static inline uint8_t FAT_MONTH(uint16_t fatDate) { return (fatDate >> 5) & 0xF; } + +/** + * day part of FAT directory date field + * \param[in] fatDate Date in packed dir format. + * + * \return Extracted day [1,31] + */ +static inline uint8_t FAT_DAY(uint16_t fatDate) { return fatDate & 0x1F; } + +/** + * time field for FAT directory entry + * \param[in] hour [0,23] + * \param[in] minute [0,59] + * \param[in] second [0,59] + * + * \return Packed time for dir_t entry. + */ +static inline uint16_t FAT_TIME(uint8_t hour, uint8_t minute, uint8_t second) { return hour << 11 | minute << 5 | second >> 1; } + +/** + * hour part of FAT directory time field + * \param[in] fatTime Time in packed dir format. + * + * \return Extracted hour [0,23] + */ +static inline uint8_t FAT_HOUR(uint16_t fatTime) { return fatTime >> 11; } + +/** + * minute part of FAT directory time field + * \param[in] fatTime Time in packed dir format. + * + * \return Extracted minute [0,59] + */ +static inline uint8_t FAT_MINUTE(uint16_t fatTime) { return (fatTime >> 5) & 0x3F; } + +/** + * second part of FAT directory time field + * Note second/2 is stored in packed time. + * + * \param[in] fatTime Time in packed dir format. + * + * \return Extracted second [0,58] + */ +static inline uint8_t FAT_SECOND(uint16_t fatTime) { return 2 * (fatTime & 0x1F); } + +// Default date for file timestamps is 1 Jan 2000 +uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1; +// Default time for file timestamp is 1 am +uint16_t const FAT_DEFAULT_TIME = (1 << 11); + +/** + * \class SdBaseFile + * \brief Base class for SdFile with Print and C++ streams. + */ +class SdBaseFile { + public: + SdBaseFile() : writeError(false), type_(FAT_FILE_TYPE_CLOSED) {} + SdBaseFile(const char *path, uint8_t oflag); + ~SdBaseFile() { if (isOpen()) close(); } + + /** + * writeError is set to true if an error occurs during a write(). + * Set writeError to false before calling print() and/or write() and check + * for true after calls to print() and/or write(). + */ + bool writeError; + + // helpers for stream classes + + /** + * get position for streams + * \param[out] pos struct to receive position + */ + void getpos(filepos_t *pos); + + /** + * set position for streams + * \param[out] pos struct with value for new position + */ + void setpos(filepos_t *pos); + + bool close(); + bool contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock); + bool createContiguous(SdBaseFile *dirFile, + const char *path, uint32_t size); + /** + * \return The current cluster number for a file or directory. + */ + uint32_t curCluster() const { return curCluster_; } + + /** + * \return The current position for a file or directory. + */ + uint32_t curPosition() const { return curPosition_; } + + /** + * \return Current working directory + */ + static SdBaseFile *cwd() { return cwd_; } + + /** + * Set the date/time callback function + * + * \param[in] dateTime The user's call back function. The callback + * function is of the form: + * + * \code + * void dateTime(uint16_t *date, uint16_t *time) { + * uint16_t year; + * uint8_t month, day, hour, minute, second; + * + * // User gets date and time from GPS or real-time clock here + * + * // return date using FAT_DATE macro to format fields + * *date = FAT_DATE(year, month, day); + * + * // return time using FAT_TIME macro to format fields + * *time = FAT_TIME(hour, minute, second); + * } + * \endcode + * + * Sets the function that is called when a file is created or when + * a file's directory entry is modified by sync(). All timestamps, + * access, creation, and modify, are set when a file is created. + * sync() maintains the last access date and last modify date/time. + * + * See the timestamp() function. + */ + static void dateTimeCallback( + void (*dateTime)(uint16_t *date, uint16_t *time)) { + dateTime_ = dateTime; + } + + /** + * Cancel the date/time callback function. + */ + static void dateTimeCallbackCancel() { dateTime_ = 0; } + bool dirEntry(dir_t *dir); + static void dirName(const dir_t& dir, char *name); + bool exists(const char *name); + int16_t fgets(char *str, int16_t num, char *delim = 0); + + /** + * \return The total number of bytes in a file or directory. + */ + uint32_t fileSize() const { return fileSize_; } + + /** + * \return The first cluster number for a file or directory. + */ + uint32_t firstCluster() const { return firstCluster_; } + + /** + * \return True if this is a directory else false. + */ + bool isDir() const { return type_ >= FAT_FILE_TYPE_MIN_DIR; } + + /** + * \return True if this is a normal file else false. + */ + bool isFile() const { return type_ == FAT_FILE_TYPE_NORMAL; } + + /** + * \return True if this is an open file/directory else false. + */ + bool isOpen() const { return type_ != FAT_FILE_TYPE_CLOSED; } + + /** + * \return True if this is a subdirectory else false. + */ + bool isSubDir() const { return type_ == FAT_FILE_TYPE_SUBDIR; } + + /** + * \return True if this is the root directory. + */ + bool isRoot() const { return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32; } + + bool getDosName(char * const name); + void ls(uint8_t flags = 0, uint8_t indent = 0); + + bool mkdir(SdBaseFile *dir, const char *path, bool pFlag = true); + bool open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag); + bool open(SdBaseFile *dirFile, const char *path, uint8_t oflag); + bool open(const char *path, uint8_t oflag = O_READ); + bool openNext(SdBaseFile *dirFile, uint8_t oflag); + bool openRoot(SdVolume *vol); + int peek(); + static void printFatDate(uint16_t fatDate); + static void printFatTime(uint16_t fatTime); + bool printName(); + int16_t read(); + int16_t read(void *buf, uint16_t nbyte); + int8_t readDir(dir_t *dir, char *longFilename); + static bool remove(SdBaseFile *dirFile, const char *path); + bool remove(); + + /** + * Set the file's current position to zero. + */ + void rewind() { seekSet(0); } + bool rename(SdBaseFile *dirFile, const char *newPath); + bool rmdir(); + bool rmRfStar(); + + /** + * Set the files position to current position + \a pos. See seekSet(). + * \param[in] offset The new position in bytes from the current position. + * \return true for success or false for failure. + */ + bool seekCur(const int32_t offset) { return seekSet(curPosition_ + offset); } + + /** + * Set the files position to end-of-file + \a offset. See seekSet(). + * \param[in] offset The new position in bytes from end-of-file. + * \return true for success or false for failure. + */ + bool seekEnd(const int32_t offset = 0) { return seekSet(fileSize_ + offset); } + bool seekSet(const uint32_t pos); + bool sync(); + bool timestamp(SdBaseFile *file); + bool timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day, + uint8_t hour, uint8_t minute, uint8_t second); + + /** + * Type of file. Use isFile() or isDir() instead of type() if possible. + * + * \return The file or directory type. + */ + uint8_t type() const { return type_; } + bool truncate(uint32_t size); + + /** + * \return SdVolume that contains this file. + */ + SdVolume* volume() const { return vol_; } + int16_t write(const void *buf, uint16_t nbyte); + + private: + friend class SdFat; // allow SdFat to set cwd_ + static SdBaseFile *cwd_; // global pointer to cwd dir + + // data time callback function + static void (*dateTime_)(uint16_t *date, uint16_t *time); + + // bits defined in flags_ + static uint8_t const F_OFLAG = (O_ACCMODE | O_APPEND | O_SYNC), // should be 0x0F + F_FILE_DIR_DIRTY = 0x80; // sync of directory entry required + + // private data + uint8_t flags_; // See above for definition of flags_ bits + uint8_t fstate_; // error and eof indicator + uint8_t type_; // type of file see above for values + uint32_t curCluster_; // cluster for current file position + uint32_t curPosition_; // current file position in bytes from beginning + uint32_t dirBlock_; // block for this files directory entry + uint8_t dirIndex_; // index of directory entry in dirBlock + uint32_t fileSize_; // file size in bytes + uint32_t firstCluster_; // first cluster of file + SdVolume *vol_; // volume where file is located + + /** + * EXPERIMENTAL - Don't use! + */ + //bool openParent(SdBaseFile *dir); + + // private functions + bool addCluster(); + bool addDirCluster(); + dir_t* cacheDirEntry(uint8_t action); + int8_t lsPrintNext(uint8_t flags, uint8_t indent); + static bool make83Name(const char *str, uint8_t *name, const char **ptr); + bool mkdir(SdBaseFile *parent, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) + ); + bool open(SdBaseFile *dirFile, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) + , uint8_t oflag + ); + bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags); + dir_t* readDirCache(); + + // Long Filename create/write support + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + static bool isDirLFN(const dir_t* dir); + static bool isDirNameLFN(const char *dirname); + static bool parsePath(const char *str, uint8_t *name, uint8_t *lname, const char **ptr); + /** + * Return the number of entries needed in the FAT for this LFN + */ + static inline uint8_t getLFNEntriesNum(const char *lname) { return (strlen(lname) + 12) / 13; } + static void getLFNName(vfat_t *vFatDir, char *lname, uint8_t startOffset); + static void setLFNName(vfat_t *vFatDir, char *lname, uint8_t lfnSequenceNumber); + #endif +}; diff --git a/src/sd/SdFatConfig.h b/src/sd/SdFatConfig.h new file mode 100644 index 0000000..dfba641 --- /dev/null +++ b/src/sd/SdFatConfig.h @@ -0,0 +1,112 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * sd/SdFatConfig.h + * + * Arduino SdFat Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include "../inc/MarlinConfig.h" + +/** + * To use multiple SD cards set USE_MULTIPLE_CARDS nonzero. + * + * Using multiple cards costs 400 - 500 bytes of flash. + * + * Each card requires about 550 bytes of SRAM so use of a Mega is recommended. + */ +#define USE_MULTIPLE_CARDS 0 //TODO? ENABLED(MULTI_VOLUME) + +/** + * Call flush for endl if ENDL_CALLS_FLUSH is nonzero + * + * The standard for iostreams is to call flush. This is very costly for + * SdFat. Each call to flush causes 2048 bytes of I/O to the SD. + * + * SdFat has a single 512 byte buffer for SD I/O so it must write the current + * data block to the SD, read the directory block from the SD, update the + * directory entry, write the directory block to the SD and read the data + * block back into the buffer. + * + * The SD flash memory controller is not designed for this many rewrites + * so performance may be reduced by more than a factor of 100. + * + * If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force + * all data to be written to the SD. + */ +#define ENDL_CALLS_FLUSH 0 + +/** + * Allow FAT12 volumes if FAT12_SUPPORT is nonzero. + * FAT12 has not been well tested. + */ +#define FAT12_SUPPORT 0 + +/** + * SPI init rate for SD initialization commands. Must be 5 (F_CPU/64) + * or 6 (F_CPU/128). + */ +#define SPI_SD_INIT_RATE 5 + +/** + * Set the SS pin high for hardware SPI. If SS is chip select for another SPI + * device this will disable that device during the SD init phase. + */ +#define SET_SPI_SS_HIGH 1 + +/** + * Define MEGA_SOFT_SPI nonzero to use software SPI on Mega Arduinos. + * Pins used are SS 10, MOSI 11, MISO 12, and SCK 13. + * + * MEGA_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used + * on Mega Arduinos. Software SPI works well with GPS Shield V1.1 + * but many SD cards will fail with GPS Shield V1.0. + */ +#define MEGA_SOFT_SPI 0 + +// Set USE_SOFTWARE_SPI nonzero to ALWAYS use Software SPI. +#define USE_SOFTWARE_SPI 0 + +/** + * The __cxa_pure_virtual function is an error handler that is invoked when + * a pure virtual function is called. + */ +#define USE_CXA_PURE_VIRTUAL 1 + +/** + * Defines for 8.3 and long (vfat) filenames + */ + +#define FILENAME_LENGTH 13 // Number of UTF-16 characters per entry + +// UTF-8 may use up to 3 bytes to represent single UTF-16 code point. +// We discard 3-byte characters allowing only 2-bytes +// or 1-byte if UTF_FILENAME_SUPPORT disabled. +#define LONG_FILENAME_CHARSIZE TERN(UTF_FILENAME_SUPPORT, 2, 1) + +// Total bytes needed to store a single long filename +#define LONG_FILENAME_LENGTH (FILENAME_LENGTH * LONG_FILENAME_CHARSIZE * MAX_VFAT_ENTRIES + 1) diff --git a/src/sd/SdFatStructs.h b/src/sd/SdFatStructs.h new file mode 100644 index 0000000..03bbc1c --- /dev/null +++ b/src/sd/SdFatStructs.h @@ -0,0 +1,609 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * sd/SdFatStructs.h + * + * Arduino SdFat Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include + +#define PACKED __attribute__((__packed__)) + +/** + * mostly from Microsoft document fatgen103.doc + * https://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx + */ + +uint8_t const BOOTSIG0 = 0x55, // Value for byte 510 of boot block or MBR + BOOTSIG1 = 0xAA, // Value for byte 511 of boot block or MBR + EXTENDED_BOOT_SIG = 0x29; // Value for bootSignature field int FAT/FAT32 boot sector + +/** + * \struct partitionTable + * \brief MBR partition table entry + * + * A partition table entry for a MBR formatted storage device. + * The MBR partition table has four entries. + */ +struct partitionTable { + /** + * Boot Indicator . Indicates whether the volume is the active + * partition. Legal values include: 0x00. Do not use for booting. + * 0x80 Active partition. + */ + uint8_t boot; + /** + * Head part of Cylinder-head-sector address of the first block in + * the partition. Legal values are 0-255. Only used in old PC BIOS. + */ + uint8_t beginHead; + /** + * Sector part of Cylinder-head-sector address of the first block in + * the partition. Legal values are 1-63. Only used in old PC BIOS. + */ + unsigned beginSector : 6; + /** High bits cylinder for first block in partition. */ + unsigned beginCylinderHigh : 2; + /** + * Combine beginCylinderLow with beginCylinderHigh. Legal values + * are 0-1023. Only used in old PC BIOS. + */ + uint8_t beginCylinderLow; + /** + * Partition type. See defines that begin with PART_TYPE_ for + * some Microsoft partition types. + */ + uint8_t type; + /** + * head part of cylinder-head-sector address of the last sector in the + * partition. Legal values are 0-255. Only used in old PC BIOS. + */ + uint8_t endHead; + /** + * Sector part of cylinder-head-sector address of the last sector in + * the partition. Legal values are 1-63. Only used in old PC BIOS. + */ + unsigned endSector : 6; + /** High bits of end cylinder */ + unsigned endCylinderHigh : 2; + /** + * Combine endCylinderLow with endCylinderHigh. Legal values + * are 0-1023. Only used in old PC BIOS. + */ + uint8_t endCylinderLow; + + uint32_t firstSector; // Logical block address of the first block in the partition. + uint32_t totalSectors; // Length of the partition, in blocks. +} PACKED; + +typedef struct partitionTable part_t; // Type name for partitionTable + +/** + * \struct masterBootRecord + * + * \brief Master Boot Record + * + * The first block of a storage device that is formatted with a MBR. + */ +struct masterBootRecord { + uint8_t codeArea[440]; // Code Area for master boot program. + uint32_t diskSignature; // Optional Windows NT disk signature. May contain boot code. + uint16_t usuallyZero; // Usually zero but may be more boot code. + part_t part[4]; // Partition tables. + uint8_t mbrSig0; // First MBR signature byte. Must be 0x55 + uint8_t mbrSig1; // Second MBR signature byte. Must be 0xAA +} PACKED; +/** Type name for masterBootRecord */ +typedef struct masterBootRecord mbr_t; + +/** + * \struct fat_boot + * + * \brief Boot sector for a FAT12/FAT16 volume. + */ +struct fat_boot { + /** + * The first three bytes of the boot sector must be valid, + * executable x 86-based CPU instructions. This includes a + * jump instruction that skips the next nonexecutable bytes. + */ + uint8_t jump[3]; + /** + * This is typically a string of characters that identifies + * the operating system that formatted the volume. + */ + char oemId[8]; + /** + * The size of a hardware sector. Valid decimal values for this + * field are 512, 1024, 2048, and 4096. For most disks used in + * the United States, the value of this field is 512. + */ + uint16_t bytesPerSector; + /** + * Number of sectors per allocation unit. This value must be a + * power of 2 that is greater than 0. The legal values are + * 1, 2, 4, 8, 16, 32, 64, and 128. 128 should be avoided. + */ + uint8_t sectorsPerCluster; + /** + * The number of sectors preceding the start of the first FAT, + * including the boot sector. The value of this field is always 1. + */ + uint16_t reservedSectorCount; + /** + * The number of copies of the FAT on the volume. + * The value of this field is always 2. + */ + uint8_t fatCount; + /** + * For FAT12 and FAT16 volumes, this field contains the count of + * 32-byte directory entries in the root directory. For FAT32 volumes, + * this field must be set to 0. For FAT12 and FAT16 volumes, this + * value should always specify a count that when multiplied by 32 + * results in a multiple of bytesPerSector. FAT16 volumes should + * use the value 512. + */ + uint16_t rootDirEntryCount; + /** + * This field is the old 16-bit total count of sectors on the volume. + * This count includes the count of all sectors in all four regions + * of the volume. This field can be 0; if it is 0, then totalSectors32 + * must be nonzero. For FAT32 volumes, this field must be 0. For + * FAT12 and FAT16 volumes, this field contains the sector count, and + * totalSectors32 is 0 if the total sector count fits + * (is less than 0x10000). + */ + uint16_t totalSectors16; + /** + * This dates back to the old MS-DOS 1.x media determination and is + * no longer usually used for anything. 0xF8 is the standard value + * for fixed (nonremovable) media. For removable media, 0xF0 is + * frequently used. Legal values are 0xF0 or 0xF8-0xFF. + */ + uint8_t mediaType; + /** + * Count of sectors occupied by one FAT on FAT12/FAT16 volumes. + * On FAT32 volumes this field must be 0, and sectorsPerFat32 + * contains the FAT size count. + */ + uint16_t sectorsPerFat16; + + uint16_t sectorsPerTrack; // Sectors per track for interrupt 0x13. Not used otherwise. + uint16_t headCount; // Number of heads for interrupt 0x13. Not used otherwise. + + /** + * Count of hidden sectors preceding the partition that contains this + * FAT volume. This field is generally only relevant for media + * visible on interrupt 0x13. + */ + uint32_t hidddenSectors; + /** + * This field is the new 32-bit total count of sectors on the volume. + * This count includes the count of all sectors in all four regions + * of the volume. This field can be 0; if it is 0, then + * totalSectors16 must be nonzero. + */ + uint32_t totalSectors32; + /** + * Related to the BIOS physical drive number. Floppy drives are + * identified as 0x00 and physical hard disks are identified as + * 0x80, regardless of the number of physical disk drives. + * Typically, this value is set prior to issuing an INT 13h BIOS + * call to specify the device to access. The value is only + * relevant if the device is a boot device. + */ + uint8_t driveNumber; + + uint8_t reserved1; // used by Windows NT - should be zero for FAT + uint8_t bootSignature; // 0x29 if next three fields are valid + + /** + * A random serial number created when formatting a disk, + * which helps to distinguish between disks. + * Usually generated by combining date and time. + */ + uint32_t volumeSerialNumber; + /** + * A field once used to store the volume label. The volume label + * is now stored as a special file in the root directory. + */ + char volumeLabel[11]; + /** + * A field with a value of either FAT, FAT12 or FAT16, + * depending on the disk format. + */ + char fileSystemType[8]; + + uint8_t bootCode[448]; // X86 boot code + uint8_t bootSectorSig0; // must be 0x55 + uint8_t bootSectorSig1; // must be 0xAA +} PACKED; + +typedef struct fat_boot fat_boot_t; // Type name for FAT Boot Sector + +/** + * \struct fat32_boot + * + * \brief Boot sector for a FAT32 volume. + */ +struct fat32_boot { + /** + * The first three bytes of the boot sector must be valid, + * executable x 86-based CPU instructions. This includes a + * jump instruction that skips the next nonexecutable bytes. + */ + uint8_t jump[3]; + /** + * This is typically a string of characters that identifies + * the operating system that formatted the volume. + */ + char oemId[8]; + /** + * The size of a hardware sector. Valid decimal values for this + * field are 512, 1024, 2048, and 4096. For most disks used in + * the United States, the value of this field is 512. + */ + uint16_t bytesPerSector; + /** + * Number of sectors per allocation unit. This value must be a + * power of 2 that is greater than 0. The legal values are + * 1, 2, 4, 8, 16, 32, 64, and 128. 128 should be avoided. + */ + uint8_t sectorsPerCluster; + /** + * The number of sectors preceding the start of the first FAT, + * including the boot sector. Must not be zero + */ + uint16_t reservedSectorCount; + /** + * The number of copies of the FAT on the volume. + * The value of this field is always 2. + */ + uint8_t fatCount; + /** + * FAT12/FAT16 only. For FAT32 volumes, this field must be set to 0. + */ + uint16_t rootDirEntryCount; + /** + * For FAT32 volumes, this field must be 0. + */ + uint16_t totalSectors16; + /** + * This dates back to the old MS-DOS 1.x media determination and is + * no longer usually used for anything. 0xF8 is the standard value + * for fixed (nonremovable) media. For removable media, 0xF0 is + * frequently used. Legal values are 0xF0 or 0xF8-0xFF. + */ + uint8_t mediaType; + /** + * On FAT32 volumes this field must be 0, and sectorsPerFat32 + * contains the FAT size count. + */ + uint16_t sectorsPerFat16; + + uint16_t sectorsPerTrack; // Sectors per track for interrupt 0x13. Not used otherwise. + uint16_t headCount; // Number of heads for interrupt 0x13. Not used otherwise. + + /** + * Count of hidden sectors preceding the partition that contains this + * FAT volume. This field is generally only relevant for media + * visible on interrupt 0x13. + */ + uint32_t hidddenSectors; + /** + * Contains the total number of sectors in the FAT32 volume. + */ + uint32_t totalSectors32; + /** + * Count of sectors occupied by one FAT on FAT32 volumes. + */ + uint32_t sectorsPerFat32; + /** + * This field is only defined for FAT32 media and does not exist on + * FAT12 and FAT16 media. + * Bits 0-3 -- Zero-based number of active FAT. + * Only valid if mirroring is disabled. + * Bits 4-6 -- Reserved. + * Bit 7 -- 0 means the FAT is mirrored at runtime into all FATs. + * -- 1 means only one FAT is active; it is the one referenced + * in bits 0-3. + * Bits 8-15 -- Reserved. + */ + uint16_t fat32Flags; + /** + * FAT32 version. High byte is major revision number. + * Low byte is minor revision number. Only 0.0 define. + */ + uint16_t fat32Version; + /** + * Cluster number of the first cluster of the root directory for FAT32. + * This usually 2 but not required to be 2. + */ + uint32_t fat32RootCluster; + /** + * Sector number of FSINFO structure in the reserved area of the + * FAT32 volume. Usually 1. + */ + uint16_t fat32FSInfo; + /** + * If nonzero, indicates the sector number in the reserved area + * of the volume of a copy of the boot record. Usually 6. + * No value other than 6 is recommended. + */ + uint16_t fat32BackBootBlock; + /** + * Reserved for future expansion. Code that formats FAT32 volumes + * should always set all of the bytes of this field to 0. + */ + uint8_t fat32Reserved[12]; + /** + * Related to the BIOS physical drive number. Floppy drives are + * identified as 0x00 and physical hard disks are identified as + * 0x80, regardless of the number of physical disk drives. + * Typically, this value is set prior to issuing an INT 13h BIOS + * call to specify the device to access. The value is only + * relevant if the device is a boot device. + */ + uint8_t driveNumber; + + uint8_t reserved1; // Used by Windows NT - should be zero for FAT + uint8_t bootSignature; // 0x29 if next three fields are valid + + /** + * A random serial number created when formatting a disk, + * which helps to distinguish between disks. + * Usually generated by combining date and time. + */ + uint32_t volumeSerialNumber; + /** + * A field once used to store the volume label. The volume label + * is now stored as a special file in the root directory. + */ + char volumeLabel[11]; + /** + * A text field with a value of FAT32. + */ + char fileSystemType[8]; + + uint8_t bootCode[420]; // X86 boot code + uint8_t bootSectorSig0; // must be 0x55 + uint8_t bootSectorSig1; // must be 0xAA + +} PACKED; + +typedef struct fat32_boot fat32_boot_t; // Type name for FAT32 Boot Sector + +uint32_t const FSINFO_LEAD_SIG = 0x41615252, // 'AaRR' Lead signature for a FSINFO sector + FSINFO_STRUCT_SIG = 0x61417272; // 'aArr' Struct signature for a FSINFO sector + +/** + * \struct fat32_fsinfo + * + * \brief FSINFO sector for a FAT32 volume. + */ +struct fat32_fsinfo { + uint32_t leadSignature; // must be 0x52, 0x52, 0x61, 0x41 'RRaA' + uint8_t reserved1[480]; // must be zero + uint32_t structSignature; // must be 0x72, 0x72, 0x41, 0x61 'rrAa' + /** + * Contains the last known free cluster count on the volume. + * If the value is 0xFFFFFFFF, then the free count is unknown + * and must be computed. Any other value can be used, but is + * not necessarily correct. It should be range checked at least + * to make sure it is <= volume cluster count. + */ + uint32_t freeCount; + /** + * This is a hint for the FAT driver. It indicates the cluster + * number at which the driver should start looking for free clusters. + * If the value is 0xFFFFFFFF, then there is no hint and the driver + * should start looking at cluster 2. + */ + uint32_t nextFree; + + uint8_t reserved2[12]; // must be zero + uint8_t tailSignature[4]; // must be 0x00, 0x00, 0x55, 0xAA +} PACKED; + +typedef struct fat32_fsinfo fat32_fsinfo_t; // Type name for FAT32 FSINFO Sector + +// End Of Chain values for FAT entries +uint16_t const FAT12EOC = 0xFFF, // FAT12 end of chain value used by Microsoft. + FAT12EOC_MIN = 0xFF8, // Minimum value for FAT12 EOC. Use to test for EOC. + FAT16EOC = 0xFFFF, // FAT16 end of chain value used by Microsoft. + FAT16EOC_MIN = 0xFFF8; // Minimum value for FAT16 EOC. Use to test for EOC. +uint32_t const FAT32EOC = 0x0FFFFFFF, // FAT32 end of chain value used by Microsoft. + FAT32EOC_MIN = 0x0FFFFFF8, // Minimum value for FAT32 EOC. Use to test for EOC. + FAT32MASK = 0x0FFFFFFF; // Mask a for FAT32 entry. Entries are 28 bits. + +/** + * \struct directoryEntry + * \brief FAT short directory entry + * + * Short means short 8.3 name, not the entry size. + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * 16-bit word): + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 + * inclusive (1980-2107). + * + * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. + * + * Bits 0-4: Day of month, valid value range 1-31 inclusive. + * + * Time Format. A FAT directory entry time stamp is a 16-bit field that has + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * 16-bit word, bit 15 is the MSB of the 16-bit word). + * + * Bits 11-15: Hours, valid value range 0-23 inclusive. + * + * Bits 5-10: Minutes, valid value range 0-59 inclusive. + * + * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). + * + * The valid time range is from Midnight 00:00:00 to 23:59:58. + */ +struct directoryEntry { + /** + * Short 8.3 name. + * + * The first eight bytes contain the file name with blank fill. + * The last three bytes contain the file extension with blank fill. + */ + uint8_t name[11]; + /** + * Entry attributes. + * + * The upper two bits of the attribute byte are reserved and should + * always be set to 0 when a file is created and never modified or + * looked at after that. See defines that begin with DIR_ATT_. + */ + uint8_t attributes; + /** + * Reserved for use by Windows NT. Set value to 0 when a file is + * created and never modify or look at it after that. + */ + uint8_t reservedNT; + /** + * The granularity of the seconds part of creationTime is 2 seconds + * so this field is a count of tenths of a second and it's valid + * value range is 0-199 inclusive. (WHG note - seems to be hundredths) + */ + uint8_t creationTimeTenths; + + uint16_t creationTime; // Time file was created. + uint16_t creationDate; // Date file was created. + + /** + * Last access date. Note that there is no last access time, only + * a date. This is the date of last read or write. In the case of + * a write, this should be set to the same date as lastWriteDate. + */ + uint16_t lastAccessDate; + /** + * High word of this entry's first cluster number (always 0 for a + * FAT12 or FAT16 volume). + */ + uint16_t firstClusterHigh; + + uint16_t lastWriteTime; // Time of last write. File creation is considered a write. + uint16_t lastWriteDate; // Date of last write. File creation is considered a write. + uint16_t firstClusterLow; // Low word of this entry's first cluster number. + uint32_t fileSize; // 32-bit unsigned holding this file's size in bytes. +} PACKED; + +/** + * \struct directoryVFATEntry + * \brief VFAT long filename directory entry + * + * directoryVFATEntries are found in the same list as normal directoryEntry. + * But have the attribute field set to DIR_ATT_LONG_NAME. + * + * Long filenames are saved in multiple directoryVFATEntries. + * Each entry containing 13 UTF-16 characters. + */ +struct directoryVFATEntry { + /** + * Sequence number. Consists of 2 parts: + * bit 6: indicates first long filename block for the next file + * bit 0-4: the position of this long filename block (first block is 1) + */ + uint8_t sequenceNumber; + + uint16_t name1[5]; // First set of UTF-16 characters + uint8_t attributes; // attributes (at the same location as in directoryEntry), always 0x0F + uint8_t reservedNT; // Reserved for use by Windows NT. Always 0. + uint8_t checksum; // Checksum of the short 8.3 filename, can be used to checked if the file system as modified by a not-long-filename aware implementation. + uint16_t name2[6]; // Second set of UTF-16 characters + uint16_t firstClusterLow; // firstClusterLow is always zero for longFilenames + uint16_t name3[2]; // Third set of UTF-16 characters +} PACKED; + +// Definitions for directory entries +// +typedef struct directoryEntry dir_t; // Type name for directoryEntry +typedef struct directoryVFATEntry vfat_t; // Type name for directoryVFATEntry + +uint8_t const DIR_NAME_0xE5 = 0x05, // escape for name[0] = 0xE5 + DIR_NAME_DELETED = 0xE5, // name[0] value for entry that is free after being "deleted" + DIR_NAME_FREE = 0x00, // name[0] value for entry that is free and no allocated entries follow + DIR_ATT_READ_ONLY = 0x01, // file is read-only + DIR_ATT_HIDDEN = 0x02, // File should hidden in directory listings + DIR_ATT_SYSTEM = 0x04, // Entry is for a system file + DIR_ATT_VOLUME_ID = 0x08, // Directory entry contains the volume label + DIR_ATT_DIRECTORY = 0x10, // Entry is for a directory + DIR_ATT_ARCHIVE = 0x20, // Old DOS archive bit for backup support + DIR_ATT_LONG_NAME = 0x0F, // Test value for long name entry. Test is (d->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME. + DIR_ATT_LONG_NAME_MASK = 0x3F, // Test mask for long name entry + DIR_ATT_DEFINED_BITS = 0x3F; // defined attribute bits + +/** + * Directory entry is part of a long name + * \param[in] dir Pointer to a directory entry. + * + * \return true if the entry is for part of a long name else false. + */ +static inline uint8_t DIR_IS_LONG_NAME(const dir_t *dir) { + return (dir->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME; +} + +/** Mask for file/subdirectory tests */ +uint8_t const DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY); + +/** + * Directory entry is for a file + * \param[in] dir Pointer to a directory entry. + * + * \return true if the entry is for a normal file else false. + */ +static inline uint8_t DIR_IS_FILE(const dir_t *dir) { + return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == 0; +} + +/** + * Directory entry is for a subdirectory + * \param[in] dir Pointer to a directory entry. + * + * \return true if the entry is for a subdirectory else false. + */ +static inline uint8_t DIR_IS_SUBDIR(const dir_t *dir) { + return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == DIR_ATT_DIRECTORY; +} + +/** + * Directory entry is for a file or subdirectory + * \param[in] dir Pointer to a directory entry. + * + * \return true if the entry is for a normal file or subdirectory else false. + */ +static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t *dir) { + return (dir->attributes & DIR_ATT_VOLUME_ID) == 0; +} diff --git a/src/sd/SdFatUtil.cpp b/src/sd/SdFatUtil.cpp new file mode 100644 index 0000000..e6f7a9a --- /dev/null +++ b/src/sd/SdFatUtil.cpp @@ -0,0 +1,62 @@ +/** + * 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 . + * + */ + +/** + * sd/SdFatUtil.cpp + * + * Arduino SdFat Library + * Copyright (c) 2008 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include "../inc/MarlinConfig.h" + +#if ENABLED(SDSUPPORT) + +#include "SdFatUtil.h" +#include + +/** + * Amount of free RAM + * \return The number of free bytes. + */ +#ifdef __arm__ + + extern "C" char* sbrk(int incr); + int SdFatUtil::FreeRam() { + char top; + return &top - reinterpret_cast(sbrk(0)); + } + +#elif defined(__AVR__) + + extern char* __brkval; + extern char __bss_end; + int SdFatUtil::FreeRam() { + char top; + return __brkval ? &top - __brkval : &top - &__bss_end; + } + +#endif + +#endif // SDSUPPORT diff --git a/src/sd/SdFatUtil.h b/src/sd/SdFatUtil.h new file mode 100644 index 0000000..f1bb657 --- /dev/null +++ b/src/sd/SdFatUtil.h @@ -0,0 +1,42 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * sd/SdFatUtil.h + * + * Arduino SdFat Library + * Copyright (c) 2008 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +/** + * \file + * \brief Useful utility functions. + */ + +namespace SdFatUtil { + int FreeRam(); +} + +using namespace SdFatUtil; // NOLINT diff --git a/src/sd/SdFile.cpp b/src/sd/SdFile.cpp new file mode 100644 index 0000000..bce96ef --- /dev/null +++ b/src/sd/SdFile.cpp @@ -0,0 +1,102 @@ +/** + * 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 . + * + */ + +/** + * sd/SdFile.cpp + * + * Arduino SdFat Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include "../inc/MarlinConfig.h" + +#if ENABLED(SDSUPPORT) + +#include "SdFile.h" + +/** + * Create a file object and open it in the current working directory. + * + * \param[in] path A path with a valid 8.3 DOS name for a file to be opened. + * + * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive + * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t). + */ +SdFile::SdFile(const char *path, uint8_t oflag) : SdBaseFile(path, oflag) { } + +/** + * Write data to an open file. + * + * \note Data is moved to the cache but may not be written to the + * storage device until sync() is called. + * + * \param[in] buf Pointer to the location of the data to be written. + * + * \param[in] nbyte Number of bytes to write. + * + * \return For success write() returns the number of bytes written, always + * \a nbyte. If an error occurs, write() returns -1. Possible errors + * include write() is called before a file has been opened, write is called + * for a read-only file, device is full, a corrupt file system or an I/O error. + */ +int16_t SdFile::write(const void *buf, uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); } + +/** + * Write a byte to a file. Required by the Arduino Print class. + * \param[in] b the byte to be written. + * Use writeError to check for errors. + */ +#if ARDUINO >= 100 + size_t SdFile::write(uint8_t b) { return SdBaseFile::write(&b, 1); } +#else + void SdFile::write(uint8_t b) { SdBaseFile::write(&b, 1); } +#endif + +/** + * Write a string to a file. Used by the Arduino Print class. + * \param[in] str Pointer to the string. + * Use writeError to check for errors. + */ +void SdFile::write(const char *str) { SdBaseFile::write(str, strlen(str)); } + +/** + * Write a PROGMEM string to a file. + * \param[in] str Pointer to the PROGMEM string. + * Use writeError to check for errors. + */ +void SdFile::write_P(PGM_P str) { + for (uint8_t c; (c = pgm_read_byte(str)); str++) write(c); +} + +/** + * Write a PROGMEM string followed by CR/LF to a file. + * \param[in] str Pointer to the PROGMEM string. + * Use writeError to check for errors. + */ +void SdFile::writeln_P(PGM_P str) { + write_P(str); + write_P(PSTR("\r\n")); +} + +#endif // SDSUPPORT diff --git a/src/sd/SdFile.h b/src/sd/SdFile.h new file mode 100644 index 0000000..1ff0582 --- /dev/null +++ b/src/sd/SdFile.h @@ -0,0 +1,55 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * sd/SdFile.h + * + * Arduino SdFat Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include "SdBaseFile.h" + +#include + +/** + * \class SdFile + * \brief SdBaseFile with Print. + */ +class SdFile : public SdBaseFile { + public: + SdFile() {} + SdFile(const char *name, uint8_t oflag); + #if ARDUINO >= 100 + size_t write(uint8_t b); + #else + void write(uint8_t b); + #endif + + int16_t write(const void *buf, uint16_t nbyte); + void write(const char *str); + void write_P(PGM_P str); + void writeln_P(PGM_P str); +}; diff --git a/src/sd/SdInfo.h b/src/sd/SdInfo.h new file mode 100644 index 0000000..bfa5a01 --- /dev/null +++ b/src/sd/SdInfo.h @@ -0,0 +1,265 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * Arduino Sd2Card Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include + +// Based on the document: +// +// SD Specifications +// Part 1 +// Physical Layer +// Simplified Specification +// Version 3.01 +// May 18, 2010 +// +// https://www.sdcard.org/downloads/pls/index.html + +// SD card commands +uint8_t const CMD0 = 0x00, // GO_IDLE_STATE - init card in spi mode if CS low + CMD8 = 0x08, // SEND_IF_COND - verify SD Memory Card interface operating condition + CMD9 = 0x09, // SEND_CSD - read the Card Specific Data (CSD register) + CMD10 = 0x0A, // SEND_CID - read the card identification information (CID register) + CMD12 = 0x0C, // STOP_TRANSMISSION - end multiple block read sequence + CMD13 = 0x0D, // SEND_STATUS - read the card status register + CMD17 = 0x11, // READ_SINGLE_BLOCK - read a single data block from the card + CMD18 = 0x12, // READ_MULTIPLE_BLOCK - read a multiple data blocks from the card + CMD24 = 0x18, // WRITE_BLOCK - write a single data block to the card + CMD25 = 0x19, // WRITE_MULTIPLE_BLOCK - write blocks of data until a STOP_TRANSMISSION + CMD32 = 0x20, // ERASE_WR_BLK_START - sets the address of the first block to be erased + CMD33 = 0x21, // ERASE_WR_BLK_END - sets the address of the last block of the continuous range to be erased + CMD38 = 0x26, // ERASE - erase all previously selected blocks + CMD55 = 0x37, // APP_CMD - escape for application specific command + CMD58 = 0x3A, // READ_OCR - read the OCR register of a card + CMD59 = 0x3B, // CRC_ON_OFF - enable or disable CRC checking + ACMD23 = 0x17, // SET_WR_BLK_ERASE_COUNT - Set the number of write blocks to be pre-erased before writing + ACMD41 = 0x29; // SD_SEND_OP_COMD - Sends host capacity support information and activates the card's initialization process + +/** status for card in the ready state */ +uint8_t const R1_READY_STATE = 0x00; +/** status for card in the idle state */ +uint8_t const R1_IDLE_STATE = 0x01; +/** status bit for illegal command */ +uint8_t const R1_ILLEGAL_COMMAND = 0x04; +/** start data token for read or write single block*/ +uint8_t const DATA_START_BLOCK = 0xFE; +/** stop token for write multiple blocks*/ +uint8_t const STOP_TRAN_TOKEN = 0xFD; +/** start data token for write multiple blocks*/ +uint8_t const WRITE_MULTIPLE_TOKEN = 0xFC; +/** mask for data response tokens after a write block operation */ +uint8_t const DATA_RES_MASK = 0x1F; +/** write data accepted token */ +uint8_t const DATA_RES_ACCEPTED = 0x05; + +/** Card IDentification (CID) register */ +typedef struct CID { + // byte 0 + /** Manufacturer ID */ + unsigned char mid; + // byte 1-2 + /** OEM/Application ID */ + char oid[2]; + // byte 3-7 + /** Product name */ + char pnm[5]; + // byte 8 + /** Product revision least significant digit */ + unsigned char prv_m : 4; + /** Product revision most significant digit */ + unsigned char prv_n : 4; + // byte 9-12 + /** Product serial number */ + uint32_t psn; + // byte 13 + /** Manufacturing date year low digit */ + unsigned char mdt_year_high : 4; + /** not used */ + unsigned char reserved : 4; + // byte 14 + /** Manufacturing date month */ + unsigned char mdt_month : 4; + /** Manufacturing date year low digit */ + unsigned char mdt_year_low : 4; + // byte 15 + /** not used always 1 */ + unsigned char always1 : 1; + /** CRC7 checksum */ + unsigned char crc : 7; +} cid_t; + +/** CSD for version 1.00 cards */ +typedef struct CSDV1 { + // byte 0 + unsigned char reserved1 : 6; + unsigned char csd_ver : 2; + // byte 1 + unsigned char taac; + // byte 2 + unsigned char nsac; + // byte 3 + unsigned char tran_speed; + // byte 4 + unsigned char ccc_high; + // byte 5 + unsigned char read_bl_len : 4; + unsigned char ccc_low : 4; + // byte 6 + unsigned char c_size_high : 2; + unsigned char reserved2 : 2; + unsigned char dsr_imp : 1; + unsigned char read_blk_misalign : 1; + unsigned char write_blk_misalign : 1; + unsigned char read_bl_partial : 1; + // byte 7 + unsigned char c_size_mid; + // byte 8 + unsigned char vdd_r_curr_max : 3; + unsigned char vdd_r_curr_min : 3; + unsigned char c_size_low : 2; + // byte 9 + unsigned char c_size_mult_high : 2; + unsigned char vdd_w_cur_max : 3; + unsigned char vdd_w_curr_min : 3; + // byte 10 + unsigned char sector_size_high : 6; + unsigned char erase_blk_en : 1; + unsigned char c_size_mult_low : 1; + // byte 11 + unsigned char wp_grp_size : 7; + unsigned char sector_size_low : 1; + // byte 12 + unsigned char write_bl_len_high : 2; + unsigned char r2w_factor : 3; + unsigned char reserved3 : 2; + unsigned char wp_grp_enable : 1; + // byte 13 + unsigned char reserved4 : 5; + unsigned char write_partial : 1; + unsigned char write_bl_len_low : 2; + // byte 14 + unsigned char reserved5: 2; + unsigned char file_format : 2; + unsigned char tmp_write_protect : 1; + unsigned char perm_write_protect : 1; + unsigned char copy : 1; + /** Indicates the file format on the card */ + unsigned char file_format_grp : 1; + // byte 15 + unsigned char always1 : 1; + unsigned char crc : 7; +} csd1_t; + +/** CSD for version 2.00 cards */ +typedef struct CSDV2 { + // byte 0 + unsigned char reserved1 : 6; + unsigned char csd_ver : 2; + // byte 1 + /** fixed to 0x0E */ + unsigned char taac; + // byte 2 + /** fixed to 0 */ + unsigned char nsac; + // byte 3 + unsigned char tran_speed; + // byte 4 + unsigned char ccc_high; + // byte 5 + /** This field is fixed to 9h, which indicates READ_BL_LEN=512 Byte */ + unsigned char read_bl_len : 4; + unsigned char ccc_low : 4; + // byte 6 + /** not used */ + unsigned char reserved2 : 4; + unsigned char dsr_imp : 1; + /** fixed to 0 */ + unsigned char read_blk_misalign : 1; + /** fixed to 0 */ + unsigned char write_blk_misalign : 1; + /** fixed to 0 - no partial read */ + unsigned char read_bl_partial : 1; + // byte 7 + /** not used */ + unsigned char reserved3 : 2; + /** high part of card size */ + unsigned char c_size_high : 6; + // byte 8 + /** middle part of card size */ + unsigned char c_size_mid; + // byte 9 + /** low part of card size */ + unsigned char c_size_low; + // byte 10 + /** sector size is fixed at 64 KB */ + unsigned char sector_size_high : 6; + /** fixed to 1 - erase single is supported */ + unsigned char erase_blk_en : 1; + /** not used */ + unsigned char reserved4 : 1; + // byte 11 + unsigned char wp_grp_size : 7; + /** sector size is fixed at 64 KB */ + unsigned char sector_size_low : 1; + // byte 12 + /** write_bl_len fixed for 512 byte blocks */ + unsigned char write_bl_len_high : 2; + /** fixed value of 2 */ + unsigned char r2w_factor : 3; + /** not used */ + unsigned char reserved5 : 2; + /** fixed value of 0 - no write protect groups */ + unsigned char wp_grp_enable : 1; + // byte 13 + unsigned char reserved6 : 5; + /** always zero - no partial block read*/ + unsigned char write_partial : 1; + /** write_bl_len fixed for 512 byte blocks */ + unsigned char write_bl_len_low : 2; + // byte 14 + unsigned char reserved7: 2; + /** Do not use always 0 */ + unsigned char file_format : 2; + unsigned char tmp_write_protect : 1; + unsigned char perm_write_protect : 1; + unsigned char copy : 1; + /** Do not use always 0 */ + unsigned char file_format_grp : 1; + // byte 15 + /** not used always 1 */ + unsigned char always1 : 1; + /** checksum */ + unsigned char crc : 7; +} csd2_t; + +/** union of old and new style CSD register */ +union csd_t { + csd1_t v1; + csd2_t v2; +}; diff --git a/src/sd/SdVolume.cpp b/src/sd/SdVolume.cpp new file mode 100644 index 0000000..1b1fdc5 --- /dev/null +++ b/src/sd/SdVolume.cpp @@ -0,0 +1,405 @@ +/** + * 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 . + * + */ + +/** + * sd/SdVolume.cpp + * + * Arduino SdFat Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include "../inc/MarlinConfig.h" + +#if ENABLED(SDSUPPORT) + +#include "SdVolume.h" + +#include "../MarlinCore.h" + +#if !USE_MULTIPLE_CARDS + // raw block cache + uint32_t SdVolume::cacheBlockNumber_; // current block number + cache_t SdVolume::cacheBuffer_; // 512 byte cache for Sd2Card + DiskIODriver *SdVolume::sdCard_; // pointer to SD card object + bool SdVolume::cacheDirty_; // cacheFlush() will write block if true + uint32_t SdVolume::cacheMirrorBlock_; // mirror block for second FAT +#endif + +// find a contiguous group of clusters +bool SdVolume::allocContiguous(uint32_t count, uint32_t *curCluster) { + if (ENABLED(SDCARD_READONLY)) return false; + + // start of group + uint32_t bgnCluster; + // end of group + uint32_t endCluster; + // last cluster of FAT + uint32_t fatEnd = clusterCount_ + 1; + + // flag to save place to start next search + bool setStart; + + // set search start cluster + if (*curCluster) { + // try to make file contiguous + bgnCluster = *curCluster + 1; + + // don't save new start location + setStart = false; + } + else { + // start at likely place for free cluster + bgnCluster = allocSearchStart_; + + // save next search start if one cluster + setStart = count == 1; + } + // end of group + endCluster = bgnCluster; + + // search the FAT for free clusters + for (uint32_t n = 0;; n++, endCluster++) { + // can't find space checked all clusters + if (n >= clusterCount_) return false; + + // past end - start from beginning of FAT + if (endCluster > fatEnd) { + bgnCluster = endCluster = 2; + } + uint32_t f; + if (!fatGet(endCluster, &f)) return false; + + if (f != 0) { + // cluster in use try next cluster as bgnCluster + bgnCluster = endCluster + 1; + } + else if ((endCluster - bgnCluster + 1) == count) { + // done - found space + break; + } + } + // mark end of chain + if (!fatPutEOC(endCluster)) return false; + + // link clusters + while (endCluster > bgnCluster) { + if (!fatPut(endCluster - 1, endCluster)) return false; + endCluster--; + } + if (*curCluster != 0) { + // connect chains + if (!fatPut(*curCluster, bgnCluster)) return false; + } + // return first cluster number to caller + *curCluster = bgnCluster; + + // remember possible next free cluster + if (setStart) allocSearchStart_ = bgnCluster + 1; + + return true; +} + +bool SdVolume::cacheFlush() { + #if DISABLED(SDCARD_READONLY) + if (cacheDirty_) { + if (!sdCard_->writeBlock(cacheBlockNumber_, cacheBuffer_.data)) + return false; + + // mirror FAT tables + if (cacheMirrorBlock_) { + if (!sdCard_->writeBlock(cacheMirrorBlock_, cacheBuffer_.data)) + return false; + cacheMirrorBlock_ = 0; + } + cacheDirty_ = 0; + } + #endif + return true; +} + +bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) { + if (cacheBlockNumber_ != blockNumber) { + if (!cacheFlush()) return false; + if (!sdCard_->readBlock(blockNumber, cacheBuffer_.data)) return false; + cacheBlockNumber_ = blockNumber; + } + if (dirty) cacheDirty_ = true; + return true; +} + +// return the size in bytes of a cluster chain +bool SdVolume::chainSize(uint32_t cluster, uint32_t *size) { + uint32_t s = 0; + do { + if (!fatGet(cluster, &cluster)) return false; + s += 512UL << clusterSizeShift_; + } while (!isEOC(cluster)); + *size = s; + return true; +} + +// Fetch a FAT entry +bool SdVolume::fatGet(uint32_t cluster, uint32_t *value) { + uint32_t lba; + if (cluster > (clusterCount_ + 1)) return false; + if (FAT12_SUPPORT && fatType_ == 12) { + uint16_t index = cluster; + index += index >> 1; + lba = fatStartBlock_ + (index >> 9); + if (!cacheRawBlock(lba, CACHE_FOR_READ)) return false; + index &= 0x1FF; + uint16_t tmp = cacheBuffer_.data[index]; + index++; + if (index == 512) { + if (!cacheRawBlock(lba + 1, CACHE_FOR_READ)) return false; + index = 0; + } + tmp |= cacheBuffer_.data[index] << 8; + *value = cluster & 1 ? tmp >> 4 : tmp & 0xFFF; + return true; + } + + if (fatType_ == 16) + lba = fatStartBlock_ + (cluster >> 8); + else if (fatType_ == 32) + lba = fatStartBlock_ + (cluster >> 7); + else + return false; + + if (lba != cacheBlockNumber_ && !cacheRawBlock(lba, CACHE_FOR_READ)) + return false; + + *value = (fatType_ == 16) ? cacheBuffer_.fat16[cluster & 0xFF] : (cacheBuffer_.fat32[cluster & 0x7F] & FAT32MASK); + return true; +} + +// Store a FAT entry +bool SdVolume::fatPut(uint32_t cluster, uint32_t value) { + if (ENABLED(SDCARD_READONLY)) return false; + + uint32_t lba; + // error if reserved cluster + if (cluster < 2) return false; + + // error if not in FAT + if (cluster > (clusterCount_ + 1)) return false; + + if (FAT12_SUPPORT && fatType_ == 12) { + uint16_t index = cluster; + index += index >> 1; + lba = fatStartBlock_ + (index >> 9); + if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) return false; + // mirror second FAT + if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_; + index &= 0x1FF; + uint8_t tmp = value; + if (cluster & 1) { + tmp = (cacheBuffer_.data[index] & 0xF) | tmp << 4; + } + cacheBuffer_.data[index] = tmp; + index++; + if (index == 512) { + lba++; + index = 0; + if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) return false; + // mirror second FAT + if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_; + } + tmp = value >> 4; + if (!(cluster & 1)) { + tmp = ((cacheBuffer_.data[index] & 0xF0)) | tmp >> 4; + } + cacheBuffer_.data[index] = tmp; + return true; + } + + if (fatType_ == 16) + lba = fatStartBlock_ + (cluster >> 8); + else if (fatType_ == 32) + lba = fatStartBlock_ + (cluster >> 7); + else + return false; + + if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) return false; + + // store entry + if (fatType_ == 16) + cacheBuffer_.fat16[cluster & 0xFF] = value; + else + cacheBuffer_.fat32[cluster & 0x7F] = value; + + // mirror second FAT + if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_; + return true; +} + +// free a cluster chain +bool SdVolume::freeChain(uint32_t cluster) { + // clear free cluster location + allocSearchStart_ = 2; + + do { + uint32_t next; + if (!fatGet(cluster, &next)) return false; + + // free cluster + if (!fatPut(cluster, 0)) return false; + + cluster = next; + } while (!isEOC(cluster)); + + return true; +} + +/** Volume free space in clusters. + * + * \return Count of free clusters for success or -1 if an error occurs. + */ +int32_t SdVolume::freeClusterCount() { + uint32_t free = 0; + uint16_t n; + uint32_t todo = clusterCount_ + 2; + + if (fatType_ == 16) + n = 256; + else if (fatType_ == 32) + n = 128; + else // put FAT12 here + return -1; + + for (uint32_t lba = fatStartBlock_; todo; todo -= n, lba++) { + if (!cacheRawBlock(lba, CACHE_FOR_READ)) return -1; + NOMORE(n, todo); + if (fatType_ == 16) { + for (uint16_t i = 0; i < n; i++) + if (cacheBuffer_.fat16[i] == 0) free++; + } + else { + for (uint16_t i = 0; i < n; i++) + if (cacheBuffer_.fat32[i] == 0) free++; + } + #ifdef ESP32 + // Needed to reset the idle task watchdog timer on ESP32 as reading the complete FAT may easily + // block for 10+ seconds. yield() is insufficient since it blocks lower prio tasks (e.g., idle). + static millis_t nextTaskTime = 0; + const millis_t ms = millis(); + if (ELAPSED(ms, nextTaskTime)) { + vTaskDelay(1); // delay 1 tick (Minimum. Usually 10 or 1 ms depending on skdconfig.h) + nextTaskTime = ms + 1000; // tickle the task manager again in 1 second + } + #endif // ESP32 + } + return free; +} + +/** Initialize a FAT volume. + * + * \param[in] dev The SD card where the volume is located. + * + * \param[in] part The partition to be used. Legal values for \a part are + * 1-4 to use the corresponding partition on a device formatted with + * a MBR, Master Boot Record, or zero if the device is formatted as + * a super floppy with the FAT boot sector in block zero. + * + * \return true for success, false for failure. + * Reasons for failure include not finding a valid partition, not finding a valid + * FAT file system in the specified partition or an I/O error. + */ +bool SdVolume::init(DiskIODriver* dev, uint8_t part) { + uint32_t totalBlocks, volumeStartBlock = 0; + fat32_boot_t *fbs; + + sdCard_ = dev; + fatType_ = 0; + allocSearchStart_ = 2; + cacheDirty_ = 0; // cacheFlush() will write block if true + cacheMirrorBlock_ = 0; + cacheBlockNumber_ = 0xFFFFFFFF; + + // if part == 0 assume super floppy with FAT boot sector in block zero + // if part > 0 assume mbr volume with partition table + if (part) { + if (part > 4) return false; + if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) return false; + part_t *p = &cacheBuffer_.mbr.part[part - 1]; + if ((p->boot & 0x7F) != 0 || p->totalSectors < 100 || p->firstSector == 0) + return false; // not a valid partition + volumeStartBlock = p->firstSector; + } + if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) return false; + fbs = &cacheBuffer_.fbs32; + if (fbs->bytesPerSector != 512 || + fbs->fatCount == 0 || + fbs->reservedSectorCount == 0 || + fbs->sectorsPerCluster == 0) { + // not valid FAT volume + return false; + } + fatCount_ = fbs->fatCount; + blocksPerCluster_ = fbs->sectorsPerCluster; + // determine shift that is same as multiply by blocksPerCluster_ + clusterSizeShift_ = 0; + while (blocksPerCluster_ != _BV(clusterSizeShift_)) { + // error if not power of 2 + if (clusterSizeShift_++ > 7) return false; + } + blocksPerFat_ = fbs->sectorsPerFat16 ? + fbs->sectorsPerFat16 : fbs->sectorsPerFat32; + + fatStartBlock_ = volumeStartBlock + fbs->reservedSectorCount; + + // count for FAT16 zero for FAT32 + rootDirEntryCount_ = fbs->rootDirEntryCount; + + // directory start for FAT16 dataStart for FAT32 + rootDirStart_ = fatStartBlock_ + fbs->fatCount * blocksPerFat_; + + // data start for FAT16 and FAT32 + dataStartBlock_ = rootDirStart_ + ((32 * fbs->rootDirEntryCount + 511) / 512); + + // total blocks for FAT16 or FAT32 + totalBlocks = fbs->totalSectors16 ? + fbs->totalSectors16 : fbs->totalSectors32; + + // total data blocks + clusterCount_ = totalBlocks - (dataStartBlock_ - volumeStartBlock); + + // divide by cluster size to get cluster count + clusterCount_ >>= clusterSizeShift_; + + // FAT type is determined by cluster count + if (clusterCount_ < 4085) { + fatType_ = 12; + if (!FAT12_SUPPORT) return false; + } + else if (clusterCount_ < 65525) + fatType_ = 16; + else { + rootDirStart_ = fbs->fat32RootCluster; + fatType_ = 32; + } + return true; +} + +#endif // SDSUPPORT diff --git a/src/sd/SdVolume.h b/src/sd/SdVolume.h new file mode 100644 index 0000000..b8e70ca --- /dev/null +++ b/src/sd/SdVolume.h @@ -0,0 +1,201 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * sd/SdVolume.h + * + * Arduino SdFat Library + * Copyright (c) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + */ + +#include + +#include "../inc/MarlinConfigPre.h" + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #include "usb_flashdrive/Sd2Card_FlashDrive.h" +#endif + +#if NEED_SD2CARD_SDIO + #include "Sd2Card_sdio.h" +#elif NEED_SD2CARD_SPI + #include "Sd2Card.h" +#endif + +#include "SdFatConfig.h" +#include "SdFatStructs.h" + +//============================================================================== +// SdVolume class + +/** + * \brief Cache for an SD data block + */ +union cache_t { + uint8_t data[512]; // Used to access cached file data blocks. + uint16_t fat16[256]; // Used to access cached FAT16 entries. + uint32_t fat32[128]; // Used to access cached FAT32 entries. + dir_t dir[16]; // Used to access cached directory entries. + mbr_t mbr; // Used to access a cached Master Boot Record. + fat_boot_t fbs; // Used to access to a cached FAT boot sector. + fat32_boot_t fbs32; // Used to access to a cached FAT32 boot sector. + fat32_fsinfo_t fsinfo; // Used to access to a cached FAT32 FSINFO sector. +}; + +/** + * \class SdVolume + * \brief Access FAT16 and FAT32 volumes on SD and SDHC cards. + */ +class SdVolume { + public: + // Create an instance of SdVolume + SdVolume() : fatType_(0) {} + /** + * Clear the cache and returns a pointer to the cache. Used by the WaveRP + * recorder to do raw write to the SD card. Not for normal apps. + * \return A pointer to the cache buffer or zero if an error occurs. + */ + cache_t* cacheClear() { + if (!cacheFlush()) return 0; + cacheBlockNumber_ = 0xFFFFFFFF; + return &cacheBuffer_; + } + + /** + * Initialize a FAT volume. Try partition one first then try super + * floppy format. + * + * \param[in] dev The DiskIODriver where the volume is located. + * + * \return true for success, false for failure. + * Reasons for failure include not finding a valid partition, not finding + * a valid FAT file system or an I/O error. + */ + bool init(DiskIODriver *dev) { return init(dev, 1) || init(dev, 0); } + bool init(DiskIODriver *dev, uint8_t part); + + // inline functions that return volume info + uint8_t blocksPerCluster() const { return blocksPerCluster_; } //> \return The volume's cluster size in blocks. + uint32_t blocksPerFat() const { return blocksPerFat_; } //> \return The number of blocks in one FAT. + uint32_t clusterCount() const { return clusterCount_; } //> \return The total number of clusters in the volume. + uint8_t clusterSizeShift() const { return clusterSizeShift_; } //> \return The shift count required to multiply by blocksPerCluster. + uint32_t dataStartBlock() const { return dataStartBlock_; } //> \return The logical block number for the start of file data. + uint8_t fatCount() const { return fatCount_; } //> \return The number of FAT structures on the volume. + uint32_t fatStartBlock() const { return fatStartBlock_; } //> \return The logical block number for the start of the first FAT. + uint8_t fatType() const { return fatType_; } //> \return The FAT type of the volume. Values are 12, 16 or 32. + int32_t freeClusterCount(); + uint32_t rootDirEntryCount() const { return rootDirEntryCount_; } /** \return The number of entries in the root directory for FAT16 volumes. */ + + /** + * \return The logical block number for the start of the root directory + * on FAT16 volumes or the first cluster number on FAT32 volumes. + */ + uint32_t rootDirStart() const { return rootDirStart_; } + + /** + * DiskIODriver object for this volume + * \return pointer to DiskIODriver object. + */ + DiskIODriver* sdCard() { return sdCard_; } + + /** + * Debug access to FAT table + * + * \param[in] n cluster number. + * \param[out] v value of entry + * \return true for success or false for failure + */ + bool dbgFat(uint32_t n, uint32_t *v) { return fatGet(n, v); } + + private: + // Allow SdBaseFile access to SdVolume private data. + friend class SdBaseFile; + + // value for dirty argument in cacheRawBlock to indicate read from cache + static bool const CACHE_FOR_READ = false; + // value for dirty argument in cacheRawBlock to indicate write to cache + static bool const CACHE_FOR_WRITE = true; + + #if USE_MULTIPLE_CARDS + cache_t cacheBuffer_; // 512 byte cache for device blocks + uint32_t cacheBlockNumber_; // Logical number of block in the cache + DiskIODriver *sdCard_; // DiskIODriver object for cache + bool cacheDirty_; // cacheFlush() will write block if true + uint32_t cacheMirrorBlock_; // block number for mirror FAT + #else + static cache_t cacheBuffer_; // 512 byte cache for device blocks + static uint32_t cacheBlockNumber_; // Logical number of block in the cache + static DiskIODriver *sdCard_; // DiskIODriver object for cache + static bool cacheDirty_; // cacheFlush() will write block if true + static uint32_t cacheMirrorBlock_; // block number for mirror FAT + #endif + + uint32_t allocSearchStart_; // start cluster for alloc search + uint8_t blocksPerCluster_; // cluster size in blocks + uint32_t blocksPerFat_; // FAT size in blocks + uint32_t clusterCount_; // clusters in one FAT + uint8_t clusterSizeShift_; // shift to convert cluster count to block count + uint32_t dataStartBlock_; // first data block number + uint8_t fatCount_; // number of FATs on volume + uint32_t fatStartBlock_; // start block for first FAT + uint8_t fatType_; // volume type (12, 16, OR 32) + uint16_t rootDirEntryCount_; // number of entries in FAT16 root dir + uint32_t rootDirStart_; // root start block for FAT16, cluster for FAT32 + + bool allocContiguous(uint32_t count, uint32_t *curCluster); + uint8_t blockOfCluster(uint32_t position) const { return (position >> 9) & (blocksPerCluster_ - 1); } + uint32_t clusterStartBlock(uint32_t cluster) const { return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_); } + uint32_t blockNumber(uint32_t cluster, uint32_t position) const { return clusterStartBlock(cluster) + blockOfCluster(position); } + + cache_t* cache() { return &cacheBuffer_; } + uint32_t cacheBlockNumber() const { return cacheBlockNumber_; } + + #if USE_MULTIPLE_CARDS + bool cacheFlush(); + bool cacheRawBlock(uint32_t blockNumber, bool dirty); + #else + static bool cacheFlush(); + static bool cacheRawBlock(uint32_t blockNumber, bool dirty); + #endif + + // used by SdBaseFile write to assign cache to SD location + void cacheSetBlockNumber(uint32_t blockNumber, bool dirty) { + cacheDirty_ = dirty; + cacheBlockNumber_ = blockNumber; + } + void cacheSetDirty() { cacheDirty_ |= CACHE_FOR_WRITE; } + bool chainSize(uint32_t beginCluster, uint32_t *size); + bool fatGet(uint32_t cluster, uint32_t *value); + bool fatPut(uint32_t cluster, uint32_t value); + bool fatPutEOC(uint32_t cluster) { return fatPut(cluster, 0x0FFFFFFF); } + bool freeChain(uint32_t cluster); + bool isEOC(uint32_t cluster) const { + if (FAT12_SUPPORT && fatType_ == 12) return cluster >= FAT12EOC_MIN; + if (fatType_ == 16) return cluster >= FAT16EOC_MIN; + return cluster >= FAT32EOC_MIN; + } + bool readBlock(uint32_t block, uint8_t *dst) { return sdCard_->readBlock(block, dst); } + bool writeBlock(uint32_t block, const uint8_t *dst) { return sdCard_->writeBlock(block, dst); } +}; diff --git a/src/sd/cardreader.cpp b/src/sd/cardreader.cpp new file mode 100644 index 0000000..3fff796 --- /dev/null +++ b/src/sd/cardreader.cpp @@ -0,0 +1,1343 @@ +/** + * 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 . + * + */ + +#include "../inc/MarlinConfig.h" + +#if ENABLED(SDSUPPORT) + +//#define DEBUG_CARDREADER + +#include "cardreader.h" + +#include "../MarlinCore.h" +#include "../lcd/marlinui.h" + +#if ENABLED(DWIN_CREALITY_LCD) + #include "../lcd/e3v2/creality/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" +#endif + +#include "../module/planner.h" // for synchronize +#include "../module/printcounter.h" +#include "../gcode/queue.h" +#include "../module/settings.h" +#include "../module/stepper/indirection.h" + +#if ENABLED(EMERGENCY_PARSER) + #include "../feature/e_parser.h" +#endif + +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../feature/powerloss.h" +#endif + +#if ENABLED(ADVANCED_PAUSE_FEATURE) + #include "../feature/pause.h" +#endif + +#define DEBUG_OUT EITHER(DEBUG_CARDREADER, MARLIN_DEV_MODE) +#include "../core/debug_out.h" +#include "../libs/hex_print.h" + +// extern + +PGMSTR(M21_STR, "M21"); +PGMSTR(M23_STR, "M23 %s"); +PGMSTR(M24_STR, "M24"); + +// public: + +card_flags_t CardReader::flag; +char CardReader::filename[FILENAME_LENGTH], CardReader::longFilename[LONG_FILENAME_LENGTH]; + +IF_DISABLED(NO_SD_AUTOSTART, uint8_t CardReader::autofile_index); // = 0 + +#if ENABLED(BINARY_FILE_TRANSFER) + serial_index_t IF_DISABLED(HAS_MULTI_SERIAL, constexpr) CardReader::transfer_port_index; +#endif + +// private: + +SdFile CardReader::root, CardReader::workDir, CardReader::workDirParents[MAX_DIR_DEPTH]; +uint8_t CardReader::workDirDepth; + +#if ENABLED(SDCARD_SORT_ALPHA) + + uint16_t CardReader::sort_count; + #if ENABLED(SDSORT_GCODE) + bool CardReader::sort_alpha; + int CardReader::sort_folders; + //bool CardReader::sort_reverse; + #endif + + #if ENABLED(SDSORT_DYNAMIC_RAM) + uint8_t *CardReader::sort_order; + #else + uint8_t CardReader::sort_order[SDSORT_LIMIT]; + #endif + + #if ENABLED(SDSORT_USES_RAM) + + #if ENABLED(SDSORT_CACHE_NAMES) + uint16_t CardReader::nrFiles; // Cached total file count + #if ENABLED(SDSORT_DYNAMIC_RAM) + char **CardReader::sortshort, **CardReader::sortnames; + #else + char CardReader::sortshort[SDSORT_LIMIT][FILENAME_LENGTH]; + char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE]; + #endif + #elif DISABLED(SDSORT_USES_STACK) + char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE]; + #endif + + #if HAS_FOLDER_SORTING + #if ENABLED(SDSORT_DYNAMIC_RAM) + uint8_t *CardReader::isDir; + #elif ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK) + uint8_t CardReader::isDir[(SDSORT_LIMIT+7)>>3]; + #endif + #define IS_DIR(n) TEST(isDir[(n) >> 3], (n) & 0x07) + #endif + + #endif // SDSORT_USES_RAM + +#endif // SDCARD_SORT_ALPHA + +#if HAS_USB_FLASH_DRIVE + DiskIODriver_USBFlash CardReader::media_driver_usbFlash; +#endif + +#if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI + CardReader::sdcard_driver_t CardReader::media_driver_sdcard; +#endif + +DiskIODriver* CardReader::driver = nullptr; +SdVolume CardReader::volume; +SdFile CardReader::file; + +#if HAS_MEDIA_SUBCALLS + uint8_t CardReader::file_subcall_ctr; + uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH]; + char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH]; +#endif + +uint32_t CardReader::filesize, CardReader::sdpos; + +CardReader::CardReader() { + changeMedia(& + #if HAS_USB_FLASH_DRIVE && !SHARED_VOLUME_IS(SD_ONBOARD) + media_driver_usbFlash + #else + media_driver_sdcard + #endif + ); + + #if ENABLED(SDCARD_SORT_ALPHA) + sort_count = 0; + #if ENABLED(SDSORT_GCODE) + sort_alpha = true; + sort_folders = FOLDER_SORTING; + //sort_reverse = false; + #endif + #endif + + flag.sdprinting = flag.sdprintdone = flag.mounted = flag.saving = flag.logging = false; + filesize = sdpos = 0; + + TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0); + + IF_DISABLED(NO_SD_AUTOSTART, autofile_cancel()); + + workDirDepth = 0; + ZERO(workDirParents); + + #if BOTH(SDSUPPORT, HAS_SD_DETECT) + SET_INPUT_PULLUP(SD_DETECT_PIN); + #endif + + #if PIN_EXISTS(SDPOWER) + OUT_WRITE(SDPOWER_PIN, HIGH); // Power the SD reader + #endif +} + +// +// Get a DOS 8.3 filename in its useful form +// +char *createFilename(char * const buffer, const dir_t &p) { + char *pos = buffer; + LOOP_L_N(i, 11) { + if (p.name[i] == ' ') continue; + if (i == 8) *pos++ = '.'; + *pos++ = p.name[i]; + } + *pos++ = 0; + return buffer; +} + +// +// Return 'true' if the item is a folder, G-code file or Binary file +// +bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/)) { + //uint8_t pn0 = p.name[0]; + + #if DISABLED(CUSTOM_FIRMWARE_UPLOAD) + constexpr bool onlyBin = false; + #endif + + if ( (p.attributes & DIR_ATT_HIDDEN) // Hidden by attribute + // When readDir() > 0 these must be false: + //|| pn0 == DIR_NAME_FREE || pn0 == DIR_NAME_DELETED // Clear or Deleted entry + //|| pn0 == '.' || longFilename[0] == '.' // Hidden file + //|| !DIR_IS_FILE_OR_SUBDIR(&p) // Not a File or Directory + ) return false; + + flag.filenameIsDir = DIR_IS_SUBDIR(&p); // We know it's a File or Folder + setBinFlag(p.name[8] == 'B' && // List .bin files (a firmware file for flashing) + p.name[9] == 'I' && + p.name[10]== 'N'); + + return ( + flag.filenameIsDir // All Directories are ok + || fileIsBinary() // BIN files are accepted + || (!onlyBin && p.name[8] == 'G' + && p.name[9] != '~') // Non-backup *.G* files are accepted + ); +} + +// +// Get the number of (compliant) items in the folder +// +int CardReader::countItems(SdFile dir) { + dir_t p; + int c = 0; + while (dir.readDir(&p, longFilename) > 0) + c += is_visible_entity(p); + + #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) + nrFiles = c; + #endif + + return c; +} + +// +// Get file/folder info for an item by index +// +void CardReader::selectByIndex(SdFile dir, const uint8_t index) { + dir_t p; + for (uint8_t cnt = 0; dir.readDir(&p, longFilename) > 0;) { + if (is_visible_entity(p)) { + if (cnt == index) { + createFilename(filename, p); + return; // 0 based index + } + cnt++; + } + } +} + +// +// Get file/folder info for an item by name +// +void CardReader::selectByName(SdFile dir, const char * const match) { + dir_t p; + for (uint8_t cnt = 0; dir.readDir(&p, longFilename) > 0; cnt++) { + if (is_visible_entity(p)) { + createFilename(filename, p); + if (strcasecmp(match, filename) == 0) return; + } + } +} + +/** + * Recursive method to print all files within a folder in flat + * DOS 8.3 format. This style of listing is the most compatible + * with legacy hosts. + * + * This method recurses to unlimited depth and lists all G-code + * files within the given parent. If the hierarchy is very deep + * this can blow up the stack, so a 'depth' parameter would be a + * good addition. + */ +void CardReader::printListing( + SdFile parent, const char * const prepend + OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/) + OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) + OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong/*=nullptr*/) +) { + dir_t p; + while (parent.readDir(&p, longFilename) > 0) { + if (DIR_IS_SUBDIR(&p)) { + + size_t lenPrepend = prepend ? strlen(prepend) + 1 : 0; + // Allocate enough stack space for the full path including / separator + char path[lenPrepend + FILENAME_LENGTH]; + if (prepend) { strcpy(path, prepend); path[lenPrepend - 1] = '/'; } + char* dosFilename = path + lenPrepend; + createFilename(dosFilename, p); + + // Get a new directory object using the full path + // and dive recursively into it. + SdFile child; // child.close() in destructor + if (child.open(&parent, dosFilename, O_READ)) { + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + if (includeLongNames) { + size_t lenPrependLong = prependLong ? strlen(prependLong) + 1 : 0; + // Allocate enough stack space for the full long path including / separator + char pathLong[lenPrependLong + strlen(longFilename) + 1]; + if (prependLong) { strcpy(pathLong, prependLong); pathLong[lenPrependLong - 1] = '/'; } + strcpy(pathLong + lenPrependLong, longFilename); + printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin), true, pathLong); + } + else + printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); + #else + printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); + #endif + } + else { + SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename); + return; + } + } + else if (is_visible_entity(p OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin))) { + if (prepend) { SERIAL_ECHO(prepend); SERIAL_CHAR('/'); } + SERIAL_ECHO(createFilename(filename, p)); + SERIAL_CHAR(' '); + SERIAL_ECHO(p.fileSize); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + if (includeLongNames) { + SERIAL_CHAR(' '); + if (prependLong) { SERIAL_ECHO(prependLong); SERIAL_CHAR('/'); } + SERIAL_ECHO(longFilename[0] ? longFilename : filename); + } + #endif + SERIAL_EOL(); + } + } +} + +// +// List all files on the SD card +// +void CardReader::ls( + TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin/*=false*/) + #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) + , + #endif + TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) +) { + if (flag.mounted) { + root.rewind(); + printListing(root, nullptr OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin) OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames)); + } +} + +#if ENABLED(LONG_FILENAME_HOST_SUPPORT) + + // + // Get a long pretty path based on a DOS 8.3 path + // + void CardReader::printLongPath(char * const path) { + + int i, pathLen = path ? strlen(path) : 0; + + // SERIAL_ECHOPGM("Full Path: "); SERIAL_ECHOLN(path); + + // Zero out slashes to make segments + for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0'; + + SdFile diveDir = root; // start from the root for segment 1 + for (i = 0; i < pathLen;) { + + if (path[i] == '\0') i++; // move past a single nul + + char *segment = &path[i]; // The segment after most slashes + + // If a segment is empty (extra-slash) then exit + if (!*segment) break; + + // Go to the next segment + while (path[++i]) { } + + //SERIAL_ECHOLNPGM("Looking for segment: ", segment); + + // Find the item, setting the long filename + diveDir.rewind(); + selectByName(diveDir, segment); + + // Print /LongNamePart to serial output or the short name if not available + SERIAL_CHAR('/'); + SERIAL_ECHO(longFilename[0] ? longFilename : filename); + + // If the filename was printed then that's it + if (!flag.filenameIsDir) break; + + // SERIAL_ECHOPGM("Opening dir: "); SERIAL_ECHOLN(segment); + + // Open the sub-item as the new dive parent + SdFile dir; + if (!dir.open(&diveDir, segment, O_READ)) { + SERIAL_EOL(); + SERIAL_ECHO_START(); + SERIAL_ECHOPGM(STR_SD_CANT_OPEN_SUBDIR, segment); + break; + } + + diveDir.close(); + diveDir = dir; + + } // while iinit(SD_SPI_SPEED, SDSS) + #if defined(LCD_SDSS) && (LCD_SDSS != SDSS) + && !driver->init(SD_SPI_SPEED, LCD_SDSS) + #endif + ) SERIAL_ECHO_MSG(STR_SD_INIT_FAIL); + else if (!volume.init(driver)) + SERIAL_ERROR_MSG(STR_SD_VOL_INIT_FAIL); + else if (!root.openRoot(&volume)) + SERIAL_ERROR_MSG(STR_SD_OPENROOT_FAIL); + else { + flag.mounted = true; + SERIAL_ECHO_MSG(STR_SD_CARD_OK); + } + + if (flag.mounted) + cdroot(); + else { + #if EITHER(HAS_SD_DETECT, USB_FLASH_DRIVE_SUPPORT) + if (marlin_state != MF_INITIALIZING) LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL); + #endif + } + + ui.refresh(); +} + +/** + * Handle SD card events + */ +#if MB(FYSETC_CHEETAH, FYSETC_AIO_II) + #include "../module/stepper.h" +#endif + +void CardReader::manage_media() { + static uint8_t prev_stat = 2; // At boot we don't know if media is present or not + uint8_t stat = uint8_t(IS_SD_INSERTED()); + if (stat == prev_stat) return; // Already checked and still no change? + + DEBUG_SECTION(cmm, "CardReader::manage_media()", true); + DEBUG_ECHOLNPGM("Media present: ", prev_stat, " -> ", stat); + + if (!ui.detected()) { + DEBUG_ECHOLNPGM("SD: No UI Detected."); + return; + } + + flag.workDirIsRoot = true; // Return to root on mount/release/init + + const uint8_t old_stat = prev_stat; + prev_stat = stat; // Change now to prevent re-entry in safe_delay + + if (stat) { // Media Inserted + safe_delay(500); // Some boards need a delay to get settled + + // Try to mount the media (only later with SD_IGNORE_AT_STARTUP) + if (TERN1(SD_IGNORE_AT_STARTUP, old_stat != 2)) mount(); + if (!isMounted()) stat = 0; // Not mounted? + + TERN_(RESET_STEPPERS_ON_MEDIA_INSERT, reset_stepper_drivers()); // Workaround for Cheetah bug + } + else { + TERN_(HAS_SD_DETECT, release()); // Card is released + } + + ui.media_changed(old_stat, stat); // Update the UI or flag an error + + if (!stat) return; // Exit if no media is present + + if (old_stat != 2) return; // First mount? + + DEBUG_ECHOLNPGM("First mount."); + + // Load settings the first time media is inserted (not just during init) + TERN_(SDCARD_EEPROM_EMULATION, settings.first_load()); + + bool do_auto = true; UNUSED(do_auto); + + // Check for PLR file. + TERN_(POWER_LOSS_RECOVERY, if (recovery.check()) do_auto = false); + + // Look for auto0.g on the next idle() + IF_DISABLED(NO_SD_AUTOSTART, if (do_auto) autofile_begin()); +} + +/** + * "Release" the media by clearing the 'mounted' flag. + * Used by M22, "Release Media", manage_media. + */ +void CardReader::release() { + // Card removed while printing? Abort! + if (IS_SD_PRINTING()) + abortFilePrintSoon(); + else + endFilePrintNow(); + + flag.mounted = false; + flag.workDirIsRoot = true; + #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) + nrFiles = 0; + #endif +} + +/** + * Open a G-code file and set Marlin to start processing it. + * Enqueues M23 and M24 commands to initiate a media print. + */ +void CardReader::openAndPrintFile(const char *name) { + char cmd[4 + strlen(name) + 1 + 3 + 1]; // Room for "M23 ", filename, "\n", "M24", and null + sprintf_P(cmd, M23_STR, name); + for (char *c = &cmd[4]; *c; c++) *c = tolower(*c); + strcat_P(cmd, PSTR("\nM24")); + queue.inject(cmd); +} + +/** + * Start or resume a media print by setting the sdprinting flag. + * The file browser pre-sort is also purged to free up memory, + * since you cannot browse files during active printing. + * Used by M24 and anywhere Start / Resume applies. + */ +void CardReader::startOrResumeFilePrinting() { + if (isMounted()) { + flag.sdprinting = true; + flag.sdprintdone = false; + TERN_(SD_RESORT, flush_presort()); + } +} + +// +// Run tasks upon finishing or aborting a file print. +// +void CardReader::endFilePrintNow(TERN_(SD_RESORT, const bool re_sort/*=false*/)) { + TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0); + TERN_(HAS_DWIN_E3V2_BASIC, HMI_flag.print_finish = flag.sdprinting); + flag.abort_sd_printing = false; + if (isFileOpen()) file.close(); + TERN_(SD_RESORT, if (re_sort) presort()); +} + +void CardReader::abortFilePrintNow(TERN_(SD_RESORT, const bool re_sort/*=false*/)) { + flag.sdprinting = flag.sdprintdone = false; + endFilePrintNow(TERN_(SD_RESORT, re_sort)); +} + +void CardReader::openLogFile(const char * const path) { + flag.logging = DISABLED(SDCARD_READONLY); + IF_DISABLED(SDCARD_READONLY, openFileWrite(path)); +} + +// +// Get the root-relative DOS path of the selected file +// +void CardReader::getAbsFilenameInCWD(char *dst) { + *dst++ = '/'; + uint8_t cnt = 1; + + auto appendAtom = [&](SdFile &file) { + file.getDosName(dst); + while (*dst && cnt < MAXPATHNAMELENGTH) { dst++; cnt++; } + if (cnt < MAXPATHNAMELENGTH) { *dst = '/'; dst++; cnt++; } + }; + + LOOP_L_N(i, workDirDepth) // Loop down to current work dir + appendAtom(workDirParents[i]); + + if (cnt < MAXPATHNAMELENGTH - (FILENAME_LENGTH) - 1) { // Leave room for filename and nul + appendAtom(file); + --dst; + } + *dst = '\0'; +} + +void openFailed(const char * const fname) { + SERIAL_ECHOLNPGM(STR_SD_OPEN_FILE_FAIL, fname, "."); +} + +void announceOpen(const uint8_t doing, const char * const path) { + if (doing) { + PORT_REDIRECT(SerialMask::All); + SERIAL_ECHO_START(); + SERIAL_ECHOPGM("Now "); + SERIAL_ECHOF(doing == 1 ? F("doing") : F("fresh")); + SERIAL_ECHOLNPGM(" file: ", path); + } +} + +// +// Open a file by DOS path for read +// The 'subcall_type' flag indicates... +// - 0 : Standard open from host or user interface. +// - 1 : (file open) Opening a new sub-procedure. +// - 1 : (no file open) Opening a macro (M98). +// - 2 : Resuming from a sub-procedure +// +void CardReader::openFileRead(const char * const path, const uint8_t subcall_type/*=0*/) { + if (!isMounted()) return; + + switch (subcall_type) { + case 0: // Starting a new print. "Now fresh file: ..." + announceOpen(2, path); + TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0); + break; + + #if HAS_MEDIA_SUBCALLS + + case 1: // Starting a sub-procedure + + // With no file is open it's a simple macro. "Now doing file: ..." + if (!isFileOpen()) { announceOpen(1, path); break; } + + // Too deep? The firmware has to bail. + if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) { + SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:", SD_PROCEDURE_DEPTH); + kill(GET_TEXT_F(MSG_KILL_SUBCALL_OVERFLOW)); + return; + } + + // Store current filename (based on workDirParents) and position + getAbsFilenameInCWD(proc_filenames[file_subcall_ctr]); + filespos[file_subcall_ctr] = sdpos; + + // For sub-procedures say 'SUBROUTINE CALL target: "..." parent: "..." pos12345' + SERIAL_ECHO_MSG("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos); + file_subcall_ctr++; + break; + + case 2: // Resuming previous file after sub-procedure + SERIAL_ECHO_MSG("END SUBROUTINE"); + break; + + #endif + } + + abortFilePrintNow(); + + SdFile *diveDir; + const char * const fname = diveToFile(true, diveDir, path); + if (!fname) return; + + if (file.open(diveDir, fname, O_READ)) { + filesize = file.fileSize(); + sdpos = 0; + + { // Don't remove this block, as the PORT_REDIRECT is a RAII + PORT_REDIRECT(SerialMask::All); + SERIAL_ECHOLNPGM(STR_SD_FILE_OPENED, fname, STR_SD_SIZE, filesize); + SERIAL_ECHOLNPGM(STR_SD_FILE_SELECTED); + } + + selectFileByName(fname); + ui.set_status(longFilename[0] ? longFilename : fname); + } + else + openFailed(fname); +} + +inline void echo_write_to_file(const char * const fname) { + SERIAL_ECHOLNPGM(STR_SD_WRITE_TO_FILE, fname); +} + +// +// Open a file by DOS path for write +// +void CardReader::openFileWrite(const char * const path) { + if (!isMounted()) return; + + announceOpen(2, path); + TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0); + + abortFilePrintNow(); + + SdFile *diveDir; + const char * const fname = diveToFile(false, diveDir, path); + if (!fname) return; + + #if ENABLED(SDCARD_READONLY) + openFailed(fname); + #else + if (file.open(diveDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { + flag.saving = true; + selectFileByName(fname); + TERN_(EMERGENCY_PARSER, emergency_parser.disable()); + echo_write_to_file(fname); + ui.set_status(fname); + } + else + openFailed(fname); + #endif +} + +// +// Check if a file exists by absolute or workDir-relative path +// If the file exists, the long name can also be fetched. +// +bool CardReader::fileExists(const char * const path) { + if (!isMounted()) return false; + + DEBUG_ECHOLNPGM("fileExists: ", path); + + // Dive to the file's directory and get the base name + SdFile *diveDir = nullptr; + const char * const fname = diveToFile(false, diveDir, path); + if (!fname) return false; + + // Get the longname of the checked file + //diveDir->rewind(); + //selectByName(*diveDir, fname); + //diveDir->close(); + + // Try to open the file and return the result + SdFile tmpFile; + const bool success = tmpFile.open(diveDir, fname, O_READ); + if (success) tmpFile.close(); + return success; +} + +// +// Delete a file by name in the working directory +// +void CardReader::removeFile(const char * const name) { + if (!isMounted()) return; + + //abortFilePrintNow(); + + SdFile *itsDirPtr; + const char * const fname = diveToFile(false, itsDirPtr, name); + if (!fname) return; + + #if ENABLED(SDCARD_READONLY) + SERIAL_ECHOLNPGM("Deletion failed (read-only), File: ", fname, "."); + #else + if (file.remove(itsDirPtr, fname)) { + SERIAL_ECHOLNPGM("File deleted:", fname); + sdpos = 0; + TERN_(SDCARD_SORT_ALPHA, presort()); + } + else + SERIAL_ECHOLNPGM("Deletion failed, File: ", fname, "."); + #endif +} + +void CardReader::report_status() { + if (isPrinting()) { + SERIAL_ECHOPGM(STR_SD_PRINTING_BYTE, sdpos); + SERIAL_CHAR('/'); + SERIAL_ECHOLN(filesize); + } + else + SERIAL_ECHOLNPGM(STR_SD_NOT_PRINTING); +} + +void CardReader::write_command(char * const buf) { + char *begin = buf, + *npos = nullptr, + *end = buf + strlen(buf) - 1; + + file.writeError = false; + if ((npos = strchr(buf, 'N'))) { + begin = strchr(npos, ' ') + 1; + end = strchr(npos, '*') - 1; + } + end[1] = '\r'; + end[2] = '\n'; + end[3] = '\0'; + file.write(begin); + + if (file.writeError) SERIAL_ERROR_MSG(STR_SD_ERR_WRITE_TO_FILE); +} + +#if DISABLED(NO_SD_AUTOSTART) + /** + * Run all the auto#.g files. Called: + * - On boot after successful card init. + * - From the LCD command to Run Auto Files + */ + void CardReader::autofile_begin() { + autofile_index = 1; + (void)autofile_check(); + } + + /** + * Run the next auto#.g file. Called: + * - On boot after successful card init + * - After finishing the previous auto#.g file + * - From the LCD command to begin the auto#.g files + * + * Return 'true' if an auto file was started + */ + bool CardReader::autofile_check() { + if (!autofile_index) return false; + + if (!isMounted()) + mount(); + else if (ENABLED(SDCARD_EEPROM_EMULATION)) + settings.first_load(); + + // Don't run auto#.g when a PLR file exists + if (isMounted() && TERN1(POWER_LOSS_RECOVERY, !recovery.valid())) { + char autoname[10]; + sprintf_P(autoname, PSTR("/auto%c.g"), '0' + autofile_index - 1); + if (fileExists(autoname)) { + cdroot(); + openAndPrintFile(autoname); + autofile_index++; + return true; + } + } + autofile_cancel(); + return false; + } +#endif + +void CardReader::closefile(const bool store_location/*=false*/) { + file.sync(); + file.close(); + flag.saving = flag.logging = false; + sdpos = 0; + TERN_(EMERGENCY_PARSER, emergency_parser.enable()); + + if (store_location) { + //future: store printer state, filename and position for continuing a stopped print + // so one can unplug the printer and continue printing the next day. + } +} + +// +// Get info for a file in the working directory by index +// +void CardReader::selectFileByIndex(const uint16_t nr) { + #if ENABLED(SDSORT_CACHE_NAMES) + if (nr < sort_count) { + strcpy(filename, sortshort[nr]); + strcpy(longFilename, sortnames[nr]); + flag.filenameIsDir = IS_DIR(nr); + setBinFlag(strcmp_P(strrchr(filename, '.'), PSTR(".BIN")) == 0); + return; + } + #endif + workDir.rewind(); + selectByIndex(workDir, nr); +} + +// +// Get info for a file in the working directory by DOS name +// +void CardReader::selectFileByName(const char * const match) { + #if ENABLED(SDSORT_CACHE_NAMES) + for (uint16_t nr = 0; nr < sort_count; nr++) + if (strcasecmp(match, sortshort[nr]) == 0) { + strcpy(filename, sortshort[nr]); + strcpy(longFilename, sortnames[nr]); + flag.filenameIsDir = IS_DIR(nr); + setBinFlag(strcmp_P(strrchr(filename, '.'), PSTR(".BIN")) == 0); + return; + } + #endif + workDir.rewind(); + selectByName(workDir, match); +} + +uint16_t CardReader::countFilesInWorkDir() { + workDir.rewind(); + return countItems(workDir); +} + +/** + * Dive to the given DOS 8.3 file path, with optional echo of the dive paths. + * + * On entry: + * - The workDir points to the last-set navigation target by cd, cdup, cdroot, or diveToFile(true, ...) + * + * On exit: + * - Your curDir pointer contains an SdFile reference to the file's directory. + * - If update_cwd was 'true' the workDir now points to the file's directory. + * + * Returns a pointer to the last segment (filename) of the given DOS 8.3 path. + * On exit, inDirPtr contains an SdFile reference to the file's directory. + * + * A nullptr result indicates an unrecoverable error. + * + * NOTE: End the path with a slash to dive to a folder. In this case the + * returned filename will be blank (points to the end of the path). + */ +const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, const char * const path, const bool echo/*=false*/) { + DEBUG_SECTION(est, "diveToFile", true); + + // Track both parent and subfolder + static SdFile newDir1, newDir2; + SdFile *sub = &newDir1, *startDirPtr; + + // Parsing the path string + const char *atom_ptr = path; + + DEBUG_ECHOLNPGM(" path = '", path, "'"); + + if (path[0] == '/') { // Starting at the root directory? + inDirPtr = &root; + atom_ptr++; + DEBUG_ECHOLNPGM(" CWD to root: ", hex_address((void*)inDirPtr)); + if (update_cwd) workDirDepth = 0; // The cwd can be updated for the benefit of sub-programs + } + else + inDirPtr = &workDir; // Dive from workDir (as set by the UI) + + startDirPtr = inDirPtr; + + DEBUG_ECHOLNPGM(" startDirPtr = ", hex_address((void*)startDirPtr)); + + while (atom_ptr) { + // Find next subdirectory delimiter + const char * const name_end = strchr(atom_ptr, '/'); + + // Last atom in the path? Item found. + if (name_end <= atom_ptr) break; + + // Isolate the next subitem name + const uint8_t len = name_end - atom_ptr; + char dosSubdirname[len + 1]; + strncpy(dosSubdirname, atom_ptr, len); + dosSubdirname[len] = 0; + + if (echo) SERIAL_ECHOLN(dosSubdirname); + + DEBUG_ECHOLNPGM(" sub = ", hex_address((void*)sub)); + + // Open inDirPtr (closing first) + sub->close(); + if (!sub->open(inDirPtr, dosSubdirname, O_READ)) { + openFailed(dosSubdirname); + atom_ptr = nullptr; + break; + } + + // Close inDirPtr if not at starting-point + if (inDirPtr != startDirPtr) { + DEBUG_ECHOLNPGM(" closing inDirPtr: ", hex_address((void*)inDirPtr)); + inDirPtr->close(); + } + + // inDirPtr now subDir + inDirPtr = sub; + DEBUG_ECHOLNPGM(" inDirPtr = sub: ", hex_address((void*)inDirPtr)); + + // Update workDirParents and workDirDepth + if (update_cwd) { + DEBUG_ECHOLNPGM(" update_cwd"); + if (workDirDepth < MAX_DIR_DEPTH) + workDirParents[workDirDepth++] = *inDirPtr; + } + + // Point sub at the other scratch object + sub = (inDirPtr != &newDir1) ? &newDir1 : &newDir2; + DEBUG_ECHOLNPGM(" swapping sub = ", hex_address((void*)sub)); + + // Next path atom address + atom_ptr = name_end + 1; + } + + if (update_cwd) { + workDir = *inDirPtr; + DEBUG_ECHOLNPGM(" final workDir = ", hex_address((void*)inDirPtr)); + flag.workDirIsRoot = (workDirDepth == 0); + TERN_(SDCARD_SORT_ALPHA, presort()); + } + + DEBUG_ECHOLNPGM(" returning string ", atom_ptr ?: "nullptr"); + return atom_ptr; +} + +void CardReader::cd(const char * relpath) { + SdFile newDir, *parent = &getWorkDir(); + + if (newDir.open(parent, relpath, O_READ)) { + workDir = newDir; + flag.workDirIsRoot = false; + if (workDirDepth < MAX_DIR_DEPTH) + workDirParents[workDirDepth++] = workDir; + TERN_(SDCARD_SORT_ALPHA, presort()); + } + else + SERIAL_ECHO_MSG(STR_SD_CANT_ENTER_SUBDIR, relpath); +} + +int8_t CardReader::cdup() { + if (workDirDepth > 0) { // At least 1 dir has been saved + workDir = --workDirDepth ? workDirParents[workDirDepth - 1] : root; // Use parent, or root if none + TERN_(SDCARD_SORT_ALPHA, presort()); + } + if (!workDirDepth) flag.workDirIsRoot = true; + return workDirDepth; +} + +void CardReader::cdroot() { + workDir = root; + flag.workDirIsRoot = true; + workDirDepth = 0; + TERN_(SDCARD_SORT_ALPHA, presort()); +} + +#if ENABLED(SDCARD_SORT_ALPHA) + + /** + * Get the name of a file in the working directory by sort-index + */ + void CardReader::getfilename_sorted(const uint16_t nr) { + selectFileByIndex(TERN1(SDSORT_GCODE, sort_alpha) && (nr < sort_count) + ? sort_order[nr] : nr); + } + + #if ENABLED(SDSORT_USES_RAM) + #if ENABLED(SDSORT_DYNAMIC_RAM) + // Use dynamic method to copy long filename + #define SET_SORTNAME(I) (sortnames[I] = strdup(longest_filename())) + #if ENABLED(SDSORT_CACHE_NAMES) + // When caching also store the short name, since + // we're replacing the selectFileByIndex() behavior. + #define SET_SORTSHORT(I) (sortshort[I] = strdup(filename)) + #else + #define SET_SORTSHORT(I) NOOP + #endif + #else + // Copy filenames into the static array + #define _SET_SORTNAME(I) strncpy(sortnames[I], longest_filename(), SORTED_LONGNAME_MAXLEN) + #if SORTED_LONGNAME_MAXLEN == LONG_FILENAME_LENGTH + // Short name sorting always use LONG_FILENAME_LENGTH with no trailing nul + #define SET_SORTNAME(I) _SET_SORTNAME(I) + #else + // Copy multiple name blocks. Add a nul for the longest case. + #define SET_SORTNAME(I) do{ _SET_SORTNAME(I); sortnames[I][SORTED_LONGNAME_MAXLEN] = '\0'; }while(0) + #endif + #if ENABLED(SDSORT_CACHE_NAMES) + #define SET_SORTSHORT(I) strcpy(sortshort[I], filename) + #else + #define SET_SORTSHORT(I) NOOP + #endif + #endif + #endif + + /** + * Read all the files and produce a sort key + * + * We can do this in 3 ways... + * - Minimal RAM: Read two filenames at a time sorting along... + * - Some RAM: Buffer the directory just for this sort + * - Most RAM: Buffer the directory and return filenames from RAM + */ + void CardReader::presort() { + + // Throw away old sort index + flush_presort(); + + // Sorting may be turned off + if (TERN0(SDSORT_GCODE, !sort_alpha)) return; + + // If there are files, sort up to the limit + uint16_t fileCnt = countFilesInWorkDir(); + if (fileCnt > 0) { + + // Never sort more than the max allowed + // If you use folders to organize, 20 may be enough + NOMORE(fileCnt, uint16_t(SDSORT_LIMIT)); + + // Sort order is always needed. May be static or dynamic. + TERN_(SDSORT_DYNAMIC_RAM, sort_order = new uint8_t[fileCnt]); + + // Use RAM to store the entire directory during pre-sort. + // SDSORT_LIMIT should be set to prevent over-allocation. + #if ENABLED(SDSORT_USES_RAM) + + // If using dynamic ram for names, allocate on the heap. + #if ENABLED(SDSORT_CACHE_NAMES) + #if ENABLED(SDSORT_DYNAMIC_RAM) + sortshort = new char*[fileCnt]; + sortnames = new char*[fileCnt]; + #endif + #elif ENABLED(SDSORT_USES_STACK) + char sortnames[fileCnt][SORTED_LONGNAME_STORAGE]; + #endif + + // Folder sorting needs 1 bit per entry for flags. + #if HAS_FOLDER_SORTING + #if ENABLED(SDSORT_DYNAMIC_RAM) + isDir = new uint8_t[(fileCnt + 7) >> 3]; + #elif ENABLED(SDSORT_USES_STACK) + uint8_t isDir[(fileCnt + 7) >> 3]; + #endif + #endif + + #else // !SDSORT_USES_RAM + + // By default re-read the names from SD for every compare + // retaining only two filenames at a time. This is very + // slow but is safest and uses minimal RAM. + char name1[LONG_FILENAME_LENGTH]; + + #endif + + if (fileCnt > 1) { + + // Init sort order. + for (uint16_t i = 0; i < fileCnt; i++) { + sort_order[i] = i; + // If using RAM then read all filenames now. + #if ENABLED(SDSORT_USES_RAM) + selectFileByIndex(i); + SET_SORTNAME(i); + SET_SORTSHORT(i); + //char out[30]; + //sprintf_P(out, PSTR("---- %i %s %s"), i, flag.filenameIsDir ? "D" : " ", sortnames[i]); + //SERIAL_ECHOLN(out); + #if HAS_FOLDER_SORTING + const uint16_t bit = i & 0x07, ind = i >> 3; + if (bit == 0) isDir[ind] = 0x00; + if (flag.filenameIsDir) SBI(isDir[ind], bit); + #endif + #endif + } + + // Bubble Sort + for (uint16_t i = fileCnt; --i;) { + bool didSwap = false; + uint8_t o1 = sort_order[0]; + #if DISABLED(SDSORT_USES_RAM) + selectFileByIndex(o1); // Pre-fetch the first entry and save it + strcpy(name1, longest_filename()); // so the loop only needs one fetch + #if HAS_FOLDER_SORTING + bool dir1 = flag.filenameIsDir; + #endif + #endif + + for (uint16_t j = 0; j < i; ++j) { + const uint16_t o2 = sort_order[j + 1]; + + // Compare names from the array or just the two buffered names + #if ENABLED(SDSORT_USES_RAM) + #define _SORT_CMP_NODIR() (strcasecmp(sortnames[o1], sortnames[o2]) > 0) + #else + #define _SORT_CMP_NODIR() (strcasecmp(name1, name2) > 0) + #endif + + #if HAS_FOLDER_SORTING + #if ENABLED(SDSORT_USES_RAM) + // Folder sorting needs an index and bit to test for folder-ness. + #define _SORT_CMP_DIR(fs) (IS_DIR(o1) == IS_DIR(o2) ? _SORT_CMP_NODIR() : IS_DIR(fs > 0 ? o1 : o2)) + #else + #define _SORT_CMP_DIR(fs) ((dir1 == flag.filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1)) + #endif + #endif + + // The most economical method reads names as-needed + // throughout the loop. Slow if there are many. + #if DISABLED(SDSORT_USES_RAM) + selectFileByIndex(o2); + const bool dir2 = flag.filenameIsDir; + char * const name2 = longest_filename(); // use the string in-place + #endif // !SDSORT_USES_RAM + + // Sort the current pair according to settings. + if ( + #if HAS_FOLDER_SORTING + #if ENABLED(SDSORT_GCODE) + sort_folders ? _SORT_CMP_DIR(sort_folders) : _SORT_CMP_NODIR() + #else + _SORT_CMP_DIR(FOLDER_SORTING) + #endif + #else + _SORT_CMP_NODIR() + #endif + ) { + // Reorder the index, indicate that sorting happened + // Note that the next o1 will be the current o1. No new fetch needed. + sort_order[j] = o2; + sort_order[j + 1] = o1; + didSwap = true; + } + else { + // The next o1 is the current o2. No new fetch needed. + o1 = o2; + #if DISABLED(SDSORT_USES_RAM) + TERN_(HAS_FOLDER_SORTING, dir1 = dir2); + strcpy(name1, name2); + #endif + } + } + if (!didSwap) break; + } + // Using RAM but not keeping names around + #if ENABLED(SDSORT_USES_RAM) && DISABLED(SDSORT_CACHE_NAMES) + #if ENABLED(SDSORT_DYNAMIC_RAM) + for (uint16_t i = 0; i < fileCnt; ++i) free(sortnames[i]); + TERN_(HAS_FOLDER_SORTING, delete [] isDir); + #endif + #endif + } + else { + sort_order[0] = 0; + #if BOTH(SDSORT_USES_RAM, SDSORT_CACHE_NAMES) + #if ENABLED(SDSORT_DYNAMIC_RAM) + sortnames = new char*[1]; + sortshort = new char*[1]; + isDir = new uint8_t[1]; + #endif + selectFileByIndex(0); + SET_SORTNAME(0); + SET_SORTSHORT(0); + isDir[0] = flag.filenameIsDir; + #endif + } + + sort_count = fileCnt; + } + } + + void CardReader::flush_presort() { + if (sort_count > 0) { + #if ENABLED(SDSORT_DYNAMIC_RAM) + delete [] sort_order; + #if ENABLED(SDSORT_CACHE_NAMES) + LOOP_L_N(i, sort_count) { + free(sortshort[i]); // strdup + free(sortnames[i]); // strdup + } + delete [] sortshort; + delete [] sortnames; + #endif + #endif + sort_count = 0; + } + } + +#endif // SDCARD_SORT_ALPHA + +uint16_t CardReader::get_num_Files() { + if (!isMounted()) return 0; + return ( + #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) + nrFiles // no need to access the SD card for filenames + #else + countFilesInWorkDir() + #endif + ); +} + +// +// Return from procedure or close out the Print Job +// +void CardReader::fileHasFinished() { + file.close(); + #if HAS_MEDIA_SUBCALLS + if (file_subcall_ctr > 0) { // Resume calling file after closing procedure + file_subcall_ctr--; + openFileRead(proc_filenames[file_subcall_ctr], 2); // 2 = Returning from sub-procedure + setIndex(filespos[file_subcall_ctr]); + startOrResumeFilePrinting(); + return; + } + #endif + + endFilePrintNow(TERN_(SD_RESORT, true)); + + flag.sdprintdone = true; // Stop getting bytes from the SD card + marlin_state = MF_SD_COMPLETE; // Tell Marlin to enqueue M1001 soon +} + +#if ENABLED(AUTO_REPORT_SD_STATUS) + AutoReporter CardReader::auto_reporter; +#endif + +#if ENABLED(POWER_LOSS_RECOVERY) + + bool CardReader::jobRecoverFileExists() { + const bool exists = recovery.file.open(&root, recovery.filename, O_READ); + if (exists) recovery.file.close(); + return exists; + } + + void CardReader::openJobRecoveryFile(const bool read) { + if (!isMounted()) return; + if (recovery.file.isOpen()) return; + if (!recovery.file.open(&root, recovery.filename, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC)) + openFailed(recovery.filename); + else if (!read) + echo_write_to_file(recovery.filename); + } + + // Removing the job recovery file currently requires closing + // the file being printed, so during SD printing the file should + // be zeroed and written instead of deleted. + void CardReader::removeJobRecoveryFile() { + if (jobRecoverFileExists()) { + recovery.init(); + removeFile(recovery.filename); + #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) + SERIAL_ECHOPGM("Power-loss file delete"); + SERIAL_ECHOF(jobRecoverFileExists() ? F(" failed.\n") : F("d.\n")); + #endif + } + } + +#endif // POWER_LOSS_RECOVERY + +#endif // SDSUPPORT diff --git a/src/sd/cardreader.h b/src/sd/cardreader.h new file mode 100644 index 0000000..d2f462c --- /dev/null +++ b/src/sd/cardreader.h @@ -0,0 +1,388 @@ +/** + * 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 . + * + */ +#pragma once + +#include "../inc/MarlinConfig.h" + +#if ENABLED(SDSUPPORT) + +extern const char M23_STR[], M24_STR[]; + +#if ENABLED(SDCARD_SORT_ALPHA) + #if ENABLED(SDSORT_DYNAMIC_RAM) + #define SD_RESORT 1 + #endif + #if FOLDER_SORTING || ENABLED(SDSORT_GCODE) + #define HAS_FOLDER_SORTING 1 + #endif +#endif + +#if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA) + #define SD_ORDER(N,C) ((C) - 1 - (N)) +#else + #define SD_ORDER(N,C) N +#endif + +#define MAX_DIR_DEPTH 10 // Maximum folder depth +#define MAXDIRNAMELENGTH 8 // DOS folder name size +#define MAXPATHNAMELENGTH (1 + (MAXDIRNAMELENGTH + 1) * (MAX_DIR_DEPTH) + 1 + FILENAME_LENGTH) // "/" + N * ("ADIRNAME/") + "filename.ext" + +#include "SdFile.h" +#include "disk_io_driver.h" + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #include "usb_flashdrive/Sd2Card_FlashDrive.h" +#endif + +#if NEED_SD2CARD_SDIO + #include "Sd2Card_sdio.h" +#elif NEED_SD2CARD_SPI + #include "Sd2Card.h" +#endif + +#if ENABLED(MULTI_VOLUME) + #define SV_SD_ONBOARD 1 + #define SV_USB_FLASH_DRIVE 2 + #define _VOLUME_ID(N) _CAT(SV_, N) + #define SHARED_VOLUME_IS(N) (DEFAULT_SHARED_VOLUME == _VOLUME_ID(N)) + #if !SHARED_VOLUME_IS(SD_ONBOARD) && !SHARED_VOLUME_IS(USB_FLASH_DRIVE) + #error "DEFAULT_SHARED_VOLUME must be either SD_ONBOARD or USB_FLASH_DRIVE." + #endif +#else + #define SHARED_VOLUME_IS(...) 0 +#endif + +typedef struct { + bool saving:1, + logging:1, + sdprinting:1, + sdprintdone:1, + mounted:1, + filenameIsDir:1, + workDirIsRoot:1, + abort_sd_printing:1 + #if DO_LIST_BIN_FILES + , filenameIsBin:1 + #endif + #if ENABLED(BINARY_FILE_TRANSFER) + , binary_mode:1 + #endif + ; +} card_flags_t; + +#if ENABLED(AUTO_REPORT_SD_STATUS) + #include "../libs/autoreport.h" +#endif + +class CardReader { +public: + static card_flags_t flag; // Flags (above) + static char filename[FILENAME_LENGTH], // DOS 8.3 filename of the selected item + longFilename[LONG_FILENAME_LENGTH]; // Long name of the selected item + + // Fast! binary file transfer + #if ENABLED(BINARY_FILE_TRANSFER) + #if HAS_MULTI_SERIAL + static serial_index_t transfer_port_index; + #else + static constexpr serial_index_t transfer_port_index = 0; + #endif + #endif + + // // // Methods // // // + + CardReader(); + + static void changeMedia(DiskIODriver *_driver) { driver = _driver; } + + static SdFile getroot() { return root; } + + static void mount(); + static void release(); + static bool isMounted() { return flag.mounted; } + + // Handle media insert/remove + static void manage_media(); + + // SD Card Logging + static void openLogFile(const char * const path); + static void write_command(char * const buf); + + #if DISABLED(NO_SD_AUTOSTART) // Auto-Start auto#.g file handling + static uint8_t autofile_index; // Next auto#.g index to run, plus one. Ignored by autofile_check when zero. + static void autofile_begin(); // Begin check. Called automatically after boot-up. + static bool autofile_check(); // Check for the next auto-start file and run it. + static void autofile_cancel() { autofile_index = 0; } + #endif + + // Basic file ops + static void openFileRead(const char * const path, const uint8_t subcall=0); + static void openFileWrite(const char * const path); + static void closefile(const bool store_location=false); + static bool fileExists(const char * const name); + static void removeFile(const char * const name); + + static char* longest_filename() { return longFilename[0] ? longFilename : filename; } + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + static void printLongPath(char * const path); // Used by M33 + #endif + + // Working Directory for SD card menu + static void cdroot(); + static void cd(const char *relpath); + static int8_t cdup(); + static uint16_t countFilesInWorkDir(); + static uint16_t get_num_Files(); + + // Select a file + static void selectFileByIndex(const uint16_t nr); + static void selectFileByName(const char * const match); // (working directory only) + + // Print job + static void report_status(); + static void getAbsFilenameInCWD(char *dst); + static void printSelectedFilename(); + static void openAndPrintFile(const char *name); // (working directory or full path) + static void startOrResumeFilePrinting(); + static void endFilePrintNow(TERN_(SD_RESORT, const bool re_sort=false)); + static void abortFilePrintNow(TERN_(SD_RESORT, const bool re_sort=false)); + static void fileHasFinished(); + static void abortFilePrintSoon() { flag.abort_sd_printing = isFileOpen(); } + static void pauseSDPrint() { flag.sdprinting = false; } + static bool isPrinting() { return flag.sdprinting; } + static bool isPaused() { return isFileOpen() && !isPrinting(); } + #if HAS_PRINT_PROGRESS_PERMYRIAD + static uint16_t permyriadDone() { + if (flag.sdprintdone) return 10000; + if (isFileOpen() && filesize) return sdpos / ((filesize + 9999) / 10000); + return 0; + } + #endif + static uint8_t percentDone() { + if (flag.sdprintdone) return 100; + if (isFileOpen() && filesize) return sdpos / ((filesize + 99) / 100); + return 0; + } + + /** + * Dive down to a relative or absolute path. + * Relative paths apply to the workDir. + * + * update_cwd: Pass 'true' to update the workDir on success. + * inDirPtr: On exit your pointer points to the target SdFile. + * A nullptr indicates failure. + * path: Start with '/' for abs path. End with '/' to get a folder ref. + * echo: Set 'true' to print the path throughout the loop. + */ + static const char* diveToFile(const bool update_cwd, SdFile* &inDirPtr, const char * const path, const bool echo=false); + + #if ENABLED(SDCARD_SORT_ALPHA) + static void presort(); + static void getfilename_sorted(const uint16_t nr); + #if ENABLED(SDSORT_GCODE) + FORCE_INLINE static void setSortOn(bool b) { sort_alpha = b; presort(); } + FORCE_INLINE static void setSortFolders(int i) { sort_folders = i; presort(); } + //FORCE_INLINE static void setSortReverse(bool b) { sort_reverse = b; } + #endif + #else + FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); } + #endif + + static void ls( + TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false) + #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) + , + #endif + TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) + ); + + #if ENABLED(POWER_LOSS_RECOVERY) + static bool jobRecoverFileExists(); + static void openJobRecoveryFile(const bool read); + static void removeJobRecoveryFile(); + #endif + + // Binary flag for the current file + static bool fileIsBinary() { return TERN0(DO_LIST_BIN_FILES, flag.filenameIsBin); } + static void setBinFlag(const bool bin) { TERN(DO_LIST_BIN_FILES, flag.filenameIsBin = bin, UNUSED(bin)); } + + // Current Working Dir - Set by cd, cdup, cdroot, and diveToFile(true, ...) + static char* getWorkDirName() { workDir.getDosName(filename); return filename; } + static SdFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } + + // Print File stats + static uint32_t getFileSize() { return filesize; } + static uint32_t getIndex() { return sdpos; } + static bool isFileOpen() { return isMounted() && file.isOpen(); } + static bool eof() { return getIndex() >= getFileSize(); } + + // File data operations + static int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; } + static int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; } + static int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } + static void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); } + + // TODO: rename to diskIODriver() + static DiskIODriver* diskIODriver() { return driver; } + + #if ENABLED(AUTO_REPORT_SD_STATUS) + // + // SD Auto Reporting + // + struct AutoReportSD { static void report() { report_status(); } }; + static AutoReporter auto_reporter; + #endif + + #if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) + #define HAS_USB_FLASH_DRIVE 1 + static DiskIODriver_USBFlash media_driver_usbFlash; + #endif + + #if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI + typedef TERN(NEED_SD2CARD_SDIO, DiskIODriver_SDIO, DiskIODriver_SPI_SD) sdcard_driver_t; + static sdcard_driver_t media_driver_sdcard; + #endif + +private: + // + // Working directory and parents + // + static SdFile root, workDir, workDirParents[MAX_DIR_DEPTH]; + static uint8_t workDirDepth; + + // + // Alphabetical file and folder sorting + // + #if ENABLED(SDCARD_SORT_ALPHA) + static uint16_t sort_count; // Count of sorted items in the current directory + #if ENABLED(SDSORT_GCODE) + static bool sort_alpha; // Flag to enable / disable the feature + static int sort_folders; // Folder sorting before/none/after + //static bool sort_reverse; // Flag to enable / disable reverse sorting + #endif + + // By default the sort index is static + #if ENABLED(SDSORT_DYNAMIC_RAM) + static uint8_t *sort_order; + #else + static uint8_t sort_order[SDSORT_LIMIT]; + #endif + + #if BOTH(SDSORT_USES_RAM, SDSORT_CACHE_NAMES) && DISABLED(SDSORT_DYNAMIC_RAM) + #define SORTED_LONGNAME_MAXLEN (SDSORT_CACHE_VFATS) * (FILENAME_LENGTH) + #define SORTED_LONGNAME_STORAGE (SORTED_LONGNAME_MAXLEN + 1) + #else + #define SORTED_LONGNAME_MAXLEN LONG_FILENAME_LENGTH + #define SORTED_LONGNAME_STORAGE SORTED_LONGNAME_MAXLEN + #endif + + // Cache filenames to speed up SD menus. + #if ENABLED(SDSORT_USES_RAM) + + // If using dynamic ram for names, allocate on the heap. + #if ENABLED(SDSORT_CACHE_NAMES) + static uint16_t nrFiles; // Cache the total count + #if ENABLED(SDSORT_DYNAMIC_RAM) + static char **sortshort, **sortnames; + #else + static char sortshort[SDSORT_LIMIT][FILENAME_LENGTH]; + #endif + #endif + + #if (ENABLED(SDSORT_CACHE_NAMES) && DISABLED(SDSORT_DYNAMIC_RAM)) || NONE(SDSORT_CACHE_NAMES, SDSORT_USES_STACK) + static char sortnames[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE]; + #endif + + // Folder sorting uses an isDir array when caching items. + #if HAS_FOLDER_SORTING + #if ENABLED(SDSORT_DYNAMIC_RAM) + static uint8_t *isDir; + #elif ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK) + static uint8_t isDir[(SDSORT_LIMIT + 7) >> 3]; + #endif + #endif + + #endif // SDSORT_USES_RAM + + #endif // SDCARD_SORT_ALPHA + + static DiskIODriver *driver; + static SdVolume volume; + static SdFile file; + + static uint32_t filesize, // Total size of the current file, in bytes + sdpos; // Index most recently read (one behind file.getPos) + + // + // Procedure calls to other files + // + #if HAS_MEDIA_SUBCALLS + static uint8_t file_subcall_ctr; + static uint32_t filespos[SD_PROCEDURE_DEPTH]; + static char proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH]; + #endif + + // + // Directory items + // + static bool is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false)); + static int countItems(SdFile dir); + static void selectByIndex(SdFile dir, const uint8_t index); + static void selectByName(SdFile dir, const char * const match); + static void printListing( + SdFile parent, const char * const prepend + OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false) + OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) + OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr) + ); + + #if ENABLED(SDCARD_SORT_ALPHA) + static void flush_presort(); + #endif +}; + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #define IS_SD_INSERTED() DiskIODriver_USBFlash::isInserted() +#elif HAS_SD_DETECT + #define IS_SD_INSERTED() (READ(SD_DETECT_PIN) == SD_DETECT_STATE) +#else + // No card detect line? Assume the card is inserted. + #define IS_SD_INSERTED() true +#endif + +#define IS_SD_PRINTING() (card.flag.sdprinting && !card.flag.abort_sd_printing) +#define IS_SD_FETCHING() (!card.flag.sdprintdone && IS_SD_PRINTING()) +#define IS_SD_PAUSED() card.isPaused() +#define IS_SD_FILE_OPEN() card.isFileOpen() + +extern CardReader card; + +#else // !SDSUPPORT + +#define IS_SD_PRINTING() false +#define IS_SD_FETCHING() false +#define IS_SD_PAUSED() false +#define IS_SD_FILE_OPEN() false + +#define LONG_FILENAME_LENGTH 0 + +#endif // !SDSUPPORT diff --git a/src/sd/disk_io_driver.h b/src/sd/disk_io_driver.h new file mode 100644 index 0000000..02e2b3c --- /dev/null +++ b/src/sd/disk_io_driver.h @@ -0,0 +1,67 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include + +/** + * DiskIO Interface + * + * Interface for low level disk io + */ +class DiskIODriver { +public: + /** + * Initialize an SD flash memory card with default clock rate and chip + * select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin). + * + * \return true for success or false for failure. + */ + virtual bool init(const uint8_t sckRateID, const pin_t chipSelectPin) = 0; //TODO: only for SPI + + /** + * Read a card's CSD register. The CSD contains Card-Specific Data that + * provides information regarding access to the card's contents. + * + * \param[out] csd pointer to area for returned data. + * + * \return true for success or false for failure. + */ + virtual bool readCSD(csd_t* csd) = 0; + + virtual bool readStart(const uint32_t block) = 0; + virtual bool readData(uint8_t* dst) = 0; + virtual bool readStop() = 0; + + virtual bool writeStart(const uint32_t block, const uint32_t) = 0; + virtual bool writeData(const uint8_t* src) = 0; + virtual bool writeStop() = 0; + + virtual bool readBlock(uint32_t block, uint8_t* dst) = 0; + virtual bool writeBlock(uint32_t blockNumber, const uint8_t* src) = 0; + + virtual uint32_t cardSize() = 0; + + virtual bool isReady() = 0; + + virtual void idle() = 0; +}; diff --git a/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp new file mode 100644 index 0000000..b5968b7 --- /dev/null +++ b/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -0,0 +1,328 @@ +/** + * 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 . + * + */ + +#include "../../inc/MarlinConfigPre.h" + +/** + * Adjust USB_DEBUG to select debugging verbosity. + * 0 - no debug messages + * 1 - basic insertion/removal messages + * 2 - show USB state transitions + * 3 - perform block range checking + * 4 - print each block access + */ +#define USB_DEBUG 1 +#define USB_STARTUP_DELAY 0 + +// uncomment to get 'printf' console debugging. NOT FOR UNO! +//#define HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPGM("UHS:",s);} +//#define BS_HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPGM("UHS:",s);} +//#define MAX_HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPGM("UHS:",s);} + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) + +#include "../../MarlinCore.h" +#include "../../core/serial.h" +#include "../../module/temperature.h" + +#if DISABLED(USE_OTG_USB_HOST) && !PINS_EXIST(USB_CS, USB_INTR) + #error "USB_FLASH_DRIVE_SUPPORT requires USB_CS_PIN and USB_INTR_PIN to be defined." +#endif + +#if ENABLED(USE_UHS3_USB) + #define NO_AUTO_SPEED + #define UHS_MAX3421E_SPD 8000000 >> SD_SPI_SPEED + #define UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE 1 + #define UHS_HOST_MAX_INTERFACE_DRIVERS 2 + #define MASS_MAX_SUPPORTED_LUN 1 + #define USB_HOST_SERIAL MYSERIAL1 + + // Workaround for certain issues with UHS3 + #define SKIP_PAGE3F // Required for IOGEAR media adapter + #define USB_NO_TEST_UNIT_READY // Required for removable media adapter + #define USB_HOST_MANUAL_POLL // Optimization to shut off IRQ automatically + + // Workarounds to keep Marlin's watchdog timer from barking... + void marlin_yield() { thermalManager.task(); } + #define SYSTEM_OR_SPECIAL_YIELD(...) marlin_yield(); + #define delay(x) safe_delay(x) + + #define LOAD_USB_HOST_SYSTEM + #define LOAD_USB_HOST_SHIELD + #define LOAD_UHS_BULK_STORAGE + + #define MARLIN_UHS_WRITE_SS(v) WRITE(USB_CS_PIN, v) + #define MARLIN_UHS_READ_IRQ() READ(USB_INTR_PIN) + + #include "lib-uhs3/UHS_host/UHS_host.h" + + MAX3421E_HOST usb(USB_CS_PIN, USB_INTR_PIN); + UHS_Bulk_Storage bulk(&usb); + + #define UHS_START (usb.Init() == 0) + #define UHS_STATE(state) UHS_USB_HOST_STATE_##state + +#elif ENABLED(USE_OTG_USB_HOST) + + #if HAS_SD_HOST_DRIVE + #include HAL_PATH(../../HAL, msc_sd.h) + #endif + + #include HAL_PATH(../../HAL, usb_host.h) + + #define UHS_START usb.start() + #define rREVISION 0 + #define UHS_STATE(state) USB_STATE_##state + +#else + + #include "lib-uhs2/Usb.h" + #include "lib-uhs2/masstorage.h" + + USB usb; + BulkOnly bulk(&usb); + + #define UHS_START usb.start() + #define UHS_STATE(state) USB_STATE_##state + +#endif + +#include "Sd2Card_FlashDrive.h" + +#include "../../lcd/marlinui.h" + +static enum { + UNINITIALIZED, + DO_STARTUP, + WAIT_FOR_DEVICE, + WAIT_FOR_LUN, + MEDIA_READY, + MEDIA_ERROR +} state; + +#if USB_DEBUG >= 3 + uint32_t lun0_capacity; +#endif + +bool DiskIODriver_USBFlash::usbStartup() { + if (state <= DO_STARTUP) { + SERIAL_ECHOPGM("Starting USB host..."); + if (!UHS_START) { + SERIAL_ECHOLNPGM(" failed."); + LCD_MESSAGE(MSG_MEDIA_USB_FAILED); + return false; + } + + // SPI quick test - check revision register + switch (usb.regRd(rREVISION)) { + case 0x01: SERIAL_ECHOLNPGM("rev.01 started"); break; + case 0x12: SERIAL_ECHOLNPGM("rev.02 started"); break; + case 0x13: SERIAL_ECHOLNPGM("rev.03 started"); break; + default: SERIAL_ECHOLNPGM("started. rev unknown."); break; + } + state = WAIT_FOR_DEVICE; + } + return true; +} + +// The USB library needs to be called periodically to detect USB thumbdrive +// insertion and removals. Call this idle() function periodically to allow +// the USB library to monitor for such events. This function also takes care +// of initializing the USB library for the first time. + +void DiskIODriver_USBFlash::idle() { + usb.Task(); + + const uint8_t task_state = usb.getUsbTaskState(); + + #if USB_DEBUG >= 2 + if (state > DO_STARTUP) { + static uint8_t laststate = 232; + if (task_state != laststate) { + laststate = task_state; + #define UHS_USB_DEBUG(x,y) case UHS_STATE(x): SERIAL_ECHOLNPGM(y); break + switch (task_state) { + UHS_USB_DEBUG(IDLE, "IDLE"); + UHS_USB_DEBUG(RESET_DEVICE, "RESET_DEVICE"); + UHS_USB_DEBUG(RESET_NOT_COMPLETE, "RESET_NOT_COMPLETE"); + UHS_USB_DEBUG(DEBOUNCE, "DEBOUNCE"); + UHS_USB_DEBUG(DEBOUNCE_NOT_COMPLETE, "DEBOUNCE_NOT_COMPLETE"); + UHS_USB_DEBUG(WAIT_SOF, "WAIT_SOF"); + UHS_USB_DEBUG(ERROR, "ERROR"); + UHS_USB_DEBUG(CONFIGURING, "CONFIGURING"); + UHS_USB_DEBUG(CONFIGURING_DONE, "CONFIGURING_DONE"); + UHS_USB_DEBUG(RUNNING, "RUNNING"); + default: + SERIAL_ECHOLNPGM("UHS_USB_HOST_STATE: ", task_state); + break; + } + } + } + #endif + + static millis_t next_state_ms = millis(); + + #define GOTO_STATE_AFTER_DELAY(STATE, DELAY) do{ state = STATE; next_state_ms = millis() + DELAY; }while(0) + + if (ELAPSED(millis(), next_state_ms)) { + GOTO_STATE_AFTER_DELAY(state, 250); // Default delay + + switch (state) { + + case UNINITIALIZED: + #ifndef MANUAL_USB_STARTUP + GOTO_STATE_AFTER_DELAY( DO_STARTUP, USB_STARTUP_DELAY ); + #endif + break; + + case DO_STARTUP: usbStartup(); break; + + case WAIT_FOR_DEVICE: + if (task_state == UHS_STATE(RUNNING)) { + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("USB device inserted"); + #endif + GOTO_STATE_AFTER_DELAY( WAIT_FOR_LUN, 250 ); + } + break; + + case WAIT_FOR_LUN: + /* USB device is inserted, but if it is an SD card, + * adapter it may not have an SD card in it yet. */ + if (bulk.LUNIsGood(0)) { + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("LUN is good"); + #endif + GOTO_STATE_AFTER_DELAY( MEDIA_READY, 100 ); + } + else { + #ifdef USB_HOST_MANUAL_POLL + // Make sure we catch disconnect events + usb.busprobe(); + usb.VBUS_changed(); + #endif + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("Waiting for media"); + #endif + LCD_MESSAGE(MSG_MEDIA_WAITING); + GOTO_STATE_AFTER_DELAY(state, 2000); + } + break; + + case MEDIA_READY: break; + case MEDIA_ERROR: break; + } + + if (state > WAIT_FOR_DEVICE && task_state != UHS_STATE(RUNNING)) { + // Handle device removal events + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("USB device removed"); + #endif + if (state != MEDIA_READY) + LCD_MESSAGE(MSG_MEDIA_USB_REMOVED); + GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); + } + + else if (state > WAIT_FOR_LUN && !bulk.LUNIsGood(0)) { + // Handle media removal events + #if USB_DEBUG >= 1 + SERIAL_ECHOLNPGM("Media removed"); + #endif + LCD_MESSAGE(MSG_MEDIA_REMOVED); + GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); + } + + else if (task_state == UHS_STATE(ERROR)) { + LCD_MESSAGE(MSG_MEDIA_READ_ERROR); + GOTO_STATE_AFTER_DELAY(MEDIA_ERROR, 0); + } + } +} + +// Marlin calls this function to check whether an USB drive is inserted. +// This is equivalent to polling the SD_DETECT when using SD cards. +bool DiskIODriver_USBFlash::isInserted() { + return state == MEDIA_READY; +} + +bool DiskIODriver_USBFlash::isReady() { + return state > DO_STARTUP && usb.getUsbTaskState() == UHS_STATE(RUNNING); +} + +// Marlin calls this to initialize an SD card once it is inserted. +bool DiskIODriver_USBFlash::init(const uint8_t, const pin_t) { + if (!isInserted()) return false; + + #if USB_DEBUG >= 1 + const uint32_t sectorSize = bulk.GetSectorSize(0); + if (sectorSize != 512) { + SERIAL_ECHOLNPGM("Expecting sector size of 512. Got: ", sectorSize); + return false; + } + #endif + + #if USB_DEBUG >= 3 + lun0_capacity = bulk.GetCapacity(0); + SERIAL_ECHOLNPGM("LUN Capacity (in blocks): ", lun0_capacity); + #endif + return true; +} + +// Returns the capacity of the card in blocks. +uint32_t DiskIODriver_USBFlash::cardSize() { + if (!isInserted()) return false; + #if USB_DEBUG < 3 + const uint32_t + #endif + lun0_capacity = bulk.GetCapacity(0); + return lun0_capacity; +} + +bool DiskIODriver_USBFlash::readBlock(uint32_t block, uint8_t *dst) { + if (!isInserted()) return false; + #if USB_DEBUG >= 3 + if (block >= lun0_capacity) { + SERIAL_ECHOLNPGM("Attempt to read past end of LUN: ", block); + return false; + } + #if USB_DEBUG >= 4 + SERIAL_ECHOLNPGM("Read block ", block); + #endif + #endif + return bulk.Read(0, block, 512, 1, dst) == 0; +} + +bool DiskIODriver_USBFlash::writeBlock(uint32_t block, const uint8_t *src) { + if (!isInserted()) return false; + #if USB_DEBUG >= 3 + if (block >= lun0_capacity) { + SERIAL_ECHOLNPGM("Attempt to write past end of LUN: ", block); + return false; + } + #if USB_DEBUG >= 4 + SERIAL_ECHOLNPGM("Write block ", block); + #endif + #endif + return bulk.Write(0, block, 512, 1, src) == 0; +} + +#endif // USB_FLASH_DRIVE_SUPPORT diff --git a/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h b/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h new file mode 100644 index 0000000..3390bc5 --- /dev/null +++ b/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h @@ -0,0 +1,80 @@ +/** + * 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 . + * + */ +#pragma once + +/** + * \file + * \brief Sd2Card class for USB Flash Drive + */ +#include "../SdFatConfig.h" +#include "../SdInfo.h" +#include "../disk_io_driver.h" + +#if DISABLED(USE_OTG_USB_HOST) + /** + * Define SOFTWARE_SPI to use bit-bang SPI + */ + #if EITHER(MEGA_SOFT_SPI, USE_SOFTWARE_SPI) + #define SOFTWARE_SPI + #endif + + // SPI pin definitions - do not edit here - change in SdFatConfig.h + #if ENABLED(SOFTWARE_SPI) + #warning "Auto-assigning '10' as the SD_CHIP_SELECT_PIN." + #define SD_CHIP_SELECT_PIN 10 // Software SPI chip select pin for the SD + #else + // hardware pin defs + #define SD_CHIP_SELECT_PIN SD_SS_PIN // The default chip select pin for the SD card is SS. + #endif +#endif + +class DiskIODriver_USBFlash : public DiskIODriver { + private: + uint32_t pos; + + static void usbStateDebug(); + + public: + static bool usbStartup(); + static bool isInserted(); + + bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=TERN(USE_OTG_USB_HOST, 0, SD_CHIP_SELECT_PIN)) override; + + inline bool readCSD(csd_t*) override { return true; } + + inline bool readStart(const uint32_t block) override { pos = block; return isReady(); } + inline bool readData(uint8_t *dst) override { return readBlock(pos++, dst); } + inline bool readStop() override { return true; } + + inline bool writeStart(const uint32_t block, const uint32_t) override { pos = block; return isReady(); } + inline bool writeData(const uint8_t *src) override { return writeBlock(pos++, src); } + inline bool writeStop() override { return true; } + + bool readBlock(uint32_t block, uint8_t *dst) override; + bool writeBlock(uint32_t blockNumber, const uint8_t *src) override; + + uint32_t cardSize() override; + + bool isReady() override; + + void idle() override; +}; diff --git a/src/sd/usb_flashdrive/lib-uhs2/README.txt b/src/sd/usb_flashdrive/lib-uhs2/README.txt new file mode 100644 index 0000000..cb87492 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/README.txt @@ -0,0 +1,43 @@ + +==== USB HOST SHIELD 2.0 LIBRARY ==== + +The lib/ folder contains a subset of the files from the USB Host Shield 2.0 +library: + + https://github.com/felis/USB_Host_Shield_2.0 + +While the original library was released under the GPLv2 and could not be +commingled with Marlin, the developers have graciously re-licenced the +files needed for Marlin as "GPLv2 or later", as documented in this thread. + + https://github.com/felis/USB_Host_Shield_2.0/issues/364 + +Small modifications have been made to the source. Please search for +USB_FLASH_DRIVE_SUPPORT or look at the patch file to see what was changed. + +==== LICENSE SUMMARY ==== + +Source Path: Repository: License: +------------ ----------- -------- +lib-uhs3/ github.com/felis/USB_Host_Shield_2.0 GPLv2 or later +lib-uhs3/lib/masstorage.cpp github.com/greiman/UsbFat [1] MIT +lib-uhs3/lib/settings.h github.com/greiman/UsbFat [1] MIT + +[1] Changes related to SKIP_WRITE_PROTECT and DELAY only + +==== PERFORMANCE ENHANCEMENTS FOR USB DRIVES ==== + +There are also some small performance enhancements from Bill Greiman, regarding +SKIP_WRITE_PROTECT and DELAY. These changes came from the following repo: + + https://github.com/greiman/UsbFat + +While the original library was released under the GPLv2 and could not be +commingled with Marlin, the developer has graciously re-licenced his changes +under the "MIT" license, as documented here: + + https://github.com/greiman/UsbFat/issues/8 + +==== MARLIN INTEGRATION WORK ==== + +All additional work done to integrate USB into Marlin was performed by LulzBot and is licensed under the GPLv3. diff --git a/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp b/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp new file mode 100644 index 0000000..75421f4 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp @@ -0,0 +1,795 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ + +// +// USB functions supporting Flash Drive +// + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB) + +#include "Usb.h" + +static uint8_t usb_error = 0; +static uint8_t usb_task_state; + +/* constructor */ +USB::USB() : bmHubPre(0) { + usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; // Set up state machine + init(); +} + +/* Initialize data structures */ +void USB::init() { + //devConfigIndex = 0; + bmHubPre = 0; +} + +uint8_t USB::getUsbTaskState() { return usb_task_state; } +void USB::setUsbTaskState(uint8_t state) { usb_task_state = state; } + +EpInfo* USB::getEpInfoEntry(uint8_t addr, uint8_t ep) { + UsbDevice *p = addrPool.GetUsbDevicePtr(addr); + + if (!p || !p->epinfo) + return nullptr; + + EpInfo *pep = p->epinfo; + + for (uint8_t i = 0; i < p->epcount; i++) { + if ((pep)->epAddr == ep) + return pep; + + pep++; + } + return nullptr; +} + +/** + * Set device table entry + * Each device is different and has different number of endpoints. + * This function plugs endpoint record structure, defined in application, to devtable + */ +uint8_t USB::setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr) { + if (!eprecord_ptr) + return USB_ERROR_INVALID_ARGUMENT; + + UsbDevice *p = addrPool.GetUsbDevicePtr(addr); + + if (!p) + return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; + + p->address.devAddress = addr; + p->epinfo = eprecord_ptr; + p->epcount = epcount; + + return 0; +} + +uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit) { + UsbDevice *p = addrPool.GetUsbDevicePtr(addr); + + if (!p) + return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; + + if (!p->epinfo) + return USB_ERROR_EPINFO_IS_NULL; + + *ppep = getEpInfoEntry(addr, ep); + + if (!*ppep) + return USB_ERROR_EP_NOT_FOUND_IN_TBL; + + *nak_limit = (0x0001UL << (((*ppep)->bmNakPower > USB_NAK_MAX_POWER) ? USB_NAK_MAX_POWER : (*ppep)->bmNakPower)); + (*nak_limit)--; + /* + USBTRACE2("\r\nAddress: ", addr); + USBTRACE2(" EP: ", ep); + USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower); + USBTRACE2(" NAK Limit: ", nak_limit); + USBTRACE("\r\n"); + */ + regWr(rPERADDR, addr); // Set peripheral address + + uint8_t mode = regRd(rMODE); + + //Serial.print("\r\nMode: "); + //Serial.println( mode, HEX); + //Serial.print("\r\nLS: "); + //Serial.println(p->lowspeed, HEX); + + // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise + regWr(rMODE, (p->lowspeed) ? mode | bmLOWSPEED | bmHubPre : mode & ~(bmHUBPRE | bmLOWSPEED)); + + return 0; +} + +/* Control transfer. Sets address, endpoint, fills control packet with necessary data, dispatches control packet, and initiates bulk IN transfer, */ +/* depending on request. Actual requests are defined as inlines */ +/* return codes: */ +/* 00 = success */ +/* 01-0f = non-zero HRSLT */ +uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, + uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t *dataptr, USBReadParser *p) { + bool direction = false; // Request direction, IN or OUT + uint8_t rcode; + SETUP_PKT setup_pkt; + + EpInfo *pep = nullptr; + uint16_t nak_limit = 0; + + rcode = SetAddress(addr, ep, &pep, &nak_limit); + if (rcode) return rcode; + + direction = ((bmReqType & 0x80) > 0); + + /* fill in setup packet */ + setup_pkt.ReqType_u.bmRequestType = bmReqType; + setup_pkt.bRequest = bRequest; + setup_pkt.wVal_u.wValueLo = wValLo; + setup_pkt.wVal_u.wValueHi = wValHi; + setup_pkt.wIndex = wInd; + setup_pkt.wLength = total; + + bytesWr(rSUDFIFO, 8, (uint8_t*) & setup_pkt); // Transfer to setup packet FIFO + + rcode = dispatchPkt(tokSETUP, ep, nak_limit); // Dispatch packet + if (rcode) return rcode; // Return HRSLT if not zero + + if (dataptr) { // Data stage, if present + if (direction) { // IN transfer + uint16_t left = total; + pep->bmRcvToggle = 1; // BmRCVTOG1; + + while (left) { + // Bytes read into buffer + uint16_t read = nbytes; + //uint16_t read = (leftbmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + continue; + } + + if (rcode) return rcode; + + // Invoke callback function if inTransfer completed successfully and callback function pointer is specified + if (!rcode && p) ((USBReadParser*)p)->Parse(read, dataptr, total - left); + + left -= read; + + if (read < nbytes) break; + } + } + else { // OUT transfer + pep->bmSndToggle = 1; // BmSNDTOG1; + rcode = OutTransfer(pep, nak_limit, nbytes, dataptr); + } + if (rcode) return rcode; // Return error + } + // Status stage + return dispatchPkt((direction) ? tokOUTHS : tokINHS, ep, nak_limit); // GET if direction +} + +/** + * IN transfer to arbitrary endpoint. Assumes PERADDR is set. Handles multiple packets if necessary. Transfers 'nbytes' bytes. + * Keep sending INs and writes data to memory area pointed by 'data' + * rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error, fe = USB xfer timeout + */ +uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval /*= 0*/) { + EpInfo *pep = nullptr; + uint16_t nak_limit = 0; + + uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit); + if (rcode) { + USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81); + USBTRACE3("(USB::InTransfer) addr requested ", addr, 0x81); + USBTRACE3("(USB::InTransfer) ep requested ", ep, 0x81); + return rcode; + } + return InTransfer(pep, nak_limit, nbytesptr, data, bInterval); +} + +uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval /*= 0*/) { + uint8_t rcode = 0; + uint8_t pktsize; + + uint16_t nbytes = *nbytesptr; + //printf("Requesting %i bytes ", nbytes); + uint8_t maxpktsize = pep->maxPktSize; + + *nbytesptr = 0; + regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); // Set toggle value + + // Use a 'break' to exit this loop + for (;;) { + rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); // IN packet to EP-'endpoint'. Function takes care of NAKS. + if (rcode == hrTOGERR) { + // Yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmRCVTOGRD) ? 0 : 1; + regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); // Set toggle value + continue; + } + if (rcode) { + //printf(">>>>>>>> Problem! dispatchPkt %2.2x\r\n", rcode); + break; // Should be 0, indicating ACK. Else return error code. + } + /* check for RCVDAVIRQ and generate error if not present */ + /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */ + if ((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) { + //printf(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n"); + rcode = 0xF0; // Receive error + break; + } + pktsize = regRd(rRCVBC); // Number of received bytes + //printf("Got %i bytes \r\n", pktsize); + // This would be OK, but... + //assert(pktsize <= nbytes); + if (pktsize > nbytes) { + // This can happen. Use of assert on Arduino locks up the Arduino. + // So I will trim the value, and hope for the best. + //printf(">>>>>>>> Problem! Wanted %i bytes but got %i.\r\n", nbytes, pktsize); + pktsize = nbytes; + } + + int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr); + if (mem_left < 0) mem_left = 0; + + data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data); + + regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer + *nbytesptr += pktsize; // Add this packet's byte count to total transfer length + + /* The transfer is complete under two conditions: */ + /* 1. The device sent a short packet (L.T. maxPacketSize) */ + /* 2. 'nbytes' have been transferred. */ + if (pktsize < maxpktsize || *nbytesptr >= nbytes) { // Transferred 'nbytes' bytes? + // Save toggle value + pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0; + //printf("\r\n"); + rcode = 0; + break; + } + else if (bInterval > 0) + delay(bInterval); // Delay according to polling interval + } + return rcode; +} + +/** + * OUT transfer to arbitrary endpoint. Handles multiple packets if necessary. Transfers 'nbytes' bytes. + * Handles NAK bug per Maxim Application Note 4000 for single buffer transfer + * rcode 0 if no errors. rcode 01-0f is relayed from HRSL + */ +uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data) { + EpInfo *pep = nullptr; + uint16_t nak_limit = 0; + + uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit); + if (rcode) return rcode; + + return OutTransfer(pep, nak_limit, nbytes, data); +} + +uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) { + uint8_t rcode = hrSUCCESS, retry_count; + uint8_t *data_p = data; // Local copy of the data pointer + uint16_t bytes_tosend, nak_count; + uint16_t bytes_left = nbytes; + + uint8_t maxpktsize = pep->maxPktSize; + + if (maxpktsize < 1 || maxpktsize > 64) + return USB_ERROR_INVALID_MAX_PKT_SIZE; + + uint32_t timeout = (uint32_t)millis() + USB_XFER_TIMEOUT; + + regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); // Set toggle value + + while (bytes_left) { + retry_count = 0; + nak_count = 0; + bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left; + bytesWr(rSNDFIFO, bytes_tosend, data_p); // Filling output FIFO + regWr(rSNDBC, bytes_tosend); // Set number of bytes + regWr(rHXFR, (tokOUT | pep->epAddr)); // Dispatch packet + while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); // Wait for the completion IRQ + regWr(rHIRQ, bmHXFRDNIRQ); // Clear IRQ + rcode = (regRd(rHRSL) & 0x0F); + + while (rcode && ((int32_t)((uint32_t)millis() - timeout) < 0L)) { + switch (rcode) { + case hrNAK: + nak_count++; + if (nak_limit && (nak_count == nak_limit)) + goto breakout; + //return rcode; + break; + case hrTIMEOUT: + retry_count++; + if (retry_count == USB_RETRY_LIMIT) + goto breakout; + //return rcode; + break; + case hrTOGERR: + // Yes, we flip it wrong here so that next time it is actually correct! + pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); // Set toggle value + break; + default: + goto breakout; + } + + /* process NAK according to Host out NAK bug */ + regWr(rSNDBC, 0); + regWr(rSNDFIFO, *data_p); + regWr(rSNDBC, bytes_tosend); + regWr(rHXFR, (tokOUT | pep->epAddr)); // Dispatch packet + while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); // Wait for the completion IRQ + regWr(rHIRQ, bmHXFRDNIRQ); // Clear IRQ + rcode = (regRd(rHRSL) & 0x0F); + } // While rcode && .... + bytes_left -= bytes_tosend; + data_p += bytes_tosend; + } // While bytes_left... +breakout: + + pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; // BmSNDTOG1 : bmSNDTOG0; // Update toggle + return ( rcode); // Should be 0 in all cases +} + +/** + * Dispatch USB packet. Assumes peripheral address is set and relevant buffer is loaded/empty + * If NAK, tries to re-send up to nak_limit times + * If nak_limit == 0, do not count NAKs, exit after timeout + * If bus timeout, re-sends up to USB_RETRY_LIMIT times + * return codes 0x00-0x0F are HRSLT( 0x00 being success ), 0xFF means timeout + */ +uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) { + uint32_t timeout = (uint32_t)millis() + USB_XFER_TIMEOUT; + uint8_t tmpdata; + uint8_t rcode = hrSUCCESS; + uint8_t retry_count = 0; + uint16_t nak_count = 0; + + while ((int32_t)((uint32_t)millis() - timeout) < 0L) { + #if defined(ESP8266) || defined(ESP32) + yield(); // Needed in order to reset the watchdog timer on the ESP8266 + #endif + regWr(rHXFR, (token | ep)); // Launch the transfer + rcode = USB_ERROR_TRANSFER_TIMEOUT; + + while ((int32_t)((uint32_t)millis() - timeout) < 0L) { // Wait for transfer completion + #if defined(ESP8266) || defined(ESP32) + yield(); // Needed to reset the watchdog timer on the ESP8266 + #endif + tmpdata = regRd(rHIRQ); + + if (tmpdata & bmHXFRDNIRQ) { + regWr(rHIRQ, bmHXFRDNIRQ); // Clear the interrupt + rcode = 0x00; + break; + } + + } // While millis() < timeout + + //if (rcode != 0x00) return rcode; // Exit if timeout + + rcode = (regRd(rHRSL) & 0x0F); // Analyze transfer result + + switch (rcode) { + case hrNAK: + nak_count++; + if (nak_limit && (nak_count == nak_limit)) + return (rcode); + break; + case hrTIMEOUT: + retry_count++; + if (retry_count == USB_RETRY_LIMIT) + return (rcode); + break; + default: + return (rcode); + } + + } // While timeout > millis() + return rcode; +} + +// USB main task. Performs enumeration/cleanup +void USB::Task() { // USB state machine + uint8_t rcode; + uint8_t tmpdata; + static uint32_t delay = 0; + //USB_FD_DEVICE_DESCRIPTOR buf; + bool lowspeed = false; + + MAX3421E::Task(); + + tmpdata = getVbusState(); + + /* modify USB task state if Vbus changed */ + switch (tmpdata) { + case SE1: // Illegal state + usb_task_state = USB_DETACHED_SUBSTATE_ILLEGAL; + lowspeed = false; + break; + case SE0: // Disconnected + if ((usb_task_state & USB_STATE_MASK) != USB_STATE_DETACHED) + usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; + lowspeed = false; + break; + case LSHOST: + lowspeed = true; + // Intentional fallthrough + case FSHOST: // Attached + if ((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) { + delay = (uint32_t)millis() + USB_SETTLE_DELAY; + usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE; + } + break; + } + + for (uint8_t i = 0; i < USB_NUMDEVICES; i++) + if (devConfig[i]) rcode = devConfig[i]->Poll(); + + switch (usb_task_state) { + case USB_DETACHED_SUBSTATE_INITIALIZE: + init(); + + for (uint8_t i = 0; i < USB_NUMDEVICES; i++) + if (devConfig[i]) + rcode = devConfig[i]->Release(); + + usb_task_state = USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE; + break; + case USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE: // Just sit here + break; + case USB_DETACHED_SUBSTATE_ILLEGAL: // Just sit here + break; + case USB_ATTACHED_SUBSTATE_SETTLE: // Settle time for just attached device + if ((int32_t)((uint32_t)millis() - delay) >= 0L) + usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE; + else break; // Don't fall through + case USB_ATTACHED_SUBSTATE_RESET_DEVICE: + regWr(rHCTL, bmBUSRST); // Issue bus reset + usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE; + break; + case USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE: + if ((regRd(rHCTL) & bmBUSRST) == 0) { + tmpdata = regRd(rMODE) | bmSOFKAENAB; // Start SOF generation + regWr(rMODE, tmpdata); + usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_SOF; + //delay = (uint32_t)millis() + 20; // 20ms wait after reset per USB spec + } + break; + case USB_ATTACHED_SUBSTATE_WAIT_SOF: // Todo: change check order + if (regRd(rHIRQ) & bmFRAMEIRQ) { + // When first SOF received _and_ 20ms has passed we can continue + /* + if (delay < (uint32_t)millis()) // 20ms passed + usb_task_state = USB_STATE_CONFIGURING; + */ + usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET; + delay = (uint32_t)millis() + 20; + } + break; + case USB_ATTACHED_SUBSTATE_WAIT_RESET: + if ((int32_t)((uint32_t)millis() - delay) >= 0L) usb_task_state = USB_STATE_CONFIGURING; + else break; // Don't fall through + case USB_STATE_CONFIGURING: + + //Serial.print("\r\nConf.LS: "); + //Serial.println(lowspeed, HEX); + + rcode = Configuring(0, 0, lowspeed); + + if (!rcode) + usb_task_state = USB_STATE_RUNNING; + else if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE) { + usb_error = rcode; + usb_task_state = USB_STATE_ERROR; + } + break; + case USB_STATE_RUNNING: + break; + case USB_STATE_ERROR: + //MAX3421E::Init(); + break; + } +} + +uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) { + //uint8_t buf[12]; + uint8_t rcode; + UsbDevice *p0 = nullptr, *p = nullptr; + + // Get pointer to pseudo device with address 0 assigned + p0 = addrPool.GetUsbDevicePtr(0); + if (!p0) return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; + if (!p0->epinfo) return USB_ERROR_EPINFO_IS_NULL; + + p0->lowspeed = lowspeed; + + // Allocate new address according to device class + uint8_t bAddress = addrPool.AllocAddress(parent, false, port); + if (!bAddress) return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; + + p = addrPool.GetUsbDevicePtr(bAddress); + if (!p) return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; + + p->lowspeed = lowspeed; + + // Assign new address to the device + rcode = setAddr(0, 0, bAddress); + if (rcode) { + addrPool.FreeAddress(bAddress); + bAddress = 0; + } + return rcode; +} + +uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed) { + //printf("AttemptConfig: parent = %i, port = %i\r\n", parent, port); + uint8_t retries = 0; + +again: + uint8_t rcode = devConfig[driver]->ConfigureDevice(parent, port, lowspeed); + if (rcode == USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET) { + if (parent == 0) { + // Send a bus reset on the root interface. + regWr(rHCTL, bmBUSRST); // Issue bus reset + delay(102); // Delay 102ms, compensate for clock inaccuracy. + } + else { + // Reset parent port + devConfig[parent]->ResetHubPort(port); + } + } + else if (rcode == hrJERR && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works + delay(100); + retries++; + goto again; + } + else if (rcode) + return rcode; + + rcode = devConfig[driver]->Init(parent, port, lowspeed); + if (rcode == hrJERR && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works + delay(100); + retries++; + goto again; + } + + if (rcode) { + // Issue a bus reset, because the device may be in a limbo state + if (parent == 0) { + // Send a bus reset on the root interface. + regWr(rHCTL, bmBUSRST); // Issue bus reset + delay(102); // Delay 102ms, compensate for clock inaccuracy. + } + else { + // Reset parent port + devConfig[parent]->ResetHubPort(port); + } + } + return rcode; +} + +/** + * This is broken. It needs to enumerate differently. + * It causes major problems with several devices if detected in an unexpected order. + * + * Oleg - I wouldn't do anything before the newly connected device is considered sane. + * i.e.(delays are not indicated for brevity): + * 1. reset + * 2. GetDevDescr(); + * 3a. If ACK, continue with allocating address, addressing, etc. + * 3b. Else reset again, count resets, stop at some number (5?). + * 4. When max.number of resets is reached, toggle power/fail + * If desired, this could be modified by performing two resets with GetDevDescr() in the middle - however, from my experience, if a device answers to GDD() + * it doesn't need to be reset again + * New steps proposal: + * 1: get address pool instance. exit on fail + * 2: pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf). exit on fail. + * 3: bus reset, 100ms delay + * 4: set address + * 5: pUsb->setEpInfoEntry(bAddress, 1, epInfo), exit on fail + * 6: while (configurations) { + * for (each configuration) { + * for (each driver) { + * 6a: Ask device if it likes configuration. Returns 0 on OK. + * If successful, the driver configured device. + * The driver now owns the endpoints, and takes over managing them. + * The following will need codes: + * Everything went well, instance consumed, exit with success. + * Instance already in use, ignore it, try next driver. + * Not a supported device, ignore it, try next driver. + * Not a supported configuration for this device, ignore it, try next driver. + * Could not configure device, fatal, exit with fail. + * } + * } + * } + * 7: for (each driver) { + * 7a: Ask device if it knows this VID/PID. Acts exactly like 6a, but using VID/PID + * 8: if we get here, no driver likes the device plugged in, so exit failure. + */ +uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { + //uint8_t bAddress = 0; + //printf("Configuring: parent = %i, port = %i\r\n", parent, port); + uint8_t devConfigIndex; + uint8_t rcode = 0; + uint8_t buf[sizeof (USB_FD_DEVICE_DESCRIPTOR)]; + USB_FD_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); + UsbDevice *p = nullptr; + EpInfo *oldep_ptr = nullptr; + EpInfo epInfo; + + epInfo.epAddr = 0; + epInfo.maxPktSize = 8; + epInfo.bmSndToggle = 0; + epInfo.bmRcvToggle = 0; + epInfo.bmNakPower = USB_NAK_MAX_POWER; + + //delay(2000); + AddressPool &addrPool = GetAddressPool(); + // Get pointer to pseudo device with address 0 assigned + p = addrPool.GetUsbDevicePtr(0); + if (!p) { + //printf("Configuring error: USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL\r\n"); + return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; + } + + // Save old pointer to EP_RECORD of address 0 + oldep_ptr = p->epinfo; + + // Temporary assign new pointer to epInfo to p->epinfo in order to + // Avoid toggle inconsistence + + p->epinfo = &epInfo; + + p->lowspeed = lowspeed; + // Get device descriptor + rcode = getDevDescr(0, 0, sizeof (USB_FD_DEVICE_DESCRIPTOR), (uint8_t*)buf); + + // Restore p->epinfo + p->epinfo = oldep_ptr; + + if (rcode) { + //printf("Configuring error: Can't get USB_FD_DEVICE_DESCRIPTOR\r\n"); + return rcode; + } + + // To-do? + // Allocate new address according to device class + //bAddress = addrPool.AllocAddress(parent, false, port); + + uint16_t vid = udd->idVendor, pid = udd->idProduct; + uint8_t klass = udd->bDeviceClass, subklass = udd->bDeviceSubClass; + + // Attempt to configure if VID/PID or device class matches with a driver + // Qualify with subclass too. + // + // VID/PID & class tests default to false for drivers not yet ported + // Subclass defaults to true, so you don't have to define it if you don't have to. + // + for (devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { + if (!devConfig[devConfigIndex]) continue; // No driver + if (devConfig[devConfigIndex]->GetAddress()) continue; // Consumed + if (devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) { + rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); + if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED) + break; + } + } + + if (devConfigIndex < USB_NUMDEVICES) return rcode; + + // Blindly attempt to configure + for (devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { + if (!devConfig[devConfigIndex]) continue; + if (devConfig[devConfigIndex]->GetAddress()) continue; // Consumed + if (devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above + rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); + + //printf("ERROR ENUMERATING %2.2x\r\n", rcode); + if (!(rcode == USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED || rcode == USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE)) { + // In case of an error dev_index should be reset to 0 + // in order to start from the very beginning the + // next time the program gets here + //if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE) + //devConfigIndex = 0; + return rcode; + } + } + // Arriving here means the device class is unsupported by registered classes + return DefaultAddressing(parent, port, lowspeed); +} + +uint8_t USB::ReleaseDevice(uint8_t addr) { + if (addr) { + for (uint8_t i = 0; i < USB_NUMDEVICES; i++) { + if (!devConfig[i]) continue; + if (devConfig[i]->GetAddress() == addr) + return devConfig[i]->Release(); + } + } + return 0; +} + +// Get device descriptor +uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr) { + return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, nullptr); +} + +// Get configuration descriptor +uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr) { + return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, nullptr); +} + +/** + * Requests Configuration Descriptor. Sends two Get Conf Descr requests. + * The first one gets the total length of all descriptors, then the second one requests this + * total length. The length of the first request can be shorter (4 bytes), however, there are + * devices which won't work unless this length is set to 9. + */ +uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) { + const uint8_t bufSize = 64; + uint8_t buf[bufSize]; + USB_FD_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); + + uint8_t ret = getConfDescr(addr, ep, 9, conf, buf); + if (ret) return ret; + + uint16_t total = ucd->wTotalLength; + + //USBTRACE2("\r\ntotal conf.size:", total); + + return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, total, bufSize, buf, p); +} + +// Get string descriptor +uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t *dataptr) { + return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, nullptr); +} + +// Set address +uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { + uint8_t rcode = ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, nullptr, nullptr); + //delay(2); // Per USB 2.0 sect.9.2.6.3 + delay(300); // Older spec says you should wait at least 200ms + return rcode; + //return ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, nullptr, nullptr); +} + +// Set configuration +uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { + return ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, nullptr, nullptr); +} + +#endif // USB_FLASH_DRIVE_SUPPORT diff --git a/src/sd/usb_flashdrive/lib-uhs2/Usb.h b/src/sd/usb_flashdrive/lib-uhs2/Usb.h new file mode 100644 index 0000000..b1ec146 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/Usb.h @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ +#pragma once + +/* USB functions */ +#define _usb_h_ + +#include "../../../inc/MarlinConfigPre.h" + +// WARNING: Do not change the order of includes, or stuff will break! +#include +#include +#include + +// None of these should ever be included by a driver, or a user's sketch. +#include "settings.h" +#include "printhex.h" +#include "message.h" + +#include "hexdump.h" +//#include "sink_parser.h" +#include "max3421e.h" +#include "address.h" +//#include "avrpins.h" +#include "usb_ch9.h" +#include "usbhost.h" +#include "UsbCore.h" +#include "parsetools.h" +#include "confdescparser.h" + +#undef _usb_h_ diff --git a/src/sd/usb_flashdrive/lib-uhs2/UsbCore.h b/src/sd/usb_flashdrive/lib-uhs2/UsbCore.h new file mode 100644 index 0000000..2b6e1be --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/UsbCore.h @@ -0,0 +1,312 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ + +#ifndef _usb_h_ + #error "Never include UsbCore.h directly; include Usb.h instead" +#endif + +#pragma once + +// Not used anymore? If anyone uses this, please let us know so that this may be +// moved to the proper place, settings.h. +//#define USB_METHODS_INLINE + +/* shield pins. First parameter - SS pin, second parameter - INT pin */ + +#ifdef __MARLIN_FIRMWARE__ +typedef MAX3421e MAX3421E; // Marlin redefines this class in "../usb_host.h" +#elif defined(BOARD_BLACK_WIDDOW) +typedef MAX3421e MAX3421E; // Black Widow +#elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) +#if EXT_RAM +typedef MAX3421e MAX3421E; // Teensy++ 2.0 with XMEM2 +#else +typedef MAX3421e MAX3421E; // Teensy++ 1.0 and 2.0 +#endif +#elif defined(BOARD_MEGA_ADK) +typedef MAX3421e MAX3421E; // Arduino Mega ADK +#elif defined(ARDUINO_AVR_BALANDUINO) +typedef MAX3421e MAX3421E; // Balanduino +#elif defined(__ARDUINO_X86__) && PLATFORM_ID == 0x06 +typedef MAX3421e MAX3421E; // The Intel Galileo supports much faster read and write speed at pin 2 and 3 +#elif defined(ESP8266) +typedef MAX3421e MAX3421E; // ESP8266 boards +#elif defined(ESP32) +typedef MAX3421e MAX3421E; // ESP32 boards +#else +typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Edison, Intel Galileo 2 or Teensy 2.0 and 3.x +#endif + +/* Common setup data constant combinations */ +#define bmREQ_GET_DESCR USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE //get descriptor request type +#define bmREQ_SET USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE //set request type for all but 'set feature' and 'set interface' +#define bmREQ_CL_GET_INTF USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE //get interface request type + +// D7 data transfer direction (0 - host-to-device, 1 - device-to-host) +// D6-5 Type (0- standard, 1 - class, 2 - vendor, 3 - reserved) +// D4-0 Recipient (0 - device, 1 - interface, 2 - endpoint, 3 - other, 4..31 - reserved) + +// USB Device Classes +#define USB_CLASS_USE_CLASS_INFO 0x00 // Use Class Info in the Interface Descriptors +#define USB_CLASS_AUDIO 0x01 // Audio +#define USB_CLASS_COM_AND_CDC_CTRL 0x02 // Communications and CDC Control +#define USB_CLASS_HID 0x03 // HID +#define USB_CLASS_PHYSICAL 0x05 // Physical +#define USB_CLASS_IMAGE 0x06 // Image +#define USB_CLASS_PRINTER 0x07 // Printer +#define USB_CLASS_MASS_STORAGE 0x08 // Mass Storage +#define USB_CLASS_HUB 0x09 // Hub +#define USB_CLASS_CDC_DATA 0x0A // CDC-Data +#define USB_CLASS_SMART_CARD 0x0B // Smart-Card +#define USB_CLASS_CONTENT_SECURITY 0x0D // Content Security +#define USB_CLASS_VIDEO 0x0E // Video +#define USB_CLASS_PERSONAL_HEALTH 0x0F // Personal Healthcare +#define USB_CLASS_DIAGNOSTIC_DEVICE 0xDC // Diagnostic Device +#define USB_CLASS_WIRELESS_CTRL 0xE0 // Wireless Controller +#define USB_CLASS_MISC 0xEF // Miscellaneous +#define USB_CLASS_APP_SPECIFIC 0xFE // Application Specific +#define USB_CLASS_VENDOR_SPECIFIC 0xFF // Vendor Specific + +// Additional Error Codes +#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED 0xD1 +#define USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE 0xD2 +#define USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS 0xD3 +#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL 0xD4 +#define USB_ERROR_HUB_ADDRESS_OVERFLOW 0xD5 +#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL 0xD6 +#define USB_ERROR_EPINFO_IS_NULL 0xD7 +#define USB_ERROR_INVALID_ARGUMENT 0xD8 +#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE 0xD9 +#define USB_ERROR_INVALID_MAX_PKT_SIZE 0xDA +#define USB_ERROR_EP_NOT_FOUND_IN_TBL 0xDB +#define USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET 0xE0 +#define USB_ERROR_FailGetDevDescr 0xE1 +#define USB_ERROR_FailSetDevTblEntry 0xE2 +#define USB_ERROR_FailGetConfDescr 0xE3 +#define USB_ERROR_TRANSFER_TIMEOUT 0xFF + +#define USB_XFER_TIMEOUT 5000 // (5000) USB transfer timeout in milliseconds, per section 9.2.6.1 of USB 2.0 spec +//#define USB_NAK_LIMIT 32000 // NAK limit for a transfer. 0 means NAKs are not counted +#define USB_RETRY_LIMIT 3 // 3 retry limit for a transfer +#define USB_SETTLE_DELAY 200 // settle delay in milliseconds + +#define USB_NUMDEVICES 16 //number of USB devices +//#define HUB_MAX_HUBS 7 // maximum number of hubs that can be attached to the host controller +#define HUB_PORT_RESET_DELAY 20 // hub port reset delay 10 ms recommended, can be up to 20 ms + +/* USB state machine states */ +#define USB_STATE_MASK 0xF0 + +#define USB_STATE_DETACHED 0x10 +#define USB_DETACHED_SUBSTATE_INITIALIZE 0x11 +#define USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE 0x12 +#define USB_DETACHED_SUBSTATE_ILLEGAL 0x13 +#define USB_ATTACHED_SUBSTATE_SETTLE 0x20 +#define USB_ATTACHED_SUBSTATE_RESET_DEVICE 0x30 +#define USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE 0x40 +#define USB_ATTACHED_SUBSTATE_WAIT_SOF 0x50 +#define USB_ATTACHED_SUBSTATE_WAIT_RESET 0x51 +#define USB_ATTACHED_SUBSTATE_GET_DEVICE_DESCRIPTOR_SIZE 0x60 +#define USB_STATE_ADDRESSING 0x70 +#define USB_STATE_CONFIGURING 0x80 +#define USB_STATE_RUNNING 0x90 +#define USB_STATE_ERROR 0xA0 + +class USBDeviceConfig { +public: + + virtual uint8_t Init(uint8_t parent __attribute__((unused)), uint8_t port __attribute__((unused)), bool lowspeed __attribute__((unused))) { + return 0; + } + + virtual uint8_t ConfigureDevice(uint8_t parent __attribute__((unused)), uint8_t port __attribute__((unused)), bool lowspeed __attribute__((unused))) { + return 0; + } + + virtual uint8_t Release() { + return 0; + } + + virtual uint8_t Poll() { + return 0; + } + + virtual uint8_t GetAddress() { + return 0; + } + + virtual void ResetHubPort(uint8_t port __attribute__((unused))) { + return; + } // Note used for hubs only! + + virtual bool VIDPIDOK(uint16_t vid __attribute__((unused)), uint16_t pid __attribute__((unused))) { + return false; + } + + virtual bool DEVCLASSOK(uint8_t klass __attribute__((unused))) { + return false; + } + + virtual bool DEVSUBCLASSOK(uint8_t subklass __attribute__((unused))) { + return true; + } + +}; + +/* USB Setup Packet Structure */ +typedef struct { + + union { // offset description + uint8_t bmRequestType; // 0 Bit-map of request type + + struct { + uint8_t recipient : 5; // Recipient of the request + uint8_t type : 2; // Type of request + uint8_t direction : 1; // Direction of data X-fer + } __attribute__((packed)); + } ReqType_u; + uint8_t bRequest; // 1 Request + + union { + uint16_t wValue; // 2 Depends on bRequest + + struct { + uint8_t wValueLo; + uint8_t wValueHi; + } __attribute__((packed)); + } wVal_u; + uint16_t wIndex; // 4 Depends on bRequest + uint16_t wLength; // 6 Depends on bRequest +} __attribute__((packed)) SETUP_PKT, *PSETUP_PKT; + + + +// Base class for incoming data parser + +class USBReadParser { +public: + virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset) = 0; +}; + +class USB : public MAX3421E { + AddressPoolImpl addrPool; + USBDeviceConfig* devConfig[USB_NUMDEVICES]; + uint8_t bmHubPre; + +public: + USB(); + + void SetHubPreMask() { + bmHubPre |= bmHUBPRE; + }; + + void ResetHubPreMask() { + bmHubPre &= (~bmHUBPRE); + }; + + AddressPool& GetAddressPool() { + return (AddressPool&)addrPool; + }; + + uint8_t RegisterDeviceClass(USBDeviceConfig *pdev) { + for (uint8_t i = 0; i < USB_NUMDEVICES; i++) { + if (!devConfig[i]) { + devConfig[i] = pdev; + return 0; + } + } + return USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS; + }; + + void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) { + addrPool.ForEachUsbDevice(pfunc); + }; + uint8_t getUsbTaskState(); + void setUsbTaskState(uint8_t state); + + EpInfo* getEpInfoEntry(uint8_t addr, uint8_t ep); + uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr); + + /* Control requests */ + uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr); + uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr); + + uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p); + + uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr); + uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr); + uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value); + /**/ + uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr, bool direction); + uint8_t ctrlStatus(uint8_t ep, bool direction, uint16_t nak_limit); + uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval = 0); + uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data); + uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit); + + void Task(); + + uint8_t DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Configuring(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t ReleaseDevice(uint8_t addr); + + uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, + uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t *dataptr, USBReadParser *p); + +private: + void init(); + uint8_t SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit); + uint8_t OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data); + uint8_t InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval = 0); + uint8_t AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed); +}; + +#if 0 //defined(USB_METHODS_INLINE) +//get device descriptor + +inline uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr) { + return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, dataptr)); +} +//get configuration descriptor + +inline uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr) { + return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, dataptr)); +} +//get string descriptor + +inline uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t *dataptr) { + return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nuint8_ts, dataptr)); +} +//set address + +inline uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { + return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, nullptr)); +} +//set configuration + +inline uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { + return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, nullptr)); +} + +#endif // defined(USB_METHODS_INLINE) diff --git a/src/sd/usb_flashdrive/lib-uhs2/address.h b/src/sd/usb_flashdrive/lib-uhs2/address.h new file mode 100644 index 0000000..373b95a --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/address.h @@ -0,0 +1,271 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ +#pragma once + +#ifndef _usb_h_ + #error "Never include address.h directly; include Usb.h instead" +#endif + +/* NAK powers. To save space in endpoint data structure, amount of retries before giving up and returning 0x4 is stored in */ +/* bmNakPower as a power of 2. The actual nak_limit is then calculated as nak_limit = ( 2^bmNakPower - 1) */ +#define USB_NAK_MAX_POWER 15 //NAK binary order maximum value +#define USB_NAK_DEFAULT 14 //default 32K-1 NAKs before giving up +#define USB_NAK_NOWAIT 1 //Single NAK stops transfer +#define USB_NAK_NONAK 0 //Do not count NAKs, stop retrying after USB Timeout + +struct EpInfo { + uint8_t epAddr; // Endpoint address + uint8_t maxPktSize; // Maximum packet size + + union { + uint8_t epAttribs; + + struct { + uint8_t bmSndToggle : 1; // Send toggle, when zero bmSNDTOG0, bmSNDTOG1 otherwise + uint8_t bmRcvToggle : 1; // Send toggle, when zero bmRCVTOG0, bmRCVTOG1 otherwise + uint8_t bmNakPower : 6; // Binary order for NAK_LIMIT value + } __attribute__((packed)); + }; +} __attribute__((packed)); + +// 7 6 5 4 3 2 1 0 +// --------------------------------- +// | | H | P | P | P | A | A | A | +// --------------------------------- +// +// H - if 1 the address is a hub address +// P - parent hub address +// A - device address / port number in case of hub +// + +struct UsbDeviceAddress { + union { + struct { + uint8_t bmAddress : 3; // device address/port number + uint8_t bmParent : 3; // parent hub address + uint8_t bmHub : 1; // hub flag + uint8_t bmReserved : 1; // reserved, must be zero + } __attribute__((packed)); + uint8_t devAddress; + }; +} __attribute__((packed)); + +#define bmUSB_DEV_ADDR_ADDRESS 0x07 +#define bmUSB_DEV_ADDR_PARENT 0x38 +#define bmUSB_DEV_ADDR_HUB 0x40 + +struct UsbDevice { + EpInfo *epinfo; // endpoint info pointer + UsbDeviceAddress address; + uint8_t epcount; // number of endpoints + bool lowspeed; // indicates if a device is the low speed one + // uint8_t devclass; // device class +} __attribute__((packed)); + +class AddressPool { + public: + virtual UsbDevice* GetUsbDevicePtr(uint8_t addr) = 0; + virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) = 0; + virtual void FreeAddress(uint8_t addr) = 0; +}; + +typedef void (*UsbDeviceHandleFunc)(UsbDevice *pdev); + +#define ADDR_ERROR_INVALID_INDEX 0xFF +#define ADDR_ERROR_INVALID_ADDRESS 0xFF + +template +class AddressPoolImpl : public AddressPool { + EpInfo dev0ep; //Endpoint data structure used during enumeration for uninitialized device + + uint8_t hubCounter; // hub counter is kept + // in order to avoid hub address duplication + + UsbDevice thePool[MAX_DEVICES_ALLOWED]; + + // Initialize address pool entry + + void InitEntry(uint8_t index) { + thePool[index].address.devAddress = 0; + thePool[index].epcount = 1; + thePool[index].lowspeed = 0; + thePool[index].epinfo = &dev0ep; + } + + // Return thePool index for a given address + + uint8_t FindAddressIndex(uint8_t address = 0) { + for (uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++) + if (thePool[i].address.devAddress == address) + return i; + + return 0; + } + + // Return thePool child index for a given parent + + uint8_t FindChildIndex(UsbDeviceAddress addr, uint8_t start = 1) { + for (uint8_t i = (start < 1 || start >= MAX_DEVICES_ALLOWED) ? 1 : start; i < MAX_DEVICES_ALLOWED; i++) { + if (thePool[i].address.bmParent == addr.bmAddress) + return i; + } + return 0; + } + + // Frees address entry specified by index parameter + + void FreeAddressByIndex(uint8_t index) { + // Zero field is reserved and should not be affected + if (index == 0) return; + + UsbDeviceAddress uda = thePool[index].address; + // If a hub was switched off all port addresses should be freed + if (uda.bmHub == 1) { + for (uint8_t i = 1; (i = FindChildIndex(uda, i));) + FreeAddressByIndex(i); + + // If the hub had the last allocated address, hubCounter should be decremented + if (hubCounter == uda.bmAddress) hubCounter--; + } + InitEntry(index); + } + + // Initialize the whole address pool at once + + void InitAllAddresses() { + for (uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++) + InitEntry(i); + + hubCounter = 0; + } + +public: + + AddressPoolImpl() : hubCounter(0) { + // Zero address is reserved + InitEntry(0); + + thePool[0].address.devAddress = 0; + thePool[0].epinfo = &dev0ep; + dev0ep.epAddr = 0; + dev0ep.maxPktSize = 8; + dev0ep.bmSndToggle = 0; // Set DATA0/1 toggles to 0 + dev0ep.bmRcvToggle = 0; + dev0ep.bmNakPower = USB_NAK_MAX_POWER; + + InitAllAddresses(); + } + + // Return a pointer to a specified address entry + + virtual UsbDevice* GetUsbDevicePtr(uint8_t addr) { + if (!addr) return thePool; + uint8_t index = FindAddressIndex(addr); + return index ? thePool + index : nullptr; + } + + // Perform an operation specified by pfunc for each addressed device + + void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) { + if (pfunc) { + for (uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++) + if (thePool[i].address.devAddress) + pfunc(thePool + i); + } + } + + // Allocate new address + + virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) { + /* if (parent != 0 && port == 0) + USB_HOST_SERIAL.println("PRT:0"); */ + UsbDeviceAddress _parent; + _parent.devAddress = parent; + if (_parent.bmReserved || port > 7) + //if(parent > 127 || port > 7) + return 0; + + if (is_hub && hubCounter == 7) return 0; + + // finds first empty address entry starting from one + uint8_t index = FindAddressIndex(0); + + if (!index) return 0; // if empty entry is not found + + if (_parent.devAddress == 0) { + if (is_hub) { + thePool[index].address.devAddress = 0x41; + hubCounter++; + } + else + thePool[index].address.devAddress = 1; + + return thePool[index].address.devAddress; + } + + UsbDeviceAddress addr; + addr.devAddress = 0; // Ensure all bits are zero + addr.bmParent = _parent.bmAddress; + if (is_hub) { + addr.bmHub = 1; + addr.bmAddress = ++hubCounter; + } + else { + addr.bmHub = 0; + addr.bmAddress = port; + } + thePool[index].address = addr; + /* + USB_HOST_SERIAL.print("Addr:"); + USB_HOST_SERIAL.print(addr.bmHub, HEX); + USB_HOST_SERIAL.print("."); + USB_HOST_SERIAL.print(addr.bmParent, HEX); + USB_HOST_SERIAL.print("."); + USB_HOST_SERIAL.println(addr.bmAddress, HEX); + */ + return thePool[index].address.devAddress; + } + + // Empty the pool entry + + virtual void FreeAddress(uint8_t addr) { + // if the root hub is disconnected all the addresses should be initialized + if (addr == 0x41) { + InitAllAddresses(); + return; + } + FreeAddressByIndex(FindAddressIndex(addr)); + } + + // Return number of hubs attached + // It can be helpful to find out if hubs are attached when getting the exact number of hubs. + //uint8_t GetNumHubs() { return hubCounter; } + //uint8_t GetNumDevices() { + // uint8_t counter = 0; + // for (uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++) + // if (thePool[i].address != 0); counter++; + // return counter; + //} +}; diff --git a/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h b/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h new file mode 100644 index 0000000..19d3756 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h @@ -0,0 +1,201 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ +#pragma once + +#ifndef _usb_h_ + #error "Never include confdescparser.h directly; include Usb.h instead" +#endif + +class UsbConfigXtracter { +public: + //virtual void ConfigXtract(const USB_FD_CONFIGURATION_DESCRIPTOR *conf) = 0; + //virtual void InterfaceXtract(uint8_t conf, const USB_FD_INTERFACE_DESCRIPTOR *iface) = 0; + + virtual void EndpointXtract(uint8_t conf __attribute__((unused)), uint8_t iface __attribute__((unused)), uint8_t alt __attribute__((unused)), uint8_t proto __attribute__((unused)), const USB_FD_ENDPOINT_DESCRIPTOR *ep __attribute__((unused))) { + } +}; + +#define CP_MASK_COMPARE_CLASS 1 +#define CP_MASK_COMPARE_SUBCLASS 2 +#define CP_MASK_COMPARE_PROTOCOL 4 +#define CP_MASK_COMPARE_ALL 7 + +// Configuration Descriptor Parser Class Template + +template +class ConfigDescParser : public USBReadParser { + UsbConfigXtracter *theXtractor; + MultiValueBuffer theBuffer; + MultiByteValueParser valParser; + ByteSkipper theSkipper; + uint8_t varBuffer[16 /*sizeof(USB_FD_CONFIGURATION_DESCRIPTOR)*/]; + + uint8_t stateParseDescr; // ParseDescriptor state + + uint8_t dscrLen; // Descriptor length + uint8_t dscrType; // Descriptor type + + bool isGoodInterface; // Appropriate interface flag + uint8_t confValue; // Configuration value + uint8_t protoValue; // Protocol value + uint8_t ifaceNumber; // Interface number + uint8_t ifaceAltSet; // Interface alternate settings + + bool UseOr; + bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn); + void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc); + +public: + + void SetOR() { UseOr = true; } + ConfigDescParser(UsbConfigXtracter *xtractor); + void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset); +}; + +template +ConfigDescParser::ConfigDescParser(UsbConfigXtracter *xtractor) : + theXtractor(xtractor), + stateParseDescr(0), + dscrLen(0), + dscrType(0), + UseOr(false) { + theBuffer.pValue = varBuffer; + valParser.Initialize(&theBuffer); + theSkipper.Initialize(&theBuffer); + }; + +template +void ConfigDescParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset __attribute__((unused))) { + uint16_t cntdn = (uint16_t)len; + uint8_t *p = (uint8_t*)pbuf; + while (cntdn) if (!ParseDescriptor(&p, &cntdn)) return; +} + +/* Parser for the configuration descriptor. Takes values for class, subclass, protocol fields in interface descriptor and + compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */ +template +bool ConfigDescParser::ParseDescriptor(uint8_t **pp, uint16_t *pcntdn) { + USB_FD_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); + USB_FD_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); + switch (stateParseDescr) { + case 0: + theBuffer.valueSize = 2; + valParser.Initialize(&theBuffer); + stateParseDescr = 1; + case 1: + if (!valParser.Parse(pp, pcntdn)) return false; + dscrLen = *((uint8_t*)theBuffer.pValue); + dscrType = *((uint8_t*)theBuffer.pValue + 1); + stateParseDescr = 2; + case 2: + // This is a sort of hack. Assuming that two bytes are all ready in the buffer + // the pointer is positioned two bytes ahead in order for the rest of descriptor + // to be read right after the size and the type fields. + // This should be used carefully. varBuffer should be used directly to handle data + // in the buffer. + theBuffer.pValue = varBuffer + 2; + stateParseDescr = 3; + case 3: + switch (dscrType) { + case USB_DESCRIPTOR_INTERFACE: + isGoodInterface = false; + break; + case USB_DESCRIPTOR_CONFIGURATION: + case USB_DESCRIPTOR_ENDPOINT: + case HID_DESCRIPTOR_HID: + break; + } + theBuffer.valueSize = dscrLen - 2; + valParser.Initialize(&theBuffer); + stateParseDescr = 4; + case 4: + switch (dscrType) { + case USB_DESCRIPTOR_CONFIGURATION: + if (!valParser.Parse(pp, pcntdn)) return false; + confValue = ucd->bConfigurationValue; + break; + case USB_DESCRIPTOR_INTERFACE: + if (!valParser.Parse(pp, pcntdn)) return false; + if ((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID) + break; + if ((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID) + break; + if (UseOr) { + if ((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol))) break; + } + else if ((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID) + break; + isGoodInterface = true; + ifaceNumber = uid->bInterfaceNumber; + ifaceAltSet = uid->bAlternateSetting; + protoValue = uid->bInterfaceProtocol; + break; + case USB_DESCRIPTOR_ENDPOINT: + if (!valParser.Parse(pp, pcntdn)) return false; + if (isGoodInterface && theXtractor) + theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_FD_ENDPOINT_DESCRIPTOR*)varBuffer); + break; + //case HID_DESCRIPTOR_HID: + // if (!valParser.Parse(pp, pcntdn)) return false; + // PrintHidDescriptor((const USB_HID_DESCRIPTOR*)varBuffer); + // break; + default: + if (!theSkipper.Skip(pp, pcntdn, dscrLen - 2)) return false; + } + theBuffer.pValue = varBuffer; + stateParseDescr = 0; + } + return true; +} + +template +void ConfigDescParser::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) { + Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); + Notify(PSTR("bDescLength:\t\t"), 0x80); + PrintHex (pDesc->bLength, 0x80); + + Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); + PrintHex (pDesc->bDescriptorType, 0x80); + + Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); + PrintHex (pDesc->bcdHID, 0x80); + + Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); + PrintHex (pDesc->bCountryCode, 0x80); + + Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); + PrintHex (pDesc->bNumDescriptors, 0x80); + + for (uint8_t i = 0; i < pDesc->bNumDescriptors; i++) { + HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType); + + Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); + PrintHex (pLT[i].bDescrType, 0x80); + + Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); + PrintHex (pLT[i].wDescriptorLength, 0x80); + } + Notify(PSTR("\r\n"), 0x80); +} diff --git a/src/sd/usb_flashdrive/lib-uhs2/hexdump.h b/src/sd/usb_flashdrive/lib-uhs2/hexdump.h new file mode 100644 index 0000000..c948e5a --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/hexdump.h @@ -0,0 +1,68 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ +#pragma once + +#ifndef _usb_h_ + #error "Never include hexdump.h directly; include Usb.h instead" +#endif + +extern int UsbDEBUGlvl; + +template +class HexDumper : public BASE_CLASS { + uint8_t byteCount; + OFFSET_TYPE byteTotal; + +public: + + HexDumper() : byteCount(0), byteTotal(0) { + }; + + void Initialize() { + byteCount = 0; + byteTotal = 0; + }; + + void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); +}; + +template +void HexDumper::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset __attribute__((unused))) { + if (UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug. + for (LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) { + if (!byteCount) { + PrintHex (byteTotal, 0x80); + E_Notify(PSTR(": "), 0x80); + } + PrintHex (pbuf[j], 0x80); + E_Notify(PSTR(" "), 0x80); + + if (byteCount == 15) { + E_Notify(PSTR("\r\n"), 0x80); + byteCount = 0xFF; + } + } + } +} diff --git a/src/sd/usb_flashdrive/lib-uhs2/macros.h b/src/sd/usb_flashdrive/lib-uhs2/macros.h new file mode 100644 index 0000000..8cb5b6b --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/macros.h @@ -0,0 +1,86 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ +#pragma once + +#ifndef _usb_h_ + #error "Never include macros.h directly; include Usb.h instead" +#endif + +//////////////////////////////////////////////////////////////////////////////// +// HANDY MACROS +//////////////////////////////////////////////////////////////////////////////// + +#define VALUE_BETWEEN(v,l,h) (((v)>(l)) && ((v)<(h))) +#define VALUE_WITHIN(v,l,h) (((v)>=(l)) && ((v)<=(h))) +#define output_pgm_message(wa,fp,mp,el) wa = &mp, fp((char *)pgm_read_pointer(wa), el) +#define output_if_between(v,l,h,wa,fp,mp,el) if (VALUE_BETWEEN(v,l,h)) output_pgm_message(wa,fp,mp[v-(l+1)],el); + +#define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))) +#ifndef __BYTE_GRABBING_DEFINED__ +#define __BYTE_GRABBING_DEFINED__ 1 +#ifdef BROKEN_OPTIMIZER_LITTLE_ENDIAN +// Note: Use this if your compiler generates horrible assembler! +#define BGRAB0(__usi__) (((uint8_t *)&(__usi__))[0]) +#define BGRAB1(__usi__) (((uint8_t *)&(__usi__))[1]) +#define BGRAB2(__usi__) (((uint8_t *)&(__usi__))[2]) +#define BGRAB3(__usi__) (((uint8_t *)&(__usi__))[3]) +#define BGRAB4(__usi__) (((uint8_t *)&(__usi__))[4]) +#define BGRAB5(__usi__) (((uint8_t *)&(__usi__))[5]) +#define BGRAB6(__usi__) (((uint8_t *)&(__usi__))[6]) +#define BGRAB7(__usi__) (((uint8_t *)&(__usi__))[7]) +#else +// Note: The cast alone to uint8_t is actually enough. +// GCC throws out the "& 0xFF", and the size is no different. +// Some compilers need it. +#define BGRAB0(__usi__) ((uint8_t)((__usi__) & 0xFF )) +#define BGRAB1(__usi__) ((uint8_t)(((__usi__) >> 8) & 0xFF)) +#define BGRAB2(__usi__) ((uint8_t)(((__usi__) >> 16) & 0xFF)) +#define BGRAB3(__usi__) ((uint8_t)(((__usi__) >> 24) & 0xFF)) +#define BGRAB4(__usi__) ((uint8_t)(((__usi__) >> 32) & 0xFF)) +#define BGRAB5(__usi__) ((uint8_t)(((__usi__) >> 40) & 0xFF)) +#define BGRAB6(__usi__) ((uint8_t)(((__usi__) >> 48) & 0xFF)) +#define BGRAB7(__usi__) ((uint8_t)(((__usi__) >> 56) & 0xFF)) +#endif +#define BOVER1(__usi__) ((uint16_t)(__usi__) << 8) +#define BOVER2(__usi__) ((uint32_t)(__usi__) << 16) +#define BOVER3(__usi__) ((uint32_t)(__usi__) << 24) +#define BOVER4(__usi__) ((uint64_t)(__usi__) << 32) +#define BOVER5(__usi__) ((uint64_t)(__usi__) << 40) +#define BOVER6(__usi__) ((uint64_t)(__usi__) << 48) +#define BOVER7(__usi__) ((uint64_t)(__usi__) << 56) + +// These are the smallest and fastest ways I have found so far in pure C/C++. +#define BMAKE16(__usc1__,__usc0__) ((uint16_t)((uint16_t)(__usc0__) | (uint16_t)BOVER1(__usc1__))) +#define BMAKE32(__usc3__,__usc2__,__usc1__,__usc0__) ((uint32_t)((uint32_t)(__usc0__) | (uint32_t)BOVER1(__usc1__) | (uint32_t)BOVER2(__usc2__) | (uint32_t)BOVER3(__usc3__))) +#define BMAKE64(__usc7__,__usc6__,__usc5__,__usc4__,__usc3__,__usc2__,__usc1__,__usc0__) ((uint64_t)((uint64_t)__usc0__ | (uint64_t)BOVER1(__usc1__) | (uint64_t)BOVER2(__usc2__) | (uint64_t)BOVER3(__usc3__) | (uint64_t)BOVER4(__usc4__) | (uint64_t)BOVER5(__usc5__) | (uint64_t)BOVER6(__usc6__) | (uint64_t)BOVER1(__usc7__))) +#endif + +/* + * Debug macros: Strings are stored in progmem (flash) instead of RAM. + */ +#define USBTRACE(s) (Notify(PSTR(s), 0x80)) +#define USBTRACE1(s,l) (Notify(PSTR(s), l)) +#define USBTRACE2(s,r) (Notify(PSTR(s), 0x80), D_PrintHex((r), 0x80), Notify(PSTR("\r\n"), 0x80)) +#define USBTRACE3(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l), Notify(PSTR("\r\n"), l)) diff --git a/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp b/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp new file mode 100644 index 0000000..1aeef17 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp @@ -0,0 +1,1209 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB) + +#include "masstorage.h" + +const uint8_t BulkOnly::epDataInIndex = 1; +const uint8_t BulkOnly::epDataOutIndex = 2; +const uint8_t BulkOnly::epInterruptInIndex = 3; + +//////////////////////////////////////////////////////////////////////////////// +// Interface code +//////////////////////////////////////////////////////////////////////////////// + +/** + * Get the capacity of the media + * + * @param lun Logical Unit Number + * @return media capacity + */ +uint32_t BulkOnly::GetCapacity(uint8_t lun) { + return LUNOk[lun] ? CurrentCapacity[lun] : 0UL; +} + +/** + * Get the sector (block) size used on the media + * + * @param lun Logical Unit Number + * @return media sector size + */ +uint16_t BulkOnly::GetSectorSize(uint8_t lun) { + return LUNOk[lun] ? CurrentSectorSize[lun] : 0U; +} + +/** + * Test if LUN is ready for use + * + * @param lun Logical Unit Number + * @return true if LUN is ready for use + */ +bool BulkOnly::LUNIsGood(uint8_t lun) { return LUNOk[lun]; } + +/** + * Test if LUN is write protected + * + * @param lun Logical Unit Number + * @return cached status of write protect switch + */ +bool BulkOnly::WriteProtected(uint8_t lun) { return WriteOk[lun]; } + +/** + * Wrap and execute a SCSI CDB with length of 6 + * + * @param cdb CDB to execute + * @param buf_size Size of expected transaction + * @param buf Buffer + * @param dir MASS_CMD_DIR_IN | MASS_CMD_DIR_OUT + * @return + */ +uint8_t BulkOnly::SCSITransaction6(CDB6_t *cdb, uint16_t buf_size, void *buf, uint8_t dir) { + // promote buf_size to 32bits. + CommandBlockWrapper cbw = CommandBlockWrapper(++dCBWTag, (uint32_t)buf_size, cdb, dir); + //SetCurLUN(cdb->LUN); + return (HandleSCSIError(Transaction(&cbw, buf_size, buf))); +} + +/** + * Wrap and execute a SCSI CDB with length of 10 + * + * @param cdb CDB to execute + * @param buf_size Size of expected transaction + * @param buf Buffer + * @param dir MASS_CMD_DIR_IN | MASS_CMD_DIR_OUT + * @return + */ +uint8_t BulkOnly::SCSITransaction10(CDB10_t *cdb, uint16_t buf_size, void *buf, uint8_t dir) { + // promote buf_size to 32bits. + CommandBlockWrapper cbw = CommandBlockWrapper(++dCBWTag, (uint32_t)buf_size, cdb, dir); + //SetCurLUN(cdb->LUN); + return (HandleSCSIError(Transaction(&cbw, buf_size, buf))); +} + +/** + * Lock or Unlock the tray or door on device. + * Caution: Some devices with buggy firmware will lock up. + * + * @param lun Logical Unit Number + * @param lock 1 to lock, 0 to unlock + * @return + */ +uint8_t BulkOnly::LockMedia(uint8_t lun, uint8_t lock) { + Notify(PSTR("\r\nLockMedia\r\n"), 0x80); + Notify(PSTR("---------\r\n"), 0x80); + + CDB6_t cdb = CDB6_t(SCSI_CMD_PREVENT_REMOVAL, lun, (uint8_t)0, lock); + return SCSITransaction6(&cdb, (uint16_t)0, nullptr, (uint8_t)MASS_CMD_DIR_IN); +} + +/** + * Media control, for spindle motor and media tray or door. + * This includes CDROM, TAPE and anything with a media loader. + * + * @param lun Logical Unit Number + * @param ctl 0x00 Stop Motor, 0x01 Start Motor, 0x02 Eject Media, 0x03 Load Media + * @return 0 on success + */ +uint8_t BulkOnly::MediaCTL(uint8_t lun, uint8_t ctl) { + Notify(PSTR("\r\nMediaCTL\r\n"), 0x80); + Notify(PSTR("-----------------\r\n"), 0x80); + + uint8_t rcode = MASS_ERR_UNIT_NOT_READY; + if (bAddress) { + CDB6_t cdb = CDB6_t(SCSI_CMD_START_STOP_UNIT, lun, ctl & 0x03, 0); + rcode = SCSITransaction6(&cdb, (uint16_t)0, nullptr, (uint8_t)MASS_CMD_DIR_OUT); + } + else + SetCurLUN(lun); + + return rcode; +} + +/** + * Read data from media + * + * @param lun Logical Unit Number + * @param addr LBA address on media to read + * @param bsize size of a block (we should probably use the cached size) + * @param blocks how many blocks to read + * @param buf memory that is able to hold the requested data + * @return 0 on success + */ +uint8_t BulkOnly::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf) { + if (!LUNOk[lun]) return MASS_ERR_NO_MEDIA; + Notify(PSTR("\r\nRead LUN:\t"), 0x80); + D_PrintHex (lun, 0x90); + Notify(PSTR("\r\nLBA:\t\t"), 0x90); + D_PrintHex (addr, 0x90); + Notify(PSTR("\r\nblocks:\t\t"), 0x90); + D_PrintHex (blocks, 0x90); + Notify(PSTR("\r\nblock size:\t"), 0x90); + D_PrintHex (bsize, 0x90); + Notify(PSTR("\r\n---------\r\n"), 0x80); + CDB10_t cdb = CDB10_t(SCSI_CMD_READ_10, lun, blocks, addr); + +again: + uint8_t er = SCSITransaction10(&cdb, ((uint16_t)bsize * blocks), buf, (uint8_t)MASS_CMD_DIR_IN); + + if (er == MASS_ERR_STALL) { + MediaCTL(lun, 1); + delay(150); + if (!TestUnitReady(lun)) goto again; + } + return er; +} + +/** + * Write data to media + * + * @param lun Logical Unit Number + * @param addr LBA address on media to write + * @param bsize size of a block (we should probably use the cached size) + * @param blocks how many blocks to write + * @param buf memory that contains the data to write + * @return 0 on success + */ +uint8_t BulkOnly::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) { + if (!LUNOk[lun]) return MASS_ERR_NO_MEDIA; + if (!WriteOk[lun]) return MASS_ERR_WRITE_PROTECTED; + Notify(PSTR("\r\nWrite LUN:\t"), 0x80); + D_PrintHex (lun, 0x90); + Notify(PSTR("\r\nLBA:\t\t"), 0x90); + D_PrintHex (addr, 0x90); + Notify(PSTR("\r\nblocks:\t\t"), 0x90); + D_PrintHex (blocks, 0x90); + Notify(PSTR("\r\nblock size:\t"), 0x90); + D_PrintHex (bsize, 0x90); + Notify(PSTR("\r\n---------\r\n"), 0x80); + CDB10_t cdb = CDB10_t(SCSI_CMD_WRITE_10, lun, blocks, addr); + +again: + uint8_t er = SCSITransaction10(&cdb, ((uint16_t)bsize * blocks), (void*)buf, (uint8_t)MASS_CMD_DIR_OUT); + + if (er == MASS_ERR_WRITE_STALL) { + MediaCTL(lun, 1); + delay(150); + if (!TestUnitReady(lun)) goto again; + } + return er; +} + +// End of user functions, the remaining code below is driver internals. +// Only developer serviceable parts below! + +//////////////////////////////////////////////////////////////////////////////// +// Main driver code +//////////////////////////////////////////////////////////////////////////////// + +BulkOnly::BulkOnly(USB *p) : +pUsb(p), +bAddress(0), +bIface(0), +bNumEP(1), +qNextPollTime(0), +bPollEnable(false), +//dCBWTag(0), +bLastUsbError(0) { + ClearAllEP(); + dCBWTag = 0; + if (pUsb) pUsb->RegisterDeviceClass(this); +} + +/** + * USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET == success + * We need to standardize either the rcode, or change the API to return values + * so a signal that additional actions are required can be produced. + * Some of these codes do exist already. + * + * TECHNICAL: We could do most of this code elsewhere, with the exception of checking the class instance. + * Doing so would save some program memory when using multiple drivers. + * + * @param parent USB address of parent + * @param port address of port on parent + * @param lowspeed true if device is low speed + * @return + */ +uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { + + const uint8_t constBufSize = sizeof (USB_FD_DEVICE_DESCRIPTOR); + + uint8_t buf[constBufSize]; + USB_FD_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); + uint8_t rcode; + UsbDevice *p = nullptr; + EpInfo *oldep_ptr = nullptr; + USBTRACE("MS ConfigureDevice\r\n"); + ClearAllEP(); + AddressPool &addrPool = pUsb->GetAddressPool(); + + if (bAddress) return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; + + // + // Get pointer to pseudo device with address 0 assigned + p = addrPool.GetUsbDevicePtr(0); + if (!p) return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; + + if (!p->epinfo) { + USBTRACE("epinfo\r\n"); + return USB_ERROR_EPINFO_IS_NULL; + } + + // Save old pointer to EP_RECORD of address 0 + oldep_ptr = p->epinfo; + + // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence + p->epinfo = epInfo; + + p->lowspeed = lowspeed; + // Get device descriptor + rcode = pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf); + + // Restore p->epinfo + p->epinfo = oldep_ptr; + + if (rcode) goto FailGetDevDescr; + + // Allocate new address according to device class + bAddress = addrPool.AllocAddress(parent, false, port); + + if (!bAddress) return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; + + // Extract Max Packet Size from the device descriptor + epInfo[0].maxPktSize = udd->bMaxPacketSize0; + // Steal and abuse from epInfo structure to save on memory. + epInfo[1].epAddr = udd->bNumConfigurations; + // + return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET; + +FailGetDevDescr: + + #ifdef DEBUG_USB_HOST + NotifyFailGetDevDescr(rcode); + #endif + rcode = USB_ERROR_FailGetDevDescr; + + Release(); + return rcode; +} + +/** + * @param parent (not used) + * @param port (not used) + * @param lowspeed true if device is low speed + * @return 0 for success + */ +uint8_t BulkOnly::Init(uint8_t parent __attribute__((unused)), uint8_t port __attribute__((unused)), bool lowspeed) { + uint8_t rcode; + uint8_t num_of_conf = epInfo[1].epAddr; // number of configurations + epInfo[1].epAddr = 0; + USBTRACE("MS Init\r\n"); + + AddressPool &addrPool = pUsb->GetAddressPool(); + UsbDevice *p = addrPool.GetUsbDevicePtr(bAddress); + + if (!p) return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; + + // Assign new address to the device + delay(2000); + rcode = pUsb->setAddr(0, 0, bAddress); + + if (rcode) { + p->lowspeed = false; + addrPool.FreeAddress(bAddress); + bAddress = 0; + USBTRACE2("setAddr:", rcode); + return rcode; + } + + USBTRACE2("Addr:", bAddress); + + p->lowspeed = false; + + p = addrPool.GetUsbDevicePtr(bAddress); + + if (!p) return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; + + p->lowspeed = lowspeed; + + // Assign epInfo to epinfo pointer + rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); + + if (rcode) goto FailSetDevTblEntry; + + USBTRACE2("NC:", num_of_conf); + + for (uint8_t i = 0; i < num_of_conf; i++) { + ConfigDescParser< USB_CLASS_MASS_STORAGE, + MASS_SUBCLASS_SCSI, + MASS_PROTO_BBB, + CP_MASK_COMPARE_CLASS | + CP_MASK_COMPARE_SUBCLASS | + CP_MASK_COMPARE_PROTOCOL > BulkOnlyParser(this); + + rcode = pUsb->getConfDescr(bAddress, 0, i, &BulkOnlyParser); + + if (rcode) goto FailGetConfDescr; + + if (bNumEP > 1) break; + } + + if (bNumEP < 3) return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; + + // Assign epInfo to epinfo pointer + pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); + + USBTRACE2("Conf:", bConfNum); + + // Set Configuration Value + rcode = pUsb->setConf(bAddress, 0, bConfNum); + + if (rcode) goto FailSetConfDescr; + + //Linux does a 1sec delay after this. + delay(1000); + + rcode = GetMaxLUN(&bMaxLUN); + if (rcode) goto FailGetMaxLUN; + + if (bMaxLUN >= MASS_MAX_SUPPORTED_LUN) bMaxLUN = MASS_MAX_SUPPORTED_LUN - 1; + ErrorMessage (PSTR("MaxLUN"), bMaxLUN); + + delay(1000); // Delay a bit for slow firmware. + + for (uint8_t lun = 0; lun <= bMaxLUN; lun++) { + InquiryResponse response; + rcode = Inquiry(lun, sizeof (InquiryResponse), (uint8_t*) & response); + if (rcode) { + ErrorMessage (PSTR("Inquiry"), rcode); + } + else { + #if 0 + printf("LUN %i `", lun); + uint8_t *buf = response.VendorID; + for (int i = 0; i < 28; i++) printf("%c", buf[i]); + printf("'\r\nQualifier %1.1X ", response.PeripheralQualifier); + printf("Device type %2.2X ", response.DeviceType); + printf("RMB %1.1X ", response.Removable); + printf("SSCS %1.1X ", response.SCCS); + uint8_t sv = response.Version; + printf("SCSI version %2.2X\r\nDevice conforms to ", sv); + switch (sv) { + case 0: + printf("No specific"); + break; + case 1: + printf("ANSI X3.131-1986 (ANSI 1)"); + break; + case 2: + printf("ANSI X3.131-1994 (ANSI 2)"); + break; + case 3: + printf("ANSI INCITS 301-1997 (SPC)"); + break; + case 4: + printf("ANSI INCITS 351-2001 (SPC-2)"); + break; + case 5: + printf("ANSI INCITS 408-2005 (SPC-4)"); + break; + case 6: + printf("T10/1731-D (SPC-4)"); + break; + default: printf("unknown"); + } + printf(" standards.\r\n"); + #endif + + uint8_t tries = 0xF0; + while ((rcode = TestUnitReady(lun))) { + if (rcode == 0x08) break; // break on no media, this is OK to do. + // try to lock media and spin up + if (tries < 14) { + LockMedia(lun, 1); + MediaCTL(lun, 1); // I actually have a USB stick that needs this! + } else + delay(2 * (tries + 1)); + tries++; + if (!tries) break; + } + if (!rcode) { + delay(1000); + LUNOk[lun] = CheckLUN(lun); + if (!LUNOk[lun]) LUNOk[lun] = CheckLUN(lun); + } + } + } + + CheckMedia(); + + rcode = OnInit(); + + if (rcode) goto FailOnInit; + + #ifdef DEBUG_USB_HOST + USBTRACE("MS configured\r\n\r\n"); + #endif + + bPollEnable = true; + + //USBTRACE("Poll enabled\r\n"); + return 0; + + FailSetConfDescr: + + #ifdef DEBUG_USB_HOST + NotifyFailSetConfDescr(); + goto Fail; + #endif + + FailOnInit: + + #ifdef DEBUG_USB_HOST + USBTRACE("OnInit:"); + goto Fail; + #endif + + FailGetMaxLUN: + + #ifdef DEBUG_USB_HOST + USBTRACE("GetMaxLUN:"); + goto Fail; + #endif + + //#ifdef DEBUG_USB_HOST + // FailInvalidSectorSize: + // USBTRACE("Sector Size is NOT VALID: "); + // goto Fail; + //#endif + + FailSetDevTblEntry: + #ifdef DEBUG_USB_HOST + NotifyFailSetDevTblEntry(); + goto Fail; + #endif + + FailGetConfDescr: + #ifdef DEBUG_USB_HOST + NotifyFailGetConfDescr(); + #endif + + #ifdef DEBUG_USB_HOST + Fail: + NotifyFail(rcode); + #endif + Release(); + return rcode; +} + +/** + * For driver use only. + * + * @param conf + * @param iface + * @param alt + * @param proto + * @param pep + */ +void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto __attribute__((unused)), const USB_FD_ENDPOINT_DESCRIPTOR * pep) { + ErrorMessage (PSTR("Conf.Val"), conf); + ErrorMessage (PSTR("Iface Num"), iface); + ErrorMessage (PSTR("Alt.Set"), alt); + + bConfNum = conf; + + uint8_t index; + + #if 1 + if ((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) { + index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; + // Fill in the endpoint info structure + epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); + epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize; + epInfo[index].bmSndToggle = 0; + epInfo[index].bmRcvToggle = 0; + + bNumEP++; + + PrintEndpointDescriptor(pep); + } + #else + if ((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80) + index = epInterruptInIndex; + else if ((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) + index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; + else + return; + + // Fill in the endpoint info structure + epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); + epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize; + epInfo[index].bmSndToggle = 0; + epInfo[index].bmRcvToggle = 0; + + bNumEP++; + + PrintEndpointDescriptor(pep); + #endif +} + +/** + * For driver use only. + * + * @return + */ +uint8_t BulkOnly::Release() { + ClearAllEP(); + pUsb->GetAddressPool().FreeAddress(bAddress); + return 0; +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @return true if LUN is ready for use. + */ +bool BulkOnly::CheckLUN(uint8_t lun) { + uint8_t rcode; + Capacity capacity; + for (uint8_t i = 0; i < 8; i++) capacity.data[i] = 0; + + rcode = ReadCapacity10(lun, (uint8_t*)capacity.data); + if (rcode) { + //printf(">>>>>>>>>>>>>>>>ReadCapacity returned %i\r\n", rcode); + return false; + } + ErrorMessage (PSTR(">>>>>>>>>>>>>>>>CAPACITY OK ON LUN"), lun); + for (uint8_t i = 0; i < 8 /*sizeof (Capacity)*/; i++) + D_PrintHex (capacity.data[i], 0x80); + Notify(PSTR("\r\n\r\n"), 0x80); + + // Only 512/1024/2048/4096 are valid values! + uint32_t c = BMAKE32(capacity.data[4], capacity.data[5], capacity.data[6], capacity.data[7]); + if (c != 0x0200UL && c != 0x0400UL && c != 0x0800UL && c != 0x1000UL) return false; + + // Store capacity information. + CurrentSectorSize[lun] = (uint16_t)(c); // & 0xFFFF); + + CurrentCapacity[lun] = BMAKE32(capacity.data[0], capacity.data[1], capacity.data[2], capacity.data[3]) + 1; + if (CurrentCapacity[lun] == /*0xFFFFFFFFUL */ 0x01UL || CurrentCapacity[lun] == 0x00UL) { + // Buggy firmware will report 0xFFFFFFFF or 0 for no media + if (CurrentCapacity[lun]) + ErrorMessage (PSTR(">>>>>>>>>>>>>>>>BUGGY FIRMWARE. CAPACITY FAIL ON LUN"), lun); + return false; + } + delay(20); + Page3F(lun); + return !TestUnitReady(lun); +} + +/** + * For driver use only. + * + * Scan for media change on all LUNs + */ +void BulkOnly::CheckMedia() { + for (uint8_t lun = 0; lun <= bMaxLUN; lun++) { + if (TestUnitReady(lun)) { + LUNOk[lun] = false; + continue; + } + if (!LUNOk[lun]) LUNOk[lun] = CheckLUN(lun); + } + #if 0 + printf("}}}}}}}}}}}}}}}}STATUS "); + for (uint8_t lun = 0; lun <= bMaxLUN; lun++) + printf(LUNOk[lun] ? "#" : "."); + printf("\r\n"); + #endif + qNextPollTime = (uint32_t)millis() + 2000; +} + +/** + * For driver use only. + * + * @return + */ +uint8_t BulkOnly::Poll() { + //uint8_t rcode = 0; + if (!bPollEnable) return 0; + if ((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L) CheckMedia(); + //rcode = 0; + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// SCSI code +//////////////////////////////////////////////////////////////////////////////// + +/** + * For driver use only. + * + * @param plun + * @return + */ +uint8_t BulkOnly::GetMaxLUN(uint8_t *plun) { + uint8_t ret = pUsb->ctrlReq(bAddress, 0, bmREQ_MASSIN, MASS_REQ_GET_MAX_LUN, 0, 0, bIface, 1, 1, plun, nullptr); + + if (ret == hrSTALL) + *plun = 0; + + return 0; +} + +/** + * For driver use only. Used during Driver Init + * + * @param lun Logical Unit Number + * @param bsize + * @param buf + * @return + */ +uint8_t BulkOnly::Inquiry(uint8_t lun, uint16_t bsize, uint8_t *buf) { + Notify(PSTR("\r\nInquiry\r\n"), 0x80); + Notify(PSTR("---------\r\n"), 0x80); + + CDB6_t cdb = CDB6_t(SCSI_CMD_INQUIRY, lun, 0UL, (uint8_t)bsize, 0); + uint8_t rc = SCSITransaction6(&cdb, bsize, buf, (uint8_t)MASS_CMD_DIR_IN); + + return rc; +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @return + */ +uint8_t BulkOnly::TestUnitReady(uint8_t lun) { + //SetCurLUN(lun); + if (!bAddress) + return MASS_ERR_UNIT_NOT_READY; + + Notify(PSTR("\r\nTestUnitReady\r\n"), 0x80); + Notify(PSTR("-----------------\r\n"), 0x80); + + CDB6_t cdb = CDB6_t(SCSI_CMD_TEST_UNIT_READY, lun, (uint8_t)0, 0); + return SCSITransaction6(&cdb, 0, nullptr, (uint8_t)MASS_CMD_DIR_IN); + +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @param pc + * @param page + * @param subpage + * @param len + * @param pbuf + * @return + */ +uint8_t BulkOnly::ModeSense6(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t * pbuf) { + Notify(PSTR("\r\rModeSense\r\n"), 0x80); + Notify(PSTR("------------\r\n"), 0x80); + + CDB6_t cdb = CDB6_t(SCSI_CMD_MODE_SENSE_6, lun, (uint32_t)((((pc << 6) | page) << 8) | subpage), len, 0); + return SCSITransaction6(&cdb, len, pbuf, (uint8_t)MASS_CMD_DIR_IN); +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @param bsize + * @param buf + * @return + */ +uint8_t BulkOnly::ReadCapacity10(uint8_t lun, uint8_t *buf) { + Notify(PSTR("\r\nReadCapacity\r\n"), 0x80); + Notify(PSTR("---------------\r\n"), 0x80); + + CDB10_t cdb = CDB10_t(SCSI_CMD_READ_CAPACITY_10, lun); + return SCSITransaction10(&cdb, 8, buf, (uint8_t)MASS_CMD_DIR_IN); +} + +/** + * For driver use only. + * + * Page 3F contains write protect status. + * + * @param lun Logical Unit Number to test. + * @return Write protect switch status. + */ +uint8_t BulkOnly::Page3F(uint8_t lun) { + uint8_t buf[192]; + for (int i = 0; i < 192; i++) { + buf[i] = 0x00; + } + WriteOk[lun] = true; + #ifdef SKIP_WRITE_PROTECT + return 0; + #endif + uint8_t rc = ModeSense6(lun, 0, 0x3F, 0, 192, buf); + if (!rc) { + WriteOk[lun] = ((buf[2] & 0x80) == 0); + Notify(PSTR("Mode Sense: "), 0x80); + for (int i = 0; i < 4; i++) { + D_PrintHex (buf[i], 0x80); + Notify(PSTR(" "), 0x80); + } + Notify(PSTR("\r\n"), 0x80); + } + return rc; +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @param size + * @param buf + * @return + */ +uint8_t BulkOnly::RequestSense(uint8_t lun, uint16_t size, uint8_t *buf) { + Notify(PSTR("\r\nRequestSense\r\n"), 0x80); + Notify(PSTR("----------------\r\n"), 0x80); + + CDB6_t cdb = CDB6_t(SCSI_CMD_REQUEST_SENSE, lun, 0UL, (uint8_t)size, 0); + CommandBlockWrapper cbw = CommandBlockWrapper(++dCBWTag, (uint32_t)size, &cdb, (uint8_t)MASS_CMD_DIR_IN); + //SetCurLUN(lun); + return Transaction(&cbw, size, buf); +} + + +//////////////////////////////////////////////////////////////////////////////// +// USB code +//////////////////////////////////////////////////////////////////////////////// + +/** + * For driver use only. + * + * @param index + * @return + */ +uint8_t BulkOnly::ClearEpHalt(uint8_t index) { + if (index == 0) + return 0; + + uint8_t ret = 0; + + while ((ret = (pUsb->ctrlReq(bAddress, 0, USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_ENDPOINT, USB_REQUEST_CLEAR_FEATURE, USB_FEATURE_ENDPOINT_HALT, 0, ((index == epDataInIndex) ? (0x80 | epInfo[index].epAddr) : epInfo[index].epAddr), 0, 0, nullptr, nullptr)) == 0x01)) + delay(6); + + if (ret) { + ErrorMessage (PSTR("ClearEpHalt"), ret); + ErrorMessage (PSTR("EP"), ((index == epDataInIndex) ? (0x80 | epInfo[index].epAddr) : epInfo[index].epAddr)); + return ret; + } + epInfo[index].bmSndToggle = 0; + epInfo[index].bmRcvToggle = 0; + return 0; +} + +/** + * For driver use only. + */ +void BulkOnly::Reset() { + while (pUsb->ctrlReq(bAddress, 0, bmREQ_MASSOUT, MASS_REQ_BOMSR, 0, 0, bIface, 0, 0, nullptr, nullptr) == 0x01) delay(6); +} + +/** + * For driver use only. + * + * @return 0 if successful + */ +uint8_t BulkOnly::ResetRecovery() { + Notify(PSTR("\r\nResetRecovery\r\n"), 0x80); + Notify(PSTR("-----------------\r\n"), 0x80); + + delay(6); + Reset(); + delay(6); + ClearEpHalt(epDataInIndex); + delay(6); + bLastUsbError = ClearEpHalt(epDataOutIndex); + delay(6); + return bLastUsbError; +} + +/** + * For driver use only. + * + * Clear all EP data and clear all LUN status + */ +void BulkOnly::ClearAllEP() { + for (uint8_t i = 0; i < MASS_MAX_ENDPOINTS; i++) { + epInfo[i].epAddr = 0; + epInfo[i].maxPktSize = (i) ? 0 : 8; + epInfo[i].bmSndToggle = 0; + epInfo[i].bmRcvToggle = 0; + epInfo[i].bmNakPower = USB_NAK_DEFAULT; + } + + for (uint8_t i = 0; i < MASS_MAX_SUPPORTED_LUN; i++) { + LUNOk[i] = false; + WriteOk[i] = false; + CurrentCapacity[i] = 0UL; + CurrentSectorSize[i] = 0; + } + + bIface = 0; + bNumEP = 1; + bAddress = 0; + qNextPollTime = 0; + bPollEnable = false; + bLastUsbError = 0; + bMaxLUN = 0; + bTheLUN = 0; +} + +/** + * For driver use only. + * + * @param pcsw + * @param pcbw + * @return + */ +bool BulkOnly::IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw) { + if (pcsw->dCSWSignature != MASS_CSW_SIGNATURE) { + Notify(PSTR("CSW:Sig error\r\n"), 0x80); + return false; + } + if (pcsw->dCSWTag != pcbw->dCBWTag) { + Notify(PSTR("CSW:Wrong tag\r\n"), 0x80); + return false; + } + return true; +} + +/** + * For driver use only. + * + * @param error + * @param index + * @return + */ +uint8_t BulkOnly::HandleUsbError(uint8_t error, uint8_t index) { + uint8_t count = 3; + + bLastUsbError = error; + //if (error) + //ClearEpHalt(index); + while (error && count) { + if (error != hrSUCCESS) { + ErrorMessage (PSTR("USB Error"), error); + ErrorMessage (PSTR("Index"), index); + } + switch (error) { + // case hrWRONGPID: + case hrSUCCESS: return MASS_ERR_SUCCESS; + case hrBUSY: return MASS_ERR_UNIT_BUSY; // SIE is busy, just hang out and try again. + case hrTIMEOUT: + case hrJERR: return MASS_ERR_DEVICE_DISCONNECTED; + case hrSTALL: + if (index) { + ClearEpHalt(index); + return (index == epDataInIndex) ? MASS_ERR_STALL : MASS_ERR_WRITE_STALL; + } + return MASS_ERR_STALL; + + case hrNAK: + return index ? MASS_ERR_UNIT_BUSY : MASS_ERR_UNIT_BUSY; + + case hrTOGERR: + // Handle a super rare corner case, where toggles become de-synced. + // I've only run into one device that has this firmware bug, and this is + // the only clean way to get back into sync with the buggy device firmware. + // --AJK + if (bAddress && bConfNum) { + error = pUsb->setConf(bAddress, 0, bConfNum); + if (error) break; + } + return MASS_ERR_SUCCESS; + default: + ErrorMessage (PSTR("\r\nUSB"), error); + return MASS_ERR_GENERAL_USB_ERROR; + } + count--; + } // while + + return ((error && !count) ? MASS_ERR_GENERAL_USB_ERROR : MASS_ERR_SUCCESS); +} + +/** + * For driver use only. + * + * @param pcbw + * @param buf_size + * @param buf + * @param flags + * @return + */ +uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf + OPTARG(MS_WANT_PARSER, uint8_t flags/*=0*/) +) { + #if MS_WANT_PARSER + uint16_t bytes = (pcbw->dCBWDataTransferLength > buf_size) ? buf_size : pcbw->dCBWDataTransferLength; + printf("Transfersize %i\r\n", bytes); + delay(1000); + + bool callback = (flags & MASS_TRANS_FLG_CALLBACK) == MASS_TRANS_FLG_CALLBACK; + #else + uint16_t bytes = buf_size; + #endif + + bool write = (pcbw->bmCBWFlags & MASS_CMD_DIR_IN) != MASS_CMD_DIR_IN; + uint8_t ret = 0; + uint8_t usberr; + CommandStatusWrapper csw; // up here, we allocate ahead to save cpu cycles. + SetCurLUN(pcbw->bmCBWLUN); + ErrorMessage (PSTR("CBW.dCBWTag"), pcbw->dCBWTag); + + while ((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw)) == hrBUSY) delay(1); + + ret = HandleUsbError(usberr, epDataOutIndex); + //ret = HandleUsbError(pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw), epDataOutIndex); + if (ret) + ErrorMessage (PSTR("============================ CBW"), ret); + else { + if (bytes) { + if (!write) { + #if MS_WANT_PARSER + if (callback) { + uint8_t rbuf[bytes]; + while ((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, rbuf)) == hrBUSY) delay(1); + if (usberr == hrSUCCESS) ((USBReadParser*)buf)->Parse(bytes, rbuf, 0); + } + else + #endif + { + while ((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*)buf)) == hrBUSY) delay(1); + } + ret = HandleUsbError(usberr, epDataInIndex); + } + else { + while ((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, bytes, (uint8_t*)buf)) == hrBUSY) delay(1); + ret = HandleUsbError(usberr, epDataOutIndex); + } + if (ret) ErrorMessage (PSTR("============================ DAT"), ret); + } + } + + bytes = sizeof (CommandStatusWrapper); + int tries = 2; + while (tries--) { + while ((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*) & csw)) == hrBUSY) delay(1); + if (!usberr) break; + ClearEpHalt(epDataInIndex); + if (tries) ResetRecovery(); + } + + if (!ret) { + Notify(PSTR("CBW:\t\tOK\r\n"), 0x80); + Notify(PSTR("Data Stage:\tOK\r\n"), 0x80); + } + else { + // Throw away csw, IT IS NOT OF ANY USE. + ResetRecovery(); + return ret; + } + + ret = HandleUsbError(usberr, epDataInIndex); + if (ret) ErrorMessage (PSTR("============================ CSW"), ret); + + if (usberr == hrSUCCESS) { + if (IsValidCSW(&csw, pcbw)) { + //ErrorMessage (PSTR("CSW.dCBWTag"), csw.dCSWTag); + //ErrorMessage (PSTR("bCSWStatus"), csw.bCSWStatus); + //ErrorMessage (PSTR("dCSWDataResidue"), csw.dCSWDataResidue); + Notify(PSTR("CSW:\t\tOK\r\n\r\n"), 0x80); + return csw.bCSWStatus; + } + else { + // NOTE! Sometimes this is caused by the reported residue being wrong. + // Get a different device. It isn't compliant, and should have never passed Q&A. + // I own one... 05e3:0701 Genesys Logic, Inc. USB 2.0 IDE Adapter. + // Other devices that exhibit this behavior exist in the wild too. + // Be sure to check quirks in the Linux source code before reporting a bug. --xxxajk + Notify(PSTR("Invalid CSW\r\n"), 0x80); + ResetRecovery(); + //return MASS_ERR_SUCCESS; + return MASS_ERR_INVALID_CSW; + } + } + return ret; +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @return + */ +uint8_t BulkOnly::SetCurLUN(uint8_t lun) { + if (lun > bMaxLUN) return MASS_ERR_INVALID_LUN; + bTheLUN = lun; + return MASS_ERR_SUCCESS; +} + +/** + * For driver use only. + * + * @param status + * @return + */ +uint8_t BulkOnly::HandleSCSIError(uint8_t status) { + uint8_t ret = 0; + + switch (status) { + case 0: return MASS_ERR_SUCCESS; + + case 2: + ErrorMessage (PSTR("Phase Error"), status); + ErrorMessage (PSTR("LUN"), bTheLUN); + ResetRecovery(); + return MASS_ERR_GENERAL_SCSI_ERROR; + + case 1: + ErrorMessage (PSTR("SCSI Error"), status); + ErrorMessage (PSTR("LUN"), bTheLUN); + RequestSenseResponce rsp; + + ret = RequestSense(bTheLUN, sizeof (RequestSenseResponce), (uint8_t*) & rsp); + + if (ret) return MASS_ERR_GENERAL_SCSI_ERROR; + + ErrorMessage (PSTR("Response Code"), rsp.bResponseCode); + if (rsp.bResponseCode & 0x80) { + Notify(PSTR("Information field: "), 0x80); + for (int i = 0; i < 4; i++) { + D_PrintHex (rsp.CmdSpecificInformation[i], 0x80); + Notify(PSTR(" "), 0x80); + } + Notify(PSTR("\r\n"), 0x80); + } + ErrorMessage (PSTR("Sense Key"), rsp.bmSenseKey); + ErrorMessage (PSTR("Add Sense Code"), rsp.bAdditionalSenseCode); + ErrorMessage (PSTR("Add Sense Qual"), rsp.bAdditionalSenseQualifier); + // warning, this is not testing ASQ, only SK and ASC. + switch (rsp.bmSenseKey) { + case SCSI_S_UNIT_ATTENTION: + switch (rsp.bAdditionalSenseCode) { + case SCSI_ASC_MEDIA_CHANGED: + return MASS_ERR_MEDIA_CHANGED; + default: + return MASS_ERR_UNIT_NOT_READY; + } + case SCSI_S_NOT_READY: + switch (rsp.bAdditionalSenseCode) { + case SCSI_ASC_MEDIUM_NOT_PRESENT: + return MASS_ERR_NO_MEDIA; + default: + return MASS_ERR_UNIT_NOT_READY; + } + case SCSI_S_ILLEGAL_REQUEST: + switch (rsp.bAdditionalSenseCode) { + case SCSI_ASC_LBA_OUT_OF_RANGE: + return MASS_ERR_BAD_LBA; + default: + return MASS_ERR_CMD_NOT_SUPPORTED; + } + default: + return MASS_ERR_GENERAL_SCSI_ERROR; + } + + // case 4: return MASS_ERR_UNIT_BUSY; // Busy means retry later. + // case 0x05/0x14: we stalled out + // case 0x15/0x16: we naked out. + default: + ErrorMessage (PSTR("Gen SCSI Err"), status); + ErrorMessage (PSTR("LUN"), bTheLUN); + return status; + } // switch +} + + +//////////////////////////////////////////////////////////////////////////////// +// Debugging code +//////////////////////////////////////////////////////////////////////////////// + +/** + * @param ep_ptr + */ +void BulkOnly::PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR * ep_ptr) { + Notify(PSTR("Endpoint descriptor:"), 0x80); + Notify(PSTR("\r\nLength:\t\t"), 0x80); + D_PrintHex (ep_ptr->bLength, 0x80); + Notify(PSTR("\r\nType:\t\t"), 0x80); + D_PrintHex (ep_ptr->bDescriptorType, 0x80); + Notify(PSTR("\r\nAddress:\t"), 0x80); + D_PrintHex (ep_ptr->bEndpointAddress, 0x80); + Notify(PSTR("\r\nAttributes:\t"), 0x80); + D_PrintHex (ep_ptr->bmAttributes, 0x80); + Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); + D_PrintHex (ep_ptr->wMaxPacketSize, 0x80); + Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); + D_PrintHex (ep_ptr->bInterval, 0x80); + Notify(PSTR("\r\n"), 0x80); +} + +//////////////////////////////////////////////////////////////////////////////// +// misc/to kill/to-do +//////////////////////////////////////////////////////////////////////////////// + +/* We won't be needing this... */ +uint8_t BulkOnly::Read(uint8_t lun __attribute__((unused)), uint32_t addr __attribute__((unused)), uint16_t bsize __attribute__((unused)), uint8_t blocks __attribute__((unused)), USBReadParser * prs __attribute__((unused))) { + #if MS_WANT_PARSER + if (!LUNOk[lun]) return MASS_ERR_NO_MEDIA; + Notify(PSTR("\r\nRead (With parser)\r\n"), 0x80); + Notify(PSTR("---------\r\n"), 0x80); + + CommandBlockWrapper cbw = CommandBlockWrapper(); + + cbw.dCBWSignature = MASS_CBW_SIGNATURE; + cbw.dCBWTag = ++dCBWTag; + cbw.dCBWDataTransferLength = ((uint32_t)bsize * blocks); + cbw.bmCBWFlags = MASS_CMD_DIR_IN, + cbw.bmCBWLUN = lun; + cbw.bmCBWCBLength = 10; + + cbw.CBWCB[0] = SCSI_CMD_READ_10; + cbw.CBWCB[8] = blocks; + cbw.CBWCB[2] = ((addr >> 24) & 0xFF); + cbw.CBWCB[3] = ((addr >> 16) & 0xFF); + cbw.CBWCB[4] = ((addr >> 8) & 0xFF); + cbw.CBWCB[5] = (addr & 0xFF); + + return HandleSCSIError(Transaction(&cbw, bsize, prs, 1)); + #else + return MASS_ERR_NOT_IMPLEMENTED; + #endif +} + +#endif // USB_FLASH_DRIVE_SUPPORT diff --git a/src/sd/usb_flashdrive/lib-uhs2/masstorage.h b/src/sd/usb_flashdrive/lib-uhs2/masstorage.h new file mode 100644 index 0000000..aafb916 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/masstorage.h @@ -0,0 +1,559 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ + +#pragma once + +// Cruft removal, makes driver smaller, faster. +#ifndef MS_WANT_PARSER + #define MS_WANT_PARSER 0 +#endif + +#include "Usb.h" + +#define bmREQ_MASSOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE +#define bmREQ_MASSIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE + +// Mass Storage Subclass Constants +#define MASS_SUBCLASS_SCSI_NOT_REPORTED 0x00 // De facto use +#define MASS_SUBCLASS_RBC 0x01 +#define MASS_SUBCLASS_ATAPI 0x02 // MMC-5 (ATAPI) +#define MASS_SUBCLASS_OBSOLETE1 0x03 // Was QIC-157 +#define MASS_SUBCLASS_UFI 0x04 // Specifies how to interface Floppy Disk Drives to USB +#define MASS_SUBCLASS_OBSOLETE2 0x05 // Was SFF-8070i +#define MASS_SUBCLASS_SCSI 0x06 // SCSI Transparent Command Set +#define MASS_SUBCLASS_LSDFS 0x07 // Specifies how host has to negotiate access before trying SCSI +#define MASS_SUBCLASS_IEEE1667 0x08 + +// Mass Storage Class Protocols +#define MASS_PROTO_CBI 0x00 // CBI (with command completion interrupt) +#define MASS_PROTO_CBI_NO_INT 0x01 // CBI (without command completion interrupt) +#define MASS_PROTO_OBSOLETE 0x02 +#define MASS_PROTO_BBB 0x50 // Bulk Only Transport +#define MASS_PROTO_UAS 0x62 + +// Request Codes +#define MASS_REQ_ADSC 0x00 +#define MASS_REQ_GET 0xFC +#define MASS_REQ_PUT 0xFD +#define MASS_REQ_GET_MAX_LUN 0xFE +#define MASS_REQ_BOMSR 0xFF // Bulk-Only Mass Storage Reset + +#define MASS_CBW_SIGNATURE 0x43425355 +#define MASS_CSW_SIGNATURE 0x53425355 + +#define MASS_CMD_DIR_OUT 0 // (0 << 7) +#define MASS_CMD_DIR_IN 0x80 //(1 << 7) + +/* + * Reference documents from T10 (https://www.t10.org) + * SCSI Primary Commands - 3 (SPC-3) + * SCSI Block Commands - 2 (SBC-2) + * Multi-Media Commands - 5 (MMC-5) + */ + +/* Group 1 commands (CDB's here are should all be 6-bytes) */ +#define SCSI_CMD_TEST_UNIT_READY 0x00 +#define SCSI_CMD_REQUEST_SENSE 0x03 +#define SCSI_CMD_FORMAT_UNIT 0x04 +#define SCSI_CMD_READ_6 0x08 +#define SCSI_CMD_WRITE_6 0x0A +#define SCSI_CMD_INQUIRY 0x12 +#define SCSI_CMD_MODE_SELECT_6 0x15 +#define SCSI_CMD_MODE_SENSE_6 0x1A +#define SCSI_CMD_START_STOP_UNIT 0x1B +#define SCSI_CMD_PREVENT_REMOVAL 0x1E +/* Group 2 Commands (CDB's here are 10-bytes) */ +#define SCSI_CMD_READ_FORMAT_CAPACITIES 0x23 +#define SCSI_CMD_READ_CAPACITY_10 0x25 +#define SCSI_CMD_READ_10 0x28 +#define SCSI_CMD_WRITE_10 0x2A +#define SCSI_CMD_SEEK_10 0x2B +#define SCSI_CMD_ERASE_10 0x2C +#define SCSI_CMD_WRITE_AND_VERIFY_10 0x2E +#define SCSI_CMD_VERIFY_10 0x2F +#define SCSI_CMD_SYNCHRONIZE_CACHE 0x35 +#define SCSI_CMD_WRITE_BUFFER 0x3B +#define SCSI_CMD_READ_BUFFER 0x3C +#define SCSI_CMD_READ_SUBCHANNEL 0x42 +#define SCSI_CMD_READ_TOC 0x43 +#define SCSI_CMD_READ_HEADER 0x44 +#define SCSI_CMD_PLAY_AUDIO_10 0x45 +#define SCSI_CMD_GET_CONFIGURATION 0x46 +#define SCSI_CMD_PLAY_AUDIO_MSF 0x47 +#define SCSI_CMD_PLAY_AUDIO_TI 0x48 +#define SCSI_CMD_PLAY_TRACK_REL_10 0x49 +#define SCSI_CMD_GET_EVENT_STATUS 0x4A +#define SCSI_CMD_PAUSE_RESUME 0x4B +#define SCSI_CMD_READ_DISC_INFORMATION 0x51 +#define SCSI_CMD_READ_TRACK_INFORMATION 0x52 +#define SCSI_CMD_RESERVE_TRACK 0x53 +#define SCSI_CMD_SEND_OPC_INFORMATION 0x54 +#define SCSI_CMD_MODE_SELECT_10 0x55 +#define SCSI_CMD_REPAIR_TRACK 0x58 +#define SCSI_CMD_MODE_SENSE_10 0x5A +#define SCSI_CMD_CLOSE_TRACK_SESSION 0x5B +#define SCSI_CMD_READ_BUFFER_CAPACITY 0x5C +#define SCSI_CMD_SEND_CUE_SHEET 0x5D +/* Group 5 Commands (CDB's here are 12-bytes) */ +#define SCSI_CMD_REPORT_LUNS 0xA0 +#define SCSI_CMD_BLANK 0xA1 +#define SCSI_CMD_SECURITY_PROTOCOL_IN 0xA2 +#define SCSI_CMD_SEND_KEY 0xA3 +#define SCSI_CMD_REPORT_KEY 0xA4 +#define SCSI_CMD_PLAY_AUDIO_12 0xA5 +#define SCSI_CMD_LOAD_UNLOAD 0xA6 +#define SCSI_CMD_SET_READ_AHEAD 0xA7 +#define SCSI_CMD_READ_12 0xA8 +#define SCSI_CMD_PLAY_TRACK_REL_12 0xA9 +#define SCSI_CMD_WRITE_12 0xAA +#define SCSI_CMD_READ_MEDIA_SERIAL_12 0xAB +#define SCSI_CMD_GET_PERFORMANCE 0xAC +#define SCSI_CMD_READ_DVD_STRUCTURE 0xAD +#define SCSI_CMD_SECURITY_PROTOCOL_OUT 0xB5 +#define SCSI_CMD_SET_STREAMING 0xB6 +#define SCSI_CMD_READ_MSF 0xB9 +#define SCSI_CMD_SET_SPEED 0xBB +#define SCSI_CMD_MECHANISM_STATUS 0xBD +#define SCSI_CMD_READ_CD 0xBE +#define SCSI_CMD_SEND_DISC_STRUCTURE 0xBF +/* Vendor-unique Commands, included for completeness */ +#define SCSI_CMD_CD_PLAYBACK_STATUS 0xC4 /* SONY unique */ +#define SCSI_CMD_PLAYBACK_CONTROL 0xC9 /* SONY unique */ +#define SCSI_CMD_READ_CDDA 0xD8 /* Vendor unique */ +#define SCSI_CMD_READ_CDXA 0xDB /* Vendor unique */ +#define SCSI_CMD_READ_ALL_SUBCODES 0xDF /* Vendor unique */ + +/* SCSI error codes */ +#define SCSI_S_NOT_READY 0x02 +#define SCSI_S_MEDIUM_ERROR 0x03 +#define SCSI_S_ILLEGAL_REQUEST 0x05 +#define SCSI_S_UNIT_ATTENTION 0x06 +#define SCSI_ASC_LBA_OUT_OF_RANGE 0x21 +#define SCSI_ASC_MEDIA_CHANGED 0x28 +#define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3A + +/* USB error codes */ +#define MASS_ERR_SUCCESS 0x00 +#define MASS_ERR_PHASE_ERROR 0x02 +#define MASS_ERR_UNIT_NOT_READY 0x03 +#define MASS_ERR_UNIT_BUSY 0x04 +#define MASS_ERR_STALL 0x05 +#define MASS_ERR_CMD_NOT_SUPPORTED 0x06 +#define MASS_ERR_INVALID_CSW 0x07 +#define MASS_ERR_NO_MEDIA 0x08 +#define MASS_ERR_BAD_LBA 0x09 +#define MASS_ERR_MEDIA_CHANGED 0x0A +#define MASS_ERR_DEVICE_DISCONNECTED 0x11 +#define MASS_ERR_UNABLE_TO_RECOVER 0x12 // Reset recovery error +#define MASS_ERR_INVALID_LUN 0x13 +#define MASS_ERR_WRITE_STALL 0x14 +#define MASS_ERR_READ_NAKS 0x15 +#define MASS_ERR_WRITE_NAKS 0x16 +#define MASS_ERR_WRITE_PROTECTED 0x17 +#define MASS_ERR_NOT_IMPLEMENTED 0xFD +#define MASS_ERR_GENERAL_SCSI_ERROR 0xFE +#define MASS_ERR_GENERAL_USB_ERROR 0xFF +#define MASS_ERR_USER 0xA0 // For subclasses to define their own error codes + +#define MASS_TRANS_FLG_CALLBACK 0x01 // Callback is involved +#define MASS_TRANS_FLG_NO_STALL_CHECK 0x02 // STALL condition is not checked +#define MASS_TRANS_FLG_NO_PHASE_CHECK 0x04 // PHASE_ERROR is not checked + +#define MASS_MAX_ENDPOINTS 3 + +struct Capacity { + uint8_t data[8]; + //uint32_t dwBlockAddress; + //uint32_t dwBlockLength; +} __attribute__((packed)); + +struct BASICCDB { + uint8_t Opcode; + + unsigned unused : 5; + unsigned LUN : 3; + + uint8_t info[12]; +} __attribute__((packed)); + +typedef BASICCDB BASICCDB_t; + +struct CDB6 { + uint8_t Opcode; + + unsigned LBAMSB : 5; + unsigned LUN : 3; + + uint8_t LBAHB; + uint8_t LBALB; + uint8_t AllocationLength; + uint8_t Control; + +public: + + CDB6(uint8_t _Opcode, uint8_t _LUN, uint32_t LBA, uint8_t _AllocationLength, uint8_t _Control) : + Opcode(_Opcode), LBAMSB(BGRAB2(LBA) & 0x1F), LUN(_LUN), LBAHB(BGRAB1(LBA)), LBALB(BGRAB0(LBA)), + AllocationLength(_AllocationLength), Control(_Control) { + } + + CDB6(uint8_t _Opcode, uint8_t _LUN, uint8_t _AllocationLength, uint8_t _Control) : + Opcode(_Opcode), LBAMSB(0), LUN(_LUN), LBAHB(0), LBALB(0), + AllocationLength(_AllocationLength), Control(_Control) { + } +} __attribute__((packed)); + +typedef CDB6 CDB6_t; + +struct CDB10 { + uint8_t Opcode; + + unsigned Service_Action : 5; + unsigned LUN : 3; + + uint8_t LBA_L_M_MB; + uint8_t LBA_L_M_LB; + uint8_t LBA_L_L_MB; + uint8_t LBA_L_L_LB; + + uint8_t Misc2; + + uint8_t ALC_MB; + uint8_t ALC_LB; + + uint8_t Control; +public: + + CDB10(uint8_t _Opcode, uint8_t _LUN) : + Opcode(_Opcode), Service_Action(0), LUN(_LUN), + LBA_L_M_MB(0), LBA_L_M_LB(0), LBA_L_L_MB(0), LBA_L_L_LB(0), + Misc2(0), ALC_MB(0), ALC_LB(0), Control(0) { + } + + CDB10(uint8_t _Opcode, uint8_t _LUN, uint16_t xflen, uint32_t _LBA) : + Opcode(_Opcode), Service_Action(0), LUN(_LUN), + LBA_L_M_MB(BGRAB3(_LBA)), LBA_L_M_LB(BGRAB2(_LBA)), LBA_L_L_MB(BGRAB1(_LBA)), LBA_L_L_LB(BGRAB0(_LBA)), + Misc2(0), ALC_MB(BGRAB1(xflen)), ALC_LB(BGRAB0(xflen)), Control(0) { + } +} __attribute__((packed)); + +typedef CDB10 CDB10_t; + +struct CDB12 { + uint8_t Opcode; + + unsigned Service_Action : 5; + unsigned Misc : 3; + + uint8_t LBA_L_M_LB; + uint8_t LBA_L_L_MB; + uint8_t LBA_L_L_LB; + + uint8_t ALC_M_LB; + uint8_t ALC_L_MB; + uint8_t ALC_L_LB; + uint8_t Control; +} __attribute__((packed)); + +typedef CDB12 CDB12_t; + +struct CDB_LBA32_16 { + uint8_t Opcode; + + unsigned Service_Action : 5; + unsigned Misc : 3; + + uint8_t LBA_L_M_MB; + uint8_t LBA_L_M_LB; + uint8_t LBA_L_L_MB; + uint8_t LBA_L_L_LB; + + uint8_t A_M_M_MB; + uint8_t A_M_M_LB; + uint8_t A_M_L_MB; + uint8_t A_M_L_LB; + + uint8_t ALC_M_MB; + uint8_t ALC_M_LB; + uint8_t ALC_L_MB; + uint8_t ALC_L_LB; + + uint8_t Misc2; + uint8_t Control; +} __attribute__((packed)); + +struct CDB_LBA64_16 { + uint8_t Opcode; + uint8_t Misc; + + uint8_t LBA_M_M_MB; + uint8_t LBA_M_M_LB; + uint8_t LBA_M_L_MB; + uint8_t LBA_M_L_LB; + + uint8_t LBA_L_M_MB; + uint8_t LBA_L_M_LB; + uint8_t LBA_L_L_MB; + uint8_t LBA_L_L_LB; + + uint8_t ALC_M_MB; + uint8_t ALC_M_LB; + uint8_t ALC_L_MB; + uint8_t ALC_L_LB; + + uint8_t Misc2; + uint8_t Control; +} __attribute__((packed)); + +struct InquiryResponse { + uint8_t DeviceType : 5; + uint8_t PeripheralQualifier : 3; + + unsigned Reserved : 7; + unsigned Removable : 1; + + uint8_t Version; + + unsigned ResponseDataFormat : 4; + unsigned HISUP : 1; + unsigned NormACA : 1; + unsigned TrmTsk : 1; + unsigned AERC : 1; + + uint8_t AdditionalLength; + //uint8_t Reserved3[2]; + + unsigned PROTECT : 1; + unsigned Res : 2; + unsigned ThreePC : 1; + unsigned TPGS : 2; + unsigned ACC : 1; + unsigned SCCS : 1; + + unsigned ADDR16 : 1; + unsigned R1 : 1; + unsigned R2 : 1; + unsigned MCHNGR : 1; + unsigned MULTIP : 1; + unsigned VS : 1; + unsigned ENCSERV : 1; + unsigned BQUE : 1; + + unsigned SoftReset : 1; + unsigned CmdQue : 1; + unsigned Reserved4 : 1; + unsigned Linked : 1; + unsigned Sync : 1; + unsigned WideBus16Bit : 1; + unsigned WideBus32Bit : 1; + unsigned RelAddr : 1; + + uint8_t VendorID[8]; + uint8_t ProductID[16]; + uint8_t RevisionID[4]; +} __attribute__((packed)); + +struct CommandBlockWrapperBase { + uint32_t dCBWSignature; + uint32_t dCBWTag; + uint32_t dCBWDataTransferLength; + uint8_t bmCBWFlags; +public: + + CommandBlockWrapperBase() { + } + + CommandBlockWrapperBase(uint32_t tag, uint32_t xflen, uint8_t flgs) : + dCBWSignature(MASS_CBW_SIGNATURE), dCBWTag(tag), dCBWDataTransferLength(xflen), bmCBWFlags(flgs) { + } +} __attribute__((packed)); + +struct CommandBlockWrapper : public CommandBlockWrapperBase { + + struct { + uint8_t bmCBWLUN : 4; + uint8_t bmReserved1 : 4; + }; + + struct { + uint8_t bmCBWCBLength : 4; + uint8_t bmReserved2 : 4; + }; + + uint8_t CBWCB[16]; + +public: + // All zeroed. + + CommandBlockWrapper() : + CommandBlockWrapperBase(0, 0, 0), bmReserved1(0), bmReserved2(0) { + for (int i = 0; i < 16; i++) CBWCB[i] = 0; + } + + // Generic Wrap, CDB zeroed. + + CommandBlockWrapper(uint32_t tag, uint32_t xflen, uint8_t flgs, uint8_t lu, uint8_t cmdlen, uint8_t cmd) : + CommandBlockWrapperBase(tag, xflen, flgs), + bmCBWLUN(lu), bmReserved1(0), bmCBWCBLength(cmdlen), bmReserved2(0) { + for (int i = 0; i < 16; i++) CBWCB[i] = 0; + // Type punning can cause optimization problems and bugs. + // Using reinterpret_cast to a dreinterpretifferent object is the proper way to do this. + //(((BASICCDB_t *) CBWCB)->LUN) = cmd; + BASICCDB_t *x = reinterpret_cast(CBWCB); + x->LUN = cmd; + } + + // Wrap for CDB of 6 + + CommandBlockWrapper(uint32_t tag, uint32_t xflen, CDB6_t *cdb, uint8_t dir) : + CommandBlockWrapperBase(tag, xflen, dir), + bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(6), bmReserved2(0) { + memcpy(&CBWCB, cdb, 6); + } + // Wrap for CDB of 10 + + CommandBlockWrapper(uint32_t tag, uint32_t xflen, CDB10_t *cdb, uint8_t dir) : + CommandBlockWrapperBase(tag, xflen, dir), + bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(10), bmReserved2(0) { + memcpy(&CBWCB, cdb, 10); + } +} __attribute__((packed)); + +struct CommandStatusWrapper { + uint32_t dCSWSignature; + uint32_t dCSWTag; + uint32_t dCSWDataResidue; + uint8_t bCSWStatus; +} __attribute__((packed)); + +struct RequestSenseResponce { + uint8_t bResponseCode; + uint8_t bSegmentNumber; + + uint8_t bmSenseKey : 4; + uint8_t bmReserved : 1; + uint8_t bmILI : 1; + uint8_t bmEOM : 1; + uint8_t bmFileMark : 1; + + uint8_t Information[4]; + uint8_t bAdditionalLength; + uint8_t CmdSpecificInformation[4]; + uint8_t bAdditionalSenseCode; + uint8_t bAdditionalSenseQualifier; + uint8_t bFieldReplaceableUnitCode; + uint8_t SenseKeySpecific[3]; +} __attribute__((packed)); + +class BulkOnly : public USBDeviceConfig, public UsbConfigXtracter { +protected: + static const uint8_t epDataInIndex; // DataIn endpoint index + static const uint8_t epDataOutIndex; // DataOUT endpoint index + static const uint8_t epInterruptInIndex; // InterruptIN endpoint index + + USB *pUsb; + uint8_t bAddress; + uint8_t bConfNum; // configuration number + uint8_t bIface; // interface value + uint8_t bNumEP; // total number of EP in the configuration + uint32_t qNextPollTime; // next poll time + bool bPollEnable; // poll enable flag + + EpInfo epInfo[MASS_MAX_ENDPOINTS]; + + uint32_t dCBWTag; // Tag + //uint32_t dCBWDataTransferLength; // Data Transfer Length + uint8_t bLastUsbError; // Last USB error + uint8_t bMaxLUN; // Max LUN + uint8_t bTheLUN; // Active LUN + uint32_t CurrentCapacity[MASS_MAX_SUPPORTED_LUN]; // Total sectors + uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits + bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes. + bool WriteOk[MASS_MAX_SUPPORTED_LUN]; + void PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR* ep_ptr); + + // Additional Initialization Method for Subclasses + + virtual uint8_t OnInit() { return 0; } + +public: + BulkOnly(USB *p); + + uint8_t GetLastUsbError() { return bLastUsbError; }; + + uint8_t GetbMaxLUN() { return bMaxLUN; } // Max LUN + uint8_t GetbTheLUN() { return bTheLUN; } // Active LUN + + bool WriteProtected(uint8_t lun); + uint8_t MediaCTL(uint8_t lun, uint8_t ctl); + uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf); + uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, USBReadParser *prs); + uint8_t Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t *buf); + uint8_t LockMedia(uint8_t lun, uint8_t lock); + + bool LUNIsGood(uint8_t lun); + uint32_t GetCapacity(uint8_t lun); + uint16_t GetSectorSize(uint8_t lun); + + // USBDeviceConfig implementation + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); + + uint8_t Release(); + uint8_t Poll(); + + virtual uint8_t GetAddress() { return bAddress; } + + // UsbConfigXtracter implementation + void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_FD_ENDPOINT_DESCRIPTOR *ep); + + virtual bool DEVCLASSOK(uint8_t klass) { return klass == USB_CLASS_MASS_STORAGE; } + + uint8_t SCSITransaction6(CDB6_t *cdb, uint16_t buf_size, void *buf, uint8_t dir); + uint8_t SCSITransaction10(CDB10_t *cdb, uint16_t buf_size, void *buf, uint8_t dir); + +private: + uint8_t Inquiry(uint8_t lun, uint16_t size, uint8_t *buf); + uint8_t TestUnitReady(uint8_t lun); + uint8_t RequestSense(uint8_t lun, uint16_t size, uint8_t *buf); + uint8_t ModeSense6(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t *buf); + uint8_t GetMaxLUN(uint8_t *max_lun); + uint8_t SetCurLUN(uint8_t lun); + void Reset(); + uint8_t ResetRecovery(); + uint8_t ReadCapacity10(uint8_t lun, uint8_t *buf); + void ClearAllEP(); + void CheckMedia(); + bool CheckLUN(uint8_t lun); + uint8_t Page3F(uint8_t lun); + bool IsValidCBW(uint8_t size, uint8_t *pcbw); + bool IsMeaningfulCBW(uint8_t size, uint8_t *pcbw); + + bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw); + + uint8_t ClearEpHalt(uint8_t index); + uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf OPTARG(MS_WANT_PARSER, uint8_t flags=0)); + uint8_t HandleUsbError(uint8_t error, uint8_t index); + uint8_t HandleSCSIError(uint8_t status); +}; diff --git a/src/sd/usb_flashdrive/lib-uhs2/max3421e.h b/src/sd/usb_flashdrive/lib-uhs2/max3421e.h new file mode 100644 index 0000000..f7eb9ad --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/max3421e.h @@ -0,0 +1,242 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ +#pragma once + +#ifndef _usb_h_ + #error "Never include max3421e.h directly; include Usb.h instead" +#endif + +/* MAX3421E register/bit names and bitmasks */ + +/* Arduino pin definitions */ +/* pin numbers to port numbers */ + +#define SE0 0 +#define SE1 1 +#define FSHOST 2 +#define LSHOST 3 + +/* MAX3421E command byte format: rrrrr0wa where 'r' is register number */ +// +// MAX3421E Registers in HOST mode. +// +#define rRCVFIFO 0x08 //1<<3 +#define rSNDFIFO 0x10 //2<<3 +#define rSUDFIFO 0x20 //4<<3 +#define rRCVBC 0x30 //6<<3 +#define rSNDBC 0x38 //7<<3 + +#define rUSBIRQ 0x68 //13<<3 +/* USBIRQ Bits */ +#define bmVBUSIRQ 0x40 //b6 +#define bmNOVBUSIRQ 0x20 //b5 +#define bmOSCOKIRQ 0x01 //b0 + +#define rUSBIEN 0x70 //14<<3 +/* USBIEN Bits */ +#define bmVBUSIE 0x40 //b6 +#define bmNOVBUSIE 0x20 //b5 +#define bmOSCOKIE 0x01 //b0 + +#define rUSBCTL 0x78 //15<<3 +/* USBCTL Bits */ +#define bmCHIPRES 0x20 //b5 +#define bmPWRDOWN 0x10 //b4 + +#define rCPUCTL 0x80 //16<<3 +/* CPUCTL Bits */ +#define bmPULSEWID1 0x80 //b7 +#define bmPULSEWID0 0x40 //b6 +#define bmIE 0x01 //b0 + +#define rPINCTL 0x88 //17<<3 +/* PINCTL Bits */ +#define bmFDUPSPI 0x10 //b4 +#define bmINTLEVEL 0x08 //b3 +#define bmPOSINT 0x04 //b2 +#define bmGPXB 0x02 //b1 +#define bmGPXA 0x01 //b0 +// GPX pin selections +#define GPX_OPERATE 0x00 +#define GPX_VBDET 0x01 +#define GPX_BUSACT 0x02 +#define GPX_SOF 0x03 + +#define rREVISION 0x90 //18<<3 + +#define rIOPINS1 0xA0 //20<<3 + +/* IOPINS1 Bits */ +#define bmGPOUT0 0x01 +#define bmGPOUT1 0x02 +#define bmGPOUT2 0x04 +#define bmGPOUT3 0x08 +#define bmGPIN0 0x10 +#define bmGPIN1 0x20 +#define bmGPIN2 0x40 +#define bmGPIN3 0x80 + +#define rIOPINS2 0xA8 //21<<3 +/* IOPINS2 Bits */ +#define bmGPOUT4 0x01 +#define bmGPOUT5 0x02 +#define bmGPOUT6 0x04 +#define bmGPOUT7 0x08 +#define bmGPIN4 0x10 +#define bmGPIN5 0x20 +#define bmGPIN6 0x40 +#define bmGPIN7 0x80 + +#define rGPINIRQ 0xB0 //22<<3 +/* GPINIRQ Bits */ +#define bmGPINIRQ0 0x01 +#define bmGPINIRQ1 0x02 +#define bmGPINIRQ2 0x04 +#define bmGPINIRQ3 0x08 +#define bmGPINIRQ4 0x10 +#define bmGPINIRQ5 0x20 +#define bmGPINIRQ6 0x40 +#define bmGPINIRQ7 0x80 + +#define rGPINIEN 0xB8 //23<<3 +/* GPINIEN Bits */ +#define bmGPINIEN0 0x01 +#define bmGPINIEN1 0x02 +#define bmGPINIEN2 0x04 +#define bmGPINIEN3 0x08 +#define bmGPINIEN4 0x10 +#define bmGPINIEN5 0x20 +#define bmGPINIEN6 0x40 +#define bmGPINIEN7 0x80 + +#define rGPINPOL 0xC0 //24<<3 +/* GPINPOL Bits */ +#define bmGPINPOL0 0x01 +#define bmGPINPOL1 0x02 +#define bmGPINPOL2 0x04 +#define bmGPINPOL3 0x08 +#define bmGPINPOL4 0x10 +#define bmGPINPOL5 0x20 +#define bmGPINPOL6 0x40 +#define bmGPINPOL7 0x80 + +#define rHIRQ 0xC8 //25<<3 +/* HIRQ Bits */ +#define bmBUSEVENTIRQ 0x01 // indicates BUS Reset Done or BUS Resume +#define bmRWUIRQ 0x02 +#define bmRCVDAVIRQ 0x04 +#define bmSNDBAVIRQ 0x08 +#define bmSUSDNIRQ 0x10 +#define bmCONDETIRQ 0x20 +#define bmFRAMEIRQ 0x40 +#define bmHXFRDNIRQ 0x80 + +#define rHIEN 0xD0 //26<<3 + +/* HIEN Bits */ +#define bmBUSEVENTIE 0x01 +#define bmRWUIE 0x02 +#define bmRCVDAVIE 0x04 +#define bmSNDBAVIE 0x08 +#define bmSUSDNIE 0x10 +#define bmCONDETIE 0x20 +#define bmFRAMEIE 0x40 +#define bmHXFRDNIE 0x80 + +#define rMODE 0xD8 //27<<3 + +/* MODE Bits */ +#define bmHOST 0x01 +#define bmLOWSPEED 0x02 +#define bmHUBPRE 0x04 +#define bmSOFKAENAB 0x08 +#define bmSEPIRQ 0x10 +#define bmDELAYISO 0x20 +#define bmDMPULLDN 0x40 +#define bmDPPULLDN 0x80 + +#define rPERADDR 0xE0 //28<<3 + +#define rHCTL 0xE8 //29<<3 +/* HCTL Bits */ +#define bmBUSRST 0x01 +#define bmFRMRST 0x02 +#define bmSAMPLEBUS 0x04 +#define bmSIGRSM 0x08 +#define bmRCVTOG0 0x10 +#define bmRCVTOG1 0x20 +#define bmSNDTOG0 0x40 +#define bmSNDTOG1 0x80 + +#define rHXFR 0xF0 //30<<3 + +#undef tokSETUP +#undef tokIN +#undef tokOUT +#undef tokINHS +#undef tokOUTHS +#undef tokISOIN +#undef tokISOOUT + +/* Host transfer token values for writing the HXFR register (R30) */ +/* OR this bit field with the endpoint number in bits 3:0 */ +#define tokSETUP 0x10 // HS=0, ISO=0, OUTNIN=0, SETUP=1 +#define tokIN 0x00 // HS=0, ISO=0, OUTNIN=0, SETUP=0 +#define tokOUT 0x20 // HS=0, ISO=0, OUTNIN=1, SETUP=0 +#define tokINHS 0x80 // HS=1, ISO=0, OUTNIN=0, SETUP=0 +#define tokOUTHS 0xA0 // HS=1, ISO=0, OUTNIN=1, SETUP=0 +#define tokISOIN 0x40 // HS=0, ISO=1, OUTNIN=0, SETUP=0 +#define tokISOOUT 0x60 // HS=0, ISO=1, OUTNIN=1, SETUP=0 + +#define rHRSL 0xF8 //31<<3 + +/* HRSL Bits */ +#define bmRCVTOGRD 0x10 +#define bmSNDTOGRD 0x20 +#define bmKSTATUS 0x40 +#define bmJSTATUS 0x80 +#define bmSE0 0x00 //SE0 - disconnect state +#define bmSE1 0xC0 //SE1 - illegal state + +/* Host error result codes, the 4 LSB's in the HRSL register */ +#define hrSUCCESS 0x00 +#define hrBUSY 0x01 +#define hrBADREQ 0x02 +#define hrUNDEF 0x03 +#define hrNAK 0x04 +#define hrSTALL 0x05 +#define hrTOGERR 0x06 +#define hrWRONGPID 0x07 +#define hrBADBC 0x08 +#define hrPIDERR 0x09 +#define hrPKTERR 0x0A +#define hrCRCERR 0x0B +#define hrKERR 0x0C +#define hrJERR 0x0D +#define hrTIMEOUT 0x0E +#define hrBABBLE 0x0F + +#define MODE_FS_HOST (bmDPPULLDN|bmDMPULLDN|bmHOST|bmSOFKAENAB) +#define MODE_LS_HOST (bmDPPULLDN|bmDMPULLDN|bmHOST|bmLOWSPEED|bmSOFKAENAB) diff --git a/src/sd/usb_flashdrive/lib-uhs2/message.cpp b/src/sd/usb_flashdrive/lib-uhs2/message.cpp new file mode 100644 index 0000000..dcc3090 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/message.cpp @@ -0,0 +1,128 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB) + +#include "Usb.h" + +// 0x80 is the default (i.e. trace) to turn off set this global to something lower. +// this allows for 126 other debugging levels. +// TO-DO: Allow assignment to a different serial port by software +int UsbDEBUGlvl = 0x80; + +void E_Notifyc(char c, int lvl) { + if (UsbDEBUGlvl < lvl) return; + USB_HOST_SERIAL.print(c + #if !defined(ARDUINO) && !defined(ARDUINO_ARCH_LPC176X) + , BYTE + #endif + ); + //USB_HOST_SERIAL.flush(); +} + +void E_Notify(char const * msg, int lvl) { + if (UsbDEBUGlvl < lvl) return; + if (!msg) return; + while (const char c = pgm_read_byte(msg++)) E_Notifyc(c, lvl); +} + +void E_NotifyStr(char const * msg, int lvl) { + if (UsbDEBUGlvl < lvl) return; + if (!msg) return; + while (const char c = *msg++) E_Notifyc(c, lvl); +} + +void E_Notify(uint8_t b, int lvl) { + if (UsbDEBUGlvl < lvl) return; + USB_HOST_SERIAL.print(b + #if !defined(ARDUINO) || ARDUINO < 100 + , DEC + #endif + ); + //USB_HOST_SERIAL.flush(); +} + +void E_Notify(double d, int lvl) { + if (UsbDEBUGlvl < lvl) return; + USB_HOST_SERIAL.print(d); + //USB_HOST_SERIAL.flush(); +} + +#ifdef DEBUG_USB_HOST + + void NotifyFailGetDevDescr() { + Notify(PSTR("\r\ngetDevDescr "), 0x80); + } + + void NotifyFailSetDevTblEntry() { + Notify(PSTR("\r\nsetDevTblEn "), 0x80); + } + + void NotifyFailGetConfDescr() { + Notify(PSTR("\r\ngetConf "), 0x80); + } + + void NotifyFailSetConfDescr() { + Notify(PSTR("\r\nsetConf "), 0x80); + } + + void NotifyFailGetDevDescr(uint8_t reason) { + NotifyFailGetDevDescr(); + NotifyFail(reason); + } + + void NotifyFailSetDevTblEntry(uint8_t reason) { + NotifyFailSetDevTblEntry(); + NotifyFail(reason); + + } + + void NotifyFailGetConfDescr(uint8_t reason) { + NotifyFailGetConfDescr(); + NotifyFail(reason); + } + + void NotifyFailSetConfDescr(uint8_t reason) { + NotifyFailSetConfDescr(); + NotifyFail(reason); + } + + void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) { + Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80); + D_PrintHex (VID, 0x80); + Notify(PSTR(" PID: "), 0x80); + D_PrintHex (PID, 0x80); + } + + void NotifyFail(uint8_t rcode) { + D_PrintHex (rcode, 0x80); + Notify(PSTR("\r\n"), 0x80); + } + +#endif // DEBUG_USB_HOST + +#endif // USB_FLASH_DRIVE_SUPPORT diff --git a/src/sd/usb_flashdrive/lib-uhs2/message.h b/src/sd/usb_flashdrive/lib-uhs2/message.h new file mode 100644 index 0000000..12195dc --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/message.h @@ -0,0 +1,85 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ +#pragma once + +#ifndef _usb_h_ + #error "Never include message.h directly; include Usb.h instead" +#endif + +extern int UsbDEBUGlvl; + +void E_Notify(char const * msg, int lvl); +void E_Notify(uint8_t b, int lvl); +void E_NotifyStr(char const * msg, int lvl); +void E_Notifyc(char c, int lvl); + +#ifdef DEBUG_USB_HOST + #define Notify E_Notify + #define NotifyStr E_NotifyStr + #define Notifyc E_Notifyc + void NotifyFailGetDevDescr(uint8_t reason); + void NotifyFailSetDevTblEntry(uint8_t reason); + void NotifyFailGetConfDescr(uint8_t reason); + void NotifyFailSetConfDescr(uint8_t reason); + void NotifyFailGetDevDescr(); + void NotifyFailSetDevTblEntry(); + void NotifyFailGetConfDescr(); + void NotifyFailSetConfDescr(); + void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID); + void NotifyFail(uint8_t rcode); +#else + #define Notify(...) ((void)0) + #define NotifyStr(...) ((void)0) + #define Notifyc(...) ((void)0) + #define NotifyFailGetDevDescr(...) ((void)0) + #define NotifyFailSetDevTblEntry(...) ((void)0) + #define NotifyFailGetConfDescr(...) ((void)0) + #define NotifyFailGetDevDescr(...) ((void)0) + #define NotifyFailSetDevTblEntry(...) ((void)0) + #define NotifyFailGetConfDescr(...) ((void)0) + #define NotifyFailSetConfDescr(...) ((void)0) + #define NotifyFailUnknownDevice(...) ((void)0) + #define NotifyFail(...) ((void)0) +#endif + +template +void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) { + #ifdef DEBUG_USB_HOST + Notify(msg, level); + Notify(PSTR(": "), level); + D_PrintHex (rcode, level); + Notify(PSTR("\r\n"), level); + #endif +} + +template +void ErrorMessage(char const * msg __attribute__((unused)), ERROR_TYPE rcode __attribute__((unused)) = 0) { + #ifdef DEBUG_USB_HOST + Notify(msg, 0x80); + Notify(PSTR(": "), 0x80); + D_PrintHex (rcode, 0x80); + Notify(PSTR("\r\n"), 0x80); + #endif +} diff --git a/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp b/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp new file mode 100644 index 0000000..5d25576 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp @@ -0,0 +1,77 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB) + +#include "Usb.h" + +bool MultiByteValueParser::Parse(uint8_t **pp, uint16_t *pcntdn) { + if (!pBuf) { + Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); + return false; + } + for (; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++) + pBuf[valueSize - countDown] = (**pp); + + if (countDown) return false; + + countDown = valueSize; + return true; +} + +bool PTPListParser::Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { + switch (nStage) { + case 0: + pBuf->valueSize = lenSize; + theParser.Initialize(pBuf); + nStage = 1; + + case 1: + if (!theParser.Parse(pp, pcntdn)) return false; + + arLen = 0; + arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); + arLenCntdn = arLen; + nStage = 2; + + case 2: + pBuf->valueSize = valSize; + theParser.Initialize(pBuf); + nStage = 3; + + case 3: + for (; arLenCntdn; arLenCntdn--) { + if (!theParser.Parse(pp, pcntdn)) return false; + if (pf) pf(pBuf, (arLen - arLenCntdn), me); + } + + nStage = 0; + } + return true; +} + +#endif // USB_FLASH_DRIVE_SUPPORT diff --git a/src/sd/usb_flashdrive/lib-uhs2/parsetools.h b/src/sd/usb_flashdrive/lib-uhs2/parsetools.h new file mode 100644 index 0000000..403766d --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/parsetools.h @@ -0,0 +1,145 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ +#pragma once + +#ifndef _usb_h_ + #error "Never include parsetools.h directly; include Usb.h instead" +#endif + +struct MultiValueBuffer { + uint8_t valueSize; + void *pValue; +} __attribute__((packed)); + +class MultiByteValueParser { + uint8_t * pBuf; + uint8_t countDown; + uint8_t valueSize; + +public: + + MultiByteValueParser() : pBuf(nullptr), countDown(0), valueSize(0) { + }; + + const uint8_t* GetBuffer() { return pBuf; } + + void Initialize(MultiValueBuffer * const pbuf) { + pBuf = (uint8_t*)pbuf->pValue; + countDown = valueSize = pbuf->valueSize; + } + + bool Parse(uint8_t **pp, uint16_t *pcntdn); +}; + +class ByteSkipper { + uint8_t *pBuf; + uint8_t nStage; + uint16_t countDown; + +public: + + ByteSkipper() : pBuf(nullptr), nStage(0), countDown(0) { + } + + void Initialize(MultiValueBuffer *pbuf) { + pBuf = (uint8_t*)pbuf->pValue; + countDown = 0; + } + + bool Skip(uint8_t **pp, uint16_t *pcntdn, uint16_t bytes_to_skip) { + switch (nStage) { + case 0: + countDown = bytes_to_skip; + nStage++; + case 1: + for (; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--); + + if (!countDown) + nStage = 0; + } + return (!countDown); + } +}; + +// Pointer to a callback function triggered for each element of PTP array when used with PTPArrayParser +typedef void (*PTP_ARRAY_EL_FUNC)(const MultiValueBuffer * const p, uint32_t count, const void *me); + +class PTPListParser { +public: + + enum ParseMode { + modeArray, modeRange/*, modeEnum*/ + }; + +private: + uint8_t nStage; + uint8_t enStage; + + uint32_t arLen; + uint32_t arLenCntdn; + + uint8_t lenSize; // size of the array length field in bytes + uint8_t valSize; // size of the array element in bytes + + MultiValueBuffer *pBuf; + + // The only parser for both size and array element parsing + MultiByteValueParser theParser; + + uint8_t /*ParseMode*/ prsMode; + +public: + + PTPListParser() : + nStage(0), + enStage(0), + arLen(0), + arLenCntdn(0), + lenSize(0), + valSize(0), + pBuf(nullptr), + prsMode(modeArray) {} + ; + + void Initialize(const uint8_t len_size, const uint8_t val_size, MultiValueBuffer * const p, const uint8_t mode = modeArray) { + pBuf = p; + lenSize = len_size; + valSize = val_size; + prsMode = mode; + + if (prsMode == modeRange) { + arLenCntdn = arLen = 3; + nStage = 2; + } + else { + arLenCntdn = arLen = 0; + nStage = 0; + } + enStage = 0; + theParser.Initialize(p); + } + + bool Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me = nullptr); +}; diff --git a/src/sd/usb_flashdrive/lib-uhs2/printhex.h b/src/sd/usb_flashdrive/lib-uhs2/printhex.h new file mode 100644 index 0000000..6ded4fa --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/printhex.h @@ -0,0 +1,80 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ +#pragma once + +#ifndef _usb_h_ + #error "Never include printhex.h directly; include Usb.h instead" +#endif + +void E_Notifyc(char c, int lvl); + +template +void PrintHex(T val, int lvl) { + int num_nybbles = sizeof (T) * 2; + do { + char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F); + if (v > 57) v += 7; + E_Notifyc(v, lvl); + } while (--num_nybbles); +} + +template +void PrintBin(T val, int lvl) { + for (T mask = (((T)1) << ((sizeof (T) << 3) - 1)); mask; mask >>= 1) + E_Notifyc(val & mask ? '1' : '0', lvl); +} + +template +void SerialPrintHex(T val) { + int num_nybbles = sizeof (T) * 2; + do { + char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F); + if (v > 57) v += 7; + USB_HOST_SERIAL.print(v); + } while (--num_nybbles); +} + +template +void PrintHex2(Print *prn, T val) { + T mask = (((T)1) << (((sizeof (T) << 1) - 1) << 2)); + while (mask > 1) { + if (val < mask) prn->print("0"); + mask >>= 4; + } + prn->print((T)val, HEX); +} + +template void D_PrintHex(T val __attribute__((unused)), int lvl __attribute__((unused))) { + #ifdef DEBUG_USB_HOST + PrintHex (val, lvl); + #endif +} + +template +void D_PrintBin(T val, int lvl) { + #ifdef DEBUG_USB_HOST + PrintBin (val, lvl); + #endif +} diff --git a/src/sd/usb_flashdrive/lib-uhs2/settings.h b/src/sd/usb_flashdrive/lib-uhs2/settings.h new file mode 100644 index 0000000..7ce7b5e --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/settings.h @@ -0,0 +1,236 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ + +#pragma once + +#include "../../../inc/MarlinConfig.h" + +#include "macros.h" + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) + //////////////////////////////////////////////////////////////////////////////// + /* Added by Bill Greiman to speed up mass storage initialization with USB + * flash drives and simple USB hard drives. + * Disable this by defining DELAY(x) to be delay(x). + */ + #define delay(x) if ((x) < 200) safe_delay(x) + /* Almost all USB flash drives and simple USB hard drives fail the write + * protect test and add 20 - 30 seconds to USB init. Set SKIP_WRITE_PROTECT + * to nonzero to skip the test and assume the drive is writable. + */ + #define SKIP_WRITE_PROTECT 1 + /* Since Marlin only cares about USB flash drives, we only need one LUN. */ + #define MASS_MAX_SUPPORTED_LUN 1 +#endif + +//////////////////////////////////////////////////////////////////////////////// +// SPI Configuration +//////////////////////////////////////////////////////////////////////////////// + +#ifndef USB_SPI + #define USB_SPI SPI + //#define USB_SPI SPI1 +#endif + +//////////////////////////////////////////////////////////////////////////////// +// DEBUGGING +//////////////////////////////////////////////////////////////////////////////// + +/* Set this to 1 to activate serial debugging */ +#define ENABLE_UHS_DEBUGGING 0 + +/* This can be used to select which serial port to use for debugging if + * multiple serial ports are available. + * For example Serial3. + */ +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #define USB_HOST_SERIAL MYSERIAL1 +#endif + +#ifndef USB_HOST_SERIAL + #define USB_HOST_SERIAL Serial +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Manual board activation +//////////////////////////////////////////////////////////////////////////////// + +/* Set this to 1 if you are using an Arduino Mega ADK board with MAX3421e built-in */ +#define USE_UHS_MEGA_ADK 0 // If you are using Arduino 1.5.5 or newer there is no need to do this manually + +/* Set this to 1 if you are using a Black Widdow */ +#define USE_UHS_BLACK_WIDDOW 0 + +/* Set this to a one to use the xmem2 lock. This is needed for multitasking and threading */ +#define USE_XMEM_SPI_LOCK 0 + +//////////////////////////////////////////////////////////////////////////////// +// Wii IR camera +//////////////////////////////////////////////////////////////////////////////// + +/* Set this to 1 to activate code for the Wii IR camera */ +#define ENABLE_WII_IR_CAMERA 0 + +//////////////////////////////////////////////////////////////////////////////// +// MASS STORAGE +//////////////////////////////////////////////////////////////////////////////// +// ******* IMPORTANT ******* +// Set this to 1 to support single LUN devices, and save RAM. -- I.E. thumb drives. +// Each LUN needs ~13 bytes to be able to track the state of each unit. +#ifndef MASS_MAX_SUPPORTED_LUN + #define MASS_MAX_SUPPORTED_LUN 8 +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Set to 1 to use the faster spi4teensy3 driver. +//////////////////////////////////////////////////////////////////////////////// +#ifndef USE_SPI4TEENSY3 + #define USE_SPI4TEENSY3 1 +#endif + +// Disabled on the Teensy LC, as it is incompatible for now +#ifdef __MKL26Z64__ + #undef USE_SPI4TEENSY3 + #define USE_SPI4TEENSY3 0 +#endif + +//////////////////////////////////////////////////////////////////////////////// +// AUTOMATIC Settings +//////////////////////////////////////////////////////////////////////////////// + +// No user serviceable parts below this line. +// DO NOT change anything below here unless you are a developer! + +//#include "version_helper.h" + +#if defined(__GNUC__) && defined(__AVR__) + #ifndef GCC_VERSION + #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + #endif + #if GCC_VERSION < 40602 // Test for GCC < 4.6.2 + #ifdef PROGMEM + #undef PROGMEM + #define PROGMEM __attribute__((section(".progmem.data"))) // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734#c4 + #ifdef PSTR + #undef PSTR + #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];})) // Copied from pgmspace.h in avr-libc source + #endif + #endif + #endif +#endif + +#if !defined(DEBUG_USB_HOST) && ENABLE_UHS_DEBUGGING + #define DEBUG_USB_HOST +#endif + +#if !defined(WIICAMERA) && ENABLE_WII_IR_CAMERA + #define WIICAMERA +#endif + +// To use some other locking (e.g. freertos), +// define XMEM_ACQUIRE_SPI and XMEM_RELEASE_SPI to point to your lock and unlock. +// NOTE: NO argument is passed. You have to do this within your routine for +// whatever you are using to lock and unlock. +#ifndef XMEM_ACQUIRE_SPI + #if USE_XMEM_SPI_LOCK || defined(USE_MULTIPLE_APP_API) + #include + #else + #define XMEM_ACQUIRE_SPI() (void(0)) + #define XMEM_RELEASE_SPI() (void(0)) + #endif +#endif + +#if !defined(EXT_RAM) && defined(EXT_RAM_STACK) || defined(EXT_RAM_HEAP) + #include +#else + #define EXT_RAM 0 +#endif + +#if defined(CORE_TEENSY) && defined(KINETISK) + #define USING_SPI4TEENSY3 USE_SPI4TEENSY3 +#else + #define USING_SPI4TEENSY3 0 +#endif +#if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(__ARDUINO_X86__) || ARDUINO >= 10600) && !USING_SPI4TEENSY3 + #include // Use the Arduino SPI library for the Arduino Due, Intel Galileo 1 & 2, Intel Edison or if the SPI library with transaction is available +#endif +#ifdef RBL_NRF51822 + #include + #include + #define SPI SPI_Master + #define MFK_CASTUINT8T (uint8_t) // RBLs return type for sizeof needs casting to uint8_t +#endif +#if defined(__PIC32MX__) || defined(__PIC32MZ__) + #include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library +#endif + +#if defined(ESP8266) || defined(ESP32) + #define MFK_CASTUINT8T (uint8_t) // ESP return type for sizeof needs casting to uint8_t +#endif + +#ifdef STM32F4 + #include "stm32f4xx_hal.h" + extern SPI_HandleTypeDef SPI_Handle; // Needed to be declared in your main.cpp +#endif + +// Fix defines on Arduino Due +#ifdef ARDUINO_SAM_DUE + #ifdef tokSETUP + #undef tokSETUP + #endif + #ifdef tokIN + #undef tokIN + #endif + #ifdef tokOUT + #undef tokOUT + #endif + #ifdef tokINHS + #undef tokINHS + #endif + #ifdef tokOUTHS + #undef tokOUTHS + #endif +#endif + +// Set defaults +#ifndef MFK_CASTUINT8T + #define MFK_CASTUINT8T +#endif + +// Workaround issue: https://github.com/esp8266/Arduino/issues/2078 +#ifdef ESP8266 + #undef PROGMEM + #define PROGMEM +#undef PSTR + #define PSTR(s) (s) +#undef pgm_read_byte + #define pgm_read_byte(addr) (*reinterpret_cast(addr)) + #undef pgm_read_word + #define pgm_read_word(addr) (*reinterpret_cast(addr)) +#endif + +#ifdef ARDUINO_ESP8266_WIFIO + #error "This board is currently not supported" +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h b/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h new file mode 100644 index 0000000..99c628f --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h @@ -0,0 +1,170 @@ +/** + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + */ + +#ifndef _usb_h_ + #error "Never include usb_ch9.h directly; include Usb.h instead" +#endif + +/* USB chapter 9 structures */ + +/* Misc.USB constants */ +#define DEV_DESCR_LEN 18 //device descriptor length +#define CONF_DESCR_LEN 9 //configuration descriptor length +#define INTR_DESCR_LEN 9 //interface descriptor length +#define EP_DESCR_LEN 7 //endpoint descriptor length + +/* Standard Device Requests */ + +#define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS +#define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE +#define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE +#define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS +#define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR +#define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR +#define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION +#define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION +#define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE +#define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE +#define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME + +#define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt +#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up +#define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode + +/* Setup Data Constants */ + +#define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer +#define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer +#define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard +#define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class +#define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor +#define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device +#define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface +#define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint +#define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other + +/* USB descriptors */ + +#define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor. +#define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor. +#define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor. +#define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor. +#define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor. +#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier. +#define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration. +#define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power. +#define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor. + +#define HID_DESCRIPTOR_HID 0x21 + + +/* OTG SET FEATURE Constants */ +#define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP +#define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP +#define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP + +/* USB Endpoint Transfer Types */ +#define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint. +#define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint. +#define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint. +#define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint. +#define bmUSB_TRANSFER_TYPE 0x03 // bit mask to separate transfer type from ISO attributes + + +/* Standard Feature Selectors for CLEAR_FEATURE Requests */ +#define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient +#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient +#define USB_FEATURE_TEST_MODE 2 // Device recipient + +/* descriptor data structures */ + +/* Device descriptor structure */ +typedef struct { + uint8_t bLength; // Length of this descriptor. + uint8_t bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE). + uint16_t bcdUSB; // USB Spec Release Number (BCD). + uint8_t bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. + uint8_t bDeviceSubClass; // Subclass code (assigned by the USB-IF). + uint8_t bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. + uint8_t bMaxPacketSize0; // Maximum packet size for endpoint 0. + uint16_t idVendor; // Vendor ID (assigned by the USB-IF). + uint16_t idProduct; // Product ID (assigned by the manufacturer). + uint16_t bcdDevice; // Device release number (BCD). + uint8_t iManufacturer; // Index of String Descriptor describing the manufacturer. + uint8_t iProduct; // Index of String Descriptor describing the product. + uint8_t iSerialNumber; // Index of String Descriptor with the device's serial number. + uint8_t bNumConfigurations; // Number of possible configurations. +} __attribute__((packed)) USB_FD_DEVICE_DESCRIPTOR; + +/* Configuration descriptor structure */ +typedef struct { + uint8_t bLength; // Length of this descriptor. + uint8_t bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION). + uint16_t wTotalLength; // Total length of all descriptors for this configuration. + uint8_t bNumInterfaces; // Number of interfaces in this configuration. + uint8_t bConfigurationValue; // Value of this configuration (1 based). + uint8_t iConfiguration; // Index of String Descriptor describing the configuration. + uint8_t bmAttributes; // Configuration characteristics. + uint8_t bMaxPower; // Maximum power consumed by this configuration. +} __attribute__((packed)) USB_FD_CONFIGURATION_DESCRIPTOR; + +/* Interface descriptor structure */ +typedef struct { + uint8_t bLength; // Length of this descriptor. + uint8_t bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE). + uint8_t bInterfaceNumber; // Number of this interface (0 based). + uint8_t bAlternateSetting; // Value of this alternate interface setting. + uint8_t bNumEndpoints; // Number of endpoints in this interface. + uint8_t bInterfaceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. + uint8_t bInterfaceSubClass; // Subclass code (assigned by the USB-IF). + uint8_t bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. + uint8_t iInterface; // Index of String Descriptor describing the interface. +} __attribute__((packed)) USB_FD_INTERFACE_DESCRIPTOR; + +/* Endpoint descriptor structure */ +typedef struct { + uint8_t bLength; // Length of this descriptor. + uint8_t bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT). + uint8_t bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN). + uint8_t bmAttributes; // Endpoint transfer type. + uint16_t wMaxPacketSize; // Maximum packet size. + uint8_t bInterval; // Polling interval in frames. +} __attribute__((packed)) USB_FD_ENDPOINT_DESCRIPTOR; + +/* HID descriptor */ +typedef struct { + uint8_t bLength; + uint8_t bDescriptorType; + uint16_t bcdHID; // HID class specification release + uint8_t bCountryCode; + uint8_t bNumDescriptors; // Number of additional class specific descriptors + uint8_t bDescrType; // Type of class descriptor + uint16_t wDescriptorLength; // Total size of the Report descriptor +} __attribute__((packed)) USB_HID_DESCRIPTOR; + +typedef struct { + uint8_t bDescrType; // Type of class descriptor + uint16_t wDescriptorLength; // Total size of the Report descriptor +} __attribute__((packed)) HID_CLASS_DESCRIPTOR_LEN_AND_TYPE; diff --git a/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp b/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp new file mode 100644 index 0000000..09fd57b --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp @@ -0,0 +1,206 @@ +/**************** + * usb_host.cpp * + ****************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +/* What follows is a modified version of the MAX3421e originally defined in + * lib/usbhost.c". This has been rewritten to use SPI routines from the + * Marlin HAL */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB) + +#if !PINS_EXIST(USB_CS, USB_INTR) + #error "USB_FLASH_DRIVE_SUPPORT requires USB_CS_PIN and USB_INTR_PIN to be defined." +#endif + +#include "Usb.h" +#include "usbhost.h" + +uint8_t MAX3421e::vbusState = 0; + +// constructor +void MAX3421e::cs() { WRITE(USB_CS_PIN, LOW); } +void MAX3421e::ncs() { WRITE(USB_CS_PIN, HIGH); } + +// write single byte into MAX3421 register +void MAX3421e::regWr(uint8_t reg, uint8_t data) { + cs(); + spiSend(reg | 0x02); + spiSend(data); + ncs(); +} + +// multiple-byte write +// return a pointer to memory position after last written +uint8_t* MAX3421e::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { + cs(); + spiSend(reg | 0x02); + while (nbytes--) spiSend(*data_p++); + ncs(); + return data_p; +} + +// GPIO write +// GPIO byte is split between 2 registers, so two writes are needed to write one byte + +// GPOUT bits are in the low nybble. 0-3 in IOPINS1, 4-7 in IOPINS2 +void MAX3421e::gpioWr(uint8_t data) { + regWr(rIOPINS1, data); + regWr(rIOPINS2, data >> 4); +} + +// single host register read +uint8_t MAX3421e::regRd(uint8_t reg) { + cs(); + spiSend(reg); + uint8_t rv = spiRec(); + ncs(); + return rv; +} + +// multiple-byte register read +// return a pointer to a memory position after last read +uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { + cs(); + spiSend(reg); + while (nbytes--) *data_p++ = spiRec(); + ncs(); + return data_p; +} + +// GPIO read. See gpioWr for explanation +// GPIN pins are in high nybbles of IOPINS1, IOPINS2 +uint8_t MAX3421e::gpioRd() { + return (regRd(rIOPINS2) & 0xF0) | // pins 4-7, clean lower nybble + (regRd(rIOPINS1) >> 4); // shift low bits and OR with upper from previous operation. +} + +// reset MAX3421e. Returns false if PLL failed to stabilize 1 second after reset +bool MAX3421e::reset() { + regWr(rUSBCTL, bmCHIPRES); + regWr(rUSBCTL, 0x00); + for (uint8_t i = 100; i--;) { + if (regRd(rUSBIRQ) & bmOSCOKIRQ) return true; + delay(10); + } + return false; +} + +// initialize MAX3421e. Set Host mode, pullups, and stuff. Returns 0 if success, -1 if not +bool MAX3421e::start() { + // Initialize pins and SPI bus + + SET_OUTPUT(USB_CS_PIN); + SET_INPUT_PULLUP(USB_INTR_PIN); + ncs(); + spiBegin(); + + spiInit(SD_SPI_SPEED); + + // MAX3421e - full-duplex, level interrupt, vbus off. + regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL | GPX_VBDET)); + + const uint8_t revision = regRd(rREVISION); + if (revision == 0x00 || revision == 0xFF) { + SERIAL_ECHOLNPGM("Revision register appears incorrect on MAX3421e initialization. Got ", revision); + return false; + } + + if (!reset()) { + SERIAL_ECHOLNPGM("OSCOKIRQ hasn't asserted in time"); + return false; + } + + // Delay a minimum of 1 second to ensure any capacitors are drained. + // 1 second is required to make sure we do not smoke a Microdrive! + + delay(1000); + + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host + regWr(rHIEN, bmCONDETIE | bmFRAMEIE); // connection detection + + // check if device is connected + regWr(rHCTL, bmSAMPLEBUS); // sample USB bus + while (!(regRd(rHCTL) & bmSAMPLEBUS)) delay(10); // wait for sample operation to finish + + busprobe(); // check if anything is connected + + regWr(rHIRQ, bmCONDETIRQ); // clear connection detect interrupt + regWr(rCPUCTL, 0x01); // enable interrupt pin + + // GPX pin on. This is done here so that busprobe will fail if we have a switch connected. + regWr(rPINCTL, bmFDUPSPI | bmINTLEVEL); + + return true; +} + +// Probe bus to determine device presence and speed. Switch host to this speed. +void MAX3421e::busprobe() { + // Switch on just the J & K bits + switch (regRd(rHRSL) & (bmJSTATUS | bmKSTATUS)) { + case bmJSTATUS: + if ((regRd(rMODE) & bmLOWSPEED) == 0) { + regWr(rMODE, MODE_FS_HOST); // start full-speed host + vbusState = FSHOST; + } + else { + regWr(rMODE, MODE_LS_HOST); // start low-speed host + vbusState = LSHOST; + } + break; + case bmKSTATUS: + if ((regRd(rMODE) & bmLOWSPEED) == 0) { + regWr(rMODE, MODE_LS_HOST); // start low-speed host + vbusState = LSHOST; + } + else { + regWr(rMODE, MODE_FS_HOST); // start full-speed host + vbusState = FSHOST; + } + break; + case bmSE1: // illegal state + vbusState = SE1; + break; + case bmSE0: // disconnected state + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST | bmSEPIRQ); + vbusState = SE0; + break; + } +} + +// MAX3421 state change task and interrupt handler +uint8_t MAX3421e::Task() { + return READ(USB_INTR_PIN) ? 0 : IntHandler(); +} + +uint8_t MAX3421e::IntHandler() { + uint8_t HIRQ = regRd(rHIRQ), // determine interrupt source + HIRQ_sendback = 0x00; + if (HIRQ & bmCONDETIRQ) { + busprobe(); + HIRQ_sendback |= bmCONDETIRQ; + } + // End HIRQ interrupts handling, clear serviced IRQs + regWr(rHIRQ, HIRQ_sendback); + return HIRQ_sendback; +} + +#endif // USB_FLASH_DRIVE_SUPPORT diff --git a/src/sd/usb_flashdrive/lib-uhs2/usbhost.h b/src/sd/usb_flashdrive/lib-uhs2/usbhost.h new file mode 100644 index 0000000..cbdd281 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs2/usbhost.h @@ -0,0 +1,58 @@ +/************** + * usb_host.h * + **************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#pragma once + +/* This the following comes from "lib/usbhost.h", but has been rewritten + * to use the SPI functions from Marlin's HAL */ + +class MAX3421e { + private: + static uint8_t vbusState; + void cs(); + void ncs(); + + uint8_t GpxHandler(); + uint8_t IntHandler(); + + public: + bool start(); + + void regWr(uint8_t reg, uint8_t data); + uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p); + void gpioWr(uint8_t data); + uint8_t regRd(uint8_t reg); + uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p); + uint8_t gpioRd(); + bool reset(); + + uint8_t getVbusState() {return vbusState;}; + + void busprobe(); + + uint8_t Task(); +}; + +#define USE_MARLIN_MAX3421E + +#if defined(__SAM3X8E__) && !defined(ARDUINO_SAM_DUE) + #define ARDUINO_SAM_DUE // Spoof the USB library that this is a DUE +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs3/README.txt b/src/sd/usb_flashdrive/lib-uhs3/README.txt new file mode 100644 index 0000000..434b17b --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/README.txt @@ -0,0 +1,29 @@ +==== USB HOST SHIELD 3.0 LIBRARY ==== + +The lib-uhs3/ folder contains a subset of the files from the USB Host Shield +3.0 library: + + https://github.com/felis/UHS30 + + +==== LICENSE SUMMARY ==== + +Source Path: Repository: License: +------------ ----------- -------- +usb_flashdrive/lib github.com/felis/UHS30 GPLv2 or later + + +==== MARLIN INTEGRATION WORK ==== + +All additional work done to integrate USB into Marlin was performed by +LulzBot and is licensed under the GPLv3. + +This version of UHS3 has been modified for better compatibility with Marlin. +The upstream version of UHS 3.0 runs a frame timer interrupt every 1 ms to +handle device polling. This timer interrupt interferes with Marlin's stepper +IRQ, so the flag USB_HOST_MANUAL_POLL has been added to move the polling to +the idle task. Additional logic was added to disable and enable the frame +IRQ. + +SKIP_PAGE3F and USB_NO_TEST_UNIT_READY were added to work around bugs with +certain devices. diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h new file mode 100644 index 0000000..b35e536 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h @@ -0,0 +1,249 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and + Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#ifndef __UHS_BULK_STORAGE_H__ +#define __UHS_BULK_STORAGE_H__ + + +//////////////////////////////////////////////////////////////////////////////// +// Define any of these options at the top of your sketch to override +// the defaults contained herewith. Do NOT do modifications here. +// Macro | Settings and notes | Default +// -----------------------------------------+-----------------------+----------- +// | 1 to 8 | +// | Each LUN needs | +// MASS_MAX_SUPPORTED_LUN | ~13 bytes to be able | 8 +// | to track the state of | +// | each unit. | +// -----------------------------------------+-----------------------+----------- +// | Just define to use. | +// DEBUG_PRINTF_EXTRA_HUGE_UHS_BULK_STORAGE | works only if extra | +// | huge debug is on too. | +// -----------------------------------------^-----------------------^----------- + +#ifndef MASS_MAX_SUPPORTED_LUN +#define MASS_MAX_SUPPORTED_LUN 8 +#endif + +#include "UHS_SCSI.h" + +#define UHS_BULK_bmREQ_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE +#define UHS_BULK_bmREQ_IN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE + +// Request Codes +#define UHS_BULK_REQ_ADSC 0x00U +#define UHS_BULK_REQ_GET 0xFCU +#define UHS_BULK_REQ_PUT 0xFDU +#define UHS_BULK_REQ_GET_MAX_LUN 0xFEU +#define UHS_BULK_REQ_BOMSR 0xFFU // Mass Storage Reset + +#define UHS_BULK_CBW_SIGNATURE 0x43425355LU +#define UHS_BULK_CSW_SIGNATURE 0x53425355LU + +#define UHS_BULK_CMD_DIR_OUT 0x00U +#define UHS_BULK_CMD_DIR_IN 0x80U + +/* Bulk error codes */ +#define UHS_BULK_ERR_SUCCESS UHS_HOST_ERROR_NONE +#define UHS_BULK_ERR_PHASE_ERROR 0x22U +#define UHS_BULK_ERR_UNIT_NOT_READY 0x23U +#define UHS_BULK_ERR_UNIT_BUSY 0x24U +#define UHS_BULK_ERR_STALL 0x25U +#define UHS_BULK_ERR_CMD_NOT_SUPPORTED 0x26U +#define UHS_BULK_ERR_INVALID_CSW 0x27U +#define UHS_BULK_ERR_NO_MEDIA 0x28U +#define UHS_BULK_ERR_BAD_LBA 0x29U +#define UHS_BULK_ERR_MEDIA_CHANGED 0x2AU +#define UHS_BULK_ERR_DEVICE_DISCONNECTED UHS_HOST_ERROR_UNPLUGGED +#define UHS_BULK_ERR_UNABLE_TO_RECOVER 0x32U // Reset recovery error +#define UHS_BULK_ERR_INVALID_LUN 0x33U +#define UHS_BULK_ERR_WRITE_STALL 0x34U +#define UHS_BULK_ERR_READ_NAKS 0x35U +#define UHS_BULK_ERR_WRITE_NAKS 0x36U +#define UHS_BULK_ERR_WRITE_PROTECTED 0x37U +#define UHS_BULK_ERR_NOT_IMPLEMENTED 0xFDU +#define UHS_BULK_ERR_GENERAL_SCSI_ERROR 0xF0U +#define UHS_BULK_ERR_GENERAL_USB_ERROR 0xFFU +#define UHS_BULK_ERR_USER 0xA0U // For subclasses to define their own error codes + +#define MASS_MAX_ENDPOINTS 3 + +struct UHS_BULK_CommandBlockWrapperBase { + volatile uint32_t dCBWSignature; + volatile uint32_t dCBWTag; + volatile uint32_t dCBWDataTransferLength; + volatile uint8_t bmCBWFlags; +public: + + UHS_BULK_CommandBlockWrapperBase() { + } + + UHS_BULK_CommandBlockWrapperBase(uint32_t tag, uint32_t xflen, uint8_t flgs) : + dCBWSignature(UHS_BULK_CBW_SIGNATURE), dCBWTag(tag), dCBWDataTransferLength(xflen), bmCBWFlags(flgs) { + } +} __attribute__((packed)); + +struct UHS_BULK_CommandBlockWrapper : public UHS_BULK_CommandBlockWrapperBase { + + struct { + uint8_t bmCBWLUN : 4; + uint8_t bmReserved1 : 4; + }; + + struct { + uint8_t bmCBWCBLength : 4; + uint8_t bmReserved2 : 4; + }; + + uint8_t CBWCB[16]; + +public: + // All zeroed. + + UHS_BULK_CommandBlockWrapper() : + UHS_BULK_CommandBlockWrapperBase(0, 0, 0), bmReserved1(0), bmReserved2(0) { + for(int i = 0; i < 16; i++) CBWCB[i] = 0; + } + + // Generic Wrap, CDB zeroed. + + UHS_BULK_CommandBlockWrapper(uint32_t tag, uint32_t xflen, uint8_t flgs, uint8_t lu, uint8_t cmdlen, uint8_t cmd) : + UHS_BULK_CommandBlockWrapperBase(tag, xflen, flgs), + bmCBWLUN(lu), bmReserved1(0), bmCBWCBLength(cmdlen), bmReserved2(0) { + for(int i = 0; i < 16; i++) CBWCB[i] = 0; + SCSI_CDB_BASE_t *x = reinterpret_cast(CBWCB); + x->LUN = cmd; + } + + // Wrap for CDB of 6 + + UHS_BULK_CommandBlockWrapper(uint32_t tag, uint32_t xflen, SCSI_CDB6_t *cdb, uint8_t dir) : + UHS_BULK_CommandBlockWrapperBase(tag, xflen, dir), + bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(6), bmReserved2(0) { + memcpy(&CBWCB, cdb, 6); + } + // Wrap for CDB of 10 + + UHS_BULK_CommandBlockWrapper(uint32_t tag, uint32_t xflen, SCSI_CDB10_t *cdb, uint8_t dir) : + UHS_BULK_CommandBlockWrapperBase(tag, xflen, dir), + bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(10), bmReserved2(0) { + memcpy(&CBWCB, cdb, 10); + } +} __attribute__((packed)); + +struct UHS_BULK_CommandStatusWrapper { + uint32_t dCSWSignature; + uint32_t dCSWTag; + uint32_t dCSWDataResidue; + uint8_t bCSWStatus; +} __attribute__((packed)); + +class UHS_Bulk_Storage : public UHS_USBInterface { +protected: + static const uint8_t epDataInIndex = 1; // DataIn endpoint index + static const uint8_t epDataOutIndex = 2; // DataOUT endpoint index + static const uint8_t epInterruptInIndex = 3; // InterruptIN endpoint index + + uint8_t bMaxLUN; // Max LUN + volatile uint32_t dCBWTag; // Tag + volatile uint8_t bTheLUN; // Active LUN + volatile uint32_t CurrentCapacity[MASS_MAX_SUPPORTED_LUN]; // Total sectors + volatile uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits + volatile bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes. + volatile bool WriteOk[MASS_MAX_SUPPORTED_LUN]; + void PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR* ep_ptr); + +public: + UHS_Bulk_Storage(UHS_USB_HOST_BASE *p); + + volatile UHS_EpInfo epInfo[MASS_MAX_ENDPOINTS]; + + uint8_t GetbMaxLUN() { + return bMaxLUN; // Max LUN + } + + uint8_t GetbTheLUN() { + return bTheLUN; // Active LUN + } + + bool WriteProtected(uint8_t lun); + uint8_t MediaCTL(uint8_t lun, uint8_t ctl); + uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf); + uint8_t Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t *buf); + uint8_t LockMedia(uint8_t lun, uint8_t lock); + + bool LUNIsGood(uint8_t lun); + uint32_t GetCapacity(uint8_t lun); + uint16_t GetSectorSize(uint8_t lun); + uint8_t SCSITransaction6(SCSI_CDB6_t *cdb, uint16_t buf_size, void *buf, uint8_t dir); + uint8_t SCSITransaction10(SCSI_CDB10_t *cdb, uint16_t buf_size, void *buf, uint8_t dir); + + + // Configure and internal methods, these should never be called by a user's sketch. + uint8_t Start(); + bool OKtoEnumerate(ENUMERATION_INFO *ei); + uint8_t SetInterface(ENUMERATION_INFO *ei); + + uint8_t GetAddress() { + return bAddress; + }; + + + void Poll(); + + void DriverDefaults(); + + +private: + void Reset(); + void CheckMedia(); + + bool IsValidCBW(uint8_t size, uint8_t *pcbw); + bool IsMeaningfulCBW(uint8_t size, uint8_t *pcbw); + bool IsValidCSW(UHS_BULK_CommandStatusWrapper *pcsw, UHS_BULK_CommandBlockWrapperBase *pcbw); + + bool CheckLUN(uint8_t lun); + + uint8_t Inquiry(uint8_t lun, uint16_t size, uint8_t *buf); + uint8_t TestUnitReady(uint8_t lun); + uint8_t RequestSense(uint8_t lun, uint16_t size, uint8_t *buf); + uint8_t ModeSense6(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t *buf); + uint8_t GetMaxLUN(uint8_t *max_lun); + uint8_t SetCurLUN(uint8_t lun); + uint8_t ResetRecovery(); + uint8_t ReadCapacity10(uint8_t lun, uint8_t *buf); + uint8_t Page3F(uint8_t lun); + uint8_t ClearEpHalt(uint8_t index); + uint8_t Transaction(UHS_BULK_CommandBlockWrapper *cbw, uint16_t bsize, void *buf); + uint8_t HandleUsbError(uint8_t error, uint8_t index); + uint8_t HandleSCSIError(uint8_t status); + +}; + +#if defined(LOAD_UHS_BULK_STORAGE) && !defined(UHS_BULK_STORAGE_LOADED) +#include "UHS_BULK_STORAGE_INLINE.h" +#endif +#endif // __MASSTORAGE_H__ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h new file mode 100644 index 0000000..37ba681 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h @@ -0,0 +1,1205 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#if defined(LOAD_UHS_BULK_STORAGE) && defined(__UHS_BULK_STORAGE_H__) && !defined(UHS_BULK_STORAGE_LOADED) +#define UHS_BULK_STORAGE_LOADED + +// uncomment to get 'printf' console debugging. NOT FOR UNO! +//#define DEBUG_PRINTF_EXTRA_HUGE_UHS_BULK_STORAGE + +#if DEBUG_PRINTF_EXTRA_HUGE +#ifdef DEBUG_PRINTF_EXTRA_HUGE_UHS_BULK_STORAGE +#define BS_HOST_DEBUG(...) printf(__VA_ARGS__) +#else +#define BS_HOST_DEBUG(...) VOID0 +#endif +#else +#define BS_HOST_DEBUG(...) VOID0 +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// Interface code + +//////////////////////////////////////////////////////////////////////////////// + +/** + * Get the capacity of the media + * + * @param lun Logical Unit Number + * @return media capacity + */ +uint32_t UHS_NI UHS_Bulk_Storage::GetCapacity(uint8_t lun) { + uint32_t v = 0LU; + pUsb->DisablePoll(); + if(LUNOk[lun]) + v = CurrentCapacity[lun]; + pUsb->EnablePoll(); + return v; +} + +/** + * Get the sector (block) size used on the media + * + * @param lun Logical Unit Number + * @return media sector size + */ +uint16_t UHS_NI UHS_Bulk_Storage::GetSectorSize(uint8_t lun) { + uint16_t v = 0U; + pUsb->DisablePoll(); + if(LUNOk[lun]) + v = CurrentSectorSize[lun]; + pUsb->EnablePoll(); + return v; +} + +/** + * Test if LUN is ready for use + * + * @param lun Logical Unit Number + * @return true if LUN is ready for use + */ +bool UHS_NI UHS_Bulk_Storage::LUNIsGood(uint8_t lun) { + bool v; + pUsb->DisablePoll(); + v = LUNOk[lun]; + pUsb->EnablePoll(); + return v; +} + +/** + * Test if LUN is write protected + * + * @param lun Logical Unit Number + * @return cached status of write protect switch + */ +bool UHS_NI UHS_Bulk_Storage::WriteProtected(uint8_t lun) { + bool v; + pUsb->DisablePoll(); + v = WriteOk[lun]; + pUsb->EnablePoll(); + return v; +} + +/** + * Wrap and execute a SCSI CDB with length of 6 + * + * @param cdb CDB to execute + * @param buf_size Size of expected transaction + * @param buf Buffer + * @param dir MASS_CMD_DIR_IN | MASS_CMD_DIR_OUT + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::SCSITransaction6(SCSI_CDB6_t *cdb, uint16_t buf_size, void *buf, uint8_t dir) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + pUsb->DisablePoll(); + // promote buf_size to 32bits. + UHS_BULK_CommandBlockWrapper cbw = UHS_BULK_CommandBlockWrapper(++dCBWTag, (uint32_t)buf_size, cdb, dir); + +#if 0 + // Lets check the CBW here: + printf("\r\n"); + printf("\r\n"); + uint8_t *dump = (uint8_t*)(&cbw); + + for(int i=0; i<(sizeof (UHS_BULK_CommandBlockWrapper)); i++) { + printf("%02.2x ", *dump); + dump++; + } + printf("\r\n"); + printf("\r\n"); +#endif + + uint8_t v = (HandleSCSIError(Transaction(&cbw, buf_size, buf))); + pUsb->EnablePoll(); + return v; +} + +/** + * Wrap and execute a SCSI CDB with length of 10 + * + * @param cdb CDB to execute + * @param buf_size Size of expected transaction + * @param buf Buffer + * @param dir MASS_CMD_DIR_IN | MASS_CMD_DIR_OUT + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::SCSITransaction10(SCSI_CDB10_t *cdb, uint16_t buf_size, void *buf, uint8_t dir) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + pUsb->DisablePoll(); + // promote buf_size to 32bits. + UHS_BULK_CommandBlockWrapper cbw = UHS_BULK_CommandBlockWrapper(++dCBWTag, (uint32_t)buf_size, cdb, dir); + //SetCurLUN(cdb->LUN); + uint8_t v = (HandleSCSIError(Transaction(&cbw, buf_size, buf))); + pUsb->EnablePoll(); + return v; +} + +/** + * Lock or Unlock the tray or door on device. + * Caution: Some devices with buggy firmware will lock up. + * + * @param lun Logical Unit Number + * @param lock 1 to lock, 0 to unlock + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::LockMedia(uint8_t lun, uint8_t lock) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + pUsb->DisablePoll(); + Notify(PSTR("\r\nLockMedia\r\n"), 0x80); + Notify(PSTR("---------\r\n"), 0x80); + + SCSI_CDB6_t cdb = SCSI_CDB6_t(SCSI_CMD_PREVENT_REMOVAL, lun, (uint8_t)0, lock); + + uint8_t v = SCSITransaction6(&cdb, (uint16_t)0, NULL, (uint8_t)UHS_BULK_CMD_DIR_IN); + pUsb->EnablePoll(); + return v; +} + +/** + * Media control, for spindle motor and media tray or door. + * This includes CDROM, TAPE and anything with a media loader. + * + * @param lun Logical Unit Number + * @param ctl 0x00 Stop Motor, 0x01 Start Motor, 0x02 Eject Media, 0x03 Load Media + * @return 0 on success + */ +uint8_t UHS_NI UHS_Bulk_Storage::MediaCTL(uint8_t lun, uint8_t ctl) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + pUsb->DisablePoll(); + Notify(PSTR("\r\nMediaCTL\r\n"), 0x80); + Notify(PSTR("-----------------\r\n"), 0x80); + + uint8_t rcode = UHS_BULK_ERR_UNIT_NOT_READY; + if(bAddress) { + SCSI_CDB6_t cdb = SCSI_CDB6_t(SCSI_CMD_START_STOP_UNIT, lun, ctl & 0x03, 0); + rcode = SCSITransaction6(&cdb, (uint16_t)0, NULL, (uint8_t)UHS_BULK_CMD_DIR_OUT); + } else { + SetCurLUN(lun); + } + pUsb->EnablePoll(); + return rcode; +} + +/** + * Read data from media + * + * @param lun Logical Unit Number + * @param addr LBA address on media to read + * @param bsize size of a block (we should probably use the cached size) + * @param blocks how many blocks to read + * @param buf memory that is able to hold the requested data + * @return 0 on success + */ +uint8_t UHS_NI UHS_Bulk_Storage::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf) { + if(!bAddress) return UHS_BULK_ERR_NO_MEDIA; + uint8_t er = UHS_BULK_ERR_NO_MEDIA; + pUsb->DisablePoll(); + if(LUNOk[lun]) { + Notify(PSTR("\r\nRead LUN:\t"), 0x80); + D_PrintHex (lun, 0x90); + Notify(PSTR("\r\nLBA:\t\t"), 0x90); + D_PrintHex (addr, 0x90); + Notify(PSTR("\r\nblocks:\t\t"), 0x90); + D_PrintHex (blocks, 0x90); + Notify(PSTR("\r\nblock size:\t"), 0x90); + D_PrintHex (bsize, 0x90); + Notify(PSTR("\r\n---------\r\n"), 0x80); + SCSI_CDB10_t cdb = SCSI_CDB10_t(SCSI_CMD_READ_10, lun, blocks, addr); + +again: + er = SCSITransaction10(&cdb, ((uint16_t)bsize * blocks), buf, (uint8_t)UHS_BULK_CMD_DIR_IN); + + if(er == UHS_BULK_ERR_STALL) { + MediaCTL(lun, 1); + + if(UHS_SLEEP_MS(150)) { + if(!TestUnitReady(lun)) goto again; + } + } + } + qNextPollTime = millis() + 100; + pUsb->EnablePoll(); + + return er; +} + +/** + * Write data to media + * + * @param lun Logical Unit Number + * @param addr LBA address on media to write + * @param bsize size of a block (we should probably use the cached size) + * @param blocks how many blocks to write + * @param buf memory that contains the data to write + * @return 0 on success + */ +uint8_t UHS_NI UHS_Bulk_Storage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) { + if(!bAddress) return UHS_BULK_ERR_NO_MEDIA; + uint8_t er = UHS_BULK_ERR_NO_MEDIA; + pUsb->DisablePoll(); + if(LUNOk[lun]) { + if(!WriteOk[lun]) { + er = UHS_BULK_ERR_WRITE_PROTECTED; + } else { + Notify(PSTR("\r\nWrite LUN:\t"), 0x80); + D_PrintHex (lun, 0x90); + Notify(PSTR("\r\nLBA:\t\t"), 0x90); + D_PrintHex (addr, 0x90); + Notify(PSTR("\r\nblocks:\t\t"), 0x90); + D_PrintHex (blocks, 0x90); + Notify(PSTR("\r\nblock size:\t"), 0x90); + D_PrintHex (bsize, 0x90); + Notify(PSTR("\r\n---------\r\n"), 0x80); + SCSI_CDB10_t cdb = SCSI_CDB10_t(SCSI_CMD_WRITE_10, lun, blocks, addr); + +again: + er = SCSITransaction10(&cdb, ((uint16_t)bsize * blocks), (void*)buf, (uint8_t)UHS_BULK_CMD_DIR_OUT); + + if(er == UHS_BULK_ERR_WRITE_STALL) { + MediaCTL(lun, 1); + + if(UHS_SLEEP_MS(150)) { + if(!TestUnitReady(lun)) goto again; + } + } + } + } + qNextPollTime = millis() + 100; + pUsb->EnablePoll(); + + return er; +} + +// End of user functions, the remaining code below is driver internals. +// Only developer serviceable parts below! + +//////////////////////////////////////////////////////////////////////////////// + +// Main driver code + +//////////////////////////////////////////////////////////////////////////////// + +UHS_NI UHS_Bulk_Storage::UHS_Bulk_Storage(UHS_USB_HOST_BASE *p) { + pUsb = p; + dCBWTag = 0; + if(pUsb) { + + DriverDefaults(); + pUsb->RegisterDeviceClass(this); + // Serial.print("Bulk Register to USB Host @ 0x"); + // Serial.println((uint32_t)pUsb, HEX); + // Serial.print("Bulk Register to USB Host Address Pool @ 0x"); + // Serial.println((uint32_t)pUsb->GetAddressPool(), HEX); + } +} + +/** + * @param ei Enumeration information + * @return true if this interface driver can handle this interface description + */ +bool UHS_NI UHS_Bulk_Storage::OKtoEnumerate(ENUMERATION_INFO *ei) { + BS_HOST_DEBUG("BulkOnly: checking numep %i, klass %2.2x, subklass %2.2x\r\n", ei->interface.numep, ei->klass, ei->subklass); + BS_HOST_DEBUG("BulkOnly: checking protocol %2.2x, interface.klass %2.2x, interface.subklass %2.2x\r\n", ei->protocol, ei->interface.klass, ei->interface.subklass); + BS_HOST_DEBUG("BulkOnly: checking interface.protocol %2.2x\r\n", ei->interface.protocol); + // + // TO-DO? + // Check that we have 2 bulk endpoints, and one in each direction?? + // e.g. (ei->interface.numep > 1) && // two or more endpoints AND check types + // This will work with proper hardware though. + // + + return ( + ((ei->klass == UHS_USB_CLASS_MASS_STORAGE) || (ei->interface.klass == UHS_USB_CLASS_MASS_STORAGE)) && // mass storage class AND + ((ei->subklass == UHS_BULK_SUBCLASS_SCSI) || (ei->interface.subklass == UHS_BULK_SUBCLASS_SCSI)) && // SCSI command set AND + ((ei->protocol == UHS_STOR_PROTO_BBB) || (ei->interface.protocol == UHS_STOR_PROTO_BBB)) // Bulk Only transport + ); +} + +/** + * @param ei Enumeration information + * @return 0 always + */ +uint8_t UHS_NI UHS_Bulk_Storage::SetInterface(ENUMERATION_INFO *ei) { + uint8_t index; + + bAddress = ei->address; + BS_HOST_DEBUG("BS SetInterface\r\n"); + // Fill in the endpoint info structure + for(uint8_t ep = 0; ep < ei->interface.numep; ep++) { + BS_HOST_DEBUG("ep: 0x%2.2x bmAttributes: 0x%2.2x ", ep, ei->interface.epInfo[ep].bmAttributes); + if(ei->interface.epInfo[ep].bmAttributes == USB_TRANSFER_TYPE_BULK) { + index = ((ei->interface.epInfo[ep].bEndpointAddress & USB_TRANSFER_DIRECTION_IN) == USB_TRANSFER_DIRECTION_IN) ? epDataInIndex : epDataOutIndex; + epInfo[index].epAddr = (ei->interface.epInfo[ep].bEndpointAddress & 0x0F); + epInfo[index].maxPktSize = ei->interface.epInfo[ep].wMaxPacketSize; + epInfo[index].epAttribs = 0; + epInfo[index].bmNakPower = UHS_USB_NAK_MAX_POWER; + epInfo[index].bmSndToggle = 0; + epInfo[index].bmRcvToggle = 0; + epInfo[index].bIface=ei->interface.bInterfaceNumber; + BS_HOST_DEBUG("index: %i\r\n", index); + } + BS_HOST_DEBUG("\r\n"); + } + bNumEP = 3; + epInfo[0].epAddr = 0; + epInfo[0].maxPktSize = ei->bMaxPacketSize0; + epInfo[0].bmNakPower = UHS_USB_NAK_MAX_POWER; + bIface = ei->interface.bInterfaceNumber; + + return 0; +}; + +/** + * @return 0 for success + */ +uint8_t UHS_NI UHS_Bulk_Storage::Start() { + uint8_t rcode; + // Serial.print("Bulk Start from USB Host @ 0x"); + // Serial.println((uint32_t)pUsb, HEX); + // Serial.print("Bulk Start USB Host Address Pool @ 0x"); + // Serial.println((uint32_t)pUsb->GetAddressPool(), HEX); + + BS_HOST_DEBUG("BS Start, speed: %i\r\n", pUsb->GetAddressPool()->GetUsbDevicePtr(bAddress)->speed); + BS_HOST_DEBUG("BS Start\r\n"); + rcode = pUsb->setEpInfoEntry(bAddress, bIface, 3, epInfo); + // Serial.println(rcode,HEX); + if(rcode) goto FailOnInit; + + // Do a 1 second delay before LUN query + if(!UHS_SLEEP_MS(1000)) goto FailUnPlug; + + rcode = GetMaxLUN(&bMaxLUN); + BS_HOST_DEBUG("GetMaxLUN 0x%2.2x\r\n", rcode); + if(rcode) { + goto FailGetMaxLUN; + } + if(bMaxLUN >= MASS_MAX_SUPPORTED_LUN) bMaxLUN = MASS_MAX_SUPPORTED_LUN - 1; + BS_HOST_DEBUG("MaxLUN %u\r\n", bMaxLUN); + //ErrorMessage (PSTR("MaxLUN"), bMaxLUN); + if(!UHS_SLEEP_MS(150)) goto FailUnPlug; // Delay a bit for slow firmware. (again) + + for(uint8_t lun = 0; lun <= bMaxLUN; lun++) { + if(!UHS_SLEEP_MS(3)) goto FailUnPlug; + SCSI_Inquiry_Response response; + rcode = Inquiry(lun, sizeof (SCSI_Inquiry_Response), (uint8_t*) & response); + BS_HOST_DEBUG("Inquiry 0x%2.2x 0x%2.2x\r\n", sizeof (SCSI_Inquiry_Response), rcode); + if(rcode) { + goto FailInquiry; +#if 0 + } else { + BS_HOST_DEBUG("LUN %i `", lun); + uint8_t *buf = response.VendorID; + for(int i = 0; i < 28; i++) BS_HOST_DEBUG("%c", buf[i]); + BS_HOST_DEBUG("'\r\nQualifier %1.1X ", response.PeripheralQualifier); + BS_HOST_DEBUG("Device type %2.2X ", response.DeviceType); + BS_HOST_DEBUG("RMB %1.1X ", response.Removable); + BS_HOST_DEBUG("SSCS %1.1X ", response.SCCS); + uint8_t sv = response.Version; + BS_HOST_DEBUG("SCSI version %2.2X\r\nDevice conforms to ", sv); + switch(sv) { + case 0: + BS_HOST_DEBUG("No specific"); + break; + case 1: + BS_HOST_DEBUG("ANSI X3.131-1986 (ANSI 1)"); + break; + case 2: + BS_HOST_DEBUG("ANSI X3.131-1994 (ANSI 2)"); + break; + case 3: + BS_HOST_DEBUG("ANSI INCITS 301-1997 (SPC)"); + break; + case 4: + BS_HOST_DEBUG("ANSI INCITS 351-2001 (SPC-2)"); + break; + case 5: + BS_HOST_DEBUG("ANSI INCITS 408-2005 (SPC-4)"); + break; + case 6: + BS_HOST_DEBUG("T10/1731-D (SPC-4)"); + break; + default: + BS_HOST_DEBUG("unknown"); + } + BS_HOST_DEBUG(" standards.\r\n"); +#endif + } + } + + for(uint8_t lun = 0; lun <= bMaxLUN; lun++) { + if(!UHS_SLEEP_MS(3)) goto FailUnPlug; + #ifndef USB_NO_TEST_UNIT_READY + uint8_t tries = 0xF0; + while((rcode = TestUnitReady(lun))) { + BS_HOST_DEBUG("\r\nTry %2.2x TestUnitReady %2.2x\r\n", tries - 0xF0, rcode); + if(rcode == 0x08) break; // break on no media, this is OK to do. + if(rcode == UHS_BULK_ERR_DEVICE_DISCONNECTED) goto FailUnPlug; + if(rcode == UHS_BULK_ERR_INVALID_CSW) goto Fail; + if(rcode != UHS_BULK_ERR_MEDIA_CHANGED) goto Fail; + if(!UHS_SLEEP_MS(2 * (tries + 1))) goto FailUnPlug; + tries++; + if(!tries) break; + } + #else + // Don't wait for the LUN to become ready, as this will + // trigger Marlin's watchdog timer + rcode = -1; + #endif + if(!UHS_SLEEP_MS(3)) goto FailUnPlug; + LockMedia(lun, 1); + if(rcode == 0x08) { + if(!UHS_SLEEP_MS(3)) goto FailUnPlug; + if(MediaCTL(lun, 1) == UHS_BULK_ERR_DEVICE_DISCONNECTED) goto FailUnPlug; // I actually have a USB stick that needs this! + } + BS_HOST_DEBUG("\r\nTry %2.2x TestUnitReady %2.2x\r\n", tries - 0xF0, rcode); + if(!rcode) { + if(!UHS_SLEEP_MS(3)) goto FailUnPlug; + BS_HOST_DEBUG("CheckLUN...\r\n"); + BS_HOST_DEBUG("%lu\r\n", millis()/1000); + // Stalls on ***some*** devices, ***WHY***?! Device SAID it is READY!! + LUNOk[lun] = CheckLUN(lun); + BS_HOST_DEBUG("%lu\r\n", millis()/1000); + if(!LUNOk[lun]) LUNOk[lun] = CheckLUN(lun); + if(!UHS_SLEEP_MS(1)) goto FailUnPlug; + BS_HOST_DEBUG("Checked LUN...\r\n"); + } else { + LUNOk[lun] = false; + } + } + + rcode = OnStart(); + + if(rcode) goto FailOnInit; + +#ifdef DEBUG_USB_HOST + USBTRACE("BS configured\r\n\r\n"); +#endif + qNextPollTime = millis() + 100; + bPollEnable = true; + + return 0; +FailUnPlug: + rcode = UHS_BULK_ERR_DEVICE_DISCONNECTED; + goto Fail; + +FailOnInit: +#ifdef DEBUG_USB_HOST + USBTRACE("OnStart:"); + goto Fail; +#endif + +FailGetMaxLUN: +#ifdef DEBUG_USB_HOST + USBTRACE("GetMaxLUN:"); + goto Fail; +#endif + +FailInquiry: +#ifdef DEBUG_USB_HOST + USBTRACE("Inquiry:"); +#endif + +Fail: +#ifdef DEBUG_USB_HOST + NotifyFail(rcode); +#endif + Release(); + + return rcode; +} + +// Base class definition of Release() used. See UHS_USBInterface class definition for details + +/** + * For driver use only. + * + * @return + */ +//void UHS_NI UHS_Bulk_Storage::Release() { +// pUsb->DisablePoll(); +// OnRelease(); +// DriverDefaults(); +// pUsb->EnablePoll(); +// return; +//} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @return true if LUN is ready for use. + */ +bool UHS_NI UHS_Bulk_Storage::CheckLUN(uint8_t lun) { + uint8_t rcode; + SCSI_Capacity capacity; + for(uint8_t i = 0; i < 8; i++) capacity.data[i] = 0; + + rcode = ReadCapacity10(lun, (uint8_t*)capacity.data); + if(rcode) { + BS_HOST_DEBUG(">>>>>>>>>>>>>>>>ReadCapacity returned %i\r\n", rcode); + return false; + } +#ifdef DEBUG_USB_HOST + ErrorMessage (PSTR(">>>>>>>>>>>>>>>>CAPACITY OK ON LUN"), lun); + for(uint8_t i = 0; i < 8 /*sizeof (Capacity)*/; i++) + D_PrintHex (capacity.data[i], 0x80); + Notify(PSTR("\r\n\r\n"), 0x80); +#endif + // Only 512/1024/2048/4096 are valid values! + uint32_t c = UHS_BYTES_TO_UINT32(capacity.data[4], capacity.data[5], capacity.data[6], capacity.data[7]); + if(c != 0x0200LU && c != 0x0400LU && c != 0x0800LU && c != 0x1000LU) { + return false; + } + // Store capacity information. + CurrentSectorSize[lun] = (uint16_t)(c); // & 0xFFFF); + + CurrentCapacity[lun] = UHS_BYTES_TO_UINT32(capacity.data[0], capacity.data[1], capacity.data[2], capacity.data[3]) + 1; + if(CurrentCapacity[lun] == /*0xffffffffLU */ 0x01LU || CurrentCapacity[lun] == 0x00LU) { + // Buggy firmware will report 0xFFFFFFFF or 0 for no media +#ifdef DEBUG_USB_HOST + if(CurrentCapacity[lun]) + ErrorMessage (PSTR(">>>>>>>>>>>>>>>>BUGGY FIRMWARE. CAPACITY FAIL ON LUN"), lun); +#endif + return false; + } + if(!UHS_SLEEP_MS(20)) return false; + #ifndef SKIP_PAGE3F + Page3F(lun); + #endif + if(!TestUnitReady(lun)) return true; + + return false; +} + +/** + * For driver use only. + * + * Scan for media change on all LUNs + */ +void UHS_NI UHS_Bulk_Storage::CheckMedia() { + if(!bAddress) return; + for(uint8_t lun = 0; lun <= bMaxLUN; lun++) { + if(TestUnitReady(lun)) { + LUNOk[lun] = false; + continue; + } + if(!LUNOk[lun]) + LUNOk[lun] = CheckLUN(lun); + } +#if 0 + BS_HOST_DEBUG("}}}}}}}}}}}}}}}}STATUS "); + for(uint8_t lun = 0; lun <= bMaxLUN; lun++) { + if(LUNOk[lun]) + BS_HOST_DEBUG("#"); + + else BS_HOST_DEBUG("."); + } + BS_HOST_DEBUG("\r\n"); +#endif + OnPoll(); + qNextPollTime = millis() + 100; +} + +/** + * For driver use only. + */ +void UHS_NI UHS_Bulk_Storage::Poll() { + if((long)(millis() - qNextPollTime) >= 0L) { + + CheckMedia(); + } + + return; +} + +//////////////////////////////////////////////////////////////////////////////// + + +// SCSI code + + +//////////////////////////////////////////////////////////////////////////////// + +/** + * For driver use only. + * + * @param plun + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::GetMaxLUN(uint8_t *plun) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + uint8_t ret = pUsb->ctrlReq(bAddress, mkSETUP_PKT16(UHS_BULK_bmREQ_IN, UHS_BULK_REQ_GET_MAX_LUN, 0x0000U, bIface, 1), 1, plun); + + if(ret == UHS_HOST_ERROR_STALL) { + + *plun = 0; + Notify(PSTR("\r\nGetMaxLUN Stalled\r\n"), 0x80); + } + return 0; +} + +/** + * For driver use only. Used during Driver Start + * + * @param lun Logical Unit Number + * @param bsize + * @param buf + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::Inquiry(uint8_t lun, uint16_t bsize, uint8_t *buf) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + Notify(PSTR("\r\nInquiry\r\n"), 0x80); + Notify(PSTR("---------\r\n"), 0x80); + + SCSI_CDB6_t cdb = SCSI_CDB6_t(SCSI_CMD_INQUIRY, lun, 0LU, (uint8_t)bsize, 0); + uint8_t rc = SCSITransaction6(&cdb, bsize, buf, (uint8_t)UHS_BULK_CMD_DIR_IN); + + return rc; +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::TestUnitReady(uint8_t lun) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + //SetCurLUN(lun); + if(!bAddress) + return UHS_BULK_ERR_UNIT_NOT_READY; + + Notify(PSTR("\r\nTestUnitReady\r\n"), 0x80); + Notify(PSTR("-----------------\r\n"), 0x80); + + SCSI_CDB6_t cdb = SCSI_CDB6_t(SCSI_CMD_TEST_UNIT_READY, lun, (uint8_t)0, 0); + + return SCSITransaction6(&cdb, 0, NULL, (uint8_t)UHS_BULK_CMD_DIR_IN); + +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @param pc + * @param page + * @param subpage + * @param len + * @param pbuf + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::ModeSense6(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t * pbuf) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + Notify(PSTR("\r\rModeSense\r\n"), 0x80); + Notify(PSTR("------------\r\n"), 0x80); + + SCSI_CDB6_t cdb = SCSI_CDB6_t(SCSI_CMD_MODE_SENSE_6, lun, (uint32_t)((((pc << 6) | page) << 8) | subpage), len, 0); + + return SCSITransaction6(&cdb, len, pbuf, (uint8_t)UHS_BULK_CMD_DIR_IN); +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @param bsize + * @param buf + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::ReadCapacity10(uint8_t lun, uint8_t *buf) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + Notify(PSTR("\r\nReadCapacity\r\n"), 0x80); + Notify(PSTR("---------------\r\n"), 0x80); + + SCSI_CDB10_t cdb = SCSI_CDB10_t(SCSI_CMD_READ_CAPACITY_10, lun); + + return SCSITransaction10(&cdb, 8, buf, (uint8_t)UHS_BULK_CMD_DIR_IN); +} + +/** + * For driver use only. + * + * Page 3F contains write protect status. + * + * @param lun Logical Unit Number to test. + * @return Write protect switch status. + */ +uint8_t UHS_NI UHS_Bulk_Storage::Page3F(uint8_t lun) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + uint8_t buf[192]; + for(int i = 0; i < 192; i++) { + buf[i] = 0x00; + } + WriteOk[lun] = true; + uint8_t rc = ModeSense6(lun, 0, 0x3F, 0, 192, buf); + if(!rc) { + WriteOk[lun] = ((buf[2] & 0x80) == 0); +#ifdef DEBUG_USB_HOST + Notify(PSTR("Mode Sense: "), 0x80); + for(int i = 0; i < 4; i++) { + + D_PrintHex (buf[i], 0x80); + Notify(PSTR(" "), 0x80); + } + Notify(PSTR("\r\n"), 0x80); +#endif + } + return rc; +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @param size + * @param buf + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::RequestSense(uint8_t lun, uint16_t size, uint8_t *buf) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + pUsb->DisablePoll(); + Notify(PSTR("\r\nRequestSense\r\n"), 0x80); + Notify(PSTR("----------------\r\n"), 0x80); + + SCSI_CDB6_t cdb = SCSI_CDB6_t(SCSI_CMD_REQUEST_SENSE, lun, 0LU, (uint8_t)size, 0); + UHS_BULK_CommandBlockWrapper cbw = UHS_BULK_CommandBlockWrapper(++dCBWTag, (uint32_t)size, &cdb, (uint8_t)UHS_BULK_CMD_DIR_IN); + uint8_t v = Transaction(&cbw, size, buf); + pUsb->EnablePoll(); + + return v; +} + + +//////////////////////////////////////////////////////////////////////////////// + + +// USB code + + +//////////////////////////////////////////////////////////////////////////////// + +/** + * For driver use only. + * + * @param index + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::ClearEpHalt(uint8_t index) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + uint8_t ret = 0; + if(index != 0) { + uint8_t ep = (index == epDataInIndex) ? (0x80 | epInfo[index].epAddr) : epInfo[index].epAddr; + do { + ret = pUsb->EPClearHalt(bAddress, ep); + if(!UHS_SLEEP_MS(6)) break; + } while(ret == 0x01); + + if(ret) { + ErrorMessage (PSTR("ClearEpHalt"), ret); + ErrorMessage (PSTR("EP"), ep); + epInfo[index].bmSndToggle = 0; + epInfo[index].bmRcvToggle = 0; + return ret; + } else { + + epInfo[index].bmSndToggle = 0; + epInfo[index].bmRcvToggle = 0; + } + } + return ret; +} + +/** + * For driver use only. + */ +void UHS_NI UHS_Bulk_Storage::Reset() { + if(!bAddress) return; + + while(pUsb->ctrlReq(bAddress, mkSETUP_PKT16(UHS_BULK_bmREQ_OUT, UHS_BULK_REQ_BOMSR, 0x0000U, bIface, 0), 0, NULL) == 0x01) { + if(!UHS_SLEEP_MS(6)) break; + } + + if(!bAddress) return; + + UHS_SLEEP_MS(2500); +} + +/** + * For driver use only. + * + * @return 0 if successful + */ +uint8_t UHS_NI UHS_Bulk_Storage::ResetRecovery() { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + Notify(PSTR("\r\nResetRecovery\r\n"), 0x80); + Notify(PSTR("-----------------\r\n"), 0x80); + qNextPollTime = millis() + 90000; + uint8_t bLastUsbError = UHS_HOST_ERROR_UNPLUGGED; + if(UHS_SLEEP_MS(6)) { + Reset(); + if(UHS_SLEEP_MS(6)) { + bLastUsbError = ClearEpHalt(epDataInIndex); + if(UHS_SLEEP_MS(6)) { + + bLastUsbError = ClearEpHalt(epDataOutIndex); + UHS_SLEEP_MS(6); + } + } + } + return bLastUsbError; +} + +/** + * For driver use only. + * + * Clear all EP data and clear all LUN status + */ +void UHS_NI UHS_Bulk_Storage::DriverDefaults() { + + pUsb->DeviceDefaults(MASS_MAX_ENDPOINTS, this); + + for(uint8_t i = 0; i < MASS_MAX_SUPPORTED_LUN; i++) { + + LUNOk[i] = false; + WriteOk[i] = false; + CurrentCapacity[i] = 0lu; + CurrentSectorSize[i] = 0; + } + + dCBWTag = 0; + bMaxLUN = 0; + bTheLUN = 0; +} + +/** + * For driver use only. + * + * @param pcsw + * @param pcbw + * @return + */ +bool UHS_NI UHS_Bulk_Storage::IsValidCSW(UHS_BULK_CommandStatusWrapper *pcsw, UHS_BULK_CommandBlockWrapperBase *pcbw) { + if(!bAddress) return false; + if(pcsw->dCSWSignature != UHS_BULK_CSW_SIGNATURE) { + Notify(PSTR("CSW:Sig error\r\n"), 0x80); + return false; + } + if(pcsw->dCSWTag != pcbw->dCBWTag) { + Notify(PSTR("CSW:Wrong tag\r\n"), 0x80); + ErrorMessage (PSTR("dCSWTag"), pcsw->dCSWTag); + ErrorMessage (PSTR("dCBWTag"), pcbw->dCBWTag); + + return false; + } + return true; +} + +/** + * For driver use only. + * + * @param error + * @param index + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::HandleUsbError(uint8_t error, uint8_t index) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + + uint8_t count = 3; + while(error && count) { + if(error != UHS_HOST_ERROR_NONE) { + ErrorMessage (PSTR("USB Error"), error); + ErrorMessage (PSTR("Index"), index); + } + switch(error) { + // case UHS_HOST_ERROR_WRONGPID: + case UHS_HOST_ERROR_NONE: + return UHS_BULK_ERR_SUCCESS; + case UHS_HOST_ERROR_BUSY: + // SIE is busy, just hang out and try again. + return UHS_BULK_ERR_UNIT_BUSY; + case UHS_HOST_ERROR_NAK: + return UHS_BULK_ERR_UNIT_BUSY; + case UHS_HOST_ERROR_UNPLUGGED: + case UHS_HOST_ERROR_TIMEOUT: + case UHS_HOST_ERROR_JERR: + return UHS_BULK_ERR_DEVICE_DISCONNECTED; + case UHS_HOST_ERROR_STALL: + if(index == 0) return UHS_BULK_ERR_STALL; + ClearEpHalt(index); + if(index != epDataInIndex) return UHS_BULK_ERR_WRITE_STALL; + return UHS_BULK_ERR_STALL; + + + case UHS_HOST_ERROR_TOGERR: + // Handle a very super rare corner case, where toggles become de-synched. + // I have only ran into one device that has this firmware bug, and this is + // the only clean way to get back into sync with the buggy device firmware. + // --AJK + if(bAddress && bConfNum) { + error = pUsb->setConf(bAddress, bConfNum); + + if(error) break; + } + return UHS_BULK_ERR_SUCCESS; + + default: + ErrorMessage (PSTR("\r\nUSB"), error); + + return UHS_BULK_ERR_GENERAL_USB_ERROR; + } + count--; + } // while + + return ((error && !count) ? UHS_BULK_ERR_GENERAL_USB_ERROR : UHS_BULK_ERR_SUCCESS); +} + +/** + * For driver use only. + * + * @param pcbw + * @param buf_size + * @param buf + * @param flags + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::Transaction(UHS_BULK_CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + + uint16_t bytes = buf_size; + bool write = (pcbw->bmCBWFlags & UHS_BULK_CMD_DIR_IN) != UHS_BULK_CMD_DIR_IN; + uint8_t ret = 0; + uint8_t usberr; + UHS_BULK_CommandStatusWrapper csw; // up here, we allocate ahead to save cpu cycles. + SetCurLUN(pcbw->bmCBWLUN); + ErrorMessage (PSTR("CBW.dCBWTag"), pcbw->dCBWTag); + + while((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (UHS_BULK_CommandBlockWrapper), (uint8_t*)pcbw)) == UHS_HOST_ERROR_BUSY) { + if(!UHS_SLEEP_MS(1)) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + } + ret = HandleUsbError(usberr, epDataOutIndex); + if(ret) { + ErrorMessage (PSTR("============================ CBW"), ret); + } else { + if(bytes) { + if(!write) { + while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*)buf)) == UHS_HOST_ERROR_BUSY) { + if(!UHS_SLEEP_MS(1)) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + } + ret = HandleUsbError(usberr, epDataInIndex); + } else { + while((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, bytes, (uint8_t*)buf)) == UHS_HOST_ERROR_BUSY) { + if(!UHS_SLEEP_MS(1)) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + } + ret = HandleUsbError(usberr, epDataOutIndex); + } + if(ret) { + ErrorMessage (PSTR("============================ DAT"), ret); + } + } + } + + { + bytes = sizeof (UHS_BULK_CommandStatusWrapper); + int tries = 2; + while(tries--) { + while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*) & csw)) == UHS_HOST_ERROR_BUSY) { + if(!UHS_SLEEP_MS(1)) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + } + if(!usberr) break; + if(tries) { + if(usberr == UHS_HOST_ERROR_STALL) { + ResetRecovery(); + } else { + ClearEpHalt(epDataInIndex); + } + } + } + if(!ret) { + Notify(PSTR("CBW:\t\tOK\r\n"), 0x80); + Notify(PSTR("Data Stage:\tOK\r\n"), 0x80); + } else { + // Throw away csw, IT IS NOT OF ANY USE. + ResetRecovery(); + return ret; + } + ret = HandleUsbError(usberr, epDataInIndex); + if(ret) { + ErrorMessage (PSTR("============================ CSW"), ret); + } + if(usberr == UHS_HOST_ERROR_NONE) { + if(IsValidCSW(&csw, pcbw)) { + //ErrorMessage (PSTR("CSW.dCBWTag"), csw.dCSWTag); + //ErrorMessage (PSTR("bCSWStatus"), csw.bCSWStatus); + //ErrorMessage (PSTR("dCSWDataResidue"), csw.dCSWDataResidue); + Notify(PSTR("CSW:\t\tOK\r\n\r\n"), 0x80); + return csw.bCSWStatus; + } else { + // NOTE! Sometimes this is caused by the reported residue being wrong. + // Get a different device. It isn't compliant, and should have never passed Q&A. + // I own one... 05e3:0701 Genesys Logic, Inc. USB 2.0 IDE Adapter. + // Other devices that exhibit this behavior exist in the wild too. + // Be sure to check quirks in the Linux source code before reporting a bug. --xxxajk + Notify(PSTR("Invalid CSW\r\n"), 0x80); + Reset(); + ResetRecovery(); + + return UHS_BULK_ERR_INVALID_CSW; + } + } + } + return ret; +} + +/** + * For driver use only. + * + * @param lun Logical Unit Number + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::SetCurLUN(uint8_t lun) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + if(lun > bMaxLUN) + return UHS_BULK_ERR_INVALID_LUN; + bTheLUN = lun; + + return UHS_BULK_ERR_SUCCESS; +}; + +/** + * For driver use only. + * + * @param status + * @return + */ +uint8_t UHS_NI UHS_Bulk_Storage::HandleSCSIError(uint8_t status) { + if(!bAddress) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + uint8_t ret = 0; + switch(status) { + case 0: return UHS_BULK_ERR_SUCCESS; + + case 2: + ErrorMessage (PSTR("Phase Error"), status); + ErrorMessage (PSTR("LUN"), bTheLUN); + ResetRecovery(); + return UHS_BULK_ERR_GENERAL_SCSI_ERROR; + + case 1: + ErrorMessage (PSTR("SCSI Error"), status); + ErrorMessage (PSTR("LUN"), bTheLUN); + SCSI_Request_Sense_Response rsp; + + ret = RequestSense(bTheLUN, sizeof (SCSI_Request_Sense_Response), (uint8_t*) & rsp); + + if(ret) { + if(ret == UHS_BULK_ERR_DEVICE_DISCONNECTED) return UHS_BULK_ERR_DEVICE_DISCONNECTED; + return UHS_BULK_ERR_GENERAL_SCSI_ERROR; + } +#if ENABLE_UHS_DEBUGGING + ErrorMessage (PSTR("Response Code"), rsp.bResponseCode); + if(rsp.bResponseCode & 0x80) { + Notify(PSTR("Information field: "), 0x80); + for(int i = 0; i < 4; i++) { + D_PrintHex (rsp.CmdSpecificInformation[i], 0x80); + Notify(PSTR(" "), 0x80); + } + Notify(PSTR("\r\n"), 0x80); + } + ErrorMessage (PSTR("Sense Key"), rsp.bmSenseKey); + ErrorMessage (PSTR("Add Sense Code"), rsp.bAdditionalSenseCode); + ErrorMessage (PSTR("Add Sense Qual"), rsp.bAdditionalSenseQualifier); +#endif + // warning, this is not testing ASQ, only SK and ASC. + switch(rsp.bmSenseKey) { + case SCSI_S_UNIT_ATTENTION: + switch(rsp.bAdditionalSenseCode) { + case SCSI_ASC_MEDIA_CHANGED: + return UHS_BULK_ERR_MEDIA_CHANGED; + default: + return UHS_BULK_ERR_UNIT_NOT_READY; + } + case SCSI_S_NOT_READY: + switch(rsp.bAdditionalSenseCode) { + case SCSI_ASC_MEDIUM_NOT_PRESENT: + return UHS_BULK_ERR_NO_MEDIA; + default: + return UHS_BULK_ERR_UNIT_NOT_READY; + } + case SCSI_S_ILLEGAL_REQUEST: + switch(rsp.bAdditionalSenseCode) { + case SCSI_ASC_LBA_OUT_OF_RANGE: + return UHS_BULK_ERR_BAD_LBA; + default: + return UHS_BULK_ERR_CMD_NOT_SUPPORTED; + } + default: + return UHS_BULK_ERR_GENERAL_SCSI_ERROR; + } + + // case 4: return MASS_ERR_UNIT_BUSY; // Busy means retry later. + // case 0x05/0x14: we stalled out + // case 0x15/0x16: we naked out. + default: + ErrorMessage (PSTR("Gen SCSI Err"), status); + ErrorMessage (PSTR("LUN"), bTheLUN); + + return status; + } // switch +} + + +//////////////////////////////////////////////////////////////////////////////// + + +// Debugging code + + +//////////////////////////////////////////////////////////////////////////////// + +/** + * @param ep_ptr + */ +void UHS_NI UHS_Bulk_Storage::PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR * ep_ptr) { + Notify(PSTR("Endpoint descriptor:"), 0x80); + Notify(PSTR("\r\nLength:\t\t"), 0x80); + D_PrintHex (ep_ptr->bLength, 0x80); + Notify(PSTR("\r\nType:\t\t"), 0x80); + D_PrintHex (ep_ptr->bDescriptorType, 0x80); + Notify(PSTR("\r\nAddress:\t"), 0x80); + D_PrintHex (ep_ptr->bEndpointAddress, 0x80); + Notify(PSTR("\r\nAttributes:\t"), 0x80); + D_PrintHex (ep_ptr->bmAttributes, 0x80); + Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); + D_PrintHex (ep_ptr->wMaxPacketSize, 0x80); + Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); + D_PrintHex (ep_ptr->bInterval, 0x80); + Notify(PSTR("\r\n"), 0x80); +} + +#else +#error "Never include UHS_BULK_STORAGE_INLINE.h, include UHS_host.h instead" +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_SCSI.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_SCSI.h new file mode 100644 index 0000000..bead520 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_SCSI.h @@ -0,0 +1,327 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#ifndef UHS_SCSI_H +#define UHS_SCSI_H + +/* + * Reference documents from T10 (https://www.t10.org) + * SCSI Primary Commands - 3 (SPC-3) + * SCSI Block Commands - 2 (SBC-2) + * Multi-Media Commands - 5 (MMC-5) + */ + +/* Group 1 commands (CDB's here are should all be 6-bytes) */ +#define SCSI_CMD_TEST_UNIT_READY 0x00U +#define SCSI_CMD_REQUEST_SENSE 0x03U +#define SCSI_CMD_FORMAT_UNIT 0x04U +#define SCSI_CMD_READ_6 0x08U +#define SCSI_CMD_WRITE_6 0x0AU +#define SCSI_CMD_INQUIRY 0x12U +#define SCSI_CMD_MODE_SELECT_6 0x15U +#define SCSI_CMD_MODE_SENSE_6 0x1AU +#define SCSI_CMD_START_STOP_UNIT 0x1BU +#define SCSI_CMD_PREVENT_REMOVAL 0x1EU +/* Group 2 Commands (CDB's here are 10-bytes) */ +#define SCSI_CMD_READ_FORMAT_CAPACITIES 0x23U +#define SCSI_CMD_READ_CAPACITY_10 0x25U +#define SCSI_CMD_READ_10 0x28U +#define SCSI_CMD_WRITE_10 0x2AU +#define SCSI_CMD_SEEK_10 0x2BU +#define SCSI_CMD_ERASE_10 0x2CU +#define SCSI_CMD_WRITE_AND_VERIFY_10 0x2EU +#define SCSI_CMD_VERIFY_10 0x2FU +#define SCSI_CMD_SYNCHRONIZE_CACHE 0x35U +#define SCSI_CMD_WRITE_BUFFER 0x3BU +#define SCSI_CMD_READ_BUFFER 0x3CU +#define SCSI_CMD_READ_SUBCHANNEL 0x42U +#define SCSI_CMD_READ_TOC 0x43U +#define SCSI_CMD_READ_HEADER 0x44U +#define SCSI_CMD_PLAY_AUDIO_10 0x45U +#define SCSI_CMD_GET_CONFIGURATION 0x46U +#define SCSI_CMD_PLAY_AUDIO_MSF 0x47U +#define SCSI_CMD_PLAY_AUDIO_TI 0x48U +#define SCSI_CMD_PLAY_TRACK_REL_10 0x49U +#define SCSI_CMD_GET_EVENT_STATUS 0x4AU +#define SCSI_CMD_PAUSE_RESUME 0x4BU +#define SCSI_CMD_READ_DISC_INFORMATION 0x51U +#define SCSI_CMD_READ_TRACK_INFORMATION 0x52U +#define SCSI_CMD_RESERVE_TRACK 0x53U +#define SCSI_CMD_SEND_OPC_INFORMATION 0x54U +#define SCSI_CMD_MODE_SELECT_10 0x55U +#define SCSI_CMD_REPAIR_TRACK 0x58U +#define SCSI_CMD_MODE_SENSE_10 0x5AU +#define SCSI_CMD_CLOSE_TRACK_SESSION 0x5BU +#define SCSI_CMD_READ_BUFFER_CAPACITY 0x5CU +#define SCSI_CMD_SEND_CUE_SHEET 0x5DU +/* Group 5 Commands (CDB's here are 12-bytes) */ +#define SCSI_CMD_REPORT_LUNS 0xA0U +#define SCSI_CMD_BLANK 0xA1U +#define SCSI_CMD_SECURITY_PROTOCOL_IN 0xA2U +#define SCSI_CMD_SEND_KEY 0xA3U +#define SCSI_CMD_REPORT_KEY 0xA4U +#define SCSI_CMD_PLAY_AUDIO_12 0xA5U +#define SCSI_CMD_LOAD_UNLOAD 0xA6U +#define SCSI_CMD_SET_READ_AHEAD 0xA7U +#define SCSI_CMD_READ_12 0xA8U +#define SCSI_CMD_PLAY_TRACK_REL_12 0xA9U +#define SCSI_CMD_WRITE_12 0xAAU +#define SCSI_CMD_READ_MEDIA_SERIAL_12 0xABU +#define SCSI_CMD_GET_PERFORMANCE 0xACU +#define SCSI_CMD_READ_DVD_STRUCTURE 0xADU +#define SCSI_CMD_SECURITY_PROTOCOL_OUT 0xB5U +#define SCSI_CMD_SET_STREAMING 0xB6U +#define SCSI_CMD_READ_MSF 0xB9U +#define SCSI_CMD_SET_SPEED 0xBBU +#define SCSI_CMD_MECHANISM_STATUS 0xBDU +#define SCSI_CMD_READ_CD 0xBEU +#define SCSI_CMD_SEND_DISC_STRUCTURE 0xBFU +/* Vendor-unique Commands, included for completeness */ +#define SCSI_CMD_CD_PLAYBACK_STATUS 0xC4U /* SONY unique */ +#define SCSI_CMD_PLAYBACK_CONTROL 0xC9U /* SONY unique */ +#define SCSI_CMD_READ_CDDA 0xD8U /* Vendor unique */ +#define SCSI_CMD_READ_CDXA 0xDBU /* Vendor unique */ +#define SCSI_CMD_READ_ALL_SUBCODES 0xDFU /* Vendor unique */ + +/* SCSI error codes */ +#define SCSI_S_NOT_READY 0x02U +#define SCSI_S_MEDIUM_ERROR 0x03U +#define SCSI_S_ILLEGAL_REQUEST 0x05U +#define SCSI_S_UNIT_ATTENTION 0x06U +#define SCSI_ASC_LBA_OUT_OF_RANGE 0x21U +#define SCSI_ASC_MEDIA_CHANGED 0x28U +#define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3AU + +struct SCSI_Capacity { + uint8_t data[8]; + //uint32_t dwBlockAddress; + //uint32_t dwBlockLength; +} __attribute__((packed)); + +struct SCSI_CDB_BASE { + uint8_t Opcode; + + unsigned unused : 5; + unsigned LUN : 3; + + uint8_t info[12]; +} __attribute__((packed)); + +typedef SCSI_CDB_BASE SCSI_CDB_BASE_t; + +struct SCSI_CDB6 { + uint8_t Opcode; + + unsigned LBAMSB : 5; + unsigned LUN : 3; + + uint8_t LBAHB; + uint8_t LBALB; + uint8_t AllocationLength; + uint8_t Control; + +public: + + SCSI_CDB6(uint8_t _Opcode, uint8_t _LUN, uint32_t LBA, uint8_t _AllocationLength, uint8_t _Control) : + Opcode(_Opcode), LBAMSB(UHS_UINT8_BYTE2(LBA) & 0x1F), LUN(_LUN), LBAHB(UHS_UINT8_BYTE1(LBA)), LBALB(UHS_UINT8_BYTE0(LBA)), + AllocationLength(_AllocationLength), Control(_Control) { + } + + SCSI_CDB6(uint8_t _Opcode, uint8_t _LUN, uint8_t _AllocationLength, uint8_t _Control) : + Opcode(_Opcode), LBAMSB(0), LUN(_LUN), LBAHB(0), LBALB(0), + AllocationLength(_AllocationLength), Control(_Control) { + } +} __attribute__((packed)); + +typedef SCSI_CDB6 SCSI_CDB6_t; + +struct SCSI_CDB10 { + uint8_t Opcode; + + unsigned Service_Action : 5; + unsigned LUN : 3; + + uint8_t LBA_L_M_MB; + uint8_t LBA_L_M_LB; + uint8_t LBA_L_L_MB; + uint8_t LBA_L_L_LB; + + uint8_t Misc2; + + uint8_t ALC_MB; + uint8_t ALC_LB; + + uint8_t Control; +public: + + SCSI_CDB10(uint8_t _Opcode, uint8_t _LUN) : + Opcode(_Opcode), Service_Action(0), LUN(_LUN), + LBA_L_M_MB(0), LBA_L_M_LB(0), LBA_L_L_MB(0), LBA_L_L_LB(0), + Misc2(0), ALC_MB(0), ALC_LB(0), Control(0) { + } + + SCSI_CDB10(uint8_t _Opcode, uint8_t _LUN, uint16_t xflen, uint32_t _LBA) : + Opcode(_Opcode), Service_Action(0), LUN(_LUN), + LBA_L_M_MB(UHS_UINT8_BYTE3(_LBA)), LBA_L_M_LB(UHS_UINT8_BYTE2(_LBA)), LBA_L_L_MB(UHS_UINT8_BYTE1(_LBA)), LBA_L_L_LB(UHS_UINT8_BYTE0(_LBA)), + Misc2(0), ALC_MB(UHS_UINT8_BYTE1(xflen)), ALC_LB(UHS_UINT8_BYTE0(xflen)), Control(0) { + } +} __attribute__((packed)); + +typedef SCSI_CDB10 SCSI_CDB10_t; + +struct SCSI_CDB12 { + uint8_t Opcode; + + unsigned Service_Action : 5; + unsigned Misc : 3; + + uint8_t LBA_L_M_LB; + uint8_t LBA_L_L_MB; + uint8_t LBA_L_L_LB; + + uint8_t ALC_M_LB; + uint8_t ALC_L_MB; + uint8_t ALC_L_LB; + uint8_t Control; +} __attribute__((packed)); + +typedef SCSI_CDB12 SCSI_CDB12_t; + +struct SCSI_CDB_LBA32_16 { + uint8_t Opcode; + + unsigned Service_Action : 5; + unsigned Misc : 3; + + uint8_t LBA_L_M_MB; + uint8_t LBA_L_M_LB; + uint8_t LBA_L_L_MB; + uint8_t LBA_L_L_LB; + + uint8_t A_M_M_MB; + uint8_t A_M_M_LB; + uint8_t A_M_L_MB; + uint8_t A_M_L_LB; + + uint8_t ALC_M_MB; + uint8_t ALC_M_LB; + uint8_t ALC_L_MB; + uint8_t ALC_L_LB; + + uint8_t Misc2; + uint8_t Control; +} __attribute__((packed)); + +struct SCSI_CDB_LBA64_16 { + uint8_t Opcode; + uint8_t Misc; + + uint8_t LBA_M_M_MB; + uint8_t LBA_M_M_LB; + uint8_t LBA_M_L_MB; + uint8_t LBA_M_L_LB; + + uint8_t LBA_L_M_MB; + uint8_t LBA_L_M_LB; + uint8_t LBA_L_L_MB; + uint8_t LBA_L_L_LB; + + uint8_t ALC_M_MB; + uint8_t ALC_M_LB; + uint8_t ALC_L_MB; + uint8_t ALC_L_LB; + + uint8_t Misc2; + uint8_t Control; +} __attribute__((packed)); + +struct SCSI_Inquiry_Response { + uint8_t DeviceType : 5; + uint8_t PeripheralQualifier : 3; + + unsigned Reserved : 7; + unsigned Removable : 1; + + uint8_t Version; + + unsigned ResponseDataFormat : 4; + unsigned HISUP : 1; + unsigned NormACA : 1; + unsigned TrmTsk : 1; + unsigned AERC : 1; + + uint8_t AdditionalLength; + + unsigned PROTECT : 1; + unsigned Res : 2; + unsigned ThreePC : 1; + unsigned TPGS : 2; + unsigned ACC : 1; + unsigned SCCS : 1; + + unsigned ADDR16 : 1; + unsigned R1 : 1; + unsigned R2 : 1; + unsigned MCHNGR : 1; + unsigned MULTIP : 1; + unsigned VS : 1; + unsigned ENCSERV : 1; + unsigned BQUE : 1; + + unsigned SoftReset : 1; + unsigned CmdQue : 1; + unsigned Reserved4 : 1; + unsigned Linked : 1; + unsigned Sync : 1; + unsigned WideBus16Bit : 1; + unsigned WideBus32Bit : 1; + unsigned RelAddr : 1; + + uint8_t VendorID[8]; + uint8_t ProductID[16]; + uint8_t RevisionID[4]; +} __attribute__((packed)); + +struct SCSI_Request_Sense_Response { + uint8_t bResponseCode; + uint8_t bSegmentNumber; + + uint8_t bmSenseKey : 4; + uint8_t bmReserved : 1; + uint8_t bmILI : 1; + uint8_t bmEOM : 1; + uint8_t bmFileMark : 1; + + uint8_t Information[4]; + uint8_t bAdditionalLength; + uint8_t CmdSpecificInformation[4]; + uint8_t bAdditionalSenseCode; + uint8_t bAdditionalSenseQualifier; + uint8_t bFieldReplaceableUnitCode; + uint8_t SenseKeySpecific[3]; +} __attribute__((packed)); + +#endif /* UHS_SCSI_H */ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UNOFFICIAL_IDs.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UNOFFICIAL_IDs.h new file mode 100644 index 0000000..6442bcc --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UNOFFICIAL_IDs.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ +#ifndef _UHS_UNOFFICIAL_IDs_h +#define _UHS_UNOFFICIAL_IDs_h + +// Bogus unofficial and unregistered VIDs from cloners to be listed here. + +#define UHS_VID_UNOFFICIAL_JOYTECH 0x162EU // For unofficial Joytech controllers + +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_USB_IDs.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_USB_IDs.h new file mode 100644 index 0000000..417c9f6 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_USB_IDs.h @@ -0,0 +1,2993 @@ +/* + * USB vendor ids + * This file was generated by running python ./make-USB_IDs.py > UHS_USB_IDs.h + * Don't change it directly. + * + * Copyright 2014, Andrew J. Kroll for Circuits At Home, LTD. All rights reserved. + * + * Copyright 2012, Michal Labedzki for Tieto Corporation + * Other values imported from libghoto2/camlibs/ptp2/library.c, music-players.h + * Copyright (C) 2001-2005 Mariusz Woloszyn + * Copyright (C) 2003-2013 Marcus Meissner + * Copyright (C) 2005 Hubert Figuiere + * Copyright (C) 2009 Axel Waggershauser + * Copyright (C) 2005-2007 Richard A. Low + * Copyright (C) 2005-2012 Linus Walleij + * Copyright (C) 2007 Ted Bullock + * Copyright (C) 2012 Sony Mobile Communications AB + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * 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 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef _UHS_USB_IDs_h_ +#define _UHS_USB_IDs_h_ +#include "UHS_UNOFFICIAL_IDs.h" + +#define UHS_VID_FRYS_ELECTRONICS 0x0001U // Fry's Electronics +#define UHS_VID_INGRAM 0x0002U // Ingram +#define UHS_VID_CLUB_MAC 0x0003U // Club Mac +#define UHS_VID_NEBRASKA_FURNITURE_MART 0x0004U // Nebraska Furniture Mart +#define UHS_VID_UNKNOWN 0x0011U // Unknown +#define UHS_VID_PLANEX 0x0053U // Planex +#define UHS_VID_DRAGONRISE 0x0079U // DragonRise Inc. +#define UHS_VID_TRUST_INTERNATIONAL_BV 0x0105U // Trust International B.V. +#define UHS_VID_IBP 0x0127U // IBP +#define UHS_VID_UNKNOWN_1 0x0145U // Unknown +#define UHS_VID_MLK 0x017cU // MLK +#define UHS_VID_TP_LINK 0x0200U // TP-Link +#define UHS_VID_CHIPSBANK_MICROELECTRONICS 0x0204U // Chipsbank Microelectronics Co., Ltd +#define UHS_VID_HANGZHOU_WORLDE 0x0218U // Hangzhou Worlde +#define UHS_VID_HUMAX 0x02adU // HUMAX Co., Ltd. +#define UHS_VID_MM300_EBOOK_READER 0x0300U // MM300 eBook Reader +#define UHS_VID_OCZ_TECHNOLOGY 0x0324U // OCZ Technology Inc +#define UHS_VID_OCZ_TECHNOLOGY_1 0x0325U // OCZ Technology Inc +#define UHS_VID_LTS 0x0386U // LTS +#define UHS_VID_SHENZHEN_SINOTE_TECH_ELECTRON 0x03d9U // Shenzhen Sinote Tech-Electron Co., Ltd +#define UHS_VID_BERND_WALTER_COMPUTER_TECHNOLOGY 0x03daU // Bernd Walter Computer Technology +#define UHS_VID_ENDPOINTS 0x03e8U // EndPoints, Inc. +#define UHS_VID_THESYS_MICROELECTRONICS 0x03e9U // Thesys Microelectronics +#define UHS_VID_DATA_BROADCASTING 0x03eaU // Data Broadcasting Corp. +#define UHS_VID_ATMEL 0x03ebU // Atmel Corp. +#define UHS_VID_IWATSU_AMERICA 0x03ecU // Iwatsu America, Inc. +#define UHS_VID_MITEL 0x03edU // Mitel Corp. +#define UHS_VID_MITSUMI 0x03eeU // Mitsumi +#define UHS_VID_HEWLETT_PACKARD 0x03f0U // Hewlett-Packard +#define UHS_VID_GENOA_TECHNOLOGY 0x03f1U // Genoa Technology +#define UHS_VID_OAK_TECHNOLOGY 0x03f2U // Oak Technology, Inc. +#define UHS_VID_ADAPTEC 0x03f3U // Adaptec, Inc. +#define UHS_VID_DIEBOLD 0x03f4U // Diebold, Inc. +#define UHS_VID_SIEMENS_ELECTROMECHANICAL 0x03f5U // Siemens Electromechanical +#define UHS_VID_EPSON_IMAGING_TECHNOLOGY_CENTER 0x03f8U // Epson Imaging Technology Center +#define UHS_VID_KEYTRONIC 0x03f9U // KeyTronic Corp. +#define UHS_VID_OPTI 0x03fbU // OPTi, Inc. +#define UHS_VID_ELITEGROUP_COMPUTER_SYSTEMS 0x03fcU // Elitegroup Computer Systems +#define UHS_VID_XILINX 0x03fdU // Xilinx, Inc. +#define UHS_VID_FARALLON_COMUNICATIONS 0x03feU // Farallon Communications +#define UHS_VID_NATIONAL_SEMICONDUCTOR 0x0400U // National Semiconductor Corp. +#define UHS_VID_NATIONAL_REGISTRY 0x0401U // National Registry, Inc. +#define UHS_VID_ALI 0x0402U // ALi Corp. +#define UHS_VID_FUTURE_TECHNOLOGY_DEVICES_INTERNATIONAL 0x0403U // Future Technology Devices International, Ltd +#define UHS_VID_NCR 0x0404U // NCR Corp. +#define UHS_VID_SYNOPSYS 0x0405U // Synopsys, Inc. +#define UHS_VID_FUJITSU_ICL_COMPUTERS 0x0406U // Fujitsu-ICL Computers +#define UHS_VID_FUJITSU_PERSONAL_SYSTEMS 0x0407U // Fujitsu Personal Systems, Inc. +#define UHS_VID_QUANTA_COMPUTER 0x0408U // Quanta Computer, Inc. +#define UHS_VID_NEC 0x0409U // NEC Corp. +#define UHS_VID_KODAK 0x040aU // Kodak Co. +#define UHS_VID_WELTREND_SEMICONDUCTOR 0x040bU // Weltrend Semiconductor +#define UHS_VID_VTECH_COMPUTERS 0x040cU // VTech Computers, Ltd +#define UHS_VID_VIA_TECHNOLOGIES 0x040dU // VIA Technologies, Inc. +#define UHS_VID_MCCI 0x040eU // MCCI +#define UHS_VID_ECHO_SPEECH 0x040fU // Echo Speech Corp. +#define UHS_VID_BUFFALO_INC_FORMERLY_MELCO 0x0411U // BUFFALO INC. (formerly MelCo., Inc.) +#define UHS_VID_AWARD_SOFTWARE_INTERNATIONAL 0x0412U // Award Software International +#define UHS_VID_LEADTEK_RESEARCH 0x0413U // Leadtek Research, Inc. +#define UHS_VID_GIGA_BYTE_TECHNOLOGY 0x0414U // Giga-Byte Technology Co., Ltd +#define UHS_VID_WINBOND_ELECTRONICS 0x0416U // Winbond Electronics Corp. +#define UHS_VID_SYMBIOS_LOGIC 0x0417U // Symbios Logic +#define UHS_VID_AST_RESEARCH 0x0418U // AST Research +#define UHS_VID_SAMSUNG_INFO_SYSTEMS_AMERICA 0x0419U // Samsung Info. Systems America, Inc. +#define UHS_VID_PHOENIX_TECHNOLOGIES 0x041aU // Phoenix Technologies, Ltd +#define UHS_VID_DTV 0x041bU // d'TV +#define UHS_VID_S3 0x041dU // S3, Inc. +#define UHS_VID_CREATIVE_TECHNOLOGY 0x041eU // Creative Technology, Ltd +#define UHS_VID_LCS_TELEGRAPHICS 0x041fU // LCS Telegraphics +#define UHS_VID_CHIPS_AND_TECHNOLOGIES 0x0420U // Chips and Technologies +#define UHS_VID_NOKIA_MOBILE_PHONES 0x0421U // Nokia Mobile Phones +#define UHS_VID_ADI_SYSTEMS 0x0422U // ADI Systems, Inc. +#define UHS_VID_COMPUTER_ACCESS_TECHNOLOGY 0x0423U // Computer Access Technology Corp. +#define UHS_VID_STANDARD_MICROSYSTEMS 0x0424U // Standard Microsystems Corp. +#define UHS_VID_MOTOROLA_SEMICONDUCTORS_HK 0x0425U // Motorola Semiconductors HK, Ltd +#define UHS_VID_INTEGRATED_DEVICE_TECHNOLOGY 0x0426U // Integrated Device Technology, Inc. +#define UHS_VID_MOTOROLA_ELECTRONICS_TAIWAN 0x0427U // Motorola Electronics Taiwan, Ltd +#define UHS_VID_ADVANCED_GRAVIS_COMPUTER_TECH 0x0428U // Advanced Gravis Computer Tech, Ltd +#define UHS_VID_CIRRUS_LOGIC 0x0429U // Cirrus Logic +#define UHS_VID_ERICSSON_AUSTRIAN_AG 0x042aU // Ericsson Austrian, AG +#define UHS_VID_INTEL 0x042bU // Intel Corp. +#define UHS_VID_INNOVATIVE_SEMICONDUCTORS 0x042cU // Innovative Semiconductors, Inc. +#define UHS_VID_MICRONICS 0x042dU // Micronics +#define UHS_VID_ACER 0x042eU // Acer, Inc. +#define UHS_VID_MOLEX 0x042fU // Molex, Inc. +#define UHS_VID_SUN_MICROSYSTEMS 0x0430U // Sun Microsystems, Inc. +#define UHS_VID_ITAC_SYSTEMS 0x0431U // Itac Systems, Inc. +#define UHS_VID_UNISYS 0x0432U // Unisys Corp. +#define UHS_VID_ALPS_ELECTRIC 0x0433U // Alps Electric, Inc. +#define UHS_VID_SAMSUNG_INFO_SYSTEMS_AMERICA_1 0x0434U // Samsung Info. Systems America, Inc. +#define UHS_VID_HYUNDAI_ELECTRONICS_AMERICA 0x0435U // Hyundai Electronics America +#define UHS_VID_TAUGAGREINING_HF 0x0436U // Taugagreining HF +#define UHS_VID_FRAMATOME_CONNECTORS_USA 0x0437U // Framatome Connectors USA +#define UHS_VID_ADVANCED_MICRO_DEVICES 0x0438U // Advanced Micro Devices, Inc. +#define UHS_VID_VOICE_TECHNOLOGIES_GROUP 0x0439U // Voice Technologies Group +#define UHS_VID_LEXMARK_INTERNATIONAL 0x043dU // Lexmark International, Inc. +#define UHS_VID_LG_ELECTRONICS_USA 0x043eU // LG Electronics USA, Inc. +#define UHS_VID_RADISYS 0x043fU // RadiSys Corp. +#define UHS_VID_EIZO_NANAO 0x0440U // Eizo Nanao Corp. +#define UHS_VID_WINBOND_SYSTEMS_LAB 0x0441U // Winbond Systems Lab. +#define UHS_VID_ERICSSON 0x0442U // Ericsson, Inc. +#define UHS_VID_GATEWAY 0x0443U // Gateway, Inc. +#define UHS_VID_LUCENT_TECHNOLOGIES 0x0445U // Lucent Technologies, Inc. +#define UHS_VID_NMB_TECHNOLOGIES 0x0446U // NMB Technologies Corp. +#define UHS_VID_MOMENTUM_MICROSYSTEMS 0x0447U // Momentum Microsystems +#define UHS_VID_SHAMROCK_TECH 0x044aU // Shamrock Tech. Co., Ltd +#define UHS_VID_WSI 0x044bU // WSI +#define UHS_VID_CCLITRI 0x044cU // CCL/ITRI +#define UHS_VID_SIEMENS_NIXDORF_AG 0x044dU // Siemens Nixdorf AG +#define UHS_VID_ALPS_ELECTRIC_1 0x044eU // Alps Electric Co., Ltd +#define UHS_VID_THRUSTMASTER 0x044fU // ThrustMaster, Inc. +#define UHS_VID_DFI 0x0450U // DFI, Inc. +#define UHS_VID_TEXAS_INSTRUMENTS 0x0451U // Texas Instruments, Inc. +#define UHS_VID_MITSUBISHI_ELECTRONICS_AMERICA 0x0452U // Mitsubishi Electronics America, Inc. +#define UHS_VID_CMD_TECHNOLOGY 0x0453U // CMD Technology +#define UHS_VID_VOBIS_MICROCOMPUTER_AG 0x0454U // Vobis Microcomputer AG +#define UHS_VID_TELEMATICS_INTERNATIONAL 0x0455U // Telematics International, Inc. +#define UHS_VID_ANALOG_DEVICES 0x0456U // Analog Devices, Inc. +#define UHS_VID_SILICON_INTEGRATED_SYSTEMS 0x0457U // Silicon Integrated Systems Corp. +#define UHS_VID_KYE_SYSTEMS_CORP_MOUSE_SYSTEMS 0x0458U // KYE Systems Corp. (Mouse Systems) +#define UHS_VID_ADOBE_SYSTEMS 0x0459U // Adobe Systems, Inc. +#define UHS_VID_SONICBLUE 0x045aU // SONICblue, Inc. +#define UHS_VID_HITACHI 0x045bU // Hitachi, Ltd +#define UHS_VID_NORTEL_NETWORKS 0x045dU // Nortel Networks, Ltd +#define UHS_VID_MICROSOFT 0x045eU // Microsoft Corp. +#define UHS_VID_ACE_CAD_ENTERPRISE 0x0460U // Ace Cad Enterprise Co., Ltd +#define UHS_VID_PRIMAX_ELECTRONICS 0x0461U // Primax Electronics, Ltd +#define UHS_VID_MGE_UPS_SYSTEMS 0x0463U // MGE UPS Systems +#define UHS_VID_AMPTYCOELECTRONICS 0x0464U // AMP/Tycoelectronics Corp. +#define UHS_VID_ATANDT_PARADYNE 0x0467U // AT&T Paradyne +#define UHS_VID_WIESON_TECHNOLOGIES 0x0468U // Wieson Technologies Co., Ltd +#define UHS_VID_CHERRY 0x046aU // Cherry GmbH +#define UHS_VID_AMERICAN_MEGATRENDS 0x046bU // American Megatrends, Inc. +#define UHS_VID_TOSHIBA_CORP_DIGITAL_MEDIA_EQUIPMENT 0x046cU // Toshiba Corp., Digital Media Equipment +#define UHS_VID_LOGITECH 0x046dU // Logitech, Inc. +#define UHS_VID_BEHAVIOR_TECH_COMPUTER 0x046eU // Behavior Tech. Computer Corp. +#define UHS_VID_CRYSTAL_SEMICONDUCTOR 0x046fU // Crystal Semiconductor +#define UHS_VID_PHILIPS_OR_NXP 0x0471U // Philips (or NXP) +#define UHS_VID_CHICONY_ELECTRONICS 0x0472U // Chicony Electronics Co., Ltd +#define UHS_VID_SANYO_INFORMATION_BUSINESS 0x0473U // Sanyo Information Business Co., Ltd +#define UHS_VID_SANYO_ELECTRIC 0x0474U // Sanyo Electric Co., Ltd +#define UHS_VID_RELISYSTECO_INFORMATION_SYSTEM 0x0475U // Relisys/Teco Information System +#define UHS_VID_AESP 0x0476U // AESP +#define UHS_VID_SEAGATE_TECHNOLOGY 0x0477U // Seagate Technology, Inc. +#define UHS_VID_CONNECTIX 0x0478U // Connectix Corp. +#define UHS_VID_ADVANCED_PERIPHERAL_LABORATORIES 0x0479U // Advanced Peripheral Laboratories +#define UHS_VID_SEMTECH 0x047aU // Semtech Corp. +#define UHS_VID_SILITEK 0x047bU // Silitek Corp. +#define UHS_VID_DELL_COMPUTER 0x047cU // Dell Computer Corp. +#define UHS_VID_KENSINGTON 0x047dU // Kensington +#define UHS_VID_AGERE_SYSTEMS_INC_LUCENT 0x047eU // Agere Systems, Inc. (Lucent) +#define UHS_VID_PLANTRONICS 0x047fU // Plantronics, Inc. +#define UHS_VID_TOSHIBA_AMERICA 0x0480U // Toshiba America Inc +#define UHS_VID_ZENITH_DATA_SYSTEMS 0x0481U // Zenith Data Systems +#define UHS_VID_KYOCERA 0x0482U // Kyocera Corp. +#define UHS_VID_STMICROELECTRONICS 0x0483U // STMicroelectronics +#define UHS_VID_SPECIALIX 0x0484U // Specialix +#define UHS_VID_NOKIA_MONITORS 0x0485U // Nokia Monitors +#define UHS_VID_ASUS_COMPUTERS 0x0486U // ASUS Computers, Inc. +#define UHS_VID_STEWART_CONNECTOR 0x0487U // Stewart Connector +#define UHS_VID_CIRQUE 0x0488U // Cirque Corp. +#define UHS_VID_FOXCONN_HON_HAI 0x0489U // Foxconn / Hon Hai +#define UHS_VID_S_MOS_SYSTEMS 0x048aU // S-MOS Systems, Inc. +#define UHS_VID_ALPS_ELECTRIC_IRELAND 0x048cU // Alps Electric Ireland, Ltd +#define UHS_VID_INTEGRATED_TECHNOLOGY_EXPRESS 0x048dU // Integrated Technology Express, Inc. +#define UHS_VID_EICON_TECH 0x048fU // Eicon Tech. +#define UHS_VID_UNITED_MICROELECTRONICS 0x0490U // United Microelectronics Corp. +#define UHS_VID_CAPETRONIC 0x0491U // Capetronic +#define UHS_VID_SAMSUNG_SEMICONDUCTOR 0x0492U // Samsung SemiConductor, Inc. +#define UHS_VID_MAG_TECHNOLOGY 0x0493U // MAG Technology Co., Ltd +#define UHS_VID_ESS_TECHNOLOGY 0x0495U // ESS Technology, Inc. +#define UHS_VID_MICRON_ELECTRONICS 0x0496U // Micron Electronics +#define UHS_VID_SMILE_INTERNATIONAL 0x0497U // Smile International +#define UHS_VID_CAPETRONIC_KAOHSIUNG 0x0498U // Capetronic (Kaohsiung) Corp. +#define UHS_VID_YAMAHA 0x0499U // Yamaha Corp. +#define UHS_VID_GANDALF_TECHNOLOGIES 0x049aU // Gandalf Technologies, Ltd +#define UHS_VID_CURTIS_COMPUTER_PRODUCTS 0x049bU // Curtis Computer Products +#define UHS_VID_ACER_ADVANCED_LABS 0x049cU // Acer Advanced Labs, Inc. +#define UHS_VID_VLSI_TECHNOLOGY 0x049dU // VLSI Technology +#define UHS_VID_COMPAQ_COMPUTER 0x049fU // Compaq Computer Corp. +#define UHS_VID_DIGITAL_EQUIPMENT 0x04a0U // Digital Equipment Corp. +#define UHS_VID_SYSTEMSOFT 0x04a1U // SystemSoft Corp. +#define UHS_VID_FIREPOWER_SYSTEMS 0x04a2U // FirePower Systems +#define UHS_VID_TRIDENT_MICROSYSTEMS 0x04a3U // Trident Microsystems, Inc. +#define UHS_VID_HITACHI_1 0x04a4U // Hitachi, Ltd +#define UHS_VID_ACER_PERIPHERALS_INC_NOW_BENQ 0x04a5U // Acer Peripherals Inc. (now BenQ Corp.) +#define UHS_VID_NOKIA_DISPLAY_PRODUCTS 0x04a6U // Nokia Display Products +#define UHS_VID_VISIONEER 0x04a7U // Visioneer +#define UHS_VID_MULTIVIDEO_LABS 0x04a8U // Multivideo Labs, Inc. +#define UHS_VID_CANON 0x04a9U // Canon, Inc. +#define UHS_VID_DAEWOO_TELECOM 0x04aaU // DaeWoo Telecom, Ltd +#define UHS_VID_CHROMATIC_RESEARCH 0x04abU // Chromatic Research +#define UHS_VID_MICRO_AUDIOMETRICS 0x04acU // Micro Audiometrics Corp. +#define UHS_VID_DOOIN_ELECTRONICS 0x04adU // Dooin Electronics +#define UHS_VID_WINNOV_LP 0x04afU // Winnov L.P. +#define UHS_VID_NIKON 0x04b0U // Nikon Corp. +#define UHS_VID_PAN_INTERNATIONAL 0x04b1U // Pan International +#define UHS_VID_IBM 0x04b3U // IBM Corp. +#define UHS_VID_CYPRESS_SEMICONDUCTOR 0x04b4U // Cypress Semiconductor Corp. +#define UHS_VID_ROHM_LSI_SYSTEMS_USA 0x04b5U // ROHM LSI Systems USA, LLC +#define UHS_VID_HINT 0x04b6U // Hint Corp. +#define UHS_VID_COMPAL_ELECTRONICS 0x04b7U // Compal Electronics, Inc. +#define UHS_VID_SEIKO_EPSON 0x04b8U // Seiko Epson Corp. +#define UHS_VID_RAINBOW_TECHNOLOGIES 0x04b9U // Rainbow Technologies, Inc. +#define UHS_VID_TOUCAN_SYSTEMS 0x04baU // Toucan Systems, Ltd +#define UHS_VID_I_O_DATA_DEVICE 0x04bbU // I-O Data Device, Inc. +#define UHS_VID_TOSHIBA_ELECTRONICS_TAIWAN 0x04bdU // Toshiba Electronics Taiwan Corp. +#define UHS_VID_TELIA_RESEARCH 0x04beU // Telia Research AB +#define UHS_VID_TDK 0x04bfU // TDK Corp. +#define UHS_VID_US_ROBOTICS_3COM 0x04c1U // U.S. Robotics (3Com) +#define UHS_VID_METHODE_ELECTRONICS_FAR_EAST_PTE 0x04c2U // Methode Electronics Far East PTE, Ltd +#define UHS_VID_MAXI_SWITCH 0x04c3U // Maxi Switch, Inc. +#define UHS_VID_LOCKHEED_MARTIN_ENERGY_RESEARCH 0x04c4U // Lockheed Martin Energy Research +#define UHS_VID_FUJITSU 0x04c5U // Fujitsu, Ltd +#define UHS_VID_TOSHIBA_AMERICA_ELECTRONIC_COMPONENTS 0x04c6U // Toshiba America Electronic Components +#define UHS_VID_MICRO_MACRO_TECHNOLOGIES 0x04c7U // Micro Macro Technologies +#define UHS_VID_KONICA 0x04c8U // Konica Corp. +#define UHS_VID_LITE_ON_TECHNOLOGY 0x04caU // Lite-On Technology Corp. +#define UHS_VID_FUJI_PHOTO_FILM 0x04cbU // Fuji Photo Film Co., Ltd +#define UHS_VID_ST_ERICSSON 0x04ccU // ST-Ericsson +#define UHS_VID_TATUNG_CO_OF_AMERICA 0x04cdU // Tatung Co. Of America +#define UHS_VID_SCANLOGIC 0x04ceU // ScanLogic Corp. +#define UHS_VID_MYSON_CENTURY 0x04cfU // Myson Century, Inc. +#define UHS_VID_DIGI_INTERNATIONAL 0x04d0U // Digi International +#define UHS_VID_ITT_CANON 0x04d1U // ITT Canon +#define UHS_VID_ALTEC_LANSING_TECHNOLOGIES 0x04d2U // Altec Lansing Technologies +#define UHS_VID_VIDUS 0x04d3U // VidUS, Inc. +#define UHS_VID_LSI_LOGIC 0x04d4U // LSI Logic, Inc. +#define UHS_VID_FORTE_TECHNOLOGIES 0x04d5U // Forte Technologies, Inc. +#define UHS_VID_MENTOR_GRAPHICS 0x04d6U // Mentor Graphics +#define UHS_VID_OKI_SEMICONDUCTOR 0x04d7U // Oki Semiconductor +#define UHS_VID_MICROCHIP_TECHNOLOGY 0x04d8U // Microchip Technology, Inc. +#define UHS_VID_HOLTEK_SEMICONDUCTOR 0x04d9U // Holtek Semiconductor, Inc. +#define UHS_VID_PANASONIC_MATSUSHITA 0x04daU // Panasonic (Matsushita) +#define UHS_VID_HYPERTEC_PTY 0x04dbU // Hypertec Pty, Ltd +#define UHS_VID_HUAN_HSIN_HOLDINGS 0x04dcU // Huan Hsin Holdings, Ltd +#define UHS_VID_SHARP 0x04ddU // Sharp Corp. +#define UHS_VID_MINDSHARE 0x04deU // MindShare, Inc. +#define UHS_VID_INTERLINK_ELECTRONICS 0x04dfU // Interlink Electronics +#define UHS_VID_IIYAMA_NORTH_AMERICA 0x04e1U // Iiyama North America, Inc. +#define UHS_VID_EXAR 0x04e2U // Exar Corp. +#define UHS_VID_ZILOG 0x04e3U // Zilog, Inc. +#define UHS_VID_ACC_MICROELECTRONICS 0x04e4U // ACC Microelectronics +#define UHS_VID_PROMISE_TECHNOLOGY 0x04e5U // Promise Technology +#define UHS_VID_SCM_MICROSYSTEMS 0x04e6U // SCM Microsystems, Inc. +#define UHS_VID_ELO_TOUCHSYSTEMS 0x04e7U // Elo TouchSystems +#define UHS_VID_SAMSUNG_ELECTRONICS 0x04e8U // Samsung Electronics Co., Ltd +#define UHS_VID_PC_TEL 0x04e9U // PC-Tel, Inc. +#define UHS_VID_BROOKTREE 0x04eaU // Brooktree Corp. +#define UHS_VID_NORTHSTAR_SYSTEMS 0x04ebU // Northstar Systems, Inc. +#define UHS_VID_TOKYO_ELECTRON_DEVICE 0x04ecU // Tokyo Electron Device, Ltd +#define UHS_VID_ANNABOOKS 0x04edU // Annabooks +#define UHS_VID_PACIFIC_ELECTRONIC_INTERNATIONAL 0x04efU // Pacific Electronic International, Inc. +#define UHS_VID_DAEWOO_ELECTRONICS 0x04f0U // Daewoo Electronics Co., Ltd +#define UHS_VID_VICTOR_COMPANY_OF_JAPAN 0x04f1U // Victor Company of Japan, Ltd +#define UHS_VID_CHICONY_ELECTRONICS_1 0x04f2U // Chicony Electronics Co., Ltd +#define UHS_VID_ELAN_MICROELECTRONICS 0x04f3U // Elan Microelectronics Corp. +#define UHS_VID_HARTING_ELEKTRONIK 0x04f4U // Harting Elektronik, Inc. +#define UHS_VID_FUJITSU_ICL_SYSTEMS 0x04f5U // Fujitsu-ICL Systems, Inc. +#define UHS_VID_NORAND 0x04f6U // Norand Corp. +#define UHS_VID_NEWNEX_TECHNOLOGY 0x04f7U // Newnex Technology Corp. +#define UHS_VID_FUTUREPLUS_SYSTEMS 0x04f8U // FuturePlus Systems +#define UHS_VID_BROTHER_INDUSTRIES 0x04f9U // Brother Industries, Ltd +#define UHS_VID_DALLAS_SEMICONDUCTOR 0x04faU // Dallas Semiconductor +#define UHS_VID_BIOSTAR_MICROTECH_INTERNATIONAL 0x04fbU // Biostar Microtech International Corp. +#define UHS_VID_SUNPLUS_TECHNOLOGY 0x04fcU // Sunplus Technology Co., Ltd +#define UHS_VID_SOLITON_SYSTEMS_KK 0x04fdU // Soliton Systems, K.K. +#define UHS_VID_PFU 0x04feU // PFU, Ltd +#define UHS_VID_E_CMOS 0x04ffU // E-CMOS Corp. +#define UHS_VID_SIAM_UNITED_HI_TECH 0x0500U // Siam United Hi-Tech +#define UHS_VID_FUJIKURA_DDK 0x0501U // Fujikura DDK, Ltd +#define UHS_VID_ACER_1 0x0502U // Acer, Inc. +#define UHS_VID_HITACHI_AMERICA 0x0503U // Hitachi America, Ltd +#define UHS_VID_HAYES_MICROCOMPUTER_PRODUCTS 0x0504U // Hayes Microcomputer Products +#define UHS_VID_3COM 0x0506U // 3Com Corp. +#define UHS_VID_HOSIDEN 0x0507U // Hosiden Corp. +#define UHS_VID_CLARION 0x0508U // Clarion Co., Ltd +#define UHS_VID_AZTECH_SYSTEMS 0x0509U // Aztech Systems, Ltd +#define UHS_VID_CINCH_CONNECTORS 0x050aU // Cinch Connectors +#define UHS_VID_CABLE_SYSTEM_INTERNATIONAL 0x050bU // Cable System International +#define UHS_VID_INNOMEDIA 0x050cU // InnoMedia, Inc. +#define UHS_VID_BELKIN_COMPONENTS 0x050dU // Belkin Components +#define UHS_VID_NEON_TECHNOLOGY 0x050eU // Neon Technology, Inc. +#define UHS_VID_KC_TECHNOLOGY 0x050fU // KC Technology, Inc. +#define UHS_VID_SEJIN_ELECTRON 0x0510U // Sejin Electron, Inc. +#define UHS_VID_NABLE_DATABOOK_TECHNOLOGIES 0x0511U // N'Able (DataBook) Technologies, Inc. +#define UHS_VID_HUALON_MICROELECTRONICS 0x0512U // Hualon Microelectronics Corp. +#define UHS_VID_DIGITAL_X 0x0513U // digital-X, Inc. +#define UHS_VID_FCI_ELECTRONICS 0x0514U // FCI Electronics +#define UHS_VID_ACTC 0x0515U // ACTC +#define UHS_VID_LONGWELL_ELECTRONICS 0x0516U // Longwell Electronics +#define UHS_VID_BUTTERFLY_COMMUNICATIONS 0x0517U // Butterfly Communications +#define UHS_VID_EZKEY 0x0518U // EzKEY Corp. +#define UHS_VID_STAR_MICRONICS 0x0519U // Star Micronics Co., Ltd +#define UHS_VID_WYSE_TECHNOLOGY 0x051aU // WYSE Technology +#define UHS_VID_SILICON_GRAPHICS 0x051bU // Silicon Graphics +#define UHS_VID_SHUTTLE 0x051cU // Shuttle, Inc. +#define UHS_VID_AMERICAN_POWER_CONVERSION 0x051dU // American Power Conversion +#define UHS_VID_SCIENTIFIC_ATLANTA 0x051eU // Scientific Atlanta, Inc. +#define UHS_VID_IO_SYSTEMS_ELITE_ELECTRONICS 0x051fU // IO Systems (Elite Electronics), Inc. +#define UHS_VID_TAIWAN_SEMICONDUCTOR_MANUFACTURING 0x0520U // Taiwan Semiconductor Manufacturing Co. +#define UHS_VID_AIRBORN_CONNECTORS 0x0521U // Airborn Connectors +#define UHS_VID_ADVANCED_CONNECTEK 0x0522U // Advanced Connectek, Inc. +#define UHS_VID_ATEN 0x0523U // ATEN GmbH +#define UHS_VID_SOLA_ELECTRONICS 0x0524U // Sola Electronics +#define UHS_VID_NETCHIP_TECHNOLOGY 0x0525U // Netchip Technology, Inc. +#define UHS_VID_TEMIC_MHS 0x0526U // Temic MHS S.A. +#define UHS_VID_ALTRA 0x0527U // ALTRA +#define UHS_VID_ATI_TECHNOLOGIES 0x0528U // ATI Technologies, Inc. +#define UHS_VID_ALADDIN_KNOWLEDGE_SYSTEMS 0x0529U // Aladdin Knowledge Systems +#define UHS_VID_CRESCENT_HEART_SOFTWARE 0x052aU // Crescent Heart Software +#define UHS_VID_TEKOM_TECHNOLOGIES 0x052bU // Tekom Technologies, Inc. +#define UHS_VID_CANON_INFORMATION_SYSTEMS 0x052cU // Canon Information Systems, Inc. +#define UHS_VID_AVID_ELECTRONICS 0x052dU // Avid Electronics Corp. +#define UHS_VID_STANDARD_MICROSYSTEMS_1 0x052eU // Standard Microsystems Corp. +#define UHS_VID_UNICORE_SOFTWARE 0x052fU // Unicore Software, Inc. +#define UHS_VID_AMERICAN_MICROSYSTEMS 0x0530U // American Microsystems, Inc. +#define UHS_VID_WACOM_TECHNOLOGY 0x0531U // Wacom Technology Corp. +#define UHS_VID_SYSTECH 0x0532U // Systech Corp. +#define UHS_VID_ALCATEL_MOBILE_PHONES 0x0533U // Alcatel Mobile Phones +#define UHS_VID_MOTOROLA 0x0534U // Motorola, Inc. +#define UHS_VID_LIH_TZU_ELECTRIC 0x0535U // LIH TZU Electric Co., Ltd +#define UHS_VID_HAND_HELD_PRODUCTS_WELCH_ALLYN 0x0536U // Hand Held Products (Welch Allyn, Inc.) +#define UHS_VID_INVENTEC 0x0537U // Inventec Corp. +#define UHS_VID_CALDERA_INTERNATIONAL_INC_SCO 0x0538U // Caldera International, Inc. (SCO) +#define UHS_VID_SHYH_SHIUN_TERMINALS 0x0539U // Shyh Shiun Terminals Co., Ltd +#define UHS_VID_PREHKEYTEC 0x053aU // PrehKeyTec GmbH +#define UHS_VID_GLOBAL_VILLAGE_COMMUNICATION 0x053bU // Global Village Communication +#define UHS_VID_INSTITUT_OF_MICROELECTRONIC_AND_MECHATRONIC_SYSTEMS 0x053cU // Institut of Microelectronic & Mechatronic Systems +#define UHS_VID_SILICON_ARCHITECT 0x053dU // Silicon Architect +#define UHS_VID_MOBILITY_ELECTRONICS 0x053eU // Mobility Electronics +#define UHS_VID_SYNOPSYS_1 0x053fU // Synopsys, Inc. +#define UHS_VID_UNIACCESS 0x0540U // UniAccess AB +#define UHS_VID_SIRF_TECHNOLOGY 0x0541U // Sirf Technology, Inc. +#define UHS_VID_VIEWSONIC 0x0543U // ViewSonic Corp. +#define UHS_VID_CRISTIE_ELECTRONICS 0x0544U // Cristie Electronics, Ltd +#define UHS_VID_XIRLINK 0x0545U // Xirlink, Inc. +#define UHS_VID_POLAROID 0x0546U // Polaroid Corp. +#define UHS_VID_ANCHOR_CHIPS 0x0547U // Anchor Chips, Inc. +#define UHS_VID_TYAN_COMPUTER 0x0548U // Tyan Computer Corp. +#define UHS_VID_PIXERA 0x0549U // Pixera Corp. +#define UHS_VID_FUJITSU_MICROELECTRONICS 0x054aU // Fujitsu Microelectronics, Inc. +#define UHS_VID_NEW_MEDIA 0x054bU // New Media Corp. +#define UHS_VID_SONY 0x054cU // Sony Corp. +#define UHS_VID_TRY 0x054dU // Try Corp. +#define UHS_VID_PROSIDE 0x054eU // Proside Corp. +#define UHS_VID_WYSE_TECHNOLOGY_TAIWAN 0x054fU // WYSE Technology Taiwan +#define UHS_VID_FUJI_XEROX 0x0550U // Fuji Xerox Co., Ltd +#define UHS_VID_COMPUTREND_SYSTEMS 0x0551U // CompuTrend Systems, Inc. +#define UHS_VID_PHILIPS_MONITORS 0x0552U // Philips Monitors +#define UHS_VID_STMICROELECTRONICS_IMAGING_DIVISION_VLSI_VISION 0x0553U // STMicroelectronics Imaging Division (VLSI Vision) +#define UHS_VID_DICTAPHONE 0x0554U // Dictaphone Corp. +#define UHS_VID_ANAM_SANDT 0x0555U // ANAM S&T Co., Ltd +#define UHS_VID_ASAHI_KASEI_MICROSYSTEMS 0x0556U // Asahi Kasei Microsystems Co., Ltd +#define UHS_VID_ATEN_INTERNATIONAL 0x0557U // ATEN International Co., Ltd +#define UHS_VID_TRUEVISION 0x0558U // Truevision, Inc. +#define UHS_VID_CADENCE_DESIGN_SYSTEMS 0x0559U // Cadence Design Systems, Inc. +#define UHS_VID_KENWOOD_USA 0x055aU // Kenwood USA +#define UHS_VID_KNOWLEDGETEK 0x055bU // KnowledgeTek, Inc. +#define UHS_VID_PROTON_ELECTRONIC_IND 0x055cU // Proton Electronic Ind. +#define UHS_VID_SAMSUNG_ELECTRO_MECHANICS 0x055dU // Samsung Electro-Mechanics Co. +#define UHS_VID_CTX_OPTO_ELECTRONICS 0x055eU // CTX Opto-Electronics Corp. +#define UHS_VID_MUSTEK_SYSTEMS 0x055fU // Mustek Systems, Inc. +#define UHS_VID_INTERFACE 0x0560U // Interface Corp. +#define UHS_VID_OASIS_DESIGN 0x0561U // Oasis Design, Inc. +#define UHS_VID_TELEX_COMMUNICATIONS 0x0562U // Telex Communications, Inc. +#define UHS_VID_IMMERSION 0x0563U // Immersion Corp. +#define UHS_VID_KODAK_DIGITAL_PRODUCT_CENTER_JAPAN_LTD_FORMERLY_CHINON_INDUSTRIES 0x0564U // Kodak Digital Product Center, Japan Ltd. (formerly Chinon Industries Inc.) +#define UHS_VID_PERACOM_NETWORKS 0x0565U // Peracom Networks, Inc. +#define UHS_VID_MONTEREY_INTERNATIONAL 0x0566U // Monterey International Corp. +#define UHS_VID_XYRATEX_INTERNATIONAL 0x0567U // Xyratex International, Ltd +#define UHS_VID_QUARTZ_INGENIERIE 0x0568U // Quartz Ingenierie +#define UHS_VID_SEGASOFT 0x0569U // SegaSoft +#define UHS_VID_WACOM 0x056aU // Wacom Co., Ltd +#define UHS_VID_DECICON 0x056bU // Decicon, Inc. +#define UHS_VID_ETEK_LABS 0x056cU // eTEK Labs +#define UHS_VID_EIZO 0x056dU // EIZO Corp. +#define UHS_VID_ELECOM 0x056eU // Elecom Co., Ltd +#define UHS_VID_KOREA_DATA_SYSTEMS 0x056fU // Korea Data Systems Co., Ltd +#define UHS_VID_EPSON_AMERICA 0x0570U // Epson America +#define UHS_VID_INTEREX 0x0571U // Interex, Inc. +#define UHS_VID_CONEXANT_SYSTEMS_ROCKWELL 0x0572U // Conexant Systems (Rockwell), Inc. +#define UHS_VID_ZORAN_CO_PERSONAL_MEDIA_DIVISION_NOGATECH 0x0573U // Zoran Co. Personal Media Division (Nogatech) +#define UHS_VID_CITY_UNIVERSITY_OF_HONG_KONG 0x0574U // City University of Hong Kong +#define UHS_VID_PHILIPS_CREATIVE_DISPLAY_SOLUTIONS 0x0575U // Philips Creative Display Solutions +#define UHS_VID_BAFOQUALITY_COMPUTER_ACCESSORIES 0x0576U // BAFO/Quality Computer Accessories +#define UHS_VID_ELSA 0x0577U // ELSA +#define UHS_VID_INTRINSIX 0x0578U // Intrinsix Corp. +#define UHS_VID_GVC 0x0579U // GVC Corp. +#define UHS_VID_SAMSUNG_ELECTRONICS_AMERICA 0x057aU // Samsung Electronics America +#define UHS_VID_Y_E_DATA 0x057bU // Y-E Data, Inc. +#define UHS_VID_AVM 0x057cU // AVM GmbH +#define UHS_VID_SHARK_MULTIMEDIA 0x057dU // Shark Multimedia, Inc. +#define UHS_VID_NINTENDO 0x057eU // Nintendo Co., Ltd +#define UHS_VID_QUICKSHOT 0x057fU // QuickShot, Ltd +#define UHS_VID_DENRON 0x0580U // Denron, Inc. +#define UHS_VID_RACAL_DATA_GROUP 0x0581U // Racal Data Group +#define UHS_VID_ROLAND 0x0582U // Roland Corp. +#define UHS_VID_PADIX_CO_LTD_ROCKFIRE 0x0583U // Padix Co., Ltd (Rockfire) +#define UHS_VID_RATOC_SYSTEM 0x0584U // RATOC System, Inc. +#define UHS_VID_FLASHPOINT_TECHNOLOGY 0x0585U // FlashPoint Technology, Inc. +#define UHS_VID_ZYXEL_COMMUNICATIONS 0x0586U // ZyXEL Communications Corp. +#define UHS_VID_AMERICA_KOTOBUKI_ELECTRONICS_INDUSTRIES 0x0587U // America Kotobuki Electronics Industries, Inc. +#define UHS_VID_SAPIEN_DESIGN 0x0588U // Sapien Design +#define UHS_VID_VICTRON 0x0589U // Victron +#define UHS_VID_NOHAU 0x058aU // Nohau Corp. +#define UHS_VID_INFINEON_TECHNOLOGIES 0x058bU // Infineon Technologies +#define UHS_VID_IN_FOCUS_SYSTEMS 0x058cU // In Focus Systems +#define UHS_VID_MICREL_SEMICONDUCTOR 0x058dU // Micrel Semiconductor +#define UHS_VID_TRIPATH_TECHNOLOGY 0x058eU // Tripath Technology, Inc. +#define UHS_VID_ALCOR_MICRO 0x058fU // Alcor Micro Corp. +#define UHS_VID_OMRON 0x0590U // Omron Corp. +#define UHS_VID_QUESTRA_CONSULTING 0x0591U // Questra Consulting +#define UHS_VID_POWERWARE 0x0592U // Powerware Corp. +#define UHS_VID_INCITE 0x0593U // Incite +#define UHS_VID_PRINCETON_GRAPHIC_SYSTEMS 0x0594U // Princeton Graphic Systems +#define UHS_VID_ZORAN_MICROELECTRONICS 0x0595U // Zoran Microelectronics, Ltd +#define UHS_VID_MICROTOUCH_SYSTEMS 0x0596U // MicroTouch Systems, Inc. +#define UHS_VID_TRISIGNAL_COMMUNICATIONS 0x0597U // Trisignal Communications +#define UHS_VID_NIIGATA_CANOTEC 0x0598U // Niigata Canotec Co., Inc. +#define UHS_VID_BRILLIANCE_SEMICONDUCTOR 0x0599U // Brilliance Semiconductor, Inc. +#define UHS_VID_SPECTRUM_SIGNAL_PROCESSING 0x059aU // Spectrum Signal Processing, Inc. +#define UHS_VID_IOMEGA 0x059bU // Iomega Corp. +#define UHS_VID_A_TREND_TECHNOLOGY 0x059cU // A-Trend Technology Co., Ltd +#define UHS_VID_ADVANCED_INPUT_DEVICES 0x059dU // Advanced Input Devices +#define UHS_VID_INTELLIGENT_INSTRUMENTATION 0x059eU // Intelligent Instrumentation +#define UHS_VID_LACIE 0x059fU // LaCie, Ltd +#define UHS_VID_VETRONIX 0x05a0U // Vetronix Corp. +#define UHS_VID_USC 0x05a1U // USC Corp. +#define UHS_VID_FUJI_FILM_MICRODEVICES 0x05a2U // Fuji Film Microdevices Co., Ltd +#define UHS_VID_ARC_INTERNATIONAL 0x05a3U // ARC International +#define UHS_VID_ORTEK_TECHNOLOGY 0x05a4U // Ortek Technology, Inc. +#define UHS_VID_SAMPO_TECHNOLOGY 0x05a5U // Sampo Technology Corp. +#define UHS_VID_CISCO_SYSTEMS 0x05a6U // Cisco Systems, Inc. +#define UHS_VID_BOSE 0x05a7U // Bose Corp. +#define UHS_VID_SPACETEC_IMC 0x05a8U // Spacetec IMC Corp. +#define UHS_VID_OMNIVISION_TECHNOLOGIES 0x05a9U // OmniVision Technologies, Inc. +#define UHS_VID_UTILUX_SOUTH_CHINA 0x05aaU // Utilux South China, Ltd +#define UHS_VID_IN_SYSTEM_DESIGN 0x05abU // In-System Design +#define UHS_VID_APPLE 0x05acU // Apple, Inc. +#define UHS_VID_YC_CABLE_USA 0x05adU // Y.C. Cable U.S.A., Inc. +#define UHS_VID_SYNOPSYS_2 0x05aeU // Synopsys, Inc. +#define UHS_VID_JING_MOLD_ENTERPRISE 0x05afU // Jing-Mold Enterprise Co., Ltd +#define UHS_VID_FOUNTAIN_TECHNOLOGIES 0x05b0U // Fountain Technologies, Inc. +#define UHS_VID_FIRST_INTERNATIONAL_COMPUTER 0x05b1U // First International Computer, Inc. +#define UHS_VID_LG_SEMICON 0x05b4U // LG Semicon Co., Ltd +#define UHS_VID_DIALOGIC 0x05b5U // Dialogic Corp. +#define UHS_VID_PROXIMA 0x05b6U // Proxima Corp. +#define UHS_VID_MEDIANIX_SEMICONDUCTOR 0x05b7U // Medianix Semiconductor, Inc. +#define UHS_VID_AGILER 0x05b8U // Agiler, Inc. +#define UHS_VID_PHILIPS_RESEARCH_LABORATORIES 0x05b9U // Philips Research Laboratories +#define UHS_VID_DIGITALPERSONA 0x05baU // DigitalPersona, Inc. +#define UHS_VID_GREY_CELL_SYSTEMS 0x05bbU // Grey Cell Systems +#define UHS_VID_3G_GREEN_GREEN_GLOBE 0x05bcU // 3G Green Green Globe Co., Ltd +#define UHS_VID_RAFI_GMBH_AND_CO_KG 0x05bdU // RAFI GmbH & Co. KG +#define UHS_VID_TYCO_ELECTRONICS_RAYCHEM 0x05beU // Tyco Electronics (Raychem) +#define UHS_VID_S_AND_S_RESEARCH 0x05bfU // S & S Research +#define UHS_VID_KEIL_SOFTWARE 0x05c0U // Keil Software +#define UHS_VID_KAWASAKI_MICROELECTRONICS 0x05c1U // Kawasaki Microelectronics, Inc. +#define UHS_VID_MEDIA_PHONICS_SUISSE 0x05c2U // Media Phonics (Suisse) S.A. +#define UHS_VID_DIGI_INTERNATIONAL_1 0x05c5U // Digi International, Inc. +#define UHS_VID_QUALCOMM 0x05c6U // Qualcomm, Inc. +#define UHS_VID_QTRONIX 0x05c7U // Qtronix Corp. +#define UHS_VID_CHENG_UEI_PRECISION_INDUSTRY_CO_LTD_FOXLINK 0x05c8U // Cheng Uei Precision Industry Co., Ltd (Foxlink) +#define UHS_VID_SEMTECH_1 0x05c9U // Semtech Corp. +#define UHS_VID_RICOH 0x05caU // Ricoh Co., Ltd +#define UHS_VID_POWERVISION_TECHNOLOGIES 0x05cbU // PowerVision Technologies, Inc. +#define UHS_VID_ELSA_AG 0x05ccU // ELSA AG +#define UHS_VID_SILICOM 0x05cdU // Silicom, Ltd +#define UHS_VID_SCI_WORX 0x05ceU // sci-worx GmbH +#define UHS_VID_SUNG_FORN 0x05cfU // Sung Forn Co., Ltd +#define UHS_VID_GE_MEDICAL_SYSTEMS_LUNAR 0x05d0U // GE Medical Systems Lunar +#define UHS_VID_BRAINBOXES 0x05d1U // Brainboxes, Ltd +#define UHS_VID_WAVE_SYSTEMS 0x05d2U // Wave Systems Corp. +#define UHS_VID_TOHOKU_RICOH 0x05d3U // Tohoku Ricoh Co., Ltd +#define UHS_VID_SUPER_GATE_TECHNOLOGY 0x05d5U // Super Gate Technology Co., Ltd +#define UHS_VID_PHILIPS_SEMICONDUCTORS_CICT 0x05d6U // Philips Semiconductors, CICT +#define UHS_VID_THOMAS_AND_BETTS 0x05d7U // Thomas & Betts Corp. +#define UHS_VID_ULTIMA_ELECTRONICS 0x05d8U // Ultima Electronics Corp. +#define UHS_VID_AXIOHM_TRANSACTION_SOLUTIONS 0x05d9U // Axiohm Transaction Solutions +#define UHS_VID_MICROTEK_INTERNATIONAL 0x05daU // Microtek International, Inc. +#define UHS_VID_SUN_CORP_SUNTAC_UNKNOWN 0x05dbU // Sun Corp. (Suntac?) +#define UHS_VID_LEXAR_MEDIA 0x05dcU // Lexar Media, Inc. +#define UHS_VID_DELTA_ELECTRONICS 0x05ddU // Delta Electronics, Inc. +#define UHS_VID_SILICON_VISION 0x05dfU // Silicon Vision, Inc. +#define UHS_VID_SYMBOL_TECHNOLOGIES 0x05e0U // Symbol Technologies +#define UHS_VID_SYNTEK_SEMICONDUCTOR 0x05e1U // Syntek Semiconductor Co., Ltd +#define UHS_VID_ELECVISION 0x05e2U // ElecVision, Inc. +#define UHS_VID_GENESYS_LOGIC 0x05e3U // Genesys Logic, Inc. +#define UHS_VID_RED_WING 0x05e4U // Red Wing Corp. +#define UHS_VID_FUJI_ELECTRIC 0x05e5U // Fuji Electric Co., Ltd +#define UHS_VID_KEITHLEY_INSTRUMENTS 0x05e6U // Keithley Instruments +#define UHS_VID_ICC 0x05e8U // ICC, Inc. +#define UHS_VID_KAWASAKI_LSI 0x05e9U // Kawasaki LSI +#define UHS_VID_FFC 0x05ebU // FFC, Ltd +#define UHS_VID_COM21 0x05ecU // COM21, Inc. +#define UHS_VID_CYTECHINFO 0x05eeU // Cytechinfo Inc. +#define UHS_VID_AVB_INC_ANKO_UNKNOWN_ 0x05efU // AVB, Inc. [anko?] +#define UHS_VID_CANOPUS 0x05f0U // Canopus Co., Ltd +#define UHS_VID_COMPASS_COMMUNICATIONS 0x05f1U // Compass Communications +#define UHS_VID_DEXIN 0x05f2U // Dexin Corp., Ltd +#define UHS_VID_PI_ENGINEERING 0x05f3U // PI Engineering, Inc. +#define UHS_VID_UNIXTAR_TECHNOLOGY 0x05f5U // Unixtar Technology, Inc. +#define UHS_VID_AOC_INTERNATIONAL 0x05f6U // AOC International +#define UHS_VID_RFC_DISTRIBUTIONS_PTE 0x05f7U // RFC Distribution(s) PTE, Ltd +#define UHS_VID_PSC_SCANNING 0x05f9U // PSC Scanning, Inc. +#define UHS_VID_SIEMENS_TELECOMMUNICATIONS_SYSTEMS 0x05faU // Siemens Telecommunications Systems, Ltd +#define UHS_VID_HARMAN 0x05fcU // Harman +#define UHS_VID_INTERACT 0x05fdU // InterAct, Inc. +#define UHS_VID_CHIC_TECHNOLOGY 0x05feU // Chic Technology Corp. +#define UHS_VID_LECROY 0x05ffU // LeCroy Corp. +#define UHS_VID_BARCO_DISPLAY_SYSTEMS 0x0600U // Barco Display Systems +#define UHS_VID_JAZZ_HIPSTER 0x0601U // Jazz Hipster Corp. +#define UHS_VID_VISTA_IMAGING 0x0602U // Vista Imaging, Inc. +#define UHS_VID_NOVATEK_MICROELECTRONICS 0x0603U // Novatek Microelectronics Corp. +#define UHS_VID_JEAN 0x0604U // Jean Co., Ltd +#define UHS_VID_ANCHOR_CANDC 0x0605U // Anchor C&C Co., Ltd +#define UHS_VID_ROYAL_INFORMATION_ELECTRONICS 0x0606U // Royal Information Electronics Co., Ltd +#define UHS_VID_BRIDGE_INFORMATION 0x0607U // Bridge Information Co., Ltd +#define UHS_VID_GENRAD_ADS 0x0608U // Genrad Ads +#define UHS_VID_SMK_MANUFACTURING 0x0609U // SMK Manufacturing, Inc. +#define UHS_VID_WORTHINGTON_DATA_SOLUTIONS 0x060aU // Worthington Data Solutions, Inc. +#define UHS_VID_SOLID_YEAR 0x060bU // Solid Year +#define UHS_VID_EEH_DATALINK 0x060cU // EEH Datalink GmbH +#define UHS_VID_AUCTOR 0x060dU // Auctor Corp. +#define UHS_VID_TRANSMONDE_TECHNOLOGIES 0x060eU // Transmonde Technologies, Inc. +#define UHS_VID_JOINSOON_ELECTRONICS_MFG 0x060fU // Joinsoon Electronics Mfg. Co., Ltd +#define UHS_VID_COSTAR_ELECTRONICS 0x0610U // Costar Electronics, Inc. +#define UHS_VID_TOTOKU_ELECTRIC 0x0611U // Totoku Electric Co., Ltd +#define UHS_VID_TRANSACT_TECHNOLOGIES 0x0613U // TransAct Technologies, Inc. +#define UHS_VID_BIO_RAD_LABORATORIES 0x0614U // Bio-Rad Laboratories +#define UHS_VID_QUABBIN_WIRE_AND_CABLE 0x0615U // Quabbin Wire & Cable Co., Inc. +#define UHS_VID_FUTURE_TECHNO_DESIGNS_PVT 0x0616U // Future Techno Designs PVT, Ltd +#define UHS_VID_SWISS_FEDERAL_INSITUTE_OF_TECHNOLOGY 0x0617U // Swiss Federal Insitute of Technology +#define UHS_VID_MACALLY 0x0618U // MacAlly +#define UHS_VID_SEIKO_INSTRUMENTS 0x0619U // Seiko Instruments, Inc. +#define UHS_VID_VERIDICOM_INTERNATIONAL 0x061aU // Veridicom International, Inc. +#define UHS_VID_PROMPTUS_COMMUNICATIONS 0x061bU // Promptus Communications, Inc. +#define UHS_VID_ACT_LABS 0x061cU // Act Labs, Ltd +#define UHS_VID_QUATECH 0x061dU // Quatech, Inc. +#define UHS_VID_NISSEI_ELECTRIC 0x061eU // Nissei Electric Co. +#define UHS_VID_ALARIS 0x0620U // Alaris, Inc. +#define UHS_VID_ODU_STECKVERBINDUNGSSYSTEME_GMBH_AND_CO_KG 0x0621U // ODU-Steckverbindungssysteme GmbH & Co. KG +#define UHS_VID_IOTECH 0x0622U // Iotech, Inc. +#define UHS_VID_LITTELFUSE 0x0623U // Littelfuse, Inc. +#define UHS_VID_AVOCENT 0x0624U // Avocent Corp. +#define UHS_VID_TIMEDIA_TECHNOLOGY 0x0625U // TiMedia Technology Co., Ltd +#define UHS_VID_NIPPON_SYSTEMS_DEVELOPMENT 0x0626U // Nippon Systems Development Co., Ltd +#define UHS_VID_ADOMAX_TECHNOLOGY 0x0627U // Adomax Technology Co., Ltd +#define UHS_VID_TASKING_SOFTWARE 0x0628U // Tasking Software, Inc. +#define UHS_VID_ZIDA_TECHNOLOGIES 0x0629U // Zida Technologies, Ltd +#define UHS_VID_CREATIVE_LABS 0x062aU // Creative Labs +#define UHS_VID_GREATLINK_ELECTRONICS_TAIWAN 0x062bU // Greatlink Electronics Taiwan, Ltd +#define UHS_VID_INSTITUTE_FOR_INFORMATION_INDUSTRY 0x062cU // Institute for Information Industry +#define UHS_VID_TAIWAN_TAI_HAO_ENTERPRISES 0x062dU // Taiwan Tai-Hao Enterprises Co., Ltd +#define UHS_VID_MAINSUPER_ENTERPRISES 0x062eU // Mainsuper Enterprises Co., Ltd +#define UHS_VID_SIN_SHENG_TERMINAL_AND_MACHINE 0x062fU // Sin Sheng Terminal & Machine, Inc. +#define UHS_VID_JUJO_ELECTRONICS 0x0631U // JUJO Electronics Corp. +#define UHS_VID_CYRIX 0x0633U // Cyrix Corp. +#define UHS_VID_MICRON_TECHNOLOGY 0x0634U // Micron Technology, Inc. +#define UHS_VID_METHODE_ELECTRONICS 0x0635U // Methode Electronics, Inc. +#define UHS_VID_SIERRA_IMAGING 0x0636U // Sierra Imaging, Inc. +#define UHS_VID_AVISION 0x0638U // Avision, Inc. +#define UHS_VID_CHRONTEL 0x0639U // Chrontel, Inc. +#define UHS_VID_TECHWIN 0x063aU // Techwin Corp. +#define UHS_VID_TAUGAGREINING_HF_1 0x063bU // Taugagreining HF +#define UHS_VID_YAMAICHI_ELECTRONICS_CO_LTD_SAKURA 0x063cU // Yamaichi Electronics Co., Ltd (Sakura) +#define UHS_VID_FONG_KAI_INDUSTRIAL 0x063dU // Fong Kai Industrial Co., Ltd +#define UHS_VID_REALMEDIA_TECHNOLOGY 0x063eU // RealMedia Technology, Inc. +#define UHS_VID_NEW_TECHNOLOGY_CABLE 0x063fU // New Technology Cable, Ltd +#define UHS_VID_HITEX_DEVELOPMENT_TOOLS 0x0640U // Hitex Development Tools +#define UHS_VID_WOODS_INDUSTRIES 0x0641U // Woods Industries, Inc. +#define UHS_VID_VIA_MEDICAL 0x0642U // VIA Medical Corp. +#define UHS_VID_TEAC 0x0644U // TEAC Corp. +#define UHS_VID_WHO_UNKNOWN_VISION_SYSTEMS 0x0645U // Who? Vision Systems, Inc. +#define UHS_VID_UMAX 0x0646U // UMAX +#define UHS_VID_ACTON_RESEARCH 0x0647U // Acton Research Corp. +#define UHS_VID_INSIDE_OUT_NETWORKS 0x0648U // Inside Out Networks +#define UHS_VID_WELI_SCIENCE 0x0649U // Weli Science Co., Ltd +#define UHS_VID_ANALOG_DEVICES_INC_WHITE_MOUNTAIN_DSP 0x064bU // Analog Devices, Inc. (White Mountain DSP) +#define UHS_VID_JI_HAW_INDUSTRIAL 0x064cU // Ji-Haw Industrial Co., Ltd +#define UHS_VID_TRITECH_MICROELECTRONICS 0x064dU // TriTech Microelectronics, Ltd +#define UHS_VID_SUYIN 0x064eU // Suyin Corp. +#define UHS_VID_WIBU_SYSTEMS_AG 0x064fU // WIBU-Systems AG +#define UHS_VID_DYNAPRO_SYSTEMS 0x0650U // Dynapro Systems +#define UHS_VID_LIKOM_TECHNOLOGY_SDN_BHD 0x0651U // Likom Technology Sdn. Bhd. +#define UHS_VID_STARGATE_SOLUTIONS 0x0652U // Stargate Solutions, Inc. +#define UHS_VID_CNF 0x0653U // CNF, Inc. +#define UHS_VID_GRANITE_MICROSYSTEMS 0x0654U // Granite Microsystems, Inc. +#define UHS_VID_SPACE_SHUTTLE_HI_TECH 0x0655U // Space Shuttle Hi-Tech Co., Ltd +#define UHS_VID_GLORY_MARK_ELECTRONIC 0x0656U // Glory Mark Electronic, Ltd +#define UHS_VID_TEKCON_ELECTRONICS 0x0657U // Tekcon Electronics Corp. +#define UHS_VID_SIGMA_DESIGNS 0x0658U // Sigma Designs, Inc. +#define UHS_VID_AETHRA 0x0659U // Aethra +#define UHS_VID_OPTOELECTRONICS 0x065aU // Optoelectronics Co., Ltd +#define UHS_VID_TRACEWELL_SYSTEMS 0x065bU // Tracewell Systems +#define UHS_VID_SILICON_GRAPHICS_1 0x065eU // Silicon Graphics +#define UHS_VID_GOOD_WAY_TECHNOLOGY_CO_LTD_AND_GWC_TECHNOLOGY 0x065fU // Good Way Technology Co., Ltd & GWC technology Inc. +#define UHS_VID_TSAY_E_BVI_INTERNATIONAL 0x0660U // TSAY-E (BVI) International, Inc. +#define UHS_VID_HAMAMATSU_PHOTONICS_KK 0x0661U // Hamamatsu Photonics K.K. +#define UHS_VID_KANSAI_ELECTRIC 0x0662U // Kansai Electric Co., Ltd +#define UHS_VID_TOPMAX_ELECTRONIC 0x0663U // Topmax Electronic Co., Ltd +#define UHS_VID_ETANDT_TECHNOLOGY 0x0664U // ET&T Technology Co., Ltd. +#define UHS_VID_CYPRESS_SEMICONDUCTOR_1 0x0665U // Cypress Semiconductor +#define UHS_VID_AIWA 0x0667U // Aiwa Co., Ltd +#define UHS_VID_WORDWAND 0x0668U // WordWand +#define UHS_VID_OCE_PRINTING_SYSTEMS 0x0669U // Oce' Printing Systems GmbH +#define UHS_VID_TOTAL_TECHNOLOGIES 0x066aU // Total Technologies, Ltd +#define UHS_VID_LINKSYS 0x066bU // Linksys, Inc. +#define UHS_VID_ENTREGA 0x066dU // Entrega, Inc. +#define UHS_VID_ACER_SEMICONDUCTOR_AMERICA 0x066eU // Acer Semiconductor America, Inc. +#define UHS_VID_SIGMATEL 0x066fU // SigmaTel, Inc. +#define UHS_VID_SEQUEL_IMAGING 0x0670U // Sequel Imaging +#define UHS_VID_LABTEC 0x0672U // Labtec, Inc. +#define UHS_VID_HCL 0x0673U // HCL +#define UHS_VID_KEY_MOUSE_ELECTRONIC_ENTERPRISE 0x0674U // Key Mouse Electronic Enterprise Co., Ltd +#define UHS_VID_DRAYTEK 0x0675U // DrayTek Corp. +#define UHS_VID_TELES_AG 0x0676U // Teles AG +#define UHS_VID_AIWA_1 0x0677U // Aiwa Co., Ltd +#define UHS_VID_ACARD_TECHNOLOGY 0x0678U // ACard Technology Corp. +#define UHS_VID_PROLIFIC_TECHNOLOGY 0x067bU // Prolific Technology, Inc. +#define UHS_VID_EFFICIENT_NETWORKS 0x067cU // Efficient Networks, Inc. +#define UHS_VID_HOHNER 0x067dU // Hohner Corp. +#define UHS_VID_INTERMEC_TECHNOLOGIES 0x067eU // Intermec Technologies Corp. +#define UHS_VID_VIRATA 0x067fU // Virata, Ltd +#define UHS_VID_REALTEK_SEMICONDUCTOR_CORP_CPP_DIV_AVANCE_LOGIC 0x0680U // Realtek Semiconductor Corp., CPP Div. (Avance Logic) +#define UHS_VID_SIEMENS_INFORMATION_AND_COMMUNICATION_PRODUCTS 0x0681U // Siemens Information and Communication Products +#define UHS_VID_VICTOR_COMPANY_OF_JAPAN_1 0x0682U // Victor Company of Japan, Ltd +#define UHS_VID_ACTIONTEC_ELECTRONICS 0x0684U // Actiontec Electronics, Inc. +#define UHS_VID_ZD_INCORPORATED 0x0685U // ZD Incorporated +#define UHS_VID_MINOLTA 0x0686U // Minolta Co., Ltd +#define UHS_VID_PERTECH 0x068aU // Pertech, Inc. +#define UHS_VID_POTRANS_INTERNATIONAL 0x068bU // Potrans International, Inc. +#define UHS_VID_CH_PRODUCTS 0x068eU // CH Products, Inc. +#define UHS_VID_GOLDEN_BRIDGE_ELECTECH 0x0690U // Golden Bridge Electech, Inc. +#define UHS_VID_HAGIWARA_SYS_COM 0x0693U // Hagiwara Sys-Com Co., Ltd +#define UHS_VID_LEGO_GROUP 0x0694U // Lego Group +#define UHS_VID_CHUNTEX_CTX 0x0698U // Chuntex (CTX) +#define UHS_VID_TEKTRONIX 0x0699U // Tektronix, Inc. +#define UHS_VID_ASKEY_COMPUTER 0x069aU // Askey Computer Corp. +#define UHS_VID_THOMSON 0x069bU // Thomson, Inc. +#define UHS_VID_HUGHES_NETWORK_SYSTEMS_HNS 0x069dU // Hughes Network Systems (HNS) +#define UHS_VID_WELCAT 0x069eU // Welcat Inc. +#define UHS_VID_ALLIED_DATA_TECHNOLOGIES_BV 0x069fU // Allied Data Technologies BV +#define UHS_VID_TOPRO_TECHNOLOGY 0x06a2U // Topro Technology, Inc. +#define UHS_VID_SAITEK_PLC 0x06a3U // Saitek PLC +#define UHS_VID_XIAMEN_DOOWELL_ELECTRON 0x06a4U // Xiamen Doowell Electron Co., Ltd +#define UHS_VID_DIVIO 0x06a5U // Divio +#define UHS_VID_MICROSTORE 0x06a7U // MicroStore, Inc. +#define UHS_VID_TOPAZ_SYSTEMS 0x06a8U // Topaz Systems, Inc. +#define UHS_VID_WESTELL 0x06a9U // Westell +#define UHS_VID_SYSGRATION 0x06aaU // Sysgration, Ltd +#define UHS_VID_FUJITSU_LABORATORIES_OF_AMERICA 0x06acU // Fujitsu Laboratories of America, Inc. +#define UHS_VID_GREATLAND_ELECTRONICS_TAIWAN 0x06adU // Greatland Electronics Taiwan, Ltd +#define UHS_VID_PROFESSIONAL_MULTIMEDIA_TESTING_CENTRE 0x06aeU // Professional Multimedia Testing Centre +#define UHS_VID_HARTING_INC_OF_NORTH_AMERICA 0x06afU // Harting, Inc. of North America +#define UHS_VID_PIXELA 0x06b8U // Pixela Corp. +#define UHS_VID_ALCATEL_TELECOM 0x06b9U // Alcatel Telecom +#define UHS_VID_SMOOTH_CORD_AND_CONNECTOR 0x06baU // Smooth Cord & Connector Co., Ltd +#define UHS_VID_EDA 0x06bbU // EDA, Inc. +#define UHS_VID_OKI_DATA 0x06bcU // Oki Data Corp. +#define UHS_VID_AGFA_GEVAERT_NV 0x06bdU // AGFA-Gevaert NV +#define UHS_VID_AME_OPTIMEDIA_TECHNOLOGY 0x06beU // AME Optimedia Technology Co., Ltd +#define UHS_VID_LEOCO 0x06bfU // Leoco Corp. +#define UHS_VID_PHIDGETS_INC_FORMERLY_GLAB 0x06c2U // Phidgets Inc. (formerly GLAB) +#define UHS_VID_BIZLINK_INTERNATIONAL 0x06c4U // Bizlink International Corp. +#define UHS_VID_HAGENUK 0x06c5U // Hagenuk, GmbH +#define UHS_VID_INFOWAVE_SOFTWARE 0x06c6U // Infowave Software, Inc. +#define UHS_VID_SIIG 0x06c8U // SIIG, Inc. +#define UHS_VID_TAXAN_EUROPE 0x06c9U // Taxan (Europe), Ltd +#define UHS_VID_NEWER_TECHNOLOGY 0x06caU // Newer Technology, Inc. +#define UHS_VID_SYNAPTICS 0x06cbU // Synaptics, Inc. +#define UHS_VID_TERAYON_COMMUNICATION_SYSTEMS 0x06ccU // Terayon Communication Systems +#define UHS_VID_KEYSPAN 0x06cdU // Keyspan +#define UHS_VID_CONTEC 0x06ceU // Contec +#define UHS_VID_SPHERONVR_AG 0x06cfU // SpheronVR AG +#define UHS_VID_LAPLINK 0x06d0U // LapLink, Inc. +#define UHS_VID_DAEWOO_ELECTRONICS_1 0x06d1U // Daewoo Electronics Co., Ltd +#define UHS_VID_MITSUBISHI_ELECTRIC 0x06d3U // Mitsubishi Electric Corp. +#define UHS_VID_CISCO_SYSTEMS_1 0x06d4U // Cisco Systems +#define UHS_VID_TOSHIBA 0x06d5U // Toshiba +#define UHS_VID_AASHIMA_TECHNOLOGY_BV 0x06d6U // Aashima Technology B.V. +#define UHS_VID_NETWORK_COMPUTING_DEVICES_NCD 0x06d7U // Network Computing Devices (NCD) +#define UHS_VID_TECHNICAL_MARKETING_RESEARCH 0x06d8U // Technical Marketing Research, Inc. +#define UHS_VID_PHOENIXTEC_POWER 0x06daU // Phoenixtec Power Co., Ltd +#define UHS_VID_PARADYNE 0x06dbU // Paradyne +#define UHS_VID_FOXLINK_IMAGE_TECHNOLOGY 0x06dcU // Foxlink Image Technology Co., Ltd +#define UHS_VID_HEISEI_ELECTRONICS 0x06deU // Heisei Electronics Co., Ltd +#define UHS_VID_MULTI_TECH_SYSTEMS 0x06e0U // Multi-Tech Systems, Inc. +#define UHS_VID_ADS_TECHNOLOGIES 0x06e1U // ADS Technologies, Inc. +#define UHS_VID_ALCATEL_MICROELECTRONICS 0x06e4U // Alcatel Microelectronics +#define UHS_VID_TIGER_JET_NETWORK 0x06e6U // Tiger Jet Network, Inc. +#define UHS_VID_SIRIUS_TECHNOLOGIES 0x06eaU // Sirius Technologies +#define UHS_VID_PC_EXPERT_TECH 0x06ebU // PC Expert Tech. Co., Ltd +#define UHS_VID_IAC_GEOMETRISCHE_INGENIEURS_BV 0x06efU // I.A.C. Geometrische Ingenieurs B.V. +#define UHS_VID_TNC_INDUSTRIAL 0x06f0U // T.N.C Industrial Co., Ltd +#define UHS_VID_OPCODE_SYSTEMS 0x06f1U // Opcode Systems, Inc. +#define UHS_VID_EMINE_TECHNOLOGY 0x06f2U // Emine Technology Co. +#define UHS_VID_WINTREND_TECHNOLOGY 0x06f6U // Wintrend Technology Co., Ltd +#define UHS_VID_WAILLY_TECHNOLOGY 0x06f7U // Wailly Technology Ltd +#define UHS_VID_GUILLEMOT 0x06f8U // Guillemot Corp. +#define UHS_VID_ASYST_ELECTRONIC_DOO 0x06f9U // ASYST electronic d.o.o. +#define UHS_VID_HSD_SRL 0x06faU // HSD S.r.L +#define UHS_VID_MOTOROLA_SEMICONDUCTOR_PRODUCTS_SECTOR 0x06fcU // Motorola Semiconductor Products Sector +#define UHS_VID_BOSTON_ACOUSTICS 0x06fdU // Boston Acoustics +#define UHS_VID_GALLANT_COMPUTER 0x06feU // Gallant Computer, Inc. +#define UHS_VID_SUPERCOMAL_WIRE_AND_CABLE_SDN_BHD 0x0701U // Supercomal Wire & Cable SDN. BHD. +#define UHS_VID_BVTECH_INDUSTRY 0x0703U // Bvtech Industry, Inc. +#define UHS_VID_NKK 0x0705U // NKK Corp. +#define UHS_VID_ARIEL 0x0706U // Ariel Corp. +#define UHS_VID_STANDARD_MICROSYSTEMS_2 0x0707U // Standard Microsystems Corp. +#define UHS_VID_PUTERCOM 0x0708U // Putercom Co., Ltd +#define UHS_VID_SILICON_SYSTEMS_LTD_SSL 0x0709U // Silicon Systems, Ltd (SSL) +#define UHS_VID_OKI_ELECTRIC_INDUSTRY 0x070aU // Oki Electric Industry Co., Ltd +#define UHS_VID_COMOSS_ELECTRONIC 0x070dU // Comoss Electronic Co., Ltd +#define UHS_VID_EXCEL_CELL_ELECTRONIC 0x070eU // Excel Cell Electronic Co., Ltd +#define UHS_VID_CONNECT_TECH 0x0710U // Connect Tech, Inc. +#define UHS_VID_MAGIC_CONTROL_TECHNOLOGY 0x0711U // Magic Control Technology Corp. +#define UHS_VID_INTERVAL_RESEARCH 0x0713U // Interval Research Corp. +#define UHS_VID_NEWMOTION 0x0714U // NewMotion, Inc. +#define UHS_VID_ZNK 0x0717U // ZNK Corp. +#define UHS_VID_IMATION 0x0718U // Imation Corp. +#define UHS_VID_TREMON_ENTERPRISES 0x0719U // Tremon Enterprises Co., Ltd +#define UHS_VID_DOMAIN_TECHNOLOGIES 0x071bU // Domain Technologies, Inc. +#define UHS_VID_XIONICS_DOCUMENT_TECHNOLOGIES 0x071cU // Xionics Document Technologies, Inc. +#define UHS_VID_EICON_NETWORKS 0x071dU // Eicon Networks Corp. +#define UHS_VID_ARISTON_TECHNOLOGIES 0x071eU // Ariston Technologies +#define UHS_VID_CENTILLIUM_COMMUNICATIONS 0x0723U // Centillium Communications Corp. +#define UHS_VID_VANGUARD_INTERNATIONAL_SEMICONDUCTOR_AMERICA 0x0726U // Vanguard International Semiconductor-America +#define UHS_VID_AMITM 0x0729U // Amitm +#define UHS_VID_SUNIX 0x072eU // Sunix Co., Ltd +#define UHS_VID_ADVANCED_CARD_SYSTEMS 0x072fU // Advanced Card Systems, Ltd +#define UHS_VID_SUSTEEN 0x0731U // Susteen, Inc. +#define UHS_VID_GOLDFULL_ELECTRONICS_AND_TELECOMMUNICATIONS 0x0732U // Goldfull Electronics & Telecommunications Corp. +#define UHS_VID_VIEWQUEST_TECHNOLOGIES 0x0733U // ViewQuest Technologies, Inc. +#define UHS_VID_LASAT_COMMUNICATIONS_AS 0x0734U // Lasat Communications A/S +#define UHS_VID_ASUSCOM_NETWORK 0x0735U // Asuscom Network +#define UHS_VID_LOROM_INDUSTRIAL 0x0736U // Lorom Industrial Co., Ltd +#define UHS_VID_MAD_CATZ 0x0738U // Mad Catz, Inc. +#define UHS_VID_CHAPLET_SYSTEMS 0x073aU // Chaplet Systems, Inc. +#define UHS_VID_SUNCOM_TECHNOLOGIES 0x073bU // Suncom Technologies +#define UHS_VID_INDUSTRIAL_ELECTRONIC_ENGINEERS 0x073cU // Industrial Electronic Engineers, Inc. +#define UHS_VID_EUTRON_SPA 0x073dU // Eutron S.p.a. +#define UHS_VID_NEC_1 0x073eU // NEC, Inc. +#define UHS_VID_STOLLMANN 0x0742U // Stollmann +#define UHS_VID_SYNTECH_INFORMATION 0x0745U // Syntech Information Co., Ltd +#define UHS_VID_ONKYO 0x0746U // Onkyo Corp. +#define UHS_VID_LABWAY 0x0747U // Labway Corp. +#define UHS_VID_STRONG_MAN_ENTERPRISE 0x0748U // Strong Man Enterprise Co., Ltd +#define UHS_VID_EVER_ELECTRONICS 0x0749U // EVer Electronics Corp. +#define UHS_VID_MING_FORTUNE_INDUSTRY 0x074aU // Ming Fortune Industry Co., Ltd +#define UHS_VID_POLESTAR_TECH 0x074bU // Polestar Tech. Corp. +#define UHS_VID_C_C_C_GROUP_PLC 0x074cU // C-C-C Group PLC +#define UHS_VID_MICRONAS 0x074dU // Micronas GmbH +#define UHS_VID_DIGITAL_STREAM 0x074eU // Digital Stream Corp. +#define UHS_VID_AUREAL_SEMICONDUCTOR 0x0755U // Aureal Semiconductor +#define UHS_VID_NETWORK_TECHNOLOGIES 0x0757U // Network Technologies, Inc. +#define UHS_VID_SOPHISTICATED_CIRCUITS 0x075bU // Sophisticated Circuits, Inc. +#define UHS_VID_MIDIMAN 0x0763U // Midiman +#define UHS_VID_CYBER_POWER_SYSTEM 0x0764U // Cyber Power System, Inc. +#define UHS_VID_X_RITE 0x0765U // X-Rite, Inc. +#define UHS_VID_JESS_LINK_PRODUCTS 0x0766U // Jess-Link Products Co., Ltd +#define UHS_VID_TOKHEIM 0x0767U // Tokheim Corp. +#define UHS_VID_CAMTEL_TECHNOLOGY 0x0768U // Camtel Technology Corp. +#define UHS_VID_SURECOM_TECHNOLOGY 0x0769U // Surecom Technology Corp. +#define UHS_VID_SMART_TECHNOLOGY_ENABLERS 0x076aU // Smart Technology Enablers, Inc. +#define UHS_VID_OMNIKEY_AG 0x076bU // OmniKey AG +#define UHS_VID_PARTNER_TECH 0x076cU // Partner Tech +#define UHS_VID_DENSO 0x076dU // Denso Corp. +#define UHS_VID_KUAN_TECH_ENTERPRISE 0x076eU // Kuan Tech Enterprise Co., Ltd +#define UHS_VID_JHEN_VEI_ELECTRONIC 0x076fU // Jhen Vei Electronic Co., Ltd +#define UHS_VID_WELCH_ALLYN_INC__MEDICAL_DIVISION 0x0770U // Welch Allyn, Inc - Medical Division +#define UHS_VID_OBSERVATOR_INSTRUMENTS_BV 0x0771U // Observator Instruments BV +#define UHS_VID_YOUR_DATA_OUR_CARE 0x0772U // Your data Our Care +#define UHS_VID_AMTRAN_TECHNOLOGY 0x0774U // AmTRAN Technology Co., Ltd +#define UHS_VID_LONGSHINE_ELECTRONICS 0x0775U // Longshine Electronics Corp. +#define UHS_VID_INALWAYS 0x0776U // Inalways Corp. +#define UHS_VID_COMDA_ENTERPRISE 0x0777U // Comda Enterprise Corp. +#define UHS_VID_VOLEX 0x0778U // Volex, Inc. +#define UHS_VID_FAIRCHILD_SEMICONDUCTOR 0x0779U // Fairchild Semiconductor +#define UHS_VID_SANKYO_SEIKI_MFG 0x077aU // Sankyo Seiki Mfg. Co., Ltd +#define UHS_VID_LINKSYS_1 0x077bU // Linksys +#define UHS_VID_FORWARD_ELECTRONICS 0x077cU // Forward Electronics Co., Ltd +#define UHS_VID_GRIFFIN_TECHNOLOGY 0x077dU // Griffin Technology +#define UHS_VID_WELL_EXCELLENT_AND_MOST 0x077fU // Well Excellent & Most Corp. +#define UHS_VID_SAGEM_MONETEL 0x0780U // Sagem Monetel GmbH +#define UHS_VID_SANDISK 0x0781U // SanDisk Corp. +#define UHS_VID_TRACKERBALL 0x0782U // Trackerball +#define UHS_VID_C3PO 0x0783U // C3PO +#define UHS_VID_VIVITAR 0x0784U // Vivitar, Inc. +#define UHS_VID_NTT_ME 0x0785U // NTT-ME +#define UHS_VID_LOGITEC 0x0789U // Logitec Corp. +#define UHS_VID_HAPP_CONTROLS 0x078bU // Happ Controls, Inc. +#define UHS_VID_GTCOCALCOMP 0x078cU // GTCO/CalComp +#define UHS_VID_BRINCOM 0x078eU // Brincom, Inc. +#define UHS_VID_PRO_IMAGE_MANUFACTURING 0x0790U // Pro-Image Manufacturing Co., Ltd +#define UHS_VID_COPARTNER_WIRE_AND_CABLE_MFG 0x0791U // Copartner Wire and Cable Mfg. Corp. +#define UHS_VID_AXIS_COMMUNICATIONS 0x0792U // Axis Communications AB +#define UHS_VID_WHA_YU_INDUSTRIAL 0x0793U // Wha Yu Industrial Co., Ltd +#define UHS_VID_ABL_ELECTRONICS 0x0794U // ABL Electronics Corp. +#define UHS_VID_REALCHIP 0x0795U // RealChip, Inc. +#define UHS_VID_CERTICOM 0x0796U // Certicom Corp. +#define UHS_VID_GRANDTECH_SEMICONDUCTOR 0x0797U // Grandtech Semiconductor Corp. +#define UHS_VID_OPTELEC 0x0798U // Optelec +#define UHS_VID_ALTERA 0x0799U // Altera +#define UHS_VID_SAGEM 0x079bU // Sagem +#define UHS_VID_ALFADATA_COMPUTER 0x079dU // Alfadata Computer Corp. +#define UHS_VID_DIGICOM_SPA 0x07a1U // Digicom S.p.A. +#define UHS_VID_NATIONAL_TECHNICAL_SYSTEMS 0x07a2U // National Technical Systems +#define UHS_VID_ONNTO 0x07a3U // Onnto Corp. +#define UHS_VID_BE 0x07a4U // Be, Inc. +#define UHS_VID_ADMTEK 0x07a6U // ADMtek, Inc. +#define UHS_VID_COREGA_KK 0x07aaU // Corega K.K. +#define UHS_VID_FREECOM_TECHNOLOGIES 0x07abU // Freecom Technologies +#define UHS_VID_MICROTECH 0x07afU // Microtech +#define UHS_VID_TRUST_TECHNOLOGIES 0x07b0U // Trust Technologies +#define UHS_VID_IMP 0x07b1U // IMP, Inc. +#define UHS_VID_MOTOROLA_BCS 0x07b2U // Motorola BCS, Inc. +#define UHS_VID_PLUSTEK 0x07b3U // Plustek, Inc. +#define UHS_VID_OLYMPUS_OPTICAL 0x07b4U // Olympus Optical Co., Ltd +#define UHS_VID_MEGA_WORLD_INTERNATIONAL 0x07b5U // Mega World International, Ltd +#define UHS_VID_MARUBUN 0x07b6U // Marubun Corp. +#define UHS_VID_TIME_INTERCONNECT 0x07b7U // TIME Interconnect, Ltd +#define UHS_VID_ABOCOM_SYSTEMS 0x07b8U // AboCom Systems Inc +#define UHS_VID_CANON_COMPUTER_SYSTEMS 0x07bcU // Canon Computer Systems, Inc. +#define UHS_VID_WEBGEAR 0x07bdU // Webgear, Inc. +#define UHS_VID_VERIDICOM 0x07beU // Veridicom +#define UHS_VID_CODE_MERCENARIES_HARD_UND_SOFTWARE 0x07c0U // Code Mercenaries Hard- und Software GmbH +#define UHS_VID_KEISOKUGIKEN 0x07c1U // Keisokugiken +#define UHS_VID_DATAFAB_SYSTEMS 0x07c4U // Datafab Systems, Inc. +#define UHS_VID_APG_CASH_DRAWER 0x07c5U // APG Cash Drawer +#define UHS_VID_SHAREWAVE 0x07c6U // ShareWave, Inc. +#define UHS_VID_POWERTECH_INDUSTRIAL 0x07c7U // Powertech Industrial Co., Ltd +#define UHS_VID_BUG 0x07c8U // B.U.G., Inc. +#define UHS_VID_ALLIED_TELESYN_INTERNATIONAL 0x07c9U // Allied Telesyn International +#define UHS_VID_AVERMEDIA_TECHNOLOGIES 0x07caU // AVerMedia Technologies, Inc. +#define UHS_VID_KINGMAX_TECHNOLOGY 0x07cbU // Kingmax Technology, Inc. +#define UHS_VID_CARRY_COMPUTER_ENG 0x07ccU // Carry Computer Eng., Co., Ltd +#define UHS_VID_ELEKTOR 0x07cdU // Elektor +#define UHS_VID_CASIO_COMPUTER 0x07cfU // Casio Computer Co., Ltd +#define UHS_VID_DAZZLE 0x07d0U // Dazzle +#define UHS_VID_D_LINK_SYSTEM 0x07d1U // D-Link System +#define UHS_VID_APTIO_PRODUCTS 0x07d2U // Aptio Products, Inc. +#define UHS_VID_CYBERDATA 0x07d3U // Cyberdata Corp. +#define UHS_VID_RADIANT_SYSTEMS 0x07d5U // Radiant Systems +#define UHS_VID_GCC_TECHNOLOGIES 0x07d7U // GCC Technologies, Inc. +#define UHS_VID_ARASAN_CHIP_SYSTEMS 0x07daU // Arasan Chip Systems +#define UHS_VID_DIAMOND_MULTIMEDIA 0x07deU // Diamond Multimedia +#define UHS_VID_DAVID_ELECTRONICS 0x07dfU // David Electronics Co., Ltd +#define UHS_VID_AMBIENT_TECHNOLOGIES 0x07e1U // Ambient Technologies, Inc. +#define UHS_VID_ELMEG_GMBH_AND 0x07e2U // Elmeg GmbH & Co., Ltd +#define UHS_VID_PLANEX_COMMUNICATIONS 0x07e3U // Planex Communications, Inc. +#define UHS_VID_MOVADO_ENTERPRISE 0x07e4U // Movado Enterprise Co., Ltd +#define UHS_VID_QPS 0x07e5U // QPS, Inc. +#define UHS_VID_ALLIED_CABLE 0x07e6U // Allied Cable Corp. +#define UHS_VID_MIRVO_TOYS 0x07e7U // Mirvo Toys, Inc. +#define UHS_VID_LABSYSTEMS 0x07e8U // Labsystems +#define UHS_VID_IWATSU_ELECTRIC 0x07eaU // Iwatsu Electric Co., Ltd +#define UHS_VID_DOUBLE_H_TECHNOLOGY 0x07ebU // Double-H Technology Co., Ltd +#define UHS_VID_TAIYO_ELECTRIC_WIRE_AND_CABLE 0x07ecU // Taiyo Electric Wire & Cable Co., Ltd +#define UHS_VID_TOREX_RETAIL_FORMERLY_LOGWARE 0x07eeU // Torex Retail (formerly Logware) +#define UHS_VID_STSN 0x07efU // STSN +#define UHS_VID_MICROCOMPUTER_APPLICATIONS 0x07f2U // Microcomputer Applications, Inc. +#define UHS_VID_CIRCUIT_ASSEMBLY 0x07f6U // Circuit Assembly Corp. +#define UHS_VID_CENTURY 0x07f7U // Century Corp. +#define UHS_VID_DOTOP_TECHNOLOGY 0x07f9U // Dotop Technology, Inc. +#define UHS_VID_DRAYTEK_1 0x07faU // DrayTek Corp. +#define UHS_VID_MARK_OF_THE_UNICORN 0x07fdU // Mark of the Unicorn +#define UHS_VID_UNKNOWN_2 0x07ffU // Unknown +#define UHS_VID_MAGTEK 0x0801U // MagTek +#define UHS_VID_MAKO_TECHNOLOGIES 0x0802U // Mako Technologies, LLC +#define UHS_VID_ZOOM_TELEPHONICS 0x0803U // Zoom Telephonics, Inc. +#define UHS_VID_GENICOM_TECHNOLOGY 0x0809U // Genicom Technology, Inc. +#define UHS_VID_EVERMUCH_TECHNOLOGY 0x080aU // Evermuch Technology Co., Ltd +#define UHS_VID_CROSS_MATCH_TECHNOLOGIES 0x080bU // Cross Match Technologies +#define UHS_VID_DATALOGIC_SPA 0x080cU // Datalogic S.p.A. +#define UHS_VID_TECO_IMAGE_SYSTEMS 0x080dU // Teco Image Systems Co., Ltd +#define UHS_VID_PERSONAL_COMMUNICATION_SYSTEMS 0x0810U // Personal Communication Systems, Inc. +#define UHS_VID_MATTEL 0x0813U // Mattel, Inc. +#define UHS_VID_ELICENSER 0x0819U // eLicenser +#define UHS_VID_MG_LOGIC 0x081aU // MG Logic +#define UHS_VID_INDIGITA 0x081bU // Indigita Corp. +#define UHS_VID_MIPSYS 0x081cU // Mipsys +#define UHS_VID_ALPHASMART 0x081eU // AlphaSmart, Inc. +#define UHS_VID_REUDO 0x0822U // Reudo Corp. +#define UHS_VID_GC_PROTRONICS 0x0825U // GC Protronics +#define UHS_VID_DATA_TRANSIT 0x0826U // Data Transit +#define UHS_VID_BROADLOGIC 0x0827U // BroadLogic, Inc. +#define UHS_VID_SATO 0x0828U // Sato Corp. +#define UHS_VID_DIRECTV_BROADBAND_INC_TELOCITY 0x0829U // DirecTV Broadband, Inc. (Telocity) +#define UHS_VID_HANDSPRING 0x082dU // Handspring +#define UHS_VID_PALM 0x0830U // Palm, Inc. +#define UHS_VID_KOUWELL_ELECTRONICS 0x0832U // Kouwell Electronics Corp. +#define UHS_VID_SOURCENEXT 0x0833U // Sourcenext Corp. +#define UHS_VID_ACTION_STAR_ENTERPRISE 0x0835U // Action Star Enterprise Co., Ltd +#define UHS_VID_TREKSTOR 0x0836U // TrekStor +#define UHS_VID_SAMSUNG_TECHWIN 0x0839U // Samsung Techwin Co., Ltd +#define UHS_VID_ACCTON_TECHNOLOGY 0x083aU // Accton Technology Corp. +#define UHS_VID_GLOBAL_VILLAGE 0x083fU // Global Village +#define UHS_VID_ARGOSY_RESEARCH 0x0840U // Argosy Research, Inc. +#define UHS_VID_RIOPORTCOM 0x0841U // Rioport.com, Inc. +#define UHS_VID_WELLAND_INDUSTRIAL 0x0844U // Welland Industrial Co., Ltd +#define UHS_VID_NETGEAR 0x0846U // NetGear, Inc. +#define UHS_VID_MINTON_OPTIC_INDUSTRY 0x084dU // Minton Optic Industry Co., Inc. +#define UHS_VID_KB_GEAR 0x084eU // KB Gear +#define UHS_VID_EMPEG 0x084fU // Empeg +#define UHS_VID_FAST_POINT_TECHNOLOGIES 0x0850U // Fast Point Technologies, Inc. +#define UHS_VID_MACRONIX_INTERNATIONAL 0x0851U // Macronix International Co., Ltd +#define UHS_VID_CSEM 0x0852U // CSEM +#define UHS_VID_TOPRE_CORPORATION 0x0853U // Topre Corporation +#define UHS_VID_ACTIVEWIRE 0x0854U // ActiveWire, Inc. +#define UHS_VID_BANDB_ELECTRONICS 0x0856U // B&B Electronics +#define UHS_VID_HITACHI_MAXELL 0x0858U // Hitachi Maxell, Ltd +#define UHS_VID_MINOLTA_SYSTEMS_LABORATORY 0x0859U // Minolta Systems Laboratory, Inc. +#define UHS_VID_XIRCOM 0x085aU // Xircom +#define UHS_VID_COLORVISION 0x085cU // ColorVision, Inc. +#define UHS_VID_TELETROL_SYSTEMS 0x0862U // Teletrol Systems, Inc. +#define UHS_VID_FILANET 0x0863U // Filanet Corp. +#define UHS_VID_NETGEAR_1 0x0864U // NetGear, Inc. +#define UHS_VID_DATA_TRANSLATION 0x0867U // Data Translation, Inc. +#define UHS_VID_EMAGIC_SOFT_UND_HARDWARE 0x086aU // Emagic Soft- und Hardware GmbH +#define UHS_VID_DETEWE__DEUTSCHE_TELEPHONWERKE_AG_AND 0x086cU // DeTeWe - Deutsche Telephonwerke AG & Co. +#define UHS_VID_SYSTEM_TALKS 0x086eU // System TALKS, Inc. +#define UHS_VID_MEC_IMEX 0x086fU // MEC IMEX, Inc. +#define UHS_VID_METRICOM 0x0870U // Metricom +#define UHS_VID_SANDISK_1 0x0871U // SanDisk, Inc. +#define UHS_VID_XPEED 0x0873U // Xpeed, Inc. +#define UHS_VID_A_TEC_SUBSYSTEM 0x0874U // A-Tec Subsystem, Inc. +#define UHS_VID_COMTROL 0x0879U // Comtrol Corp. +#define UHS_VID_ADESSOKBTEK_AMERICA 0x087cU // Adesso/Kbtek America, Inc. +#define UHS_VID_JATON 0x087dU // Jaton Corp. +#define UHS_VID_FUJITSU_COMPUTER_PRODUCTS_OF_AMERICA 0x087eU // Fujitsu Computer Products of America +#define UHS_VID_QUALCORE_LOGIC 0x087fU // QualCore Logic Inc. +#define UHS_VID_APT_TECHNOLOGIES 0x0880U // APT Technologies, Inc. +#define UHS_VID_RECORDING_INDUSTRY_ASSOCIATION_OF_AMERICA_RIAA 0x0883U // Recording Industry Association of America (RIAA) +#define UHS_VID_BOCA_RESEARCH 0x0885U // Boca Research, Inc. +#define UHS_VID_XAC_AUTOMATION 0x0886U // XAC Automation Corp. +#define UHS_VID_HANNSTAR_ELECTRONICS 0x0887U // Hannstar Electronics Corp. +#define UHS_VID_TECHTOOLS 0x088aU // TechTools +#define UHS_VID_MASSWORKS 0x088bU // MassWorks, Inc. +#define UHS_VID_SWECOIN 0x088cU // Swecoin AB +#define UHS_VID_ILOK 0x088eU // iLok +#define UHS_VID_DIOGRAPHY 0x0892U // DioGraphy, Inc. +#define UHS_VID_TSI_INCORPORATED 0x0894U // TSI Incorporated +#define UHS_VID_LAUTERBACH 0x0897U // Lauterbach +#define UHS_VID_UNITED_TECHNOLOGIES_RESEARCH_CNTR 0x089cU // United Technologies Research Cntr. +#define UHS_VID_ICRON_TECHNOLOGIES 0x089dU // Icron Technologies Corp. +#define UHS_VID_NST 0x089eU // NST Co., Ltd +#define UHS_VID_PRIMEX_AEROSPACE 0x089fU // Primex Aerospace Co. +#define UHS_VID_E9 0x08a5U // e9, Inc. +#define UHS_VID_TOSHIBA_TEC 0x08a6U // Toshiba TEC +#define UHS_VID_ANDREA_ELECTRONICS 0x08a8U // Andrea Electronics +#define UHS_VID_CWAV 0x08a9U // CWAV Inc. +#define UHS_VID_MACRAIGOR_SYSTEMS 0x08acU // Macraigor Systems LLC +#define UHS_VID_MACALLY_MACE_GROUP 0x08aeU // Macally (Mace Group, Inc.) +#define UHS_VID_METROHM 0x08b0U // Metrohm +#define UHS_VID_SORENSON_VISION 0x08b4U // Sorenson Vision, Inc. +#define UHS_VID_NATSU 0x08b7U // NATSU +#define UHS_VID_J_GORDON_ELECTRONIC_DESIGN 0x08b8U // J. Gordon Electronic Design, Inc. +#define UHS_VID_RADIOSHACK_CORP_TANDY 0x08b9U // RadioShack Corp. (Tandy) +#define UHS_VID_TEXAS_INSTRUMENTS_1 0x08bbU // Texas Instruments +#define UHS_VID_CITIZEN_WATCH 0x08bdU // Citizen Watch Co., Ltd +#define UHS_VID_PRECISE_BIOMETRICS 0x08c3U // Precise Biometrics +#define UHS_VID_PROXIM 0x08c4U // Proxim, Inc. +#define UHS_VID_KEY_NICE_ENTERPRISE 0x08c7U // Key Nice Enterprise Co., Ltd +#define UHS_VID_2WIRE 0x08c8U // 2Wire, Inc. +#define UHS_VID_NIPPON_TELEGRAPH_AND_TELEPHONE 0x08c9U // Nippon Telegraph and Telephone Corp. +#define UHS_VID_AIPTEK_INTERNATIONAL 0x08caU // Aiptek International, Inc. +#define UHS_VID_JUE_HSUN_IND 0x08cdU // Jue Hsun Ind. Corp. +#define UHS_VID_LONG_WELL_ELECTRONICS 0x08ceU // Long Well Electronics Corp. +#define UHS_VID_PRODUCTIVITY_ENHANCEMENT_PRODUCTS 0x08cfU // Productivity Enhancement Products +#define UHS_VID_SMARTBRIDGES 0x08d1U // smartBridges, Inc. +#define UHS_VID_VIRTUAL_INK 0x08d3U // Virtual Ink +#define UHS_VID_FUJITSU_SIEMENS_COMPUTERS 0x08d4U // Fujitsu Siemens Computers +#define UHS_VID_IXXAT_AUTOMATION 0x08d8U // IXXAT Automation GmbH +#define UHS_VID_INCREMENT_P 0x08d9U // Increment P Corp. +#define UHS_VID_BILLIONTON_SYSTEMS 0x08ddU // Billionton Systems, Inc. +#define UHS_VID__UNKNOWN 0x08deU // ? +#define UHS_VID_SPYRUS 0x08dfU // Spyrus, Inc. +#define UHS_VID_OLITEC 0x08e3U // Olitec, Inc. +#define UHS_VID_PIONEER 0x08e4U // Pioneer Corp. +#define UHS_VID_LITRONIC 0x08e5U // Litronic +#define UHS_VID_GEMALTO_WAS_GEMPLUS 0x08e6U // Gemalto (was Gemplus) +#define UHS_VID_PAN_INTERNATIONAL_WIRE_AND_CABLE 0x08e7U // Pan-International Wire & Cable +#define UHS_VID_INTEGRATED_MEMORY_LOGIC 0x08e8U // Integrated Memory Logic +#define UHS_VID_EXTENDED_SYSTEMS 0x08e9U // Extended Systems, Inc. +#define UHS_VID_ERICSSON_INC_BLUE_RIDGE_LABS 0x08eaU // Ericsson, Inc., Blue Ridge Labs +#define UHS_VID_M_SYSTEMS_FLASH_DISK_PIONEERS 0x08ecU // M-Systems Flash Disk Pioneers +#define UHS_VID_MEDIATEK 0x08edU // MediaTek Inc. +#define UHS_VID_CCSIHESSO 0x08eeU // CCSI/Hesso +#define UHS_VID_COREX_TECHNOLOGIES 0x08f0U // Corex Technologies +#define UHS_VID_CTI_ELECTRONICS 0x08f1U // CTI Electronics Corp. +#define UHS_VID_GOTOP_INFORMATION 0x08f2U // Gotop Information Inc. +#define UHS_VID_SYSTEC 0x08f5U // SysTec Co., Ltd +#define UHS_VID_LOGIC_3_INTERNATIONAL 0x08f6U // Logic 3 International, Ltd +#define UHS_VID_VERNIER 0x08f7U // Vernier +#define UHS_VID_KEEN_TOP_INTERNATIONAL_ENTERPRISE 0x08f8U // Keen Top International Enterprise Co., Ltd +#define UHS_VID_WIPRO_TECHNOLOGIES 0x08f9U // Wipro Technologies +#define UHS_VID_CAERE 0x08faU // Caere +#define UHS_VID_SOCKET_COMMUNICATIONS 0x08fbU // Socket Communications +#define UHS_VID_SICON_CABLE_TECHNOLOGY 0x08fcU // Sicon Cable Technology Co., Ltd +#define UHS_VID_DIGIANSWER_AS 0x08fdU // Digianswer A/S +#define UHS_VID_AUTHENTEC 0x08ffU // AuthenTec, Inc. +#define UHS_VID_PINNACLE_SYSTEMS 0x0900U // Pinnacle Systems, Inc. +#define UHS_VID_VST_TECHNOLOGIES 0x0901U // VST Technologies +#define UHS_VID_FARADAY_TECHNOLOGY 0x0906U // Faraday Technology Corp. +#define UHS_VID_SIEMENS_AG 0x0908U // Siemens AG +#define UHS_VID_AUDIO_TECHNICA 0x0909U // Audio-Technica Corp. +#define UHS_VID_TRUMPION_MICROELECTRONICS 0x090aU // Trumpion Microelectronics, Inc. +#define UHS_VID_NEUROSMITH 0x090bU // Neurosmith +#define UHS_VID_SILICON_MOTION_INC__TAIWAN_FORMERLY_FEIYA_TECHNOLOGY 0x090cU // Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) +#define UHS_VID_MULTIPORT_COMPUTER_VERTRIEBS 0x090dU // Multiport Computer Vertriebs GmbH +#define UHS_VID_SHINING_TECHNOLOGY 0x090eU // Shining Technology, Inc. +#define UHS_VID_FUJITSU_DEVICES 0x090fU // Fujitsu Devices, Inc. +#define UHS_VID_ALATION_SYSTEMS 0x0910U // Alation Systems, Inc. +#define UHS_VID_PHILIPS_SPEECH_PROCESSING 0x0911U // Philips Speech Processing +#define UHS_VID_VOQUETTE 0x0912U // Voquette, Inc. +#define UHS_VID_GLOBESPAN 0x0915U // GlobeSpan, Inc. +#define UHS_VID_SMARTDISK 0x0917U // SmartDisk Corp. +#define UHS_VID_TIGER_ELECTRONICS 0x0919U // Tiger Electronics +#define UHS_VID_GARMIN_INTERNATIONAL 0x091eU // Garmin International +#define UHS_VID_ECHELON 0x0920U // Echelon Co. +#define UHS_VID_GOHUBS 0x0921U // GoHubs, Inc. +#define UHS_VID_DYMO_COSTAR 0x0922U // Dymo-CoStar Corp. +#define UHS_VID_IC_MEDIA 0x0923U // IC Media Corp. +#define UHS_VID_XEROX 0x0924U // Xerox +#define UHS_VID_LAKEVIEW_RESEARCH 0x0925U // Lakeview Research +#define UHS_VID_SUMMUS 0x0927U // Summus, Ltd +#define UHS_VID_PLX_TECHNOLOGY_INC_FORMERLY_OXFORD_SEMICONDUCTOR 0x0928U // PLX Technology, Inc. (formerly Oxford Semiconductor, Ltd) +#define UHS_VID_AMERICAN_BIOMETRIC 0x0929U // American Biometric Co. +#define UHS_VID_TOSHIBA_INFORMATION_AND_INDUSTRIAL_SYS_AND_SERVICES 0x092aU // Toshiba Information & Industrial Sys. And Services +#define UHS_VID_SENA_TECHNOLOGIES 0x092bU // Sena Technologies, Inc. +#define UHS_VID_NORTHERN_EMBEDDED_SCIENCECAVNEX 0x092fU // Northern Embedded Science/CAVNEX +#define UHS_VID_TOSHIBA_1 0x0930U // Toshiba Corp. +#define UHS_VID_HARMONIC_DATA_SYSTEMS 0x0931U // Harmonic Data Systems, Ltd +#define UHS_VID_CRESCENTEC 0x0932U // Crescentec Corp. +#define UHS_VID_QUANTUM 0x0933U // Quantum Corp. +#define UHS_VID_SPIRENT_COMMUNICATIONS 0x0934U // Spirent Communications +#define UHS_VID_NUTESLA 0x0936U // NuTesla +#define UHS_VID_LUMBERG 0x0939U // Lumberg, Inc. +#define UHS_VID_PIXART_IMAGING 0x093aU // Pixart Imaging, Inc. +#define UHS_VID_PLEXTOR 0x093bU // Plextor Corp. +#define UHS_VID_INTREPID_CONTROL_SYSTEMS 0x093cU // Intrepid Control Systems, Inc. +#define UHS_VID_INNOSYNC 0x093dU // InnoSync, Inc. +#define UHS_VID_JST_MFG 0x093eU // J.S.T. Mfg. Co., Ltd +#define UHS_VID_OLYMPIA_TELECOM_VERTRIEBS 0x093fU // Olympia Telecom Vertriebs GmbH +#define UHS_VID_JAPAN_STORAGE_BATTERY 0x0940U // Japan Storage Battery Co., Ltd +#define UHS_VID_PHOTOBIT 0x0941U // Photobit Corp. +#define UHS_VID_I2GOCOM 0x0942U // i2Go.com, LLC +#define UHS_VID_HCL_TECHNOLOGIES_INDIA_PRIVATE 0x0943U // HCL Technologies India Private, Ltd +#define UHS_VID_KORG 0x0944U // KORG, Inc. +#define UHS_VID_PASCO_SCIENTIFIC 0x0945U // Pasco Scientific +#define UHS_VID_KRONAUER_MUSIC_IN_DIGITAL 0x0948U // Kronauer music in digital +#define UHS_VID_LINKUP_SYSTEMS 0x094bU // Linkup Systems Corp. +#define UHS_VID_CABLE_TELEVISION_LABORATORIES 0x094dU // Cable Television Laboratories +#define UHS_VID_YANO 0x094fU // Yano +#define UHS_VID_KINGSTON_TECHNOLOGY 0x0951U // Kingston Technology +#define UHS_VID_RPM_SYSTEMS 0x0954U // RPM Systems Corp. +#define UHS_VID_NVIDIA 0x0955U // NVidia Corp. +#define UHS_VID_BSQUARE 0x0956U // BSquare Corp. +#define UHS_VID_AGILENT_TECHNOLOGIES 0x0957U // Agilent Technologies, Inc. +#define UHS_VID_COMPULINK_RESEARCH 0x0958U // CompuLink Research, Inc. +#define UHS_VID_COLOGNE_CHIP_AG 0x0959U // Cologne Chip AG +#define UHS_VID_PORTSMITH 0x095aU // Portsmith +#define UHS_VID_MEDIALOGIC 0x095bU // Medialogic Corp. +#define UHS_VID_K_TEC_ELECTRONICS 0x095cU // K-Tec Electronics +#define UHS_VID_POLYCOM 0x095dU // Polycom, Inc. +#define UHS_VID_ACER_NEWEB 0x0967U // Acer NeWeb Corp. +#define UHS_VID_CATALYST_ENTERPRISES 0x0968U // Catalyst Enterprises, Inc. +#define UHS_VID_FEITIAN_TECHNOLOGIES 0x096eU // Feitian Technologies, Inc. +#define UHS_VID_GRETAG_MACBETH_AG 0x0971U // Gretag-Macbeth AG +#define UHS_VID_SCHLUMBERGER 0x0973U // Schlumberger +#define UHS_VID_DATAGRAPHIX_A_BUSINESS_UNIT_OF_ANACOMP 0x0974U // Datagraphix, a business unit of Anacomp +#define UHS_VID_OLE_COMMUNICATIONS 0x0975U // OL'E Communications, Inc. +#define UHS_VID_ADIRONDACK_WIRE_AND_CABLE 0x0976U // Adirondack Wire & Cable +#define UHS_VID_LIGHTSURF_TECHNOLOGIES 0x0977U // Lightsurf Technologies +#define UHS_VID_BECKHOFF 0x0978U // Beckhoff GmbH +#define UHS_VID_JEILIN_TECHNOLOGY 0x0979U // Jeilin Technology Corp., Ltd +#define UHS_VID_MINDS_AT_WORK 0x097aU // Minds At Work LLC +#define UHS_VID_KNUDSEN_ENGINEERING 0x097bU // Knudsen Engineering, Ltd +#define UHS_VID_MARUNIX 0x097cU // Marunix Co., Ltd +#define UHS_VID_ROSUN_TECHNOLOGIES 0x097dU // Rosun Technologies, Inc. +#define UHS_VID_BIOPAC_SYSTEMS 0x097eU // Biopac Systems Inc. +#define UHS_VID_BARUN_ELECTRONICS 0x097fU // Barun Electronics Co., Ltd +#define UHS_VID_OAK_TECHNOLOGY_1 0x0981U // Oak Technology, Ltd +#define UHS_VID_APRICORN 0x0984U // Apricorn +#define UHS_VID_CAB_PRODUKTTECHNIK_GMBH_AND_CO_KG 0x0985U // cab Produkttechnik GmbH & Co KG +#define UHS_VID_MATSUSHITA_ELECTRIC_WORKS 0x0986U // Matsushita Electric Works, Ltd. +#define UHS_VID_VITANA 0x098cU // Vitana Corp. +#define UHS_VID_INDESIGN 0x098dU // INDesign +#define UHS_VID_INTEGRATED_INTELLECTUAL_PROPERTY 0x098eU // Integrated Intellectual Property, Inc. +#define UHS_VID_KENWOOD_TMI 0x098fU // Kenwood TMI Corp. +#define UHS_VID_GEMSTAR_EBOOK_GROUP 0x0993U // Gemstar eBook Group, Ltd +#define UHS_VID_INTEGRATED_TELECOM_EXPRESS 0x0996U // Integrated Telecom Express, Inc. +#define UHS_VID_ZIPPY_TECHNOLOGY 0x099aU // Zippy Technology Corp. +#define UHS_VID_PAIRGAIN_TECHNOLOGIES 0x09a3U // PairGain Technologies +#define UHS_VID_CONTECH_RESEARCH 0x09a4U // Contech Research, Inc. +#define UHS_VID_VCON_TELECOMMUNICATIONS 0x09a5U // VCON Telecommunications +#define UHS_VID_POINCHIPS 0x09a6U // Poinchips +#define UHS_VID_DATA_TRANSMISSION_NETWORK 0x09a7U // Data Transmission Network Corp. +#define UHS_VID_LIN_SHIUNG_ENTERPRISE 0x09a8U // Lin Shiung Enterprise Co., Ltd +#define UHS_VID_SMART_CARD_TECHNOLOGIES 0x09a9U // Smart Card Technologies Co., Ltd +#define UHS_VID_INTERSIL 0x09aaU // Intersil Corp. +#define UHS_VID_JAPAN_CASH_MACHINE 0x09abU // Japan Cash Machine Co., Ltd. +#define UHS_VID_TRIPP_LITE 0x09aeU // Tripp Lite +#define UHS_VID_FRANKLIN_ELECTRONIC_PUBLISHERS 0x09b2U // Franklin Electronic Publishers, Inc. +#define UHS_VID_ALTIUS_SOLUTIONS 0x09b3U // Altius Solutions, Inc. +#define UHS_VID_MDS_TELEPHONE_SYSTEMS 0x09b4U // MDS Telephone Systems +#define UHS_VID_CELLTRIX_TECHNOLOGY 0x09b5U // Celltrix Technology Co., Ltd +#define UHS_VID_GRUNDIG 0x09bcU // Grundig +#define UHS_VID_MYSMARTCOM 0x09beU // MySmart.Com +#define UHS_VID_AUERSWALD_GMBH_AND_CO_KG 0x09bfU // Auerswald GmbH & Co. KG +#define UHS_VID_GENPIX_ELECTRONICS 0x09c0U // Genpix Electronics, LLC +#define UHS_VID_ARRIS_INTERACTIVE 0x09c1U // Arris Interactive LLC +#define UHS_VID_NISCA 0x09c2U // Nisca Corp. +#define UHS_VID_ACTIVCARD 0x09c3U // ActivCard, Inc. +#define UHS_VID_ACTISYS 0x09c4U // ACTiSYS Corp. +#define UHS_VID_MEMORY 0x09c5U // Memory Corp. +#define UHS_VID_BMC_MESSSYSTEME 0x09caU // BMC Messsysteme GmbH +#define UHS_VID_WORKBIT 0x09ccU // Workbit Corp. +#define UHS_VID_PSION_DACOM_HOME_NETWORKS 0x09cdU // Psion Dacom Home Networks, Ltd +#define UHS_VID_CITY_ELECTRONICS 0x09ceU // City Electronics, Ltd +#define UHS_VID_ELECTRONICS_TESTING_CENTER_TAIWAN 0x09cfU // Electronics Testing Center, Taiwan +#define UHS_VID_NEOMAGIC 0x09d1U // NeoMagic, Inc. +#define UHS_VID_VREELIN_ENGINEERING 0x09d2U // Vreelin Engineering, Inc. +#define UHS_VID_COM_ONE 0x09d3U // Com One +#define UHS_VID_NOVATEL_WIRELESS 0x09d7U // Novatel Wireless +#define UHS_VID_KRF_TECH 0x09d9U // KRF Tech, Ltd +#define UHS_VID_A4TECH 0x09daU // A4Tech Co., Ltd. +#define UHS_VID_MEASUREMENT_COMPUTING 0x09dbU // Measurement Computing Corp. +#define UHS_VID_AIMEX 0x09dcU // Aimex Corp. +#define UHS_VID_FELLOWES 0x09ddU // Fellowes, Inc. +#define UHS_VID_ADDONICS_TECHNOLOGIES 0x09dfU // Addonics Technologies Corp. +#define UHS_VID_INTELLON 0x09e1U // Intellon Corp. +#define UHS_VID_JO_DAN_INTERNATIONAL 0x09e5U // Jo-Dan International, Inc. +#define UHS_VID_SILUTIA 0x09e6U // Silutia, Inc. +#define UHS_VID_REAL_3D 0x09e7U // Real 3D, Inc. +#define UHS_VID_AKAI_PROFESSIONAL_MI 0x09e8U // AKAI Professional M.I. Corp. +#define UHS_VID_CHEN_SOURCE 0x09e9U // Chen-Source, Inc. +#define UHS_VID_IM_NETWORKS 0x09ebU // IM Networks, Inc. +#define UHS_VID_XITEL 0x09efU // Xitel +#define UHS_VID_GOFLIGHT 0x09f3U // GoFlight, Inc. +#define UHS_VID_ARESCOM 0x09f5U // AresCom +#define UHS_VID_ROCKETCHIPS 0x09f6U // RocketChips, Inc. +#define UHS_VID_EDU_SCIENCE_HK 0x09f7U // Edu-Science (H.K.), Ltd +#define UHS_VID_SOFTCONNEX_TECHNOLOGIES 0x09f8U // SoftConnex Technologies, Inc. +#define UHS_VID_BAY_ASSOCIATES 0x09f9U // Bay Associates +#define UHS_VID_MTEK_VISION 0x09faU // Mtek Vision +#define UHS_VID_ALTERA_1 0x09fbU // Altera +#define UHS_VID_GAIN_TECHNOLOGY 0x09ffU // Gain Technology Corp. +#define UHS_VID_LIQUID_AUDIO 0x0a00U // Liquid Audio +#define UHS_VID_VIA 0x0a01U // ViA, Inc. +#define UHS_VID_UNKNOWN_MANUFACTURER 0x0a05U // Unknown Manufacturer +#define UHS_VID_ONTRAK_CONTROL_SYSTEMS 0x0a07U // Ontrak Control Systems Inc. +#define UHS_VID_CYBEX_COMPUTER_PRODUCTS 0x0a0bU // Cybex Computer Products Co. +#define UHS_VID_SERVERGY 0x0a0dU // Servergy, Inc +#define UHS_VID_XENTEC 0x0a11U // Xentec, Inc. +#define UHS_VID_CAMBRIDGE_SILICON_RADIO 0x0a12U // Cambridge Silicon Radio, Ltd +#define UHS_VID_TELEBYTE 0x0a13U // Telebyte, Inc. +#define UHS_VID_SPACELABS_MEDICAL 0x0a14U // Spacelabs Medical, Inc. +#define UHS_VID_SCALAR 0x0a15U // Scalar Corp. +#define UHS_VID_TREK_TECHNOLOGY_S_PTE 0x0a16U // Trek Technology (S) PTE, Ltd +#define UHS_VID_PENTAX 0x0a17U // Pentax Corp. +#define UHS_VID_HEIDELBERGER_DRUCKMASCHINEN_AG 0x0a18U // Heidelberger Druckmaschinen AG +#define UHS_VID_HUA_GENG_TECHNOLOGIES 0x0a19U // Hua Geng Technologies, Inc. +#define UHS_VID_MEDTRONIC_PHYSIO_CONTROL 0x0a21U // Medtronic Physio Control Corp. +#define UHS_VID_CENTURY_SEMICONDUCTOR_USA 0x0a22U // Century Semiconductor USA, Inc. +#define UHS_VID_DATACARD_GROUP 0x0a27U // Datacard Group +#define UHS_VID_AK_MODUL_BUS_COMPUTER 0x0a2cU // AK-Modul-Bus Computer GmbH +#define UHS_VID_TG3_ELECTRONICS 0x0a34U // TG3 Electronics, Inc. +#define UHS_VID_RADIKAL_TECHNOLOGIES 0x0a35U // Radikal Technologies +#define UHS_VID_GILAT_SATELLITE_NETWORKS 0x0a39U // Gilat Satellite Networks, Ltd +#define UHS_VID_PENTAMEDIA 0x0a3aU // PentaMedia Co., Ltd +#define UHS_VID_NTT_DOCOMO 0x0a3cU // NTT DoCoMo, Inc. +#define UHS_VID_VARO_VISION 0x0a3dU // Varo Vision +#define UHS_VID_SWISSONIC_AG 0x0a3fU // Swissonic AG +#define UHS_VID_BOCA_SYSTEMS 0x0a43U // Boca Systems, Inc. +#define UHS_VID_DAVICOM_SEMICONDUCTOR 0x0a46U // Davicom Semiconductor, Inc. +#define UHS_VID_HIROSE_ELECTRIC 0x0a47U // Hirose Electric +#define UHS_VID_IO_INTERCONNECT 0x0a48U // I/O Interconnect +#define UHS_VID_PLOYTEC 0x0a4aU // Ploytec GmbH +#define UHS_VID_FUJITSU_MEDIA_DEVICES 0x0a4bU // Fujitsu Media Devices, Ltd +#define UHS_VID_COMPUTEX 0x0a4cU // Computex Co., Ltd +#define UHS_VID_EVOLUTION_ELECTRONICS 0x0a4dU // Evolution Electronics, Ltd +#define UHS_VID_STEINBERG_SOFT_UND_HARDWARE 0x0a4eU // Steinberg Soft-und Hardware GmbH +#define UHS_VID_LITTON_SYSTEMS 0x0a4fU // Litton Systems, Inc. +#define UHS_VID_MIMAKI_ENGINEERING 0x0a50U // Mimaki Engineering Co., Ltd +#define UHS_VID_SONY_ELECTRONICS 0x0a51U // Sony Electronics, Inc. +#define UHS_VID_JEBSEE_ELECTRONICS 0x0a52U // Jebsee Electronics Co., Ltd +#define UHS_VID_PORTABLE_PERIPHERAL 0x0a53U // Portable Peripheral Co., Ltd +#define UHS_VID_ELECTRONICS_FOR_IMAGING 0x0a5aU // Electronics For Imaging, Inc. +#define UHS_VID_EASICS_NV 0x0a5bU // EAsics NV +#define UHS_VID_BROADCOM 0x0a5cU // Broadcom Corp. +#define UHS_VID_DIATREND 0x0a5dU // Diatrend Corp. +#define UHS_VID_ZEBRA 0x0a5fU // Zebra +#define UHS_VID_MPMAN 0x0a62U // MPMan +#define UHS_VID_CLEARCUBE_TECHNOLOGY 0x0a66U // ClearCube Technology +#define UHS_VID_MEDELI_ELECTRONICS 0x0a67U // Medeli Electronics Co., Ltd +#define UHS_VID_COMAIDE 0x0a68U // Comaide Corp. +#define UHS_VID_CHROMA_ATE 0x0a69U // Chroma ate, Inc. +#define UHS_VID_GREEN_HOUSE 0x0a6bU // Green House Co., Ltd +#define UHS_VID_INTEGRATED_CIRCUIT_SYSTEMS 0x0a6cU // Integrated Circuit Systems, Inc. +#define UHS_VID_UPS_MANUFACTURING 0x0a6dU // UPS Manufacturing +#define UHS_VID_BENWIN 0x0a6eU // Benwin +#define UHS_VID_CORE_TECHNOLOGY 0x0a6fU // Core Technology, Inc. +#define UHS_VID_INTERNATIONAL_GAME_TECHNOLOGY 0x0a70U // International Game Technology +#define UHS_VID_VIPCOLOR_TECHNOLOGIES_USA 0x0a71U // VIPColor Technologies USA, Inc. +#define UHS_VID_SANWA_DENSHI 0x0a72U // Sanwa Denshi +#define UHS_VID_MACKIE_DESIGNS 0x0a73U // Mackie Designs +#define UHS_VID_NSTL 0x0a7dU // NSTL, Inc. +#define UHS_VID_OCTAGON_SYSTEMS 0x0a7eU // Octagon Systems Corp. +#define UHS_VID_REXON_TECHNOLOGY 0x0a80U // Rexon Technology Corp., Ltd +#define UHS_VID_CHESEN_ELECTRONICS 0x0a81U // Chesen Electronics Corp. +#define UHS_VID_SYSCAN 0x0a82U // Syscan +#define UHS_VID_NEXTCOMM 0x0a83U // NextComm, Inc. +#define UHS_VID_MAUI_INNOVATIVE_PERIPHERALS 0x0a84U // Maui Innovative Peripherals +#define UHS_VID_IDEXX_LABS 0x0a85U // Idexx Labs +#define UHS_VID_NITGEN 0x0a86U // NITGen Co., Ltd +#define UHS_VID_AKTIV 0x0a89U // Aktiv +#define UHS_VID_PICTURETEL 0x0a8dU // Picturetel +#define UHS_VID_JAPAN_AVIATION_ELECTRONICS_INDUSTRY 0x0a8eU // Japan Aviation Electronics Industry, Ltd +#define UHS_VID_CANDY_TECHNOLOGY 0x0a90U // Candy Technology Co., Ltd +#define UHS_VID_GLOBLINK_TECHNOLOGY 0x0a91U // Globlink Technology, Inc. +#define UHS_VID_EGO_SYSTEMS 0x0a92U // EGO SYStems, Inc. +#define UHS_VID_C_TECHNOLOGIES 0x0a93U // C Technologies AB +#define UHS_VID_INTERSENSE 0x0a94U // Intersense +#define UHS_VID_LAVA_COMPUTER_MFG 0x0aa3U // Lava Computer Mfg., Inc. +#define UHS_VID_DEVELCO_ELEKTRONIK 0x0aa4U // Develco Elektronik +#define UHS_VID_FIRST_INTERNATIONAL_DIGITAL 0x0aa5U // First International Digital +#define UHS_VID_PERCEPTION_DIGITAL 0x0aa6U // Perception Digital, Ltd +#define UHS_VID_WINCOR_NIXDORF_INTERNATIONAL 0x0aa7U // Wincor Nixdorf International GmbH +#define UHS_VID_TRIGEM_COMPUTER 0x0aa8U // TriGem Computer, Inc. +#define UHS_VID_BAROMTEC 0x0aa9U // Baromtec Co. +#define UHS_VID_JAPAN_CBM 0x0aaaU // Japan CBM Corp. +#define UHS_VID_VISION_SHAPE_EUROPE 0x0aabU // Vision Shape Europe SA +#define UHS_VID_ICOMPRESSION 0x0aacU // iCompression, Inc. +#define UHS_VID_ROHDE_AND_SCHWARZ_GMBH_AND_CO_KG 0x0aadU // Rohde & Schwarz GmbH & Co. KG +#define UHS_VID_NEC_INFRONTIA_CORP_NITSUKO 0x0aaeU // NEC infrontia Corp. (Nitsuko) +#define UHS_VID_DIGITALWAY 0x0aafU // Digitalway Co., Ltd +#define UHS_VID_ARROW_STRONG_ELECTRONICS 0x0ab0U // Arrow Strong Electronics Co., Ltd +#define UHS_VID_FEIG_ELECTRONIC 0x0ab1U // FEIG ELECTRONIC GmbH +#define UHS_VID_ELLISYS 0x0abaU // Ellisys +#define UHS_VID_STEREO_LINK 0x0abeU // Stereo-Link +#define UHS_VID_DIOLAN 0x0abfU // Diolan +#define UHS_VID_SANYO_SEMICONDUCTOR_COMPANY_MICRO 0x0ac3U // Sanyo Semiconductor Company Micro +#define UHS_VID_LECO 0x0ac4U // Leco Corp. +#define UHS_VID_I_AND_C 0x0ac5U // I & C Corp. +#define UHS_VID_SINGING_ELECTRONS 0x0ac6U // Singing Electrons, Inc. +#define UHS_VID_PANWEST 0x0ac7U // Panwest Corp. +#define UHS_VID_Z_STAR_MICROELECTRONICS 0x0ac8U // Z-Star Microelectronics Corp. +#define UHS_VID_MICRO_SOLUTIONS 0x0ac9U // Micro Solutions, Inc. +#define UHS_VID_OPEN_NETWORKS 0x0acaU // OPEN Networks Ltd +#define UHS_VID_KOGA_ELECTRONICS 0x0accU // Koga Electronics Co. +#define UHS_VID_ID_TECH 0x0acdU // ID Tech +#define UHS_VID_ZYDAS 0x0aceU // ZyDAS +#define UHS_VID_INTOTO 0x0acfU // Intoto, Inc. +#define UHS_VID_INTELLIX 0x0ad0U // Intellix Corp. +#define UHS_VID_REMOTEC_TECHNOLOGY 0x0ad1U // Remotec Technology, Ltd +#define UHS_VID_SERVICE_AND_QUALITY_TECHNOLOGY 0x0ad2U // Service & Quality Technology Co., Ltd +#define UHS_VID_DATA_ENCRYPTION_SYSTEMS 0x0adaU // Data Encryption Systems Ltd. +#define UHS_VID_ALLION_COMPUTER 0x0ae3U // Allion Computer, Inc. +#define UHS_VID_TAITO 0x0ae4U // Taito Corp. +#define UHS_VID_NEODYM_SYSTEMS 0x0ae7U // Neodym Systems, Inc. +#define UHS_VID_SYSTEM_SUPPORT 0x0ae8U // System Support Co., Ltd +#define UHS_VID_NORTH_SHORE_CIRCUIT_DESIGN_LLP 0x0ae9U // North Shore Circuit Design L.L.P. +#define UHS_VID_SCIESSENCE 0x0aeaU // SciEssence, LLC +#define UHS_VID_TTP_COMMUNICATIONS 0x0aebU // TTP Communications, Ltd +#define UHS_VID_NEODIO_TECHNOLOGIES 0x0aecU // Neodio Technologies Corp. +#define UHS_VID_OPTION 0x0af0U // Option +#define UHS_VID_SILVER_I 0x0af6U // Silver I Co., Ltd +#define UHS_VID_B2C2 0x0af7U // B2C2, Inc. +#define UHS_VID_HAMA 0x0af9U // Hama, Inc. +#define UHS_VID_DMC 0x0afaU // DMC Co., Ltd. +#define UHS_VID_ZAPTRONIX 0x0afcU // Zaptronix Ltd +#define UHS_VID_TATENO_DENNOU 0x0afdU // Tateno Dennou, Inc. +#define UHS_VID_CUMMINS_ENGINE 0x0afeU // Cummins Engine Co. +#define UHS_VID_JUMP_ZONE_NETWORK_PRODUCTS 0x0affU // Jump Zone Network Products, Inc. +#define UHS_VID_INGENICO 0x0b00U // INGENICO +#define UHS_VID_ASUSTEK_COMPUTER 0x0b05U // ASUSTek Computer, Inc. +#define UHS_VID_DATAMAX_ONEIL 0x0b0bU // Datamax-O'Neil +#define UHS_VID_TODOS 0x0b0cU // Todos AB +#define UHS_VID_PROJECTLAB 0x0b0dU // ProjectLab +#define UHS_VID_GN_NETCOM 0x0b0eU // GN Netcom +#define UHS_VID_AVID_TECHNOLOGY 0x0b0fU // AVID Technology +#define UHS_VID_PCALLY 0x0b10U // Pcally +#define UHS_VID_I_TECH_SOLUTIONS 0x0b11U // I Tech Solutions Co., Ltd +#define UHS_VID_ELECTRONIC_WARFARE_ASSOC_INC_EWA 0x0b1eU // Electronic Warfare Assoc., Inc. (EWA) +#define UHS_VID_INSYDE_SOFTWARE 0x0b1fU // Insyde Software Corp. +#define UHS_VID_TRANSDIMENSION 0x0b20U // TransDimension, Inc. +#define UHS_VID_YOKOGAWA_ELECTRIC 0x0b21U // Yokogawa Electric Corp. +#define UHS_VID_JAPAN_SYSTEM_DEVELOPMENT 0x0b22U // Japan System Development Co., Ltd +#define UHS_VID_PAN_ASIA_ELECTRONICS 0x0b23U // Pan-Asia Electronics Co., Ltd +#define UHS_VID_LINK_EVOLUTION 0x0b24U // Link Evolution Corp. +#define UHS_VID_RITEK 0x0b27U // Ritek Corp. +#define UHS_VID_KENWOOD 0x0b28U // Kenwood Corp. +#define UHS_VID_VILLAGE_CENTER 0x0b2cU // Village Center, Inc. +#define UHS_VID_PNY_TECHNOLOGIES 0x0b30U // PNY Technologies, Inc. +#define UHS_VID_CONTOUR_DESIGN 0x0b33U // Contour Design, Inc. +#define UHS_VID_HITACHI_ULSI_SYSTEMS 0x0b37U // Hitachi ULSI Systems Co., Ltd +#define UHS_VID_GEAR_HEAD 0x0b38U // Gear Head +#define UHS_VID_OMNIDIRECTIONAL_CONTROL_TECHNOLOGY 0x0b39U // Omnidirectional Control Technology, Inc. +#define UHS_VID_IPAXESS 0x0b3aU // IPaxess +#define UHS_VID_TEKRAM_TECHNOLOGY 0x0b3bU // Tekram Technology Co., Ltd +#define UHS_VID_OLIVETTI_TECHCENTER 0x0b3cU // Olivetti Techcenter +#define UHS_VID_KIKUSUI_ELECTRONICS 0x0b3eU // Kikusui Electronics Corp. +#define UHS_VID_HAL 0x0b41U // Hal Corp. +#define UHS_VID_PLAYCOM 0x0b43U // Play.com, Inc. +#define UHS_VID_SPORTBUGCOM 0x0b47U // Sportbug.com, Inc. +#define UHS_VID_TECHNOTREND_AG 0x0b48U // TechnoTrend AG +#define UHS_VID_ASCII 0x0b49U // ASCII Corp. +#define UHS_VID_PINE 0x0b4bU // Pine Corp. Ltd. +#define UHS_VID_GRAPHTEC_AMERICA 0x0b4dU // Graphtec America, Inc. +#define UHS_VID_MUSICAL_ELECTRONICS 0x0b4eU // Musical Electronics, Ltd +#define UHS_VID_DUMPRIES 0x0b50U // Dumpries Co., Ltd +#define UHS_VID_COMFORT_KEYBOARD 0x0b51U // Comfort Keyboard Co. +#define UHS_VID_COLORADO_MICRODISPLAY 0x0b52U // Colorado MicroDisplay, Inc. +#define UHS_VID_SINBON_ELECTRONICS 0x0b54U // Sinbon Electronics Co., Ltd +#define UHS_VID_TYI_SYSTEMS 0x0b56U // TYI Systems, Ltd +#define UHS_VID_BEIJING_HANWANGTECHNOLOGY 0x0b57U // Beijing HanwangTechnology Co., Ltd +#define UHS_VID_LAKE_COMMUNICATIONS 0x0b59U // Lake Communications, Ltd +#define UHS_VID_COREL 0x0b5aU // Corel Corp. +#define UHS_VID_GREEN_ELECTRONICS 0x0b5fU // Green Electronics Co., Ltd +#define UHS_VID_NSINE 0x0b60U // Nsine, Ltd +#define UHS_VID_NEC_VIEWTECHNOLOGY 0x0b61U // NEC Viewtechnology, Ltd +#define UHS_VID_ORANGE_MICRO 0x0b62U // Orange Micro, Inc. +#define UHS_VID_ADLINK_TECHNOLOGY 0x0b63U // ADLink Technology, Inc. +#define UHS_VID_WONDERFUL_WIRE_CABLE 0x0b64U // Wonderful Wire Cable Co., Ltd +#define UHS_VID_EXPERT_MAGNETICS 0x0b65U // Expert Magnetics Corp. +#define UHS_VID_CYBIKO 0x0b66U // Cybiko Inc. +#define UHS_VID_FAIRBANKS_SCALES 0x0b67U // Fairbanks Scales +#define UHS_VID_CACHEVISION 0x0b69U // CacheVision +#define UHS_VID_MAXIM_INTEGRATED_PRODUCTS 0x0b6aU // Maxim Integrated Products +#define UHS_VID_NAGANO_JAPAN_RADIO 0x0b6fU // Nagano Japan Radio Co., Ltd +#define UHS_VID_PORTALPLAYER 0x0b70U // PortalPlayer, Inc. +#define UHS_VID_SHIN_EI_SANGYO 0x0b71U // SHIN-EI Sangyo Co., Ltd +#define UHS_VID_EMBEDDED_WIRELESS_TECHNOLOGY 0x0b72U // Embedded Wireless Technology Co., Ltd +#define UHS_VID_COMPUTONE 0x0b73U // Computone Corp. +#define UHS_VID_ROLAND_DG 0x0b75U // Roland DG Corp. +#define UHS_VID_SUNRISE_TELECOM 0x0b79U // Sunrise Telecom, Inc. +#define UHS_VID_ZEEVO 0x0b7aU // Zeevo, Inc. +#define UHS_VID_TAIKO_DENKI 0x0b7bU // Taiko Denki Co., Ltd +#define UHS_VID_ITRAN_COMMUNICATIONS 0x0b7cU // ITRAN Communications, Ltd +#define UHS_VID_ASTRODESIGN 0x0b7dU // Astrodesign, Inc. +#define UHS_VID_ID3_TECHNOLOGIES 0x0b81U // id3 Technologies +#define UHS_VID_REXTRON_TECHNOLOGY 0x0b84U // Rextron Technology, Inc. +#define UHS_VID_ELKAT_ELECTRONICS_SDN_BHD 0x0b85U // Elkat Electronics, Sdn., Bhd. +#define UHS_VID_EXPUTER_SYSTEMS 0x0b86U // Exputer Systems, Inc. +#define UHS_VID_PLUS_ONE_I_AND_T 0x0b87U // Plus-One I & T, Inc. +#define UHS_VID_SIGMA_KOKI_CO_LTD_TECHNOLOGY_CENTER 0x0b88U // Sigma Koki Co., Ltd, Technology Center +#define UHS_VID_ADVANCED_DIGITAL_BROADCAST 0x0b89U // Advanced Digital Broadcast, Ltd +#define UHS_VID_SMART_TECHNOLOGIES 0x0b8cU // SMART Technologies Inc. +#define UHS_VID_ASIX_ELECTRONICS 0x0b95U // ASIX Electronics Corp. +#define UHS_VID_SEWON_TELECOM 0x0b96U // Sewon Telecom +#define UHS_VID_O2_MICRO 0x0b97U // O2 Micro, Inc. +#define UHS_VID_PLAYMATES_TOYS 0x0b98U // Playmates Toys, Inc. +#define UHS_VID_AUDIO_INTERNATIONAL 0x0b99U // Audio International, Inc. +#define UHS_VID_DIPL_ING_STEFAN_KUNDE 0x0b9bU // Dipl.-Ing. Stefan Kunde +#define UHS_VID_SOFTPROTEC 0x0b9dU // Softprotec Co. +#define UHS_VID_CHIPPO_TECHNOLOGIES 0x0b9fU // Chippo Technologies +#define UHS_VID_US_ROBOTICS 0x0bafU // U.S. Robotics +#define UHS_VID_CONCORD_CAMERA 0x0bb0U // Concord Camera Corp. +#define UHS_VID_INFINILINK 0x0bb1U // Infinilink Corp. +#define UHS_VID_AMBIT_MICROSYSTEMS 0x0bb2U // Ambit Microsystems Corp. +#define UHS_VID_OFUJI_TECHNOLOGY 0x0bb3U // Ofuji Technology +#define UHS_VID_HTC_HIGH_TECH_COMPUTER 0x0bb4U // HTC (High Tech Computer Corp.) +#define UHS_VID_MURATA_MANUFACTURING 0x0bb5U // Murata Manufacturing Co., Ltd +#define UHS_VID_NETWORK_ALCHEMY 0x0bb6U // Network Alchemy +#define UHS_VID_JOYTECH_COMPUTER 0x0bb7U // Joytech Computer Co., Ltd +#define UHS_VID_HITACHI_SEMICONDUCTOR_AND_DEVICES_SALES 0x0bb8U // Hitachi Semiconductor and Devices Sales Co., Ltd +#define UHS_VID_EIGER_MANDC 0x0bb9U // Eiger M&C Co., Ltd +#define UHS_VID_ZACCESS_SYSTEMS 0x0bbaU // ZAccess Systems +#define UHS_VID_GENERAL_METERS 0x0bbbU // General Meters Corp. +#define UHS_VID_ASSISTIVE_TECHNOLOGY 0x0bbcU // Assistive Technology, Inc. +#define UHS_VID_SYSTEM_CONNECTION 0x0bbdU // System Connection, Inc. +#define UHS_VID_KNILINK_TECHNOLOGY 0x0bc0U // Knilink Technology, Inc. +#define UHS_VID_FUW_YNG_ELECTRONICS 0x0bc1U // Fuw Yng Electronics Co., Ltd +#define UHS_VID_SEAGATE_RSS 0x0bc2U // Seagate RSS LLC +#define UHS_VID_IPWIRELESS 0x0bc3U // IPWireless, Inc. +#define UHS_VID_MICROCUBE 0x0bc4U // Microcube Corp. +#define UHS_VID_JCN 0x0bc5U // JCN Co., Ltd +#define UHS_VID_EXWAY 0x0bc6U // ExWAY, Inc. +#define UHS_VID_X10_WIRELESS_TECHNOLOGY 0x0bc7U // X10 Wireless Technology, Inc. +#define UHS_VID_TELMAX_COMMUNICATIONS 0x0bc8U // Telmax Communications +#define UHS_VID_ECI_TELECOM 0x0bc9U // ECI Telecom, Ltd +#define UHS_VID_STARTEK_ENGINEERING 0x0bcaU // Startek Engineering, Inc. +#define UHS_VID_PERFECT_TECHNIC_ENTERPRISE 0x0bcbU // Perfect Technic Enterprise Co., Ltd +#define UHS_VID_ANDREW_PARGETER_AND_ASSOCIATES 0x0bd7U // Andrew Pargeter & Associates +#define UHS_VID_REALTEK_SEMICONDUCTOR 0x0bdaU // Realtek Semiconductor Corp. +#define UHS_VID_ERICSSON_BUSINESS_MOBILE_NETWORKS_BV 0x0bdbU // Ericsson Business Mobile Networks BV +#define UHS_VID_Y_MEDIA 0x0bdcU // Y Media Corp. +#define UHS_VID_ORANGE_PCS 0x0bddU // Orange PCS +#define UHS_VID_KANDA_TSUSHIN_KOGYO 0x0be2U // Kanda Tsushin Kogyo Co., Ltd +#define UHS_VID_TOYO 0x0be3U // TOYO Corp. +#define UHS_VID_ELKA_INTERNATIONAL 0x0be4U // Elka International, Ltd +#define UHS_VID_DOME_IMAGING_SYSTEMS 0x0be5U // DOME imaging systems, Inc. +#define UHS_VID_DONG_GUAN_HUMEN_WONDERFUL_WIRE_CABLE_FACTORY 0x0be6U // Dong Guan Humen Wonderful Wire Cable Factory +#define UHS_VID_MEI 0x0bedU // MEI +#define UHS_VID_LTK_INDUSTRIES 0x0beeU // LTK Industries, Ltd +#define UHS_VID_WAY2CALL_COMMUNICATIONS 0x0befU // Way2Call Communications +#define UHS_VID_PACE_MICRO_TECHNOLOGY_PLC 0x0bf0U // Pace Micro Technology PLC +#define UHS_VID_INTRACOM 0x0bf1U // Intracom S.A. +#define UHS_VID_KONEXX 0x0bf2U // Konexx +#define UHS_VID_ADDONICS_TECHNOLOGIES_1 0x0bf6U // Addonics Technologies, Inc. +#define UHS_VID_SUNNY_GIKEN 0x0bf7U // Sunny Giken, Inc. +#define UHS_VID_FUJITSU_SIEMENS_COMPUTERS_1 0x0bf8U // Fujitsu Siemens Computers +#define UHS_VID_KVASER 0x0bfdU // Kvaser AB +#define UHS_VID_MOTO_DEVELOPMENT_GROUP 0x0c04U // MOTO Development Group, Inc. +#define UHS_VID_APPIAN_GRAPHICS 0x0c05U // Appian Graphics +#define UHS_VID_HASBRO_GAMES 0x0c06U // Hasbro Games, Inc. +#define UHS_VID_INFINITE_DATA_STORAGE 0x0c07U // Infinite Data Storage, Ltd +#define UHS_VID_AGATE 0x0c08U // Agate +#define UHS_VID_COMJET_INFORMATION_SYSTEM 0x0c09U // Comjet Information System +#define UHS_VID_HIGHPOINT_TECHNOLOGIES 0x0c0aU // Highpoint Technologies, Inc. +#define UHS_VID_DURA_MICRO_INC_ACOMDATA 0x0c0bU // Dura Micro, Inc. (Acomdata) +#define UHS_VID_ZEROPLUS 0x0c12U // Zeroplus +#define UHS_VID_IRIS_GRAPHICS 0x0c15U // Iris Graphics +#define UHS_VID_GYRATION 0x0c16U // Gyration, Inc. +#define UHS_VID_CYBERBOARD_AS 0x0c17U // Cyberboard A/S +#define UHS_VID_SYNERTEK_KOREA 0x0c18U // SynerTek Korea, Inc. +#define UHS_VID_CYBERPIXIE 0x0c19U // cyberPIXIE, Inc. +#define UHS_VID_SILICON_MOTION 0x0c1aU // Silicon Motion, Inc. +#define UHS_VID_MIPS_TECHNOLOGIES 0x0c1bU // MIPS Technologies +#define UHS_VID_HANG_ZHOU_SILAN_ELECTRONICS 0x0c1cU // Hang Zhou Silan Electronics Co., Ltd +#define UHS_VID_TALLY_PRINTER 0x0c22U // Tally Printer Corp. +#define UHS_VID_LERNOUT__HAUSPIE 0x0c23U // Lernout + Hauspie +#define UHS_VID_TAIYO_YUDEN 0x0c24U // Taiyo Yuden +#define UHS_VID_SAMPO 0x0c25U // Sampo Corp. +#define UHS_VID_PROLIFIC_TECHNOLOGY_1 0x0c26U // Prolific Technology Inc. +#define UHS_VID_RFIDEAS 0x0c27U // RFIDeas, Inc +#define UHS_VID_METROLOGIC_INSTRUMENTS 0x0c2eU // Metrologic Instruments +#define UHS_VID_EAGLETRON 0x0c35U // Eagletron, Inc. +#define UHS_VID_E_INK 0x0c36U // E Ink Corp. +#define UHS_VID_EDIGITAL 0x0c37U // e.Digital +#define UHS_VID_DER_AN_ELECTRIC_WIRE_AND_CABLE 0x0c38U // Der An Electric Wire & Cable Co., Ltd +#define UHS_VID_IFR 0x0c39U // IFR +#define UHS_VID_FURUI_PRECISE_COMPONENT_KUNSHAN 0x0c3aU // Furui Precise Component (Kunshan) Co., Ltd +#define UHS_VID_KOMATSU 0x0c3bU // Komatsu, Ltd +#define UHS_VID_RADIUS 0x0c3cU // Radius Co., Ltd +#define UHS_VID_INNOCOM 0x0c3dU // Innocom, Inc. +#define UHS_VID_NEXTCELL 0x0c3eU // Nextcell, Inc. +#define UHS_VID_MOTOROLA_IDEN 0x0c44U // Motorola iDEN +#define UHS_VID_MICRODIA 0x0c45U // Microdia +#define UHS_VID_WAVERIDER_COMMUNICATIONS 0x0c46U // WaveRider Communications, Inc. +#define UHS_VID_ALGE_TIMING 0x0c4aU // ALGE-TIMING GmbH +#define UHS_VID_REINER_SCT_KARTENSYSTEME 0x0c4bU // Reiner SCT Kartensysteme GmbH +#define UHS_VID_NEEDHAMS_ELECTRONICS 0x0c4cU // Needham's Electronics +#define UHS_VID_SEALEVEL_SYSTEMS 0x0c52U // Sealevel Systems, Inc. +#define UHS_VID_VIEWPLUS 0x0c53U // ViewPLUS, Inc. +#define UHS_VID_GLORY 0x0c54U // Glory, Ltd +#define UHS_VID_SPECTRUM_DIGITAL 0x0c55U // Spectrum Digital, Inc. +#define UHS_VID_BILLION_BRIGHT 0x0c56U // Billion Bright, Ltd +#define UHS_VID_IMAGINATIVE_DESIGN_OPERATION 0x0c57U // Imaginative Design Operation Co., Ltd +#define UHS_VID_VIDAR_SYSTEMS 0x0c58U // Vidar Systems Corp. +#define UHS_VID_DONG_GUAN_SHINKO_WIRE 0x0c59U // Dong Guan Shinko Wire Co., Ltd +#define UHS_VID_TRS_INTERNATIONAL_MFG 0x0c5aU // TRS International Mfg., Inc. +#define UHS_VID_XYTRONIX_RESEARCH_AND_DESIGN 0x0c5eU // Xytronix Research & Design +#define UHS_VID_APOGEE_ELECTRONICS 0x0c60U // Apogee Electronics Corp. +#define UHS_VID_CHANT_SINCERE 0x0c62U // Chant Sincere Co., Ltd +#define UHS_VID_TOKO 0x0c63U // Toko, Inc. +#define UHS_VID_SIGNALITY_SYSTEM_ENGINEERING 0x0c64U // Signality System Engineering Co., Ltd +#define UHS_VID_EMINENCE_ENTERPRISE 0x0c65U // Eminence Enterprise Co., Ltd +#define UHS_VID_REXON_ELECTRONICS 0x0c66U // Rexon Electronics Corp. +#define UHS_VID_CONCEPT_TELECOM 0x0c67U // Concept Telecom, Ltd +#define UHS_VID_ACS 0x0c6aU // ACS +#define UHS_VID_JETI_TECHNISCHE_INSTRUMENTE 0x0c6cU // JETI Technische Instrumente GmbH +#define UHS_VID_MCT_ELEKTRONIKLADEN 0x0c70U // MCT Elektronikladen +#define UHS_VID_PEAK_SYSTEM 0x0c72U // PEAK System +#define UHS_VID_OPTRONIC_LABORATORIES 0x0c74U // Optronic Laboratories Inc. +#define UHS_VID_JMTEK 0x0c76U // JMTek, LLC. +#define UHS_VID_SIPIX_GROUP 0x0c77U // Sipix Group, Ltd +#define UHS_VID_DETTO 0x0c78U // Detto Corp. +#define UHS_VID_NUCONNEX_TECHNOLOGIES_PTE 0x0c79U // NuConnex Technologies Pte., Ltd +#define UHS_VID_WING_SPAN_ENTERPRISE 0x0c7aU // Wing-Span Enterprise Co., Ltd +#define UHS_VID_NDA_TECHNOLOGIES 0x0c86U // NDA Technologies, Inc. +#define UHS_VID_KYOCERA_WIRELESS 0x0c88U // Kyocera Wireless Corp. +#define UHS_VID_HONDA_TSUSHIN_KOGYO 0x0c89U // Honda Tsushin Kogyo Co., Ltd +#define UHS_VID_PATHWAY_CONNECTIVITY 0x0c8aU // Pathway Connectivity, Inc. +#define UHS_VID_WAVEFLY 0x0c8bU // Wavefly Corp. +#define UHS_VID_COACTIVE_NETWORKS 0x0c8cU // Coactive Networks +#define UHS_VID_TEMPO 0x0c8dU // Tempo +#define UHS_VID_CESSCOM 0x0c8eU // Cesscom Co., Ltd +#define UHS_VID_APPLIED_MICROSYSTEMS 0x0c8fU // Applied Microsystems +#define UHS_VID_CRYPTERA 0x0c94U // Cryptera +#define UHS_VID_BERKSHIRE_PRODUCTS 0x0c98U // Berkshire Products, Inc. +#define UHS_VID_INNOCHIPS 0x0c99U // Innochips Co., Ltd +#define UHS_VID_HANWOOL_ROBOTICS 0x0c9aU // Hanwool Robotics Corp. +#define UHS_VID_JOBIN_YVON 0x0c9bU // Jobin Yvon, Inc. +#define UHS_VID_SEMTEK 0x0c9dU // SemTek +#define UHS_VID_ZYFER 0x0ca2U // Zyfer +#define UHS_VID_SEGA 0x0ca3U // Sega Corp. +#define UHS_VID_STANDT_INSTRUMENT 0x0ca4U // ST&T Instrument Corp. +#define UHS_VID_BAE_SYSTEMS_CANADA 0x0ca5U // BAE Systems Canada, Inc. +#define UHS_VID_CASTLES_TECHNOLOGY 0x0ca6U // Castles Technology Co., Ltd +#define UHS_VID_INFORMATION_SYSTEMS_LABORATORIES 0x0ca7U // Information Systems Laboratories +#define UHS_VID_MOTOROLA_CGISS 0x0cadU // Motorola CGISS +#define UHS_VID_ASCOM_BUSINESS_SYSTEMS 0x0caeU // Ascom Business Systems, Ltd +#define UHS_VID_BUSLINK 0x0cafU // Buslink +#define UHS_VID_FLYING_PIG_SYSTEMS 0x0cb0U // Flying Pig Systems +#define UHS_VID_INNOVONICS 0x0cb1U // Innovonics, Inc. +#define UHS_VID_CELESTIX_NETWORKS_PTE 0x0cb6U // Celestix Networks, Pte., Ltd +#define UHS_VID_SINGATRON_ENTERPRISE 0x0cb7U // Singatron Enterprise Co., Ltd +#define UHS_VID_OPTICIS 0x0cb8U // Opticis Co., Ltd +#define UHS_VID_TRUST_ELECTRONIC_SHANGHAI 0x0cbaU // Trust Electronic (Shanghai) Co., Ltd +#define UHS_VID_SHANGHAI_DARONG_ELECTRONICS 0x0cbbU // Shanghai Darong Electronics Co., Ltd +#define UHS_VID_PALMAX_TECHNOLOGY 0x0cbcU // Palmax Technology Co., Ltd +#define UHS_VID_PENTEL_CO_LTD_ELECTRONICS_EQUIPMENT_DIV 0x0cbdU // Pentel Co., Ltd (Electronics Equipment Div.) +#define UHS_VID_KERYX_TECHNOLOGIES 0x0cbeU // Keryx Technologies, Inc. +#define UHS_VID_UNION_GENIUS_COMPUTER 0x0cbfU // Union Genius Computer Co., Ltd +#define UHS_VID_KUON_YI_INDUSTRIAL 0x0cc0U // Kuon Yi Industrial Corp. +#define UHS_VID_GIVEN_IMAGING 0x0cc1U // Given Imaging, Ltd +#define UHS_VID_TIMEX 0x0cc2U // Timex Corp. +#define UHS_VID_RIMAGE 0x0cc3U // Rimage Corp. +#define UHS_VID_EMSYS 0x0cc4U // emsys GmbH +#define UHS_VID_SENDO 0x0cc5U // Sendo +#define UHS_VID_INTERMAGIC 0x0cc6U // Intermagic Corp. +#define UHS_VID_KONTRON_MEDICAL_AG 0x0cc7U // Kontron Medical AG +#define UHS_VID_TECHNOTOOLS 0x0cc8U // Technotools Corp. +#define UHS_VID_BROADMAX_TECHNOLOGIES 0x0cc9U // BroadMAX Technologies, Inc. +#define UHS_VID_AMPHENOL 0x0ccaU // Amphenol +#define UHS_VID_SKNET 0x0ccbU // SKNet Co., Ltd +#define UHS_VID_DOMEX_TECHNOLOGY 0x0cccU // Domex Technology Corp. +#define UHS_VID_TERRATEC_ELECTRONIC 0x0ccdU // TerraTec Electronic GmbH +#define UHS_VID_BANG_OLUFSEN 0x0cd4U // Bang Olufsen +#define UHS_VID_LABJACK_CORPORATION 0x0cd5U // LabJack Corporation +#define UHS_VID_NEWCHIP_SRL 0x0cd7U // NewChip S.r.l. +#define UHS_VID_JS_DIGITECH 0x0cd8U // JS Digitech, Inc. +#define UHS_VID_HITACHI_SHIN_DIN_CABLE 0x0cd9U // Hitachi Shin Din Cable, Ltd +#define UHS_VID_Z_COM 0x0cdeU // Z-Com +#define UHS_VID_VALIDATION_TECHNOLOGIES_INTERNATIONAL 0x0ce5U // Validation Technologies International +#define UHS_VID_PICO_TECHNOLOGY 0x0ce9U // Pico Technology +#define UHS_VID_E_CONN_ELECTRONIC 0x0cf1U // e-Conn Electronic Co., Ltd +#define UHS_VID_ENE_TECHNOLOGY 0x0cf2U // ENE Technology, Inc. +#define UHS_VID_ATHEROS_COMMUNICATIONS 0x0cf3U // Atheros Communications, Inc. +#define UHS_VID_FOMTEX 0x0cf4U // Fomtex Corp. +#define UHS_VID_CELLINK 0x0cf5U // Cellink Co., Ltd +#define UHS_VID_COMPUCABLE 0x0cf6U // Compucable Corp. +#define UHS_VID_ISHONI_NETWORKS 0x0cf7U // ishoni Networks +#define UHS_VID_CLARISYS 0x0cf8U // Clarisys, Inc. +#define UHS_VID_CENTRAL_SYSTEM_RESEARCH 0x0cf9U // Central System Research Co., Ltd +#define UHS_VID_INVISO 0x0cfaU // Inviso, Inc. +#define UHS_VID_MINOLTA_QMS 0x0cfcU // Minolta-QMS, Inc. +#define UHS_VID_SAFA_MEDIA 0x0cffU // SAFA MEDIA Co., Ltd. +#define UHS_VID_TELOS_EDV_SYSTEMENTWICKLUNG 0x0d06U // telos EDV Systementwicklung GmbH +#define UHS_VID_UTSTARCOM 0x0d08U // UTStarcom +#define UHS_VID_CONTEMPORARY_CONTROLS 0x0d0bU // Contemporary Controls +#define UHS_VID_ASTRON_ELECTRONICS 0x0d0cU // Astron Electronics Co., Ltd +#define UHS_VID_MKNET 0x0d0dU // MKNet Corp. +#define UHS_VID_HYBRID_NETWORKS 0x0d0eU // Hybrid Networks, Inc. +#define UHS_VID_FENG_SHIN_CABLE 0x0d0fU // Feng Shin Cable Co., Ltd +#define UHS_VID_ELASTIC_NETWORKS 0x0d10U // Elastic Networks +#define UHS_VID_MASPRO_DENKOH 0x0d11U // Maspro Denkoh Corp. +#define UHS_VID_HANSOL_ELECTRONICS 0x0d12U // Hansol Electronics, Inc. +#define UHS_VID_BMF 0x0d13U // BMF Corp. +#define UHS_VID_ARRAY_COMM 0x0d14U // Array Comm, Inc. +#define UHS_VID_ONSTREAM_BV 0x0d15U // OnStream b.v. +#define UHS_VID_HI_TOUCH_IMAGING_TECHNOLOGIES 0x0d16U // Hi-Touch Imaging Technologies Co., Ltd +#define UHS_VID_NALTEC 0x0d17U // NALTEC, Inc. +#define UHS_VID_COAXMEDIA 0x0d18U // coaXmedia +#define UHS_VID_HANK_CONNECTION_INDUSTRIAL 0x0d19U // Hank Connection Industrial Co., Ltd +#define UHS_VID_NXP 0x0d28U // NXP +#define UHS_VID_LEO_HUI_ELECTRIC_WIRE_AND_CABLE 0x0d32U // Leo Hui Electric Wire & Cable Co., Ltd +#define UHS_VID_AIRSPEAK 0x0d33U // AirSpeak, Inc. +#define UHS_VID_REARDEN_STEEL_TECHNOLOGIES 0x0d34U // Rearden Steel Technologies +#define UHS_VID_DAH_KUN 0x0d35U // Dah Kun Co., Ltd +#define UHS_VID_POSIFLEX_TECHNOLOGIES 0x0d3aU // Posiflex Technologies, Inc. +#define UHS_VID_SRI_CABLE_TECHNOLOGY 0x0d3cU // Sri Cable Technology, Ltd +#define UHS_VID_TANGTOP_TECHNOLOGY 0x0d3dU // Tangtop Technology Co., Ltd +#define UHS_VID_FITCOM 0x0d3eU // Fitcom, inc. +#define UHS_VID_MTS_SYSTEMS 0x0d3fU // MTS Systems Corp. +#define UHS_VID_ASCOR 0x0d40U // Ascor, Inc. +#define UHS_VID_TA_YUN_TERMINALS_INDUSTRIAL 0x0d41U // Ta Yun Terminals Industrial Co., Ltd +#define UHS_VID_FULL_DER 0x0d42U // Full Der Co., Ltd +#define UHS_VID_KOBIL_SYSTEMS 0x0d46U // Kobil Systems GmbH +#define UHS_VID_PROMETHEAN_LIMITED 0x0d48U // Promethean Limited +#define UHS_VID_MAXTOR 0x0d49U // Maxtor +#define UHS_VID_NF 0x0d4aU // NF Corp. +#define UHS_VID_GRAPE_SYSTEMS 0x0d4bU // Grape Systems, Inc. +#define UHS_VID_TEDAS_AG 0x0d4cU // Tedas AG +#define UHS_VID_COHERENT 0x0d4dU // Coherent, Inc. +#define UHS_VID_AGERE_SYSTEMS_NETHERLAND_BV 0x0d4eU // Agere Systems Netherland BV +#define UHS_VID_EADS_AIRBUS_FRANCE 0x0d4fU // EADS Airbus France +#define UHS_VID_CLEWARE 0x0d50U // Cleware GmbH +#define UHS_VID_VOLEX_ASIA_PTE 0x0d51U // Volex (Asia) Pte., Ltd +#define UHS_VID_HMI 0x0d53U // HMI Co., Ltd +#define UHS_VID_HOLON 0x0d54U // Holon Corp. +#define UHS_VID_ASKA_TECHNOLOGIES 0x0d55U // ASKA Technologies, Inc. +#define UHS_VID_AVLAB_TECHNOLOGY 0x0d56U // AVLAB Technology, Inc. +#define UHS_VID_SOLOMON_MICROTECH 0x0d57U // Solomon Microtech, Ltd +#define UHS_VID_SMC_NETWORKS 0x0d5cU // SMC Networks, Inc. +#define UHS_VID_MYACOM 0x0d5eU // Myacom, Ltd +#define UHS_VID_CSI 0x0d5fU // CSI, Inc. +#define UHS_VID_IVL_TECHNOLOGIES 0x0d60U // IVL Technologies, Ltd +#define UHS_VID_MEILU_ELECTRONICS_SHENZHEN 0x0d61U // Meilu Electronics (Shenzhen) Co., Ltd +#define UHS_VID_DARFON_ELECTRONICS 0x0d62U // Darfon Electronics Corp. +#define UHS_VID_FRITZ_GEGAUF_AG 0x0d63U // Fritz Gegauf AG +#define UHS_VID_DXG_TECHNOLOGY 0x0d64U // DXG Technology Corp. +#define UHS_VID_KMJP 0x0d65U // KMJP Co., Ltd +#define UHS_VID_TMT 0x0d66U // TMT +#define UHS_VID_ADVANET 0x0d67U // Advanet, Inc. +#define UHS_VID_SUPER_LINK_ELECTRONICS 0x0d68U // Super Link Electronics Co., Ltd +#define UHS_VID_NSI 0x0d69U // NSI +#define UHS_VID_MEGAPOWER_INTERNATIONAL 0x0d6aU // Megapower International Corp. +#define UHS_VID_AND_OR_LOGIC 0x0d6bU // And-Or Logic +#define UHS_VID_TRY_COMPUTER 0x0d70U // Try Computer Co., Ltd +#define UHS_VID_HIRAKAWA_HEWTECH 0x0d71U // Hirakawa Hewtech Corp. +#define UHS_VID_WINMATE_COMMUNICATION 0x0d72U // Winmate Communication, Inc. +#define UHS_VID_HITS_COMMUNICATIONS 0x0d73U // Hit's Communications, Inc. +#define UHS_VID_MFP_KOREA 0x0d76U // MFP Korea, Inc. +#define UHS_VID_POWER_SENTRYNEWPOINT 0x0d77U // Power Sentry/Newpoint +#define UHS_VID_JAPAN_DISTRIBUTOR 0x0d78U // Japan Distributor Corp. +#define UHS_VID_MARX_DATENTECHNIK 0x0d7aU // MARX Datentechnik GmbH +#define UHS_VID_WELLCO_TECHNOLOGY 0x0d7bU // Wellco Technology Co., Ltd +#define UHS_VID_TAIWAN_LINE_TEK_ELECTRONIC 0x0d7cU // Taiwan Line Tek Electronic Co., Ltd +#define UHS_VID_PHISON_ELECTRONICS 0x0d7dU // Phison Electronics Corp. +#define UHS_VID_AMERICAN_COMPUTER_AND_DIGITAL_COMPONENTS 0x0d7eU // American Computer & Digital Components +#define UHS_VID_ESSENTIAL_REALITY 0x0d7fU // Essential Reality LLC +#define UHS_VID_HR_SILVINE_ELECTRONICS 0x0d80U // H.R. Silvine Electronics, Inc. +#define UHS_VID_TECHNOVISION 0x0d81U // TechnoVision +#define UHS_VID_THINK_OUTSIDE 0x0d83U // Think Outside, Inc. +#define UHS_VID_DOLBY_LABORATORIES 0x0d87U // Dolby Laboratories Inc. +#define UHS_VID_OZ_SOFTWARE 0x0d89U // Oz Software +#define UHS_VID_KING_JIM 0x0d8aU // King Jim Co., Ltd +#define UHS_VID_ASCOM_TELECOMMUNICATIONS 0x0d8bU // Ascom Telecommunications, Ltd +#define UHS_VID_C_MEDIA_ELECTRONICS 0x0d8cU // C-Media Electronics, Inc. +#define UHS_VID_PROMOTION_AND_DISPLAY_TECHNOLOGY 0x0d8dU // Promotion & Display Technology, Ltd +#define UHS_VID_GLOBAL_SUN_TECHNOLOGY 0x0d8eU // Global Sun Technology, Inc. +#define UHS_VID_PITNEY_BOWES 0x0d8fU // Pitney Bowes +#define UHS_VID_SURE_FIRE_ELECTRICAL 0x0d90U // Sure-Fire Electrical Corp. +#define UHS_VID_SKANHEX_TECHNOLOGY 0x0d96U // Skanhex Technology, Inc. +#define UHS_VID_SANTA_BARBARA_INSTRUMENT_GROUP 0x0d97U // Santa Barbara Instrument Group +#define UHS_VID_MARS_SEMICONDUCTOR 0x0d98U // Mars Semiconductor Corp. +#define UHS_VID_TRAZER_TECHNOLOGIES 0x0d99U // Trazer Technologies, Inc. +#define UHS_VID_RTX_TELECOM_AS 0x0d9aU // RTX Telecom AS +#define UHS_VID_TAT_SHING_ELECTRICAL 0x0d9bU // Tat Shing Electrical Co. +#define UHS_VID_CHEE_CHEN_HI_TECHNOLOGY 0x0d9cU // Chee Chen Hi-Technology Co., Ltd +#define UHS_VID_SANWA_SUPPLY 0x0d9dU // Sanwa Supply, Inc. +#define UHS_VID_AVAYA 0x0d9eU // Avaya +#define UHS_VID_POWERCOM 0x0d9fU // Powercom Co., Ltd +#define UHS_VID_DANGER_RESEARCH 0x0da0U // Danger Research +#define UHS_VID_SUZHOU_PETERS_PRECISE_INDUSTRIAL 0x0da1U // Suzhou Peter's Precise Industrial Co., Ltd +#define UHS_VID_LAND_INSTRUMENTS_INTERNATIONAL 0x0da2U // Land Instruments International, Ltd +#define UHS_VID_NIPPON_ELECTRO_SENSORY_DEVICES 0x0da3U // Nippon Electro-Sensory Devices Corp. +#define UHS_VID_POLAR_ELECTRO_OY 0x0da4U // Polar Electro Oy +#define UHS_VID_IOGEAR 0x0da7U // IOGear, Inc. +#define UHS_VID_SOFTDSP 0x0da8U // softDSP Co., Ltd +#define UHS_VID_CUBIG_GROUP 0x0dabU // Cubig Group +#define UHS_VID_WESTOVER_SCIENTIFIC 0x0dadU // Westover Scientific +#define UHS_VID_MICRO_STAR_INTERNATIONAL 0x0db0U // Micro Star International +#define UHS_VID_WEN_TE_ELECTRONICS 0x0db1U // Wen Te Electronics Co., Ltd +#define UHS_VID_SHIAN_HWI_PLUG_PARTS_PLASTIC_FACTORY 0x0db2U // Shian Hwi Plug Parts, Plastic Factory +#define UHS_VID_TEKRAM_TECHNOLOGY_1 0x0db3U // Tekram Technology Co., Ltd +#define UHS_VID_CHUNG_FU_CHEN_YEH_ENTERPRISE 0x0db4U // Chung Fu Chen Yeh Enterprise Corp. +#define UHS_VID_ACCESS_IS 0x0db5U // Access IS +#define UHS_VID_ELCON_SYSTEMTECHNIK 0x0db7U // ELCON Systemtechnik +#define UHS_VID_DIGIDESIGN 0x0dbaU // Digidesign +#define UHS_VID_AANDD_MEDICAL 0x0dbcU // A&D Medical +#define UHS_VID_JIUH_SHIUH_PRECISION_INDUSTRY 0x0dbeU // Jiuh Shiuh Precision Industry Co., Ltd +#define UHS_VID_JESS_LINK_INTERNATIONAL 0x0dbfU // Jess-Link International +#define UHS_VID_G7_SOLUTIONS_FORMERLY_GREAT_NOTIONS 0x0dc0U // G7 Solutions (formerly Great Notions) +#define UHS_VID_TAMAGAWA_SEIKI 0x0dc1U // Tamagawa Seiki Co., Ltd +#define UHS_VID_ATHENA_SMARTCARD_SOLUTIONS 0x0dc3U // Athena Smartcard Solutions, Inc. +#define UHS_VID_MACPOWER_PERIPHERALS 0x0dc4U // Macpower Peripherals, Ltd +#define UHS_VID_SDK 0x0dc5U // SDK Co., Ltd +#define UHS_VID_PRECISION_SQUARED_TECHNOLOGY 0x0dc6U // Precision Squared Technology Corp. +#define UHS_VID_FIRST_CABLE_LINE 0x0dc7U // First Cable Line, Inc. +#define UHS_VID_NETWORKFAB 0x0dcdU // NetworkFab Corp. +#define UHS_VID_ACCESS_SOLUTIONS 0x0dd0U // Access Solutions +#define UHS_VID_CONTEK_ELECTRONICS 0x0dd1U // Contek Electronics Co., Ltd +#define UHS_VID_POWER_QUOTIENT_INTERNATIONAL 0x0dd2U // Power Quotient International Co., Ltd +#define UHS_VID_MEDIAQ 0x0dd3U // MediaQ +#define UHS_VID_CUSTOM_ENGINEERING_SPA 0x0dd4U // Custom Engineering SPA +#define UHS_VID_CALIFORNIA_MICRO_DEVICES 0x0dd5U // California Micro Devices +#define UHS_VID_KOCOM 0x0dd7U // Kocom Co., Ltd +#define UHS_VID_NETAC_TECHNOLOGY 0x0dd8U // Netac Technology Co., Ltd +#define UHS_VID_HIGHSPEED_SURFING 0x0dd9U // HighSpeed Surfing +#define UHS_VID_INTEGRATED_CIRCUIT_SOLUTION 0x0ddaU // Integrated Circuit Solution, Inc. +#define UHS_VID_TAMARACK 0x0ddbU // Tamarack, Inc. +#define UHS_VID_DATELINK_TECHNOLOGY 0x0dddU // Datelink Technology Co., Ltd +#define UHS_VID_UBICOM 0x0ddeU // Ubicom, Inc. +#define UHS_VID_BD_CONSUMER_HEALTHCARE 0x0de0U // BD Consumer Healthcare +#define UHS_VID_USBMICRO 0x0de7U // USBmicro +#define UHS_VID_UTECH_ELECTRONIC_DG 0x0deaU // UTECH Electronic (D.G.) Co., Ltd. +#define UHS_VID_NOVASONICS 0x0dedU // Novasonics +#define UHS_VID_LIFETIME_MEMORY_PRODUCTS 0x0deeU // Lifetime Memory Products +#define UHS_VID_FULL_RISE_ELECTRONIC 0x0defU // Full Rise Electronic Co., Ltd +#define UHS_VID_NETANDSYS 0x0df4U // NET&SYS +#define UHS_VID_SITECOM_EUROPE_BV 0x0df6U // Sitecom Europe B.V. +#define UHS_VID_MOBILE_ACTION_TECHNOLOGY 0x0df7U // Mobile Action Technology, Inc. +#define UHS_VID_TOYO_COMMUNICATION_EQUIPMENT 0x0dfaU // Toyo Communication Equipment Co., Ltd +#define UHS_VID_GENERALTOUCH_TECHNOLOGY 0x0dfcU // GeneralTouch Technology Co., Ltd +#define UHS_VID_NIPPON_SYSTEMWARE 0x0e03U // Nippon Systemware Co., Ltd +#define UHS_VID_WINBEST_TECHNOLOGY 0x0e08U // Winbest Technology Co., Ltd +#define UHS_VID_AMIGO_TECHNOLOGY 0x0e0bU // Amigo Technology Inc. +#define UHS_VID_GESYTEC 0x0e0cU // Gesytec +#define UHS_VID_PICOQUANT 0x0e0dU // PicoQuant GmbH +#define UHS_VID_VMWARE 0x0e0fU // VMware, Inc. +#define UHS_VID_JMTEK_1 0x0e16U // JMTek, LLC +#define UHS_VID_WALEX_ELECTRONIC 0x0e17U // Walex Electronic, Ltd +#define UHS_VID_UNISYS_1 0x0e1aU // Unisys +#define UHS_VID_CREWAVE 0x0e1bU // Crewave +#define UHS_VID_PEGASUS_TECHNOLOGIES 0x0e20U // Pegasus Technologies Ltd. +#define UHS_VID_COWON_SYSTEMS 0x0e21U // Cowon Systems, Inc. +#define UHS_VID_SYMBIAN 0x0e22U // Symbian Ltd. +#define UHS_VID_LIOU_YUANE_ENTERPRISE 0x0e23U // Liou Yuane Enterprise Co., Ltd +#define UHS_VID_VINCHIP_SYSTEMS 0x0e25U // VinChip Systems, Inc. +#define UHS_VID_J_PHONE_EAST 0x0e26U // J-Phone East Co., Ltd +#define UHS_VID_HEARTMATH 0x0e30U // HeartMath LLC +#define UHS_VID_MICRO_COMPUTER_CONTROL 0x0e34U // Micro Computer Control Corp. +#define UHS_VID_3PEA_TECHNOLOGIES 0x0e35U // 3Pea Technologies, Inc. +#define UHS_VID_TIEPIE_ENGINEERING 0x0e36U // TiePie engineering +#define UHS_VID_STRATITEC 0x0e38U // Stratitec, Inc. +#define UHS_VID_SMART_MODULAR_TECHNOLOGIES 0x0e39U // Smart Modular Technologies, Inc. +#define UHS_VID_NEOSTAR_TECHNOLOGY 0x0e3aU // Neostar Technology Co., Ltd +#define UHS_VID_MANSELLA 0x0e3bU // Mansella, Ltd +#define UHS_VID_LINE6 0x0e41U // Line6, Inc. +#define UHS_VID_SUN_RISEFUL_TECHNOLOGY 0x0e44U // Sun-Riseful Technology Co., Ltd. +#define UHS_VID_JULIA 0x0e48U // Julia Corp., Ltd +#define UHS_VID_SHENZHEN_BAO_HING_ELECTRIC_WIRE_AND_CABLE_MFR 0x0e4aU // Shenzhen Bao Hing Electric Wire & Cable Mfr. Co. +#define UHS_VID_RADICA_GAMES 0x0e4cU // Radica Games, Ltd +#define UHS_VID_TECHNODATA_INTERWARE 0x0e50U // TechnoData Interware +#define UHS_VID_SPEED_DRAGON_MULTIMEDIA 0x0e55U // Speed Dragon Multimedia, Ltd +#define UHS_VID_KINGSTON_TECHNOLOGY_COMPANY 0x0e56U // Kingston Technology Company, Inc. +#define UHS_VID_ACTIVE 0x0e5aU // Active Co., Ltd +#define UHS_VID_UNION_POWER_INFORMATION_INDUSTRIAL 0x0e5bU // Union Power Information Industrial Co., Ltd +#define UHS_VID_BITLAND_INFORMATION_TECHNOLOGY 0x0e5cU // Bitland Information Technology Co., Ltd +#define UHS_VID_NELTRON_INDUSTRIAL 0x0e5dU // Neltron Industrial Co., Ltd +#define UHS_VID_CONWISE_TECHNOLOGY 0x0e5eU // Conwise Technology Co., Ltd. +#define UHS_VID_HAWKING_TECHNOLOGIES 0x0e66U // Hawking Technologies +#define UHS_VID_FOSSIL 0x0e67U // Fossil, Inc. +#define UHS_VID_MEGAWIN_TECHNOLOGY 0x0e6aU // Megawin Technology Co., Ltd +#define UHS_VID_LOGIC3 0x0e6fU // Logic3 +#define UHS_VID_TOKYO_ELECTRONIC_INDUSTRY 0x0e70U // Tokyo Electronic Industry Co., Ltd +#define UHS_VID_HSI_CHIN_ELECTRONICS 0x0e72U // Hsi-Chin Electronics Co., Ltd +#define UHS_VID_TVS_ELECTRONICS 0x0e75U // TVS Electronics, Ltd +#define UHS_VID_ARCHOS 0x0e79U // Archos, Inc. +#define UHS_VID_ON_TECH_INDUSTRY 0x0e7bU // On-Tech Industry Co., Ltd +#define UHS_VID_GMATE 0x0e7eU // Gmate, Inc. +#define UHS_VID_CHING_TAI_ELECTRIC_WIRE_AND_CABLE 0x0e82U // Ching Tai Electric Wire & Cable Co., Ltd +#define UHS_VID_SHIN_AN_WIRE_AND_CABLE 0x0e83U // Shin An Wire & Cable Co. +#define UHS_VID_WELL_FORCE_ELECTRONIC 0x0e8cU // Well Force Electronic Co., Ltd +#define UHS_VID_MEDIATEK_1 0x0e8dU // MediaTek Inc. +#define UHS_VID_GREENASIA 0x0e8fU // GreenAsia Inc. +#define UHS_VID_WIEBETECH 0x0e90U // WiebeTech, LLC +#define UHS_VID_VTECH_ENGINEERING_CANADA 0x0e91U // VTech Engineering Canada, Ltd +#define UHS_VID_CS_GLORY_ENTERPRISE 0x0e92U // C's Glory Enterprise Co., Ltd +#define UHS_VID_EM_TECHNICS 0x0e93U // eM Technics Co., Ltd +#define UHS_VID_FUTURE_TECHNOLOGY 0x0e95U // Future Technology Co., Ltd +#define UHS_VID_APLUX_COMMUNICATIONS 0x0e96U // Aplux Communications, Ltd +#define UHS_VID_FINGERWORKS 0x0e97U // Fingerworks, Inc. +#define UHS_VID_ADVANCED_ANALOGIC_TECHNOLOGIES 0x0e98U // Advanced Analogic Technologies, Inc. +#define UHS_VID_PARALLEL_DICE 0x0e99U // Parallel Dice Co., Ltd +#define UHS_VID_TA_HSING_INDUSTRIES 0x0e9aU // TA HSING Industries, Ltd +#define UHS_VID_ADTEC 0x0e9bU // ADTEC Corp. +#define UHS_VID_STREAMZAP 0x0e9cU // Streamzap, Inc. +#define UHS_VID_TAMURA 0x0e9fU // Tamura Corp. +#define UHS_VID_OURS_TECHNOLOGY 0x0ea0U // Ours Technology, Inc. +#define UHS_VID_NIHON_COMPUTER 0x0ea6U // Nihon Computer Co., Ltd +#define UHS_VID_MSL_ENTERPRISES 0x0ea7U // MSL Enterprises Corp. +#define UHS_VID_CENDYNE 0x0ea8U // CenDyne, Inc. +#define UHS_VID_HUMAX_1 0x0eadU // Humax Co., Ltd +#define UHS_VID_NOVATECH 0x0eb0U // NovaTech +#define UHS_VID_WIS_TECHNOLOGIES 0x0eb1U // WIS Technologies, Inc. +#define UHS_VID_Y_S_ELECTRONIC 0x0eb2U // Y-S Electronic Co., Ltd +#define UHS_VID_SAINT_TECHNOLOGY 0x0eb3U // Saint Technology Corp. +#define UHS_VID_ENDOR_AG 0x0eb7U // Endor AG +#define UHS_VID_METTLER_TOLEDO 0x0eb8U // Mettler Toledo +#define UHS_VID_THERMO_FISHER_SCIENTIFIC 0x0ebbU // Thermo Fisher Scientific +#define UHS_VID_VWEB 0x0ebeU // VWeb Corp. +#define UHS_VID_OMEGA_TECHNOLOGY_OF_TAIWAN 0x0ebfU // Omega Technology of Taiwan, Inc. +#define UHS_VID_LHI_TECHNOLOGY_CHINA 0x0ec0U // LHI Technology (China) Co., Ltd +#define UHS_VID_ABIT_COMPUTER 0x0ec1U // Abit Computer Corp. +#define UHS_VID_SWEETRAY_INDUSTRIAL 0x0ec2U // Sweetray Industrial, Ltd +#define UHS_VID_AXELL 0x0ec3U // Axell Co., Ltd +#define UHS_VID_BALLRACING_DEVELOPMENTS 0x0ec4U // Ballracing Developments, Ltd +#define UHS_VID_GT_INFORMATION_SYSTEM 0x0ec5U // GT Information System Co., Ltd +#define UHS_VID_INNOVISION_MULTIMEDIA 0x0ec6U // InnoVISION Multimedia, Ltd +#define UHS_VID_THETA_LINK 0x0ec7U // Theta Link Corp. +#define UHS_VID_LITE_ON_IT 0x0ecdU // Lite-On IT Corp. +#define UHS_VID_TAISOL_ELECTRONICS 0x0eceU // TaiSol Electronics Co., Ltd +#define UHS_VID_PHOGENIX_IMAGING 0x0ecfU // Phogenix Imaging, LLC +#define UHS_VID_WINMAXGROUP 0x0ed1U // WinMaxGroup +#define UHS_VID_KYOTO_MICRO_COMPUTER 0x0ed2U // Kyoto Micro Computer Co., Ltd +#define UHS_VID_WING_TECH_ENTERPRISE 0x0ed3U // Wing-Tech Enterprise Co., Ltd +#define UHS_VID_FIBERBYTE 0x0ed5U // Fiberbyte +#define UHS_VID_NORIAKE_ITRON 0x0edaU // Noriake Itron Corp. +#define UHS_VID_E_MDT 0x0edfU // e-MDT Co., Ltd +#define UHS_VID_SHIMA_SEIKI_MFG 0x0ee0U // Shima Seiki Mfg., Ltd +#define UHS_VID_SAROTECH 0x0ee1U // Sarotech Co., Ltd +#define UHS_VID_AMI_SEMICONDUCTOR 0x0ee2U // AMI Semiconductor, Inc. +#define UHS_VID_COMTRUE_TECHNOLOGY 0x0ee3U // ComTrue Technology Corp. +#define UHS_VID_SUNRICH_TECHNOLOGY 0x0ee4U // Sunrich Technology, Ltd +#define UHS_VID_DIGITAL_STREAM_TECHNOLOGY 0x0eeeU // Digital Stream Technology, Inc. +#define UHS_VID_D_WAV_SCIENTIFIC 0x0eefU // D-WAV Scientific Co., Ltd +#define UHS_VID_HITACHI_CABLE 0x0ef0U // Hitachi Cable, Ltd +#define UHS_VID_AICHI_MICRO_INTELLIGENT 0x0ef1U // Aichi Micro Intelligent Corp. +#define UHS_VID_IO_MAGIC 0x0ef2U // I/O Magic Corp. +#define UHS_VID_LYNN_PRODUCTS 0x0ef3U // Lynn Products, Inc. +#define UHS_VID_DSI_DATOTECH 0x0ef4U // DSI Datotech +#define UHS_VID_POINTCHIPS 0x0ef5U // PointChips +#define UHS_VID_YIELD_MICROELECTRONICS 0x0ef6U // Yield Microelectronics Corp. +#define UHS_VID_SM_TECH_CO_LTD_TULIP 0x0ef7U // SM Tech Co., Ltd (Tulip) +#define UHS_VID_OASIS_SEMICONDUCTOR 0x0efdU // Oasis Semiconductor +#define UHS_VID_WEM_TECHNOLOGY 0x0efeU // Wem Technology, Inc. +#define UHS_VID_UNITEK_UPS_SYSTEMS 0x0f03U // Unitek UPS Systems +#define UHS_VID_VISUAL_FRONTIER_ENTERPRISE 0x0f06U // Visual Frontier Enterprise Co., Ltd +#define UHS_VID_CSL_WIRE_AND_PLUG_SHEN_ZHEN 0x0f08U // CSL Wire & Plug (Shen Zhen) Co. +#define UHS_VID_CAS 0x0f0cU // CAS Corp. +#define UHS_VID_HORI 0x0f0dU // Hori Co., Ltd +#define UHS_VID_ENERGY_FULL 0x0f0eU // Energy Full Corp. +#define UHS_VID_LD_DIDACTIC 0x0f11U // LD Didactic GmbH +#define UHS_VID_MARS_ENGINEERING 0x0f12U // Mars Engineering Corp. +#define UHS_VID_ACETEK_TECHNOLOGY 0x0f13U // Acetek Technology Co., Ltd +#define UHS_VID_INGENICO_1 0x0f14U // Ingenico +#define UHS_VID_FINGER_LAKES_INSTRUMENTATION 0x0f18U // Finger Lakes Instrumentation +#define UHS_VID_ORACOM 0x0f19U // Oracom Co., Ltd +#define UHS_VID_ONSET_COMPUTER 0x0f1bU // Onset Computer Corp. +#define UHS_VID_FUNAI_ELECTRIC 0x0f1cU // Funai Electric Co., Ltd +#define UHS_VID_IWILL 0x0f1dU // Iwill Corp. +#define UHS_VID_IOI_TECHNOLOGY 0x0f21U // IOI Technology Corp. +#define UHS_VID_SENIOR_INDUSTRIES 0x0f22U // Senior Industries, Inc. +#define UHS_VID_LEADER_TECH_MANUFACTURER 0x0f23U // Leader Tech Manufacturer Co., Ltd +#define UHS_VID_FLEX_P_INDUSTRIES_SND_BHD 0x0f24U // Flex-P Industries, Snd., Bhd. +#define UHS_VID_VIPOWER 0x0f2dU // ViPower, Inc. +#define UHS_VID_GENIALITY_MAPLE_TECHNOLOGY 0x0f2eU // Geniality Maple Technology Co., Ltd +#define UHS_VID_PRIVA_DESIGN_SERVICES 0x0f2fU // Priva Design Services +#define UHS_VID_JESS_TECHNOLOGY 0x0f30U // Jess Technology Co., Ltd +#define UHS_VID_CHRYSALIS_DEVELOPMENT 0x0f31U // Chrysalis Development +#define UHS_VID_YFC_BONEAGLE_ELECTRIC 0x0f32U // YFC-BonEagle Electric Co., Ltd +#define UHS_VID_KOKUYO 0x0f37U // Kokuyo Co., Ltd +#define UHS_VID_NIEN_YI_INDUSTRIAL 0x0f38U // Nien-Yi Industrial Corp. +#define UHS_VID_TG3_ELECTRONICS_1 0x0f39U // TG3 Electronics +#define UHS_VID_AIRPRIME_INCORPORATED 0x0f3dU // Airprime, Incorporated +#define UHS_VID_RDC_SEMICONDUCTOR 0x0f41U // RDC Semiconductor Co., Ltd +#define UHS_VID_NITAL_CONSULTING_SERVICES 0x0f42U // Nital Consulting Services, Inc. +#define UHS_VID_POLHEMUS 0x0f44U // Polhemus +#define UHS_VID_ST_JOHN_TECHNOLOGY 0x0f4bU // St. John Technology Co., Ltd +#define UHS_VID_WORLDWIDE_CABLE_OPTO 0x0f4cU // WorldWide Cable Opto Corp. +#define UHS_VID_MICROTUNE 0x0f4dU // Microtune, Inc. +#define UHS_VID_FREEDOM_SCIENTIFIC 0x0f4eU // Freedom Scientific +#define UHS_VID_WING_KEY_ELECTRICAL 0x0f52U // Wing Key Electrical Co., Ltd +#define UHS_VID_DONGGUAN_WHITE_HORSE_CABLE_FACTORY 0x0f53U // Dongguan White Horse Cable Factory, Ltd +#define UHS_VID_KAWAI_MUSICAL_INSTRUMENTS_MFG 0x0f54U // Kawai Musical Instruments Mfg. Co., Ltd +#define UHS_VID_AMBICOM 0x0f55U // AmbiCom, Inc. +#define UHS_VID_PRAIRIECOMM 0x0f5cU // Prairiecomm, Inc. +#define UHS_VID_NEWAGE_INTERNATIONAL 0x0f5dU // NewAge International, LLC +#define UHS_VID_KEY_TECHNOLOGY 0x0f5fU // Key Technology Corp. +#define UHS_VID_NTK 0x0f60U // NTK, Ltd +#define UHS_VID_VARIAN 0x0f61U // Varian, Inc. +#define UHS_VID_ACROX_TECHNOLOGIES 0x0f62U // Acrox Technologies Co., Ltd +#define UHS_VID_LEAPFROG_ENTERPRISES 0x0f63U // LeapFrog Enterprises +#define UHS_VID_KOBE_STEEL 0x0f68U // Kobe Steel, Ltd +#define UHS_VID_DIONEX 0x0f69U // Dionex Corp. +#define UHS_VID_VIBREN_TECHNOLOGIES 0x0f6aU // Vibren Technologies, Inc. +#define UHS_VID_INTELLIGENT_SYSTEMS 0x0f6eU // INTELLIGENT SYSTEMS +#define UHS_VID_DFI_1 0x0f73U // DFI +#define UHS_VID_GUNTERMANN_AND_DRUNCK 0x0f78U // Guntermann & Drunck GmbH +#define UHS_VID_DQ_TECHNOLOGY 0x0f7cU // DQ Technology, Inc. +#define UHS_VID_NETBOTZ 0x0f7dU // NetBotz, Inc. +#define UHS_VID_FLUKE 0x0f7eU // Fluke Corp. +#define UHS_VID_VTECH_HOLDINGS 0x0f88U // VTech Holdings, Ltd +#define UHS_VID_YAZAKI 0x0f8bU // Yazaki Corp. +#define UHS_VID_YOUNG_GENERATION_INTERNATIONAL 0x0f8cU // Young Generation International Corp. +#define UHS_VID_UNIWILL_COMPUTER 0x0f8dU // Uniwill Computer Corp. +#define UHS_VID_KINGNET_TECHNOLOGY 0x0f8eU // Kingnet Technology Co., Ltd +#define UHS_VID_SOMA_NETWORKS 0x0f8fU // Soma Networks +#define UHS_VID_CVILUX 0x0f97U // CviLux Corp. +#define UHS_VID_CYBERBANK 0x0f98U // CyberBank Corp. +#define UHS_VID_HYUN_WON 0x0f9cU // Hyun Won, Inc. +#define UHS_VID_LUCENT_TECHNOLOGIES_1 0x0f9eU // Lucent Technologies +#define UHS_VID_STARCONN_ELECTRONIC 0x0fa3U // Starconn Electronic Co., Ltd +#define UHS_VID_ATL_TECHNOLOGY 0x0fa4U // ATL Technology +#define UHS_VID_SOTEC 0x0fa5U // Sotec Co., Ltd +#define UHS_VID_EPOX_COMPUTER 0x0fa7U // Epox Computer Co., Ltd +#define UHS_VID_LOGIC_CONTROLS 0x0fa8U // Logic Controls, Inc. +#define UHS_VID_WINPOINT_ELECTRONIC 0x0fafU // Winpoint Electronic Corp. +#define UHS_VID_HAURTIAN_WIRE_AND_CABLE 0x0fb0U // Haurtian Wire & Cable Co., Ltd +#define UHS_VID_INCLOSE_DESIGN 0x0fb1U // Inclose Design, Inc. +#define UHS_VID_JUAN_CHERN_INDUSTRIAL 0x0fb2U // Juan-Chern Industrial Co., Ltd +#define UHS_VID_HEBER 0x0fb6U // Heber Ltd +#define UHS_VID_WISTRON 0x0fb8U // Wistron Corp. +#define UHS_VID_AACOM 0x0fb9U // AACom Corp. +#define UHS_VID_SAN_SHING_ELECTRONICS 0x0fbaU // San Shing Electronics Co., Ltd +#define UHS_VID_BITWISE_SYSTEMS 0x0fbbU // Bitwise Systems, Inc. +#define UHS_VID_MITAC_INTERNATINAL 0x0fc1U // Mitac Internatinal Corp. +#define UHS_VID_PLUG_AND_JACK_INDUSTRIAL 0x0fc2U // Plug and Jack Industrial, Inc. +#define UHS_VID_DELCOM_ENGINEERING 0x0fc5U // Delcom Engineering +#define UHS_VID_DATAPLUS_SUPPLIES 0x0fc6U // Dataplus Supplies, Inc. +#define UHS_VID_RESEARCH_IN_MOTION 0x0fcaU // Research In Motion, Ltd. +#define UHS_VID_SONY_ERICSSON_MOBILE_COMMUNICATIONS 0x0fceU // Sony Ericsson Mobile Communications AB +#define UHS_VID_DYNASTREAM_INNOVATIONS 0x0fcfU // Dynastream Innovations, Inc. +#define UHS_VID_TULIP_COMPUTERS_BV 0x0fd0U // Tulip Computers B.V. +#define UHS_VID_GIANT_ELECTRONICS 0x0fd1U // Giant Electronics Ltd. +#define UHS_VID_SEAC_BANCHE 0x0fd2U // Seac Banche +#define UHS_VID_TENOVIS_GMBH_AND_CO_KG 0x0fd4U // Tenovis GmbH & Co., KG +#define UHS_VID_DIRECT_ACCESS_TECHNOLOGY 0x0fd5U // Direct Access Technology, Inc. +#define UHS_VID_ELGATO_SYSTEMS 0x0fd9U // Elgato Systems GmbH +#define UHS_VID_QUANTEC_NETWORKS 0x0fdaU // Quantec Networks GmbH +#define UHS_VID_MICRO_PLUS 0x0fdcU // Micro Plus +#define UHS_VID_OREGON_SCIENTIFIC 0x0fdeU // Oregon Scientific +#define UHS_VID_OSTERHOUT_DESIGN_GROUP 0x0fe0U // Osterhout Design Group +#define UHS_VID_IN_TECH_ELECTRONICS 0x0fe4U // IN-Tech Electronics, Ltd +#define UHS_VID_GREENCONN_USA 0x0fe5U // Greenconn (U.S.A.), Inc. +#define UHS_VID_KONTRON_INDUSTRIAL_COMPUTER_SOURCE_ICS_ADVENT 0x0fe6U // Kontron (Industrial Computer Source / ICS Advent) +#define UHS_VID_DVICO 0x0fe9U // DVICO +#define UHS_VID_UNITED_COMPUTER_ACCESSORIES 0x0feaU // United Computer Accessories +#define UHS_VID_CRS_ELECTRONIC 0x0febU // CRS Electronic Co., Ltd +#define UHS_VID_UMC_ELECTRONICS 0x0fecU // UMC Electronics Co., Ltd +#define UHS_VID_ACCESS 0x0fedU // Access Co., Ltd +#define UHS_VID_XSIDO 0x0feeU // Xsido Corp. +#define UHS_VID_MJ_RESEARCH 0x0fefU // MJ Research, Inc. +#define UHS_VID_CORE_VALLEY 0x0ff6U // Core Valley Co., Ltd +#define UHS_VID_CHI_SHING_COMPUTER_ACCESSORIES 0x0ff7U // CHI SHING Computer Accessories Co., Ltd +#define UHS_VID_CLAVIA_DMI 0x0ffcU // Clavia DMI AB +#define UHS_VID_EARLYSENSE 0x0ffdU // EarlySense +#define UHS_VID_AOPEN 0x0fffU // Aopen, Inc. +#define UHS_VID_SPEED_TECH 0x1000U // Speed Tech Corp. +#define UHS_VID_RITRONICS_COMPONENTS_S_PTE 0x1001U // Ritronics Components (S) Pte., Ltd +#define UHS_VID_SIGMA 0x1003U // Sigma Corp. +#define UHS_VID_LG_ELECTRONICS 0x1004U // LG Electronics, Inc. +#define UHS_VID_APACER_TECHNOLOGY 0x1005U // Apacer Technology, Inc. +#define UHS_VID_IRIVER 0x1006U // iRiver, Ltd. +#define UHS_VID_EMUZED 0x1009U // Emuzed, Inc. +#define UHS_VID_AV_CHASEWAY 0x100aU // AV Chaseway, Ltd +#define UHS_VID_CHOU_CHIN_INDUSTRIAL 0x100bU // Chou Chin Industrial Co., Ltd +#define UHS_VID_NETOPIA 0x100dU // Netopia, Inc. +#define UHS_VID_FUKUDA_DENSHI 0x1010U // Fukuda Denshi Co., Ltd +#define UHS_VID_MOBILE_MEDIA_TECH 0x1011U // Mobile Media Tech. +#define UHS_VID_SDKM_FIBRES_WIRES_AND_CABLES_BERHAD 0x1012U // SDKM Fibres, Wires & Cables Berhad +#define UHS_VID_TST_TOUCHLESS_SENSOR_TECHNOLOGY_AG 0x1013U // TST-Touchless Sensor Technology AG +#define UHS_VID_DENSITRON_TECHNOLOGIES_PLC 0x1014U // Densitron Technologies PLC +#define UHS_VID_SOFTRONICS_PTY 0x1015U // Softronics Pty., Ltd +#define UHS_VID_XIAMEN_HUNGS_ENTERPRISE 0x1016U // Xiamen Hung's Enterprise Co., Ltd +#define UHS_VID_SPEEDY_INDUSTRIAL_SUPPLIES_PTE 0x1017U // Speedy Industrial Supplies, Pte., Ltd +#define UHS_VID_ELITEGROUP_COMPUTER_SYSTEMS_ECS 0x1019U // Elitegroup Computer Systems (ECS) +#define UHS_VID_LABTEC_1 0x1020U // Labtec +#define UHS_VID_SHINKO_SHOJI 0x1022U // Shinko Shoji Co., Ltd +#define UHS_VID_HYPER_PALTEK 0x1025U // Hyper-Paltek +#define UHS_VID_NEWLY 0x1026U // Newly Corp. +#define UHS_VID_TIME_DOMAIN 0x1027U // Time Domain +#define UHS_VID_INOVYS 0x1028U // Inovys Corp. +#define UHS_VID_ATLANTIC_COAST_TELESYS 0x1029U // Atlantic Coast Telesys +#define UHS_VID_RAMOS_TECHNOLOGY 0x102aU // Ramos Technology Co., Ltd +#define UHS_VID_INFOTRONIC_AMERICA 0x102bU // Infotronic America, Inc. +#define UHS_VID_ETOMS_ELECTRONICS 0x102cU // Etoms Electronics Corp. +#define UHS_VID_WINIC 0x102dU // Winic Corp. +#define UHS_VID_COMAX_TECHNOLOGY 0x1031U // Comax Technology, Inc. +#define UHS_VID_C_ONE_TECHNOLOGY 0x1032U // C-One Technology Corp. +#define UHS_VID_NUCAM 0x1033U // Nucam Corp. +#define UHS_VID_STEELSERIES_APS 0x1038U // SteelSeries ApS +#define UHS_VID_DEVOLO_AG 0x1039U // devolo AG +#define UHS_VID_PSA 0x103aU // PSA +#define UHS_VID_STANTON 0x103dU // Stanton +#define UHS_VID_ICREATE_TECHNOLOGIES 0x1043U // iCreate Technologies Corp. +#define UHS_VID_CHU_YUEN_ENTERPRISE 0x1044U // Chu Yuen Enterprise Co., Ltd +#define UHS_VID_WINBOND_ELECTRONICS_CORP_HEX_ 0x1046U // Winbond Electronics Corp. [hex] +#define UHS_VID_TARGUS_GROUP_INTERNATIONAL 0x1048U // Targus Group International +#define UHS_VID_MYLEX_BUSLOGIC 0x104bU // Mylex / Buslogic +#define UHS_VID_AMCO_TEC_INTERNATIONAL 0x104cU // AMCO TEC International, Inc. +#define UHS_VID_NEWPORT_CORPORATION 0x104dU // Newport Corporation +#define UHS_VID_WB_ELECTRONICS 0x104fU // WB Electronics +#define UHS_VID_YUBICOCOM 0x1050U // Yubico.com +#define UHS_VID_IMMANUEL_ELECTRONICS 0x1053U // Immanuel Electronics Co., Ltd +#define UHS_VID_BMS_INTERNATIONAL_BEHEER_NV 0x1054U // BMS International Beheer N.V. +#define UHS_VID_COMPLEX_MICRO_INTERCONNECTION 0x1055U // Complex Micro Interconnection Co., Ltd +#define UHS_VID_HSIN_CHEN_ENT 0x1056U // Hsin Chen Ent Co., Ltd +#define UHS_VID_ON_SEMICONDUCTOR 0x1057U // ON Semiconductor +#define UHS_VID_WESTERN_DIGITAL_TECHNOLOGIES 0x1058U // Western Digital Technologies, Inc. +#define UHS_VID_GIESECKE_AND_DEVRIENT 0x1059U // Giesecke & Devrient GmbH +#define UHS_VID_FOXCONN_INTERNATIONAL 0x105bU // Foxconn International, Inc. +#define UHS_VID_HONG_JI_ELECTRIC_WIRE_AND_CABLE_DONGGUAN 0x105cU // Hong Ji Electric Wire & Cable (Dongguan) Co., Ltd +#define UHS_VID_DELKIN_DEVICES 0x105dU // Delkin Devices, Inc. +#define UHS_VID_VALENCE_SEMICONDUCTOR_DESIGN 0x105eU // Valence Semiconductor Design, Ltd +#define UHS_VID_CHIN_SHONG_ENTERPRISE 0x105fU // Chin Shong Enterprise Co., Ltd +#define UHS_VID_EASTHOME_INDUSTRIAL 0x1060U // Easthome Industrial Co., Ltd +#define UHS_VID_MOTOROLA_ELECTRONICS_TAIWAN_LTD_HEX_ 0x1063U // Motorola Electronics Taiwan, Ltd [hex] +#define UHS_VID_CCYU_TECHNOLOGY 0x1065U // CCYU Technology +#define UHS_VID_LOYAL_LEGEND 0x106aU // Loyal Legend, Ltd +#define UHS_VID_CURITEL_COMMUNICATIONS 0x106cU // Curitel Communications, Inc. +#define UHS_VID_SAN_CHIEH_MANUFACTURING 0x106dU // San Chieh Manufacturing, Ltd +#define UHS_VID_CONECTL 0x106eU // ConectL +#define UHS_VID_MONEY_CONTROLS 0x106fU // Money Controls +#define UHS_VID_GCT_SEMICONDUCTOR 0x1076U // GCT Semiconductor, Inc. +#define UHS_VID_GATEWAY_1 0x107bU // Gateway, Inc. +#define UHS_VID_ARLEC_AUSTRALIA 0x107dU // Arlec Australia, Ltd +#define UHS_VID_MIDORIYA_ELECTRIC 0x107eU // Midoriya Electric Co., Ltd +#define UHS_VID_KIDZMOUSE 0x107fU // KidzMouse, Inc. +#define UHS_VID_SHIN_ETSUKAKEN 0x1082U // Shin-Etsukaken Co., Ltd +#define UHS_VID_CANON_ELECTRONICS 0x1083U // Canon Electronics, Inc. +#define UHS_VID_PANTECH 0x1084U // Pantech Co., Ltd +#define UHS_VID_CHLORIDE_POWER_PROTECTION 0x108aU // Chloride Power Protection +#define UHS_VID_GRAND_TEK_TECHNOLOGY 0x108bU // Grand-tek Technology Co., Ltd +#define UHS_VID_ROBERT_BOSCH 0x108cU // Robert Bosch GmbH +#define UHS_VID_LOTES 0x108eU // Lotes Co., Ltd. +#define UHS_VID_SURFACE_OPTICS 0x1099U // Surface Optics Corp. +#define UHS_VID_DATASOFT_SYSTEMS 0x109aU // DATASOFT Systems GmbH +#define UHS_VID_HISENSE 0x109bU // Hisense +#define UHS_VID_ESOL 0x109fU // eSOL Co., Ltd +#define UHS_VID_HIROTECH 0x10a0U // Hirotech, Inc. +#define UHS_VID_MITSUBISHI_MATERIALS 0x10a3U // Mitsubishi Materials Corp. +#define UHS_VID_SK_TELETECH 0x10a9U // SK Teletech Co., Ltd +#define UHS_VID_CABLES_TO_GO 0x10aaU // Cables To Go +#define UHS_VID_USI 0x10abU // USI Co., Ltd +#define UHS_VID_HONEYWELL 0x10acU // Honeywell, Inc. +#define UHS_VID_PRINCETON_TECHNOLOGY 0x10aeU // Princeton Technology Corp. +#define UHS_VID_LIEBERT 0x10afU // Liebert Corp. +#define UHS_VID_COMODO_PLX_UNKNOWN 0x10b5U // Comodo (PLX?) +#define UHS_VID_DIBCOM 0x10b8U // DiBcom +#define UHS_VID_TM_TECHNOLOGY 0x10bbU // TM Technology, Inc. +#define UHS_VID_DINGING_TECHNOLOGY 0x10bcU // Dinging Technology Co., Ltd +#define UHS_VID_TMT_TECHNOLOGY 0x10bdU // TMT Technology, Inc. +#define UHS_VID_SMARTHOME 0x10bfU // SmartHome +#define UHS_VID_UNIVERSAL_LASER_SYSTEMS 0x10c3U // Universal Laser Systems, Inc. +#define UHS_VID_CYGNAL_INTEGRATED_PRODUCTS 0x10c4U // Cygnal Integrated Products, Inc. +#define UHS_VID_SANEI_ELECTRIC 0x10c5U // Sanei Electric, Inc. +#define UHS_VID_INTEC 0x10c6U // Intec, Inc. +#define UHS_VID_ERATECH 0x10cbU // Eratech +#define UHS_VID_GBM_CONNECTOR 0x10ccU // GBM Connector Co., Ltd +#define UHS_VID_KYCON 0x10cdU // Kycon, Inc. +#define UHS_VID_SILICON_LABS 0x10ceU // Silicon Labs +#define UHS_VID_VELLEMAN_COMPONENTS 0x10cfU // Velleman Components, Inc. +#define UHS_VID_HOTTINGER_BALDWIN_MEASUREMENT 0x10d1U // Hottinger Baldwin Measurement +#define UHS_VID_RAYCOMPOSER__R_ADAMS 0x10d2U // RayComposer - R. Adams +#define UHS_VID_MAN_BOON_MANUFACTORY 0x10d4U // Man Boon Manufactory, Ltd +#define UHS_VID_UNI_CLASS_TECHNOLOGY 0x10d5U // Uni Class Technology Co., Ltd +#define UHS_VID_ACTIONS_SEMICONDUCTOR 0x10d6U // Actions Semiconductor Co., Ltd +#define UHS_VID_AUTHENEX 0x10deU // Authenex, Inc. +#define UHS_VID_IN_WIN_DEVELOPMENT 0x10dfU // In-Win Development, Inc. +#define UHS_VID_POST_OP_VIDEO 0x10e0U // Post-Op Video, Inc. +#define UHS_VID_CABLEPLUS 0x10e1U // CablePlus, Ltd +#define UHS_VID_NADA_ELECTRONICS 0x10e2U // Nada Electronics, Ltd +#define UHS_VID_VAST_TECHNOLOGIES 0x10ecU // Vast Technologies, Inc. +#define UHS_VID_NEXIO 0x10f0U // Nexio Co., Ltd +#define UHS_VID_IMPORTEK 0x10f1U // Importek +#define UHS_VID_TURTLE_BEACH 0x10f5U // Turtle Beach +#define UHS_VID_PICTOS_TECHNOLOGIES 0x10fbU // Pictos Technologies, Inc. +#define UHS_VID_ANUBIS_ELECTRONICS 0x10fdU // Anubis Electronics, Ltd +#define UHS_VID_THRANE_AND_THRANE 0x10feU // Thrane & Thrane +#define UHS_VID_VIRTOUCH 0x1100U // VirTouch, Ltd +#define UHS_VID_EASYPASS_INDUSTRIAL 0x1101U // EasyPass Industrial Co., Ltd +#define UHS_VID_BRIGHTCOM_TECHNOLOGIES 0x1108U // Brightcom Technologies, Ltd +#define UHS_VID_MOXA_TECHNOLOGIES 0x110aU // Moxa Technologies Co., Ltd. +#define UHS_VID_ANALOG_DEVICES_CANADA_LTD_ALLIED_TELESYN 0x1110U // Analog Devices Canada, Ltd (Allied Telesyn) +#define UHS_VID_PANDORA_INTERNATIONAL 0x1111U // Pandora International Ltd. +#define UHS_VID_YM_ELECTRIC 0x1112U // YM ELECTRIC CO., Ltd +#define UHS_VID_MEDION_AG 0x1113U // Medion AG +#define UHS_VID_VSO_ELECTRIC 0x111eU // VSO Electric Co., Ltd +#define UHS_VID_REDRAT 0x112aU // RedRat +#define UHS_VID_MASTER_HILL_ELECTRIC_WIRE_AND_CABLE 0x112eU // Master Hill Electric Wire and Cable Co., Ltd +#define UHS_VID_CELLON_INTERNATIONAL 0x112fU // Cellon International, Inc. +#define UHS_VID_TENX_TECHNOLOGY 0x1130U // Tenx Technology, Inc. +#define UHS_VID_INTEGRATED_SYSTEM_SOLUTION 0x1131U // Integrated System Solution Corp. +#define UHS_VID_TOSHIBA_CORP_DIGITAL_MEDIA_EQUIPMENT_HEX_ 0x1132U // Toshiba Corp., Digital Media Equipment [hex] +#define UHS_VID_CTS_ELECTRONINCS 0x1136U // CTS Electronincs +#define UHS_VID_ARIN_TECH 0x113cU // Arin Tech Co., Ltd +#define UHS_VID_MAPOWER_ELECTRONICS 0x113dU // Mapower Electronics Co., Ltd +#define UHS_VID_V_ONE_MULTIMEDIA_PTE 0x1141U // V One Multimedia, Pte., Ltd +#define UHS_VID_CYBERSCAN_TECHNOLOGIES 0x1142U // CyberScan Technologies, Inc. +#define UHS_VID_JAPAN_RADIO_COMPANY 0x1145U // Japan Radio Company +#define UHS_VID_SHIMANE_SANYO_ELECTRIC 0x1146U // Shimane SANYO Electric Co., Ltd. +#define UHS_VID_EVER_GREAT_ELECTRIC_WIRE_AND_CABLE 0x1147U // Ever Great Electric Wire and Cable Co., Ltd +#define UHS_VID_SPHAIRON_ACCESS_SYSTEMS 0x114bU // Sphairon Access Systems GmbH +#define UHS_VID_TINIUS_OLSEN_TESTING_MACHINE 0x114cU // Tinius Olsen Testing Machine Co., Inc. +#define UHS_VID_ALPHA_IMAGING_TECHNOLOGY 0x114dU // Alpha Imaging Technology Corp. +#define UHS_VID_WAVECOM 0x114fU // Wavecom +#define UHS_VID_SALIX_TECHNOLOGY 0x115bU // Salix Technology Co., Ltd. +#define UHS_VID_SECUGEN 0x1162U // Secugen Corp. +#define UHS_VID_DELORME_PUBLISHING 0x1163U // DeLorme Publishing, Inc. +#define UHS_VID_YUAN_HIGH_TECH_DEVELOPMENT 0x1164U // YUAN High-Tech Development Co., Ltd +#define UHS_VID_TELSON_ELECTRONICS 0x1165U // Telson Electronics Co., Ltd +#define UHS_VID_BANTAM_INTERACTIVE_TECHNOLOGIES 0x1166U // Bantam Interactive Technologies +#define UHS_VID_SALIENT_SYSTEMS 0x1167U // Salient Systems Corp. +#define UHS_VID_BIZCONN_INTERNATIONAL 0x1168U // BizConn International Corp. +#define UHS_VID_GIGASTORAGE 0x116eU // Gigastorage Corp. +#define UHS_VID_SILICON_10_TECHNOLOGY 0x116fU // Silicon 10 Technology Corp. +#define UHS_VID_SHENGYIH_STEEL_MOLD 0x1175U // Shengyih Steel Mold Co., Ltd +#define UHS_VID_SANTA_ELECTRONIC 0x117dU // Santa Electronic, Inc. +#define UHS_VID_JNC 0x117eU // JNC, Inc. +#define UHS_VID_VENTURE 0x1182U // Venture Corp., Ltd +#define UHS_VID_COMPAQ_COMPUTER_CORP_HEX_DIGITAL_DREAM_UNKNOWN 0x1183U // Compaq Computer Corp. [hex] (Digital Dream ?) +#define UHS_VID_KYOCERA_ELCO 0x1184U // Kyocera Elco Corp. +#define UHS_VID_BLOOMBERG_LP 0x1188U // Bloomberg L.P. +#define UHS_VID_ACER_COMMUNICATIONS_AND_MULTIMEDIA 0x1189U // Acer Communications & Multimedia +#define UHS_VID_YOU_YANG_TECHNOLOGY 0x118fU // You Yang Technology Co., Ltd +#define UHS_VID_TRIPACE 0x1190U // Tripace +#define UHS_VID_LOYALTY_FOUNDER_ENTERPRISE 0x1191U // Loyalty Founder Enterprise Co., Ltd +#define UHS_VID_YANKEE_ROBOTICS 0x1196U // Yankee Robotics, LLC +#define UHS_VID_TECHNOIMAGIA 0x1197U // Technoimagia Co., Ltd +#define UHS_VID_STARSHINE_TECHNOLOGY 0x1198U // StarShine Technology Corp. +#define UHS_VID_SIERRA_WIRELESS 0x1199U // Sierra Wireless, Inc. +#define UHS_VID_ZHAN_QI_TECHNOLOGY 0x119aU // ZHAN QI Technology Co., Ltd +#define UHS_VID_RUWIDO_AUSTRIA 0x119bU // ruwido austria GmbH +#define UHS_VID_CHIPCON_AS 0x11a0U // Chipcon AS +#define UHS_VID_TECHNOVAS 0x11a3U // Technovas Co., Ltd +#define UHS_VID_GLOBALMEDIA_GROUP 0x11aaU // GlobalMedia Group, LLC +#define UHS_VID_EXITO_ELECTRONICS 0x11abU // Exito Electronics Co., Ltd +#define UHS_VID_NIKE 0x11acU // Nike +#define UHS_VID_ATECH_FLASH_TECHNOLOGY 0x11b0U // ATECH FLASH TECHNOLOGY +#define UHS_VID_RANDD_INTERNATIONAL_NV 0x11beU // R&D International NV +#define UHS_VID_INMAX 0x11c5U // Inmax +#define UHS_VID_VERIFONE 0x11caU // VeriFone Inc +#define UHS_VID_TOPFIELD 0x11dbU // Topfield Co., Ltd. +#define UHS_VID_KI_TECHNOLOGY 0x11e6U // K.I. Technology Co. Ltd. +#define UHS_VID_SIEMENS_AG_1 0x11f5U // Siemens AG +#define UHS_VID_PROLIFIC 0x11f6U // Prolific +#define UHS_VID_ALCATEL_UNKNOWN 0x11f7U // Alcatel (?) +#define UHS_VID_TSC_AUTO_ID_TECHNOLOGY 0x1203U // TSC Auto ID Technology Co., Ltd +#define UHS_VID_INTERBIOMETRICS 0x1209U // InterBiometrics +#define UHS_VID_HUDSON_SOFT 0x120eU // Hudson Soft Co., Ltd +#define UHS_VID_MAGELLAN 0x120fU // Magellan +#define UHS_VID_DIGITECH 0x1210U // DigiTech +#define UHS_VID_JUNGSOFT 0x121eU // Jungsoft Co., Ltd +#define UHS_VID_UNKNOWN_MANUFACTURER_1 0x1221U // Unknown manufacturer +#define UHS_VID_SKYCABLE_ENTERPRISE 0x1223U // SKYCABLE ENTERPRISE. CO., LTD. +#define UHS_VID_DATAPAQ_LIMITED 0x1228U // Datapaq Limited +#define UHS_VID_CHIPIDEA_MICROELECTRONICA 0x1230U // Chipidea-Microelectronica, S.A. +#define UHS_VID_DENVER_ELECTRONICS 0x1233U // Denver Electronics +#define UHS_VID_BRAIN_ACTUATED_TECHNOLOGIES 0x1234U // Brain Actuated Technologies +#define UHS_VID_FOCUSRITE_NOVATION 0x1235U // Focusrite-Novation +#define UHS_VID_BELKIN 0x1241U // Belkin +#define UHS_VID_AIRVAST 0x124aU // AirVast +#define UHS_VID_NYKO_HONEY_BEE 0x124bU // Nyko (Honey Bee) +#define UHS_VID_MXI__MEMORY_EXPERTS_INTERNATIONAL 0x124cU // MXI - Memory Experts International, Inc. +#define UHS_VID_APOGEE 0x125cU // Apogee Inc. +#define UHS_VID_A_DATA_TECHNOLOGY 0x125fU // A-DATA Technology Co., Ltd. +#define UHS_VID_STANDARD_MICROSYSTEMS_3 0x1260U // Standard Microsystems Corp. +#define UHS_VID_COVIDIEN_ENERGY_BASED_DEVICES 0x1264U // Covidien Energy-based Devices +#define UHS_VID_PIRELLI_BROADBAND_SOLUTIONS 0x1266U // Pirelli Broadband Solutions +#define UHS_VID_LOGIC3_SPECTRAVIDEO_PLC 0x1267U // Logic3 / SpectraVideo plc +#define UHS_VID_ARISTOCRAT_TECHNOLOGIES 0x126cU // Aristocrat Technologies +#define UHS_VID_BEL_STEWART 0x126dU // Bel Stewart +#define UHS_VID_STROBE_DATA 0x126eU // Strobe Data, Inc. +#define UHS_VID_TWINMOS 0x126fU // TwinMOS +#define UHS_VID_ENSONIQ 0x1274U // Ensoniq +#define UHS_VID_XAXERO_MARINE_SOFTWARE_ENGINEERING 0x1275U // Xaxero Marine Software Engineering, Ltd. +#define UHS_VID_STARLIGHT_XPRESS 0x1278U // Starlight Xpress +#define UHS_VID_ZEBRIS_MEDICAL 0x1283U // zebris Medical GmbH +#define UHS_VID_MARVELL_SEMICONDUCTOR 0x1286U // Marvell Semiconductor, Inc. +#define UHS_VID_QUALCOMM_FLARION_TECHNOLOGIES_INC_LEADTEK_RESEARCH 0x1291U // Qualcomm Flarion Technologies, Inc. / Leadtek Research, Inc. +#define UHS_VID_INNOMEDIA_1 0x1292U // Innomedia +#define UHS_VID_BELKIN_COMPONENTS_HEX_ 0x1293U // Belkin Components [hex] +#define UHS_VID_RISO_KAGAKU 0x1294U // RISO KAGAKU CORP. +#define UHS_VID_CYBERTAN_TECHNOLOGY 0x129bU // CyberTAN Technology +#define UHS_VID_TRENDCHIP_TECHNOLOGIES 0x12a7U // Trendchip Technologies Corp. +#define UHS_VID_HONEY_BEE_ELECTRONIC_INTERNATIONAL 0x12abU // Honey Bee Electronic International Ltd. +#define UHS_VID_ZHEJIANG_XINYA_ELECTRONIC_TECHNOLOGY 0x12b8U // Zhejiang Xinya Electronic Technology Co., Ltd. +#define UHS_VID_E28 0x12b9U // E28 +#define UHS_VID_LICENSED_BY_SONY_COMPUTER_ENTERTAINMENT_AMERICA 0x12baU // Licensed by Sony Computer Entertainment America +#define UHS_VID_GEMBIRD 0x12bdU // Gembird +#define UHS_VID_AUTOCUE_GROUP 0x12c4U // Autocue Group Ltd +#define UHS_VID_DEXIN_1 0x12cfU // DEXIN +#define UHS_VID_HUAWEI_TECHNOLOGIES 0x12d1U // Huawei Technologies Co., Ltd. +#define UHS_VID_LINE_TECH_INDUSTRIAL 0x12d2U // LINE TECH INDUSTRIAL CO., LTD. +#define UHS_VID_EMS_DR_THOMAS_WUENSCHE 0x12d6U // EMS Dr. Thomas Wuensche +#define UHS_VID_BETTER_WIRE_FACTORY 0x12d7U // BETTER WIRE FACTORY CO., LTD. +#define UHS_VID_ARANEUS_INFORMATION_SYSTEMS_OY 0x12d8U // Araneus Information Systems Oy +#define UHS_VID_WALDORF_MUSIC 0x12e6U // Waldorf Music GmbH +#define UHS_VID_TAPWAVE 0x12efU // Tapwave, Inc. +#define UHS_VID_DYNAMIC_SYSTEM_ELECTRONICS 0x12f5U // Dynamic System Electronics Corp. +#define UHS_VID_MEMOREX_PRODUCTS 0x12f7U // Memorex Products, Inc. +#define UHS_VID_AIN_COMM_TECHNOLOGY 0x12fdU // AIN Comm. Technology Co., Ltd +#define UHS_VID_FASCINATING_ELECTRONICS 0x12ffU // Fascinating Electronics, Inc. +#define UHS_VID_TRANSCEND_INFORMATION 0x1307U // Transcend Information, Inc. +#define UHS_VID_SHUTTLE_1 0x1308U // Shuttle, Inc. +#define UHS_VID_ROPER 0x1310U // Roper +#define UHS_VID_ICS_ELECTRONICS 0x1312U // ICS Electronics +#define UHS_VID_THORLABS 0x1313U // ThorLabs +#define UHS_VID_NATURAL_POINT 0x131dU // Natural Point +#define UHS_VID_ENVARA 0x132aU // Envara Inc. +#define UHS_VID_KONICA_MINOLTA 0x132bU // Konica Minolta +#define UHS_VID_KEMPER_DIGITAL 0x133eU // Kemper Digital GmbH +#define UHS_VID_MOBILITY 0x1342U // Mobility +#define UHS_VID_CITIZEN_SYSTEMS 0x1343U // Citizen Systems +#define UHS_VID_SINO_LITE_TECHNOLOGY 0x1345U // Sino Lite Technology Corp. +#define UHS_VID_MORAVIAN_INSTRUMENTS 0x1347U // Moravian Instruments +#define UHS_VID_KATSURAGAWA_ELECTRIC 0x1348U // Katsuragawa Electric Co., Ltd. +#define UHS_VID_PANJIT_INTERNATIONAL 0x134cU // PanJit International Inc. +#define UHS_VID_DIGBYS_BITPILE_INC_DBA_D_BIT 0x134eU // Digby's Bitpile, Inc. DBA D Bit +#define UHS_VID_PANDE_MICROCOMPUTER_SYSTEMS 0x1357U // P&E Microcomputer Systems +#define UHS_VID_CONTROL_DEVELOPMENT 0x135fU // Control Development Inc. +#define UHS_VID_SEGGER 0x1366U // SEGGER +#define UHS_VID_STEC 0x136bU // STEC +#define UHS_VID_ANDOR_TECHNOLOGY 0x136eU // Andor Technology Ltd. +#define UHS_VID_SWISSBIT 0x1370U // Swissbit +#define UHS_VID_CNET_TECHNOLOGY 0x1371U // CNet Technology Inc. +#define UHS_VID_VIMTRON_ELECTRONICS 0x1376U // Vimtron Electronics Co., Ltd. +#define UHS_VID_SCAPS 0x137bU // SCAPS GmbH +#define UHS_VID_NETGEAR_2 0x1385U // Netgear, Inc +#define UHS_VID_VALIDITY_SENSORS 0x138aU // Validity Sensors, Inc. +#define UHS_VID_JUNGO 0x138eU // Jungo LTD +#define UHS_VID_TOMTOM_BV 0x1390U // TOMTOM B.V. +#define UHS_VID_IDEALTEK 0x1391U // IdealTEK, Inc. +#define UHS_VID_SENNHEISER_COMMUNICATIONS 0x1395U // Sennheiser Communications +#define UHS_VID_BEHRINGER_INTERNATIONAL 0x1397U // BEHRINGER International GmbH +#define UHS_VID_Q_TEC 0x1398U // Q-tec +#define UHS_VID_BALTECH 0x13adU // Baltech +#define UHS_VID_PERKINELMER_OPTOELECTRONICS 0x13b0U // PerkinElmer Optoelectronics +#define UHS_VID_LINKSYS_2 0x13b1U // Linksys +#define UHS_VID_ALESIS 0x13b2U // Alesis +#define UHS_VID_NIPPON_DICS 0x13b3U // Nippon Dics Co., Ltd. +#define UHS_VID_PCPLAY 0x13baU // PCPlay +#define UHS_VID_RICOH_PRINTING_SYSTEMS 0x13beU // Ricoh Printing Systems, Ltd. +#define UHS_VID_JYETAI_PRECISION_INDUSTRIAL 0x13caU // JyeTai Precision Industrial Co., Ltd. +#define UHS_VID_WISAIR 0x13cfU // Wisair Ltd. +#define UHS_VID_TECHSAN_ELECTRONICS 0x13d0U // Techsan Electronics Co., Ltd. +#define UHS_VID_A_MAX_TECHNOLOGY_MACAO_COMMERCIAL_OFFSHORE 0x13d1U // A-Max Technology Macao Commercial Offshore Co. Ltd. +#define UHS_VID_SHARK_MULTIMEDIA_1 0x13d2U // Shark Multimedia +#define UHS_VID_IMC_NETWORKS 0x13d3U // IMC Networks +#define UHS_VID_GUIDANCE_SOFTWARE 0x13d7U // Guidance Software, Inc. +#define UHS_VID_ALEREON 0x13dcU // ALEREON, INC. +#define UHS_VID_ITECH_DYNAMIC_LIMITED 0x13ddU // i.Tech Dynamic Limited +#define UHS_VID_KAIBO_WIRE_AND_CABLE_SHENZHEN 0x13e1U // Kaibo Wire & Cable (Shenzhen) Co., Ltd. +#define UHS_VID_RANE 0x13e5U // Rane +#define UHS_VID_TECHNOSCOPE 0x13e6U // TechnoScope Co., Ltd. +#define UHS_VID_HENGSTLER 0x13eaU // Hengstler +#define UHS_VID_ZYDACRON 0x13ecU // Zydacron +#define UHS_VID_MOSART 0x13eeU // MosArt +#define UHS_VID_INITIO_CORPORATION 0x13fdU // Initio Corporation +#define UHS_VID_KINGSTON_TECHNOLOGY_COMPANY_1 0x13feU // Kingston Technology Company Inc. +#define UHS_VID_AXXION_GROUP 0x1400U // Axxion Group Corp. +#define UHS_VID_BOWE_BELL_AND_HOWELL 0x1402U // Bowe Bell & Howell +#define UHS_VID_SITRONIX 0x1403U // Sitronix +#define UHS_VID_IDS_IMAGING_DEVELOPMENT_SYSTEMS 0x1409U // IDS Imaging Development Systems GmbH +#define UHS_VID_TELECHIPS 0x140eU // Telechips, Inc. +#define UHS_VID_NOVATEL_WIRELESS_1 0x1410U // Novatel Wireless +#define UHS_VID_NAM_TAI_EANDE_PRODUCTS_LTD_OR_OMNIVISION_TECHNOLOGIES 0x1415U // Nam Tai E&E Products Ltd. or OmniVision Technologies, Inc. +#define UHS_VID_ABILITY_ENTERPRISE 0x1419U // ABILITY ENTERPRISE CO., LTD. +#define UHS_VID_SENSOR_TECHNOLOGY 0x1421U // Sensor Technology +#define UHS_VID_VEGA_TECHNOLOGIES_INDUSTRIAL_AUSTRIA 0x1429U // Vega Technologies Industrial (Austria) Co. +#define UHS_VID_THALES_E_TRANSACTIONS 0x142aU // Thales E-Transactions +#define UHS_VID_ARBITER_SYSTEMS 0x142bU // Arbiter Systems, Inc. +#define UHS_VID_REDOCTANE 0x1430U // RedOctane +#define UHS_VID_PERTECH_RESOURCES 0x1431U // Pertech Resources, Inc. +#define UHS_VID_WISTRON_NEWEB 0x1435U // Wistron NeWeb +#define UHS_VID_DENALI_SOFTWARE 0x1436U // Denali Software, Inc. +#define UHS_VID_ALTEK_CORPORATION 0x143cU // Altek Corporation +#define UHS_VID_DIGILENT 0x1443U // Digilent +#define UHS_VID_XJGROUP 0x1446U // X.J.GROUP +#define UHS_VID_RADIO_SHACK 0x1453U // Radio Shack +#define UHS_VID_EXTENDING_WIRE_AND_CABLE 0x1456U // Extending Wire & Cable Co., Ltd. +#define UHS_VID_FIRST_INTERNATIONAL_COMPUTER_1 0x1457U // First International Computer, Inc. +#define UHS_VID_TRUST 0x145fU // Trust +#define UHS_VID_TATUNG 0x1460U // Tatung Co. +#define UHS_VID_STACCATO_COMMUNICATIONS 0x1461U // Staccato Communications +#define UHS_VID_MICRO_STAR_INTERNATIONAL_1 0x1462U // Micro Star International +#define UHS_VID_HUAWEI_3COM 0x1472U // Huawei-3Com +#define UHS_VID_FORMOSA_INDUSTRIAL_COMPUTING 0x147aU // Formosa Industrial Computing, Inc. +#define UHS_VID_UPEK 0x147eU // Upek +#define UHS_VID_HAMA_GMBH_AND_CO_KG 0x147fU // Hama GmbH & Co., KG +#define UHS_VID_VAILLANT 0x1482U // Vaillant +#define UHS_VID_ELSA_AG_HEX_ 0x1484U // Elsa AG [hex] +#define UHS_VID_SILICOM_1 0x1485U // Silicom +#define UHS_VID_DSP_GROUP 0x1487U // DSP Group, Ltd. +#define UHS_VID_EVATRONIX 0x148eU // EVATRONIX SA +#define UHS_VID_RALINK_TECHNOLOGY 0x148fU // Ralink Technology, Corp. +#define UHS_VID_FUTRONIC_TECHNOLOGY 0x1491U // Futronic Technology Co. Ltd. +#define UHS_VID_SUUNTO 0x1493U // Suunto +#define UHS_VID_PANSTRONG_COMPANY 0x1497U // Panstrong Company Ltd. +#define UHS_VID_MICROTEK_INTERNATIONAL_1 0x1498U // Microtek International Inc. +#define UHS_VID_IMAGINATION_TECHNOLOGIES 0x149aU // Imagination Technologies +#define UHS_VID_WIDEVIEW_TECHNOLOGY 0x14aaU // WideView Technology Inc. +#define UHS_VID_CTK_CORPORATION 0x14adU // CTK Corporation +#define UHS_VID_PRINTRONIX 0x14aeU // Printronix Inc. +#define UHS_VID_ATP_ELECTRONICS 0x14afU // ATP Electronics Inc. +#define UHS_VID_STARTECHCOM 0x14b0U // StarTech.com Ltd. +#define UHS_VID_RALINK_TECHNOLOGY_1 0x14b2U // Ralink Technology, Corp. +#define UHS_VID_ROCKWELL_AUTOMATION 0x14c0U // Rockwell Automation, Inc. +#define UHS_VID_GEMLIGHT_COMPUTER 0x14c2U // Gemlight Computer, Ltd +#define UHS_VID_ZYTRONIC 0x14c8U // Zytronic +#define UHS_VID_SUPER_TOP 0x14cdU // Super Top +#define UHS_VID_JAMER_INDUSTRIES 0x14d8U // JAMER INDUSTRIES CO., LTD. +#define UHS_VID_RARITAN_COMPUTER 0x14ddU // Raritan Computer, Inc. +#define UHS_VID_WINRADIO_COMMUNICATIONS 0x14e0U // WiNRADiO Communications +#define UHS_VID_DIALOGUE_TECHNOLOGY 0x14e1U // Dialogue Technology Corp. +#define UHS_VID_SAIN_INFORMATION_AND_COMMUNICATIONS 0x14e5U // SAIN Information & Communications Co., Ltd. +#define UHS_VID_PLANEX_COMMUNICATIONS_1 0x14eaU // Planex Communications +#define UHS_VID_SHURE 0x14edU // Shure Inc. +#define UHS_VID_TECHNISAT_DIGITAL 0x14f7U // TechniSat Digital GmbH +#define UHS_VID_ELLISYS_1 0x1500U // Ellisys +#define UHS_VID_PINE_TUM_ENTERPRISE 0x1501U // Pine-Tum Enterprise Co., Ltd. +#define UHS_VID_FIRST_INTERNATIONAL_COMPUTER_2 0x1509U // First International Computer, Inc. +#define UHS_VID_MEDMOBILE 0x1513U // medMobile +#define UHS_VID_ACTEL 0x1514U // Actel +#define UHS_VID_COMPUSA 0x1516U // CompUSA +#define UHS_VID_CHESHIRE_ENGINEERING 0x1518U // Cheshire Engineering Corp. +#define UHS_VID_COMNEON 0x1519U // Comneon +#define UHS_VID_BITWIRE 0x1520U // Bitwire Corp. +#define UHS_VID_ENE_TECHNOLOGY_1 0x1524U // ENE Technology Inc +#define UHS_VID_SILICON_PORTALS 0x1527U // Silicon Portals +#define UHS_VID_UBIQUAM 0x1529U // UBIQUAM Co., Ltd. +#define UHS_VID_THESYCON_SYSTEMSOFTWARE_AND_CONSULTING 0x152aU // Thesycon Systemsoftware & Consulting GmbH +#define UHS_VID_MIR_SRL 0x152bU // MIR Srl +#define UHS_VID_JMICRON_TECHNOLOGY_CORP_JMICRON_USA_TECHNOLOGY 0x152dU // JMicron Technology Corp. / JMicron USA Technology Corp. +#define UHS_VID_LG_HLDS 0x152eU // LG (HLDS) +#define UHS_VID_RAZER_USA 0x1532U // Razer USA, Ltd +#define UHS_VID_TERRATEC_ELECTRONIC_1 0x153bU // TerraTec Electronic GmbH +#define UHS_VID_U_BLOX_AG 0x1546U // U-Blox AG +#define UHS_VID_SG_INTEC_LTD_AND_CO_KG 0x1547U // SG Intec Ltd & Co KG +#define UHS_VID_CELECTRONIC 0x154aU // Celectronic GmbH +#define UHS_VID_PNY 0x154bU // PNY +#define UHS_VID_CONNECTCOUNTY_HOLDINGS_BERHAD 0x154dU // ConnectCounty Holdings Berhad +#define UHS_VID_DANDM_HOLDINGS_INC_DENONMARANTZ 0x154eU // D&M Holdings, Inc. (Denon/Marantz) +#define UHS_VID_SNBC 0x154fU // SNBC CO., Ltd +#define UHS_VID_PROLINK_MICROSYSTEMS 0x1554U // Prolink Microsystems Corp. +#define UHS_VID_OQO 0x1557U // OQO +#define UHS_VID_SUNF_PU_TECHNOLOGY 0x1568U // Sunf Pu Technology Co., Ltd +#define UHS_VID_QUANTUM_CORPORATION 0x156fU // Quantum Corporation +#define UHS_VID_ALLTOP_TECHNOLOGY 0x1570U // ALLTOP TECHNOLOGY CO., LTD. +#define UHS_VID_KETRON_SRL 0x157bU // Ketron SRL +#define UHS_VID_TRENDNET 0x157eU // TRENDnet +#define UHS_VID_FIBERLINE 0x1582U // Fiberline +#define UHS_VID_SMA_TECHNOLOGIE_AG 0x1587U // SMA Technologie AG +#define UHS_VID_OAKLEY 0x158dU // Oakley Inc. +#define UHS_VID_JDS_UNIPHASE_CORPORATION_JDSU 0x158eU // JDS Uniphase Corporation (JDSU) +#define UHS_VID_KUNSHAN_GUOJI_ELECTRONICS 0x1598U // Kunshan Guoji Electronics Co., Ltd. +#define UHS_VID_FREESCALE_SEMICONDUCTOR 0x15a2U // Freescale Semiconductor, Inc. +#define UHS_VID_AFATECH_TECHNOLOGIES 0x15a4U // Afatech Technologies, Inc. +#define UHS_VID_TEAMS_POWER_LIMITED 0x15a8U // Teams Power Limited +#define UHS_VID_GEMTEK 0x15a9U // Gemtek +#define UHS_VID_GEARWAY_ELECTRONICS_DONG_GUAN 0x15aaU // Gearway Electronics (Dong Guan) Co., Ltd. +#define UHS_VID_VMWARE_1 0x15adU // VMware Inc. +#define UHS_VID_OLIMEX 0x15baU // Olimex Ltd. +#define UHS_VID_XL_IMAGING 0x15c0U // XL Imaging +#define UHS_VID_SOUNDGRAPH 0x15c2U // SoundGraph Inc. +#define UHS_VID_ADVANCE_MULTIMEDIA_INTERNET_TECHNOLOGY_INC_AMIT 0x15c5U // Advance Multimedia Internet Technology Inc. (AMIT) +#define UHS_VID_LABORATOIRES_MXM 0x15c6U // Laboratoires MXM +#define UHS_VID_KTF_TECHNOLOGIES 0x15c8U // KTF Technologies +#define UHS_VID_D_BOX_TECHNOLOGIES 0x15c9U // D-Box Technologies +#define UHS_VID_TEXTECH_INTERNATIONAL 0x15caU // Textech International Ltd. +#define UHS_VID_COULOMB_ELECTRONICS 0x15d5U // Coulomb Electronics Ltd. +#define UHS_VID_TRUST_INTERNATIONAL_BV_1 0x15d9U // Trust International B.V. +#define UHS_VID_HYNIX_SEMICONDUCTOR 0x15dcU // Hynix Semiconductor Inc. +#define UHS_VID_SEONG_JI_INDUSTRIAL 0x15e0U // Seong Ji Industrial Co., Ltd. +#define UHS_VID_RSA 0x15e1U // RSA +#define UHS_VID_NUMARK 0x15e4U // Numark +#define UHS_VID_SOHOWARE 0x15e8U // SohoWare +#define UHS_VID_PACIFIC_DIGITAL 0x15e9U // Pacific Digital Corp. +#define UHS_VID_BELCARRA_TECHNOLOGIES 0x15ecU // Belcarra Technologies Corp. +#define UHS_VID_HANFTEK 0x15f4U // HanfTek +#define UHS_VID_TASCAM 0x1604U // Tascam +#define UHS_VID_UMAX_1 0x1606U // Umax +#define UHS_VID_INSIDE_OUT_NETWORKS_HEX_ 0x1608U // Inside Out Networks [hex] +#define UHS_VID_VIA_TECHNOLOGIES_1 0x160aU // VIA Technologies, Inc. +#define UHS_VID_INRO 0x160eU // INRO +#define UHS_VID_AMOI_ELECTRONICS 0x1614U // Amoi Electronics +#define UHS_VID_SONY_1 0x1617U // Sony Corp. +#define UHS_VID_L_AND_K_PRECISION_TECHNOLOGY 0x1619U // L & K Precision Technology Co., Ltd. +#define UHS_VID_WIONICS_RESEARCH 0x1621U // Wionics Research +#define UHS_VID_STONESTREET_ONE 0x1628U // Stonestreet One, Inc. +#define UHS_VID_AIRGO_NETWORKS 0x162aU // Airgo Networks Inc. +#define UHS_VID_WIQUEST_COMMUNICATIONS 0x162fU // WiQuest Communications, Inc. +#define UHS_VID_2WIRE_1 0x1630U // 2Wire, Inc. +#define UHS_VID_GOOD_WAY_TECHNOLOGY 0x1631U // Good Way Technology +#define UHS_VID_ENTREGA_HEX_ 0x1645U // Entrega [hex] +#define UHS_VID_SOFTEC_MICROSYSTEMS 0x1649U // SofTec Microsystems +#define UHS_VID_CHIPX 0x164aU // ChipX +#define UHS_VID_MATRIX_VISION 0x164cU // Matrix Vision GmbH +#define UHS_VID_STRUCK_INNOVATIVE_SYSTEME 0x1657U // Struck Innovative Systeme GmbH +#define UHS_VID_FRONTIER_DESIGN_GROUP 0x165bU // Frontier Design Group +#define UHS_VID_KONDO_KAGAKU 0x165cU // Kondo Kagaku +#define UHS_VID_CREATIX_POLYMEDIA 0x1660U // Creatix Polymedia GmbH +#define UHS_VID_GIGA_TMS 0x1667U // GIGA-TMS INC. +#define UHS_VID_ACTIONTEC_ELECTRONICS_INC_HEX_ 0x1668U // Actiontec Electronics, Inc. [hex] +#define UHS_VID_PIKRON_LTD_HEX_ 0x1669U // PiKRON Ltd. [hex] +#define UHS_VID_CLIPSAL 0x166aU // Clipsal +#define UHS_VID_CHINA_HUADA_INTEGRATED_CIRCUIT_DESIGN_GROUP_CO_LTD_CIDC_GROUP 0x1677U // China Huada Integrated Circuit Design (Group) Co., Ltd. (CIDC Group) +#define UHS_VID_TOTAL_PHASE 0x1679U // Total Phase +#define UHS_VID_GOLDEN_BRIDGE_ELECTECH_1 0x1680U // Golden Bridge Electech Inc. +#define UHS_VID_PREVO_TECHNOLOGIES 0x1681U // Prevo Technologies, Inc. +#define UHS_VID_MAXWISE_PRODUCTION_ENTERPRISE 0x1682U // Maxwise Production Enterprise Ltd. +#define UHS_VID_GODSPEED_COMPUTER 0x1684U // Godspeed Computer Corp. +#define UHS_VID_DELOCK 0x1685U // Delock +#define UHS_VID_ZOOM_CORPORATION 0x1686U // ZOOM Corporation +#define UHS_VID_KINGMAX_DIGITAL 0x1687U // Kingmax Digital Inc. +#define UHS_VID_SAAB 0x1688U // Saab AB +#define UHS_VID_RAZER_USA_1 0x1689U // Razer USA, Ltd +#define UHS_VID_ATHEROS_COMMUNICATIONS_1 0x168cU // Atheros Communications +#define UHS_VID_ASKEY_COMPUTER_CORP_HEX_ 0x1690U // Askey Computer Corp. [hex] +#define UHS_VID_HITACHI_VIDEO_AND_INFORMATION_SYSTEM 0x1696U // Hitachi Video and Information System, Inc. +#define UHS_VID_VTEC_TEST 0x1697U // VTec Test, Inc. +#define UHS_VID_SHENZHEN_ZHENGERYA_CABLE 0x16a5U // Shenzhen Zhengerya Cable Co., Ltd. +#define UHS_VID_UNIGRAF 0x16a6U // Unigraf +#define UHS_VID_GLOBAL_SUN_TECHNOLOGY_1 0x16abU // Global Sun Technology +#define UHS_VID_DONGGUAN_CHINGLUNG_WIRE_AND_CABLE 0x16acU // Dongguan ChingLung Wire & Cable Co., Ltd. +#define UHS_VID_ISTATION 0x16b4U // iStation +#define UHS_VID_PERSENTEC 0x16b5U // Persentec, Inc. +#define UHS_VID_VAN_OOIJEN_TECHNISCHE_INFORMATICA 0x16c0U // Van Ooijen Technische Informatica +#define UHS_VID_WIRELESS_CABLES 0x16caU // Wireless Cables, Inc. +#define UHS_VID_SILEX_TECHNOLOGY 0x16ccU // silex technology, Inc. +#define UHS_VID_MCS 0x16d0U // MCS +#define UHS_VID_SUPREMA 0x16d1U // Suprema Inc. +#define UHS_VID_FRONTLINE_TEST_EQUIPMENT 0x16d3U // Frontline Test Equipment, Inc. +#define UHS_VID_ANYDATA_CORPORATION 0x16d5U // AnyDATA Corporation +#define UHS_VID_JABLOCOM_SRO 0x16d6U // JABLOCOM s.r.o. +#define UHS_VID_CMOTECH 0x16d8U // CMOTECH Co., Ltd. +#define UHS_VID_WIENER_PLEIN_AND_BAUS 0x16dcU // Wiener, Plein & Baus +#define UHS_VID_KING_BILLION_ELECTRONICS 0x16dfU // King Billion Electronics Co., Ltd. +#define UHS_VID_GN_RESOUND_AS 0x16f0U // GN ReSound A/S +#define UHS_VID_FUTURELOGIC 0x16f5U // Futurelogic Inc. +#define UHS_VID_BLUEVIEW_TECHNOLOGIES 0x1706U // BlueView Technologies, Inc. +#define UHS_VID_ARTIMI 0x1707U // ARTIMI +#define UHS_VID_SWISSONIC 0x170bU // Swissonic +#define UHS_VID_AVNERA 0x170dU // Avnera +#define UHS_VID_LEICA_MICROSYSTEMS 0x1711U // Leica Microsystems +#define UHS_VID_MEYER_INSTRUMENTS_MIS 0x1724U // Meyer Instruments (MIS) +#define UHS_VID_VITESSE_SEMICONDUCTOR 0x1725U // Vitesse Semiconductor +#define UHS_VID_AXESSTEL 0x1726U // Axesstel, Inc. +#define UHS_VID_WALTOP_INTERNATIONAL 0x172fU // Waltop International Corp. +#define UHS_VID_CELLINK_TECHNOLOGY 0x1733U // Cellink Technology Co., Ltd +#define UHS_VID_CANON_IMAGING_SYSTEM_TECHNOLOGIES 0x1736U // CANON IMAGING SYSTEM TECHNOLOGIES INC. +#define UHS_VID_LINKSYS_3 0x1737U // Linksys +#define UHS_VID_QSENN 0x173dU // QSENN +#define UHS_VID_SENAO 0x1740U // Senao +#define UHS_VID_GENERAL_ATOMICS 0x1743U // General Atomics +#define UHS_VID_MQP_ELECTRONICS 0x1748U // MQP Electronics +#define UHS_VID_ASMEDIA_TECHNOLOGY 0x174cU // ASMedia Technology Inc. +#define UHS_VID_SYNTEK 0x174fU // Syntek +#define UHS_VID_GERTEC_TELECOMUNICACOES_LTDA 0x1753U // GERTEC Telecomunicacoes Ltda. +#define UHS_VID_ENENSYS_TECHNOLOGIES 0x1756U // ENENSYS Technologies +#define UHS_VID_LUCIDPORT_TECHNOLOGY 0x1759U // LucidPort Technology, Inc. +#define UHS_VID_ASUSTEK_COMPUTER_INC_WRONG_ID 0x1761U // ASUSTek Computer, Inc. (wrong ID) +#define UHS_VID_SYSTEM_LEVEL_SOLUTIONS 0x1772U // System Level Solutions, Inc. +#define UHS_VID_AROWANA 0x1776U // Arowana +#define UHS_VID_SWEEX 0x177fU // Sweex +#define UHS_VID_MULTIPLE_VENDORS 0x1781U // Multiple Vendors +#define UHS_VID_SPREADTRUM_COMMUNICATIONS 0x1782U // Spreadtrum Communications Inc. +#define UHS_VID_TOPSEED_TECHNOLOGY 0x1784U // TopSeed Technology Corp. +#define UHS_VID_ATI_AIB 0x1787U // ATI AIB +#define UHS_VID_SHENZHEN_LITKCONN_TECHNOLOGY 0x1788U // ShenZhen Litkconn Technology Co., Ltd. +#define UHS_VID_PRINTREX 0x1796U // Printrex, Inc. +#define UHS_VID_JALCO 0x1797U // JALCO CO., LTD. +#define UHS_VID_THALES_NORWAY_AS 0x1799U // Thales Norway A/S +#define UHS_VID_RICAVISION_INTERNATIONAL 0x179dU // Ricavision International, Inc. +#define UHS_VID_SAMSON_TECHNOLOGIES 0x17a0U // Samson Technologies Corp. +#define UHS_VID_CONCEPT2 0x17a4U // Concept2 +#define UHS_VID_ADVANCED_CONNECTION_TECHNOLOGY 0x17a5U // Advanced Connection Technology Inc. +#define UHS_VID_MICOMSOFT 0x17a7U // MICOMSOFT CO., LTD. +#define UHS_VID_KAMSTRUP_AS 0x17a8U // Kamstrup A/S +#define UHS_VID_GREY_INNOVATION 0x17b3U // Grey Innovation +#define UHS_VID_LUNATONE 0x17b5U // Lunatone +#define UHS_VID_SAURIS 0x17baU // SAURIS GmbH +#define UHS_VID_SINGIM_INTERNATIONAL 0x17c3U // Singim International Corp. +#define UHS_VID_NATIVE_INSTRUMENTS 0x17ccU // Native Instruments +#define UHS_VID_HIP_HING_CABLE_AND_PLUG_MFY 0x17cfU // Hip Hing Cable & Plug Mfy. Ltd. +#define UHS_VID_SANFORD_LP 0x17d0U // Sanford L.P. +#define UHS_VID_KOREA_TECHTRON 0x17d3U // Korea Techtron Co., Ltd. +#define UHS_VID_DISPLAYLINK 0x17e9U // DisplayLink +#define UHS_VID_CORNICE 0x17ebU // Cornice, Inc. +#define UHS_VID_LENOVO 0x17efU // Lenovo +#define UHS_VID_WAVESENSE 0x17f4U // WaveSense +#define UHS_VID_KK_ROCKY 0x17f5U // K.K. Rocky +#define UHS_VID_UNICOMP 0x17f6U // Unicomp, Inc +#define UHS_VID_ADVANTECH 0x1809U // Advantech +#define UHS_VID_TWINHAN 0x1822U // Twinhan +#define UHS_VID_GWO_JINN_INDUSTRIES 0x1831U // Gwo Jinn Industries Co., Ltd. +#define UHS_VID_HUIZHOU_SHENGHUA_INDUSTRIAL 0x1832U // Huizhou Shenghua Industrial Co., Ltd. +#define UHS_VID_VIVOPHONE 0x183dU // VIVOphone +#define UHS_VID_VAISALA 0x1843U // Vaisala +#define UHS_VID_ASROCK_INCORPORATION 0x1849U // ASRock Incorporation +#define UHS_VID_GYROCOM_CANDC 0x1852U // GYROCOM C&C Co., LTD +#define UHS_VID_MEMORY_DEVICES 0x1854U // Memory Devices Ltd. +#define UHS_VID_COMPRO 0x185bU // Compro +#define UHS_VID_TECH_TECHNOLOGY_INDUSTRIAL_COMPANY 0x1861U // Tech Technology Industrial Company +#define UHS_VID_TERIDIAN_SEMICONDUCTOR 0x1862U // Teridian Semiconductor Corp. +#define UHS_VID_NEXIO_1 0x1870U // Nexio Co., Ltd +#define UHS_VID_AVEO_TECHNOLOGY 0x1871U // Aveo Technology Corp. +#define UHS_VID_NAVILOCK 0x1873U // Navilock +#define UHS_VID_ALIENWARE_CORPORATION 0x187cU // Alienware Corporation +#define UHS_VID_SIANO_MOBILE_SILICON 0x187fU // Siano Mobile Silicon +#define UHS_VID_VAST_TECHNOLOGIES_1 0x1892U // Vast Technologies, Inc. +#define UHS_VID_TOPSEED 0x1894U // Topseed +#define UHS_VID_EVERTOP_WIRE_CABLE 0x1897U // Evertop Wire Cable Co. +#define UHS_VID_3SHAPE_AS 0x189fU // 3Shape A/S +#define UHS_VID_CSSN 0x18a4U // CSSN +#define UHS_VID_VERBATIM 0x18a5U // Verbatim, Ltd +#define UHS_VID_PETALYNX 0x18b1U // Petalynx +#define UHS_VID_E3C_TECHNOLOGIES 0x18b4U // e3C Technologies +#define UHS_VID_MIKKON_TECHNOLOGY_LIMITED 0x18b6U // Mikkon Technology Limited +#define UHS_VID_ZOTEK_ELECTRONIC 0x18b7U // Zotek Electronic Co., Ltd. +#define UHS_VID_AMIT_TECHNOLOGY 0x18c5U // AMIT Technology, Inc. +#define UHS_VID_ECAMM 0x18cdU // Ecamm +#define UHS_VID_GOOGLE 0x18d1U // Google Inc. +#define UHS_VID_STARLINE_INTERNATIONAL_GROUP_LIMITED 0x18d5U // Starline International Group Limited +#define UHS_VID_KABA 0x18d9U // Kaba +#define UHS_VID_LKC_TECHNOLOGIES 0x18dcU // LKC Technologies, Inc. +#define UHS_VID_PLANON_SYSTEM_SOLUTIONS 0x18ddU // Planon System Solutions Inc. +#define UHS_VID_FITIPOWER_INTEGRATED_TECHNOLOGY 0x18e3U // Fitipower Integrated Technology Inc +#define UHS_VID_QCOM 0x18e8U // Qcom +#define UHS_VID_MATROX_GRAPHICS 0x18eaU // Matrox Graphics, Inc. +#define UHS_VID_ARKMICRO_TECHNOLOGIES 0x18ecU // Arkmicro Technologies Inc. +#define UHS_VID_FINEARCH 0x18fdU // FineArch Inc. +#define UHS_VID_GEMBIRD_1 0x1908U // GEMBIRD +#define UHS_VID_MOTOROLA_GSG 0x190dU // Motorola GSG +#define UHS_VID_ALCO_DIGITAL_DEVICES_LIMITED 0x1914U // Alco Digital Devices Limited +#define UHS_VID_NORDIC_SEMICONDUCTOR_ASA 0x1915U // Nordic Semiconductor ASA +#define UHS_VID_FITLINXX 0x1923U // FitLinxx +#define UHS_VID_NEXTWINDOW 0x1926U // NextWindow +#define UHS_VID_AVAGO_TECHNOLOGIES_PTE 0x192fU // Avago Technologies, Pte. +#define UHS_VID_SHENZHEN_XIANHE_TECHNOLOGY 0x1930U // Shenzhen Xianhe Technology Co., Ltd. +#define UHS_VID_NINGBO_BROAD_TELECOMMUNICATION 0x1931U // Ningbo Broad Telecommunication Co., Ltd. +#define UHS_VID_FEATURE_INTEGRATION_TECHNOLOGY_INC_FINTEK 0x1934U // Feature Integration Technology Inc. (Fintek) +#define UHS_VID_DREAM_LINK 0x1941U // Dream Link +#define UHS_VID_SENSORAY 0x1943U // Sensoray Co., Inc. +#define UHS_VID_LAB126 0x1949U // Lab126, Inc. +#define UHS_VID_PRESONUS_AUDIO_ELECTRONICS 0x194fU // PreSonus Audio Electronics, Inc. +#define UHS_VID_HYPERSTONE_AG 0x1951U // Hyperstone AG +#define UHS_VID_IRONKEY 0x1953U // Ironkey Inc. +#define UHS_VID_RADIIENT_TECHNOLOGIES 0x1954U // Radiient Technologies +#define UHS_VID_ITRON_TECHNOLOGY_IONE 0x195dU // Itron Technology iONE +#define UHS_VID_UNIDEN_CORPORATION 0x1965U // Uniden Corporation +#define UHS_VID_CASIO_HITACHI_MOBILE_COMMUNICATIONS 0x1967U // CASIO HITACHI Mobile Communications Co., Ltd. +#define UHS_VID_WISPRO_TECHNOLOGY 0x196bU // Wispro Technology Inc. +#define UHS_VID_DANE_ELEC_CORP_USA 0x1970U // Dane-Elec Corp. USA +#define UHS_VID_DONGGUAN_GUNEETAL_WIRE_AND_CABLE 0x1975U // Dongguan Guneetal Wire & Cable Co., Ltd. +#define UHS_VID_CHIPSBRAND_MICROELECTRONICS_HK 0x1976U // Chipsbrand Microelectronics (HK) Co., Ltd. +#define UHS_VID_T_LOGIC 0x1977U // T-Logic +#define UHS_VID_LEUZE_ELECTRONIC 0x197dU // Leuze electronic +#define UHS_VID_NUCONN_TECHNOLOGY 0x1989U // Nuconn Technology Corp. +#define UHS_VID_BECEEM_COMMUNICATIONS 0x198fU // Beceem Communications Inc. +#define UHS_VID_ACRON_PRECISION_INDUSTRIAL 0x1990U // Acron Precision Industrial Co., Ltd. +#define UHS_VID_TRILLIUM_TECHNOLOGY_PTY 0x1995U // Trillium Technology Pty. Ltd. +#define UHS_VID_PIXELINK 0x1996U // PixeLINK +#define UHS_VID_MICROSTRAIN 0x199bU // MicroStrain, Inc. +#define UHS_VID_THE_IMAGING_SOURCE_EUROPE 0x199eU // The Imaging Source Europe GmbH +#define UHS_VID_BENICA_CORPORATION 0x199fU // Benica Corporation +#define UHS_VID_BIFORST_TECHNOLOGY 0x19a8U // Biforst Technology Inc. +#define UHS_VID_BODELIN 0x19abU // Bodelin +#define UHS_VID_S_LIFE 0x19afU // S Life +#define UHS_VID_BATRONIX 0x19b2U // Batronix +#define UHS_VID_CELESTRON 0x19b4U // Celestron +#define UHS_VID_B_AND_W_GROUP 0x19b5U // B & W Group +#define UHS_VID_INFOTECH_LOGISTIC 0x19b6U // Infotech Logistic, LLC +#define UHS_VID_DATA_ROBOTICS 0x19b9U // Data Robotics +#define UHS_VID_FUTUBA 0x19c2U // Futuba +#define UHS_VID_MINDTRIBE 0x19caU // Mindtribe +#define UHS_VID_PARROT 0x19cfU // Parrot SA +#define UHS_VID_ZTE_WCDMA_TECHNOLOGIES_MSM 0x19d2U // ZTE WCDMA Technologies MSM +#define UHS_VID_KFI_PRINTERS 0x19dbU // KFI Printers +#define UHS_VID_WEIDUAN_ELECTRONIC_ACCESSORY_SZ 0x19e1U // WeiDuan Electronic Accessory (S.Z.) Co., Ltd. +#define UHS_VID_INDUSTRIAL_TECHNOLOGY_RESEARCH_INSTITUTE 0x19e8U // Industrial Technology Research Institute +#define UHS_VID_PAK_HENG_TECHNOLOGY_SHENZHEN 0x19efU // Pak Heng Technology (Shenzhen) Co., Ltd. +#define UHS_VID_RODE_MICROPHONES 0x19f7U // RODE Microphones +#define UHS_VID_GAMPAQ_COLTD 0x19faU // Gampaq Co.Ltd +#define UHS_VID_DYNEX 0x19ffU // Dynex +#define UHS_VID_BELLWOOD_INTERNATIONAL 0x1a08U // Bellwood International, Inc. +#define UHS_VID_USB_IF_NON_WORKSHOP 0x1a0aU // USB-IF non-workshop +#define UHS_VID_KES 0x1a12U // KES Co., Ltd. +#define UHS_VID_VEHO 0x1a1dU // Veho +#define UHS_VID_AMPHENOL_EAST_ASIA 0x1a25U // Amphenol East Asia Ltd. +#define UHS_VID_SEAGATE_BRANDED_SOLUTIONS 0x1a2aU // Seagate Branded Solutions +#define UHS_VID_CHINA_RESOURCE_SEMICO 0x1a2cU // China Resource Semico Co., Ltd +#define UHS_VID_QUANTA_MICROSYSTEMS 0x1a32U // Quanta Microsystems, Inc. +#define UHS_VID_ACRUX 0x1a34U // ACRUX +#define UHS_VID_BIWIN_TECHNOLOGY 0x1a36U // Biwin Technology Ltd. +#define UHS_VID_TERMINUS_TECHNOLOGY 0x1a40U // Terminus Technology Inc. +#define UHS_VID_ACTION_ELECTRONICS 0x1a41U // Action Electronics Co., Ltd. +#define UHS_VID_VASCO_DATA_SECURITY_INTERNATIONAL 0x1a44U // VASCO Data Security International +#define UHS_VID_SILICON_IMAGE 0x1a4aU // Silicon Image +#define UHS_VID_SAFEBOOT_INTERNATIONAL_BV 0x1a4bU // SafeBoot International B.V. +#define UHS_VID_TANDBERG_DATA 0x1a5aU // Tandberg Data +#define UHS_VID_ABBOTT_DIABETES_CARE 0x1a61U // Abbott Diabetes Care +#define UHS_VID_SPANSION 0x1a6aU // Spansion Inc. +#define UHS_VID_SAMYOUNG_ELECTRONICS 0x1a6dU // SamYoung Electronics Co., Ltd +#define UHS_VID_GLOBAL_UNICHIP 0x1a6eU // Global Unichip Corp. +#define UHS_VID_SAGEM_ORGA 0x1a6fU // Sagem Orga GmbH +#define UHS_VID_PHYSIK_INSTRUMENTE 0x1a72U // Physik Instrumente +#define UHS_VID_BAYER_HEALTH_CARE 0x1a79U // Bayer Health Care LLC +#define UHS_VID_LUMBERG_CONNECT_GMBH_AND_CO_KG 0x1a7bU // Lumberg Connect GmbH & Co. KG +#define UHS_VID_EVOLUENT 0x1a7cU // Evoluent +#define UHS_VID_HOLTEK_SEMICONDUCTOR_1 0x1a81U // Holtek Semiconductor, Inc. +#define UHS_VID_QINHENG_ELECTRONICS 0x1a86U // QinHeng Electronics +#define UHS_VID_DYNALITH_SYSTEMS 0x1a89U // Dynalith Systems Co., Ltd. +#define UHS_VID_SGS_TAIWAN 0x1a8bU // SGS Taiwan Ltd. +#define UHS_VID_BANDRICH 0x1a8dU // BandRich, Inc. +#define UHS_VID_LEICA_CAMERA_AG 0x1a98U // Leica Camera AG +#define UHS_VID_DATA_DRIVE_THRU 0x1aa4U // Data Drive Thru, Inc. +#define UHS_VID_UBEACON_TECHNOLOGIES 0x1aa5U // UBeacon Technologies, Inc. +#define UHS_VID_EFORTUNE_TECHNOLOGY 0x1aa6U // eFortune Technology Corp. +#define UHS_VID_KEETOUCH 0x1aadU // KeeTouch +#define UHS_VID_RIGOL_TECHNOLOGIES 0x1ab1U // Rigol Technologies +#define UHS_VID_SALCOMP_PLC 0x1acbU // Salcomp Plc +#define UHS_VID_MIDIPLUS 0x1accU // Midiplus Co, Ltd. +#define UHS_VID_DESAY_WIRE 0x1ad1U // Desay Wire Co., Ltd. +#define UHS_VID_APS 0x1ad4U // APS +#define UHS_VID_SEL_C662_SERIAL_CABLE 0x1adbU // SEL C662 Serial Cable +#define UHS_VID_IC_DESIGN_REINHARD_GOTTINGER 0x1ae4U // ic-design Reinhard Gottinger GmbH +#define UHS_VID_X_TENSIONS 0x1ae7U // X-TENSIONS +#define UHS_VID_HIGH_TOP_PRECISION_ELECTRONIC 0x1aedU // High Top Precision Electronic Co., Ltd. +#define UHS_VID_CONNTECH_ELECTRONIC_SUZHOU_CORPORATION 0x1aefU // Conntech Electronic (Suzhou) Corporation +#define UHS_VID_CONNECT_ONE 0x1af1U // Connect One Ltd. +#define UHS_VID_A_EBERLE_GMBH_AND_CO_KG 0x1afeU // A. Eberle GmbH & Co. KG +#define UHS_VID_MEILHAUS_ELECTRONIC 0x1b04U // Meilhaus Electronic GmbH +#define UHS_VID_BLUTRONICS_SRL 0x1b0eU // BLUTRONICS S.r.l. +#define UHS_VID_CORSAIR 0x1b1cU // Corsair +#define UHS_VID_MSTAR_SEMICONDUCTOR 0x1b20U // MStar Semiconductor, Inc. +#define UHS_VID_WILINX 0x1b22U // WiLinx Corp. +#define UHS_VID_CELLEX_POWER_PRODUCTS 0x1b26U // Cellex Power Products, Inc. +#define UHS_VID_CURRENT_ELECTRONICS 0x1b27U // Current Electronics Inc. +#define UHS_VID_NAVISIS 0x1b28U // NAVIsis Inc. +#define UHS_VID_UGOBE_LIFE_FORMS 0x1b32U // Ugobe Life Forms, Inc. +#define UHS_VID_VIXS_SYSTEMS 0x1b36U // ViXS Systems, Inc. +#define UHS_VID_IPASSION_TECHNOLOGY 0x1b3bU // iPassion Technology Inc. +#define UHS_VID_GENERALPLUS_TECHNOLOGY 0x1b3fU // Generalplus Technology Inc. +#define UHS_VID_ENERGIZER_HOLDINGS 0x1b47U // Energizer Holdings, Inc. +#define UHS_VID_PLASTRON_PRECISION 0x1b48U // Plastron Precision Co., Ltd. +#define UHS_VID_ARH 0x1b52U // ARH Inc. +#define UHS_VID_KS_TERMINALS 0x1b59U // K.S. Terminals Inc. +#define UHS_VID_CHAO_ZHOU_KAI_YUAN_ELECTRIC 0x1b5aU // Chao Zhou Kai Yuan Electric Co., Ltd. +#define UHS_VID_THE_HONG_KONG_STANDARDS_AND_TESTING_CENTRE 0x1b65U // The Hong Kong Standards and Testing Centre Ltd. +#define UHS_VID_FUSHICAI 0x1b71U // Fushicai +#define UHS_VID_ATERGI_TECHNOLOGY 0x1b72U // ATERGI TECHNOLOGY CO., LTD. +#define UHS_VID_FRESCO_LOGIC 0x1b73U // Fresco Logic +#define UHS_VID_OVISLINK 0x1b75U // Ovislink Corp. +#define UHS_VID_LEGEND_SILICON 0x1b76U // Legend Silicon Corp. +#define UHS_VID_AFATECH 0x1b80U // Afatech +#define UHS_VID_DONGGUAN_GUANSHANG_ELECTRONICS 0x1b86U // Dongguan Guanshang Electronics Co., Ltd. +#define UHS_VID_SHENMING_ELECTRON_DONG_GUAN 0x1b88U // ShenMing Electron (Dong Guan) Co., Ltd. +#define UHS_VID_ALTIUM_LIMITED 0x1b8cU // Altium Limited +#define UHS_VID_E_MOVE_TECHNOLOGY 0x1b8dU // e-MOVE Technology Co., Ltd. +#define UHS_VID_AMLOGIC 0x1b8eU // Amlogic, Inc. +#define UHS_VID_MA_LABS 0x1b8fU // MA LABS, Inc. +#define UHS_VID_N_TRIG 0x1b96U // N-Trig +#define UHS_VID_YMAX_COMMUNICATIONS 0x1b98U // YMax Communications Corp. +#define UHS_VID_SHENZHEN_YUANCHUAN_ELECTRONIC 0x1b99U // Shenzhen Yuanchuan Electronic +#define UHS_VID_JINQ_CHERN_ENTERPRISE 0x1ba1U // JINQ CHERN ENTERPRISE CO., LTD. +#define UHS_VID_LITE_METALS_AND_PLASTIC_SHENZHEN 0x1ba2U // Lite Metals & Plastic (Shenzhen) Co., Ltd. +#define UHS_VID_EMBER_CORPORATION 0x1ba4U // Ember Corporation +#define UHS_VID_ABILIS_SYSTEMS 0x1ba6U // Abilis Systems +#define UHS_VID_CHINA_TELECOMMUNICATION_TECHNOLOGY_LABS 0x1ba8U // China Telecommunication Technology Labs +#define UHS_VID_HARMONIX_MUSIC 0x1badU // Harmonix Music +#define UHS_VID_VUZIX_CORPORATION 0x1baeU // Vuzix Corporation +#define UHS_VID_T_AND_A_MOBILE_PHONES 0x1bbbU // T & A Mobile Phones +#define UHS_VID_FORD_MOTOR 0x1bc4U // Ford Motor Co. +#define UHS_VID_AVIXE_TECHNOLOGY_CHINA 0x1bc5U // AVIXE Technology (China) Ltd. +#define UHS_VID_TELIT_WIRELESS_SOLUTIONS 0x1bc7U // Telit Wireless Solutions +#define UHS_VID_CONTAC_CABLE_INDUSTRIAL_LIMITED 0x1bceU // Contac Cable Industrial Limited +#define UHS_VID_SUNPLUS_INNOVATION_TECHNOLOGY 0x1bcfU // Sunplus Innovation Technology Inc. +#define UHS_VID_HANGZHOU_RIYUE_ELECTRONIC 0x1bd0U // Hangzhou Riyue Electronic Co., Ltd. +#define UHS_VID_BG_SYSTEMS 0x1bd5U // BG Systems, Inc. +#define UHS_VID_P_TWO_INDUSTRIES 0x1bdeU // P-TWO INDUSTRIES, INC. +#define UHS_VID_SHENZHEN_TONGYUAN_NETWORK_COMMUNICATION_CABLES 0x1befU // Shenzhen Tongyuan Network-Communication Cables Co., Ltd +#define UHS_VID_REALVISION 0x1bf0U // RealVision Inc. +#define UHS_VID_EXTRANET_SYSTEMS 0x1bf5U // Extranet Systems Inc. +#define UHS_VID_ORIENT_SEMICONDUCTOR_ELECTRONICS 0x1bf6U // Orient Semiconductor Electronics, Ltd. +#define UHS_VID_TOUCHPACK 0x1bfdU // TouchPack +#define UHS_VID_KRETON_CORPORATION 0x1c02U // Kreton Corporation +#define UHS_VID_QNAP_SYSTEM 0x1c04U // QNAP System Inc. +#define UHS_VID_IONICS_EMS 0x1c0cU // Ionics EMS, Inc. +#define UHS_VID_RELM_WIRELESS 0x1c0dU // Relm Wireless +#define UHS_VID_LANTERRA_INDUSTRIAL 0x1c10U // Lanterra Industrial Co., Ltd. +#define UHS_VID_ALECTRONIC_LIMITED 0x1c13U // ALECTRONIC LIMITED +#define UHS_VID_DATEL_ELECTRONICS 0x1c1aU // Datel Electronics Ltd. +#define UHS_VID_VOLKSWAGEN_OF_AMERICA 0x1c1bU // Volkswagen of America, Inc. +#define UHS_VID_GOLDVISH 0x1c1fU // Goldvish S.A. +#define UHS_VID_FUJI_ELECTRIC_DEVICE_TECHNOLOGY 0x1c20U // Fuji Electric Device Technology Co., Ltd. +#define UHS_VID_ADDMM 0x1c21U // ADDMM LLC +#define UHS_VID_ZHONGSHAN_CHIANG_YU_ELECTRIC 0x1c22U // ZHONGSHAN CHIANG YU ELECTRIC CO., LTD. +#define UHS_VID_SHANGHAI_HAIYING_ELECTRONICS 0x1c26U // Shanghai Haiying Electronics Co., Ltd. +#define UHS_VID_HUIYANG_D_AND_S_CABLE 0x1c27U // HuiYang D & S Cable Co., Ltd. +#define UHS_VID_ELSTER 0x1c29U // Elster GmbH +#define UHS_VID_LS_CABLE 0x1c31U // LS Cable Ltd. +#define UHS_VID_SPRINGCARD 0x1c34U // SpringCard +#define UHS_VID_AUTHORIZER_TECHNOLOGIES 0x1c37U // Authorizer Technologies, Inc. +#define UHS_VID_NONIN_MEDICAL 0x1c3dU // NONIN MEDICAL INC. +#define UHS_VID_WEP_PERIPHERALS 0x1c3eU // Wep Peripherals +#define UHS_VID_EZPROTOTYPES 0x1c40U // EZPrototypes +#define UHS_VID_CHERNG_WEEI_TECHNOLOGY 0x1c49U // Cherng Weei Technology Corp. +#define UHS_VID_SIGMA_MICRO 0x1c4fU // SiGma Micro +#define UHS_VID_PHILIPS_AND_LITE_ON_DIGITAL_SOLUTIONS_CORPORATION 0x1c6bU // Philips & Lite-ON Digital Solutions Corporation +#define UHS_VID_SKYDIGITAL 0x1c6cU // Skydigital Inc. +#define UHS_VID_AMT 0x1c73U // AMT +#define UHS_VID_KAETAT_INDUSTRIAL 0x1c77U // Kaetat Industrial Co., Ltd. +#define UHS_VID_DATASCOPE 0x1c78U // Datascope Corp. +#define UHS_VID_UNIGEN_CORPORATION 0x1c79U // Unigen Corporation +#define UHS_VID_LIGHTUNING_TECHNOLOGY 0x1c7aU // LighTuning Technology Inc. +#define UHS_VID_LUXSHARE_PRECISION_INDUSTRY_SHENZHEN 0x1c7bU // LUXSHARE PRECISION INDUSTRY (SHENZHEN) CO., LTD. +#define UHS_VID_SCHOMAECKER 0x1c83U // Schomaecker GmbH +#define UHS_VID_2N_TELEKOMUNIKACE_AS 0x1c87U // 2N TELEKOMUNIKACE a.s. +#define UHS_VID_SOMAGIC 0x1c88U // Somagic, Inc. +#define UHS_VID_HONGKONG_WEIDIDA_ELECTRON_LIMITED 0x1c89U // HONGKONG WEIDIDA ELECTRON LIMITED +#define UHS_VID_ASTRON_INTERNATIONAL 0x1c8eU // ASTRON INTERNATIONAL CORP. +#define UHS_VID_ALPINE_ELECTRONICS 0x1c98U // ALPINE ELECTRONICS, INC. +#define UHS_VID_OMEGA_TECHNOLOGY 0x1c9eU // OMEGA TECHNOLOGY +#define UHS_VID_ACCARIO 0x1ca0U // ACCARIO Inc. +#define UHS_VID_SYMWAVE 0x1ca1U // Symwave +#define UHS_VID_KINSTONE 0x1cacU // Kinstone +#define UHS_VID_ACES_ELECTRONIC 0x1cb3U // Aces Electronic Co., Ltd. +#define UHS_VID_OPEX_CORPORATION 0x1cb4U // OPEX CORPORATION +#define UHS_VID_IDEACOM_TECHNOLOGY 0x1cb6U // IdeaCom Technology Inc. +#define UHS_VID_LUMINARY_MICRO 0x1cbeU // Luminary Micro Inc. +#define UHS_VID_FORTAT_SKYMARK_INDUSTRIAL_COMPANY 0x1cbfU // FORTAT SKYMARK INDUSTRIAL COMPANY +#define UHS_VID_PLANTSENSE 0x1cc0U // PlantSense +#define UHS_VID_NEXTWAVE_BROADBAND 0x1ccaU // NextWave Broadband Inc. +#define UHS_VID_BODATONG_TECHNOLOGY_SHENZHEN 0x1ccdU // Bodatong Technology (Shenzhen) Co., Ltd. +#define UHS_VID_ADP_CORPORATION 0x1cd4U // adp corporation +#define UHS_VID_FIRECOMMS 0x1cd5U // Firecomms Ltd. +#define UHS_VID_ANTONIO_PRECISE_PRODUCTS_MANUFACTORY 0x1cd6U // Antonio Precise Products Manufactory Ltd. +#define UHS_VID_TELECOMMUNICATIONS_TECHNOLOGY_ASSOCIATION_TTA 0x1cdeU // Telecommunications Technology Association (TTA) +#define UHS_VID_WONTEN_TECHNOLOGY 0x1cdfU // WonTen Technology Co., Ltd. +#define UHS_VID_EDIMAX_TECHNOLOGY 0x1ce0U // EDIMAX TECHNOLOGY CO., LTD. +#define UHS_VID_AMPHENOL_KAE 0x1ce1U // Amphenol KAE +#define UHS_VID_DRESDEN_ELEKTRONIK 0x1cf1U // Dresden Elektronik +#define UHS_VID_ANDES_TECHNOLOGY_CORPORATION 0x1cfcU // ANDES TECHNOLOGY CORPORATION +#define UHS_VID_FLEXTRONICS_DIGITAL_DESIGN_JAPAN 0x1cfdU // Flextronics Digital Design Japan, LTD. +#define UHS_VID_ICON 0x1d03U // iCON +#define UHS_VID_SOLID_MOTION 0x1d07U // Solid-Motion +#define UHS_VID_NINGBO_HENTEK_DRAGON_ELECTRONICS 0x1d08U // NINGBO HENTEK DRAGON ELECTRONICS CO., LTD. +#define UHS_VID_TECHFAITH_WIRELESS_TECHNOLOGY_LIMITED 0x1d09U // TechFaith Wireless Technology Limited +#define UHS_VID_JOHNSON_CONTROLS_INC_THE_AUTOMOTIVE_BUSINESS_UNIT 0x1d0aU // Johnson Controls, Inc. The Automotive Business Unit +#define UHS_VID_HAN_HUA_CABLE_AND_WIRE_TECHNOLOGY_JX 0x1d0bU // HAN HUA CABLE & WIRE TECHNOLOGY (J.X.) CO., LTD. +#define UHS_VID_SONIX_TECHNOLOGY 0x1d0fU // Sonix Technology Co., Ltd. +#define UHS_VID_ALPHA_SAT_TECHNOLOGY_LIMITED 0x1d14U // ALPHA-SAT TECHNOLOGY LIMITED +#define UHS_VID_C_THRU_MUSIC 0x1d17U // C-Thru Music Ltd. +#define UHS_VID_DEXATEK_TECHNOLOGY 0x1d19U // Dexatek Technology Ltd. +#define UHS_VID_DIOSTECH 0x1d1fU // Diostech Co., Ltd. +#define UHS_VID_SAMTACK 0x1d20U // SAMTACK INC. +#define UHS_VID_ASUS 0x1d27U // ASUS +#define UHS_VID_DREAM_CHEEKY 0x1d34U // Dream Cheeky +#define UHS_VID_TOUCH 0x1d45U // Touch +#define UHS_VID_PEGATRON_CORPORATION 0x1d4dU // PEGATRON CORPORATION +#define UHS_VID_OPENMOKO 0x1d50U // OpenMoko, Inc. +#define UHS_VID_XENTA 0x1d57U // Xenta +#define UHS_VID_SMARTRONIX 0x1d5bU // Smartronix, Inc. +#define UHS_VID_LINUX_FOUNDATION 0x1d6bU // Linux Foundation +#define UHS_VID_CITIZEN 0x1d90U // Citizen +#define UHS_VID_ACTIONS_MICROELECTRONICS 0x1de1U // Actions Microelectronics Co. +#define UHS_VID_QUALCOMM_OPTION 0x1e0eU // Qualcomm / Option +#define UHS_VID_POINT_GREY_RESEARCH 0x1e10U // Point Grey Research, Inc. +#define UHS_VID_MIRION_TECHNOLOGIES_DOSIMETRY_SERVICES_DIVISION 0x1e17U // Mirion Technologies Dosimetry Services Division +#define UHS_VID_LUMENSION_SECURITY 0x1e1dU // Lumension Security +#define UHS_VID_INVIA 0x1e1fU // INVIA +#define UHS_VID_FESTO_AG_AND_CO_KG 0x1e29U // Festo AG & Co. KG +#define UHS_VID_CHIPSBANK_MICROELECTRONICS_1 0x1e3dU // Chipsbank Microelectronics Co., Ltd +#define UHS_VID_CLEVERSCOPE 0x1e41U // Cleverscope +#define UHS_VID_CUBETERNET 0x1e4eU // Cubeternet +#define UHS_VID_TYPEMATRIX 0x1e54U // TypeMatrix +#define UHS_VID_TREKSTOR_GMBH_AND_CO_KG 0x1e68U // TrekStor GmbH & Co. KG +#define UHS_VID_NZXT 0x1e71U // NZXT +#define UHS_VID_COBY_ELECTRONICS_CORPORATION 0x1e74U // Coby Electronics Corporation +#define UHS_VID_ROCCAT 0x1e7dU // ROCCAT +#define UHS_VID_NUCORE_TECHNOLOGY 0x1ebbU // NuCORE Technology, Inc. +#define UHS_VID_AIRTIES_WIRELESS_NETWORKS 0x1edaU // AirTies Wireless Networks +#define UHS_VID_BLACKMAGIC_DESIGN 0x1edbU // Blackmagic design +#define UHS_VID_ONDA_COMMUNICATION_SPA 0x1ee8U // ONDA COMMUNICATION S.p.a. +#define UHS_VID_EADS_DEUTSCHLAND 0x1ef6U // EADS Deutschland GmbH +#define UHS_VID_CAL_COMP 0x1f28U // Cal-Comp +#define UHS_VID_ONDA_UNVERIFIED 0x1f3aU // Onda (unverified) +#define UHS_VID_THE_NEAT_COMPANY 0x1f44U // The Neat Company +#define UHS_VID_H_TRONIC 0x1f48U // H-TRONIC GmbH +#define UHS_VID_G_TEK_ELECTRONICS_GROUP 0x1f4dU // G-Tek Electronics Group +#define UHS_VID_ALIPH 0x1f6fU // Aliph +#define UHS_VID_INNOSTOR_TECHNOLOGY_CORPORATION 0x1f75U // Innostor Technology Corporation +#define UHS_VID_TANDBERG 0x1f82U // TANDBERG +#define UHS_VID_ALERE 0x1f84U // Alere, Inc. +#define UHS_VID_STANTUM 0x1f87U // Stantum +#define UHS_VID_UBIQUITI_NETWORKS 0x1f9bU // Ubiquiti Networks, Inc. +#define UHS_VID_SAMSUNG_OPTO_ELECTRONCS 0x1fabU // Samsung Opto-Electroncs Co., Ltd. +#define UHS_VID_DELPHIN_TECHNOLOGY_AG 0x1fbdU // Delphin Technology AG +#define UHS_VID_NXP_SEMICONDUCTORS 0x1fc9U // NXP Semiconductors +#define UHS_VID_ILX_LIGHTWAVE_CORPORATION 0x1fdeU // ILX Lightwave Corporation +#define UHS_VID_VERTEX_WIRELESS 0x1fe7U // Vertex Wireless Co., Ltd. +#define UHS_VID_CVT_ELECTRONICSCOLTD 0x1ff7U // CVT Electronics.Co.,Ltd +#define UHS_VID_IDEOFY 0x1fffU // Ideofy Inc. +#define UHS_VID_D_LINK 0x2001U // D-Link Corp. +#define UHS_VID_DAP_TECHNOLOGIES 0x2002U // DAP Technologies +#define UHS_VID_DETECTOMAT 0x2003U // detectomat +#define UHS_VID_RELOOP 0x200cU // Reloop +#define UHS_VID_PCTV_SYSTEMS 0x2013U // PCTV Systems +#define UHS_VID_PLANEX_1 0x2019U // PLANEX +#define UHS_VID_ENCORE_ELECTRONICS 0x203dU // Encore Electronics Inc. +#define UHS_VID_HAUPPAUGE 0x2040U // Hauppauge +#define UHS_VID_TEXAS_INSTRUMENTS_2 0x2047U // Texas Instruments +#define UHS_VID_NANO_RIVER_TECHNOLOGY 0x2058U // Nano River Technology +#define UHS_VID_TAICANG_TANDW_ELECTRONICS 0x2077U // Taicang T&W Electronics Co. Ltd +#define UHS_VID_BARNES_AND_NOBLE 0x2080U // Barnes & Noble +#define UHS_VID_SIMPASS 0x2086U // SIMPASS +#define UHS_VID_CANDO 0x2087U // Cando +#define UHS_VID_CLAY_LOGIC 0x20a0U // Clay Logic +#define UHS_VID_XMOS 0x20b1U // XMOS Ltd +#define UHS_VID_HANVON 0x20b3U // Hanvon +#define UHS_VID_QI_HARDWARE 0x20b7U // Qi Hardware +#define UHS_VID_MINICIRCUITS 0x20ceU // Minicircuits +#define UHS_VID_SIMTEC_ELECTRONICS 0x20dfU // Simtec Electronics +#define UHS_VID_NET_NEW_ELECTRONIC_TECHNOLOGY 0x20f1U // NET New Electronic Technology GmbH +#define UHS_VID_TRENDNET_1 0x20f4U // TRENDnet +#define UHS_VID_XIMEA 0x20f7U // XIMEA +#define UHS_VID_RT_SYSTEMS 0x2100U // RT Systems +#define UHS_VID_ACTIONSTAR 0x2101U // ActionStar +#define UHS_VID_VIA_LABS 0x2109U // VIA Labs, Inc. +#define UHS_VID_SOFTKINETIC 0x2113U // Softkinetic +#define UHS_VID_ADVANCED_SILICON 0x2149U // Advanced Silicon S.A. +#define UHS_VID_CREATIVE_UNKNOWN 0x2162U // Creative (?) +#define UHS_VID_GW_INSTEK 0x2184U // GW Instek +#define UHS_VID_EMOTIV_SYSTEMS_PTY 0x21a1U // Emotiv Systems Pty. Ltd. +#define UHS_VID_AGECODAGIS_SARL 0x21d6U // Agecodagis SARL +#define UHS_VID_MACALLY_1 0x2222U // MacAlly +#define UHS_VID_SAMWOO_ENTERPRISE 0x2227U // SAMWOO Enterprise +#define UHS_VID_SILICON_MOTION_1 0x2232U // Silicon Motion +#define UHS_VID_RADIOSHACK_CORPORATION 0x2233U // RadioShack Corporation +#define UHS_VID_KOBO 0x2237U // Kobo Inc. +#define UHS_VID_MORPHO 0x225dU // Morpho +#define UHS_VID_8D_TECHNOLOGIES 0x228dU // 8D Technologies inc. +#define UHS_VID_PIE_DIGITAL 0x22a6U // Pie Digital, Inc. +#define UHS_VID_MOTOROLA_PCS 0x22b8U // Motorola PCS +#define UHS_VID_ETURBOTOUCH_TECHNOLOGY 0x22b9U // eTurboTouch Technology, Inc. +#define UHS_VID_TECHNOLOGY_INNOVATION_HOLDINGS 0x22baU // Technology Innovation Holdings, Ltd +#define UHS_VID_PINNACLE_SYSTEMS_1 0x2304U // Pinnacle Systems, Inc. +#define UHS_VID_SHINING_TECHNOLOGIES_INC_HEX_ 0x2318U // Shining Technologies, Inc. [hex] +#define UHS_VID_ARDUINO 0x2341U // Arduino SA +#define UHS_VID_PUMATRONIX_LTDA 0x2373U // Pumatronix Ltda +#define UHS_VID_DIGITALWAY_1 0x2375U // Digit@lway, Inc. +#define UHS_VID_SANHO_DIGITAL_ELECTRONICS 0x2406U // SANHO Digital Electronics Co., Ltd. +#define UHS_VID_AESSENT_TECHNOLOGY 0x2443U // Aessent Technology Ltd +#define UHS_VID_TRIPP_LITE_1 0x2478U // Tripp-Lite +#define UHS_VID_MAXXTER 0x248aU // Maxxter +#define UHS_VID_M2TECH_SRL 0x249cU // M2Tech s.r.l. +#define UHS_VID_PARATRONIC 0x24e1U // Paratronic +#define UHS_VID_TWINMOS_1 0x2632U // TwinMOS +#define UHS_VID_XSENS 0x2639U // Xsens +#define UHS_VID_ELECTRONICS_FOR_IMAGING_INC_HEX_ 0x2650U // Electronics For Imaging, Inc. [hex] +#define UHS_VID_SUNDTEK 0x2659U // Sundtek +#define UHS_VID_BASLER_AG 0x2676U // Basler AG +#define UHS_VID_CITIZEN_1 0x2730U // Citizen +#define UHS_VID_DIGITALWAY_2 0x2735U // DigitalWay +#define UHS_VID_NHJ 0x2770U // NHJ, Ltd +#define UHS_VID_THINGM 0x27b8U // ThingM +#define UHS_VID_ASUSTEK_COMPUTER_1 0x2821U // ASUSTek Computer Inc. +#define UHS_VID_TOPTRONIC_INDUSTRIAL 0x2899U // Toptronic Industrial Co., Ltd +#define UHS_VID_DRACALRAPHNET_TECHNOLOGIES 0x289bU // Dracal/Raphnet technologies +#define UHS_VID_JOLLA_OY 0x2931U // Jolla Oy +#define UHS_VID_DOG_HUNTER_AG 0x2a03U // dog hunter AG +#define UHS_VID_RTD_EMBEDDED_TECHNOLOGIES 0x2a37U // RTD Embedded Technologies, Inc. +#define UHS_VID_MEIZU 0x2a45U // Meizu Corp. +#define UHS_VID_PLANEX_COMMUNICATIONS_2 0x2c02U // Planex Communications +#define UHS_VID_DOLPHIN_PERIPHERALS 0x2c1aU // Dolphin Peripherals +#define UHS_VID_FUJITSU_1 0x2fb2U // Fujitsu, Ltd +#define UHS_VID_EAGLETRON_1 0x3125U // Eagletron +#define UHS_VID_NAVINI_NETWORKS 0x3136U // Navini Networks +#define UHS_VID_WHANAM_ELECTRONICS 0x3176U // Whanam Electronics Co., Ltd +#define UHS_VID_LINK_INSTRUMENTS 0x3195U // Link Instruments +#define UHS_VID_VIDZMEDIA_PTE 0x3275U // VidzMedia Pte Ltd +#define UHS_VID_INLINE 0x3333U // InLine +#define UHS_VID_AEI 0x3334U // AEI +#define UHS_VID_YAKUMO 0x3340U // Yakumo +#define UHS_VID_LEAGUER_MICROELECTRONICS_LME 0x3344U // Leaguer Microelectronics (LME) +#define UHS_VID_MICRO_STAR 0x3504U // Micro Star +#define UHS_VID_POWER_QUOTIENT_INTERNATIONAL_1 0x3538U // Power Quotient International Co., Ltd +#define UHS_VID_DIVA 0x3579U // DIVA +#define UHS_VID_SHARKOON 0x357dU // Sharkoon +#define UHS_VID_INVIBRO 0x3636U // InVibro +#define UHS_VID_WEM 0x3838U // WEM +#define UHS_VID_NATIONAL_INSTRUMENTS 0x3923U // National Instruments Corp. +#define UHS_VID_I_O_DATA 0x40bbU // I-O Data +#define UHS_VID_I_ROCKS 0x4101U // i-rocks +#define UHS_VID_IRIVER_1 0x4102U // iRiver, Ltd. +#define UHS_VID_DELL_COMPUTER_1 0x413cU // Dell Computer Corp. +#define UHS_VID_USBEST_TECHNOLOGY 0x4146U // USBest Technology +#define UHS_VID_TARGUS 0x4168U // Targus +#define UHS_VID_USB_DESIGN_BY_EXAMPLE 0x4242U // USB Design by Example +#define UHS_VID_GOPRO 0x4255U // GoPro +#define UHS_VID_BROADCOM_1 0x4317U // Broadcom Corp. +#define UHS_VID_WINCHIPHEAD 0x4348U // WinChipHead +#define UHS_VID_SHUTTLE_2 0x4572U // Shuttle, Inc. +#define UHS_VID_PANRAM 0x4586U // Panram +#define UHS_VID_EMS_PRODUCTION 0x4670U // EMS Production +#define UHS_VID_MIDITECH 0x4752U // Miditech +#define UHS_VID_GW_INSTEK_1 0x4757U // GW Instek +#define UHS_VID_ACEECA 0x4766U // Aceeca +#define UHS_VID_MEMOREX 0x4855U // Memorex +#define UHS_VID_SIMPLETECH 0x4971U // SimpleTech +#define UHS_VID_MUSICAL_FIDELITY 0x4d46U // Musical Fidelity +#define UHS_VID_GRANDTEC 0x5032U // Grandtec +#define UHS_VID_LINKSYS_UNKNOWN 0x5041U // Linksys (?) +#define UHS_VID_AVERATEC_UNKNOWN 0x50c2U // Averatec (?) +#define UHS_VID_SWEEX_1 0x5173U // Sweex +#define UHS_VID_I_TETRA 0x5219U // I-Tetra +#define UHS_VID_OWON 0x5345U // Owon +#define UHS_VID_SATOSHILABS 0x534cU // SatoshiLabs +#define UHS_VID_MEYER_INSTRUMENTS_MIS_1 0x5354U // Meyer Instruments (MIS) +#define UHS_VID_TRANSMETA 0x544dU // Transmeta Corp. +#define UHS_VID_UC_LOGIC_TECHNOLOGY 0x5543U // UC-Logic Technology Corp. +#define UHS_VID_EPIPHAN_SYSTEMS 0x5555U // Epiphan Systems Inc. +#define UHS_VID_ONSPEC_ELECTRONIC 0x55aaU // OnSpec Electronic, Inc. +#define UHS_VID_GOTVIEW 0x5654U // Gotview +#define UHS_VID_UNI_TREND_GROUP_LIMITED 0x5656U // Uni-Trend Group Limited +#define UHS_VID_IRTOUCHSYSTEMS 0x595aU // IRTOUCHSYSTEMS Co. Ltd. +#define UHS_VID_ACER_2 0x5986U // Acer, Inc +#define UHS_VID_NONOLITH_LABS 0x59e3U // Nonolith Labs +#define UHS_VID_ZINWELL 0x5a57U // Zinwell +#define UHS_VID_BEHOLDER_INTERNATIONAL 0x6000U // Beholder International Ltd. +#define UHS_VID_INGENIC_SEMICONDUCTOR 0x601aU // Ingenic Semiconductor Ltd. +#define UHS_VID_SITECOM 0x6189U // Sitecom +#define UHS_VID_LIGHTINGSOFT_AG 0x6244U // LightingSoft AG +#define UHS_VID_TWINHAN_TECHNOLOGY 0x6253U // TwinHan Technology Co., Ltd +#define UHS_VID_CORELOGIC 0x636cU // CoreLogic, Inc. +#define UHS_VID_UNKNOWN_SONY_UNKNOWN 0x6472U // Unknown (Sony?) +#define UHS_VID_ARKMICRO_TECHNOLOGIES_1 0x6547U // Arkmicro Technologies Inc. +#define UHS_VID_IRTOUCHSYSTEMS_1 0x6615U // IRTOUCHSYSTEMS Co. Ltd. +#define UHS_VID_PROTOTYPE_PRODUCT_VENDOR_ID 0x6666U // Prototype product Vendor ID +#define UHS_VID_WISEGROUP 0x6677U // WiseGroup, Ltd. +#define UHS_VID_3COM_1 0x6891U // 3Com +#define UHS_VID_OPERA1 0x695cU // Opera1 +#define UHS_VID_YEALINK_NETWORK_TECHNOLOGY 0x6993U // Yealink Network Technology Co., Ltd. +#define UHS_VID_SHANGHAI_JUJO_ELECTRONICS 0x6a75U // Shanghai Jujo Electronics Co., Ltd +#define UHS_VID_CME_CENTRAL_MUSIC 0x7104U // CME (Central Music Co.) +#define UHS_VID_STACKFOUNDRY 0x726cU // StackFoundry LLC +#define UHS_VID_TBS_TECHNOLOGIES_CHINA 0x734cU // TBS Technologies China +#define UHS_VID_BEIJING_STONE_TECHNOLOGY 0x7373U // Beijing STONE Technology Co. Ltd. +#define UHS_VID_EDIMAX_TECHNOLOGY_1 0x7392U // Edimax Technology Co., Ltd +#define UHS_VID_INTEL_1 0x8086U // Intel Corp. +#define UHS_VID_INTEL_2 0x8087U // Intel Corp. +#define UHS_VID_VIRTUALBOX 0x80eeU // VirtualBox +#define UHS_VID_KEIO 0x8282U // Keio +#define UHS_VID_EGO_SYSTEMS_1 0x8341U // EGO Systems, Inc. +#define UHS_VID_TRANSCEND_INFORMATION_1 0x8564U // Transcend Information, Inc. +#define UHS_VID_INTENSO_GMBG 0x8644U // Intenso GmbG +#define UHS_VID_CH_PRODUCTS_1 0x8e06U // CH Products, Inc. +#define UHS_VID_SITECOM_1 0x9016U // Sitecom +#define UHS_VID_TEVII_TECHNOLOGY 0x9022U // TeVii Technology Ltd. +#define UHS_VID_GEOLAB 0x9148U // GeoLab, Ltd +#define UHS_VID_MOSCHIP_SEMICONDUCTOR 0x9710U // MosChip Semiconductor +#define UHS_VID_BESTMEDIA_CD_RECORDABLE_GMBH_AND_CO_KG 0x9849U // Bestmedia CD Recordable GmbH & Co. KG +#define UHS_VID_ODEON 0x9999U // Odeon +#define UHS_VID_GRANDTEC_1 0x99faU // Grandtec +#define UHS_VID_J_WESTHUES 0x9ac4U // J. Westhues +#define UHS_VID_MARVELL_SEMICONDUCTOR_1 0x9e88U // Marvell Semiconductor, Inc. +#define UHS_VID_ANMO_ELECTRONICS_CORP_DINO_LITE_UNKNOWN 0xa128U // AnMo Electronics Corp. / Dino-Lite (?) +#define UHS_VID_ANMO_ELECTRONICS_CORPORATION 0xa168U // AnMo Electronics Corporation +#define UHS_VID_ASIX 0xa600U // Asix +#define UHS_VID_3COM_2 0xa727U // 3Com +#define UHS_VID_MXT 0xaaaaU // MXT +#define UHS_VID_UNKNOWN_3 0xabcdU // Unknown +#define UHS_VID_BLUE_MICROPHONES 0xb58eU // Blue Microphones +#define UHS_VID_CARD_DEVICE_EXPERT 0xc216U // Card Device Expert Co., LTD +#define UHS_VID_KEIL_SOFTWARE_1 0xc251U // Keil Software, Inc. +#define UHS_VID_CACE_TECHNOLOGIES 0xcaceU // CACE Technologies Inc. +#define UHS_VID_SMART_TECHNOLOGY_INDUSTRIAL 0xcd12U // SMART TECHNOLOGY INDUSTRIAL LTD. +#define UHS_VID_ULTIMARC 0xd208U // Ultimarc +#define UHS_VID_ULTIMARC_1 0xd209U // Ultimarc +#define UHS_VID_LOGILINK 0xd904U // LogiLink +#define UHS_VID_XORCOM 0xe4e4U // Xorcom Ltd. +#define UHS_VID_MAKINGTHINGS 0xeb03U // MakingThings +#define UHS_VID_EMPIA_TECHNOLOGY 0xeb1aU // eMPIA Technology, Inc. +#define UHS_VID_KWORLD 0xeb2aU // KWorld +#define UHS_VID_SMART_TECHNOLOGY_INDUSTRIAL_1 0xef18U // SMART TECHNOLOGY INDUSTRIAL LTD. +#define UHS_VID_HEWLETT_PACKARD_1 0xf003U // Hewlett Packard +#define UHS_VID_LEAP_MOTION 0xf182U // Leap Motion +#define UHS_VID_ATTEN_ELECTRONICS_SIGLENT_TECHNOLOGIES 0xf4ecU // Atten Electronics / Siglent Technologies +#define UHS_VID_SHENZHEN_SIGLENT 0xf4edU // Shenzhen Siglent Co., Ltd. +#define UHS_VID_HAMA_1 0xf766U // Hama +#define UHS_VID_CONRAD_ELECTRONIC_SE 0xfc08U // Conrad Electronic SE +#define UHS_VID_FNK_TECH 0xffeeU // FNK Tech + +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UsbCore.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UsbCore.h new file mode 100644 index 0000000..58d7ba2 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UsbCore.h @@ -0,0 +1,336 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#if !defined(_UHS_host_h_) || defined(USBCORE_H) +#error "Never include UHS_UsbCore.h directly; include UHS_Host.h instead" +#else +#define USBCORE_H + +#ifndef UHS_HOST_MAX_INTERFACE_DRIVERS +#define UHS_HOST_MAX_INTERFACE_DRIVERS 0x10U // Default maximum number of USB interface drivers +#endif + +#ifndef SYSTEM_OR_SPECIAL_YIELD +#define SYSTEM_OR_SPECIAL_YIELD(...) VOID0 +#endif + +#ifndef SYSTEM_OR_SPECIAL_YIELD_FROM_ISR +#define SYSTEM_OR_SPECIAL_YIELD_FROM_ISR(...) SYSTEM_OR_SPECIAL_YIELD +#endif + +// As we make extensions to a target interface add to UHS_HOST_MAX_INTERFACE_DRIVERS +// This offset gets calculated for supporting wide subclasses, such as HID, BT, etc. +#define UHS_HID_INDEX (UHS_HOST_MAX_INTERFACE_DRIVERS + 1) + +/* Common setup data constant combinations */ +//get descriptor request type +#define UHS_bmREQ_GET_DESCR (USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE) + +//set request type for all but 'set feature' and 'set interface' +#define UHS_bmREQ_SET (USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE) + +//get interface request type +#define UHS_bmREQ_CL_GET_INTF (USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE) + +// D7 data transfer direction (0 - host-to-device, 1 - device-to-host) +// D6-5 Type (0- standard, 1 - class, 2 - vendor, 3 - reserved) +// D4-0 Recipient (0 - device, 1 - interface, 2 - endpoint, 3 - other, 4..31 - reserved) + + +// TO-DO: Use the python script to generate these. +// TO-DO: Add _all_ subclasses here. +// USB Device Classes, Subclasses and Protocols +//////////////////////////////////////////////////////////////////////////////// +// Use Class Info in the Interface Descriptors +#define UHS_USB_CLASS_USE_CLASS_INFO 0x00U + +//////////////////////////////////////////////////////////////////////////////// +// Audio +#define UHS_USB_CLASS_AUDIO 0x01U +// Subclasses +#define UHS_USB_SUBCLASS_AUDIOCONTROL 0x01U +#define UHS_USB_SUBCLASS_AUDIOSTREAMING 0x02U +#define UHS_USB_SUBCLASS_MIDISTREAMING 0x03U + +//////////////////////////////////////////////////////////////////////////////// +// Communications and CDC Control +#define UHS_USB_CLASS_COM_AND_CDC_CTRL 0x02U + +//////////////////////////////////////////////////////////////////////////////// +// HID +#define UHS_USB_CLASS_HID 0x03U +// Subclasses +#define UHS_HID_BOOT_SUBCLASS 0x01U +// Protocols +#define UHS_HID_PROTOCOL_HIDBOOT_KEYBOARD 0x01U +#define UHS_HID_PROTOCOL_HIDBOOT_MOUSE 0x02U +//////////////////////////////////////////////////////////////////////////////// +// Physical +#define UHS_USB_CLASS_PHYSICAL 0x05U + +//////////////////////////////////////////////////////////////////////////////// +// Image +#define UHS_USB_CLASS_IMAGE 0x06U + +//////////////////////////////////////////////////////////////////////////////// +// Printer +#define UHS_USB_CLASS_PRINTER 0x07U + +//////////////////////////////////////////////////////////////////////////////// +// Mass Storage +#define UHS_USB_CLASS_MASS_STORAGE 0x08 +// Subclasses +#define UHS_BULK_SUBCLASS_SCSI_NOT_REPORTED 0x00U // De facto use +#define UHS_BULK_SUBCLASS_RBC 0x01U +#define UHS_BULK_SUBCLASS_ATAPI 0x02U // MMC-5 (ATAPI) +#define UHS_BULK_SUBCLASS_OBSOLETE1 0x03U // Was QIC-157 +#define UHS_BULK_SUBCLASS_UFI 0x04U // Specifies how to interface Floppy Disk Drives to USB +#define UHS_BULK_SUBCLASS_OBSOLETE2 0x05U // Was SFF-8070i +#define UHS_BULK_SUBCLASS_SCSI 0x06U // SCSI Transparent Command Set +#define UHS_BULK_SUBCLASS_LSDFS 0x07U // Specifies how host has to negotiate access before trying SCSI +#define UHS_BULK_SUBCLASS_IEEE1667 0x08U +// Protocols +#define UHS_STOR_PROTO_CBI 0x00U // CBI (with command completion interrupt) +#define UHS_STOR_PROTO_CBI_NO_INT 0x01U // CBI (without command completion interrupt) +#define UHS_STOR_PROTO_OBSOLETE 0x02U +#define UHS_STOR_PROTO_BBB 0x50U // Bulk Only Transport +#define UHS_STOR_PROTO_UAS 0x62U + +//////////////////////////////////////////////////////////////////////////////// +// Hub +#define UHS_USB_CLASS_HUB 0x09U + +//////////////////////////////////////////////////////////////////////////////// +// CDC-Data +#define UHS_USB_CLASS_CDC_DATA 0x0AU + +//////////////////////////////////////////////////////////////////////////////// +// Smart-Card +#define UHS_USB_CLASS_SMART_CARD 0x0BU + +//////////////////////////////////////////////////////////////////////////////// +// Content Security +#define UHS_USB_CLASS_CONTENT_SECURITY 0x0DU + +//////////////////////////////////////////////////////////////////////////////// +// Video +#define UHS_USB_CLASS_VIDEO 0x0EU + +//////////////////////////////////////////////////////////////////////////////// +// Personal Healthcare +#define UHS_USB_CLASS_PERSONAL_HEALTH 0x0FU + +//////////////////////////////////////////////////////////////////////////////// +// Diagnostic Device +#define UHS_USB_CLASS_DIAGNOSTIC_DEVICE 0xDCU + +//////////////////////////////////////////////////////////////////////////////// +// Wireless Controller +#define UHS_USB_CLASS_WIRELESS_CTRL 0xE0U + +//////////////////////////////////////////////////////////////////////////////// +// Miscellaneous +#define UHS_USB_CLASS_MISC 0xEFU + +//////////////////////////////////////////////////////////////////////////////// +// Application Specific +#define UHS_USB_CLASS_APP_SPECIFIC 0xFEU + +//////////////////////////////////////////////////////////////////////////////// +// Vendor Specific +#define UHS_USB_CLASS_VENDOR_SPECIFIC 0xFFU + +//////////////////////////////////////////////////////////////////////////////// + + +/* USB state machine states */ +#define UHS_USB_HOST_STATE_MASK 0xF0U + +// Configure states, MSN == 0 --------------------------V +#define UHS_USB_HOST_STATE_DETACHED 0x00U +#define UHS_USB_HOST_STATE_DEBOUNCE 0x01U +#define UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE 0x02U +#define UHS_USB_HOST_STATE_RESET_NOT_COMPLETE 0x03U +#define UHS_USB_HOST_STATE_WAIT_SOF 0x04U +#define UHS_USB_HOST_STATE_WAIT_BUS_READY 0x05U +#define UHS_USB_HOST_STATE_RESET_DEVICE 0x0AU +#define UHS_USB_HOST_STATE_CONFIGURING 0x0CU // Looks like "CO"nfig (backwards) +#define UHS_USB_HOST_STATE_CONFIGURING_DONE 0x0DU // Looks like "DO"one (backwards) +#define UHS_USB_HOST_STATE_CHECK 0x0EU +#define UHS_USB_HOST_STATE_ILLEGAL 0x0FU // Foo + +// Run states, MSN != 0 --------------------------------V +#define UHS_USB_HOST_STATE_RUNNING 0x60U // Looks like "GO" +#define UHS_USB_HOST_STATE_IDLE 0x1DU // Looks like "ID"le +#define UHS_USB_HOST_STATE_ERROR 0xF0U // Looks like "FO"o +#define UHS_USB_HOST_STATE_INITIALIZE 0x10U // Looks like "I"nit + +// Host SE result codes. +// Common SE results are stored in the low nybble, all interface drivers understand these plus 0x1F. +// Extended SE results are 0x10-0x1E. SE code only understands these internal to the hardware. +// Values > 0x1F are driver or other internal error conditions. +// Return these result codes from your host controller driver to match the error condition +// ALL Non-zero values are errors. +// Values not listed in this table are not handled in the base class, or any host driver. + +#define UHS_HOST_ERROR_NONE 0x00U // No error +#define UHS_HOST_ERROR_BUSY 0x01U // transfer pending +#define UHS_HOST_ERROR_BADREQ 0x02U // Transfer Launch Request was bad +#define UHS_HOST_ERROR_DMA 0x03U // DMA was too short, or too long +#define UHS_HOST_ERROR_NAK 0x04U // Peripheral returned NAK +#define UHS_HOST_ERROR_STALL 0x05U // Peripheral returned STALL +#define UHS_HOST_ERROR_TOGERR 0x06U // Toggle error/ISO over-underrun +#define UHS_HOST_ERROR_WRONGPID 0x07U // Received wrong Packet ID +#define UHS_HOST_ERROR_BADBC 0x08U // Byte count is bad +#define UHS_HOST_ERROR_PIDERR 0x09U // Received Packet ID is corrupted +#define UHS_HOST_ERROR_BADRQ 0x0AU // Packet error. Increase max packet. +#define UHS_HOST_ERROR_CRC 0x0BU // USB CRC was incorrect +#define UHS_HOST_ERROR_KERR 0x0CU // K-state instead of response, usually indicates wrong speed +#define UHS_HOST_ERROR_JERR 0x0DU // J-state instead of response, usually indicates wrong speed +#define UHS_HOST_ERROR_TIMEOUT 0x0EU // Device did not respond in time +#define UHS_HOST_ERROR_BABBLE 0x0FU // Line noise/unexpected data +#define UHS_HOST_ERROR_MEM_LAT 0x10U // Error caused by memory latency. +#define UHS_HOST_ERROR_NYET 0x11U // OUT transfer accepted with NYET + +// Addressing error codes +#define ADDR_ERROR_INVALID_INDEX 0xA0U +#define ADDR_ERROR_INVALID_ADDRESS 0xA1U + +// Common Interface Driver error codes +#define UHS_HOST_ERROR_DEVICE_NOT_SUPPORTED 0xD1U // Driver doesn't support the device or interfaces +#define UHS_HOST_ERROR_DEVICE_INIT_INCOMPLETE 0xD2U // Init partially finished, but died. +#define UHS_HOST_ERROR_CANT_REGISTER_DEVICE_CLASS 0xD3U // There was no driver for the interface requested. +#define UHS_HOST_ERROR_ADDRESS_POOL_FULL 0xD4U // No addresses left in the address pool. +#define UHS_HOST_ERROR_HUB_ADDRESS_OVERFLOW 0xD5U // No hub addresses left. The maximum is 7. +#define UHS_HOST_ERROR_NO_ADDRESS_IN_POOL 0xD6U // Address was not allocated in the pool, thus not found. +#define UHS_HOST_ERROR_NULL_EPINFO 0xD7U // The supplied endpoint was NULL, indicates a bug or other problem. +#define UHS_HOST_ERROR_BAD_ARGUMENT 0xD8U // Indicates a range violation bug. +#define UHS_HOST_ERROR_DEVICE_DRIVER_BUSY 0xD9U // The interface driver is busy or out buffer is full, try again later. +#define UHS_HOST_ERROR_BAD_MAX_PACKET_SIZE 0xDAU // The maximum packet size was exceeded. Try again with smaller size. +#define UHS_HOST_ERROR_NO_ENDPOINT_IN_TABLE 0xDBU // The endpoint could not be found in the endpoint table. +#define UHS_HOST_ERROR_UNPLUGGED 0xDEU // Someone removed the USB device, or Vbus was turned off. +#define UHS_HOST_ERROR_NOMEM 0xDFU // Out Of Memory. + +// Control request stream errors +#define UHS_HOST_ERROR_FailGetDevDescr 0xE1U +#define UHS_HOST_ERROR_FailSetDevTblEntry 0xE2U +#define UHS_HOST_ERROR_FailGetConfDescr 0xE3U +#define UHS_HOST_ERROR_END_OF_STREAM 0xEFU + +// Host base class specific Error codes +#define UHS_HOST_ERROR_NOT_IMPLEMENTED 0xFEU +#define UHS_HOST_ERROR_TRANSFER_TIMEOUT 0xFFU + +// SEI interaction defaults +#define UHS_HOST_TRANSFER_MAX_MS 10000 // USB transfer timeout in ms, per section 9.2.6.1 of USB 2.0 spec +#define UHS_HOST_TRANSFER_RETRY_MAXIMUM 3 // 3 retry limit for a transfer +#define UHS_HOST_DEBOUNCE_DELAY_MS 500 // settle delay in milliseconds +#define UHS_HUB_RESET_DELAY_MS 20 // hub port reset delay, 10ms recommended, but can be up to 20ms + +// +// We only provide the minimum needed information for enumeration. +// Interface drivers should be able to set up what is needed with nothing more. +// A driver needs to know the following information: +// 1: address on the USB network, parent and port (aka UsbDeviceAddress) +// 2: endpoints +// 3: vid:pid, class, subclass, protocol +// + +struct ENDPOINT_INFO { + uint8_t bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN). + uint8_t bmAttributes; // Endpoint transfer type. + uint16_t wMaxPacketSize; // Maximum packet size. + uint8_t bInterval; // Polling interval in frames. +} __attribute__((packed)); + +struct INTERFACE_INFO { + uint8_t bInterfaceNumber; + uint8_t bAlternateSetting; + uint8_t numep; + uint8_t klass; + uint8_t subklass; + uint8_t protocol; + ENDPOINT_INFO epInfo[16]; +} __attribute__((packed)); + +struct ENUMERATION_INFO { + uint16_t vid; + uint16_t pid; + uint16_t bcdDevice; + uint8_t klass; + uint8_t subklass; + uint8_t protocol; + uint8_t bMaxPacketSize0; + uint8_t currentconfig; + uint8_t parent; + uint8_t port; + uint8_t address; + INTERFACE_INFO interface; +} __attribute__((packed)); + +/* USB Setup Packet Structure */ +typedef struct { + // offset description + // 0 Bit-map of request type + union { + uint8_t bmRequestType; + + struct { + uint8_t recipient : 5; // Recipient of the request + uint8_t type : 2; // Type of request + uint8_t direction : 1; // Direction of data transfer + } __attribute__((packed)); + } ReqType_u; + + // 1 Request + uint8_t bRequest; + + // 2 Depends on bRequest + union { + uint16_t wValue; + + struct { + uint8_t wValueLo; + uint8_t wValueHi; + } __attribute__((packed)); + } wVal_u; + // 4 Depends on bRequest + uint16_t wIndex; + // 6 Depends on bRequest + uint16_t wLength; + // 8 bytes total +} __attribute__((packed)) SETUP_PKT, *PSETUP_PKT; + + +// little endian :-) 8 8 8 8 16 16 +#define mkSETUP_PKT8(bmReqType, bRequest, wValLo, wValHi, wInd, total) ((uint64_t)(((uint64_t)(bmReqType)))|(((uint64_t)(bRequest))<<8)|(((uint64_t)(wValLo))<<16)|(((uint64_t)(wValHi))<<24)|(((uint64_t)(wInd))<<32)|(((uint64_t)(total)<<48))) +#define mkSETUP_PKT16(bmReqType, bRequest, wVal, wInd, total) ((uint64_t)(((uint64_t)(bmReqType)))|(((uint64_t)(bRequest))<<8)|(((uint64_t)(wVal ))<<16) |(((uint64_t)(wInd))<<32)|(((uint64_t)(total)<<48))) + +// Big endian -- but we aren't able to use this :-/ +//#define mkSETUP_PKT8(bmReqType, bRequest, wValLo, wValHi, wInd, total) ((uint64_t)(((uint64_t)(bmReqType))<<56)|(((uint64_t)(bRequest))<<48)|(((uint64_t)(wValLo))<<40)|(((uint64_t)(wValHi))<<32)|(((uint64_t)(wInd))<<16)|((uint64_t)(total))) +//#define mkSETUP_PKT16(bmReqType, bRequest, wVal, wInd, total) ((uint64_t)(((uint64_t)(bmReqType))<<56)|(((uint64_t)(bRequest))<<48) |(((uint64_t)(wVal))<<32) |(((uint64_t)(wInd))<<16)|((uint64_t)(total))) + +#endif /* USBCORE_H */ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_address.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_address.h new file mode 100644 index 0000000..4d9d35b --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_address.h @@ -0,0 +1,248 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#if !defined(_UHS_host_h_) || defined(__ADDRESS_H__) +#error "Never include UHS_address.h directly; include UHS_Usb.h instead" +#else +#define __ADDRESS_H__ + + + +/* NAK powers. To save space in endpoint data structure, amount of retries before giving up and returning 0x4 is stored in */ +/* bmNakPower as a power of 2. The actual nak_limit is then calculated as nak_limit = ( 2^bmNakPower - 1) */ +#define UHS_USB_NAK_MAX_POWER 14 // NAK binary order maximum value +#define UHS_USB_NAK_DEFAULT 13 // default 16K-1 NAKs before giving up +#define UHS_USB_NAK_NOWAIT 1 // Single NAK stops transfer +#define UHS_USB_NAK_NONAK 0 // Do not count NAKs, stop retrying after USB Timeout. Try not to use this. + +#define bmUSB_DEV_ADDR_PORT 0x07 +#define bmUSB_DEV_ADDR_PARENT 0x78 +#define bmUSB_DEV_ADDR_HUB 0x40 + +// TODO: embed parent? +struct UHS_EpInfo { + uint8_t epAddr; // Endpoint address + uint8_t bIface; + uint16_t maxPktSize; // Maximum packet size + + union { + uint8_t epAttribs; + + struct { + uint8_t bmSndToggle : 1; // Send toggle, when zero bmSNDTOG0, bmSNDTOG1 otherwise + uint8_t bmRcvToggle : 1; // Send toggle, when zero bmRCVTOG0, bmRCVTOG1 otherwise + uint8_t bmNeedPing : 1; // 1 == ping protocol needed for next out packet + uint8_t bmNakPower : 5; // Binary order for NAK_LIMIT value + } __attribute__((packed)); + }; +} __attribute__((packed)); + +// TODO: embed parent address and port into epinfo struct, +// and nuke this address stupidity. +// This is a compact scheme. Should also support full spec. +// This produces a 7 hub limit, 49 devices + 7 hubs, 56 total. +// +// 7 6 5 4 3 2 1 0 +// --------------------------------- +// | | H | P | P | P | A | A | A | +// --------------------------------- +// +// H - if 1 the address is a hub address +// P - parent hub number +// A - port number of parent +// + +struct UHS_DeviceAddress { + + union { + + struct { + uint8_t bmAddress : 3; // port number + uint8_t bmParent : 3; // parent hub address + uint8_t bmHub : 1; // hub flag + uint8_t bmReserved : 1; // reserved, must be zero + } __attribute__((packed)); + uint8_t devAddress; + }; +} __attribute__((packed)); + +struct UHS_Device { + volatile UHS_EpInfo *epinfo[UHS_HOST_MAX_INTERFACE_DRIVERS]; // endpoint info pointer + UHS_DeviceAddress address; + uint8_t epcount; // number of endpoints + uint8_t speed; // indicates device speed +} __attribute__((packed)); + +typedef void (*UsbDeviceHandleFunc)(UHS_Device *pdev); + +class AddressPool { + UHS_EpInfo dev0ep; //Endpoint data structure used during enumeration for uninitialized device + + // In order to avoid hub address duplication, this should use bits + uint8_t hubCounter; // hub counter + + UHS_Device thePool[UHS_HOST_MAX_INTERFACE_DRIVERS]; + + // Initializes address pool entry + + void UHS_NI InitEntry(uint8_t index) { + thePool[index].address.devAddress = 0; + thePool[index].epcount = 1; + thePool[index].speed = 0; + for(uint8_t i = 0; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) { + thePool[index].epinfo[i] = &dev0ep; + } + }; + + // Returns thePool index for a given address + + uint8_t UHS_NI FindAddressIndex(uint8_t address = 0) { + for(uint8_t i = 1; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) { + if(thePool[i].address.devAddress == address) + return i; + } + return 0; + }; + + // Returns thePool child index for a given parent + + uint8_t UHS_NI FindChildIndex(UHS_DeviceAddress addr, uint8_t start = 1) { + for(uint8_t i = (start < 1 || start >= UHS_HOST_MAX_INTERFACE_DRIVERS) ? 1 : start; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) { + if(thePool[i].address.bmParent == addr.bmAddress) + return i; + } + return 0; + }; + + // Frees address entry specified by index parameter + + void UHS_NI FreeAddressByIndex(uint8_t index) { + // Zero field is reserved and should not be affected + if(index == 0) + return; + + UHS_DeviceAddress uda = thePool[index].address; + // If a hub was switched off all port addresses should be freed + if(uda.bmHub == 1) { + for(uint8_t i = 1; (i = FindChildIndex(uda, i));) + FreeAddressByIndex(i); + + // FIXME: use BIT MASKS + // If the hub had the last allocated address, hubCounter should be decremented + if(hubCounter == uda.bmAddress) + hubCounter--; + } + InitEntry(index); + } + + void InitAllAddresses() { + for(uint8_t i = 1; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) InitEntry(i); + hubCounter = 0; + }; +public: + + AddressPool() { + hubCounter = 0; + // Zero address is reserved + InitEntry(0); + + thePool[0].epinfo[0] = &dev0ep; + dev0ep.epAddr = 0; +#if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE + dev0ep.maxPktSize = 0x40; //starting at 0x40 and work down +#else + dev0ep.maxPktSize = 0x08; +#endif + dev0ep.epAttribs = 0; //set DATA0/1 toggles to 0 + dev0ep.bmNakPower = UHS_USB_NAK_MAX_POWER; + InitAllAddresses(); + }; + + // Returns a pointer to a specified address entry + + UHS_Device* UHS_NI GetUsbDevicePtr(uint8_t addr) { + if(!addr) + return thePool; + + uint8_t index = FindAddressIndex(addr); + + return (!index) ? NULL : &thePool[index]; + }; + + + // Allocates new address + + uint8_t UHS_NI AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 1) { + /* if (parent != 0 && port == 0) + USB_HOST_SERIAL.println("PRT:0"); */ + UHS_DeviceAddress _parent; + _parent.devAddress = parent; + if(_parent.bmReserved || port > 7) + //if(parent > 127 || port > 7) + return 0; + + // FIXME: use BIT MASKS + if(is_hub && hubCounter == 7) + return 0; + + // finds first empty address entry starting from one + uint8_t index = FindAddressIndex(0); + + if(!index) // if empty entry is not found + return 0; + + UHS_DeviceAddress addr; + addr.devAddress = port; + addr.bmParent = _parent.bmAddress; + + // FIXME: use BIT MASKS + if(is_hub) { + hubCounter++; + addr.bmHub = 1; + addr.bmAddress = hubCounter; + } + thePool[index].address = addr; +#if DEBUG_PRINTF_EXTRA_HUGE +#ifdef UHS_DEBUG_USB_ADDRESS + printf("Address: %x (%x.%x.%x)\r\n", addr.devAddress, addr.bmHub, addr.bmParent, addr.bmAddress); +#endif +#endif + return thePool[index].address.devAddress; + }; + + void UHS_NI FreeAddress(uint8_t addr) { + // if the root hub is disconnected all the addresses should be initialized + if(addr == 0x41) { + InitAllAddresses(); + return; + } + uint8_t index = FindAddressIndex(addr); + FreeAddressByIndex(index); + }; + +}; + +#endif // __ADDRESS_H__ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_hexdump.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_hexdump.h new file mode 100644 index 0000000..945512c --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_hexdump.h @@ -0,0 +1,70 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ +#if !defined(_usb_h_) || defined(__HEXDUMP_H__) +#error "Never include UHS_hexdump.h directly; include UHS_Usb.h instead" +#else +#define __HEXDUMP_H__ + +extern int UsbDEBUGlvl; + +template +class HexDumper : public BASE_CLASS { + uint8_t byteCount; + OFFSET_TYPE byteTotal; + +public: + + HexDumper() : byteCount(0), byteTotal(0) { + }; + + void Initialize() { + byteCount = 0; + byteTotal = 0; + }; + + virtual void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); +}; + +template +void HexDumper::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) { + if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug. + for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) { + if(!byteCount) { + PrintHex (byteTotal, 0x80); + E_Notify(PSTR(": "), 0x80); + } + PrintHex (pbuf[j], 0x80); + E_Notify(PSTR(" "), 0x80); + + if(byteCount == 15) { + E_Notify(PSTR("\r\n"), 0x80); + byteCount = 0xFF; + } + } + } +} + +#endif // __HEXDUMP_H__ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host.h new file mode 100644 index 0000000..5d711c1 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host.h @@ -0,0 +1,111 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ +/* USB functions */ +#ifndef _UHS_host_h_ +#define _UHS_host_h_ + +// WARNING: Do not change the order of includes, or stuff will break! +#include +#include +#include +#include + +#if DISABLED(USE_UHS3_USB) +#include +#include +#include +#include +#endif +#include "UHS_macros.h" + +// None of these should ever be directly included by a driver, or a user's sketch. +#include "../dyn_SWI/dyn_SWI.h" +#include "UHS_USB_IDs.h" +#include "UHS_settings.h" +#include "UHS_usb_ch9.h" +#include "UHS_UsbCore.h" +#include "UHS_address.h" +#include "UHS_usbhost.h" +#include "UHS_printhex.h" +#include "UHS_message.h" + +// Load system components as required +#if defined(LOAD_USB_HOST_SYSTEM) && !defined(USB_HOST_SYSTEM_LOADED) +#include "UHS_util_INLINE.h" +#include "UHS_host_INLINE.h" +#include "UHS_printf_HELPER.h" + +#ifdef LOAD_USB_HOST_SHIELD +#include "USB_HOST_SHIELD/USB_HOST_SHIELD.h" +#endif + +#if defined(LOAD_UHS_KINETIS_FS_HOST) && !defined(UHS_KINETIS_FS_HOST_LOADED) +#include "UHS_KINETIS_FS_HOST/UHS_KINETIS_FS_HOST.h" +#endif + +#if defined(LOAD_UHS_KINETIS_EHCI) && !defined(UHS_KINETIS_EHCI_LOADED) +#include "UHS_KINETIS_EHCI/UHS_KINETIS_EHCI.h" +#endif + +// Load USB drivers and multiplexers + +#ifdef LOAD_UHS_HUB +#include "UHS_HUB/UHS_HUB.h" +#endif // HUB loaded + +#ifdef LOAD_UHS_BULK_STORAGE +#include "UHS_BULK_STORAGE/UHS_BULK_STORAGE.h" +#endif + +#ifdef LOAD_GENERIC_STORAGE +#include "../UHS_FS/UHS_FS.h" +#endif +// Add BT and optionally HID if directed to do so +#ifdef LOAD_UHS_BT +#include "UHS_BT/UHS_BT.h" +#endif // BT and optionally HID loaded + +// Add HID +#ifdef LOAD_UHS_HID +#include "UHS_HID/UHS_HID.h" +#endif // HID loaded + +// Add CDC multiplexers (currently only ACM) +#if defined(LOAD_UHS_CDC_ACM) || defined(LOAD_UHS_CDC_ACM_FTDI) || defined(LOAD_UHS_CDC_ACM_PROLIFIC) || defined(LOAD_UHS_CDC_ACM_XR21B1411) +#include "UHS_CDC/UHS_CDC.h" +#endif // CDC loaded + +#ifdef LOAD_UHS_ADK +#include "UHS_ADK/UHS_ADK.h" +#endif + +#ifdef LOAD_UHS_MIDI +#include "UHS_MIDI/UHS_MIDI.h" +#endif + +#endif // System code loaded + +#endif // _UHS_host_h_ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h new file mode 100644 index 0000000..f78a3bb --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h @@ -0,0 +1,1222 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#if defined(LOAD_USB_HOST_SYSTEM) && !defined(USB_HOST_SYSTEM_LOADED) +#define USB_HOST_SYSTEM_LOADED + +#ifndef DEBUG_PRINTF_EXTRA_HUGE_UHS_HOST +#define DEBUG_PRINTF_EXTRA_HUGE_UHS_HOST 0 +#endif + +#if DEBUG_PRINTF_EXTRA_HUGE +#if DEBUG_PRINTF_EXTRA_HUGE_UHS_HOST +#define HOST_DEBUG(...) printf(__VA_ARGS__) +#else +#define HOST_DEBUG(...) VOID0 +#endif +#else +#define HOST_DEBUG(...) VOID0 +#endif + +UHS_EpInfo* UHS_USB_HOST_BASE::getEpInfoEntry(uint8_t addr, uint8_t ep) { + UHS_Device *p = addrPool.GetUsbDevicePtr(addr); + + if(!p || !p->epinfo) + return NULL; + + + UHS_EpInfo *pep; + for(uint8_t j = 0; j < UHS_HOST_MAX_INTERFACE_DRIVERS; j++) { + pep = (UHS_EpInfo *)(p->epinfo[j]); + + for(uint8_t i = 0; i < p->epcount; i++) { + if((pep)->epAddr == ep) { + HOST_DEBUG("ep entry for interface %d ep %d max packet size = %d\r\n", pep->bIface, ep, pep->maxPktSize); + return pep; + } + + pep++; + } + } + return NULL; +} + +/** + * Sets a device table entry for a device. + * Each device is different and has different number of endpoints. + * This function plugs endpoint record structure, defined in application, to devtable + * + * @param addr device address + * @param epcount how many endpoints + * @param eprecord pointer to the endpoint structure + * @return Zero for success, or error code + */ +uint8_t UHS_USB_HOST_BASE::setEpInfoEntry(uint8_t addr, uint8_t iface, uint8_t epcount, volatile UHS_EpInfo* eprecord) { + if(!eprecord) + return UHS_HOST_ERROR_BAD_ARGUMENT; + + UHS_Device *p = addrPool.GetUsbDevicePtr(addr); + + if(!p) + return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; + + p->address.devAddress = addr; + p->epinfo[iface] = eprecord; + p->epcount = epcount; + return 0; +} + +/** + * sets all endpoint addresses to zero. + * Sets all max packet sizes to defaults + * Clears all endpoint attributes + * Sets bmNakPower to USB_NAK_DEFAULT + * Sets binterface to zero. + * Sets bNumEP to zero. + * Sets bAddress to zero. + * Clears qNextPollTime and sets bPollEnable to false. + * + * @param maxep How many endpoints to initialize + * @param device pointer to the device driver instance (this) + */ + +void UHS_USB_HOST_BASE::DeviceDefaults(uint8_t maxep, UHS_USBInterface *interface) { + + for(uint8_t i = 0; i < maxep; i++) { + interface->epInfo[i].epAddr = 0; + interface->epInfo[i].maxPktSize = (i) ? 0 : 8; + interface->epInfo[i].epAttribs = 0; + interface->epInfo[i].bmNakPower = UHS_USB_NAK_DEFAULT; + } + interface->pUsb->GetAddressPool()->FreeAddress(interface->bAddress); + interface->bIface = 0; + interface->bNumEP = 1; + interface->bAddress = 0; + interface->qNextPollTime = 0; + interface->bPollEnable = false; +} + +/** + * Perform a bus reset to the port of the connected device + * + * @param parent index to Parent + * @param port what port on the parent + * @param address address of the device + * @return Zero for success, or error code + */ + +uint8_t UHS_USB_HOST_BASE::doSoftReset(uint8_t parent, uint8_t port, uint8_t address) { + uint8_t rcode = 0; + + if(parent == 0) { + // Send a bus reset on the root interface. + doHostReset(); + } else { + // reset parent port + devConfig[parent]->ResetHubPort(port); + } + + // + // Many devices require a delay before setting the address here... + // We loop upon fails for up to 2 seconds instead. + // Most devices will be happy without a retry. + // + uint8_t retries = 0; + if(address) { + do { + rcode = setAddr(0, address); + if(!rcode) break; + retries++; + sof_delay(10); + } while(retries < 200); + HOST_DEBUG("%i retries.\r\n", retries); + } else { +#if DEBUG_PRINTF_EXTRA_HUGE + printf("\r\ndoSoftReset called with address == 0.\r\n"); +#endif + } + return rcode; +} + +/* + * Pseudo code so you may understand the code flow. + * + * reset; (happens at the lower level) + * GetDevDescr(); + * reset; + * If there are no configuration descriptors { + * // + * // Note: I know of no device that does this. + * // I suppose there could be one though. + * // + * try to enumerate. + * } else { + * last success count = 0 + * best config = 0 + * for each configuration descriptor { + * for each interface descriptor { + * get the endpoint descriptors for this interface. + * Check to see if a driver can handle this interface. + * If it can, add 1 to the success count. + * } + * if success count > last success count { + * best config = current config + * last success count = success count + * } + * } + * set the device config to the best config + * for each best config interface descriptor { + * initialize driver that can handle this interface config + * } + * } + * + * NOTES: + * 1: We do not need to save toggle states anymore and have not + * needed to for some time, because the lower level driver + * actually corrects wrong toggles on-the-fly for us. + * + * 2: We always do a second reset, since this stupid bug is + * actually part of the specification documents that I + * have found all over the net. Even Linux does it, and + * many devices actually EXPECT this behavior. Some devices + * will not enumerate without it. For devices that do not + * need it, the additional reset is harmless. Here is an + * example of one of these documents, see page Five: + * https://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_113_Simplified%20Description%20of%20USB%20Device%20Enumeration.pdf + * + */ + +/** + * Enumerates interfaces on devices + * + * @param parent index to Parent + * @param port what port on the parent + * @param speed the speed of the device + * @return Zero for success, or error code + */ +uint8_t UHS_USB_HOST_BASE::Configuring(uint8_t parent, uint8_t port, uint8_t speed) { + //uint8_t bAddress = 0; + HOST_DEBUG("\r\n\r\n\r\nConfiguring: parent = %i, port = %i, speed = %i\r\n", parent, port, speed); + uint8_t rcode = 0; + uint8_t retries = 0; + uint8_t numinf = 0; + uint8_t configs; + UHS_Device *p = NULL; + //EpInfo epInfo; // cap at 16, this should be fairly reasonable. + ENUMERATION_INFO ei; + uint8_t bestconf = 0; + uint8_t bestsuccess = 0; + + uint8_t devConfigIndex; + +#if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE + const uint8_t biggest = 0x40; + // wrap in {} to throw away the 64 byte buffer when we are done with it + { + uint8_t buf[biggest]; + USB_FD_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); +#else + const uint8_t biggest = 18; + uint8_t buf[biggest]; + USB_FD_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); + USB_FD_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); +#endif + + //for(devConfigIndex = 0; devConfigIndex < UHS_HOST_MAX_INTERFACE_DRIVERS; devConfigIndex++) { + // if((devConfig[devConfigIndex]->bAddress) && (!devConfig[devConfigIndex]->bPollEnable)) { + // devConfig[devConfigIndex]->bAddress = 0; + // } + //} + // Serial.print("HOST USB Host @ 0x"); + // Serial.println((uint32_t)this, HEX); + // Serial.print("HOST USB Host Address Pool @ 0x"); + // Serial.println((uint32_t)GetAddressPool(), HEX); + + sof_delay(200); + p = addrPool.GetUsbDevicePtr(0); + if(!p) { + HOST_DEBUG("Configuring error: USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL\r\n"); + return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; + } + + p->speed = speed; +#if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE + + p->epinfo[0][0].maxPktSize = 0x40; // Windows bug is expected. + // poison data + // udd->bMaxPacketSize0 = 0U; +#else + p->epinfo[0][0].maxPktSize = 0x08; // USB Spec, start small, work your way up. +#endif +again: + memset((void *)buf, 0, biggest); + HOST_DEBUG("\r\n\r\nConfiguring PktSize 0x%2.2x, rcode: 0x%2.2x, retries %i,\r\n", p->epinfo[0][0].maxPktSize, rcode, retries); + rcode = getDevDescr(0, biggest, (uint8_t*)buf); +#if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE + if(rcode || udd->bMaxPacketSize0 < 8) +#else + if(rcode) +#endif + { + if(rcode == UHS_HOST_ERROR_JERR && retries < 4) { + // + // Some devices return JERR when plugged in. + // Attempts to reinitialize the device usually works. + // + // I have a hub that will refuse to work and acts like + // this unless external power is supplied. + // So this may not always work, and you may be fooled. + // + sof_delay(100); + retries++; + goto again; +#if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE + } else if(((rcode == UHS_HOST_ERROR_DMA || rcode == UHS_HOST_ERROR_MEM_LAT) && retries < 4) || (udd->bMaxPacketSize0 < 8 && !rcode)) { + + if(p->epinfo[0][0].maxPktSize > 8 && rcode == UHS_HOST_ERROR_DMA) p->epinfo[0][0].maxPktSize = p->epinfo[0][0].maxPktSize >> 1; +#else + } else if((rcode == UHS_HOST_ERROR_DMA || rcode == UHS_HOST_ERROR_MEM_LAT) && retries < 4) { + if(p->epinfo[0][0].maxPktSize < 32) p->epinfo[0][0].maxPktSize = p->epinfo[0][0].maxPktSize << 1; +#endif + HOST_DEBUG("Configuring error: 0x%2.2x UHS_HOST_ERROR_DMA. Retry with maxPktSize: %i\r\n", rcode, p->epinfo[0][0].maxPktSize); + doSoftReset(parent, port, 0); + retries++; + sof_delay(200); + goto again; + } + HOST_DEBUG("Configuring error: 0x%2.2x Can't get USB_FD_DEVICE_DESCRIPTOR\r\n", rcode); + return rcode; + } + + +#if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE + ei.address = addrPool.AllocAddress(parent, false, port); + + if(!ei.address) { + return UHS_HOST_ERROR_ADDRESS_POOL_FULL; + } + + p = addrPool.GetUsbDevicePtr(ei.address); + // set to 1 if you suspect address table corruption. +#if 0 + if(!p) { + return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; + } +#endif + + p->speed = speed; + + rcode = doSoftReset(parent, port, ei.address); + + if(rcode) { + addrPool.FreeAddress(ei.address); + HOST_DEBUG("Configuring error: %2.2x Can't set USB INTERFACE ADDRESS\r\n", rcode); + return rcode; + } + + { // the { } wrapper saves on stack. + HOST_DEBUG("DevDescr 2nd poll, bMaxPacketSize0:%u\r\n", udd->bMaxPacketSize0); + UHS_EpInfo dev1ep; + dev1ep.maxPktSize = udd->bMaxPacketSize0; + dev1ep.epAddr = 0; + dev1ep.epAttribs = 0; + dev1ep.bmNakPower = UHS_USB_NAK_MAX_POWER; + p->address.devAddress = ei.address; + p->epcount = 1; + p->epinfo[0] = &dev1ep; + + sof_delay(10); + memset((void *)buf, 0, biggest); + rcode = getDevDescr(ei.address, 18, (uint8_t*)buf); + if(rcode) HOST_DEBUG("getDevDescr err: 0x%x \r\n", rcode); + + addrPool.FreeAddress(ei.address); + if(rcode && rcode != UHS_HOST_ERROR_DMA) { + return rcode; + } + sof_delay(10); + } +#endif + + ei.vid = udd->idVendor; + ei.pid = udd->idProduct; + ei.bcdDevice = udd->bcdDevice; + ei.klass = udd->bDeviceClass; + ei.subklass = udd->bDeviceSubClass; + ei.protocol = udd->bDeviceProtocol; + ei.bMaxPacketSize0 = udd->bMaxPacketSize0; + ei.currentconfig = 0; + ei.parent = parent; + ei.port = port; + configs = udd->bNumConfigurations; +#if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE + } // unwrapped, old large buf now invalid and discarded. + + uint8_t buf[18]; + USB_FD_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); +#endif + + ei.address = addrPool.AllocAddress(parent, IsHub(ei.klass), port); + + if(!ei.address) { + return UHS_HOST_ERROR_ADDRESS_POOL_FULL; + } + + p = addrPool.GetUsbDevicePtr(ei.address); + // set to 1 if you suspect address table corruption. +#if 0 + if(!p) { + return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; + } +#endif + + p->speed = speed; + + rcode = doSoftReset(parent, port, ei.address); + + if(rcode) { + addrPool.FreeAddress(ei.address); + HOST_DEBUG("Configuring error: %2.2x Can't set USB INTERFACE ADDRESS\r\n", rcode); + return rcode; + } + + if(configs < 1) { + HOST_DEBUG("No interfaces?!\r\n"); + addrPool.FreeAddress(ei.address); + // rcode = TestInterface(&ei); + // Not implemented (yet) + rcode = UHS_HOST_ERROR_DEVICE_NOT_SUPPORTED; + } else { + HOST_DEBUG("configs: %i\r\n", configs); + for(uint8_t conf = 0; (!rcode) && (conf < configs); conf++) { + // read the config descriptor into a buffer. + rcode = getConfDescr(ei.address, sizeof (USB_FD_CONFIGURATION_DESCRIPTOR), conf, buf); + if(rcode) { + HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR\r\n", rcode); + rcode = UHS_HOST_ERROR_FailGetConfDescr; + continue; + } + ei.currentconfig = conf; + numinf = ucd->bNumInterfaces; // Does _not_ include alternates! + HOST_DEBUG("CONFIGURATION: %i, bNumInterfaces %i, wTotalLength %i\r\n", conf, numinf, ucd->wTotalLength); + uint8_t success = 0; + uint16_t inf = 0; + uint8_t data[ei.bMaxPacketSize0]; + UHS_EpInfo *pep; + pep = ctrlReqOpen(ei.address, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, ei.currentconfig, USB_DESCRIPTOR_CONFIGURATION, 0x0000U, ucd->wTotalLength), data); + if(!pep) { + rcode = UHS_HOST_ERROR_NULL_EPINFO; + continue; + } + uint16_t left; + uint16_t read; + uint8_t offset; + rcode = initDescrStream(&ei, ucd, pep, data, &left, &read, &offset); + if(rcode) { + HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode); + break; + } + for(; (numinf) && (!rcode); inf++) { + // iterate for each interface on this config + rcode = getNextInterface(&ei, pep, data, &left, &read, &offset); + if(rcode == UHS_HOST_ERROR_END_OF_STREAM) { + HOST_DEBUG("USB_INTERFACE END OF STREAM\r\n"); + ctrlReqClose(pep, UHS_bmREQ_GET_DESCR, left, ei.bMaxPacketSize0, data); + rcode = 0; + break; + } + if(rcode) { + HOST_DEBUG("Configuring error: %2.2x Can't close USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode); + continue; + } + rcode = TestInterface(&ei); + if(!rcode) success++; + rcode = 0; + } + if(!inf) { + rcode = TestInterface(&ei); + if(!rcode) success++; + rcode = 0; + } + if(success > bestsuccess) { + bestconf = conf; + bestsuccess = success; + } + } + if(!bestsuccess) rcode = UHS_HOST_ERROR_DEVICE_NOT_SUPPORTED; + } + if(!rcode) { + rcode = getConfDescr(ei.address, sizeof (USB_FD_CONFIGURATION_DESCRIPTOR), bestconf, buf); + if(rcode) { + HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR\r\n", rcode); + rcode = UHS_HOST_ERROR_FailGetConfDescr; + } + } + if(!rcode) { + bestconf++; + ei.currentconfig = bestconf; + numinf = ucd->bNumInterfaces; // Does _not_ include alternates! + HOST_DEBUG("CONFIGURATION: %i, bNumInterfaces %i, wTotalLength %i\r\n", bestconf, numinf, ucd->wTotalLength); + if(!rcode) { + HOST_DEBUG("Best configuration is %i, enumerating interfaces.\r\n", bestconf); + uint16_t inf = 0; + uint8_t data[ei.bMaxPacketSize0]; + UHS_EpInfo *pep; + pep = ctrlReqOpen(ei.address, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, ei.currentconfig - 1, USB_DESCRIPTOR_CONFIGURATION, 0x0000U, ucd->wTotalLength), data); + if(!pep) { + rcode = UHS_HOST_ERROR_NULL_EPINFO; + + } else { + uint16_t left; + uint16_t read; + uint8_t offset; + rcode = initDescrStream(&ei, ucd, pep, data, &left, &read, &offset); + if(rcode) { + HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode); + } else { + for(; (numinf) && (!rcode); inf++) { + // iterate for each interface on this config + rcode = getNextInterface(&ei, pep, data, &left, &read, &offset); + if(rcode == UHS_HOST_ERROR_END_OF_STREAM) { + ctrlReqClose(pep, UHS_bmREQ_GET_DESCR, left, ei.bMaxPacketSize0, data); + rcode = 0; + break; + } + if(rcode) { + HOST_DEBUG("Configuring error: %2.2x Can't close USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode); + continue; + } + + if(enumerateInterface(&ei) == UHS_HOST_MAX_INTERFACE_DRIVERS) { + HOST_DEBUG("No interface driver for this interface."); + } else { + HOST_DEBUG("Interface Configured\r\n"); + } + } + } + } + } else { + HOST_DEBUG("Configuring error: %2.2x Can't set USB_INTERFACE_CONFIG stream.\r\n", rcode); + } + } + + if(!rcode) { + rcode = setConf(ei.address, bestconf); + if(rcode) { + HOST_DEBUG("Configuring error: %2.2x Can't set Configuration.\r\n", rcode); + addrPool.FreeAddress(ei.address); + } else { + for(devConfigIndex = 0; devConfigIndex < UHS_HOST_MAX_INTERFACE_DRIVERS; devConfigIndex++) { + HOST_DEBUG("Driver %i ", devConfigIndex); + if(!devConfig[devConfigIndex]) { + HOST_DEBUG("no driver at this index.\r\n"); + continue; // no driver + } + HOST_DEBUG("@ %2.2x ", devConfig[devConfigIndex]->bAddress); + if(devConfig[devConfigIndex]->bAddress) { + if(!devConfig[devConfigIndex]->bPollEnable) { + HOST_DEBUG("Initialize\r\n"); + rcode = devConfig[devConfigIndex]->Finalize(); + rcode = devConfig[devConfigIndex]->Start(); + if(!rcode) { + HOST_DEBUG("Total endpoints = (%i)%i\r\n", p->epcount, devConfig[devConfigIndex]->bNumEP); + } else { + break; + } + } else { + HOST_DEBUG("Already initialized.\r\n"); + continue; // consumed + } + } else { + HOST_DEBUG("Skipped\r\n"); + } + } +#if 0 // defined(UHS_HID_LOADED) + // Now do HID +#endif + } + } else { + addrPool.FreeAddress(ei.address); + } + return rcode; +} + +/** + * Removes a device from the tables + * + * @param addr address of the device + * @return nothing + */ +void UHS_USB_HOST_BASE::ReleaseDevice(uint8_t addr) { + if(addr) { +#if 0 // defined(UHS_HID_LOADED) + // Release any HID children + UHS_HID_Release(this, addr); +#endif + for(uint8_t i = 0; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) { + if(!devConfig[i]) continue; + if(devConfig[i]->bAddress == addr) { + devConfig[i]->Release(); + break; + } + } + } +} + +/** + * Gets the device descriptor, or part of it from endpoint Zero. + * + * @param addr Address of the device + * @param nbytes how many bytes to return + * @param dataptr pointer to the data to return + * @return status of the request, zero is success. + */ +uint8_t UHS_USB_HOST_BASE::getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t *dataptr) { + return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes), nbytes, dataptr)); +} + +/** + * Gets the config descriptor, or part of it from endpoint Zero. + * + * @param addr Address of the device + * @param nbytes how many bytes to return + * @param conf index to descriptor to return + * @param dataptr ointer to the data to return + * @return status of the request, zero is success. + */ +uint8_t UHS_USB_HOST_BASE::getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t *dataptr) { + return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes), nbytes, dataptr)); +} + +/** + * Get the string descriptor from a device + * + * @param addr Address of the device + * @param ns + * @param index + * @param langid language ID + * @param dataptr pointer to the data to return + * @return status of the request, zero is success. + */ +uint8_t UHS_USB_HOST_BASE::getStrDescr(uint8_t addr, uint16_t ns, uint8_t index, uint16_t langid, uint8_t *dataptr) { + return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns), ns, dataptr)); +} + +// +//set address +// + +/** + * Set the address of a device to a new address via endpoint Zero. + * + * @param oldaddr current address + * @param newaddr new address + * @return status of the request, zero is success. + */ +uint8_t UHS_USB_HOST_BASE::setAddr(uint8_t oldaddr, uint8_t newaddr) { + uint8_t rcode = ctrlReq(oldaddr, mkSETUP_PKT8(UHS_bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000), 0x0000, NULL); + sof_delay(300); // Older spec says you should wait at least 200ms + return rcode; +} + +// +//set configuration +// + +/** + * Set the configuration for the device to use via endpoint Zero. + * + * @param addr Address of the device + * @param conf_value configuration index value + * @return status of the request, zero is success. + */ +uint8_t UHS_USB_HOST_BASE::setConf(uint8_t addr, uint8_t conf_value) { + return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000), 0x0000, NULL)); +} + +/* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */ + +/** + * Writes data to an interface pipe + * + * @param addr Address of the device + * @param ep Endpoint of the pipe + * @param nbytes number of bytes to transfer + * @param data pointer to buffer to hold transfer + * @return zero for success or error code + */ +uint8_t UHS_USB_HOST_BASE::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data) { + UHS_EpInfo *pep = NULL; + uint16_t nak_limit = 0; + HOST_DEBUG("outTransfer: addr: 0x%2.2x ep: 0x%2.2x nbytes: 0x%4.4x data: 0x%p\r\n", addr, ep, nbytes, data); + + uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit); + HOST_DEBUG("outTransfer: SetAddress 0x%2.2x\r\n", rcode); + if(!rcode) + rcode = OutTransfer(pep, nak_limit, nbytes, data); + return rcode; +}; + +/** + * Reads data from an interface pipe + * + * @param addr Address of the device + * @param ep Endpoint of the pipe + * @param nbytesptr number of bytes to transfer + * @param data pointer to buffer to hold transfer + * @return zero for success or error code + */ +uint8_t UHS_USB_HOST_BASE::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data) { + UHS_EpInfo *pep = NULL; + uint16_t nak_limit = 0; + + uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit); + + // if(rcode) { + // USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81); + // USBTRACE3("(USB::InTransfer) addr requested ", addr, 0x81); + // USBTRACE3("(USB::InTransfer) ep requested ", ep, 0x81); + // return rcode; + // } + if(!rcode) + rcode = InTransfer(pep, nak_limit, nbytesptr, data); + return rcode; + +} + +/** + * Initialize the descriptor stream, works much like opening a file. + * + * @param ei + * @param ucd + * @param pep + * @param data + * @param left + * @param read + * @param offset + * @return zero for success or error code + */ +uint8_t UHS_USB_HOST_BASE::initDescrStream(ENUMERATION_INFO *ei, USB_FD_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset) { + if(!ei || !ucd) return UHS_HOST_ERROR_BAD_ARGUMENT; + if(!pep) return UHS_HOST_ERROR_NULL_EPINFO; + *left = ucd->wTotalLength; + *read = 0; + *offset = 1; + uint8_t rcode; + pep->maxPktSize = ei->bMaxPacketSize0; + rcode = getone(pep, left, read, data, offset); + return rcode; +} + +uint8_t UHS_USB_HOST_BASE::getNextInterface(ENUMERATION_INFO *ei, UHS_EpInfo *pep, uint8_t data[], uint16_t *left, uint16_t *read, uint8_t *offset) { + uint16_t remain; + uint8_t ty; + uint8_t rcode = UHS_HOST_ERROR_END_OF_STREAM; + uint8_t *ptr; + uint8_t epc = 0; + ei->interface.numep = 0; + ei->interface.klass = 0; + ei->interface.subklass = 0; + ei->interface.protocol = 0; + while(*left + *read) { + remain = data[*offset]; // bLength + while(remain < 2) { + rcode = getone(pep, left, read, data, offset); + if(rcode) + return rcode; + remain = data[*offset]; + } + rcode = getone(pep, left, read, data, offset); + if(rcode) + return rcode; + ty = data[*offset]; // bDescriptorType + HOST_DEBUG("bLength: %i ", remain); + HOST_DEBUG("bDescriptorType: %2.2x\r\n", ty); + remain--; + if(ty == USB_DESCRIPTOR_INTERFACE) { + HOST_DEBUG("INTERFACE DESCRIPTOR FOUND\r\n"); + ptr = (uint8_t *)(&(ei->interface.bInterfaceNumber)); + for(int i = 0; i < 6; i++) { + rcode = getone(pep, left, read, data, offset); + if(rcode) + return rcode; + *ptr = data[*offset]; + ptr++; + } + rcode = getone(pep, left, read, data, offset); + if(rcode) + return rcode; + // Now at iInterface + // Get endpoints. + HOST_DEBUG("Getting %i endpoints\r\n", ei->interface.numep); + while(epc < ei->interface.numep) { + rcode = getone(pep, left, read, data, offset); + if(rcode) { + HOST_DEBUG("ENDPOINT DESCRIPTOR DIED WAY EARLY\r\n"); + return rcode; + } + remain = data[*offset]; // bLength + while(remain < 2) { + rcode = getone(pep, left, read, data, offset); + if(rcode) + return rcode; + remain = data[*offset]; + } + rcode = getone(pep, left, read, data, offset); + if(rcode) { + HOST_DEBUG("ENDPOINT DESCRIPTOR DIED EARLY\r\n"); + return rcode; + } + ty = data[*offset]; // bDescriptorType + HOST_DEBUG("bLength: %i ", remain); + HOST_DEBUG("bDescriptorType: %2.2x\r\n", ty); + remain -= 2; + if(ty == USB_DESCRIPTOR_ENDPOINT) { + HOST_DEBUG("ENDPOINT DESCRIPTOR: %i\r\n", epc); + ptr = (uint8_t *)(&(ei->interface.epInfo[epc].bEndpointAddress)); + for(unsigned int i = 0; i< sizeof (ENDPOINT_INFO); i++) { + rcode = getone(pep, left, read, data, offset); + if(rcode) { + HOST_DEBUG("ENDPOINT DESCRIPTOR DIED LATE\r\n"); + return rcode; + } + *ptr = data[*offset]; + ptr++; + remain--; + } + epc++; + HOST_DEBUG("ENDPOINT DESCRIPTOR OK\r\n"); + } + rcode = eat(pep, left, read, data, offset, &remain); + if(rcode) { + HOST_DEBUG("ENDPOINT DESCRIPTOR DIED EATING\r\n"); + return rcode; + } + remain = 0; + } + remain = 1; + // queue ahead, but do not report if error. + rcode = eat(pep, left, read, data, offset, &remain); + if(!ei->interface.numep && rcode) { + return rcode; + } + HOST_DEBUG("ENDPOINT DESCRIPTORS FILLED\r\n"); + return 0; + } else { + rcode = eat(pep, left, read, data, offset, &remain); + if(rcode) + return rcode; + } + rcode = UHS_HOST_ERROR_END_OF_STREAM; + } + return rcode; +} + +uint8_t UHS_USB_HOST_BASE::seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_FD_CONFIGURATION_DESCRIPTOR *ucd) { + if(!ei || !ucd) return UHS_HOST_ERROR_BAD_ARGUMENT; + uint8_t data[ei->bMaxPacketSize0]; + UHS_EpInfo *pep; + pep = ctrlReqOpen(ei->address, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, ei->currentconfig, + USB_DESCRIPTOR_CONFIGURATION, 0x0000U, ucd->wTotalLength), data); + if(!pep) return UHS_HOST_ERROR_NULL_EPINFO; + uint16_t left = ucd->wTotalLength; + uint8_t cinf = 0; + uint8_t ty; + uint8_t epc = 0; + uint16_t remain = ucd->bLength; + uint16_t read = 0; + uint8_t offset = remain; + uint8_t *ptr; + uint8_t rcode; + ei->interface.numep = 0; + ei->interface.klass = 0; + ei->interface.subklass = 0; + ei->interface.protocol = 0; + pep->maxPktSize = ei->bMaxPacketSize0; + + rcode = getone(pep, &left, &read, data, &offset); + if(rcode) + return rcode; + HOST_DEBUG("\r\nGetting interface: %i\r\n", inf); + inf++; + while(cinf != inf && (left + read)) { + //HOST_DEBUG("getInterface: cinf: %i inf: %i left: %i read: %i offset: %i remain %i\r\n", cinf, inf, left, read, offset, remain); + // Go past current descriptor + HOST_DEBUG("Skip: %i\r\n", remain); + rcode = eat(pep, &left, &read, data, &offset, &remain); + if(rcode) + return rcode; + remain = data[offset]; // bLength + while(remain < 2) { + rcode = getone(pep, &left, &read, data, &offset); + if(rcode) + return rcode; + remain = data[offset]; + } + rcode = getone(pep, &left, &read, data, &offset); + if(rcode) + return rcode; + ty = data[offset]; // bDescriptorType + HOST_DEBUG("bLength: %i ", remain); + HOST_DEBUG("bDescriptorType: %2.2x\r\n", ty); + remain--; + if(ty == USB_DESCRIPTOR_INTERFACE) { + HOST_DEBUG("INTERFACE DESCRIPTOR: %i\r\n", cinf); + cinf++; + if(cinf == inf) { + // Get the interface descriptor information. + ptr = (uint8_t *)(&(ei->interface.bInterfaceNumber)); + for(int i = 0; i < 6; i++) { + rcode = getone(pep, &left, &read, data, &offset); + if(rcode) + return rcode; + *ptr = data[offset]; + ptr++; + } + rcode = getone(pep, &left, &read, data, &offset); + if(rcode) + return rcode; + // Now at iInterface + remain = 0; + // Get endpoints. + HOST_DEBUG("Getting %i endpoints\r\n", ei->interface.numep); + while(epc < ei->interface.numep) { + rcode = getone(pep, &left, &read, data, &offset); + if(rcode) + return rcode; + remain = data[offset]; // bLength + while(remain < 2) { + rcode = getone(pep, &left, &read, data, &offset); + if(rcode) + return rcode; + remain = data[offset]; + } + rcode = getone(pep, &left, &read, data, &offset); + if(rcode) + return rcode; + ty = data[offset]; // bDescriptorType + HOST_DEBUG("bLength: %i ", remain); + HOST_DEBUG("bDescriptorType: %2.2x\r\n", ty); + remain--; + if(ty == USB_DESCRIPTOR_ENDPOINT) { + HOST_DEBUG("ENDPOINT DESCRIPTOR: %i\r\n", epc); + ptr = (uint8_t *)(&(ei->interface.epInfo[epc].bEndpointAddress)); + for(unsigned int i = 0; i< sizeof (ENDPOINT_INFO); i++) { + rcode = getone(pep, &left, &read, data, &offset); + if(rcode) + return rcode; + *ptr = data[offset]; + ptr++; + } + epc++; + remain = 0; + } else { + rcode = eat(pep, &left, &read, data, &offset, &remain); + if(rcode) + return rcode; + remain = 0; + } + } + } + } + } + + return ctrlReqClose(pep, UHS_bmREQ_GET_DESCR, left, ei->bMaxPacketSize0, data); +} + +uint8_t UHS_USB_HOST_BASE::getone(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset) { + uint8_t rcode = 0; + *offset += 1; + if(*offset < *read) { + return 0; + } else if(*left > 0) { + // uint16_t num = *left; + uint16_t num = pep->maxPktSize; + if(num > *left) num = *left; + *offset = 0; + rcode = ctrlReqRead(pep, left, read, num, dataptr); + if(rcode == 0) { + if(*read == 0) { + rcode = UHS_HOST_ERROR_END_OF_STREAM; + } else if(*read < num) *left = 0; + } + } else { + rcode = UHS_HOST_ERROR_END_OF_STREAM; + } + return rcode; +} + +uint8_t UHS_USB_HOST_BASE::eat(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset, uint16_t *yum) { + uint8_t rcode = 0; + HOST_DEBUG("eating %i\r\n", *yum); + while(*yum) { + *yum -= 1; + rcode = getone(pep, left, read, dataptr, offset); + if(rcode) break; + } + return rcode; +} + +uint8_t UHS_USB_HOST_BASE::ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t *dataptr) { + //bool direction = bmReqType & 0x80; //request direction, IN or OUT + uint8_t rcode = 0; + + //Serial.println(); + UHS_EpInfo *pep = ctrlReqOpen(addr, Request, dataptr); + if(!pep) { + HOST_DEBUG("ctrlReq1: ERROR_NULL_EPINFO addr: %d\r\n", addr); + return UHS_HOST_ERROR_NULL_EPINFO; + } + uint8_t rt = (uint8_t)(Request & 0xFFU); + + // Serial.println("Opened"); + uint16_t left = (uint16_t)(Request >> 48) /*total*/; + if(dataptr != NULL) { + //data stage + if((rt & 0x80) == 0x80) { + //IN transfer + while(left) { + // Bytes read into buffer + uint16_t read = nbytes; + HOST_DEBUG("ctrlReq2: left: %i, read:%i, nbytes %i\r\n", left, read, nbytes); + rcode = ctrlReqRead(pep, &left, &read, nbytes, dataptr); + +#if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE + HOST_DEBUG("RESULT: 0x%2.2x 0x%2.2x 0x%2.2x 0x%8.8lx%8.8lx\r\n", rcode, addr, read, (uint32_t)((Request>>32)&0xFFFFFFFFLU), (uint32_t)(Request&0xFFFFFFFFLU)); + // Should only be used for GET_DESCRIPTOR USB_DESCRIPTOR_DEVICE + constexpr uint32_t req_match = ((uint32_t)USB_DESCRIPTOR_DEVICE << 24) | + ((uint32_t)USB_REQUEST_GET_DESCRIPTOR << 8); + const uint32_t req_found = Request & 0xFF00FF00ul; + if(!addr && read && (req_found == req_match)) { + HOST_DEBUG("ctrlReq3: acceptBuffer sz %i nbytes %i left %i\n\r", read, nbytes, left); + left = 0; + rcode = UHS_HOST_ERROR_NONE; + break; + } +#endif + if(rcode) { + return rcode; + } + } + } else { + // OUT transfer + rcode = OutTransfer(pep, 0, nbytes, dataptr); + } + if(rcode) { + //return error + return ( rcode); + } + } + + // Serial.println("Close Phase"); + // Serial.flush(); + // Status stage + rcode = ctrlReqClose(pep, rt, left, nbytes, dataptr); + // Serial.println("Closed"); + return rcode; +} + +uint8_t UHS_USB_HOST_BASE::EPClearHalt(uint8_t addr, uint8_t ep) { + return ctrlReq(addr, mkSETUP_PKT8(USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_ENDPOINT, USB_REQUEST_CLEAR_FEATURE, USB_FEATURE_ENDPOINT_HALT, 0, ep, 0), 0, NULL); +} + +uint8_t UHS_USB_HOST_BASE::TestInterface(ENUMERATION_INFO *ei) { + + uint8_t devConfigIndex; + uint8_t rcode = 0; + HOST_DEBUG("TestInterface VID:%4.4x PID:%4.4x Class:%2.2x Subclass:%2.2x Protocol %2.2x\r\n", ei->vid, ei->pid, ei->klass, ei->subklass, ei->protocol); + HOST_DEBUG("Interface data: Class:%2.2x Subclass:%2.2x Protocol %2.2x, number of endpoints %i\r\n", ei->interface.klass, ei->interface.subklass, ei->interface.subklass, ei->interface.numep); + HOST_DEBUG("Parent: %2.2x, bAddress: %2.2x\r\n", ei->parent, ei->address); + for(devConfigIndex = 0; devConfigIndex < UHS_HOST_MAX_INTERFACE_DRIVERS; devConfigIndex++) { + if(!devConfig[devConfigIndex]) { + HOST_DEBUG("No driver at index %i\r\n", devConfigIndex); + continue; // no driver + } + if(devConfig[devConfigIndex]->bAddress) { + HOST_DEBUG("Driver %i is already consumed @ %2.2x\r\n", devConfigIndex, devConfig[devConfigIndex]->bAddress); + continue; // consumed + } + + if(devConfig[devConfigIndex]->OKtoEnumerate(ei)) { + HOST_DEBUG("Driver %i supports this interface\r\n", devConfigIndex); + break; + } + } + if(devConfigIndex == UHS_HOST_MAX_INTERFACE_DRIVERS) { + rcode = UHS_HOST_ERROR_DEVICE_NOT_SUPPORTED; +#if 0 // defined(UHS_HID_LOADED) + // Check HID here, if it is, then lie + if(ei->klass == UHS_USB_CLASS_HID) { + devConfigIndex = UHS_HID_INDEX; // for debugging, otherwise this has no use. + rcode = 0; + } +#endif + } + if(!rcode) HOST_DEBUG("Driver %i can be used for this interface\r\n", devConfigIndex); + else HOST_DEBUG("No driver for this interface.\r\n"); + return rcode; +}; + +uint8_t UHS_USB_HOST_BASE::enumerateInterface(ENUMERATION_INFO *ei) { + uint8_t devConfigIndex; + + HOST_DEBUG("AttemptConfig: parent = %i, port = %i\r\n", ei->parent, ei->port); + +#if 0 // defined(UHS_HID_LOADED) + // Check HID here, if it is, then lie + if(ei->klass == UHS_USB_CLASS_HID || ei->interface.klass == UHS_USB_CLASS_HID) { + UHS_HID_SetUSBInterface(this, ENUMERATION_INFO * ei); + devConfigIndex = UHS_HID_INDEX; + } else +#endif + for(devConfigIndex = 0; devConfigIndex < UHS_HOST_MAX_INTERFACE_DRIVERS; devConfigIndex++) { + if(!devConfig[devConfigIndex]) { + HOST_DEBUG("No driver at index %i\r\n", devConfigIndex); + continue; // no driver + } + if(devConfig[devConfigIndex]->bAddress) { + HOST_DEBUG("Driver %i is already consumed @ %2.2x\r\n", devConfigIndex, devConfig[devConfigIndex]->bAddress); + continue; // consumed + } + + if(devConfig[devConfigIndex]->OKtoEnumerate(ei)) { + HOST_DEBUG("Driver %i supports this interface\r\n", devConfigIndex); + if(!devConfig[devConfigIndex]->SetInterface(ei)) break; + else devConfigIndex = UHS_HOST_MAX_INTERFACE_DRIVERS; + } + } + return devConfigIndex; +}; + + +//////////////////////////////////////////////////////////////////////////////// +// Vendor Specific Interface Class +//////////////////////////////////////////////////////////////////////////////// + +#if 0 +/** + * Might go away, depends on if it is useful, or not. + * + * @param ei Enumeration information + * @return true if this interface driver can handle this interface description + */ +bool UHS_NI UHS_VSI::OKtoEnumerate(ENUMERATION_INFO *ei) { + return ( + (ei->subklass == UHS_USB_CLASS_VENDOR_SPECIFIC) || + (ei->interface.subklass == UHS_USB_CLASS_VENDOR_SPECIFIC) + ); +} + +/** + * Copy the entire ENUMERATION_INFO structure + * @param ei Enumeration information + * @return 0 + */ +uint8_t UHS_NI UHS_VSI::SetInterface(ENUMERATION_INFO *ei) { + bNumEP = 1; + bAddress = ei->address; + + eInfo.address = ei->address; + eInfo.bMaxPacketSize0 = ei->bMaxPacketSize0; + eInfo.currentconfig = ei->currentconfig; + eInfo.interface.bAlternateSetting = ei->interface.bAlternateSetting; + eInfo.interface.bInterfaceNumber = ei->interface.bInterfaceNumber; + eInfo.interface.numep = ei->interface.numep; + eInfo.interface.protocol = ei->interface.protocol; + eInfo.interface.subklass = ei->interface.subklass; + eInfo.klass = ei->klass; + eInfo.parent = ei->parent; + eInfo.pid = ei->pid; + eInfo.port = ei->port; + eInfo.protocol = ei->protocol; + eInfo.subklass = ei->subklass; + eInfo.vid = ei->vid; + for(uint8_t i = 0; i < eInfo.interface.numep; i++) { + eInfo.interface.epInfo[i].bEndpointAddress = ei->interface.epInfo[i].bEndpointAddress; + eInfo.interface.epInfo[i].bInterval = ei->interface.epInfo[i].bInterval; + eInfo.interface.epInfo[i].bmAttributes = ei->interface.epInfo[i].bmAttributes; + eInfo.interface.epInfo[i].wMaxPacketSize = ei->interface.epInfo[i].wMaxPacketSize; + } + return 0; +} +#endif + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + + +#if 0 + +/* TO-DO: Move this silliness to a NONE driver. + * When we have a generic NONE driver we can: + * o Extract ALL device information to help users with a new device. + * o Use an unknown device from a sketch, kind of like usblib does. + * This will aid in making more drivers in a faster way. + */ +uint8_t UHS_USB_HOST_BASE::DefaultAddressing(uint8_t parent, uint8_t port, uint8_t speed) { + uint8_t rcode; + UHS_Device *p0 = NULL, *p = NULL; + + // Get pointer to pseudo device with address 0 assigned + p0 = addrPool.GetUsbDevicePtr(0); + + if(!p0) + return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; + + if(!p0->epinfo) + return UHS_HOST_ERROR_NULL_EPINFO; + + p0->speed = speed; + + // Allocate new address according to device class + uint8_t bAddress = addrPool.AllocAddress(parent, false, port); + + if(!bAddress) + return UHS_HOST_ERROR_ADDRESS_POOL_FULL; + + p = addrPool.GetUsbDevicePtr(bAddress); + + if(!p) + return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; + + p->speed = speed; + + // Assign new address to the device + rcode = setAddr(0, bAddress); + + if(rcode) { + addrPool.FreeAddress(bAddress); + bAddress = 0; + return rcode; + } + return 0; +} +#endif + +#else +#error "Never include UHS_host_INLINE.h, include UHS_host.h instead" +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_macros.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_macros.h new file mode 100644 index 0000000..bb2a87c --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_macros.h @@ -0,0 +1,230 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#ifndef MACROS_H +#define MACROS_H +#include "macro_logic.h" +/* + * Universal Arduino(tm) "IDE" fixups. + */ + + +// Just in case... +#ifndef SERIAL_PORT_MONITOR +#define SERIAL_PORT_MONITOR Serial +#endif + +#ifndef INT16_MIN +#define INT16_MIN -32768 +#endif +// require 10607+ +#if defined(ARDUINO) && ARDUINO >=10607 +// nop :-) +#else +#error "Arduino version too old, and must be at least 1.6.7" +#endif + +// Nuke screwed up macro junk from the IDE. +#ifdef __cplusplus +#ifdef true +#undef true +#endif +#ifdef false +#undef false +#endif +#endif + + +#ifndef UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE + +#ifndef UHS_BIG_FLASH + +#if defined(FLASHEND) && defined(FLASHSTART) +#if (FLASHEND - FLASHSTART) > 0x0FFFFU +#define UHS_BIG_FLASH 1 +#else +#define UHS_BIG_FLASH 0 +#endif + +#elif defined(__PIC32_FLASH_SIZE) +#if __PIC32_FLASH_SIZE > 511 +#define UHS_BIG_FLASH 1 +#else +#define UHS_BIG_FLASH 0 +#endif + +#elif defined(FLASHEND) && !defined(FLASHSTART) +// Assumes flash starts at 0x00000, is this a safe assumption? +// 192K + should be OK +#if FLASHEND > 0x02FFFFU +#define UHS_BIG_FLASH 1 +#else +#define UHS_BIG_FLASH 0 +#endif + +#elif defined(IFLASH_SIZE) +#if IFLASH_SIZE > 0x0FFFFU +#define UHS_BIG_FLASH 1 +#else +#define UHS_BIG_FLASH 0 +#endif + +#elif defined(ESP8266) +#define UHS_BIG_FLASH 1 +#define SYSTEM_OR_SPECIAL_YIELD(...) yield() + +#elif defined(__arm__) && defined(CORE_TEENSY) +#define UHS_BIG_FLASH 1 + +#elif defined(ARDUINO_spresense_ast) +#define UHS_BIG_FLASH 1 +#else +// safe default +#warning Small flash? +#define UHS_BIG_FLASH 0 +#endif +#endif + +#if UHS_BIG_FLASH +#define UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE 1 +#else +#define UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE 0 +#endif +#endif + +#if defined(__arm__) && defined(CORE_TEENSY) +#define UHS_PIN_WRITE(p, v) digitalWriteFast(p, v) +#define UHS_PIN_READ(p) digitalReadFast(p) +#endif +// TODO: Fast inline code for AVR and SAM based microcontrollers +// This can be done pretty easily. +// For now, this will just work out-of-the-box. +#ifndef UHS_PIN_WRITE +#define UHS_PIN_WRITE(p, v) digitalWrite(p, v) +#endif +#ifndef UHS_PIN_READ +#define UHS_PIN_READ(p) digitalRead(p) +#endif + +#if defined( __PIC32MX__ ) && !defined(interrupts) // compiling with Microchip XC32 compiler +#define interrupts() __builtin_enable_interrupts() +#edfine noInterrupts() __builtin_disable_interrupts() +#endif + +#ifndef ARDUINO_SAMD_ZERO +#ifdef ARDUINO_AVR_ADK +#define UHS_GET_DPI(x) (x == 54 ? 6 : digitalPinToInterrupt(x)) +#else +#define UHS_GET_DPI(x) digitalPinToInterrupt(x) +#endif +#else +#define UHS_GET_DPI(x) (x) +#endif + +#include "../../../../HAL/shared/progmem.h" + +//////////////////////////////////////////////////////////////////////////////// +// HANDY MACROS +//////////////////////////////////////////////////////////////////////////////// + +// Atomically set/clear single bits using bitbands. +// Believe it or not, this boils down to a constant, +// and is less code than using |= &= operators. +// Bonus, it makes code easier to read too. +// Bitbanding is a wonderful thing. +#define BITNR(i) (i&0x1?0:i&0x2?1:i&0x4?2:i&0x8?3:i&0x10?4:i&0x20?5:i&0x40?6:i&0x80?7:i&0x100?8:i&0x200?9:i&0x400?10:i&0x800?11:i&0x1000?12:i&0x2000?13:i&0x4000?14:i&0x8000?15:i&0x10000?16:i&0x20000?17:i&0x40000?18:i&0x80000?19:i&0x100000?20:i&0x200000?21:i&0x400000?22:i&0x800000?23:i&0x1000000?24:i&0x2000000?25:i&0x4000000?26:i&0x8000000?27:i&0x10000000?28:i&0x20000000?29:i&0x40000000?30:i&0x80000000?31:32) +#define UHS_KIO_BITBAND_ADDR(r, i) (((uint32_t)&(r) - 0x40000000) * 32 + (i) * 4 + 0x42000000) +#define UHS_KIO_SETBIT_ATOMIC(r, m) (*(uint32_t *)UHS_KIO_BITBAND_ADDR((r), BITNR((m)))) = 1 +#define UHS_KIO_CLRBIT_ATOMIC(r, m) (*(uint32_t *)UHS_KIO_BITBAND_ADDR((r), BITNR((m)))) = 0 + + +#define VALUE_BETWEEN(v,l,h) (((v)>(l)) && ((v)<(h))) +#define VALUE_WITHIN(v,l,h) (((v)>=(l)) && ((v)<=(h))) +#define output_pgm_message(wa,fp,mp,el) wa = &mp, fp((char *)pgm_read_pointer(wa), el) +#define output_if_between(v,l,h,wa,fp,mp,el) if(VALUE_BETWEEN(v,l,h)) output_pgm_message(wa,fp,mp[v-(l+1)],el); + +#define UHS_SWAP_VALUES(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))) +#ifndef __BYTE_GRABBING_DEFINED__ +#define __BYTE_GRABBING_DEFINED__ 1 +#ifdef BROKEN_OPTIMIZER_LITTLE_ENDIAN +// Note: Use this if your compiler generates horrible assembler! +#define UHS_UINT8_BYTE0(__usi__) (((uint8_t *)&(__usi__))[0]) +#define UHS_UINT8_BYTE1(__usi__) (((uint8_t *)&(__usi__))[1]) +#define UHS_UINT8_BYTE2(__usi__) (((uint8_t *)&(__usi__))[2]) +#define UHS_UINT8_BYTE3(__usi__) (((uint8_t *)&(__usi__))[3]) +#define UHS_UINT8_BYTE4(__usi__) (((uint8_t *)&(__usi__))[4]) +#define UHS_UINT8_BYTE5(__usi__) (((uint8_t *)&(__usi__))[5]) +#define UHS_UINT8_BYTE6(__usi__) (((uint8_t *)&(__usi__))[6]) +#define UHS_UINT8_BYTE7(__usi__) (((uint8_t *)&(__usi__))[7]) +#else +// Note: The cast alone to uint8_t is actually enough. +// GCC throws out the "& 0xFF", and the size is no different. +// Some compilers need it. +#define UHS_UINT8_BYTE0(__usi__) ((uint8_t)((__usi__) & 0xFF )) +#define UHS_UINT8_BYTE1(__usi__) ((uint8_t)(((__usi__) >> 8) & 0xFF)) +#define UHS_UINT8_BYTE2(__usi__) ((uint8_t)(((__usi__) >> 16) & 0xFF)) +#define UHS_UINT8_BYTE3(__usi__) ((uint8_t)(((__usi__) >> 24) & 0xFF)) +#define UHS_UINT8_BYTE4(__usi__) ((uint8_t)(((__usi__) >> 32) & 0xFF)) +#define UHS_UINT8_BYTE5(__usi__) ((uint8_t)(((__usi__) >> 40) & 0xFF)) +#define UHS_UINT8_BYTE6(__usi__) ((uint8_t)(((__usi__) >> 48) & 0xFF)) +#define UHS_UINT8_BYTE7(__usi__) ((uint8_t)(((__usi__) >> 56) & 0xFF)) +#endif +#define UHS_UINT16_SET_BYTE1(__usi__) ((uint16_t)(__usi__) << 8) +#define UHS_UINT32_SET_BYTE1(__usi__) ((uint32_t)(__usi__) << 8) +#define UHS_UINT64_SET_BYTE1(__usi__) ((uint64_t)(__usi__) << 8) +#define UHS_UINT32_SET_BYTE2(__usi__) ((uint32_t)(__usi__) << 16) +#define UHS_UINT64_SET_BYTE2(__usi__) ((uint64_t)(__usi__) << 16) +#define UHS_UINT32_SET_BYTE3(__usi__) ((uint32_t)(__usi__) << 24) +#define UHS_UINT64_SET_BYTE3(__usi__) ((uint64_t)(__usi__) << 24) +#define UHS_UINT64_SET_BYTE4(__usi__) ((uint64_t)(__usi__) << 32) +#define UHS_UINT64_SET_BYTE5(__usi__) ((uint64_t)(__usi__) << 40) +#define UHS_UINT64_SET_BYTE6(__usi__) ((uint64_t)(__usi__) << 48) +#define UHS_UINT64_SET_BYTE7(__usi__) ((uint64_t)(__usi__) << 56) + +// These are the smallest and fastest ways I have found so far in pure C/C++. +#define UHS_BYTES_TO_UINT16(__usc1__,__usc0__) ((uint16_t)((uint16_t)(__usc0__) | (uint16_t)UHS_UINT16_SET_BYTE1(__usc1__))) +#define UHS_BYTES_TO_UINT32(__usc3__,__usc2__,__usc1__,__usc0__) ((uint32_t)((uint32_t)(__usc0__) | UHS_UINT32_SET_BYTE1(__usc1__) | UHS_UINT32_SET_BYTE2(__usc2__) | UHS_UINT32_SET_BYTE3(__usc3__))) +#define UHS_BYTES_TO_UINT64(__usc7__,__usc6__,__usc5__,__usc4__,__usc3__,__usc2__,__usc1__,__usc0__) ((uint64_t)((uint64_t)__usc0__ | UHS_UINT64_SET_BYTE1(__usc1__) | UHS_UINT64_SET_BYTE2(__usc2__) | UHS_UINT64_SET_BYTE3(__usc3__) | UHS_UINT64_SET_BYTE4(__usc4__) | UHS_UINT64_SET_BYTE5(__usc5__) | UHS_UINT64_SET_BYTE6(__usc6__) | UHS_UINT64_SET_BYTE7(__usc7__))) +#endif +/* + * Debug macros. + * Useful when porting from UHS2. + * Do not use these for any new code. + * Change to better debugging after port is completed. + * Strings are stored in progmem (flash) instead of RAM. + */ +#define USBTRACE1(s,l) (Notify(PSTR(s), l)) +#define USBTRACE(s) (USBTRACE1((s), 0x80)); USB_HOST_SERIAL.flush() +#define USBTRACE3(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l), Notify(PSTR("\r\n"), l)) +#define USBTRACE3X(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l)) +#define USBTRACE2(s,r) (USBTRACE3((s),(r),0x80)); USB_HOST_SERIAL.flush() +#define USBTRACE2X(s,r) (USBTRACE3X((s),(r),0x80)); USB_HOST_SERIAL.flush() + +#define VOID0 ((void)0) +#ifndef NOTUSED +#define NOTUSED(...) __VA_ARGS__ __attribute__((unused)) +#endif +#endif /* MACROS_H */ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_message.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_message.h new file mode 100644 index 0000000..c0cc78d --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_message.h @@ -0,0 +1,91 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ +#if !defined(_UHS_host_h_) || defined(__MESSAGE_H__) +#error "Never include UHS_message.h directly; include UHS_Usb.h instead" +#else +#define __MESSAGE_H__ + +extern int UsbDEBUGlvl; + +void E_Notify(char const * msg, int lvl); +void E_Notify(uint8_t b, int lvl); +void E_NotifyStr(char const * msg, int lvl); +void E_Notifyc(char c, int lvl); + +#ifdef DEBUG_USB_HOST +#define Notify E_Notify +#define NotifyStr E_NotifyStr +#define Notifyc E_Notifyc +void NotifyFailGetDevDescr(uint8_t reason); +void NotifyFailSetDevTblEntry(uint8_t reason); +void NotifyFailGetConfDescr(uint8_t reason); +void NotifyFailSetConfDescr(uint8_t reason); +void NotifyFailGetDevDescr(); +void NotifyFailSetDevTblEntry(); +void NotifyFailGetConfDescr(); +void NotifyFailSetConfDescr(); +void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID); +void NotifyFail(uint8_t rcode); +#else +#define Notify(...) VOID0 +#define NotifyStr(...) VOID0 +#define Notifyc(...) VOID0 +#define NotifyFailGetDevDescr(...) VOID0 +#define NotifyFailSetDevTblEntry(...) VOID0 +#define NotifyFailGetConfDescr(...) VOID0 +#define NotifyFailGetDevDescr(...) VOID0 +#define NotifyFailSetDevTblEntry(...) VOID0 +#define NotifyFailGetConfDescr(...) VOID0 +#define NotifyFailSetConfDescr(...) VOID0 +#define NotifyFailUnknownDevice(...) VOID0 +#define NotifyFail(...) VOID0 +#endif + +#ifdef DEBUG_USB_HOST +template void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) { + Notify(msg, level); + Notify(PSTR(": "), level); + D_PrintHex (rcode, level); + Notify(PSTR("\r\n"), level); +#else +template void ErrorMessage(NOTUSED(uint8_t level), NOTUSED(char const * msg), ERROR_TYPE rcode = 0) { + (void)rcode; +#endif +} + +#ifdef DEBUG_USB_HOST +template void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) { + Notify(msg, 0x80); + Notify(PSTR(": "), 0x80); + D_PrintHex (rcode, 0x80); + Notify(PSTR("\r\n"), 0x80); +#else +template void ErrorMessage(NOTUSED(char const * msg), ERROR_TYPE rcode = 0) { + (void)rcode; +#endif +} + +#endif // __MESSAGE_H__ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printf_HELPER.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printf_HELPER.h new file mode 100644 index 0000000..4fc9b94 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printf_HELPER.h @@ -0,0 +1,200 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#ifndef UHS_PRINTF_HELPER_H +#define UHS_PRINTF_HELPER_H + +#ifdef LOAD_UHS_PRINTF_HELPER +#include +#ifdef true +#undef true +#endif +#ifdef false +#undef false +#endif + +#ifndef STDIO_IS_OK_TO_USE_AS_IS +#if defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAM_DUE) || defined(ARDUINO_spresense_ast) +// STDIO patching not required. +#define STDIO_IS_OK_TO_USE_AS_IS +#endif +#endif + +#ifndef STDIO_IS_OK_TO_USE_AS_IS +// We need to patch STDIO so it can be used. + +#ifndef SERIAL_PORT_MONITOR +// Some don't define this. +#define SERIAL_PORT_MONITOR Serial +#endif + +#ifndef SERIAL_PORT_HARDWARE +// Some don't define this. +#define SERIAL_PORT_HARDWARE SERIAL_PORT_MONITOR +#endif + +#ifndef USB_HOST_SERIAL +#if defined(SERIAL_PORT_USBVIRTUAL) && defined(LOAD_UHS_KINETIS_FS_HOST) +#define USB_HOST_SERIAL SERIAL_PORT_HARDWARE +#else +#define USB_HOST_SERIAL SERIAL_PORT_MONITOR +#endif +#endif + +#ifndef NOTUSED +#define NOTUSED(...) __VA_ARGS__ __attribute__((unused)) +#endif + +#ifndef __AVR__ +#ifndef printf_P +#define printf_P(...) printf(__VA_ARGS__) +#endif +#endif + +#ifdef ARDUINO_ARCH_PIC32 +/* + * For printf() output with pic32 Arduino + */ +extern "C" { + + void _mon_putc(char s) { + USB_HOST_SERIAL.write(s); + } + + int _mon_getc() { + while(!USB_HOST_SERIAL.available()); + return USB_HOST_SERIAL.read(); + } +} + +#elif defined(__AVR__) +extern "C" { + + static FILE tty_stdio; + static FILE tty_stderr; + + static int NOTUSED(tty_stderr_putc(char c, NOTUSED(FILE *t))); + static int NOTUSED(tty_stderr_flush(NOTUSED(FILE *t))); + static int NOTUSED(tty_std_putc(char c, NOTUSED(FILE *t))); + static int NOTUSED(tty_std_getc(NOTUSED(FILE *t))); + static int NOTUSED(tty_std_flush(NOTUSED(FILE *t))); + + static int tty_stderr_putc(char c, NOTUSED(FILE *t)) { + USB_HOST_SERIAL.write(c); + return 0; + } + + static int tty_stderr_flush(NOTUSED(FILE *t)) { + USB_HOST_SERIAL.flush(); + return 0; + } + + static int tty_std_putc(char c, NOTUSED(FILE *t)) { + USB_HOST_SERIAL.write(c); + return 0; + } + + static int tty_std_getc(NOTUSED(FILE *t)) { + while(!USB_HOST_SERIAL.available()); + return USB_HOST_SERIAL.read(); + } + + static int tty_std_flush(NOTUSED(FILE *t)) { + USB_HOST_SERIAL.flush(); + return 0; + } +} +#elif defined(CORE_TEENSY) +extern "C" { + + int _write(int fd, const char *ptr, int len) { + int j; + for(j = 0; j < len; j++) { + if(fd == 1) + USB_HOST_SERIAL.write(*ptr++); + else if(fd == 2) + USB_HOST_SERIAL.write(*ptr++); + } + return len; + } + + int _read(int fd, char *ptr, int len) { + if(len > 0 && fd == 0) { + while(!USB_HOST_SERIAL.available()); + *ptr = USB_HOST_SERIAL.read(); + return 1; + } + return 0; + } + +#include + + int _fstat(int fd, struct stat *st) { + memset(st, 0, sizeof (*st)); + st->st_mode = S_IFCHR; + st->st_blksize = 1024; + return 0; + } + + int _isatty(int fd) { + return (fd < 3) ? 1 : 0; + } +} +#else +#error no STDIO +#endif // defined(ARDUINO_ARCH_PIC32) + + + +#ifdef __AVR__ +// The only wierdo in the bunch... +void UHS_AVR_printf_HELPER_init() { + // Set up stdio/stderr + tty_stdio.put = tty_std_putc; + tty_stdio.get = tty_std_getc; + tty_stdio.flags = _FDEV_SETUP_RW; + tty_stdio.udata = 0; + + tty_stderr.put = tty_stderr_putc; + tty_stderr.get = NULL; + tty_stderr.flags = _FDEV_SETUP_WRITE; + tty_stderr.udata = 0; + + stdout = &tty_stdio; + stdin = &tty_stdio; + stderr = &tty_stderr; + +} +#define UHS_printf_HELPER_init() UHS_AVR_printf_HELPER_init() +#endif + +#endif /* STDIO_IS_OK_TO_USE_AS_IS */ +#endif /* load.... */ + +#ifndef UHS_printf_HELPER_init +#define UHS_printf_HELPER_init() (void(0)) +#endif +#endif /* UHS_PRINTF_HELPER_H */ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h new file mode 100644 index 0000000..edf673a --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h @@ -0,0 +1,96 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#if !defined(_UHS_host_h_) || defined(__PRINTHEX_H__) +#error "Never include UHS_printhex.h directly; include UHS_Usb.h instead" +#else +#define __PRINTHEX_H__ + +void E_Notifyc(char c, int lvl); + +template +void PrintHex(T val, int lvl) { + int num_nybbles = sizeof (T) * 2; + + do { + char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F); + if(v > 57) v += 7; + E_Notifyc(v, lvl); + } while(--num_nybbles); +} + +template +void PrintBin(T val, int lvl) { + for(T mask = (((T)1) << ((sizeof (T) << 3) - 1)); mask; mask >>= 1) + if(val & mask) + E_Notifyc('1', lvl); + else + E_Notifyc('0', lvl); +} + +template +void SerialPrintHex(T val) { + int num_nybbles = sizeof (T) * 2; + + do { + char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F); + if(v > 57) v += 7; + USB_HOST_SERIAL.print(v); + } while(--num_nybbles); +} + +template +void PrintHex2(Print *prn, T val) { + T mask = (((T)1) << (((sizeof (T) << 1) - 1) << 2)); + + while(mask > 1) { + if(val < mask) + prn->print("0"); + + mask >>= 4; + } + prn->print((T)val, HEX); +} + +#ifdef DEBUG_USB_HOST +template void D_PrintHex(T val, int lvl) { + PrintHex (val, lvl); +#else +template void D_PrintHex(NOTUSED(T val), NOTUSED(int lvl)) { +#endif +} + +#ifdef DEBUG_USB_HOST +template void D_PrintBin(T val, int lvl) { + PrintBin (val, lvl); +#else +template void D_PrintBin(NOTUSED(T val), NOTUSED(int lvl)) { +#endif +} + + + +#endif // __PRINTHEX_H__ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_settings.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_settings.h new file mode 100644 index 0000000..c516599 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_settings.h @@ -0,0 +1,141 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#ifndef UHS_SETTINGS_H +#define UHS_SETTINGS_H + +// TO-DO: Move specific settings to modules which use them. + +//////////////////////////////////////////////////////////////////////////////// +// Define any of these options at the top of your sketch to override +// the defaults contained herewith. Do NOT do modifications here. +// Individual Components have their own settings. +// +// Macro | Settings and notes | Default +// -----------------------------+-----------------------+----------------------- +// | Any class that does | +// USB_HOST_SERIAL | text streaming | SERIAL_PORT_MONITOR +// | e.g. Serial2 | +// -----------------------------+-----------------------+----------------------- +// ENABLE_UHS_DEBUGGING | 0 = off, 1 = on | 0 +// -----------------------------+-----------------------+----------------------- +// | 0 = off, 1 = on | +// | Caution! Can make | +// DEBUG_PRINTF_EXTRA_HUGE | program too large! | 0 +// | Other modules depend | +// | on this setting. | +// -----------------------------+-----------------------+----------------------- +// USE_UHS_BLACK_WIDDOW | 0 = no, 1 = yes | 0 +// -----------------------------+-----------------------+----------------------- +// ENABLE_WII_IR_CAMERA | 0 = no, 1 = yes | 0 +// -----------------------------^-----------------------^----------------------- +// +//////////////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////////////////// +// DEBUGGING +//////////////////////////////////////////////////////////////////////////////// + +#ifndef USB_HOST_SERIAL +#if defined(SERIAL_PORT_USBVIRTUAL) && defined(LOAD_UHS_KINETIS_FS_HOST) +#define USB_HOST_SERIAL SERIAL_PORT_HARDWARE +#else +#define USB_HOST_SERIAL SERIAL_PORT_MONITOR +#endif +#endif + +#ifndef ENABLE_UHS_DEBUGGING +#define ENABLE_UHS_DEBUGGING 0 +#endif + +#ifndef DEBUG_PRINTF_EXTRA_HUGE +#define DEBUG_PRINTF_EXTRA_HUGE 0 +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Manual board activation +//////////////////////////////////////////////////////////////////////////////// + +/* Set this to 1 if you are using a Black Widdow */ +#ifndef USE_UHS_BLACK_WIDDOW +#define USE_UHS_BLACK_WIDDOW 0 +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Wii IR camera +//////////////////////////////////////////////////////////////////////////////// + +/* Set this to 1 to activate code for the Wii IR camera */ +#ifndef ENABLE_WII_IR_CAMERA +#define ENABLE_WII_IR_CAMERA 0 +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Set to 1 to use the faster spi4teensy3 driver. (not used yet)) +//////////////////////////////////////////////////////////////////////////////// +#ifndef USE_SPI4TEENSY3 +#define USE_SPI4TEENSY3 0 +#endif + +//////////////////////////////////////////////////////////////////////////////// +// AUTOMATIC Settings +//////////////////////////////////////////////////////////////////////////////// + +// No user serviceable parts below this line. +// DO NOT change anything below here unless you are a developer! + +#if defined(__GNUC__) && defined(__AVR__) +#ifndef GCC_VERSION +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#endif +#if GCC_VERSION < 40602 // Test for GCC < 4.6.2 +#ifdef PROGMEM +#undef PROGMEM +#define PROGMEM __attribute__((section(".progmem.data"))) // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734#c4 +#ifdef PSTR +#undef PSTR +#define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];})) // Copied from pgmspace.h in avr-libc source +#endif +#endif +#endif +#endif + +#if !defined(DEBUG_USB_HOST) && ENABLE_UHS_DEBUGGING +#define DEBUG_USB_HOST +#endif + +#if !defined(WIICAMERA) && ENABLE_WII_IR_CAMERA +#define WIICAMERA +#endif + +#define UHS_SLEEP_MS(v) pUsb->sof_delay(v) + +#ifndef UHS_NI +#define UHS_NI __attribute__((noinline)) +#endif + +#endif /* SETTINGS_H */ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h new file mode 100644 index 0000000..6486482 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h @@ -0,0 +1,222 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#if !defined(_UHS_host_h_) || defined(_UHS_ch9_h_) +#error "Never include UHS_usb_ch9.h directly; include UHS_Usb.h instead" +#else + +/* USB chapter 9 structures */ +#define _UHS_ch9_h_ + +/* Misc.USB constants */ +#define DEV_DESCR_LEN 18 //device descriptor length +#define CONF_DESCR_LEN 9 //configuration descriptor length +#define INTR_DESCR_LEN 9 //interface descriptor length +#define EP_DESCR_LEN 7 //endpoint descriptor length + +/* Standard Device Requests */ +#define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS +#define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE +#define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE +#define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS +#define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR +#define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR +#define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION +#define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION +#define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE +#define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE +#define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME + +/* Wireless USB Device Requests */ +#define USB_REQ_SET_ENCRYPTION 0x0D +#define USB_REQ_GET_ENCRYPTION 0x0E +#define USB_REQ_RPIPE_ABORT 0x0E +#define USB_REQ_SET_HANDSHAKE 0x0F +#define USB_REQ_RPIPE_RESET 0x0F +#define USB_REQ_GET_HANDSHAKE 0x10 +#define USB_REQ_SET_CONNECTION 0x11 +#define USB_REQ_SET_SECURITY_DATA 0x12 +#define USB_REQ_GET_SECURITY_DATA 0x13 +#define USB_REQ_SET_WUSB_DATA 0x14 +#define USB_REQ_LOOPBACK_DATA_WRITE 0x15 +#define USB_REQ_LOOPBACK_DATA_READ 0x16 +#define USB_REQ_SET_INTERFACE_DS 0x17 + +/* USB feature flags */ +#define USB_DEVICE_SELF_POWERED 0 /* (read only) */ +#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ +#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */ +#define USB_DEVICE_BATTERY 2 /* (wireless) */ +#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */ +#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/ +#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */ +#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ +#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ + +#define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt +#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up +#define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode +/* OTG SET FEATURE Constants */ +#define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP +#define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP +#define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP + +/* Setup Data Constants */ +#define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer +#define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer +#define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard +#define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class +#define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor +#define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device +#define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface +#define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint +#define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other +#define USB_SETUP_RECIPIENT_PORT 0x04 // Wireless USB 1.0 +#define USB_SETUP_RECIPIENT_RPIPE 0x05 // Wireless USB 1.0 + + +/* USB descriptors */ +#define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor. +#define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor. +#define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor. +#define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor. +#define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor. +#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier. +#define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration. +#define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power. +#define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor. +#define USB_DESCRIPTOR_DEBUG 0x0A +#define USB_DESCRIPTOR_INTERFACE_ASSOCIATION 0x0B +#define USB_DESCRIPTOR_SECURITY 0x0C +#define USB_DESCRIPTOR_KEY 0x0D +#define USB_DESCRIPTOR_ENCRYPTION_TYPE 0x0E +#define USB_DESCRIPTOR_BOS 0x0F +#define USB_DESCRIPTOR_DEVICE_CAPABILITY 0x10 +#define USB_DESCRIPTOR_WIRELESS_ENDPOINT_COMP 0x11 +#define USB_DESCRIPTOR_WIRE_ADAPTER 0x21 +#define USB_DESCRIPTOR_RPIPE 0x22 +#define USB_DESCRIPTOR_CS_RADIO_CONTROL 0x23 +#define USB_DESCRIPTOR_SS_ENDPOINT_COMP 0x30 + +#define USB_HID_DESCRIPTOR 0x21 + + +// Conventional codes for class-specific descriptors. "Common Class" Spec (3.11) +#define USB_DESCRIPTOR_CS_DEVICE 0x21 +#define USB_DESCRIPTOR_CS_CONFIG 0x22 +#define USB_DESCRIPTOR_CS_STRING 0x23 +#define USB_DESCRIPTOR_CS_INTERFACE 0x24 +#define USB_DESCRIPTOR_CS_ENDPOINT 0x25 + + + +/* USB Endpoint Transfer Types */ +#define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint. +#define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint. +#define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint. +#define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint. +#define bmUSB_TRANSFER_TYPE 0x03 // bit mask to separate transfer type from ISO attributes +#define USB_TRANSFER_DIRECTION_IN 0x80 // Indicate direction is IN + +/* Standard Feature Selectors for CLEAR_FEATURE Requests */ +#define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient +#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient +#define USB_FEATURE_TEST_MODE 2 // Device recipient + +/* descriptor data structures */ + +/* Device descriptor structure */ +typedef struct { + uint8_t bLength; // Length of this descriptor. + uint8_t bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE). + uint16_t bcdUSB; // USB Spec Release Number (BCD). + uint8_t bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. + uint8_t bDeviceSubClass; // Subclass code (assigned by the USB-IF). + uint8_t bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. + uint8_t bMaxPacketSize0; // Maximum packet size for endpoint 0. + uint16_t idVendor; // Vendor ID (assigned by the USB-IF). + uint16_t idProduct; // Product ID (assigned by the manufacturer). + uint16_t bcdDevice; // Device release number (BCD). + uint8_t iManufacturer; // Index of String Descriptor describing the manufacturer. + uint8_t iProduct; // Index of String Descriptor describing the product. + uint8_t iSerialNumber; // Index of String Descriptor with the device's serial number. + uint8_t bNumConfigurations; // Number of possible configurations. +} __attribute__((packed)) USB_FD_DEVICE_DESCRIPTOR; + +/* Configuration descriptor structure */ +typedef struct { + uint8_t bLength; // Length of this descriptor. + uint8_t bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION). + uint16_t wTotalLength; // Total length of all descriptors for this configuration. + uint8_t bNumInterfaces; // Number of interfaces in this configuration. + uint8_t bConfigurationValue; // Value of this configuration (1 based). + uint8_t iConfiguration; // Index of String Descriptor describing the configuration. + uint8_t bmAttributes; // Configuration characteristics. + uint8_t bMaxPower; // Maximum power consumed by this configuration. +} __attribute__((packed)) USB_FD_CONFIGURATION_DESCRIPTOR; + +/* Interface descriptor structure */ +typedef struct { + uint8_t bLength; // Length of this descriptor. + uint8_t bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE). + uint8_t bInterfaceNumber; // Number of this interface (0 based). + uint8_t bAlternateSetting; // Value of this alternate interface setting. + uint8_t bNumEndpoints; // Number of endpoints in this interface. + uint8_t bInterfaceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. + uint8_t bInterfaceSubClass; // Subclass code (assigned by the USB-IF). + uint8_t bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. + uint8_t iInterface; // Index of String Descriptor describing the interface. +} __attribute__((packed)) USB_FD_INTERFACE_DESCRIPTOR; + +/* Endpoint descriptor structure */ +typedef struct { + uint8_t bLength; // Length of this descriptor. + uint8_t bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT). + uint8_t bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN). + uint8_t bmAttributes; // Endpoint transfer type. + uint16_t wMaxPacketSize; // Maximum packet size. + uint8_t bInterval; // Polling interval in frames. +} __attribute__((packed)) USB_FD_ENDPOINT_DESCRIPTOR; + +/* HID descriptor */ +/* +typedef struct { + uint8_t bLength; + uint8_t bDescriptorType; + uint16_t bcdHID; // HID class specification release + uint8_t bCountryCode; + uint8_t bNumDescriptors; // Number of additional class specific descriptors + uint8_t bDescrType; // Type of class descriptor + uint16_t wDescriptorLength; // Total size of the Report descriptor +} __attribute__((packed)) USB_HID_DESCRIPTOR; +*/ + +typedef struct { + uint8_t bDescrType; // Type of class descriptor + uint16_t wDescriptorLength; // Total size of the Report descriptor +} __attribute__((packed)) HID_CLASS_DESCRIPTOR_LEN_AND_TYPE; + +#endif // _ch9_h_ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h new file mode 100644 index 0000000..b81dbf2 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h @@ -0,0 +1,449 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#ifndef _UHS_host_h_ +#error "Never include UHS_usbhost.h directly; include UHS_host.h instead" +#else +#ifndef _USBHOST_H_ +#define _USBHOST_H_ + +// Very early prototypes +#ifdef UHS_LOAD_BT +void UHS_BT_SetUSBInterface(UHS_USB_HOST_BASE *host, ENUMERATION_INFO *ei); +void UHS_BT_ScanUninitialized(UHS_USB_HOST_BASE *host); +void UHS_BT_Poll(UHS_USB_HOST_BASE *host); +#endif +#ifdef UHS_LOAD_HID +void UHS_HID_SetUSBInterface(UHS_USB_HOST_BASE *host, ENUMERATION_INFO *ei); +void UHS_HID_ScanUninitialized(UHS_USB_HOST_BASE *host); +void UHS_HID_Poll(UHS_USB_HOST_BASE *host); +#endif + +//#if defined(LOAD_UHS_CDC_ACM) || defined(LOAD_UHS_CDC_ACM_FTDI) || defined(LOAD_UHS_CDC_ACM_PROLIFIC) || defined(LOAD_UHS_CDC_ACM_XR21B1411) +//void UHS_CDC_ACM_SetUSBInterface(UHS_USB_HOST_BASE *host, ENUMERATION_INFO *ei); +//void UHS_CDC_ACM_ScanUninitialized(UHS_USB_HOST_BASE *host); +//void UHS_CDC_ACM_Poll(UHS_USB_HOST_BASE *host); +//#endif + +class UHS_USBInterface; // forward class declaration + +// enumerator to turn the VBUS on/off + +typedef enum { + vbus_on = 0, + vbus_off = 1 +} VBUS_t; + +// All host SEI use this base class + +class UHS_USB_HOST_BASE { +public: + AddressPool addrPool; + UHS_USBInterface* devConfig[UHS_HOST_MAX_INTERFACE_DRIVERS]; + volatile uint8_t usb_error; + volatile uint8_t usb_task_state; + volatile uint8_t usb_task_polling_disabled; + volatile uint8_t usb_host_speed; + volatile uint8_t hub_present; + + UHS_USB_HOST_BASE() { + for(uint16_t i = 0; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) { + devConfig[i] = NULL; + } + usb_task_polling_disabled = 0; + usb_task_state = UHS_USB_HOST_STATE_INITIALIZE; //set up state machine + usb_host_speed = 0; + usb_error = 0; + }; + + ///////////////////////////////////////////// + // + // Virtual methods that interface to the SIE + // Overriding each is mandatory. + // + ///////////////////////////////////////////// + + /** + * Delay for x milliseconds + * Override if your controller provides an SOF IRQ, which may involve + * some sort of reentrant ISR or workaround with interrupts enabled. + * + * @param x how many milliseconds to delay + * @return true if delay completed without a state change, false if delay aborted + */ + virtual bool UHS_NI sof_delay(uint16_t x) { + if(!(usb_task_state & UHS_USB_HOST_STATE_MASK)) return false; + uint8_t current_state = usb_task_state; + while(current_state == usb_task_state && x--) { + delay(1); + } + return (current_state == usb_task_state); + }; + + virtual UHS_EpInfo * UHS_NI ctrlReqOpen(NOTUSED(uint8_t addr), NOTUSED(uint64_t Request), NOTUSED(uint8_t *dataptr)) { + return NULL; + }; + + virtual void UHS_NI vbusPower(NOTUSED(VBUS_t state)) { + }; + + virtual void UHS_NI Task() { + }; + + virtual uint8_t UHS_NI SetAddress(NOTUSED(uint8_t addr), NOTUSED(uint8_t ep), NOTUSED(UHS_EpInfo **ppep), NOTUSED(uint16_t &nak_limit)) { + return UHS_HOST_ERROR_NOT_IMPLEMENTED; + }; + + virtual uint8_t UHS_NI OutTransfer(NOTUSED(UHS_EpInfo *pep), NOTUSED(uint16_t nak_limit), NOTUSED(uint16_t nbytes), NOTUSED(uint8_t *data)) { + return UHS_HOST_ERROR_NOT_IMPLEMENTED; + }; + + virtual uint8_t UHS_NI InTransfer(NOTUSED(UHS_EpInfo *pep), NOTUSED(uint16_t nak_limit), NOTUSED(uint16_t *nbytesptr), NOTUSED(uint8_t *data)) { + return UHS_HOST_ERROR_NOT_IMPLEMENTED; + }; + + virtual uint8_t UHS_NI ctrlReqClose(NOTUSED(UHS_EpInfo *pep), NOTUSED(uint8_t bmReqType), NOTUSED(uint16_t left), NOTUSED(uint16_t nbytes), NOTUSED(uint8_t *dataptr)) { + return UHS_HOST_ERROR_NOT_IMPLEMENTED; + }; + + virtual uint8_t UHS_NI ctrlReqRead(NOTUSED(UHS_EpInfo *pep), NOTUSED(uint16_t *left), NOTUSED(uint16_t *read), NOTUSED(uint16_t nbytes), NOTUSED(uint8_t *dataptr)) { + return UHS_HOST_ERROR_NOT_IMPLEMENTED; + }; + + virtual uint8_t UHS_NI dispatchPkt(NOTUSED(uint8_t token), NOTUSED(uint8_t ep), NOTUSED(uint16_t nak_limit)) { + return UHS_HOST_ERROR_NOT_IMPLEMENTED; + }; + + virtual uint8_t UHS_NI init() { + return 0; + }; + + virtual void UHS_NI doHostReset() { + }; + + virtual int16_t UHS_NI Init(NOTUSED(int16_t mseconds)) { + return -1; + }; + + virtual int16_t UHS_NI Init() { + return Init(INT16_MIN); + }; + + virtual uint8_t hwlPowerUp() { + /* This is for machine specific support to enable/power up the USB HW to operate*/ + return UHS_HOST_ERROR_NOT_IMPLEMENTED; + }; + + virtual uint8_t hwPowerDown() { + /* This is for machine specific support to disable/powerdown the USB Hw */ + return UHS_HOST_ERROR_NOT_IMPLEMENTED; + }; + + virtual bool IsHub(uint8_t klass) { + return (klass == UHS_USB_CLASS_HUB); + }; + + virtual void UHS_NI suspend_host() { + // Used on MCU that lack control of IRQ priority (AVR). + // Suspends ISRs, for critical code. IRQ will be serviced after it is resumed. + // NOTE: you must track the state yourself! + }; + + virtual void UHS_NI resume_host() { + // Used on MCU that lack control of IRQ priority (AVR). + // Resumes ISRs. + // NOTE: you must track the state yourself! + }; + + ///////////////////////////////////////////// + // + // Built-ins, No need to override + // + ///////////////////////////////////////////// + // these two probably will go away, and won't be used, TBD + inline void Poll_Others() { +#ifdef UHS_LOAD_BT + UHS_BT_Poll(this); +#endif +#ifdef UHS_LOAD_HID + UHS_HID_Poll(this); +#endif + } + + inline void DisablePoll() { + noInterrupts(); + usb_task_polling_disabled++; + DDSB(); + interrupts(); + } + + inline void EnablePoll() { + noInterrupts(); + usb_task_polling_disabled--; + DDSB(); + interrupts(); + } + + uint8_t UHS_NI seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_FD_CONFIGURATION_DESCRIPTOR *ucd); + + uint8_t UHS_NI setEpInfoEntry(uint8_t addr, uint8_t iface, uint8_t epcount, volatile UHS_EpInfo* eprecord_ptr); + + uint8_t UHS_NI EPClearHalt(uint8_t addr, uint8_t ep); + + uint8_t UHS_NI ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t *dataptr); + + uint8_t UHS_NI getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t *dataptr); + + uint8_t UHS_NI getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t *dataptr); + + uint8_t UHS_NI setAddr(uint8_t oldaddr, uint8_t newaddr); + + uint8_t UHS_NI setConf(uint8_t addr, uint8_t conf_value); + + uint8_t UHS_NI getStrDescr(uint8_t addr, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr); + + void UHS_NI ReleaseDevice(uint8_t addr); + + uint8_t UHS_NI Configuring(uint8_t parent, uint8_t port, uint8_t speed); + + void UHS_NI DeviceDefaults(uint8_t maxep, UHS_USBInterface *device); + + UHS_EpInfo* UHS_NI getEpInfoEntry(uint8_t addr, uint8_t ep); + + inline uint8_t getUsbTaskState() { + return ( usb_task_state); + }; + + inline AddressPool* GetAddressPool() { + return &addrPool; + }; + + int UHS_NI RegisterDeviceClass(UHS_USBInterface *pdev) { + for(uint8_t i = 0; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) { + if(!devConfig[i]) { + devConfig[i] = pdev; + return i; + } + } + //return UHS_HOST_ERROR_CANT_REGISTER_DEVICE_CLASS; + return -1; + }; +#if 0 + + inline void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) { + addrPool.ForEachUsbDevice(pfunc); + }; +#endif + + uint8_t TestInterface(ENUMERATION_INFO *ei); + uint8_t enumerateInterface(ENUMERATION_INFO *ei); + uint8_t getNextInterface(ENUMERATION_INFO *ei, UHS_EpInfo *pep, uint8_t data[], uint16_t *left, uint16_t *read, uint8_t *offset); + uint8_t initDescrStream(ENUMERATION_INFO *ei, USB_FD_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset); + uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data); + uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data); + uint8_t doSoftReset(uint8_t parent, uint8_t port, uint8_t address); + uint8_t getone(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset); + uint8_t eat(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset, uint16_t *yum); + +}; + +// All device interface drivers use this subclass + +class UHS_USBInterface { +public: + + UHS_USB_HOST_BASE *pUsb; // Parent USB host + volatile uint8_t bNumEP; // total number of EP in this interface + volatile UHS_EpInfo epInfo[16]; // This is a stub, override in the driver. + + volatile uint8_t bAddress; // address of the device + volatile uint8_t bConfNum; // configuration number + volatile uint8_t bIface; // interface value + volatile bool bPollEnable; // poll enable flag, operating status + volatile uint32_t qNextPollTime; // next poll time + + /** + * Resets interface driver to unused state. You should override this in + * your driver if it requires extra class variable cleanup. + */ + virtual void DriverDefaults() { + printf("Default driver defaults.\r\n"); + pUsb->DeviceDefaults(bNumEP, this); + }; + + /** + * Checks if this interface is supported. + * Executed called when new devices are connected. + * + * @param ei + * @return true if the interface is supported + */ + virtual bool OKtoEnumerate(NOTUSED(ENUMERATION_INFO *ei)) { + return false; + }; + + /** + * Configures any needed endpoint information for an interface. + * You must provide this in your driver. + * Executed when new devices are connected and OKtoEnumerate() + * returned true. + * + * @param ei + * @return zero on success + */ + virtual uint8_t SetInterface(NOTUSED(ENUMERATION_INFO *ei)) { + return UHS_HOST_ERROR_NOT_IMPLEMENTED; + }; + + /** + * Interface specific additional setup and enumeration that + * can't occur when the descriptor stream is open. + * Also used for collection of unclaimed interfaces, to link to the master. + * + * @return zero on success + */ + virtual uint8_t Finalize() { + return 0; + }; + + /** + * Executed after interface is finalized but, before polling has started. + * + * @return 0 on success + */ + virtual uint8_t OnStart() { + return 0; + }; + + /** + * Start interface polling + * @return + */ + virtual uint8_t Start() { + uint8_t rcode = OnStart(); + if(!rcode) bPollEnable = true; + return rcode; + }; + + /** + * Executed before anything else in Release(). + */ + virtual void OnRelease() { + return; + }; + + /** + * Release resources when device is disconnected. + * Normally this does not need to be overridden. + */ + virtual void Release() { + OnRelease(); + DriverDefaults(); + return; + }; + + /** + * Executed After driver polls. + * Can be used when there is an important change detected during polling + * and you want to handle it elsewhere. + * Examples: + * Media status change for bulk, e.g. ready, not-ready, media changed, door opened. + * Button state/joystick position/etc changes on a HID device. + * Flow control status change on a communication device, e.g. CTS on serial + */ + virtual void OnPoll() { + return; + }; + + /** + * Poll interface driver. You should override this in your driver if you + * require polling faster or slower than every 100 milliseconds, or your + * driver requires special housekeeping. + */ + virtual void Poll() { + OnPoll(); + qNextPollTime = millis() + 100; + }; + + virtual bool UHS_NI Polling() { + return bPollEnable; + } + + /** + * This is only for a hub. + * @param port + */ + virtual void ResetHubPort(NOTUSED(uint8_t port)) { + return; + }; + +#if 0 + /** + * @return true if this interface is Vendor Specific. + */ + virtual bool IsVSI() { + return false; + } +#endif +}; + +#if 0 +/** + * Vendor Specific interface class. + * This is used by a partner interface. + * It can also be used to force-enumerate an interface that + * can use this interface directly. + * You can also add an instance of this class within the interface constructor + * if you expect the interface. + * + * If this is not needed, it may be removed. Nothing I have written needs this. + * Let me know if it is not required, then IsVSI method can also be shit-canned. + * -- AJK + */ + +class UHS_VSI : public UHS_USBInterface { +public: + volatile UHS_EpInfo epInfo[1]; + volatile ENUMERATION_INFO eInfo; + UHS_VSI(UHS_USB_HOST_BASE *p); + bool OKtoEnumerate(ENUMERATION_INFO *ei); + uint8_t SetInterface(ENUMERATION_INFO *ei); + virtual void DriverDefaults(); + virtual void Release(); + + uint8_t GetAddress() { + return bAddress; + }; + + virtual bool IsVSI() { + return true; + } + +}; +#endif + +#endif //_USBHOST_H_ +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_util_INLINE.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_util_INLINE.h new file mode 100644 index 0000000..52015b5 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_util_INLINE.h @@ -0,0 +1,129 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +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 2 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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#if defined(LOAD_USB_HOST_SYSTEM) && !defined(USB_HOST_SYSTEM_UTIL_LOADED) +#define USB_HOST_SYSTEM_UTIL_LOADED + +// 0x80 is the default (i.e. trace) to turn off set this global to something lower. +// this allows for 126 other debugging levels. +// TO-DO: Allow assignment to a different serial port by software +int UsbDEBUGlvl = 0x80; + +void E_Notifyc(char c, int lvl) { + if(UsbDEBUGlvl < lvl) return; +#if defined(ARDUINO) && ARDUINO >=100 + USB_HOST_SERIAL.print(c); +#else + USB_HOST_SERIAL.print(c, BYTE); +#endif + //USB_HOST_SERIAL.flush(); +} + +void E_Notify(char const * msg, int lvl) { + if(UsbDEBUGlvl < lvl) return; + if(!msg) return; + char c; + + while((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl); +} + +void E_NotifyStr(char const * msg, int lvl) { + if(UsbDEBUGlvl < lvl) return; + if(!msg) return; + char c; + + while((c = *msg++)) E_Notifyc(c, lvl); +} + +void E_Notify(uint8_t b, int lvl) { + if(UsbDEBUGlvl < lvl) return; +#if defined(ARDUINO) && ARDUINO >=100 + USB_HOST_SERIAL.print(b); +#else + USB_HOST_SERIAL.print(b, DEC); +#endif +} + +void E_Notify(double d, int lvl) { + if(UsbDEBUGlvl < lvl) return; + USB_HOST_SERIAL.print(d); +} + +#ifdef DEBUG_USB_HOST + +void NotifyFailGetDevDescr() { + Notify(PSTR("\r\ngetDevDescr "), 0x80); +} + +void NotifyFailSetDevTblEntry() { + Notify(PSTR("\r\nsetDevTblEn "), 0x80); +} + +void NotifyFailGetConfDescr() { + Notify(PSTR("\r\ngetConf "), 0x80); +} + +void NotifyFailSetConfDescr() { + Notify(PSTR("\r\nsetConf "), 0x80); +} + +void NotifyFailGetDevDescr(uint8_t reason) { + NotifyFailGetDevDescr(); + NotifyFail(reason); +} + +void NotifyFailSetDevTblEntry(uint8_t reason) { + NotifyFailSetDevTblEntry(); + NotifyFail(reason); + +} + +void NotifyFailGetConfDescr(uint8_t reason) { + NotifyFailGetConfDescr(); + NotifyFail(reason); +} + +void NotifyFailSetConfDescr(uint8_t reason) { + NotifyFailSetConfDescr(); + NotifyFail(reason); +} + +void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) { + Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80); + D_PrintHex (VID, 0x80); + Notify(PSTR(" PID: "), 0x80); + D_PrintHex (PID, 0x80); +} + +void NotifyFail(uint8_t rcode) { + D_PrintHex (rcode, 0x80); + Notify(PSTR("\r\n"), 0x80); +} +#endif + +#else +#error "Never include UHS_util_INLINE.h, include UHS_host.h instead" +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/UHS_max3421e.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/UHS_max3421e.h new file mode 100644 index 0000000..841cc8f --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/UHS_max3421e.h @@ -0,0 +1,226 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +This software may be distributed and modified under the terms of the GNU +General Public License version 2 (GPL2) as published by the Free Software +Foundation and appearing in the file GPL2.TXT included in the packaging of +this file. Please note that GPL2 Section 2[b] requires that all works based +on this software must also be made publicly available under the terms of +the GPL2 ("Copyleft"). + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ +#if !defined(USB_HOST_SHIELD_H) || defined(_max3421e_h_) +#error "Never include UHS_max3421e.h directly; include USB_HOST_SHIELD.h instead" +#else + +#define _max3421e_h_ + +/* MAX3421E register/bit names and bitmasks */ + +#define SE0 0 +#define SE1 1 +#define FSHOST 2 +#define LSHOST 3 + +/* MAX3421E command byte format: rrrrr0wa where 'r' is register number */ + +// +// MAX3421E Registers in HOST mode. +// +#define rRCVFIFO 0x08 // Receive FIFO Register +#define rSNDFIFO 0x10 // Send FIFO Register +#define rSUDFIFO 0x20 // Set Up Data FIFO Register +#define rRCVBC 0x30 // Receive FIFO Byte Count Register +#define rSNDBC 0x38 // Send FIFO Byte Count Register + +// USB Interrupt Request Status (USBIRQ) +#define rUSBIRQ 0x68 // USB Interrupt Request Register +#define bmVBUSIRQ 0x40 // Vbus Present Interrupt Request +#define bmNOVBUSIRQ 0x20 // Vbus Absent Interrupt Request +#define bmOSCOKIRQ 0x01 // Oscillator OK Interrupt Request + +// USB Interrupt Request Control (USBIEN) +#define rUSBIEN 0x70 // USB Interrupt Request Enable Register +#define bmVBUSIE bmVBUSIRQ // Vbus Present Interrupt Request Enable +#define bmNOVBUSIE bmNOVBUSIRQ // Vbus Absent Interrupt Request Enable +#define bmOSCOKIE bmOSCOKIRQ // Oscillator OK Interrupt Request Enable + +// (USBCTL) +#define rUSBCTL 0x78 //15<<3 +#define bmCHIPRES 0x20 //b5 +#define bmPWRDOWN 0x10 //b4 + +// (CPUCTL) +#define rCPUCTL 0x80 //16<<3 +#define bmPULSEWID1 0x80 //b7 +#define bmPULSEWID0 0x40 //b6 +#define bmIE 0x01 //b0 + +// bmPULSEWID1 bmPULSEWID0 Pulse width +// 0 0 10.6uS +// 0 1 5.3uS +// 1 0 2.6uS +// 1 1 1.3uS +#define PULSEWIDTH10_6 (0) +#define PULSEWIDTH5_3 (bmPULSEWID0) +#define PULSEWIDTH2_6 (bmPULSEWID1) +#define PULSEWIDTH1_3 (bmPULSEWID0 | bmPULSEWID1) + +// (PINCTL) +#define rPINCTL 0x88 //17<<3 +#define bmFDUPSPI 0x10 //b4 +#define bmINTLEVEL 0x08 //b3 +#define bmPOSINT 0x04 //b2 +#define bmGPXB 0x02 //b1 +#define bmGPXA 0x01 //b0 + +// GPX pin selections +#define GPX_OPERATE 0x00 // +#define GPX_VBDET 0x01 // +#define GPX_BUSACT 0x02 // +#define GPX_SOF 0x03 // + +#define rREVISION 0x90 //18<<3 + +// (IOPINS1) +#define rIOPINS1 0xA0 //20<<3 +#define bmGPOUT0 0x01 // +#define bmGPOUT1 0x02 // +#define bmGPOUT2 0x04 // +#define bmGPOUT3 0x08 // +#define bmGPIN0 0x10 // +#define bmGPIN1 0x20 // +#define bmGPIN2 0x40 // +#define bmGPIN3 0x80 // + +// (IOPINS2) +#define rIOPINS2 0xA8 //21<<3 +#define bmGPOUT4 0x01 // +#define bmGPOUT5 0x02 // +#define bmGPOUT6 0x04 // +#define bmGPOUT7 0x08 // +#define bmGPIN4 0x10 // +#define bmGPIN5 0x20 // +#define bmGPIN6 0x40 // +#define bmGPIN7 0x80 // + +// (GPINIRQ) +#define rGPINIRQ 0xB0 //22<<3 +#define bmGPINIRQ0 0x01 // +#define bmGPINIRQ1 0x02 // +#define bmGPINIRQ2 0x04 // +#define bmGPINIRQ3 0x08 // +#define bmGPINIRQ4 0x10 // +#define bmGPINIRQ5 0x20 // +#define bmGPINIRQ6 0x40 // +#define bmGPINIRQ7 0x80 // + +// (GPINIEN) +#define rGPINIEN 0xB8 //23<<3 +#define bmGPINIEN0 0x01 // +#define bmGPINIEN1 0x02 // +#define bmGPINIEN2 0x04 // +#define bmGPINIEN3 0x08 // +#define bmGPINIEN4 0x10 // +#define bmGPINIEN5 0x20 // +#define bmGPINIEN6 0x40 // +#define bmGPINIEN7 0x80 // + +// (GPINPOL) +#define rGPINPOL 0xC0 //24<<3 +#define bmGPINPOL0 0x01 // +#define bmGPINPOL1 0x02 // +#define bmGPINPOL2 0x04 // +#define bmGPINPOL3 0x08 // +#define bmGPINPOL4 0x10 // +#define bmGPINPOL5 0x20 // +#define bmGPINPOL6 0x40 // +#define bmGPINPOL7 0x80 // + +// +// If any data transfer errors occur, the HXFRDNIRQ asserts, while the RCVDAVIRQ does not. +// +// The CPU clears the SNDBAVIRQ by writing the SNDBC register. +// The CPU should never directly clear the SNDBAVIRQ bit. + +// Host Interrupt Request Status (HIRQ) +#define rHIRQ 0xC8 // Host Interrupt Request Register +#define bmBUSEVENTIRQ 0x01 // BUS Reset Done or BUS Resume Interrupt Request +#define bmRWUIRQ 0x02 // Remote Wakeup Interrupt Request +#define bmRCVDAVIRQ 0x04 // Receive FIFO Data Available Interrupt Request +#define bmSNDBAVIRQ 0x08 // Send Buffer Available Interrupt Request +#define bmSUSDNIRQ 0x10 // Suspend operation Done Interrupt Request +#define bmCONDETIRQ 0x20 // Peripheral Connect/Disconnect Interrupt Request +#define bmFRAMEIRQ 0x40 // Frame Generator Interrupt Request +#define bmHXFRDNIRQ 0x80 // Host Transfer Done Interrupt Request + +// IRQs that are OK for the CPU to clear +#define ICLRALLBITS (bmBUSEVENTIRQ | bmRWUIRQ | bmRCVDAVIRQ | bmSUSDNIRQ | bmCONDETIRQ | bmFRAMEIRQ | bmHXFRDNIRQ) + +// Host Interrupt Request Control (HIEN) +#define rHIEN 0xD0 // +#define bmBUSEVENTIE bmBUSEVENTIRQ // BUS Reset Done or BUS Resume Interrupt Request Enable +#define bmRWUIE bmRWUIRQ // Remote Wakeup Interrupt Request Enable +#define bmRCVDAVIE bmRCVDAVIRQ // Receive FIFO Data Available Interrupt Request Enable +#define bmSNDBAVIE bmSNDBAVIRQ // Send Buffer Available Interrupt Request Enable +#define bmSUSDNIE bmSUSDNIRQ // Suspend operation Done Interrupt Request Enable +#define bmCONDETIE bmCONDETIRQ // Peripheral Connect/Disconnect Interrupt Request Enable +#define bmFRAMEIE bmFRAMEIRQ // Frame Generator Interrupt Request Enable +#define bmHXFRDNIE bmHXFRDNIRQ // Host Transfer Done Interrupt Request Enable + +// (MODE)) +#define rMODE 0xD8 //27<<3 +#define bmHOST 0x01 // +#define bmLOWSPEED 0x02 // +#define bmHUBPRE 0x04 // +#define bmSOFKAENAB 0x08 // +#define bmSEPIRQ 0x10 // +#define bmDELAYISO 0x20 // +#define bmDMPULLDN 0x40 // +#define bmDPPULLDN 0x80 // + +#define rPERADDR 0xE0 //28<<3 + +// (HCTL) +#define rHCTL 0xE8 //29<<3 +#define bmBUSRST 0x01 // +#define bmFRMRST 0x02 // +#define bmSAMPLEBUS 0x04 // +#define bmSIGRSM 0x08 // +#define bmRCVTOG0 0x10 // +#define bmRCVTOG1 0x20 // +#define bmSNDTOG0 0x40 // +#define bmSNDTOG1 0x80 // + +// Host transfer (HXFR) +#define rHXFR 0xF0 //30<<3 +/* Host transfer token values for writing the HXFR register (R30) */ +/* OR this bit field with the endpoint number in bits 3:0 */ +#define MAX3421E_tokSETUP 0x10 // HS=0, ISO=0, OUTNIN=0, SETUP=1 +#define MAX3421E_tokIN 0x00 // HS=0, ISO=0, OUTNIN=0, SETUP=0 +#define MAX3421E_tokOUT 0x20 // HS=0, ISO=0, OUTNIN=1, SETUP=0 +#define MAX3421E_tokINHS 0x80 // HS=1, ISO=0, OUTNIN=0, SETUP=0 +#define MAX3421E_tokOUTHS 0xA0 // HS=1, ISO=0, OUTNIN=1, SETUP=0 +#define MAX3421E_tokISOIN 0x40 // HS=0, ISO=1, OUTNIN=0, SETUP=0 +#define MAX3421E_tokISOOUT 0x60 // HS=0, ISO=1, OUTNIN=1, SETUP=0 + +// (HRSL) +#define rHRSL 0xF8 //31<<3 +#define bmRCVTOGRD 0x10 // +#define bmSNDTOGRD 0x20 // +#define bmKSTATUS 0x40 // +#define bmJSTATUS 0x80 // +#define bmSE0 0x00 //SE0 - disconnect state +#define bmSE1 0xC0 //SE1 - illegal state + +#define MODE_FS_HOST (bmDPPULLDN|bmDMPULLDN|bmHOST|bmSOFKAENAB) +#define MODE_LS_HOST (bmDPPULLDN|bmDMPULLDN|bmHOST|bmLOWSPEED|bmSOFKAENAB) + +#endif //_max3421e_h_ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h new file mode 100644 index 0000000..79c06a4 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h @@ -0,0 +1,519 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +This software may be distributed and modified under the terms of the GNU +General Public License version 2 (GPL2) as published by the Free Software +Foundation and appearing in the file GPL2.TXT included in the packaging of +this file. Please note that GPL2 Section 2[b] requires that all works based +on this software must also be made publicly available under the terms of +the GPL2 ("Copyleft"). + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#ifndef USB_HOST_SHIELD_H +#define USB_HOST_SHIELD_H + +// uncomment to get 'printf' console debugging. NOT FOR UNO! +//#define DEBUG_PRINTF_EXTRA_HUGE_USB_HOST_SHIELD + +#ifdef LOAD_USB_HOST_SHIELD +#include "UHS_max3421e.h" +#include + + +#ifndef SPI_HAS_TRANSACTION +#error "Your SPI library installation is too old." +#else +#ifndef SPI_ATOMIC_VERSION +#warning "Your SPI library installation lacks 'SPI_ATOMIC_VERSION'. Please complain to the maintainer." +#elif SPI_ATOMIC_VERSION < 1 +#error "Your SPI library installation is too old." +#endif + +#endif +#if DEBUG_PRINTF_EXTRA_HUGE +#ifdef DEBUG_PRINTF_EXTRA_HUGE_USB_HOST_SHIELD +#define MAX_HOST_DEBUG(...) printf_P(__VA_ARGS__) +#else +#define MAX_HOST_DEBUG(...) VOID0 +#endif +#else +#define MAX_HOST_DEBUG(...) VOID0 +#endif + +#ifndef USB_HOST_SHIELD_USE_ISR +#ifdef USE_MULTIPLE_APP_API +#define USB_HOST_SHIELD_USE_ISR 0 +#else +#define USB_HOST_SHIELD_USE_ISR 1 +#endif +#else +#define USB_HOST_SHIELD_USE_ISR 1 +#endif + + + +#if !USB_HOST_SHIELD_USE_ISR +#error NOISR Polled mode _NOT SUPPORTED YET_ + +// +// Polled defaults +// +#ifdef BOARD_BLACK_WIDDOW +#define UHS_MAX3421E_SS_ 6 +#define UHS_MAX3421E_INT_ 3 +#elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) +#if EXT_RAM +// Teensy++ 2.0 with XMEM2 +#define UHS_MAX3421E_SS_ 20 +#define UHS_MAX3421E_INT_ 7 +#else +#define UHS_MAX3421E_SS_ 9 +#define UHS_MAX3421E_INT_ 8 +#endif +#define UHS_MAX3421E_SPD +#elif defined(ARDUINO_AVR_ADK) +#define UHS_MAX3421E_SS_ 53 +#define UHS_MAX3421E_INT_ 54 +#elif defined(ARDUINO_AVR_BALANDUINO) +#define UHS_MAX3421E_SS_ 20 +#define UHS_MAX3421E_INT_ 19 +#else +#define UHS_MAX3421E_SS_ 10 +#define UHS_MAX3421E_INT_ 9 +#endif + +#else +#ifdef ARDUINO_ARCH_PIC32 +// PIC32 only allows edge interrupts, isn't that lovely? We'll emulate it... +#if CHANGE < 2 +#error core too old. +#endif + +#define IRQ_IS_EDGE 0 +#ifndef digitalPinToInterrupt +// great, this isn't implemented. +#warning digitalPinToInterrupt is not defined, complain here https://github.com/chipKIT32/chipKIT-core/issues/114 +#if defined(_BOARD_UNO_) || defined(_BOARD_UC32_) +#define digitalPinToInterrupt(p) ((p) == 2 ? 1 : ((p) == 7 ? 2 : ((p) == 8 ? 3 : ((p) == 35 ? 4 : ((p) == 38 ? 0 : NOT_AN_INTERRUPT))))) +#warning digitalPinToInterrupt is now defined until this is taken care of. +#else +#error digitalPinToInterrupt not defined for your board, complain here https://github.com/chipKIT32/chipKIT-core/issues/114 +#endif +#endif +#else +#define IRQ_IS_EDGE 0 +#endif + +// More stupidity from our friends @ Sony... +#ifdef ARDUINO_spresense_ast +#ifndef NOT_AN_INTERRUPT +#define NOT_AN_INTERRUPT -1 +#endif +#endif + +// SAMD uses an enum for this instead of a define. Isn't that just dandy? +#if !defined(NOT_AN_INTERRUPT) && !defined(ARDUINO_ARCH_SAMD) +#warning NOT_AN_INTERRUPT not defined, possible problems ahead. +#warning If NOT_AN_INTERRUPT is an enum or something else, complain to UHS30 developers on github. +#warning Otherwise complain to your board core developer/maintainer. +#define NOT_AN_INTERRUPT -1 +#endif + +// +// Interrupt defaults. Int0 or Int1 +// +#ifdef BOARD_BLACK_WIDDOW +#error "HELP! Please send us an email, I don't know the values for Int0 and Int1 on the Black Widow board!" +#elif defined(ARDUINO_AVR_ADK) +#define UHS_MAX3421E_SS_ 53 +#define UHS_MAX3421E_INT_ 54 +#elif defined(ARDUINO_spresense_ast) +#define UHS_MAX3421E_SS_ 21 +#define UHS_MAX3421E_INT_ 20 +#define SPIclass SPI5 +//#define UHS_MAX3421E_SPD 100000 +#elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) + +// TO-DO! + +#if EXT_RAM +// Teensy++ 2.0 with XMEM2 +#define UHS_MAX3421E_SS_ 20 +#define UHS_MAX3421E_INT_ 7 +#else +#define UHS_MAX3421E_SS_ 9 +#define UHS_MAX3421E_INT_ 8 +#endif + +#elif defined(ARDUINO_AVR_BALANDUINO) +#error "ISR mode is currently not supported on the Balanduino. Please set USB_HOST_SHIELD_USE_ISR to 0." +#else +#define UHS_MAX3421E_SS_ 10 +#ifdef __AVR__ +#ifdef __AVR_ATmega32U4__ +#define INT_FOR_PIN2 1 +#define INT_FOR_PIN3 0 +#else +// Everybody else??? +#define INT_FOR_PIN2 0 +#define INT_FOR_PIN3 1 +#endif +#define UHS_MAX3421E_INT_ 3 +#else +// Non-avr +#ifdef ARDUINO_ARCH_PIC32 +// UNO32 External Interrupts: +// Pin 38 (INT0), Pin 2 (INT1), Pin 7 (INT2), Pin 8 (INT3), Pin 35 (INT4) +#define UHS_MAX3421E_INT_ 7 +#else +#define UHS_MAX3421E_INT_ 9 +#endif +#endif +#endif +#endif + + + +#ifdef NO_AUTO_SPEED +// Ugly details section... +// MAX3421E characteristics +// SPI Serial - Clock Input. An external SPI master supplies SCLK with frequencies up to 26MHz. The +// logic level is referenced to the voltage on VL. Data is clocked into the SPI slave inter face on the +// rising edge of SCLK. Data is clocked out of the SPI slave interface on the falling edge of SCLK. +// Serial Clock (SCLK) Period 38.4ns minimum. 17ns minimum pulse width. VL >2.5V +// SCLK Fall to MISO Propagation Delay 14.2ns +// SCLK Fall to MOSI Propagation Delay 14.2ns +// SCLK Fall to MOSI Drive 3.5ns +// Theoretical deadline for reply 17.7ns +// 26MHz 38.4615ns period <-- MAX3421E theoretical maximum + +#ifndef UHS_MAX3421E_SPD +#ifdef ARDUINO_SAMD_ZERO +// Zero violates spec early, needs a long setup time, or doesn't like high latency. +#define UHS_MAX3421E_SPD 10000000 +#elif defined(ARDUINO_ARCH_PIC32) +// PIC MX 5/6/7 characteristics +// 25MHZ 40ns period <-- PIC MX 5/6/7 theoretical maximum +// pulse width minimum Tsclk/2ns +// Trise/fall 10ns maximum. 5ns is typical but not guaranteed. +// Tsetup minimum for MISO 10ns. +// We are in violation by 7.7ns @ 25MHz due to latency alone. +// Even reading at end of data cycle, we only have a 2.3ns window. +// This is too narrow to to compensate for capacitance, trace lengths, and noise. + +// 17.7ns + 10ns = 27.7ns +// 18MHz fits and has enough slack time to compensate for capacitance, trace lengths, and noise. +// For high speeds the SMP bit is recommended too, which samples at the end instead of the middle. +// 20Mhz seems to work. + +#define UHS_MAX3421E_SPD 20000000 +#else +#define UHS_MAX3421E_SPD 25000000 +#endif +#endif +#else +// We start at 25MHz, and back down until hardware can take it. +// Of course, SPI library can adjust this for us too. +// Why not 26MHz? Because I have not found any MCU board that +// can actually go that fast without problems. +// Could be a shield limitation too. +#ifndef UHS_MAX3421E_SPD +#define UHS_MAX3421E_SPD 25000000 +#endif +#endif + +#ifndef UHS_MAX3421E_INT +#define UHS_MAX3421E_INT UHS_MAX3421E_INT_ +#endif + +#ifndef UHS_MAX3421E_SS +#define UHS_MAX3421E_SS UHS_MAX3421E_SS_ +#endif + +// NOTE: On the max3421e the irq enable and irq bits are in the same position. + +// IRQs used if CPU polls +#define ENIBITSPOLLED (bmCONDETIE | bmBUSEVENTIE | bmFRAMEIE) +// IRQs used if CPU is interrupted +#define ENIBITSISR (bmCONDETIE | bmBUSEVENTIE | bmFRAMEIE /* | bmRCVDAVIRQ | bmSNDBAVIRQ | bmHXFRDNIRQ */ ) + +#if !USB_HOST_SHIELD_USE_ISR +#define IRQ_CHECK_MASK (ENIBITSPOLLED & ICLRALLBITS) +#define IRQ_IS_EDGE 0 +#else +#define IRQ_CHECK_MASK (ENIBITSISR & ICLRALLBITS) +#endif + +#if IRQ_IS_EDGE +// Note: UNO32 Interrupts can only be RISING, or FALLING. +// This poses an interesting problem, since we want to use a LOW level. +// The MAX3421E provides for pulse width control for an IRQ. +// We do need to watch the timing on this, as a second IRQ could cause +// a missed IRQ, since we read the level of the line to check if the IRQ +// is actually for this chip. The only other alternative is to add a capacitor +// and an NPN transistor, and use two lines. We can try this first, though. +// Worse case, we can ignore reading the pin for verification on UNO32. +// Too bad there is no minimum low width setting. +// +// Single Clear First Second Clear first Clear last +// IRQ Single IRQ IRQ Second active pending IRQ +// | | | | | | +// V V V V V V +// _____ _________ _ _ _______ +// |______| |______| |______| |______________| +// +#define IRQ_SENSE FALLING +#ifdef ARDUINO_ARCH_PIC32 +//#define bmPULSEWIDTH PULSEWIDTH10_6 +#define bmPULSEWIDTH 0 +#define bmIRQ_SENSE 0 +#else +#define bmPULSEWIDTH PULSEWIDTH1_3 +#define bmIRQ_SENSE 0 +#endif +#else +#ifndef IRQ_SENSE +#define IRQ_SENSE LOW +#endif +#ifndef bmPULSEWIDTH +#define bmPULSEWIDTH 0 +#endif +#ifndef bmIRQ_SENSE +#define bmIRQ_SENSE bmINTLEVEL +#endif +#endif + +class MAX3421E_HOST : +public UHS_USB_HOST_BASE +#ifdef SWI_IRQ_NUM +, public dyn_SWI +#endif +{ + // TO-DO: move these into the parent class. + volatile uint8_t vbusState; + volatile uint16_t sof_countdown; + + // TO-DO: pack into a struct/union and use one byte + volatile bool busevent; + volatile bool sofevent; + volatile bool counted; + volatile bool condet; + volatile bool doingreset; + + #ifdef USB_HOST_MANUAL_POLL + volatile bool frame_irq_enabled = false; + + bool enable_frame_irq(bool enable) { + const bool prev_state = frame_irq_enabled; + if(prev_state != enable) { + if(enable) + regWr(rHIEN, regRd(rHIEN) | bmFRAMEIE); + else + regWr(rHIEN, regRd(rHIEN) & ~bmFRAMEIE); + frame_irq_enabled = enable; + } + return prev_state; + } + #endif + +public: + SPISettings MAX3421E_SPI_Settings; + uint8_t ss_pin; + uint8_t irq_pin; + // Will use the defaults UHS_MAX3421E_SS, UHS_MAX3421E_INT and speed + + UHS_NI MAX3421E_HOST() { + sof_countdown = 0; + busevent = false; + doingreset = false; + sofevent = false; + condet = false; + ss_pin = UHS_MAX3421E_SS; + irq_pin = UHS_MAX3421E_INT; + MAX3421E_SPI_Settings = SPISettings(UHS_MAX3421E_SPD, MSBFIRST, SPI_MODE0); + hub_present = 0; + }; + + // Will use user supplied pins, and UHS_MAX3421E_SPD + + UHS_NI MAX3421E_HOST(uint8_t pss, uint8_t pirq) { + sof_countdown = 0; + busevent = false; + doingreset = false; + sofevent = false; + condet = false; + ss_pin = pss; + irq_pin = pirq; + MAX3421E_SPI_Settings = SPISettings(UHS_MAX3421E_SPD, MSBFIRST, SPI_MODE0); + hub_present = 0; + }; + + // Will use user supplied pins, and speed + + UHS_NI MAX3421E_HOST(uint8_t pss, uint8_t pirq, uint32_t pspd) { + sof_countdown = 0; + doingreset = false; + busevent = false; + sofevent = false; + condet = false; + ss_pin = pss; + irq_pin = pirq; + MAX3421E_SPI_Settings = SPISettings(pspd, MSBFIRST, SPI_MODE0); + hub_present = 0; + }; + + virtual bool UHS_NI sof_delay(uint16_t x) { +#ifdef USB_HOST_MANUAL_POLL + const bool saved_irq_state = enable_frame_irq(true); +#endif + sof_countdown = x; + while((sof_countdown != 0) && !condet) { + SYSTEM_OR_SPECIAL_YIELD(); +#if !USB_HOST_SHIELD_USE_ISR + Task(); +#endif + } +#ifdef USB_HOST_MANUAL_POLL + enable_frame_irq(saved_irq_state); +#endif + // Serial.println("...Wake"); + return (!condet); + }; + + virtual UHS_EpInfo *ctrlReqOpen(uint8_t addr, uint64_t Request, uint8_t *dataptr); + + virtual void UHS_NI vbusPower(VBUS_t state) { + regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE) | (uint8_t)(state)); + }; + + void UHS_NI Task(); + + virtual uint8_t SetAddress(uint8_t addr, uint8_t ep, UHS_EpInfo **ppep, uint16_t &nak_limit); + virtual uint8_t OutTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data); + virtual uint8_t InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data); + virtual uint8_t ctrlReqClose(UHS_EpInfo *pep, uint8_t bmReqType, uint16_t left, uint16_t nbytes, uint8_t *dataptr); + virtual uint8_t ctrlReqRead(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint16_t nbytes, uint8_t *dataptr); + virtual uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit); + + void UHS_NI ReleaseChildren() { + for(uint8_t i = 0; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) + if(devConfig[i]) + devConfig[i]->Release(); + hub_present = 0; + }; + + virtual bool IsHub(uint8_t klass) { + if(klass == UHS_USB_CLASS_HUB) { + hub_present = bmHUBPRE; + return true; + } + return false; + }; + + virtual void VBUS_changed(); + + virtual void UHS_NI doHostReset() { +#if USB_HOST_SHIELD_USE_ISR + // Enable interrupts + noInterrupts(); +#endif + doingreset = true; + busevent = true; + regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. + regWr(rHCTL, bmBUSRST); //issue bus reset +#if USB_HOST_SHIELD_USE_ISR + DDSB(); + // Enable interrupts + interrupts(); +#endif + while(busevent) { + DDSB(); + SYSTEM_OR_SPECIAL_YIELD(); + } +#endif +#if USB_HOST_SHIELD_USE_ISR + // Enable interrupts + noInterrupts(); +#endif + #ifdef USB_HOST_MANUAL_POLL + enable_frame_irq(true); + #endif + sofevent = true; +#if USB_HOST_SHIELD_USE_ISR + DDSB(); + // Enable interrupts + interrupts(); +#endif + // Wait for SOF + while(sofevent) { + } +#if USB_HOST_SHIELD_USE_ISR + // Enable interrupts + noInterrupts(); +#endif + doingreset = false; +#if USB_HOST_SHIELD_USE_ISR + DDSB(); + // Enable interrupts + interrupts(); + }; + + + int16_t UHS_NI Init(int16_t mseconds); + + int16_t UHS_NI Init() { + return Init(INT16_MIN); + }; + + void ISRTask(); + void ISRbottom(); + void busprobe(); + uint16_t reset(); + + // MAX3421e specific + void regWr(uint8_t reg, uint8_t data); + void gpioWr(uint8_t data); + uint8_t regRd(uint8_t reg); + uint8_t gpioRd(); + uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p); + uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p); + + // ARM/NVIC specific, used to emulate reentrant ISR. +#ifdef SWI_IRQ_NUM + + void dyn_SWISR() { + ISRbottom(); + }; +#endif + + virtual void UHS_NI suspend_host() { + // Used on MCU that lack control of IRQ priority (AVR). + // Suspends ISRs, for critical code. IRQ will be serviced after it is resumed. + // NOTE: you must track the state yourself! +#ifdef __AVR__ + noInterrupts(); + detachInterrupt(UHS_GET_DPI(irq_pin)); + interrupts(); +#endif + }; + + virtual void UHS_NI resume_host(); +}; +#ifndef SPIclass +#define SPIclass SPI +#endif +#ifndef USB_HOST_SHIELD_LOADED +#include "USB_HOST_SHIELD_INLINE.h" +#endif +#else +#error "define LOAD_USB_HOST_SHIELD in your sketch, never include USB_HOST_SHIELD.h in a driver." +#endif +#endif /* USB_HOST_SHIELD_H */ diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h new file mode 100644 index 0000000..6cfc015 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h @@ -0,0 +1,1003 @@ +/* Copyright (C) 2015-2016 Andrew J. Kroll + and +Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +This software may be distributed and modified under the terms of the GNU +General Public License version 2 (GPL2) as publishe7d by the Free Software +Foundation and appearing in the file GPL2.TXT included in the packaging of +this file. Please note that GPL2 Section 2[b] requires that all works based +on this software must also be made publicly available under the terms of +the GPL2 ("Copyleft"). + +Contact information +------------------- + +Circuits At Home, LTD +Web : https://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +#if defined(USB_HOST_SHIELD_H) && !defined(USB_HOST_SHIELD_LOADED) +#define USB_HOST_SHIELD_LOADED +#include + +#ifndef digitalPinToInterrupt +#error digitalPinToInterrupt not defined, complain to your board maintainer. +#endif + + +#if USB_HOST_SHIELD_USE_ISR + +// allow two slots. this makes the maximum allowed shield count TWO +// for AVRs this is limited to pins 2 and 3 ONLY +// for all other boards, one odd and one even pin number is allowed. +static MAX3421E_HOST *ISReven; +static MAX3421E_HOST *ISRodd; + +static void UHS_NI call_ISReven() { + ISReven->ISRTask(); +} + +static void UHS_NI call_ISRodd() { + UHS_PIN_WRITE(LED_BUILTIN, HIGH); + ISRodd->ISRTask(); +} +#endif + + +void UHS_NI MAX3421E_HOST::resume_host() { + // Used on MCU that lack control of IRQ priority (AVR). + // Resumes ISRs. + // NOTE: you must track the state yourself! +#ifdef __AVR__ + noInterrupts(); + if(irq_pin & 1) { + ISRodd = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); + } else { + ISReven = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); + } + interrupts(); +#endif + +} +/* write single byte into MAX3421e register */ +void UHS_NI MAX3421E_HOST::regWr(uint8_t reg, uint8_t data) { + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg | 0x02); + SPIclass.transfer(data); + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); +} + + +/* multiple-byte write */ + +/* returns a pointer to memory position after last written */ +uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg | 0x02); + //printf("%2.2x :", reg); + + while(nbytes) { + SPIclass.transfer(*data_p); + //printf("%2.2x ", *data_p); + nbytes--; + data_p++; // advance data pointer + } + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); + //printf("\r\n"); + return (data_p); +} +/* GPIO write */ +/*GPIO byte is split between 2 registers, so two writes are needed to write one byte */ + +/* GPOUT bits are in the low nybble. 0-3 in IOPINS1, 4-7 in IOPINS2 */ +void UHS_NI MAX3421E_HOST::gpioWr(uint8_t data) { + regWr(rIOPINS1, data); + data >>= 4; + regWr(rIOPINS2, data); + return; +} + +/* single host register read */ +uint8_t UHS_NI MAX3421E_HOST::regRd(uint8_t reg) { + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg); + uint8_t rv = SPIclass.transfer(0); + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); + return (rv); +} +/* multiple-byte register read */ + +/* returns a pointer to a memory position after last read */ +uint8_t* UHS_NI MAX3421E_HOST::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg); + while(nbytes) { + *data_p++ = SPIclass.transfer(0); + nbytes--; + } + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); + return ( data_p); +} + +/* GPIO read. See gpioWr for explanation */ + +/* GPIN pins are in high nybbles of IOPINS1, IOPINS2 */ +uint8_t UHS_NI MAX3421E_HOST::gpioRd() { + uint8_t gpin = 0; + gpin = regRd(rIOPINS2); //pins 4-7 + gpin &= 0xF0; //clean lower nybble + gpin |= (regRd(rIOPINS1) >> 4); //shift low bits and OR with upper from previous operation. + return ( gpin); +} + +/* reset MAX3421E. Returns number of microseconds it took for PLL to stabilize after reset + or zero if PLL haven't stabilized in 65535 cycles */ +uint16_t UHS_NI MAX3421E_HOST::reset() { + uint16_t i = 0; + + // Initiate chip reset + regWr(rUSBCTL, bmCHIPRES); + regWr(rUSBCTL, 0x00); + + int32_t now; + uint32_t expires = micros() + 65535; + + // Enable full-duplex SPI so we can read rUSBIRQ + regWr(rPINCTL, bmFDUPSPI); + while((int32_t)(micros() - expires) < 0L) { + if((regRd(rUSBIRQ) & bmOSCOKIRQ)) { + break; + } + } + now = (int32_t)(micros() - expires); + if(now < 0L) { + i = 65535 + now; // Note this subtracts, as now is negative + } + return (i); +} + +void UHS_NI MAX3421E_HOST::VBUS_changed() { + /* modify USB task state because Vbus changed or unknown */ + uint8_t speed = 1; + //printf("\r\n\r\n\r\n\r\nSTATE %2.2x -> ", usb_task_state); + switch(vbusState) { + case LSHOST: // Low speed + + speed = 0; + // Intentional fall-through + case FSHOST: // Full speed + // Start device initialization if we are not initializing + // Resets to the device cause an IRQ + // usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; + //if((usb_task_state & UHS_USB_HOST_STATE_MASK) != UHS_USB_HOST_STATE_DETACHED) { + ReleaseChildren(); + if(!doingreset) { + if(usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE) { + usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; + } else if(usb_task_state != UHS_USB_HOST_STATE_WAIT_BUS_READY) { + usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE; + } + } + sof_countdown = 0; + break; + case SE1: //illegal state + sof_countdown = 0; + doingreset = false; + ReleaseChildren(); + usb_task_state = UHS_USB_HOST_STATE_ILLEGAL; + break; + case SE0: //disconnected + default: + sof_countdown = 0; + doingreset = false; + ReleaseChildren(); + usb_task_state = UHS_USB_HOST_STATE_IDLE; + break; + } + usb_host_speed = speed; + //printf("0x%2.2x\r\n\r\n\r\n\r\n", usb_task_state); + return; +}; + +/** + * Probe bus to determine device presence and speed, + * then switch host to detected speed. + */ +void UHS_NI MAX3421E_HOST::busprobe() { + uint8_t bus_sample; + uint8_t tmpdata; + bus_sample = regRd(rHRSL); //Get J,K status + bus_sample &= (bmJSTATUS | bmKSTATUS); //zero the rest of the byte + switch(bus_sample) { //start full-speed or low-speed host + case(bmJSTATUS): + // Serial.println("J"); + if((regRd(rMODE) & bmLOWSPEED) == 0) { + regWr(rMODE, MODE_FS_HOST); // start full-speed host + vbusState = FSHOST; + } else { + regWr(rMODE, MODE_LS_HOST); // start low-speed host + vbusState = LSHOST; + } + #ifdef USB_HOST_MANUAL_POLL + enable_frame_irq(true); + #endif + tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation + regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. + regWr(rMODE, tmpdata); + break; + case(bmKSTATUS): + // Serial.println("K"); + if((regRd(rMODE) & bmLOWSPEED) == 0) { + regWr(rMODE, MODE_LS_HOST); // start low-speed host + vbusState = LSHOST; + } else { + regWr(rMODE, MODE_FS_HOST); // start full-speed host + vbusState = FSHOST; + } + #ifdef USB_HOST_MANUAL_POLL + enable_frame_irq(true); + #endif + tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation + regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. + regWr(rMODE, tmpdata); + break; + case(bmSE1): //illegal state + // Serial.println("I"); + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); + vbusState = SE1; + // sofevent = false; + break; + case(bmSE0): //disconnected state + // Serial.println("D"); + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); + vbusState = SE0; + // sofevent = false; + break; + }//end switch( bus_sample ) +} + +/** + * Initialize USB hardware, turn on VBUS + * + * @param mseconds Delay energizing VBUS after mseconds, A value of INT16_MIN means no delay. + * @return 0 on success, -1 on error + */ +int16_t UHS_NI MAX3421E_HOST::Init(int16_t mseconds) { + usb_task_state = UHS_USB_HOST_STATE_INITIALIZE; //set up state machine + // Serial.print("MAX3421E 'this' USB Host @ 0x"); + // Serial.println((uint32_t)this, HEX); + // Serial.print("MAX3421E 'this' USB Host Address Pool @ 0x"); + // Serial.println((uint32_t)GetAddressPool(), HEX); + Init_dyn_SWI(); + UHS_printf_HELPER_init(); + noInterrupts(); +#ifdef ARDUINO_AVR_ADK + // For Mega ADK, which has a Max3421e on-board, + // set MAX_RESET to output mode, and then set it to HIGH + // PORTJ bit 2 + if(irq_pin == 54) { + DDRJ |= 0x04; // output + PORTJ |= 0x04; // HIGH + } +#endif + SPIclass.begin(); +#ifdef ARDUINO_AVR_ADK + if(irq_pin == 54) { + DDRE &= ~0x20; // input + PORTE |= 0x20; // pullup + } else +#endif + pinMode(irq_pin, INPUT_PULLUP); + //UHS_PIN_WRITE(irq_pin, HIGH); + pinMode(ss_pin, OUTPUT); + MARLIN_UHS_WRITE_SS(HIGH); + +#ifdef USB_HOST_SHIELD_TIMING_PIN + pinMode(USB_HOST_SHIELD_TIMING_PIN, OUTPUT); + // My counter/timer can't work on an inverted gate signal + // so we gate using a high pulse -- AJK + UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); +#endif + interrupts(); + +#if USB_HOST_SHIELD_USE_ISR + int intr = digitalPinToInterrupt(irq_pin); + if(intr == NOT_AN_INTERRUPT) { +#ifdef ARDUINO_AVR_ADK + if(irq_pin == 54) + intr = 6; + else +#endif + return (-2); + } + SPIclass.usingInterrupt(intr); +#else + SPIclass.usingInterrupt(255); +#endif +#ifndef NO_AUTO_SPEED + // test to get to reset acceptance. + uint32_t spd = UHS_MAX3421E_SPD; +again: + MAX3421E_SPI_Settings = SPISettings(spd, MSBFIRST, SPI_MODE0); + if(reset() == 0) { + MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); + if(spd > 1999999) { + spd -= 1000000; + goto again; + } + return (-1); + } else { + // reset passes, does 64k? + uint8_t sample_wr = 0; + uint8_t sample_rd = 0; + uint8_t gpinpol_copy = regRd(rGPINPOL); + for(uint16_t j = 0; j < 65535; j++) { + regWr(rGPINPOL, sample_wr); + sample_rd = regRd(rGPINPOL); + if(sample_rd != sample_wr) { + MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); + if(spd > 1999999) { + spd -= 1000000; + goto again; + } + return (-1); + } + sample_wr++; + } + regWr(rGPINPOL, gpinpol_copy); + } + + MAX_HOST_DEBUG(PSTR("Pass SPI speed %lu\r\n"), spd); +#endif + + if(reset() == 0) { //OSCOKIRQ hasn't asserted in time + MAX_HOST_DEBUG(PSTR("OSCOKIRQ hasn't asserted in time")); + return ( -1); + } + + /* MAX3421E - full-duplex SPI, interrupt kind, vbus off */ + regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE | GPX_VBDET)); + + // Delay a minimum of 1 second to ensure any capacitors are drained. + // 1 second is required to make sure we do not smoke a Microdrive! + if(mseconds != INT16_MIN) { + if(mseconds < 1000) mseconds = 1000; + delay(mseconds); // We can't depend on SOF timer here. + } + + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host + + // Enable interrupts on the MAX3421e + regWr(rHIEN, IRQ_CHECK_MASK); + // Enable interrupt pin on the MAX3421e, set pulse width for edge + regWr(rCPUCTL, (bmIE | bmPULSEWIDTH)); + + /* check if device is connected */ + regWr(rHCTL, bmSAMPLEBUS); // sample USB bus + while(!(regRd(rHCTL) & bmSAMPLEBUS)); //wait for sample operation to finish + + busprobe(); //check if anything is connected + VBUS_changed(); + + // GPX pin on. This is done here so that a change is detected if we have a switch connected. + /* MAX3421E - full-duplex SPI, interrupt kind, vbus on */ + regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE)); + regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. + regWr(rHCTL, bmBUSRST); // issue bus reset to force generate yet another possible IRQ + + +#if USB_HOST_SHIELD_USE_ISR + // Attach ISR to service IRQ from MAX3421e + noInterrupts(); + if(irq_pin & 1) { + ISRodd = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); + } else { + ISReven = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); + } + interrupts(); +#endif + //printf("\r\nrPINCTL 0x%2.2X\r\n", rPINCTL); + //printf("rCPUCTL 0x%2.2X\r\n", rCPUCTL); + //printf("rHIEN 0x%2.2X\r\n", rHIEN); + //printf("irq_pin %i\r\n", irq_pin); + return 0; +} + +/** + * Setup UHS_EpInfo structure + * + * @param addr USB device address + * @param ep Endpoint + * @param ppep pointer to the pointer to a valid UHS_EpInfo structure + * @param nak_limit how many NAKs before aborting + * @return 0 on success + */ +uint8_t UHS_NI MAX3421E_HOST::SetAddress(uint8_t addr, uint8_t ep, UHS_EpInfo **ppep, uint16_t &nak_limit) { + UHS_Device *p = addrPool.GetUsbDevicePtr(addr); + + if(!p) + return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; + + if(!p->epinfo) + return UHS_HOST_ERROR_NULL_EPINFO; + + *ppep = getEpInfoEntry(addr, ep); + + if(!*ppep) + return UHS_HOST_ERROR_NO_ENDPOINT_IN_TABLE; + + nak_limit = (0x0001UL << (((*ppep)->bmNakPower > UHS_USB_NAK_MAX_POWER) ? UHS_USB_NAK_MAX_POWER : (*ppep)->bmNakPower)); + nak_limit--; + /* + USBTRACE2("\r\nAddress: ", addr); + USBTRACE2(" EP: ", ep); + USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower); + USBTRACE2(" NAK Limit: ", nak_limit); + USBTRACE("\r\n"); + */ + regWr(rPERADDR, addr); //set peripheral address + + uint8_t mode = regRd(rMODE); + + //Serial.print("\r\nMode: "); + //Serial.println( mode, HEX); + //Serial.print("\r\nLS: "); + //Serial.println(p->speed, HEX); + + // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise + regWr(rMODE, (p->speed) ? mode & ~(bmHUBPRE | bmLOWSPEED) : mode | bmLOWSPEED | hub_present); + + return 0; +} + +/** + * Receive a packet + * + * @param pep pointer to a valid UHS_EpInfo structure + * @param nak_limit how many NAKs before aborting + * @param nbytesptr pointer to maximum number of bytes of data to receive + * @param data pointer to data buffer + * @return 0 on success + */ +uint8_t UHS_NI MAX3421E_HOST::InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data) { + uint8_t rcode = 0; + uint8_t pktsize; + + uint16_t nbytes = *nbytesptr; + MAX_HOST_DEBUG(PSTR("Requesting %i bytes "), nbytes); + uint8_t maxpktsize = pep->maxPktSize; + + *nbytesptr = 0; + regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value + + // use a 'break' to exit this loop + while(1) { + rcode = dispatchPkt(MAX3421E_tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS. +#if 0 + // This issue should be resolved now. + if(rcode == UHS_HOST_ERROR_TOGERR) { + //MAX_HOST_DEBUG(PSTR("toggle wrong\r\n")); + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value + continue; + } +#endif + if(rcode) { + //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! dispatchPkt %2.2x\r\n"), rcode); + break; //should be 0, indicating ACK. Else return error code. + } + /* check for RCVDAVIRQ and generate error if not present */ + /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */ + if((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) { + //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n")); + rcode = 0xF0; //receive error + break; + } + pktsize = regRd(rRCVBC); //number of received bytes + MAX_HOST_DEBUG(PSTR("Got %i bytes \r\n"), pktsize); + + if(pktsize > nbytes) { //certain devices send more than asked + //MAX_HOST_DEBUG(PSTR(">>>>>>>> Warning: wanted %i bytes but got %i.\r\n"), nbytes, pktsize); + pktsize = nbytes; + } + + int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr); + + if(mem_left < 0) + mem_left = 0; + + data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data); + + regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer + *nbytesptr += pktsize; // add this packet's byte count to total transfer length + + /* The transfer is complete under two conditions: */ + /* 1. The device sent a short packet (L.T. maxPacketSize) */ + /* 2. 'nbytes' have been transferred. */ + if((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes? + { + // Save toggle value + pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0; + //MAX_HOST_DEBUG(PSTR("\r\n")); + rcode = 0; + break; + } // if + } //while( 1 ) + return ( rcode); +} + +/** + * Transmit a packet + * + * @param pep pointer to a valid UHS_EpInfo structure + * @param nak_limit how many NAKs before aborting + * @param nbytes number of bytes of data to send + * @param data pointer to data buffer + * @return 0 on success + */ +uint8_t UHS_NI MAX3421E_HOST::OutTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) { + uint8_t rcode = UHS_HOST_ERROR_NONE; + uint8_t retry_count; + uint8_t *data_p = data; //local copy of the data pointer + uint16_t bytes_tosend; + uint16_t nak_count; + uint16_t bytes_left = nbytes; + + uint8_t maxpktsize = pep->maxPktSize; + + if(maxpktsize < 1 || maxpktsize > 64) + return UHS_HOST_ERROR_BAD_MAX_PACKET_SIZE; + + unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; + + regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value + + while(bytes_left) { + SYSTEM_OR_SPECIAL_YIELD(); + retry_count = 0; + nak_count = 0; + bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left; + bytesWr(rSNDFIFO, bytes_tosend, data_p); //filling output FIFO + regWr(rSNDBC, bytes_tosend); //set number of bytes + regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); //dispatch packet + while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ + regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ + rcode = (regRd(rHRSL) & 0x0F); + + while(rcode && ((long)(millis() - timeout) < 0L)) { + switch(rcode) { + case UHS_HOST_ERROR_NAK: + nak_count++; + if(nak_limit && (nak_count == nak_limit)) + goto breakout; + break; + case UHS_HOST_ERROR_TIMEOUT: + retry_count++; + if(retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) + goto breakout; + break; + case UHS_HOST_ERROR_TOGERR: + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value + break; + default: + goto breakout; + }//switch( rcode + + /* process NAK according to Host out NAK bug */ + regWr(rSNDBC, 0); + regWr(rSNDFIFO, *data_p); + regWr(rSNDBC, bytes_tosend); + regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); //dispatch packet + while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ + regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ + rcode = (regRd(rHRSL) & 0x0F); + SYSTEM_OR_SPECIAL_YIELD(); + }//while( rcode && .... + bytes_left -= bytes_tosend; + data_p += bytes_tosend; + }//while( bytes_left... +breakout: + + pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; //bmSNDTOG1 : bmSNDTOG0; //update toggle + return ( rcode); //should be 0 in all cases +} + +/** + * Send the actual packet. + * + * @param token + * @param ep Endpoint + * @param nak_limit how many NAKs before aborting, 0 == exit after timeout + * @return 0 on success, 0xFF indicates NAK timeout. @see + */ +/* Assumes peripheral address is set and relevant buffer is loaded/empty */ +/* If NAK, tries to re-send up to nak_limit times */ +/* If nak_limit == 0, do not count NAKs, exit after timeout */ +/* If bus timeout, re-sends up to USB_RETRY_LIMIT times */ + +/* return codes 0x00-0x0F are HRSLT( 0x00 being success ), 0xFF means timeout */ +uint8_t UHS_NI MAX3421E_HOST::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) { + unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; + uint8_t tmpdata; + uint8_t rcode = UHS_HOST_ERROR_NONE; + uint8_t retry_count = 0; + uint16_t nak_count = 0; + + for(;;) { + regWr(rHXFR, (token | ep)); //launch the transfer + while((long)(millis() - timeout) < 0L) //wait for transfer completion + { + SYSTEM_OR_SPECIAL_YIELD(); + tmpdata = regRd(rHIRQ); + + if(tmpdata & bmHXFRDNIRQ) { + regWr(rHIRQ, bmHXFRDNIRQ); //clear the interrupt + //rcode = 0x00; + break; + }//if( tmpdata & bmHXFRDNIRQ + + }//while ( millis() < timeout + + rcode = (regRd(rHRSL) & 0x0F); //analyze transfer result + + switch(rcode) { + case UHS_HOST_ERROR_NAK: + nak_count++; + if(nak_limit && (nak_count == nak_limit)) + return (rcode); + delayMicroseconds(200); + break; + case UHS_HOST_ERROR_TIMEOUT: + retry_count++; + if(retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) + return (rcode); + break; + default: + return (rcode); + }//switch( rcode + } +} + +// +// NULL is error, we don't need to know the reason. +// + +UHS_EpInfo * UHS_NI MAX3421E_HOST::ctrlReqOpen(uint8_t addr, uint64_t Request, uint8_t *dataptr) { + uint8_t rcode; + UHS_EpInfo *pep = NULL; + uint16_t nak_limit = 0; + rcode = SetAddress(addr, 0, &pep, nak_limit); + + if(!rcode) { + + bytesWr(rSUDFIFO, 8, (uint8_t*)(&Request)); //transfer to setup packet FIFO + + rcode = dispatchPkt(MAX3421E_tokSETUP, 0, nak_limit); //dispatch packet + if(!rcode) { + if(dataptr != NULL) { + if(((Request)/* bmReqType*/ & 0x80) == 0x80) { + pep->bmRcvToggle = 1; //bmRCVTOG1; + } else { + pep->bmSndToggle = 1; //bmSNDTOG1; + } + } + } else { + pep = NULL; + } + } + return pep; +} + +uint8_t UHS_NI MAX3421E_HOST::ctrlReqRead(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint16_t nbytes, uint8_t *dataptr) { + *read = 0; + uint16_t nak_limit = 0; + MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i\r\n"), *left); + if(*left) { +again: + *read = nbytes; + uint8_t rcode = InTransfer(pep, nak_limit, read, dataptr); + if(rcode == UHS_HOST_ERROR_TOGERR) { + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + goto again; + } + + if(rcode) { + MAX_HOST_DEBUG(PSTR("ctrlReqRead ERROR: %2.2x, left: %i, read %i\r\n"), rcode, *left, *read); + return rcode; + } + *left -= *read; + MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i, read %i\r\n"), *left, *read); + } + return 0; +} + +uint8_t UHS_NI MAX3421E_HOST::ctrlReqClose(UHS_EpInfo *pep, uint8_t bmReqType, uint16_t left, uint16_t nbytes, uint8_t *dataptr) { + uint8_t rcode = 0; + + //MAX_HOST_DEBUG(PSTR("Closing")); + if(((bmReqType & 0x80) == 0x80) && pep && left && dataptr) { + MAX_HOST_DEBUG(PSTR("ctrlReqRead Sinking %i\r\n"), left); + // If reading, sink the rest of the data. + while(left) { + uint16_t read = nbytes; + rcode = InTransfer(pep, 0, &read, dataptr); + if(rcode == UHS_HOST_ERROR_TOGERR) { + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + continue; + } + if(rcode) break; + left -= read; + if(read < nbytes) break; + } + } + if(!rcode) { + // Serial.println("Dispatching"); + rcode = dispatchPkt(((bmReqType & 0x80) == 0x80) ? MAX3421E_tokOUTHS : MAX3421E_tokINHS, 0, 0); //GET if direction + // } else { + // Serial.println("Bypassed Dispatch"); + } + return rcode; +} + +/** + * Bottom half of the ISR task + */ +void UHS_NI MAX3421E_HOST::ISRbottom() { + uint8_t x; + // Serial.print("Enter "); + // Serial.print((uint32_t)this,HEX); + // Serial.print(" "); + // Serial.println(usb_task_state, HEX); + + DDSB(); + if(condet) { + VBUS_changed(); +#if USB_HOST_SHIELD_USE_ISR + noInterrupts(); +#endif + condet = false; +#if USB_HOST_SHIELD_USE_ISR + interrupts(); +#endif + } + switch(usb_task_state) { + case UHS_USB_HOST_STATE_INITIALIZE: + // should never happen... + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_INITIALIZE\r\n")); + busprobe(); + VBUS_changed(); + break; + case UHS_USB_HOST_STATE_DEBOUNCE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE\r\n")); + // This seems to not be needed. The host controller has debounce built in. + sof_countdown = UHS_HOST_DEBOUNCE_DELAY_MS; + usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE; + break; + case UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE\r\n")); + if(!sof_countdown) usb_task_state = UHS_USB_HOST_STATE_RESET_DEVICE; + break; + case UHS_USB_HOST_STATE_RESET_DEVICE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_DEVICE\r\n")); + busevent = true; + usb_task_state = UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; + regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. + regWr(rHCTL, bmBUSRST); // issue bus reset + break; + case UHS_USB_HOST_STATE_RESET_NOT_COMPLETE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_NOT_COMPLETE\r\n")); + if(!busevent) usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; + break; + case UHS_USB_HOST_STATE_WAIT_BUS_READY: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_WAIT_BUS_READY\r\n")); + usb_task_state = UHS_USB_HOST_STATE_CONFIGURING; + break; // don't fall through + + case UHS_USB_HOST_STATE_CONFIGURING: + usb_task_state = UHS_USB_HOST_STATE_CHECK; + x = Configuring(0, 1, usb_host_speed); + usb_error = x; + if(usb_task_state == UHS_USB_HOST_STATE_CHECK) { + if(x) { + MAX_HOST_DEBUG(PSTR("Error 0x%2.2x"), x); + if(x == UHS_HOST_ERROR_JERR) { + usb_task_state = UHS_USB_HOST_STATE_IDLE; + } else if(x != UHS_HOST_ERROR_DEVICE_INIT_INCOMPLETE) { + usb_error = x; + usb_task_state = UHS_USB_HOST_STATE_ERROR; + } + } else + usb_task_state = UHS_USB_HOST_STATE_CONFIGURING_DONE; + } + break; + + case UHS_USB_HOST_STATE_CHECK: + // Serial.println((uint32_t)__builtin_return_address(0), HEX); + break; + case UHS_USB_HOST_STATE_CONFIGURING_DONE: + usb_task_state = UHS_USB_HOST_STATE_RUNNING; + break; + #ifdef USB_HOST_MANUAL_POLL + case UHS_USB_HOST_STATE_RUNNING: + case UHS_USB_HOST_STATE_ERROR: + case UHS_USB_HOST_STATE_IDLE: + case UHS_USB_HOST_STATE_ILLEGAL: + enable_frame_irq(false); + break; + #else + case UHS_USB_HOST_STATE_RUNNING: + Poll_Others(); + for(x = 0; (usb_task_state == UHS_USB_HOST_STATE_RUNNING) && (x < UHS_HOST_MAX_INTERFACE_DRIVERS); x++) { + if(devConfig[x]) { + if(devConfig[x]->bPollEnable) devConfig[x]->Poll(); + } + } + // fall thru + #endif + default: + // Do nothing + break; + } // switch( usb_task_state ) + DDSB(); +#if USB_HOST_SHIELD_USE_ISR + if(condet) { + VBUS_changed(); + noInterrupts(); + condet = false; + interrupts(); + } +#endif +#ifdef USB_HOST_SHIELD_TIMING_PIN + // My counter/timer can't work on an inverted gate signal + // so we gate using a high pulse -- AJK + UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); +#endif + //usb_task_polling_disabled--; + EnablePoll(); + DDSB(); +} + + +/* USB main task. Services the MAX3421e */ +#if !USB_HOST_SHIELD_USE_ISR + +void UHS_NI MAX3421E_HOST::ISRTask() { +} +void UHS_NI MAX3421E_HOST::Task() +#else + +void UHS_NI MAX3421E_HOST::Task() { +#ifdef USB_HOST_MANUAL_POLL + if(usb_task_state == UHS_USB_HOST_STATE_RUNNING) { + noInterrupts(); + for(uint8_t x = 0; x < UHS_HOST_MAX_INTERFACE_DRIVERS; x++) + if(devConfig[x] && devConfig[x]->bPollEnable) + devConfig[x]->Poll(); + interrupts(); + } +#endif +} + +void UHS_NI MAX3421E_HOST::ISRTask() +#endif +{ + DDSB(); + +#ifndef SWI_IRQ_NUM + suspend_host(); +#if USB_HOST_SHIELD_USE_ISR + // Enable interrupts + interrupts(); +#endif +#endif + + counted = false; + if(!MARLIN_UHS_READ_IRQ()) { + uint8_t HIRQALL = regRd(rHIRQ); //determine interrupt source + uint8_t HIRQ = HIRQALL & IRQ_CHECK_MASK; + uint8_t HIRQ_sendback = 0x00; + + if((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { + MAX_HOST_DEBUG + (PSTR("\r\nBEFORE CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), + (HIRQ & bmCONDETIRQ) ? "T" : "F", + (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", + doingreset ? "T" : "F", + usb_task_state + ); + } + // ALWAYS happens BEFORE or WITH CONDETIRQ + if(HIRQ & bmBUSEVENTIRQ) { + HIRQ_sendback |= bmBUSEVENTIRQ; + if(!doingreset) condet = true; + busprobe(); + busevent = false; + } + + if(HIRQ & bmCONDETIRQ) { + HIRQ_sendback |= bmCONDETIRQ; + if(!doingreset) condet = true; + busprobe(); + } + +#if 1 + if((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { + MAX_HOST_DEBUG + (PSTR("\r\nAFTER CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), + (HIRQ & bmCONDETIRQ) ? "T" : "F", + (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", + doingreset ? "T" : "F", + usb_task_state + ); + } +#endif + + if(HIRQ & bmFRAMEIRQ) { + HIRQ_sendback |= bmFRAMEIRQ; + if(sof_countdown) { + sof_countdown--; + counted = true; + } + sofevent = false; + } + + //MAX_HOST_DEBUG(PSTR("\r\n%s%s%s\r\n"), + // sof_countdown ? "T" : "F", + // counted ? "T" : "F", + // usb_task_polling_disabled? "T" : "F"); + DDSB(); + regWr(rHIRQ, HIRQ_sendback); +#ifndef SWI_IRQ_NUM + resume_host(); +#if USB_HOST_SHIELD_USE_ISR + // Disable interrupts + noInterrupts(); +#endif +#endif + if(!sof_countdown && !counted && !usb_task_polling_disabled) { + DisablePoll(); + //usb_task_polling_disabled++; +#ifdef USB_HOST_SHIELD_TIMING_PIN + // My counter/timer can't work on an inverted gate signal + // so we gate using a high pulse -- AJK + UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, HIGH); +#endif + +#ifdef SWI_IRQ_NUM + // MAX_HOST_DEBUG(PSTR("--------------- Doing SWI ----------------")); + exec_SWI(this); +#else +#if USB_HOST_SHIELD_USE_ISR + // Enable interrupts + interrupts(); +#endif /* USB_HOST_SHIELD_USE_ISR */ + ISRbottom(); +#endif /* SWI_IRQ_NUM */ + } + } +} + +#if 0 +DDSB(); +#endif +#else +#error "Never include USB_HOST_SHIELD_INLINE.h, include UHS_host.h instead" +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs3/UHS_host/macro_logic.h b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/macro_logic.h new file mode 100644 index 0000000..eeaa4f8 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/UHS_host/macro_logic.h @@ -0,0 +1,152 @@ +/* + * File: macro_logic.h + * Author: root + * + * Created on December 22, 2018, 4:49 AM + * + * To test: + * gcc -DAJK_TEST_MACRO_LOGIC -E macro_logic.h + */ + +#ifndef MACRO_LOGIC_H +#define MACRO_LOGIC_H + +#define AJK_CAT(a, ...) AJK_PRIMITIVE_CAT(a, __VA_ARGS__) +#define AJK_PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__ + +#define AJK_COMPL(b) AJK_PRIMITIVE_CAT(AJK_COMPL_, b) +#define AJK_COMPL_0 1 +#define AJK_COMPL_1 0 + +#define AJK_BITAND(x) AJK_PRIMITIVE_CAT(AJK_BITAND_, x) +#define AJK_BITAND_0(y) 0 +#define AJK_BITAND_1(y) y + +#define AJK_INC(x) AJK_PRIMITIVE_CAT(AJK_INC_, x) +#define AJK_INC_0 1 +#define AJK_INC_1 2 +#define AJK_INC_2 3 +#define AJK_INC_3 4 +#define AJK_INC_4 5 +#define AJK_INC_5 6 +#define AJK_INC_6 7 +#define AJK_INC_7 8 +#define AJK_INC_8 9 +#define AJK_INC_9 10 +#define AJK_INC_10 10 + +#define AJK_DEC(x) AJK_PRIMITIVE_CAT(AJK_DEC_, x) +#define AJK_DEC_0 0 +#define AJK_DEC_1 0 +#define AJK_DEC_2 1 +#define AJK_DEC_3 2 +#define AJK_DEC_4 3 +#define AJK_DEC_5 4 +#define AJK_DEC_6 5 +#define AJK_DEC_7 6 +#define AJK_DEC_8 7 +#define AJK_DEC_9 8 +#define AJK_DEC_10 9 + +#define AJK_CHECK_N(x, n, ...) n +#define AJK_CHECK(...) AJK_CHECK_N(__VA_ARGS__, 0,) +#define AJK_PROBE(x) x, 1, + +#define AJK_IS_PAREN(x) AJK_CHECK(AJK_IS_PAREN_PROBE x) +#define AJK_IS_PAREN_PROBE(...) AJK_PROBE(~) + +#define AJK_NOT(x) AJK_CHECK(AJK_PRIMITIVE_CAT(AJK_NOT_, x)) +#define AJK_NOT_0 AJK_PROBE(~) + +#define AJK_COMPL(b) AJK_PRIMITIVE_CAT(AJK_COMPL_, b) +#define AJK_COMPL_0 1 +#define AJK_COMPL_1 0 + +#define AJK_BOOL(x) AJK_COMPL(AJK_NOT(x)) + +#define AJK_IIF(c) AJK_PRIMITIVE_CAT(AJK_IIF_, c) +#define AJK_IIF_0(t, ...) __VA_ARGS__ +#define AJK_IIF_1(t, ...) t + +#define AJK_IF(c) AJK_IIF(AJK_BOOL(c)) + +#define AJK_EAT(...) +#define AJK_EXPAND(...) __VA_ARGS__ +#define AJK_WHEN(c) AJK_IF(c)(AJK_EXPAND, AJK_EAT) + +#define AJK_EMPTY() +#define AJK_DEFER(id) id AJK_EMPTY() +#define AJK_OBSTRUCT(id) id AJK_DEFER(AJK_EMPTY)() + +#define AJK_EVAL(...) AJK_EVAL1(AJK_EVAL1(AJK_EVAL1(__VA_ARGS__))) +#define AJK_EVAL1(...) AJK_EVAL2(AJK_EVAL2(AJK_EVAL2(__VA_ARGS__))) +#define AJK_EVAL2(...) AJK_EVAL3(AJK_EVAL3(AJK_EVAL3(__VA_ARGS__))) +#define AJK_EVAL3(...) AJK_EVAL4(AJK_EVAL4(AJK_EVAL4(__VA_ARGS__))) +#define AJK_EVAL4(...) AJK_EVAL5(AJK_EVAL5(AJK_EVAL5(__VA_ARGS__))) +#define AJK_EVAL5(...) __VA_ARGS__ + +#define AJK_REPEAT(AJK_count, AJK_macro, ...) \ + AJK_WHEN(AJK_count) \ + ( \ + AJK_OBSTRUCT(AJK_REPEAT_INDIRECT) () \ + ( \ + AJK_DEC(AJK_count), AJK_macro, __VA_ARGS__ \ + ) \ + AJK_OBSTRUCT(AJK_macro) \ + ( \ + AJK_DEC(AJK_count), __VA_ARGS__ \ + ) \ + ) +#define AJK_REPEAT_INDIRECT() AJK_REPEAT + +#define AJK_WHILE(AJK_pred, AJK_op, ...) \ + IF(AJK_pred(__VA_ARGS__)) \ + ( \ + AJK_OBSTRUCT(AJK_WHILE_INDIRECT) () \ + ( \ + AJK_pred, AJK_op, AJK_op(__VA_ARGS__) \ + ), \ + __VA_ARGS__ \ + ) +#define AJK_WHILE_INDIRECT() AJK_WHILE + +#define AJK_PRIMITIVE_COMPARE(x, y) AJK_IS_PAREN \ +( \ + AJK_COMPARE_ ## x ( AJK_COMPARE_ ## y) (()) \ +) + +#define AJK_IS_COMPARABLE(x) AJK_IS_PAREN( AJK_CAT(AJK_COMPARE_, x) (()) ) + +#define AJK_NOT_EQUAL(x, y) \ +AJK_IIF(AJK_BITAND(AJK_IS_COMPARABLE(x))(AJK_IS_COMPARABLE(y)) ) \ +( \ + AJK_PRIMITIVE_COMPARE, \ + 1 AJK_EAT \ +)(x, y) + +#define AJK_EQUAL(x, y) AJK_COMPL(AJK_NOT_EQUAL(x, y)) + + +#define AJK_COMMA() , + +#define AJK_COMMA_IF(n) AJK_IF(n)(AJK_COMMA, AJK_EAT)() + + +#define AJK_COMMA_VAR(AJK_count, AJK_v) AJK_COMMA_IF(AJK_count) AJK_v ## AJK_count + +#define AJK_MAKE_LIST(AJK_v, AJK_count) AJK_EVAL(AJK_REPEAT(AJK_count, AJK_COMMA_VAR, AJK_v)) + +#define AJK_FUN(AJK_count, AJK_v, AJK_args, AJK_body) AJK_v ## AJK_count (AJK_args) { AJK_body(AJK_count) } +#define AJK_MAKE_FUNS(AJK_v, AJK_args, AJK_count, AJK_body) AJK_EVAL(AJK_REPEAT(AJK_count, AJK_FUN, AJK_v, AJK_args, AJK_body)) +#ifdef AJK_TEST_MACRO_LOGIC + +#define BODY(AJKindex) some(C, statement); containing(a, test[AJKindex]); +#define ZERO_TIMES_TEST 0 +#define THREE_TIMES_TEST 3 +blank > AJK_MAKE_LIST(VARIABLE_, ZERO_TIMES_TEST) < because zero repeats +Make 3 comma separated indexed variables : AJK_MAKE_LIST(VARIABLE_, THREE_TIMES_TEST) +Make 3 bogus function bodies +AJK_MAKE_FUNS(unsigned Cfunc,(arg1, arg2),3,BODY) +#endif + +#endif /* MACRO_LOGIC_H */ diff --git a/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/SWI_INLINE.h b/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/SWI_INLINE.h new file mode 100644 index 0000000..f86054c --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/SWI_INLINE.h @@ -0,0 +1,244 @@ +/* + * File: SWI_INLINE.h + * Author: xxxajk@gmail.com + * + * Created on December 5, 2014, 9:40 AM + * + * This is the actual library. + * There are no 'c' or 'cpp' files. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifdef DYN_SWI_H +#ifndef SWI_INLINE_H +#define SWI_INLINE_H + +#ifndef SWI_MAXIMUM_ALLOWED +#define SWI_MAXIMUM_ALLOWED 4 +#endif + + + +#if defined(__arm__) || defined(ARDUINO_ARCH_PIC32) +static char dyn_SWI_initied = 0; +static dyn_SWI* dyn_SWI_LIST[SWI_MAXIMUM_ALLOWED]; +static dyn_SWI* dyn_SWI_EXEC[SWI_MAXIMUM_ALLOWED]; +#ifdef __arm__ +#ifdef __USE_CMSIS_VECTORS__ +extern "C" { + void (*_VectorsRam[VECTORTABLE_SIZE])(void)__attribute__((aligned(VECTORTABLE_ALIGNMENT))); +} +#else + +__attribute__((always_inline)) static inline void __DSB() { + __asm__ volatile ("dsb"); +} +#endif // defined(__USE_CMSIS_VECTORS__) +#else // defined(__arm__) +__attribute__((always_inline)) static inline void __DSB() { + __asm__ volatile ("sync" : : : "memory"); +} +#endif // defined(__arm__) + +/** + * Execute queued class ISR routines. + */ +#ifdef ARDUINO_ARCH_PIC32 +static p32_regset *ifs = ((p32_regset *) & IFS0) + (SWI_IRQ_NUM / 32); //interrupt flag register set +static p32_regset *iec = ((p32_regset *) & IEC0) + (SWI_IRQ_NUM / 32); //interrupt enable control reg set +static uint32_t swibit = 1 << (SWI_IRQ_NUM % 32); + +void +#ifdef __PIC32MZXX__ + __attribute__((nomips16,at_vector(SWI_VECTOR),interrupt(SWI_IPL))) +#else + __attribute__((interrupt(),nomips16)) +#endif + softISR() { +#else +#ifdef ARDUINO_spresense_ast +unsigned int softISR() { +#else +void softISR() { +#endif +#endif + + // + // TO-DO: Perhaps limit to 8, and inline this? + // + + + // Make a working copy, while clearing the queue. + noInterrupts(); +#ifdef ARDUINO_ARCH_PIC32 + //ifs->clr = swibit; +#endif + for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) { + dyn_SWI_EXEC[i] = dyn_SWI_LIST[i]; + dyn_SWI_LIST[i] = NULL; + } + __DSB(); + interrupts(); + + // Execute each class SWI + for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) { + if(dyn_SWI_EXEC[i]) { +#ifdef __DYN_SWI_DEBUG_LED__ + digitalWrite(__DYN_SWI_DEBUG_LED__, HIGH); +#endif + dyn_SWI_EXEC[i]->dyn_SWISR(); +#ifdef __DYN_SWI_DEBUG_LED__ + digitalWrite(__DYN_SWI_DEBUG_LED__, LOW); +#endif + } + } +#ifdef ARDUINO_ARCH_PIC32 + noInterrupts(); + if(!dyn_SWI_EXEC[0]) ifs->clr = swibit; + interrupts(); +#endif +#ifdef ARDUINO_spresense_ast + return 0; +#endif +} + +#define DDSB() __DSB() +#endif + + +#ifdef __arm__ +#ifndef interruptsStatus +#define interruptsStatus() __interruptsStatus() +static inline unsigned char __interruptsStatus() __attribute__((always_inline, unused)); + +static inline unsigned char __interruptsStatus() { + unsigned int primask; + asm volatile ("mrs %0, primask" : "=r" (primask)); + if(primask) return 0; + return 1; +} +#endif + +/** + * Initialize the Dynamic (class) Software Interrupt + */ +static void Init_dyn_SWI() { + if(!dyn_SWI_initied) { +#ifdef __USE_CMSIS_VECTORS__ + uint32_t *X_Vectors = (uint32_t*)SCB->VTOR; + for(int i = 0; i < VECTORTABLE_SIZE; i++) { + _VectorsRam[i] = reinterpret_cast(X_Vectors[i]); /* copy vector table to RAM */ + } + /* relocate vector table */ + noInterrupts(); + SCB->VTOR = reinterpret_cast(&_VectorsRam); + DDSB(); + interrupts(); +#endif +#ifndef ARDUINO_spresense_ast + for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) dyn_SWI_LIST[i] = NULL; + noInterrupts(); + _VectorsRam[SWI_IRQ_NUM + 16] = reinterpret_cast(softISR); + DDSB(); + interrupts(); + NVIC_SET_PRIORITY(SWI_IRQ_NUM, 255); + NVIC_ENABLE_IRQ(SWI_IRQ_NUM); +#endif +#ifdef __DYN_SWI_DEBUG_LED__ + pinMode(__DYN_SWI_DEBUG_LED__, OUTPUT); + digitalWrite(__DYN_SWI_DEBUG_LED__, LOW); +#endif + dyn_SWI_initied = 1; + } +} + +/** + * @param klass class that extends dyn_SWI + * @return 0 on queue full, else returns queue position (ones based) + */ +int exec_SWI(const dyn_SWI* klass) { + int rc = 0; + + uint8_t irestore = interruptsStatus(); + // Allow use from inside a critical section... + // ... and prevent races if also used inside an ISR + noInterrupts(); + for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) { + if(!dyn_SWI_LIST[i]) { + rc = 1 + i; // Success! + dyn_SWI_LIST[i] = (dyn_SWI*)klass; +#ifndef ARDUINO_spresense_ast + if(!NVIC_GET_PENDING(SWI_IRQ_NUM)) NVIC_SET_PENDING(SWI_IRQ_NUM); +#else + // Launch 1-shot timer as an emulated SWI + // Hopefully the value of Zero is legal. + // 1 microsecond latency would suck! + attachTimerInterrupt(softISR, 100); +#endif + DDSB(); + break; + } + } + // Restore interrupts, if they were on. + if(irestore) interrupts(); + return rc; +} +#elif defined(ARDUINO_ARCH_PIC32) + +/** + * Initialize the Dynamic (class) Software Interrupt + */ +static void Init_dyn_SWI() { + if(!dyn_SWI_initied) { + uint32_t sreg = disableInterrupts(); + + setIntVector(SWI_VECTOR, softISR); + setIntPriority(SWI_VECTOR, 1, 1); // Lowest priority, ever. + ifs->clr = swibit; + iec->clr = swibit; + iec->set = swibit; + restoreInterrupts(sreg); +#ifdef __DYN_SWI_DEBUG_LED__ + pinMode(__DYN_SWI_DEBUG_LED__, OUTPUT); + UHS_PIN_WRITE(__DYN_SWI_DEBUG_LED__, LOW); +#endif + } +} + +/** + * @param klass class that extends dyn_SWI + * @return 0 on queue full, else returns queue position (ones based) + */ +int exec_SWI(const dyn_SWI* klass) { + int rc = 0; + uint32_t sreg = disableInterrupts(); + for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) { + if(!dyn_SWI_LIST[i]) { + rc = 1 + i; // Success! + dyn_SWI_LIST[i] = (dyn_SWI*)klass; + if(!(ifs->reg & swibit)) ifs->set = swibit; + ; + break; + } + } + restoreInterrupts(sreg); + return rc; +} + +#endif /* defined(__arm__) */ +#endif /* SWI_INLINE_H */ +#else +#error "Never include SWI_INLINE.h directly, include dyn_SWI.h instead" +#endif diff --git a/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/dyn_SWI.h b/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/dyn_SWI.h new file mode 100644 index 0000000..07f4ae0 --- /dev/null +++ b/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/dyn_SWI.h @@ -0,0 +1,172 @@ +/* + * File: dyn_SWI.h + * Author: xxxajk@gmail.com + * + * Created on December 5, 2014, 9:12 AM + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef DYN_SWI_H +#define DYN_SWI_H + + +#if defined(__arm__) || defined(ARDUINO_ARCH_PIC32) +#ifdef ARDUINO_ARCH_PIC32 +#include +#endif +#ifdef __cplusplus + +#ifdef true +#undef true +#endif + +#ifdef false +#undef false +#endif + +#endif + +#ifdef ARDUINO_spresense_ast +#define SWI_IRQ_NUM 666 // because this board is totally evil. +#elif defined(ARDUINO_ARCH_PIC32) +#ifndef SWI_IRQ_NUM +#ifdef _DSPI0_IPL_ISR +#define SWI_IPL _DSPI0_IPL_ISR +#define SWI_VECTOR _DSPI0_ERR_IRQ +#define SWI_IRQ_NUM _DSPI0_ERR_IRQ +#elif defined(_PMP_ERROR_IRQ) +#define SWI_IRQ_NUM _PMP_ERROR_IRQ +#define SWI_VECTOR _PMP_VECTOR +#else +#error SWI_IRQ_NUM and SWI_VECTOR need a definition +#endif +#ifdef __cplusplus +extern "C" +{ + void +#ifdef __PIC32MZXX__ + __attribute__((nomips16,at_vector(SWI_VECTOR),interrupt(SWI_IPL))) +#else + __attribute__((interrupt(),nomips16)) +#endif + softISR(); +} +#endif +#endif +#elif !defined(NVIC_NUM_INTERRUPTS) +// Assume CMSIS +#define __USE_CMSIS_VECTORS__ +#ifdef NUMBER_OF_INT_VECTORS +#define NVIC_NUM_INTERRUPTS (NUMBER_OF_INT_VECTORS-16) +#else +#define NVIC_NUM_INTERRUPTS ((int)PERIPH_COUNT_IRQn) +#endif +#define VECTORTABLE_SIZE (NVIC_NUM_INTERRUPTS+16) +#define VECTORTABLE_ALIGNMENT (0x100UL) +#define NVIC_GET_ACTIVE(n) NVIC_GetActive((IRQn_Type)n) +#define NVIC_GET_PENDING(n) NVIC_GetPendingIRQ((IRQn_Type)n) +#define NVIC_SET_PENDING(n) NVIC_SetPendingIRQ((IRQn_Type)n) +#define NVIC_ENABLE_IRQ(n) NVIC_EnableIRQ((IRQn_Type)n) +#define NVIC_SET_PRIORITY(n ,p) NVIC_SetPriority((IRQn_Type)n, (uint32_t) p) +//extern "C" { +// extern uint32_t _VectorsRam[VECTORTABLE_SIZE] __attribute__((aligned(VECTORTABLE_ALIGNMENT))); +//} + +#ifndef SWI_IRQ_NUM +#if defined(__SAM3X8E__) && defined(_VARIANT_ARDUINO_DUE_X_) +// DUE +// Choices available: +// HSMCI_IRQn Multimedia Card Interface (HSMCI) +// EMAC_IRQn Ethernet MAC (EMAC) +// EMAC is not broken out on the official DUE, but is on clones. +// SPI0_IRQn Serial Peripheral Interface (SPI0) +// SPI0_IRQn seems to be the best choice, as long as nobody uses an ISR based master +#define SWI_IRQ_NUM SPI0_IRQn +#elif defined(ARDUINO_SAMD_ZERO) +// Just use sercom4's unused IRQ vector. +#define SWI_IRQ_NUM I2S_IRQn +//#define SWI_IRQ_NUM SERCOM4_IRQn +#endif +#endif + +#ifndef SWI_IRQ_NUM +#error SWI_IRQ_NUM not defined (CMSIS) +#endif + +#elif defined(CORE_TEENSY) + +#ifndef NVIC_GET_ACTIVE +#define NVIC_GET_ACTIVE(n) (*((volatile uint32_t *)0xE000E300 + ((n) >> 5)) & (1 << ((n) & 31))) +#endif +#ifndef NVIC_GET_PENDING +#define NVIC_GET_PENDING(n) (*((volatile uint32_t *)0xE000E200 + ((n) >> 5)) & (1 << ((n) & 31))) +#ifndef SWI_IRQ_NUM +#ifdef __MK20DX256__ +#define SWI_IRQ_NUM 17 +#elif defined(__MK20DX128__) +#define SWI_IRQ_NUM 5 +#elif defined(__MKL26Z64__) +#define SWI_IRQ_NUM 4 +#elif defined(__MK66FX1M0__) +#define SWI_IRQ_NUM 30 +#elif defined(__MK64FX512__) +#define SWI_IRQ_NUM 30 +#elif defined(__IMXRT1052__) || defined(__IMXRT1062__) +#define SWI_IRQ_NUM 71 +#else +#error Do not know how to relocate IRQ vectors for this pjrc product +#endif +#endif +#endif +#else // Not CMSIS or PJRC CORE_TEENSY or PIC32 or SPRESENSE +#error Do not know how to relocate IRQ vectors or perform SWI +#endif // SWI_IRQ_NUM + + +#ifndef SWI_IRQ_NUM +#error SWI_IRQ_NUM not defined +#else +/** + * Use this class to extend your class, in order to provide + * a C++ context callable SWI. + */ +class dyn_SWI { +public: + + /** + * Override this method with your code. + */ + virtual void dyn_SWISR() { + }; +}; + +extern int exec_SWI(const dyn_SWI* klass); + +#include "SWI_INLINE.h" + +// IMPORTANT! Define this so that you do NOT end up with a NULL stub! +#define SWI_NO_STUB +#endif /* SWI_IRQ_NUM */ +#endif /* __arm__ */ + +// if no SWI for CPU (e.g. AVR) make a void stub. +#ifndef SWI_NO_STUB +#define Init_dyn_SWI() (void(0)) +#ifndef DDSB +#define DDSB() (void(0)) +#endif +#endif +#endif /* DYN_SWI_H */