Add new CAN API (#1036)

This commit is contained in:
Thad House
2018-05-21 16:09:38 -07:00
committed by Peter Johnson
parent 55b0fe0082
commit 680aabbe7c
19 changed files with 1545 additions and 1 deletions

View 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

View File

@@ -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"

View File

@@ -43,4 +43,6 @@ typedef HAL_Handle HAL_RelayHandle;
typedef HAL_Handle HAL_SolenoidHandle;
typedef HAL_Handle HAL_CANHandle;
typedef int32_t HAL_Bool;

View File

@@ -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) {