diff --git a/bricks/_common/arm_none_eabi.mk b/bricks/_common/arm_none_eabi.mk index 2f8393053..ac207b950 100644 --- a/bricks/_common/arm_none_eabi.mk +++ b/bricks/_common/arm_none_eabi.mk @@ -93,9 +93,6 @@ endif # qstr definitions (must come before including py.mk) QSTR_DEFS = $(PBTOP)/bricks/_common/qstrdefs.h QSTR_GLOBAL_DEPENDENCIES = $(PBTOP)/bricks/_common/mpconfigport.h -ifeq ($(PB_MCU_FAMILY),STM32) -QSTR_GLOBAL_DEPENDENCIES += ../_common_stm32/mpconfigport.h -endif # MicroPython feature configurations MICROPY_ROM_TEXT_COMPRESSION ?= 1 diff --git a/bricks/_common/mpconfigport.h b/bricks/_common/mpconfigport.h index e2013c9ba..b12ca47c1 100644 --- a/bricks/_common/mpconfigport.h +++ b/bricks/_common/mpconfigport.h @@ -120,3 +120,48 @@ #if PYBRICKS_OPT_CUSTOM_IMPORT #define mp_builtin___import__ pb_builtin_import #endif + +#define MICROPY_MPHALPORT_H "../_common/mphalport.h" + +// type definitions for the specific machine + +#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1)) + +// This port is intended to be 32-bit, but unfortunately, int32_t for +// different targets may be defined in different ways - either as int +// or as long. This requires different printf formatting specifiers +// to print such value. So, we avoid int32_t and use int directly. +#define UINT_FMT "%u" +#define INT_FMT "%d" +typedef int mp_int_t; // must be pointer size +typedef unsigned mp_uint_t; // must be pointer size + +typedef long mp_off_t; + +#include "pbio_os_config.h" + +#define MICROPY_BEGIN_ATOMIC_SECTION() pbio_os_hook_disable_irq() +#define MICROPY_END_ATOMIC_SECTION(state) pbio_os_hook_enable_irq(state) + +#define MICROPY_VM_HOOK_LOOP \ + do { \ + extern bool pbio_os_run_processes_once(void); \ + pbio_os_run_processes_once(); \ + } while (0); + +#define MICROPY_GC_HOOK_LOOP(i) do { \ + if (((i) & 0xf) == 0) { \ + MICROPY_VM_HOOK_LOOP \ + } \ +} while (0) + +#define MICROPY_EVENT_POLL_HOOK \ + do { \ + extern void pb_event_poll_hook(void); \ + pb_event_poll_hook(); \ + } while (0); + +// We need to provide a declaration/definition of alloca() +#include + +#define MP_STATE_PORT MP_STATE_VM diff --git a/bricks/_common_stm32/mpconfigport.h b/bricks/_common_stm32/mpconfigport.h deleted file mode 100644 index e6b82d31a..000000000 --- a/bricks/_common_stm32/mpconfigport.h +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2013, 2014 Damien P. George -// Copyright (c) 2018-2023 The Pybricks Authors - -// Contains the MicroPython configuration for all STM32-based Pybricks ports. - -// Start with config shared by all Pybricks ports. -#include "../_common/mpconfigport.h" - -#define MICROPY_MPHALPORT_H "../_common/mphalport.h" - -// type definitions for the specific machine - -#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1)) - -// This port is intended to be 32-bit, but unfortunately, int32_t for -// different targets may be defined in different ways - either as int -// or as long. This requires different printf formatting specifiers -// to print such value. So, we avoid int32_t and use int directly. -#define UINT_FMT "%u" -#define INT_FMT "%d" -typedef int mp_int_t; // must be pointer size -typedef unsigned mp_uint_t; // must be pointer size - -typedef long mp_off_t; - -#include "pbio_os_config.h" - -#define MICROPY_BEGIN_ATOMIC_SECTION() pbio_os_hook_disable_irq() -#define MICROPY_END_ATOMIC_SECTION(state) pbio_os_hook_enable_irq(state) - -#define MICROPY_VM_HOOK_LOOP \ - do { \ - extern bool pbio_os_run_processes_once(void); \ - pbio_os_run_processes_once(); \ - } while (0); - -#define MICROPY_GC_HOOK_LOOP(i) do { \ - if (((i) & 0xf) == 0) { \ - MICROPY_VM_HOOK_LOOP \ - } \ -} while (0) - -#define MICROPY_EVENT_POLL_HOOK \ - do { \ - extern void pb_event_poll_hook(void); \ - pb_event_poll_hook(); \ - } while (0); - -// We need to provide a declaration/definition of alloca() -#include - -#define MP_STATE_PORT MP_STATE_VM diff --git a/bricks/cityhub/mpconfigport.h b/bricks/cityhub/mpconfigport.h index 42067f558..c4727a0e4 100644 --- a/bricks/cityhub/mpconfigport.h +++ b/bricks/cityhub/mpconfigport.h @@ -58,4 +58,4 @@ #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) -#include "../_common_stm32/mpconfigport.h" +#include "../_common/mpconfigport.h" diff --git a/bricks/essentialhub/mpconfigport.h b/bricks/essentialhub/mpconfigport.h index 142032d30..57dd2d4c1 100644 --- a/bricks/essentialhub/mpconfigport.h +++ b/bricks/essentialhub/mpconfigport.h @@ -59,4 +59,4 @@ #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) -#include "../_common_stm32/mpconfigport.h" +#include "../_common/mpconfigport.h" diff --git a/bricks/ev3/mpconfigport.h b/bricks/ev3/mpconfigport.h index 69088570c..f7255a1ab 100644 --- a/bricks/ev3/mpconfigport.h +++ b/bricks/ev3/mpconfigport.h @@ -57,54 +57,5 @@ #define PYBRICKS_OPT_EXTRA_LEVEL2 (1) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (1) -// Start with config shared by all Pybricks ports. -#include "../_common/mpconfigport.h" - -// Reduced from 256 for better raw paste stability. -// FIXME: USB driver limitation -- should allow higher. -#define MICROPY_REPL_STDIN_BUFFER_MAX (64) - -#define MICROPY_MPHALPORT_H "../_common/mphalport.h" - -// type definitions for the specific machine - -#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1)) - -// This port is intended to be 32-bit, but unfortunately, int32_t for -// different targets may be defined in different ways - either as int -// or as long. This requires different printf formatting specifiers -// to print such value. So, we avoid int32_t and use int directly. -#define UINT_FMT "%u" -#define INT_FMT "%d" -typedef int mp_int_t; // must be pointer size -typedef unsigned mp_uint_t; // must be pointer size - -typedef long mp_off_t; -#include "pbio_os_config.h" - -#define MICROPY_BEGIN_ATOMIC_SECTION() pbio_os_hook_disable_irq() -#define MICROPY_END_ATOMIC_SECTION(state) pbio_os_hook_enable_irq(state) - -#define MICROPY_VM_HOOK_LOOP \ - do { \ - extern bool pbio_os_run_processes_once(void); \ - pbio_os_run_processes_once(); \ - } while (0); - -#define MICROPY_GC_HOOK_LOOP(i) do { \ - if (((i) & 0xf) == 0) { \ - MICROPY_VM_HOOK_LOOP \ - } \ -} while (0) - -#define MICROPY_EVENT_POLL_HOOK \ - do { \ - extern void pb_event_poll_hook(void); \ - pb_event_poll_hook(); \ - } while (0); - -// We need to provide a declaration/definition of alloca() -#include - -#define MP_STATE_PORT MP_STATE_VM +#include "../_common/mpconfigport.h" diff --git a/bricks/movehub/mpconfigport.h b/bricks/movehub/mpconfigport.h index 6bd2516e4..f8ede50e7 100644 --- a/bricks/movehub/mpconfigport.h +++ b/bricks/movehub/mpconfigport.h @@ -55,4 +55,4 @@ #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) -#include "../_common_stm32/mpconfigport.h" +#include "../_common/mpconfigport.h" diff --git a/bricks/nxt/mpconfigport.h b/bricks/nxt/mpconfigport.h index daa665147..eeb0e97e0 100644 --- a/bricks/nxt/mpconfigport.h +++ b/bricks/nxt/mpconfigport.h @@ -57,50 +57,4 @@ #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) -// Start with config shared by all Pybricks ports. #include "../_common/mpconfigport.h" - -#define MICROPY_MPHALPORT_H "../_common/mphalport.h" - -// type definitions for the specific machine - -#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1)) - -// This port is intended to be 32-bit, but unfortunately, int32_t for -// different targets may be defined in different ways - either as int -// or as long. This requires different printf formatting specifiers -// to print such value. So, we avoid int32_t and use int directly. -#define UINT_FMT "%u" -#define INT_FMT "%d" -typedef int mp_int_t; // must be pointer size -typedef unsigned mp_uint_t; // must be pointer size - -typedef long mp_off_t; - -// We need to provide a declaration/definition of alloca() -#include - -#include "pbio_os_config.h" - -#define MICROPY_BEGIN_ATOMIC_SECTION() pbio_os_hook_disable_irq() -#define MICROPY_END_ATOMIC_SECTION(state) pbio_os_hook_enable_irq(state) - -#define MICROPY_VM_HOOK_LOOP \ - do { \ - extern bool pbio_os_run_processes_once(void); \ - pbio_os_run_processes_once(); \ - } while (0); - -#define MICROPY_GC_HOOK_LOOP(i) do { \ - if (((i) & 0xf) == 0) { \ - MICROPY_VM_HOOK_LOOP \ - } \ -} while (0) - -#define MICROPY_EVENT_POLL_HOOK \ - do { \ - extern void pb_event_poll_hook(void); \ - pb_event_poll_hook(); \ - } while (0); - -#define MP_STATE_PORT MP_STATE_VM diff --git a/bricks/primehub/mpconfigport.h b/bricks/primehub/mpconfigport.h index d88884174..217bf2008 100644 --- a/bricks/primehub/mpconfigport.h +++ b/bricks/primehub/mpconfigport.h @@ -60,4 +60,4 @@ #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (1) -#include "../_common_stm32/mpconfigport.h" +#include "../_common/mpconfigport.h" diff --git a/bricks/technichub/mpconfigport.h b/bricks/technichub/mpconfigport.h index 3d83861e1..0a999489f 100644 --- a/bricks/technichub/mpconfigport.h +++ b/bricks/technichub/mpconfigport.h @@ -58,4 +58,4 @@ #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) -#include "../_common_stm32/mpconfigport.h" +#include "../_common/mpconfigport.h"