|
@@ -56,8 +56,9 @@ BOOL xMBPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits,
|
|
* set 485 mode receive and transmit control IO
|
|
* set 485 mode receive and transmit control IO
|
|
* @note MODBUS_SLAVE_RT_CONTROL_PIN_INDEX need be defined by user
|
|
* @note MODBUS_SLAVE_RT_CONTROL_PIN_INDEX need be defined by user
|
|
*/
|
|
*/
|
|
|
|
+#if defined(RT_MODBUS_SLAVE_USE_CONTROL_PIN)
|
|
rt_pin_mode(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT);
|
|
rt_pin_mode(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT);
|
|
-
|
|
|
|
|
|
+#endif
|
|
/* set serial name */
|
|
/* set serial name */
|
|
if (ucPORT == 1) {
|
|
if (ucPORT == 1) {
|
|
#if defined(RT_USING_UART1) || defined(RT_USING_REMAP_UART1)
|
|
#if defined(RT_USING_UART1) || defined(RT_USING_REMAP_UART1)
|
|
@@ -127,12 +128,16 @@ void vMBPortSerialEnable(BOOL xRxEnable, BOOL xTxEnable)
|
|
/* enable RX interrupt */
|
|
/* enable RX interrupt */
|
|
serial->ops->control(serial, RT_DEVICE_CTRL_SET_INT, (void *)RT_DEVICE_FLAG_INT_RX);
|
|
serial->ops->control(serial, RT_DEVICE_CTRL_SET_INT, (void *)RT_DEVICE_FLAG_INT_RX);
|
|
/* switch 485 to receive mode */
|
|
/* switch 485 to receive mode */
|
|
|
|
+#if defined(RT_MODBUS_SLAVE_USE_CONTROL_PIN)
|
|
rt_pin_write(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_LOW);
|
|
rt_pin_write(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_LOW);
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
/* switch 485 to transmit mode */
|
|
/* switch 485 to transmit mode */
|
|
|
|
+#if defined(RT_MODBUS_SLAVE_USE_CONTROL_PIN)
|
|
rt_pin_write(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_HIGH);
|
|
rt_pin_write(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_HIGH);
|
|
|
|
+#endif
|
|
/* disable RX interrupt */
|
|
/* disable RX interrupt */
|
|
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_FLAG_INT_RX);
|
|
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_FLAG_INT_RX);
|
|
}
|
|
}
|