Skip to content

Commit 800d5cd

Browse files
atxdpgeorge
authored andcommitted
esp8266: Implement time functions
1 parent c7df9c6 commit 800d5cd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

esp8266/esp_mphal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "etshal.h"
3030
#include "uart.h"
3131
#include "esp_mphal.h"
32+
#include "user_interface.h"
3233

3334
extern void ets_wdt_disable(void);
3435
extern void wdt_feed(void);
@@ -82,8 +83,7 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
8283
}
8384

8485
uint32_t HAL_GetTick(void) {
85-
// TODO
86-
return 0;
86+
return system_get_time() / 1000;
8787
}
8888

8989
void HAL_Delay(uint32_t Delay) {

esp8266/modpyb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ STATIC mp_obj_t pyb_elapsed_millis(mp_obj_t start) {
108108
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_millis_obj, pyb_elapsed_millis);
109109

110110
STATIC mp_obj_t pyb_micros(void) {
111-
return MP_OBJ_NEW_SMALL_INT(0);
111+
return MP_OBJ_NEW_SMALL_INT(system_get_time());
112112
}
113113
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_micros_obj, pyb_micros);
114114

115115
STATIC mp_obj_t pyb_elapsed_micros(mp_obj_t start) {
116116
uint32_t startMicros = mp_obj_get_int(start);
117-
uint32_t currMicros = 0;
117+
uint32_t currMicros = system_get_time();
118118
return MP_OBJ_NEW_SMALL_INT((currMicros - startMicros) & 0x3fffffff);
119119
}
120120
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_micros_obj, pyb_elapsed_micros);

0 commit comments

Comments
 (0)