Skip to content

Commit 6a2c609

Browse files
committed
windows: Enable utime_mphal following unix, define mp_hal_ticks_*.
mp_hal_ticks_ms, mp_hal_ticks_us taken from unix port, mp_hal_ticks_cpu dummy.
1 parent 3cc87b1 commit 6a2c609

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

windows/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
#define MICROPY_PY_UBINASCII (1)
9393
#define MICROPY_PY_URANDOM (1)
9494
#define MICROPY_PY_UTIME (1)
95+
#define MICROPY_PY_UTIME_MP_HAL (1)
9596
#define MICROPY_PY_MACHINE (1)
9697

9798
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)

windows/windows_mphal.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include <windows.h>
3232
#include <unistd.h>
33+
#include <sys/time.h>
3334

3435
HANDLE std_in = NULL;
3536
HANDLE con_out = NULL;
@@ -204,3 +205,15 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
204205
void mp_hal_stdout_tx_str(const char *str) {
205206
mp_hal_stdout_tx_strn(str, strlen(str));
206207
}
208+
209+
mp_uint_t mp_hal_ticks_ms(void) {
210+
struct timeval tv;
211+
gettimeofday(&tv, NULL);
212+
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
213+
}
214+
215+
mp_uint_t mp_hal_ticks_us(void) {
216+
struct timeval tv;
217+
gettimeofday(&tv, NULL);
218+
return tv.tv_sec * 1000000 + tv.tv_usec;
219+
}

windows/windows_mphal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@
3131

3232
void mp_hal_move_cursor_back(unsigned int pos);
3333
void mp_hal_erase_line_from_cursor(unsigned int n_chars_to_erase);
34+
35+
// TODO: Implement.
36+
#define mp_hal_ticks_cpu() 0

0 commit comments

Comments
 (0)