Skip to content

Commit 083197a

Browse files
committed
Update UART remapping usage in document
The interface of UART alternate function remapping has been updated. This commit update the document to reflect the new API. Old interface: - Serial::new(UART, pins, MAPR, /* omit */); New interface (2 ways): - Serial::new(UART.remap(MAPR), pins, /* omit */); - UART.remap(MAPR).serial(/* omit */); Signed-off-by: justapig9020 <justapig9020@gmail.com>
1 parent c561e9e commit 083197a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/serial.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@
6363
//! let pin_rx = gpioa.pa10;
6464
//! // Create an interface struct for USART1 with 9600 Baud
6565
//! let serial = Serial::new(
66-
//! dp.USART1,
66+
//! dp.USART1.remap(&mut afio.mapr),
6767
//! (pin_tx, pin_rx),
68-
//! &mut afio.mapr,
6968
//! Config::default()
7069
//! .baudrate(9600.bps())
7170
//! .wordlength_9bits()
@@ -519,7 +518,17 @@ impl<USART: Instance, Otype, PULL> Serial<USART, Otype, PULL> {
519518
/// Basic usage:
520519
///
521520
/// ```
522-
/// let mut serial = Serial::new(usart, (tx_pin, rx_pin), &mut afio.mapr, 9600.bps(), &mut rcc);
521+
/// let serial = Serial::new(
522+
/// usart.remap(&mut afio.mapr),
523+
/// (tx_pin, rx_pin),
524+
/// 9600.bps(),
525+
/// &mut rcc);
526+
///
527+
/// // Or
528+
///
529+
/// let serial = usart
530+
/// .remap(&mut afio.mapr)
531+
/// .serial((tx_pin, rx_pin), 9600.bps(), &mut rcc);
523532
///
524533
/// // You can split the `Serial`
525534
/// let Serial { tx, rx, token } = serial;

0 commit comments

Comments
 (0)