esp8266: Implement time functions

This commit is contained in:
Josef Gajdusek 2015-05-10 17:54:09 +02:00 committed by Damien George
parent c7df9c6c47
commit 800d5cd16f
2 changed files with 4 additions and 4 deletions

View File

@ -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) {

View File

@ -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);