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 /teensy | |
| parent | 0bd3f3291d3ea0252a91653a1edcbfa83d524834 (diff) | |
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 'teensy')
| -rw-r--r-- | teensy/led.c | 2 | ||||
| -rw-r--r-- | teensy/main.c | 2 | ||||
| -rw-r--r-- | teensy/modpyb.c | 3 | ||||
| -rw-r--r-- | teensy/mpconfigport.h | 3 | ||||
| -rw-r--r-- | teensy/pin_defs_teensy.c | 2 | ||||
| -rw-r--r-- | teensy/teensy_hal.c | 10 | ||||
| -rw-r--r-- | teensy/teensy_hal.h | 7 | ||||
| -rw-r--r-- | teensy/timer.c | 2 | ||||
| -rw-r--r-- | teensy/uart.c | 1 |
9 files changed, 11 insertions, 21 deletions
diff --git a/teensy/led.c b/teensy/led.c index 500900ffc..5798f537b 100644 --- a/teensy/led.c +++ b/teensy/led.c @@ -4,8 +4,8 @@ #include "py/nlr.h" #include "py/runtime.h" +#include "py/mphal.h" #include "led.h" -#include MICROPY_HAL_H #include "pin.h" #include "genhdr/pins.h" diff --git a/teensy/main.c b/teensy/main.c index 4fa7aaab3..c31be6e01 100644 --- a/teensy/main.c +++ b/teensy/main.c @@ -9,13 +9,13 @@ #include "py/runtime.h" #include "py/stackctrl.h" #include "py/gc.h" +#include "py/mphal.h" #include "gccollect.h" #include "pyexec.h" #include "readline.h" #include "lexermemzip.h" #include "Arduino.h" -#include MICROPY_HAL_H #include "servo.h" #include "led.h" diff --git a/teensy/modpyb.c b/teensy/modpyb.c index aded02263..8429191af 100644 --- a/teensy/modpyb.c +++ b/teensy/modpyb.c @@ -31,8 +31,7 @@ #include "py/obj.h" #include "py/gc.h" - -#include MICROPY_HAL_H +#include "py/mphal.h" #include "gccollect.h" #include "irq.h" diff --git a/teensy/mpconfigport.h b/teensy/mpconfigport.h index d4bfd1cd3..4b2181cdb 100644 --- a/teensy/mpconfigport.h +++ b/teensy/mpconfigport.h @@ -66,7 +66,6 @@ typedef void *machine_ptr_t; // must be of pointer size typedef const void *machine_const_ptr_t; // must be of pointer size typedef long mp_off_t; -void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len); #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) // We have inlined IRQ functions for efficiency (they are generally @@ -149,5 +148,5 @@ __attribute__(( always_inline )) static inline mp_uint_t disable_irq(void) { #define MICROPY_MATH_SQRT_ASM (1) -#define MICROPY_HAL_H "teensy_hal.h" +#define MICROPY_MPHALPORT_H "teensy_hal.h" #define MICROPY_PIN_DEFS_PORT_H "pin_defs_teensy.h" diff --git a/teensy/pin_defs_teensy.c b/teensy/pin_defs_teensy.c index fd2476f7b..e7af1e969 100644 --- a/teensy/pin_defs_teensy.c +++ b/teensy/pin_defs_teensy.c @@ -1,7 +1,7 @@ #include <stdint.h> #include <mk20dx128.h> #include "py/runtime.h" -#include MICROPY_HAL_H +#include "py/mphal.h" #include "pin.h" // Returns the pin mode. This value returned by this macro should be one of: diff --git a/teensy/teensy_hal.c b/teensy/teensy_hal.c index 099848fb3..8996c27c9 100644 --- a/teensy/teensy_hal.c +++ b/teensy/teensy_hal.c @@ -2,16 +2,16 @@ #include <string.h> #include "py/mpstate.h" +#include "py/mphal.h" #include "usb.h" #include "uart.h" #include "Arduino.h" -#include MICROPY_HAL_H -uint32_t mp_hal_ticks_ms(void) { +mp_uint_t mp_hal_ticks_ms(void) { return millis(); } -void mp_hal_delay_ms(uint32_t ms) { +void mp_hal_delay_ms(mp_uint_t ms) { delay(ms); } @@ -37,7 +37,7 @@ void mp_hal_stdout_tx_str(const char *str) { mp_hal_stdout_tx_strn(str, strlen(str)); } -void mp_hal_stdout_tx_strn(const char *str, uint32_t len) { +void mp_hal_stdout_tx_strn(const char *str, size_t len) { if (MP_STATE_PORT(pyb_stdio_uart) != NULL) { uart_tx_strn(MP_STATE_PORT(pyb_stdio_uart), str, len); } @@ -46,7 +46,7 @@ void mp_hal_stdout_tx_strn(const char *str, uint32_t len) { } } -void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) { +void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) { // send stdout to UART and USB CDC VCP if (MP_STATE_PORT(pyb_stdio_uart) != NULL) { uart_tx_strn_cooked(MP_STATE_PORT(pyb_stdio_uart), str, len); diff --git a/teensy/teensy_hal.h b/teensy/teensy_hal.h index 24402ee84..b00b6e4ac 100644 --- a/teensy/teensy_hal.h +++ b/teensy/teensy_hal.h @@ -112,17 +112,10 @@ __attribute__(( always_inline )) static inline void __WFI(void) { __asm volatile ("wfi"); } -uint32_t mp_hal_ticks_ms(void); -void mp_hal_delay_ms(uint32_t delay); void mp_hal_set_interrupt_char(int c); void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio); -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, uint32_t len); -void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len); - void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *init); #define GPIO_read_pin(gpio, pin) (((gpio)->PDIR >> (pin)) & 1) diff --git a/teensy/timer.c b/teensy/timer.c index 5d6237d00..88583a09b 100644 --- a/teensy/timer.c +++ b/teensy/timer.c @@ -32,7 +32,7 @@ #include "py/nlr.h" #include "py/runtime.h" #include "py/gc.h" -#include MICROPY_HAL_H +#include "py/mphal.h" #include "pin.h" #include "reg.h" #include "timer.h" diff --git a/teensy/uart.c b/teensy/uart.c index 1a04bb0d6..81035aed6 100644 --- a/teensy/uart.c +++ b/teensy/uart.c @@ -29,7 +29,6 @@ #include "py/nlr.h" #include "py/runtime.h" -#include MICROPY_HAL_H #include "bufhelper.h" #include "uart.h" |
