Skip to content

Commit 9db2873

Browse files
committed
bricks/_common/mpconfigport: deduplicate mpconfigport.h files
Move duplicated content from individual hub ports to the existing common mpconfigport.h file. This also has the side effect of removing MICROPY_REPL_STDIN_BUFFER_MAX in the EV3 port which is no longer needed since we have reworked the USB code.
1 parent db177a5 commit 9db2873

File tree

10 files changed

+51
-157
lines changed

10 files changed

+51
-157
lines changed

bricks/_common/arm_none_eabi.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ endif
9393
# qstr definitions (must come before including py.mk)
9494
QSTR_DEFS = $(PBTOP)/bricks/_common/qstrdefs.h
9595
QSTR_GLOBAL_DEPENDENCIES = $(PBTOP)/bricks/_common/mpconfigport.h
96-
ifeq ($(PB_MCU_FAMILY),STM32)
97-
QSTR_GLOBAL_DEPENDENCIES += ../_common_stm32/mpconfigport.h
98-
endif
9996

10097
# MicroPython feature configurations
10198
MICROPY_ROM_TEXT_COMPRESSION ?= 1

bricks/_common/mpconfigport.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,48 @@
120120
#if PYBRICKS_OPT_CUSTOM_IMPORT
121121
#define mp_builtin___import__ pb_builtin_import
122122
#endif
123+
124+
#define MICROPY_MPHALPORT_H "../_common/mphalport.h"
125+
126+
// type definitions for the specific machine
127+
128+
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1))
129+
130+
// This port is intended to be 32-bit, but unfortunately, int32_t for
131+
// different targets may be defined in different ways - either as int
132+
// or as long. This requires different printf formatting specifiers
133+
// to print such value. So, we avoid int32_t and use int directly.
134+
#define UINT_FMT "%u"
135+
#define INT_FMT "%d"
136+
typedef int mp_int_t; // must be pointer size
137+
typedef unsigned mp_uint_t; // must be pointer size
138+
139+
typedef long mp_off_t;
140+
141+
#include "pbio_os_config.h"
142+
143+
#define MICROPY_BEGIN_ATOMIC_SECTION() pbio_os_hook_disable_irq()
144+
#define MICROPY_END_ATOMIC_SECTION(state) pbio_os_hook_enable_irq(state)
145+
146+
#define MICROPY_VM_HOOK_LOOP \
147+
do { \
148+
extern bool pbio_os_run_processes_once(void); \
149+
pbio_os_run_processes_once(); \
150+
} while (0);
151+
152+
#define MICROPY_GC_HOOK_LOOP(i) do { \
153+
if (((i) & 0xf) == 0) { \
154+
MICROPY_VM_HOOK_LOOP \
155+
} \
156+
} while (0)
157+
158+
#define MICROPY_EVENT_POLL_HOOK \
159+
do { \
160+
extern void pb_event_poll_hook(void); \
161+
pb_event_poll_hook(); \
162+
} while (0);
163+
164+
// We need to provide a declaration/definition of alloca()
165+
#include <alloca.h>
166+
167+
#define MP_STATE_PORT MP_STATE_VM

bricks/_common_stm32/mpconfigport.h

Lines changed: 0 additions & 53 deletions
This file was deleted.

bricks/cityhub/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@
5858
#define PYBRICKS_OPT_CUSTOM_IMPORT (1)
5959
#define PYBRICKS_OPT_NATIVE_MOD (0)
6060

61-
#include "../_common_stm32/mpconfigport.h"
61+
#include "../_common/mpconfigport.h"

bricks/essentialhub/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@
5959
#define PYBRICKS_OPT_CUSTOM_IMPORT (1)
6060
#define PYBRICKS_OPT_NATIVE_MOD (0)
6161

62-
#include "../_common_stm32/mpconfigport.h"
62+
#include "../_common/mpconfigport.h"

bricks/ev3/mpconfigport.h

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -57,54 +57,5 @@
5757
#define PYBRICKS_OPT_EXTRA_LEVEL2 (1)
5858
#define PYBRICKS_OPT_CUSTOM_IMPORT (1)
5959
#define PYBRICKS_OPT_NATIVE_MOD (1)
60-
// Start with config shared by all Pybricks ports.
61-
#include "../_common/mpconfigport.h"
62-
63-
// Reduced from 256 for better raw paste stability.
64-
// FIXME: USB driver limitation -- should allow higher.
65-
#define MICROPY_REPL_STDIN_BUFFER_MAX (64)
66-
67-
#define MICROPY_MPHALPORT_H "../_common/mphalport.h"
68-
69-
// type definitions for the specific machine
70-
71-
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1))
72-
73-
// This port is intended to be 32-bit, but unfortunately, int32_t for
74-
// different targets may be defined in different ways - either as int
75-
// or as long. This requires different printf formatting specifiers
76-
// to print such value. So, we avoid int32_t and use int directly.
77-
#define UINT_FMT "%u"
78-
#define INT_FMT "%d"
79-
typedef int mp_int_t; // must be pointer size
80-
typedef unsigned mp_uint_t; // must be pointer size
81-
82-
typedef long mp_off_t;
8360

84-
#include "pbio_os_config.h"
85-
86-
#define MICROPY_BEGIN_ATOMIC_SECTION() pbio_os_hook_disable_irq()
87-
#define MICROPY_END_ATOMIC_SECTION(state) pbio_os_hook_enable_irq(state)
88-
89-
#define MICROPY_VM_HOOK_LOOP \
90-
do { \
91-
extern bool pbio_os_run_processes_once(void); \
92-
pbio_os_run_processes_once(); \
93-
} while (0);
94-
95-
#define MICROPY_GC_HOOK_LOOP(i) do { \
96-
if (((i) & 0xf) == 0) { \
97-
MICROPY_VM_HOOK_LOOP \
98-
} \
99-
} while (0)
100-
101-
#define MICROPY_EVENT_POLL_HOOK \
102-
do { \
103-
extern void pb_event_poll_hook(void); \
104-
pb_event_poll_hook(); \
105-
} while (0);
106-
107-
// We need to provide a declaration/definition of alloca()
108-
#include <alloca.h>
109-
110-
#define MP_STATE_PORT MP_STATE_VM
61+
#include "../_common/mpconfigport.h"

bricks/movehub/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@
5555
#define PYBRICKS_OPT_CUSTOM_IMPORT (1)
5656
#define PYBRICKS_OPT_NATIVE_MOD (0)
5757

58-
#include "../_common_stm32/mpconfigport.h"
58+
#include "../_common/mpconfigport.h"

bricks/nxt/mpconfigport.h

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -57,50 +57,4 @@
5757
#define PYBRICKS_OPT_CUSTOM_IMPORT (1)
5858
#define PYBRICKS_OPT_NATIVE_MOD (0)
5959

60-
// Start with config shared by all Pybricks ports.
6160
#include "../_common/mpconfigport.h"
62-
63-
#define MICROPY_MPHALPORT_H "../_common/mphalport.h"
64-
65-
// type definitions for the specific machine
66-
67-
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1))
68-
69-
// This port is intended to be 32-bit, but unfortunately, int32_t for
70-
// different targets may be defined in different ways - either as int
71-
// or as long. This requires different printf formatting specifiers
72-
// to print such value. So, we avoid int32_t and use int directly.
73-
#define UINT_FMT "%u"
74-
#define INT_FMT "%d"
75-
typedef int mp_int_t; // must be pointer size
76-
typedef unsigned mp_uint_t; // must be pointer size
77-
78-
typedef long mp_off_t;
79-
80-
// We need to provide a declaration/definition of alloca()
81-
#include <alloca.h>
82-
83-
#include "pbio_os_config.h"
84-
85-
#define MICROPY_BEGIN_ATOMIC_SECTION() pbio_os_hook_disable_irq()
86-
#define MICROPY_END_ATOMIC_SECTION(state) pbio_os_hook_enable_irq(state)
87-
88-
#define MICROPY_VM_HOOK_LOOP \
89-
do { \
90-
extern bool pbio_os_run_processes_once(void); \
91-
pbio_os_run_processes_once(); \
92-
} while (0);
93-
94-
#define MICROPY_GC_HOOK_LOOP(i) do { \
95-
if (((i) & 0xf) == 0) { \
96-
MICROPY_VM_HOOK_LOOP \
97-
} \
98-
} while (0)
99-
100-
#define MICROPY_EVENT_POLL_HOOK \
101-
do { \
102-
extern void pb_event_poll_hook(void); \
103-
pb_event_poll_hook(); \
104-
} while (0);
105-
106-
#define MP_STATE_PORT MP_STATE_VM

bricks/primehub/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@
6060
#define PYBRICKS_OPT_CUSTOM_IMPORT (1)
6161
#define PYBRICKS_OPT_NATIVE_MOD (1)
6262

63-
#include "../_common_stm32/mpconfigport.h"
63+
#include "../_common/mpconfigport.h"

bricks/technichub/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@
5858
#define PYBRICKS_OPT_CUSTOM_IMPORT (1)
5959
#define PYBRICKS_OPT_NATIVE_MOD (0)
6060

61-
#include "../_common_stm32/mpconfigport.h"
61+
#include "../_common/mpconfigport.h"

0 commit comments

Comments
 (0)