[components][freemodbus] update function : xMBPortSerialInit(...) and xMBMasterPortSerialInit(...) | 更新 xMBPortSerialInit() 与 xMBMasterPortSerialInit() 函数
This commit is contained in:
parent
3dd64da78b
commit
4f44fa8f60
|
@ -53,6 +53,7 @@ BOOL xMBPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits,
|
|||
eMBParity eParity)
|
||||
{
|
||||
rt_device_t dev = RT_NULL;
|
||||
char uart_name[20];
|
||||
/**
|
||||
* set 485 mode receive and transmit control IO
|
||||
* @note MODBUS_SLAVE_RT_CONTROL_PIN_INDEX need be defined by user
|
||||
|
@ -61,21 +62,12 @@ BOOL xMBPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits,
|
|||
rt_pin_mode(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT);
|
||||
#endif
|
||||
/* set serial name */
|
||||
if (ucPORT == 1)
|
||||
{
|
||||
dev = rt_device_find("uart1");
|
||||
}
|
||||
else if (ucPORT == 2)
|
||||
{
|
||||
dev = rt_device_find("uart2");
|
||||
}
|
||||
else if (ucPORT == 3)
|
||||
{
|
||||
dev = rt_device_find("uart3");
|
||||
}
|
||||
rt_snprintf(uart_name,sizeof(uart_name), "uart%d", ucPORT);
|
||||
|
||||
dev = rt_device_find(uart_name);
|
||||
if(dev == RT_NULL)
|
||||
{
|
||||
/* can not find uart */
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -54,6 +54,8 @@ BOOL xMBMasterPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits,
|
|||
eMBParity eParity)
|
||||
{
|
||||
rt_device_t dev = RT_NULL;
|
||||
char uart_name[20];
|
||||
|
||||
/**
|
||||
* set 485 mode receive and transmit control IO
|
||||
* @note MODBUS_MASTER_RT_CONTROL_PIN_INDEX need be defined by user
|
||||
|
@ -62,27 +64,19 @@ BOOL xMBMasterPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits,
|
|||
rt_pin_mode(MODBUS_MASTER_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT);
|
||||
#endif
|
||||
/* set serial name */
|
||||
if (ucPORT == 1)
|
||||
{
|
||||
dev = rt_device_find("uart1");
|
||||
}
|
||||
else if (ucPORT == 2)
|
||||
{
|
||||
dev = rt_device_find("uart2");
|
||||
}
|
||||
else if (ucPORT == 3)
|
||||
{
|
||||
dev = rt_device_find("uart3");
|
||||
}
|
||||
rt_snprintf(uart_name,sizeof(uart_name), "uart%d", ucPORT);
|
||||
|
||||
dev = rt_device_find(uart_name);
|
||||
if(dev == RT_NULL)
|
||||
{
|
||||
/* can not find uart */
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
serial = (struct rt_serial_device*)dev;
|
||||
}
|
||||
|
||||
/* set serial configure parameter */
|
||||
serial->config.baud_rate = ulBaudRate;
|
||||
serial->config.stop_bits = STOP_BITS_1;
|
||||
|
@ -216,12 +210,6 @@ static void serial_soft_trans_irq(void* parameter) {
|
|||
RT_WAITING_FOREVER, &recved_event);
|
||||
/* execute modbus callback */
|
||||
prvvUARTTxReadyISR();
|
||||
/* waiting for serial transmit start */
|
||||
// if (rt_event_recv(&event_serial, EVENT_SERIAL_TRANS_START, RT_EVENT_FLAG_OR,RT_WAITING_FOREVER, &recved_event) == RT_EOK )
|
||||
// {
|
||||
// /* execute modbus callback */
|
||||
// prvvUARTTxReadyISR();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue