blob: b72218bda4fbd74f5fc197cd48be1e438025faf2 [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 {
Brian Silverman1289ded2013-03-29 21:59:51 -07007 int64_t gyro_angle;
Austin Schuh63d0e9b2013-03-27 04:43:14 +00008
Brian Silverman1289ded2013-03-29 21:59:51 -07009 int32_t left_drive;
Brian Silverman98701db2013-04-10 16:37:52 -070010 int32_t right_drive;
Brian Silverman1289ded2013-03-29 21:59:51 -070011 int32_t shooter_angle;
12 int32_t shooter;
13 int32_t indexer;
14 int32_t wrist;
Austin Schuh63d0e9b2013-03-27 04:43:14 +000015
Brian Silverman1289ded2013-03-29 21:59:51 -070016 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;
Austin Schuh63d0e9b2013-03-27 04:43:14 +000021
Brian Silverman1289ded2013-03-29 21:59:51 -070022 int8_t top_rise_count;
Austin Schuh63d0e9b2013-03-27 04:43:14 +000023
Brian Silverman1289ded2013-03-29 21:59:51 -070024 int8_t top_fall_count;
Austin Schuh63d0e9b2013-03-27 04:43:14 +000025
Brian Silverman1289ded2013-03-29 21:59:51 -070026 int8_t bottom_rise_count;
Austin Schuh63d0e9b2013-03-27 04:43:14 +000027
Brian Silverman1289ded2013-03-29 21:59:51 -070028 int8_t bottom_fall_delay_count;
29 int8_t bottom_fall_count;
Austin Schuh63d0e9b2013-03-27 04:43:14 +000030
Brian Silverman1289ded2013-03-29 21:59:51 -070031 int8_t wrist_rise_count;
Austin Schuh63d0e9b2013-03-27 04:43:14 +000032
Brian Silverman1289ded2013-03-29 21:59:51 -070033 int8_t shooter_angle_rise_count;
34
35 union {
36 struct {
37 uint8_t wrist_hall_effect : 1;
38 uint8_t angle_adjust_bottom_hall_effect : 1;
39 uint8_t top_disc : 1;
40 uint8_t bottom_disc : 1;
41 };
42 uint32_t digitals;
43 };
Brian Silverman6ad00b82013-03-27 19:02:38 -070044} __attribute__((__packed__));
Brian Silvermand2411482013-03-28 21:36:32 -070045// Gets called in the USB data output ISR. Assumes that it will not be preempted
46// except by very high priority things.
Austin Schuh63d0e9b2013-03-27 04:43:14 +000047void fillSensorPacket(struct DataStruct *packet);
48
Brian Silverman6ad00b82013-03-27 19:02:38 -070049void analog_init(void);
50int analog(int channel);
Austin Schuh63d0e9b2013-03-27 04:43:14 +000051
Brian Silverman6ad00b82013-03-27 19:02:38 -070052int digital(int channel);
53
Brian Silvermand2411482013-03-28 21:36:32 -070054void encoder_init(void);
55// For debugging only.
Brian Silverman6ad00b82013-03-27 19:02:38 -070056// Returns the current values of the inputs for the given encoder (as the low 2
57// bits).
58int encoder_bits(int channel);
Brian Silvermand2411482013-03-28 21:36:32 -070059// Returns the current position of the given encoder.
Brian Silverman6ad00b82013-03-27 19:02:38 -070060int32_t encoder_val(int channel);
61
62int dip(int channel);
63#endif // __ANALOG_H__