aa

Dependencies:   mbed

Committer:
kishibekairohan
Date:
Mon Jul 01 13:00:20 2019 +0000
Revision:
16:3f2c2d89372b
Parent:
0:669ef71cba68
aaa;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t_yamamoto 0:669ef71cba68 1 #ifndef CONTROLLER_H_
t_yamamoto 0:669ef71cba68 2 #define CONTROLLER_H_
t_yamamoto 0:669ef71cba68 3
t_yamamoto 0:669ef71cba68 4 #include <stdint.h>
t_yamamoto 0:669ef71cba68 5
t_yamamoto 0:669ef71cba68 6 namespace CONTROLLER {
kishibekairohan 16:3f2c2d89372b 7 #define MU_TX PA_0
kishibekairohan 16:3f2c2d89372b 8 #define MU_RX PA_1
t_yamamoto 0:669ef71cba68 9
t_yamamoto 0:669ef71cba68 10 #define CTR_DATA_LENGTH 4
t_yamamoto 0:669ef71cba68 11 #define CTR_DEFAULT_DATA {0x00, 0x00, 0x77, 0x77}
t_yamamoto 0:669ef71cba68 12
t_yamamoto 0:669ef71cba68 13 typedef union
t_yamamoto 0:669ef71cba68 14 {
t_yamamoto 0:669ef71cba68 15 struct {
t_yamamoto 0:669ef71cba68 16 struct {
t_yamamoto 0:669ef71cba68 17 unsigned int X:1;
t_yamamoto 0:669ef71cba68 18 unsigned int A:1;
t_yamamoto 0:669ef71cba68 19 unsigned int B:1;
t_yamamoto 0:669ef71cba68 20 unsigned int Y:1;
t_yamamoto 0:669ef71cba68 21 unsigned int UP:1;
t_yamamoto 0:669ef71cba68 22 unsigned int RIGHT:1;
t_yamamoto 0:669ef71cba68 23 unsigned int DOWN:1;
t_yamamoto 0:669ef71cba68 24 unsigned int LEFT:1;
t_yamamoto 0:669ef71cba68 25 unsigned int SELECT:1;
t_yamamoto 0:669ef71cba68 26 unsigned int HOME:1;
t_yamamoto 0:669ef71cba68 27 unsigned int START:1;
t_yamamoto 0:669ef71cba68 28 unsigned int ZL:1;
t_yamamoto 0:669ef71cba68 29 unsigned int ZR:1;
t_yamamoto 0:669ef71cba68 30 unsigned int L:1;
t_yamamoto 0:669ef71cba68 31 unsigned int R:1;
t_yamamoto 0:669ef71cba68 32 unsigned int :1;
t_yamamoto 0:669ef71cba68 33 } __attribute__ ((packed)) Button;
t_yamamoto 0:669ef71cba68 34 struct {
t_yamamoto 0:669ef71cba68 35 unsigned int Y:4;
t_yamamoto 0:669ef71cba68 36 unsigned int X:4;
t_yamamoto 0:669ef71cba68 37 } __attribute__ ((packed)) AnalogL;
t_yamamoto 0:669ef71cba68 38 struct {
t_yamamoto 0:669ef71cba68 39 unsigned int Y:4;
t_yamamoto 0:669ef71cba68 40 unsigned int X:4;
t_yamamoto 0:669ef71cba68 41 } __attribute__ ((packed)) AnalogR;
t_yamamoto 0:669ef71cba68 42 } __attribute__ ((packed)) ;
t_yamamoto 0:669ef71cba68 43 uint8_t buf[CTR_DATA_LENGTH];
t_yamamoto 0:669ef71cba68 44 }ControllerData;
t_yamamoto 0:669ef71cba68 45
t_yamamoto 0:669ef71cba68 46 class Controller
t_yamamoto 0:669ef71cba68 47 {
t_yamamoto 0:669ef71cba68 48 public:
t_yamamoto 0:669ef71cba68 49 static void Initialize(void);
t_yamamoto 0:669ef71cba68 50 static ControllerData* GetData(void);
t_yamamoto 0:669ef71cba68 51 static void DataReset(void);
t_yamamoto 0:669ef71cba68 52 static bool CheckControllerLost(void);
t_yamamoto 0:669ef71cba68 53 };
t_yamamoto 0:669ef71cba68 54 }
t_yamamoto 0:669ef71cba68 55
t_yamamoto 0:669ef71cba68 56 #endif