WPILibC++ 2023.4.3
AnalogAccumulator.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_analogaccumulator Analog Accumulator Functions
13 * @ingroup hal_capi
14 * @{
15 */
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/**
22 * Is the channel attached to an accumulator.
23 *
24 * @param[in] analogPortHandle Handle to the analog port.
25 * @param[out] status Error status variable. 0 on success.
26 * @return The analog channel is attached to an accumulator.
27 */
30
31/**
32 * Initialize the accumulator.
33 *
34 * @param[in] analogPortHandle Handle to the analog port.
35 * @param[out] status Error status variable. 0 on success.
36 */
39
40/**
41 * Resets the accumulator to the initial value.
42 *
43 * @param[in] analogPortHandle Handle to the analog port.
44 * @param[out] status Error status variable. 0 on success.
45 */
48
49/**
50 * Set the center value of the accumulator.
51 *
52 * The center value is subtracted from each A/D value before it is added to the
53 * accumulator. This is used for the center value of devices like gyros and
54 * accelerometers to make integration work and to take the device offset into
55 * account when integrating.
56 *
57 * This center value is based on the output of the oversampled and averaged
58 * source from channel 1. Because of this, any non-zero oversample bits will
59 * affect the size of the value for this field.
60 *
61 * @param[in] analogPortHandle Handle to the analog port.
62 * @param[in] center The center value of the accumulator.
63 * @param[out] status Error status variable. 0 on success.
64 */
66 int32_t center, int32_t* status);
67
68/**
69 * Set the accumulator's deadband.
70 *
71 * @param[in] analogPortHandle Handle to the analog port.
72 * @param[in] deadband The deadband of the accumulator.
73 * @param[out] status Error status variable. 0 on success.
74 */
76 int32_t deadband, int32_t* status);
77
78/**
79 * Read the accumulated value.
80 *
81 * Read the value that has been accumulating on channel 1.
82 * The accumulator is attached after the oversample and average engine.
83 *
84 * @param[in] analogPortHandle Handle to the analog port.
85 * @param[out] status Error status variable. 0 on success.
86 * @return The 64-bit value accumulated since the last Reset().
87 */
90
91/**
92 * Read the number of accumulated values.
93 *
94 * Read the count of the accumulated values since the accumulator was last
95 * Reset().
96 *
97 * @param[in] analogPortHandle Handle to the analog port.
98 * @param[out] status Error status variable. 0 on success.
99 * @return The number of times samples from the channel were accumulated.
100 */
102 int32_t* status);
103
104/**
105 * Read the accumulated value and the number of accumulated values atomically.
106 *
107 * This function reads the value and count from the FPGA atomically.
108 * This can be used for averaging.
109 *
110 * @param[in] analogPortHandle Handle to the analog port.
111 * @param[in] value Pointer to the 64-bit accumulated output.
112 * @param[in] count Pointer to the number of accumulation cycles.
113 * @param[out] status Error status variable. 0 on success.
114 */
117#ifdef __cplusplus
118} // extern "C"
119#endif
120/** @} */
Definition: core.h:1240
constexpr auto count() -> size_t
Definition: core.h:1204
void HAL_SetAccumulatorCenter(HAL_AnalogInputHandle analogPortHandle, int32_t center, int32_t *status)
Set the center value of the accumulator.
void HAL_GetAccumulatorOutput(HAL_AnalogInputHandle analogPortHandle, int64_t *value, int64_t *count, int32_t *status)
Read the accumulated value and the number of accumulated values atomically.
int64_t HAL_GetAccumulatorValue(HAL_AnalogInputHandle analogPortHandle, int32_t *status)
Read the accumulated value.
int64_t HAL_GetAccumulatorCount(HAL_AnalogInputHandle analogPortHandle, int32_t *status)
Read the number of accumulated values.
HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analogPortHandle, int32_t *status)
Is the channel attached to an accumulator.
void HAL_InitAccumulator(HAL_AnalogInputHandle analogPortHandle, int32_t *status)
Initialize the accumulator.
void HAL_SetAccumulatorDeadband(HAL_AnalogInputHandle analogPortHandle, int32_t deadband, int32_t *status)
Set the accumulator's deadband.
void HAL_ResetAccumulator(HAL_AnalogInputHandle analogPortHandle, int32_t *status)
Resets the accumulator to the initial value.
int32_t HAL_Bool
Definition: Types.h:73
HAL_Handle HAL_AnalogInputHandle
Definition: Types.h:21
::int32_t int32_t
Definition: Meta.h:57
::int64_t int64_t
Definition: Meta.h:59
GHC_FS_API file_status status(const path &p, std::error_code &ec) noexcept
Definition: filesystem.hpp:4892