From 731f359292c0e2630873df1a19c5baac7287024f Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 30 Oct 2015 23:03:58 +0000 Subject: 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. --- stmhal/Makefile | 2 +- stmhal/adc.c | 3 +- stmhal/boards/stm32f4xx_prefix.c | 2 +- stmhal/can.c | 2 +- stmhal/extint.c | 2 +- stmhal/i2c.c | 2 +- stmhal/irq.c | 3 +- stmhal/led.c | 3 +- stmhal/main.c | 2 +- stmhal/modmachine.c | 2 +- stmhal/modnwwiznet5k.c | 2 +- stmhal/moduselect.c | 2 +- stmhal/mpconfigport.h | 2 - stmhal/mphal.c | 120 --------------------------------------- stmhal/mphal.h | 38 ------------- stmhal/mphalport.c | 120 +++++++++++++++++++++++++++++++++++++++ stmhal/mphalport.h | 33 +++++++++++ stmhal/pin.c | 2 +- stmhal/pin_defs_stmhal.c | 1 - stmhal/pin_named_pins.c | 2 +- stmhal/printf.c | 4 +- stmhal/pybstdio.c | 2 +- stmhal/pyexec.c | 4 +- stmhal/spi.c | 2 +- stmhal/stm32_it.c | 2 +- stmhal/timer.c | 1 - stmhal/uart.c | 2 +- stmhal/usbd_desc.c | 2 +- stmhal/usrsw.c | 2 +- 29 files changed, 175 insertions(+), 191 deletions(-) delete mode 100644 stmhal/mphal.c delete mode 100644 stmhal/mphal.h create mode 100644 stmhal/mphalport.c create mode 100644 stmhal/mphalport.h (limited to 'stmhal') diff --git a/stmhal/Makefile b/stmhal/Makefile index 222e19b32..8c0cd2175 100644 --- a/stmhal/Makefile +++ b/stmhal/Makefile @@ -113,7 +113,7 @@ SRC_C = \ usbd_desc.c \ usbd_cdc_interface.c \ usbd_msc_storage.c \ - mphal.c \ + mphalport.c \ irq.c \ pendsv.c \ systick.c \ diff --git a/stmhal/adc.c b/stmhal/adc.c index c70d88eaf..d8ce90cb3 100644 --- a/stmhal/adc.c +++ b/stmhal/adc.c @@ -25,16 +25,15 @@ */ #include -#include STM32_HAL_H #include #include "py/nlr.h" #include "py/runtime.h" #include "py/binary.h" +#include "py/mphal.h" #include "adc.h" #include "pin.h" #include "genhdr/pins.h" -#include "mphal.h" #include "timer.h" /// \moduleref pyb diff --git a/stmhal/boards/stm32f4xx_prefix.c b/stmhal/boards/stm32f4xx_prefix.c index 529e0f0c3..f4ffdab68 100644 --- a/stmhal/boards/stm32f4xx_prefix.c +++ b/stmhal/boards/stm32f4xx_prefix.c @@ -3,8 +3,8 @@ #include #include "py/obj.h" +#include "py/mphal.h" #include "pin.h" -#include MICROPY_HAL_H #define AF(af_idx, af_fn, af_unit, af_type, af_ptr) \ { \ diff --git a/stmhal/can.c b/stmhal/can.c index 18fd31eeb..38ddf7448 100644 --- a/stmhal/can.c +++ b/stmhal/can.c @@ -33,10 +33,10 @@ #include "py/objtuple.h" #include "py/runtime.h" #include "py/gc.h" +#include "py/mphal.h" #include "bufhelper.h" #include "can.h" #include "pybioctl.h" -#include MICROPY_HAL_H #if MICROPY_HW_ENABLE_CAN diff --git a/stmhal/extint.c b/stmhal/extint.c index ebd9d3e39..1fcf587db 100644 --- a/stmhal/extint.c +++ b/stmhal/extint.c @@ -31,7 +31,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 "extint.h" diff --git a/stmhal/i2c.c b/stmhal/i2c.c index af37abf44..eb6716ce3 100644 --- a/stmhal/i2c.c +++ b/stmhal/i2c.c @@ -29,13 +29,13 @@ #include "py/nlr.h" #include "py/runtime.h" +#include "py/mphal.h" #include "irq.h" #include "pin.h" #include "genhdr/pins.h" #include "bufhelper.h" #include "dma.h" #include "i2c.h" -#include MICROPY_HAL_H #if !defined(MICROPY_HW_I2C_BAUDRATE_DEFAULT) #define MICROPY_HW_I2C_BAUDRATE_DEFAULT 400000 diff --git a/stmhal/irq.c b/stmhal/irq.c index 7a265a52b..749e4813c 100644 --- a/stmhal/irq.c +++ b/stmhal/irq.c @@ -26,10 +26,9 @@ #include "py/nlr.h" #include "py/obj.h" +#include "py/mphal.h" #include "irq.h" -#include MICROPY_HAL_H - /// \moduleref pyb /// \function wfi() diff --git a/stmhal/led.c b/stmhal/led.c index e3dbdb594..ca52931e3 100644 --- a/stmhal/led.c +++ b/stmhal/led.c @@ -25,15 +25,14 @@ */ #include -#include STM32_HAL_H #include "py/nlr.h" #include "py/runtime.h" +#include "py/mphal.h" #include "timer.h" #include "led.h" #include "pin.h" #include "genhdr/pins.h" -#include "mphal.h" #if defined(MICROPY_HW_LED1) diff --git a/stmhal/main.c b/stmhal/main.c index fe4b4c20c..de52cac8f 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -34,6 +34,7 @@ #include "py/runtime.h" #include "py/stackctrl.h" #include "py/gc.h" +#include "py/mphal.h" #include "lib/fatfs/ff.h" @@ -60,7 +61,6 @@ #include "dac.h" #include "can.h" #include "modnetwork.h" -#include MICROPY_HAL_H void SystemClock_Config(void); diff --git a/stmhal/modmachine.c b/stmhal/modmachine.c index fa6a1f9dd..6a0c4a9fc 100644 --- a/stmhal/modmachine.c +++ b/stmhal/modmachine.c @@ -29,6 +29,7 @@ #include "modmachine.h" #include "py/gc.h" #include "py/runtime.h" +#include "py/mphal.h" #include "lib/fatfs/ff.h" #include "lib/fatfs/diskio.h" #include "gccollect.h" @@ -38,7 +39,6 @@ #include "pin.h" #include "timer.h" #include "usb.h" -#include MICROPY_HAL_H // machine.info([dump_alloc_table]) // Print out lots of information about the board. diff --git a/stmhal/modnwwiznet5k.c b/stmhal/modnwwiznet5k.c index 48d9be170..2feb9b953 100644 --- a/stmhal/modnwwiznet5k.c +++ b/stmhal/modnwwiznet5k.c @@ -32,12 +32,12 @@ #include "py/nlr.h" #include "py/objlist.h" #include "py/runtime.h" +#include "py/mphal.h" #include "netutils.h" #include "modnetwork.h" #include "pin.h" #include "genhdr/pins.h" #include "spi.h" -#include MICROPY_HAL_H #include "ethernet/wizchip_conf.h" #include "ethernet/socket.h" diff --git a/stmhal/moduselect.c b/stmhal/moduselect.c index 0ba595488..232520ec4 100644 --- a/stmhal/moduselect.c +++ b/stmhal/moduselect.c @@ -30,8 +30,8 @@ #include "py/nlr.h" #include "py/obj.h" #include "py/objlist.h" +#include "py/mphal.h" #include "pybioctl.h" -#include MICROPY_HAL_H /// \module select - Provides select function to wait for events on a stream /// diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h index 52032135c..3848daa8f 100644 --- a/stmhal/mpconfigport.h +++ b/stmhal/mpconfigport.h @@ -199,7 +199,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, mp_uint_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 @@ -242,7 +241,6 @@ static inline mp_uint_t disable_irq(void) { // We need to provide a declaration/definition of alloca() #include -#define MICROPY_HAL_H "mphal.h" #define MICROPY_PIN_DEFS_PORT_H "pin_defs_stmhal.h" #endif // __INCLUDED_MPCONFIGPORT_H diff --git a/stmhal/mphal.c b/stmhal/mphal.c deleted file mode 100644 index 145ed8a1f..000000000 --- a/stmhal/mphal.c +++ /dev/null @@ -1,120 +0,0 @@ -#include -#include - -#include "py/mpstate.h" -#include "usb.h" -#include "uart.h" -#include "mphal.h" - -// this table converts from HAL_StatusTypeDef to POSIX errno -const byte mp_hal_status_to_errno_table[4] = { - [HAL_OK] = 0, - [HAL_ERROR] = EIO, - [HAL_BUSY] = EBUSY, - [HAL_TIMEOUT] = ETIMEDOUT, -}; - -NORETURN void mp_hal_raise(HAL_StatusTypeDef status) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(mp_hal_status_to_errno_table[status]))); -} - -void mp_hal_set_interrupt_char(int c) { - usb_vcp_set_interrupt_char(c); -} - -int mp_hal_stdin_rx_chr(void) { - for (;;) { -#if 0 -#ifdef USE_HOST_MODE - pyb_usb_host_process(); - int c = pyb_usb_host_get_keyboard(); - if (c != 0) { - return c; - } -#endif -#endif - - byte c; - if (usb_vcp_recv_byte(&c) != 0) { - return c; - } else if (MP_STATE_PORT(pyb_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(pyb_stdio_uart))) { - return uart_rx_char(MP_STATE_PORT(pyb_stdio_uart)); - } - __WFI(); - } -} - -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, mp_uint_t len) { - if (MP_STATE_PORT(pyb_stdio_uart) != NULL) { - uart_tx_strn(MP_STATE_PORT(pyb_stdio_uart), str, len); - } -#if 0 && defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD - lcd_print_strn(str, len); -#endif - if (usb_vcp_is_enabled()) { - usb_vcp_send_strn(str, len); - } -} - -void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_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); - } - if (usb_vcp_is_enabled()) { - usb_vcp_send_strn_cooked(str, len); - } -} - -void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio) { - if (0) { - #ifdef __GPIOA_CLK_ENABLE - } else if (gpio == GPIOA) { - __GPIOA_CLK_ENABLE(); - #endif - #ifdef __GPIOB_CLK_ENABLE - } else if (gpio == GPIOB) { - __GPIOB_CLK_ENABLE(); - #endif - #ifdef __GPIOC_CLK_ENABLE - } else if (gpio == GPIOC) { - __GPIOC_CLK_ENABLE(); - #endif - #ifdef __GPIOD_CLK_ENABLE - } else if (gpio == GPIOD) { - __GPIOD_CLK_ENABLE(); - #endif - #ifdef __GPIOE_CLK_ENABLE - } else if (gpio == GPIOE) { - __GPIOE_CLK_ENABLE(); - #endif - #ifdef __GPIOF_CLK_ENABLE - } else if (gpio == GPIOF) { - __GPIOF_CLK_ENABLE(); - #endif - #ifdef __GPIOG_CLK_ENABLE - } else if (gpio == GPIOG) { - __GPIOG_CLK_ENABLE(); - #endif - #ifdef __GPIOH_CLK_ENABLE - } else if (gpio == GPIOH) { - __GPIOH_CLK_ENABLE(); - #endif - #ifdef __GPIOI_CLK_ENABLE - } else if (gpio == GPIOI) { - __GPIOI_CLK_ENABLE(); - #endif - #ifdef __GPIOJ_CLK_ENABLE - } else if (gpio == GPIOJ) { - __GPIOJ_CLK_ENABLE(); - #endif - #ifdef __GPIOK_CLK_ENABLE - } else if (gpio == GPIOK) { - __GPIOK_CLK_ENABLE(); - #endif - } -} diff --git a/stmhal/mphal.h b/stmhal/mphal.h deleted file mode 100644 index bafee7b13..000000000 --- a/stmhal/mphal.h +++ /dev/null @@ -1,38 +0,0 @@ -// We use the ST Cube HAL library for most hardware peripherals -#include STM32_HAL_H - -// The unique id address differs per MCU. Ideally this define should -// go in some MCU-specific header, but for now it lives here. -#if defined(MCU_SERIES_F4) -#define MP_HAL_UNIQUE_ID_ADDRESS (0x1fff7a10) -#elif defined(MCU_SERIES_F7) -#define MP_HAL_UNIQUE_ID_ADDRESS (0x1ff0f420) -#else -#error mphal.h: Unrecognized MCU_SERIES -#endif - -// Basic GPIO functions -#define GPIO_read_pin(gpio, pin) (((gpio)->IDR >> (pin)) & 1) -#if defined(MCU_SERIES_F7) -#define GPIO_set_pin(gpio, pin_mask) (((gpio)->BSRR) = (pin_mask)) -#define GPIO_clear_pin(gpio, pin_mask) (((gpio)->BSRR) = ((pin_mask) << 16)) -#else -#define GPIO_set_pin(gpio, pin_mask) (((gpio)->BSRRL) = (pin_mask)) -#define GPIO_clear_pin(gpio, pin_mask) (((gpio)->BSRRH) = (pin_mask)) -#endif -#define GPIO_read_output_pin(gpio, pin) (((gpio)->ODR >> (pin)) & 1) - -void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio); - -extern const byte mp_hal_status_to_errno_table[4]; - -NORETURN void mp_hal_raise(HAL_StatusTypeDef status); -void mp_hal_set_interrupt_char(int c); // -1 to disable - -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 HAL_Delay -#define mp_hal_ticks_ms HAL_GetTick diff --git a/stmhal/mphalport.c b/stmhal/mphalport.c new file mode 100644 index 000000000..147a8682d --- /dev/null +++ b/stmhal/mphalport.c @@ -0,0 +1,120 @@ +#include +#include + +#include "py/mpstate.h" +#include "py/mphal.h" +#include "usb.h" +#include "uart.h" + +// this table converts from HAL_StatusTypeDef to POSIX errno +const byte mp_hal_status_to_errno_table[4] = { + [HAL_OK] = 0, + [HAL_ERROR] = EIO, + [HAL_BUSY] = EBUSY, + [HAL_TIMEOUT] = ETIMEDOUT, +}; + +NORETURN void mp_hal_raise(HAL_StatusTypeDef status) { + nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(mp_hal_status_to_errno_table[status]))); +} + +void mp_hal_set_interrupt_char(int c) { + usb_vcp_set_interrupt_char(c); +} + +int mp_hal_stdin_rx_chr(void) { + for (;;) { +#if 0 +#ifdef USE_HOST_MODE + pyb_usb_host_process(); + int c = pyb_usb_host_get_keyboard(); + if (c != 0) { + return c; + } +#endif +#endif + + byte c; + if (usb_vcp_recv_byte(&c) != 0) { + return c; + } else if (MP_STATE_PORT(pyb_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(pyb_stdio_uart))) { + return uart_rx_char(MP_STATE_PORT(pyb_stdio_uart)); + } + __WFI(); + } +} + +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, size_t len) { + if (MP_STATE_PORT(pyb_stdio_uart) != NULL) { + uart_tx_strn(MP_STATE_PORT(pyb_stdio_uart), str, len); + } +#if 0 && defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD + lcd_print_strn(str, len); +#endif + if (usb_vcp_is_enabled()) { + usb_vcp_send_strn(str, 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); + } + if (usb_vcp_is_enabled()) { + usb_vcp_send_strn_cooked(str, len); + } +} + +void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio) { + if (0) { + #ifdef __GPIOA_CLK_ENABLE + } else if (gpio == GPIOA) { + __GPIOA_CLK_ENABLE(); + #endif + #ifdef __GPIOB_CLK_ENABLE + } else if (gpio == GPIOB) { + __GPIOB_CLK_ENABLE(); + #endif + #ifdef __GPIOC_CLK_ENABLE + } else if (gpio == GPIOC) { + __GPIOC_CLK_ENABLE(); + #endif + #ifdef __GPIOD_CLK_ENABLE + } else if (gpio == GPIOD) { + __GPIOD_CLK_ENABLE(); + #endif + #ifdef __GPIOE_CLK_ENABLE + } else if (gpio == GPIOE) { + __GPIOE_CLK_ENABLE(); + #endif + #ifdef __GPIOF_CLK_ENABLE + } else if (gpio == GPIOF) { + __GPIOF_CLK_ENABLE(); + #endif + #ifdef __GPIOG_CLK_ENABLE + } else if (gpio == GPIOG) { + __GPIOG_CLK_ENABLE(); + #endif + #ifdef __GPIOH_CLK_ENABLE + } else if (gpio == GPIOH) { + __GPIOH_CLK_ENABLE(); + #endif + #ifdef __GPIOI_CLK_ENABLE + } else if (gpio == GPIOI) { + __GPIOI_CLK_ENABLE(); + #endif + #ifdef __GPIOJ_CLK_ENABLE + } else if (gpio == GPIOJ) { + __GPIOJ_CLK_ENABLE(); + #endif + #ifdef __GPIOK_CLK_ENABLE + } else if (gpio == GPIOK) { + __GPIOK_CLK_ENABLE(); + #endif + } +} diff --git a/stmhal/mphalport.h b/stmhal/mphalport.h new file mode 100644 index 000000000..652f1e7be --- /dev/null +++ b/stmhal/mphalport.h @@ -0,0 +1,33 @@ +// We use the ST Cube HAL library for most hardware peripherals +#include STM32_HAL_H + +// The unique id address differs per MCU. Ideally this define should +// go in some MCU-specific header, but for now it lives here. +#if defined(MCU_SERIES_F4) +#define MP_HAL_UNIQUE_ID_ADDRESS (0x1fff7a10) +#elif defined(MCU_SERIES_F7) +#define MP_HAL_UNIQUE_ID_ADDRESS (0x1ff0f420) +#else +#error mphalport.h: Unrecognized MCU_SERIES +#endif + +// Basic GPIO functions +#define GPIO_read_pin(gpio, pin) (((gpio)->IDR >> (pin)) & 1) +#if defined(MCU_SERIES_F7) +#define GPIO_set_pin(gpio, pin_mask) (((gpio)->BSRR) = (pin_mask)) +#define GPIO_clear_pin(gpio, pin_mask) (((gpio)->BSRR) = ((pin_mask) << 16)) +#else +#define GPIO_set_pin(gpio, pin_mask) (((gpio)->BSRRL) = (pin_mask)) +#define GPIO_clear_pin(gpio, pin_mask) (((gpio)->BSRRH) = (pin_mask)) +#endif +#define GPIO_read_output_pin(gpio, pin) (((gpio)->ODR >> (pin)) & 1) + +void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio); + +extern const unsigned char mp_hal_status_to_errno_table[4]; + +NORETURN void mp_hal_raise(HAL_StatusTypeDef status); +void mp_hal_set_interrupt_char(int c); // -1 to disable + +#define mp_hal_delay_ms HAL_Delay +#define mp_hal_ticks_ms HAL_GetTick diff --git a/stmhal/pin.c b/stmhal/pin.c index 3aba94975..a0f3994f7 100644 --- a/stmhal/pin.c +++ b/stmhal/pin.c @@ -30,7 +30,7 @@ #include "py/nlr.h" #include "py/runtime.h" -#include MICROPY_HAL_H +#include "py/mphal.h" #include "pin.h" /// \moduleref pyb diff --git a/stmhal/pin_defs_stmhal.c b/stmhal/pin_defs_stmhal.c index 6dfefb6bb..0aef5f95f 100644 --- a/stmhal/pin_defs_stmhal.c +++ b/stmhal/pin_defs_stmhal.c @@ -1,6 +1,5 @@ #include "py/obj.h" #include "pin.h" -#include MICROPY_HAL_H // Returns the pin mode. This value returned by this macro should be one of: // GPIO_MODE_INPUT, GPIO_MODE_OUTPUT_PP, GPIO_MODE_OUTPUT_OD, diff --git a/stmhal/pin_named_pins.c b/stmhal/pin_named_pins.c index d0cf8adc8..9e5f9593b 100644 --- a/stmhal/pin_named_pins.c +++ b/stmhal/pin_named_pins.c @@ -28,7 +28,7 @@ #include #include "py/runtime.h" -#include MICROPY_HAL_H +#include "py/mphal.h" #include "pin.h" STATIC void pin_named_pins_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { diff --git a/stmhal/printf.c b/stmhal/printf.c index 87cf4f0f9..611ad2df4 100644 --- a/stmhal/printf.c +++ b/stmhal/printf.c @@ -29,9 +29,7 @@ #include #include "py/obj.h" -#ifdef MICROPY_HAL_H -#include MICROPY_HAL_H -#endif +#include "py/mphal.h" #if MICROPY_PY_BUILTINS_FLOAT #include "py/formatfloat.h" diff --git a/stmhal/pybstdio.c b/stmhal/pybstdio.c index de0a3a0e3..72c164b36 100644 --- a/stmhal/pybstdio.c +++ b/stmhal/pybstdio.c @@ -30,7 +30,7 @@ #include "py/obj.h" #include "py/stream.h" -#include MICROPY_HAL_H +#include "py/mphal.h" // TODO make stdin, stdout and stderr writable objects so they can // be changed by Python code. This requires some changes, as these diff --git a/stmhal/pyexec.c b/stmhal/pyexec.c index f5de90422..116a41d35 100644 --- a/stmhal/pyexec.c +++ b/stmhal/pyexec.c @@ -33,9 +33,7 @@ #include "py/runtime.h" #include "py/repl.h" #include "py/gc.h" -#ifdef MICROPY_HAL_H -#include MICROPY_HAL_H -#endif +#include "py/mphal.h" #if defined(USE_DEVICE_MODE) #include "irq.h" #include "usb.h" diff --git a/stmhal/spi.c b/stmhal/spi.c index 864463df2..7458da627 100644 --- a/stmhal/spi.c +++ b/stmhal/spi.c @@ -29,13 +29,13 @@ #include "py/nlr.h" #include "py/runtime.h" +#include "py/mphal.h" #include "irq.h" #include "pin.h" #include "genhdr/pins.h" #include "bufhelper.h" #include "dma.h" #include "spi.h" -#include MICROPY_HAL_H // The following defines are for compatability with the '405 #if !defined(MICROPY_HW_SPI1_NSS) diff --git a/stmhal/stm32_it.c b/stmhal/stm32_it.c index dfc33b7c2..1c510d35f 100644 --- a/stmhal/stm32_it.c +++ b/stmhal/stm32_it.c @@ -92,7 +92,7 @@ extern PCD_HandleTypeDef pcd_handle; #if REPORT_HARD_FAULT_REGS -#include "mphal.h" +#include "py/mphal.h" char *fmt_hex(uint32_t val, char *buf) { const char *hexDig = "0123456789abcdef"; diff --git a/stmhal/timer.c b/stmhal/timer.c index f88229b8a..18c027cf3 100644 --- a/stmhal/timer.c +++ b/stmhal/timer.c @@ -35,7 +35,6 @@ #include "py/nlr.h" #include "py/runtime.h" #include "py/gc.h" -#include MICROPY_HAL_H #include "timer.h" #include "servo.h" #include "pin.h" diff --git a/stmhal/uart.c b/stmhal/uart.c index 177318aec..79c272bdb 100644 --- a/stmhal/uart.c +++ b/stmhal/uart.c @@ -32,9 +32,9 @@ #include "py/nlr.h" #include "py/runtime.h" #include "py/stream.h" +#include "py/mphal.h" #include "uart.h" #include "pybioctl.h" -#include MICROPY_HAL_H //TODO: Add UART7/8 support for MCU_SERIES_F7 diff --git a/stmhal/usbd_desc.c b/stmhal/usbd_desc.c index 32e4fd043..1ad960b46 100644 --- a/stmhal/usbd_desc.c +++ b/stmhal/usbd_desc.c @@ -35,7 +35,7 @@ // need these headers just for MP_HAL_UNIQUE_ID_ADDRESS #include "py/misc.h" -#include MICROPY_HAL_H +#include "py/mphal.h" // So we don't clash with existing ST boards, we use the unofficial FOSS VID. // This needs a proper solution. diff --git a/stmhal/usrsw.c b/stmhal/usrsw.c index 225373ca8..69b0ca9ab 100644 --- a/stmhal/usrsw.c +++ b/stmhal/usrsw.c @@ -27,10 +27,10 @@ #include #include "py/runtime.h" +#include "py/mphal.h" #include "extint.h" #include "pin.h" #include "genhdr/pins.h" -#include "mphal.h" #include "usrsw.h" #if MICROPY_HW_HAS_SWITCH -- cgit v1.2.3