summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-01-17 18:19:07 -0800
committerScott Shawcroft <scott@tannewt.org>2019-01-17 18:19:07 -0800
commit6404aaf411d7fe5fd96f3a8cbf7a1cb7580a09e7 (patch)
treec4862f29c962e724a0df35c01ed04256df03b22a /supervisor
parent760bd8d8a4f0aa0ed8651e89596fb2e6effbc14f (diff)
Fix up nrf and using board.SPI in FourWire
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/shared/board_busses.c25
-rw-r--r--supervisor/shared/board_busses.h6
2 files changed, 23 insertions, 8 deletions
diff --git a/supervisor/shared/board_busses.c b/supervisor/shared/board_busses.c
index 38308ccee..ed1f98a58 100644
--- a/supervisor/shared/board_busses.c
+++ b/supervisor/shared/board_busses.c
@@ -33,6 +33,10 @@
#include "mpconfigboard.h"
#include "py/runtime.h"
+#ifdef CIRCUITPY_DISPLAYIO
+#include "shared-module/displayio/__init__.h"
+#endif
+
#define BOARD_I2C (defined(DEFAULT_I2C_BUS_SDA) && defined(DEFAULT_I2C_BUS_SCL))
#define BOARD_SPI (defined(DEFAULT_SPI_BUS_SCK) && defined(DEFAULT_SPI_BUS_MISO) && defined(DEFAULT_SPI_BUS_MOSI))
#define BOARD_UART (defined(DEFAULT_UART_BUS_RX) && defined(DEFAULT_UART_BUS_TX))
@@ -40,7 +44,7 @@
#if BOARD_I2C
STATIC mp_obj_t i2c_singleton = NULL;
-STATIC mp_obj_t board_i2c(void) {
+mp_obj_t board_i2c(void) {
if (i2c_singleton == NULL) {
busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t);
@@ -54,7 +58,7 @@ STATIC mp_obj_t board_i2c(void) {
return i2c_singleton;
}
#else
-STATIC mp_obj_t board_i2c(void) {
+mp_obj_t board_i2c(void) {
mp_raise_NotImplementedError(translate("No default I2C bus"));
return NULL;
}
@@ -91,7 +95,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi);
#if BOARD_UART
STATIC mp_obj_t uart_singleton = NULL;
-STATIC mp_obj_t board_uart(void) {
+mp_obj_t board_uart(void) {
if (uart_singleton == NULL) {
busio_uart_obj_t *self = m_new_obj(busio_uart_obj_t);
self->base.type = &busio_uart_type;
@@ -108,7 +112,7 @@ STATIC mp_obj_t board_uart(void) {
return uart_singleton;
}
#else
-STATIC mp_obj_t board_uart(void) {
+mp_obj_t board_uart(void) {
mp_raise_NotImplementedError(translate("No default UART bus"));
return NULL;
}
@@ -121,7 +125,18 @@ void reset_board_busses(void) {
i2c_singleton = NULL;
#endif
#if BOARD_SPI
- spi_singleton = NULL;
+ bool display_using_spi = false;
+ #ifdef CIRCUITPY_DISPLAYIO
+ for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
+ if (displays[i].fourwire_bus.bus == spi_singleton) {
+ display_using_spi = true;
+ break;
+ }
+ }
+ #endif
+ if (!display_using_spi) {
+ spi_singleton = NULL;
+ }
#endif
#if BOARD_UART
uart_singleton = NULL;
diff --git a/supervisor/shared/board_busses.h b/supervisor/shared/board_busses.h
index f6a8a4296..0ccb3ba6a 100644
--- a/supervisor/shared/board_busses.h
+++ b/supervisor/shared/board_busses.h
@@ -30,13 +30,13 @@
#include "py/obj.h"
mp_obj_t board_i2c(void);
-extern mp_obj_fun_builtin_fixed_t board_i2c_obj;
+MP_DECLARE_CONST_FUN_OBJ_0(board_i2c_obj);
mp_obj_t board_spi(void);
-extern mp_obj_fun_builtin_fixed_t board_spi_obj;
+MP_DECLARE_CONST_FUN_OBJ_0(board_spi_obj);
mp_obj_t board_uart(void);
-extern mp_obj_fun_builtin_fixed_t board_uart_obj;
+MP_DECLARE_CONST_FUN_OBJ_0(board_uart_obj);
void reset_board_busses(void);