blob: 111e4c6fba349d5ad2b3d7b05a503d820cdf3b22 [file] [log] [blame]
Parker Schuhd3b7a8872018-02-19 16:42:27 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#include "frc971/wpilib/ahal/SensorBase.h"
9
10#include "FRC_NetworkCommunication/LoadOut.h"
Austin Schuh9950f682021-11-06 15:27:58 -070011#include "frc971/wpilib/ahal/WPIErrors.h"
Austin Schuhf6b94632019-02-02 22:11:27 -080012#include "hal/AnalogInput.h"
13#include "hal/AnalogOutput.h"
14#include "hal/DIO.h"
15#include "hal/HAL.h"
Austin Schuhf6b94632019-02-02 22:11:27 -080016#include "hal/PWM.h"
17#include "hal/Ports.h"
Austin Schuh9950f682021-11-06 15:27:58 -070018#include "hal/PowerDistribution.h"
Austin Schuhf6b94632019-02-02 22:11:27 -080019#include "hal/Relay.h"
Parker Schuhd3b7a8872018-02-19 16:42:27 -080020
21namespace frc {
22
23const int kDigitalChannels = HAL_GetNumDigitalChannels();
24const int kAnalogInputs = HAL_GetNumAnalogInputs();
Parker Schuhd3b7a8872018-02-19 16:42:27 -080025const int kPwmChannels = HAL_GetNumPWMChannels();
26const int kRelayChannels = HAL_GetNumRelayHeaders();
Austin Schuh9950f682021-11-06 15:27:58 -070027const int kCTREPDPChannels = HAL_GetNumCTREPDPChannels();
28const int kREVPDPChannels = HAL_GetNumREVPDHChannels();
Parker Schuhd3b7a8872018-02-19 16:42:27 -080029
30/**
31 * Check that the digital channel number is valid.
32 *
33 * Verify that the channel number is one of the legal channel numbers. Channel
34 * numbers are 1-based.
35 *
36 * @return Digital channel is valid
37 */
38bool CheckDigitalChannel(int channel) { return HAL_CheckDIOChannel(channel); }
39
40/**
41 * Check that the relay channel number is valid.
42 *
43 * Verify that the channel number is one of the legal channel numbers. Channel
44 * numbers are 0-based.
45 *
46 * @return Relay channel is valid
47 */
48bool CheckRelayChannel(int channel) { return HAL_CheckRelayChannel(channel); }
49
50/**
51 * Check that the digital channel number is valid.
52 *
53 * Verify that the channel number is one of the legal channel numbers. Channel
54 * numbers are 1-based.
55 *
56 * @return PWM channel is valid
57 */
58bool CheckPWMChannel(int channel) { return HAL_CheckPWMChannel(channel); }
59
60/**
61 * Check that the analog input number is value.
62 *
63 * Verify that the analog input number is one of the legal channel numbers.
64 * Channel numbers are 0-based.
65 *
66 * @return Analog channel is valid
67 */
68bool CheckAnalogInputChannel(int channel) {
69 return HAL_CheckAnalogInputChannel(channel);
70}
71
72/**
73 * Check that the analog output number is valid.
74 *
75 * Verify that the analog output number is one of the legal channel numbers.
76 * Channel numbers are 0-based.
77 *
78 * @return Analog channel is valid
79 */
80bool CheckAnalogOutputChannel(int channel) {
81 return HAL_CheckAnalogOutputChannel(channel);
82}
83
84/**
Parker Schuhd3b7a8872018-02-19 16:42:27 -080085 * Verify that the power distribution channel number is within limits.
86 *
87 * @return PDP channel is valid
88 */
Austin Schuh9950f682021-11-06 15:27:58 -070089bool CheckPDPChannel(int channel, HAL_PowerDistributionType type) {
90 return HAL_CheckPowerDistributionModule(channel, type);
91}
Parker Schuhd3b7a8872018-02-19 16:42:27 -080092
93} // namespace frc