mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Prepends all HAL functions with HAL_ (#146)
This commit is contained in:
committed by
Peter Johnson
parent
5ad28d58ec
commit
b637b9ee4c
@@ -56,5 +56,5 @@ class AnalogGyro : public GyroBase {
|
||||
std::shared_ptr<AnalogInput> m_analog;
|
||||
|
||||
private:
|
||||
HalGyroHandle m_gyroHandle = HAL_INVALID_HANDLE;
|
||||
HAL_GyroHandle m_gyroHandle = HAL_kInvalidHandle;
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ class AnalogInput : public SensorBase,
|
||||
private:
|
||||
uint32_t m_channel;
|
||||
// TODO: Adjust HAL to avoid use of raw pointers.
|
||||
HalAnalogInputHandle m_port;
|
||||
HAL_AnalogInputHandle m_port;
|
||||
int64_t m_accumulatorOffset;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
|
||||
@@ -35,7 +35,7 @@ class AnalogOutput : public SensorBase, public LiveWindowSendable {
|
||||
|
||||
protected:
|
||||
uint32_t m_channel;
|
||||
HalAnalogOutputHandle m_port;
|
||||
HAL_AnalogOutputHandle m_port;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ class AnalogTrigger : public SensorBase {
|
||||
|
||||
private:
|
||||
uint8_t m_index;
|
||||
HalAnalogTriggerHandle m_trigger;
|
||||
HAL_AnalogTriggerHandle m_trigger;
|
||||
AnalogInput* m_analogInput = nullptr;
|
||||
bool m_ownsAnalog = false;
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ class AnalogTriggerOutput : public DigitalSource {
|
||||
bool Get() const;
|
||||
|
||||
// DigitalSource interface
|
||||
virtual HalHandle GetPortHandleForRouting() const override;
|
||||
virtual HAL_Handle GetPortHandleForRouting() const override;
|
||||
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
virtual bool IsAnalogTrigger() const override;
|
||||
virtual uint32_t GetChannel() const override;
|
||||
|
||||
15
wpilibc/athena/include/AnalogTriggerType.h
Normal file
15
wpilibc/athena/include/AnalogTriggerType.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
enum class AnalogTriggerType {
|
||||
kInWindow = 0,
|
||||
kState = 1,
|
||||
kRisingPulse = 2,
|
||||
kFallingPulse = 3
|
||||
};
|
||||
@@ -54,7 +54,7 @@ class Compressor : public SensorBase,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
|
||||
protected:
|
||||
HalCompressorHandle m_compressorHandle;
|
||||
HAL_CompressorHandle m_compressorHandle;
|
||||
|
||||
private:
|
||||
void SetCompressor(bool on);
|
||||
|
||||
@@ -31,6 +31,12 @@ class Counter : public SensorBase,
|
||||
public CounterBase,
|
||||
public LiveWindowSendable {
|
||||
public:
|
||||
enum Mode {
|
||||
kTwoPulse = 0,
|
||||
kSemiperiod = 1,
|
||||
kPulseLength = 2,
|
||||
kExternalDirection = 3
|
||||
};
|
||||
explicit Counter(Mode mode = kTwoPulse);
|
||||
explicit Counter(int32_t channel);
|
||||
explicit Counter(DigitalSource* source);
|
||||
@@ -98,7 +104,7 @@ class Counter : public SensorBase,
|
||||
// Makes the counter count down.
|
||||
std::shared_ptr<DigitalSource> m_downSource;
|
||||
// The FPGA counter object
|
||||
HalCounterHandle m_counter = HAL_INVALID_HANDLE;
|
||||
HAL_CounterHandle m_counter = HAL_kInvalidHandle;
|
||||
|
||||
private:
|
||||
int32_t m_index = 0; ///< The index of this counter.
|
||||
|
||||
@@ -32,7 +32,7 @@ class DigitalInput : public DigitalSource, public LiveWindowSendable {
|
||||
uint32_t GetChannel() const override;
|
||||
|
||||
// Digital Source Interface
|
||||
virtual HalHandle GetPortHandleForRouting() const override;
|
||||
virtual HAL_Handle GetPortHandleForRouting() const override;
|
||||
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
virtual bool IsAnalogTrigger() const override;
|
||||
|
||||
@@ -45,7 +45,7 @@ class DigitalInput : public DigitalSource, public LiveWindowSendable {
|
||||
|
||||
private:
|
||||
uint32_t m_channel;
|
||||
HalDigitalHandle m_handle;
|
||||
HAL_DigitalHandle m_handle;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
friend class DigitalGlitchFilter;
|
||||
|
||||
@@ -36,7 +36,7 @@ class DigitalOutput : public DigitalSource,
|
||||
void UpdateDutyCycle(float dutyCycle);
|
||||
|
||||
// Digital Source Interface
|
||||
virtual HalHandle GetPortHandleForRouting() const override;
|
||||
virtual HAL_Handle GetPortHandleForRouting() const override;
|
||||
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
virtual bool IsAnalogTrigger() const override;
|
||||
|
||||
@@ -51,8 +51,8 @@ class DigitalOutput : public DigitalSource,
|
||||
|
||||
private:
|
||||
uint32_t m_channel;
|
||||
HalDigitalHandle m_handle;
|
||||
HalDigitalPWMHandle m_pwmGenerator;
|
||||
HAL_DigitalHandle m_handle;
|
||||
HAL_DigitalPWMHandle m_pwmGenerator;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
class DigitalSource : public InterruptableSensorBase {
|
||||
public:
|
||||
virtual ~DigitalSource() = default;
|
||||
virtual HalHandle GetPortHandleForRouting() const = 0;
|
||||
virtual HAL_Handle GetPortHandleForRouting() const = 0;
|
||||
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const = 0;
|
||||
virtual bool IsAnalogTrigger() const = 0;
|
||||
virtual uint32_t GetChannel() const = 0;
|
||||
|
||||
@@ -50,8 +50,8 @@ class DoubleSolenoid : public SolenoidBase,
|
||||
uint32_t m_reverseChannel; ///< The reverse channel on the module to control.
|
||||
uint8_t m_forwardMask; ///< The mask for the forward channel.
|
||||
uint8_t m_reverseMask; ///< The mask for the reverse channel.
|
||||
HalSolenoidHandle m_forwardHandle = HAL_INVALID_HANDLE;
|
||||
HalSolenoidHandle m_reverseHandle = HAL_INVALID_HANDLE;
|
||||
HAL_SolenoidHandle m_forwardHandle = HAL_kInvalidHandle;
|
||||
HAL_SolenoidHandle m_reverseHandle = HAL_kInvalidHandle;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
};
|
||||
|
||||
@@ -100,16 +100,16 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
void ReportJoystickUnpluggedWarning(std::string message);
|
||||
void Run();
|
||||
|
||||
std::unique_ptr<HALJoystickAxes[]> m_joystickAxes;
|
||||
std::unique_ptr<HALJoystickPOVs[]> m_joystickPOVs;
|
||||
std::unique_ptr<HALJoystickButtons[]> m_joystickButtons;
|
||||
std::unique_ptr<HALJoystickDescriptor[]> m_joystickDescriptor;
|
||||
std::unique_ptr<HAL_JoystickAxes[]> m_joystickAxes;
|
||||
std::unique_ptr<HAL_JoystickPOVs[]> m_joystickPOVs;
|
||||
std::unique_ptr<HAL_JoystickButtons[]> m_joystickButtons;
|
||||
std::unique_ptr<HAL_JoystickDescriptor[]> m_joystickDescriptor;
|
||||
|
||||
// Cached Data
|
||||
std::unique_ptr<HALJoystickAxes[]> m_joystickAxesCache;
|
||||
std::unique_ptr<HALJoystickPOVs[]> m_joystickPOVsCache;
|
||||
std::unique_ptr<HALJoystickButtons[]> m_joystickButtonsCache;
|
||||
std::unique_ptr<HALJoystickDescriptor[]> m_joystickDescriptorCache;
|
||||
std::unique_ptr<HAL_JoystickAxes[]> m_joystickAxesCache;
|
||||
std::unique_ptr<HAL_JoystickPOVs[]> m_joystickPOVsCache;
|
||||
std::unique_ptr<HAL_JoystickButtons[]> m_joystickButtonsCache;
|
||||
std::unique_ptr<HAL_JoystickDescriptor[]> m_joystickDescriptorCache;
|
||||
|
||||
Task m_task;
|
||||
std::atomic<bool> m_isRunning{false};
|
||||
|
||||
@@ -99,7 +99,7 @@ class Encoder : public SensorBase,
|
||||
std::shared_ptr<DigitalSource> m_aSource; // the A phase of the quad encoder
|
||||
std::shared_ptr<DigitalSource> m_bSource; // the B phase of the quad encoder
|
||||
std::unique_ptr<DigitalSource> m_indexSource = nullptr;
|
||||
HalEncoderHandle m_encoder = HAL_INVALID_HANDLE;
|
||||
HAL_EncoderHandle m_encoder = HAL_kInvalidHandle;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
friend class DigitalGlitchFilter;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "HAL/AnalogTrigger.h"
|
||||
#include "AnalogTriggerType.h"
|
||||
#include "HAL/Interrupts.h"
|
||||
#include "SensorBase.h"
|
||||
|
||||
@@ -24,7 +24,7 @@ class InterruptableSensorBase : public SensorBase {
|
||||
|
||||
InterruptableSensorBase();
|
||||
virtual ~InterruptableSensorBase() = default;
|
||||
virtual HalHandle GetPortHandleForRouting() const = 0;
|
||||
virtual HAL_Handle GetPortHandleForRouting() const = 0;
|
||||
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const = 0;
|
||||
virtual void RequestInterrupts(
|
||||
InterruptHandlerFunction handler,
|
||||
@@ -45,6 +45,6 @@ class InterruptableSensorBase : public SensorBase {
|
||||
virtual void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
|
||||
|
||||
protected:
|
||||
HalInterruptHandle m_interrupt = HAL_INVALID_HANDLE;
|
||||
HAL_InterruptHandle m_interrupt = HAL_kInvalidHandle;
|
||||
void AllocateInterrupts(bool watcher);
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ class Notifier : public ErrorBase {
|
||||
// held while updating process information
|
||||
priority_mutex m_processMutex;
|
||||
// HAL handle, atomic for proper destruction
|
||||
std::atomic<HalNotifierHandle> m_notifier{0};
|
||||
std::atomic<HAL_NotifierHandle> m_notifier{0};
|
||||
// address of the handler
|
||||
TimerEventHandler m_handler;
|
||||
// the absolute expiration time
|
||||
|
||||
@@ -75,5 +75,5 @@ class PWM : public SensorBase,
|
||||
|
||||
private:
|
||||
uint32_t m_channel;
|
||||
HalDigitalHandle m_handle;
|
||||
HAL_DigitalHandle m_handle;
|
||||
};
|
||||
|
||||
@@ -67,8 +67,8 @@ class Relay : public MotorSafety,
|
||||
uint32_t m_channel;
|
||||
Direction m_direction;
|
||||
|
||||
HalRelayHandle m_forwardHandle = HAL_INVALID_HANDLE;
|
||||
HalRelayHandle m_reverseHandle = HAL_INVALID_HANDLE;
|
||||
HAL_RelayHandle m_forwardHandle = HAL_kInvalidHandle;
|
||||
HAL_RelayHandle m_reverseHandle = HAL_kInvalidHandle;
|
||||
|
||||
std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
|
||||
};
|
||||
|
||||
@@ -17,12 +17,12 @@ class DriverStation;
|
||||
|
||||
#define START_ROBOT_CLASS(_ClassName_) \
|
||||
int main() { \
|
||||
if (!HALInitialize()) { \
|
||||
if (!HAL_Initialize()) { \
|
||||
std::cerr << "FATAL ERROR: HAL could not be initialized" << std::endl; \
|
||||
return -1; \
|
||||
} \
|
||||
HALReport(HALUsageReporting::kResourceType_Language, \
|
||||
HALUsageReporting::kLanguage_CPlusPlus); \
|
||||
HAL_Report(HALUsageReporting::kResourceType_Language, \
|
||||
HALUsageReporting::kLanguage_CPlusPlus); \
|
||||
static _ClassName_ robot; \
|
||||
std::printf("\n********** Robot program starting **********\n"); \
|
||||
robot.StartCompetition(); \
|
||||
|
||||
@@ -41,7 +41,7 @@ class Solenoid : public SolenoidBase,
|
||||
std::shared_ptr<ITable> GetTable() const;
|
||||
|
||||
private:
|
||||
HalSolenoidHandle m_solenoidHandle = HAL_INVALID_HANDLE;
|
||||
HAL_SolenoidHandle m_solenoidHandle = HAL_kInvalidHandle;
|
||||
uint32_t m_channel; ///< The channel on the module to control.
|
||||
std::shared_ptr<ITable> m_table;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user