blob: 0b796f123237ec5920570278b79fa9eee93cf0d9 [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 Schuhf6b94632019-02-02 22:11:27 -080011#include "hal/AnalogInput.h"
12#include "hal/AnalogOutput.h"
13#include "hal/DIO.h"
14#include "hal/HAL.h"
15#include "hal/PDP.h"
16#include "hal/PWM.h"
17#include "hal/Ports.h"
18#include "hal/Relay.h"
19#include "hal/Solenoid.h"
Parker Schuhd3b7a8872018-02-19 16:42:27 -080020#include "frc971/wpilib/ahal/WPIErrors.h"
21
22namespace frc {
23
24const int kDigitalChannels = HAL_GetNumDigitalChannels();
25const int kAnalogInputs = HAL_GetNumAnalogInputs();
26const int kSolenoidChannels = HAL_GetNumSolenoidChannels();
27const int kSolenoidModules = HAL_GetNumPCMModules();
28const int kPwmChannels = HAL_GetNumPWMChannels();
29const int kRelayChannels = HAL_GetNumRelayHeaders();
30const int kPDPChannels = HAL_GetNumPDPChannels();
31
32/**
33 * Check that the solenoid module number is valid.
34 *
35 * @return Solenoid module is valid and present
36 */
37bool CheckSolenoidModule(int moduleNumber) {
38 return HAL_CheckSolenoidModule(moduleNumber);
39}
40
41/**
42 * Check that the digital channel number is valid.
43 *
44 * Verify that the channel number is one of the legal channel numbers. Channel
45 * numbers are 1-based.
46 *
47 * @return Digital channel is valid
48 */
49bool CheckDigitalChannel(int channel) { return HAL_CheckDIOChannel(channel); }
50
51/**
52 * Check that the relay channel number is valid.
53 *
54 * Verify that the channel number is one of the legal channel numbers. Channel
55 * numbers are 0-based.
56 *
57 * @return Relay channel is valid
58 */
59bool CheckRelayChannel(int channel) { return HAL_CheckRelayChannel(channel); }
60
61/**
62 * Check that the digital channel number is valid.
63 *
64 * Verify that the channel number is one of the legal channel numbers. Channel
65 * numbers are 1-based.
66 *
67 * @return PWM channel is valid
68 */
69bool CheckPWMChannel(int channel) { return HAL_CheckPWMChannel(channel); }
70
71/**
72 * Check that the analog input number is value.
73 *
74 * Verify that the analog input number is one of the legal channel numbers.
75 * Channel numbers are 0-based.
76 *
77 * @return Analog channel is valid
78 */
79bool CheckAnalogInputChannel(int channel) {
80 return HAL_CheckAnalogInputChannel(channel);
81}
82
83/**
84 * Check that the analog output number is valid.
85 *
86 * Verify that the analog output number is one of the legal channel numbers.
87 * Channel numbers are 0-based.
88 *
89 * @return Analog channel is valid
90 */
91bool CheckAnalogOutputChannel(int channel) {
92 return HAL_CheckAnalogOutputChannel(channel);
93}
94
95/**
96 * Verify that the solenoid channel number is within limits.
97 *
98 * @return Solenoid channel is valid
99 */
100bool CheckSolenoidChannel(int channel) {
101 return HAL_CheckSolenoidChannel(channel);
102}
103
104/**
105 * Verify that the power distribution channel number is within limits.
106 *
107 * @return PDP channel is valid
108 */
109bool CheckPDPChannel(int channel) { return HAL_CheckPDPModule(channel); }
110
111} // namespace frc