From f42daefb50b0477c86e7c2085a39dc606a216b15 Mon Sep 17 00:00:00 2001 From: Baldanos Date: Thu, 6 Jun 2024 07:15:57 +0200 Subject: [PATCH] BBIO SPI fix Properly deinit old SPI if switching to a different device. --- src/hydrabus/hydrabus_bbio_spi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hydrabus/hydrabus_bbio_spi.c b/src/hydrabus/hydrabus_bbio_spi.c index 0f16fa5e..fc2fc997 100644 --- a/src/hydrabus/hydrabus_bbio_spi.c +++ b/src/hydrabus/hydrabus_bbio_spi.c @@ -283,7 +283,13 @@ void bbio_mode_spi(t_hydra_console *con) } else if ((bbio_subcommand & BBIO_SPI_CONFIG) == BBIO_SPI_CONFIG) { proto->config.spi.dev_polarity = (bbio_subcommand & 0b100)?1:0; proto->config.spi.dev_phase = (bbio_subcommand & 0b10)?1:0; - proto->dev_num = (bbio_subcommand & 0b1)?BSP_DEV_SPI1:BSP_DEV_SPI2; + + data = (bbio_subcommand & 0b1)?BSP_DEV_SPI1:BSP_DEV_SPI2; + if (proto->dev_num != data) { + bsp_spi_deinit(proto->dev_num); + proto->dev_num = data; + } + status = bsp_spi_init(proto->dev_num, proto); if(status == BSP_OK) { cprint(con, "\x01", 1);