@@ -387,7 +387,7 @@ impl Comparator {
387387 /// Configure the function of the comparator
388388 #[ allow( clippy:: missing_inline_in_public_items) ]
389389 pub fn configure ( & self , settings : ComparatorFunction ) -> Result < ( ) , DwtError > {
390- let ( func , emit , data_match , cyc_match , comp , mask ) = match settings {
390+ match settings {
391391 ComparatorFunction :: Address ( settings) => {
392392 // FUNCTION, EMITRANGE
393393 // See Table C1-14
@@ -411,50 +411,45 @@ impl Comparator {
411411 ( _, EmitOption :: PC ) => return Err ( DwtError :: InvalidFunction ) ,
412412 } ;
413413
414- (
415- function,
416- emit_range,
417- // don't compare data value
418- false ,
419- // don't compare cycle counter value
420- // NOTE: only needed for comparator 0, but is SBZP.
421- false ,
422- settings. address ,
423- settings. mask ,
424- )
414+ unsafe {
415+ self . function . modify ( |mut r| {
416+ r. set_function ( function) ;
417+ r. set_emitrange ( emit_range) ;
418+ // don't compare data value
419+ r. set_datavmatch ( false ) ;
420+ // don't compare cycle counter value
421+ // NOTE: only needed for comparator 0, but is SBZP.
422+ r. set_cycmatch ( false ) ;
423+
424+ r
425+ } ) ;
426+
427+ self . comp . write ( settings. address ) ;
428+ self . mask . write ( settings. mask ) ;
429+ }
425430 }
426431 ComparatorFunction :: CycleCount ( settings) => {
427- (
428- // emit a Debug Watchpoint event, either halting execution or
429- // firing a `DebugMonitor` exception
430- 0b0111 ,
431- // emit_range is N/A for cycle count compare
432- false ,
433- // don't compare data
434- false ,
435- // compare cyccnt
436- true ,
437- settings. compare ,
438- settings. mask ,
439- )
432+ unsafe {
433+ self . function . modify ( |mut r| {
434+ // emit a Debug Watchpoint event, either halting execution or
435+ // firing a `DebugMonitor` exception
436+ // See Table C1-15 DWT cycle count comparison functions
437+ r. set_function ( 0b0100 ) ;
438+ // emit_range is N/A for cycle count compare
439+ r. set_emitrange ( false ) ;
440+ // don't compare data
441+ r. set_datavmatch ( false ) ;
442+ // compare cyccnt
443+ r. set_cycmatch ( true ) ;
444+ r
445+ } ) ;
446+
447+ self . comp . write ( settings. compare ) ;
448+ self . mask . write ( settings. mask ) ;
449+ }
440450 }
441- } ;
442-
443- unsafe {
444- self . function . modify ( |mut r| {
445- r. set_function ( func) ;
446- r. set_emitrange ( emit) ;
447- r. set_datavmatch ( data_match) ;
448-
449- // NOTE: only valid for comparator 0, but is SBZP.
450- r. set_cycmatch ( cyc_match) ;
451-
452- r
453- } ) ;
454-
455- self . comp . write ( comp) ;
456- self . mask . write ( mask) ;
457451 }
452+
458453 Ok ( ( ) )
459454 }
460455}
0 commit comments