hw/mcu/dialog: Add helpers to control MTB
These helpers allow to enable/disable MTB tracing from code. It may be
useful to start tracing for interesting pieces of code, or temporarily
disable for uniteresting pieces of code to spare buffer space (e.g.
on some long loops that create a lot of branches).
@@ -35,6 +35,21 @@ hal_debug_break(void)
__BKPT(1);
}
+static inline void
+mcu_mtb_enable(void)
+{
+ *(uint32_t *)0xe0043004 |= (1 << 31);
+ __DSB();
+ __ISB();
+}
+
+static inline void
+mcu_mtb_disable(void)
+{
+ __ISB();
+ *(uint32_t *)0xe0043004 &= ~(1 << 31);
+}
+
#ifdef __cplusplus
}
#endif
