Skip to content

Commit

Permalink
Added generic map for ESP32-S3, refactored UART and lowlevel Trinamic…
Browse files Browse the repository at this point in the history
… driver code.

Removed superfluous definitions in board maps.
  • Loading branch information
terjeio committed Dec 12, 2024
1 parent 50ec32c commit ab34bb1
Show file tree
Hide file tree
Showing 31 changed files with 938 additions and 590 deletions.
2 changes: 1 addition & 1 deletion driver.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
"URL": "https://docs.v1e.com/electronics/jackpot/",
"MAP": "main/boards/jackpot_map.h",
"caps": {
"axes": 4,
"axes": 6,
"digital_in": 0,
"digital_out": 1,
"serial_ports": 2,
Expand Down
4 changes: 2 additions & 2 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ set(NETWORKING_SOURCE

set(TRINAMIC_SPI_SOURCE
spi.c
trinamic_if.c
tmc_spi.c
motors/trinamic.c
trinamic/common.c
trinamic/tmc_interface.c
Expand All @@ -192,7 +192,7 @@ set(TRINAMIC_SPI_SOURCE
)

set(TRINAMIC_UART_SOURCE
trinamic_if.c
tmc_uart.c
motors/trinamic.c
trinamic/common.c
trinamic/tmc_interface.c
Expand Down
4 changes: 0 additions & 4 deletions main/boards/BlackBoxX32_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
#define HAS_BOARD_INIT
#endif

// timer definitions
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

// Stepper Driver Pins
#define STEPPERS_ENABLE_PIN GPIO_NUM_17

Expand Down
11 changes: 4 additions & 7 deletions main/boards/bdring_i2s_6_axis_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
#define USE_I2S_OUT
#define I2S_OUT_PIN_BASE 64

// timer definitions
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

#if SDCARD_ENABLE || TRINAMIC_SPI_ENABLE

// Pin mapping when using SPI mode.
Expand Down Expand Up @@ -131,9 +127,10 @@
#define MOTOR_CS_PIN I2SO(3)
#endif

#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_15
#define UART2_TX_PIN GPIO_NUM_14
#ifdef ADD_SERIAL1
#define SERIAL1_PORT
#define UART1_RX_PIN GPIO_NUM_15
#define UART1_TX_PIN GPIO_NUM_14
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
#define MODBUS_DIRECTION_PIN GPIO_NUM_13
#endif
Expand Down
11 changes: 4 additions & 7 deletions main/boards/bdring_i2s_6pack_ext_v2_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
#define USE_I2S_OUT
#define I2S_OUT_PIN_BASE 64

// timer definitions
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

#if SDCARD_ENABLE

// Pin mapping when using SPI mode.
Expand Down Expand Up @@ -116,9 +112,10 @@
#define PROBE_PIN AUXINPUT0_PIN
#endif

#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_15
#define UART2_TX_PIN GPIO_NUM_14
#ifdef ADD_SERIAL1
#define SERIAL1_PORT
#define UART1_RX_PIN GPIO_NUM_15
#define UART1_TX_PIN GPIO_NUM_14
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
#define MODBUS_DIRECTION_PIN GPIO_NUM_13
#endif
Expand Down
18 changes: 7 additions & 11 deletions main/boards/bdring_i2s_6x_v1_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@
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 <http://www.gnu.org/licenses/>.
along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
*/

#define BOARD_NAME "BDRING 6x External Drives V1.1"

#define USE_I2S_OUT
#define I2S_OUT_PIN_BASE 64

// timer definitions
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

#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.
Expand Down Expand Up @@ -101,8 +97,8 @@
// Define MODBUS spindle pins (exclusive use - can use PWM or modbus since they share output pins)

#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
#define UART2_RX_PIN GPIO_NUM_16
#define UART2_TX_PIN GPIO_NUM_15
#define UART1_RX_PIN GPIO_NUM_16
#define UART1_TX_PIN GPIO_NUM_15
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
#define MODBUS_DIRECTION_PIN GPIO_NUM_14
#endif
Expand Down Expand Up @@ -130,4 +126,4 @@

// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.

// N/A
// N/A
4 changes: 0 additions & 4 deletions main/boards/bdring_v3.5_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@

#define BOARD_NAME "BDRING v3.5"

// timer definitions
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

// Define step pulse output pins.
#define X_STEP_PIN GPIO_NUM_12
#define Y_STEP_PIN GPIO_NUM_14
Expand Down
11 changes: 4 additions & 7 deletions main/boards/bdring_v4_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@

#define BOARD_NAME "BDRING v4"

// timer definitions
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

// Define step pulse output pins.
#define X_STEP_PIN GPIO_NUM_12
#define Y_STEP_PIN GPIO_NUM_26
Expand Down Expand Up @@ -96,9 +92,10 @@
#define PIN_NUM_CS GPIO_NUM_5
#endif

#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_22
#define UART2_TX_PIN GPIO_NUM_21
#ifdef ADD_SERIAL1
#define SERIAL1_PORT
#define UART1_RX_PIN GPIO_NUM_22
#define UART1_TX_PIN GPIO_NUM_21
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
#define MODBUS_DIRECTION_PIN GPIO_NUM_2
#endif
Expand Down
131 changes: 131 additions & 0 deletions main/boards/btt_rodent_map.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
btt_rodent_map.h - An embedded CNC Controller with rs274/ngc (g-code) support
Driver code for ESP32
Part of grblHAL
Copyright (c) 2024 Terje Io
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.
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 grblHAL. If not, see <http://www.gnu.org/licenses/>.
*/

#define BOARD_NAME "BTT Rodent"
#define BOARD_URL "https://github.com/bigtreetech/Rodent/tree/master"
// https://bttwiki.com/Rodent.html

#if KEYPAD_ENABLE == 1
#error No free pins for I2C keypad!
#endif

#define USE_I2S_OUT
#define I2S_OUT_PIN_BASE 64

#define I2S_OUT_BCK GPIO_NUM_22
#define I2S_OUT_WS GPIO_NUM_17
#define I2S_OUT_DATA GPIO_NUM_21

#define X_STEP_PIN I2SO(2)
#define X_DIRECTION_PIN I2SO(1)
#define X_ENABLE_PIN I2SO(0)
#define X_LIMIT_PIN GPIO_NUM_35

#define Y_STEP_PIN I2SO(5)
#define Y_DIRECTION_PIN I2SO(4)
#define Y_ENABLE_PIN I2SO(7)
#define Y_LIMIT_PIN GPIO_NUM_34

#define Z_STEP_PIN I2SO(10)
#define Z_DIRECTION_PIN I2SO(9)
#define Z_ENABLE_PIN I2SO(8)
#define Z_LIMIT_PIN GPIO_NUM_33

// Define ganged axis or A axis step pulse and step direction output pins.
#if N_ABC_MOTORS >= 1
#define M3_AVAILABLE
#define M3_STEP_PIN I2SO(13)
#define M3_DIRECTION_PIN I2SO(12)
#define M3_ENABLE_PIN I2SO(15)
#define M3_LIMIT_PIN GPIO_NUM_32
#endif

// Define ganged axis or B axis step pulse and step direction output pins.
#if N_ABC_MOTORS == 2
#define M4_AVAILABLE
#define M4_STEP_PIN I2SO(18)
#define M4_DIRECTION_PIN I2SO(17)
#define M4_ENABLE_PIN I2SO(16)
#define M4_LIMIT_PIN GPIO_NUM_34
#endif
// Define driver spindle pins

#define AUXOUTPUT0_PIN I2SO(11)
#define AUXOUTPUT0_PIN I2SO(14)
#define AUXOUTPUT0_PIN I2SO(3)

#if DRIVER_SPINDLE_PWM_ENABLE
#define SPINDLE_PWM_PIN GPIO_NUM_13
#else
#define AUXOUTPUT1_PIN GPIO_NUM_13
#endif

#if DRIVER_SPINDLE_DIR_ENABLE
#define SPINDLE_DIRECTION_PIN GPIO_NUM_15
#else
#define AUXOUTPUT3_PIN GPIO_NUM_15
#endif

#if DRIVER_SPINDLE_ENABLE
#define SPINDLE_ENABLE_PIN GPIO_NUM_25
#else
#define AUXOUTPUT4_PIN GPIO_NUM_25
#endif

// Define flood and mist coolant enable output pins.

#define COOLANT_MIST_PIN GPIO_NUM_2
#define COOLANT_FLOOD_PIN GPIO_NUM_3

// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.

// N/A

#define AUXINPUT0_PIN GPIO_NUM_5

#if PROBE_ENABLE
#define PROBE_PIN AUXINPUT0_PIN
#endif

// Define I2C port/pins
#define I2C_PORT I2C_NUM_1
#define I2C_SDA GPIO_NUM_27
#define I2C_SCL GPIO_NUM_26
#define I2C_CLOCK 100000

// 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
#if SDCARD_ENABLE
#define PIN_NUM_CS GPIO_NUM_0
#endif

#ifdef ADD_SERIAL1
#define SERIAL1_PORT
#define UART1_RX_PIN GPIO_NUM_16
#define UART1_TX_PIN GPIO_NUM_15
//#define UART1_RTS_PIN GPIO_NUM_14
#endif
9 changes: 2 additions & 7 deletions main/boards/cnc3040_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@
#define BOARD_NAME "CNC3040 4-axis CNC"
#define BOARD_URL "https://github.com/shaise/GrblCNC/tree/master/Hardware/GrblCnc3040"

// timer definitions
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

#ifdef ADD_SERIAL2
#define UART2_TX_PIN GPIO_NUM_17
#define UART2_RX_PIN GPIO_NUM_16
#ifdef ADD_SERIAL1
#define SERIAL1_PORT // RX: 16, TX: 17
#endif

// Define step pulse output pins.
Expand Down
13 changes: 5 additions & 8 deletions main/boards/cnc_boosterpack_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
#define IOEXPAND_ENABLE 1 // I2C IO expander for some output signals.
#endif

// timer definitions
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

// Define step pulse output pins.
#define X_STEP_PIN GPIO_NUM_26
#define Y_STEP_PIN GPIO_NUM_27
Expand Down Expand Up @@ -90,8 +86,9 @@
#define COOLANT_FLOOD_PIN IOEXPAND
#define COOLANT_MIST_PIN IOEXPAND

#ifdef ADD_SERIAL2
#define UART2_RX_PIN GPIO_NUM_33
#ifdef ADD_SERIAL1
#define SERIAL1_PORT
#define UART1_RX_PIN GPIO_NUM_33
#else
#define AUXINPUT0_PIN GPIO_NUM_33
#endif
Expand Down Expand Up @@ -121,11 +118,11 @@
#define NEOPIXELS_NUM NEOPIXELS_ENABLE
#endif

#ifdef ADD_SERIAL2
#ifdef ADD_SERIAL1
#if MPG_ENABLE == 1
#define MPG_ENABLE_PIN GPIO_NUM_25
#else
#define UART2_TX_PIN GPIO_NUM_25
#define UART1_TX_PIN GPIO_NUM_25
#endif
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
#define MODBUS_DIRECTION_PIN GPIO_NUM_25 //??
Expand Down
Loading

0 comments on commit ab34bb1

Please sign in to comment.