summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/mphalport.c
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal/mphalport.c')
-rw-r--r--stmhal/mphalport.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/stmhal/mphalport.c b/stmhal/mphalport.c
index f392550b80..3bf993ec25 100644
--- a/stmhal/mphalport.c
+++ b/stmhal/mphalport.c
@@ -7,6 +7,8 @@
#include "usb.h"
#include "uart.h"
+bool mp_hal_ticks_cpu_enabled = false;
+
// this table converts from HAL_StatusTypeDef to POSIX errno
const byte mp_hal_status_to_errno_table[4] = {
[HAL_OK] = 0,
@@ -71,6 +73,15 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
}
}
+void mp_hal_ticks_cpu_enable(void) {
+ if (!mp_hal_ticks_cpu_enabled) {
+ CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
+ DWT->CYCCNT = 0;
+ DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
+ mp_hal_ticks_cpu_enabled = true;
+ }
+}
+
void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio) {
if (0) {
#ifdef __GPIOA_CLK_ENABLE