unix/unix_mphal: Implement HAL_Delay() and HAL_GetTick().
This commit is contained in:
parent
7799410950
commit
949c5c9180
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue