File tree 1 file changed +7
-13
lines changed
1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -261,8 +261,7 @@ mod tests {
261
261
debug ! ( "temp: {}°C" , temp) ;
262
262
assert ! ( ( 20.0 ..30.0 ) . contains( & temp) , "20.0 < {} < 30.0" , temp) ;
263
263
}
264
-
265
- // TODO: This does not seem to work
264
+
266
265
#[ test]
267
266
fn dac ( ) {
268
267
use super :: * ;
@@ -274,26 +273,21 @@ mod tests {
274
273
let mut delay = cp. SYST . delay ( & rcc. clocks ) ;
275
274
276
275
let gpioa = dp. GPIOA . split ( & mut rcc) ;
277
- let dac1ch1 = dp. DAC1 . constrain ( gpioa. pa4 , & mut rcc) ;
276
+ let pa4 = gpioa. pa4 . into_floating_input ( ) ;
277
+ let dac1ch1 = dp. DAC1 . constrain ( pa4, & mut rcc) ;
278
278
279
279
let gpioa = unsafe { & * GPIOA :: PTR } ;
280
280
281
281
// dac_manual will have its value set manually
282
282
let mut dac = dac1ch1. calibrate_buffer ( & mut delay) . enable ( ) ;
283
283
284
284
dac. set_value ( 0 ) ;
285
- delay. delay_ms ( 100 ) ;
285
+ delay. delay_ms ( 1 ) ;
286
286
assert ! ( is_pax_low( & gpioa, 4 ) ) ;
287
287
288
- /*for i in (0..=4095).step_by(10) {
289
- dac.set_value(i);
290
- delay.delay_ms(1);
291
- defmt::println!("i: {}, is_pax_low: {}", i, gpioa.idr().read().bits());
292
- }
293
-
294
- delay.delay_ms(100);
295
- assert!(!is_pax_low(&gpioa, 4)); // TODO: <---- Why does this not work?
296
- */
288
+ dac. set_value ( 4095 ) ;
289
+ delay. delay_ms ( 1 ) ;
290
+ assert ! ( !is_pax_low( & gpioa, 4 ) ) ;
297
291
}
298
292
}
299
293
You can’t perform that action at this time.
0 commit comments