esp8266: Implement time functions
This commit is contained in:
parent
c7df9c6c47
commit
800d5cd16f
|
@ -29,6 +29,7 @@
|
|||
#include "etshal.h"
|
||||
#include "uart.h"
|
||||
#include "esp_mphal.h"
|
||||
#include "user_interface.h"
|
||||
|
||||
extern void ets_wdt_disable(void);
|
||||
extern void wdt_feed(void);
|
||||
|
@ -82,8 +83,7 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
|
|||
}
|
||||
|
||||
uint32_t HAL_GetTick(void) {
|
||||
// TODO
|
||||
return 0;
|
||||
return system_get_time() / 1000;
|
||||
}
|
||||
|
||||
void HAL_Delay(uint32_t Delay) {
|
||||
|
|
|
@ -108,13 +108,13 @@ STATIC mp_obj_t pyb_elapsed_millis(mp_obj_t start) {
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_millis_obj, pyb_elapsed_millis);
|
||||
|
||||
STATIC mp_obj_t pyb_micros(void) {
|
||||
return MP_OBJ_NEW_SMALL_INT(0);
|
||||
return MP_OBJ_NEW_SMALL_INT(system_get_time());
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_micros_obj, pyb_micros);
|
||||
|
||||
STATIC mp_obj_t pyb_elapsed_micros(mp_obj_t start) {
|
||||
uint32_t startMicros = mp_obj_get_int(start);
|
||||
uint32_t currMicros = 0;
|
||||
uint32_t currMicros = system_get_time();
|
||||
return MP_OBJ_NEW_SMALL_INT((currMicros - startMicros) & 0x3fffffff);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_micros_obj, pyb_elapsed_micros);
|
||||
|
|
Loading…
Reference in New Issue