Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
| 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 Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 11 | |
Austin Schuh | 9950f68 | 2021-11-06 15:27:58 -0700 | [diff] [blame] | 12 | #include "frc971/wpilib/ahal/WPIErrors.h" |
Austin Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame] | 13 | #include "hal/AnalogInput.h" |
| 14 | #include "hal/AnalogOutput.h" |
| 15 | #include "hal/DIO.h" |
| 16 | #include "hal/HAL.h" |
Austin Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame] | 17 | #include "hal/PWM.h" |
| 18 | #include "hal/Ports.h" |
Austin Schuh | 9950f68 | 2021-11-06 15:27:58 -0700 | [diff] [blame] | 19 | #include "hal/PowerDistribution.h" |
Austin Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame] | 20 | #include "hal/Relay.h" |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 21 | |
| 22 | namespace frc { |
| 23 | |
| 24 | const int kDigitalChannels = HAL_GetNumDigitalChannels(); |
| 25 | const int kAnalogInputs = HAL_GetNumAnalogInputs(); |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 26 | const int kPwmChannels = HAL_GetNumPWMChannels(); |
| 27 | const int kRelayChannels = HAL_GetNumRelayHeaders(); |
Austin Schuh | 9950f68 | 2021-11-06 15:27:58 -0700 | [diff] [blame] | 28 | const int kCTREPDPChannels = HAL_GetNumCTREPDPChannels(); |
| 29 | const int kREVPDPChannels = HAL_GetNumREVPDHChannels(); |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 30 | |
| 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 | */ |
| 39 | bool 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 | */ |
| 49 | bool 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 | */ |
| 59 | bool 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 | */ |
| 69 | bool 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 | */ |
| 81 | bool CheckAnalogOutputChannel(int channel) { |
| 82 | return HAL_CheckAnalogOutputChannel(channel); |
| 83 | } |
| 84 | |
| 85 | /** |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 86 | * Verify that the power distribution channel number is within limits. |
| 87 | * |
| 88 | * @return PDP channel is valid |
| 89 | */ |
Austin Schuh | 9950f68 | 2021-11-06 15:27:58 -0700 | [diff] [blame] | 90 | bool CheckPDPChannel(int channel, HAL_PowerDistributionType type) { |
| 91 | return HAL_CheckPowerDistributionModule(channel, type); |
| 92 | } |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 93 | |
| 94 | } // namespace frc |