From 4d3f5fab9d6d9d48abbd86ad8fbb5b497b2740ac Mon Sep 17 00:00:00 2001
From: ks6n19 <ks6n19@soton.ac.uk>
Date: Tue, 18 Aug 2020 10:39:13 +0100
Subject: [PATCH] commit for switches to change pixel coordinate

---
 software/code/main.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/software/code/main.c b/software/code/main.c
index 5cf7e73..5ff1cc1 100644
--- a/software/code/main.c
+++ b/software/code/main.c
@@ -25,6 +25,11 @@ volatile uint32_t* OUT_REGS = (volatile uint32_t*) AHB_OUT_BASE;
 //////////////////////////////////////////////////////////////////
 // Functions provided to access i/o devices
 //////////////////////////////////////////////////////////////////
+uint32_t read_switches(int addr) {
+
+  return SW_REGS[addr];
+
+}
 // x1
 void write_out_0(uint32_t value_0) {
 
@@ -104,14 +109,31 @@ void wait_for_any_switch_data(void) {
 //////////////////////////////////////////////////////////////////
 
 int main(void) {
-
-while(1) {
+  int switch_temp ;
+
+while(1) {  
+    if ( check_switches(0) ) {
+      write_out( read_switches(0) );
+    }
+   if ( check_switches(1) ) {
+      switch_temp = read_switches(1);
+      if (switch_temp = 1) {
   write_out_0( 0x000 ); //x1
   write_out_1( 0x000 );//y1
   write_out_2( 0x140 );//x2
   write_out_3( 0x140 );// y2  
+      }
+ if (switch_temp = 0) {
+  write_out_0( 0x000 ); //x1
+  write_out_1( 0x000 );//y1
+  write_out_2( 0x200 );//x2
+  write_out_3( 0x240 );// y2  
+      }
+   }
+   }
 }
+
     
 
 
-}
+
-- 
GitLab