Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame^] | 2 | /* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */ |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 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 "PCMInternal.h" |
| 9 | |
| 10 | #include "HALInitializer.h" |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 11 | #include "hal/Errors.h" |
| 12 | #include "hal/Solenoid.h" |
| 13 | |
| 14 | namespace hal { |
| 15 | |
| 16 | std::unique_ptr<PCM> PCM_modules[kNumPCMModules]; |
| 17 | |
| 18 | namespace init { |
| 19 | void InitializePCMInternal() { |
| 20 | for (int i = 0; i < kNumPCMModules; i++) { |
| 21 | PCM_modules[i] = nullptr; |
| 22 | } |
| 23 | } |
| 24 | } // namespace init |
| 25 | |
| 26 | void initializePCM(int32_t module, int32_t* status) { |
| 27 | hal::init::CheckInit(); |
| 28 | if (!HAL_CheckSolenoidModule(module)) { |
| 29 | *status = RESOURCE_OUT_OF_RANGE; |
| 30 | return; |
| 31 | } |
| 32 | if (!PCM_modules[module]) { |
| 33 | PCM_modules[module] = std::make_unique<PCM>(module); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | } // namespace hal |