This program uses a NUCLEO-F401RE to control an SNES console by sending the button states. (1 = Unpressed, 0 = Pressed) Data, Clock and Latch from the SNES must be connected to the appropriate pins. The NUCLEO is powered by the SNES through E5V. The power jumper should be moved to E5V configuration when powered by SNES.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kyancey
Date:
Thu Oct 05 15:21:03 2017 +0000
Parent:
0:2af5c09cf1ee
Commit message:
Added some comments.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 2af5c09cf1ee -r 2a346daf070f main.cpp
--- a/main.cpp	Thu Oct 05 14:43:56 2017 +0000
+++ b/main.cpp	Thu Oct 05 15:21:03 2017 +0000
@@ -22,11 +22,13 @@
     waitUntilHigh(Clock);
 }
 
+// The SNES expects unpressed buttons to have a high state.
+// 1 = unpressed, 0 = pressed
 void sendButtonsPressed(int b, int y, int select, int start,
                         int up, int down, int left, int right,
                         int a, int x, int l1, int r1)
 {
-    Data = 1;
+    Data = 1; // Seems sensible to start with data being high
     waitUntilHigh(Latch);
     waitUntilLow(Latch);
 
@@ -47,6 +49,7 @@
 int main()
 {
     while(1) {
+        // Repeatedly press A
         sendButtonsPressed(1, 1, 1, 1,      //b,y,select,start
                            1, 1, 1, 1,     //up,down,left,right
                            0, 1, 1, 1);    //a,x,l1,r1