@@ -318,15 +318,15 @@ impl DWT {
318
318
/// Whether the comparator should match on read, write or read/write operations.
319
319
#[ derive( Debug , Eq , PartialEq , Copy , Clone ) ]
320
320
pub enum AccessType {
321
- /// Generate packet only when matched adress is read from.
321
+ /// Generate packet only when matched address is read from.
322
322
ReadOnly ,
323
- /// Generate packet only when matched adress is written to.
323
+ /// Generate packet only when matched address is written to.
324
324
WriteOnly ,
325
- /// Generate packet when matched adress is both read from and written to.
325
+ /// Generate packet when matched address is both read from and written to.
326
326
ReadWrite ,
327
327
}
328
328
329
- /// The sequence of packet(s) that should be emitted on comparator match.
329
+ /// The sequence of packet(s) or events that should be emitted/generated on comparator match.
330
330
#[ derive( Debug , Eq , PartialEq , Copy , Clone ) ]
331
331
pub enum EmitOption {
332
332
/// Emit only trace data value packet.
@@ -341,6 +341,15 @@ pub enum EmitOption {
341
341
AddressData ,
342
342
/// Emit trace PC value and data value packets.
343
343
PCData ,
344
+ /// Generate a watchpoint debug event.
345
+ ///
346
+ /// either halts execution or fires a `DebugMonitor` exception.
347
+ /// See more in section "Watchpoint debug event generation" page C1-729
348
+ WatchpointDebugEvent ,
349
+ /// Generate a `CMPMATCH[N]` event.
350
+ ///
351
+ /// See more in section "CMPMATCH[N] event generation" page C1-730
352
+ CompareMatchEvent ,
344
353
}
345
354
346
355
/// Settings for address matching
@@ -359,6 +368,9 @@ pub struct ComparatorAddressSettings {
359
368
/// Settings for cycle count matching
360
369
#[ derive( Debug , Eq , PartialEq , Copy , Clone ) ]
361
370
pub struct CycleCountSettings {
371
+ /// The function selection used.
372
+ /// See Table C1-15 DWT cycle count comparison functions
373
+ pub emit : EmitOption ,
362
374
/// The cycle count value to compare against.
363
375
pub compare : u32 ,
364
376
/// The cycle count mask value to use.
@@ -396,16 +408,22 @@ impl Comparator {
396
408
( AccessType :: ReadOnly , EmitOption :: Address ) => ( 0b1100 , true ) ,
397
409
( AccessType :: ReadOnly , EmitOption :: AddressData ) => ( 0b1110 , true ) ,
398
410
( AccessType :: ReadOnly , EmitOption :: PCData ) => ( 0b1110 , false ) ,
411
+ ( AccessType :: ReadOnly , EmitOption :: WatchpointDebugEvent ) => ( 0b0101 , false ) ,
412
+ ( AccessType :: ReadOnly , EmitOption :: CompareMatchEvent ) => ( 0b1001 , false ) ,
399
413
400
414
( AccessType :: WriteOnly , EmitOption :: Data ) => ( 0b1101 , false ) ,
401
415
( AccessType :: WriteOnly , EmitOption :: Address ) => ( 0b1101 , true ) ,
402
416
( AccessType :: WriteOnly , EmitOption :: AddressData ) => ( 0b1111 , true ) ,
403
417
( AccessType :: WriteOnly , EmitOption :: PCData ) => ( 0b1111 , false ) ,
418
+ ( AccessType :: WriteOnly , EmitOption :: WatchpointDebugEvent ) => ( 0b0110 , false ) ,
419
+ ( AccessType :: WriteOnly , EmitOption :: CompareMatchEvent ) => ( 0b1010 , false ) ,
404
420
405
421
( AccessType :: ReadWrite , EmitOption :: Data ) => ( 0b0010 , false ) ,
406
422
( AccessType :: ReadWrite , EmitOption :: Address ) => ( 0b0001 , true ) ,
407
423
( AccessType :: ReadWrite , EmitOption :: AddressData ) => ( 0b0010 , true ) ,
408
424
( AccessType :: ReadWrite , EmitOption :: PCData ) => ( 0b0011 , false ) ,
425
+ ( AccessType :: ReadWrite , EmitOption :: WatchpointDebugEvent ) => ( 0b0111 , false ) ,
426
+ ( AccessType :: ReadWrite , EmitOption :: CompareMatchEvent ) => ( 0b1011 , false ) ,
409
427
410
428
( AccessType :: ReadWrite , EmitOption :: PC ) => ( 0b0001 , false ) ,
411
429
( _, EmitOption :: PC ) => return Err ( DwtError :: InvalidFunction ) ,
@@ -429,12 +447,16 @@ impl Comparator {
429
447
}
430
448
}
431
449
ComparatorFunction :: CycleCount ( settings) => {
450
+ let function = match & settings. emit {
451
+ EmitOption :: PCData => 0b0001 ,
452
+ EmitOption :: WatchpointDebugEvent => 0b0100 ,
453
+ EmitOption :: CompareMatchEvent => 0b1000 ,
454
+ _ => return Err ( DwtError :: InvalidFunction ) ,
455
+ } ;
456
+
432
457
unsafe {
433
458
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 ) ;
459
+ r. set_function ( function) ;
438
460
// emit_range is N/A for cycle count compare
439
461
r. set_emitrange ( false ) ;
440
462
// don't compare data
0 commit comments