WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
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 "wpi/hal/Types.h"
8
9/**
10 * @defgroup hal_dutycycle DutyCycle Functions
11 * @ingroup hal_capi
12 * @{
13 */
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/**
20 * Initialize a DutyCycle input.
21 *
22 * @param[in] channel the smartio channel
23 * @param[in] allocationLocation the location where the allocation is occurring
24 * (can be null)
25 * @param[out] status Error status variable. 0 on success.
26 * @return the created duty cycle handle
27 */
29 const char* allocationLocation,
30 int32_t* status);
31
32/**
33 * Free a DutyCycle.
34 *
35 * @param dutyCycleHandle the duty cycle handle
36 */
38
39/**
40 * Indicates the duty cycle is used by a simulated device.
41 *
42 * @param handle the duty cycle handle
43 * @param device simulated device handle
44 */
46 HAL_SimDeviceHandle device);
47
48/**
49 * Get the frequency of the duty cycle signal.
50 *
51 * @param[in] dutyCycleHandle the duty cycle handle
52 * @param[out] status Error status variable. 0 on success.
53 * @return frequency in Hertz
54 */
56 int32_t* status);
57
58/**
59 * Get the output ratio of the duty cycle signal.
60 *
61 * <p> 0 means always low, 1 means always high.
62 *
63 * @param[in] dutyCycleHandle the duty cycle handle
64 * @param[out] status Error status variable. 0 on success.
65 * @return output ratio between 0 and 1
66 */
68 int32_t* status);
69
70/**
71 * Get the raw high time of the duty cycle signal.
72 *
73 * @param[in] dutyCycleHandle the duty cycle handle
74 * @param[out] status Error status variable. 0 on success.
75 * @return high time of last pulse in nanoseconds
76 */
78 int32_t* status);
79
80#ifdef __cplusplus
81} // extern "C"
82#endif
83/** @} */
int32_t HAL_GetDutyCycleHighTime(HAL_DutyCycleHandle dutyCycleHandle, int32_t *status)
Get the raw high time of the duty cycle signal.
double HAL_GetDutyCycleFrequency(HAL_DutyCycleHandle dutyCycleHandle, int32_t *status)
Get the frequency of the duty cycle signal.
double HAL_GetDutyCycleOutput(HAL_DutyCycleHandle dutyCycleHandle, int32_t *status)
Get the output ratio of the duty cycle signal.
void HAL_FreeDutyCycle(HAL_DutyCycleHandle dutyCycleHandle)
Free a DutyCycle.
void HAL_SetDutyCycleSimDevice(HAL_DutyCycleHandle handle, HAL_SimDeviceHandle device)
Indicates the duty cycle is used by a simulated device.
HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel, const char *allocationLocation, int32_t *status)
Initialize a DutyCycle input.
HAL_Handle HAL_SimDeviceHandle
Definition Types.h:53
HAL_Handle HAL_DutyCycleHandle
Definition Types.h:59