WPILibC++ 2024.3.2
DutyCycle.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 "hal/AnalogTrigger.h"
8#include "hal/Types.h"
9
10/**
11 * @defgroup hal_dutycycle DutyCycle Functions
12 * @ingroup hal_capi
13 * @{
14 */
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/**
21 * Initialize a DutyCycle input.
22 *
23 * @param[in] digitalSourceHandle the digital source to use (either a
24 * HAL_DigitalHandle or a
25 * HAL_AnalogTriggerHandle)
26 * @param[in] triggerType the analog trigger type of the source if it is
27 * an analog trigger
28 * @param[out] status Error status variable. 0 on success.
29 * @return the created duty cycle handle
30 */
32 HAL_AnalogTriggerType triggerType,
33 int32_t* status);
34
35/**
36 * Free a DutyCycle.
37 *
38 * @param dutyCycleHandle the duty cycle handle
39 */
41
42/**
43 * Indicates the duty cycle is used by a simulated device.
44 *
45 * @param handle the duty cycle handle
46 * @param device simulated device handle
47 */
49 HAL_SimDeviceHandle device);
50
51/**
52 * Get the frequency of the duty cycle signal.
53 *
54 * @param[in] dutyCycleHandle the duty cycle handle
55 * @param[out] status Error status variable. 0 on success.
56 * @return frequency in Hertz
57 */
59 int32_t* status);
60
61/**
62 * Get the output ratio of the duty cycle signal.
63 *
64 * <p> 0 means always low, 1 means always high.
65 *
66 * @param[in] dutyCycleHandle the duty cycle handle
67 * @param[out] status Error status variable. 0 on success.
68 * @return output ratio between 0 and 1
69 */
71 int32_t* status);
72
73/**
74 * Get the raw high time of the duty cycle signal.
75 *
76 * @param[in] dutyCycleHandle the duty cycle handle
77 * @param[out] status Error status variable. 0 on success.
78 * @return high time of last pulse in nanoseconds
79 */
81 int32_t* status);
82
83/**
84 * Get the scale factor of the output.
85 *
86 * <p> An output equal to this value is always high, and then linearly scales
87 * down to 0. Divide a raw result by this in order to get the
88 * percentage between 0 and 1. Used by DMA.
89 *
90 * @param[in] dutyCycleHandle the duty cycle handle
91 * @param[out] status Error status variable. 0 on success.
92 * @return the output scale factor
93 */
95 int32_t* status);
96
97/**
98 * Get the FPGA index for the DutyCycle.
99 *
100 * @param[in] dutyCycleHandle the duty cycle handle
101 * @param[out] status Error status variable. 0 on success.
102 * @return the FPGA index
103 */
105 int32_t* status);
106
107#ifdef __cplusplus
108} // extern "C"
109#endif
110/** @} */
HAL_AnalogTriggerType
The type of analog trigger to trigger on.
Definition: AnalogTrigger.h:20
int32_t HAL_GetDutyCycleHighTime(HAL_DutyCycleHandle dutyCycleHandle, int32_t *status)
Get the raw high time of the duty cycle signal.
double HAL_GetDutyCycleOutput(HAL_DutyCycleHandle dutyCycleHandle, int32_t *status)
Get the output ratio of the duty cycle signal.
int32_t HAL_GetDutyCycleFPGAIndex(HAL_DutyCycleHandle dutyCycleHandle, int32_t *status)
Get the FPGA index for the DutyCycle.
void HAL_FreeDutyCycle(HAL_DutyCycleHandle dutyCycleHandle)
Free a DutyCycle.
int32_t HAL_GetDutyCycleOutputScaleFactor(HAL_DutyCycleHandle dutyCycleHandle, int32_t *status)
Get the scale factor of the output.
HAL_DutyCycleHandle HAL_InitializeDutyCycle(HAL_Handle digitalSourceHandle, HAL_AnalogTriggerType triggerType, int32_t *status)
Initialize a DutyCycle input.
void HAL_SetDutyCycleSimDevice(HAL_DutyCycleHandle handle, HAL_SimDeviceHandle device)
Indicates the duty cycle is used by a simulated device.
int32_t HAL_GetDutyCycleFrequency(HAL_DutyCycleHandle dutyCycleHandle, int32_t *status)
Get the frequency of the duty cycle signal.
int32_t HAL_Handle
Definition: Types.h:17
HAL_Handle HAL_SimDeviceHandle
Definition: Types.h:53
HAL_Handle HAL_DutyCycleHandle
Definition: Types.h:59