diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-04-09 11:36:10 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2019-04-09 11:36:10 -0700 |
| commit | 72992070c5137ce44969555828673ba7ccd69f08 (patch) | |
| tree | 6b0540f83aa47efd12ba43c9dafffc656cd0151a /shared-module | |
| parent | ac7822ba4c144634593c2a0e4a98d0bd75c6de5c (diff) | |
Fix boards with no shared busses.
Diffstat (limited to 'shared-module')
| -rw-r--r-- | shared-module/board/__init__.c | 7 | ||||
| -rw-r--r-- | shared-module/displayio/__init__.c | 14 |
2 files changed, 15 insertions, 6 deletions
diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 3647e2654..ac4de2fe5 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -37,6 +37,7 @@ #include "shared-module/displayio/__init__.h" #endif +#if BOARD_I2C mp_obj_t common_hal_board_get_i2c(void) { return MP_STATE_VM(shared_i2c_bus); } @@ -49,7 +50,10 @@ mp_obj_t common_hal_board_create_i2c(void) { MP_STATE_VM(shared_i2c_bus) = MP_OBJ_FROM_PTR(self); return MP_STATE_VM(shared_i2c_bus); } +#endif + +#if BOARD_SPI // Statically allocate the SPI object so it can live past the end of the heap and into the next VM. // That way it can be used by built-in FourWire displays and be accessible through board.SPI(). STATIC busio_spi_obj_t spi_obj; @@ -73,7 +77,9 @@ mp_obj_t common_hal_board_create_spi(void) { spi_singleton = (mp_obj_t)self; return spi_singleton; } +#endif +#if BOARD_UART mp_obj_t common_hal_board_get_uart(void) { return MP_STATE_VM(shared_uart_bus); } @@ -89,6 +95,7 @@ mp_obj_t common_hal_board_create_uart(void) { MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self); return MP_STATE_VM(shared_uart_bus); } +#endif void reset_board_busses(void) { #if BOARD_I2C diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index c1f5a6810..156640440 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -191,12 +191,14 @@ void reset_displays(void) { if (((uint32_t) fourwire->bus) < ((uint32_t) &displays) || ((uint32_t) fourwire->bus) > ((uint32_t) &displays + CIRCUITPY_DISPLAY_LIMIT)) { busio_spi_obj_t* original_spi = fourwire->bus; - // We don't need to move original_spi if it is the board.SPI object because it is - // statically allocated already. (Doing so would also make it impossible to reference in - // a subsequent VM run.) - if (original_spi == common_hal_board_get_spi()) { - continue; - } + #if BOARD_SPI + // We don't need to move original_spi if it is the board.SPI object because it is + // statically allocated already. (Doing so would also make it impossible to reference in + // a subsequent VM run.) + if (original_spi == common_hal_board_get_spi()) { + continue; + } + #endif memcpy(&fourwire->inline_bus, original_spi, sizeof(busio_spi_obj_t)); fourwire->bus = &fourwire->inline_bus; // Check for other displays that use the same spi bus and swap them too. |
