Brian Silverman | f7f267a | 2017-02-04 16:16:08 -0800 | [diff] [blame^] | 1 | /** |
| 2 | * @file ctre_frames.h |
| 3 | * CAN Encoder/Decoder Structures for CTRE devices. |
| 4 | */ |
| 5 | #ifndef CTRE_FRAMES_H |
| 6 | #define CTRE_FRAMES_H |
| 7 | |
| 8 | /** control */ |
| 9 | typedef struct _TALON_Control_1_General_10ms_t { |
| 10 | unsigned TokenH:8; |
| 11 | unsigned TokenL:8; |
| 12 | unsigned DemandH:8; |
| 13 | unsigned DemandM:8; |
| 14 | unsigned DemandL:8; |
| 15 | unsigned ProfileSlotSelect:1; |
| 16 | unsigned FeedbackDeviceSelect:4; |
| 17 | unsigned OverrideLimitSwitchEn:3; |
| 18 | unsigned RevFeedbackSensor:1; |
| 19 | unsigned RevMotDuringCloseLoopEn:1; |
| 20 | unsigned OverrideBrakeType:2; |
| 21 | unsigned ModeSelect:4; |
| 22 | unsigned RampThrottle:8; |
| 23 | } TALON_Control_1_General_10ms_t ; |
| 24 | |
| 25 | /* TALON_Control_2_Rates_OneShot_t removed since it has been deprecated */ |
| 26 | |
| 27 | typedef struct _TALON_Control_3_ClearFlags_OneShot_t { |
| 28 | unsigned ZeroFeedbackSensor:1; |
| 29 | unsigned ClearStickyFaults:1; |
| 30 | } TALON_Control_3_ClearFlags_OneShot_t ; |
| 31 | |
| 32 | typedef struct _TALON_Control_5_General_10ms_t { |
| 33 | unsigned ThrottleBump_h3:3; |
| 34 | unsigned ReservedZero:5; |
| 35 | unsigned ThrottleBump_l8:8; |
| 36 | unsigned DemandH:8; |
| 37 | unsigned DemandM:8; |
| 38 | unsigned DemandL:8; |
| 39 | unsigned ProfileSlotSelect:1; |
| 40 | unsigned FeedbackDeviceSelect:4; |
| 41 | unsigned OverrideLimitSwitchEn:3; |
| 42 | unsigned RevFeedbackSensor:1; |
| 43 | unsigned RevMotDuringCloseLoopEn:1; |
| 44 | unsigned OverrideBrakeType:2; |
| 45 | unsigned ModeSelect:4; |
| 46 | unsigned RampThrottle:8; |
| 47 | } TALON_Control_5_General_10ms_t ; |
| 48 | |
| 49 | typedef struct _TALON_Control_6_MotProfAddTrajPoint_t { |
| 50 | unsigned huffCode:2; //!< Compression coding |
| 51 | unsigned NextPt_VelOnly:1; |
| 52 | unsigned NextPt_IsLast:1; |
| 53 | unsigned reserved0:2; |
| 54 | unsigned NextPt_ZeroPosition:1; |
| 55 | unsigned NextPt_ProfileSlotSelect:1; |
| 56 | unsigned Idx:4; |
| 57 | unsigned reserved1:4; |
| 58 | unsigned restOfFrame0:8; |
| 59 | unsigned restOfFrame1:8; |
| 60 | unsigned restOfFrame2:8; |
| 61 | unsigned restOfFrame3:8; |
| 62 | unsigned restOfFrame4:8; |
| 63 | unsigned restOfFrame5:8; |
| 64 | } TALON_Control_6_MotProfAddTrajPoint_t; |
| 65 | |
| 66 | typedef struct _TALON_Control_6_MotProfAddTrajPoint_huff0_t { |
| 67 | unsigned huffCode_expect_0:2; //!< Compression coding |
| 68 | unsigned NextPt_VelOnly:1; |
| 69 | unsigned NextPt_IsLast:1; |
| 70 | unsigned reserved0:2; |
| 71 | unsigned NextPt_ZeroPosition:1; |
| 72 | unsigned NextPt_ProfileSlotSelect:1; |
| 73 | unsigned Idx:4; |
| 74 | unsigned reserved1:4; |
| 75 | unsigned NextPt_DurationMs:8; |
| 76 | unsigned NextPt_VelocityH:8; |
| 77 | unsigned NextPt_VelocityL:8; |
| 78 | unsigned NextPt_PositionH:8; |
| 79 | unsigned NextPt_PositionM:8; |
| 80 | unsigned NextPt_PositionL:8; |
| 81 | } TALON_Control_6_MotProfAddTrajPoint_huff0_t; |
| 82 | |
| 83 | typedef struct _TALON_Control_6_MotProfAddTrajPoint_huff1_t { |
| 84 | unsigned huffCode_expect_1:2; //!< Compression coding |
| 85 | unsigned NextPt_VelOnly:1; |
| 86 | unsigned NextPt_IsLast:1; |
| 87 | unsigned reserved0:2; |
| 88 | unsigned NextPt_ZeroPosition:1; |
| 89 | unsigned NextPt_ProfileSlotSelect:1; |
| 90 | unsigned Idx:4; |
| 91 | unsigned reserved1:4; |
| 92 | unsigned NextPt_DurationMs:8; |
| 93 | unsigned NextPt_SameVelocityH:8; |
| 94 | unsigned NextPt_SameVelocityL:8; |
| 95 | unsigned NextPt_DeltaPositionH:8; |
| 96 | unsigned NextPt_DeltaPositionL:8; |
| 97 | unsigned NextPt_Count:8; |
| 98 | } TALON_Control_6_MotProfAddTrajPoint_huff1_t; |
| 99 | |
| 100 | /** status */ |
| 101 | typedef struct _TALON_Status_1_General_10ms_t { |
| 102 | unsigned CloseLoopErrH:8; |
| 103 | unsigned CloseLoopErrM:8; |
| 104 | unsigned CloseLoopErrL:8; |
| 105 | unsigned AppliedThrottle_h3:3; |
| 106 | unsigned Fault_RevSoftLim:1; |
| 107 | unsigned Fault_ForSoftLim:1; |
| 108 | unsigned TokLocked:1; |
| 109 | unsigned LimitSwitchClosedRev:1; |
| 110 | unsigned LimitSwitchClosedFor:1; |
| 111 | unsigned AppliedThrottle_l8:8; |
| 112 | unsigned ModeSelect_h1:1; |
| 113 | unsigned FeedbackDeviceSelect:4; |
| 114 | unsigned LimitSwitchEn:3; |
| 115 | unsigned Fault_HardwareFailure:1; |
| 116 | unsigned Fault_RevLim:1; |
| 117 | unsigned Fault_ForLim:1; |
| 118 | unsigned Fault_UnderVoltage:1; |
| 119 | unsigned Fault_OverTemp:1; |
| 120 | unsigned ModeSelect_b3:3; |
| 121 | unsigned TokenSeed:8; |
| 122 | } TALON_Status_1_General_10ms_t ; |
| 123 | typedef struct _TALON_Status_2_Feedback_20ms_t { |
| 124 | unsigned SensorPositionH:8; |
| 125 | unsigned SensorPositionM:8; |
| 126 | unsigned SensorPositionL:8; |
| 127 | unsigned SensorVelocityH:8; |
| 128 | unsigned SensorVelocityL:8; |
| 129 | unsigned Current_h8:8; |
| 130 | unsigned StckyFault_RevSoftLim:1; |
| 131 | unsigned StckyFault_ForSoftLim:1; |
| 132 | unsigned StckyFault_RevLim:1; |
| 133 | unsigned StckyFault_ForLim:1; |
| 134 | unsigned StckyFault_UnderVoltage:1; |
| 135 | unsigned StckyFault_OverTemp:1; |
| 136 | unsigned Current_l2:2; |
| 137 | unsigned reserved:3; |
| 138 | unsigned Cmd5Allowed:1; |
| 139 | unsigned VelDiv4:1; |
| 140 | unsigned PosDiv8:1; |
| 141 | unsigned ProfileSlotSelect:1; |
| 142 | unsigned BrakeIsEnabled:1; |
| 143 | } TALON_Status_2_Feedback_20ms_t ; |
| 144 | typedef struct _TALON_Status_3_Enc_100ms_t { |
| 145 | unsigned EncPositionH:8; |
| 146 | unsigned EncPositionM:8; |
| 147 | unsigned EncPositionL:8; |
| 148 | unsigned EncVelH:8; |
| 149 | unsigned EncVelL:8; |
| 150 | unsigned EncIndexRiseEventsH:8; |
| 151 | unsigned EncIndexRiseEventsL:8; |
| 152 | unsigned reserved:3; |
| 153 | unsigned VelDiv4:1; |
| 154 | unsigned PosDiv8:1; |
| 155 | unsigned QuadIdxpin:1; |
| 156 | unsigned QuadBpin:1; |
| 157 | unsigned QuadApin:1; |
| 158 | } TALON_Status_3_Enc_100ms_t ; |
| 159 | typedef struct _TALON_Status_4_AinTempVbat_100ms_t { |
| 160 | unsigned AnalogInWithOvH:8; |
| 161 | unsigned AnalogInWithOvM:8; |
| 162 | unsigned AnalogInWithOvL:8; |
| 163 | unsigned AnalogInVelH:8; |
| 164 | unsigned AnalogInVelL:8; |
| 165 | unsigned Temp:8; |
| 166 | unsigned BatteryV:8; |
| 167 | unsigned reserved:6; |
| 168 | unsigned VelDiv4:1; |
| 169 | unsigned PosDiv8:1; |
| 170 | } TALON_Status_4_AinTempVbat_100ms_t ; |
| 171 | typedef struct _TALON_Status_5_Startup_OneShot_t { |
| 172 | unsigned ResetCountH:8; |
| 173 | unsigned ResetCountL:8; |
| 174 | unsigned ResetFlagsH:8; |
| 175 | unsigned ResetFlagsL:8; |
| 176 | unsigned FirmVersH:8; |
| 177 | unsigned FirmVersL:8; |
| 178 | } TALON_Status_5_Startup_OneShot_t ; |
| 179 | typedef struct _TALON_Status_6_Eol_t { |
| 180 | unsigned currentAdcUncal_h2:2; |
| 181 | unsigned reserved1:5; |
| 182 | unsigned SpiCsPin_GadgeteerPin6:1; |
| 183 | unsigned currentAdcUncal_l8:8; |
| 184 | unsigned tempAdcUncal_h2:2; |
| 185 | unsigned reserved2:6; |
| 186 | unsigned tempAdcUncal_l8:8; |
| 187 | unsigned vbatAdcUncal_h2:2; |
| 188 | unsigned reserved3:6; |
| 189 | unsigned vbatAdcUncal_l8:8; |
| 190 | unsigned analogAdcUncal_h2:2; |
| 191 | unsigned reserved4:6; |
| 192 | unsigned analogAdcUncal_l8:8; |
| 193 | } TALON_Status_6_Eol_t ; |
| 194 | typedef struct _TALON_Status_7_Debug_200ms_t { |
| 195 | unsigned TokenizationFails_h8:8; |
| 196 | unsigned TokenizationFails_l8:8; |
| 197 | unsigned LastFailedToken_h8:8; |
| 198 | unsigned LastFailedToken_l8:8; |
| 199 | unsigned TokenizationSucceses_h8:8; |
| 200 | unsigned TokenizationSucceses_l8:8; |
| 201 | } TALON_Status_7_Debug_200ms_t ; |
| 202 | typedef struct _TALON_Status_8_PulseWid_100ms_t { |
| 203 | unsigned PulseWidPositionH:8; |
| 204 | unsigned PulseWidPositionM:8; |
| 205 | unsigned PulseWidPositionL:8; |
| 206 | unsigned reserved:6; |
| 207 | unsigned VelDiv4:1; |
| 208 | unsigned PosDiv8:1; |
| 209 | unsigned PeriodUsM8:8; |
| 210 | unsigned PeriodUsL8:8; |
| 211 | unsigned PulseWidVelH:8; |
| 212 | unsigned PulseWidVelL:8; |
| 213 | } TALON_Status_8_PulseWid_100ms_t ; |
| 214 | typedef struct _TALON_Status_9_MotProfBuffer_100ms_t { |
| 215 | unsigned ActTraj_IsValid:1; //!< '1' if other ActTraj_* signals are valid. '0' if there is no active trajectory pt. |
| 216 | unsigned ActTraj_ProfileSlotSelect:1; |
| 217 | unsigned ActTraj_VelOnly:1; |
| 218 | unsigned ActTraj_IsLast:1; |
| 219 | unsigned OutputType:2; |
| 220 | unsigned HasUnderrun:1; |
| 221 | unsigned IsUnderrun:1; |
| 222 | unsigned NextID:4; |
| 223 | unsigned reserved1:3; |
| 224 | unsigned BufferIsFull:1; |
| 225 | unsigned Count:8; |
| 226 | unsigned ActTraj_VelocityH:8; |
| 227 | unsigned ActTraj_VelocityL:8; |
| 228 | unsigned ActTraj_PositionH:8; |
| 229 | unsigned ActTraj_PositionM:8; |
| 230 | unsigned ActTraj_PositionL:8; |
| 231 | } TALON_Status_9_MotProfBuffer_100ms_t ; |
| 232 | typedef struct _TALON_Param_Request_t { |
| 233 | unsigned ParamEnum:8; |
| 234 | } TALON_Param_Request_t ; |
| 235 | typedef struct _TALON_Param_Response_t { |
| 236 | unsigned ParamEnum:8; |
| 237 | unsigned ParamValueL:8; |
| 238 | unsigned ParamValueML:8; |
| 239 | unsigned ParamValueMH:8; |
| 240 | unsigned ParamValueH:8; |
| 241 | } TALON_Param_Response_t ; |
| 242 | |
| 243 | #endif /* CTRE_FRAMES_H */ |