blob: 471618705b2683d912b8f4a108a1e5f02d13ad8f [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"
Philipp Schrader790cb542023-07-05 21:06:52 -070011
Austin Schuh9950f682021-11-06 15:27:58 -070012#include "frc971/wpilib/ahal/WPIErrors.h"
Austin Schuhf6b94632019-02-02 22:11:27 -080013#include "hal/AnalogInput.h"
14#include "hal/AnalogOutput.h"
15#include "hal/DIO.h"
16#include "hal/HAL.h"
Austin Schuhf6b94632019-02-02 22:11:27 -080017#include "hal/PWM.h"
18#include "hal/Ports.h"
Austin Schuh9950f682021-11-06 15:27:58 -070019#include "hal/PowerDistribution.h"
Austin Schuhf6b94632019-02-02 22:11:27 -080020#include "hal/Relay.h"
Parker Schuhd3b7a8872018-02-19 16:42:27 -080021
22namespace frc {
23
24const int kDigitalChannels = HAL_GetNumDigitalChannels();
25const int kAnalogInputs = HAL_GetNumAnalogInputs();
Parker Schuhd3b7a8872018-02-19 16:42:27 -080026const int kPwmChannels = HAL_GetNumPWMChannels();
27const int kRelayChannels = HAL_GetNumRelayHeaders();
Austin Schuh9950f682021-11-06 15:27:58 -070028const int kCTREPDPChannels = HAL_GetNumCTREPDPChannels();
29const int kREVPDPChannels = HAL_GetNumREVPDHChannels();
Parker Schuhd3b7a8872018-02-19 16:42:27 -080030
31/**
32 * Check that the digital channel number is valid.
33 *
34 * Verify that the channel number is one of the legal channel numbers. Channel
35 * numbers are 1-based.
36 *
37 * @return Digital channel is valid
38 */
39bool CheckDigitalChannel(int channel) { return HAL_CheckDIOChannel(channel); }
40
41/**
42 * Check that the relay channel number is valid.
43 *
44 * Verify that the channel number is one of the legal channel numbers. Channel
45 * numbers are 0-based.
46 *
47 * @return Relay channel is valid
48 */
49bool CheckRelayChannel(int channel) { return HAL_CheckRelayChannel(channel); }
50
51/**
52 * Check that the digital channel number is valid.
53 *
54 * Verify that the channel number is one of the legal channel numbers. Channel
55 * numbers are 1-based.
56 *
57 * @return PWM channel is valid
58 */
59bool CheckPWMChannel(int channel) { return HAL_CheckPWMChannel(channel); }
60
61/**
62 * Check that the analog input number is value.
63 *
64 * Verify that the analog input number is one of the legal channel numbers.
65 * Channel numbers are 0-based.
66 *
67 * @return Analog channel is valid
68 */
69bool CheckAnalogInputChannel(int channel) {
70 return HAL_CheckAnalogInputChannel(channel);
71}
72
73/**
74 * Check that the analog output number is valid.
75 *
76 * Verify that the analog output number is one of the legal channel numbers.
77 * Channel numbers are 0-based.
78 *
79 * @return Analog channel is valid
80 */
81bool CheckAnalogOutputChannel(int channel) {
82 return HAL_CheckAnalogOutputChannel(channel);
83}
84
85/**
Parker Schuhd3b7a8872018-02-19 16:42:27 -080086 * Verify that the power distribution channel number is within limits.
87 *
88 * @return PDP channel is valid
89 */
Austin Schuh9950f682021-11-06 15:27:58 -070090bool CheckPDPChannel(int channel, HAL_PowerDistributionType type) {
91 return HAL_CheckPowerDistributionModule(channel, type);
92}
Parker Schuhd3b7a8872018-02-19 16:42:27 -080093
94} // namespace frc