Skip to content

Commit

Permalink
drivers: spi: gd32 fix a transceive error
Browse files Browse the repository at this point in the history
There have an extral TBE interrupt event though we have cleared the
SPI_CTL1_TBEIE bit. To cover this situation, add a on_going check
before enter exchange function.

Signed-off-by: HaiLong Yang <[email protected]>
  • Loading branch information
HaiLong Yang authored and fabiobaltieri committed Apr 5, 2023
1 parent 5e80329 commit 3d5de89
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/spi/spi_gd32.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,19 @@ static void spi_gd32_isr(struct device *dev)
struct spi_gd32_data *data = dev->data;
int err = 0;

if ((SPI_STAT(cfg->reg) & SPI_GD32_ERR_MASK) != 0) {
err = spi_gd32_get_err(cfg);
} else {
err = spi_gd32_get_err(cfg);
if (err) {
spi_gd32_complete(dev, err);
return;
}

if (spi_gd32_transfer_ongoing(data)) {
err = spi_gd32_frame_exchange(dev);
}

if (err || !spi_gd32_transfer_ongoing(data)) {
spi_gd32_complete(dev, err);
}

SPI_STAT(cfg->reg) = 0;
}

#endif /* SPI_GD32_INTERRUPT */
Expand Down

0 comments on commit 3d5de89

Please sign in to comment.