Skip to content

Commit a3ea056

Browse files
committed
Merge remote-tracking branch 'remotes/rtt/master' into chenyong
2 parents a8c9b2f + f7d1931 commit a3ea056

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

components/net/freemodbus/port/portserial_m.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ BOOL xMBMasterPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits,
5757
* set 485 mode receive and transmit control IO
5858
* @note MODBUS_MASTER_RT_CONTROL_PIN_INDEX need be defined by user
5959
*/
60+
#if defined(RT_MODBUS_MASTER_USE_CONTROL_PIN)
6061
rt_pin_mode(MODBUS_MASTER_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT);
62+
#endif
6163

6264
/* set serial name */
6365
if (ucPORT == 1) {
@@ -128,12 +130,16 @@ void vMBMasterPortSerialEnable(BOOL xRxEnable, BOOL xTxEnable)
128130
/* enable RX interrupt */
129131
serial->ops->control(serial, RT_DEVICE_CTRL_SET_INT, (void *)RT_DEVICE_FLAG_INT_RX);
130132
/* switch 485 to receive mode */
133+
#if defined(RT_MODBUS_MASTER_USE_CONTROL_PIN)
131134
rt_pin_write(MODBUS_MASTER_RT_CONTROL_PIN_INDEX, PIN_LOW);
135+
#endif
132136
}
133137
else
134138
{
135139
/* switch 485 to transmit mode */
140+
#if defined(RT_MODBUS_MASTER_USE_CONTROL_PIN)
136141
rt_pin_write(MODBUS_MASTER_RT_CONTROL_PIN_INDEX, PIN_HIGH);
142+
#endif
137143
/* disable RX interrupt */
138144
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_FLAG_INT_RX);
139145
}

0 commit comments

Comments
 (0)