Commit 949c5c91 authored by Paul Sokolovsky's avatar Paul Sokolovsky

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

parent 77994109
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/time.h>
#include "py/mpstate.h" #include "py/mpstate.h"
#include MICROPY_HAL_H #include MICROPY_HAL_H
...@@ -117,3 +118,9 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) { ...@@ -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) { void mp_hal_stdout_tx_str(const char *str) {
mp_hal_stdout_tx_strn(str, strlen(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;
}
...@@ -37,3 +37,6 @@ int mp_hal_stdin_rx_chr(void); ...@@ -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_str(const char *str);
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len); 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); 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);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment