CTRE Phoenix C++ 5.33.1
CANifier.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
4#include <cstdint>
15
16namespace ctre {namespace phoenix {
17
18/**
19 * Configurables available to CANifier
20 */
22 /**
23 * Velocity measurement period to use
24 */
26 /**
27 * Velocity measurement window to use
28 */
30 /**
31 * Whether to clear sensor position on forward limit
32 */
34 /**
35 * Whether to clear sensor position on reverse limit
36 */
38 /**
39 * Whether to clear sensor position on index
40 */
42
49 {
50 }
51
52 /**
53 * @return String representation of configs
54 */
55 std::string toString() {
56 return toString("");
57 }
58
59 /**
60 * @param prependString
61 * String to prepend to configs
62 * @return String representation of configs
63 */
64 std::string toString(std::string prependString) {
65
66 std::string retstr = prependString + ".velocityMeasurementPeriod = " + ctre::phoenix::sensors::SensorVelocityMeasPeriodRoutines::toString(velocityMeasurementPeriod) + ";\n";
67 retstr += prependString + ".velocityMeasurementWindow = " + std::to_string(velocityMeasurementWindow) + ";\n";
68 retstr += prependString + ".clearPositionOnLimitF = " + std::to_string(clearPositionOnLimitF) + ";\n";
69 retstr += prependString + ".clearPositionOnLimitR = " + std::to_string(clearPositionOnLimitR) + ";\n";
70 retstr += prependString + ".clearPositionOnQuadIdx = " + std::to_string(clearPositionOnQuadIdx) + ";\n";
71
72 retstr += CustomParamConfiguration::toString(prependString);
73
74 return retstr;
75 }
76
77};// struct CANifierConfiguration
78
79/**
80 * Util class to help with configuring CANifier
81 */
83private:
84 static CANifierConfiguration _default;
85public:
86 /**
87 * Determine if specified value is different from default
88 * @param settings settings to compare against
89 * @return if specified value is different from default
90 * @{
91 */
92 static bool VelocityMeasurementPeriodDifferent (const CANifierConfiguration & settings) { return (!(settings.velocityMeasurementPeriod == _default.velocityMeasurementPeriod)) || !settings.enableOptimizations; }
93 static bool VelocityMeasurementWindowDifferent (const CANifierConfiguration & settings) { return (!(settings.velocityMeasurementWindow == _default.velocityMeasurementWindow)) || !settings.enableOptimizations; }
94 static bool ClearPositionOnLimitFDifferent (const CANifierConfiguration & settings) { return (!(settings.clearPositionOnLimitF == _default.clearPositionOnLimitF)) || !settings.enableOptimizations; }
95 static bool ClearPositionOnLimitRDifferent (const CANifierConfiguration & settings) { return (!(settings.clearPositionOnLimitR == _default.clearPositionOnLimitR)) || !settings.enableOptimizations; }
96 static bool ClearPositionOnQuadIdxDifferent (const CANifierConfiguration & settings) { return (!(settings.clearPositionOnQuadIdx == _default.clearPositionOnQuadIdx)) || !settings.enableOptimizations; }
97 static bool CustomParam0Different (const CANifierConfiguration & settings) { return (!(settings.customParam0 == _default.customParam0)) || !settings.enableOptimizations; }
98 static bool CustomParam1Different (const CANifierConfiguration & settings) { return (!(settings.customParam1 == _default.customParam1)) || !settings.enableOptimizations; }
99 /** @} */
100};
101
102
103/**
104 * CTRE CANifier
105 *
106 * Device for interfacing common devices to the CAN bus.
107 */
109public:
110 /**
111 * Enum for the LED Output Channels
112 */
114 /**
115 * LED Channel A
116 */
118 /**
119 * LED Channel B
120 */
122 /**
123 * LED Channel C
124 */
126 };
127
128 /**
129 * Enum for the PWM Input Channels
130 */
132 /**
133 * PWM Channel 0
134 */
136 /**
137 * PWM Channel 1
138 */
140 /**
141 * PWM Channel 2
142 */
144 /**
145 * PWM Channel 3
146 */
148 };
149
150 /**
151 * Number of PWM channels available to CANifier
152 */
153 const int PWMChannelCount = 4;
154
155 /**
156 * General IO Pins on the CANifier
157 */
158 enum GeneralPin { //----- Must match CANifier_CCI enums -----//
159 /**
160 * Quadrature Idx pin
161 */
163 /**
164 * Quadrature B pin
165 */
167 /**
168 * Quadrature A pin
169 */
171 /**
172 * Reverse limit pin
173 */
174 LIMR = 3,
175 /**
176 * Forward limit pin
177 */
178 LIMF = 4,
179 /**
180 * SDA pin
181 */
182 SDA = 5,
183 /**
184 * SCL pin
185 */
186 SCL = 6,
187 /**
188 * SPI_CS pin
189 */
191 /**
192 * SPI_MISO_PWM2 pin
193 */
195 /**
196 * SPI_MOSI_PWM1 pin
197 */
199 /**
200 * SPI_CLK_PWM0 pin
201 */
203 };
204
205 /**
206 * Structure to hold the pin values.
207 */
208 struct PinValues {
209 /**
210 * Quadrature Idx pin
211 */
213 /**
214 * Quadrature B pin
215 */
216 bool QUAD_B;
217 /**
218 * Quadrature A pin
219 */
220 bool QUAD_A;
221 /**
222 * Reverse limit pin
223 */
224 bool LIMR;
225 /**
226 * Forward limit pin
227 */
228 bool LIMF;
229 /**
230 * SDA pin
231 */
232 bool SDA;
233 /**
234 * SCL pin
235 */
236 bool SCL;
237 /**
238 * SPI_CS_PWM3 pin
239 */
241 /**
242 * SPI_MISO_PWM2 pin
243 */
245 /**
246 * SPI_MOSI_PWM1 pin
247 */
249 /**
250 * SPI_CLK_PWM0 pin
251 */
253 };
254
255 /**
256 * Constructor.
257 * @param deviceNumber The CAN Device ID of the CANifier.
258 */
259 CANifier(int deviceNumber);
260
262
263 /**
264 * Destructs all CANifier objects
265 */
266 static void DestroyAllCANifiers();
267
268 /**
269 * Sets the LED Output
270 * @param percentOutput Output duty cycle expressed as percentage.
271 * @param ledChannel Channel to set the output of.
272 */
273 ErrorCode SetLEDOutput(double percentOutput, LEDChannel ledChannel);
274 /**
275 * Sets the output of a General Pin
276 * @param outputPin The pin to use as output.
277 * @param outputValue The desired output state.
278 * @param outputEnable Whether this pin is an output. "True" enables output.
279 */
280 ErrorCode SetGeneralOutput(GeneralPin outputPin, bool outputValue, bool outputEnable);
281 /**
282 * Sets the output of all General Pins
283 * @param outputBits A bit mask of all the output states. LSB->MSB is in the order of the #GeneralPin enum.
284 * @param isOutputBits A boolean bit mask that sets the pins to be outputs or inputs. A bit of 1 enables output.
285 */
286 ErrorCode SetGeneralOutputs(int outputBits, int isOutputBits);
287 /**
288 * Gets the state of all General Pins
289 * @param allPins A structure to fill with the current state of all pins.
290 */
292 /**
293 * Gets the state of the specified pin
294 * @param inputPin The index of the pin.
295 * @return The state of the pin.
296 */
298 /**
299 * Gets the quadrature encoder's position
300 * @return Position of encoder
301 */
303 /**
304 * Gets the quadrature encoder's velocity
305 * @return Velocity of encoder
306 */
308 /**
309 * Sets the quadrature encoder's position
310 * @param newPosition Position to set
311 * @param timeoutMs
312 Timeout value in ms. If nonzero, function will wait for
313 config success and report an error if it times out.
314 If zero, no blocking or checking is performed.
315 * @return Error Code generated by function. 0 indicates no error.
316 */
317 ErrorCode SetQuadraturePosition(int newPosition, int timeoutMs = 0);
318 /**
319 * Configures the period of each velocity sample.
320 * Every 1ms a position value is sampled, and the delta between that sample
321 * and the position sampled kPeriod ms ago is inserted into a filter.
322 * kPeriod is configured with this function.
323 *
324 * @param period Desired period for the velocity measurement.
325 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
326 * config success and report an error if it times out.
327 * If zero, no blocking or checking is performed.
328 * @return Error Code generated by function. 0 indicates no error.
329 */
331 ctre::phoenix::sensors::SensorVelocityMeasPeriod period, int timeoutMs = 0);
332
333 [[deprecated("Use the overload with SensorVelocityMeasPeriod instead")]]
335 CANifierVelocityMeasPeriod period, int timeoutMs = 0);
336 /**
337 * Sets the number of velocity samples used in the rolling average velocity
338 * measurement.
339 *
340 * @param windowSize Number of samples in the rolling average of velocity
341 * measurement. Valid values are 1,2,4,8,16,32. If another
342 * value is specified, it will truncate to nearest support value.
343 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
344 * config success and report an error if it times out.
345 * If zero, no blocking or checking is performed.
346 * @return Error Code generated by function. 0 indicates no error.
347 */
348 ErrorCode ConfigVelocityMeasurementWindow(int windowSize, int timeoutMs = 0);
349 /**
350 * Enables clearing the position of the feedback sensor when the forward
351 * limit switch is triggered
352 *
353 * @param clearPositionOnLimitF Whether clearing is enabled, defaults false
354 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
355 * config success and report an error if it times out.
356 * If zero, no blocking or checking is performed.
357 * @return Error Code generated by function. 0 indicates no error.
358 */
359 ErrorCode ConfigClearPositionOnLimitF (bool clearPositionOnLimitF, int timeoutMs = 0);
360 /**
361 * Enables clearing the position of the feedback sensor when the reverse
362 * limit switch is triggered
363 *
364 * @param clearPositionOnLimitR Whether clearing is enabled, defaults false
365 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
366 * config success and report an error if it times out.
367 * If zero, no blocking or checking is performed.
368 * @return Error Code generated by function. 0 indicates no error.
369 */
370 ErrorCode ConfigClearPositionOnLimitR (bool clearPositionOnLimitR, int timeoutMs = 0);
371 /**
372 * Enables clearing the position of the feedback sensor when the quadrature index signal
373 * is detected
374 *
375 * @param clearPositionOnQuadIdx Whether clearing is enabled, defaults false
376 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
377 * config success and report an error if it times out.
378 * If zero, no blocking or checking is performed.
379 * @return Error Code generated by function. 0 indicates no error.
380 */
381 ErrorCode ConfigClearPositionOnQuadIdx(bool clearPositionOnQuadIdx, int timeoutMs = 0);
382 /**
383 * Gets the bus voltage seen by the device.
384 *
385 * @return The bus voltage value (in volts).
386 */
388 /**
389 * Call GetLastError() generated by this object.
390 * Not all functions return an error code but can
391 * potentially report errors.
392 *
393 * This function can be used to retrieve those error codes.
394 *
395 * @return The last ErrorCode generated.
396 */
398 /**
399 * Sets the PWM Output
400 * Currently supports PWM 0, PWM 1, and PWM 2
401 * @param pwmChannel Index of the PWM channel to output.
402 * @param dutyCycle Duty Cycle (0 to 1) to output. Default period of the signal is 4.2 ms.
403 */
404 ErrorCode SetPWMOutput(int pwmChannel, double dutyCycle);
405 /**
406 * Enables PWM Outputs
407 * Currently supports PWM 0, PWM 1, and PWM 2
408 * @param pwmChannel Index of the PWM channel to enable.
409 * @param bEnable "True" enables output on the pwm channel.
410 */
411 ErrorCode EnablePWMOutput(int pwmChannel, bool bEnable);
412 /**
413 * Gets the PWM Input
414 * @param pwmChannel PWM channel to get.
415 * @param pulseWidthAndPeriod Double array to hold Duty Cycle [0] and Period [1].
416 */
417 ErrorCode GetPWMInput(PWMChannel pwmChannel, double pulseWidthAndPeriod[]);
418
419 //------ Custom Persistent Params ----------//
420 /**
421 * Sets the value of a custom parameter. This is for arbitrary use.
422 *
423 * Sometimes it is necessary to save calibration/duty cycle/output
424 * information in the device. Particularly if the
425 * device is part of a subsystem that can be replaced.
426 *
427 * @param newValue Value for custom parameter.
428 * @param paramIndex Index of custom parameter. [0-1]
429 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
430 * config success and report an error if it times out.
431 * If zero, no blocking or checking is performed.
432 * @return Error Code generated by function. 0 indicates no error.
433 */
434 ErrorCode ConfigSetCustomParam(int newValue, int paramIndex,
435 int timeoutMs = 0);
436 /**
437 * Gets the value of a custom parameter. This is for arbitrary use.
438 *
439 * Sometimes it is necessary to save calibration/duty cycle/output
440 * information in the device. Particularly if the
441 * device is part of a subsystem that can be replaced.
442 *
443 * @param paramIndex Index of custom parameter. [0-1]
444 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
445 * config success and report an error if it times out.
446 * If zero, no blocking or checking is performed.
447 * @return Value of the custom param.
448 */
449 int ConfigGetCustomParam(int paramIndex,
450 int timeoutMs = 0);
451 //------ Generic Param API, typically not used ----------//
452 /**
453 * Sets a parameter. Generally this is not used.
454 * This can be utilized in
455 * - Using new features without updating API installation.
456 * - Errata workarounds to circumvent API implementation.
457 * - Allows for rapid testing / unit testing of firmware.
458 *
459 * @param param Parameter enumeration.
460 * @param value Value of parameter.
461 * @param subValue Subvalue for parameter. Maximum value of 255.
462 * @param ordinal Ordinal of parameter.
463 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
464 * config success and report an error if it times out.
465 * If zero, no blocking or checking is performed.
466 * @return Error Code generated by function. 0 indicates no error.
467 */
469 uint8_t subValue, int ordinal, int timeoutMs = 0);
470 /**
471 * Gets a parameter. Generally this is not used.
472 * This can be utilized in
473 * - Using new features without updating API installation.
474 * - Errata workarounds to circumvent API implementation.
475 * - Allows for rapid testing / unit testing of firmware.
476 *
477 * @param param Parameter enumeration.
478 * @param ordinal Ordinal of parameter.
479 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
480 * config success and report an error if it times out.
481 * If zero, no blocking or checking is performed.
482 * @return Value of parameter.
483 */
484 double ConfigGetParameter(ParamEnum param, int ordinal, int timeoutMs = 0);
485
486 /**
487 * Gets a parameter by passing an int by reference
488 *
489 * @param param
490 * Parameter enumeration
491 * @param valueToSend
492 * Value to send to parameter
493 * @param valueReceived
494 * Reference to integer to receive
495 * @param subValue
496 * SubValue of parameter
497 * @param ordinal
498 * Ordinal of parameter
499 * @param timeoutMs
500 * Timeout value in ms. If nonzero, function will wait for
501 * config success and report an error if it times out.
502 * If zero, no blocking or checking is performed.
503 * @return Error Code generated by function. 0 indicates no error.
504 */
505 ErrorCode ConfigGetParameter(ParamEnum param, int32_t valueToSend,
506 int32_t & valueReceived, uint8_t & subValue, int32_t ordinal,
507 int32_t timeoutMs);
508
509
510 /**
511 * Sets the period of the given status frame.
512 *
513 * @param statusFrame Frame whose period is to be changed.
514 * @param periodMs Period in ms for the given frame.
515 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
516 * config success and report an error if it times out.
517 * If zero, no blocking or checking is performed.
518 * @return Error Code generated by function. 0 indicates no error.
519 */
521 uint8_t periodMs, int timeoutMs = 0);
522 /**
523 * Gets the period of the given status frame.
524 *
525 * @param frame Frame to get the period of.
526 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
527 * config success and report an error if it times out.
528 * If zero, no blocking or checking is performed.
529 * @return Period of the given status frame.
530 */
531 int GetStatusFramePeriod(CANifierStatusFrame frame, int timeoutMs = 0);
532 /**
533 * Sets the period of the given control frame.
534 *
535 * @param frame Frame whose period is to be changed.
536 * @param periodMs Period in ms for the given frame.
537 * @return Error Code generated by function. 0 indicates no error.
538 */
540 /**
541 * Gets the firmware version of the device.
542 *
543 * @return Firmware version of device.
544 */
546 /**
547 * Returns true if the device has reset since last call.
548 *
549 * @return Has a Device Reset Occurred?
550 */
552 /**
553 * Gets the CANifier fault status
554 *
555 * @param toFill
556 * Container for fault statuses.
557 * @return Error Code generated by function. 0 indicates no error.
558 */
560 /**
561 * Gets the CANifier sticky fault status
562 *
563 * @param toFill
564 * Container for sticky fault statuses.
565 * @return Error Code generated by function. 0 indicates no error.
566 */
568 /**
569 * Clears the Sticky Faults
570 *
571 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
572 * config success and report an error if it times out.
573 * If zero, no blocking or checking is performed.
574 *
575 * @return Error Code generated by function. 0 indicates no error.
576 */
577 ErrorCode ClearStickyFaults(int timeoutMs = 0);
578
579 //------ All Configs ----------//
580 /**
581 * Configures all persistent settings.
582 *
583 * @param allConfigs Object with all of the persistant settings
584 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
585 * config success and report an error if it times out.
586 * If zero, no blocking or checking is performed.
587 *
588 * @return Error Code generated by function. 0 indicates no error.
589 */
591 /**
592 * Gets all persistant settings.
593 *
594 * @param allConfigs Object with all of the persistant settings
595 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
596 * config success and report an error if it times out.
597 * If zero, no blocking or checking is performed.
598 */
599 void GetAllConfigs(CANifierConfiguration &allConfigs, int timeoutMs = 50);
600 /**
601 * Configures all persistent settings to defaults (overloaded so timeoutMs is 50 ms).
602 *
603 * @param timeoutMs Timeout value in ms. If nonzero, function will wait for
604 * config success and report an error if it times out.
605 * If zero, no blocking or checking is performed.
606 *
607 * @return Error Code generated by function. 0 indicates no error.
608 */
609 ErrorCode ConfigFactoryDefault(int timeoutMs = 50);
610
611
612private:
613 void* m_handle;
614 bool _tempPins[11];
615};// class CANifier
616
617} // namespace phoenix
618} // namespace ctre
Simple address holder.
Definition: CANBusAddressable.h:9
CTRE CANifier.
Definition: CANifier.h:108
ErrorCode ConfigVelocityMeasurementPeriod(CANifierVelocityMeasPeriod period, int timeoutMs=0)
ErrorCode ConfigFactoryDefault(int timeoutMs=50)
Configures all persistent settings to defaults (overloaded so timeoutMs is 50 ms).
GeneralPin
General IO Pins on the CANifier.
Definition: CANifier.h:158
@ SPI_MOSI_PWM1P
SPI_MOSI_PWM1 pin.
Definition: CANifier.h:198
@ LIMR
Reverse limit pin.
Definition: CANifier.h:174
@ QUAD_A
Quadrature A pin.
Definition: CANifier.h:170
@ LIMF
Forward limit pin.
Definition: CANifier.h:178
@ SPI_CLK_PWM0P
SPI_CLK_PWM0 pin.
Definition: CANifier.h:202
@ SPI_MISO_PWM2P
SPI_MISO_PWM2 pin.
Definition: CANifier.h:194
@ SCL
SCL pin.
Definition: CANifier.h:186
@ SDA
SDA pin.
Definition: CANifier.h:182
@ SPI_CS
SPI_CS pin.
Definition: CANifier.h:190
@ QUAD_B
Quadrature B pin.
Definition: CANifier.h:166
@ QUAD_IDX
Quadrature Idx pin.
Definition: CANifier.h:162
bool GetGeneralInput(GeneralPin inputPin)
Gets the state of the specified pin.
bool HasResetOccurred()
Returns true if the device has reset since last call.
ErrorCode ConfigVelocityMeasurementWindow(int windowSize, int timeoutMs=0)
Sets the number of velocity samples used in the rolling average velocity measurement.
int GetStatusFramePeriod(CANifierStatusFrame frame, int timeoutMs=0)
Gets the period of the given status frame.
ErrorCode GetFaults(CANifierFaults &toFill)
Gets the CANifier fault status.
PWMChannel
Enum for the PWM Input Channels.
Definition: CANifier.h:131
@ PWMChannel0
PWM Channel 0.
Definition: CANifier.h:135
@ PWMChannel3
PWM Channel 3.
Definition: CANifier.h:147
@ PWMChannel1
PWM Channel 1.
Definition: CANifier.h:139
@ PWMChannel2
PWM Channel 2.
Definition: CANifier.h:143
ctre::phoenix::ErrorCode ConfigAllSettings(const CANifierConfiguration &allConfigs, int timeoutMs=50)
Configures all persistent settings.
ErrorCode ClearStickyFaults(int timeoutMs=0)
Clears the Sticky Faults.
ErrorCode ConfigClearPositionOnQuadIdx(bool clearPositionOnQuadIdx, int timeoutMs=0)
Enables clearing the position of the feedback sensor when the quadrature index signal is detected.
ErrorCode ConfigSetParameter(ParamEnum param, double value, uint8_t subValue, int ordinal, int timeoutMs=0)
Sets a parameter.
ErrorCode ConfigSetCustomParam(int newValue, int paramIndex, int timeoutMs=0)
Sets the value of a custom parameter.
CANifier(int deviceNumber)
Constructor.
ErrorCode ConfigClearPositionOnLimitR(bool clearPositionOnLimitR, int timeoutMs=0)
Enables clearing the position of the feedback sensor when the reverse limit switch is triggered.
ErrorCode SetStatusFramePeriod(CANifierStatusFrame statusFrame, uint8_t periodMs, int timeoutMs=0)
Sets the period of the given status frame.
double ConfigGetParameter(ParamEnum param, int ordinal, int timeoutMs=0)
Gets a parameter.
LEDChannel
Enum for the LED Output Channels.
Definition: CANifier.h:113
@ LEDChannelC
LED Channel C.
Definition: CANifier.h:125
@ LEDChannelA
LED Channel A.
Definition: CANifier.h:117
@ LEDChannelB
LED Channel B.
Definition: CANifier.h:121
ErrorCode GetGeneralInputs(PinValues &allPins)
Gets the state of all General Pins.
ErrorCode SetLEDOutput(double percentOutput, LEDChannel ledChannel)
Sets the LED Output.
const int PWMChannelCount
Number of PWM channels available to CANifier.
Definition: CANifier.h:153
ErrorCode SetPWMOutput(int pwmChannel, double dutyCycle)
Sets the PWM Output Currently supports PWM 0, PWM 1, and PWM 2.
ErrorCode SetGeneralOutput(GeneralPin outputPin, bool outputValue, bool outputEnable)
Sets the output of a General Pin.
static void DestroyAllCANifiers()
Destructs all CANifier objects.
ErrorCode ConfigClearPositionOnLimitF(bool clearPositionOnLimitF, int timeoutMs=0)
Enables clearing the position of the feedback sensor when the forward limit switch is triggered.
ErrorCode SetQuadraturePosition(int newPosition, int timeoutMs=0)
Sets the quadrature encoder's position.
int ConfigGetCustomParam(int paramIndex, int timeoutMs=0)
Gets the value of a custom parameter.
ErrorCode GetLastError()
Call GetLastError() generated by this object.
ErrorCode SetGeneralOutputs(int outputBits, int isOutputBits)
Sets the output of all General Pins.
double GetBusVoltage()
Gets the bus voltage seen by the device.
int GetQuadraturePosition()
Gets the quadrature encoder's position.
ErrorCode ConfigGetParameter(ParamEnum param, int32_t valueToSend, int32_t &valueReceived, uint8_t &subValue, int32_t ordinal, int32_t timeoutMs)
Gets a parameter by passing an int by reference.
ErrorCode ConfigVelocityMeasurementPeriod(ctre::phoenix::sensors::SensorVelocityMeasPeriod period, int timeoutMs=0)
Configures the period of each velocity sample.
ErrorCode GetStickyFaults(CANifierStickyFaults &toFill)
Gets the CANifier sticky fault status.
ErrorCode GetPWMInput(PWMChannel pwmChannel, double pulseWidthAndPeriod[])
Gets the PWM Input.
void GetAllConfigs(CANifierConfiguration &allConfigs, int timeoutMs=50)
Gets all persistant settings.
ErrorCode SetControlFramePeriod(CANifierControlFrame frame, int periodMs)
Sets the period of the given control frame.
int GetQuadratureVelocity()
Gets the quadrature encoder's velocity.
ErrorCode EnablePWMOutput(int pwmChannel, bool bEnable)
Enables PWM Outputs Currently supports PWM 0, PWM 1, and PWM 2.
int GetFirmwareVersion()
Gets the firmware version of the device.
static std::string toString(SensorVelocityMeasPeriod value)
String representation of specified CANCoderVelocityMeasPeriod.
Definition: SensorVelocityMeasPeriod.h:58
SensorVelocityMeasPeriod
Enumerate filter periods for any sensor that measures velocity.
Definition: SensorVelocityMeasPeriod.h:13
CANifierStatusFrame
Enumerated type for status frame types.
Definition: CANifierStatusFrame.h:8
ParamEnum
Signal enumeration for generic signal access.
Definition: paramEnum.h:13
ErrorCode
Definition: ErrorCode.h:13
CANifierVelocityMeasPeriod
Enum for velocity periods used for CANifier.
Definition: CANifierVelocityMeasPeriod.h:12
@ Period_100Ms
100ms velocity measurement period
Definition: CANifierVelocityMeasPeriod.h:44
CANifierControlFrame
Enumerated type for status frame types.
Definition: CANifierControlFrame.h:8
namespace ctre
Definition: paramEnum.h:5
Structure to hold the pin values.
Definition: CANifier.h:208
bool SPI_MOSI_PWM1
SPI_MOSI_PWM1 pin.
Definition: CANifier.h:248
bool LIMR
Reverse limit pin.
Definition: CANifier.h:224
bool SPI_CS_PWM3
SPI_CS_PWM3 pin.
Definition: CANifier.h:240
bool QUAD_IDX
Quadrature Idx pin.
Definition: CANifier.h:212
bool SPI_MISO_PWM2
SPI_MISO_PWM2 pin.
Definition: CANifier.h:244
bool QUAD_B
Quadrature B pin.
Definition: CANifier.h:216
bool SCL
SCL pin.
Definition: CANifier.h:236
bool SPI_CLK_PWM0
SPI_CLK_PWM0 pin.
Definition: CANifier.h:252
bool QUAD_A
Quadrature A pin.
Definition: CANifier.h:220
bool LIMF
Forward limit pin.
Definition: CANifier.h:228
bool SDA
SDA pin.
Definition: CANifier.h:232
Util class to help with configuring CANifier.
Definition: CANifier.h:82
static bool ClearPositionOnLimitFDifferent(const CANifierConfiguration &settings)
Definition: CANifier.h:94
static bool ClearPositionOnLimitRDifferent(const CANifierConfiguration &settings)
Definition: CANifier.h:95
static bool VelocityMeasurementWindowDifferent(const CANifierConfiguration &settings)
Definition: CANifier.h:93
static bool VelocityMeasurementPeriodDifferent(const CANifierConfiguration &settings)
Determine if specified value is different from default.
Definition: CANifier.h:92
static bool CustomParam0Different(const CANifierConfiguration &settings)
Definition: CANifier.h:97
static bool ClearPositionOnQuadIdxDifferent(const CANifierConfiguration &settings)
Definition: CANifier.h:96
static bool CustomParam1Different(const CANifierConfiguration &settings)
Definition: CANifier.h:98
Configurables available to CANifier.
Definition: CANifier.h:21
bool clearPositionOnLimitF
Whether to clear sensor position on forward limit.
Definition: CANifier.h:33
bool clearPositionOnLimitR
Whether to clear sensor position on reverse limit.
Definition: CANifier.h:37
bool clearPositionOnQuadIdx
Whether to clear sensor position on index.
Definition: CANifier.h:41
ctre::phoenix::sensors::SensorVelocityMeasPeriod velocityMeasurementPeriod
Velocity measurement period to use.
Definition: CANifier.h:25
int velocityMeasurementWindow
Velocity measurement window to use.
Definition: CANifier.h:29
CANifierConfiguration()
Definition: CANifier.h:43
std::string toString()
Definition: CANifier.h:55
std::string toString(std::string prependString)
Definition: CANifier.h:64
Faults available to CANifier (Currently has none)
Definition: CANifierFaults.h:10
Sticky Faults for CANifier (Currently has none)
Definition: CANifierStickyFaults.h:10
Configurables for any custom param configs.
Definition: CustomParamConfiguration.h:11
int customParam1
Custom Param 1.
Definition: CustomParamConfiguration.h:19
bool enableOptimizations
Enable optimizations for ConfigAll (defaults true)
Definition: CustomParamConfiguration.h:23
int customParam0
Custom Param 0.
Definition: CustomParamConfiguration.h:15
std::string toString()
Definition: CustomParamConfiguration.h:34