unix/unix_mphal: Implement HAL_Delay() and HAL_GetTick().

This commit is contained in:
Paul Sokolovsky 2015-10-19 00:29:40 +03:00
parent 7799410950
commit 949c5c9180
2 changed files with 10 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "py/mpstate.h"
#include MICROPY_HAL_H
@ -117,3 +118,9 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) {
void mp_hal_stdout_tx_str(const char *str) {
mp_hal_stdout_tx_strn(str, strlen(str));
}
uint32_t HAL_GetTick(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}

View File

@ -37,3 +37,6 @@ int mp_hal_stdin_rx_chr(void);
void mp_hal_stdout_tx_str(const char *str);
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len);
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
#define HAL_Delay(ms) usleep((ms) * 1000)
uint32_t HAL_GetTick(void);