blob: c81dc1ab70dbca19eb805ef67bd55f8a8ac3f113 [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001/*----------------------------------------------------------------------------*/
Austin Schuh1e69f942020-11-14 15:06:14 -08002/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
Brian Silverman8fce7482020-01-05 13:18:21 -08003/* 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 Silverman8fce7482020-01-05 13:18:21 -080011#include "hal/Errors.h"
12#include "hal/Solenoid.h"
13
14namespace hal {
15
16std::unique_ptr<PCM> PCM_modules[kNumPCMModules];
17
18namespace init {
19void InitializePCMInternal() {
20 for (int i = 0; i < kNumPCMModules; i++) {
21 PCM_modules[i] = nullptr;
22 }
23}
24} // namespace init
25
26void 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