UART初始化:prevent UART拉RTS高 [英] UART initialisation: Prevent UART to pull RTS high
问题描述
我在写Linux上的ARM AT91SAM9260板RS485驱动程序。
I'm writing a RS485 driver for an ARM AT91SAM9260 board on Linux.
当我初始化UART,RTS信号线变高(1)。我想这将并应在RS232操作模式的标准行为。在RS485方式然而,这是不想要的。
When I initialise the UART, the RTS signal line gets high (1). I guess this would and should be the standard behaviour in RS232 operation mode. In RS485 mode however this is not wanted.
我使用的胳膊拱部分提供初始化UART的标准功能。因此,显著步骤是:
I'm using the standard functions provided by the arm-arch section to initialise the UART. Therefore the significant steps are:
at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
//consisting of:
// >> configure/mux the pins
at91_set_A_periph(AT91_PIN_PB10, 1); /* TXD */
at91_set_A_periph(AT91_PIN_PB11, 0); /* RXD */
if (pins & ATMEL_UART_RTS)
at91_set_B_periph(AT91_PIN_PC8, 0); /* RTS */
if (pins & ATMEL_UART_CTS)
at91_set_B_periph(AT91_PIN_PC10, 0); /* CTS */
// >> associate the clock
axm_clock_associate("usart3_clk", &pdev->dev, "usart");
// >> et voilà
正如你可以看到用
As you can see with
at91_set_B_periph(AT91_PIN_PC8,0);
at91_set_B_periph(AT91_PIN_PC8, 0);
RTS管脚上上拉没有被激活。
the pull-up on the RTS pin isn't activated.
-
为什么UART设置RTS高呢?
只是因为这将是标准
在RS232模式行为?
Why does the UART set the RTS high? Just because this would be the standard behaviour in RS232 mode?
那岂不是一个更好的标准
UART的保持沉默,直到结果
操作模式明确设置?
Wouldn't it be a better standard for
the UART to keep silent till the
operation mode is explicitly set?
推荐答案
初始化后,似乎是在许多平台上的标准行为的高RTS信号。这取决于男子汉其中串行操作模式的启动例程预期的接口。
A high RTS signal after initialisation seems to be the standard behaviour on many platforms. It manly depends which serial operation mode the start-up routines anticipates for the interface.
要prevent RTS高上ATMEL AT91SAM9260板上运行Linux,你必须把UART到正确的模式之前流合并at91_set_X_periph()的引脚和注册设备。
To prevent RTS-high on a ATMEL AT91SAM9260 board running Linux, you have to put the UART into the right mode BEFORE muxing at91_set_X_periph() the Pins and register the device.
由于Linux内核2.6.35版本的的 支持RS485方式ATMEL串口驱动程序。在此驱动程序的UART引脚(GPIO)设置有角色之前,正确配置。
Since Linux Kernel Version 2.6.35, the ATMEL serial driver supports the RS485 mode. In this driver the UART is properly configured before setting the Pins (GPIO) to there role.
对于运行较旧版本的Linux嵌入式我的设备,我解决了这个问题,下面一行的codeS:
For my embedded device which is running an older Linux version, I solved the problem with the following line of codes:
/* write control flags */
control |= ATMEL_US_RTSEN;
mode |= ATMEL_US_USMODE_RS485;
UART_PUT(uartbaseaddr, ATMEL_US_CR, control);
UART_PUT(uartbaseaddr, ATMEL_US_MR,mode);
现在,这些引脚可以复用的自己的角色
Now the Pins can be muxed the their role
at91_set_X_periph(RTS_PIN,0);
at91_set_X_periph(RTS_PIN, 0);
这篇关于UART初始化:prevent UART拉RTS高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!