]> git.sesse.net Git - pistorm/blobdiff - gpio/ps_protocol.c
Fix config reload?
[pistorm] / gpio / ps_protocol.c
index 92ec2ffcfdf041466e5dd3f78ad32c425820d1d4..94e38a41b60481e2f2d5008af6cb862cfa2cd996 100644 (file)
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: MIT
+
 /*
   Original Copyright 2020 Claude Schwarz
   Code reorganized and rewritten by
@@ -175,10 +177,9 @@ unsigned int ps_read_16(unsigned int address) {
   *(gpio + 7) = (REG_DATA << PIN_A0);
   *(gpio + 7) = 1 << PIN_RD;
 
-  while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS))
-    ;
-
   unsigned int value = *(gpio + 13);
+  while ((value=*(gpio + 13)) & (1 << PIN_TXN_IN_PROGRESS))
+    ;
 
   *(gpio + 10) = 0xffffec;
 
@@ -207,10 +208,9 @@ unsigned int ps_read_8(unsigned int address) {
   *(gpio + 7) = (REG_DATA << PIN_A0);
   *(gpio + 7) = 1 << PIN_RD;
 
-  while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS))
-    ;
-
   unsigned int value = *(gpio + 13);
+  while ((value=*(gpio + 13)) & (1 << PIN_TXN_IN_PROGRESS))
+    ;
 
   *(gpio + 10) = 0xffffec;