wpilib_sys/
hal_bindings.rs

1/* automatically generated by rust-bindgen */
2
3#[repr(C)]
4#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub struct __BindgenBitfieldUnit<Storage, Align>
6where
7    Storage: AsRef<[u8]> + AsMut<[u8]>,
8{
9    storage: Storage,
10    align: [Align; 0],
11}
12
13impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
14where
15    Storage: AsRef<[u8]> + AsMut<[u8]>,
16{
17    #[inline]
18    pub fn new(storage: Storage) -> Self {
19        Self { storage, align: [] }
20    }
21
22    #[inline]
23    pub fn get_bit(&self, index: usize) -> bool {
24        debug_assert!(index / 8 < self.storage.as_ref().len());
25
26        let byte_index = index / 8;
27        let byte = self.storage.as_ref()[byte_index];
28
29        let bit_index = if cfg!(target_endian = "big") {
30            7 - (index % 8)
31        } else {
32            index % 8
33        };
34
35        let mask = 1 << bit_index;
36
37        byte & mask == mask
38    }
39
40    #[inline]
41    pub fn set_bit(&mut self, index: usize, val: bool) {
42        debug_assert!(index / 8 < self.storage.as_ref().len());
43
44        let byte_index = index / 8;
45        let byte = &mut self.storage.as_mut()[byte_index];
46
47        let bit_index = if cfg!(target_endian = "big") {
48            7 - (index % 8)
49        } else {
50            index % 8
51        };
52
53        let mask = 1 << bit_index;
54        if val {
55            *byte |= mask;
56        } else {
57            *byte &= !mask;
58        }
59    }
60
61    #[inline]
62    pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
63        debug_assert!(bit_width <= 64);
64        debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
65        debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
66
67        let mut val = 0;
68
69        for i in 0..(bit_width as usize) {
70            if self.get_bit(i + bit_offset) {
71                let index = if cfg!(target_endian = "big") {
72                    bit_width as usize - 1 - i
73                } else {
74                    i
75                };
76                val |= 1 << index;
77            }
78        }
79
80        val
81    }
82
83    #[inline]
84    pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
85        debug_assert!(bit_width <= 64);
86        debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
87        debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
88
89        for i in 0..(bit_width as usize) {
90            let mask = 1 << i;
91            let val_bit_is_set = val & mask == mask;
92            let index = if cfg!(target_endian = "big") {
93                bit_width as usize - 1 - i
94            } else {
95                i
96            };
97            self.set_bit(index + bit_offset, val_bit_is_set);
98        }
99    }
100}
101pub const HAL_kInvalidHandle: u32 = 0;
102pub const HAL_kMaxJoystickAxes: u32 = 12;
103pub const HAL_kMaxJoystickPOVs: u32 = 12;
104pub const HAL_kMaxJoysticks: u32 = 6;
105pub type HAL_Handle = i32;
106pub type HAL_PortHandle = HAL_Handle;
107pub type HAL_AnalogInputHandle = HAL_Handle;
108pub type HAL_AnalogOutputHandle = HAL_Handle;
109pub type HAL_AnalogTriggerHandle = HAL_Handle;
110pub type HAL_CompressorHandle = HAL_Handle;
111pub type HAL_CounterHandle = HAL_Handle;
112pub type HAL_DigitalHandle = HAL_Handle;
113pub type HAL_DigitalPWMHandle = HAL_Handle;
114pub type HAL_EncoderHandle = HAL_Handle;
115pub type HAL_FPGAEncoderHandle = HAL_Handle;
116pub type HAL_GyroHandle = HAL_Handle;
117pub type HAL_InterruptHandle = HAL_Handle;
118pub type HAL_NotifierHandle = HAL_Handle;
119pub type HAL_RelayHandle = HAL_Handle;
120pub type HAL_SolenoidHandle = HAL_Handle;
121pub type HAL_CANHandle = HAL_Handle;
122pub type HAL_PDPHandle = HAL_CANHandle;
123pub type HAL_Bool = i32;
124pub mod HAL_AccelerometerRange {
125    /// The acceptable accelerometer ranges.
126    pub type Type = i32;
127    pub const k2G: Type = 0;
128    pub const k4G: Type = 1;
129    pub const k8G: Type = 2;
130}
131extern "C" {
132    /// Sets the accelerometer to active or standby mode.
133    ///
134    /// It must be in standby mode to change any configuration.
135    ///
136    /// @param active true to set to active, false for standby
137    pub fn HAL_SetAccelerometerActive(active: HAL_Bool);
138}
139extern "C" {
140    /// Sets the range of values that can be measured (either 2, 4, or 8 g-forces).
141    ///
142    /// The accelerometer should be in standby mode when this is called.
143    ///
144    /// @param range the accelerometer range
145    pub fn HAL_SetAccelerometerRange(range: HAL_AccelerometerRange::Type);
146}
147extern "C" {
148    /// Gets the x-axis acceleration.
149    ///
150    /// This is a floating point value in units of 1 g-force.
151    ///
152    /// @return the X acceleration
153    pub fn HAL_GetAccelerometerX() -> f64;
154}
155extern "C" {
156    /// Gets the y-axis acceleration.
157    ///
158    /// This is a floating point value in units of 1 g-force.
159    ///
160    /// @return the Y acceleration
161    pub fn HAL_GetAccelerometerY() -> f64;
162}
163extern "C" {
164    /// Gets the z-axis acceleration.
165    ///
166    /// This is a floating point value in units of 1 g-force.
167    ///
168    /// @return the Z acceleration
169    pub fn HAL_GetAccelerometerZ() -> f64;
170}
171extern "C" {
172    /// Is the channel attached to an accumulator.
173    ///
174    /// @param analogPortHandle Handle to the analog port.
175    /// @return The analog channel is attached to an accumulator.
176    pub fn HAL_IsAccumulatorChannel(
177        analogPortHandle: HAL_AnalogInputHandle,
178        status: *mut i32,
179    ) -> HAL_Bool;
180}
181extern "C" {
182    /// Initialize the accumulator.
183    ///
184    /// @param analogPortHandle Handle to the analog port.
185    pub fn HAL_InitAccumulator(analogPortHandle: HAL_AnalogInputHandle, status: *mut i32);
186}
187extern "C" {
188    /// Resets the accumulator to the initial value.
189    ///
190    /// @param analogPortHandle Handle to the analog port.
191    pub fn HAL_ResetAccumulator(analogPortHandle: HAL_AnalogInputHandle, status: *mut i32);
192}
193extern "C" {
194    /// Set the center value of the accumulator.
195    ///
196    /// The center value is subtracted from each A/D value before it is added to the
197    /// accumulator. This is used for the center value of devices like gyros and
198    /// accelerometers to make integration work and to take the device offset into
199    /// account when integrating.
200    ///
201    /// This center value is based on the output of the oversampled and averaged
202    /// source from channel 1. Because of this, any non-zero oversample bits will
203    /// affect the size of the value for this field.
204    ///
205    /// @param analogPortHandle Handle to the analog port.
206    /// @param center The center value of the accumulator.
207    pub fn HAL_SetAccumulatorCenter(
208        analogPortHandle: HAL_AnalogInputHandle,
209        center: i32,
210        status: *mut i32,
211    );
212}
213extern "C" {
214    /// Set the accumulator's deadband.
215    ///
216    /// @param analogPortHandle Handle to the analog port.
217    /// @param deadband The deadband of the accumulator.
218    pub fn HAL_SetAccumulatorDeadband(
219        analogPortHandle: HAL_AnalogInputHandle,
220        deadband: i32,
221        status: *mut i32,
222    );
223}
224extern "C" {
225    /// Read the accumulated value.
226    ///
227    /// Read the value that has been accumulating on channel 1.
228    /// The accumulator is attached after the oversample and average engine.
229    ///
230    /// @param analogPortHandle Handle to the analog port.
231    /// @return The 64-bit value accumulated since the last Reset().
232    pub fn HAL_GetAccumulatorValue(
233        analogPortHandle: HAL_AnalogInputHandle,
234        status: *mut i32,
235    ) -> i64;
236}
237extern "C" {
238    /// Read the number of accumulated values.
239    ///
240    /// Read the count of the accumulated values since the accumulator was last
241    /// Reset().
242    ///
243    /// @param analogPortHandle Handle to the analog port.
244    /// @return The number of times samples from the channel were accumulated.
245    pub fn HAL_GetAccumulatorCount(
246        analogPortHandle: HAL_AnalogInputHandle,
247        status: *mut i32,
248    ) -> i64;
249}
250extern "C" {
251    /// Read the accumulated value and the number of accumulated values atomically.
252    ///
253    /// This function reads the value and count from the FPGA atomically.
254    /// This can be used for averaging.
255    ///
256    /// @param analogPortHandle Handle to the analog port.
257    /// @param value Pointer to the 64-bit accumulated output.
258    /// @param count Pointer to the number of accumulation cycles.
259    pub fn HAL_GetAccumulatorOutput(
260        analogPortHandle: HAL_AnalogInputHandle,
261        value: *mut i64,
262        count: *mut i64,
263        status: *mut i32,
264    );
265}
266extern "C" {
267    /// Initializes an analog gyro.
268    ///
269    /// @param handle handle to the analog port
270    /// @return       the initialized gyro handle
271    pub fn HAL_InitializeAnalogGyro(
272        handle: HAL_AnalogInputHandle,
273        status: *mut i32,
274    ) -> HAL_GyroHandle;
275}
276extern "C" {
277    /// Sets up an analog gyro with the proper offsets and settings for the KOP
278    /// analog gyro.
279    ///
280    /// @param handle the gyro handle
281    pub fn HAL_SetupAnalogGyro(handle: HAL_GyroHandle, status: *mut i32);
282}
283extern "C" {
284    /// Frees an analog gyro.
285    ///
286    /// @param handle the gyro handle
287    pub fn HAL_FreeAnalogGyro(handle: HAL_GyroHandle);
288}
289extern "C" {
290    /// Sets the analog gyro parameters to the specified values.
291    ///
292    /// This is meant to be used if you want to reuse the values from a previous
293    /// calibration.
294    ///
295    /// @param handle                  the gyro handle
296    /// @param voltsPerDegreePerSecond the gyro volts scaling
297    /// @param offset                  the gyro offset
298    /// @param center                  the gyro center
299    pub fn HAL_SetAnalogGyroParameters(
300        handle: HAL_GyroHandle,
301        voltsPerDegreePerSecond: f64,
302        offset: f64,
303        center: i32,
304        status: *mut i32,
305    );
306}
307extern "C" {
308    /// Sets the analog gyro volts per degrees per second scaling.
309    ///
310    /// @param handle                  the gyro handle
311    /// @param voltsPerDegreePerSecond the gyro volts scaling
312    pub fn HAL_SetAnalogGyroVoltsPerDegreePerSecond(
313        handle: HAL_GyroHandle,
314        voltsPerDegreePerSecond: f64,
315        status: *mut i32,
316    );
317}
318extern "C" {
319    /// Resets the analog gyro value to 0.
320    ///
321    /// @param handle the gyro handle
322    pub fn HAL_ResetAnalogGyro(handle: HAL_GyroHandle, status: *mut i32);
323}
324extern "C" {
325    /// Calibrates the analog gyro.
326    ///
327    /// This happens by calculating the average value of the gyro over 5 seconds, and
328    /// setting that as the center. Note that this call blocks for 5 seconds to
329    /// perform this.
330    ///
331    /// @param handle the gyro handle
332    pub fn HAL_CalibrateAnalogGyro(handle: HAL_GyroHandle, status: *mut i32);
333}
334extern "C" {
335    /// Sets the deadband of the analog gyro.
336    ///
337    /// @param handle the gyro handle
338    /// @param volts  the voltage deadband
339    pub fn HAL_SetAnalogGyroDeadband(handle: HAL_GyroHandle, volts: f64, status: *mut i32);
340}
341extern "C" {
342    /// Gets the gyro angle in degrees.
343    ///
344    /// @param handle the gyro handle
345    /// @return the gyro angle in degrees
346    pub fn HAL_GetAnalogGyroAngle(handle: HAL_GyroHandle, status: *mut i32) -> f64;
347}
348extern "C" {
349    /// Gets the gyro rate in degrees/second.
350    ///
351    /// @param handle the gyro handle
352    /// @return the gyro rate in degrees/second
353    pub fn HAL_GetAnalogGyroRate(handle: HAL_GyroHandle, status: *mut i32) -> f64;
354}
355extern "C" {
356    /// Gets the calibrated gyro offset.
357    ///
358    /// Can be used to not repeat a calibration but reconstruct the gyro object.
359    ///
360    /// @param handle the gyro handle
361    /// @return the gryo offset
362    pub fn HAL_GetAnalogGyroOffset(handle: HAL_GyroHandle, status: *mut i32) -> f64;
363}
364extern "C" {
365    /// Gets the calibrated gyro center.
366    ///
367    /// Can be used to not repeat a calibration but reconstruct the gyro object.
368    ///
369    /// @param handle the gyro handle
370    /// @return the gyro center
371    pub fn HAL_GetAnalogGyroCenter(handle: HAL_GyroHandle, status: *mut i32) -> i32;
372}
373extern "C" {
374    /// Initializes the analog input port using the given port object.
375    ///
376    /// @param portHandle Handle to the port to initialize.
377    /// @return           the created analog input handle
378    pub fn HAL_InitializeAnalogInputPort(
379        portHandle: HAL_PortHandle,
380        status: *mut i32,
381    ) -> HAL_AnalogInputHandle;
382}
383extern "C" {
384    /// Frees an analog input port.
385    ///
386    /// @param analogPortHandle Handle to the analog port.
387    pub fn HAL_FreeAnalogInputPort(analogPortHandle: HAL_AnalogInputHandle);
388}
389extern "C" {
390    /// Checks that the analog module number is valid.
391    ///
392    /// @param module The analog module number.
393    /// @return Analog module is valid and present
394    pub fn HAL_CheckAnalogModule(module: i32) -> HAL_Bool;
395}
396extern "C" {
397    /// Checks that the analog output channel number is value.
398    /// Verifies that the analog channel number is one of the legal channel numbers.
399    /// Channel numbers are 0-based.
400    ///
401    /// @param channel The analog output channel number.
402    /// @return Analog channel is valid
403    pub fn HAL_CheckAnalogInputChannel(channel: i32) -> HAL_Bool;
404}
405extern "C" {
406    /// Sets the sample rate.
407    ///
408    /// This is a global setting for the Athena and effects all channels.
409    ///
410    /// @param samplesPerSecond The number of samples per channel per second.
411    pub fn HAL_SetAnalogSampleRate(samplesPerSecond: f64, status: *mut i32);
412}
413extern "C" {
414    /// Gets the current sample rate.
415    ///
416    /// This assumes one entry in the scan list.
417    /// This is a global setting for the Athena and effects all channels.
418    ///
419    /// @return Sample rate.
420    pub fn HAL_GetAnalogSampleRate(status: *mut i32) -> f64;
421}
422extern "C" {
423    /// Sets the number of averaging bits.
424    ///
425    /// This sets the number of averaging bits. The actual number of averaged samples
426    /// is 2**bits. Use averaging to improve the stability of your measurement at the
427    /// expense of sampling rate. The averaging is done automatically in the FPGA.
428    ///
429    /// @param analogPortHandle Handle to the analog port to configure.
430    /// @param bits Number of bits to average.
431    pub fn HAL_SetAnalogAverageBits(
432        analogPortHandle: HAL_AnalogInputHandle,
433        bits: i32,
434        status: *mut i32,
435    );
436}
437extern "C" {
438    /// Gets the number of averaging bits.
439    ///
440    /// This gets the number of averaging bits from the FPGA. The actual number of
441    /// averaged samples is 2**bits. The averaging is done automatically in the FPGA.
442    ///
443    /// @param analogPortHandle Handle to the analog port to use.
444    /// @return Bits to average.
445    pub fn HAL_GetAnalogAverageBits(
446        analogPortHandle: HAL_AnalogInputHandle,
447        status: *mut i32,
448    ) -> i32;
449}
450extern "C" {
451    /// Sets the number of oversample bits.
452    ///
453    /// This sets the number of oversample bits. The actual number of oversampled
454    /// values is 2**bits. Use oversampling to improve the resolution of your
455    /// measurements at the expense of sampling rate. The oversampling is done
456    /// automatically in the FPGA.
457    ///
458    /// @param analogPortHandle Handle to the analog port to use.
459    /// @param bits Number of bits to oversample.
460    pub fn HAL_SetAnalogOversampleBits(
461        analogPortHandle: HAL_AnalogInputHandle,
462        bits: i32,
463        status: *mut i32,
464    );
465}
466extern "C" {
467    /// Gets the number of oversample bits.
468    ///
469    /// This gets the number of oversample bits from the FPGA. The actual number of
470    /// oversampled values is 2**bits. The oversampling is done automatically in the
471    /// FPGA.
472    ///
473    /// @param analogPortHandle Handle to the analog port to use.
474    /// @return Bits to oversample.
475    pub fn HAL_GetAnalogOversampleBits(
476        analogPortHandle: HAL_AnalogInputHandle,
477        status: *mut i32,
478    ) -> i32;
479}
480extern "C" {
481    /// Gets a sample straight from the channel on this module.
482    ///
483    /// The sample is a 12-bit value representing the 0V to 5V range of the A/D
484    /// converter in the module. The units are in A/D converter codes.  Use
485    /// GetVoltage() to get the analog value in calibrated units.
486    ///
487    /// @param analogPortHandle Handle to the analog port to use.
488    /// @return A sample straight from the channel on this module.
489    pub fn HAL_GetAnalogValue(analogPortHandle: HAL_AnalogInputHandle, status: *mut i32) -> i32;
490}
491extern "C" {
492    /// Gets a sample from the output of the oversample and average engine for the
493    /// channel.
494    ///
495    /// The sample is 12-bit + the value configured in SetOversampleBits().
496    /// The value configured in SetAverageBits() will cause this value to be averaged
497    /// 2**bits number of samples. This is not a sliding window.  The sample will not
498    /// change until 2**(OversamplBits + AverageBits) samples have been acquired from
499    /// the module on this channel. Use GetAverageVoltage() to get the analog value
500    /// in calibrated units.
501    ///
502    /// @param analogPortHandle Handle to the analog port to use.
503    /// @return A sample from the oversample and average engine for the channel.
504    pub fn HAL_GetAnalogAverageValue(
505        analogPortHandle: HAL_AnalogInputHandle,
506        status: *mut i32,
507    ) -> i32;
508}
509extern "C" {
510    /// Converts a voltage to a raw value for a specified channel.
511    ///
512    /// This process depends on the calibration of each channel, so the channel must
513    /// be specified.
514    ///
515    /// @todo This assumes raw values.  Oversampling not supported as is.
516    ///
517    /// @param analogPortHandle Handle to the analog port to use.
518    /// @param voltage The voltage to convert.
519    /// @return The raw value for the channel.
520    pub fn HAL_GetAnalogVoltsToValue(
521        analogPortHandle: HAL_AnalogInputHandle,
522        voltage: f64,
523        status: *mut i32,
524    ) -> i32;
525}
526extern "C" {
527    /// Gets a scaled sample straight from the channel on this module.
528    ///
529    /// The value is scaled to units of Volts using the calibrated scaling data from
530    /// GetLSBWeight() and GetOffset().
531    ///
532    /// @param analogPortHandle Handle to the analog port to use.
533    /// @return A scaled sample straight from the channel on this module.
534    pub fn HAL_GetAnalogVoltage(analogPortHandle: HAL_AnalogInputHandle, status: *mut i32) -> f64;
535}
536extern "C" {
537    /// Gets a scaled sample from the output of the oversample and average engine for
538    /// the channel.
539    ///
540    /// The value is scaled to units of Volts using the calibrated scaling data from
541    /// GetLSBWeight() and GetOffset(). Using oversampling will cause this value to
542    /// be higher resolution, but it will update more slowly. Using averaging will
543    /// cause this value to be more stable, but it will update more slowly.
544    ///
545    /// @param analogPortHandle Handle to the analog port to use.
546    /// @return A scaled sample from the output of the oversample and average engine
547    /// for the channel.
548    pub fn HAL_GetAnalogAverageVoltage(
549        analogPortHandle: HAL_AnalogInputHandle,
550        status: *mut i32,
551    ) -> f64;
552}
553extern "C" {
554    /// Gets the factory scaling least significant bit weight constant.
555    /// The least significant bit weight constant for the channel that was calibrated
556    /// in manufacturing and stored in an eeprom in the module.
557    ///
558    /// Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
559    ///
560    /// @param analogPortHandle Handle to the analog port to use.
561    /// @return Least significant bit weight.
562    pub fn HAL_GetAnalogLSBWeight(analogPortHandle: HAL_AnalogInputHandle, status: *mut i32)
563        -> i32;
564}
565extern "C" {
566    /// Gets the factory scaling offset constant.
567    /// The offset constant for the channel that was calibrated in manufacturing and
568    /// stored in an eeprom in the module.
569    ///
570    /// Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
571    ///
572    /// @param analogPortHandle Handle to the analog port to use.
573    /// @return Offset constant.
574    pub fn HAL_GetAnalogOffset(analogPortHandle: HAL_AnalogInputHandle, status: *mut i32) -> i32;
575}
576extern "C" {
577    /// Initializes the analog output port using the given port object.
578    ///
579    /// @param handle handle to the port
580    /// @return       the created analog output handle
581    pub fn HAL_InitializeAnalogOutputPort(
582        portHandle: HAL_PortHandle,
583        status: *mut i32,
584    ) -> HAL_AnalogOutputHandle;
585}
586extern "C" {
587    /// Frees an analog output port.
588    ///
589    /// @param analogOutputHandle the analog output handle
590    pub fn HAL_FreeAnalogOutputPort(analogOutputHandle: HAL_AnalogOutputHandle);
591}
592extern "C" {
593    /// Sets an analog output value.
594    ///
595    /// @param analogOutputHandle the analog output handle
596    /// @param voltage            the voltage (0-5v) to output
597    pub fn HAL_SetAnalogOutput(
598        analogOutputHandle: HAL_AnalogOutputHandle,
599        voltage: f64,
600        status: *mut i32,
601    );
602}
603extern "C" {
604    /// Gets the current analog output value.
605    ///
606    /// @param analogOutputHandle the analog output handle
607    /// @return                   the current output voltage (0-5v)
608    pub fn HAL_GetAnalogOutput(analogOutputHandle: HAL_AnalogOutputHandle, status: *mut i32)
609        -> f64;
610}
611extern "C" {
612    /// Checks that the analog output channel number is value.
613    ///
614    /// Verifies that the analog channel number is one of the legal channel numbers.
615    /// Channel numbers are 0-based.
616    ///
617    /// @return Analog channel is valid
618    pub fn HAL_CheckAnalogOutputChannel(channel: i32) -> HAL_Bool;
619}
620pub mod HAL_AnalogTriggerType {
621    /// The type of analog trigger to trigger on.
622    pub type Type = i32;
623    pub const HAL_Trigger_kInWindow: Type = 0;
624    pub const HAL_Trigger_kState: Type = 1;
625    pub const HAL_Trigger_kRisingPulse: Type = 2;
626    pub const HAL_Trigger_kFallingPulse: Type = 3;
627}
628extern "C" {
629    /// Initializes an analog trigger.
630    ///
631    /// @param portHandle the analog input to use for triggering
632    /// @param index      the trigger index value (output)
633    /// @return           the created analog trigger handle
634    pub fn HAL_InitializeAnalogTrigger(
635        portHandle: HAL_AnalogInputHandle,
636        index: *mut i32,
637        status: *mut i32,
638    ) -> HAL_AnalogTriggerHandle;
639}
640extern "C" {
641    /// Frees an analog trigger.
642    ///
643    /// @param analogTriggerHandle the trigger handle
644    pub fn HAL_CleanAnalogTrigger(analogTriggerHandle: HAL_AnalogTriggerHandle, status: *mut i32);
645}
646extern "C" {
647    /// Sets the raw ADC upper and lower limits of the analog trigger.
648    ///
649    /// HAL_SetAnalogTriggerLimitsVoltage is likely better in most cases.
650    ///
651    /// @param analogTriggerHandle the trigger handle
652    /// @param lower               the lower ADC value
653    /// @param upper               the upper ADC value
654    pub fn HAL_SetAnalogTriggerLimitsRaw(
655        analogTriggerHandle: HAL_AnalogTriggerHandle,
656        lower: i32,
657        upper: i32,
658        status: *mut i32,
659    );
660}
661extern "C" {
662    /// Sets the upper and lower limits of the analog trigger.
663    ///
664    /// The limits are given as floating point voltage values.
665    ///
666    /// @param analogTriggerHandle the trigger handle
667    /// @param lower               the lower voltage value
668    /// @param upper               the upper voltage value
669    pub fn HAL_SetAnalogTriggerLimitsVoltage(
670        analogTriggerHandle: HAL_AnalogTriggerHandle,
671        lower: f64,
672        upper: f64,
673        status: *mut i32,
674    );
675}
676extern "C" {
677    /// Configures the analog trigger to use the averaged vs. raw values.
678    ///
679    /// If the value is true, then the averaged value is selected for the analog
680    /// trigger, otherwise the immediate value is used.
681    ///
682    /// @param analogTriggerHandle the trigger handle
683    /// @param useAveragedValue    true to use averaged values, false for raw
684    pub fn HAL_SetAnalogTriggerAveraged(
685        analogTriggerHandle: HAL_AnalogTriggerHandle,
686        useAveragedValue: HAL_Bool,
687        status: *mut i32,
688    );
689}
690extern "C" {
691    /// Configures the analog trigger to use a filtered value.
692    ///
693    /// The analog trigger will operate with a 3 point average rejection filter. This
694    /// is designed to help with 360 degree pot applications for the period where the
695    /// pot crosses through zero.
696    ///
697    /// @param analogTriggerHandle the trigger handle
698    /// @param useFilteredValue    true to use filtered values, false for average or
699    /// raw
700    pub fn HAL_SetAnalogTriggerFiltered(
701        analogTriggerHandle: HAL_AnalogTriggerHandle,
702        useFilteredValue: HAL_Bool,
703        status: *mut i32,
704    );
705}
706extern "C" {
707    /// Returns the InWindow output of the analog trigger.
708    ///
709    /// True if the analog input is between the upper and lower limits.
710    ///
711    /// @param analogTriggerHandle the trigger handle
712    /// @return                    the InWindow output of the analog trigger
713    pub fn HAL_GetAnalogTriggerInWindow(
714        analogTriggerHandle: HAL_AnalogTriggerHandle,
715        status: *mut i32,
716    ) -> HAL_Bool;
717}
718extern "C" {
719    /// Returns the TriggerState output of the analog trigger.
720    ///
721    /// True if above upper limit.
722    /// False if below lower limit.
723    /// If in Hysteresis, maintain previous state.
724    ///
725    /// @param analogTriggerHandle the trigger handle
726    /// @return                    the TriggerState output of the analog trigger
727    pub fn HAL_GetAnalogTriggerTriggerState(
728        analogTriggerHandle: HAL_AnalogTriggerHandle,
729        status: *mut i32,
730    ) -> HAL_Bool;
731}
732extern "C" {
733    /// Gets the state of the analog trigger output.
734    ///
735    /// @param analogTriggerHandle the trigger handle
736    /// @param type                the type of trigger to trigger on
737    /// @return                    the state of the analog trigger output
738    pub fn HAL_GetAnalogTriggerOutput(
739        analogTriggerHandle: HAL_AnalogTriggerHandle,
740        type_: HAL_AnalogTriggerType::Type,
741        status: *mut i32,
742    ) -> HAL_Bool;
743}
744/// Storage for CAN Stream Messages.
745#[repr(C)]
746#[derive(Debug, Default, Copy, Clone)]
747pub struct HAL_CANStreamMessage {
748    pub messageID: u32,
749    pub timeStamp: u32,
750    pub data: [u8; 8usize],
751    pub dataSize: u8,
752}
753#[test]
754fn bindgen_test_layout_HAL_CANStreamMessage() {
755    assert_eq!(
756        ::std::mem::size_of::<HAL_CANStreamMessage>(),
757        20usize,
758        concat!("Size of: ", stringify!(HAL_CANStreamMessage))
759    );
760    assert_eq!(
761        ::std::mem::align_of::<HAL_CANStreamMessage>(),
762        4usize,
763        concat!("Alignment of ", stringify!(HAL_CANStreamMessage))
764    );
765    assert_eq!(
766        unsafe { &(*(::std::ptr::null::<HAL_CANStreamMessage>())).messageID as *const _ as usize },
767        0usize,
768        concat!(
769            "Offset of field: ",
770            stringify!(HAL_CANStreamMessage),
771            "::",
772            stringify!(messageID)
773        )
774    );
775    assert_eq!(
776        unsafe { &(*(::std::ptr::null::<HAL_CANStreamMessage>())).timeStamp as *const _ as usize },
777        4usize,
778        concat!(
779            "Offset of field: ",
780            stringify!(HAL_CANStreamMessage),
781            "::",
782            stringify!(timeStamp)
783        )
784    );
785    assert_eq!(
786        unsafe { &(*(::std::ptr::null::<HAL_CANStreamMessage>())).data as *const _ as usize },
787        8usize,
788        concat!(
789            "Offset of field: ",
790            stringify!(HAL_CANStreamMessage),
791            "::",
792            stringify!(data)
793        )
794    );
795    assert_eq!(
796        unsafe { &(*(::std::ptr::null::<HAL_CANStreamMessage>())).dataSize as *const _ as usize },
797        16usize,
798        concat!(
799            "Offset of field: ",
800            stringify!(HAL_CANStreamMessage),
801            "::",
802            stringify!(dataSize)
803        )
804    );
805}
806extern "C" {
807    /// Initializes a compressor on the given PCM module.
808    ///
809    /// @param module the module number
810    /// @return       the created handle
811    pub fn HAL_InitializeCompressor(module: i32, status: *mut i32) -> HAL_CompressorHandle;
812}
813extern "C" {
814    /// Gets if a compressor module is valid.
815    ///
816    /// @param module the module number
817    /// @return       true if the module is valid, otherwise false
818    pub fn HAL_CheckCompressorModule(module: i32) -> HAL_Bool;
819}
820extern "C" {
821    /// Gets the compressor state (on or off).
822    ///
823    /// @param compressorHandle the compressor handle
824    /// @return                 true if the compressor is on, otherwise false
825    pub fn HAL_GetCompressor(compressorHandle: HAL_CompressorHandle, status: *mut i32) -> HAL_Bool;
826}
827extern "C" {
828    /// Sets the compressor to closed loop mode.
829    ///
830    /// @param compressorHandle the compressor handle
831    /// @param value            true for closed loop mode, false for off
832    pub fn HAL_SetCompressorClosedLoopControl(
833        compressorHandle: HAL_CompressorHandle,
834        value: HAL_Bool,
835        status: *mut i32,
836    );
837}
838extern "C" {
839    /// Gets if the compressor is in closed loop mode.
840    ///
841    /// @param compressorHandle the compressor handle
842    /// @return                 true if the compressor is in closed loop mode,
843    /// otherwise false
844    pub fn HAL_GetCompressorClosedLoopControl(
845        compressorHandle: HAL_CompressorHandle,
846        status: *mut i32,
847    ) -> HAL_Bool;
848}
849extern "C" {
850    /// Gets the compressor pressure switch state.
851    ///
852    /// @param compressorHandle the compressor handle
853    /// @return                 true if the pressure switch is triggered, otherwise
854    /// false
855    pub fn HAL_GetCompressorPressureSwitch(
856        compressorHandle: HAL_CompressorHandle,
857        status: *mut i32,
858    ) -> HAL_Bool;
859}
860extern "C" {
861    /// Gets the compressor current.
862    ///
863    /// @param compressorHandle the compressor handle
864    /// @return                 the compressor current in amps
865    pub fn HAL_GetCompressorCurrent(
866        compressorHandle: HAL_CompressorHandle,
867        status: *mut i32,
868    ) -> f64;
869}
870extern "C" {
871    /// Gets if the compressor is faulted because of too high of current.
872    ///
873    /// @param compressorHandle the compressor handle
874    /// @return                 true if falted, otherwise false
875    pub fn HAL_GetCompressorCurrentTooHighFault(
876        compressorHandle: HAL_CompressorHandle,
877        status: *mut i32,
878    ) -> HAL_Bool;
879}
880extern "C" {
881    /// Gets if a sticky fauly is triggered because of too high of current.
882    ///
883    /// @param compressorHandle the compressor handle
884    /// @return                 true if falted, otherwise false
885    pub fn HAL_GetCompressorCurrentTooHighStickyFault(
886        compressorHandle: HAL_CompressorHandle,
887        status: *mut i32,
888    ) -> HAL_Bool;
889}
890extern "C" {
891    /// Gets if a sticky fauly is triggered because of a short.
892    ///
893    /// @param compressorHandle the compressor handle
894    /// @return                 true if falted, otherwise false
895    pub fn HAL_GetCompressorShortedStickyFault(
896        compressorHandle: HAL_CompressorHandle,
897        status: *mut i32,
898    ) -> HAL_Bool;
899}
900extern "C" {
901    /// Gets if the compressor is faulted because of a short.
902    ///
903    /// @param compressorHandle the compressor handle
904    /// @return                 true if shorted, otherwise false
905    pub fn HAL_GetCompressorShortedFault(
906        compressorHandle: HAL_CompressorHandle,
907        status: *mut i32,
908    ) -> HAL_Bool;
909}
910extern "C" {
911    /// Gets if a sticky fault is triggered of the compressor not connected.
912    ///
913    /// @param compressorHandle the compressor handle
914    /// @return                 true if falted, otherwise false
915    pub fn HAL_GetCompressorNotConnectedStickyFault(
916        compressorHandle: HAL_CompressorHandle,
917        status: *mut i32,
918    ) -> HAL_Bool;
919}
920extern "C" {
921    /// Gets if the compressor is not connected.
922    ///
923    /// @param compressorHandle the compressor handle
924    /// @return                 true if not connected, otherwise false
925    pub fn HAL_GetCompressorNotConnectedFault(
926        compressorHandle: HAL_CompressorHandle,
927        status: *mut i32,
928    ) -> HAL_Bool;
929}
930extern "C" {
931    /// Gets the number of FPGA system clock ticks per microsecond.
932    ///
933    /// @return the number of clock ticks per microsecond
934    pub fn HAL_GetSystemClockTicksPerMicrosecond() -> i32;
935}
936pub mod HAL_Counter_Mode {
937    /// The counter mode.
938    pub type Type = i32;
939    pub const HAL_Counter_kTwoPulse: Type = 0;
940    pub const HAL_Counter_kSemiperiod: Type = 1;
941    pub const HAL_Counter_kPulseLength: Type = 2;
942    pub const HAL_Counter_kExternalDirection: Type = 3;
943}
944extern "C" {
945    /// Initializes a counter.
946    ///
947    /// @param mode  the counter mode
948    /// @param index the compressor index (output)
949    /// @return      the created handle
950    pub fn HAL_InitializeCounter(
951        mode: HAL_Counter_Mode::Type,
952        index: *mut i32,
953        status: *mut i32,
954    ) -> HAL_CounterHandle;
955}
956extern "C" {
957    /// Frees a counter.
958    ///
959    /// @param counterHandle the counter handle
960    pub fn HAL_FreeCounter(counterHandle: HAL_CounterHandle, status: *mut i32);
961}
962extern "C" {
963    /// Sets the average sample size of a counter.
964    ///
965    /// @param counterHandle the counter handle
966    /// @param size          the size of samples to average
967    pub fn HAL_SetCounterAverageSize(counterHandle: HAL_CounterHandle, size: i32, status: *mut i32);
968}
969extern "C" {
970    /// Sets the source object that causes the counter to count up.
971    ///
972    /// @param counterHandle       the counter handle
973    /// @param digitalSourceHandle the digital source handle (either a
974    /// HAL_AnalogTriggerHandle of a HAL_DigitalHandle)
975    /// @param analogTriggerType   the analog trigger type if the source is an analog
976    /// trigger
977    pub fn HAL_SetCounterUpSource(
978        counterHandle: HAL_CounterHandle,
979        digitalSourceHandle: HAL_Handle,
980        analogTriggerType: HAL_AnalogTriggerType::Type,
981        status: *mut i32,
982    );
983}
984extern "C" {
985    /// Sets the up source to either detect rising edges or falling edges.
986    ///
987    /// Note that both are allowed to be set true at the same time without issues.
988    ///
989    /// @param counterHandle the counter handle
990    /// @param risingEdge    true to trigger on rising
991    /// @param fallingEdge   true to trigger on falling
992    pub fn HAL_SetCounterUpSourceEdge(
993        counterHandle: HAL_CounterHandle,
994        risingEdge: HAL_Bool,
995        fallingEdge: HAL_Bool,
996        status: *mut i32,
997    );
998}
999extern "C" {
1000    /// Disables the up counting source to the counter.
1001    ///
1002    /// @param counterHandle the counter handle
1003    pub fn HAL_ClearCounterUpSource(counterHandle: HAL_CounterHandle, status: *mut i32);
1004}
1005extern "C" {
1006    /// Sets the source object that causes the counter to count down.
1007    ///
1008    /// @param counterHandle       the counter handle
1009    /// @param digitalSourceHandle the digital source handle (either a
1010    /// HAL_AnalogTriggerHandle of a HAL_DigitalHandle)
1011    /// @param analogTriggerType   the analog trigger type if the source is an analog
1012    /// trigger
1013    pub fn HAL_SetCounterDownSource(
1014        counterHandle: HAL_CounterHandle,
1015        digitalSourceHandle: HAL_Handle,
1016        analogTriggerType: HAL_AnalogTriggerType::Type,
1017        status: *mut i32,
1018    );
1019}
1020extern "C" {
1021    /// Sets the down source to either detect rising edges or falling edges.
1022    /// Note that both are allowed to be set true at the same time without issues.
1023    ///
1024    /// @param counterHandle the counter handle
1025    /// @param risingEdge    true to trigger on rising
1026    /// @param fallingEdge   true to trigger on falling
1027    pub fn HAL_SetCounterDownSourceEdge(
1028        counterHandle: HAL_CounterHandle,
1029        risingEdge: HAL_Bool,
1030        fallingEdge: HAL_Bool,
1031        status: *mut i32,
1032    );
1033}
1034extern "C" {
1035    /// Disables the down counting source to the counter.
1036    ///
1037    /// @param counterHandle the counter handle
1038    pub fn HAL_ClearCounterDownSource(counterHandle: HAL_CounterHandle, status: *mut i32);
1039}
1040extern "C" {
1041    /// Sets standard up / down counting mode on this counter.
1042    ///
1043    /// Up and down counts are sourced independently from two inputs.
1044    ///
1045    /// @param counterHandle the counter handle
1046    pub fn HAL_SetCounterUpDownMode(counterHandle: HAL_CounterHandle, status: *mut i32);
1047}
1048extern "C" {
1049    /// Sets directional counting mode on this counter.
1050    ///
1051    /// The direction is determined by the B input, with counting happening with the
1052    /// A input.
1053    ///
1054    /// @param counterHandle the counter handle
1055    pub fn HAL_SetCounterExternalDirectionMode(counterHandle: HAL_CounterHandle, status: *mut i32);
1056}
1057extern "C" {
1058    /// Sets Semi-period mode on this counter.
1059    ///
1060    /// The counter counts up based on the time the input is triggered. High or Low
1061    /// depends on the highSemiPeriod parameter.
1062    ///
1063    /// @param counterHandle  the counter handle
1064    /// @param highSemiPeriod true for counting when the input is high, false for low
1065    pub fn HAL_SetCounterSemiPeriodMode(
1066        counterHandle: HAL_CounterHandle,
1067        highSemiPeriod: HAL_Bool,
1068        status: *mut i32,
1069    );
1070}
1071extern "C" {
1072    /// Configures the counter to count in up or down based on the length of the
1073    /// input pulse.
1074    ///
1075    /// This mode is most useful for direction sensitive gear tooth sensors.
1076    ///
1077    /// @param counterHandle the counter handle
1078    /// @param threshold The pulse length beyond which the counter counts the
1079    /// opposite direction (seconds)
1080    pub fn HAL_SetCounterPulseLengthMode(
1081        counterHandle: HAL_CounterHandle,
1082        threshold: f64,
1083        status: *mut i32,
1084    );
1085}
1086extern "C" {
1087    /// Gets the Samples to Average which specifies the number of samples of the
1088    /// timer to average when calculating the period. Perform averaging to account
1089    /// for mechanical imperfections or as oversampling to increase resolution.
1090    ///
1091    /// @param counterHandle the counter handle
1092    /// @return SamplesToAverage The number of samples being averaged (from 1 to 127)
1093    pub fn HAL_GetCounterSamplesToAverage(
1094        counterHandle: HAL_CounterHandle,
1095        status: *mut i32,
1096    ) -> i32;
1097}
1098extern "C" {
1099    /// Sets the Samples to Average which specifies the number of samples of the
1100    /// timer to average when calculating the period. Perform averaging to account
1101    /// for mechanical imperfections or as oversampling to increase resolution.
1102    ///
1103    /// @param counterHandle    the counter handle
1104    /// @param samplesToAverage The number of samples to average from 1 to 127
1105    pub fn HAL_SetCounterSamplesToAverage(
1106        counterHandle: HAL_CounterHandle,
1107        samplesToAverage: i32,
1108        status: *mut i32,
1109    );
1110}
1111extern "C" {
1112    /// Resets the Counter to zero.
1113    ///
1114    /// Sets the counter value to zero. This does not effect the running state of the
1115    /// counter, just sets the current value to zero.
1116    ///
1117    /// @param counterHandle the counter handle
1118    pub fn HAL_ResetCounter(counterHandle: HAL_CounterHandle, status: *mut i32);
1119}
1120extern "C" {
1121    /// Reads the current counter value.
1122    ///
1123    /// Reads the value at this instant. It may still be running, so it reflects the
1124    /// current value. Next time it is read, it might have a different value.
1125    ///
1126    /// @param counterHandle the counter handle
1127    /// @return              the current counter value
1128    pub fn HAL_GetCounter(counterHandle: HAL_CounterHandle, status: *mut i32) -> i32;
1129}
1130extern "C" {
1131    pub fn HAL_GetCounterPeriod(counterHandle: HAL_CounterHandle, status: *mut i32) -> f64;
1132}
1133extern "C" {
1134    /// Sets the maximum period where the device is still considered "moving".
1135    ///
1136    /// Sets the maximum period where the device is considered moving. This value is
1137    /// used to determine the "stopped" state of the counter using the
1138    /// HAL_GetCounterStopped method.
1139    ///
1140    /// @param counterHandle the counter handle
1141    /// @param maxPeriod     the maximum period where the counted device is
1142    /// considered moving in seconds
1143    pub fn HAL_SetCounterMaxPeriod(
1144        counterHandle: HAL_CounterHandle,
1145        maxPeriod: f64,
1146        status: *mut i32,
1147    );
1148}
1149extern "C" {
1150    /// Selects whether you want to continue updating the event timer output when
1151    /// there are no samples captured.
1152    ///
1153    /// The output of the event timer has a buffer of periods that are averaged and
1154    /// posted to a register on the FPGA.  When the timer detects that the event
1155    /// source has stopped (based on the MaxPeriod) the buffer of samples to be
1156    /// averaged is emptied.
1157    ///
1158    /// If you enable the update when empty, you will be
1159    /// notified of the stopped source and the event time will report 0 samples.
1160    ///
1161    /// If you disable update when empty, the most recent average will remain on the
1162    /// output until a new sample is acquired.
1163    ///
1164    /// You will never see 0 samples output (except when there have been no events
1165    /// since an FPGA reset) and you will likely not see the stopped bit become true
1166    /// (since it is updated at the end of an average and there are no samples to
1167    /// average).
1168    ///
1169    /// @param counterHandle the counter handle
1170    /// @param enabled       true to enable counter updating with no samples
1171    pub fn HAL_SetCounterUpdateWhenEmpty(
1172        counterHandle: HAL_CounterHandle,
1173        enabled: HAL_Bool,
1174        status: *mut i32,
1175    );
1176}
1177extern "C" {
1178    /// Determines if the clock is stopped.
1179    ///
1180    /// Determine if the clocked input is stopped based on the MaxPeriod value set
1181    /// using the SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the
1182    /// device (and counter) are assumed to be stopped and it returns true.
1183    ///
1184    /// @param counterHandle the counter handle
1185    /// @return              true if the most recent counter period exceeds the
1186    /// MaxPeriod value set by SetMaxPeriod
1187    pub fn HAL_GetCounterStopped(counterHandle: HAL_CounterHandle, status: *mut i32) -> HAL_Bool;
1188}
1189extern "C" {
1190    /// Gets the last direction the counter value changed.
1191    ///
1192    /// @param counterHandle the counter handle
1193    /// @return              the last direction the counter value changed
1194    pub fn HAL_GetCounterDirection(counterHandle: HAL_CounterHandle, status: *mut i32) -> HAL_Bool;
1195}
1196extern "C" {
1197    /// Sets the Counter to return reversed sensing on the direction.
1198    ///
1199    /// This allows counters to change the direction they are counting in the case of
1200    /// 1X and 2X quadrature encoding only. Any other counter mode isn't supported.
1201    ///
1202    /// @param counterHandle    the counter handle
1203    /// @param reverseDirection true if the value counted should be negated.
1204    pub fn HAL_SetCounterReverseDirection(
1205        counterHandle: HAL_CounterHandle,
1206        reverseDirection: HAL_Bool,
1207        status: *mut i32,
1208    );
1209}
1210extern "C" {
1211    /// Creates a new instance of a digital port.
1212    ///
1213    /// @param portHandle the port handle to create from
1214    /// @param input      true for input, false for output
1215    /// @return           the created digital handle
1216    pub fn HAL_InitializeDIOPort(
1217        portHandle: HAL_PortHandle,
1218        input: HAL_Bool,
1219        status: *mut i32,
1220    ) -> HAL_DigitalHandle;
1221}
1222extern "C" {
1223    /// Checks if a DIO channel is valid.
1224    ///
1225    /// @param channel the channel number to check
1226    /// @return        true if the channel is correct, otherwise false
1227    pub fn HAL_CheckDIOChannel(channel: i32) -> HAL_Bool;
1228}
1229extern "C" {
1230    pub fn HAL_FreeDIOPort(dioPortHandle: HAL_DigitalHandle);
1231}
1232extern "C" {
1233    /// Allocates a DO PWM Generator.
1234    ///
1235    /// @return the allocated digital PWM handle
1236    pub fn HAL_AllocateDigitalPWM(status: *mut i32) -> HAL_DigitalPWMHandle;
1237}
1238extern "C" {
1239    /// Frees the resource associated with a DO PWM generator.
1240    ///
1241    /// @param pwmGenerator the digital PWM handle
1242    pub fn HAL_FreeDigitalPWM(pwmGenerator: HAL_DigitalPWMHandle, status: *mut i32);
1243}
1244extern "C" {
1245    /// Changes the frequency of the DO PWM generator.
1246    ///
1247    /// The valid range is from 0.6 Hz to 19 kHz.
1248    ///
1249    ///  The frequency resolution is logarithmic.
1250    ///
1251    /// @param rate the frequency to output all digital output PWM signals
1252    pub fn HAL_SetDigitalPWMRate(rate: f64, status: *mut i32);
1253}
1254extern "C" {
1255    /// Configures the duty-cycle of the PWM generator.
1256    ///
1257    /// @param pwmGenerator the digital PWM handle
1258    /// @param dutyCycle    the percent duty cycle to output [0..1]
1259    pub fn HAL_SetDigitalPWMDutyCycle(
1260        pwmGenerator: HAL_DigitalPWMHandle,
1261        dutyCycle: f64,
1262        status: *mut i32,
1263    );
1264}
1265extern "C" {
1266    /// Configures which DO channel the PWM signal is output on.
1267    ///
1268    /// @param pwmGenerator the digital PWM handle
1269    /// @param channel      the channel to output on
1270    pub fn HAL_SetDigitalPWMOutputChannel(
1271        pwmGenerator: HAL_DigitalPWMHandle,
1272        channel: i32,
1273        status: *mut i32,
1274    );
1275}
1276extern "C" {
1277    /// Writes a digital value to a DIO channel.
1278    ///
1279    /// @param dioPortHandle the digital port handle
1280    /// @param value         the state to set the digital channel (if it is
1281    /// configured as an output)
1282    pub fn HAL_SetDIO(dioPortHandle: HAL_DigitalHandle, value: HAL_Bool, status: *mut i32);
1283}
1284extern "C" {
1285    /// Sets the direction of a DIO channel.
1286    ///
1287    /// @param dioPortHandle the digital port handle
1288    /// @param input         true to set input, false for output
1289    pub fn HAL_SetDIODirection(dioPortHandle: HAL_DigitalHandle, input: HAL_Bool, status: *mut i32);
1290}
1291extern "C" {
1292    /// Reads a digital value from a DIO channel.
1293    ///
1294    /// @param dioPortHandle the digital port handle
1295    /// @return              the state of the specified channel
1296    pub fn HAL_GetDIO(dioPortHandle: HAL_DigitalHandle, status: *mut i32) -> HAL_Bool;
1297}
1298extern "C" {
1299    /// Reads the direction of a DIO channel.
1300    ///
1301    /// @param dioPortHandle the digital port handle
1302    /// @return              true for input, false for output
1303    pub fn HAL_GetDIODirection(dioPortHandle: HAL_DigitalHandle, status: *mut i32) -> HAL_Bool;
1304}
1305extern "C" {
1306    /// Generates a single digital pulse.
1307    ///
1308    /// Write a pulse to the specified digital output channel. There can only be a
1309    /// single pulse going at any time.
1310    ///
1311    /// @param dioPortHandle the digital port handle
1312    /// @param pulseLength   the active length of the pulse (in seconds)
1313    pub fn HAL_Pulse(dioPortHandle: HAL_DigitalHandle, pulseLength: f64, status: *mut i32);
1314}
1315extern "C" {
1316    /// Checks a DIO line to see if it is currently generating a pulse.
1317    ///
1318    /// @return true if a pulse is in progress, otherwise false
1319    pub fn HAL_IsPulsing(dioPortHandle: HAL_DigitalHandle, status: *mut i32) -> HAL_Bool;
1320}
1321extern "C" {
1322    /// Checks if any DIO line is currently generating a pulse.
1323    ///
1324    /// @return true if a pulse on some line is in progress
1325    pub fn HAL_IsAnyPulsing(status: *mut i32) -> HAL_Bool;
1326}
1327extern "C" {
1328    /// Writes the filter index from the FPGA.
1329    ///
1330    /// Set the filter index used to filter out short pulses.
1331    ///
1332    /// @param dioPortHandle the digital port handle
1333    /// @param filterIndex   the filter index (Must be in the range 0 - 3, where 0
1334    /// means "none" and 1 - 3 means filter # filterIndex - 1)
1335    pub fn HAL_SetFilterSelect(
1336        dioPortHandle: HAL_DigitalHandle,
1337        filterIndex: i32,
1338        status: *mut i32,
1339    );
1340}
1341extern "C" {
1342    /// Reads the filter index from the FPGA.
1343    ///
1344    /// Gets the filter index used to filter out short pulses.
1345    ///
1346    /// @param dioPortHandle the digital port handle
1347    /// @return filterIndex  the filter index (Must be in the range 0 - 3,
1348    /// where 0 means "none" and 1 - 3 means filter # filterIndex - 1)
1349    pub fn HAL_GetFilterSelect(dioPortHandle: HAL_DigitalHandle, status: *mut i32) -> i32;
1350}
1351extern "C" {
1352    /// Sets the filter period for the specified filter index.
1353    ///
1354    /// Sets the filter period in FPGA cycles.  Even though there are 2 different
1355    /// filter index domains (MXP vs HDR), ignore that distinction for now since it
1356    /// compilicates the interface.  That can be changed later.
1357    ///
1358    /// @param filterIndex the filter index, 0 - 2
1359    /// @param value       the number of cycles that the signal must not transition
1360    /// to be counted as a transition.
1361    pub fn HAL_SetFilterPeriod(filterIndex: i32, value: i64, status: *mut i32);
1362}
1363extern "C" {
1364    /// Gets the filter period for the specified filter index.
1365    ///
1366    /// Gets the filter period in FPGA cycles.  Even though there are 2 different
1367    /// filter index domains (MXP vs HDR), ignore that distinction for now since it
1368    /// compilicates the interface.  Set status to NiFpga_Status_SoftwareFault if the
1369    /// filter values miss-match.
1370    ///
1371    /// @param filterIndex the filter index, 0 - 2
1372    /// @param value       the number of cycles that the signal must not transition
1373    /// to be counted as a transition.
1374    pub fn HAL_GetFilterPeriod(filterIndex: i32, status: *mut i32) -> i64;
1375}
1376#[repr(C)]
1377#[derive(Debug, Default, Copy, Clone)]
1378pub struct HAL_ControlWord {
1379    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>,
1380    pub __bindgen_align: [u32; 0usize],
1381}
1382#[test]
1383fn bindgen_test_layout_HAL_ControlWord() {
1384    assert_eq!(
1385        ::std::mem::size_of::<HAL_ControlWord>(),
1386        4usize,
1387        concat!("Size of: ", stringify!(HAL_ControlWord))
1388    );
1389    assert_eq!(
1390        ::std::mem::align_of::<HAL_ControlWord>(),
1391        4usize,
1392        concat!("Alignment of ", stringify!(HAL_ControlWord))
1393    );
1394}
1395impl HAL_ControlWord {
1396    #[inline]
1397    pub fn enabled(&self) -> u32 {
1398        unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) }
1399    }
1400    #[inline]
1401    pub fn set_enabled(&mut self, val: u32) {
1402        unsafe {
1403            let val: u32 = ::std::mem::transmute(val);
1404            self._bitfield_1.set(0usize, 1u8, val as u64)
1405        }
1406    }
1407    #[inline]
1408    pub fn autonomous(&self) -> u32 {
1409        unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) }
1410    }
1411    #[inline]
1412    pub fn set_autonomous(&mut self, val: u32) {
1413        unsafe {
1414            let val: u32 = ::std::mem::transmute(val);
1415            self._bitfield_1.set(1usize, 1u8, val as u64)
1416        }
1417    }
1418    #[inline]
1419    pub fn test(&self) -> u32 {
1420        unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) }
1421    }
1422    #[inline]
1423    pub fn set_test(&mut self, val: u32) {
1424        unsafe {
1425            let val: u32 = ::std::mem::transmute(val);
1426            self._bitfield_1.set(2usize, 1u8, val as u64)
1427        }
1428    }
1429    #[inline]
1430    pub fn eStop(&self) -> u32 {
1431        unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) }
1432    }
1433    #[inline]
1434    pub fn set_eStop(&mut self, val: u32) {
1435        unsafe {
1436            let val: u32 = ::std::mem::transmute(val);
1437            self._bitfield_1.set(3usize, 1u8, val as u64)
1438        }
1439    }
1440    #[inline]
1441    pub fn fmsAttached(&self) -> u32 {
1442        unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u32) }
1443    }
1444    #[inline]
1445    pub fn set_fmsAttached(&mut self, val: u32) {
1446        unsafe {
1447            let val: u32 = ::std::mem::transmute(val);
1448            self._bitfield_1.set(4usize, 1u8, val as u64)
1449        }
1450    }
1451    #[inline]
1452    pub fn dsAttached(&self) -> u32 {
1453        unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u32) }
1454    }
1455    #[inline]
1456    pub fn set_dsAttached(&mut self, val: u32) {
1457        unsafe {
1458            let val: u32 = ::std::mem::transmute(val);
1459            self._bitfield_1.set(5usize, 1u8, val as u64)
1460        }
1461    }
1462    #[inline]
1463    pub fn control_reserved(&self) -> u32 {
1464        unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 26u8) as u32) }
1465    }
1466    #[inline]
1467    pub fn set_control_reserved(&mut self, val: u32) {
1468        unsafe {
1469            let val: u32 = ::std::mem::transmute(val);
1470            self._bitfield_1.set(6usize, 26u8, val as u64)
1471        }
1472    }
1473    #[inline]
1474    pub fn new_bitfield_1(
1475        enabled: u32,
1476        autonomous: u32,
1477        test: u32,
1478        eStop: u32,
1479        fmsAttached: u32,
1480        dsAttached: u32,
1481        control_reserved: u32,
1482    ) -> __BindgenBitfieldUnit<[u8; 4usize], u32> {
1483        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize], u32> =
1484            Default::default();
1485        __bindgen_bitfield_unit.set(0usize, 1u8, {
1486            let enabled: u32 = unsafe { ::std::mem::transmute(enabled) };
1487            enabled as u64
1488        });
1489        __bindgen_bitfield_unit.set(1usize, 1u8, {
1490            let autonomous: u32 = unsafe { ::std::mem::transmute(autonomous) };
1491            autonomous as u64
1492        });
1493        __bindgen_bitfield_unit.set(2usize, 1u8, {
1494            let test: u32 = unsafe { ::std::mem::transmute(test) };
1495            test as u64
1496        });
1497        __bindgen_bitfield_unit.set(3usize, 1u8, {
1498            let eStop: u32 = unsafe { ::std::mem::transmute(eStop) };
1499            eStop as u64
1500        });
1501        __bindgen_bitfield_unit.set(4usize, 1u8, {
1502            let fmsAttached: u32 = unsafe { ::std::mem::transmute(fmsAttached) };
1503            fmsAttached as u64
1504        });
1505        __bindgen_bitfield_unit.set(5usize, 1u8, {
1506            let dsAttached: u32 = unsafe { ::std::mem::transmute(dsAttached) };
1507            dsAttached as u64
1508        });
1509        __bindgen_bitfield_unit.set(6usize, 26u8, {
1510            let control_reserved: u32 = unsafe { ::std::mem::transmute(control_reserved) };
1511            control_reserved as u64
1512        });
1513        __bindgen_bitfield_unit
1514    }
1515}
1516pub mod HAL_AllianceStationID {
1517    pub type Type = i32;
1518    pub const kRed1: Type = 0;
1519    pub const kRed2: Type = 1;
1520    pub const kRed3: Type = 2;
1521    pub const kBlue1: Type = 3;
1522    pub const kBlue2: Type = 4;
1523    pub const kBlue3: Type = 5;
1524}
1525pub mod HAL_MatchType {
1526    pub type Type = i32;
1527    pub const HAL_kMatchType_none: Type = 0;
1528    pub const HAL_kMatchType_practice: Type = 1;
1529    pub const HAL_kMatchType_qualification: Type = 2;
1530    pub const HAL_kMatchType_elimination: Type = 3;
1531}
1532#[repr(C)]
1533#[derive(Debug, Default, Copy, Clone)]
1534pub struct HAL_JoystickAxes {
1535    pub count: i16,
1536    pub axes: [f32; 12usize],
1537}
1538#[test]
1539fn bindgen_test_layout_HAL_JoystickAxes() {
1540    assert_eq!(
1541        ::std::mem::size_of::<HAL_JoystickAxes>(),
1542        52usize,
1543        concat!("Size of: ", stringify!(HAL_JoystickAxes))
1544    );
1545    assert_eq!(
1546        ::std::mem::align_of::<HAL_JoystickAxes>(),
1547        4usize,
1548        concat!("Alignment of ", stringify!(HAL_JoystickAxes))
1549    );
1550    assert_eq!(
1551        unsafe { &(*(::std::ptr::null::<HAL_JoystickAxes>())).count as *const _ as usize },
1552        0usize,
1553        concat!(
1554            "Offset of field: ",
1555            stringify!(HAL_JoystickAxes),
1556            "::",
1557            stringify!(count)
1558        )
1559    );
1560    assert_eq!(
1561        unsafe { &(*(::std::ptr::null::<HAL_JoystickAxes>())).axes as *const _ as usize },
1562        4usize,
1563        concat!(
1564            "Offset of field: ",
1565            stringify!(HAL_JoystickAxes),
1566            "::",
1567            stringify!(axes)
1568        )
1569    );
1570}
1571#[repr(C)]
1572#[derive(Debug, Default, Copy, Clone)]
1573pub struct HAL_JoystickPOVs {
1574    pub count: i16,
1575    pub povs: [i16; 12usize],
1576}
1577#[test]
1578fn bindgen_test_layout_HAL_JoystickPOVs() {
1579    assert_eq!(
1580        ::std::mem::size_of::<HAL_JoystickPOVs>(),
1581        26usize,
1582        concat!("Size of: ", stringify!(HAL_JoystickPOVs))
1583    );
1584    assert_eq!(
1585        ::std::mem::align_of::<HAL_JoystickPOVs>(),
1586        2usize,
1587        concat!("Alignment of ", stringify!(HAL_JoystickPOVs))
1588    );
1589    assert_eq!(
1590        unsafe { &(*(::std::ptr::null::<HAL_JoystickPOVs>())).count as *const _ as usize },
1591        0usize,
1592        concat!(
1593            "Offset of field: ",
1594            stringify!(HAL_JoystickPOVs),
1595            "::",
1596            stringify!(count)
1597        )
1598    );
1599    assert_eq!(
1600        unsafe { &(*(::std::ptr::null::<HAL_JoystickPOVs>())).povs as *const _ as usize },
1601        2usize,
1602        concat!(
1603            "Offset of field: ",
1604            stringify!(HAL_JoystickPOVs),
1605            "::",
1606            stringify!(povs)
1607        )
1608    );
1609}
1610#[repr(C)]
1611#[derive(Debug, Default, Copy, Clone)]
1612pub struct HAL_JoystickButtons {
1613    pub buttons: u32,
1614    pub count: u8,
1615}
1616#[test]
1617fn bindgen_test_layout_HAL_JoystickButtons() {
1618    assert_eq!(
1619        ::std::mem::size_of::<HAL_JoystickButtons>(),
1620        8usize,
1621        concat!("Size of: ", stringify!(HAL_JoystickButtons))
1622    );
1623    assert_eq!(
1624        ::std::mem::align_of::<HAL_JoystickButtons>(),
1625        4usize,
1626        concat!("Alignment of ", stringify!(HAL_JoystickButtons))
1627    );
1628    assert_eq!(
1629        unsafe { &(*(::std::ptr::null::<HAL_JoystickButtons>())).buttons as *const _ as usize },
1630        0usize,
1631        concat!(
1632            "Offset of field: ",
1633            stringify!(HAL_JoystickButtons),
1634            "::",
1635            stringify!(buttons)
1636        )
1637    );
1638    assert_eq!(
1639        unsafe { &(*(::std::ptr::null::<HAL_JoystickButtons>())).count as *const _ as usize },
1640        4usize,
1641        concat!(
1642            "Offset of field: ",
1643            stringify!(HAL_JoystickButtons),
1644            "::",
1645            stringify!(count)
1646        )
1647    );
1648}
1649#[repr(C)]
1650#[derive(Copy, Clone)]
1651pub struct HAL_JoystickDescriptor {
1652    pub isXbox: u8,
1653    pub type_: u8,
1654    pub name: [::std::os::raw::c_char; 256usize],
1655    pub axisCount: u8,
1656    pub axisTypes: [u8; 12usize],
1657    pub buttonCount: u8,
1658    pub povCount: u8,
1659}
1660#[test]
1661fn bindgen_test_layout_HAL_JoystickDescriptor() {
1662    assert_eq!(
1663        ::std::mem::size_of::<HAL_JoystickDescriptor>(),
1664        273usize,
1665        concat!("Size of: ", stringify!(HAL_JoystickDescriptor))
1666    );
1667    assert_eq!(
1668        ::std::mem::align_of::<HAL_JoystickDescriptor>(),
1669        1usize,
1670        concat!("Alignment of ", stringify!(HAL_JoystickDescriptor))
1671    );
1672    assert_eq!(
1673        unsafe { &(*(::std::ptr::null::<HAL_JoystickDescriptor>())).isXbox as *const _ as usize },
1674        0usize,
1675        concat!(
1676            "Offset of field: ",
1677            stringify!(HAL_JoystickDescriptor),
1678            "::",
1679            stringify!(isXbox)
1680        )
1681    );
1682    assert_eq!(
1683        unsafe { &(*(::std::ptr::null::<HAL_JoystickDescriptor>())).type_ as *const _ as usize },
1684        1usize,
1685        concat!(
1686            "Offset of field: ",
1687            stringify!(HAL_JoystickDescriptor),
1688            "::",
1689            stringify!(type_)
1690        )
1691    );
1692    assert_eq!(
1693        unsafe { &(*(::std::ptr::null::<HAL_JoystickDescriptor>())).name as *const _ as usize },
1694        2usize,
1695        concat!(
1696            "Offset of field: ",
1697            stringify!(HAL_JoystickDescriptor),
1698            "::",
1699            stringify!(name)
1700        )
1701    );
1702    assert_eq!(
1703        unsafe {
1704            &(*(::std::ptr::null::<HAL_JoystickDescriptor>())).axisCount as *const _ as usize
1705        },
1706        258usize,
1707        concat!(
1708            "Offset of field: ",
1709            stringify!(HAL_JoystickDescriptor),
1710            "::",
1711            stringify!(axisCount)
1712        )
1713    );
1714    assert_eq!(
1715        unsafe {
1716            &(*(::std::ptr::null::<HAL_JoystickDescriptor>())).axisTypes as *const _ as usize
1717        },
1718        259usize,
1719        concat!(
1720            "Offset of field: ",
1721            stringify!(HAL_JoystickDescriptor),
1722            "::",
1723            stringify!(axisTypes)
1724        )
1725    );
1726    assert_eq!(
1727        unsafe {
1728            &(*(::std::ptr::null::<HAL_JoystickDescriptor>())).buttonCount as *const _ as usize
1729        },
1730        271usize,
1731        concat!(
1732            "Offset of field: ",
1733            stringify!(HAL_JoystickDescriptor),
1734            "::",
1735            stringify!(buttonCount)
1736        )
1737    );
1738    assert_eq!(
1739        unsafe { &(*(::std::ptr::null::<HAL_JoystickDescriptor>())).povCount as *const _ as usize },
1740        272usize,
1741        concat!(
1742            "Offset of field: ",
1743            stringify!(HAL_JoystickDescriptor),
1744            "::",
1745            stringify!(povCount)
1746        )
1747    );
1748}
1749impl Default for HAL_JoystickDescriptor {
1750    fn default() -> Self {
1751        unsafe { ::std::mem::zeroed() }
1752    }
1753}
1754#[repr(C)]
1755#[derive(Copy, Clone)]
1756pub struct HAL_MatchInfo {
1757    pub eventName: [::std::os::raw::c_char; 64usize],
1758    pub matchType: HAL_MatchType::Type,
1759    pub matchNumber: u16,
1760    pub replayNumber: u8,
1761    pub gameSpecificMessage: [u8; 64usize],
1762    pub gameSpecificMessageSize: u16,
1763}
1764#[test]
1765fn bindgen_test_layout_HAL_MatchInfo() {
1766    assert_eq!(
1767        ::std::mem::size_of::<HAL_MatchInfo>(),
1768        140usize,
1769        concat!("Size of: ", stringify!(HAL_MatchInfo))
1770    );
1771    assert_eq!(
1772        ::std::mem::align_of::<HAL_MatchInfo>(),
1773        4usize,
1774        concat!("Alignment of ", stringify!(HAL_MatchInfo))
1775    );
1776    assert_eq!(
1777        unsafe { &(*(::std::ptr::null::<HAL_MatchInfo>())).eventName as *const _ as usize },
1778        0usize,
1779        concat!(
1780            "Offset of field: ",
1781            stringify!(HAL_MatchInfo),
1782            "::",
1783            stringify!(eventName)
1784        )
1785    );
1786    assert_eq!(
1787        unsafe { &(*(::std::ptr::null::<HAL_MatchInfo>())).matchType as *const _ as usize },
1788        64usize,
1789        concat!(
1790            "Offset of field: ",
1791            stringify!(HAL_MatchInfo),
1792            "::",
1793            stringify!(matchType)
1794        )
1795    );
1796    assert_eq!(
1797        unsafe { &(*(::std::ptr::null::<HAL_MatchInfo>())).matchNumber as *const _ as usize },
1798        68usize,
1799        concat!(
1800            "Offset of field: ",
1801            stringify!(HAL_MatchInfo),
1802            "::",
1803            stringify!(matchNumber)
1804        )
1805    );
1806    assert_eq!(
1807        unsafe { &(*(::std::ptr::null::<HAL_MatchInfo>())).replayNumber as *const _ as usize },
1808        70usize,
1809        concat!(
1810            "Offset of field: ",
1811            stringify!(HAL_MatchInfo),
1812            "::",
1813            stringify!(replayNumber)
1814        )
1815    );
1816    assert_eq!(
1817        unsafe {
1818            &(*(::std::ptr::null::<HAL_MatchInfo>())).gameSpecificMessage as *const _ as usize
1819        },
1820        71usize,
1821        concat!(
1822            "Offset of field: ",
1823            stringify!(HAL_MatchInfo),
1824            "::",
1825            stringify!(gameSpecificMessage)
1826        )
1827    );
1828    assert_eq!(
1829        unsafe {
1830            &(*(::std::ptr::null::<HAL_MatchInfo>())).gameSpecificMessageSize as *const _ as usize
1831        },
1832        136usize,
1833        concat!(
1834            "Offset of field: ",
1835            stringify!(HAL_MatchInfo),
1836            "::",
1837            stringify!(gameSpecificMessageSize)
1838        )
1839    );
1840}
1841impl Default for HAL_MatchInfo {
1842    fn default() -> Self {
1843        unsafe { ::std::mem::zeroed() }
1844    }
1845}
1846extern "C" {
1847    /// Sends an error to the driver station.
1848    ///
1849    /// @param isError   true for error, false for warning
1850    /// @param errorCode the error code
1851    /// @param isLVCode  true for a LV error code, false for a standard error code
1852    /// @param details   the details of the error
1853    /// @param location  the file location of the errror
1854    /// @param callstack the callstack of the error
1855    /// @param printMsg  true to print the error message to stdout as well as to the
1856    /// DS
1857    pub fn HAL_SendError(
1858        isError: HAL_Bool,
1859        errorCode: i32,
1860        isLVCode: HAL_Bool,
1861        details: *const ::std::os::raw::c_char,
1862        location: *const ::std::os::raw::c_char,
1863        callStack: *const ::std::os::raw::c_char,
1864        printMsg: HAL_Bool,
1865    ) -> i32;
1866}
1867extern "C" {
1868    /// Gets the current control word of the driver station.
1869    ///
1870    /// The control work contains the robot state.
1871    ///
1872    /// @param controlWord the control word (out)
1873    /// @return            the error code, or 0 for success
1874    pub fn HAL_GetControlWord(controlWord: *mut HAL_ControlWord) -> i32;
1875}
1876extern "C" {
1877    /// Gets the current alliance station ID.
1878    ///
1879    /// @param status the error code, or 0 for success
1880    /// @return       the alliance station ID
1881    pub fn HAL_GetAllianceStation(status: *mut i32) -> HAL_AllianceStationID::Type;
1882}
1883extern "C" {
1884    /// Gets the axes of a specific joystick.
1885    ///
1886    /// @param joystickNum the joystick number
1887    /// @param axes        the axes values (output)
1888    /// @return            the error code, or 0 for success
1889    pub fn HAL_GetJoystickAxes(joystickNum: i32, axes: *mut HAL_JoystickAxes) -> i32;
1890}
1891extern "C" {
1892    /// Gets the POVs of a specific joystick.
1893    ///
1894    /// @param joystickNum the joystick number
1895    /// @param povs        the POV values (output)
1896    /// @return            the error code, or 0 for success
1897    pub fn HAL_GetJoystickPOVs(joystickNum: i32, povs: *mut HAL_JoystickPOVs) -> i32;
1898}
1899extern "C" {
1900    /// Gets the buttons of a specific joystick.
1901    ///
1902    /// @param joystickNum the joystick number
1903    /// @param buttons     the button values (output)
1904    /// @return            the error code, or 0 for success
1905    pub fn HAL_GetJoystickButtons(joystickNum: i32, buttons: *mut HAL_JoystickButtons) -> i32;
1906}
1907extern "C" {
1908    /// Retrieves the Joystick Descriptor for particular slot.
1909    ///
1910    /// @param desc [out] descriptor (data transfer object) to fill in.  desc is
1911    /// filled in regardless of success. In other words, if descriptor is not
1912    /// available, desc is filled in with default values matching the init-values in
1913    /// Java and C++ Driverstation for when caller requests a too-large joystick
1914    /// index.
1915    ///
1916    /// @return error code reported from Network Comm back-end.  Zero is good,
1917    /// nonzero is bad.
1918    pub fn HAL_GetJoystickDescriptor(joystickNum: i32, desc: *mut HAL_JoystickDescriptor) -> i32;
1919}
1920extern "C" {
1921    /// Gets is a specific joystick is considered to be an XBox controller.
1922    ///
1923    /// @param joystickNum the joystick number
1924    /// @return            true if xbox, false otherwise
1925    pub fn HAL_GetJoystickIsXbox(joystickNum: i32) -> HAL_Bool;
1926}
1927extern "C" {
1928    /// Gets the type of joystick connected.
1929    ///
1930    /// This is device specific, and different depending on what system input type
1931    /// the joystick uses.
1932    ///
1933    /// @param joystickNum the joystick number
1934    /// @return            the enumerated joystick type
1935    pub fn HAL_GetJoystickType(joystickNum: i32) -> i32;
1936}
1937extern "C" {
1938    /// Gets the name of a joystick.
1939    ///
1940    /// The returned array must be freed with HAL_FreeJoystickName.
1941    ///
1942    /// Will be null terminated.
1943    ///
1944    /// @param joystickNum the joystick number
1945    /// @return            the joystick name
1946    pub fn HAL_GetJoystickName(joystickNum: i32) -> *mut ::std::os::raw::c_char;
1947}
1948extern "C" {
1949    /// Frees a joystick name received with HAL_GetJoystickName
1950    ///
1951    /// @param name the name storage
1952    pub fn HAL_FreeJoystickName(name: *mut ::std::os::raw::c_char);
1953}
1954extern "C" {
1955    /// Gets the type of a specific joystick axis.
1956    ///
1957    /// This is device specific, and different depending on what system input type
1958    /// the joystick uses.
1959    ///
1960    /// @param joystickNum the joystick number
1961    /// @param axis        the axis number
1962    /// @return            the enumerated axis type
1963    pub fn HAL_GetJoystickAxisType(joystickNum: i32, axis: i32) -> i32;
1964}
1965extern "C" {
1966    /// Set joystick outputs.
1967    ///
1968    /// @param joystickNum the joystick numer
1969    /// @param outputs     bitmask of outputs, 1 for on 0 for off
1970    /// @param leftRumble  the left rumble value (0-FFFF)
1971    /// @param rightRumble the right rumble value (0-FFFF)
1972    /// @return            the error code, or 0 for success
1973    pub fn HAL_SetJoystickOutputs(
1974        joystickNum: i32,
1975        outputs: i64,
1976        leftRumble: i32,
1977        rightRumble: i32,
1978    ) -> i32;
1979}
1980extern "C" {
1981    /// Returns the approximate match time.
1982    ///
1983    /// The FMS does not send an official match time to the robots, but does send
1984    /// an approximate match time. The value will count down the time remaining in
1985    /// the current period (auto or teleop).
1986    ///
1987    /// Warning: This is not an official time (so it cannot be used to dispute ref
1988    /// calls or guarantee that a function will trigger before the match ends).
1989    ///
1990    /// The Practice Match function of the DS approximates the behaviour seen on
1991    /// the field.
1992    ///
1993    /// @param status the error code, or 0 for success
1994    /// @return time remaining in current match period (auto or teleop)
1995    pub fn HAL_GetMatchTime(status: *mut i32) -> f64;
1996}
1997extern "C" {
1998    /// Gets info about a specific match.
1999    ///
2000    /// @param info the match info (output)
2001    /// @return     the error code, or 0 for success
2002    pub fn HAL_GetMatchInfo(info: *mut HAL_MatchInfo) -> i32;
2003}
2004extern "C" {
2005    /// Releases the DS Mutex to allow proper shutdown of any threads that are
2006    /// waiting on it.
2007    pub fn HAL_ReleaseDSMutex();
2008}
2009extern "C" {
2010    /// Has a new control packet from the driver station arrived since the last
2011    /// time this function was called?
2012    ///
2013    /// @return true if the control data has been updated since the last call
2014    pub fn HAL_IsNewControlData() -> HAL_Bool;
2015}
2016extern "C" {
2017    /// Waits for the newest DS packet to arrive. Note that this is a blocking call.
2018    pub fn HAL_WaitForDSData();
2019}
2020extern "C" {
2021    /// Waits for the newest DS packet to arrive. If timeout is <= 0, this will wait
2022    /// forever. Otherwise, it will wait until either a new packet, or the timeout
2023    /// time has passed.
2024    ///
2025    /// @param timeout timeout in seconds
2026    /// @return        true for new data, false for timeout
2027    pub fn HAL_WaitForDSDataTimeout(timeout: f64) -> HAL_Bool;
2028}
2029extern "C" {
2030    /// Initializes the driver station communication. This will properly
2031    /// handle multiple calls. However note that this CANNOT be called from a library
2032    /// that interfaces with LabVIEW.
2033    pub fn HAL_InitializeDriverStation();
2034}
2035extern "C" {
2036    /// Sets the program starting flag in the DS.
2037    ///
2038    /// This is what changes the DS to showing robot code ready.
2039    pub fn HAL_ObserveUserProgramStarting();
2040}
2041extern "C" {
2042    /// Sets the disabled flag in the DS.
2043    ///
2044    /// This is used for the DS to ensure the robot is properly responding to its
2045    /// state request. Ensure this get called about every 50ms, or the robot will be
2046    /// disabled by the DS.
2047    pub fn HAL_ObserveUserProgramDisabled();
2048}
2049extern "C" {
2050    /// Sets the autonomous enabled flag in the DS.
2051    ///
2052    /// This is used for the DS to ensure the robot is properly responding to its
2053    /// state request. Ensure this get called about every 50ms, or the robot will be
2054    /// disabled by the DS.
2055    pub fn HAL_ObserveUserProgramAutonomous();
2056}
2057extern "C" {
2058    /// Sets the teleoperated enabled flag in the DS.
2059    ///
2060    /// This is used for the DS to ensure the robot is properly responding to its
2061    /// state request. Ensure this get called about every 50ms, or the robot will be
2062    /// disabled by the DS.
2063    pub fn HAL_ObserveUserProgramTeleop();
2064}
2065extern "C" {
2066    /// Sets the test mode flag in the DS.
2067    ///
2068    /// This is used for the DS to ensure the robot is properly responding to its
2069    /// state request. Ensure this get called about every 50ms, or the robot will be
2070    /// disabled by the DS.
2071    pub fn HAL_ObserveUserProgramTest();
2072}
2073pub mod HAL_I2CPort {
2074    /// @defgroup hal_i2c I2C Functions
2075    /// @ingroup hal_capi
2076    /// @{
2077    pub type Type = i32;
2078    pub const HAL_I2C_kInvalid: Type = -1;
2079    pub const HAL_I2C_kOnboard: Type = 0;
2080    pub const HAL_I2C_kMXP: Type = 1;
2081}
2082extern "C" {
2083    /// Initializes the I2C port.
2084    ///
2085    /// Opens the port if necessary and saves the handle.
2086    /// If opening the MXP port, also sets up the channel functions appropriately.
2087    ///
2088    /// @param port The port to open, 0 for the on-board, 1 for the MXP.
2089    pub fn HAL_InitializeI2C(port: HAL_I2CPort::Type, status: *mut i32);
2090}
2091extern "C" {
2092    /// Generic I2C read/write transaction.
2093    ///
2094    /// This is a lower-level interface to the I2C hardware giving you more control
2095    /// over each transaction.
2096    ///
2097    /// @param port The I2C port, 0 for the on-board, 1 for the MXP.
2098    /// @param dataToSend Buffer of data to send as part of the transaction.
2099    /// @param sendSize Number of bytes to send as part of the transaction.
2100    /// @param dataReceived Buffer to read data into.
2101    /// @param receiveSize Number of bytes to read from the device.
2102    /// @return >= 0 on success or -1 on transfer abort.
2103    pub fn HAL_TransactionI2C(
2104        port: HAL_I2CPort::Type,
2105        deviceAddress: i32,
2106        dataToSend: *const u8,
2107        sendSize: i32,
2108        dataReceived: *mut u8,
2109        receiveSize: i32,
2110    ) -> i32;
2111}
2112extern "C" {
2113    /// Executes a write transaction with the device.
2114    ///
2115    /// Writes a single byte to a register on a device and wait until the
2116    ///   transaction is complete.
2117    ///
2118    /// @param port The I2C port, 0 for the on-board, 1 for the MXP.
2119    /// @param registerAddress The address of the register on the device to be
2120    /// written.
2121    /// @param data The byte to write to the register on the device.
2122    /// @return >= 0 on success or -1 on transfer abort.
2123    pub fn HAL_WriteI2C(
2124        port: HAL_I2CPort::Type,
2125        deviceAddress: i32,
2126        dataToSend: *const u8,
2127        sendSize: i32,
2128    ) -> i32;
2129}
2130extern "C" {
2131    /// Executes a read transaction with the device.
2132    ///
2133    /// Reads bytes from a device.
2134    /// Most I2C devices will auto-increment the register pointer internally allowing
2135    ///   you to read consecutive registers on a device in a single transaction.
2136    ///
2137    /// @param port The I2C port, 0 for the on-board, 1 for the MXP.
2138    /// @param registerAddress The register to read first in the transaction.
2139    /// @param count The number of bytes to read in the transaction.
2140    /// @param buffer A pointer to the array of bytes to store the data read from the
2141    /// device.
2142    /// @return >= 0 on success or -1 on transfer abort.
2143    pub fn HAL_ReadI2C(
2144        port: HAL_I2CPort::Type,
2145        deviceAddress: i32,
2146        buffer: *mut u8,
2147        count: i32,
2148    ) -> i32;
2149}
2150extern "C" {
2151    /// Closes an I2C port
2152    ///
2153    /// @param port The I2C port, 0 for the on-board, 1 for the MXP.
2154    pub fn HAL_CloseI2C(port: HAL_I2CPort::Type);
2155}
2156pub type HAL_InterruptHandlerFunction = ::std::option::Option<
2157    unsafe extern "C" fn(interruptAssertedMask: u32, param: *mut ::std::os::raw::c_void),
2158>;
2159extern "C" {
2160    /// Initializes an interrupt.
2161    ///
2162    /// @param watcher true for synchronous interrupts, false for asynchronous
2163    /// @return        the created interrupt handle
2164    pub fn HAL_InitializeInterrupts(watcher: HAL_Bool, status: *mut i32) -> HAL_InterruptHandle;
2165}
2166extern "C" {
2167    /// Frees an interrupt.
2168    ///
2169    /// @param interruptHandle the interrupt handle
2170    /// @return                the param passed to the interrupt, or nullptr if one
2171    /// wasn't passed.
2172    pub fn HAL_CleanInterrupts(
2173        interruptHandle: HAL_InterruptHandle,
2174        status: *mut i32,
2175    ) -> *mut ::std::os::raw::c_void;
2176}
2177extern "C" {
2178    /// In synchronous mode, waits for the defined interrupt to occur.
2179    ///
2180    /// @param interruptHandle the interrupt handle
2181    /// @param timeout        timeout in seconds
2182    /// @param ignorePrevious if true, ignore interrupts that happened before
2183    /// waitForInterrupt was called
2184    /// @return               the mask of interrupts that fired
2185    pub fn HAL_WaitForInterrupt(
2186        interruptHandle: HAL_InterruptHandle,
2187        timeout: f64,
2188        ignorePrevious: HAL_Bool,
2189        status: *mut i32,
2190    ) -> i64;
2191}
2192extern "C" {
2193    /// Enables interrupts to occur on this input.
2194    ///
2195    /// Interrupts are disabled when the RequestInterrupt call is made. This gives
2196    /// time to do the setup of the other options before starting to field
2197    /// interrupts.
2198    ///
2199    /// @param interruptHandle the interrupt handle
2200    pub fn HAL_EnableInterrupts(interruptHandle: HAL_InterruptHandle, status: *mut i32);
2201}
2202extern "C" {
2203    /// Disables interrupts without without deallocating structures.
2204    ///
2205    /// @param interruptHandle the interrupt handle
2206    pub fn HAL_DisableInterrupts(interruptHandle: HAL_InterruptHandle, status: *mut i32);
2207}
2208extern "C" {
2209    /// Returns the timestamp for the rising interrupt that occurred most recently.
2210    ///
2211    /// This is in the same time domain as HAL_GetFPGATime().  It only contains the
2212    /// bottom 32 bits of the timestamp.  If your robot has been running for over 1
2213    /// hour, you will need to fill in the upper 32 bits yourself.
2214    ///
2215    /// @param interruptHandle the interrupt handle
2216    /// @return                timestamp in microseconds since FPGA Initialization
2217    pub fn HAL_ReadInterruptRisingTimestamp(
2218        interruptHandle: HAL_InterruptHandle,
2219        status: *mut i32,
2220    ) -> i64;
2221}
2222extern "C" {
2223    /// Returns the timestamp for the falling interrupt that occurred most recently.
2224    ///
2225    /// This is in the same time domain as HAL_GetFPGATime().  It only contains the
2226    /// bottom 32 bits of the timestamp.  If your robot has been running for over 1
2227    /// hour, you will need to fill in the upper 32 bits yourself.
2228    ///
2229    /// @param interruptHandle the interrupt handle
2230    /// @return                timestamp in microseconds since FPGA Initialization
2231    pub fn HAL_ReadInterruptFallingTimestamp(
2232        interruptHandle: HAL_InterruptHandle,
2233        status: *mut i32,
2234    ) -> i64;
2235}
2236extern "C" {
2237    /// Requests interrupts on a specific digital source.
2238    ///
2239    /// @param interruptHandle     the interrupt handle
2240    /// @param digitalSourceHandle the digital source handle (either a
2241    /// HAL_AnalogTriggerHandle of a HAL_DigitalHandle)
2242    /// @param analogTriggerType   the trigger type if the source is an AnalogTrigger
2243    pub fn HAL_RequestInterrupts(
2244        interruptHandle: HAL_InterruptHandle,
2245        digitalSourceHandle: HAL_Handle,
2246        analogTriggerType: HAL_AnalogTriggerType::Type,
2247        status: *mut i32,
2248    );
2249}
2250extern "C" {
2251    /// Attaches an asynchronous interrupt handler to the interrupt.
2252    ///
2253    /// This interrupt gets called directly on the FPGA interrupt thread, so will
2254    /// block other interrupts while running.
2255    ///
2256    /// @param interruptHandle the interrupt handle
2257    /// @param handler         the handler function for the interrupt to call
2258    /// @param param           a parameter to be passed to the handler
2259    pub fn HAL_AttachInterruptHandler(
2260        interruptHandle: HAL_InterruptHandle,
2261        handler: HAL_InterruptHandlerFunction,
2262        param: *mut ::std::os::raw::c_void,
2263        status: *mut i32,
2264    );
2265}
2266extern "C" {
2267    /// Attaches an asynchronous interrupt handler to the interrupt.
2268    ///
2269    /// This interrupt gets called on a thread specific to the interrupt, so will not
2270    /// block other interrupts.
2271    ///
2272    /// @param interruptHandle the interrupt handle
2273    /// @param handler         the handler function for the interrupt to call
2274    /// @param param           a parameter to be passed to the handler
2275    pub fn HAL_AttachInterruptHandlerThreaded(
2276        interruptHandle: HAL_InterruptHandle,
2277        handler: HAL_InterruptHandlerFunction,
2278        param: *mut ::std::os::raw::c_void,
2279        status: *mut i32,
2280    );
2281}
2282extern "C" {
2283    /// Sets the edges to trigger the interrupt on.
2284    ///
2285    /// Note that both edges triggered is a valid configuration.
2286    ///
2287    /// @param interruptHandle the interrupt handle
2288    /// @param risingEdge      true for triggering on rising edge
2289    /// @param fallingEdge     true for triggering on falling edge
2290    pub fn HAL_SetInterruptUpSourceEdge(
2291        interruptHandle: HAL_InterruptHandle,
2292        risingEdge: HAL_Bool,
2293        fallingEdge: HAL_Bool,
2294        status: *mut i32,
2295    );
2296}
2297extern "C" {
2298    /// Initializes a notifier.
2299    ///
2300    /// A notifier is an FPGA controller timer that triggers at requested intervals
2301    /// based on the FPGA time. This can be used to make precise control loops.
2302    ///
2303    /// @return the created notifier
2304    pub fn HAL_InitializeNotifier(status: *mut i32) -> HAL_NotifierHandle;
2305}
2306extern "C" {
2307    /// Stops a notifier from running.
2308    ///
2309    /// This will cause any call into HAL_WaitForNotifierAlarm to return.
2310    ///
2311    /// @param notifierHandle the notifier handle
2312    pub fn HAL_StopNotifier(notifierHandle: HAL_NotifierHandle, status: *mut i32);
2313}
2314extern "C" {
2315    /// Cleans a notifier.
2316    ///
2317    /// Note this also stops a notifier if it is already running.
2318    ///
2319    /// @param notifierHandle the notifier handle
2320    pub fn HAL_CleanNotifier(notifierHandle: HAL_NotifierHandle, status: *mut i32);
2321}
2322extern "C" {
2323    /// Updates the trigger time for a notifier.
2324    ///
2325    /// Note that this time is an absolute time relative to HAL_GetFPGATime()
2326    ///
2327    /// @param notifierHandle the notifier handle
2328    /// @param triggerTime    the updated trigger time
2329    pub fn HAL_UpdateNotifierAlarm(
2330        notifierHandle: HAL_NotifierHandle,
2331        triggerTime: u64,
2332        status: *mut i32,
2333    );
2334}
2335extern "C" {
2336    /// Cancels the next notifier alarm.
2337    ///
2338    /// This does not cause HAL_WaitForNotifierAlarm to return.
2339    ///
2340    /// @param notifierHandle the notifier handle
2341    pub fn HAL_CancelNotifierAlarm(notifierHandle: HAL_NotifierHandle, status: *mut i32);
2342}
2343extern "C" {
2344    /// Waits for the next alarm for the specific notifier.
2345    ///
2346    /// This is a blocking call until either the time elapses or HAL_StopNotifier
2347    /// gets called.
2348    ///
2349    /// @param notifierHandle the notifier handle
2350    /// @return               the FPGA time the notifier returned
2351    pub fn HAL_WaitForNotifierAlarm(notifierHandle: HAL_NotifierHandle, status: *mut i32) -> u64;
2352}
2353extern "C" {
2354    /// Initializes a Power Distribution Panel.
2355    ///
2356    /// @param  module the module number to initialize
2357    /// @return the created PDP
2358    pub fn HAL_InitializePDP(module: i32, status: *mut i32) -> HAL_PDPHandle;
2359}
2360extern "C" {
2361    /// Cleans a PDP module.
2362    ///
2363    /// @param handle the module handle
2364    pub fn HAL_CleanPDP(handle: HAL_PDPHandle);
2365}
2366extern "C" {
2367    /// Checks if a PDP channel is valid.
2368    ///
2369    /// @param channel the channel to check
2370    /// @return        true if the channel is valid, otherwise false
2371    pub fn HAL_CheckPDPChannel(channel: i32) -> HAL_Bool;
2372}
2373extern "C" {
2374    /// Checks if a PDP module is valid.
2375    ///
2376    /// @param channel the module to check
2377    /// @return        true if the module is valid, otherwise false
2378    pub fn HAL_CheckPDPModule(module: i32) -> HAL_Bool;
2379}
2380extern "C" {
2381    /// Gets the temperature of the PDP.
2382    ///
2383    /// @param handle the module handle
2384    /// @return       the module temperature (celsius)
2385    pub fn HAL_GetPDPTemperature(handle: HAL_PDPHandle, status: *mut i32) -> f64;
2386}
2387extern "C" {
2388    /// Gets the PDP input voltage.
2389    ///
2390    /// @param handle the module handle
2391    /// @return       the input voltage (volts)
2392    pub fn HAL_GetPDPVoltage(handle: HAL_PDPHandle, status: *mut i32) -> f64;
2393}
2394extern "C" {
2395    /// Gets the current of a specific PDP channel.
2396    ///
2397    /// @param module  the module
2398    /// @param channel the channel
2399    /// @return        the channel current (amps)
2400    pub fn HAL_GetPDPChannelCurrent(handle: HAL_PDPHandle, channel: i32, status: *mut i32) -> f64;
2401}
2402extern "C" {
2403    /// Gets the total current of the PDP.
2404    ///
2405    /// @param handle the module handle
2406    /// @return       the total current (amps)
2407    pub fn HAL_GetPDPTotalCurrent(handle: HAL_PDPHandle, status: *mut i32) -> f64;
2408}
2409extern "C" {
2410    /// Gets the total power of the PDP.
2411    ///
2412    /// @param handle the module handle
2413    /// @return       the total power (watts)
2414    pub fn HAL_GetPDPTotalPower(handle: HAL_PDPHandle, status: *mut i32) -> f64;
2415}
2416extern "C" {
2417    /// Gets the total energy of the PDP.
2418    ///
2419    /// @param handle the module handle
2420    /// @return       the total energy (joules)
2421    pub fn HAL_GetPDPTotalEnergy(handle: HAL_PDPHandle, status: *mut i32) -> f64;
2422}
2423extern "C" {
2424    /// Resets the PDP accumulated energy.
2425    ///
2426    /// @param handle the module handle
2427    pub fn HAL_ResetPDPTotalEnergy(handle: HAL_PDPHandle, status: *mut i32);
2428}
2429extern "C" {
2430    /// Clears any PDP sticky faults.
2431    ///
2432    /// @param handle the module handle
2433    pub fn HAL_ClearPDPStickyFaults(handle: HAL_PDPHandle, status: *mut i32);
2434}
2435extern "C" {
2436    /// Initializes a PWM port.
2437    ///
2438    /// @param portHandle the port to initialize
2439    /// @return           the created pwm handle
2440    pub fn HAL_InitializePWMPort(portHandle: HAL_PortHandle, status: *mut i32)
2441        -> HAL_DigitalHandle;
2442}
2443extern "C" {
2444    /// Frees a PWM port.
2445    ///
2446    /// @param pwmPortHandle the pwm handle
2447    pub fn HAL_FreePWMPort(pwmPortHandle: HAL_DigitalHandle, status: *mut i32);
2448}
2449extern "C" {
2450    /// Checks if a pwm channel is valid.
2451    ///
2452    /// @param channel the channel to check
2453    /// @return        true if the channel is valid, otherwise false
2454    pub fn HAL_CheckPWMChannel(channel: i32) -> HAL_Bool;
2455}
2456extern "C" {
2457    /// Sets the configuration settings for the PWM channel.
2458    ///
2459    /// All values are in milliseconds.
2460    ///
2461    /// @param pwmPortHandle  the PWM handle
2462    /// @param maxPwm         the maximum PWM value
2463    /// @param deadbandMaxPwm the high range of the center deadband
2464    /// @param centerPwm      the center PWM value
2465    /// @param deadbandMinPwm the low range of the center deadband
2466    /// @param minPwm         the minimum PWM value
2467    pub fn HAL_SetPWMConfig(
2468        pwmPortHandle: HAL_DigitalHandle,
2469        maxPwm: f64,
2470        deadbandMaxPwm: f64,
2471        centerPwm: f64,
2472        deadbandMinPwm: f64,
2473        minPwm: f64,
2474        status: *mut i32,
2475    );
2476}
2477extern "C" {
2478    /// Sets the raw configuration settings for the PWM channel.
2479    ///
2480    /// We recommend using HAL_SetPWMConfig() instead, as those values are properly
2481    /// scaled. Usually used for values grabbed by HAL_GetPWMConfigRaw().
2482    ///
2483    /// Values are in raw FPGA units.
2484    ///
2485    /// @param pwmPortHandle  the PWM handle
2486    /// @param maxPwm         the maximum PWM value
2487    /// @param deadbandMaxPwm the high range of the center deadband
2488    /// @param centerPwm      the center PWM value
2489    /// @param deadbandMinPwm the low range of the center deadband
2490    /// @param minPwm         the minimum PWM value
2491    pub fn HAL_SetPWMConfigRaw(
2492        pwmPortHandle: HAL_DigitalHandle,
2493        maxPwm: i32,
2494        deadbandMaxPwm: i32,
2495        centerPwm: i32,
2496        deadbandMinPwm: i32,
2497        minPwm: i32,
2498        status: *mut i32,
2499    );
2500}
2501extern "C" {
2502    /// Gets the raw pwm configuration settings for the PWM channel.
2503    ///
2504    /// Values are in raw FPGA units. These units have the potential to change for
2505    /// any FPGA release.
2506    ///
2507    /// @param pwmPortHandle  the PWM handle
2508    /// @param maxPwm         the maximum PWM value
2509    /// @param deadbandMaxPwm the high range of the center deadband
2510    /// @param centerPwm      the center PWM value
2511    /// @param deadbandMinPwm the low range of the center deadband
2512    /// @param minPwm         the minimum PWM value
2513    pub fn HAL_GetPWMConfigRaw(
2514        pwmPortHandle: HAL_DigitalHandle,
2515        maxPwm: *mut i32,
2516        deadbandMaxPwm: *mut i32,
2517        centerPwm: *mut i32,
2518        deadbandMinPwm: *mut i32,
2519        minPwm: *mut i32,
2520        status: *mut i32,
2521    );
2522}
2523extern "C" {
2524    /// Sets if the FPGA should output the center value if the input value is within
2525    /// the deadband.
2526    ///
2527    /// @param pwmPortHandle     the PWM handle
2528    /// @param eliminateDeadband true to eliminate deadband, otherwise false
2529    pub fn HAL_SetPWMEliminateDeadband(
2530        pwmPortHandle: HAL_DigitalHandle,
2531        eliminateDeadband: HAL_Bool,
2532        status: *mut i32,
2533    );
2534}
2535extern "C" {
2536    /// Gets the current eliminate deadband value.
2537    ///
2538    /// @param pwmPortHandle the PWM handle
2539    /// @return              true if set, otherwise false
2540    pub fn HAL_GetPWMEliminateDeadband(
2541        pwmPortHandle: HAL_DigitalHandle,
2542        status: *mut i32,
2543    ) -> HAL_Bool;
2544}
2545extern "C" {
2546    /// Sets a PWM channel to the desired value.
2547    ///
2548    /// The values are in raw FPGA units, and have the potential to change with any
2549    /// FPGA release.
2550    ///
2551    /// @param pwmPortHandle the PWM handle
2552    /// @param value         the PWM value to set
2553    pub fn HAL_SetPWMRaw(pwmPortHandle: HAL_DigitalHandle, value: i32, status: *mut i32);
2554}
2555extern "C" {
2556    /// Sets a PWM channel to the desired scaled value.
2557    ///
2558    /// The values range from -1 to 1 and the period is controlled by the PWM Period
2559    /// and MinHigh registers.
2560    ///
2561    /// @param pwmPortHandle the PWM handle
2562    /// @param value         the scaled PWM value to set
2563    pub fn HAL_SetPWMSpeed(pwmPortHandle: HAL_DigitalHandle, speed: f64, status: *mut i32);
2564}
2565extern "C" {
2566    /// Sets a PWM channel to the desired position value.
2567    ///
2568    /// The values range from 0 to 1 and the period is controlled by the PWM Period
2569    /// and MinHigh registers.
2570    ///
2571    /// @param pwmPortHandle the PWM handle
2572    /// @param value         the positional PWM value to set
2573    pub fn HAL_SetPWMPosition(pwmPortHandle: HAL_DigitalHandle, position: f64, status: *mut i32);
2574}
2575extern "C" {
2576    /// Sets a PWM channel to be disabled.
2577    ///
2578    /// The channel is disabled until the next time it is set. Note this is different
2579    /// from just setting a 0 speed, as this will actively stop all signalling on the
2580    /// channel.
2581    ///
2582    /// @param pwmPortHandle the PWM handle.
2583    pub fn HAL_SetPWMDisabled(pwmPortHandle: HAL_DigitalHandle, status: *mut i32);
2584}
2585extern "C" {
2586    /// Gets a value from a PWM channel.
2587    ///
2588    /// The values are in raw FPGA units, and have the potential to change with any
2589    /// FPGA release.
2590    ///
2591    /// @param pwmPortHandle the PWM handle
2592    /// @return              the current raw PWM value
2593    pub fn HAL_GetPWMRaw(pwmPortHandle: HAL_DigitalHandle, status: *mut i32) -> i32;
2594}
2595extern "C" {
2596    /// Gets a scaled value from a PWM channel.
2597    ///
2598    /// The values range from -1 to 1.
2599    ///
2600    /// @param pwmPortHandle the PWM handle
2601    /// @return              the current speed PWM value
2602    pub fn HAL_GetPWMSpeed(pwmPortHandle: HAL_DigitalHandle, status: *mut i32) -> f64;
2603}
2604extern "C" {
2605    /// Gets a position value from a PWM channel.
2606    ///
2607    /// The values range from 0 to 1.
2608    ///
2609    /// @param pwmPortHandle the PWM handle
2610    /// @return              the current positional PWM value
2611    pub fn HAL_GetPWMPosition(pwmPortHandle: HAL_DigitalHandle, status: *mut i32) -> f64;
2612}
2613extern "C" {
2614    /// Forces a PWM signal to go to 0 temporarily.
2615    ///
2616    /// @param pwmPortHandle the PWM handle.
2617    pub fn HAL_LatchPWMZero(pwmPortHandle: HAL_DigitalHandle, status: *mut i32);
2618}
2619extern "C" {
2620    /// Sets how how often the PWM signal is squelched, thus scaling the period.
2621    ///
2622    /// @param pwmPortHandle the PWM handle.
2623    /// @param squelchMask   the 2-bit mask of outputs to squelch
2624    pub fn HAL_SetPWMPeriodScale(
2625        pwmPortHandle: HAL_DigitalHandle,
2626        squelchMask: i32,
2627        status: *mut i32,
2628    );
2629}
2630extern "C" {
2631    /// Gets the loop timing of the PWM system.
2632    ///
2633    /// @return the loop time
2634    pub fn HAL_GetPWMLoopTiming(status: *mut i32) -> i32;
2635}
2636extern "C" {
2637    /// Gets the pwm starting cycle time.
2638    ///
2639    /// This time is relative to the FPGA time.
2640    ///
2641    /// @return the pwm cycle start time
2642    pub fn HAL_GetPWMCycleStartTime(status: *mut i32) -> u64;
2643}
2644extern "C" {
2645    /// Gets the number of analog accumulators in the current system.
2646    ///
2647    /// @return the number of analog accumulators
2648    pub fn HAL_GetNumAccumulators() -> i32;
2649}
2650extern "C" {
2651    /// Gets the number of analog triggers in the current system.
2652    ///
2653    /// @return the number of analog triggers
2654    pub fn HAL_GetNumAnalogTriggers() -> i32;
2655}
2656extern "C" {
2657    /// Gets the number of analog inputs in the current system.
2658    ///
2659    /// @return the number of analog inputs
2660    pub fn HAL_GetNumAnalogInputs() -> i32;
2661}
2662extern "C" {
2663    /// Gets the number of analog outputs in the current system.
2664    ///
2665    /// @return the number of analog outputs
2666    pub fn HAL_GetNumAnalogOutputs() -> i32;
2667}
2668extern "C" {
2669    /// Gets the number of analog counters in the current system.
2670    ///
2671    /// @return the number of counters
2672    pub fn HAL_GetNumCounters() -> i32;
2673}
2674extern "C" {
2675    /// Gets the number of digital headers in the current system.
2676    ///
2677    /// @return the number of digital headers
2678    pub fn HAL_GetNumDigitalHeaders() -> i32;
2679}
2680extern "C" {
2681    /// Gets the number of PWM headers in the current system.
2682    ///
2683    /// @return the number of PWM headers
2684    pub fn HAL_GetNumPWMHeaders() -> i32;
2685}
2686extern "C" {
2687    /// Gets the number of digital channels in the current system.
2688    ///
2689    /// @return the number of digital channels
2690    pub fn HAL_GetNumDigitalChannels() -> i32;
2691}
2692extern "C" {
2693    /// Gets the number of PWM channels in the current system.
2694    ///
2695    /// @return the number of PWM channels
2696    pub fn HAL_GetNumPWMChannels() -> i32;
2697}
2698extern "C" {
2699    /// Gets the number of digital IO PWM outputs in the current system.
2700    ///
2701    /// @return the number of digital IO PWM outputs
2702    pub fn HAL_GetNumDigitalPWMOutputs() -> i32;
2703}
2704extern "C" {
2705    /// Gets the number of quadrature encoders in the current system.
2706    ///
2707    /// @return the number of quadrature encoders
2708    pub fn HAL_GetNumEncoders() -> i32;
2709}
2710extern "C" {
2711    /// Gets the number of interrupts in the current system.
2712    ///
2713    /// @return the number of interrupts
2714    pub fn HAL_GetNumInterrupts() -> i32;
2715}
2716extern "C" {
2717    /// Gets the number of relay channels in the current system.
2718    ///
2719    /// @return the number of relay channels
2720    pub fn HAL_GetNumRelayChannels() -> i32;
2721}
2722extern "C" {
2723    /// Gets the number of relay headers in the current system.
2724    ///
2725    /// @return the number of relay headers
2726    pub fn HAL_GetNumRelayHeaders() -> i32;
2727}
2728extern "C" {
2729    /// Gets the number of PCM modules in the current system.
2730    ///
2731    /// @return the number of PCM modules
2732    pub fn HAL_GetNumPCMModules() -> i32;
2733}
2734extern "C" {
2735    /// Gets the number of solenoid channels in the current system.
2736    ///
2737    /// @return the number of solenoid channels
2738    pub fn HAL_GetNumSolenoidChannels() -> i32;
2739}
2740extern "C" {
2741    /// Gets the number of PDP modules in the current system.
2742    ///
2743    /// @return the number of PDP modules
2744    pub fn HAL_GetNumPDPModules() -> i32;
2745}
2746extern "C" {
2747    /// Gets the number of PDP channels in the current system.
2748    ///
2749    /// @return the number of PDP channels
2750    pub fn HAL_GetNumPDPChannels() -> i32;
2751}
2752extern "C" {
2753    /// Gets the roboRIO input voltage.
2754    ///
2755    /// @return the input voltage (volts)
2756    pub fn HAL_GetVinVoltage(status: *mut i32) -> f64;
2757}
2758extern "C" {
2759    /// Gets the roboRIO input current.
2760    ///
2761    /// @return the input current (amps)
2762    pub fn HAL_GetVinCurrent(status: *mut i32) -> f64;
2763}
2764extern "C" {
2765    /// Gets the 6V rail voltage.
2766    ///
2767    /// @return the 6V rail voltage (volts)
2768    pub fn HAL_GetUserVoltage6V(status: *mut i32) -> f64;
2769}
2770extern "C" {
2771    /// Gets the 6V rail current.
2772    ///
2773    /// @return the 6V rail current (amps)
2774    pub fn HAL_GetUserCurrent6V(status: *mut i32) -> f64;
2775}
2776extern "C" {
2777    /// Gets the active state of the 6V rail.
2778    ///
2779    /// @return true if the rail is active, otherwise false
2780    pub fn HAL_GetUserActive6V(status: *mut i32) -> HAL_Bool;
2781}
2782extern "C" {
2783    /// Gets the fault count for the 6V rail.
2784    ///
2785    /// @return the number of 6V fault counts
2786    pub fn HAL_GetUserCurrentFaults6V(status: *mut i32) -> i32;
2787}
2788extern "C" {
2789    /// Gets the 5V rail voltage.
2790    ///
2791    /// @return the 5V rail voltage (volts)
2792    pub fn HAL_GetUserVoltage5V(status: *mut i32) -> f64;
2793}
2794extern "C" {
2795    /// Gets the 5V rail current.
2796    ///
2797    /// @return the 5V rail current (amps)
2798    pub fn HAL_GetUserCurrent5V(status: *mut i32) -> f64;
2799}
2800extern "C" {
2801    /// Gets the active state of the 5V rail.
2802    ///
2803    /// @return true if the rail is active, otherwise false
2804    pub fn HAL_GetUserActive5V(status: *mut i32) -> HAL_Bool;
2805}
2806extern "C" {
2807    /// Gets the fault count for the 5V rail.
2808    ///
2809    /// @return the number of 5V fault counts
2810    pub fn HAL_GetUserCurrentFaults5V(status: *mut i32) -> i32;
2811}
2812extern "C" {
2813    /// Gets the 3V3 rail voltage.
2814    ///
2815    /// @return the 3V3 rail voltage (volts)
2816    pub fn HAL_GetUserVoltage3V3(status: *mut i32) -> f64;
2817}
2818extern "C" {
2819    /// Gets the 3V3 rail current.
2820    ///
2821    /// @return the 3V3 rail current (amps)
2822    pub fn HAL_GetUserCurrent3V3(status: *mut i32) -> f64;
2823}
2824extern "C" {
2825    /// Gets the active state of the 3V3 rail.
2826    ///
2827    /// @return true if the rail is active, otherwise false
2828    pub fn HAL_GetUserActive3V3(status: *mut i32) -> HAL_Bool;
2829}
2830extern "C" {
2831    /// Gets the fault count for the 3V3 rail.
2832    ///
2833    /// @return the number of 3V3 fault counts
2834    pub fn HAL_GetUserCurrentFaults3V3(status: *mut i32) -> i32;
2835}
2836extern "C" {
2837    /// Initializes a relay.
2838    ///
2839    /// Note this call will only initialize either the forward or reverse port of the
2840    /// relay. If you need both, you will need to initialize 2 relays.
2841    ///
2842    /// @param portHandle the port handle to initialize
2843    /// @param fwd        true for the forward port, false for the reverse port
2844    /// @return           the created relay handle
2845    pub fn HAL_InitializeRelayPort(
2846        portHandle: HAL_PortHandle,
2847        fwd: HAL_Bool,
2848        status: *mut i32,
2849    ) -> HAL_RelayHandle;
2850}
2851extern "C" {
2852    /// Frees a relay port.
2853    ///
2854    /// @param relayPortHandle the relay handle
2855    pub fn HAL_FreeRelayPort(relayPortHandle: HAL_RelayHandle);
2856}
2857extern "C" {
2858    /// Checks if a relay channel is valid.
2859    ///
2860    /// @param channel the channel to check
2861    /// @return        true if the channel is valid, otherwise false
2862    pub fn HAL_CheckRelayChannel(channel: i32) -> HAL_Bool;
2863}
2864extern "C" {
2865    /// Sets the state of a relay output.
2866    ///
2867    /// @param relayPortHandle the relay handle
2868    /// @param on              true for on, false for off
2869    pub fn HAL_SetRelay(relayPortHandle: HAL_RelayHandle, on: HAL_Bool, status: *mut i32);
2870}
2871extern "C" {
2872    /// Gets the current state of the relay channel.
2873    ///
2874    /// @param relayPortHandle the relay handle
2875    /// @return                true for on, false for off
2876    pub fn HAL_GetRelay(relayPortHandle: HAL_RelayHandle, status: *mut i32) -> HAL_Bool;
2877}
2878pub mod HAL_SPIPort {
2879    /// @defgroup hal_spi SPI Functions
2880    /// @ingroup hal_capi
2881    /// @{
2882    pub type Type = i32;
2883    pub const HAL_SPI_kInvalid: Type = -1;
2884    pub const HAL_SPI_kOnboardCS0: Type = 0;
2885    pub const HAL_SPI_kOnboardCS1: Type = 1;
2886    pub const HAL_SPI_kOnboardCS2: Type = 2;
2887    pub const HAL_SPI_kOnboardCS3: Type = 3;
2888    pub const HAL_SPI_kMXP: Type = 4;
2889}
2890extern "C" {
2891    /// Initializes the SPI port. Opens the port if necessary and saves the handle.
2892    ///
2893    /// If opening the MXP port, also sets up the channel functions appropriately.
2894    ///
2895    /// @param port The number of the port to use. 0-3 for Onboard CS0-CS3, 4 for MXP
2896    pub fn HAL_InitializeSPI(port: HAL_SPIPort::Type, status: *mut i32);
2897}
2898extern "C" {
2899    /// Performs an SPI send/receive transaction.
2900    ///
2901    /// This is a lower-level interface to the spi hardware giving you more control
2902    /// over each transaction.
2903    ///
2904    /// @param port         The number of the port to use. 0-3 for Onboard CS0-CS2, 4
2905    /// for MXP
2906    /// @param dataToSend   Buffer of data to send as part of the transaction.
2907    /// @param dataReceived Buffer to read data into.
2908    /// @param size         Number of bytes to transfer. [0..7]
2909    /// @return             Number of bytes transferred, -1 for error
2910    pub fn HAL_TransactionSPI(
2911        port: HAL_SPIPort::Type,
2912        dataToSend: *const u8,
2913        dataReceived: *mut u8,
2914        size: i32,
2915    ) -> i32;
2916}
2917extern "C" {
2918    /// Executes a write transaction with the device.
2919    ///
2920    /// Writes to a device and wait until the transaction is complete.
2921    ///
2922    /// @param port      The number of the port to use. 0-3 for Onboard CS0-CS2, 4
2923    /// for MXP
2924    /// @param datToSend The data to write to the register on the device.
2925    /// @param sendSize  The number of bytes to be written
2926    /// @return          The number of bytes written. -1 for an error
2927    pub fn HAL_WriteSPI(port: HAL_SPIPort::Type, dataToSend: *const u8, sendSize: i32) -> i32;
2928}
2929extern "C" {
2930    /// Executes a read from the device.
2931    ///
2932    /// This method does not write any data out to the device.
2933    ///
2934    /// Most spi devices will require a register address to be written before they
2935    /// begin returning data.
2936    ///
2937    /// @param port   The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for
2938    /// MXP
2939    /// @param buffer A pointer to the array of bytes to store the data read from the
2940    /// device.
2941    /// @param count  The number of bytes to read in the transaction. [1..7]
2942    /// @return       Number of bytes read. -1 for error.
2943    pub fn HAL_ReadSPI(port: HAL_SPIPort::Type, buffer: *mut u8, count: i32) -> i32;
2944}
2945extern "C" {
2946    /// Closes the SPI port.
2947    ///
2948    /// @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
2949    pub fn HAL_CloseSPI(port: HAL_SPIPort::Type);
2950}
2951extern "C" {
2952    /// Sets the clock speed for the SPI bus.
2953    ///
2954    /// @param port  The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for
2955    /// MXP
2956    /// @param speed The speed in Hz (0-1MHz)
2957    pub fn HAL_SetSPISpeed(port: HAL_SPIPort::Type, speed: i32);
2958}
2959extern "C" {
2960    /// Sets the SPI options.
2961    ///
2962    /// @param port             The number of the port to use. 0-3 for Onboard
2963    /// CS0-CS2, 4 for MXP
2964    /// @param msbFirst         True to write the MSB first, False for LSB first
2965    /// @param sampleOnTrailing True to sample on the trailing edge, False to sample
2966    /// on the leading edge
2967    /// @param clkIdleHigh      True to set the clock to active low, False to set the
2968    /// clock active high
2969    pub fn HAL_SetSPIOpts(
2970        port: HAL_SPIPort::Type,
2971        msbFirst: HAL_Bool,
2972        sampleOnTrailing: HAL_Bool,
2973        clkIdleHigh: HAL_Bool,
2974    );
2975}
2976extern "C" {
2977    /// Sets the CS Active high for a SPI port.
2978    ///
2979    /// @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
2980    pub fn HAL_SetSPIChipSelectActiveHigh(port: HAL_SPIPort::Type, status: *mut i32);
2981}
2982extern "C" {
2983    /// Sets the CS Active low for a SPI port.
2984    ///
2985    /// @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
2986    pub fn HAL_SetSPIChipSelectActiveLow(port: HAL_SPIPort::Type, status: *mut i32);
2987}
2988extern "C" {
2989    /// Gets the stored handle for a SPI port.
2990    ///
2991    /// @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
2992    /// @return     The stored handle for the SPI port. 0 represents no stored
2993    /// handle.
2994    pub fn HAL_GetSPIHandle(port: HAL_SPIPort::Type) -> i32;
2995}
2996extern "C" {
2997    /// Sets the stored handle for a SPI port.
2998    ///
2999    /// @param port   The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for
3000    /// MXP.
3001    /// @param handle The value of the handle for the port.
3002    pub fn HAL_SetSPIHandle(port: HAL_SPIPort::Type, handle: i32);
3003}
3004extern "C" {
3005    /// Initializes the SPI automatic accumulator.
3006    ///
3007    /// @param port       The number of the port to use. 0-3 for Onboard CS0-CS2, 4
3008    /// for MXP.
3009    /// @param bufferSize The accumulator buffer size.
3010    pub fn HAL_InitSPIAuto(port: HAL_SPIPort::Type, bufferSize: i32, status: *mut i32);
3011}
3012extern "C" {
3013    /// Frees an SPI automatic accumulator.
3014    ///
3015    /// @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for
3016    /// MXP.
3017    pub fn HAL_FreeSPIAuto(port: HAL_SPIPort::Type, status: *mut i32);
3018}
3019extern "C" {
3020    /// Sets the period for automatic SPI accumulation.
3021    ///
3022    /// @param port   The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for
3023    /// MXP.
3024    /// @param period The accumlation period (seconds).
3025    pub fn HAL_StartSPIAutoRate(port: HAL_SPIPort::Type, period: f64, status: *mut i32);
3026}
3027extern "C" {
3028    /// Starts the auto SPI accumulator on a specific trigger.
3029    ///
3030    /// Note that triggering on both rising and falling edges is a valid
3031    /// configuration.
3032    ///
3033    /// @param port                The number of the port to use. 0-3 for Onboard
3034    /// CS0-CS2, 4 for MXP.
3035    /// @param digitalSourceHandle The trigger source to use (Either
3036    /// HAL_AnalogTriggerHandle or HAL_DigitalHandle).
3037    /// @param analogTriggerType   The analog trigger type, if the source is an
3038    /// analog trigger.
3039    /// @param triggerRising       Trigger on the rising edge if true.
3040    /// @param triggerFalling      Trigger on the falling edge if true.
3041    pub fn HAL_StartSPIAutoTrigger(
3042        port: HAL_SPIPort::Type,
3043        digitalSourceHandle: HAL_Handle,
3044        analogTriggerType: HAL_AnalogTriggerType::Type,
3045        triggerRising: HAL_Bool,
3046        triggerFalling: HAL_Bool,
3047        status: *mut i32,
3048    );
3049}
3050extern "C" {
3051    /// Stops an automatic SPI accumlation.
3052    ///
3053    /// @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for
3054    /// MXP.
3055    pub fn HAL_StopSPIAuto(port: HAL_SPIPort::Type, status: *mut i32);
3056}
3057extern "C" {
3058    /// Sets the data to be transmitted to the device to initiate a read.
3059    ///
3060    /// @param port       The number of the port to use. 0-3 for Onboard CS0-CS2, 4
3061    /// for MXP.
3062    /// @param dataToSend Pointer to the data to send (Gets copied for continue use,
3063    /// so no need to keep alive).
3064    /// @param dataSize   The length of the data to send.
3065    /// @param zeroSize   The number of zeros to send after the data.
3066    pub fn HAL_SetSPIAutoTransmitData(
3067        port: HAL_SPIPort::Type,
3068        dataToSend: *const u8,
3069        dataSize: i32,
3070        zeroSize: i32,
3071        status: *mut i32,
3072    );
3073}
3074extern "C" {
3075    /// Immediately forces an SPI read to happen.
3076    ///
3077    /// @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for
3078    /// MXP.
3079    pub fn HAL_ForceSPIAutoRead(port: HAL_SPIPort::Type, status: *mut i32);
3080}
3081extern "C" {
3082    /// Reads data received by the SPI accumulator.  Each received data sequence
3083    /// consists of a timestamp followed by the received data bytes, one byte per
3084    /// word (in the least significant byte).  The length of each received data
3085    /// sequence is the same as the combined dataSize + zeroSize set in
3086    /// HAL_SetSPIAutoTransmitData.
3087    ///
3088    /// @param port      The number of the port to use. 0-3 for Onboard CS0-CS2, 4
3089    /// for MXP.
3090    /// @param buffer    The buffer to store the data into.
3091    /// @param numToRead The number of words to read.
3092    /// @param timeout   The read timeout (in seconds).
3093    /// @return          The number of words actually read.
3094    pub fn HAL_ReadSPIAutoReceivedData(
3095        port: HAL_SPIPort::Type,
3096        buffer: *mut u32,
3097        numToRead: i32,
3098        timeout: f64,
3099        status: *mut i32,
3100    ) -> i32;
3101}
3102extern "C" {
3103    /// Gets the count of how many SPI accumulations have been missed.
3104    ///
3105    /// @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for
3106    /// MXP.
3107    /// @return     The number of missed accumulations.
3108    pub fn HAL_GetSPIAutoDroppedCount(port: HAL_SPIPort::Type, status: *mut i32) -> i32;
3109}
3110pub mod HAL_SerialPort {
3111    /// @defgroup hal_serialport Serial Port Functions
3112    /// @ingroup hal_capi
3113    /// @{
3114    pub type Type = i32;
3115    pub const Onboard: Type = 0;
3116    pub const MXP: Type = 1;
3117    pub const USB1: Type = 2;
3118    pub const USB2: Type = 3;
3119}
3120extern "C" {
3121    /// Initializes a serial port.
3122    ///
3123    /// The channels are either the onboard RS232, the mxp uart, or 2 USB ports. The
3124    /// top port is USB1, the bottom port is USB2.
3125    ///
3126    /// @param port the serial port to initialize
3127    pub fn HAL_InitializeSerialPort(port: HAL_SerialPort::Type, status: *mut i32);
3128}
3129extern "C" {
3130    /// Initializes a serial port with a direct name.
3131    ///
3132    /// This name is the VISA name for a specific port (find this in the web dash).
3133    /// Note these are not always consistent between roboRIO reboots.
3134    ///
3135    /// @param port     the serial port to initialize
3136    /// @param portName the VISA port name
3137    pub fn HAL_InitializeSerialPortDirect(
3138        port: HAL_SerialPort::Type,
3139        portName: *const ::std::os::raw::c_char,
3140        status: *mut i32,
3141    );
3142}
3143extern "C" {
3144    /// Sets the baud rate of a serial port.
3145    ///
3146    /// Any value between 0 and 0xFFFFFFFF may be used. Default is 9600.
3147    ///
3148    /// @param port the serial port
3149    /// @param baud the baud rate to set
3150    pub fn HAL_SetSerialBaudRate(port: HAL_SerialPort::Type, baud: i32, status: *mut i32);
3151}
3152extern "C" {
3153    /// Sets the number of data bits on a serial port.
3154    ///
3155    /// Defaults to 8.
3156    ///
3157    /// @param port the serial port
3158    /// @param bits the number of data bits (5-8)
3159    pub fn HAL_SetSerialDataBits(port: HAL_SerialPort::Type, bits: i32, status: *mut i32);
3160}
3161extern "C" {
3162    /// Sets the number of parity bits on a serial port.
3163    ///
3164    /// Valid values are:
3165    ///   0: None (default)
3166    ///   1: Odd
3167    ///   2: Even
3168    ///   3: Mark - Means exists and always 1
3169    ///   4: Space - Means exists and always 0
3170    ///
3171    /// @param port   the serial port
3172    /// @param parity the parity bit mode (see remarks for valid values)
3173    pub fn HAL_SetSerialParity(port: HAL_SerialPort::Type, parity: i32, status: *mut i32);
3174}
3175extern "C" {
3176    /// Sets the number of stop bits on a serial port.
3177    ///
3178    /// Valid values are:
3179    ///   10: One stop bit (default)
3180    ///   15: One and a half stop bits
3181    ///   20: Two stop bits
3182    ///
3183    /// @param port     the serial port
3184    /// @param stopBits the stop bit value (see remarks for valid values)
3185    pub fn HAL_SetSerialStopBits(port: HAL_SerialPort::Type, stopBits: i32, status: *mut i32);
3186}
3187extern "C" {
3188    /// Sets the write mode on a serial port.
3189    ///
3190    /// Valid values are:
3191    ///   1: Flush on access
3192    ///   2: Flush when full (default)
3193    ///
3194    /// @param port the serial port
3195    /// @param mode the mode to set (see remarks for valid values)
3196    pub fn HAL_SetSerialWriteMode(port: HAL_SerialPort::Type, mode: i32, status: *mut i32);
3197}
3198extern "C" {
3199    /// Sets the flow control mode of a serial port.
3200    ///
3201    /// Valid values are:
3202    ///   0: None (default)
3203    ///   1: XON-XOFF
3204    ///   2: RTS-CTS
3205    ///   3: DTR-DSR
3206    ///
3207    /// @param port the serial port
3208    /// @param flow the mode to set (see remarks for valid values)
3209    pub fn HAL_SetSerialFlowControl(port: HAL_SerialPort::Type, flow: i32, status: *mut i32);
3210}
3211extern "C" {
3212    /// Sets the minimum serial read timeout of a port.
3213    ///
3214    /// @param port    the serial port
3215    /// @param timeout the timeout in milliseconds
3216    pub fn HAL_SetSerialTimeout(port: HAL_SerialPort::Type, timeout: f64, status: *mut i32);
3217}
3218extern "C" {
3219    /// Sets the termination character that terminates a read.
3220    ///
3221    /// By default this is disabled.
3222    ///
3223    /// @param port       the serial port
3224    /// @param terminator the termination character to set
3225    pub fn HAL_EnableSerialTermination(
3226        port: HAL_SerialPort::Type,
3227        terminator: ::std::os::raw::c_char,
3228        status: *mut i32,
3229    );
3230}
3231extern "C" {
3232    /// Disables a termination character for reads.
3233    ///
3234    /// @param port the serial port
3235    pub fn HAL_DisableSerialTermination(port: HAL_SerialPort::Type, status: *mut i32);
3236}
3237extern "C" {
3238    /// Sets the size of the read buffer.
3239    ///
3240    /// @param port the serial port
3241    /// @param size the read buffer size
3242    pub fn HAL_SetSerialReadBufferSize(port: HAL_SerialPort::Type, size: i32, status: *mut i32);
3243}
3244extern "C" {
3245    /// Sets the size of the write buffer.
3246    ///
3247    /// @param port the serial port
3248    /// @param size the write buffer size
3249    pub fn HAL_SetSerialWriteBufferSize(port: HAL_SerialPort::Type, size: i32, status: *mut i32);
3250}
3251extern "C" {
3252    /// Gets the number of bytes currently in the read buffer.
3253    ///
3254    /// @param port the serial port
3255    /// @return     the number of bytes in the read buffer
3256    pub fn HAL_GetSerialBytesReceived(port: HAL_SerialPort::Type, status: *mut i32) -> i32;
3257}
3258extern "C" {
3259    /// Reads data from the serial port.
3260    ///
3261    /// Will wait for either timeout (if set), the termination char (if set), or the
3262    /// count to be full. Whichever one comes first.
3263    ///
3264    /// @param port  the serial port
3265    /// @param count the number of bytes maximum to read
3266    /// @return      the number of bytes actually read
3267    pub fn HAL_ReadSerial(
3268        port: HAL_SerialPort::Type,
3269        buffer: *mut ::std::os::raw::c_char,
3270        count: i32,
3271        status: *mut i32,
3272    ) -> i32;
3273}
3274extern "C" {
3275    /// Writes data to the serial port.
3276    ///
3277    /// @param port   the serial port
3278    /// @param buffer the buffer to write
3279    /// @param count  the number of bytes to write from the buffer
3280    /// @return       the number of bytes actually written
3281    pub fn HAL_WriteSerial(
3282        port: HAL_SerialPort::Type,
3283        buffer: *const ::std::os::raw::c_char,
3284        count: i32,
3285        status: *mut i32,
3286    ) -> i32;
3287}
3288extern "C" {
3289    /// Flushes the serial write buffer out to the port.
3290    ///
3291    /// @param port the serial port
3292    pub fn HAL_FlushSerial(port: HAL_SerialPort::Type, status: *mut i32);
3293}
3294extern "C" {
3295    /// Clears the receive buffer of the serial port.
3296    ///
3297    /// @param port the serial port
3298    pub fn HAL_ClearSerial(port: HAL_SerialPort::Type, status: *mut i32);
3299}
3300extern "C" {
3301    /// Closes a serial port.
3302    ///
3303    /// @param port the serial port to close
3304    pub fn HAL_CloseSerial(port: HAL_SerialPort::Type, status: *mut i32);
3305}
3306extern "C" {
3307    /// Initializes a solenoid port.
3308    ///
3309    /// @param portHandle the port handle of the module and channel to initialize
3310    /// @return           the created solenoid handle
3311    pub fn HAL_InitializeSolenoidPort(
3312        portHandle: HAL_PortHandle,
3313        status: *mut i32,
3314    ) -> HAL_SolenoidHandle;
3315}
3316extern "C" {
3317    /// Frees a solenoid port.
3318    ///
3319    /// @param solenoidPortHandle the solenoid handle
3320    pub fn HAL_FreeSolenoidPort(solenoidPortHandle: HAL_SolenoidHandle);
3321}
3322extern "C" {
3323    /// Checks if a solenoid module is in the valid range.
3324    ///
3325    /// @param module the module number to check
3326    /// @return       true if the module number is valid, otherwise false
3327    pub fn HAL_CheckSolenoidModule(module: i32) -> HAL_Bool;
3328}
3329extern "C" {
3330    /// Checks if a solenoid channel is in the valid range.
3331    ///
3332    /// @param channel the channel number to check
3333    /// @return       true if the channel number is valid, otherwise false
3334    pub fn HAL_CheckSolenoidChannel(channel: i32) -> HAL_Bool;
3335}
3336extern "C" {
3337    /// Gets the current solenoid output value.
3338    ///
3339    /// @param solenoidPortHandle the solenoid handle
3340    /// @return                   true if the solenoid is on, otherwise false
3341    pub fn HAL_GetSolenoid(solenoidPortHandle: HAL_SolenoidHandle, status: *mut i32) -> HAL_Bool;
3342}
3343extern "C" {
3344    /// Gets the status of all solenoids on a specific module.
3345    ///
3346    /// @param module the module to check
3347    /// @return       bitmask of the channels, 1 for on 0 for off
3348    pub fn HAL_GetAllSolenoids(module: i32, status: *mut i32) -> i32;
3349}
3350extern "C" {
3351    /// Sets a solenoid output value.
3352    ///
3353    /// @param solenoidPortHandle the solenoid handle
3354    /// @param value              true for on, false for off
3355    pub fn HAL_SetSolenoid(
3356        solenoidPortHandle: HAL_SolenoidHandle,
3357        value: HAL_Bool,
3358        status: *mut i32,
3359    );
3360}
3361extern "C" {
3362    /// Sets all channels on a specific module.
3363    ///
3364    /// @param module the module to set the channels on
3365    /// @param state  bitmask of the channels to set, 1 for on 0 for off
3366    pub fn HAL_SetAllSolenoids(module: i32, state: i32, status: *mut i32);
3367}
3368extern "C" {
3369    /// Gets the channels blacklisted from being enabled on a module.
3370    ///
3371    /// @param module the module to check
3372    /// @retur        bitmask of the blacklisted channels, 1 for true 0 for false
3373    pub fn HAL_GetPCMSolenoidBlackList(module: i32, status: *mut i32) -> i32;
3374}
3375extern "C" {
3376    /// Gets if a specific module has an over or under voltage sticky fault.
3377    ///
3378    /// @param module the module to check
3379    /// @return       true if a stick fault is set, otherwise false
3380    pub fn HAL_GetPCMSolenoidVoltageStickyFault(module: i32, status: *mut i32) -> HAL_Bool;
3381}
3382extern "C" {
3383    /// Gets if a specific module has an over or under voltage fault.
3384    ///
3385    /// @param module the module to check
3386    /// @return       true if faulted, otherwise false
3387    pub fn HAL_GetPCMSolenoidVoltageFault(module: i32, status: *mut i32) -> HAL_Bool;
3388}
3389extern "C" {
3390    /// Clears all faults on a module.
3391    ///
3392    /// @param module the module to clear
3393    pub fn HAL_ClearAllPCMStickyFaults(module: i32, status: *mut i32);
3394}
3395extern "C" {
3396    /// Sets the one shot duration on a solenoid channel.
3397    ///
3398    /// @param solenoidPortHandle the solenoid handle
3399    /// @param durMS              the one shot duration in ms
3400    pub fn HAL_SetOneShotDuration(
3401        solenoidPortHandle: HAL_SolenoidHandle,
3402        durMS: i32,
3403        status: *mut i32,
3404    );
3405}
3406extern "C" {
3407    /// Fires a single pulse on a solenoid channel.
3408    ///
3409    /// The pulse is the duration set by HAL_SetOneShotDuration().
3410    ///
3411    /// @param solenoidPortHandle the solenoid handle
3412    pub fn HAL_FireOneShot(solenoidPortHandle: HAL_SolenoidHandle, status: *mut i32);
3413}
3414pub mod HAL_RuntimeType {
3415    /// @defgroup hal_capi WPILib HAL API
3416    /// Hardware Abstraction Layer to hardware or simulator
3417    /// @{
3418    pub type Type = i32;
3419    pub const HAL_Athena: Type = 0;
3420    pub const HAL_Mock: Type = 1;
3421}
3422extern "C" {
3423    /// Gets the error message for a specific status code.
3424    ///
3425    /// @param code the status code
3426    /// @return     the error message for the code. This does not need to be freed.
3427    pub fn HAL_GetErrorMessage(code: i32) -> *const ::std::os::raw::c_char;
3428}
3429extern "C" {
3430    /// Returns the FPGA Version number.
3431    ///
3432    /// For now, expect this to be competition year.
3433    ///
3434    /// @return FPGA Version number.
3435    pub fn HAL_GetFPGAVersion(status: *mut i32) -> i32;
3436}
3437extern "C" {
3438    /// Returns the FPGA Revision number.
3439    ///
3440    /// The format of the revision is 3 numbers.
3441    /// The 12 most significant bits are the Major Revision.
3442    /// the next 8 bits are the Minor Revision.
3443    /// The 12 least significant bits are the Build Number.
3444    ///
3445    /// @return FPGA Revision number.
3446    pub fn HAL_GetFPGARevision(status: *mut i32) -> i64;
3447}
3448extern "C" {
3449    pub fn HAL_GetRuntimeType() -> HAL_RuntimeType::Type;
3450}
3451extern "C" {
3452    /// Gets the state of the "USER" button on the roboRIO.
3453    ///
3454    /// @return true if the button is currently pressed down
3455    pub fn HAL_GetFPGAButton(status: *mut i32) -> HAL_Bool;
3456}
3457extern "C" {
3458    /// Gets if the system outputs are currently active
3459    ///
3460    /// @return true if the system outputs are active, false if disabled
3461    pub fn HAL_GetSystemActive(status: *mut i32) -> HAL_Bool;
3462}
3463extern "C" {
3464    /// Gets if the system is in a browned out state.
3465    ///
3466    /// @return true if the system is in a low voltage brown out, false otherwise
3467    pub fn HAL_GetBrownedOut(status: *mut i32) -> HAL_Bool;
3468}
3469extern "C" {
3470    /// The base HAL initialize function. Useful if you need to ensure the DS and
3471    /// base HAL functions (the ones above this declaration in HAL.h) are properly
3472    /// initialized. For normal programs and executables, please use HAL_Initialize.
3473    ///
3474    /// This is mainly expected to be use from libraries that are expected to be used
3475    /// from LabVIEW, as it handles its own initialization for objects.
3476    pub fn HAL_BaseInitialize(status: *mut i32);
3477}
3478extern "C" {
3479    /// Gets a port handle for a specific channel.
3480    ///
3481    /// The created handle does not need to be freed.
3482    ///
3483    /// @param channel the channel number
3484    /// @return        the created port
3485    pub fn HAL_GetPort(channel: i32) -> HAL_PortHandle;
3486}
3487extern "C" {
3488    /// Gets a port handle for a specific channel and module.
3489    ///
3490    /// This is expected to be used for PCMs, as the roboRIO does not work with
3491    /// modules anymore.
3492    ///
3493    /// The created handle does not need to be freed.
3494    ///
3495    /// @param module  the module number
3496    /// @param channel the channel number
3497    /// @return        the created port
3498    pub fn HAL_GetPortWithModule(module: i32, channel: i32) -> HAL_PortHandle;
3499}
3500extern "C" {
3501    /// Reads the microsecond-resolution timer on the FPGA.
3502    ///
3503    /// @return The current time in microseconds according to the FPGA (since FPGA
3504    /// reset).
3505    pub fn HAL_GetFPGATime(status: *mut i32) -> u64;
3506}
3507extern "C" {
3508    /// Call this to start up HAL. This is required for robot programs.
3509    ///
3510    /// This must be called before any other HAL functions. Failure to do so will
3511    /// result in undefined behavior, and likely segmentation faults. This means that
3512    /// any statically initialized variables in a program MUST call this function in
3513    /// their constructors if they want to use other HAL calls.
3514    ///
3515    /// The common parameters are 500 for timeout and 0 for mode.
3516    ///
3517    /// This function is safe to call from any thread, and as many times as you wish.
3518    /// It internally guards from any reentrancy.
3519    ///
3520    /// The applicable modes are:
3521    ///   0: Try to kill an existing HAL from another program, if not successful,
3522    /// error.
3523    ///   1: Force kill a HAL from another program.
3524    ///   2: Just warn if another hal exists and cannot be killed. Will likely result
3525    /// in undefined behavior.
3526    ///
3527    /// @param timeout the initialization timeout (ms)
3528    /// @param mode    the initialization mode (see remarks)
3529    /// @return        true if initialization was successful, otherwise false.
3530    pub fn HAL_Initialize(timeout: i32, mode: i32) -> HAL_Bool;
3531}
3532extern "C" {
3533    /// Reports a hardware usage to the HAL.
3534    ///
3535    /// @param resource       the used resource
3536    /// @param instanceNumber the instance of the resource
3537    /// @param context        a user specified context index
3538    /// @param feature        a user specified feature string
3539    /// @return               the index of the added value in NetComm
3540    pub fn HAL_Report(
3541        resource: i32,
3542        instanceNumber: i32,
3543        context: i32,
3544        feature: *const ::std::os::raw::c_char,
3545    ) -> i64;
3546}
3547pub mod HALUsageReporting_tResourceType {
3548    pub type Type = u32;
3549    pub const Controller: Type = 0;
3550    pub const Module: Type = 1;
3551    pub const Language: Type = 2;
3552    pub const CANPlugin: Type = 3;
3553    pub const Accelerometer: Type = 4;
3554    pub const ADXL345: Type = 5;
3555    pub const AnalogChannel: Type = 6;
3556    pub const AnalogTrigger: Type = 7;
3557    pub const AnalogTriggerOutput: Type = 8;
3558    pub const CANJaguar: Type = 9;
3559    pub const Compressor: Type = 10;
3560    pub const Counter: Type = 11;
3561    pub const Dashboard: Type = 12;
3562    pub const DigitalInput: Type = 13;
3563    pub const DigitalOutput: Type = 14;
3564    pub const DriverStationCIO: Type = 15;
3565    pub const DriverStationEIO: Type = 16;
3566    pub const DriverStationLCD: Type = 17;
3567    pub const Encoder: Type = 18;
3568    pub const GearTooth: Type = 19;
3569    pub const Gyro: Type = 20;
3570    pub const I2C: Type = 21;
3571    pub const Framework: Type = 22;
3572    pub const Jaguar: Type = 23;
3573    pub const Joystick: Type = 24;
3574    pub const Kinect: Type = 25;
3575    pub const KinectStick: Type = 26;
3576    pub const PIDController: Type = 27;
3577    pub const Preferences: Type = 28;
3578    pub const PWM: Type = 29;
3579    pub const Relay: Type = 30;
3580    pub const RobotDrive: Type = 31;
3581    pub const SerialPort: Type = 32;
3582    pub const Servo: Type = 33;
3583    pub const Solenoid: Type = 34;
3584    pub const SPI: Type = 35;
3585    pub const Task: Type = 36;
3586    pub const Ultrasonic: Type = 37;
3587    pub const Victor: Type = 38;
3588    pub const Button: Type = 39;
3589    pub const Command: Type = 40;
3590    pub const AxisCamera: Type = 41;
3591    pub const PCVideoServer: Type = 42;
3592    pub const SmartDashboard: Type = 43;
3593    pub const Talon: Type = 44;
3594    pub const HiTechnicColorSensor: Type = 45;
3595    pub const HiTechnicAccel: Type = 46;
3596    pub const HiTechnicCompass: Type = 47;
3597    pub const SRF08: Type = 48;
3598    pub const AnalogOutput: Type = 49;
3599    pub const VictorSP: Type = 50;
3600    pub const PWMTalonSRX: Type = 51;
3601    pub const CANTalonSRX: Type = 52;
3602    pub const ADXL362: Type = 53;
3603    pub const ADXRS450: Type = 54;
3604    pub const RevSPARK: Type = 55;
3605    pub const MindsensorsSD540: Type = 56;
3606    pub const DigitalGlitchFilter: Type = 57;
3607    pub const ADIS16448: Type = 58;
3608    pub const PDP: Type = 59;
3609    pub const PCM: Type = 60;
3610    pub const PigeonIMU: Type = 61;
3611    pub const NidecBrushless: Type = 62;
3612    pub const CANifier: Type = 63;
3613    pub const CTRE_future0: Type = 64;
3614    pub const CTRE_future1: Type = 65;
3615    pub const CTRE_future2: Type = 66;
3616    pub const CTRE_future3: Type = 67;
3617    pub const CTRE_future4: Type = 68;
3618    pub const CTRE_future5: Type = 69;
3619    pub const CTRE_future6: Type = 70;
3620    pub const LinearFilter: Type = 71;
3621    pub const XboxController: Type = 72;
3622    pub const UsbCamera: Type = 73;
3623    pub const NavX: Type = 74;
3624    pub const Pixy: Type = 75;
3625    pub const Pixy2: Type = 76;
3626    pub const ScanseSweep: Type = 77;
3627    pub const Shuffleboard: Type = 78;
3628    pub const CAN: Type = 79;
3629    pub const DigilentDMC60: Type = 80;
3630    pub const PWMVictorSPX: Type = 81;
3631    pub const RevSparkMaxPWM: Type = 82;
3632    pub const RevSparkMaxCAN: Type = 83;
3633    pub const ADIS16470: Type = 84;
3634}
3635pub mod HALUsageReporting_tInstances {
3636    pub type Type = u32;
3637    pub const kLanguage_LabVIEW: Type = 1;
3638    pub const kLanguage_CPlusPlus: Type = 2;
3639    pub const kLanguage_Java: Type = 3;
3640    pub const kLanguage_Python: Type = 4;
3641    pub const kLanguage_DotNet: Type = 5;
3642    pub const kCANPlugin_BlackJagBridge: Type = 1;
3643    pub const kCANPlugin_2CAN: Type = 2;
3644    pub const kFramework_Iterative: Type = 1;
3645    pub const kFramework_Simple: Type = 2;
3646    pub const kFramework_CommandControl: Type = 3;
3647    pub const kFramework_Timed: Type = 4;
3648    pub const kFramework_ROS: Type = 5;
3649    pub const kFramework_RobotBuilder: Type = 6;
3650    pub const kRobotDrive_ArcadeStandard: Type = 1;
3651    pub const kRobotDrive_ArcadeButtonSpin: Type = 2;
3652    pub const kRobotDrive_ArcadeRatioCurve: Type = 3;
3653    pub const kRobotDrive_Tank: Type = 4;
3654    pub const kRobotDrive_MecanumPolar: Type = 5;
3655    pub const kRobotDrive_MecanumCartesian: Type = 6;
3656    pub const kRobotDrive2_DifferentialArcade: Type = 7;
3657    pub const kRobotDrive2_DifferentialTank: Type = 8;
3658    pub const kRobotDrive2_DifferentialCurvature: Type = 9;
3659    pub const kRobotDrive2_MecanumCartesian: Type = 10;
3660    pub const kRobotDrive2_MecanumPolar: Type = 11;
3661    pub const kRobotDrive2_KilloughCartesian: Type = 12;
3662    pub const kRobotDrive2_KilloughPolar: Type = 13;
3663    pub const kDriverStationCIO_Analog: Type = 1;
3664    pub const kDriverStationCIO_DigitalIn: Type = 2;
3665    pub const kDriverStationCIO_DigitalOut: Type = 3;
3666    pub const kDriverStationEIO_Acceleration: Type = 1;
3667    pub const kDriverStationEIO_AnalogIn: Type = 2;
3668    pub const kDriverStationEIO_AnalogOut: Type = 3;
3669    pub const kDriverStationEIO_Button: Type = 4;
3670    pub const kDriverStationEIO_LED: Type = 5;
3671    pub const kDriverStationEIO_DigitalIn: Type = 6;
3672    pub const kDriverStationEIO_DigitalOut: Type = 7;
3673    pub const kDriverStationEIO_FixedDigitalOut: Type = 8;
3674    pub const kDriverStationEIO_PWM: Type = 9;
3675    pub const kDriverStationEIO_Encoder: Type = 10;
3676    pub const kDriverStationEIO_TouchSlider: Type = 11;
3677    pub const kADXL345_SPI: Type = 1;
3678    pub const kADXL345_I2C: Type = 2;
3679    pub const kCommand_Scheduler: Type = 1;
3680    pub const kSmartDashboard_Instance: Type = 1;
3681}
3682pub mod HAL_EncoderIndexingType {
3683    /// The type of index pulse for the encoder.
3684    pub type Type = i32;
3685    pub const HAL_kResetWhileHigh: Type = 0;
3686    pub const HAL_kResetWhileLow: Type = 1;
3687    pub const HAL_kResetOnFallingEdge: Type = 2;
3688    pub const HAL_kResetOnRisingEdge: Type = 3;
3689}
3690pub mod HAL_EncoderEncodingType {
3691    /// The encoding scaling of the encoder.
3692    pub type Type = i32;
3693    pub const HAL_Encoder_k1X: Type = 0;
3694    pub const HAL_Encoder_k2X: Type = 1;
3695    pub const HAL_Encoder_k4X: Type = 2;
3696}
3697extern "C" {
3698    /// Initializes an encoder.
3699    ///
3700    /// @param digitalSourceHandleA the A source (either a HAL_DigitalHandle or a
3701    /// HAL_AnalogTriggerHandle)
3702    /// @param analogTriggerTypeA   the analog trigger type of the A source if it is
3703    /// an analog trigger
3704    /// @param digitalSourceHandleB the B source (either a HAL_DigitalHandle or a
3705    /// HAL_AnalogTriggerHandle)
3706    /// @param analogTriggerTypeB   the analog trigger type of the B source if it is
3707    /// an analog trigger
3708    /// @param reverseDirection     true to reverse the counting direction from
3709    /// standard, otherwise false
3710    /// @param encodingType         the encoding type
3711    ///@return                     the created encoder handle
3712    pub fn HAL_InitializeEncoder(
3713        digitalSourceHandleA: HAL_Handle,
3714        analogTriggerTypeA: HAL_AnalogTriggerType::Type,
3715        digitalSourceHandleB: HAL_Handle,
3716        analogTriggerTypeB: HAL_AnalogTriggerType::Type,
3717        reverseDirection: HAL_Bool,
3718        encodingType: HAL_EncoderEncodingType::Type,
3719        status: *mut i32,
3720    ) -> HAL_EncoderHandle;
3721}
3722extern "C" {
3723    /// Frees an encoder.
3724    ///
3725    /// @param encoderHandle the encoder handle
3726    pub fn HAL_FreeEncoder(encoderHandle: HAL_EncoderHandle, status: *mut i32);
3727}
3728extern "C" {
3729    /// Gets the current counts of the encoder after encoding type scaling.
3730    ///
3731    /// This is scaled by the value passed duing initialization to encodingType.
3732    ///
3733    /// @param encoderHandle the encoder handle
3734    /// @return the current scaled count
3735    pub fn HAL_GetEncoder(encoderHandle: HAL_EncoderHandle, status: *mut i32) -> i32;
3736}
3737extern "C" {
3738    /// Gets the raw counts of the encoder.
3739    ///
3740    /// This is not scaled by any values.
3741    ///
3742    /// @param encoderHandle the encoder handle
3743    /// @return              the raw encoder count
3744    pub fn HAL_GetEncoderRaw(encoderHandle: HAL_EncoderHandle, status: *mut i32) -> i32;
3745}
3746extern "C" {
3747    /// Gets the encoder scale value.
3748    ///
3749    /// This is set by the value passed during initialization to encodingType.
3750    ///
3751    /// @param encoderHandle the encoder handle
3752    /// @return              the encoder scale value
3753    pub fn HAL_GetEncoderEncodingScale(encoderHandle: HAL_EncoderHandle, status: *mut i32) -> i32;
3754}
3755extern "C" {
3756    /// Reads the current encoder value.
3757    ///
3758    /// Read the value at this instant. It may still be running, so it reflects the
3759    /// current value. Next time it is read, it might have a different value.
3760    ///
3761    /// @param encoderHandle the encoder handle
3762    /// @return              the current encoder value
3763    pub fn HAL_ResetEncoder(encoderHandle: HAL_EncoderHandle, status: *mut i32);
3764}
3765extern "C" {
3766    pub fn HAL_GetEncoderPeriod(encoderHandle: HAL_EncoderHandle, status: *mut i32) -> f64;
3767}
3768extern "C" {
3769    /// Sets the maximum period where the device is still considered "moving".
3770    ///
3771    /// Sets the maximum period where the device is considered moving. This value is
3772    /// used to determine the "stopped" state of the encoder using the
3773    /// HAL_GetEncoderStopped method.
3774    ///
3775    /// @param encoderHandle the encoder handle
3776    /// @param maxPeriod     the maximum period where the counted device is
3777    /// considered moving in seconds
3778    pub fn HAL_SetEncoderMaxPeriod(
3779        encoderHandle: HAL_EncoderHandle,
3780        maxPeriod: f64,
3781        status: *mut i32,
3782    );
3783}
3784extern "C" {
3785    /// Determines if the clock is stopped.
3786    ///
3787    /// Determines if the clocked input is stopped based on the MaxPeriod value set
3788    /// using the SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the
3789    /// device (and encoder) are assumed to be stopped and it returns true.
3790    ///
3791    /// @param encoderHandle the encoder handle
3792    /// @return              true if the most recent encoder period exceeds the
3793    /// MaxPeriod value set by SetMaxPeriod
3794    pub fn HAL_GetEncoderStopped(encoderHandle: HAL_EncoderHandle, status: *mut i32) -> HAL_Bool;
3795}
3796extern "C" {
3797    /// Gets the last direction the encoder value changed.
3798    ///
3799    /// @param encoderHandle the encoder handle
3800    /// @return              the last direction the encoder value changed
3801    pub fn HAL_GetEncoderDirection(encoderHandle: HAL_EncoderHandle, status: *mut i32) -> HAL_Bool;
3802}
3803extern "C" {
3804    /// Gets the current distance traveled by the encoder.
3805    ///
3806    /// This is the encoder count scaled by the distance per pulse set for the
3807    /// encoder.
3808    ///
3809    /// @param encoderHandle the encoder handle
3810    /// @return              the encoder distance (units are determined by the units
3811    /// passed to HAL_SetEncoderDistancePerPulse)
3812    pub fn HAL_GetEncoderDistance(encoderHandle: HAL_EncoderHandle, status: *mut i32) -> f64;
3813}
3814extern "C" {
3815    /// Gets the current rate of the encoder.
3816    ///
3817    /// This is the encoder period scaled by the distance per pulse set for the
3818    /// encoder.
3819    ///
3820    /// @param encoderHandle the encoder handle
3821    /// @return              the encoder rate (units are determined by the units
3822    /// passed to HAL_SetEncoderDistancePerPulse, time value is seconds)
3823    pub fn HAL_GetEncoderRate(encoderHandle: HAL_EncoderHandle, status: *mut i32) -> f64;
3824}
3825extern "C" {
3826    /// Sets the minimum rate to be considered moving by the encoder.
3827    ///
3828    /// Units need to match what is set by HAL_SetEncoderDistancePerPulse, with time
3829    /// as seconds.
3830    ///
3831    /// @param encoderHandle the encoder handle
3832    /// @param minRate       the minimum rate to be considered moving (units are
3833    /// determined by the units passed to HAL_SetEncoderDistancePerPulse, time value
3834    /// is seconds)
3835    pub fn HAL_SetEncoderMinRate(encoderHandle: HAL_EncoderHandle, minRate: f64, status: *mut i32);
3836}
3837extern "C" {
3838    /// Sets the distance traveled per encoder pulse. This is used as a scaling
3839    /// factor for the rate and distance calls.
3840    ///
3841    /// @param encoderHandle    the encoder handle
3842    /// @param distancePerPulse the distance traveled per encoder pulse (units user
3843    /// defined)
3844    pub fn HAL_SetEncoderDistancePerPulse(
3845        encoderHandle: HAL_EncoderHandle,
3846        distancePerPulse: f64,
3847        status: *mut i32,
3848    );
3849}
3850extern "C" {
3851    /// Sets if to reverse the direction of the encoder.
3852    ///
3853    /// Note that this is not a toggle. It is an absolute set.
3854    ///
3855    /// @param encoderHandle    the encoder handle
3856    /// @param reverseDirection true to reverse the direction, false to not.
3857    pub fn HAL_SetEncoderReverseDirection(
3858        encoderHandle: HAL_EncoderHandle,
3859        reverseDirection: HAL_Bool,
3860        status: *mut i32,
3861    );
3862}
3863extern "C" {
3864    /// Sets the number of encoder samples to average when calculating encoder rate.
3865    ///
3866    /// @param encoderHandle    the encoder handle
3867    /// @param samplesToAverage the number of samples to average
3868    pub fn HAL_SetEncoderSamplesToAverage(
3869        encoderHandle: HAL_EncoderHandle,
3870        samplesToAverage: i32,
3871        status: *mut i32,
3872    );
3873}
3874extern "C" {
3875    /// Gets the current samples to average value.
3876    ///
3877    /// @param encoderHandle the encoder handle
3878    /// @return              the current samples to average value
3879    pub fn HAL_GetEncoderSamplesToAverage(
3880        encoderHandle: HAL_EncoderHandle,
3881        status: *mut i32,
3882    ) -> i32;
3883}
3884extern "C" {
3885    /// Sets the source for an index pulse on the encoder.
3886    ///
3887    /// The index pulse can be used to cause an encoder to reset based on an external
3888    /// input.
3889    ///
3890    /// @param encoderHandle       the encoder handle
3891    /// @param digitalSourceHandle the index source handle (either a
3892    /// HAL_AnalogTriggerHandle of a HAL_DigitalHandle)
3893    /// @param analogTriggerType   the analog trigger type if the source is an analog
3894    /// trigger
3895    /// @param type                the index triggering type
3896    pub fn HAL_SetEncoderIndexSource(
3897        encoderHandle: HAL_EncoderHandle,
3898        digitalSourceHandle: HAL_Handle,
3899        analogTriggerType: HAL_AnalogTriggerType::Type,
3900        type_: HAL_EncoderIndexingType::Type,
3901        status: *mut i32,
3902    );
3903}
3904extern "C" {
3905    /// Gets the FPGA index of the encoder.
3906    ///
3907    /// @param encoderHandle the encoder handle
3908    /// @return              the FPGA index of the encoder
3909    pub fn HAL_GetEncoderFPGAIndex(encoderHandle: HAL_EncoderHandle, status: *mut i32) -> i32;
3910}
3911extern "C" {
3912    /// Gets the decoding scale factor of the encoder.
3913    ///
3914    /// This is used to perform the scaling from raw to type scaled values.
3915    ///
3916    /// @param encoderHandle the encoder handle
3917    /// @return              the scale value for the encoder
3918    pub fn HAL_GetEncoderDecodingScaleFactor(
3919        encoderHandle: HAL_EncoderHandle,
3920        status: *mut i32,
3921    ) -> f64;
3922}
3923extern "C" {
3924    /// Gets the user set distance per pulse of the encoder.
3925    ///
3926    /// @param encoderHandle the encoder handle
3927    /// @return              the set distance per pulse
3928    pub fn HAL_GetEncoderDistancePerPulse(
3929        encoderHandle: HAL_EncoderHandle,
3930        status: *mut i32,
3931    ) -> f64;
3932}
3933extern "C" {
3934    /// Gets the encoding type of the encoder.
3935    ///
3936    /// @param encoderHandle the encoder handle
3937    /// @return              the encoding type
3938    pub fn HAL_GetEncoderEncodingType(
3939        encoderHandle: HAL_EncoderHandle,
3940        status: *mut i32,
3941    ) -> HAL_EncoderEncodingType::Type;
3942}