33
44use panic_rtt_target as _;
55
6+ // This example application prints all characters it receives via Serial and sends them back.
7+ //
8+ // NOTES:
9+ // - Depending on the board you're using, `Serial` might need different Tx and Rx pins instead of
10+ // pa9 and pa10 (for example, the STM32f3DISCOVERY board uses pc4 and pc5).
11+ // Check your boards' schematic and adjust the code accordingly.
12+ // - https://docs.rust-embedded.org/discovery/10-serial-communication/nix-tooling.html?highlight=*nix#nix-tooling
13+ // has instructions on how to connect to your Serial device (make sure to adjust the baud rate)
614#[ rtic:: app( device = stm32f3xx_hal:: pac, dispatchers = [ TIM20_BRK , TIM20_UP , TIM20_TRG_COM ] ) ]
715mod app {
816 use dwt_systick_monotonic:: DwtSystick ;
@@ -19,6 +27,7 @@ mod app {
1927 type DwtMono = DwtSystick < 48_000_000 > ;
2028
2129 type SerialType = Serial < pac:: USART1 , ( gpio:: PA9 < AF7 < PushPull > > , gpio:: PA10 < AF7 < PushPull > > ) > ;
30+ // The LED that will light up when data is received via serial
2231 type DirType = gpio:: PE13 < Output < PushPull > > ;
2332
2433 #[ shared]
@@ -46,7 +55,7 @@ mod app {
4655 let mono = DwtSystick :: new ( & mut dcb, dwt, systick, clocks. sysclk ( ) . 0 ) ;
4756
4857 // Initialize the peripherals
49- // DIR
58+ // DIR (the LED that lights up during serial rx)
5059 let mut gpioe = cx. device . GPIOE . split ( & mut rcc. ahb ) ;
5160 let mut dir: DirType = gpioe
5261 . pe13
@@ -57,10 +66,18 @@ mod app {
5766 let mut gpioa = cx. device . GPIOA . split ( & mut rcc. ahb ) ;
5867 let mut pins = (
5968 gpioa
69+ // Tx pin
6070 . pa9
71+ // configure this pin to make use of its `USART1_TX` alternative function
72+ // (AF mapping taken from table 14 "Alternate functions for port A" of the datasheet at
73+ // https://www.st.com/en/microcontrollers-microprocessors/stm32f303vc.html)
6174 . into_af7_push_pull ( & mut gpioa. moder , & mut gpioa. otyper , & mut gpioa. afrh ) ,
6275 gpioa
76+ // Rx pin
6377 . pa10
78+ // configure this pin to make use of its `USART1_RX` alternative function
79+ // (AF mapping taken from table 14 "Alternate functions for port A" of the datasheet at
80+ // https://www.st.com/en/microcontrollers-microprocessors/stm32f303vc.html)
6481 . into_af7_push_pull ( & mut gpioa. moder , & mut gpioa. otyper , & mut gpioa. afrh ) ,
6582 ) ;
6683 pins. 1 . internal_pull_up ( & mut gpioa. pupdr , true ) ;
0 commit comments