mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Changes HAL Headers to be C compliant. (#171)
This commit is contained in:
committed by
Peter Johnson
parent
1b1ee7f9f3
commit
edf5ecd4a0
@@ -15,10 +15,14 @@ enum HAL_AccelerometerRange {
|
||||
HAL_AccelerometerRange_k8G = 2,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
void HAL_SetAccelerometerActive(HAL_Bool);
|
||||
void HAL_SetAccelerometerRange(HAL_AccelerometerRange);
|
||||
double HAL_GetAccelerometerX();
|
||||
double HAL_GetAccelerometerY();
|
||||
double HAL_GetAccelerometerZ();
|
||||
#endif
|
||||
void HAL_SetAccelerometerActive(HAL_Bool active);
|
||||
void HAL_SetAccelerometerRange(HAL_AccelerometerRange range);
|
||||
double HAL_GetAccelerometerX(void);
|
||||
double HAL_GetAccelerometerY(void);
|
||||
double HAL_GetAccelerometerZ(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analog_port_handle,
|
||||
int32_t* status);
|
||||
void HAL_InitAccumulator(HAL_AnalogInputHandle analog_port_handle,
|
||||
@@ -28,4 +30,6 @@ int64_t HAL_GetAccumulatorCount(HAL_AnalogInputHandle analog_port_handle,
|
||||
int32_t* status);
|
||||
void HAL_GetAccumulatorOutput(HAL_AnalogInputHandle analog_port_handle,
|
||||
int64_t* value, int64_t* count, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle handle,
|
||||
int32_t* status);
|
||||
void HAL_SetupAnalogGyro(HAL_GyroHandle handle, int32_t* status);
|
||||
@@ -30,4 +32,6 @@ double HAL_GetAnalogGyroAngle(HAL_GyroHandle handle, int32_t* status);
|
||||
double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t* status);
|
||||
double HAL_GetAnalogGyroOffset(HAL_GyroHandle handle, int32_t* status);
|
||||
int32_t HAL_GetAnalogGyroCenter(HAL_GyroHandle handle, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(HAL_PortHandle port_handle,
|
||||
int32_t* status);
|
||||
void HAL_FreeAnalogInputPort(HAL_AnalogInputHandle analog_port_handle);
|
||||
@@ -42,4 +44,6 @@ int32_t HAL_GetAnalogLSBWeight(HAL_AnalogInputHandle analog_port_handle,
|
||||
int32_t* status);
|
||||
int32_t HAL_GetAnalogOffset(HAL_AnalogInputHandle analog_port_handle,
|
||||
int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(
|
||||
HAL_PortHandle port_handle, int32_t* status);
|
||||
void HAL_FreeAnalogOutputPort(HAL_AnalogOutputHandle analog_output_handle);
|
||||
@@ -20,4 +22,6 @@ void HAL_SetAnalogOutput(HAL_AnalogOutputHandle analog_output_handle,
|
||||
double HAL_GetAnalogOutput(HAL_AnalogOutputHandle analog_output_handle,
|
||||
int32_t* status);
|
||||
HAL_Bool HAL_CheckAnalogOutputChannel(int32_t pin);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,9 @@ enum HAL_AnalogTriggerType {
|
||||
HAL_Trigger_kFallingPulse = 3
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_AnalogTriggerHandle HAL_InitializeAnalogTrigger(
|
||||
HAL_AnalogInputHandle port_handle, int32_t* index, int32_t* status);
|
||||
void HAL_CleanAnalogTrigger(HAL_AnalogTriggerHandle analog_trigger_handle,
|
||||
@@ -40,4 +42,6 @@ HAL_Bool HAL_GetAnalogTriggerTriggerState(
|
||||
HAL_Bool HAL_GetAnalogTriggerOutput(
|
||||
HAL_AnalogTriggerHandle analog_trigger_handle, HAL_AnalogTriggerType type,
|
||||
int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_CompressorHandle HAL_InitializeCompressor(int32_t module, int32_t* status);
|
||||
HAL_Bool HAL_CheckCompressorModule(int32_t module);
|
||||
|
||||
@@ -40,4 +42,6 @@ HAL_Bool HAL_GetCompressorNotConnectedStickyFault(
|
||||
HAL_CompressorHandle compressor_handle, int32_t* status);
|
||||
HAL_Bool HAL_GetCompressorNotConnectedFault(
|
||||
HAL_CompressorHandle compressor_handle, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int32_t HAL_GetSystemClockTicksPerMicrosecond(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,9 @@ enum HAL_Counter_Mode {
|
||||
HAL_Counter_kExternalDirection = 3
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_CounterHandle HAL_InitializeCounter(HAL_Counter_Mode mode, int32_t* index,
|
||||
int32_t* status);
|
||||
void HAL_FreeCounter(HAL_CounterHandle counter_handle, int32_t* status);
|
||||
@@ -68,4 +70,6 @@ HAL_Bool HAL_GetCounterDirection(HAL_CounterHandle counter_handle,
|
||||
int32_t* status);
|
||||
void HAL_SetCounterReverseDirection(HAL_CounterHandle counter_handle,
|
||||
HAL_Bool reverseDirection, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle port_handle,
|
||||
int32_t input, int32_t* status);
|
||||
void HAL_FreeDIOPort(HAL_DigitalHandle dio_port_handle);
|
||||
@@ -38,4 +40,6 @@ void HAL_SetFilterSelect(HAL_DigitalHandle dio_port_handle,
|
||||
int32_t HAL_GetFilterSelect(HAL_DigitalHandle dio_port_handle, int32_t* status);
|
||||
void HAL_SetFilterPeriod(int32_t filter_index, int64_t value, int32_t* status);
|
||||
int64_t HAL_GetFilterPeriod(int32_t filter_index, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "HAL/AnalogTrigger.h"
|
||||
#include "HAL/Types.h"
|
||||
|
||||
extern "C" {
|
||||
enum HAL_EncoderIndexingType {
|
||||
HAL_kResetWhileHigh,
|
||||
HAL_kResetWhileLow,
|
||||
@@ -25,6 +24,9 @@ enum HAL_EncoderEncodingType {
|
||||
HAL_Encoder_k4X
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_EncoderHandle HAL_InitializeEncoder(
|
||||
HAL_Handle digitalSourceHandleA, HAL_AnalogTriggerType analogTriggerTypeA,
|
||||
HAL_Handle digitalSourceHandleB, HAL_AnalogTriggerType analogTriggerTypeB,
|
||||
@@ -73,4 +75,6 @@ double HAL_GetEncoderDistancePerPulse(HAL_EncoderHandle encoder_handle,
|
||||
|
||||
HAL_EncoderEncodingType HAL_GetEncoderEncodingType(
|
||||
HAL_EncoderHandle encoder_handle, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -103,7 +103,9 @@ struct HAL_JoystickDescriptor {
|
||||
uint8_t povCount;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_PortHandle HAL_GetPort(int32_t pin);
|
||||
HAL_PortHandle HAL_GetPortWithModule(int32_t module, int32_t pin);
|
||||
const char* HAL_GetErrorMessage(int32_t code);
|
||||
@@ -136,18 +138,26 @@ int32_t HAL_SetJoystickOutputs(int32_t joystickNum, int64_t outputs,
|
||||
int32_t leftRumble, int32_t rightRumble);
|
||||
float HAL_GetMatchTime(int32_t* status);
|
||||
|
||||
void HAL_WaitForDSData();
|
||||
void HAL_WaitForDSData(void);
|
||||
|
||||
HAL_Bool HAL_GetSystemActive(int32_t* status);
|
||||
HAL_Bool HAL_GetBrownedOut(int32_t* status);
|
||||
|
||||
int32_t HAL_Initialize(int32_t mode = 0);
|
||||
void HAL_ObserveUserProgramStarting();
|
||||
void HAL_ObserveUserProgramDisabled();
|
||||
void HAL_ObserveUserProgramAutonomous();
|
||||
void HAL_ObserveUserProgramTeleop();
|
||||
void HAL_ObserveUserProgramTest();
|
||||
int32_t HAL_Initialize(int32_t mode);
|
||||
void HAL_ObserveUserProgramStarting(void);
|
||||
void HAL_ObserveUserProgramDisabled(void);
|
||||
void HAL_ObserveUserProgramAutonomous(void);
|
||||
void HAL_ObserveUserProgramTeleop(void);
|
||||
void HAL_ObserveUserProgramTest(void);
|
||||
|
||||
// ifdef's definition is to allow for default parameters in C++.
|
||||
#ifdef __cplusplus
|
||||
int64_t HAL_Report(int32_t resource, int32_t instanceNumber,
|
||||
int32_t context = 0, const char* feature = nullptr);
|
||||
#else
|
||||
int64_t HAL_Report(int32_t resource, int32_t instanceNumber, int32_t context,
|
||||
const char* feature);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void HAL_InitializeI2C(int32_t port, int32_t* status);
|
||||
int32_t HAL_TransactionI2C(int32_t port, int32_t deviceAddress,
|
||||
uint8_t* dataToSend, int32_t sendSize,
|
||||
@@ -19,4 +21,6 @@ int32_t HAL_WriteI2C(int32_t port, int32_t deviceAddress, uint8_t* dataToSend,
|
||||
int32_t HAL_ReadI2C(int32_t port, int32_t deviceAddress, uint8_t* buffer,
|
||||
int32_t count);
|
||||
void HAL_CloseI2C(int32_t port);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#include "HAL/AnalogTrigger.h"
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef void (*InterruptHandlerFunction)(uint32_t interruptAssertedMask,
|
||||
void* param);
|
||||
|
||||
@@ -40,4 +42,6 @@ void HAL_AttachInterruptHandler(HAL_InterruptHandle interrupt_handle,
|
||||
void HAL_SetInterruptUpSourceEdge(HAL_InterruptHandle interrupt_handle,
|
||||
HAL_Bool risingEdge, HAL_Bool fallingEdge,
|
||||
int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_NotifierHandle HAL_InitializeNotifier(void (*process)(uint64_t, void*),
|
||||
void* param, int32_t* status);
|
||||
void HAL_CleanNotifier(HAL_NotifierHandle notifier_handle, int32_t* status);
|
||||
@@ -19,4 +21,6 @@ void* HAL_GetNotifierParam(HAL_NotifierHandle notifier_handle, int32_t* status);
|
||||
void HAL_UpdateNotifierAlarm(HAL_NotifierHandle notifier_handle,
|
||||
uint64_t triggerTime, int32_t* status);
|
||||
void HAL_StopNotifierAlarm(HAL_NotifierHandle notifier_handle, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void HAL_InitializePDP(int32_t module, int32_t* status);
|
||||
HAL_Bool HAL_CheckPDPModule(int32_t module);
|
||||
double HAL_GetPDPTemperature(int32_t module, int32_t* status);
|
||||
@@ -23,4 +25,6 @@ double HAL_GetPDPTotalPower(int32_t module, int32_t* status);
|
||||
double HAL_GetPDPTotalEnergy(int32_t module, int32_t* status);
|
||||
void HAL_ResetPDPTotalEnergy(int32_t module, int32_t* status);
|
||||
void HAL_ClearPDPStickyFaults(int32_t module, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle port_handle,
|
||||
int32_t* status);
|
||||
void HAL_FreePWMPort(HAL_DigitalHandle pwm_port_handle, int32_t* status);
|
||||
@@ -47,4 +49,6 @@ void HAL_LatchPWMZero(HAL_DigitalHandle pwm_port_handle, int32_t* status);
|
||||
void HAL_SetPWMPeriodScale(HAL_DigitalHandle pwm_port_handle,
|
||||
int32_t squelchMask, int32_t* status);
|
||||
int32_t HAL_GetLoopTiming(int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int32_t HAL_GetNumAccumulators(void);
|
||||
int32_t HAL_GetNumAnalogTriggers(void);
|
||||
int32_t HAL_GetNumAnalogInputs(void);
|
||||
@@ -29,4 +31,6 @@ int32_t HAL_GetNumSolenoidPins(void);
|
||||
int32_t HAL_GetNumPDPModules(void);
|
||||
int32_t HAL_GetNumPDPChannels(void);
|
||||
int32_t HAL_GetNumCanTalons(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
double HAL_GetVinVoltage(int32_t* status);
|
||||
double HAL_GetVinCurrent(int32_t* status);
|
||||
double HAL_GetUserVoltage6V(int32_t* status);
|
||||
@@ -26,4 +28,6 @@ double HAL_GetUserVoltage3V3(int32_t* status);
|
||||
double HAL_GetUserCurrent3V3(int32_t* status);
|
||||
HAL_Bool HAL_GetUserActive3V3(int32_t* status);
|
||||
int32_t HAL_GetUserCurrentFaults3V3(int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle port_handle,
|
||||
HAL_Bool fwd, int32_t* status);
|
||||
void HAL_FreeRelayPort(HAL_RelayHandle relay_port_handle);
|
||||
@@ -21,4 +23,6 @@ HAL_Bool HAL_CheckRelayChannel(int32_t pin);
|
||||
void HAL_SetRelay(HAL_RelayHandle relay_port_handle, HAL_Bool on,
|
||||
int32_t* status);
|
||||
HAL_Bool HAL_GetRelay(HAL_RelayHandle relay_port_handle, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void HAL_InitializeSPI(int32_t port, int32_t* status);
|
||||
int32_t HAL_TransactionSPI(int32_t port, uint8_t* dataToSend,
|
||||
uint8_t* dataReceived, int32_t size);
|
||||
@@ -42,4 +44,6 @@ int64_t HAL_GetSPIAccumulatorCount(int32_t port, int32_t* status);
|
||||
double HAL_GetSPIAccumulatorAverage(int32_t port, int32_t* status);
|
||||
void HAL_GetSPIAccumulatorOutput(int32_t port, int64_t* value, int64_t* count,
|
||||
int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void HAL_InitializeSerialPort(int32_t port, int32_t* status);
|
||||
void HAL_SetSerialBaudRate(int32_t port, int32_t baud, int32_t* status);
|
||||
void HAL_SetSerialDataBits(int32_t port, int32_t bits, int32_t* status);
|
||||
@@ -31,4 +33,6 @@ int32_t HAL_WriteSerial(int32_t port, const char* buffer, int32_t count,
|
||||
void HAL_FlushSerial(int32_t port, int32_t* status);
|
||||
void HAL_ClearSerial(int32_t port, int32_t* status);
|
||||
void HAL_CloseSerial(int32_t port, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
HAL_SolenoidHandle HAL_InitializeSolenoidPort(HAL_PortHandle port_handle,
|
||||
int32_t* status);
|
||||
void HAL_FreeSolenoidPort(HAL_SolenoidHandle solenoid_port_handle);
|
||||
@@ -26,4 +28,6 @@ int32_t HAL_GetPCMSolenoidBlackList(int32_t module, int32_t* status);
|
||||
HAL_Bool HAL_GetPCMSolenoidVoltageStickyFault(int32_t module, int32_t* status);
|
||||
HAL_Bool HAL_GetPCMSolenoidVoltageFault(int32_t module, int32_t* status);
|
||||
void HAL_ClearAllPCMStickyFaults(int32_t module, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,9 @@ typedef int STATUS;
|
||||
|
||||
typedef pthread_t* TASK;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
// Note: These constants used to be declared extern and were defined in
|
||||
// Task.cpp. This caused issues with the JNI bindings for java, and so the
|
||||
// instantiations were moved here.
|
||||
@@ -33,4 +35,6 @@ const int32_t HAL_TaskLib_ILLEGAL_PRIORITY = 22; // 22 is EINVAL
|
||||
STATUS HAL_VerifyTaskID(TASK task);
|
||||
STATUS HAL_SetTaskPriority(TASK task, int priority); // valid priority [1..99]
|
||||
STATUS HAL_GetTaskPriority(TASK task, int* priority);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,7 @@ class DriverStation;
|
||||
|
||||
#define START_ROBOT_CLASS(_ClassName_) \
|
||||
int main() { \
|
||||
if (!HAL_Initialize()) { \
|
||||
if (!HAL_Initialize(0)) { \
|
||||
std::cerr << "FATAL ERROR: HAL could not be initialized" << std::endl; \
|
||||
return -1; \
|
||||
} \
|
||||
|
||||
@@ -21,7 +21,7 @@ class TestEnvironment : public testing::Environment {
|
||||
if (m_alreadySetUp) return;
|
||||
m_alreadySetUp = true;
|
||||
|
||||
if (!HAL_Initialize()) {
|
||||
if (!HAL_Initialize(0)) {
|
||||
std::cerr << "FATAL ERROR: HAL could not be initialized" << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user