blob: 64c9631d3d98cec37a305e9594dac82891f6e730 [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
Brian Silverman70478d12013-10-11 17:54:58 -070043 // This is a counter that gets incremented with each packet sent (and wraps
44 // around when it reaches 255).
45 uint8_t sequence;
46
Brian Silvermanf92396c2013-09-12 20:13:13 -070047 union {
48 struct {
49 union {
50 struct {
51 uint8_t wrist_hall_effect : 1;
52 uint8_t angle_adjust_bottom_hall_effect : 1;
53 uint8_t top_disc : 1;
54 uint8_t bottom_disc : 1;
Brian Silverman1623c332013-10-01 18:05:16 -070055 uint8_t loader_top : 1;
56 uint8_t loader_bottom : 1;
Brian Silvermanf92396c2013-09-12 20:13:13 -070057 };
58 uint16_t booleans;
59 };
60 int32_t left_drive;
61 int32_t right_drive;
62 int32_t shooter_angle;
63 int32_t shooter;
64 int32_t indexer;
65 int32_t wrist;
66
67 int32_t capture_top_rise;
68 int32_t capture_top_fall;
69 int32_t capture_bottom_fall_delay;
70 int32_t capture_wrist_rise;
71 int32_t capture_shooter_angle_rise;
72
73 int8_t top_rise_count;
74
75 int8_t top_fall_count;
76
77 int8_t bottom_rise_count;
78
79 int8_t bottom_fall_delay_count;
80 int8_t bottom_fall_count;
81
82 int8_t wrist_rise_count;
83
84 int8_t shooter_angle_rise_count;
85 } main;
86
87 struct {
88 union {
89 struct {
90 };
91 uint16_t booleans;
92 };
93 } bot3;
94 };
95};
96#pragma pack(pop)
Brian Silverman466d6692013-09-13 14:16:36 -070097
98#ifdef __cplusplus
99// TODO(brians): Consider using C1X's _Static_assert once we have a compiler
100// (GCC 4.6) + flags that support it.
101static_assert(sizeof(DATA_STRUCT_NAME) <= 64,
102 "We only have room for 64 bytes in the USB packet.");
103#endif // defined(__cplusplus)