Skip to content

Commit

Permalink
Made it build serial_echo.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
rtvd committed Oct 26, 2023
1 parent e5f70e3 commit c160ab5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/serial_echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() -> ! {
let tx = gpioa.pa9.into_alternate();
let rx = gpiob.pb7.into_alternate();

let serial = Serial::new_async_uart_no_flwctl(
let serial = Serial::new_async_no_flwctl(
p.USART1,
(tx, rx),
&clocks,
Expand Down
24 changes: 12 additions & 12 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ pub struct Serial<U, PINS> {
pins: PINS,
}

pub trait UART<U: Instance> {
fn new_async_uart_no_flwctl<PINS: Pins<U>>(
pub trait UART<U: Instance, PINS: Pins<U>> {
fn new_async_no_flwctl<>(
uart: U, pins: PINS, clocks: &Clocks, config: Config,
) -> Serial<U, PINS> {
Serial::new(uart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232None))
}

fn new_async_uart_rs232_cts_rts<PINS: Pins<U>, CTS: PinCts<U>, RTS: PinRts<U>>(
fn new_async_rs232_cts_rts<CTS: PinCts<U>, RTS: PinRts<U>>(
uart: U, pins: PINS, clocks: &Clocks, config: Config, cts: CTS, rts: RTS,

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f733, stable)

unused variable: `cts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f733, stable)

unused variable: `rts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f756, stable)

unused variable: `cts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f756, stable)

unused variable: `rts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f769, stable)

unused variable: `cts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f769, stable)

unused variable: `rts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f779, stable)

unused variable: `cts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f779, stable)

unused variable: `rts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, stm32f746, true)

unused variable: `cts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, stm32f746, true)

unused variable: `rts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f723, stable)

unused variable: `cts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f723, stable)

unused variable: `rts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f767, stable)

unused variable: `cts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f767, stable)

unused variable: `rts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f746, stable)

unused variable: `cts`

Check warning on line 170 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f746, stable)

unused variable: `rts`
) -> Serial<U, PINS> {
// TODO Clarify if we can borrow cts and rts and keep them borrowed.
Expand All @@ -175,28 +175,28 @@ pub trait UART<U: Instance> {
Serial::new(uart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232CtsRts))
}

fn new_async_uart_rs232_cts<PINS: Pins<U>, CTS: PinCts<U>, RTS: PinRts<U>>(
fn new_async_rs232_cts<CTS: PinCts<U>>(
uart: U, pins: PINS, clocks: &Clocks, config: Config, cts: CTS,

Check warning on line 179 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f733, stable)

unused variable: `cts`

Check warning on line 179 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f756, stable)

unused variable: `cts`

Check warning on line 179 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f769, stable)

unused variable: `cts`

Check warning on line 179 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f779, stable)

unused variable: `cts`

Check warning on line 179 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, stm32f746, true)

unused variable: `cts`

Check warning on line 179 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f723, stable)

unused variable: `cts`

Check warning on line 179 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f767, stable)

unused variable: `cts`

Check warning on line 179 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f746, stable)

unused variable: `cts`
) -> Serial<U, PINS> {
Serial::new(uart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232Cts))
}

fn new_async_uart_rs232_rts<PINS: Pins<U>, RTS: PinRts<U>>(
fn new_async_rs232_rts<RTS: PinRts<U>>(
uart: U, pins: PINS, clocks: &Clocks, config: Config, rts: RTS,

Check warning on line 185 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f733, stable)

unused variable: `rts`

Check warning on line 185 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f756, stable)

unused variable: `rts`

Check warning on line 185 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f769, stable)

unused variable: `rts`

Check warning on line 185 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f779, stable)

unused variable: `rts`

Check warning on line 185 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, stm32f746, true)

unused variable: `rts`

Check warning on line 185 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f723, stable)

unused variable: `rts`

Check warning on line 185 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f767, stable)

unused variable: `rts`

Check warning on line 185 in src/serial.rs

View workflow job for this annotation

GitHub Actions / ci (stm32f746, stable)

unused variable: `rts`
) -> Serial<U, PINS> {
Serial::new(uart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232Rts))
}

// TODO Add constructors for other modes of operation
}
impl <PINS> UART<UART4> for Serial<UART4, PINS> where PINS: Pins<UART4> {}
impl <PINS> UART<UART5> for Serial<UART5, PINS> where PINS: Pins<UART5> {}
impl <PINS> UART<UART7> for Serial<UART7, PINS> where PINS: Pins<UART7> {}
impl <PINS: Pins<UART4>> UART<UART4, PINS> for Serial<UART4, PINS> {}
impl <PINS: Pins<UART5>> UART<UART5, PINS> for Serial<UART5, PINS> {}
impl <PINS: Pins<UART7>> UART<UART7, PINS> for Serial<UART7, PINS> {}
// TODO where is UART8?
impl <PINS> UART<USART1> for Serial<USART1, PINS> where PINS: Pins<USART1> {}
impl <PINS> UART<USART2> for Serial<USART2, PINS> where PINS: Pins<USART2> {}
impl <PINS> UART<USART3> for Serial<USART3, PINS> where PINS: Pins<USART3> {}
impl <PINS> UART<USART6> for Serial<USART6, PINS> where PINS: Pins<USART6> {}
impl <PINS: Pins<USART1>> UART<USART1, PINS> for Serial<USART1, PINS> {}
impl <PINS: Pins<USART2>> UART<USART2, PINS> for Serial<USART2, PINS> {}
impl <PINS: Pins<USART3>> UART<USART3, PINS> for Serial<USART3, PINS> {}
impl <PINS: Pins<USART6>> UART<USART6, PINS> for Serial<USART6, PINS> {}

// TODO add USART trait which would have USART-specific modes like "Synchronous" and "SmartCard"
// TOOD add add implementation of those traits for all USART*
Expand Down

0 comments on commit c160ab5

Please sign in to comment.