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