From eea0b9ebf24f010fe239430856ed743c26523179 Mon Sep 17 00:00:00 2001 From: shauew Date: Wed, 29 Aug 2018 18:31:32 +0800 Subject: [PATCH 1/2] Update portserial_m.c add macro to aviod compile error with: rt_pin_mode(MODBUS_MASTER_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT); --- components/net/freemodbus/port/portserial_m.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/net/freemodbus/port/portserial_m.c b/components/net/freemodbus/port/portserial_m.c index 366dc79983..eb50cf51d3 100644 --- a/components/net/freemodbus/port/portserial_m.c +++ b/components/net/freemodbus/port/portserial_m.c @@ -57,7 +57,9 @@ BOOL xMBMasterPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits, * set 485 mode receive and transmit control IO * @note MODBUS_MASTER_RT_CONTROL_PIN_INDEX need be defined by user */ +#if defined(RT_MODBUS_MASTER_USE_CONTROL_PIN) rt_pin_mode(MODBUS_MASTER_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT); +#endif /* set serial name */ if (ucPORT == 1) { From 4fb344e759be728522082f4e48df28db91642cf7 Mon Sep 17 00:00:00 2001 From: shauew Date: Thu, 30 Aug 2018 09:10:52 +0800 Subject: [PATCH 2/2] Update portserial_m.c sorry, miss out other two parts. --- components/net/freemodbus/port/portserial_m.c | 4 ++++ 1 file changed, 4 insertions(+) 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); }