导航

在AT91ARM中要实现multidrop mode,需要完成如下三点:

1,将PAR field in the Mode Register (US_MR) should be programmed to 0x06/0x07.

2.if Send is an address.you need Write SENDA to US_CR.(this flag will clean after this BYTE is been sendout automatically)

3.if send is data address,do nothing.

本人实际使用背景如下

所有数据包开始的第一个Byte代表地址,表示该串行数据的目的地址。其后的表示是为该地址的从机准备的数据。

所以本人只需要在每一次发送之前实现上述三点就可。

核心代码如下:

void Send_with_addr(struct uart_port *port)
{
    UART_PUT_MR(port, (UART_GET_MR(port) & (unsigned int)~ATMEL_US_PAR) |
                                    ATMEL_US_PAR_MULTI_DROP);
    /*Just set to MultiDrop Do not feed any thing  */
    UART_PUT_CR(port, ATMEL_US_SENDA);

}

在从Ldisc 调用 tty->driver->ops->write 将数据写入底层驱动前调用上述函数即可。

实际上,并不是每次都要求设定multidrop模式,关键的就是什么时候Write to US_CR.

如下是一示波器的现实,附录其数据分析。

mtdrop