daad

Dependencies:   mbed TrapezoidControl QEI

Revision:
0:669ef71cba68
Child:
16:3f2c2d89372b
diff -r 000000000000 -r 669ef71cba68 Communication/Controller/Controller.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Communication/Controller/Controller.h	Sat Sep 08 06:05:22 2018 +0000
@@ -0,0 +1,56 @@
+#ifndef CONTROLLER_H_
+#define CONTROLLER_H_
+
+#include <stdint.h>
+
+namespace CONTROLLER {
+    #define MU_TX PC_6
+    #define MU_RX PC_7
+    
+    #define CTR_DATA_LENGTH 4
+    #define CTR_DEFAULT_DATA {0x00, 0x00, 0x77, 0x77}
+
+	typedef union 
+	{
+		struct {
+			struct {
+				unsigned int X:1;
+				unsigned int A:1;
+				unsigned int B:1;
+				unsigned int Y:1;
+				unsigned int UP:1;
+				unsigned int RIGHT:1;
+				unsigned int DOWN:1;
+				unsigned int LEFT:1;
+				unsigned int SELECT:1;
+				unsigned int HOME:1;
+				unsigned int START:1;
+				unsigned int ZL:1;
+				unsigned int ZR:1;
+				unsigned int L:1;
+				unsigned int R:1;
+				unsigned int :1;
+			} __attribute__ ((packed)) Button;
+			struct {
+				unsigned int Y:4;
+				unsigned int X:4;
+			} __attribute__ ((packed)) AnalogL;
+			struct {
+				unsigned int Y:4;
+				unsigned int X:4;
+			} __attribute__ ((packed)) AnalogR;
+		} __attribute__ ((packed)) ;
+		uint8_t buf[CTR_DATA_LENGTH];		
+	}ControllerData;
+    
+    class Controller
+    {
+        public:
+            static void Initialize(void);
+            static ControllerData* GetData(void);
+            static void DataReset(void);
+            static bool CheckControllerLost(void);
+    };
+}
+
+#endif