22// command build: cargo build --example adc_ext_trig_double_dma_serial --features stm32g031
33// command run: cargo run --example adc_ext_trig_double_dma_serial --features stm32g031
44
5- #![ deny( warnings) ]
65#![ no_main]
76#![ no_std]
87
@@ -27,7 +26,7 @@ use cortex_m::interrupt::Mutex;
2726use crate :: hal:: stm32:: { interrupt, Interrupt } ;
2827use hal:: analog:: adc:: { InjTrigSource , Precision , SampleTime } ; //, VTemp
2928
30- use hal:: dma:: { self , Channel , Target } ;
29+ use hal:: dma:: { self , Target , Channel } ;
3130
3231use crate :: hal:: analog:: adc:: DmaMode ;
3332use crate :: hal:: analog:: adc:: InjectMode ;
@@ -120,10 +119,10 @@ fn main() -> ! {
120119 . set_peripheral_address ( adc_data_register_addr, false ) ;
121120 dma. ch1 . set_transfer_length ( adc_buffer1. len ( ) as u16 ) ;
122121
123- hprintln ! ( "adc_data_register_addr {:?}" , adc_buffer1_addr) . unwrap ( ) ; // will output addr in dec
124- // in gdb read the data bytes with: x /32xh 0x??????? (last is addr in hex)
125- // or put addr in dec format: x /32xh 536878092
126- // https://sourceware.org/gdb/current/onlinedocs/gdb/Memory.html
122+ hprintln ! ( "adc_data_register_addr {:?}" , adc_buffer1_addr) ; // will output addr in dec
123+ // in gdb read the data bytes with: x /32xh 0x??????? (last is addr in hex)
124+ // or put addr in dec format: x /32xh 536878092
125+ // https://sourceware.org/gdb/current/onlinedocs/gdb/Memory.html
127126
128127 // dma ch1 reads from ADC register into memory
129128 dma. ch1 . select_peripheral ( hal:: dmamux:: DmaMuxIndex :: ADC ) ;
@@ -162,9 +161,9 @@ fn main() -> ! {
162161 adc. set_sample_time ( SampleTime :: T_80 ) ;
163162 adc. set_precision ( Precision :: B_12 ) ;
164163 let mut pa3 = gpioa. pa5 . into_analog ( ) ;
165- let u_raw: u32 = adc. read ( & mut pa3) . expect ( "adc read failed" ) ;
164+ let u_raw = adc. read ( & mut pa3) . expect ( "adc read failed" ) ;
166165 let u = u_raw. saturating_sub ( 32 ) as f32 / 4_096_f32 * 3.3 ;
167- hprintln ! ( "u: {:.4} V " , u) . unwrap ( ) ;
166+ hprintln ! ( "u: {:.4} V " , u) ;
168167
169168 adc. set_oversampling_ratio ( adc:: OversamplingRatio :: X_16 ) ;
170169 adc. set_oversampling_shift ( 4 ) ;
0 commit comments