brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 1 | /************************************************************* |
| 2 | * NOTICE |
| 3 | * |
| 4 | * These are the only externally exposed functions to the |
| 5 | * NetworkCommunication library |
| 6 | * |
| 7 | * This is an implementation of FRC Spec for Comm Protocol |
| 8 | * Revision 4.5, June 30, 2008 |
| 9 | * |
| 10 | * Copyright (c) National Instruments 2008. All Rights Reserved. |
| 11 | * |
| 12 | *************************************************************/ |
| 13 | |
| 14 | #ifndef __FRC_COMM_H__ |
| 15 | #define __FRC_COMM_H__ |
| 16 | |
| 17 | #include <stdint.h> |
| 18 | |
| 19 | typedef uint64_t UINT64; |
| 20 | typedef uint32_t UINT32; |
| 21 | typedef uint16_t UINT16; |
| 22 | typedef uint8_t UINT8; |
| 23 | typedef int8_t INT8; |
| 24 | |
| 25 | struct FRCCommonControlData{ |
| 26 | UINT16 packetIndex; |
| 27 | union { |
| 28 | UINT8 control; |
brians | 6591d58 | 2013-03-03 05:31:53 +0000 | [diff] [blame] | 29 | // The order of the bits has to be flipped on little-endian machines (aka |
| 30 | // everything other than the cRIO that we build for) in order for it to |
| 31 | // work. Upstream WPILib does this based off of a different macro. |
| 32 | #ifndef __VXWORKS__ |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 33 | struct { |
brians | 6591d58 | 2013-03-03 05:31:53 +0000 | [diff] [blame] | 34 | UINT8 checkVersions :1; |
| 35 | UINT8 test :1; |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 36 | UINT8 resync : 1; |
| 37 | UINT8 fmsAttached:1; |
| 38 | UINT8 autonomous : 1; |
| 39 | UINT8 enabled : 1; |
| 40 | UINT8 notEStop : 1; |
| 41 | UINT8 reset : 1; |
| 42 | }; |
brians | 6591d58 | 2013-03-03 05:31:53 +0000 | [diff] [blame] | 43 | #else |
| 44 | struct { |
| 45 | UINT8 reset : 1; |
| 46 | UINT8 notEStop : 1; |
| 47 | UINT8 enabled : 1; |
| 48 | UINT8 autonomous : 1; |
| 49 | UINT8 fmsAttached:1; |
| 50 | UINT8 resync : 1; |
| 51 | UINT8 test :1; |
| 52 | UINT8 checkVersions :1; |
| 53 | }; |
| 54 | #endif |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 55 | }; |
| 56 | UINT8 dsDigitalIn; |
| 57 | UINT16 teamID; |
| 58 | |
| 59 | char dsID_Alliance; |
| 60 | char dsID_Position; |
| 61 | |
| 62 | union { |
| 63 | INT8 stick0Axes[6]; |
| 64 | struct { |
| 65 | INT8 stick0Axis1; |
| 66 | INT8 stick0Axis2; |
| 67 | INT8 stick0Axis3; |
| 68 | INT8 stick0Axis4; |
| 69 | INT8 stick0Axis5; |
| 70 | INT8 stick0Axis6; |
| 71 | }; |
| 72 | }; |
| 73 | UINT16 stick0Buttons; // Left-most 4 bits are unused |
| 74 | |
| 75 | union { |
| 76 | INT8 stick1Axes[6]; |
| 77 | struct { |
| 78 | INT8 stick1Axis1; |
| 79 | INT8 stick1Axis2; |
| 80 | INT8 stick1Axis3; |
| 81 | INT8 stick1Axis4; |
| 82 | INT8 stick1Axis5; |
| 83 | INT8 stick1Axis6; |
| 84 | }; |
| 85 | }; |
| 86 | UINT16 stick1Buttons; // Left-most 4 bits are unused |
| 87 | |
| 88 | union { |
| 89 | INT8 stick2Axes[6]; |
| 90 | struct { |
| 91 | INT8 stick2Axis1; |
| 92 | INT8 stick2Axis2; |
| 93 | INT8 stick2Axis3; |
| 94 | INT8 stick2Axis4; |
| 95 | INT8 stick2Axis5; |
| 96 | INT8 stick2Axis6; |
| 97 | }; |
| 98 | }; |
| 99 | UINT16 stick2Buttons; // Left-most 4 bits are unused |
| 100 | |
| 101 | union { |
| 102 | INT8 stick3Axes[6]; |
| 103 | struct { |
| 104 | INT8 stick3Axis1; |
| 105 | INT8 stick3Axis2; |
| 106 | INT8 stick3Axis3; |
| 107 | INT8 stick3Axis4; |
| 108 | INT8 stick3Axis5; |
| 109 | INT8 stick3Axis6; |
| 110 | }; |
| 111 | }; |
| 112 | UINT16 stick3Buttons; // Left-most 4 bits are unused |
| 113 | |
| 114 | //Analog inputs are 10 bit right-justified |
| 115 | UINT16 analog1; |
| 116 | UINT16 analog2; |
| 117 | UINT16 analog3; |
| 118 | UINT16 analog4; |
| 119 | |
| 120 | UINT64 cRIOChecksum; |
| 121 | UINT32 FPGAChecksum0; |
| 122 | UINT32 FPGAChecksum1; |
| 123 | UINT32 FPGAChecksum2; |
| 124 | UINT32 FPGAChecksum3; |
| 125 | |
| 126 | char versionData[8]; |
| 127 | }; |
| 128 | |
| 129 | |
| 130 | #endif |