Skip to content

Commit 7299207

Browse files
committed
Fix boards with no shared busses.
1 parent ac7822b commit 7299207

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

py/runtime.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,14 @@ NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg) {
15901590
mp_raise_msg(&mp_type_NotImplementedError, msg);
15911591
}
15921592

1593+
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...) {
1594+
va_list argptr;
1595+
va_start(argptr,fmt);
1596+
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_NotImplementedError, fmt, argptr);
1597+
va_end(argptr);
1598+
nlr_raise(exception);
1599+
}
1600+
15931601
#if MICROPY_STACK_CHECK || MICROPY_ENABLE_PYSTACK
15941602
NORETURN void mp_raise_recursion_depth(void) {
15951603
mp_raise_RuntimeError(translate("maximum recursion depth exceeded"));

py/runtime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ NORETURN void mp_raise_OSError(int errno_);
162162
NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg);
163163
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...);
164164
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg);
165+
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...);
165166
NORETURN void mp_raise_recursion_depth(void);
166167

167168
#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG

shared-bindings/board/__init__.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include "py/obj.h"
28+
#include "py/runtime.h"
2829

2930
#include "shared-bindings/board/__init__.h"
3031

shared-module/board/__init__.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "shared-module/displayio/__init__.h"
3838
#endif
3939

40+
#if BOARD_I2C
4041
mp_obj_t common_hal_board_get_i2c(void) {
4142
return MP_STATE_VM(shared_i2c_bus);
4243
}
@@ -49,7 +50,10 @@ mp_obj_t common_hal_board_create_i2c(void) {
4950
MP_STATE_VM(shared_i2c_bus) = MP_OBJ_FROM_PTR(self);
5051
return MP_STATE_VM(shared_i2c_bus);
5152
}
53+
#endif
5254

55+
56+
#if BOARD_SPI
5357
// Statically allocate the SPI object so it can live past the end of the heap and into the next VM.
5458
// That way it can be used by built-in FourWire displays and be accessible through board.SPI().
5559
STATIC busio_spi_obj_t spi_obj;
@@ -73,7 +77,9 @@ mp_obj_t common_hal_board_create_spi(void) {
7377
spi_singleton = (mp_obj_t)self;
7478
return spi_singleton;
7579
}
80+
#endif
7681

82+
#if BOARD_UART
7783
mp_obj_t common_hal_board_get_uart(void) {
7884
return MP_STATE_VM(shared_uart_bus);
7985
}
@@ -89,6 +95,7 @@ mp_obj_t common_hal_board_create_uart(void) {
8995
MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self);
9096
return MP_STATE_VM(shared_uart_bus);
9197
}
98+
#endif
9299

93100
void reset_board_busses(void) {
94101
#if BOARD_I2C

shared-module/displayio/__init__.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,14 @@ void reset_displays(void) {
191191
if (((uint32_t) fourwire->bus) < ((uint32_t) &displays) ||
192192
((uint32_t) fourwire->bus) > ((uint32_t) &displays + CIRCUITPY_DISPLAY_LIMIT)) {
193193
busio_spi_obj_t* original_spi = fourwire->bus;
194-
// We don't need to move original_spi if it is the board.SPI object because it is
195-
// statically allocated already. (Doing so would also make it impossible to reference in
196-
// a subsequent VM run.)
197-
if (original_spi == common_hal_board_get_spi()) {
198-
continue;
199-
}
194+
#if BOARD_SPI
195+
// We don't need to move original_spi if it is the board.SPI object because it is
196+
// statically allocated already. (Doing so would also make it impossible to reference in
197+
// a subsequent VM run.)
198+
if (original_spi == common_hal_board_get_spi()) {
199+
continue;
200+
}
201+
#endif
200202
memcpy(&fourwire->inline_bus, original_spi, sizeof(busio_spi_obj_t));
201203
fourwire->bus = &fourwire->inline_bus;
202204
// Check for other displays that use the same spi bus and swap them too.

0 commit comments

Comments
 (0)