[hal, wpilib] Remove DMA (#7701)

This commit is contained in:
Thad House
2025-01-17 14:05:34 -08:00
committed by GitHub
parent f80874dd4b
commit 1600e773f4
27 changed files with 1 additions and 2930 deletions

View File

@@ -13,9 +13,6 @@
namespace frc {
class DMA;
class DMASample;
/**
* Analog input class.
*
@@ -31,8 +28,6 @@ class DMASample;
class AnalogInput : public wpi::Sendable,
public wpi::SendableHelper<AnalogInput> {
friend class AnalogTrigger;
friend class DMA;
friend class DMASample;
public:
/**

View File

@@ -18,8 +18,6 @@
namespace frc {
class DigitalGlitchFilter;
class DMA;
class DMASample;
/**
* Class for counting the number of ticks on a digital input channel.
@@ -34,9 +32,6 @@ class DMASample;
class Counter : public CounterBase,
public wpi::Sendable,
public wpi::SendableHelper<Counter> {
friend class DMA;
friend class DMASample;
public:
enum Mode {
kTwoPulse = 0,

View File

@@ -1,193 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <hal/DMA.h>
#include <units/time.h>
namespace frc {
class Encoder;
class Counter;
class DigitalSource;
class DutyCycle;
class AnalogInput;
class DMASample;
class PWM;
class PWMMotorController;
/**
* Class for configuring Direct Memory Access (DMA) of FPGA inputs.
*/
class DMA {
friend class DMASample;
public:
DMA();
DMA& operator=(DMA&& other) = default;
DMA(DMA&& other) = default;
/**
* Sets whether DMA is paused.
*
* @param pause True pauses DMA.
*/
void SetPause(bool pause);
/**
* Sets DMA to trigger at an interval.
*
* @param period Period at which to trigger DMA.
*/
void SetTimedTrigger(units::second_t period);
/**
* Sets number of DMA cycles to trigger.
*
* @param cycles Number of cycles.
*/
void SetTimedTriggerCycles(int cycles);
/**
* Adds position data for an encoder to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param encoder Encoder to add to DMA.
*/
void AddEncoder(const Encoder* encoder);
/**
* Adds timer data for an encoder to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param encoder Encoder to add to DMA.
*/
void AddEncoderPeriod(const Encoder* encoder);
/**
* Adds position data for an counter to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param counter Counter to add to DMA.
*/
void AddCounter(const Counter* counter);
/**
* Adds timer data for an counter to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param counter Counter to add to DMA.
*/
void AddCounterPeriod(const Counter* counter);
/**
* Adds a digital source to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param digitalSource DigitalSource to add to DMA.
*/
void AddDigitalSource(const DigitalSource* digitalSource);
/**
* Adds a digital source to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param digitalSource DigitalSource to add to DMA.
*/
void AddDutyCycle(const DutyCycle* digitalSource);
/**
* Adds an analog input to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param analogInput AnalogInput to add to DMA.
*/
void AddAnalogInput(const AnalogInput* analogInput);
/**
* Adds averaged data of an analog input to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param analogInput AnalogInput to add to DMA.
*/
void AddAveragedAnalogInput(const AnalogInput* analogInput);
/**
* Adds accumulator data of an analog input to be collected by DMA.
*
* This can only be called if DMA is not started.
*
* @param analogInput AnalogInput to add to DMA.
*/
void AddAnalogAccumulator(const AnalogInput* analogInput);
/**
* Sets an external DMA trigger.
*
* @param source the source to trigger from.
* @param rising trigger on rising edge.
* @param falling trigger on falling edge.
* @return the index of the trigger
*/
int SetExternalTrigger(DigitalSource* source, bool rising, bool falling);
/**
* Sets a DMA PWM edge trigger.
*
* @param pwm the PWM to trigger from.
* @param rising trigger on rising edge.
* @param falling trigger on falling edge.
* @return the index of the trigger
*/
int SetPwmEdgeTrigger(PWM* pwm, bool rising, bool falling);
/**
* Sets a DMA PWMMotorController edge trigger.
*
* @param pwm the PWMMotorController to trigger from.
* @param rising trigger on rising edge.
* @param falling trigger on falling edge.
* @return the index of the trigger
*/
int SetPwmEdgeTrigger(PWMMotorController* pwm, bool rising, bool falling);
/**
* Clear all sensors from the DMA collection list.
*
* This can only be called if DMA is not started.
*/
void ClearSensors();
/**
* Clear all external triggers from the DMA trigger list.
*
* This can only be called if DMA is not started.
*/
void ClearExternalTriggers();
/**
* Starts DMA Collection.
*
* @param queueDepth The number of objects to be able to queue.
*/
void Start(int queueDepth);
/**
* Stops DMA Collection.
*/
void Stop();
private:
hal::Handle<HAL_DMAHandle, HAL_FreeDMA> dmaHandle;
};
} // namespace frc

View File

@@ -1,232 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <type_traits>
#include <hal/AnalogInput.h>
#include <hal/DMA.h>
#include <units/time.h>
#include "frc/AnalogInput.h"
#include "frc/Counter.h"
#include "frc/DMA.h"
#include "frc/DutyCycle.h"
#include "frc/Encoder.h"
namespace frc {
/**
* DMA sample.
*/
class DMASample : public HAL_DMASample {
public:
/**
* DMA read status.
*/
enum class DMAReadStatus {
/// OK status.
kOk = HAL_DMA_OK,
/// Timeout status.
kTimeout = HAL_DMA_TIMEOUT,
/// Error status.
kError = HAL_DMA_ERROR
};
/**
* Retrieves a new DMA sample.
*
* @param dma DMA object.
* @param timeout Timeout for retrieval.
* @param remaining Number of remaining samples.
* @param status DMA read status.
*/
DMAReadStatus Update(const DMA* dma, units::second_t timeout,
int32_t* remaining, int32_t* status) {
return static_cast<DMAReadStatus>(
HAL_ReadDMA(dma->dmaHandle, this, timeout.value(), remaining, status));
}
/**
* Returns the DMA sample time in microseconds.
*
* @return The DMA sample time in microseconds.
*/
uint64_t GetTime() const { return timeStamp; }
/**
* Returns the DMA sample timestamp.
*
* @return The DMA sample timestamp.
*/
units::second_t GetTimeStamp() const {
return units::second_t{static_cast<double>(GetTime()) * 1.0e-6};
}
/**
* Returns raw encoder value from DMA.
*
* @param encoder Encoder used for DMA.
* @param status DMA read status.
* @return Raw encoder value from DMA.
*/
int32_t GetEncoderRaw(const Encoder* encoder, int32_t* status) const {
return HAL_GetDMASampleEncoderRaw(this, encoder->m_encoder, status);
}
/**
* Returns encoder distance from DMA.
*
* @param encoder Encoder used for DMA.
* @param status DMA read status.
* @return Encoder distance from DMA.
*/
double GetEncoderDistance(const Encoder* encoder, int32_t* status) const {
double val = GetEncoderRaw(encoder, status);
val *= encoder->DecodingScaleFactor();
val *= encoder->GetDistancePerPulse();
return val;
}
/**
* Returns raw encoder period from DMA.
*
* @param encoder Encoder used for DMA.
* @param status DMA read status.
* @return Raw encoder period from DMA.
*/
int32_t GetEncoderPeriodRaw(const Encoder* encoder, int32_t* status) const {
return HAL_GetDMASampleEncoderPeriodRaw(this, encoder->m_encoder, status);
}
/**
* Returns counter value from DMA.
*
* @param counter Counter used for DMA.
* @param status DMA read status.
* @return Counter value from DMA.
*/
int32_t GetCounter(const Counter* counter, int32_t* status) const {
return HAL_GetDMASampleCounter(this, counter->m_counter, status);
}
/**
* Returns counter period from DMA.
*
* @param counter Counter used for DMA.
* @param status DMA read status.
* @return Counter period from DMA.
*/
int32_t GetCounterPeriod(const Counter* counter, int32_t* status) const {
return HAL_GetDMASampleCounterPeriod(this, counter->m_counter, status);
}
/**
* Returns digital source value from DMA.
*
* @param digitalSource DigitalSource used for DMA.
* @param status DMA read status.
* @return DigitalSource value from DMA.
*/
bool GetDigitalSource(const DigitalSource* digitalSource,
int32_t* status) const {
return HAL_GetDMASampleDigitalSource(
this, digitalSource->GetPortHandleForRouting(), status);
}
/**
* Returns raw analog input value from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param status DMA read status.
* @return Raw analog input value from DMA.
*/
int32_t GetAnalogInputRaw(const AnalogInput* analogInput,
int32_t* status) const {
return HAL_GetDMASampleAnalogInputRaw(this, analogInput->m_port, status);
}
/**
* Returns analog input voltage from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param status DMA read status.
* @return Analog input voltage from DMA.
*/
double GetAnalogInputVoltage(const AnalogInput* analogInput,
int32_t* status) {
return HAL_GetAnalogValueToVolts(
analogInput->m_port, GetAnalogInputRaw(analogInput, status), status);
}
/**
* Returns averaged analog input raw value from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param status DMA read status.
* @return Averaged analog input raw value from DMA.
*/
int32_t GetAveragedAnalogInputRaw(const AnalogInput* analogInput,
int32_t* status) const {
return HAL_GetDMASampleAveragedAnalogInputRaw(this, analogInput->m_port,
status);
}
/**
* Returns averaged analog input voltage from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param status DMA read status.
* @return Averaged analog input voltage from DMA.
*/
double GetAveragedAnalogInputVoltage(const AnalogInput* analogInput,
int32_t* status) {
return HAL_GetAnalogValueToVolts(
analogInput->m_port, GetAveragedAnalogInputRaw(analogInput, status),
status);
}
/**
* Returns analog accumulator value from DMA.
*
* @param analogInput AnalogInput used for DMA.
* @param count Accumulator sample count.
* @param value Accumulator value.
* @param status DMA read status.
*/
void GetAnalogAccumulator(const AnalogInput* analogInput, int64_t* count,
int64_t* value, int32_t* status) const {
return HAL_GetDMASampleAnalogAccumulator(this, analogInput->m_port, count,
value, status);
}
/**
* Returns raw duty cycle output from DMA.
*
* @param dutyCycle DutyCycle used for DMA.
* @param status DMA read status.
* @return Raw duty cycle output from DMA.
*/
int32_t GetDutyCycleOutputRaw(const DutyCycle* dutyCycle,
int32_t* status) const {
return HAL_GetDMASampleDutyCycleOutputRaw(this, dutyCycle->m_handle,
status);
}
/**
* Returns duty cycle output (0-1) from DMA.
*
* @param dutyCycle DutyCycle used for DMA.
* @param status DMA read status.
* @return Duty cycle output (0-1) from DMA.
*/
double GetDutyCycleOutput(const DutyCycle* dutyCycle, int32_t* status) {
return GetDutyCycleOutputRaw(dutyCycle, status) /
static_cast<double>(dutyCycle->GetOutputScaleFactor());
}
};
static_assert(std::is_standard_layout_v<frc::DMASample>,
"frc::DMASample must have standard layout");
} // namespace frc

View File

@@ -15,8 +15,6 @@
namespace frc {
class DigitalSource;
class AnalogTrigger;
class DMA;
class DMASample;
/**
* Class to read a duty cycle PWM input.
@@ -31,8 +29,6 @@ class DMASample;
*/
class DutyCycle : public wpi::Sendable, public wpi::SendableHelper<DutyCycle> {
friend class AnalogTrigger;
friend class DMA;
friend class DMASample;
public:
/**

View File

@@ -18,8 +18,6 @@ namespace frc {
class DigitalSource;
class DigitalGlitchFilter;
class DMA;
class DMASample;
/**
* Class to read quad encoders.
@@ -39,9 +37,6 @@ class DMASample;
class Encoder : public CounterBase,
public wpi::Sendable,
public wpi::SendableHelper<Encoder> {
friend class DMA;
friend class DMASample;
public:
/**
* Encoder indexing types.

View File

@@ -14,7 +14,6 @@
namespace frc {
class AddressableLED;
class DMA;
/**
* Class implements the PWM generation in the FPGA.
@@ -27,7 +26,6 @@ class DMA;
class PWM : public wpi::Sendable, public wpi::SendableHelper<PWM> {
public:
friend class AddressableLED;
friend class DMA;
/**
* Represents the amount to multiply the minimum servo-pulse pwm period by.
*/

View File

@@ -22,7 +22,6 @@
#include "frc/motorcontrol/MotorController.h"
namespace frc {
class DMA;
WPI_IGNORE_DEPRECATED
@@ -34,8 +33,6 @@ class PWMMotorController : public MotorController,
public wpi::Sendable,
public wpi::SendableHelper<PWMMotorController> {
public:
friend class DMA;
PWMMotorController(PWMMotorController&&) = default;
PWMMotorController& operator=(PWMMotorController&&) = default;