grblHAL core  20250320
driver_opts2.h
Go to the documentation of this file.
1 /*
2  driver_opts2.h - for preprocessing options from my_machine.h, compiler symbols or from the board map file
3 
4  NOTE: This file is not used by the core, it may be included by drivers after the map file is included
5 
6  Part of grblHAL
7 
8  Copyright (c) 2024-2025 Terje Io
9 
10  grblHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  grblHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 //
25 // NOTE: do NOT change options here - edit the driver specific my_machine.h instead!
26 //
27 
28 #ifndef WEB_BUILD
29 
30 #if (DRIVER_SPINDLE_ENABLE & SPINDLE_ENA) && !defined(SPINDLE_ENABLE_PIN)
31 #warning "Selected spindle is not supported!"
32 #endif
33 
34 #if (DRIVER_SPINDLE_ENABLE & SPINDLE_DIR) && !defined(SPINDLE_DIRECTION_PIN)
35 #warning "Selected spindle is not fully supported - no direction output!"
36 #endif
37 
38 #if (DRIVER_SPINDLE_ENABLE & SPINDLE_PWM) && !defined(SPINDLE_PWM_PIN)
39 #warning "Selected spindle is not supported!"
40 #endif
41 
42 #if (DRIVER_SPINDLE1_ENABLE & SPINDLE_PWM) && !defined(SPINDLE_PWM_PIN)
43 #warning "Selected spindle 1 is not supported!"
44 #endif
45 
46 #endif
47 
48 #if MPG_ENABLE == 1 && !defined(MPG_MODE_PIN)
49 #error "MPG_MODE_PIN must be defined!"
50 #endif
51 
52 #if KEYPAD_ENABLE == 1 && !defined(I2C_STROBE_PORT)
53 #error Keypad plugin not supported!
54 #elif I2C_STROBE_ENABLE && !defined(I2C_STROBE_PORT)
55 #error "I2C strobe not supported!"
56 #endif
57 
58 #if EEPROM_ENABLE == 0
59 #define FLASH_ENABLE 1
60 #else
61 #define FLASH_ENABLE 0
62 #endif
63 
64 #if TRINAMIC_ENABLE
65 
66 #include "motors/trinamic.h"
67 
68 #ifndef TRINAMIC_MIXED_DRIVERS
69 #define TRINAMIC_MIXED_DRIVERS 1
70 #endif
71 
72 #if TRINAMIC_UART_ENABLE == 1 && !defined(TRINAMIC_STREAM)
73 #define TRINAMIC_STREAM 1
74 #endif
75 
76 #if TRINAMIC_SPI_ENABLE == 1 || TRINAMIC_ENABLE == 2130 || TRINAMIC_ENABLE == 2660 || TRINAMIC_ENABLE == 5160
77 
78 #undef TRINAMIC_SPI_ENABLE
79 #define TRINAMIC_SPI_40BIT (1<<1)
80 #define TRINAMIC_SPI_20BIT (1<<2)
81 #define TRINAMIC_SPI_CS_SINGLE (1<<3)
82 
83 #if TRINAMIC_ENABLE == 2660
84 #ifdef MOTOR_CS_PORT
85 #define TRINAMIC_SPI_ENABLE (TRINAMIC_SPI_20BIT|TRINAMIC_SPI_CS_SINGLE)
86 #else
87 #define TRINAMIC_SPI_ENABLE TRINAMIC_SPI_20BIT
88 #endif
89 #else
90 #ifdef MOTOR_CS_PIN
91 #define TRINAMIC_SPI_ENABLE (TRINAMIC_SPI_40BIT|TRINAMIC_SPI_CS_SINGLE)
92 #else
93 #define TRINAMIC_SPI_ENABLE TRINAMIC_SPI_40BIT
94 #endif
95 #endif
96 #endif // TRINAMIC_SPI_ENABLE ...
97 
98 #endif // TRINAMIC_ENABLE
99 
100 #ifndef TRINAMIC_I2C
101 #define TRINAMIC_I2C 0
102 #endif
103 #if TRINAMIC_ENABLE && TRINAMIC_I2C
104 #define TRINAMIC_MOTOR_ENABLE 1
105 #else
106 #define TRINAMIC_MOTOR_ENABLE 0
107 #endif
108 
109 #if USB_SERIAL_CDC && defined(SERIAL_PORT)
110 #define SP0 1
111 #else
112 #define SP0 0
113 #endif
114 
115 #ifdef SERIAL1_PORT
116 #define SP1 1
117 #else
118 #define SP1 0
119 #endif
120 
121 #ifdef SERIAL2_PORT
122 #define SP2 1
123 #else
124 #define SP2 0
125 #endif
126 
127 #if MODBUS_ENABLE & MODBUS_RTU_ENABLED
128 #define MODBUS_TEST 1
129 #else
130 #define MODBUS_TEST 0
131 #endif
132 
133 #if TRINAMIC_ENABLE && TRINAMIC_UART_ENABLE == 1
134 #define TRINAMIC_TEST 1
135 #else
136 #define TRINAMIC_TEST 0
137 #endif
138 
139 #if KEYPAD_ENABLE == 2 && MPG_ENABLE == 0
140 #define KEYPAD_TEST 1
141 #else
142 #define KEYPAD_TEST 0
143 #endif
144 
145 #if (MODBUS_TEST + KEYPAD_TEST + (MPG_ENABLE ? 1 : 0) + TRINAMIC_TEST + (BLUETOOTH_ENABLE == 2 ? 1 : 0)) > (SP0 + SP1 + SP2)
146 #error "Too many options that uses a serial port are enabled!"
147 #endif
148 
149 #undef SP0
150 #undef SP1
151 #undef SP2
152 #undef MODBUS_TEST
153 #undef KEYPAD_TEST
154 #undef TRINAMIC_TEST
155 
156 #if MPG_ENABLE && !defined(MPG_STREAM)
157 #if USB_SERIAL_CDC
158 #define MPG_STREAM 0
159 #else
160 #define MPG_STREAM 1
161 #endif
162 #if (MODBUS_ENABLE & MODBUS_RTU_ENABLED) && defined(MODBUS_RTU_STREAM) && MODBUS_RTU_STREAM == MPG_STREAM
163 #undef MPG_STREAM
164 #define MPG_STREAM (MODBUS_RTU_STREAM + 1)
165 #endif
166 #endif
167 
168 #if KEYPAD_ENABLE == 2 && !defined(KEYPAD_STREAM)
169 #if MPG_ENABLE
170 #define KEYPAD_STREAM MPG_STREAM
171 #elif USB_SERIAL_CDC
172 #define KEYPAD_STREAM 0
173 #else
174 #define KEYPAD_STREAM 1
175 #endif
176 #if (MODBUS_ENABLE & MODBUS_RTU_ENABLED) && defined(MODBUS_RTU_STREAM) && MODBUS_RTU_STREAM == MPG_STREAM
177 #undef KEYPAD_STREAM
178 #define KEYPAD_STREAM (MODBUS_RTU_STREAM + 1)
179 #endif
180 #endif
181 
182 #if defined(COPROC_RESET_PIN) && defined(COPROC_BOOT0_PIN)
183 #define COPROC_PASSTHRU 1
184 #else
185 #define COPROC_PASSTHRU 0
186 #endif
187 
188 #ifndef COPROC_STREAM
189 #if USB_SERIAL_CDC
190 #define COPROC_STREAM 0
191 #else
192 #define COPROC_STREAM 1
193 #endif
194 #endif
195 
196