blob: dee64cf98682d3f024b85f719ef7e711cdde38e0 [file] [log] [blame]
Brian Silverman41cdd3e2019-01-19 19:48:58 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2016-2018 FIRST. 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 "PCMInternal.h"
9
10#include "HALInitializer.h"
11#include "PortsInternal.h"
12#include "hal/Errors.h"
13#include "hal/Solenoid.h"
14
15namespace hal {
16
17std::unique_ptr<PCM> PCM_modules[kNumPCMModules];
18
19namespace init {
20void InitializePCMInternal() {
21 for (int i = 0; i < kNumPCMModules; i++) {
22 PCM_modules[i] = nullptr;
23 }
24}
25} // namespace init
26
27void initializePCM(int32_t module, int32_t* status) {
28 hal::init::CheckInit();
29 if (!HAL_CheckSolenoidModule(module)) {
30 *status = RESOURCE_OUT_OF_RANGE;
31 return;
32 }
33 if (!PCM_modules[module]) {
34 PCM_modules[module] = std::make_unique<PCM>(module);
35 }
36}
37
38} // namespace hal