Skip to content

Commit ac60b31

Browse files
authored
Merge pull request adafruit#10834 from tannewt/fix_port_yield
Remove extra yields for Zephyr
2 parents 8a4c050 + 0a244ee commit ac60b31

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed

ports/zephyr-cp/background.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ void port_background_tick(void) {
3636
#endif
3737
}
3838

39-
// Allow boards to override this.
40-
MP_WEAK void board_background_task(void) {
41-
}
42-
4339
void port_background_task(void) {
44-
board_background_task();
40+
// Make sure time advances in the simulator.
41+
#if defined(CONFIG_ARCH_POSIX)
42+
k_busy_wait(100);
43+
#endif
4544
}

ports/zephyr-cp/mphalport.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
#include "py/mpconfig.h"
1414
#include "supervisor/shared/tick.h"
1515

16+
#include <zephyr/kernel.h>
17+
1618
#define mp_hal_ticks_ms() ((mp_uint_t)supervisor_ticks_ms32())
17-
#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t)(us))
19+
20+
static inline void mp_hal_delay_us(mp_uint_t us) {
21+
k_busy_wait((uint32_t)us);
22+
}
1823

1924
bool mp_hal_stdin_any(void);

ports/zephyr-cp/supervisor/port.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ void port_wake_main_task_from_isr(void) {
6767

6868
void port_yield(void) {
6969
k_yield();
70-
// Make sure time advances in the simulator.
71-
#if defined(CONFIG_ARCH_POSIX)
72-
k_busy_wait(100);
73-
#endif
7470
}
7571

7672
void port_boot_info(void) {
@@ -97,6 +93,10 @@ uint32_t port_get_saved_word(void) {
9793
}
9894

9995
uint64_t port_get_raw_ticks(uint8_t *subticks) {
96+
// Make sure time advances in the simulator.
97+
#if defined(CONFIG_ARCH_POSIX)
98+
k_busy_wait(100);
99+
#endif
100100
int64_t uptime = k_uptime_ticks() * 32768 / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
101101
if (subticks != NULL) {
102102
*subticks = uptime % 32;

supervisor/shared/background_callback.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ static int background_prevention_count;
6161
void PLACE_IN_ITCM(background_callback_run_all)(void) {
6262
port_background_task();
6363
if (!background_callback_pending()) {
64-
// TEMPORARY to fix #10822
65-
#ifdef __ZEPHYR__
66-
port_yield();
67-
#endif
6864
return;
6965
}
7066
CALLBACK_CRITICAL_BEGIN;
@@ -91,10 +87,6 @@ void PLACE_IN_ITCM(background_callback_run_all)(void) {
9187
}
9288
--background_prevention_count;
9389
CALLBACK_CRITICAL_END;
94-
// TEMPORARY to fix #10822
95-
#ifdef __ZEPHYR__
96-
port_yield();
97-
#endif
9890
}
9991

10092
void background_callback_prevent(void) {

supervisor/shared/safe_mode.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ safe_mode_t wait_for_safe_mode_reset(void) {
8282
boot_in_safe_mode = true;
8383
break;
8484
}
85-
// TEMPORARY to fix #10822
86-
#ifdef __ZEPHYR__
87-
port_yield();
88-
#endif
8985
diff = supervisor_ticks_ms64() - start_ticks;
9086
}
9187
#if CIRCUITPY_STATUS_LED

0 commit comments

Comments
 (0)