dwt: refactor out unnecessary explicit panic
@@ -364,19 +364,6 @@ impl Comparator {
pub fn configure(&self, settings: ComparatorFunction) -> Result<(), DwtError> {
match settings {
ComparatorFunction::Address(settings) => unsafe {
- if settings.emit == EmitOption::PC && settings.access_type != AccessType::ReadWrite
- {
- return Err(DWTError::InvalidFunction);
- }
-
- self.function.modify(|mut r| {
- // don't compare data value
- r.set_datavmatch(false);
-
- // don't compare cycle counter value
- // NOTE: only needed for comparator 0, but is SBZP.
- r.set_cycmatch(false);
-
// FUNCTION, EMITRANGE
// See Table C1-14
let (function, emit_range) = match (&settings.access_type, &settings.emit) {
@@ -396,11 +383,20 @@ impl Comparator {
(AccessType::ReadWrite, EmitOption::PCData) => (0b0011, false),
(AccessType::ReadWrite, EmitOption::PC) => (0b0001, false),
- (_, EmitOption::PC) => unreachable!(), // cannot return Err here; handled above
+ (_, EmitOption::PC) => return Err(DWTError::InvalidFunction),
};
+
+ self.function.modify(|mut r| {
r.set_function(function);
r.set_emitrange(emit_range);
+ // don't compare data value
+ r.set_datavmatch(false);
+
+ // don't compare cycle counter value
+ // NOTE: only needed for comparator 0, but is SBZP.
+ r.set_cycmatch(false);
+
r
});
