diff --git a/hydrabus/hydrabus_bbio.c b/hydrabus/hydrabus_bbio.c index 0532494f..702e8493 100644 --- a/hydrabus/hydrabus_bbio.c +++ b/hydrabus/hydrabus_bbio.c @@ -70,9 +70,9 @@ int cmd_bbio(t_hydra_console *con) case BBIO_RESET_HW: return TRUE; default: + cprint(con, "\x01", 1); break; } - cprint(con, "BBIO1", 5); } } return TRUE; diff --git a/hydrabus/hydrabus_bbio_spi.c b/hydrabus/hydrabus_bbio_spi.c index ac57ba70..da736773 100644 --- a/hydrabus/hydrabus_bbio_spi.c +++ b/hydrabus/hydrabus_bbio_spi.c @@ -138,14 +138,24 @@ void bbio_mode_spi(t_hydra_console *con) cprint(con, "\x00", 1); break; } - if(to_rx > 0) { + if(bbio_subcommand == BBIO_SPI_WRITE_READ) { + bsp_spi_select(proto->dev_num); + } + if(to_tx > 0) { chnRead(con->sdu, tx_data, to_tx); - - if(bbio_subcommand == BBIO_SPI_WRITE_READ) { - bsp_spi_select(proto->dev_num); + i=0; + while(i= 255) { + bsp_spi_write_u8(proto->dev_num, + tx_data+i, + 255); + } else { + bsp_spi_write_u8(proto->dev_num, + tx_data+i, + to_tx-i); + } + i+=255; } - bsp_spi_write_u8(proto->dev_num, tx_data, - to_tx); } i=0; while(idev_polarity = (bbio_subcommand & 0b100)?1:0; - proto->dev_phase = (bbio_subcommand & 0b10)?1:0; - proto->dev_num = (bbio_subcommand & 0b1)?BSP_DEV_SPI2:BSP_DEV_SPI1; + proto->dev_phase = (bbio_subcommand & 0b10)?0:1; + proto->dev_num = (bbio_subcommand & 0b1)?BSP_DEV_SPI1:BSP_DEV_SPI2; status = bsp_spi_init(proto->dev_num, proto); if(status == BSP_OK) { cprint(con, "\x01", 1); @@ -276,6 +287,11 @@ void bbio_mode_spi(t_hydra_console *con) cprint(con, "\x00", 1); } } else if ((bbio_subcommand & BBIO_SPI_CONFIG_PERIPH) == BBIO_SPI_CONFIG_PERIPH) { + if (bbio_subcommand & 0b1) { + bsp_spi_unselect(proto->dev_num); + } else { + bsp_spi_select(proto->dev_num); + } cprint(con, "\x01", 1); }