Skip to content

gigadevice gd32 spi callback error #55647

Closed Answered by cameled
lmikl asked this question in Q&A
Mar 9, 2023 · 2 comments · 10 replies
Discussion options

You must be logged in to vote

Please test with below patch, transceive will be ok.

diff --git a/drivers/spi/spi_gd32.c b/drivers/spi/spi_gd32.c
index 37c705ed30..4d705f9037 100644
--- a/drivers/spi/spi_gd32.c
+++ b/drivers/spi/spi_gd32.c
@@ -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);
 	}
-…

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
1 reply
@lmikl
Comment options

Comment options

You must be logged in to vote
9 replies
@cameled
Comment options

cameled Apr 4, 2023
Collaborator

@cameled
Comment options

cameled Apr 4, 2023
Collaborator

@lmikl
Comment options

@cameled
Comment options

cameled Apr 4, 2023
Collaborator

Answer selected by cameled
@lmikl
Comment options

@cameled
Comment options

cameled Apr 5, 2023
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: SPI SPI bus platform: GD32 GigaDevice
2 participants