]> git.sesse.net Git - pistorm/blobdiff - gpio/ps_protocol.c
Add Meson build files.
[pistorm] / gpio / ps_protocol.c
index 2e8364ee42aaef0040023a8b9542b918289238d1..4fb4ee6a677283f60592da01c8b42178fb656439 100644 (file)
@@ -1,6 +1,8 @@
+// SPDX-License-Identifier: MIT
+
 /*
   Original Copyright 2020 Claude Schwarz
-  Code reorganized and rewritten by 
+  Code reorganized and rewritten by
   Niklas Ekström 2021 (https://github.com/niklasekstrom)
 */
 
@@ -13,7 +15,9 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+
 #include "ps_protocol.h"
+#include "m68k.h"
 
 volatile unsigned int *gpio;
 volatile unsigned int *gpclk;
@@ -109,8 +113,7 @@ void ps_write_16(unsigned int address, unsigned int data) {
   *(gpio + 1) = GPFSEL1_INPUT;
   *(gpio + 2) = GPFSEL2_INPUT;
 
-  while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS))
-    ;
+  while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS)) {}
 }
 
 void ps_write_8(unsigned int address, unsigned int data) {
@@ -142,8 +145,7 @@ void ps_write_8(unsigned int address, unsigned int data) {
   *(gpio + 1) = GPFSEL1_INPUT;
   *(gpio + 2) = GPFSEL2_INPUT;
 
-  while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS))
-    ;
+  while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS)) {}
 }
 
 void ps_write_32(unsigned int address, unsigned int value) {
@@ -173,9 +175,7 @@ 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))
-    ;
-
+  while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS)) {}
   unsigned int value = *(gpio + 13);
 
   *(gpio + 10) = 0xffffec;
@@ -205,9 +205,7 @@ 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))
-    ;
-
+  while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS)) {}
   unsigned int value = *(gpio + 13);
 
   *(gpio + 10) = 0xffffec;