summaryrefslogtreecommitdiff
path: root/tinyusb/hal
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-03-22 17:08:51 +0700
committerhathach <[email protected]>2013-03-22 17:08:51 +0700
commitdbaf6c0d30657ec1659ddb13269edc4ae28b7bc2 (patch)
tree59685ec0d0e0eea4b29cbff5d308e1befe4a8dd6 /tinyusb/hal
parentcd2915e78cdd261713f1b0aa4ebe0441f99f9456 (diff)
- fix bug when unplugged unmounted-already device (mostly plugged when power on)
- add hal_debugger_is_attached & hal_debugger_breakpoint - assert will suspend (place breakpoint) if the condition is failed and debugger is attached. Otherwise, a message to uart is printed - fix get control qhd function when dev_addr is not zero (shifted 1) - fix wrong logic for unsupported class
Diffstat (limited to 'tinyusb/hal')
-rw-r--r--tinyusb/hal/hal.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/tinyusb/hal/hal.h b/tinyusb/hal/hal.h
index ad77055eb..941063665 100644
--- a/tinyusb/hal/hal.h
+++ b/tinyusb/hal/hal.h
@@ -52,6 +52,7 @@
#define _TUSB_HAL_H_
#include "tusb_option.h"
+#include "common/errors.h"
#include "common/compiler/compiler.h"
#if MCU == 0
@@ -91,6 +92,27 @@ static inline void hal_interrupt_enable() ATTR_ALWAYS_INLINE;
*/
static inline void hal_interrupt_disable() ATTR_ALWAYS_INLINE;
+static inline bool hal_debugger_is_attached() ATTR_PURE ATTR_ALWAYS_INLINE;
+static inline bool hal_debugger_is_attached()
+{
+#ifndef _TEST_
+ return (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == CoreDebug_DHCSR_C_DEBUGEN_Msk;
+#else
+ return false;
+#endif
+}
+
+static inline void hal_debugger_breakpoint() ATTR_ALWAYS_INLINE;
+static inline void hal_debugger_breakpoint()
+{
+#ifndef _TEST_
+ if (hal_debugger_is_attached()) /* if there is debugger connected */
+ {
+ __asm("BKPT #0\n");
+ }
+#endif
+}
+
#ifdef __cplusplus
}
#endif