@@ -2,13 +2,14 @@ use core::fmt;
22use core:: marker:: PhantomData ;
33use core:: ptr;
44
5+ use nb:: block;
6+
57use crate :: gpio:: { gpioa:: * , gpiob:: * , gpioc:: * , gpiod:: * , gpioe:: * } ;
68use crate :: gpio:: { PinMode , AltMode } ;
79use crate :: hal;
810use crate :: hal:: prelude:: * ;
911pub use crate :: pac:: { LPUART1 , USART1 , USART2 , USART4 , USART5 } ;
1012use crate :: rcc:: Rcc ;
11- use nb:: block;
1213
1314#[ cfg( any( feature = "stm32l0x2" , feature = "stm32l0x3" ) ) ]
1415use core:: {
@@ -23,7 +24,7 @@ use as_slice::{AsMutSlice, AsSlice};
2324pub use crate :: dma;
2425
2526#[ cfg( any( feature = "stm32l0x2" , feature = "stm32l0x3" ) ) ]
26- use dma:: Buffer ;
27+ use crate :: dma:: Buffer ;
2728
2829/// Serial error
2930#[ derive( Debug ) ]
@@ -581,7 +582,7 @@ macro_rules! usart {
581582 }
582583 }
583584
584- #[ cfg( any( feature = "stm32l0x2" , feature = "stm32l0x3" ) ) ]
585+ #[ cfg( any( feature = "stm32l0x2" , feature = "stm32l0x3" ) ) ]
585586 impl Tx <$USARTX> {
586587 pub fn write_all<Buffer , Channel >( self ,
587588 dma: & mut dma:: Handle ,
@@ -638,17 +639,27 @@ macro_rules! usart {
638639 }
639640}
640641
641- #[ cfg( feature = "stm32l0x1" ) ]
642+ // LPUART1 and USART2 are available on category 1/2/3/5 MCUs
643+ #[ cfg( any(
644+ feature = "io-STM32L021" ,
645+ feature = "io-STM32L031" ,
646+ feature = "io-STM32L051" ,
647+ feature = "io-STM32L071" ,
648+ ) ) ]
642649usart ! {
643- LPUART1 : ( lpuart1, apb1enr, lpuart1en, apb1_clk, Serial1Ext ) ,
650+ LPUART1 : ( lpuart1, apb1enr, lpuart1en, apb1_clk, Serial1LpExt ) ,
644651 USART2 : ( usart2, apb1enr, usart2en, apb1_clk, Serial2Ext ) ,
645652}
646653
647- #[ cfg( any( feature = "stm32l0x2" , feature = "stm32l0x3" ) ) ]
654+ // USART1 is available on category 3/5 MCUs
655+ #[ cfg( any( feature = "io-STM32L051" , feature = "io-STM32L071" ) ) ]
648656usart ! {
649- LPUART1 : ( lpuart1, apb1enr, lpuart1en, apb1_clk, Serial1LpExt ) ,
650657 USART1 : ( usart1, apb2enr, usart1en, apb1_clk, Serial1Ext ) ,
651- USART2 : ( usart2, apb1enr, usart2en, apb1_clk, Serial2Ext ) ,
658+ }
659+
660+ // USART4 and USART5 are available on category 5 MCUs
661+ #[ cfg( feature = "io-STM32L071" ) ]
662+ usart ! {
652663 USART4 : ( usart4, apb1enr, usart4en, apb1_clk, Serial4Ext ) ,
653664 USART5 : ( usart5, apb1enr, usart5en, apb1_clk, Serial5Ext ) ,
654665}
0 commit comments