|
1 | | -use crate::ringbuf::{Consumer, Producer, RingBuffer}; |
2 | | -use embedded_hal_nb as e_nb; |
3 | | -use embedded_io as e_io; |
4 | | - |
| 1 | +mod uart_dma_ringbuf_rx; |
| 2 | +pub use uart_dma_ringbuf_rx::*; |
5 | 3 | mod uart_it; |
| 4 | +pub use uart_it::*; |
6 | 5 | mod uart_poll; |
| 6 | +pub use uart_poll::*; |
| 7 | + |
| 8 | +use embedded_hal_nb as e_nb; |
| 9 | +use embedded_io as e_io; |
7 | 10 |
|
8 | 11 | pub use core::convert::Infallible; |
9 | | -pub use uart_it::*; |
10 | | -pub use uart_poll::*; |
11 | 12 |
|
12 | 13 | // pub mod uart_dma_tx; |
13 | 14 | // pub use uart_dma_tx::*; |
14 | | -// pub mod uart_dma_ringbuf_rx; |
15 | | -// pub use uart_dma_ringbuf_rx::*; |
16 | 15 | // pub mod uart_dma_ringbuf_tx; |
17 | 16 | // pub use uart_dma_ringbuf_tx::*; |
18 | 17 |
|
19 | | -/// UART Transmitter |
20 | | -pub struct Tx<U> { |
21 | | - uart: [U; 2], |
22 | | -} |
23 | | - |
24 | | -impl<U: UartPeriph> Tx<U> { |
25 | | - pub(crate) fn new(uart: [U; 2]) -> Self { |
26 | | - Self { uart } |
27 | | - } |
28 | | - |
29 | | - // pub fn get_interrupt_handler(&self) -> UartInterrupt<U> { |
30 | | - // UartInterrupt::new(unsafe { self.uart.steal_mut() }) |
31 | | - // } |
32 | | - |
33 | | - pub fn into_poll(self, retry_times: u32, flush_retry_times: u32) -> UartPollTx<U> { |
34 | | - let [uart, _] = self.uart; |
35 | | - UartPollTx::<U>::new(uart, retry_times, flush_retry_times) |
36 | | - } |
37 | | - |
38 | | - pub fn into_interrupt( |
39 | | - self, |
40 | | - buf_size: usize, |
41 | | - transmit_retry_times: u32, |
42 | | - flush_retry_times: u32, |
43 | | - ) -> (UartInterruptTx<U>, UartInterruptTxHandler<U>) { |
44 | | - let (w, r) = RingBuffer::<u8>::new(buf_size); |
45 | | - let [u1, u2] = self.uart; |
46 | | - ( |
47 | | - UartInterruptTx::new(u1, w, transmit_retry_times, flush_retry_times), |
48 | | - UartInterruptTxHandler::new(u2, r), |
49 | | - ) |
50 | | - } |
51 | | - |
52 | | - // pub fn into_dma<CH>(self, dma_ch: CH) -> UartDmaTx<U, CH> |
53 | | - // where |
54 | | - // CH: BindDmaTx<U>, |
55 | | - // { |
56 | | - // UartDmaTx::<U, CH>::new(self.uart, dma_ch) |
57 | | - // } |
58 | | - |
59 | | - // pub fn into_dma_ringbuf<CH>(self, dma_ch: CH, buf_size: usize) -> UartDmaBufTx<U, CH> |
60 | | - // where |
61 | | - // CH: BindDmaTx<U>, |
62 | | - // { |
63 | | - // UartDmaBufTx::<U, CH>::new(self.uart, dma_ch, buf_size) |
64 | | - // } |
65 | | -} |
66 | | - |
67 | | -// ------------------------------------------------------------------------------------------------ |
68 | | - |
69 | | -/// UART Receiver |
70 | | -pub struct Rx<U: UartPeriph> { |
71 | | - uart: [U; 2], |
72 | | -} |
73 | | - |
74 | | -impl<U: UartPeriph> Rx<U> { |
75 | | - pub(crate) fn new(uart: [U; 2]) -> Self { |
76 | | - Self { uart } |
77 | | - } |
78 | | - |
79 | | - pub fn into_poll(self, retry_times: u32, continue_retry_times: u32) -> UartPollRx<U> { |
80 | | - let [uart, _] = self.uart; |
81 | | - UartPollRx::<U>::new(uart, retry_times, continue_retry_times) |
82 | | - } |
83 | | - |
84 | | - pub fn into_interrupt( |
85 | | - self, |
86 | | - buf_size: usize, |
87 | | - retry_times: u32, |
88 | | - ) -> (UartInterruptRx<U>, UartInterruptRxHandler<U>) { |
89 | | - let (w, r) = RingBuffer::<u8>::new(buf_size); |
90 | | - let [u1, u2] = self.uart; |
91 | | - ( |
92 | | - UartInterruptRx::new(u1, r, retry_times), |
93 | | - UartInterruptRxHandler::new(u2, w), |
94 | | - ) |
95 | | - } |
96 | | - |
97 | | - // pub fn into_dma_circle<CH>(self, dma_ch: CH, buf_size: usize) -> UartDmaBufRx<U, CH> |
98 | | - // where |
99 | | - // CH: BindDmaRx<U>, |
100 | | - // { |
101 | | - // UartDmaBufRx::<U, CH>::new(self.uart, dma_ch, buf_size) |
102 | | - // } |
103 | | -} |
104 | | - |
105 | 18 | // ------------------------------------------------------------------------------------------------ |
106 | 19 |
|
107 | 20 | // UART idle interrupt handler |
|
0 commit comments