• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pybricks / pybricks-micropython / 14329424534

31 Mar 2025 01:50PM UTC coverage: 56.638% (+0.2%) from 56.477%
14329424534

push

github

laurensvalk
pbio/os: Move IRQ hooks to platform.

Proceed to make pbio more independent from MicroPython.

Also restore them as static inline as they used to be
prior to https://github.com/pybricks/pybricks-micropython/pull/298
which reduces build size.

0 of 6 new or added lines in 1 file covered. (0.0%)

204 existing lines in 11 files now uncovered.

3878 of 6847 relevant lines covered (56.64%)

20623019.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.41
/lib/pbio/sys/core.c
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) 2022 The Pybricks Authors
3

4
#include <stdint.h>
5

6
#include <pbio/main.h>
7
#include <pbio/os.h>
8

9
#include <pbsys/battery.h>
10
#include <pbsys/bluetooth.h>
11

12
#include "core.h"
13
#include "hmi.h"
14
#include "light.h"
15
#include "storage.h"
16
#include "supervisor.h"
17
#include "program_stop.h"
18

19
uint32_t pbsys_init_busy_count;
20

21
PROCESS(pbsys_system_process, "System");
22

23
PROCESS_THREAD(pbsys_system_process, ev, data) {
1,083✔
24
    static struct etimer timer;
1,083✔
25

26
    PROCESS_BEGIN();
1,083✔
27

28
    etimer_set(&timer, 50);
24✔
29

30
    for (;;) {
1,083✔
31
        PROCESS_WAIT_EVENT();
1,083✔
32
        pbsys_hmi_handle_event(ev, data);
1,059✔
33
        if (ev == PROCESS_EVENT_TIMER && etimer_expired(&timer)) {
1,059✔
34
            etimer_reset(&timer);
1,035✔
35
            pbsys_battery_poll();
1,035✔
36
            pbsys_hmi_poll();
1,035✔
37
            pbsys_supervisor_poll();
1,035✔
38
            pbsys_program_stop_poll();
1,035✔
39
        }
40
    }
41

UNCOV
42
    PROCESS_END();
×
43
}
44

45
void pbsys_init(void) {
24✔
46
    pbsys_battery_init();
24✔
47
    pbsys_bluetooth_init();
24✔
48
    pbsys_hmi_init();
24✔
49
    pbsys_storage_init();
24✔
50
    process_start(&pbsys_system_process);
24✔
51

52
    while (pbsys_init_busy()) {
24✔
UNCOV
53
        pbio_os_run_processes_once();
×
54
    }
55
}
24✔
56

UNCOV
57
void pbsys_deinit(void) {
×
58

UNCOV
59
    pbsys_storage_deinit();
×
60

UNCOV
61
    uint32_t start = pbdrv_clock_get_ms();
×
62

63
    // Wait for all relevant pbsys processes to end, but at least 500 ms so we
64
    // see a shutdown animation even if the button is released sooner.
UNCOV
65
    while (pbsys_init_busy() || pbdrv_clock_get_ms() - start < 500) {
×
66
        pbio_os_run_processes_once();
×
67
    }
UNCOV
68
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc