2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "AnalogTriggerOutput.h"
|
2016-09-25 16:50:13 -07:00
|
|
|
|
2017-08-27 00:11:52 -07:00
|
|
|
#include <HAL/HAL.h>
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "AnalogTrigger.h"
|
|
|
|
|
#include "WPIErrors.h"
|
|
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
AnalogTriggerOutput::~AnalogTriggerOutput() {
|
2016-07-09 00:24:26 -07:00
|
|
|
if (m_interrupt != HAL_kInvalidHandle) {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_CleanInterrupts(m_interrupt, &status);
|
2016-06-20 23:22:49 -07:00
|
|
|
// ignore status, as an invalid handle just needs to be ignored.
|
2016-07-09 00:24:26 -07:00
|
|
|
m_interrupt = HAL_kInvalidHandle;
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
bool AnalogTriggerOutput::Get() const {
|
2013-12-15 18:30:16 -05:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
bool result = HAL_GetAnalogTriggerOutput(
|
2016-08-24 21:39:16 -07:00
|
|
|
m_trigger.m_trigger, static_cast<HAL_AnalogTriggerType>(m_outputType),
|
|
|
|
|
&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2013-12-15 18:30:16 -05:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_Handle AnalogTriggerOutput::GetPortHandleForRouting() const {
|
2016-07-07 21:43:55 -07:00
|
|
|
return m_trigger.m_trigger;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2016-07-07 21:43:55 -07:00
|
|
|
AnalogTriggerType AnalogTriggerOutput::GetAnalogTriggerTypeForRouting() const {
|
|
|
|
|
return m_outputType;
|
|
|
|
|
}
|
2016-06-30 21:39:09 -07:00
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
bool AnalogTriggerOutput::IsAnalogTrigger() const { return true; }
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
int AnalogTriggerOutput::GetChannel() const { return m_trigger.m_index; }
|
2017-12-04 23:28:33 -08:00
|
|
|
|
|
|
|
|
void AnalogTriggerOutput::InitSendable(SendableBuilder&) {}
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
AnalogTriggerOutput::AnalogTriggerOutput(const AnalogTrigger& trigger,
|
|
|
|
|
AnalogTriggerType outputType)
|
|
|
|
|
: m_trigger(trigger), m_outputType(outputType) {
|
|
|
|
|
HAL_Report(HALUsageReporting::kResourceType_AnalogTriggerOutput,
|
|
|
|
|
trigger.GetIndex(), static_cast<uint8_t>(outputType));
|
|
|
|
|
}
|