@@ -9,32 +9,25 @@ use panic_halt as _;
99use bxcan:: filter:: Mask32 ;
1010use cortex_m_rt:: entry;
1111use nb:: block;
12- use stm32f1xx_hal :: { can:: Can , pac, prelude:: * } ;
12+ use stm32f4xx_hal :: { can:: Can , pac, prelude:: * } ;
1313
1414#[ entry]
1515fn main ( ) -> ! {
1616 let dp = pac:: Peripherals :: take ( ) . unwrap ( ) ;
1717
18- let mut flash = dp. FLASH . constrain ( ) ;
1918 let mut rcc = dp. RCC . constrain ( ) ;
2019
2120 // To meet CAN clock accuracy requirements an external crystal or ceramic
2221 // resonator must be used. The blue pill has a 8MHz external crystal.
2322 // Other boards might have a crystal with another frequency or none at all.
24- rcc. cfgr . use_hse ( 8 . mhz ( ) ) . freeze ( & mut flash. acr ) ;
25-
26- let mut afio = dp. AFIO . constrain ( & mut rcc. apb2 ) ;
23+ rcc. cfgr . use_hse ( 8 . mhz ( ) ) . freeze ( ) ;
2724
2825 let mut can1 = {
29- #[ cfg( not( feature = "connectivity" ) ) ]
30- let can = Can :: new ( dp. CAN1 , & mut rcc. apb1 , dp. USB ) ;
31- #[ cfg( feature = "connectivity" ) ]
3226 let can = Can :: new ( dp. CAN1 , & mut rcc. apb1 ) ;
3327
34- let mut gpioa = dp. GPIOA . split ( & mut rcc. apb2 ) ;
35- let rx = gpioa. pa11 . into_floating_input ( & mut gpioa. crh ) ;
36- let tx = gpioa. pa12 . into_alternate_push_pull ( & mut gpioa. crh ) ;
37- can. assign_pins ( ( tx, rx) , & mut afio. mapr ) ;
28+ let mut gpioa = dp. GPIOA . split ( ) ;
29+ let rx = gpioa. pa11 . into_floating_input ( ) ;
30+ let tx = gpioa. pa12 . into_alternate_af7 ( ) ;
3831
3932 bxcan:: Can :: new ( can)
4033 } ;
@@ -48,14 +41,12 @@ fn main() -> ! {
4841 let mut filters = can1. modify_filters ( ) ;
4942 filters. enable_bank ( 0 , Mask32 :: accept_all ( ) ) ;
5043
51- #[ cfg( feature = "connectivity" ) ]
5244 let can2 = {
5345 let can = Can :: new ( dp. CAN2 , & mut rcc. apb1 ) ;
5446
55- let mut gpiob = dp. GPIOB . split ( & mut rcc. apb2 ) ;
56- let rx = gpiob. pb5 . into_floating_input ( & mut gpiob. crl ) ;
57- let tx = gpiob. pb6 . into_alternate_push_pull ( & mut gpiob. crl ) ;
58- can. assign_pins ( ( tx, rx) , & mut afio. mapr ) ;
47+ let mut gpiob = dp. GPIOB . split ( ) ;
48+ let rx = gpiob. pb5 . into_floating_input ( ) ;
49+ let tx = gpiob. pb6 . into_alternate_af7 ( ) ;
5950
6051 let mut can2 = bxcan:: Can :: new ( can) ;
6152 can2. configure ( |config| {
0 commit comments