0

私は、2 つの半二重 UART と 1 つの全二重 UART を含む組み込みプロジェクトに取り組んでいます。

UART1 はデバイス A に接続されます。UART2 はデバイス B に接続され、UART3 は PC に接続されます。UART1 と UART2 は半二重であるため、RX/TX モードを適切に設定する必要があります。

UART1 の信号がトリガーされると、UART2 はデバイス B からデータをフェッチします。そのデータはバッファに入れられ、UART1 と UART3 に送り返されます。デバイス A はデータを消費し、UART1 でさらに項目を送信します。デバイス B が応答するには、そのデータを UART2 に渡す必要があります。

TX/RX モード間の切り替えモードを処理できる効率的なステート マシンについて考えていましたが、これまでのところ、私の UART コードは割り込み駆動型です。このプログラムの流れに取り組むには、どのような方法がありますか?

4

1 に答える 1

0

I don't think you will need a state machine for this case. Why not just hook up all interrupts accordingly and just forward anything received from one devivce to the other(s)?

You may want to include a TX (ring-)buffer to accomodate for different speeds of each UART and then just have a RX-ISR write the data received to the appropriate TX buffer(s), from where it will then be consumed by the other UARTs' UDRE-ISRs.

于 2013-08-27T14:31:33.773 に答える