summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-08-30 12:58:56 +0800
committerGitHub <[email protected]>2018-08-30 12:58:56 +0800
commit830975f66da16c85ab09bcb0695a76c659ebcae9 (patch)
tree1a638ff8b7e62fc0f8bff170b8fb8065a63a8fa9
parenteada5059da7e869aec4556d312cc9f7ef769a8ac (diff)
parent4fb344e759be728522082f4e48df28db91642cf7 (diff)
Merge pull request #1750 from shauew/patch-2
Update portserial_m.c
-rw-r--r--components/net/freemodbus/port/portserial_m.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/components/net/freemodbus/port/portserial_m.c b/components/net/freemodbus/port/portserial_m.c
index eb50cf51d3..f68794a617 100644
--- a/components/net/freemodbus/port/portserial_m.c
+++ b/components/net/freemodbus/port/portserial_m.c
@@ -130,12 +130,16 @@ void vMBMasterPortSerialEnable(BOOL xRxEnable, BOOL xTxEnable)
/* enable RX interrupt */
serial->ops->control(serial, RT_DEVICE_CTRL_SET_INT, (void *)RT_DEVICE_FLAG_INT_RX);
/* switch 485 to receive mode */
+#if defined(RT_MODBUS_MASTER_USE_CONTROL_PIN)
rt_pin_write(MODBUS_MASTER_RT_CONTROL_PIN_INDEX, PIN_LOW);
+#endif
}
else
{
/* switch 485 to transmit mode */
+#if defined(RT_MODBUS_MASTER_USE_CONTROL_PIN)
rt_pin_write(MODBUS_MASTER_RT_CONTROL_PIN_INDEX, PIN_HIGH);
+#endif
/* disable RX interrupt */
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_FLAG_INT_RX);
}