Skip to content

Commit

Permalink
Fix for Modbus RTU serial port board definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeio committed Sep 5, 2023
1 parent f7af682 commit 334adea
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion main/BlackBoxX32_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
#define PIN_NUM_CS GPIO_NUM_5
// #endif

#if MODBUS_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
#error BlackBox X32 does not support Modbus
#endif

Expand Down
4 changes: 2 additions & 2 deletions main/bdring_i2s_6_axis_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@

// N/A

#if MODBUS_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
#define UART2_RX_PIN GPIO_NUM_15
#define UART2_TX_PIN GPIO_NUM_14
#if RS485_DIR_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
#define MODBUS_DIRECTION_PIN GPIO_NUM_13
#endif
#endif
Expand Down
6 changes: 3 additions & 3 deletions main/bdring_v4_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

// Define spindle enable and spindle direction output pins.

#if DRIVER_SPINDLE_ENABLE && !MODBUS_ENABLE
#if DRIVER_SPINDLE_ENABLE && !(MODBUS_ENABLE & MODBUS_RTU_ENABLED)
#define SPINDLE_ENABLE_PIN GPIO_NUM_22
#define SPINDLEPWMPIN GPIO_NUM_2
#endif
Expand Down Expand Up @@ -86,10 +86,10 @@
#define PIN_NUM_CS GPIO_NUM_5
#endif

#if MODBUS_ENABLE && !MODBUS_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
#define UART2_RX_PIN GPIO_NUM_22
#define UART2_TX_PIN GPIO_NUM_21
#if RS485_DIR_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
#define MODBUS_DIRECTION_PIN GPIO_NUM_2
#endif
#endif
Expand Down
4 changes: 3 additions & 1 deletion main/cnc_boosterpack_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#define BOARD_NAME "CNC BoosterPack"
#define BOARD_URL "https://github.com/terjeio/CNC_Boosterpack"

#define HAS_IOPORTS

#if TRINAMIC_ENABLE
#ifdef TRINAMIC_MIXED_DRIVERS
#undef TRINAMIC_MIXED_DRIVERS
Expand Down Expand Up @@ -98,7 +100,7 @@
#define AUXINPUT0_PIN GPIO_NUM_33
#endif

#if MODBUS_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
#define UART2_RX_PIN GPIO_NUM_33
#define UART2_TX_PIN GPIO_NUM_25
#if RS485_DIR_ENABLE
Expand Down
2 changes: 1 addition & 1 deletion main/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ extern SemaphoreHandle_t i2cBusy;
#error "I2C port not available!"
#endif

#if MPG_MODE_ENABLE || MODBUS_ENABLE || TRINAMIC_UART_ENABLE || defined(DEBUGOUT)
#if MPG_MODE_ENABLE || (MODBUS_ENABLE & MODBUS_RTU_ENABLED) || TRINAMIC_UART_ENABLE || defined(DEBUGOUT)
#define SERIAL2_ENABLE 1
#else
#define SERIAL2_ENABLE 0
Expand Down
6 changes: 3 additions & 3 deletions main/esp32-hal-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ static void IRAM_ATTR _uart2_isr (void *arg)
uart2->dev->int_clr.frm_err = 1;
uart2->dev->int_clr.rxfifo_tout = 1;

#if MODBUS_ENABLE && defined(MODBUS_DIRECTION_PIN)
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
if(uart2->dev->int_st.tx_done) {
// uart2->dev->int_clr.tx_done = 1;
uart2->dev->int_ena.tx_done = 0;
Expand Down Expand Up @@ -531,14 +531,14 @@ void static serial2Write (const char *s, uint16_t length)
{
char *ptr = (char *)s;

#if MODBUS_ENABLE && defined(MODBUS_DIRECTION_PIN)
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
gpio_set_level(MODBUS_DIRECTION_PIN, true);
#endif

while(length--)
serial2PutC(*ptr++);

#if MODBUS_ENABLE && defined(MODBUS_DIRECTION_PIN)
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
uart2->dev->int_clr.tx_done = 1;
uart2->dev->int_ena.tx_done = 1;
#endif
Expand Down
7 changes: 4 additions & 3 deletions main/espduino-32_wemos_d1_r32_uno_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#endif

// Define flood enable output pin.
#if !MODBUS_ENABLE
#if !(MODBUS_ENABLE & MODBUS_RTU_ENABLED)
#define COOLANT_FLOOD_PIN GPIO_NUM_32
#endif

Expand All @@ -83,11 +83,12 @@
#define PROBE_PIN GPIO_NUM_39
#endif

#if MODBUS_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
#define UART2_RX_PIN GPIO_NUM_33
#define UART2_TX_PIN GPIO_NUM_32
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
#define MODBUS_DIRECTION_PIN GPIO_NUM_15
#define MODBUS_BAUD 19200
#endif
#endif

#if SDCARD_ENABLE
Expand Down
4 changes: 2 additions & 2 deletions main/mks_tinybee_1_0_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@
#define PROBE_PIN GPIO_NUM_35 // MT_DET
#endif

#if MODBUS_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
#define UART2_RX_PIN GPIO_NUM_16 // EXP_1
#define UART2_TX_PIN GPIO_NUM_17 // EXP_1
#if RS485_DIR_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_DIR_ENABLED
#define MODBUS_DIRECTION_PIN GPIO_NUM_13 // EXP_1
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion main/sourcerabbit_4axis.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

#if MODBUS_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
#error VFD Spindle not supported!
#endif

Expand Down
4 changes: 2 additions & 2 deletions main/xPro_v5_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#endif

// Define spindle enable and spindle direction output pins.
#if DRIVER_SPINDLE_ENABLE && !MODBUS_ENABLE
#if DRIVER_SPINDLE_ENABLE && !(MODBUS_ENABLE & MODBUS_RTU_ENABLED)
#define SPINDLE_ENABLE_PIN GPIO_NUM_4
#define SPINDLEPWMPIN GPIO_NUM_25
#endif
Expand Down Expand Up @@ -98,7 +98,7 @@
#define PIN_NUM_CS GPIO_NUM_5
#endif

#if MODBUS_ENABLE
#if MODBUS_ENABLE & MODBUS_RTU_ENABLED
#define UART2_RX_PIN GPIO_NUM_25
#define UART2_TX_PIN GPIO_NUM_4
#endif
Expand Down

0 comments on commit 334adea

Please sign in to comment.