aboutsummaryrefslogtreecommitdiff
path: root/stmhal/mphalport.c
diff options
context:
space:
mode:
authorDamien George2016-10-18 14:30:00 +1100
committerDamien George2016-10-18 14:34:08 +1100
commitcd9b14bb11c35e013e47db46bcc73734f0d6cd55 (patch)
tree265cf0a142d3b2a2cbd7c7d2a55d64fd3f0db57c /stmhal/mphalport.c
parent5c93d0b91655dcd32e633d720b5b790b10be989c (diff)
stmhal/modutime: Refactor to use extmod's version of ticks_cpu.
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 f392550b8..3bf993ec2 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