Skip to content

Commit 4d43486

Browse files
committed
bricks/simhub: Compile option for CI clock.
For CI tests, we don't want to wait on the wall clock.
1 parent 2e2b2d2 commit 4d43486

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

bricks/simhub/pbio_os_hook.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,41 @@
99
#include "py/runtime.h"
1010
#include "py/mphal.h"
1111

12+
#if PBDRV_CONFIG_CLOCK_TEST
13+
#include <pbdrv/../../drv/clock/clock_test.h>
14+
#endif
15+
1216
pbio_os_irq_flags_t pbio_os_hook_disable_irq(void) {
1317
sigset_t sigmask;
14-
sigfillset(&sigmask);
1518

19+
#if PBDRV_CONFIG_CLOCK_TEST
20+
sigemptyset(&sigmask);
21+
return sigmask;
22+
#endif
23+
24+
sigfillset(&sigmask);
1625
sigset_t origmask;
1726
pthread_sigmask(SIG_SETMASK, &sigmask, &origmask);
1827
return origmask;
1928
}
2029

2130
void pbio_os_hook_enable_irq(pbio_os_irq_flags_t flags) {
31+
#if PBDRV_CONFIG_CLOCK_TEST
32+
return;
33+
#endif
34+
2235
sigset_t origmask = (sigset_t)flags;
2336
pthread_sigmask(SIG_SETMASK, &origmask, NULL);
2437
}
2538

2639
void pbio_os_hook_wait_for_interrupt(pbio_os_irq_flags_t flags) {
40+
#if PBDRV_CONFIG_CLOCK_TEST
41+
// All events have been handled at this time. Advance the clock
42+
// and continue immediately.
43+
pbio_test_clock_tick(1);
44+
return;
45+
#endif
46+
2747
struct timespec timeout = {
2848
.tv_sec = 0,
2949
.tv_nsec = 100000,

lib/pbio/platform/sim_hub/pbdrvconfig.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
#define PBDRV_CONFIG_BUTTON_TEST (1)
1616

1717
#define PBDRV_CONFIG_CLOCK (1)
18-
#define PBDRV_CONFIG_CLOCK_LINUX (1)
18+
#ifdef PBDRV_CONFIG_CLOCK_LINUX
1919
#define PBDRV_CONFIG_CLOCK_LINUX_SIGNAL (1)
20+
#else
21+
#define PBDRV_CONFIG_CLOCK_TEST (1)
22+
#endif
2023

2124
#define PBDRV_CONFIG_COUNTER (1)
2225

0 commit comments

Comments
 (0)