diff options
author | Damien George <damien.p.george@gmail.com> | 2015-10-30 23:03:58 +0000 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-10-31 19:14:30 +0300 |
commit | 731f359292c0e2630873df1a19c5baac7287024f (patch) | |
tree | 3aef09fd15b82baa9fff7c72fe3bc7e05a869614 /unix | |
parent | 0bd3f3291d3ea0252a91653a1edcbfa83d524834 (diff) | |
download | micropython-731f359292c0e2630873df1a19c5baac7287024f.tar.gz micropython-731f359292c0e2630873df1a19c5baac7287024f.zip |
all: Add py/mphal.h and use it in all ports.
py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for. A
port will also provide mphalport.h with further HAL declarations.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/input.c | 2 | ||||
-rw-r--r-- | unix/main.c | 2 | ||||
-rw-r--r-- | unix/mpconfigport.h | 2 | ||||
-rw-r--r-- | unix/unix_mphal.c | 4 | ||||
-rw-r--r-- | unix/unix_mphal.h | 8 |
5 files changed, 6 insertions, 12 deletions
diff --git a/unix/input.c b/unix/input.c index 9baa342b94..a38b63ae3c 100644 --- a/unix/input.c +++ b/unix/input.c @@ -29,10 +29,10 @@ #include <string.h> #include "py/mpstate.h" +#include "py/mphal.h" #include "input.h" #if MICROPY_USE_READLINE == 1 -#include MICROPY_HAL_H #include "lib/mp-readline/readline.h" #elif MICROPY_USE_READLINE == 2 #include <readline/readline.h> diff --git a/unix/main.c b/unix/main.c index eed7065bf2..1dc54198e5 100644 --- a/unix/main.c +++ b/unix/main.c @@ -44,8 +44,8 @@ #include "py/repl.h" #include "py/gc.h" #include "py/stackctrl.h" +#include "py/mphal.h" #include "genhdr/mpversion.h" -#include MICROPY_HAL_H #include "input.h" // Command line options, with their defaults diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h index 13cf1e87b8..0e1fb6a401 100644 --- a/unix/mpconfigport.h +++ b/unix/mpconfigport.h @@ -223,7 +223,7 @@ extern const struct _mp_obj_fun_builtin_t mp_builtin_open_obj; mp_obj_t keyboard_interrupt_obj; \ void *mmap_region_head; \ -#define MICROPY_HAL_H "unix_mphal.h" +#define MICROPY_MPHALPORT_H "unix_mphal.h" // We need to provide a declaration/definition of alloca() #ifdef __FreeBSD__ diff --git a/unix/unix_mphal.c b/unix/unix_mphal.c index 54a710a3ba..308349c60e 100644 --- a/unix/unix_mphal.c +++ b/unix/unix_mphal.c @@ -30,7 +30,7 @@ #include <sys/time.h> #include "py/mpstate.h" -#include MICROPY_HAL_H +#include "py/mphal.h" #ifndef _WIN32 #include <signal.h> @@ -119,7 +119,7 @@ void mp_hal_stdout_tx_str(const char *str) { mp_hal_stdout_tx_strn(str, strlen(str)); } -uint32_t mp_hal_ticks_ms(void) { +mp_uint_t mp_hal_ticks_ms(void) { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * 1000 + tv.tv_usec / 1000; diff --git a/unix/unix_mphal.h b/unix/unix_mphal.h index 2e10d48a65..8961722db7 100644 --- a/unix/unix_mphal.h +++ b/unix/unix_mphal.h @@ -33,10 +33,4 @@ void mp_hal_set_interrupt_char(char c); void mp_hal_stdio_mode_raw(void); void mp_hal_stdio_mode_orig(void); -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 mp_hal_delay_ms(ms) usleep((ms) * 1000) -uint32_t mp_hal_ticks_ms(void); +static inline void mp_hal_delay_ms(mp_uint_t ms) { usleep((ms) * 1000); } |