Miya Miyagawa
/
OREWOTAOSITAI
aaaaa
Communication/XBee/XBee.h@12:8321e464475f, 2019-02-25 (annotated)
- Committer:
- Ryosei
- Date:
- Mon Feb 25 06:44:02 2019 +0000
- Revision:
- 12:8321e464475f
- Parent:
- 0:562021ed1ba9
unko
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
t_yamamoto | 0:562021ed1ba9 | 1 | #ifndef XBEE_H_ |
t_yamamoto | 0:562021ed1ba9 | 2 | #define XBEE_H_ |
t_yamamoto | 0:562021ed1ba9 | 3 | |
t_yamamoto | 0:562021ed1ba9 | 4 | #include <stdint.h> |
t_yamamoto | 0:562021ed1ba9 | 5 | |
t_yamamoto | 0:562021ed1ba9 | 6 | namespace XBEE |
t_yamamoto | 0:562021ed1ba9 | 7 | { |
t_yamamoto | 0:562021ed1ba9 | 8 | #define CTR_DATA_LENGTH 4 |
t_yamamoto | 0:562021ed1ba9 | 9 | #define CTR_DEFAULT_DATA {0x00, 0x00, 0x77, 0x77} |
t_yamamoto | 0:562021ed1ba9 | 10 | |
t_yamamoto | 0:562021ed1ba9 | 11 | #define XBEE_TX D1 |
t_yamamoto | 0:562021ed1ba9 | 12 | #define XBEE_RX D0 |
t_yamamoto | 0:562021ed1ba9 | 13 | |
t_yamamoto | 0:562021ed1ba9 | 14 | #define LED_OFF 0 |
t_yamamoto | 0:562021ed1ba9 | 15 | #define LED_ON 1 |
t_yamamoto | 0:562021ed1ba9 | 16 | |
t_yamamoto | 0:562021ed1ba9 | 17 | typedef union |
t_yamamoto | 0:562021ed1ba9 | 18 | { |
t_yamamoto | 0:562021ed1ba9 | 19 | struct { |
t_yamamoto | 0:562021ed1ba9 | 20 | struct { |
t_yamamoto | 0:562021ed1ba9 | 21 | unsigned int X:1; |
t_yamamoto | 0:562021ed1ba9 | 22 | unsigned int A:1; |
t_yamamoto | 0:562021ed1ba9 | 23 | unsigned int B:1; |
t_yamamoto | 0:562021ed1ba9 | 24 | unsigned int Y:1; |
t_yamamoto | 0:562021ed1ba9 | 25 | unsigned int UP:1; |
t_yamamoto | 0:562021ed1ba9 | 26 | unsigned int RIGHT:1; |
t_yamamoto | 0:562021ed1ba9 | 27 | unsigned int DOWN:1; |
t_yamamoto | 0:562021ed1ba9 | 28 | unsigned int LEFT:1; |
t_yamamoto | 0:562021ed1ba9 | 29 | unsigned int SELECT:1; |
t_yamamoto | 0:562021ed1ba9 | 30 | unsigned int HOME:1; |
t_yamamoto | 0:562021ed1ba9 | 31 | unsigned int START:1; |
t_yamamoto | 0:562021ed1ba9 | 32 | unsigned int ZL:1; |
t_yamamoto | 0:562021ed1ba9 | 33 | unsigned int ZR:1; |
t_yamamoto | 0:562021ed1ba9 | 34 | unsigned int L:1; |
t_yamamoto | 0:562021ed1ba9 | 35 | unsigned int R:1; |
t_yamamoto | 0:562021ed1ba9 | 36 | unsigned int :1; |
t_yamamoto | 0:562021ed1ba9 | 37 | } __attribute__ ((packed)) Button; |
t_yamamoto | 0:562021ed1ba9 | 38 | struct { |
t_yamamoto | 0:562021ed1ba9 | 39 | unsigned int Y:4; |
t_yamamoto | 0:562021ed1ba9 | 40 | unsigned int X:4; |
t_yamamoto | 0:562021ed1ba9 | 41 | } __attribute__ ((packed)) AnalogL; |
t_yamamoto | 0:562021ed1ba9 | 42 | struct { |
t_yamamoto | 0:562021ed1ba9 | 43 | unsigned int Y:4; |
t_yamamoto | 0:562021ed1ba9 | 44 | unsigned int X:4; |
t_yamamoto | 0:562021ed1ba9 | 45 | } __attribute__ ((packed)) AnalogR; |
t_yamamoto | 0:562021ed1ba9 | 46 | } __attribute__ ((packed)) ; |
t_yamamoto | 0:562021ed1ba9 | 47 | uint8_t buf[CTR_DATA_LENGTH]; |
t_yamamoto | 0:562021ed1ba9 | 48 | }ControllerData; |
t_yamamoto | 0:562021ed1ba9 | 49 | |
t_yamamoto | 0:562021ed1ba9 | 50 | class Controller |
t_yamamoto | 0:562021ed1ba9 | 51 | { |
t_yamamoto | 0:562021ed1ba9 | 52 | public: |
t_yamamoto | 0:562021ed1ba9 | 53 | static void Initialize(void); |
t_yamamoto | 0:562021ed1ba9 | 54 | static ControllerData* GetData(void); |
t_yamamoto | 0:562021ed1ba9 | 55 | static void DataReset(void); |
t_yamamoto | 0:562021ed1ba9 | 56 | static bool CheckControllerLost(void); |
t_yamamoto | 0:562021ed1ba9 | 57 | }; |
t_yamamoto | 0:562021ed1ba9 | 58 | } |
t_yamamoto | 0:562021ed1ba9 | 59 | |
t_yamamoto | 0:562021ed1ba9 | 60 | #endif |
t_yamamoto | 0:562021ed1ba9 | 61 |