mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Add new CAN API (#1036)
This commit is contained in:
committed by
Peter Johnson
parent
55b0fe0082
commit
680aabbe7c
78
hal/src/main/native/include/HAL/CANAPI.h
Normal file
78
hal/src/main/native/include/HAL/CANAPI.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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"
|
||||
|
||||
enum HAL_CANDeviceType : int32_t {
|
||||
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
|
||||
};
|
||||
|
||||
enum HAL_CANManufacturer : int32_t {
|
||||
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,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
HAL_CANHandle HAL_InitializeCAN(HAL_CANManufacturer manufacturer,
|
||||
int32_t deviceId, HAL_CANDeviceType deviceType,
|
||||
int32_t* status);
|
||||
|
||||
void HAL_CleanCAN(HAL_CANHandle handle);
|
||||
|
||||
void HAL_WriteCANPacket(HAL_CANHandle handle, const uint8_t* data,
|
||||
int32_t length, int32_t apiId, int32_t* status);
|
||||
|
||||
void HAL_WriteCANPacketRepeating(HAL_CANHandle handle, const uint8_t* data,
|
||||
int32_t length, int32_t apiId,
|
||||
int32_t repeatMs, int32_t* status);
|
||||
|
||||
void HAL_StopCANPacketRepeating(HAL_CANHandle handle, int32_t apiId,
|
||||
int32_t* status);
|
||||
|
||||
void HAL_ReadCANPacketNew(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
|
||||
int32_t* length, uint64_t* receivedTimestamp,
|
||||
int32_t* status);
|
||||
|
||||
void HAL_ReadCANPacketLatest(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
|
||||
int32_t* length, uint64_t* receivedTimestamp,
|
||||
int32_t* status);
|
||||
|
||||
void HAL_ReadCANPacketTimeout(HAL_CANHandle handle, int32_t apiId,
|
||||
uint8_t* data, int32_t* length,
|
||||
uint64_t* receivedTimestamp, int32_t timeoutMs,
|
||||
int32_t* status);
|
||||
void HAL_ReadCANPeriodicPacket(HAL_CANHandle handle, int32_t apiId,
|
||||
uint8_t* data, int32_t* length,
|
||||
uint64_t* receivedTimestamp, int32_t timeoutMs,
|
||||
int32_t periodMs, int32_t* status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -103,6 +103,9 @@
|
||||
#define HAL_THREAD_PRIORITY_RANGE_ERROR_MESSAGE \
|
||||
"HAL: The priority requested to be set is invalid"
|
||||
|
||||
#define HAL_CAN_TIMEOUT -1154
|
||||
#define HAL_CAN_TIMEOUT_MESSAGE "HAL: CAN Receive has Timed Out"
|
||||
|
||||
#define VI_ERROR_SYSTEM_ERROR_MESSAGE "HAL - VISA: System Error";
|
||||
#define VI_ERROR_INV_OBJECT_MESSAGE "HAL - VISA: Invalid Object"
|
||||
#define VI_ERROR_RSRC_LOCKED_MESSAGE "HAL - VISA: Resource Locked"
|
||||
|
||||
@@ -43,4 +43,6 @@ typedef HAL_Handle HAL_RelayHandle;
|
||||
|
||||
typedef HAL_Handle HAL_SolenoidHandle;
|
||||
|
||||
typedef HAL_Handle HAL_CANHandle;
|
||||
|
||||
typedef int32_t HAL_Bool;
|
||||
|
||||
@@ -57,7 +57,8 @@ enum class HAL_HandleEnum {
|
||||
Solenoid = 15,
|
||||
AnalogGyro = 16,
|
||||
Vendor = 17,
|
||||
SimulationJni = 18
|
||||
SimulationJni = 18,
|
||||
CAN = 19,
|
||||
};
|
||||
|
||||
static inline int16_t getHandleIndex(HAL_Handle handle) {
|
||||
|
||||
Reference in New Issue
Block a user