blob: aa0e78265f211c67180ebaaa33a84729ef14bbaf [file] [log] [blame]
Brian Silvermanf92396c2013-09-12 20:13:13 -07001// This isn't really a header file. It's designed to be #included directly into
2// other code (possibly in a namespace or whatever), so it doesn't have include
3// guards.
4// In the gyro board code, fill_packet.h #includes this file.
5// In the fitpc code, frc971/input/gyro_board_data.h #includes this file.
6
7#pragma pack(push, 1)
Brian Silverman49876942013-10-11 17:50:26 -07008// Be careful with declaration order in here. ARM doesn't like unaligned
9// accesses!
Brian Silvermanf92396c2013-09-12 20:13:13 -070010struct DATA_STRUCT_NAME {
11 int64_t gyro_angle;
12
13 union {
14 struct {
15 // Which robot (+version) the gyro board is sending out data for.
16 // We should keep this in the same place for all gyro board software
17 // versions so that the fitpc can detect when it's reading from a gyro
18 // board set up for a different robot than it is.
19 // 0 = 2013 competition/practice robot
20 // 1 = 2013 3rd robot
21 uint8_t robot_id;
22 // This information should also be kept in the same place from year to
23 // year so that the fitpc code can record the dip switch values when it
24 // detects the wrong robot id to make debugging easier.
25 union {
26 struct {
27 uint8_t dip_switch0 : 1;
28 uint8_t dip_switch1 : 1;
29 uint8_t dip_switch2 : 1;
30 uint8_t dip_switch3 : 1;
Brian Silverman49876942013-10-11 17:50:26 -070031 // If the current gyro_angle has been not updated because of a bad
32 // reading from the sensor.
33 uint8_t old_gyro_reading : 1;
34 // If we're not going to get any more good gyro_angles.
35 uint8_t bad_gyro : 1;
Brian Silvermanf92396c2013-09-12 20:13:13 -070036 };
Brian Silverman49876942013-10-11 17:50:26 -070037 uint8_t base_status;
Brian Silvermanf92396c2013-09-12 20:13:13 -070038 };
39 };
40 uint16_t header;
41 };
42
43 union {
44 struct {
45 union {
46 struct {
47 uint8_t wrist_hall_effect : 1;
48 uint8_t angle_adjust_bottom_hall_effect : 1;
49 uint8_t top_disc : 1;
50 uint8_t bottom_disc : 1;
Brian Silverman1623c332013-10-01 18:05:16 -070051 uint8_t loader_top : 1;
52 uint8_t loader_bottom : 1;
Brian Silvermanf92396c2013-09-12 20:13:13 -070053 };
54 uint16_t booleans;
55 };
56 int32_t left_drive;
57 int32_t right_drive;
58 int32_t shooter_angle;
59 int32_t shooter;
60 int32_t indexer;
61 int32_t wrist;
62
63 int32_t capture_top_rise;
64 int32_t capture_top_fall;
65 int32_t capture_bottom_fall_delay;
66 int32_t capture_wrist_rise;
67 int32_t capture_shooter_angle_rise;
68
69 int8_t top_rise_count;
70
71 int8_t top_fall_count;
72
73 int8_t bottom_rise_count;
74
75 int8_t bottom_fall_delay_count;
76 int8_t bottom_fall_count;
77
78 int8_t wrist_rise_count;
79
80 int8_t shooter_angle_rise_count;
81 } main;
82
83 struct {
84 union {
85 struct {
86 };
87 uint16_t booleans;
88 };
89 } bot3;
90 };
91};
92#pragma pack(pop)
Brian Silverman466d6692013-09-13 14:16:36 -070093
94#ifdef __cplusplus
95// TODO(brians): Consider using C1X's _Static_assert once we have a compiler
96// (GCC 4.6) + flags that support it.
97static_assert(sizeof(DATA_STRUCT_NAME) <= 64,
98 "We only have room for 64 bytes in the USB packet.");
99#endif // defined(__cplusplus)