From e5f70e369d8f783e46c8335946da246be3aaf466 Mon Sep 17 00:00:00 2001 From: Denys Rtveliashvili Date: Thu, 26 Oct 2023 07:04:44 +0100 Subject: [PATCH] One more attempt --- examples/serial_echo.rs | 4 ++-- src/serial.rs | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/serial_echo.rs b/examples/serial_echo.rs index 5a51185..f97c4d6 100644 --- a/examples/serial_echo.rs +++ b/examples/serial_echo.rs @@ -15,7 +15,7 @@ use cortex_m_rt::entry; use stm32f7xx_hal::{ pac, prelude::*, - serial::{self, Serial}, + serial::{self, Serial, UART}, }; #[entry] @@ -31,7 +31,7 @@ fn main() -> ! { let tx = gpioa.pa9.into_alternate(); let rx = gpiob.pb7.into_alternate(); - let serial = Serial::new( + let serial = Serial::new_async_uart_no_flwctl( p.USART1, (tx, rx), &clocks, diff --git a/src/serial.rs b/src/serial.rs index 69843ab..cc67f7c 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -161,35 +161,35 @@ pub struct Serial { pub trait UART { fn new_async_uart_no_flwctl>( - usart: U, pins: PINS, clocks: &Clocks, config: Config, + uart: U, pins: PINS, clocks: &Clocks, config: Config, ) -> Serial { - Serial::new(usart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232None)) + Serial::new(uart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232None)) } fn new_async_uart_rs232_cts_rts, CTS: PinCts, RTS: PinRts>( - usart: U, pins: PINS, clocks: &Clocks, config: Config, cts: CTS, rts: RTS, + uart: U, pins: PINS, clocks: &Clocks, config: Config, cts: CTS, rts: RTS, ) -> Serial { // TODO Clarify if we can borrow cts and rts and keep them borrowed. // TODO Note that at the moment any CTS and RTS pin of this U(S)ART would be accepted // This may be too flexible. - Serial::new(usart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232CtsRts)) + Serial::new(uart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232CtsRts)) } fn new_async_uart_rs232_cts, CTS: PinCts, RTS: PinRts>( - usart: U, pins: PINS, clocks: &Clocks, config: Config, cts: CTS, + uart: U, pins: PINS, clocks: &Clocks, config: Config, cts: CTS, ) -> Serial { - Serial::new(usart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232Cts)) + Serial::new(uart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232Cts)) } fn new_async_uart_rs232_rts, RTS: PinRts>( - usart: U, pins: PINS, clocks: &Clocks, config: Config, rts: RTS, + uart: U, pins: PINS, clocks: &Clocks, config: Config, rts: RTS, ) -> Serial { - Serial::new(usart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232Rts)) + Serial::new(uart, pins, clocks, config, SerialMode::Async(AsyncFlowControl::Rs232Rts)) } // TODO Add constructors for other modes of operation } -impl UART for Serial where PINS: Pins {} +impl UART for Serial where PINS: Pins {} impl UART for Serial where PINS: Pins {} impl UART for Serial where PINS: Pins {} // TODO where is UART8?