WPILibC++  2018.4.1-20180921134745-1191-g456d3e1
 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 
20 // clang-format off
26 HAL_ENUM(HAL_CANDeviceType) {
27  HAL_CAN_Dev_kBroadcast = 0,
28  HAL_CAN_Dev_kRobotController = 1,
29  HAL_CAN_Dev_kMotorController = 2,
30  HAL_CAN_Dev_kRelayController = 3,
31  HAL_CAN_Dev_kGyroSensor = 4,
32  HAL_CAN_Dev_kAccelerometer = 5,
33  HAL_CAN_Dev_kUltrasonicSensor = 6,
34  HAL_CAN_Dev_kGearToothSensor = 7,
35  HAL_CAN_Dev_kPowerDistribution = 8,
36  HAL_CAN_Dev_kPneumatics = 9,
37  HAL_CAN_Dev_kMiscellaneous = 10,
38  HAL_CAN_Dev_kFirmwareUpdate = 31
39 };
40 
46 HAL_ENUM(HAL_CANManufacturer) {
47  HAL_CAN_Man_kBroadcast = 0,
48  HAL_CAN_Man_kNI = 1,
49  HAL_CAN_Man_kLM = 2,
50  HAL_CAN_Man_kDEKA = 3,
51  HAL_CAN_Man_kCTRE = 4,
52  HAL_CAN_Man_kMS = 7,
53  HAL_CAN_Man_kTeamUse = 8,
54 };
55 // clang-format on
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
71 HAL_CANHandle HAL_InitializeCAN(HAL_CANManufacturer manufacturer,
72  int32_t deviceId, HAL_CANDeviceType deviceType,
73  int32_t* status);
74 
80 void HAL_CleanCAN(HAL_CANHandle handle);
81 
92 void HAL_WriteCANPacket(HAL_CANHandle handle, const uint8_t* data,
93  int32_t length, int32_t apiId, int32_t* status);
94 
108 void HAL_WriteCANPacketRepeating(HAL_CANHandle handle, const uint8_t* data,
109  int32_t length, int32_t apiId,
110  int32_t repeatMs, int32_t* status);
111 
120 void HAL_StopCANPacketRepeating(HAL_CANHandle handle, int32_t apiId,
121  int32_t* status);
122 
136 void HAL_ReadCANPacketNew(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
137  int32_t* length, uint64_t* receivedTimestamp,
138  int32_t* status);
139 
151 void HAL_ReadCANPacketLatest(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
152  int32_t* length, uint64_t* receivedTimestamp,
153  int32_t* status);
154 
168 void HAL_ReadCANPacketTimeout(HAL_CANHandle handle, int32_t apiId,
169  uint8_t* data, int32_t* length,
170  uint64_t* receivedTimestamp, int32_t timeoutMs,
171  int32_t* status);
172 
190 void HAL_ReadCANPeriodicPacket(HAL_CANHandle handle, int32_t apiId,
191  uint8_t* data, int32_t* length,
192  uint64_t* receivedTimestamp, int32_t timeoutMs,
193  int32_t periodMs, int32_t* status);
194 
195 #ifdef __cplusplus
196 } // extern "C"
197 #endif
198 
void HAL_WriteCANPacket(HAL_CANHandle handle, const uint8_t *data, int32_t length, int32_t apiId, int32_t *status)
Writes a packet to the CAN device with a specific ID.
void HAL_ReadCANPacketTimeout(HAL_CANHandle handle, int32_t apiId, uint8_t *data, int32_t *length, uint64_t *receivedTimestamp, int32_t timeoutMs, int32_t *status)
Reads a CAN packet.
HAL_ENUM(HAL_CANDeviceType)
The CAN device type.
Definition: CANAPI.h:26
void HAL_StopCANPacketRepeating(HAL_CANHandle handle, int32_t apiId, int32_t *status)
Stops a repeating packet with a specific ID.
HAL_CANHandle HAL_InitializeCAN(HAL_CANManufacturer manufacturer, int32_t deviceId, HAL_CANDeviceType deviceType, int32_t *status)
Initializes a CAN device.
void HAL_ReadCANPacketNew(HAL_CANHandle handle, int32_t apiId, uint8_t *data, int32_t *length, uint64_t *receivedTimestamp, int32_t *status)
Reads a new CAN packet.
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)
Reads a CAN packet.
void HAL_CleanCAN(HAL_CANHandle handle)
Frees a CAN device.
void HAL_ReadCANPacketLatest(HAL_CANHandle handle, int32_t apiId, uint8_t *data, int32_t *length, uint64_t *receivedTimestamp, int32_t *status)
Reads a CAN packet.
void HAL_WriteCANPacketRepeating(HAL_CANHandle handle, const uint8_t *data, int32_t length, int32_t apiId, int32_t repeatMs, int32_t *status)
Writes a repeating packet to the CAN device with a specific ID.