Fix flash-display conflict error

This commit is contained in:
Lucian Copeland 2020-01-24 14:25:36 -05:00
parent d8bc57c1dc
commit 2afca4e942
6 changed files with 32 additions and 0 deletions

View File

@ -38,6 +38,7 @@
#define BOARD_OSC_DIV 12
#define BOARD_NO_VBUS_SENSE
//#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader
#define SHOW_FLASH_SPI
// On-board flash
#define SPI_FLASH_MOSI_PIN (&pin_PB15)

View File

@ -428,31 +428,43 @@ STATIC void spi_clock_disable(uint8_t mask) {
#ifdef SPI1
if (mask & (1 << 0)) {
__HAL_RCC_SPI1_CLK_DISABLE();
__HAL_RCC_SPI1_FORCE_RESET();
__HAL_RCC_SPI1_RELEASE_RESET();
}
#endif
#ifdef SPI2
if (mask & (1 << 1)) {
__HAL_RCC_SPI2_CLK_DISABLE();
__HAL_RCC_SPI2_FORCE_RESET();
__HAL_RCC_SPI2_RELEASE_RESET();
}
#endif
#ifdef SPI3
if (mask & (1 << 2)) {
__HAL_RCC_SPI3_CLK_DISABLE();
__HAL_RCC_SPI3_FORCE_RESET();
__HAL_RCC_SPI3_RELEASE_RESET();
}
#endif
#ifdef SPI4
if (mask & (1 << 3)) {
__HAL_RCC_SPI4_CLK_DISABLE();
__HAL_RCC_SPI4_FORCE_RESET();
__HAL_RCC_SPI4_RELEASE_RESET();
}
#endif
#ifdef SPI5
if (mask & (1 << 4)) {
__HAL_RCC_SPI5_CLK_DISABLE();
__HAL_RCC_SPI5_FORCE_RESET();
__HAL_RCC_SPI5_RELEASE_RESET();
}
#endif
#ifdef SPI6
if (mask & (1 << 5)) {
__HAL_RCC_SPI6_CLK_DISABLE();
__HAL_RCC_SPI6_FORCE_RESET();
__HAL_RCC_SPI6_RELEASE_RESET();
}
#endif
}

View File

@ -296,6 +296,7 @@ extern const struct _mp_obj_module_t board_module;
#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))
#define BOARD_INTERNAL_SPI (defined(SHOW_FLASH_SPI))
// I2C and SPI are always allocated off the heap.

View File

@ -37,6 +37,8 @@ mp_obj_t common_hal_board_get_i2c(void);
mp_obj_t common_hal_board_create_i2c(void);
MP_DECLARE_CONST_FUN_OBJ_0(board_i2c_obj);
mp_obj_t common_hal_board_get_internal_spi(void);
mp_obj_t common_hal_board_get_spi(void);
mp_obj_t common_hal_board_create_spi(void);
MP_DECLARE_CONST_FUN_OBJ_0(board_spi_obj);

View File

@ -29,6 +29,8 @@
#include "mpconfigboard.h"
#include "py/runtime.h"
#include "supervisor/spi_flash_api.h"
#if CIRCUITPY_BUSIO
#include "shared-bindings/busio/I2C.h"
#include "shared-bindings/busio/SPI.h"
@ -89,6 +91,15 @@ mp_obj_t common_hal_board_create_spi(void) {
}
#endif
#if BOARD_INTERNAL_SPI
//Provide a reference to the internal SPI, if required.
mp_obj_t common_hal_board_get_internal_spi(void) {
//TODO: can we change the name of this without having to change every instance of spi in every
//flash file?
return (mp_obj_t)(&spi);
}
#endif
#if BOARD_UART
mp_obj_t common_hal_board_get_uart(void) {
return MP_STATE_VM(shared_uart_bus);

View File

@ -100,6 +100,11 @@ void reset_displays(void) {
continue;
}
#endif
#if BOARD_INTERNAL_SPI
if (original_spi == common_hal_board_get_internal_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.