blob: e2097f236ac36335f54be113816aa55b70a00fe9 [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2013-2017. 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 <cstddef>
13
14#include "HAL/Types.h"
15
16#define HAL_IO_CONFIG_DATA_SIZE 32
17#define HAL_SYS_STATUS_DATA_SIZE 44
18#define HAL_USER_STATUS_DATA_SIZE \
19 (984 - HAL_IO_CONFIG_DATA_SIZE - HAL_SYS_STATUS_DATA_SIZE)
20
21#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17
22#define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18
23#define HALFRC_NetworkCommunication_DynamicType_Kinect_Header 19
24#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra1 20
25#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 21
26#define HALFRC_NetworkCommunication_DynamicType_Kinect_Extra2 22
27#define HALFRC_NetworkCommunication_DynamicType_Kinect_Vertices2 23
28#define HALFRC_NetworkCommunication_DynamicType_Kinect_Joystick 24
29#define HALFRC_NetworkCommunication_DynamicType_Kinect_Custom 25
30
31struct HAL_ControlWord {
32 uint32_t enabled : 1;
33 uint32_t autonomous : 1;
34 uint32_t test : 1;
35 uint32_t eStop : 1;
36 uint32_t fmsAttached : 1;
37 uint32_t dsAttached : 1;
38 uint32_t control_reserved : 26;
39};
40
41enum HAL_AllianceStationID : int32_t {
42 HAL_AllianceStationID_kRed1,
43 HAL_AllianceStationID_kRed2,
44 HAL_AllianceStationID_kRed3,
45 HAL_AllianceStationID_kBlue1,
46 HAL_AllianceStationID_kBlue2,
47 HAL_AllianceStationID_kBlue3,
48};
49
50/* The maximum number of axes that will be stored in a single HALJoystickAxes
51 * struct. This is used for allocating buffers, not bounds checking, since
52 * there are usually less axes in practice.
53 */
54#define HAL_kMaxJoystickAxes 12
55#define HAL_kMaxJoystickPOVs 12
56
57struct HAL_JoystickAxes {
58 int16_t count;
59 float axes[HAL_kMaxJoystickAxes];
60};
61
62struct HAL_JoystickPOVs {
63 int16_t count;
64 int16_t povs[HAL_kMaxJoystickPOVs];
65};
66
67struct HAL_JoystickButtons {
68 uint32_t buttons;
69 uint8_t count;
70};
71
72struct HAL_JoystickDescriptor {
73 uint8_t isXbox;
74 uint8_t type;
75 char name[256];
76 uint8_t axisCount;
77 uint8_t axisTypes[HAL_kMaxJoystickAxes];
78 uint8_t buttonCount;
79 uint8_t povCount;
80};
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85int32_t HAL_SetErrorData(const char* errors, int32_t errorsLength,
86 int32_t waitMs);
87int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
88 const char* details, const char* location,
89 const char* callStack, HAL_Bool printMsg);
90
91int32_t HAL_GetControlWord(HAL_ControlWord* controlWord);
92HAL_AllianceStationID HAL_GetAllianceStation(int32_t* status);
93int32_t HAL_GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes);
94int32_t HAL_GetJoystickPOVs(int32_t joystickNum, HAL_JoystickPOVs* povs);
95int32_t HAL_GetJoystickButtons(int32_t joystickNum,
96 HAL_JoystickButtons* buttons);
97int32_t HAL_GetJoystickDescriptor(int32_t joystickNum,
98 HAL_JoystickDescriptor* desc);
99HAL_Bool HAL_GetJoystickIsXbox(int32_t joystickNum);
100int32_t HAL_GetJoystickType(int32_t joystickNum);
101char* HAL_GetJoystickName(int32_t joystickNum);
102int32_t HAL_GetJoystickAxisType(int32_t joystickNum, int32_t axis);
103int32_t HAL_SetJoystickOutputs(int32_t joystickNum, int64_t outputs,
104 int32_t leftRumble, int32_t rightRumble);
105double HAL_GetMatchTime(int32_t* status);
106
107#ifndef HAL_USE_LABVIEW
108
109void HAL_WaitForDSData(void);
110void HAL_InitializeDriverStation(void);
111
112void HAL_ObserveUserProgramStarting(void);
113void HAL_ObserveUserProgramDisabled(void);
114void HAL_ObserveUserProgramAutonomous(void);
115void HAL_ObserveUserProgramTeleop(void);
116void HAL_ObserveUserProgramTest(void);
117
118#endif // HAL_USE_LABVIEW
119
120#ifdef __cplusplus
121} // extern "C"
122#endif