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 { |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 7 | int64_t gyro_angle; |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 8 | |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 9 | int32_t left_drive; |
Brian Silverman | 98701db | 2013-04-10 16:37:52 -0700 | [diff] [blame^] | 10 | int32_t right_drive; |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 11 | int32_t shooter_angle; |
| 12 | int32_t shooter; |
| 13 | int32_t indexer; |
| 14 | int32_t wrist; |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 15 | |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 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; |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 21 | |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 22 | int8_t top_rise_count; |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 23 | |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 24 | int8_t top_fall_count; |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 25 | |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 26 | int8_t bottom_rise_count; |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 27 | |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 28 | int8_t bottom_fall_delay_count; |
| 29 | int8_t bottom_fall_count; |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 30 | |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 31 | int8_t wrist_rise_count; |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 32 | |
Brian Silverman | 1289ded | 2013-03-29 21:59:51 -0700 | [diff] [blame] | 33 | 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 Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 44 | } __attribute__((__packed__)); |
Brian Silverman | d241148 | 2013-03-28 21:36:32 -0700 | [diff] [blame] | 45 | // Gets called in the USB data output ISR. Assumes that it will not be preempted |
| 46 | // except by very high priority things. |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 47 | void fillSensorPacket(struct DataStruct *packet); |
| 48 | |
Brian Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 49 | void analog_init(void); |
| 50 | int analog(int channel); |
Austin Schuh | 63d0e9b | 2013-03-27 04:43:14 +0000 | [diff] [blame] | 51 | |
Brian Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 52 | int digital(int channel); |
| 53 | |
Brian Silverman | d241148 | 2013-03-28 21:36:32 -0700 | [diff] [blame] | 54 | void encoder_init(void); |
| 55 | // For debugging only. |
Brian Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 56 | // Returns the current values of the inputs for the given encoder (as the low 2 |
| 57 | // bits). |
| 58 | int encoder_bits(int channel); |
Brian Silverman | d241148 | 2013-03-28 21:36:32 -0700 | [diff] [blame] | 59 | // Returns the current position of the given encoder. |
Brian Silverman | 6ad00b8 | 2013-03-27 19:02:38 -0700 | [diff] [blame] | 60 | int32_t encoder_val(int channel); |
| 61 | |
| 62 | int dip(int channel); |
| 63 | #endif // __ANALOG_H__ |