Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MainBoard2018_Auto_Master_A by
Communication/Controller/Controller.h@4:3ae504b88679, 2018-10-01 (annotated)
- Committer:
- kishibekairohan
- Date:
- Mon Oct 01 09:07:27 2018 +0000
- Revision:
- 4:3ae504b88679
- Parent:
- 0:669ef71cba68
maruyama
Who changed what in which revision?
User | Revision | Line number | New 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 { |
t_yamamoto | 0:669ef71cba68 | 7 | #define MU_TX PC_6 |
t_yamamoto | 0:669ef71cba68 | 8 | #define MU_RX PC_7 |
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 |