Prusa MINI Firmware overview
drivers.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 #include "../inc/MarlinConfigPre.h"
25 
26 #define _A4988 0x001
27 #define _A5984 0x002
28 #define _DRV8825 0x003
29 #define _LV8729 0x004
30 #define _L6470 0x105
31 #define _TB6560 0x006
32 #define _TB6600 0x007
33 #define _TMC2100 0x008
34 #define _TMC2130 2130
35 #define _TMC2130_STANDALONE 0x009
36 #define _TMC2160 2160
37 #define _TMC2160_STANDALONE 2161
38 #define _TMC2208 2208
39 #define _TMC2208_STANDALONE 0x00A
40 #define _TMC2209 2209
41 #define _TMC2209_STANDALONE 0x00D
42 #define _TMC26X 0x10B
43 #define _TMC26X_STANDALONE 0x00B
44 #define _TMC2660 2660
45 #define _TMC2660_STANDALONE 0x00C
46 #define _TMC5130 5130
47 #define _TMC5130_STANDALONE 5131
48 #define _TMC5160 5160
49 #define _TMC5160_STANDALONE 5161
50 
51 #define _DRIVER_ID(V) _CAT(_, V)
52 #define _AXIS_DRIVER_TYPE(A,T) (_DRIVER_ID(A##_DRIVER_TYPE) == _CAT(_, T))
53 
54 #define AXIS_DRIVER_TYPE_X(T) _AXIS_DRIVER_TYPE(X,T)
55 #define AXIS_DRIVER_TYPE_Y(T) _AXIS_DRIVER_TYPE(Y,T)
56 #define AXIS_DRIVER_TYPE_Z(T) _AXIS_DRIVER_TYPE(Z,T)
57 #define AXIS_DRIVER_TYPE_X2(T) (EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) && _AXIS_DRIVER_TYPE(X2,T))
58 #define AXIS_DRIVER_TYPE_Y2(T) (ENABLED(Y_DUAL_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Y2,T))
59 #define AXIS_DRIVER_TYPE_Z2(T) (Z_MULTI_STEPPER_DRIVERS && _AXIS_DRIVER_TYPE(Z2,T))
60 #define AXIS_DRIVER_TYPE_Z3(T) (ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Z3,T))
61 #define AXIS_DRIVER_TYPE_E0(T) (E_STEPPERS > 0 && _AXIS_DRIVER_TYPE(E0,T))
62 #define AXIS_DRIVER_TYPE_E1(T) (E_STEPPERS > 1 && _AXIS_DRIVER_TYPE(E1,T))
63 #define AXIS_DRIVER_TYPE_E2(T) (E_STEPPERS > 2 && _AXIS_DRIVER_TYPE(E2,T))
64 #define AXIS_DRIVER_TYPE_E3(T) (E_STEPPERS > 3 && _AXIS_DRIVER_TYPE(E3,T))
65 #define AXIS_DRIVER_TYPE_E4(T) (E_STEPPERS > 4 && _AXIS_DRIVER_TYPE(E4,T))
66 #define AXIS_DRIVER_TYPE_E5(T) (E_STEPPERS > 5 && _AXIS_DRIVER_TYPE(E5,T))
67 
68 #define AXIS_DRIVER_TYPE(A,T) AXIS_DRIVER_TYPE_##A(T)
69 
70 #define HAS_E_DRIVER(T) ( AXIS_DRIVER_TYPE_E0(T) || AXIS_DRIVER_TYPE_E1(T) \
71  || AXIS_DRIVER_TYPE_E2(T) || AXIS_DRIVER_TYPE_E3(T) \
72  || AXIS_DRIVER_TYPE_E4(T) || AXIS_DRIVER_TYPE_E5(T) )
73 
74 #define HAS_DRIVER(T) ( AXIS_DRIVER_TYPE_X(T) || AXIS_DRIVER_TYPE_X2(T) \
75  || AXIS_DRIVER_TYPE_Y(T) || AXIS_DRIVER_TYPE_Y2(T) \
76  || AXIS_DRIVER_TYPE_Z(T) || AXIS_DRIVER_TYPE_Z2(T) || AXIS_DRIVER_TYPE_Z3(T) \
77  || HAS_E_DRIVER(T) )
78 
79 // Test for supported TMC drivers that require advanced configuration
80 // Does not match standalone configurations
81 #define HAS_TRINAMIC ( HAS_DRIVER(TMC2130) \
82  || HAS_DRIVER(TMC2160) \
83  || HAS_DRIVER(TMC2208) \
84  || HAS_DRIVER(TMC2209) \
85  || HAS_DRIVER(TMC2660) \
86  || HAS_DRIVER(TMC5130) \
87  || HAS_DRIVER(TMC5160) )
88 
89 #define HAS_TMC220x (HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209))
90 
91 #define AXIS_IS_TMC(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
92  || AXIS_DRIVER_TYPE(A,TMC2160) \
93  || AXIS_DRIVER_TYPE(A,TMC2208) \
94  || AXIS_DRIVER_TYPE(A,TMC2209) \
95  || AXIS_DRIVER_TYPE(A,TMC2660) \
96  || AXIS_DRIVER_TYPE(A,TMC5130) \
97  || AXIS_DRIVER_TYPE(A,TMC5160) )
98 
99 // Test for a driver that uses SPI - this allows checking whether a _CS_ pin
100 // is considered sensitive
101 #define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
102  || AXIS_DRIVER_TYPE(A,TMC2160) \
103  || AXIS_DRIVER_TYPE(A,TMC2660) \
104  || AXIS_DRIVER_TYPE(A,TMC5130) \
105  || AXIS_DRIVER_TYPE(A,TMC5160) )
106 
107 #define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) \
108  || AXIS_DRIVER_TYPE(A,TMC2209) )
109 
110 #define AXIS_HAS_STALLGUARD(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
111  || AXIS_DRIVER_TYPE(A,TMC2160) \
112  || AXIS_DRIVER_TYPE(A,TMC2209) \
113  || AXIS_DRIVER_TYPE(A,TMC2660) \
114  || AXIS_DRIVER_TYPE(A,TMC5130) \
115  || AXIS_DRIVER_TYPE(A,TMC5160) )
116 
117 #define AXIS_HAS_STEALTHCHOP(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
118  || AXIS_DRIVER_TYPE(A,TMC2160) \
119  || AXIS_DRIVER_TYPE(A,TMC2208) \
120  || AXIS_DRIVER_TYPE(A,TMC2209) \
121  || AXIS_DRIVER_TYPE(A,TMC5130) \
122  || AXIS_DRIVER_TYPE(A,TMC5160) )
123 
124 //
125 // Stretching 'drivers.h' to include LPC/SAMD51 SD options
126 //
127 #define _SDCARD_LCD 1
128 #define _SDCARD_ONBOARD 2
129 #define _SDCARD_CUSTOM_CABLE 3
130 #define _SDCARD_ID(V) _CAT(_SDCARD_, V)
131 #define SD_CONNECTION_IS(V) (_SDCARD_ID(SDCARD_CONNECTION) == _SDCARD_ID(V))