File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 6565// every couple of MicroPython byte codes. This also polls to the event loop.
6666#define PYBRICKS_VM_HOOK_LOOP_EXTRA \
6767 do { \
68- static uint32_t count; \
69- if ((count % 16) == 0) { \
70- extern void pbio_test_clock_tick(uint32_t ticks); \
71- pbio_test_clock_tick(1); \
72- } \
68+ extern void pbio_clock_test_advance_eventually(void); \
69+ pbio_clock_test_advance_eventually(); \
7370 } while (0);
7471#else
7572// When using the wall clock, time advances automatically but we still need to
Original file line number Diff line number Diff line change @@ -26,6 +26,23 @@ void pbio_test_clock_tick(uint32_t ticks) {
2626 pbio_os_request_poll ();
2727}
2828
29+ /**
30+ * Simulates incrementing the clock after a certain number of CPU cycles.
31+ *
32+ * This should be called from loops that take a very small but nonzero amount
33+ * of time.
34+ */
35+ void pbio_clock_test_advance_eventually (void ) {
36+
37+ static uint32_t count = 0 ;
38+
39+ if (++ count % 16 ) {
40+ return ;
41+ }
42+
43+ pbio_test_clock_tick (1 );
44+ }
45+
2946void pbdrv_clock_init (void ) {
3047}
3148
You can’t perform that action at this time.
0 commit comments