WPILibC++  2018.4.1-20180729133221-1141-g00c2cd7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
CANAPI.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <stdint.h>
11 
12 #include "hal/Types.h"
13 
14 // clang-format off
20 HAL_ENUM(HAL_CANDeviceType) {
21  HAL_CAN_Dev_kBroadcast = 0,
22  HAL_CAN_Dev_kRobotController = 1,
23  HAL_CAN_Dev_kMotorController = 2,
24  HAL_CAN_Dev_kRelayController = 3,
25  HAL_CAN_Dev_kGyroSensor = 4,
26  HAL_CAN_Dev_kAccelerometer = 5,
27  HAL_CAN_Dev_kUltrasonicSensor = 6,
28  HAL_CAN_Dev_kGearToothSensor = 7,
29  HAL_CAN_Dev_kPowerDistribution = 8,
30  HAL_CAN_Dev_kPneumatics = 9,
31  HAL_CAN_Dev_kMiscellaneous = 10,
32  HAL_CAN_Dev_kFirmwareUpdate = 31
33 };
34 
40 HAL_ENUM(HAL_CANManufacturer) {
41  HAL_CAN_Man_kBroadcast = 0,
42  HAL_CAN_Man_kNI = 1,
43  HAL_CAN_Man_kLM = 2,
44  HAL_CAN_Man_kDEKA = 3,
45  HAL_CAN_Man_kCTRE = 4,
46  HAL_CAN_Man_kMS = 7,
47  HAL_CAN_Man_kTeamUse = 8,
48 };
49 // clang-format on
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
65 HAL_CANHandle HAL_InitializeCAN(HAL_CANManufacturer manufacturer,
66  int32_t deviceId, HAL_CANDeviceType deviceType,
67  int32_t* status);
68 
74 void HAL_CleanCAN(HAL_CANHandle handle);
75 
86 void HAL_WriteCANPacket(HAL_CANHandle handle, const uint8_t* data,
87  int32_t length, int32_t apiId, int32_t* status);
88 
102 void HAL_WriteCANPacketRepeating(HAL_CANHandle handle, const uint8_t* data,
103  int32_t length, int32_t apiId,
104  int32_t repeatMs, int32_t* status);
105 
114 void HAL_StopCANPacketRepeating(HAL_CANHandle handle, int32_t apiId,
115  int32_t* status);
116 
130 void HAL_ReadCANPacketNew(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
131  int32_t* length, uint64_t* receivedTimestamp,
132  int32_t* status);
133 
145 void HAL_ReadCANPacketLatest(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
146  int32_t* length, uint64_t* receivedTimestamp,
147  int32_t* status);
148 
162 void HAL_ReadCANPacketTimeout(HAL_CANHandle handle, int32_t apiId,
163  uint8_t* data, int32_t* length,
164  uint64_t* receivedTimestamp, int32_t timeoutMs,
165  int32_t* status);
166 
184 void HAL_ReadCANPeriodicPacket(HAL_CANHandle handle, int32_t apiId,
185  uint8_t* data, int32_t* length,
186  uint64_t* receivedTimestamp, int32_t timeoutMs,
187  int32_t periodMs, int32_t* status);
188 
189 #ifdef __cplusplus
190 } // extern "C"
191 #endif