diff --git a/driver.json b/driver.json
index b8ded2d..ed49a33 100644
--- a/driver.json
+++ b/driver.json
@@ -1,14 +1,17 @@
{
"caps": {
+ "informal": 1,
"axes": 6,
"uart": 1,
- "serial_ports": 1,
+ "serial_ports": 3,
+ "sdcard": 1,
"littlefs": 1,
"probe": 1,
"safety_door": 1,
"estop": 1,
"wifi": 1,
"bluetooth": 1,
+ "neopixels": 1,
"pwm_spindle_aux": 3,
"pio_board": "esp32dev",
"plugins": [
@@ -50,7 +53,10 @@
"auto_square": 1,
"digital_in": 2,
"safety_door": 1,
- "sdcard": 1
+ "serial_ports": 1,
+ "sdcard": 1,
+ "wifi": 1,
+ "bluetooth": 1
},
"symbols": {
"DEFAULT_LIMIT_SIGNALS_INVERT_MASK": "N_AXIS",
@@ -71,8 +77,8 @@
"serial_ports": 2,
"trinamic_spi_cs": 1,
"trinamic_spi_chain": 1,
- "trinamic_uart_n": 0,
- "trinamic_uart_addr": 0
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -86,8 +92,26 @@
"safety_door": 0,
"sdcard": 1,
"probe": 1,
+ "pwm_spindle_aux": 2,
+ "wifi": 1,
+ "bluetooth": 1
+ }
+ },
+ {
+ "name": "MKS DLC32 2.0",
+ "symbol": "BOARD_MKS_DLC32_V2P0",
+ "URL": "https://github.com/makerbase-mks/MKS-DLC32",
+ "MAP": "main/boards/mks_dlc32_2_0_map.h",
+ "caps": {
+ "axes": 3,
+ "digital_in": 1,
+ "digital_out": 4,
"safety_door": 0,
- "pwm_spindle_aux": 2
+ "serial_ports": 1,
+ "pwm_spindle_aux": 2,
+ "sdcard": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -97,9 +121,12 @@
"MAP": "main/boards/mks_tinybee_1_0_map.h",
"caps": {
"axes": 5,
+ "auto_square": 2,
"serial_ports": 2,
"sdcard": 1,
- "estop": 0
+ "estop": 0,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -112,7 +139,10 @@
"auto_square": 0,
"safety_door": 0,
"estop": 0,
- "pwm_spindle_aux": 1
+ "serial_ports": 1,
+ "pwm_spindle_aux": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -124,7 +154,10 @@
"axes": 4,
"auto_square": 0,
"safety_door": 0,
- "estop": 0
+ "estop": 0,
+ "serial_ports": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -134,7 +167,10 @@
"MAP": "main/boards/protoneer_3.xx_map.h",
"caps": {
"axes": 3,
- "pwm_spindle_aux": 2
+ "pwm_spindle_aux": 2,
+ "serial_ports": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -147,7 +183,10 @@
"auto_square": 0,
"pwm_spindle_aux": 2,
"sdcard": 1,
- "i2c": 1
+ "i2c": 1,
+ "serial_ports": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -161,21 +200,9 @@
"serial_ports": 2,
"sdcard": 1,
"trinamic": 5160,
- "trinamic_spi_chain": 1
- }
- },
- {
- "name": "MKS DLC32 2.0",
- "symbol": "BOARD_MKS_DLC32_V2P0",
- "URL": "https://github.com/makerbase-mks/MKS-DLC32",
- "MAP": "main/boards/mks_dlc32_2_0_map.h",
- "caps": {
- "axes": 3,
- "digital_in": 1,
- "digital_out": 4,
- "pwm_spindle_aux": 2,
- "sdcard": 1,
- "i2c": 1
+ "trinamic_spi_chain": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -189,7 +216,9 @@
"digital_in": 1,
"serial_ports": 2,
"estop": 0,
- "sdcard": 1
+ "sdcard": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -203,7 +232,9 @@
"digital_in": 1,
"serial_ports": 2,
"estop": 0,
- "sdcard": 1
+ "sdcard": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -229,7 +260,9 @@
"axes": 3,
"digital_in": 1,
"serial_ports": 1,
- "sdcard": 1
+ "sdcard": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -241,7 +274,9 @@
"axes": 3,
"serial_ports": 2,
"digital_in": 1,
- "sdcard": 1
+ "sdcard": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
},
{
@@ -256,7 +291,9 @@
"eeprom": 1,
"fram": 1,
"i2c": 1,
- "sdcard": 1
+ "sdcard": 1,
+ "wifi": 1,
+ "bluetooth": 1
}
}
]
diff --git a/main/boards/BlackBoxX32_map.h b/main/boards/BlackBoxX32_map.h
index f16d121..e56ed58 100644
--- a/main/boards/BlackBoxX32_map.h
+++ b/main/boards/BlackBoxX32_map.h
@@ -7,18 +7,18 @@
Copyright (c) 2022 Peter van der Walt
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
Pin Definitions for the OpenBuilds BlackBox X32 Controller from https://openbuilds.com
@@ -28,6 +28,14 @@
#error "Axis configuration is not supported!"
#endif
+#if KEYPAD_ENABLE == 1
+#error No free pins for I2C keypad!
+#endif
+
+#if TRINAMIC_ENABLE
+#error BlackBox X32 does not use Trinamic drivers
+#endif
+
#define BOARD_NAME "BlackBox X32"
#define BOARD_URL "https://docs.openbuilds.com/doku.php?id=docs:blackbox-x32:start"
#if N_AUTO_SQUARED || N_AXIS > 3
@@ -72,12 +80,6 @@
#define Y_LIMIT_PIN GPIO_NUM_34
#define Z_LIMIT_PIN GPIO_NUM_39
-// Define probe switch input pin.
-// NOTE: probe input is not available when an auto-squared axis is enabled.
-#if PROBE_ENABLE
- #define PROBE_PIN GPIO_NUM_22
-#endif
-
// Define driver spindle pins
#if DRIVER_SPINDLE_PWM_ENABLE
@@ -103,10 +105,16 @@
#define COOLANT_FLOOD_PIN GPIO_NUM_21 // coolant
//#define COOLANT_MIST_PIN GPIO_NUM_21 // or mist
+// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
+
#define AUXINPUT0_PIN GPIO_NUM_0 // Mode button on front panel
#define AUXINPUT1_PIN GPIO_NUM_16
+#define AUXINPUT2_PIN GPIO_NUM_22
+
+#if PROBE_ENABLE
+ #define PROBE_PIN AUXINPUT2_PIN
+#endif
-// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
#if SAFETY_DOOR_ENABLE
#define SAFETY_DOOR_PIN AUXINPUT1_PIN
#endif
@@ -121,15 +129,3 @@
// #if SDCARD_ENABLE
#define PIN_NUM_CS GPIO_NUM_5
// #endif
-
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
-#error BlackBox X32 does not support Modbus
-#endif
-
-#if KEYPAD_ENABLE
-#error BlackBox X32 does not support Keypad
-#endif
-
-#if TRINAMIC_ENABLE
-#error BlackBox X32 does not use Trinamic drivers
-#endif
diff --git a/main/boards/bdring_i2s_6_axis_map.h b/main/boards/bdring_i2s_6_axis_map.h
index 8e215bb..70401eb 100644
--- a/main/boards/bdring_i2s_6_axis_map.h
+++ b/main/boards/bdring_i2s_6_axis_map.h
@@ -7,22 +7,26 @@
Copyright (c) 2020-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#define BOARD_NAME "BDRING 6-axis I2S"
+#if KEYPAD_ENABLE == 1
+#error No free pins for I2C keypad!
+#endif
+
#define USE_I2S_OUT
#define I2S_OUT_PIN_BASE 64
@@ -117,11 +121,17 @@
// N/A
+#define AUXINPUT0_PIN GPIO_NUM_25
+
+#if PROBE_ENABLE
+#define PROBE_PIN AUXINPUT0_PIN
+#endif
+
#if TRINAMIC_SPI_ENABLE
#define MOTOR_CS_PIN I2SO(3)
#endif
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
+#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_15
#define UART2_TX_PIN GPIO_NUM_14
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
@@ -129,11 +139,5 @@
#endif
#endif
-// Define probe switch input pin.
-#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_25
-#endif
-#if KEYPAD_ENABLE
-#error No free pins for keypad!
-#endif
+
diff --git a/main/boards/bdring_i2s_6pack_ext_v2_map.h b/main/boards/bdring_i2s_6pack_ext_v2_map.h
index 680ffd9..42375d0 100644
--- a/main/boards/bdring_i2s_6pack_ext_v2_map.h
+++ b/main/boards/bdring_i2s_6pack_ext_v2_map.h
@@ -7,18 +7,18 @@
Copyright (c) 2020-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#define BOARD_NAME "BDRING 6-Pack External drives V2.0"
@@ -110,7 +110,13 @@
// N/A
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
+#define AUXINPUT0_PIN GPIO_NUM_25
+
+#if PROBE_ENABLE
+#define PROBE_PIN AUXINPUT0_PIN
+#endif
+
+#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_15
#define UART2_TX_PIN GPIO_NUM_14
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
@@ -118,11 +124,6 @@
#endif
#endif
-// Define probe switch input pin.
-#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_25
-#endif
-
#if KEYPAD_ENABLE
#error No free pins for keypad!
#endif
diff --git a/main/boards/bdring_v3.5_map.h b/main/boards/bdring_v3.5_map.h
index d1f8f56..54d2363 100644
--- a/main/boards/bdring_v3.5_map.h
+++ b/main/boards/bdring_v3.5_map.h
@@ -7,18 +7,18 @@
Copyright (c) 2020-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#if N_ABC_MOTORS > 0
@@ -67,8 +67,6 @@
#define AUXOUTPUT1_PIN GPIO_NUM_22
#endif
-#define AUXINPUT0_PIN GPIO_NUM_35
-
// Define flood and mist coolant enable output pins.
// N/A
@@ -77,13 +75,16 @@
#define RESET_PIN GPIO_NUM_34
#define FEED_HOLD_PIN GPIO_NUM_36
#define CYCLE_START_PIN GPIO_NUM_39
-#if SAFETY_DOOR_ENABLE
-#define SAFETY_DOOR_PIN AUXINPUT0_PIN
-#endif
-// Define probe switch input pin.
+#define AUXINPUT0_PIN GPIO_NUM_35
+#define AUXINPUT1_PIN GPIO_NUM_32
+
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_32
+#define PROBE_PIN AUXINPUT1_PIN
+#endif
+
+#if SAFETY_DOOR_ENABLE
+#define SAFETY_DOOR_PIN AUXINPUT0_PIN
#endif
#if SDCARD_ENABLE
diff --git a/main/boards/bdring_v4_map.h b/main/boards/bdring_v4_map.h
index 4126f57..675f06b 100644
--- a/main/boards/bdring_v4_map.h
+++ b/main/boards/bdring_v4_map.h
@@ -7,24 +7,28 @@
Copyright (c) 2020-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#if N_ABC_MOTORS > 0
#error "Axis configuration is not supported!"
#endif
+#if KEYPAD_ENABLE == 1
+#error No free pins for I2C keypad!
+#endif
+
#define BOARD_NAME "BDRING v4"
// timer definitions
@@ -59,8 +63,6 @@
#define SPINDLE_ENABLE_PIN GPIO_NUM_22
#endif
-#define AUXINPUT0_PIN GPIO_NUM_35
-
// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PIN GPIO_NUM_25
@@ -72,13 +74,16 @@
#define RESET_PIN GPIO_NUM_34
#define FEED_HOLD_PIN GPIO_NUM_36
#define CYCLE_START_PIN GPIO_NUM_39
-#if SAFETY_DOOR_ENABLE
-#define SAFETY_DOOR_PIN AUXINPUT0_PIN
-#endif
-// Define probe switch input pin.
+#define AUXINPUT0_PIN GPIO_NUM_35
+#define AUXINPUT1_PIN GPIO_NUM_32
+
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_32
+#define PROBE_PIN AUXINPUT1_PIN
+#endif
+
+#if SAFETY_DOOR_ENABLE
+#define SAFETY_DOOR_PIN AUXINPUT0_PIN
#endif
#if SDCARD_ENABLE
@@ -91,7 +96,7 @@
#define PIN_NUM_CS GPIO_NUM_5
#endif
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
+#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_22
#define UART2_TX_PIN GPIO_NUM_21
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
@@ -99,6 +104,3 @@
#endif
#endif
-#if KEYPAD_ENABLE
-#error No free pins for keypad!
-#endif
diff --git a/main/boards/cnc3040_map.h b/main/boards/cnc3040_map.h
index 86179e4..c12ebba 100644
--- a/main/boards/cnc3040_map.h
+++ b/main/boards/cnc3040_map.h
@@ -5,26 +5,34 @@
Part of grblHAL
- Copyright (c) 2021-2022 Terje Io
+ Copyright (c) 2021-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#if N_ABC_MOTORS > 1
#error "Axis configuration is not supported!"
#endif
+#if KEYPAD_ENABLE == 1
+#error No free pins for I2C keypad!
+#endif
+
+#if SDCARD_ENABLE
+#error SD card not supported!
+#endif
+
#define BOARD_NAME "CNC3040 4-axis CNC"
#define BOARD_URL "https://github.com/shaise/GrblCNC/tree/master/Hardware/GrblCnc3040"
@@ -32,19 +40,9 @@
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0
-#if MODBUS_ENABLE
-#error VFD Spindle not supported!
-#endif
-
-#if KEYPAD_ENABLE == 2
-#define UART2_TX_PIN GPIO_NUM_17
-#define UART2_RX_PIN GPIO_NUM_16
-#elif KEYPAD_ENABLE == 1
-#error I2C Keypad not supported!
-#endif
-
-#if SDCARD_ENABLE
-#error SD card not supported!
+#ifdef ADD_SERIAL2
+#define UART2_TX_PIN GPIO_NUM_17
+#define UART2_RX_PIN GPIO_NUM_16
#endif
// Define step pulse output pins.
@@ -75,15 +73,15 @@
// Define driver spindle pins
#if DRIVER_SPINDLE_PWM_ENABLE
-#define SPINDLE_PWM_PIN GPIO_NUM_21
+#define SPINDLE_PWM_PIN GPIO_NUM_21
#else
-#define AUXOUTPUT0_PIN GPIO_NUM_21
+#define AUXOUTPUT0_PIN GPIO_NUM_21
#endif
#if DRIVER_SPINDLE_ENABLE
-#define SPINDLE_ENABLE_PIN GPIO_NUM_2
+#define SPINDLE_ENABLE_PIN GPIO_NUM_2
#else
-#define AUXOUTPUT1_PIN GPIO_NUM_2
+#define AUXOUTPUT1_PIN GPIO_NUM_2
#endif
// Define flood and mist coolant enable output pins.
@@ -94,14 +92,13 @@
// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
// N/A
-// Define probe switch input pin.
+#define AUXINPUT0_PIN GPIO_NUM_35 // ATC Door
+#define AUXINPUT1_PIN GPIO_NUM_25
+
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_19
+#define PROBE_PIN AUXINPUT1_PIN
#endif
#if SAFETY_DOOR_ENABLE
-#define SAFETY_DOOR_PIN GPIO_NUM_35 // ATC Door
-#else
-#define AUXINPUT0_PIN GPIO_NUM_35 // ATC Door
+#define SAFETY_DOOR_PIN AUXINPUT0_PIN // ATC Door
#endif
-
diff --git a/main/boards/cnc_boosterpack_map.h b/main/boards/cnc_boosterpack_map.h
index 0adc1d7..1e3b73d 100644
--- a/main/boards/cnc_boosterpack_map.h
+++ b/main/boards/cnc_boosterpack_map.h
@@ -7,18 +7,18 @@
Copyright (c) 2020-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#if N_ABC_MOTORS > 0
#error "Axis configuration is not supported!"
@@ -39,8 +39,8 @@
#endif
#if !EEPROM_ENABLE
-#undef EEPROM_ENABLE
-#define EEPROM_ENABLE 1 // I2C EEPROM (24LC16) support.
+//#undef EEPROM_ENABLE
+//#define EEPROM_ENABLE 1 // I2C EEPROM (24LC16) support.
#endif
#if !IOEXPAND_ENABLE
@@ -90,36 +90,48 @@
#define COOLANT_FLOOD_PIN IOEXPAND
#define COOLANT_MIST_PIN IOEXPAND
+#ifdef ADD_SERIAL2
+#define UART2_RX_PIN GPIO_NUM_33
+#else
+#define AUXINPUT0_PIN GPIO_NUM_33
+#endif
#define AUXINPUT1_PIN GPIO_NUM_34
+#define AUXINPUT2_PIN GPIO_NUM_13
// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
#define RESET_PIN GPIO_NUM_35
#define FEED_HOLD_PIN GPIO_NUM_39
#define CYCLE_START_PIN GPIO_NUM_36
-#if SAFETY_DOOR_ENABLE
-#define SAFETY_DOOR_PIN AUXINPUT1_PIN
-#endif
// Define probe switch input pin.
-#define PROBE_PIN GPIO_NUM_13
+#if PROBE_ENABLE
+#define PROBE_PIN AUXINPUT2_PIN
+#endif
-#if I2C_STROBE_ENABLE
-#define I2C_STROBE_PIN GPIO_NUM_33
-#else
-#define AUXINPUT0_PIN GPIO_NUM_33
+#if SAFETY_DOOR_ENABLE
+#define SAFETY_DOOR_PIN AUXINPUT1_PIN
#endif
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
-#define UART2_RX_PIN GPIO_NUM_33
-#define UART2_TX_PIN GPIO_NUM_25
-#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
-#define MODBUS_DIRECTION_PIN GPIO_NUM_25
+#if I2C_STROBE_ENABLE && defined(AUXINPUT0_PIN)
+#define I2C_STROBE_PIN AUXINPUT0_PIN
#endif
+
+#if NEOPIXELS_ENABLE && !I2C_STROBE_ENABLE && defined(AUXINPUT0_PIN)
+#define NEOPIXELS_PIN AUXINPUT0_PIN
+#define NEOPIXELS_NUM NEOPIXELS_ENABLE
#endif
+#ifdef ADD_SERIAL2
#if MPG_MODE == 1
-#define UART2_RX_PIN GPIO_NUM_33
#define MPG_ENABLE_PIN GPIO_NUM_25
+#else
+#define UART2_TX_PIN GPIO_NUM_25
+#endif
+#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
+#define MODBUS_DIRECTION_PIN GPIO_NUM_25 //??
+#endif
+#else
+#define AUXOUTPUT0_PIN GPIO_NUM_25
#endif
// Define I2C port/pins
diff --git a/main/boards/cnc_boosterpack_s3_map.h b/main/boards/cnc_boosterpack_s3_map.h
index 6a0611d..0f3bf00 100644
--- a/main/boards/cnc_boosterpack_s3_map.h
+++ b/main/boards/cnc_boosterpack_s3_map.h
@@ -7,19 +7,20 @@
Copyright (c)2023-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
+
#if N_ABC_MOTORS > 0
#error "Axis configuration is not supported!"
#endif
@@ -104,7 +105,7 @@
#define AUXINPUT0_PIN GPIO_NUM_33
#endif
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
+#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_33
#define UART2_TX_PIN GPIO_NUM_25
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
diff --git a/main/boards/espduino-32_wemos_d1_r32_uno_map.h b/main/boards/espduino-32_wemos_d1_r32_uno_map.h
index aa501c2..a3743cf 100644
--- a/main/boards/espduino-32_wemos_d1_r32_uno_map.h
+++ b/main/boards/espduino-32_wemos_d1_r32_uno_map.h
@@ -85,12 +85,13 @@
#define FEED_HOLD_PIN GPIO_NUM_4
#define CYCLE_START_PIN GPIO_NUM_35
-// Define probe switch input pin.
+#define AUXINPUT0_PIN GPIO_NUM_39
+
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_39
+#define PROBE_PIN AUXINPUT0_PIN
#endif
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
+#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_33
#define UART2_TX_PIN GPIO_NUM_32
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
diff --git a/main/boards/fysetc_e4_map.h b/main/boards/fysetc_e4_map.h
index 3336f87..156327e 100644
--- a/main/boards/fysetc_e4_map.h
+++ b/main/boards/fysetc_e4_map.h
@@ -3,20 +3,20 @@
Part of grblHAL
- Copyright (c) 2020-2022 Terje Io
+ Copyright (c) 2020-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#if N_ABC_MOTORS > 1
@@ -27,6 +27,10 @@
#error "Fystec E4 board does not have support for VFD spindle."
#endif
+#if KEYPAD_ENABLE
+#error No free pins for I2C keypad!
+#endif
+
#define BOARD_NAME "Fysetc E4 v1.0"
// timer definitions
@@ -87,33 +91,24 @@
#define RESET_PIN GPIO_NUM_34
#define FEED_HOLD_PIN GPIO_NUM_36
#define CYCLE_START_PIN GPIO_NUM_39
-#if SAFETY_DOOR_ENABLE
-#if !I2C_ENABLE
-#define SAFETY_DOOR_PIN GPIO_NUM_22
-#else
-#warning No free pin for safety door input!
-#endif
-#endif
-// Define probe switch input pin.
-#if PROBE_ENABLE
-#if !I2C_ENABLE
-#define PROBE_PIN GPIO_NUM_21
+#if I2C_ENABLE
+// Define I2C port/pins
+#define I2C_PORT I2C_NUM_1
+#define I2C_SDA GPIO_NUM_21
+#define I2C_SCL GPIO_NUM_22
+#define I2C_CLOCK 100000
#else
-#warning No free pin for probe input!
-#endif
+#define AUXINPUT0_PIN GPIO_NUM_21
+#define AUXINPUT1_PIN GPIO_NUM_22
#endif
-#if KEYPAD_ENABLE
-#error No free pins for keypad!
+#if PROBE_ENABLE && defined(AUXINPUT0_PIN)
+#define PROBE_PIN AUXINPUT0_PIN
#endif
-#if I2C_ENABLE
-// Define I2C port/pins
-#define I2C_PORT I2C_NUM_1
-#define I2C_SDA GPIO_NUM_21
-#define I2C_SCL GPIO_NUM_22
-#define I2C_CLOCK 100000
+#if SAFETY_DOOR_ENABLE && defined(AUXINPUT1_PIN)
+#define SAFETY_DOOR_PIN AUXINPUT1_PIN
#endif
#if SDCARD_ENABLE
diff --git a/main/boards/generic_map.h b/main/boards/generic_map.h
index a9acb13..e443301 100644
--- a/main/boards/generic_map.h
+++ b/main/boards/generic_map.h
@@ -1,109 +1,120 @@
/*
-Driver code for ESP32
+ generic_map.h - driver code for ESP32
-Part of grblHAL
+ Part of grblHAL
-Copyright (c) 2020-2023 Terje Io
+ Copyright (c) 2020-2023 Terje Io
-Grbl is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+ grblHAL is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
-Grbl is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ grblHAL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with Grbl. If not, see http://www.gnu.org/licenses/.
+ You should have received a copy of the GNU General Public License
+ along with grblHAL. If not, see .
*/
-#if VFD_SPINDLE
-#error "Board RDS does not have support for VFD spindle."
+#if N_ABC_MOTORS > 0
+#error "Axis configuration is not supported!"
#endif
-#define BOARD_NAME "RDS"
#if VFD_SPINDLE
#error "Generic map does not have support for VFD spindle."
#endif
-#define USE_I2S_OUT
-#define I2S_OUT_BCK GPIO_NUM_13
-#define I2S_OUT_WS GPIO_NUM_12
-#define I2S_OUT_DATA GPIO_NUM_14
+#if KEYPAD_ENABLE == 1
+#error No free pins for I2C keypad!
+#endif
// timer definitions
-#define STEP_TIMER_GROUP TIMER_GROUP_0
-#define STEP_TIMER_INDEX TIMER_0
+#define STEP_TIMER_GROUP TIMER_GROUP_0
+#define STEP_TIMER_INDEX TIMER_0
-// Define step pulse output pin27
-#define X_STEP_PIN I2SO(1)
-#define Y_STEP_PIN I2SO(3)
-#define Z_STEP_PIN I2SO(5)
+// Define step pulse output pins.
+#define X_STEP_PIN GPIO_NUM_12
+#define Y_STEP_PIN GPIO_NUM_14
+#define Z_STEP_PIN GPIO_NUM_27
// Define step direction output pins. NOTE: All direction pins must be on the same port.
-#define X_DIRECTION_PIN I2SO(2)
-#define Y_DIRECTION_PIN I2SO(4)
-#define Z_DIRECTION_PIN I2SO(6)
+#define X_DIRECTION_PIN GPIO_NUM_26
+#define Y_DIRECTION_PIN GPIO_NUM_25
+#define Z_DIRECTION_PIN GPIO_NUM_33
// Define stepper driver enable/disable output pin(s).
-#define STEPPERS_ENABLE_PIN GPIO_NUM_27
+#define STEPPERS_ENABLE_PIN GPIO_NUM_13
// Define homing/hard limit switch input pins and limit interrupt vectors.
-#define X_LIMIT_PIN GPIO_NUM_33
-#define Y_LIMIT_PIN GPIO_NUM_32
-#define Z_LIMIT_PIN GPIO_NUM_35
-
-#if N_ABC_MOTORS >= 1
-#define M3_AVAILABLE
-#define M3_STEP_PIN I2SO(7)
-#define M3_DIRECTION_PIN I2SO(0)
-#define M3_LIMIT_PIN GPIO_NUM_34
+#define X_LIMIT_PIN GPIO_NUM_2
+#define Y_LIMIT_PIN GPIO_NUM_4
+#define Z_LIMIT_PIN GPIO_NUM_15
+
+#if DRIVER_SPINDLE_ENABLE
+// Define spindle enable and spindle direction output pins.
+#define SPINDLE_ENABLE_PIN GPIO_NUM_18
+#define SPINDLE_DIRECTION_PIN GPIO_NUM_5
+#define SPINDLEPWMPIN GPIO_NUM_17
#endif
// Define driver spindle pins
#if DRIVER_SPINDLE_PWM_ENABLE
-#define SPINDLE_PWM_PIN GPIO_NUM_2
+#define SPINDLE_PWM_PIN GPIO_NUM_17
#else
-#define AUXOUTPUT0_PIN GPIO_NUM_2
+#define AUXOUTPUT0_PIN GPIO_NUM_17
+#endif
+
+#if DRIVER_SPINDLE_DIR_ENABLE
+#define SPINDLE_DIRECTION_PIN GPIO_NUM_5
+#else
+#define AUXOUTPUT1_PIN GPIO_NUM_5
#endif
#if DRIVER_SPINDLE_ENABLE
-#define SPINDLE_ENABLE_PIN GPIO_NUM_4
+#define SPINDLE_ENABLE_PIN GPIO_NUM_18
#else
-#define AUXOUTPUT2_PIN GPIO_NUM_4
+#define AUXOUTPUT2_PIN GPIO_NUM_18
#endif
// Define flood and mist coolant enable output pins.
-#define COOLANT_FLOOD_PIN GPIO_NUM_15
-#define COOLANT_MIST_PIN I2SO(11)
+
+#define COOLANT_FLOOD_PIN GPIO_NUM_16
+#define COOLANT_MIST_PIN GPIO_NUM_21
// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
-//#define RESET_PIN GPIO_NUM_34
-//#define FEED_HOLD_PIN GPIO_NUM_36
-//#define CYCLE_START_PIN GPIO_NUM_39
-#if SAFETY_DOOR_ENABLE
-#define SAFETY_DOOR_PIN GPIO_NUM_25
-#endif
+#define RESET_PIN GPIO_NUM_34
+#define FEED_HOLD_PIN GPIO_NUM_36
+#define CYCLE_START_PIN GPIO_NUM_39
+
+#define AUXINPUT0_PIN GPIO_NUM_35
+#define AUXINPUT1_PIN GPIO_NUM_32
-// Define probe switch input pin.
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_26
+#define PROBE_PIN AUXINPUT1_PIN
#endif
-#if KEYPAD_ENABLE
-#error No free pins for keypad!
+#if SAFETY_DOOR_ENABLE
+#define SAFETY_DOOR_PIN AUXINPUT0_PIN
+#endif
+
+#if I2C_ENABLE
+// Define I2C port/pins
+#define I2C_PORT I2C_NUM_1
+#define I2C_SDA GPIO_NUM_21
+#define I2C_SCL GPIO_NUM_22
+#define I2C_CLOCK 100000
#endif
#if SDCARD_ENABLE
// Pin mapping when using SPI mode.
// With this mapping, SD card can be used both in SPI and 1-line SD mode.
// Note that a pull-up on CS line is required in SD mode.
-#define PIN_NUM_MISO GPIO_NUM_19
-#define PIN_NUM_MOSI GPIO_NUM_23
-#define PIN_NUM_CLK GPIO_NUM_18
-#define PIN_NUM_CS GPIO_NUM_5
+#define PIN_NUM_MISO GPIO_NUM_19
+#define PIN_NUM_MOSI GPIO_NUM_23
+#define PIN_NUM_CLK GPIO_NUM_18
+#define PIN_NUM_CS GPIO_NUM_5
#endif
-
diff --git a/main/boards/jackpot_map.h b/main/boards/jackpot_map.h
index 57596ea..3076481 100644
--- a/main/boards/jackpot_map.h
+++ b/main/boards/jackpot_map.h
@@ -7,23 +7,27 @@
Copyright (c) 2023 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#define BOARD_NAME "Jackpot"
#define BOARD_URL "https://docs.v1e.com/electronics/jackpot/"
+#if KEYPAD_ENABLE == 1
+#error No free pins for I2C keypad!
+#endif
+
#define USE_I2S_OUT
#define I2S_OUT_PIN_BASE 64
@@ -106,6 +110,12 @@
// N/A
+#define AUXINPUT0_PIN GPIO_NUM_36
+
+#if PROBE_ENABLE
+#define PROBE_PIN AUXINPUT0_PIN
+#endif
+
#define AUXOUTPUT0_PIN GPIO_NUM_26
#define AUXOUTPUT1_PIN GPIO_NUM_27
@@ -120,16 +130,7 @@
#define PIN_NUM_CS GPIO_NUM_5
#endif
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
-#define UART2_RX_PIN GPIO_NUM_4
-#define UART2_TX_PIN GPIO_NUM_0
-#endif
-
-// Define probe switch input pin.
-#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_36
-#endif
-
-#if KEYPAD_ENABLE
-#error No free pins for keypad!
+#ifdef ADD_SERIAL2
+#define UART2_RX_PIN GPIO_NUM_4
+#define UART2_TX_PIN GPIO_NUM_0
#endif
diff --git a/main/boards/mks_dlc32_2_0_map.h b/main/boards/mks_dlc32_2_0_map.h
index e59e30f..614a430 100644
--- a/main/boards/mks_dlc32_2_0_map.h
+++ b/main/boards/mks_dlc32_2_0_map.h
@@ -8,18 +8,18 @@
Copyright (c) 2023 Terje Io
Copyright (c) 2022 Lucio Tarantino
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#if VFD_SPINDLE
@@ -97,16 +97,18 @@
#endif
#define AUXINPUT0_PIN GPIO_NUM_33 // EXP_1,8 (LCD_RS)
-#define AUXOUTPUT0_PIN GPIO_NUM_25 // EXP_1,7 (LCD_CS_0)
-#define AUXOUTPUT1_PIN GPIO_NUM_26 // EXP_1,5 (LCD_TOUCH_CS_0)
-#define AUXOUTPUT2_PIN GPIO_NUM_27 // EXP_1,4 (LCD_RST_0)
-#define AUXOUTPUT3_PIN GPIO_NUM_5 // EXP_1,3 (LCD_EN_0)
+#define AUXINPUT1_PIN GPIO_NUM_22
// Define probe switch input pin.
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_22
+#define PROBE_PIN AUXINPUT1_PIN
#endif
+#define AUXOUTPUT0_PIN GPIO_NUM_25 // EXP_1,7 (LCD_CS_0)
+#define AUXOUTPUT1_PIN GPIO_NUM_26 // EXP_1,5 (LCD_TOUCH_CS_0)
+#define AUXOUTPUT2_PIN GPIO_NUM_27 // EXP_1,4 (LCD_RST_0)
+#define AUXOUTPUT3_PIN GPIO_NUM_5 // EXP_1,3 (LCD_EN_0)
+
#if I2C_ENABLE
// Define I2C port/pins
#define I2C_SDA GPIO_NUM_0
diff --git a/main/boards/mks_tinybee_1_0_map.h b/main/boards/mks_tinybee_1_0_map.h
index db35c72..f4a3610 100644
--- a/main/boards/mks_tinybee_1_0_map.h
+++ b/main/boards/mks_tinybee_1_0_map.h
@@ -8,27 +8,34 @@
Copyright (c) 2022 Ennio Sesana
Copyright (c) 2023-2024 Terje Io (added SD card, ModBus and MPG options)
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#define BOARD_NAME "MKS Tinybee V1.0"
#define BOARD_URL "https://github.com/makerbase-mks/MKS-TinyBee"
+#if N_ABC_MOTORS > 2
+#error "Axis configuration is not supported!"
+#endif
+
+#if KEYPAD_ENABLE == 1
+#error "No free pins for I2C keypad!"
+#endif
+
#define USE_I2S_OUT
#define I2S_OUT_PIN_BASE 64
-//#define SERIAL2_ENABLE 1
#define UART2_RX_PIN GPIO_NUM_16 // EXP_1
#define UART2_TX_PIN GPIO_NUM_17 // EXP_1
@@ -55,19 +62,25 @@
#define Z_ENABLE_PIN I2SO(6)
#define Z_LIMIT_PIN GPIO_NUM_22
+#if PROBE_ENABLE || N_ABC_MOTORS == 0
+#define AUXINPUT1_PIN GPIO_NUM_35 // MT_DET
+#endif
+
#if N_ABC_MOTORS >= 1
#define M3_AVAILABLE // E0
#define M3_STEP_PIN I2SO(10)
#define M3_DIRECTION_PIN I2SO(11)
#define M3_ENABLE_PIN I2SO(9)
-#if SDCARD_ENABLE
+#ifndef AUXINPUT1_PIN
+#define M3_LIMIT_PIN GPIO_NUM_35 // MT_DET
+#elif SDCARD_ENABLE
#define M3_LIMIT_PIN GPIO_NUM_12 // EXP2
#else
#define M3_LIMIT_PIN GPIO_NUM_19 // EXP2
#endif
#endif
-#if N_ABC_MOTORS >= 2
+#if N_ABC_MOTORS == 2
#define M4_AVAILABLE // E1
#define M4_STEP_PIN I2SO(13)
#define M4_DIRECTION_PIN I2SO(14)
@@ -79,6 +92,8 @@
#endif
#endif
+#define AUXINPUT0_PIN GPIO_NUM_39 // TB
+
// Define driver spindle pins
#if DRIVER_SPINDLE_PWM_ENABLE
@@ -108,13 +123,14 @@
#define CYCLE_START_PIN GPIO_NUM_36 // TH1
#define FEED_HOLD_PIN GPIO_NUM_34 // TH2
//#define RESET_PIN (use board hardware)
-#if SAFETY_DOOR_ENABLE
-#define SAFETY_DOOR_PIN GPIO_NUM_39 // TB
-#endif
// Define probe switch input pin.
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_35 // MT_DET
+#define PROBE_PIN AUXINPUT1_PIN // MT_DET
+#endif
+
+#if SAFETY_DOOR_ENABLE
+#define SAFETY_DOOR_PIN AUXINPUT0_PIN // TB
#endif
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
diff --git a/main/boards/protoneer_3.xx_map.h b/main/boards/protoneer_3.xx_map.h
index 7111c17..256f1a1 100644
--- a/main/boards/protoneer_3.xx_map.h
+++ b/main/boards/protoneer_3.xx_map.h
@@ -7,18 +7,18 @@
Copyright (c) 2021 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#if N_ABC_MOTORS > 0
@@ -85,7 +85,8 @@
#define FEED_HOLD_PIN GPIO_NUM_4 // A1
#define CYCLE_START_PIN GPIO_NUM_35 // A2
-// Define probe switch input pin.
+#define AUXINPUT0_PIN GPIO_NUM_39 // A5
+
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_39 // A5
+#define PROBE_PIN AUXINPUT0_PIN
#endif
diff --git a/main/boards/root_cnc_v2_map.h b/main/boards/root_cnc_v2_map.h
index ad91b42..5db27fe 100644
--- a/main/boards/root_cnc_v2_map.h
+++ b/main/boards/root_cnc_v2_map.h
@@ -7,23 +7,27 @@
Copyright (c) 2023 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#define BOARD_NAME "Root CNC v2.x"
#define BOARD_URL "https://wiki.rootcnc.com/en/Root-Controller-ISO/DetailedInfo"
+#if KEYPAD_ENABLE == 1
+#error No free pins for I2C keypad!
+#endif
+
#define USE_I2S_OUT
#define I2S_OUT_PIN_BASE 64
@@ -119,7 +123,7 @@
// N/A
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
+#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_16
#define UART2_TX_PIN GPIO_NUM_17
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
@@ -127,11 +131,8 @@
#endif
#endif
-// Define probe switch input pin.
-#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_27
-#endif
+#define AUXINPUT0_PIN GPIO_NUM_27
-#if KEYPAD_ENABLE
-#error No free pins for keypad!
+#if PROBE_ENABLE
+#define PROBE_PIN AUXINPUT0_PIN
#endif
diff --git a/main/boards/root_cnc_v3_map.h b/main/boards/root_cnc_v3_map.h
index b7b2aa3..4bff6ad 100644
--- a/main/boards/root_cnc_v3_map.h
+++ b/main/boards/root_cnc_v3_map.h
@@ -7,23 +7,27 @@
Copyright (c) 2023 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#define BOARD_NAME "Root CNC v3"
#define BOARD_URL "https://wiki.rootcnc.com/en/Root-Controller-ISO/DetailedInfo"
+#if KEYPAD_ENABLE == 1
+#error No free pins for I2C keypad!
+#endif
+
#define USE_I2S_OUT
#define I2S_OUT_PIN_BASE 64
@@ -119,7 +123,7 @@
// N/A
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
+#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_16
#define UART2_TX_PIN GPIO_NUM_17
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
@@ -127,11 +131,8 @@
#endif
#endif
-// Define probe switch input pin.
-#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_2
-#endif
+#define AUXINPUT0_PIN GPIO_NUM_2
-#if KEYPAD_ENABLE
-#error No free pins for keypad!
+#if PROBE_ENABLE
+#define PROBE_PIN AUXINPUT0_PIN
#endif
diff --git a/main/boards/sourcerabbit_4axis.h b/main/boards/sourcerabbit_4axis.h
index 4042b5f..b39f207 100644
--- a/main/boards/sourcerabbit_4axis.h
+++ b/main/boards/sourcerabbit_4axis.h
@@ -7,18 +7,18 @@
Copyright (c) 2021-2022 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#if N_ABC_MOTORS > 1
@@ -97,6 +97,12 @@
#endif
#endif
+#ifdef BOARD_SOURCERABBIT_4AXIS_12
+#define AUXINPUT1_PIN GPIO_NUM_5 // ATC Door
+#define AUXOUTPUT0_PIN GPIO_NUM_19 // ATC Lock
+#define AUXOUTPUT1_PIN GPIO_NUM_18 // ATC Blow
+#endif
+
// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PIN GPIO_NUM_22
@@ -105,17 +111,12 @@
// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
// N/A
-// Define probe switch input pin.
+#define AUXINPUT0_PIN GPIO_NUM_32
+
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_32
+#define PROBE_PIN AUXINPUT0_PIN
#endif
-#ifdef BOARD_SOURCERABBIT_4AXIS_12
-#if SAFETY_DOOR_ENABLE
-#define SAFETY_DOOR_PIN GPIO_NUM_5 // ATC Door
-#else
-#define AUXINPUT0_PIN GPIO_NUM_5 // ATC Door
-#endif
-#define AUXOUTPUT0_PIN GPIO_NUM_19 // ATC Lock
-#define AUXOUTPUT1_PIN GPIO_NUM_18 // ATC Blow
+#if SAFETY_DOOR_ENABLE && defined(AUXINPUT1_PIN)
+#define SAFETY_DOOR_PIN AUXINPUT1_PIN
#endif
diff --git a/main/boards/xPro_v5_map.h b/main/boards/xPro_v5_map.h
index 25e69c9..b1f8ec6 100644
--- a/main/boards/xPro_v5_map.h
+++ b/main/boards/xPro_v5_map.h
@@ -7,24 +7,28 @@
Copyright (c) 2021-2022 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#if N_ABC_MOTORS > 1
#error "Axis configuration is not supported!"
#endif
+#if KEYPAD_ENABLE == 1
+#error No free pins for I2C keypad!
+#endif
+
#define BOARD_NAME "x-Pro v5"
#define HAS_BOARD_INIT
#if TRINAMIC_ENABLE != 5160
@@ -74,6 +78,7 @@
#define AUXINPUT0_PIN GPIO_NUM_13
#define AUXINPUT1_PIN GPIO_NUM_0
+#define AUXINPUT2_PIN GPIO_NUM_22
// Define flood and mist coolant enable output pins.
// Only one can be enabled!
@@ -86,7 +91,7 @@
// Define probe switch input pin.
#if PROBE_ENABLE
-#define PROBE_PIN GPIO_NUM_22
+#define PROBE_PIN AUXINPUT2_PIN
#endif
// Pin mapping when using SPI mode.
@@ -100,11 +105,7 @@
#define PIN_NUM_CS GPIO_NUM_5
#endif
-#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
+#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_25
#define UART2_TX_PIN GPIO_NUM_4
#endif
-
-#if KEYPAD_ENABLE
-#error No free pins for keypad!
-#endif
diff --git a/main/driver.c b/main/driver.c
index 8c12542..7b10b16 100644
--- a/main/driver.c
+++ b/main/driver.c
@@ -11,18 +11,18 @@
Copyright (c) 2011-2015 Sungeun K. Jeon
Copyright (c) 2009-2011 Simen Svale Skogsrud
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#include
@@ -49,6 +49,8 @@
#include "hal/gpio_types.h"
#include "xtensa/core-macros.h"
+#define AUX_DEVICES // until all drivers are converted?
+
#include "grbl/protocol.h"
#include "grbl/state_machine.h"
#include "grbl/motor_pins.h"
@@ -108,8 +110,6 @@ static spindle_id_t spindle_id = -1;
#if DRIVER_SPINDLE_PWM_ENABLE
-#define pwm(s) ((spindle_pwm_t *)s->context)
-
static uint32_t pwm_max_value;
static bool pwmEnabled = false;
static spindle_pwm_t spindle_pwm;
@@ -165,9 +165,6 @@ typedef struct {
static pwm_ramp_t pwm_ramp;
#endif
-#if SAFETY_DOOR_ENABLE
-static input_signal_t *door_pin;
-#endif
static periph_signal_t *periph_pins = NULL;
static input_signal_t inputpin[] = {
@@ -184,45 +181,65 @@ static input_signal_t inputpin[] = {
#ifdef CYCLE_START_PIN
{ .id = Input_CycleStart, .pin = CYCLE_START_PIN, .group = PinGroup_Control },
#endif
-#if SAFETY_DOOR_BIT
- { .id = Input_SafetyDoor, .pin = SAFETY_DOOR_PIN, .group = PinGroup_Control },
-#endif
-#ifdef PROBE_PIN
- { .id = Input_Probe, .pin = PROBE_PIN, .group = PinGroup_Probe },
-#endif
#ifdef X_LIMIT_PIN
{ .id = Input_LimitX, .pin = X_LIMIT_PIN, .group = PinGroup_Limit },
#endif
#ifdef X2_LIMIT_PIN
{ .id = Input_LimitX_2, .pin = X2_LIMIT_PIN, .group = PinGroup_Limit },
#endif
+#ifdef X_LIMIT_PIN_MAX
+ { .id = Input_LimitX_Max, .pin = X_LIMIT_PIN_MAX, .group = PinGroup_LimitMax },
+#endif
#ifdef Y_LIMIT_PIN
{ .id = Input_LimitY, .pin = Y_LIMIT_PIN, .group = PinGroup_Limit },
#endif
#ifdef Y2_LIMIT_PIN
{ .id = Input_LimitY_2, .pin = Y2_LIMIT_PIN, .group = PinGroup_Limit },
#endif
+#ifdef Y_LIMIT_PIN_MAX
+ { .id = Input_LimitY_Max, .pin = Y_LIMIT_PIN_MAX, .group = PinGroup_LimitMax },
+#endif
#ifdef Z_LIMIT_PIN
{ .id = Input_LimitZ, .pin = Z_LIMIT_PIN, .group = PinGroup_Limit },
#endif
#ifdef Z2_LIMIT_PIN
{ .id = Input_LimitZ_2, .pin = Z2_LIMIT_PIN, .group = PinGroup_Limit },
#endif
+#ifdef Z_LIMIT_PIN_MAX
+ { .id = Input_LimitZ_Max, .pin = Z_LIMIT_PIN_MAX, .group = PinGroup_LimitMax },
+#endif
#ifdef A_LIMIT_PIN
{ .id = Input_LimitA, .pin = A_LIMIT_PIN, .group = PinGroup_Limit },
#endif
+#ifdef A_LIMIT_PIN_MAX
+ { .id = Input_LimitA_Max, .pin = A_LIMIT_PIN_MAX, .group = PinGroup_Limit },
+#endif
#ifdef B_LIMIT_PIN
{ .id = Input_LimitB, .pin = B_LIMIT_PIN, .group = PinGroup_Limit },
#endif
+#ifdef B_LIMIT_PIN_MAX
+ { .id = Input_LimitB_Max, .pin = B_LIMIT_PIN_MAX, .group = PinGroup_Limit },
+#endif
#ifdef C_LIMIT_PIN
{ .id = Input_LimitC, .pin = C_LIMIT_PIN, .group = PinGroup_Limit },
#endif
-#if MPG_MODE == 1
- { .id = Input_ModeSelect, .pin = MPG_ENABLE_PIN, .group = PinGroup_MPG },
+#ifdef C_LIMIT_PIN_MAX
+ { .id = Input_LimitC_Max, .pin = C_LIMIT_PIN_MAX, .group = PinGroup_Limit },
#endif
-#ifdef I2C_STROBE_PIN
+#ifndef AUX_DEVICES
+ #if SAFETY_DOOR_BIT
+ { .id = Input_SafetyDoor, .pin = SAFETY_DOOR_PIN, .group = PinGroup_Control },
+ #endif
+ #ifdef PROBE_PIN
+ { .id = Input_Probe, .pin = PROBE_PIN, .group = PinGroup_Probe },
+ #endif
+ #if MPG_MODE == 1
+ { .id = Input_ModeSelect, .pin = MPG_ENABLE_PIN, .group = PinGroup_MPG },
+ #endif
+ #ifdef I2C_STROBE_PIN
{ .id = Input_I2CStrobe, .pin = I2C_STROBE_PIN, .group = PinGroup_Keypad },
-#endif
+ #endif
+#endif // AUX_DEVICES
// Aux input pins must be consecutive in this array
#ifdef AUXINPUT0_PIN
{ .id = Input_Aux0, .pin = AUXINPUT0_PIN, .group = PinGroup_AuxInput },
@@ -413,28 +430,30 @@ static output_signal_t outputpin[] = {
};
static bool IOInitDone = false, rtc_started = false;
-static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED, debounce_mux = portMUX_INITIALIZER_UNLOCKED;
+static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
+static pin_group_pins_t limit_inputs = {0};
+static on_execute_realtime_ptr on_execute_realtime;
#if PROBE_ENABLE
static probe_state_t probe = {
.connected = On
};
#endif
-#ifdef SQUARING_ENABLED
-static axes_signals_t motors_1 = {AXES_BITMASK}, motors_2 = {AXES_BITMASK};
+#if IOEXPAND_ENABLE
+static ioexpand_t iopins = {0};
#endif
-#if USE_I2S_OUT
-static bool goIdlePending = false;
-static uint32_t i2s_step_length = I2S_OUT_USEC_PER_PULSE, i2s_delay_length = I2S_OUT_USEC_PER_PULSE, i2s_delay_samples = 1, i2s_step_samples = 1;
-static bool laser_mode = false;
-#if DRIVER_SPINDLE_ENABLE
-static on_spindle_selected_ptr on_spindle_selected;
+#ifdef NEOPIXELS_PIN
+neopixel_cfg_t neopixel = { .intensity = 255 };
#endif
-#endif // USE_I2S_OUT
-#if IOEXPAND_ENABLE
-static ioexpand_t iopins = {0};
+#if AUX_CONTROLS_ENABLED
+static uint8_t probe_port;
+#ifdef SAFETY_DOOR_PIN
+static pin_debounce_t debounce = {0};
+static input_signal_t *safety_door = NULL;
+#endif
+static void aux_irq_handler (uint8_t port, bool state);
#endif
#if I2C_STROBE_ENABLE
@@ -469,107 +488,7 @@ static void gpio_isr (void *arg);
#endif
static void stepper_driver_isr (void *arg);
-static TimerHandle_t xDelayTimer = NULL, debounceTimer = NULL;
-
-#if USE_I2S_OUT
-
-// Set stepper pulse output pins
-inline __attribute__((always_inline)) IRAM_ATTR static void i2s_set_step_outputs (axes_signals_t step_outbits_1);
-
-#else
-
-void initRMT (settings_t *settings)
-{
- rmt_item32_t rmtItem[2];
-
- rmt_config_t rmtConfig = {
- .rmt_mode = RMT_MODE_TX,
- .clk_div = 20,
- .mem_block_num = 1,
- .tx_config.loop_en = false,
- .tx_config.carrier_en = false,
- .tx_config.carrier_freq_hz = 0,
- .tx_config.carrier_duty_percent = 50,
- .tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW,
- .tx_config.idle_output_en = true
- };
-
- rmtItem[0].duration0 = (uint32_t)(settings->steppers.pulse_delay_microseconds > 0.0f ? 4.0f * settings->steppers.pulse_delay_microseconds : 1.0f);
- rmtItem[0].duration1 = (uint32_t)(4.0f * settings->steppers.pulse_microseconds);
- rmtItem[1].duration0 = 0;
- rmtItem[1].duration1 = 0;
-
-// hal.max_step_rate = 4000000UL / (rmtItem[0].duration0 + rmtItem[0].duration1); // + latency
-
- uint32_t channel;
- for(channel = 0; channel < (N_AXIS + N_GANGED); channel++) {
-
- rmtConfig.channel = channel;
-
- switch(channel) {
- case X_AXIS:
- rmtConfig.tx_config.idle_level = settings->steppers.step_invert.x;
- rmtConfig.gpio_num = X_STEP_PIN;
- break;
- case Y_AXIS:
- rmtConfig.tx_config.idle_level = settings->steppers.step_invert.y;
- rmtConfig.gpio_num = Y_STEP_PIN;
- break;
-#ifdef Z_STEP_PIN
- case Z_AXIS:
- rmtConfig.tx_config.idle_level = settings->steppers.step_invert.z;
- rmtConfig.gpio_num = Z_STEP_PIN;
- break;
-#endif
-#ifdef A_STEP_PIN
- case A_AXIS:
- rmtConfig.tx_config.idle_level = settings->steppers.step_invert.a;
- rmtConfig.gpio_num = A_STEP_PIN;
- break;
-#endif
-#ifdef B_STEP_PIN
- case B_AXIS:
- rmtConfig.tx_config.idle_level = settings->steppers.step_invert.b;
- rmtConfig.gpio_num = B_STEP_PIN;
- break;
-#endif
-#ifdef C_STEP_PIN
- case C_AXIS:
- rmtConfig.tx_config.idle_level = settings->steppers.step_invert.c;
- rmtConfig.gpio_num = C_STEP_PIN;
- break;
-#endif
-#ifdef X2_STEP_PIN
- case X2_MOTOR:
- rmtConfig.tx_config.idle_level = settings->steppers.step_invert.x;
- rmtConfig.gpio_num = X2_STEP_PIN;
- break;
-#endif
-#ifdef Y2_STEP_PIN
- case Y2_MOTOR:
- rmtConfig.tx_config.idle_level = settings->steppers.step_invert.y;
- rmtConfig.gpio_num = Y2_STEP_PIN;
- break;
-#endif
-#ifdef Z2_STEP_PIN
- case Z2_MOTOR:
- rmtConfig.tx_config.idle_level = settings->steppers.step_invert.z;
- rmtConfig.gpio_num = Z2_STEP_PIN;
- break;
-#endif
- }
-#ifndef Z_STEP_PIN
- if(channel == Z_AXIS)
- continue;
-#endif
- rmtItem[0].level0 = rmtConfig.tx_config.idle_level;
- rmtItem[0].level1 = !rmtConfig.tx_config.idle_level;
- rmt_config(&rmtConfig);
- rmt_fill_tx_items(rmtConfig.channel, &rmtItem[0], 2, 0);
- }
-}
-
-#endif
+static TimerHandle_t xDelayTimer = NULL;
void vTimerCallback (TimerHandle_t xTimer)
{
@@ -590,10 +509,13 @@ IRAM_ATTR static void driver_delay_ms (uint32_t ms, void (*callback)(void))
xTimerDelete(xDelayTimer, 3);
xDelayTimer = NULL;
}
- xDelayTimer = xTimerCreate("msDelay", pdMS_TO_TICKS(ms), pdFALSE, callback, vTimerCallback);
- xTimerStartFromISR(xDelayTimer, &xHigherPriorityTaskWoken);
- if(xHigherPriorityTaskWoken)
- portYIELD_FROM_ISR();
+ if(ms) {
+ xDelayTimer = xTimerCreate("msDelay", pdMS_TO_TICKS(ms), pdFALSE, callback, vTimerCallback);
+ xTimerStartFromISR(xDelayTimer, &xHigherPriorityTaskWoken);
+ if(xHigherPriorityTaskWoken)
+ portYIELD_FROM_ISR();
+ } else
+ callback();
} else {
if(xDelayTimer) {
xTimerDelete(xDelayTimer, 3);
@@ -607,71 +529,48 @@ IRAM_ATTR static void driver_delay_ms (uint32_t ms, void (*callback)(void))
}
}
-#if !CONFIG_IDF_TARGET_ESP32S3
-
-IRAM_ATTR static void delay_us (uint32_t us)
-{
-#if CONFIG_IDF_TARGET_ESP32S3
- int32_t t = XTHAL_GET_CCOUNT() + hal.f_mcu * us;
-
- while((XTHAL_GET_CCOUNT() - t) < 0) {
- __asm__ __volatile__ ("nop");
- }
-#else
- uint64_t start_time = esp_timer_get_time();
-
- while (esp_timer_get_time() - start_time < us) {
- __asm__ __volatile__ ("nop");
- }
-#endif
-}
-
-#endif
-
// Enable/disable steppers
static void stepperEnable (axes_signals_t enable)
{
enable.mask ^= settings.steppers.enable_invert.mask;
#if !TRINAMIC_MOTOR_ENABLE
- #if IOEXPAND_ENABLE // TODO: read from expander?
+ #if IOEXPAND_ENABLE // TODO: read from expander?
iopins.stepper_enable_x = enable.x;
iopins.stepper_enable_y = enable.y;
iopins.stepper_enable_z = enable.z;
ioexpand_out(iopins);
- #else
- #if defined(STEPPERS_ENABLE_PIN)
- DIGITAL_OUT(STEPPERS_ENABLE_PIN, enable.x);
- #else
- #ifdef X_ENABLE_PIN
- DIGITAL_OUT(X_ENABLE_PIN, enable.x);
- #endif
- #ifdef Y_ENABLE_PIN
- DIGITAL_OUT(Y_ENABLE_PIN, enable.y);
- #endif
- #ifdef Z_ENABLE_PIN
- DIGITAL_OUT(Z_ENABLE_PIN, enable.z);
- #endif
- #ifdef A_ENABLE_PIN
- DIGITAL_OUT(A_ENABLE_PIN, enable.a);
- #endif
- #ifdef B_ENABLE_PIN
- DIGITAL_OUT(B_ENABLE_PIN, enable.b);
- #endif
- #ifdef C_ENABLE_PIN
- DIGITAL_OUT(C_ENABLE_PIN, enable.c);
- #endif
- #ifdef X2_ENABLE_PIN
- DIGITAL_OUT(X2_ENABLE_PIN, enable.x);
- #endif
- #ifdef Y2_ENABLE_PIN
- DIGITAL_OUT(Y2_ENABLE_PIN, enable.y);
- #endif
- #ifdef Z2_ENABLE_PIN
- DIGITAL_OUT(Z2_ENABLE_PIN, enable.z);
- #endif
- #endif
+ #elif defined(STEPPERS_ENABLE_PIN)
+ DIGITAL_OUT(STEPPERS_ENABLE_PIN, enable.x);
+ #else
+ #ifdef X_ENABLE_PIN
+ DIGITAL_OUT(X_ENABLE_PIN, enable.x);
+ #endif
+ #ifdef X2_ENABLE_PIN
+ DIGITAL_OUT(X2_ENABLE_PIN, enable.x);
+ #endif
+ #ifdef Y_ENABLE_PIN
+ DIGITAL_OUT(Y_ENABLE_PIN, enable.y);
+ #endif
+ #ifdef Y2_ENABLE_PIN
+ DIGITAL_OUT(Y2_ENABLE_PIN, enable.y);
#endif
+ #ifdef Z_ENABLE_PIN
+ DIGITAL_OUT(Z_ENABLE_PIN, enable.z);
+ #endif
+ #ifdef Z2_ENABLE_PIN
+ DIGITAL_OUT(Z2_ENABLE_PIN, enable.z);
+ #endif
+ #ifdef A_ENABLE_PIN
+ DIGITAL_OUT(A_ENABLE_PIN, enable.a);
+ #endif
+ #ifdef B_ENABLE_PIN
+ DIGITAL_OUT(B_ENABLE_PIN, enable.b);
+ #endif
+ #ifdef C_ENABLE_PIN
+ DIGITAL_OUT(C_ENABLE_PIN, enable.c);
+ #endif
+ #endif
#endif
}
@@ -751,16 +650,60 @@ inline IRAM_ATTR static void set_dir_outputs (axes_signals_t dir_outbits)
#endif
}
+#ifdef SQUARING_ENABLED
+
+static axes_signals_t motors_1 = {AXES_BITMASK}, motors_2 = {AXES_BITMASK};
+
+// Enable/disable motors for auto squaring of ganged axes
+static void StepperDisableMotors (axes_signals_t axes, squaring_mode_t mode)
+{
+ motors_1.mask = (mode == SquaringMode_A || mode == SquaringMode_Both ? axes.mask : 0) ^ AXES_BITMASK;
+ motors_2.mask = (mode == SquaringMode_B || mode == SquaringMode_Both ? axes.mask : 0) ^ AXES_BITMASK;
+}
+
+#endif // SQUARING_ENABLED
+
#if USE_I2S_OUT
-IRAM_ATTR static void I2S_stepperCyclesPerTick (uint32_t cycles_per_tick)
+static bool goIdlePending = false;
+static uint32_t i2s_step_length = I2S_OUT_USEC_PER_PULSE, i2s_delay_length = I2S_OUT_USEC_PER_PULSE, i2s_delay_samples = 1, i2s_step_samples = 1;
+static bool laser_mode = false;
+#if DRIVER_SPINDLE_ENABLE
+static on_spindle_selected_ptr on_spindle_selected;
+#endif
+
+// Set stepper pulse output pins
+inline __attribute__((always_inline)) IRAM_ATTR static void i2s_set_step_outputs (axes_signals_t step_outbits_1);
+
+#if !CONFIG_IDF_TARGET_ESP32S3
+
+IRAM_ATTR static void delay_us (uint32_t us)
+{
+#if CONFIG_IDF_TARGET_ESP32S3
+ int32_t t = XTHAL_GET_CCOUNT() + hal.f_mcu * us;
+
+ while((XTHAL_GET_CCOUNT() - t) < 0) {
+ __asm__ __volatile__ ("nop");
+ }
+#else
+ uint64_t start_time = esp_timer_get_time();
+
+ while (esp_timer_get_time() - start_time < us) {
+ __asm__ __volatile__ ("nop");
+ }
+#endif
+}
+
+#endif // !CONFIG_IDF_TARGET_ESP32S3
+
+IRAM_ATTR static void I2SStepperCyclesPerTick (uint32_t cycles_per_tick)
{
i2s_out_set_pulse_period((cycles_per_tick < (1UL << 18) ? cycles_per_tick : (1UL << 18) - 1UL) / (hal.f_step_timer / 1000000));
}
// Sets stepper direction and pulse pins and starts a step pulse
// Called when in I2S stepping mode
-IRAM_ATTR static void I2S_stepperPulseStart (stepper_t *stepper)
+IRAM_ATTR static void I2SStepperPulseStart (stepper_t *stepper)
{
if(stepper->dir_change) {
set_dir_outputs(stepper->dir_outbits);
@@ -776,19 +719,15 @@ IRAM_ATTR static void I2S_stepperPulseStart (stepper_t *stepper)
}
// Starts stepper driver ISR timer and forces a stepper driver interrupt callback
-static void I2S_stepperWakeUp (void)
+static void I2SStepperWakeUp (void)
{
// Enable stepper drivers.
stepperEnable((axes_signals_t){AXES_BITMASK});
i2s_out_set_stepping();
}
-#endif // USE_I2S_OUT
-
#ifdef SQUARING_ENABLED
-#if USE_I2S_OUT
-
// Set stepper pulse output pins
inline __attribute__((always_inline)) IRAM_ATTR static void i2s_set_step_outputs (axes_signals_t step_outbits_1)
{
@@ -821,99 +760,22 @@ inline __attribute__((always_inline)) IRAM_ATTR static void i2s_set_step_outputs
#endif
}
-#else // RMT
+#else // !SQUARING_ENABLED
// Set stepper pulse output pins
-inline IRAM_ATTR static void set_step_outputs (axes_signals_t step_outbits_1)
+inline __attribute__((always_inline)) IRAM_ATTR static void i2s_set_step_outputs (axes_signals_t step_outbits)
{
- axes_signals_t step_outbits_2;
- step_outbits_2.mask = (step_outbits_1.mask & motors_2.mask) ^ settings.steppers.step_invert.mask;
- step_outbits_1.mask = (step_outbits_1.mask & motors_1.mask) ^ settings.steppers.step_invert.mask;
-
- if(step_outbits_1.x) {
- rmt_ll_tx_reset_pointer(&RMT, X_AXIS);
- rmt_ll_tx_start(&RMT, X_AXIS);
- }
+ step_outbits.value ^= settings.steppers.step_invert.mask;
+ DIGITAL_OUT(X_STEP_PIN, step_outbits.x);
+ DIGITAL_OUT(Y_STEP_PIN, step_outbits.y);
+#ifdef Z_STEP_PIN
+ DIGITAL_OUT(Z_STEP_PIN, step_outbits.z);
+#endif
#ifdef X2_STEP_PIN
- if(step_outbits_2.x) {
- rmt_ll_tx_reset_pointer(&RMT, X2_MOTOR);
- rmt_ll_tx_start(&RMT, X2_MOTOR);
- }
+ DIGITAL_OUT(X2_STEP_PIN, step_outbits.x);
#endif
-
- if(step_outbits_1.y) {
- rmt_ll_tx_reset_pointer(&RMT, Y_AXIS);
- rmt_ll_tx_start(&RMT, Y_AXIS);
- }
#ifdef Y2_STEP_PIN
- if(step_outbits_2.y) {
- rmt_ll_tx_reset_pointer(&RMT, Y2_MOTOR);
- rmt_ll_tx_start(&RMT, Y2_MOTOR);
- }
-#endif
-
-#ifdef Z_STEP_PIN
- if(step_outbits_1.z) {
- rmt_ll_tx_reset_pointer(&RMT, Z_AXIS);
- rmt_ll_tx_start(&RMT, Z_AXIS);
- }
- #ifdef Z2_STEP_PIN
- if(step_outbits_2.z) {
- rmt_ll_tx_reset_pointer(&RMT, Z2_MOTOR);
- rmt_ll_tx_start(&RMT, Z2_MOTOR);
- }
- #endif
-#endif // Z_STEP_PIN
-
-#ifdef A_STEP_PIN
- if(step_outbits_1.a) {
- rmt_ll_tx_reset_pointer(&RMT, A_AXIS);
- rmt_ll_tx_start(&RMT, A_AXIS);
- }
-#endif
-
-#ifdef B_STEP_PIN
- if(step_outbits_1.b) {
- rmt_ll_tx_reset_pointer(&RMT, B_AXIS);
- rmt_ll_tx_start(&RMT, B_AXIS);
- }
-#endif
-
-#ifdef C_STEP_PIN
- if(step_outbits_1.c) {
- rmt_ll_tx_reset_pointer(&RMT, C_AXIS);
- rmt_ll_tx_start(&RMT, C_AXIS);
- }
-#endif
-}
-
-#endif // SQUARING_ENABLED
-
-// Enable/disable motors for auto squaring of ganged axes
-static void StepperDisableMotors (axes_signals_t axes, squaring_mode_t mode)
-{
- motors_1.mask = (mode == SquaringMode_A || mode == SquaringMode_Both ? axes.mask : 0) ^ AXES_BITMASK;
- motors_2.mask = (mode == SquaringMode_B || mode == SquaringMode_Both ? axes.mask : 0) ^ AXES_BITMASK;
-}
-
-#else // SQUARING DISABLED
-
-#if USE_I2S_OUT
-
-// Set stepper pulse output pins
-inline __attribute__((always_inline)) IRAM_ATTR static void i2s_set_step_outputs (axes_signals_t step_outbits)
-{
- step_outbits.value ^= settings.steppers.step_invert.mask;
- DIGITAL_OUT(X_STEP_PIN, step_outbits.x);
- DIGITAL_OUT(Y_STEP_PIN, step_outbits.y);
-#ifdef Z_STEP_PIN
- DIGITAL_OUT(Z_STEP_PIN, step_outbits.z);
-#endif
-#ifdef X2_STEP_PIN
- DIGITAL_OUT(X2_STEP_PIN, step_outbits.x);
-#endif
-#ifdef Y2_STEP_PIN
- DIGITAL_OUT(Y2_STEP_PIN, step_outbits.y);
+ DIGITAL_OUT(Y2_STEP_PIN, step_outbits.y);
#endif
#ifdef Z2_STEP_PIN
DIGITAL_OUT(Z2_STEP_PIN, step_outbits.z);
@@ -929,6 +791,8 @@ inline __attribute__((always_inline)) IRAM_ATTR static void i2s_set_step_outputs
#endif
}
+#endif // !SQUARING_ENABLED
+
#if STEP_INJECT_ENABLE
void stepperOutputStep (axes_signals_t step_outbits, axes_signals_t dir_outbits)
@@ -1014,10 +878,199 @@ void stepperOutputStep (axes_signals_t step_outbits, axes_signals_t dir_outbits)
i2s_set_step_outputs((axes_signals_t){0});
}
}
+
#endif // STEP_INJECT_ENABLE
+void i2s_step_sink (void)
+{
+ //NOOP
+}
+
+void I2SReset (void)
+{
+ if(goIdlePending) {
+ i2s_out_set_passthrough();
+ i2s_out_delay();
+// i2s_out_reset();
+ goIdlePending = false;
+ }
+}
+
+IRAM_ATTR static void I2SStepperGoIdle (bool clear_signals)
+{
+ if(clear_signals) {
+ i2s_set_step_outputs((axes_signals_t){0});
+ set_dir_outputs((axes_signals_t){0});
+ i2s_out_reset();
+ }
+
+ if(!(goIdlePending = xPortInIsrContext())) {
+ i2s_out_set_passthrough();
+ i2s_out_delay();
+ }
+}
+
#else // RMT stepping
+void initRMT (settings_t *settings)
+{
+ rmt_item32_t rmtItem[2];
+
+ rmt_config_t rmtConfig = {
+ .rmt_mode = RMT_MODE_TX,
+ .clk_div = 20,
+ .mem_block_num = 1,
+ .tx_config.loop_en = false,
+ .tx_config.carrier_en = false,
+ .tx_config.carrier_freq_hz = 0,
+ .tx_config.carrier_duty_percent = 50,
+ .tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW,
+ .tx_config.idle_output_en = true
+ };
+
+ rmtItem[0].duration0 = (uint32_t)(settings->steppers.pulse_delay_microseconds > 0.0f ? 4.0f * settings->steppers.pulse_delay_microseconds : 1.0f);
+ rmtItem[0].duration1 = (uint32_t)(4.0f * settings->steppers.pulse_microseconds);
+ rmtItem[1].duration0 = 0;
+ rmtItem[1].duration1 = 0;
+
+// hal.max_step_rate = 4000000UL / (rmtItem[0].duration0 + rmtItem[0].duration1); // + latency
+
+ uint32_t channel;
+ for(channel = 0; channel < (N_AXIS + N_GANGED); channel++) {
+
+ rmtConfig.channel = channel;
+
+ switch(channel) {
+ case X_AXIS:
+ rmtConfig.tx_config.idle_level = settings->steppers.step_invert.x;
+ rmtConfig.gpio_num = X_STEP_PIN;
+ break;
+ case Y_AXIS:
+ rmtConfig.tx_config.idle_level = settings->steppers.step_invert.y;
+ rmtConfig.gpio_num = Y_STEP_PIN;
+ break;
+#ifdef Z_STEP_PIN
+ case Z_AXIS:
+ rmtConfig.tx_config.idle_level = settings->steppers.step_invert.z;
+ rmtConfig.gpio_num = Z_STEP_PIN;
+ break;
+#endif
+#ifdef A_STEP_PIN
+ case A_AXIS:
+ rmtConfig.tx_config.idle_level = settings->steppers.step_invert.a;
+ rmtConfig.gpio_num = A_STEP_PIN;
+ break;
+#endif
+#ifdef B_STEP_PIN
+ case B_AXIS:
+ rmtConfig.tx_config.idle_level = settings->steppers.step_invert.b;
+ rmtConfig.gpio_num = B_STEP_PIN;
+ break;
+#endif
+#ifdef C_STEP_PIN
+ case C_AXIS:
+ rmtConfig.tx_config.idle_level = settings->steppers.step_invert.c;
+ rmtConfig.gpio_num = C_STEP_PIN;
+ break;
+#endif
+#ifdef X2_STEP_PIN
+ case X2_MOTOR:
+ rmtConfig.tx_config.idle_level = settings->steppers.step_invert.x;
+ rmtConfig.gpio_num = X2_STEP_PIN;
+ break;
+#endif
+#ifdef Y2_STEP_PIN
+ case Y2_MOTOR:
+ rmtConfig.tx_config.idle_level = settings->steppers.step_invert.y;
+ rmtConfig.gpio_num = Y2_STEP_PIN;
+ break;
+#endif
+#ifdef Z2_STEP_PIN
+ case Z2_MOTOR:
+ rmtConfig.tx_config.idle_level = settings->steppers.step_invert.z;
+ rmtConfig.gpio_num = Z2_STEP_PIN;
+ break;
+#endif
+ }
+#ifndef Z_STEP_PIN
+ if(channel == Z_AXIS)
+ continue;
+#endif
+ rmtItem[0].level0 = rmtConfig.tx_config.idle_level;
+ rmtItem[0].level1 = !rmtConfig.tx_config.idle_level;
+ rmt_config(&rmtConfig);
+ rmt_fill_tx_items(rmtConfig.channel, &rmtItem[0], 2, 0);
+ }
+}
+
+#ifdef SQUARING_ENABLED
+
+// Set stepper pulse output pins
+inline IRAM_ATTR static void set_step_outputs (axes_signals_t step_outbits_1)
+{
+ axes_signals_t step_outbits_2;
+ step_outbits_2.mask = (step_outbits_1.mask & motors_2.mask) ^ settings.steppers.step_invert.mask;
+ step_outbits_1.mask = (step_outbits_1.mask & motors_1.mask) ^ settings.steppers.step_invert.mask;
+
+ if(step_outbits_1.x) {
+ rmt_ll_tx_reset_pointer(&RMT, X_AXIS);
+ rmt_ll_tx_start(&RMT, X_AXIS);
+ }
+#ifdef X2_STEP_PIN
+ if(step_outbits_2.x) {
+ rmt_ll_tx_reset_pointer(&RMT, X2_MOTOR);
+ rmt_ll_tx_start(&RMT, X2_MOTOR);
+ }
+#endif
+
+ if(step_outbits_1.y) {
+ rmt_ll_tx_reset_pointer(&RMT, Y_AXIS);
+ rmt_ll_tx_start(&RMT, Y_AXIS);
+ }
+#ifdef Y2_STEP_PIN
+ if(step_outbits_2.y) {
+ rmt_ll_tx_reset_pointer(&RMT, Y2_MOTOR);
+ rmt_ll_tx_start(&RMT, Y2_MOTOR);
+ }
+#endif
+
+#ifdef Z_STEP_PIN
+ if(step_outbits_1.z) {
+ rmt_ll_tx_reset_pointer(&RMT, Z_AXIS);
+ rmt_ll_tx_start(&RMT, Z_AXIS);
+ }
+ #ifdef Z2_STEP_PIN
+ if(step_outbits_2.z) {
+ rmt_ll_tx_reset_pointer(&RMT, Z2_MOTOR);
+ rmt_ll_tx_start(&RMT, Z2_MOTOR);
+ }
+ #endif
+#endif // Z_STEP_PIN
+
+#ifdef A_STEP_PIN
+ if(step_outbits_1.a) {
+ rmt_ll_tx_reset_pointer(&RMT, A_AXIS);
+ rmt_ll_tx_start(&RMT, A_AXIS);
+ }
+#endif
+
+#ifdef B_STEP_PIN
+ if(step_outbits_1.b) {
+ rmt_ll_tx_reset_pointer(&RMT, B_AXIS);
+ rmt_ll_tx_start(&RMT, B_AXIS);
+ }
+#endif
+
+#ifdef C_STEP_PIN
+ if(step_outbits_1.c) {
+ rmt_ll_tx_reset_pointer(&RMT, C_AXIS);
+ rmt_ll_tx_start(&RMT, C_AXIS);
+ }
+#endif
+}
+
+#else // !SQUARING_ENABLED
+
// Set stepper pulse output pins
inline IRAM_ATTR static void set_step_outputs (axes_signals_t step_outbits)
{
@@ -1070,6 +1123,8 @@ inline IRAM_ATTR static void set_step_outputs (axes_signals_t step_outbits)
#endif
}
+#endif // !SQUARING_ENABLED
+
#if STEP_INJECT_ENABLE
void stepperOutputStep (axes_signals_t step_outbits, axes_signals_t dir_outbits)
@@ -1172,8 +1227,6 @@ void stepperOutputStep (axes_signals_t step_outbits, axes_signals_t dir_outbits)
#endif // RMT Stepping
-#endif // SQUARING DISABLED
-
#ifdef GANGING_ENABLED
static axes_signals_t getGangedAxes (bool auto_squared)
@@ -1286,35 +1339,6 @@ IRAM_ATTR static void stepperGoIdle (bool clear_signals)
#if USE_I2S_OUT
-void i2s_step_sink (void)
-{
- //NOOP
-}
-
-void I2S_reset (void)
-{
- if(goIdlePending) {
- i2s_out_set_passthrough();
- i2s_out_delay();
-// i2s_out_reset();
- goIdlePending = false;
- }
-}
-
-IRAM_ATTR static void I2S_stepperGoIdle (bool clear_signals)
-{
- if(clear_signals) {
- i2s_set_step_outputs((axes_signals_t){0});
- set_dir_outputs((axes_signals_t){0});
- i2s_out_reset();
- }
-
- if(!(goIdlePending = xPortInIsrContext())) {
- i2s_out_set_passthrough();
- i2s_out_delay();
- }
-}
-
static void i2s_set_streaming_mode (bool stream)
{
#if CONFIG_IDF_TARGET_ESP32S3
@@ -1323,17 +1347,17 @@ static void i2s_set_streaming_mode (bool stream)
TIMERG0.hw_timer[STEP_TIMER_INDEX].config.enable = 0;
#endif
- if(!stream && hal.stepper.wake_up == I2S_stepperWakeUp && i2s_out_get_pulser_status() == STEPPING) {
+ if(!stream && hal.stepper.wake_up == I2SStepperWakeUp && i2s_out_get_pulser_status() == STEPPING) {
i2s_out_set_passthrough();
i2s_out_delay();
}
if(stream) {
- if(hal.stepper.wake_up != I2S_stepperWakeUp) {
- hal.stepper.wake_up = I2S_stepperWakeUp;
- hal.stepper.go_idle = I2S_stepperGoIdle;
- hal.stepper.cycles_per_tick = I2S_stepperCyclesPerTick;
- hal.stepper.pulse_start = I2S_stepperPulseStart;
+ if(hal.stepper.wake_up != I2SStepperWakeUp) {
+ hal.stepper.wake_up = I2SStepperWakeUp;
+ hal.stepper.go_idle = I2SStepperGoIdle;
+ hal.stepper.cycles_per_tick = I2SStepperCyclesPerTick;
+ hal.stepper.pulse_start = I2SStepperPulseStart;
i2s_out_set_pulse_callback(hal.stepper.interrupt_callback);
}
} else if(hal.stepper.wake_up != stepperWakeUp) {
@@ -1367,23 +1391,21 @@ static void limitsEnable (bool on, axes_signals_t homing_cycle)
#endif
bool disable = !on;
- uint32_t i = sizeof(inputpin) / sizeof(input_signal_t);
+ uint32_t i = limit_inputs.n_pins;
axes_signals_t pin;
limit_signals_t homing_source = xbar_get_homing_source_from_cycle(homing_cycle);
- do {
+ if(i) do {
i--;
- if(inputpin[i].group & (PinGroup_Limit|PinGroup_LimitMax)) {
- if(on && homing_cycle.mask) {
- pin = xbar_fn_to_axismask(inputpin[i].id);
- disable = inputpin[i].group == PinGroup_Limit ? (pin.mask & homing_source.min.mask) : (pin.mask & homing_source.max.mask);
- }
- gpio_set_intr_type(inputpin[i].pin, on ? map_intr_type(inputpin[i].mode.irq_mode) : GPIO_INTR_DISABLE);
- if(disable)
- gpio_intr_disable(inputpin[i].pin);
- else
- gpio_intr_enable(inputpin[i].pin);
+ if(on && homing_cycle.mask) {
+ pin = xbar_fn_to_axismask(limit_inputs.pins.inputs[i].id);
+ disable = limit_inputs.pins.inputs[i].group == PinGroup_Limit ? (pin.mask & homing_source.min.mask) : (pin.mask & homing_source.max.mask);
}
+ gpio_set_intr_type(limit_inputs.pins.inputs[i].pin, on ? map_intr_type(limit_inputs.pins.inputs[i].mode.irq_mode) : GPIO_INTR_DISABLE);
+ if(disable)
+ gpio_intr_disable(limit_inputs.pins.inputs[i].pin);
+ else
+ gpio_intr_enable(limit_inputs.pins.inputs[i].pin);
} while(i);
}
@@ -1397,6 +1419,10 @@ inline IRAM_ATTR static limit_signals_t limitsGetState (void)
#ifdef DUAL_LIMIT_SWITCHES
signals.min2.mask = settings.limits.invert.mask;
#endif
+#ifdef MAX_LIMIT_SWITCHES
+ signals.max.mask = settings.limits.invert.mask;
+#endif
+
#ifdef X_LIMIT_PIN
signals.min.x = DIGITAL_IN(X_LIMIT_PIN);
#endif
@@ -1426,10 +1452,32 @@ inline IRAM_ATTR static limit_signals_t limitsGetState (void)
signals.min2.z = DIGITAL_IN(Z2_LIMIT_PIN);
#endif
+#ifdef X_LIMIT_PIN_MAX
+ signals.max.x = DIGITAL_IN(X_LIMIT_PIN_MAX);
+#endif
+#ifdef Y_LIMIT_PIN_MAX
+ signals.max.y = DIGITAL_IN(Y_LIMIT_PIN_MAX);
+#endif
+#ifdef Z_LIMIT_PIN_MAX
+ signals.max.z = DIGITAL_IN(Z_LIMIT_PIN_MAX);
+#endif
+#ifdef A_LIMIT_PIN_MAX
+ signals.max.a = DIGITAL_IN(A_LIMIT_PIN_MAX);
+#endif
+#ifdef B_LIMIT_PIN_MAX
+ signals.max.b = DIGITAL_IN(B_LIMIT_PIN_MAX);
+#endif
+#ifdef C_LIMIT_PIN_MAX
+ signals.max.c = DIGITAL_IN(C_LIMIT_PIN_MAX);
+#endif
+
if(settings.limits.invert.mask) {
signals.min.value ^= settings.limits.invert.mask;
#ifdef DUAL_LIMIT_SWITCHES
signals.min2.mask ^= settings.limits.invert.mask;
+#endif
+#ifdef MAX_LIMIT_SWITCHES
+ signals.max.value ^= settings.limits.invert.mask;
#endif
}
@@ -1468,143 +1516,82 @@ inline IRAM_ATTR static control_signals_t systemGetState (void)
#if AUX_CONTROLS_ENABLED
#ifdef SAFETY_DOOR_PIN
- if(aux_ctrl[AuxCtrl_SafetyDoor].debouncing)
+ if(safety_door && debounce.safety_door)
signals.safety_door_ajar = !settings.control_invert.safety_door_ajar;
else
signals.safety_door_ajar = DIGITAL_IN(SAFETY_DOOR_PIN);
#endif
- #ifdef MOTOR_FAULT_PIN
- signals.motor_fault = DIGITAL_IN(MOTOR_FAULT_PIN);
- #endif
- #ifdef MOTOR_WARNING_PIN
- signals.motor_warning = DIGITAL_IN(MOTOR_WARNING_PIN);
- #endif
-
- if(settings.control_invert.mask)
- signals.value ^= settings.control_invert.mask;
-
- #if AUX_CONTROLS_SCAN
- uint_fast8_t i;
- for(i = AUX_CONTROLS_SCAN; i < AuxCtrl_NumEntries; i++) {
- if(!fpu_hack && aux_ctrl[i].enabled) {
- signals.mask &= ~aux_ctrl[i].cap.mask;
- if(hal.port.wait_on_input(Port_Digital, aux_ctrl[i].port, WaitMode_Immediate, FZERO) == 1)
- signals.mask |= aux_ctrl[i].cap.mask;
- }
- }
- #endif
-
-#else
- if(settings.control_invert.mask)
- signals.value ^= settings.control_invert.mask;
-
-#endif // AUX_CONTROLS_ENABLED
-
- return signals;
-}
-
-#if AUX_CONTROLS_ENABLED
-
-IRAM_ATTR static void aux_irq_handler (uint8_t port, bool state)
-{
- uint_fast8_t i;
- control_signals_t signals = {0};
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
-
- for(i = 0; i < AuxCtrl_NumEntries; i++) {
- if(aux_ctrl[i].port == port) {
- if(!aux_ctrl[i].debouncing) {
-#if SAFETY_DOOR_ENABLE
- if(i == AuxCtrl_SafetyDoor) {
- if((aux_ctrl[i].debouncing = door_pin->active = (xTimerStartFromISR(debounceTimer, &xHigherPriorityTaskWoken) == pdPASS)))
- break;
- }
-#endif
- signals.mask |= aux_ctrl[i].cap.mask;
- if(aux_ctrl[i].irq_mode == IRQ_Mode_Change)
- signals.deasserted = hal.port.wait_on_input(Port_Digital, aux_ctrl[i].port, WaitMode_Immediate, FZERO) == 0;
- }
- break;
- }
- }
-
- if(signals.mask) {
- if(!signals.deasserted) {
- fpu_hack = true;
- signals.mask |= systemGetState().mask;
- }
- hal.control.interrupt_callback(signals);
- fpu_hack = false;
- }
-
- if(xHigherPriorityTaskWoken)
- portYIELD_FROM_ISR();
-}
-
-static bool aux_attach (xbar_t *properties, aux_ctrl_t *aux_ctrl)
-{
- bool ok;
- uint_fast8_t i = sizeof(inputpin) / sizeof(input_signal_t);
-
- do {
- i--;
- if((ok = inputpin[i].pin == properties->pin)) {
- inputpin[i].aux_ctrl = aux_ctrl;
- break;
- }
- } while(i);
+ #ifdef MOTOR_FAULT_PIN
+ signals.motor_fault = DIGITAL_IN(MOTOR_FAULT_PIN);
+ #endif
+ #ifdef MOTOR_WARNING_PIN
+ signals.motor_warning = DIGITAL_IN(MOTOR_WARNING_PIN);
+ #endif
- return ok;
-}
+ if(settings.control_invert.mask)
+ signals.value ^= settings.control_invert.mask;
-static bool aux_claim (xbar_t *properties, uint8_t port, void *data)
-{
- bool ok;
+ #if AUX_CONTROLS_SCAN
+ signals = aux_ctrl_scan_status(signals);
+ #endif
- ((aux_ctrl_t *)data)->port = port;
+#else
+ if(settings.control_invert.mask)
+ signals.value ^= settings.control_invert.mask;
- if((ok = ioport_claim(Port_Digital, Port_Input, &((aux_ctrl_t *)data)->port, xbar_fn_to_pinname(((aux_ctrl_t *)data)->function))))
- aux_attach(properties, (aux_ctrl_t *)data);
+#endif // AUX_CONTROLS_ENABLED
- return ok;
+ return signals;
}
-#if AUX_CONTROLS_XMAP
+#if MPG_MODE == 1
-static bool aux_claim_explicit (aux_ctrl_t *aux_ctrl)
+static void modeChange (void *data)
{
- if((aux_ctrl->enabled = aux_ctrl->port != 0xFF && ioport_claim(Port_Digital, Port_Input, &aux_ctrl->port, xbar_fn_to_pinname(aux_ctrl->function)))) {
- hal.signals_cap.mask |= aux_ctrl->cap.mask;
- aux_attach(hal.port.get_pin_info(Port_Digital, Port_Input, aux_ctrl->port), aux_ctrl);
- } else
- aux_ctrl->port = 0xFF;
-
- return aux_ctrl->enabled;
+ stream_mpg_enable(!DIGITAL_IN(MPG_ENABLE_PIN));
}
-#endif
+static void mpg_enable (void *data)
+{
+ if(sys.mpg_mode == DIGITAL_IN(MPG_ENABLE_PIN))
+ stream_mpg_enable(true);
+}
-#endif // AUX_CONTROLS_ENABLED
+#endif // MPG_MODE == 1
#ifdef PROBE_PIN
+// Toggle probe connected status. Used when no input pin is available.
+static void probeConnectedToggle (void)
+{
+ probe.connected = !probe.connected;
+}
+
// Sets up the probe pin invert mask to
// appropriately set the pin logic according to setting for normal-high/normal-low operation
// and the probing cycle modes for toward-workpiece/away-from-workpiece.
-static void probeConfigure(bool is_probe_away, bool probing)
+static void probeConfigure (bool is_probe_away, bool probing)
{
#if USE_I2S_OUT
i2s_set_streaming_mode(!(probing || laser_mode));
#endif
- probe.triggered = Off;
- probe.is_probing = probing;
probe.inverted = is_probe_away ? !settings.probe.invert_probe_pin : settings.probe.invert_probe_pin;
-#if PROBE_ISR
- gpio_set_intr_type(inputpin[INPUT_PROBE].pin, probe_invert ? GPIO_INTR_NEGEDGE : GPIO_INTR_POSEDGE);
- inputpin[INPUT_PROBE].active = false;
+#ifdef AUX_DEVICES
+
+ if(hal.driver_cap.probe_latch) {
+ probe.is_probing = Off;
+ probe.triggered = hal.probe.get_state().triggered;
+ pin_irq_mode_t irq_mode = probing && !probe.triggered ? (probe.inverted ? IRQ_Mode_Falling : IRQ_Mode_Rising) : IRQ_Mode_None;
+ probe.irq_enabled = hal.port.register_interrupt_handler(probe_port, irq_mode, aux_irq_handler) && irq_mode != IRQ_Mode_None;
+ }
+
+ if(!probe.irq_enabled)
#endif
+ probe.triggered = Off;
+
+ probe.is_probing = probing;
}
// Returns the probe connected and triggered pin states.
@@ -1613,19 +1600,91 @@ static probe_state_t probeGetState (void)
probe_state_t state = {0};
state.connected = probe.connected;
+ state.triggered = probe.is_probing && probe.irq_enabled ? probe.triggered : DIGITAL_IN(PROBE_PIN) ^ probe.inverted;
-#if PROBE_ISR
- // TODO: verify!
- inputpin[INPUT_PROBE].active = inputpin[INPUT_PROBE].active || ((uint8_t)DIGITAL_IN(PROBE_PIN) ^ probe.inverted);
- state.triggered = inputpin[INPUT_PROBE].active;
-#else
- state.triggered = (uint8_t)DIGITAL_IN(PROBE_PIN) ^ probe.inverted;
+ return state;
+}
+
+#endif // PROBE_PIN
+
+#if AUX_CONTROLS_ENABLED
+
+IRAM_ATTR static void aux_irq_handler (uint8_t port, bool state)
+{
+ aux_ctrl_t *pin;
+ control_signals_t signals = {0};
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
+
+ if((pin = aux_ctrl_get_pin(port))) {
+ switch(pin->function) {
+#ifdef PROBE_PIN
+ case Input_Probe:
+ if(probe.is_probing) {
+ probe.triggered = On;
+ return;
+ } else
+ signals.probe_triggered = On;
+ break;
+#endif
+#ifdef I2C_STROBE_PIN
+ case Input_I2CStrobe:
+ if(i2c_strobe.callback)
+ i2c_strobe.callback(0, DIGITAL_IN(I2C_STROBE_PIN) == 0);
+ break;
+#endif
+#ifdef MPG_MODE_PIN
+ case Input_MPGSelect:
+ protocol_enqueue_foreground_task(mpg_select, NULL);
+ break;
#endif
+ default:
+ break;
+ }
+ signals.mask |= pin->cap.mask;
+ if(pin->irq_mode == IRQ_Mode_Change && pin->cap.mask)
+ signals.deasserted = hal.port.wait_on_input(Port_Digital, pin->aux_port, WaitMode_Immediate, FZERO) == 0; // DIGITAL_IN(((input_signal_t *)pin->input)->pin)
+ }
- return state;
+ if(signals.mask) {
+ if(!signals.deasserted) {
+ fpu_hack = true;
+ signals.mask |= systemGetState().mask;
+ }
+ hal.control.interrupt_callback(signals);
+ fpu_hack = false;
+ }
+
+ if(xHigherPriorityTaskWoken)
+ portYIELD_FROM_ISR();
}
+static bool aux_claim_explicit (aux_ctrl_t *aux_ctrl)
+{
+ if(ioport_claim(Port_Digital, Port_Input, &aux_ctrl->aux_port, NULL)) {
+ ioport_assign_function(aux_ctrl, &((input_signal_t *)aux_ctrl->input)->id);
+#ifdef PROBE_PIN
+ if(aux_ctrl->function == Input_Probe) {
+ probe_port = aux_ctrl->aux_port;
+ hal.probe.get_state = probeGetState;
+ hal.probe.configure = probeConfigure;
+ hal.probe.connected_toggle = probeConnectedToggle;
+ hal.driver_cap.probe_pull_up = On;
+ hal.signals_cap.probe_triggered = hal.driver_cap.probe_latch = aux_ctrl->irq_mode != IRQ_Mode_None;
+ }
+#endif
+#ifdef SAFETY_DOOR_PIN
+ if(aux_ctrl->function == Input_SafetyDoor) {
+ safety_door = (input_signal_t *)aux_ctrl->input;
+ safety_door->mode.debounce = hal.driver_cap.software_debounce;
+ }
#endif
+ } else
+ aux_ctrl->aux_port = 0xFF;
+
+ return aux_ctrl->aux_port != 0xFF;
+}
+
+#endif // AUX_CONTROLS_ENABLED
#if DRIVER_SPINDLE_ENABLE
@@ -1685,9 +1744,9 @@ IRAM_ATTR static void spindleSetState (spindle_ptrs_t *spindle, spindle_state_t
// Sets spindle speed
IRAM_ATTR static void spindleSetSpeed (spindle_ptrs_t *spindle, uint_fast16_t pwm_value)
{
- if(pwm_value == pwm(spindle)->off_value) {
- if(pwm(spindle)->settings->flags.enable_rpm_controlled) {
- if(pwm(spindle)->cloned)
+ if(pwm_value == spindle->context.pwm->off_value) {
+ if(spindle->context.pwm->settings->flags.enable_rpm_controlled) {
+ if(spindle->context.pwm->cloned)
spindle_dir(false);
else
spindle_off();
@@ -1697,10 +1756,10 @@ IRAM_ATTR static void spindleSetSpeed (spindle_ptrs_t *spindle, uint_fast16_t pw
ledc_set_fade_step_and_start(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel, pwm_ramp.pwm_target, 1, 4, LEDC_FADE_NO_WAIT);
#else
if(spindle_pwm.always_on) {
- ledc_set_duty(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel, pwm(spindle)->off_value);
+ ledc_set_duty(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel, spindle->context.pwm->off_value);
ledc_update_duty(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel);
} else
- ledc_stop(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel, pwm(spindle)->settings->invert.pwm ? 1 : 0);
+ ledc_stop(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel, spindle->context.pwm->settings->invert.pwm ? 1 : 0);
#endif
pwmEnabled = false;
} else {
@@ -1708,11 +1767,11 @@ IRAM_ATTR static void spindleSetSpeed (spindle_ptrs_t *spindle, uint_fast16_t pw
pwm_ramp.pwm_target = pwm_value;
ledc_set_fade_step_and_start(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel, pwm_ramp.pwm_target, 1, 4, LEDC_FADE_NO_WAIT);
#else
- ledc_set_duty(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel, pwm(spindle)->settings->invert.pwm ? pwm_max_value - pwm_value : pwm_value);
+ ledc_set_duty(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel, spindle->context.pwm->settings->invert.pwm ? pwm_max_value - pwm_value : pwm_value);
ledc_update_duty(spindle_pwm_channel.speed_mode, spindle_pwm_channel.channel);
#endif
if(!pwmEnabled) {
- if(pwm(spindle)->cloned)
+ if(spindle->context.pwm->cloned)
spindle_dir(true);
else
spindle_on();
@@ -1723,7 +1782,7 @@ IRAM_ATTR static void spindleSetSpeed (spindle_ptrs_t *spindle, uint_fast16_t pw
static uint_fast16_t spindleGetPWM (spindle_ptrs_t *spindle, float rpm)
{
- return pwm(spindle)->compute_value(pwm(spindle), rpm, false);
+ return spindle->context.pwm->compute_value(spindle->context.pwm, rpm, false);
}
// Start or stop spindle, variable version
@@ -1732,25 +1791,25 @@ IRAM_ATTR static void spindleOff (spindle_ptrs_t *spindle)
{
spindle_off();
if(spindle)
- spindleSetSpeed(spindle, pwm(spindle)->off_value);
+ spindleSetSpeed(spindle, spindle->context.pwm->off_value);
}
IRAM_ATTR static void spindleSetStateVariable (spindle_ptrs_t *spindle, spindle_state_t state, float rpm)
{
#ifdef SPINDLE_DIRECTION_PIN
- if(state.on || pwm(spindle)->cloned)
+ if(state.on || spindle->context.pwm->cloned)
spindle_dir(state.ccw);
#endif
- if(!pwm(spindle)->settings->flags.enable_rpm_controlled) {
+ if(!spindle->context.pwm->settings->flags.enable_rpm_controlled) {
if(state.on)
spindle_on();
else
spindle_off();
}
- spindleSetSpeed(spindle, state.on || (state.ccw && pwm(spindle)->cloned)
- ? pwm(spindle)->compute_value(pwm(spindle), rpm, false)
- : pwm(spindle)->off_value);
+ spindleSetSpeed(spindle, state.on || (state.ccw && spindle->context.pwm->cloned)
+ ? spindle->context.pwm->compute_value(spindle->context.pwm, rpm, false)
+ : spindle->context.pwm->off_value);
}
bool spindleConfig (spindle_ptrs_t *spindle)
@@ -1920,53 +1979,6 @@ static inline uint64_t getElapsedMicros (void)
return (uint64_t)esp_timer_get_time();
}
-#if MPG_MODE == 1
-
-static void modeChange (void *data)
-{
- stream_mpg_enable(!DIGITAL_IN(MPG_ENABLE_PIN));
-}
-
-static void modeEnable (void *data)
-{
- if(sys.mpg_mode == DIGITAL_IN(MPG_ENABLE_PIN))
- stream_mpg_enable(true);
-}
-
-#endif
-
-void debounceTimerCallback (TimerHandle_t xTimer)
-{
- uint32_t grp = 0, i = sizeof(inputpin) / sizeof(input_signal_t);
- do {
- i--;
- if(inputpin[i].debounce && inputpin[i].active) {
- inputpin[i].active = false; //DIGITAL_IN(inputpin[i].pin) == (inputpin[i].invert ? 0 : 1);
- grp |= inputpin[i].group;
- }
-#if SAFETY_DOOR_ENABLE
- if(&inputpin[i] == door_pin)
- aux_ctrl[AuxCtrl_SafetyDoor].debouncing = Off;
-#endif
- } while(i);
-
- if(grp & (PinGroup_Limit|PinGroup_LimitMax)) {
- portENTER_CRITICAL(&debounce_mux);
- hal.limits.interrupt_callback(limitsGetState());
- portEXIT_CRITICAL(&debounce_mux);
- }
-
-#if SAFETY_DOOR_ENABLE
- if(grp & (PinGroup_Control|PinGroup_AuxInput)) {
-#else
- if(grp & PinGroup_Control) {
-#endif
- portENTER_CRITICAL(&debounce_mux);
- hal.control.interrupt_callback(systemGetState());
- portEXIT_CRITICAL(&debounce_mux);
- }
-}
-
gpio_int_type_t map_intr_type (pin_irq_mode_t mode)
{
switch(mode) {
@@ -2000,6 +2012,31 @@ static void settings_changed (settings_t *settings, settings_changed_flags_t cha
{
if(IOInitDone) {
+#ifdef NEOPIXELS_PIN
+
+ if(neopixel.leds == NULL || hal.rgb.num_devices != settings->rgb_strip0_length) {
+
+ if(settings->rgb_strip0_length == 0)
+ settings->rgb_strip0_length = hal.rgb.num_devices;
+ else
+ hal.rgb.num_devices = settings->rgb_strip0_length;
+
+ if(neopixel.leds) {
+ free(neopixel.leds);
+ neopixel.leds = NULL;
+ }
+
+ if(hal.rgb.num_devices) {
+ neopixel.num_bytes = hal.rgb.num_devices * 3;
+ if((neopixel.leds = calloc(neopixel.num_bytes, sizeof(uint8_t))) == NULL)
+ hal.rgb.num_devices = 0;
+ }
+
+ neopixel.num_leds = hal.rgb.num_devices;
+ }
+
+#endif
+
#if DRIVER_SPINDLE_PWM_ENABLE
if(changed.spindle) {
spindleConfig(spindle_get_hal(spindle_id, SpindleHAL_Configured));
@@ -2057,7 +2094,6 @@ static void settings_changed (settings_t *settings, settings_changed_flags_t cha
* Control, limit & probe pins config *
****************************************/
- bool pullup = true;
control_signals_t control_fei;
gpio_config_t config;
input_signal_t *signal;
@@ -2072,96 +2108,103 @@ static void settings_changed (settings_t *settings, settings_changed_flags_t cha
do {
signal = &inputpin[--i];
- signal->mode.irq_mode = IRQ_Mode_None;
if(signal->group == PinGroup_AuxInputAnalog)
continue;
+ if(!(signal->group == PinGroup_AuxInput || signal->group == PinGroup_MPG))
+ signal->mode.irq_mode = IRQ_Mode_None;
+
switch(signal->id) {
case Input_Reset:
- pullup = !settings->control_disable_pullup.reset;
- signal->invert = control_fei.reset;
+ signal->mode.pull_mode = settings->control_disable_pullup.reset ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = control_fei.reset;
break;
case Input_FeedHold:
- pullup = !settings->control_disable_pullup.feed_hold;
- signal->invert = control_fei.feed_hold;
+ signal->mode.pull_mode = settings->control_disable_pullup.feed_hold ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = control_fei.feed_hold;
break;
case Input_CycleStart:
- pullup = !settings->control_disable_pullup.cycle_start;
- signal->invert = control_fei.cycle_start;
+ signal->mode.pull_mode = settings->control_disable_pullup.cycle_start ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = control_fei.cycle_start;
break;
case Input_SafetyDoor:
- pullup = !settings->control_disable_pullup.safety_door_ajar;
- signal->invert = control_fei.safety_door_ajar;
- break;
-
- case Input_Probe:
- pullup = hal.driver_cap.probe_pull_up;
- signal->invert = false;
+ signal->mode.pull_mode = settings->control_disable_pullup.safety_door_ajar ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = control_fei.safety_door_ajar;
break;
case Input_LimitX:
case Input_LimitX_2:
case Input_LimitX_Max:
- pullup = !settings->limits.disable_pullup.x;
- signal->invert = limit_fei.x;
+ signal->mode.pull_mode = settings->limits.disable_pullup.x ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = limit_fei.x;
break;
case Input_LimitY:
case Input_LimitY_2:
case Input_LimitY_Max:
- pullup = !settings->limits.disable_pullup.y;
- signal->invert = limit_fei.y;
+ signal->mode.pull_mode = settings->limits.disable_pullup.y ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = limit_fei.y;
break;
case Input_LimitZ:
case Input_LimitZ_2:
case Input_LimitZ_Max:
- pullup = !settings->limits.disable_pullup.z;
- signal->invert = limit_fei.z;
+ signal->mode.pull_mode = settings->limits.disable_pullup.z ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = limit_fei.z;
break;
#ifdef A_LIMIT_PIN
case Input_LimitA:
- pullup = !settings->limits.disable_pullup.a;
- signal->invert = limit_fei.a;
+ case Input_LimitA_Max:
+ signal->mode.pull_mode = settings->limits.disable_pullup.a ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = limit_fei.a;
break;
#endif
#ifdef B_LIMIT_PIN
case Input_LimitB:
- pullup = !settings->limits.disable_pullup.b;
- signal->invert = limit_fei.b;
+ case Input_LimitB_Max:
+ signal->mode.pull_mode = settings->limits.disable_pullup.b ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = limit_fei.b;
break;
#endif
#ifdef C_LIMIT_PIN
case Input_LimitC:
- pullup = !settings->limits.disable_pullup.c;
- signal->invert = limit_fei.c;
+ case Input_LimitC_Max:
+ signal->mode.pull_mode = settings->limits.disable_pullup.c ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = limit_fei.c;
break;
#endif
-#if MPG_MODE == 1
+#ifndef AUX_DEVICES
+ case Input_Probe:
+ signal->mode.pull_mode = settings->probe.flag.disable_pullup ? PullMode_Down : PullMode_Up;
+ signal->mode.inverted = false;
+ break;
+
+ #if MPG_MODE == 1
case Input_ModeSelect:
- pullup = true;
- signal->invert = false;
+ signal->mode.pull_mode = PullMode_Up;
+ signal->mode.inverted = false;
config.intr_type = GPIO_INTR_ANYEDGE;
#if ETHERNET_ENABLE
gpio_isr_handler_add(signal->pin, gpio_mpg_isr, signal);
#endif
break;
-#endif
-#if I2C_STROBE_ENABLE
+ #endif
+ #if I2C_STROBE_ENABLE
case Input_I2CStrobe:
- pullup = true;
- signal->invert = false;
+ signal->mode.pull_mode = PullMode_Up;
+ signal->mode.inverted = false;
config.intr_type = GPIO_INTR_ANYEDGE;
#if ETHERNET_ENABLE
gpio_isr_handler_add(signal->pin, gpio_i2c_strobe_isr, signal);
#endif
break;
-#endif
+ #endif
+#endif // AUX_DEVICES
default:
break;
}
@@ -2171,16 +2214,14 @@ static void settings_changed (settings_t *settings, settings_changed_flags_t cha
case PinGroup_Control:
case PinGroup_Limit:
case PinGroup_LimitMax:
- signal->mode.irq_mode = signal->invert ? IRQ_Mode_Falling : IRQ_Mode_Rising;
- signal->debounce = hal.driver_cap.software_debounce;
+ signal->mode.debounce = hal.driver_cap.software_debounce;
+ signal->mode.irq_mode = signal->mode.inverted ? IRQ_Mode_Falling : IRQ_Mode_Rising;
#if ETHERNET_ENABLE
gpio_isr_handler_add(signal->pin, (signal->group & (PinGroup_Limit|PinGroup_LimitMax)) ? gpio_limit_isr : gpio_control_isr, signal);
#endif
break;
case PinGroup_AuxInput:
- pullup = true;
- signal->invert = false;
#if ETHERNET_ENABLE
gpio_isr_handler_add(signal->pin, gpio_aux_isr, signal);
#endif
@@ -2201,8 +2242,8 @@ static void settings_changed (settings_t *settings, settings_changed_flags_t cha
config.pull_down_en = pullup ? GPIO_PULLDOWN_DISABLE : GPIO_PULLDOWN_ENABLE;
// Early versions(?) has an internal pullup on 45 - https://github.com/espressif/esp-idf/issues/9731
#else
- config.pull_up_en = pullup && signal->pin < 34 ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE;
- config.pull_down_en = pullup || signal->pin >= 34 ? GPIO_PULLDOWN_DISABLE : GPIO_PULLDOWN_ENABLE;
+ config.pull_up_en = signal->mode.pull_mode == PullMode_Up && signal->pin < 34 ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE;
+ config.pull_down_en = signal->mode.pull_mode == PullMode_Up || signal->pin >= 34 ? GPIO_PULLDOWN_DISABLE : GPIO_PULLDOWN_ENABLE;
#endif
config.intr_type = (signal->group & (PinGroup_Limit|PinGroup_LimitMax)) ? GPIO_INTR_DISABLE : map_intr_type(signal->mode.irq_mode);
@@ -2212,19 +2253,13 @@ static void settings_changed (settings_t *settings, settings_changed_flags_t cha
// printf("IN %d - %d - %d : %x\n", signal->pin, signal->offset, signal->mask, signal->invert);
gpio_config(&config);
-
- signal->active = signal->debounce && DIGITAL_IN(signal->pin) == (signal->invert ? 0 : 1);
}
} while(i);
+ hal.limits.enable(settings->limits.flags.hard_enabled, (axes_signals_t){0});
+
#if AUX_CONTROLS_ENABLED
- for(i = 0; i < AuxCtrl_NumEntries; i++) {
- if(aux_ctrl[i].enabled && aux_ctrl[i].irq_mode != IRQ_Mode_None) {
- if(aux_ctrl[i].irq_mode & (IRQ_Mode_Falling|IRQ_Mode_Rising))
- aux_ctrl[i].irq_mode = (settings->control_invert.mask & aux_ctrl[i].cap.mask) ? IRQ_Mode_Falling : IRQ_Mode_Rising;
- hal.port.register_interrupt_handler(aux_ctrl[i].port, aux_ctrl[i].irq_mode, aux_irq_handler);
- }
- }
+ aux_ctrl_irq_enable(settings, aux_irq_handler);
#endif
}
}
@@ -2232,11 +2267,13 @@ static void settings_changed (settings_t *settings, settings_changed_flags_t cha
static void enumeratePins (bool low_level, pin_info_ptr pin_info, void *data)
{
static xbar_t pin = {0};
- uint32_t i = sizeof(inputpin) / sizeof(input_signal_t);
+
+ uint32_t i, id = 0;
pin.mode.input = On;
for(i = 0; i < sizeof(inputpin) / sizeof(input_signal_t); i++) {
+ pin.id = id++;
pin.pin = inputpin[i].pin;
pin.function = inputpin[i].id;
pin.group = inputpin[i].group;
@@ -2251,6 +2288,7 @@ static void enumeratePins (bool low_level, pin_info_ptr pin_info, void *data)
pin.mode.output = On;
for(i = 0; i < sizeof(outputpin) / sizeof(output_signal_t); i++) {
+ pin.id = id++;
pin.pin = outputpin[i].pin - (outputpin[i].pin < I2S_OUT_PIN_BASE ? 0 : I2S_OUT_PIN_BASE);
pin.port = low_level || outputpin[i].pin < I2S_OUT_PIN_BASE ? NULL : "I2S";
pin.function = outputpin[i].id;
@@ -2263,6 +2301,7 @@ static void enumeratePins (bool low_level, pin_info_ptr pin_info, void *data)
periph_signal_t *ppin = periph_pins;
if(ppin) do {
+ pin.id = id++;
pin.pin = ppin->pin.pin;
pin.function = ppin->pin.function;
pin.group = ppin->pin.group;
@@ -2270,9 +2309,7 @@ static void enumeratePins (bool low_level, pin_info_ptr pin_info, void *data)
pin.description = ppin->pin.description;
pin_info(&pin, data);
-
- ppin = ppin->next;
- } while(ppin);
+ } while((ppin = ppin->next));
}
void registerPeriphPin (const periph_pin_t *pin)
@@ -2371,18 +2408,14 @@ static char *sdcard_mount (FATFS **fs)
};
sdmmc_host_t host = SDSPI_HOST_DEFAULT();
-#if CONFIG_IDF_TARGET_ESP32S3
- host.max_freq_khz = 10000; // higher corrupts the card... Still incredible fast: ~35 Kb/sec vs. ~1.5 Mb/sec for the Teensy4 via FTP - 20 times faster! /sarc
-#endif
-
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT();
slot_config.gpio_cs = PIN_NUM_CS;
slot_config.host_id = host.slot;
gpio_set_drive_capability(PIN_NUM_CS, GPIO_DRIVE_CAP_3);
- if ((ret = esp_vfs_fat_sdspi_mount("/sdcard", &host, &slot_config, &mount_config, &card)) != ESP_OK)
- report_message(ret == ESP_FAIL ? "Failed to mount filesystem" : "Failed to initialize SD card", Message_Warning);
+ if((ret = esp_vfs_fat_sdspi_mount("/sdcard", &host, &slot_config, &mount_config, &card)) != ESP_OK)
+ protocol_enqueue_foreground_task(report_warning, ret == ESP_FAIL ? "Failed to mount filesystem" : "Failed to initialize SD card");
}
if(card && fs) {
@@ -2408,7 +2441,11 @@ static char *sdcard_mount (FATFS **fs)
#define NEOPIXELS_NUM 1
#endif
-static rmt_config_t neo_config = RMT_DEFAULT_CONFIG_TX(NEOPIXELS_PIN, 3); // TODO: sort out channel allocation
+#if CONFIG_IDF_TARGET_ESP32S3
+static rmt_config_t neo_config = RMT_DEFAULT_CONFIG_TX(NEOPIXELS_PIN, 3);
+#else
+static rmt_config_t neo_config = RMT_DEFAULT_CONFIG_TX(NEOPIXELS_PIN, 7);
+#endif
#define WS2812_T0H_NS (450)
#define WS2812_T0L_NS (850)
@@ -2426,73 +2463,94 @@ static rmt_config_t neo_config = RMT_DEFAULT_CONFIG_TX(NEOPIXELS_PIN, 3); // TOD
#define WS2812_T1L_NS (1300)
*/
-static uint8_t pixels[NEOPIXELS_NUM * 3] = {0};
static uint32_t t0h_ticks = 0, t1h_ticks = 0, t0l_ticks = 0, t1l_ticks = 0;
static void IRAM_ATTR ws2812_rmt_adapter (const void *src, rmt_item32_t *dest, size_t src_size,
size_t wanted_num, size_t *translated_size, size_t *item_num)
{
- if (src == NULL || dest == NULL) {
- *translated_size = 0;
- *item_num = 0;
- return;
- }
const rmt_item32_t bit0 = {{{ t0h_ticks, 1, t0l_ticks, 0 }}}; //Logical 0
const rmt_item32_t bit1 = {{{ t1h_ticks, 1, t1l_ticks, 0 }}}; //Logical 1
- size_t size = 0;
- size_t num = 0;
- uint8_t *psrc = (uint8_t *)src;
- rmt_item32_t *pdest = dest;
- while (size < src_size && num < wanted_num) {
- for (int i = 0; i < 8; i++) {
- // MSB first
- if (*psrc & (1 << (7 - i))) {
- pdest->val = bit1.val;
- } else {
- pdest->val = bit0.val;
- }
- num++;
- pdest++;
+
+ rgb_color_t color = {0};
+ size_t size = 0, num = 0;
+ uint8_t *psrc = (uint8_t *)src, bitmask;
+
+ if(!(src == NULL || dest == NULL)) {
+ while(size < src_size && num < wanted_num) {
+
+ color.G = *psrc++;
+ color.R = *psrc++;
+ color.B = *psrc++;
+ color = rgb_set_intensity(color, neopixel.intensity);
+
+ bitmask = 0b10000000;
+ do {
+ dest->val = color.G & bitmask ? bit1.val : bit0.val;
+ dest++;
+ } while(bitmask >>= 1);
+
+ bitmask = 0b10000000;
+ do {
+ dest->val = color.R & bitmask ? bit1.val : bit0.val;
+ dest++;
+ } while(bitmask >>= 1);
+
+ bitmask = 0b10000000;
+ do {
+ dest->val = color.B & bitmask ? bit1.val : bit0.val;
+ dest++;
+ } while(bitmask >>= 1);
+
+ num += 24;
+ size += 3;
}
- size++;
- psrc++;
}
+
*translated_size = size;
*item_num = num;
}
void neopixels_write (void)
{
- rmt_write_sample(neo_config.channel, pixels, sizeof(pixels), true);
+ uint8_t *buf = neopixel.leds;
+ size_t size = neopixel.num_bytes;
+
+ if(buf) do {
+ rmt_write_sample(neo_config.channel, buf, size > 6 ? 6 : size, true);
+ buf += size > 6 ? 6 : size;
+ size -= size > 6 ? 6 : size;
+ } while(size);
}
static void neopixel_out_masked (uint16_t device, rgb_color_t color, rgb_color_mask_t mask)
{
- if(device < NEOPIXELS_NUM) {
+ if(neopixel.num_leds && device < neopixel.num_leds) {
- device *= 3;
- if(mask.G)
- pixels[device++] = color.G;
- else
- device++;
- if(mask.R)
- pixels[device++] = color.R;
- else
- device++;
- if(mask.B)
- pixels[device] = color.B;
-#if NEOPIXELS_NUM == 1
- rmt_write_sample(neo_config.channel, pixels, sizeof(pixels), true);
-#endif
-//?? rmt_wait_tx_done(neo_config.channel, pdMS_TO_TICKS(100));
+ rgb_1bpp_assign(&neopixel.leds[device * 3], color, mask);
+
+ if(neopixel.num_leds == 1)
+ neopixels_write();
}
}
-static void neopixel_out (uint8_t device, rgb_color_t color)
+static void neopixel_out (uint16_t device, rgb_color_t color)
{
neopixel_out_masked(device, color, (rgb_color_mask_t){ .mask = 0xFF });
}
+uint8_t neopixels_set_intensity (uint8_t value)
+{
+ uint8_t prev = neopixel.intensity;
+
+ if(neopixel.intensity != value) {
+
+ neopixel.intensity = value;
+// neopixels_write();
+ }
+
+ return prev;
+}
+
#endif // NEOPIXELS_PIN
// Initializes MCU peripherals for Grbl use
@@ -2595,13 +2653,6 @@ static bool driver_setup (settings_t *settings)
#endif
- /****************************
- * Software debounce init *
- ****************************/
-
- if(hal.driver_cap.software_debounce)
- debounceTimer = xTimerCreate("debounce", pdMS_TO_TICKS(32), pdFALSE, NULL, debounceTimerCallback);
-
/******************************************
* Control, limit & probe pins dir init *
******************************************/
@@ -2733,7 +2784,8 @@ static void wdt_tickler (sys_state_t state)
if(xTaskGetTickCountFromISR() - ms > 250) {
ms = xTaskGetTickCountFromISR();
vTaskDelay(1);
- }
+ } else
+ on_execute_realtime(state);
}
// Initialize HAL pointers, setup serial comms and enable EEPROM
@@ -2750,7 +2802,7 @@ bool driver_init (void)
#else
hal.info = "ESP32";
#endif
- hal.driver_version = "240119";
+ hal.driver_version = "240304";
hal.driver_url = GRBL_URL "/ESP32";
#ifdef BOARD_NAME
hal.board = BOARD_NAME;
@@ -2767,22 +2819,22 @@ bool driver_init (void)
hal.delay_ms = driver_delay_ms;
hal.settings_changed = settings_changed;
-#if !USE_I2S_OUT
+#if USE_I2S_OUT
+ hal.driver_reset = I2SReset;
+ hal.stepper.wake_up = I2SStepperWakeUp;
+ hal.stepper.go_idle = I2SStepperGoIdle;
+ hal.stepper.enable = stepperEnable;
+ hal.stepper.cycles_per_tick = I2SStepperCyclesPerTick;
+ hal.stepper.pulse_start = I2SStepperPulseStart;
+#else
hal.stepper.wake_up = stepperWakeUp;
hal.stepper.go_idle = stepperGoIdle;
hal.stepper.enable = stepperEnable;
hal.stepper.cycles_per_tick = stepperCyclesPerTick;
hal.stepper.pulse_start = stepperPulseStart;
- #if STEP_INJECT_ENABLE
+#endif
+#if STEP_INJECT_ENABLE
hal.stepper.output_step = stepperOutputStep;
- #endif
-#else
- hal.driver_reset = I2S_reset;
- hal.stepper.wake_up = I2S_stepperWakeUp;
- hal.stepper.go_idle = I2S_stepperGoIdle;
- hal.stepper.enable = stepperEnable;
- hal.stepper.cycles_per_tick = I2S_stepperCyclesPerTick;
- hal.stepper.pulse_start = I2S_stepperPulseStart;
#endif
hal.stepper.motor_iterator = motor_iterator;
#ifdef GANGING_ENABLED
@@ -2798,9 +2850,11 @@ bool driver_init (void)
hal.coolant.set_state = coolantSetState;
hal.coolant.get_state = coolantGetState;
-#ifdef PROBE_PIN
+#if defined(PROBE_PIN) && !defined(AUX_DEVICES)
hal.probe.get_state = probeGetState;
hal.probe.configure = probeConfigure;
+ hal.probe.connected_toggle = probeConnectedToggle;
+ hal.driver_cap.probe_pull_up = On;
#endif
hal.control.get_state = systemGetState;
@@ -2825,6 +2879,7 @@ bool driver_init (void)
serialRegisterStreams();
+ on_execute_realtime = grbl.on_execute_realtime;
grbl.on_execute_realtime = wdt_tickler;
#if USB_SERIAL_CDC
@@ -2910,7 +2965,6 @@ bool driver_init (void)
hal.driver_cap.amass_level = 3;
hal.driver_cap.control_pull_up = On;
hal.driver_cap.limits_pull_up = On;
- hal.driver_cap.probe_pull_up = On;
#if ESTOP_ENABLE
hal.signals_cap.e_stop = On;
hal.signals_cap.reset = Off;
@@ -2918,11 +2972,11 @@ bool driver_init (void)
hal.limits_cap = get_limits_cap();
hal.home_cap = get_home_cap();
- uint32_t i;
static pin_group_pins_t aux_inputs = {0}, aux_outputs = {0},
aux_analog_in = {0}, aux_analog_out = {0};
+
+ uint32_t i;
input_signal_t *input;
- output_signal_t *output;
for(i = 0 ; i < sizeof(inputpin) / sizeof(input_signal_t); i++) {
input = &inputpin[i];
@@ -2930,32 +2984,35 @@ bool driver_init (void)
if(input->group == PinGroup_AuxInput) {
if(aux_inputs.pins.inputs == NULL)
aux_inputs.pins.inputs = input;
- input->id = (pin_function_t)(Input_Aux0 + aux_inputs.n_pins++);
+ input->user_port = aux_inputs.n_pins++;
+ input->id = (pin_function_t)(Input_Aux0 + input->user_port);
+ input->cap.debounce = On;
input->cap.pull_mode = PullMode_UpDown;
input->cap.irq_mode = IRQ_Mode_Edges;
-#if SAFETY_DOOR_ENABLE
- if(input->pin == SAFETY_DOOR_PIN && input->cap.irq_mode != IRQ_Mode_None) {
- door_pin = input;
- door_pin->debounce = On;
- aux_ctrl[AuxCtrl_SafetyDoor].port = aux_inputs.n_pins - 1;
+ input->mode.pull_mode = PullMode_Up;
+#if AUX_CONTROLS_ENABLED
+ aux_ctrl_t *aux_remap;
+ if((aux_remap = aux_ctrl_remap_explicit(input->port, input->pin, input->user_port, input))) {
+ if(aux_remap->function == Input_Probe)
+ aux_remap->irq_mode = IRQ_Mode_Change;
}
#endif
-#if MOTOR_FAULT_ENABLE
- if(input->pin == MOTOR_FAULT_PIN && input->cap.irq_mode != IRQ_Mode_None)
- aux_ctrl[AuxCtrl_MotorFault].port = aux_inputs.n_pins - 1;
-#endif
-#if MOTOR_WARNING_ENABLE
- if(input->pin == MOTOR_WARNING_PIN && input->cap.irq_mode != IRQ_Mode_None)
- aux_ctrl[AuxCtrl_MotorWarning].port = aux_inputs.n_pins - 1;
-#endif
+ } else if(input->group == PinGroup_Limit || input->group == PinGroup_LimitMax) {
+ if(limit_inputs.pins.inputs == NULL)
+ limit_inputs.pins.inputs = input;
+ limit_inputs.n_pins++;
+ input->mode.debounce = hal.driver_cap.software_debounce;
} else if(input->group == PinGroup_AuxInputAnalog) {
if(aux_analog_in.pins.inputs == NULL)
aux_analog_in.pins.inputs = input;
input->mode.analog = input->cap.analog = On;
input->id = (pin_function_t)(Input_Analog_Aux0 + aux_analog_in.n_pins++);
- }
+ } else if(input->group == PinGroup_Control)
+ input->mode.debounce = hal.driver_cap.software_debounce;
}
+ output_signal_t *output;
+
for(i = 0 ; i < sizeof(outputpin) / sizeof(output_signal_t); i++) {
output = &outputpin[i];
output->mode.output = On;
@@ -2975,33 +3032,12 @@ bool driver_init (void)
if(aux_analog_in.n_pins || aux_analog_out.n_pins)
ioports_init_analog(&aux_analog_in, &aux_analog_out);
-#if SAFETY_DOOR_ENABLE
- aux_claim_explicit(&aux_ctrl[AuxCtrl_SafetyDoor]);
+#if AUX_CONTROLS_ENABLED
+ aux_ctrl_claim_ports(aux_claim_explicit, NULL);
#elif defined(SAFETY_DOOR_PIN)
hal.signals_cap.safety_door_ajar = On;
#endif
-#if MOTOR_FAULT_ENABLE
- aux_claim_explicit(&aux_ctrl[AuxCtrl_MotorFault]);
-#elif defined(MOTOR_FAULT_PIN)
- hal.signals_cap.motor_fault = On;
-#endif
-
-#if MOTOR_WARNING_ENABLE
- aux_claim_explicit(&aux_ctrl[AuxCtrl_MotorWarning]);
-#elif defined(MOTOR_WARNING_PIN)
- hal.signals_cap.motor_warning = On;
-#endif
-
-#if AUX_CONTROLS_ENABLED
- for(i = AuxCtrl_ProbeDisconnect; i < AuxCtrl_NumEntries; i++) {
- if(aux_ctrl[i].enabled) {
- if((aux_ctrl[i].enabled = ioports_enumerate(Port_Digital, Port_Input, (pin_cap_t){ .irq_mode = aux_ctrl[i].irq_mode, .claimable = On }, aux_claim, (void *)&aux_ctrl[i])))
- hal.signals_cap.mask |= aux_ctrl[i].cap.mask;
- }
- }
-#endif
-
#ifdef NEOPIXELS_PIN
neo_config.clk_div = 2;
@@ -3026,9 +3062,8 @@ bool driver_init (void)
hal.rgb.out = neopixel_out;
hal.rgb.out_masked = neopixel_out_masked;
-#if NEOPIXELS_NUM > 1
hal.rgb.write = neopixels_write;
-#endif
+ hal.rgb.set_intensity = neopixels_set_intensity;
hal.rgb.num_devices = NEOPIXELS_NUM;
hal.rgb.cap = (rgb_color_t){ .R = 255, .G = 255, .B = 255 };
@@ -3036,7 +3071,8 @@ bool driver_init (void)
.function = Output_LED_Adressable,
.group = PinGroup_LED,
.pin = NEOPIXELS_PIN,
- .mode = { .mask = PINMODE_OUTPUT }
+ .mode = { .mask = PINMODE_OUTPUT },
+ .description = "NeoPixels"
};
hal.periph_port.register_pin(&neopixels);
@@ -3049,16 +3085,18 @@ bool driver_init (void)
#if MPG_MODE == 1
#if KEYPAD_ENABLE == 2
- if((hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL), MPG_STREAM_DUPLEX, keypad_enqueue_keycode)))
- protocol_enqueue_foreground_task(modeEnable, NULL);
+ if((hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL, NULL), false, keypad_enqueue_keycode)))
+ protocol_enqueue_foreground_task(mpg_enable, NULL);
#else
- if((hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL), MPG_STREAM_DUPLEX, NULL)))
- protocol_enqueue_foreground_task(modeEnable, NULL);
+ if((hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL, NULL), false, NULL)))
+ protocol_enqueue_foreground_task(mpg_enable, NULL);
#endif
#elif MPG_MODE == 2
- hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL), 0, keypad_enqueue_keycode);
+ hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL, NULL), false, keypad_enqueue_keycode);
+#elif MPG_MODE == 3
+ hal.driver_cap.mpg_mode = stream_mpg_register(stream_open_instance(MPG_STREAM, 115200, NULL, NULL), false, stream_mpg_check_enable);
#elif KEYPAD_ENABLE == 2
- stream_open_instance(KEYPAD_STREAM, 115200, keypad_enqueue_keycode);
+ stream_open_instance(KEYPAD_STREAM, 115200, keypad_enqueue_keycode, "Keypad");
#endif
#if WIFI_ENABLE
@@ -3079,6 +3117,39 @@ bool driver_init (void)
return hal.version == 10;
}
+void pin_debounce (void *pin)
+{
+ input_signal_t *input = (input_signal_t *)pin;
+
+#if SAFETY_DOOR_ENABLE
+ if(input->id == Input_SafetyDoor)
+ debounce.safety_door = Off;
+#endif
+
+ if(input->mode.irq_mode == IRQ_Mode_Change ||
+ DIGITAL_IN(input->pin) == (input->mode.irq_mode == IRQ_Mode_Falling ? 0 : 1))
+ switch(input->group) {
+
+ case PinGroup_Limit:
+ case PinGroup_LimitMax:
+ hal.limits.interrupt_callback(limitsGetState());
+ break;
+
+ case PinGroup_Control:
+ hal.control.interrupt_callback(systemGetState());
+ break;
+
+ case PinGroup_AuxInput:
+ ioports_event(input);
+ break;
+
+ default:
+ break;
+ }
+
+ gpio_intr_enable(input->pin);
+}
+
/* interrupt handlers */
// Main stepper driver
@@ -3098,21 +3169,17 @@ IRAM_ATTR static void stepper_driver_isr (void *arg)
IRAM_ATTR static void gpio_limit_isr (void *signal)
{
- if(((input_signal_t *)signal)->debounce) {
- ((input_signal_t *)signal)->active = true;
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
- xTimerStartFromISR(debounceTimer, &xHigherPriorityTaskWoken);
- } else
+ if(((input_signal_t *)signal)->debounce)
+ task_add_delayed(pin_debounce, (input_signal_t *)signal, 40);
+ else
hal.limits.interrupt_callback(limitsGetState());
}
IRAM_ATTR static void gpio_control_isr (void *signal)
{
- if(((input_signal_t *)signal)->debounce) {
- ((input_signal_t *)signal)->active = true;
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
- xTimerStartFromISR(debounceTimer, &xHigherPriorityTaskWoken);
- } else
+ if(((input_signal_t *)signal)->debounce)
+ task_add_delayed(pin_debounce, (input_signal_t *)signal, 40);
+ else
hal.control.interrupt_callback(systemGetState());
}
@@ -3146,12 +3213,10 @@ IRAM_ATTR static void gpio_i2c_strobe_isr (void *signal)
#else // ETHERNET_ENABLE
- //GPIO intr process
+//GPIO IRQ process
IRAM_ATTR static void gpio_isr (void *arg)
{
- bool debounce = false;
uint32_t grp = 0, intr_status[2];
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
gpio_ll_get_intr_status(&GPIO, GRBLHAL_TASK_CORE, &intr_status[0]); // get interrupt status for GPIO0-31
gpio_ll_get_intr_status_high(&GPIO, GRBLHAL_TASK_CORE, &intr_status[1]); // get interrupt status for GPIO32-39
@@ -3162,29 +3227,28 @@ IRAM_ATTR static void gpio_isr (void *arg)
do {
i--;
if(intr_status[inputpin[i].offset] & inputpin[i].mask) {
-
- if(inputpin[i].group & PinGroup_AuxInput)
+ if(inputpin[i].mode.debounce && task_add_delayed(pin_debounce, &inputpin[i], 40)) {
+#if SAFETY_DOOR_ENABLE
+ if(inputpin[i].id == Input_SafetyDoor)
+ debounce.safety_door = On;
+#endif
+ gpio_intr_disable(inputpin[i].pin);
+ } else if(inputpin[i].group & PinGroup_AuxInput)
ioports_event(&inputpin[i]);
- else {
- inputpin[i].active = true;
- if(inputpin[i].debounce)
- debounce = true;
- else
- grp |= inputpin[i].group;
- }
+ else
+ grp |= inputpin[i].group;
}
} while(i);
- if(debounce)
- xTimerStartFromISR(debounceTimer, &xHigherPriorityTaskWoken);
-
if(grp & (PinGroup_Limit|PinGroup_LimitMax))
hal.limits.interrupt_callback(limitsGetState());
if(grp & PinGroup_Control)
hal.control.interrupt_callback(systemGetState());
-#if MPG_MODE == 1
+#if !AUX_CONTROLS_ENABLED
+
+ #if MPG_MODE == 1
static bool mpg_mutex = false;
@@ -3193,15 +3257,14 @@ IRAM_ATTR static void gpio_isr (void *arg)
protocol_enqueue_foreground_task(modeChange, NULL);
mpg_mutex = false;
}
-#endif
+ #endif
-#if I2C_STROBE_ENABLE
+ #if I2C_STROBE_ENABLE
if((grp & PinGroup_Keypad) && i2c_strobe.callback)
i2c_strobe.callback(0, DIGITAL_IN(I2C_STROBE_PIN));
-#endif
+ #endif
- if(xHigherPriorityTaskWoken)
- portYIELD_FROM_ISR();
+#endif
}
#endif
diff --git a/main/driver.h b/main/driver.h
index 263a84e..5a193bc 100644
--- a/main/driver.h
+++ b/main/driver.h
@@ -9,18 +9,18 @@
Copyright (c) 2011-2015 Sungeun K. Jeon
Copyright (c) 2009-2011 Simen Svale Skogsrud
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#ifndef __DRIVER_H__
@@ -114,6 +114,10 @@ typedef struct {
// End configuration
+#if !USB_SERIAL_CDC && ((MODBUS_ENABLE & MODBUS_RTU_ENABLED) || TRINAMIC_UART_ENABLE || MPG_ENABLE || (KEYPAD_ENABLE == 2 && MPG_ENABLE == 0))
+#define ADD_SERIAL2
+#endif
+
#ifdef BOARD_CNC_BOOSTERPACK
#include "boards/cnc_boosterpack_map.h"
#elif defined(BOARD_BDRING_V4)
@@ -128,7 +132,7 @@ typedef struct {
#include "boards/bdring_i2s_6pack_ext_v2_map.h"
#elif defined(BOARD_ESPDUINO32)
#include "boards/espduino-32_wemos_d1_r32_uno_map.h"
-#elif defined(BOARD_SOURCERABBIT_4AXIS)
+#elif defined(BOARD_SOURCERABBIT_4AXIS) || defined(BOARD_SOURCERABBIT_4AXIS_12)
#include "boards/sourcerabbit_4axis.h"
#elif defined(BOARD_PROTONEER_3XX)
#include "boards/protoneer_3.xx_map.h"
@@ -155,7 +159,9 @@ typedef struct {
#elif defined(BOARD_GENERIC_I2S_S3)
#include "boards/generic_i2s_s3_map.h"
#else // default board - NOTE: NOT FINAL VERSION!
+ #ifndef WEB_BUILD
#warning "Compiling for generic board!"
+ #endif
#include "boards/generic_map.h"
#endif
@@ -173,6 +179,12 @@ typedef struct {
#define DRIVER_SPINDLE_PWM_ENABLE 0
#endif
+#if SAFETY_DOOR_ENABLE && !defined(SAFETY_DOOR_PIN)
+#warning "Safety door input is not available!"
+#undef SAFETY_DOOR_ENABLE
+#define SAFETY_DOOR_ENABLE 0
+#endif
+
#if IOEXPAND_ENABLE || EEPROM_ENABLE || KEYPAD_ENABLE == 1 || I2C_STROBE_ENABLE || (TRINAMIC_ENABLE && TRINAMIC_I2C)
#undef I2C_ENABLE
#define I2C_ENABLE 1
@@ -301,25 +313,24 @@ typedef struct {
} adc_map_t;
typedef struct {
- pin_function_t id;
- pin_group_t group;
uint8_t pin;
- uint32_t mask;
+ uint8_t user_port;
uint8_t offset;
- bool invert;
- volatile bool active;
- volatile bool debounce;
+ pin_group_t group;
+ void *port;
+ uint32_t mask;
pin_cap_t cap;
pin_mode_t mode;
+ pin_function_t id;
const adc_map_t *adc;
ioport_interrupt_callback_ptr interrupt_callback;
- aux_ctrl_t *aux_ctrl;
const char *description;
} input_signal_t;
typedef struct {
pin_function_t id;
pin_group_t group;
+ void *port;
uint8_t pin;
esp_pin_t type;
pin_mode_t mode;
diff --git a/main/grbl b/main/grbl
index b200199..06f4426 160000
--- a/main/grbl
+++ b/main/grbl
@@ -1 +1 @@
-Subproject commit b200199612fba6f163d532a5815c48ba23cf6c34
+Subproject commit 06f442643a115ab3acd6722b4afc1fcee8d9d7be
diff --git a/main/ioexpand.c b/main/ioexpand.c
index 9b84dd6..fdcf3f8 100644
--- a/main/ioexpand.c
+++ b/main/ioexpand.c
@@ -4,22 +4,22 @@
I2C I/O expander, PCA9654E - with address pins to GND. PCA9654EA has a different address!
- Part of Grbl
+ Part of grblHAL
- Copyright (c) 2018-2023 Terje Io
+ Copyright (c) 2018-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
@@ -46,6 +46,39 @@ void ioexpand_init (void)
.reserved = 1
};
+ periph_pin_t pin = {
+ .pin = 0,
+ .mode.output = On,
+ .description = "PCA9654"
+ };
+
+ const pin_function_t function[] = {
+ Output_SpindleOn,
+ Output_SpindleDir,
+ Output_CoolantMist,
+ Output_CoolantFlood,
+ Output_StepperEnableX,
+ Output_StepperEnableY,
+ Output_StepperEnableZ
+ };
+
+ const pin_group_t group[] = {
+ PinGroup_SpindleControl,
+ PinGroup_SpindleControl,
+ PinGroup_Coolant,
+ PinGroup_Coolant,
+ PinGroup_StepperEnable,
+ PinGroup_StepperEnable,
+ PinGroup_StepperEnable
+ };
+
+ for(uint32_t i = 0; i < 7; i++) {
+ pin.group = group[i];
+ pin.function = function[i];
+ hal.periph_port.register_pin(&pin);
+ pin.pin++;
+ }
+
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, IOEX_ADDRESS|I2C_MASTER_WRITE, true);
diff --git a/main/ioports.c b/main/ioports.c
index 8c332a9..025d0b6 100644
--- a/main/ioports.c
+++ b/main/ioports.c
@@ -5,18 +5,18 @@
Copyright (c) 2020-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#include "driver.h"
@@ -35,44 +35,80 @@
static io_ports_data_t digital;
static input_signal_t *aux_in;
static output_signal_t *aux_out;
-static ioport_bus_t invert_digital_out;
-static volatile uint32_t event_bits;
-static volatile bool spin_lock = false;
static volatile input_signal_t *event_port;
+static bool digital_out_cfg (xbar_t *output, gpio_out_config_t *config, bool persistent)
+{
+ if(output->id < digital.out.n_ports) {
+
+ if(config->inverted != aux_out[output->id].mode.inverted) {
+ aux_out[output->id].mode.inverted = config->inverted;
+ DIGITAL_OUT(aux_out[output->id].pin, !DIGITAL_IN(aux_out[output->id].pin));
+ }
+/*
+ if(config->open_drain != aux_out[output->id].mode.open_drain) {
+ if((aux_out[output->id].mode.open_drain = config->open_drain))
+ aux_out[output->id].port->OTYPER |= (GPIO_OTYPER_OT_0 << aux_out[output->id].pin);
+ else
+ aux_out[output->id].port->OTYPER &= ~(GPIO_OTYPER_OT_0 << aux_out[output->id].pin);
+ }
+*/
+ if(persistent)
+ ioport_save_output_settings(output, config);
+ }
+
+ return aux_out->id < digital.out.n_ports;
+}
+
static void digital_out (uint8_t port, bool on)
{
if(port < digital.out.n_ports) {
port = ioports_map(digital.out, port);
- DIGITAL_OUT(aux_out[port].pin, ((settings.ioport.invert_out.mask >> port) & 0x01) ? !on : on);
+ DIGITAL_OUT(aux_out[port].pin, aux_out[port].mode.inverted ? !on : on);
}
}
-static float digital_out_state (xbar_t *pin)
+static float digital_out_state (xbar_t *output)
{
float value = -1.0f;
- uint8_t port = pin->function - Output_Aux0;
- if(port < digital.out.n_ports)
- value = (float)(DIGITAL_IN(aux_out[port].pin) ^ aux_out[port].mode.inverted);
+ if(output->id < digital.out.n_ports)
+ value = (float)(DIGITAL_IN(aux_out[output->id].pin) ^ aux_out[output->id].mode.inverted);
return value;
}
-static float digital_in_state (xbar_t *pin)
+static bool digital_in_cfg (xbar_t *input, gpio_in_config_t *config, bool persistent)
+{
+ if(input->id < digital.in.n_ports && config->pull_mode != PullMode_UpDown) {
+
+ aux_in[input->id].mode.inverted = config->inverted;
+ aux_in[input->id].mode.debounce = config->debounce;
+ aux_in[input->id].mode.pull_mode = config->pull_mode;
+/* aux_in[input->id].port->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << (input->pin << 1));
+ aux_in[input->id].port->PUPDR |= (config->pull_mode << (input->pin << 1));*/
+
+ if(persistent)
+ ioport_save_input_settings(input, config);
+ }
+
+ return input->id < digital.in.n_ports;
+}
+
+static float digital_in_state (xbar_t *input)
{
float value = -1.0f;
- uint8_t port = pin->function - Input_Aux0;
- if(port < digital.in.n_ports)
- value = (float)(DIGITAL_IN(aux_in[port].pin) ^ aux_in[port].mode.inverted);
+ if(input->id < digital.in.n_ports)
+ value = (float)(DIGITAL_IN(aux_in[input->id].pin) ^ aux_in[input->id].mode.inverted);
return value;
}
-inline static __attribute__((always_inline)) int32_t get_input (const input_signal_t *input, bool invert, wait_mode_t wait_mode, float timeout)
+
+inline static __attribute__((always_inline)) int32_t get_input (const input_signal_t *input, wait_mode_t wait_mode, float timeout)
{
if(wait_mode == WaitMode_Immediate)
- return DIGITAL_IN(input->pin) ^ invert;
+ return DIGITAL_IN(input->pin) ^ input->mode.inverted;
int32_t value = -1;
uint_fast16_t delay = (uint_fast16_t)ceilf((1000.0f / 50.0f) * timeout) + 1;
@@ -89,7 +125,7 @@ inline static __attribute__((always_inline)) int32_t get_input (const input_sign
do {
if(event_port == input) {
- value = gpio_get_level(input->pin) ^ invert;
+ value = gpio_get_level(input->pin) ^ input->mode.inverted;
break;
}
if(delay) {
@@ -111,8 +147,8 @@ inline static __attribute__((always_inline)) int32_t get_input (const input_sign
bool wait_for = wait_mode != WaitMode_Low;
do {
- if((gpio_get_level(input->pin) ^ invert) == wait_for) {
- value = gpio_get_level(input->pin) ^ invert;
+ if((gpio_get_level(input->pin) ^ input->mode.inverted) == wait_for) {
+ value = gpio_get_level(input->pin) ^ input->mode.inverted;
break;
}
if(delay) {
@@ -132,7 +168,7 @@ IRAM_ATTR static int32_t wait_on_input (io_port_type_t type, uint8_t port, wait_
if(type == Port_Digital && port < digital.in.n_ports) {
port = ioports_map(digital.in, port);
- value = get_input(&aux_in[port], (settings.ioport.invert_in.mask >> port) & 0x01, wait_mode, timeout);
+ value = get_input(&aux_in[port], wait_mode, timeout);
}
return value;
@@ -140,19 +176,10 @@ IRAM_ATTR static int32_t wait_on_input (io_port_type_t type, uint8_t port, wait_
IRAM_ATTR void ioports_event (input_signal_t *input)
{
- spin_lock = true;
event_port = input;
- if(input->interrupt_callback) {
- uint_fast8_t port = digital.in.n_ports;
- do {
- port--;
- if(input == &aux_in[port])
- input->interrupt_callback(ioports_map_reverse(&digital.in, port), DIGITAL_IN(input->pin));
- } while(port);
- }
-
- spin_lock = false;
+ if(input->interrupt_callback)
+ input->interrupt_callback(input->user_port, DIGITAL_IN(input->pin));
}
static bool register_interrupt_handler (uint8_t port, pin_irq_mode_t irq_mode, ioport_interrupt_callback_ptr interrupt_callback)
@@ -173,10 +200,11 @@ static bool register_interrupt_handler (uint8_t port, pin_irq_mode_t irq_mode, i
}
if(irq_mode == IRQ_Mode_None || !ok) {
- while(spin_lock);
+ hal.irq_disable();
gpio_intr_disable(input->pin); // Disable pin interrupt
input->mode.irq_mode = IRQ_Mode_None;
input->interrupt_callback = NULL;
+ hal.irq_enable();
}
}
@@ -186,39 +214,18 @@ static bool register_interrupt_handler (uint8_t port, pin_irq_mode_t irq_mode, i
static xbar_t *get_pin_info (io_port_type_t type, io_port_direction_t dir, uint8_t port)
{
static xbar_t pin;
+
xbar_t *info = NULL;
if(type == Port_Digital) {
- memset(&pin, 0, sizeof(xbar_t));
-
if(dir == Port_Input && port < digital.in.n_ports) {
- port = ioports_map(digital.in, port);
- pin.mode = aux_in[port].mode;
- pin.mode.input = On;
- pin.cap = aux_in[port].cap;
- pin.cap.invert = On;
- pin.cap.claimable = !pin.mode.claimed;
- pin.function = aux_in[port].id;
- pin.group = aux_in[port].group;
- pin.pin = aux_in[port].pin;
- pin.description = aux_in[port].description;
- pin.get_value = digital_in_state;
+ XBAR_SET_DIN_INFO(pin, ioports_map(digital.in, port), aux_in[pin.id], digital_in_cfg, digital_in_state);
info = &pin;
}
if(dir == Port_Output && port < digital.out.n_ports) {
- port = ioports_map(digital.out, port);
- pin.mode = aux_out[port].mode;
- pin.mode.output = On;
- XBAR_SET_CAP(pin.cap, pin.mode);
- pin.cap.invert = On;
- pin.mode.inverted = (settings.ioport.invert_out.mask >> port) & 0x01;
- pin.function = aux_out[port].id;
- pin.group = aux_out[port].group;
- pin.pin = aux_out[port].pin;
- pin.description = aux_out[port].description;
- pin.get_value = digital_out_state;
+ XBAR_SET_DOUT_INFO(pin, ioports_map(digital.out, port), aux_out[pin.id], digital_out_cfg, digital_out_state);
info = &pin;
}
}
@@ -252,10 +259,12 @@ static bool claim (io_port_type_t type, io_port_direction_t dir, uint8_t *port,
for(i = ioports_map_reverse(&digital.in, *port); i < hal.port.num_digital_in ; i++) {
digital.in.map[i] = digital.in.map[i + 1];
+ aux_in[digital.in.map[i]].user_port = i;
aux_in[digital.in.map[i]].description = iports_get_pnum(digital, i);
}
aux_in[*port].mode.claimed = On;
+ aux_in[*port].user_port = hal.port.num_digital_in;
aux_in[*port].description = description;
digital.in.map[hal.port.num_digital_in] = *port;
@@ -318,95 +327,6 @@ bool swap_pins (io_port_type_t type, io_port_direction_t dir, uint8_t port_a, ui
return ok;
}
-static void on_setting_changed (setting_id_t id)
-{
- bool write = false;
- uint_fast8_t port;
-
- switch(id) {
-
- case Settings_IoPort_InvertIn:
- port = digital.in.n_ports;
- do {
- port--;
- aux_in[port].mode.inverted = !!(settings.ioport.invert_in.mask & (1 << port));
- if(aux_in[port].aux_ctrl) {
- write = true;
- if(aux_in[port].mode.inverted)
- settings.control_invert.mask |= aux_in[port].aux_ctrl->cap.mask;
- else
- settings.control_invert.mask &= ~aux_in[port].aux_ctrl->cap.mask;
- }
- } while(port);
- break;
-
- case Settings_IoPort_InvertOut:
- if(invert_digital_out.mask != settings.ioport.invert_out.mask) {
- port = digital.out.n_ports;
- do {
- port--;
- aux_out[port].mode.inverted = !!(settings.ioport.invert_out.mask & (1 << port));
- if(((settings.ioport.invert_out.mask >> port) & 0x01) != ((invert_digital_out.mask >> port) & 0x01))
- DIGITAL_OUT(aux_out[port].pin, !DIGITAL_IN(aux_out[port].pin));
- } while(port);
-
- invert_digital_out = settings.ioport.invert_out;
- }
- break;
-
- case Setting_ControlInvertMask:
- port = digital.in.n_ports;
- do {
- if(aux_in[--port].aux_ctrl) {
- write = true;
- if(settings.control_invert.mask & aux_in[port].aux_ctrl->cap.mask)
- settings.ioport.invert_in.mask |= (1 << port);
- else
- settings.ioport.invert_in.mask &= ~(1 << port);
- aux_in[port].mode.inverted = !!(settings.ioport.invert_in.mask & (1 << port));
- }
- } while(port);
- break;
-
- default:
- break;
- }
-
- if(write)
- settings_write_global();
-}
-
-static void on_settings_loaded (void)
-{
- bool write = false;
- uint_fast8_t port = digital.out.n_ports;
-
- invert_digital_out = settings.ioport.invert_out;
-
- if(digital.out.n_ports) do {
- port--;
- aux_out[port].mode.inverted = !!(settings.ioport.invert_out.mask & (1 << port));
- DIGITAL_OUT(aux_out[port].pin, aux_out[port].mode.inverted);
- } while(port);
-
- port = digital.in.n_ports;
- do {
- if(aux_in[--port].aux_ctrl &&
- !!(settings.control_invert.mask & aux_in[port].aux_ctrl->cap.mask) !=
- !!(settings.ioport.invert_in.mask & (1 << port))) {
- write = true;
- if(settings.control_invert.mask & aux_in[port].aux_ctrl->cap.mask)
- settings.ioport.invert_in.mask |= (1 << port);
- else
- settings.ioport.invert_in.mask &= ~(1 << port);
- }
- aux_in[port].mode.inverted = !!(settings.ioport.invert_in.mask & (1 << port));
- } while(port);
-
- if(write)
- settings_write_global();
-}
-
void ioports_init (pin_group_pins_t *aux_inputs, pin_group_pins_t *aux_outputs)
{
aux_in = aux_inputs->pins.inputs;
@@ -428,7 +348,7 @@ void ioports_init (pin_group_pins_t *aux_inputs, pin_group_pins_t *aux_outputs)
hal.port.swap_pins = swap_pins;
hal.port.get_pin_info = get_pin_info;
- ioports_add_settings(on_settings_loaded, on_setting_changed);
+ ioports_add_settings(NULL, NULL);
} else
hal.port.set_pin_description = NULL;
diff --git a/main/ioports_analog.c b/main/ioports_analog.c
index 096687e..4b2610a 100644
--- a/main/ioports_analog.c
+++ b/main/ioports_analog.c
@@ -5,18 +5,18 @@
Copyright (c) 2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public Licens
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
#include "driver.h"
@@ -163,7 +163,7 @@ static void pwm_set_value (uint_fast8_t ch, float value)
#ifdef AUXOUTPUT0_PWM_PIN
-static bool init_pwm0 (xbar_t *pin, pwm_config_t *config)
+static bool init_pwm0 (xbar_t *pin, pwm_config_t *config, bool persistent)
{
static bool init_ok = false;
@@ -242,7 +242,7 @@ static bool init_pwm0 (xbar_t *pin, pwm_config_t *config)
#ifdef AUXOUTPUT1_PWM_PIN
-static bool init_pwm1 (xbar_t *pin, pwm_config_t *config)
+static bool init_pwm1 (xbar_t *pin, pwm_config_t *config, bool persistent)
{
static bool init_ok = false;
@@ -368,14 +368,14 @@ static xbar_t *get_pin_info (io_port_type_t type, io_port_direction_t dir, uint8
else
#endif
if(aux_in_analog[port].cap.analog) {
- pin.mode = aux_in_analog[port].mode;
- pin.cap = aux_in_analog[port].cap;
+ pin.id = port;
+ pin.mode = aux_in_analog[pin.id].mode;
+ pin.cap = aux_in_analog[pin.id].cap;
pin.cap.claimable = !pin.mode.claimed;
- pin.function = aux_in_analog[port].id;
- pin.group = aux_in_analog[port].group;
- pin.pin = aux_in_analog[port].pin;
- pin.bit = 1 << aux_in_analog[port].pin;
- pin.description = aux_in_analog[port].description;
+ pin.function = aux_in_analog[pin.id].id;
+ pin.group = aux_in_analog[pin.id].group;
+ pin.pin = aux_in_analog[pin.id].pin;
+ pin.description = aux_in_analog[pin.id].description;
info = &pin;
}
}
@@ -386,23 +386,22 @@ static xbar_t *get_pin_info (io_port_type_t type, io_port_direction_t dir, uint8
memset(&pin, 0, sizeof(xbar_t));
if(port < analog.out.n_ports) {
- port = ioports_map(analog.out, port);
- pin.mode = aux_out_analog[port].mode;
+ pin.id = ioports_map(analog.out, port);
+ pin.mode = aux_out_analog[pin.id].mode;
pin.mode.pwm = !pin.mode.servo_pwm; //?? for easy filtering
XBAR_SET_CAP(pin.cap, pin.mode);
- pin.function = aux_out_analog[port].id;
- pin.group = aux_out_analog[port].group;
- pin.pin = aux_out_analog[port].pin;
- pin.bit = 1 << aux_out_analog[port].pin;
- pin.description = aux_out_analog[port].description;
+ pin.function = aux_out_analog[pin.id].id;
+ pin.group = aux_out_analog[pin.id].group;
+ pin.pin = aux_out_analog[pin.id].pin;
+ pin.description = aux_out_analog[pin.id].description;
pin.get_value = pwm_get_value;
#ifdef AUXOUTPUT0_PWM_PIN
- if(aux_out_analog[port].pin == AUXOUTPUT0_PWM_PIN)
- pin.config = (xbar_config_ptr)init_pwm0;
+ if(aux_out_analog[pin.id].pin == AUXOUTPUT0_PWM_PIN)
+ pin.config = init_pwm0;
#endif
#ifdef AUXOUTPUT1_PWM_PIN
- if(aux_out_analog[port].pin == AUXOUTPUT1_PWM_PIN)
- pin.config = (xbar_config_ptr)init_pwm1;
+ if(aux_out_analog[pin.id].pin == AUXOUTPUT1_PWM_PIN)
+ pin.config = init_pwm1;
#endif
info = &pin;
}
@@ -593,7 +592,7 @@ void ioports_init_analog (pin_group_pins_t *aux_inputs, pin_group_pins_t *aux_ou
for(i = 0; i < analog.out.n_ports; i++) {
if((pin = get_pin_info(Port_Analog, Port_Output, i)))
- pin->config(pin, &config);
+ pin->config(pin, &config, false);
}
}
diff --git a/main/keypad b/main/keypad
index 61d86aa..138aeaa 160000
--- a/main/keypad
+++ b/main/keypad
@@ -1 +1 @@
-Subproject commit 61d86aafb4b7d4c01a8506e0d07ba56a402a6149
+Subproject commit 138aeaa3be1ca76ee7108374c3f4aab049f8cb81
diff --git a/main/laser b/main/laser
index c3e3aca..3b25965 160000
--- a/main/laser
+++ b/main/laser
@@ -1 +1 @@
-Subproject commit c3e3aca0d4840fce88c17238a608f50370083e11
+Subproject commit 3b25965519370f314485daea1a5f87ae41e95824
diff --git a/main/my_machine.h b/main/my_machine.h
index 3a0be34..4a55276 100644
--- a/main/my_machine.h
+++ b/main/my_machine.h
@@ -3,18 +3,18 @@
Copyright (c) 2020-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Grbl is distributed in the hope that it will be useful,
+ grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
+ along with grblHAL. If not, see .
*/
// NOTE: Only one board may be enabled!
@@ -53,7 +53,7 @@
// Spindle definitions can be found in grbl/spindle_control.h.
// More here https://github.com/grblHAL/Plugins_spindle
//#define SPINDLE0_ENABLE SPINDLE_HUANYANG1
-//#define SPINDLE0_ENABLE SPINDLE_PWM0_NODIR
+//#define SPINDLE1_ENABLE SPINDLE_PWM0_NODIR
//#define SPINDLE2_ENABLE SPINDLE_NONE
//#define SPINDLE3_ENABLE SPINDLE_NONE
// **********************
@@ -64,8 +64,13 @@
//#define WIFI_SOFTAP 1 // Use Soft AP mode for WiFi.
//#define ETHERNET_ENABLE 1 // Ethernet streaming. Uses networking plugin.
//#define BLUETOOTH_ENABLE 1 // Set to 1 for native radio, 2 for HC-05 module.
-#define SDCARD_ENABLE 2 // Run gcode programs from SD card. Set to 2 to enable YModem upload.
-//#define KEYPAD_ENABLE 1 // I2C keypad for jogging etc., uses keypad plugin.
+//#define SDCARD_ENABLE 1 // Run gcode programs from SD card. Set to 2 to enable YModem upload.
+//#define MPG_ENABLE 1 // Enable MPG interface. Requires a serial port and means to switch between normal and MPG mode.
+ // 1: Mode switching is by handshake pin input unless the keypad plugin is enabled in mode 2 which
+ // uses mode switching by the CMD_MPG_MODE_TOGGLE (0x8B) command character.
+ // 2: Mode switching is by the CMD_MPG_MODE_TOGGLE command character. The keypad plugin is not required.
+//#define KEYPAD_ENABLE 1 // 1: uses a I2C keypad for input.
+ // 2: uses a serial port for input. If MPG_ENABLE is set to 1 the serial stream is shared with the MPG.
//#define PPI_ENABLE 1 // Laser PPI plugin. To be completed.
//#define LASER_COOLANT_ENABLE 1 // Laser coolant plugin. To be completed.
//#define LB_CLUSTERS_ENABLE 1 // LaserBurn cluster support.
diff --git a/main/networking b/main/networking
index f87c17f..b4cdfd9 160000
--- a/main/networking
+++ b/main/networking
@@ -1 +1 @@
-Subproject commit f87c17f26c24e8eec585c0663779a8904b64001c
+Subproject commit b4cdfd9f11ea797fc2708b795e8dd8c6293f9a70
diff --git a/main/sdcard b/main/sdcard
index 686e114..dc208df 160000
--- a/main/sdcard
+++ b/main/sdcard
@@ -1 +1 @@
-Subproject commit 686e1145601d9652c0a03e8420cc6b96ddb02238
+Subproject commit dc208df956add3944dcd8752bf658a8fa73b6b0d
diff --git a/main/spi.c b/main/spi.c
index b075727..bf10ada 100644
--- a/main/spi.c
+++ b/main/spi.c
@@ -118,7 +118,7 @@ uint8_t spi_get_byte (void)
uint8_t spi_put_byte (uint8_t byte)
{
- esp_err_t err;
+// esp_err_t err;
// err = spi_device_acquire_bus(handle, portMAX_DELAY);
// if (err != ESP_OK) return err;
diff --git a/main/spindle b/main/spindle
index 7056c25..8069ca2 160000
--- a/main/spindle
+++ b/main/spindle
@@ -1 +1 @@
-Subproject commit 7056c25b302f0719dd3ac1c52e8bb0a1b4624463
+Subproject commit 8069ca2093b8915cfefbe029b772377a6102286a
diff --git a/main/trinamic_if.c b/main/trinamic_if.c
index e4422d8..7f72e64 100644
--- a/main/trinamic_if.c
+++ b/main/trinamic_if.c
@@ -261,10 +261,8 @@ void board_init (void)
const io_stream_t *stream;
- if((stream = stream_open_instance(TRINAMIC_STREAM, 230400, NULL)) == NULL)
+ if((stream = stream_open_instance(TRINAMIC_STREAM, 230400, NULL, "Trinamic UART")) == NULL)
stream = stream_null_init(230400);
- else
- stream_set_description(stream, "Trinamic UART");
if(stream) {
memcpy(&tmc_uart, stream, sizeof(io_stream_t));
diff --git a/main/webui b/main/webui
index 60dddcc..8e6e51b 160000
--- a/main/webui
+++ b/main/webui
@@ -1 +1 @@
-Subproject commit 60dddcc13259f4d564e475ba8055d34000df4354
+Subproject commit 8e6e51ba8eda14864712ab14fc31c026a4751c05