Brian Silverman | 8d3816a | 2017-07-03 18:52:15 -0700 | [diff] [blame] | 1 | #ifndef MOTORS_PERIPHERAL_ADC_H_ |
| 2 | #define MOTORS_PERIPHERAL_ADC_H_ |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
Brian Silverman | 19ea60f | 2018-01-03 21:43:15 -0800 | [diff] [blame] | 6 | #include "motors/util.h" |
| 7 | |
Brian Silverman | a3a172b | 2018-03-24 03:53:32 -0400 | [diff] [blame] | 8 | // TODO(Brian): Avoid cramming all the code for each specific application into a |
| 9 | // single file like this. |
| 10 | |
Brian Silverman | 8d3816a | 2017-07-03 18:52:15 -0700 | [diff] [blame] | 11 | namespace frc971 { |
| 12 | namespace salsa { |
| 13 | |
| 14 | struct MediumAdcReadings { |
| 15 | uint16_t motor_currents[3][2]; |
| 16 | uint16_t motor_current_ref; |
| 17 | uint16_t input_voltage; |
| 18 | }; |
| 19 | |
Brian Silverman | 19ea60f | 2018-01-03 21:43:15 -0800 | [diff] [blame] | 20 | struct SmallAdcReadings { |
| 21 | uint16_t currents[3]; |
| 22 | }; |
Brian Silverman | 8d3816a | 2017-07-03 18:52:15 -0700 | [diff] [blame] | 23 | |
Brian Silverman | 19ea60f | 2018-01-03 21:43:15 -0800 | [diff] [blame] | 24 | struct SmallInitReadings { |
| 25 | uint16_t motor0_abs; |
| 26 | uint16_t motor1_abs; |
| 27 | uint16_t wheel_abs; |
| 28 | }; |
| 29 | |
Brian Silverman | 259c443 | 2018-01-15 14:34:21 -0800 | [diff] [blame] | 30 | struct JoystickAdcReadings { |
| 31 | uint16_t analog0, analog1, analog2, analog3; |
| 32 | }; |
| 33 | |
Brian Silverman | a3a172b | 2018-03-24 03:53:32 -0400 | [diff] [blame] | 34 | struct SimpleAdcReadings { |
| 35 | uint16_t sin, cos; |
| 36 | }; |
| 37 | |
Brian Silverman | 19ea60f | 2018-01-03 21:43:15 -0800 | [diff] [blame] | 38 | void AdcInitMedium(); |
| 39 | void AdcInitSmall(); |
Brian Silverman | 259c443 | 2018-01-15 14:34:21 -0800 | [diff] [blame] | 40 | void AdcInitJoystick(); |
Brian Silverman | a3a172b | 2018-03-24 03:53:32 -0400 | [diff] [blame] | 41 | void AdcInitSimple(); |
Brian Silverman | 19ea60f | 2018-01-03 21:43:15 -0800 | [diff] [blame] | 42 | |
| 43 | MediumAdcReadings AdcReadMedium(const DisableInterrupts &); |
| 44 | SmallAdcReadings AdcReadSmall0(const DisableInterrupts &); |
| 45 | SmallAdcReadings AdcReadSmall1(const DisableInterrupts &); |
| 46 | SmallInitReadings AdcReadSmallInit(const DisableInterrupts &); |
Brian Silverman | 259c443 | 2018-01-15 14:34:21 -0800 | [diff] [blame] | 47 | JoystickAdcReadings AdcReadJoystick(const DisableInterrupts &); |
Brian Silverman | a3a172b | 2018-03-24 03:53:32 -0400 | [diff] [blame] | 48 | SimpleAdcReadings AdcReadSimple(const DisableInterrupts &); |
Brian Silverman | 8d3816a | 2017-07-03 18:52:15 -0700 | [diff] [blame] | 49 | |
| 50 | } // namespace salsa |
| 51 | } // namespace frc971 |
| 52 | |
| 53 | #endif // MOTORS_PERIPHERAL_ADC_H_ |