blob: 04caff735aefeaa634d0e3b8fc58e7c1ed257b6c [file] [log] [blame]
Brian Silverman8d3816a2017-07-03 18:52:15 -07001#ifndef MOTORS_PERIPHERAL_ADC_H_
2#define MOTORS_PERIPHERAL_ADC_H_
3
4#include <stdint.h>
5
Brian Silverman19ea60f2018-01-03 21:43:15 -08006#include "motors/util.h"
7
Brian Silvermana3a172b2018-03-24 03:53:32 -04008// TODO(Brian): Avoid cramming all the code for each specific application into a
9// single file like this.
10
Brian Silverman8d3816a2017-07-03 18:52:15 -070011namespace frc971 {
12namespace salsa {
13
14struct MediumAdcReadings {
15 uint16_t motor_currents[3][2];
16 uint16_t motor_current_ref;
17 uint16_t input_voltage;
18};
19
Brian Silverman19ea60f2018-01-03 21:43:15 -080020struct SmallAdcReadings {
21 uint16_t currents[3];
22};
Brian Silverman8d3816a2017-07-03 18:52:15 -070023
Brian Silverman19ea60f2018-01-03 21:43:15 -080024struct SmallInitReadings {
25 uint16_t motor0_abs;
26 uint16_t motor1_abs;
27 uint16_t wheel_abs;
28};
29
Brian Silverman259c4432018-01-15 14:34:21 -080030struct JoystickAdcReadings {
31 uint16_t analog0, analog1, analog2, analog3;
32};
33
Brian Silvermana3a172b2018-03-24 03:53:32 -040034struct SimpleAdcReadings {
35 uint16_t sin, cos;
36};
37
Brian Silverman19ea60f2018-01-03 21:43:15 -080038void AdcInitMedium();
39void AdcInitSmall();
Brian Silverman259c4432018-01-15 14:34:21 -080040void AdcInitJoystick();
Brian Silvermana3a172b2018-03-24 03:53:32 -040041void AdcInitSimple();
Brian Silverman19ea60f2018-01-03 21:43:15 -080042
43MediumAdcReadings AdcReadMedium(const DisableInterrupts &);
44SmallAdcReadings AdcReadSmall0(const DisableInterrupts &);
45SmallAdcReadings AdcReadSmall1(const DisableInterrupts &);
46SmallInitReadings AdcReadSmallInit(const DisableInterrupts &);
Brian Silverman259c4432018-01-15 14:34:21 -080047JoystickAdcReadings AdcReadJoystick(const DisableInterrupts &);
Brian Silvermana3a172b2018-03-24 03:53:32 -040048SimpleAdcReadings AdcReadSimple(const DisableInterrupts &);
Brian Silverman8d3816a2017-07-03 18:52:15 -070049
50} // namespace salsa
51} // namespace frc971
52
53#endif // MOTORS_PERIPHERAL_ADC_H_