add freemodbus slave contorl pin config in Kconfig
This commit is contained in:
parent
d188fa496c
commit
125235c61c
|
@ -12,6 +12,16 @@ config RT_USING_MODBUS
|
|||
config RT_MODBUS_SLAVE_RTU
|
||||
bool "RTU slave mode"
|
||||
default n
|
||||
if RT_MODBUS_SLAVE_RTU
|
||||
config RT_MODBUS_SLAVE_USE_CONTROL_PIN
|
||||
bool "Use Contorl Pin"
|
||||
default n
|
||||
if RT_MODBUS_SLAVE_USE_CONTROL_PIN
|
||||
config MODBUS_SLAVE_RT_CONTROL_PIN_INDEX
|
||||
int "pin index for RS485 TX/RX select"
|
||||
default 10
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -56,8 +56,9 @@ BOOL xMBPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits,
|
|||
* set 485 mode receive and transmit control IO
|
||||
* @note MODBUS_SLAVE_RT_CONTROL_PIN_INDEX need be defined by user
|
||||
*/
|
||||
//rt_pin_mode(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT);
|
||||
|
||||
#if defined(RT_MODBUS_SLAVE_USE_CONTROL_PIN)
|
||||
rt_pin_mode(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT);
|
||||
#endif
|
||||
/* set serial name */
|
||||
if (ucPORT == 1) {
|
||||
#if defined(RT_USING_UART1) || defined(RT_USING_REMAP_UART1)
|
||||
|
@ -127,12 +128,16 @@ void vMBPortSerialEnable(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 */
|
||||
//rt_pin_write(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_LOW);
|
||||
#if defined(RT_MODBUS_SLAVE_USE_CONTROL_PIN)
|
||||
rt_pin_write(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_LOW);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* switch 485 to transmit mode */
|
||||
//rt_pin_write(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_HIGH);
|
||||
#if defined(RT_MODBUS_SLAVE_USE_CONTROL_PIN)
|
||||
rt_pin_write(MODBUS_SLAVE_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);
|
||||
}
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
/* salve mode: discrete's all address */
|
||||
#define S_DI_RESERVE 0
|
||||
/* slave mode: holding register"s startup address */
|
||||
#define S_SYSTEM_START_ADDR 0x003A
|
||||
#define S_SYSTEM_SLAVE_ID_ADDR 0x0040
|
||||
#define S_SYSTEM_KEEP_TEMP 0x0009
|
||||
|
||||
/* -----------------------Master Defines -------------------------------------*/
|
||||
#define M_DISCRETE_INPUT_START 1
|
||||
|
|
Loading…
Reference in New Issue