brians | 0ab60bb | 2013-01-31 02:21:51 +0000 | [diff] [blame] | 1 | #ifndef __ANALOG_H__ |
| 2 | #define __ANALOG_H__ |
| 3 | |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 4 | extern int64_t gyro_angle; |
Brian Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 5 | |
| 6 | struct DataStruct { |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 7 | 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 Silverman | d241148 | 2013-03-28 21:36:32 -0700 | [diff] [blame^] | 22 | int8_t top_rise_count; |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 23 | |
| 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 Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 34 | } __attribute__((__packed__)); |
Brian Silverman | d241148 | 2013-03-28 21:36:32 -0700 | [diff] [blame^] | 35 | // Gets called in the USB data output ISR. Assumes that it will not be preempted |
| 36 | // except by very high priority things. |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 37 | void fillSensorPacket(struct DataStruct *packet); |
| 38 | |
Brian Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 39 | void analog_init(void); |
| 40 | int analog(int channel); |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 41 | |
Brian Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 42 | int digital(int channel); |
| 43 | |
Brian Silverman | d241148 | 2013-03-28 21:36:32 -0700 | [diff] [blame^] | 44 | void encoder_init(void); |
| 45 | // For debugging only. |
Brian Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 46 | // Returns the current values of the inputs for the given encoder (as the low 2 |
| 47 | // bits). |
| 48 | int encoder_bits(int channel); |
Brian Silverman | d241148 | 2013-03-28 21:36:32 -0700 | [diff] [blame^] | 49 | // Returns the current position of the given encoder. |
Brian Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 50 | int32_t encoder_val(int channel); |
| 51 | |
| 52 | int dip(int channel); |
| 53 | #endif // __ANALOG_H__ |