Skip to content

Commit

Permalink
BBIO SPI fix
Browse files Browse the repository at this point in the history
Properly deinit old SPI if switching to a different device.
  • Loading branch information
Baldanos committed Jun 20, 2024
1 parent 116882b commit f42daef
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/hydrabus/hydrabus_bbio_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f42daef

Please sign in to comment.