WPILibC++ 2024.3.2
DMA.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/Types.h>
8#include <units/time.h>
9
10namespace frc {
11class Encoder;
12class Counter;
13class DigitalSource;
14class DutyCycle;
15class AnalogInput;
16class DMASample;
17class PWM;
18class PWMMotorController;
19
20/**
21 * Class for configuring Direct Memory Access (DMA) of FPGA inputs.
22 */
23class DMA {
24 friend class DMASample;
25
26 public:
27 DMA();
29
30 DMA& operator=(DMA&& other) = default;
31 DMA(DMA&& other) = default;
32
33 /**
34 * Sets whether DMA is paused.
35 *
36 * @param pause True pauses DMA.
37 */
38 void SetPause(bool pause);
39
40 /**
41 * Sets DMA to trigger at an interval.
42 *
43 * @param period Period at which to trigger DMA.
44 */
45 void SetTimedTrigger(units::second_t period);
46
47 /**
48 * Sets number of DMA cycles to trigger.
49 *
50 * @param cycles Number of cycles.
51 */
52 void SetTimedTriggerCycles(int cycles);
53
54 /**
55 * Adds position data for an encoder to be collected by DMA.
56 *
57 * This can only be called if DMA is not started.
58 *
59 * @param encoder Encoder to add to DMA.
60 */
61 void AddEncoder(const Encoder* encoder);
62
63 /**
64 * Adds timer data for an encoder to be collected by DMA.
65 *
66 * This can only be called if DMA is not started.
67 *
68 * @param encoder Encoder to add to DMA.
69 */
70 void AddEncoderPeriod(const Encoder* encoder);
71
72 /**
73 * Adds position data for an counter to be collected by DMA.
74 *
75 * This can only be called if DMA is not started.
76 *
77 * @param counter Counter to add to DMA.
78 */
79 void AddCounter(const Counter* counter);
80
81 /**
82 * Adds timer data for an counter to be collected by DMA.
83 *
84 * This can only be called if DMA is not started.
85 *
86 * @param counter Counter to add to DMA.
87 */
88 void AddCounterPeriod(const Counter* counter);
89
90 /**
91 * Adds a digital source to be collected by DMA.
92 *
93 * This can only be called if DMA is not started.
94 *
95 * @param digitalSource DigitalSource to add to DMA.
96 */
97 void AddDigitalSource(const DigitalSource* digitalSource);
98
99 /**
100 * Adds a digital source to be collected by DMA.
101 *
102 * This can only be called if DMA is not started.
103 *
104 * @param digitalSource DigitalSource to add to DMA.
105 */
106 void AddDutyCycle(const DutyCycle* digitalSource);
107
108 /**
109 * Adds an analog input to be collected by DMA.
110 *
111 * This can only be called if DMA is not started.
112 *
113 * @param analogInput AnalogInput to add to DMA.
114 */
115 void AddAnalogInput(const AnalogInput* analogInput);
116
117 /**
118 * Adds averaged data of an analog input to be collected by DMA.
119 *
120 * This can only be called if DMA is not started.
121 *
122 * @param analogInput AnalogInput to add to DMA.
123 */
124 void AddAveragedAnalogInput(const AnalogInput* analogInput);
125
126 /**
127 * Adds accumulator data of an analog input to be collected by DMA.
128 *
129 * This can only be called if DMA is not started.
130 *
131 * @param analogInput AnalogInput to add to DMA.
132 */
133 void AddAnalogAccumulator(const AnalogInput* analogInput);
134
135 /**
136 * Sets an external DMA trigger.
137 *
138 * @param source the source to trigger from.
139 * @param rising trigger on rising edge.
140 * @param falling trigger on falling edge.
141 * @return the index of the trigger
142 */
143 int SetExternalTrigger(DigitalSource* source, bool rising, bool falling);
144
145 /**
146 * Sets a DMA PWM edge trigger.
147 *
148 * @param pwm the PWM to trigger from.
149 * @param rising trigger on rising edge.
150 * @param falling trigger on falling edge.
151 * @return the index of the trigger
152 */
153 int SetPwmEdgeTrigger(PWM* pwm, bool rising, bool falling);
154
155 /**
156 * Sets a DMA PWMMotorController edge trigger.
157 *
158 * @param pwm the PWMMotorController to trigger from.
159 * @param rising trigger on rising edge.
160 * @param falling trigger on falling edge.
161 * @return the index of the trigger
162 */
163 int SetPwmEdgeTrigger(PWMMotorController* pwm, bool rising, bool falling);
164
165 /**
166 * Clear all sensors from the DMA collection list.
167 *
168 * This can only be called if DMA is not started.
169 */
171
172 /**
173 * Clear all external triggers from the DMA trigger list.
174 *
175 * This can only be called if DMA is not started.
176 */
178
179 /**
180 * Starts DMA Collection.
181 *
182 * @param queueDepth The number of objects to be able to queue.
183 */
184 void Start(int queueDepth);
185
186 /**
187 * Stops DMA Collection.
188 */
189 void Stop();
190
191 private:
193};
194} // namespace frc
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation source
Definition: ThirdPartyNotices.txt:111
Analog input class.
Definition: AnalogInput.h:31
Class for counting the number of ticks on a digital input channel.
Definition: Counter.h:35
Class for configuring Direct Memory Access (DMA) of FPGA inputs.
Definition: DMA.h:23
void AddEncoderPeriod(const Encoder *encoder)
Adds timer data for an encoder to be collected by DMA.
void SetPause(bool pause)
Sets whether DMA is paused.
DMA(DMA &&other)=default
int SetPwmEdgeTrigger(PWM *pwm, bool rising, bool falling)
Sets a DMA PWM edge trigger.
void Stop()
Stops DMA Collection.
void AddDigitalSource(const DigitalSource *digitalSource)
Adds a digital source to be collected by DMA.
int SetExternalTrigger(DigitalSource *source, bool rising, bool falling)
Sets an external DMA trigger.
DMA & operator=(DMA &&other)=default
void SetTimedTriggerCycles(int cycles)
Sets number of DMA cycles to trigger.
void AddDutyCycle(const DutyCycle *digitalSource)
Adds a digital source to be collected by DMA.
void ClearSensors()
Clear all sensors from the DMA collection list.
void AddCounter(const Counter *counter)
Adds position data for an counter to be collected by DMA.
void Start(int queueDepth)
Starts DMA Collection.
void AddCounterPeriod(const Counter *counter)
Adds timer data for an counter to be collected by DMA.
void AddAnalogInput(const AnalogInput *analogInput)
Adds an analog input to be collected by DMA.
void AddAveragedAnalogInput(const AnalogInput *analogInput)
Adds averaged data of an analog input to be collected by DMA.
void SetTimedTrigger(units::second_t period)
Sets DMA to trigger at an interval.
void ClearExternalTriggers()
Clear all external triggers from the DMA trigger list.
void AddEncoder(const Encoder *encoder)
Adds position data for an encoder to be collected by DMA.
int SetPwmEdgeTrigger(PWMMotorController *pwm, bool rising, bool falling)
Sets a DMA PWMMotorController edge trigger.
void AddAnalogAccumulator(const AnalogInput *analogInput)
Adds accumulator data of an analog input to be collected by DMA.
DMA sample.
Definition: DMASample.h:23
DigitalSource Interface.
Definition: DigitalSource.h:22
Class to read a duty cycle PWM input.
Definition: DutyCycle.h:31
Class to read quad encoders.
Definition: Encoder.h:40
Class implements the PWM generation in the FPGA.
Definition: PWM.h:26
Common base class for all PWM Motor Controllers.
Definition: PWMMotorController.h:35
Definition: AprilTagPoseEstimator.h:15