WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
Relay.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include "hal/Types.h"
10
11/**
12 * @defgroup hal_relay Relay Output Functions
13 * @ingroup hal_capi
14 * @{
15 */
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/**
22 * Initializes a relay.
23 *
24 * Note this call will only initialize either the forward or reverse port of the
25 * relay. If you need both, you will need to initialize 2 relays.
26 *
27 * @param[in] portHandle the port handle to initialize
28 * @param[in] fwd true for the forward port, false for the
29 * reverse port
30 * @param[in] allocationLocation the location where the allocation is occurring
31 * (can be null)
32 * @param[out] status Error status variable. 0 on success.
33 * @return the created relay handle
34 */
36 const char* allocationLocation,
37 int32_t* status);
38
39/**
40 * Frees a relay port.
41 *
42 * @param relayPortHandle the relay handle
43 */
44void HAL_FreeRelayPort(HAL_RelayHandle relayPortHandle);
45
46/**
47 * Checks if a relay channel is valid.
48 *
49 * @param channel the channel to check
50 * @return true if the channel is valid, otherwise false
51 */
53
54/**
55 * Sets the state of a relay output.
56 *
57 * @param[in] relayPortHandle the relay handle
58 * @param[in] on true for on, false for off
59 * @param[out] status Error status variable. 0 on success.
60 */
61void HAL_SetRelay(HAL_RelayHandle relayPortHandle, HAL_Bool on,
62 int32_t* status);
63
64/**
65 * Gets the current state of the relay channel.
66 *
67 * @param[in] relayPortHandle the relay handle
68 * @param[out] status Error status variable. 0 on success.
69 * @return true for on, false for off
70 */
71HAL_Bool HAL_GetRelay(HAL_RelayHandle relayPortHandle, int32_t* status);
72#ifdef __cplusplus
73} // extern "C"
74#endif
75/** @} */
void HAL_SetRelay(HAL_RelayHandle relayPortHandle, HAL_Bool on, int32_t *status)
Sets the state of a relay output.
void HAL_FreeRelayPort(HAL_RelayHandle relayPortHandle)
Frees a relay port.
HAL_Bool HAL_GetRelay(HAL_RelayHandle relayPortHandle, int32_t *status)
Gets the current state of the relay channel.
HAL_Bool HAL_CheckRelayChannel(int32_t channel)
Checks if a relay channel is valid.
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd, const char *allocationLocation, int32_t *status)
Initializes a relay.
int32_t HAL_Bool
Definition Types.h:73
HAL_Handle HAL_PortHandle
Definition Types.h:19
HAL_Handle HAL_RelayHandle
Definition Types.h:45