mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Remove large HAL headers from wpilibc headers (#1386)
Now only includes the types in the wpilib headers. Should immensely clean up intellisense. Closes #1383
This commit is contained in:
committed by
Peter Johnson
parent
f774e47c80
commit
f0b0965f9b
@@ -14,7 +14,6 @@
|
||||
#include "HALInitializer.h"
|
||||
#include "PortsInternal.h"
|
||||
#include "hal/AnalogAccumulator.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/handles/HandlesInternal.h"
|
||||
|
||||
namespace hal {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/CANAPITypes.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
/**
|
||||
@@ -17,43 +18,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
* The CAN device type.
|
||||
*
|
||||
* Teams should use HAL_CAN_Dev_kMiscellaneous
|
||||
*/
|
||||
HAL_ENUM(HAL_CANDeviceType) {
|
||||
HAL_CAN_Dev_kBroadcast = 0,
|
||||
HAL_CAN_Dev_kRobotController = 1,
|
||||
HAL_CAN_Dev_kMotorController = 2,
|
||||
HAL_CAN_Dev_kRelayController = 3,
|
||||
HAL_CAN_Dev_kGyroSensor = 4,
|
||||
HAL_CAN_Dev_kAccelerometer = 5,
|
||||
HAL_CAN_Dev_kUltrasonicSensor = 6,
|
||||
HAL_CAN_Dev_kGearToothSensor = 7,
|
||||
HAL_CAN_Dev_kPowerDistribution = 8,
|
||||
HAL_CAN_Dev_kPneumatics = 9,
|
||||
HAL_CAN_Dev_kMiscellaneous = 10,
|
||||
HAL_CAN_Dev_kFirmwareUpdate = 31
|
||||
};
|
||||
|
||||
/**
|
||||
* The CAN manufacturer ID.
|
||||
*
|
||||
* Teams should use HAL_CAN_Man_kTeamUse.
|
||||
*/
|
||||
HAL_ENUM(HAL_CANManufacturer) {
|
||||
HAL_CAN_Man_kBroadcast = 0,
|
||||
HAL_CAN_Man_kNI = 1,
|
||||
HAL_CAN_Man_kLM = 2,
|
||||
HAL_CAN_Man_kDEKA = 3,
|
||||
HAL_CAN_Man_kCTRE = 4,
|
||||
HAL_CAN_Man_kMS = 7,
|
||||
HAL_CAN_Man_kTeamUse = 8,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
56
hal/src/main/native/include/hal/CANAPITypes.h
Normal file
56
hal/src/main/native/include/hal/CANAPITypes.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. 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
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/Types.h"
|
||||
|
||||
/**
|
||||
* @defgroup hal_canapi CAN API Functions
|
||||
* @ingroup hal_capi
|
||||
* @{
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
* The CAN device type.
|
||||
*
|
||||
* Teams should use HAL_CAN_Dev_kMiscellaneous
|
||||
*/
|
||||
HAL_ENUM(HAL_CANDeviceType) {
|
||||
HAL_CAN_Dev_kBroadcast = 0,
|
||||
HAL_CAN_Dev_kRobotController = 1,
|
||||
HAL_CAN_Dev_kMotorController = 2,
|
||||
HAL_CAN_Dev_kRelayController = 3,
|
||||
HAL_CAN_Dev_kGyroSensor = 4,
|
||||
HAL_CAN_Dev_kAccelerometer = 5,
|
||||
HAL_CAN_Dev_kUltrasonicSensor = 6,
|
||||
HAL_CAN_Dev_kGearToothSensor = 7,
|
||||
HAL_CAN_Dev_kPowerDistribution = 8,
|
||||
HAL_CAN_Dev_kPneumatics = 9,
|
||||
HAL_CAN_Dev_kMiscellaneous = 10,
|
||||
HAL_CAN_Dev_kFirmwareUpdate = 31
|
||||
};
|
||||
|
||||
/**
|
||||
* The CAN manufacturer ID.
|
||||
*
|
||||
* Teams should use HAL_CAN_Man_kTeamUse.
|
||||
*/
|
||||
HAL_ENUM(HAL_CANManufacturer) {
|
||||
HAL_CAN_Man_kBroadcast = 0,
|
||||
HAL_CAN_Man_kNI = 1,
|
||||
HAL_CAN_Man_kLM = 2,
|
||||
HAL_CAN_Man_kDEKA = 3,
|
||||
HAL_CAN_Man_kCTRE = 4,
|
||||
HAL_CAN_Man_kMS = 7,
|
||||
HAL_CAN_Man_kTeamUse = 8,
|
||||
};
|
||||
// clang-format on
|
||||
/** @} */
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/DriverStationTypes.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
/**
|
||||
@@ -17,97 +18,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define HAL_IO_CONFIG_DATA_SIZE 32
|
||||
#define HAL_SYS_STATUS_DATA_SIZE 44
|
||||
#define HAL_USER_STATUS_DATA_SIZE \
|
||||
(984 - HAL_IO_CONFIG_DATA_SIZE - HAL_SYS_STATUS_DATA_SIZE)
|
||||
|
||||
#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17
|
||||
#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Header 19
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1 20
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 21
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra2 22
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices2 23
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick 24
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Custom 25
|
||||
|
||||
struct HAL_ControlWord {
|
||||
uint32_t enabled : 1;
|
||||
uint32_t autonomous : 1;
|
||||
uint32_t test : 1;
|
||||
uint32_t eStop : 1;
|
||||
uint32_t fmsAttached : 1;
|
||||
uint32_t dsAttached : 1;
|
||||
uint32_t control_reserved : 26;
|
||||
};
|
||||
typedef struct HAL_ControlWord HAL_ControlWord;
|
||||
|
||||
// clang-format off
|
||||
HAL_ENUM(HAL_AllianceStationID) {
|
||||
HAL_AllianceStationID_kRed1,
|
||||
HAL_AllianceStationID_kRed2,
|
||||
HAL_AllianceStationID_kRed3,
|
||||
HAL_AllianceStationID_kBlue1,
|
||||
HAL_AllianceStationID_kBlue2,
|
||||
HAL_AllianceStationID_kBlue3,
|
||||
};
|
||||
|
||||
HAL_ENUM(HAL_MatchType) {
|
||||
HAL_kMatchType_none,
|
||||
HAL_kMatchType_practice,
|
||||
HAL_kMatchType_qualification,
|
||||
HAL_kMatchType_elimination,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
/* The maximum number of axes that will be stored in a single HALJoystickAxes
|
||||
* struct. This is used for allocating buffers, not bounds checking, since
|
||||
* there are usually less axes in practice.
|
||||
*/
|
||||
#define HAL_kMaxJoystickAxes 12
|
||||
#define HAL_kMaxJoystickPOVs 12
|
||||
#define HAL_kMaxJoysticks 6
|
||||
|
||||
struct HAL_JoystickAxes {
|
||||
int16_t count;
|
||||
float axes[HAL_kMaxJoystickAxes];
|
||||
};
|
||||
typedef struct HAL_JoystickAxes HAL_JoystickAxes;
|
||||
|
||||
struct HAL_JoystickPOVs {
|
||||
int16_t count;
|
||||
int16_t povs[HAL_kMaxJoystickPOVs];
|
||||
};
|
||||
typedef struct HAL_JoystickPOVs HAL_JoystickPOVs;
|
||||
|
||||
struct HAL_JoystickButtons {
|
||||
uint32_t buttons;
|
||||
uint8_t count;
|
||||
};
|
||||
typedef struct HAL_JoystickButtons HAL_JoystickButtons;
|
||||
|
||||
struct HAL_JoystickDescriptor {
|
||||
uint8_t isXbox;
|
||||
uint8_t type;
|
||||
char name[256];
|
||||
uint8_t axisCount;
|
||||
uint8_t axisTypes[HAL_kMaxJoystickAxes];
|
||||
uint8_t buttonCount;
|
||||
uint8_t povCount;
|
||||
};
|
||||
typedef struct HAL_JoystickDescriptor HAL_JoystickDescriptor;
|
||||
|
||||
struct HAL_MatchInfo {
|
||||
char eventName[64];
|
||||
HAL_MatchType matchType;
|
||||
uint16_t matchNumber;
|
||||
uint8_t replayNumber;
|
||||
uint8_t gameSpecificMessage[64];
|
||||
uint16_t gameSpecificMessageSize;
|
||||
};
|
||||
typedef struct HAL_MatchInfo HAL_MatchInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
110
hal/src/main/native/include/hal/DriverStationTypes.h
Normal file
110
hal/src/main/native/include/hal/DriverStationTypes.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. 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
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/Types.h"
|
||||
|
||||
/**
|
||||
* @defgroup hal_driverstation Driver Station Functions
|
||||
* @ingroup hal_capi
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define HAL_IO_CONFIG_DATA_SIZE 32
|
||||
#define HAL_SYS_STATUS_DATA_SIZE 44
|
||||
#define HAL_USER_STATUS_DATA_SIZE \
|
||||
(984 - HAL_IO_CONFIG_DATA_SIZE - HAL_SYS_STATUS_DATA_SIZE)
|
||||
|
||||
#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17
|
||||
#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Header 19
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1 20
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 21
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra2 22
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices2 23
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick 24
|
||||
#define HALFRC_NetworkCommunication_DynamicType_Kinect_Custom 25
|
||||
|
||||
struct HAL_ControlWord {
|
||||
uint32_t enabled : 1;
|
||||
uint32_t autonomous : 1;
|
||||
uint32_t test : 1;
|
||||
uint32_t eStop : 1;
|
||||
uint32_t fmsAttached : 1;
|
||||
uint32_t dsAttached : 1;
|
||||
uint32_t control_reserved : 26;
|
||||
};
|
||||
typedef struct HAL_ControlWord HAL_ControlWord;
|
||||
|
||||
// clang-format off
|
||||
HAL_ENUM(HAL_AllianceStationID) {
|
||||
HAL_AllianceStationID_kRed1,
|
||||
HAL_AllianceStationID_kRed2,
|
||||
HAL_AllianceStationID_kRed3,
|
||||
HAL_AllianceStationID_kBlue1,
|
||||
HAL_AllianceStationID_kBlue2,
|
||||
HAL_AllianceStationID_kBlue3,
|
||||
};
|
||||
|
||||
HAL_ENUM(HAL_MatchType) {
|
||||
HAL_kMatchType_none,
|
||||
HAL_kMatchType_practice,
|
||||
HAL_kMatchType_qualification,
|
||||
HAL_kMatchType_elimination,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
/* The maximum number of axes that will be stored in a single HALJoystickAxes
|
||||
* struct. This is used for allocating buffers, not bounds checking, since
|
||||
* there are usually less axes in practice.
|
||||
*/
|
||||
#define HAL_kMaxJoystickAxes 12
|
||||
#define HAL_kMaxJoystickPOVs 12
|
||||
#define HAL_kMaxJoysticks 6
|
||||
|
||||
struct HAL_JoystickAxes {
|
||||
int16_t count;
|
||||
float axes[HAL_kMaxJoystickAxes];
|
||||
};
|
||||
typedef struct HAL_JoystickAxes HAL_JoystickAxes;
|
||||
|
||||
struct HAL_JoystickPOVs {
|
||||
int16_t count;
|
||||
int16_t povs[HAL_kMaxJoystickPOVs];
|
||||
};
|
||||
typedef struct HAL_JoystickPOVs HAL_JoystickPOVs;
|
||||
|
||||
struct HAL_JoystickButtons {
|
||||
uint32_t buttons;
|
||||
uint8_t count;
|
||||
};
|
||||
typedef struct HAL_JoystickButtons HAL_JoystickButtons;
|
||||
|
||||
struct HAL_JoystickDescriptor {
|
||||
uint8_t isXbox;
|
||||
uint8_t type;
|
||||
char name[256];
|
||||
uint8_t axisCount;
|
||||
uint8_t axisTypes[HAL_kMaxJoystickAxes];
|
||||
uint8_t buttonCount;
|
||||
uint8_t povCount;
|
||||
};
|
||||
typedef struct HAL_JoystickDescriptor HAL_JoystickDescriptor;
|
||||
|
||||
struct HAL_MatchInfo {
|
||||
char eventName[64];
|
||||
HAL_MatchType matchType;
|
||||
uint16_t matchNumber;
|
||||
uint8_t replayNumber;
|
||||
uint8_t gameSpecificMessage[64];
|
||||
uint16_t gameSpecificMessageSize;
|
||||
};
|
||||
typedef struct HAL_MatchInfo HAL_MatchInfo;
|
||||
/** @} */
|
||||
@@ -39,177 +39,8 @@
|
||||
#endif // HAL_USE_LABVIEW
|
||||
|
||||
#include "hal/Types.h"
|
||||
#include "hal/HALBase.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "hal/FRCUsageReporting.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup hal_capi WPILib HAL API
|
||||
* Hardware Abstraction Layer to hardware or simulator
|
||||
* @{
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
HAL_ENUM(HAL_RuntimeType) { HAL_Athena, HAL_Mock };
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Gets the error message for a specific status code.
|
||||
*
|
||||
* @param code the status code
|
||||
* @return the error message for the code. This does not need to be freed.
|
||||
*/
|
||||
const char* HAL_GetErrorMessage(int32_t code);
|
||||
|
||||
/**
|
||||
* Returns the FPGA Version number.
|
||||
*
|
||||
* For now, expect this to be competition year.
|
||||
*
|
||||
* @return FPGA Version number.
|
||||
*/
|
||||
int32_t HAL_GetFPGAVersion(int32_t* status);
|
||||
|
||||
/**
|
||||
* Returns the FPGA Revision number.
|
||||
*
|
||||
* The format of the revision is 3 numbers.
|
||||
* The 12 most significant bits are the Major Revision.
|
||||
* the next 8 bits are the Minor Revision.
|
||||
* The 12 least significant bits are the Build Number.
|
||||
*
|
||||
* @return FPGA Revision number.
|
||||
*/
|
||||
int64_t HAL_GetFPGARevision(int32_t* status);
|
||||
|
||||
HAL_RuntimeType HAL_GetRuntimeType(void);
|
||||
|
||||
/**
|
||||
* Gets the state of the "USER" button on the roboRIO.
|
||||
*
|
||||
* @return true if the button is currently pressed down
|
||||
*/
|
||||
HAL_Bool HAL_GetFPGAButton(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets if the system outputs are currently active
|
||||
*
|
||||
* @return true if the system outputs are active, false if disabled
|
||||
*/
|
||||
HAL_Bool HAL_GetSystemActive(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets if the system is in a browned out state.
|
||||
*
|
||||
* @return true if the system is in a low voltage brown out, false otherwise
|
||||
*/
|
||||
HAL_Bool HAL_GetBrownedOut(int32_t* status);
|
||||
|
||||
/**
|
||||
* The base HAL initialize function. Useful if you need to ensure the DS and
|
||||
* base HAL functions (the ones above this declaration in HAL.h) are properly
|
||||
* initialized. For normal programs and executables, please use HAL_Initialize.
|
||||
*
|
||||
* This is mainly expected to be use from libraries that are expected to be used
|
||||
* from LabVIEW, as it handles its own initialization for objects.
|
||||
*/
|
||||
void HAL_BaseInitialize(int32_t* status);
|
||||
|
||||
#ifndef HAL_USE_LABVIEW
|
||||
|
||||
/**
|
||||
* Gets a port handle for a specific channel.
|
||||
*
|
||||
* The created handle does not need to be freed.
|
||||
*
|
||||
* @param channel the channel number
|
||||
* @return the created port
|
||||
*/
|
||||
HAL_PortHandle HAL_GetPort(int32_t channel);
|
||||
|
||||
/**
|
||||
* Gets a port handle for a specific channel and module.
|
||||
*
|
||||
* This is expected to be used for PCMs, as the roboRIO does not work with
|
||||
* modules anymore.
|
||||
*
|
||||
* The created handle does not need to be freed.
|
||||
*
|
||||
* @param module the module number
|
||||
* @param channel the channel number
|
||||
* @return the created port
|
||||
*/
|
||||
HAL_PortHandle HAL_GetPortWithModule(int32_t module, int32_t channel);
|
||||
|
||||
/**
|
||||
* Reads the microsecond-resolution timer on the FPGA.
|
||||
*
|
||||
* @return The current time in microseconds according to the FPGA (since FPGA
|
||||
* reset).
|
||||
*/
|
||||
uint64_t HAL_GetFPGATime(int32_t* status);
|
||||
|
||||
/**
|
||||
* Call this to start up HAL. This is required for robot programs.
|
||||
*
|
||||
* This must be called before any other HAL functions. Failure to do so will
|
||||
* result in undefined behavior, and likely segmentation faults. This means that
|
||||
* any statically initialized variables in a program MUST call this function in
|
||||
* their constructors if they want to use other HAL calls.
|
||||
*
|
||||
* The common parameters are 500 for timeout and 0 for mode.
|
||||
*
|
||||
* This function is safe to call from any thread, and as many times as you wish.
|
||||
* It internally guards from any reentrancy.
|
||||
*
|
||||
* The applicable modes are:
|
||||
* 0: Try to kill an existing HAL from another program, if not successful,
|
||||
* error.
|
||||
* 1: Force kill a HAL from another program.
|
||||
* 2: Just warn if another hal exists and cannot be killed. Will likely result
|
||||
* in undefined behavior.
|
||||
*
|
||||
* @param timeout the initialization timeout (ms)
|
||||
* @param mode the initialization mode (see remarks)
|
||||
* @return true if initialization was successful, otherwise false.
|
||||
*/
|
||||
HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode);
|
||||
|
||||
// ifdef's definition is to allow for default parameters in C++.
|
||||
#ifdef __cplusplus
|
||||
/**
|
||||
* Reports a hardware usage to the HAL.
|
||||
*
|
||||
* @param resource the used resource
|
||||
* @param instanceNumber the instance of the resource
|
||||
* @param context a user specified context index
|
||||
* @param feature a user specified feature string
|
||||
* @return the index of the added value in NetComm
|
||||
*/
|
||||
int64_t HAL_Report(int32_t resource, int32_t instanceNumber,
|
||||
int32_t context = 0, const char* feature = nullptr);
|
||||
#else
|
||||
|
||||
/**
|
||||
* Reports a hardware usage to the HAL.
|
||||
*
|
||||
* @param resource the used resource
|
||||
* @param instanceNumber the instance of the resource
|
||||
* @param context a user specified context index
|
||||
* @param feature a user specified feature string
|
||||
* @return the index of the added value in NetComm
|
||||
*/
|
||||
int64_t HAL_Report(int32_t resource, int32_t instanceNumber, int32_t context,
|
||||
const char* feature);
|
||||
#endif
|
||||
|
||||
#endif // HAL_USE_LABVIEW
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
182
hal/src/main/native/include/hal/HALBase.h
Normal file
182
hal/src/main/native/include/hal/HALBase.h
Normal file
@@ -0,0 +1,182 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. 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
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/Types.h"
|
||||
|
||||
/**
|
||||
* @defgroup hal_capi WPILib HAL API
|
||||
* Hardware Abstraction Layer to hardware or simulator
|
||||
* @{
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
HAL_ENUM(HAL_RuntimeType) { HAL_Athena, HAL_Mock };
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Gets the error message for a specific status code.
|
||||
*
|
||||
* @param code the status code
|
||||
* @return the error message for the code. This does not need to be freed.
|
||||
*/
|
||||
const char* HAL_GetErrorMessage(int32_t code);
|
||||
|
||||
/**
|
||||
* Returns the FPGA Version number.
|
||||
*
|
||||
* For now, expect this to be competition year.
|
||||
*
|
||||
* @return FPGA Version number.
|
||||
*/
|
||||
int32_t HAL_GetFPGAVersion(int32_t* status);
|
||||
|
||||
/**
|
||||
* Returns the FPGA Revision number.
|
||||
*
|
||||
* The format of the revision is 3 numbers.
|
||||
* The 12 most significant bits are the Major Revision.
|
||||
* the next 8 bits are the Minor Revision.
|
||||
* The 12 least significant bits are the Build Number.
|
||||
*
|
||||
* @return FPGA Revision number.
|
||||
*/
|
||||
int64_t HAL_GetFPGARevision(int32_t* status);
|
||||
|
||||
HAL_RuntimeType HAL_GetRuntimeType(void);
|
||||
|
||||
/**
|
||||
* Gets the state of the "USER" button on the roboRIO.
|
||||
*
|
||||
* @return true if the button is currently pressed down
|
||||
*/
|
||||
HAL_Bool HAL_GetFPGAButton(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets if the system outputs are currently active
|
||||
*
|
||||
* @return true if the system outputs are active, false if disabled
|
||||
*/
|
||||
HAL_Bool HAL_GetSystemActive(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets if the system is in a browned out state.
|
||||
*
|
||||
* @return true if the system is in a low voltage brown out, false otherwise
|
||||
*/
|
||||
HAL_Bool HAL_GetBrownedOut(int32_t* status);
|
||||
|
||||
/**
|
||||
* The base HAL initialize function. Useful if you need to ensure the DS and
|
||||
* base HAL functions (the ones above this declaration in HAL.h) are properly
|
||||
* initialized. For normal programs and executables, please use HAL_Initialize.
|
||||
*
|
||||
* This is mainly expected to be use from libraries that are expected to be used
|
||||
* from LabVIEW, as it handles its own initialization for objects.
|
||||
*/
|
||||
void HAL_BaseInitialize(int32_t* status);
|
||||
|
||||
#ifndef HAL_USE_LABVIEW
|
||||
|
||||
/**
|
||||
* Gets a port handle for a specific channel.
|
||||
*
|
||||
* The created handle does not need to be freed.
|
||||
*
|
||||
* @param channel the channel number
|
||||
* @return the created port
|
||||
*/
|
||||
HAL_PortHandle HAL_GetPort(int32_t channel);
|
||||
|
||||
/**
|
||||
* Gets a port handle for a specific channel and module.
|
||||
*
|
||||
* This is expected to be used for PCMs, as the roboRIO does not work with
|
||||
* modules anymore.
|
||||
*
|
||||
* The created handle does not need to be freed.
|
||||
*
|
||||
* @param module the module number
|
||||
* @param channel the channel number
|
||||
* @return the created port
|
||||
*/
|
||||
HAL_PortHandle HAL_GetPortWithModule(int32_t module, int32_t channel);
|
||||
|
||||
/**
|
||||
* Reads the microsecond-resolution timer on the FPGA.
|
||||
*
|
||||
* @return The current time in microseconds according to the FPGA (since FPGA
|
||||
* reset).
|
||||
*/
|
||||
uint64_t HAL_GetFPGATime(int32_t* status);
|
||||
|
||||
/**
|
||||
* Call this to start up HAL. This is required for robot programs.
|
||||
*
|
||||
* This must be called before any other HAL functions. Failure to do so will
|
||||
* result in undefined behavior, and likely segmentation faults. This means that
|
||||
* any statically initialized variables in a program MUST call this function in
|
||||
* their constructors if they want to use other HAL calls.
|
||||
*
|
||||
* The common parameters are 500 for timeout and 0 for mode.
|
||||
*
|
||||
* This function is safe to call from any thread, and as many times as you wish.
|
||||
* It internally guards from any reentrancy.
|
||||
*
|
||||
* The applicable modes are:
|
||||
* 0: Try to kill an existing HAL from another program, if not successful,
|
||||
* error.
|
||||
* 1: Force kill a HAL from another program.
|
||||
* 2: Just warn if another hal exists and cannot be killed. Will likely result
|
||||
* in undefined behavior.
|
||||
*
|
||||
* @param timeout the initialization timeout (ms)
|
||||
* @param mode the initialization mode (see remarks)
|
||||
* @return true if initialization was successful, otherwise false.
|
||||
*/
|
||||
HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode);
|
||||
|
||||
// ifdef's definition is to allow for default parameters in C++.
|
||||
#ifdef __cplusplus
|
||||
/**
|
||||
* Reports a hardware usage to the HAL.
|
||||
*
|
||||
* @param resource the used resource
|
||||
* @param instanceNumber the instance of the resource
|
||||
* @param context a user specified context index
|
||||
* @param feature a user specified feature string
|
||||
* @return the index of the added value in NetComm
|
||||
*/
|
||||
int64_t HAL_Report(int32_t resource, int32_t instanceNumber,
|
||||
int32_t context = 0, const char* feature = nullptr);
|
||||
#else
|
||||
|
||||
/**
|
||||
* Reports a hardware usage to the HAL.
|
||||
*
|
||||
* @param resource the used resource
|
||||
* @param instanceNumber the instance of the resource
|
||||
* @param context a user specified context index
|
||||
* @param feature a user specified feature string
|
||||
* @return the index of the added value in NetComm
|
||||
*/
|
||||
int64_t HAL_Report(int32_t resource, int32_t instanceNumber, int32_t context,
|
||||
const char* feature);
|
||||
#endif
|
||||
|
||||
#endif // HAL_USE_LABVIEW
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
/** @} */
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/I2CTypes.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
/**
|
||||
@@ -17,10 +18,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
HAL_ENUM(HAL_I2CPort) { HAL_I2C_kInvalid = -1, HAL_I2C_kOnboard, HAL_I2C_kMXP };
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
24
hal/src/main/native/include/hal/I2CTypes.h
Normal file
24
hal/src/main/native/include/hal/I2CTypes.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. 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
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/Types.h"
|
||||
|
||||
/**
|
||||
* @defgroup hal_i2c I2C Functions
|
||||
* @ingroup hal_capi
|
||||
* @{
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
HAL_ENUM(HAL_I2CPort) { HAL_I2C_kInvalid = -1, HAL_I2C_kOnboard, HAL_I2C_kMXP };
|
||||
// clang-format on
|
||||
|
||||
/** @} */
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/AnalogTrigger.h"
|
||||
#include "hal/SPITypes.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
/**
|
||||
@@ -18,17 +19,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
HAL_ENUM(HAL_SPIPort) {
|
||||
HAL_SPI_kInvalid = -1,
|
||||
HAL_SPI_kOnboardCS0,
|
||||
HAL_SPI_kOnboardCS1,
|
||||
HAL_SPI_kOnboardCS2,
|
||||
HAL_SPI_kOnboardCS3,
|
||||
HAL_SPI_kMXP
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
30
hal/src/main/native/include/hal/SPITypes.h
Normal file
30
hal/src/main/native/include/hal/SPITypes.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. 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
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/Types.h"
|
||||
|
||||
/**
|
||||
* @defgroup hal_spi SPI Functions
|
||||
* @ingroup hal_capi
|
||||
* @{
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
HAL_ENUM(HAL_SPIPort) {
|
||||
HAL_SPI_kInvalid = -1,
|
||||
HAL_SPI_kOnboardCS0,
|
||||
HAL_SPI_kOnboardCS1,
|
||||
HAL_SPI_kOnboardCS2,
|
||||
HAL_SPI_kOnboardCS3,
|
||||
HAL_SPI_kMXP
|
||||
};
|
||||
// clang-format on
|
||||
/** @} */
|
||||
@@ -10,7 +10,8 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Accelerometer.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
enum HALSIM_AnalogTriggerMode : int32_t {
|
||||
HALSIM_AnalogTriggerUnassigned,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "HAL_Value.h"
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
typedef void (*HAL_CAN_SendMessageCallback)(const char* name, void* param,
|
||||
uint32_t messageID,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/DriverStation.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/DriverStationTypes.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include "NotifyListener.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/Types.h"
|
||||
|
||||
typedef void (*HAL_SpiReadAutoReceiveBufferCallback)(const char* name,
|
||||
void* param,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "AnalogInternal.h"
|
||||
#include "HALInitializer.h"
|
||||
#include "PortsInternal.h"
|
||||
#include "hal/AnalogAccumulator.h"
|
||||
#include "hal/handles/HandlesInternal.h"
|
||||
#include "mockdata/AnalogInDataInternal.h"
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "DriverStationDataInternal.h"
|
||||
#include "hal/DriverStation.h"
|
||||
|
||||
namespace hal {
|
||||
struct JoystickOutputStore {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <hal/DriverStation.h>
|
||||
#include <hal/DriverStationTypes.h>
|
||||
|
||||
namespace halsim {
|
||||
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <hal/CAN.h>
|
||||
#include <hal/CANAPI.h>
|
||||
#include <hal/Errors.h>
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <hal/HALBase.h>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <hal/Encoder.h>
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <hal/HALBase.h>
|
||||
|
||||
#include "frc/DigitalInput.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
|
||||
@@ -23,6 +23,17 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
int frc::RunHALInitialization() {
|
||||
if (!HAL_Initialize(500, 0)) {
|
||||
wpi::errs() << "FATAL ERROR: HAL could not be initialized\n";
|
||||
return -1;
|
||||
}
|
||||
HAL_Report(HALUsageReporting::kResourceType_Language,
|
||||
HALUsageReporting::kLanguage_CPlusPlus);
|
||||
wpi::outs() << "\n********** Robot program starting **********\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::thread::id RobotBase::m_threadId;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
#include "frc/SampleRobot.h"
|
||||
|
||||
#include <hal/DriverStation.h>
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <hal/HALBase.h>
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <hal/AnalogOutput.h>
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <hal/AnalogTrigger.h>
|
||||
|
||||
#include "frc/DigitalSource.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <hal/CANAPI.h>
|
||||
#include <hal/CANAPITypes.h>
|
||||
#include <wpi/ArrayRef.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <hal/Counter.h>
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/AnalogTrigger.h"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include <hal/DriverStation.h>
|
||||
#include <hal/DriverStationTypes.h>
|
||||
#include <wpi/Twine.h>
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <hal/Encoder.h>
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/CounterBase.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <hal/I2C.h>
|
||||
#include <hal/I2CTypes.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/Notifier.h>
|
||||
#include <hal/Types.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <hal/PDP.h>
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/Base.h"
|
||||
@@ -18,15 +17,14 @@ namespace frc {
|
||||
|
||||
class DriverStation;
|
||||
|
||||
int RunHALInitialization();
|
||||
|
||||
template <class Robot>
|
||||
int StartRobot() {
|
||||
if (!HAL_Initialize(500, 0)) {
|
||||
wpi::errs() << "FATAL ERROR: HAL could not be initialized\n";
|
||||
return -1;
|
||||
int halInit = RunHALInitialization();
|
||||
if (halInit != 0) {
|
||||
return halInit;
|
||||
}
|
||||
HAL_Report(HALUsageReporting::kResourceType_Language,
|
||||
HALUsageReporting::kLanguage_CPlusPlus);
|
||||
wpi::outs() << "\n********** Robot program starting **********\n";
|
||||
static Robot robot;
|
||||
robot.StartCompetition();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <hal/SPI.h>
|
||||
#include <hal/SPITypes.h>
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <hal/Notifier.h>
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/IterativeRobotBase.h"
|
||||
|
||||
Reference in New Issue
Block a user