Skip to content

Commit db177a5

Browse files
committed
bricks/_common/mphalport: use same file for EV3 and STM32
Move the STM32 mphalport.c to the common directory so that it can be used for both the EV3 and STM32 ports. Eventually, all platforms should use the same file. The EV3 clock driver had to have a small change to make it work with the common mphalport.c. Also clean up some duplication with regard to thumb assembly code files while we are touching this.
1 parent dfec425 commit db177a5

File tree

4 files changed

+13
-108
lines changed

4 files changed

+13
-108
lines changed

bricks/_common/arm_none_eabi.mk

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -253,24 +253,22 @@ PY_EXTRA_SRC_C += $(addprefix bricks/_common/,\
253253
micropython.c \
254254
)
255255

256-
ifeq ($(PB_MCU_FAMILY),STM32)
257-
PY_EXTRA_SRC_C += $(addprefix bricks/_common_stm32/,\
256+
# TODO: NXT should eventually use the same mphalport.c as well.
257+
ifeq ($(PB_MCU_FAMILY),AT91SAM7)
258+
PY_EXTRA_SRC_C += $(addprefix bricks/nxt/,\
258259
mphalport.c \
259260
)
260-
261-
ifeq ($(PB_MCU_SERIES),F0)
262-
SRC_S += shared/runtime/gchelper_thumb1.s
263261
else
264-
SRC_S += shared/runtime/gchelper_thumb2.s
265-
endif
266-
endif
267-
268-
ifeq ($(PB_MCU_FAMILY),AT91SAM7)
269-
PY_EXTRA_SRC_C += $(addprefix bricks/nxt/,\
262+
PY_EXTRA_SRC_C += $(addprefix bricks/_common/,\
270263
mphalport.c \
271264
)
265+
endif
272266

267+
# Not all MCUs support thumb2 instructions.
268+
ifeq ($(PB_MCU_SERIES),$(filter $(PB_MCU_SERIES),AT91SAM7 F0 TIAM1808))
273269
SRC_S += shared/runtime/gchelper_thumb1.s
270+
else
271+
SRC_S += shared/runtime/gchelper_thumb2.s
274272
endif
275273

276274
# Skipping uart_irda_cir.c, gpio_v2.c, and hsi2c.c usbphyGS70.c, which
@@ -316,14 +314,6 @@ EV3_SRC_S = $(addprefix lib/pbio/platform/ev3/,\
316314
start.S \
317315
)
318316

319-
ifeq ($(PB_MCU_FAMILY),TIAM1808)
320-
PY_EXTRA_SRC_C += $(addprefix bricks/ev3/,\
321-
mphalport.c \
322-
)
323-
324-
SRC_S += shared/runtime/gchelper_thumb1.s
325-
endif
326-
327317
# STM32 Bluetooth stack
328318

329319
BLUENRG_SRC_C = $(addprefix lib/BlueNRG-MS/hci/,\
File renamed without changes.

bricks/ev3/mphalport.c

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

lib/pbio/drv/clock/clock_ev3.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
// SPDX-License-Identifier: MPL-1.0
1+
// SPDX-License-Identifier: MPL-1.0 AND MIT
22
// Copyright (c) 2016 Tobias Schießl
3-
4-
// SPDX-License-Identifier: MIT
53
// Copyright (c) 2024 The Pybricks Authors
64

7-
85
#include <pbdrv/config.h>
96

107
#if PBDRV_CONFIG_CLOCK_TIAM1808
@@ -35,7 +32,7 @@ static const uint32_t timer_us_division = auxclk_freq_hz / 1000000;
3532
/**
3633
* The current tick in milliseconds
3734
*/
38-
volatile uint32_t systick_ms = 0;
35+
volatile uint32_t pbdrv_clock_ticks;
3936

4037
/**
4138
* The systick interrupt service routine (ISR) which will be called every millisecond.
@@ -45,7 +42,7 @@ void systick_isr_C(void) {
4542
IntSystemStatusClear(SYS_INT_TINT12_0);
4643
TimerIntStatusClear(SOC_TMR_0_REGS, TMR_INTSTAT12_TIMER_NON_CAPT);
4744

48-
++systick_ms;
45+
pbdrv_clock_ticks++;
4946

5047
etimer_request_poll();
5148
pbio_os_request_poll();
@@ -88,7 +85,7 @@ uint32_t pbdrv_clock_get_us(void) {
8885
}
8986

9087
uint32_t pbdrv_clock_get_ms(void) {
91-
return systick_ms;
88+
return pbdrv_clock_ticks;
9289
}
9390

9491
uint32_t pbdrv_clock_get_100us(void) {

0 commit comments

Comments
 (0)