mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilibc] Remove ErrorBase (#3306)
Replace with new exception-based error reporting, consistent with Java. This also builds stacktraces into the reporting/exceptions.
This commit is contained in:
@@ -4,21 +4,22 @@
|
||||
|
||||
#include "frc/DMA.h"
|
||||
|
||||
#include <frc/AnalogInput.h>
|
||||
#include <frc/Counter.h>
|
||||
#include <frc/DigitalSource.h>
|
||||
#include <frc/DutyCycle.h>
|
||||
#include <frc/Encoder.h>
|
||||
|
||||
#include <hal/DMA.h>
|
||||
#include <hal/HALBase.h>
|
||||
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/DigitalSource.h"
|
||||
#include "frc/DutyCycle.h"
|
||||
#include "frc/Encoder.h"
|
||||
#include "frc/Errors.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
DMA::DMA() {
|
||||
int32_t status = 0;
|
||||
dmaHandle = HAL_InitializeDMA(&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "InitializeDMA");
|
||||
}
|
||||
|
||||
DMA::~DMA() {
|
||||
@@ -28,68 +29,68 @@ DMA::~DMA() {
|
||||
void DMA::SetPause(bool pause) {
|
||||
int32_t status = 0;
|
||||
HAL_SetDMAPause(dmaHandle, pause, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "SetPause");
|
||||
}
|
||||
|
||||
void DMA::SetRate(int cycles) {
|
||||
int32_t status = 0;
|
||||
HAL_SetDMARate(dmaHandle, cycles, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "SetRate");
|
||||
}
|
||||
|
||||
void DMA::AddEncoder(const Encoder* encoder) {
|
||||
int32_t status = 0;
|
||||
HAL_AddDMAEncoder(dmaHandle, encoder->m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "AddEncoder");
|
||||
}
|
||||
|
||||
void DMA::AddEncoderPeriod(const Encoder* encoder) {
|
||||
int32_t status = 0;
|
||||
HAL_AddDMAEncoderPeriod(dmaHandle, encoder->m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "AddEncoderPeriod");
|
||||
}
|
||||
|
||||
void DMA::AddCounter(const Counter* counter) {
|
||||
int32_t status = 0;
|
||||
HAL_AddDMACounter(dmaHandle, counter->m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "AddCounter");
|
||||
}
|
||||
|
||||
void DMA::AddCounterPeriod(const Counter* counter) {
|
||||
int32_t status = 0;
|
||||
HAL_AddDMACounterPeriod(dmaHandle, counter->m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "AddCounterPeriod");
|
||||
}
|
||||
|
||||
void DMA::AddDigitalSource(const DigitalSource* digitalSource) {
|
||||
int32_t status = 0;
|
||||
HAL_AddDMADigitalSource(dmaHandle, digitalSource->GetPortHandleForRouting(),
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "AddDigitalSource");
|
||||
}
|
||||
|
||||
void DMA::AddDutyCycle(const DutyCycle* dutyCycle) {
|
||||
int32_t status = 0;
|
||||
HAL_AddDMADutyCycle(dmaHandle, dutyCycle->m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "AddDutyCycle");
|
||||
}
|
||||
|
||||
void DMA::AddAnalogInput(const AnalogInput* analogInput) {
|
||||
int32_t status = 0;
|
||||
HAL_AddDMAAnalogInput(dmaHandle, analogInput->m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "AddAnalogInput");
|
||||
}
|
||||
|
||||
void DMA::AddAveragedAnalogInput(const AnalogInput* analogInput) {
|
||||
int32_t status = 0;
|
||||
HAL_AddDMAAveragedAnalogInput(dmaHandle, analogInput->m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "AddAveragedAnalogInput");
|
||||
}
|
||||
|
||||
void DMA::AddAnalogAccumulator(const AnalogInput* analogInput) {
|
||||
int32_t status = 0;
|
||||
HAL_AddDMAAnalogAccumulator(dmaHandle, analogInput->m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "AddAnalogAccumulator");
|
||||
}
|
||||
|
||||
void DMA::SetExternalTrigger(DigitalSource* source, bool rising, bool falling) {
|
||||
@@ -98,17 +99,17 @@ void DMA::SetExternalTrigger(DigitalSource* source, bool rising, bool falling) {
|
||||
static_cast<HAL_AnalogTriggerType>(
|
||||
source->GetAnalogTriggerTypeForRouting()),
|
||||
rising, falling, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "SetExternalTrigger");
|
||||
}
|
||||
|
||||
void DMA::StartDMA(int queueDepth) {
|
||||
int32_t status = 0;
|
||||
HAL_StartDMA(dmaHandle, queueDepth, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "StartDMA");
|
||||
}
|
||||
|
||||
void DMA::StopDMA() {
|
||||
int32_t status = 0;
|
||||
HAL_StopDMA(dmaHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
FRC_CheckErrorStatus(status, "StopDMA");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user