blob: 7b2fb5893a12cc2c6e4511882ee793385e2a7dda [file] [log] [blame]
brians0ab60bb2013-01-31 02:21:51 +00001#ifndef __ANALOG_H__
2#define __ANALOG_H__
3
Austin Schuh63d0e9b2013-03-27 04:43:14 +00004extern int64_t gyro_angle;
Brian Silverman6ad00b82013-03-27 19:02:38 -07005
6struct DataStruct {
Austin Schuh63d0e9b2013-03-27 04:43:14 +00007 int64_t gyro_angle;
8
9 int32_t right_drive;
10 int32_t left_drive;
11 int32_t shooter_angle;
12 int32_t shooter;
13 int32_t indexer;
14 int32_t wrist;
15
16 int32_t capture_top_rise;
17 int32_t capture_top_fall;
18 int32_t capture_bottom_fall_delay;
19 int32_t capture_wrist_rise;
20 int32_t capture_shooter_angle_rise;
21
Brian Silvermand2411482013-03-28 21:36:32 -070022 int8_t top_rise_count;
Austin Schuh63d0e9b2013-03-27 04:43:14 +000023
24 int8_t top_fall_count;
25
26 int8_t bottom_rise_count;
27
28 int8_t bottom_fall_delay_count;
29 int8_t bottom_fall_count;
30
31 int8_t wrist_rise_count;
32
33 int8_t shooter_angle_rise_count;
Brian Silverman6ad00b82013-03-27 19:02:38 -070034} __attribute__((__packed__));
Brian Silvermand2411482013-03-28 21:36:32 -070035// Gets called in the USB data output ISR. Assumes that it will not be preempted
36// except by very high priority things.
Austin Schuh63d0e9b2013-03-27 04:43:14 +000037void fillSensorPacket(struct DataStruct *packet);
38
Brian Silverman6ad00b82013-03-27 19:02:38 -070039void analog_init(void);
40int analog(int channel);
Austin Schuh63d0e9b2013-03-27 04:43:14 +000041
Brian Silverman6ad00b82013-03-27 19:02:38 -070042int digital(int channel);
43
Brian Silvermand2411482013-03-28 21:36:32 -070044void encoder_init(void);
45// For debugging only.
Brian Silverman6ad00b82013-03-27 19:02:38 -070046// Returns the current values of the inputs for the given encoder (as the low 2
47// bits).
48int encoder_bits(int channel);
Brian Silvermand2411482013-03-28 21:36:32 -070049// Returns the current position of the given encoder.
Brian Silverman6ad00b82013-03-27 19:02:38 -070050int32_t encoder_val(int channel);
51
52int dip(int channel);
53#endif // __ANALOG_H__