• 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

0.0
/lib/pbio/include/pbdrv/uart.h
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) 2018-2020 The Pybricks Authors
3

4
/**
5
 * @addtogroup UARTDriver Driver: Universal Asynchronous Receiver/Transmitter (UART)
6
 * @{
7
 */
8

9
#ifndef _PBDRV_UART_H_
10
#define _PBDRV_UART_H_
11

12
#include <stdint.h>
13
#include <stddef.h>
14

15
#include <pbdrv/config.h>
16
#include <pbio/error.h>
17
#include <pbio/os.h>
18
#include <pbio/port.h>
19

20
typedef struct _pbdrv_uart_dev_t pbdrv_uart_dev_t;
21

22
#if PBDRV_CONFIG_UART
23

24
/**
25
 * Get an instance of the UART driver.
26
 *
27
 * @param [in]  id              The ID of the UART device.
28
 * @param [out] uart_dev        The UART device.
29
 */
30
pbio_error_t pbdrv_uart_get_instance(uint8_t id, pbdrv_uart_dev_t **uart_dev);
31

32
void pbdrv_uart_set_baud_rate(pbdrv_uart_dev_t *uart_dev, uint32_t baud);
33
void pbdrv_uart_stop(pbdrv_uart_dev_t *uart_dev);
34
void pbdrv_uart_flush(pbdrv_uart_dev_t *uart_dev);
35

36
int32_t pbdrv_uart_get_char(pbdrv_uart_dev_t *uart_dev);
37

38
/**
39
 * Asynchronously read from the UART.
40
 *
41
 * @param [in]  state     The protothread state.
42
 * @param [in]  uart_dev  The UART device.
43
 * @param [out] msg       The buffer to store the received message.
44
 * @param [in]  length    The length of the expected message.
45
 * @param [in]  timeout   The timeout in milliseconds or 0 for no timeout.
46
 * @return The error code.
47
 */
48
pbio_error_t pbdrv_uart_read(pbio_os_state_t *state, pbdrv_uart_dev_t *uart_dev, uint8_t *msg, uint8_t length, uint32_t timeout);
49

50
/**
51
 * Asynchronously write to the UART.
52
 *
53
 * @param [in]  state     The protothread state.
54
 * @param [in]  uart_dev  The UART device.
55
 * @param [in]  msg       The message to send.
56
 * @param [in]  length    The length of the message.
57
 * @param [in]  timeout   The timeout in milliseconds or 0 for no timeout.
58
 *
59
 * @return The error code.
60
 */
61
pbio_error_t pbdrv_uart_write(pbio_os_state_t *state, pbdrv_uart_dev_t *uart, uint8_t *msg, uint8_t length, uint32_t timeout);
62

63
#else // PBDRV_CONFIG_UART
64

UNCOV
65
static inline pbio_error_t pbdrv_uart_get_instance(uint8_t id, pbdrv_uart_dev_t **uart_dev) {
×
66
    *uart_dev = NULL;
×
67
    return PBIO_ERROR_NOT_SUPPORTED;
×
68
}
69
static inline void pbdrv_uart_set_baud_rate(pbdrv_uart_dev_t *uart_dev, uint32_t baud) {
70
}
71
static inline void pbdrv_uart_stop(pbdrv_uart_dev_t *uart_dev) {
72
}
73
static inline pbio_error_t pbdrv_uart_read_begin(pbdrv_uart_dev_t *uart_dev, uint8_t *msg, uint8_t length, uint32_t timeout) {
74
    return PBIO_ERROR_NOT_SUPPORTED;
75
}
76
static inline pbio_error_t pbdrv_uart_read_end(pbdrv_uart_dev_t *uart_dev) {
77
    return PBIO_ERROR_NOT_SUPPORTED;
78
}
79
static inline pbio_error_t pbdrv_uart_write_begin(pbdrv_uart_dev_t *uart_dev, uint8_t *msg, uint8_t length, uint32_t timeout) {
80
    return PBIO_ERROR_NOT_SUPPORTED;
81
}
82
static inline pbio_error_t pbdrv_uart_write_end(pbdrv_uart_dev_t *uart_dev) {
83
    return PBIO_ERROR_NOT_SUPPORTED;
84
}
85
static inline void pbdrv_uart_write_cancel(pbdrv_uart_dev_t *uart_dev) {
86
}
87
static inline void pbdrv_uart_flush(pbdrv_uart_dev_t *uart_dev) {
88
}
89

90
/**
91
 * Get a character from the UART.
92
 *
93
 * @param uart_dev The UART device
94
 * @return The character read, or -1 if no character is available
95
 */
96
static inline int32_t pbdrv_uart_get_char(pbdrv_uart_dev_t *uart_dev) {
97
    return -1;
98
}
99

100
static inline pbio_error_t pbdrv_uart_write(pbio_os_state_t *state, pbdrv_uart_dev_t *uart_dev, uint8_t *msg, uint8_t length, uint32_t timeout) {
101
    return PBIO_ERROR_NOT_SUPPORTED;
102
}
103

104
static inline pbio_error_t pbdrv_uart_read(pbio_os_state_t *state, pbdrv_uart_dev_t *uart_dev, uint8_t *msg, uint8_t length, uint32_t timeout) {
105
    return PBIO_ERROR_NOT_SUPPORTED;
106
}
107

108
#endif // PBDRV_CONFIG_UART
109

110
#endif // _PBDRV_UART_H_
111

112
/** @} */
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