|
CTRE Phoenix C++ 5.34.0-beta-4
|
#include <ctre/phoenix/CANifier.h>
Classes | |
| struct | PinValues |
| Structure to hold the pin values. More... | |
Public Types | |
| enum | LEDChannel { LEDChannelA = 0 , LEDChannelB = 1 , LEDChannelC = 2 } |
| Enum for the LED Output Channels. More... | |
| enum | PWMChannel { PWMChannel0 = 0 , PWMChannel1 = 1 , PWMChannel2 = 2 , PWMChannel3 = 3 } |
| Enum for the PWM Input Channels. More... | |
| enum | GeneralPin { QUAD_IDX = 0 , QUAD_B = 1 , QUAD_A = 2 , LIMR = 3 , LIMF = 4 , SDA = 5 , SCL = 6 , SPI_CS = 7 , SPI_MISO_PWM2P = 8 , SPI_MOSI_PWM1P = 9 , SPI_CLK_PWM0P = 10 } |
| General IO Pins on the CANifier. More... | |
Public Member Functions | |
| CANifier (int deviceNumber) | |
| Constructor. More... | |
| ~CANifier () | |
| ErrorCode | SetLEDOutput (double percentOutput, LEDChannel ledChannel) |
| Sets the LED Output. More... | |
| ErrorCode | SetGeneralOutput (GeneralPin outputPin, bool outputValue, bool outputEnable) |
| Sets the output of a General Pin. More... | |
| ErrorCode | SetGeneralOutputs (int outputBits, int isOutputBits) |
| Sets the output of all General Pins. More... | |
| ErrorCode | GetGeneralInputs (PinValues &allPins) |
| Gets the state of all General Pins. More... | |
| bool | GetGeneralInput (GeneralPin inputPin) |
| Gets the state of the specified pin. More... | |
| int | GetQuadraturePosition () |
| Gets the quadrature encoder's position. More... | |
| int | GetQuadratureVelocity () |
| Gets the quadrature encoder's velocity. More... | |
| ErrorCode | SetQuadraturePosition (int newPosition, int timeoutMs=0) |
| Sets the quadrature encoder's position. More... | |
| ErrorCode | ConfigVelocityMeasurementPeriod (ctre::phoenix::sensors::SensorVelocityMeasPeriod period, int timeoutMs=0) |
| Configures the period of each velocity sample. More... | |
| ErrorCode | ConfigVelocityMeasurementPeriod (CANifierVelocityMeasPeriod period, int timeoutMs=0) |
| ErrorCode | ConfigVelocityMeasurementWindow (int windowSize, int timeoutMs=0) |
| Sets the number of velocity samples used in the rolling average velocity measurement. More... | |
| ErrorCode | ConfigClearPositionOnLimitF (bool clearPositionOnLimitF, int timeoutMs=0) |
| Enables clearing the position of the feedback sensor when the forward limit switch is triggered. More... | |
| ErrorCode | ConfigClearPositionOnLimitR (bool clearPositionOnLimitR, int timeoutMs=0) |
| Enables clearing the position of the feedback sensor when the reverse limit switch is triggered. More... | |
| ErrorCode | ConfigClearPositionOnQuadIdx (bool clearPositionOnQuadIdx, int timeoutMs=0) |
| Enables clearing the position of the feedback sensor when the quadrature index signal is detected. More... | |
| double | GetBusVoltage () |
| Gets the bus voltage seen by the device. More... | |
| ErrorCode | GetLastError () |
| Call GetLastError() generated by this object. More... | |
| ErrorCode | SetPWMOutput (int pwmChannel, double dutyCycle) |
| Sets the PWM Output Currently supports PWM 0, PWM 1, and PWM 2. More... | |
| ErrorCode | EnablePWMOutput (int pwmChannel, bool bEnable) |
| Enables PWM Outputs Currently supports PWM 0, PWM 1, and PWM 2. More... | |
| ErrorCode | GetPWMInput (PWMChannel pwmChannel, double pulseWidthAndPeriod[]) |
| Gets the PWM Input. More... | |
| ErrorCode | ConfigSetCustomParam (int newValue, int paramIndex, int timeoutMs=0) |
| Sets the value of a custom parameter. More... | |
| int | ConfigGetCustomParam (int paramIndex, int timeoutMs=0) |
| Gets the value of a custom parameter. More... | |
| ErrorCode | ConfigSetParameter (ParamEnum param, double value, uint8_t subValue, int ordinal, int timeoutMs=0) |
| Sets a parameter. More... | |
| double | ConfigGetParameter (ParamEnum param, int ordinal, int timeoutMs=0) |
| Gets a parameter. More... | |
| 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. More... | |
| ErrorCode | SetStatusFramePeriod (CANifierStatusFrame statusFrame, uint8_t periodMs, int timeoutMs=0) |
| Sets the period of the given status frame. More... | |
| int | GetStatusFramePeriod (CANifierStatusFrame frame, int timeoutMs=0) |
| Gets the period of the given status frame. More... | |
| ErrorCode | SetControlFramePeriod (CANifierControlFrame frame, int periodMs) |
| Sets the period of the given control frame. More... | |
| int | GetFirmwareVersion () |
| Gets the firmware version of the device. More... | |
| bool | HasResetOccurred () |
| Returns true if the device has reset since last call. More... | |
| ErrorCode | GetFaults (CANifierFaults &toFill) |
| Gets the CANifier fault status. More... | |
| ErrorCode | GetStickyFaults (CANifierStickyFaults &toFill) |
| Gets the CANifier sticky fault status. More... | |
| ErrorCode | ClearStickyFaults (int timeoutMs=0) |
| Clears the Sticky Faults. More... | |
| ctre::phoenix::ErrorCode | ConfigAllSettings (const CANifierConfiguration &allConfigs, int timeoutMs=50) |
| Configures all persistent settings. More... | |
| void | GetAllConfigs (CANifierConfiguration &allConfigs, int timeoutMs=50) |
| Gets all persistant settings. More... | |
| ErrorCode | ConfigFactoryDefault (int timeoutMs=50) |
| Configures all persistent settings to defaults (overloaded so timeoutMs is 50 ms). More... | |
Public Member Functions inherited from ctre::phoenix::CANBusAddressable | |
| CANBusAddressable (int deviceNumber) | |
| Constructor for a CANBusAddressable device. More... | |
| int | GetDeviceNumber () |
Static Public Member Functions | |
| static void | DestroyAllCANifiers () |
| Destructs all CANifier objects. More... | |
Public Attributes | |
| const int | PWMChannelCount = 4 |
| Number of PWM channels available to CANifier. More... | |
CTRE CANifier.
Device for interfacing common devices to the CAN bus.
General IO Pins on the CANifier.
| ctre::phoenix::CANifier::CANifier | ( | int | deviceNumber | ) |
Constructor.
| deviceNumber | The CAN Device ID of the CANifier. |
| ctre::phoenix::CANifier::~CANifier | ( | ) |
| ErrorCode ctre::phoenix::CANifier::ClearStickyFaults | ( | int | timeoutMs = 0 | ) |
Clears the Sticky Faults.
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ctre::phoenix::ErrorCode ctre::phoenix::CANifier::ConfigAllSettings | ( | const CANifierConfiguration & | allConfigs, |
| int | timeoutMs = 50 |
||
| ) |
Configures all persistent settings.
| allConfigs | Object with all of the persistant settings |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::ConfigClearPositionOnLimitF | ( | bool | clearPositionOnLimitF, |
| int | timeoutMs = 0 |
||
| ) |
Enables clearing the position of the feedback sensor when the forward limit switch is triggered.
| clearPositionOnLimitF | Whether clearing is enabled, defaults false |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::ConfigClearPositionOnLimitR | ( | bool | clearPositionOnLimitR, |
| int | timeoutMs = 0 |
||
| ) |
Enables clearing the position of the feedback sensor when the reverse limit switch is triggered.
| clearPositionOnLimitR | Whether clearing is enabled, defaults false |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::ConfigClearPositionOnQuadIdx | ( | bool | clearPositionOnQuadIdx, |
| int | timeoutMs = 0 |
||
| ) |
Enables clearing the position of the feedback sensor when the quadrature index signal is detected.
| clearPositionOnQuadIdx | Whether clearing is enabled, defaults false |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::ConfigFactoryDefault | ( | int | timeoutMs = 50 | ) |
Configures all persistent settings to defaults (overloaded so timeoutMs is 50 ms).
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| int ctre::phoenix::CANifier::ConfigGetCustomParam | ( | int | paramIndex, |
| int | timeoutMs = 0 |
||
| ) |
Gets the value of a custom parameter.
This is for arbitrary use.
Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.
| paramIndex | Index of custom parameter. [0-1] |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| double ctre::phoenix::CANifier::ConfigGetParameter | ( | ParamEnum | param, |
| int | ordinal, | ||
| int | timeoutMs = 0 |
||
| ) |
Gets a parameter.
Generally this is not used. This can be utilized in
| param | Parameter enumeration. |
| ordinal | Ordinal of parameter. |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::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.
| param | Parameter enumeration |
| valueToSend | Value to send to parameter |
| valueReceived | Reference to integer to receive |
| subValue | SubValue of parameter |
| ordinal | Ordinal of parameter |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::ConfigSetCustomParam | ( | int | newValue, |
| int | paramIndex, | ||
| int | timeoutMs = 0 |
||
| ) |
Sets the value of a custom parameter.
This is for arbitrary use.
Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.
| newValue | Value for custom parameter. |
| paramIndex | Index of custom parameter. [0-1] |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::ConfigSetParameter | ( | ParamEnum | param, |
| double | value, | ||
| uint8_t | subValue, | ||
| int | ordinal, | ||
| int | timeoutMs = 0 |
||
| ) |
Sets a parameter.
Generally this is not used. This can be utilized in
| param | Parameter enumeration. |
| value | Value of parameter. |
| subValue | Subvalue for parameter. Maximum value of 255. |
| ordinal | Ordinal of parameter. |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::ConfigVelocityMeasurementPeriod | ( | CANifierVelocityMeasPeriod | period, |
| int | timeoutMs = 0 |
||
| ) |
| ErrorCode ctre::phoenix::CANifier::ConfigVelocityMeasurementPeriod | ( | ctre::phoenix::sensors::SensorVelocityMeasPeriod | period, |
| int | timeoutMs = 0 |
||
| ) |
Configures the period of each velocity sample.
Every 1ms a position value is sampled, and the delta between that sample and the position sampled kPeriod ms ago is inserted into a filter. kPeriod is configured with this function.
| period | Desired period for the velocity measurement. |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::ConfigVelocityMeasurementWindow | ( | int | windowSize, |
| int | timeoutMs = 0 |
||
| ) |
Sets the number of velocity samples used in the rolling average velocity measurement.
| windowSize | Number of samples in the rolling average of velocity measurement. Valid values are 1,2,4,8,16,32. If another value is specified, it will truncate to nearest support value. |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
|
static |
Destructs all CANifier objects.
| ErrorCode ctre::phoenix::CANifier::EnablePWMOutput | ( | int | pwmChannel, |
| bool | bEnable | ||
| ) |
Enables PWM Outputs Currently supports PWM 0, PWM 1, and PWM 2.
| pwmChannel | Index of the PWM channel to enable. |
| bEnable | "True" enables output on the pwm channel. |
| void ctre::phoenix::CANifier::GetAllConfigs | ( | CANifierConfiguration & | allConfigs, |
| int | timeoutMs = 50 |
||
| ) |
Gets all persistant settings.
| allConfigs | Object with all of the persistant settings |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| double ctre::phoenix::CANifier::GetBusVoltage | ( | ) |
Gets the bus voltage seen by the device.
| ErrorCode ctre::phoenix::CANifier::GetFaults | ( | CANifierFaults & | toFill | ) |
Gets the CANifier fault status.
| toFill | Container for fault statuses. |
| int ctre::phoenix::CANifier::GetFirmwareVersion | ( | ) |
Gets the firmware version of the device.
| bool ctre::phoenix::CANifier::GetGeneralInput | ( | GeneralPin | inputPin | ) |
Gets the state of the specified pin.
| inputPin | The index of the pin. |
Gets the state of all General Pins.
| allPins | A structure to fill with the current state of all pins. |
| ErrorCode ctre::phoenix::CANifier::GetLastError | ( | ) |
Call GetLastError() generated by this object.
Not all functions return an error code but can potentially report errors.
This function can be used to retrieve those error codes.
| ErrorCode ctre::phoenix::CANifier::GetPWMInput | ( | PWMChannel | pwmChannel, |
| double | pulseWidthAndPeriod[] | ||
| ) |
Gets the PWM Input.
| pwmChannel | PWM channel to get. |
| pulseWidthAndPeriod | Double array to hold Duty Cycle [0] and Period [1]. |
| int ctre::phoenix::CANifier::GetQuadraturePosition | ( | ) |
Gets the quadrature encoder's position.
| int ctre::phoenix::CANifier::GetQuadratureVelocity | ( | ) |
Gets the quadrature encoder's velocity.
| int ctre::phoenix::CANifier::GetStatusFramePeriod | ( | CANifierStatusFrame | frame, |
| int | timeoutMs = 0 |
||
| ) |
Gets the period of the given status frame.
| frame | Frame to get the period of. |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::GetStickyFaults | ( | CANifierStickyFaults & | toFill | ) |
Gets the CANifier sticky fault status.
| toFill | Container for sticky fault statuses. |
| bool ctre::phoenix::CANifier::HasResetOccurred | ( | ) |
Returns true if the device has reset since last call.
| ErrorCode ctre::phoenix::CANifier::SetControlFramePeriod | ( | CANifierControlFrame | frame, |
| int | periodMs | ||
| ) |
Sets the period of the given control frame.
| frame | Frame whose period is to be changed. |
| periodMs | Period in ms for the given frame. |
| ErrorCode ctre::phoenix::CANifier::SetGeneralOutput | ( | GeneralPin | outputPin, |
| bool | outputValue, | ||
| bool | outputEnable | ||
| ) |
Sets the output of a General Pin.
| outputPin | The pin to use as output. |
| outputValue | The desired output state. |
| outputEnable | Whether this pin is an output. "True" enables output. |
| ErrorCode ctre::phoenix::CANifier::SetGeneralOutputs | ( | int | outputBits, |
| int | isOutputBits | ||
| ) |
Sets the output of all General Pins.
| outputBits | A bit mask of all the output states. LSB->MSB is in the order of the GeneralPin enum. |
| isOutputBits | A boolean bit mask that sets the pins to be outputs or inputs. A bit of 1 enables output. |
| ErrorCode ctre::phoenix::CANifier::SetLEDOutput | ( | double | percentOutput, |
| LEDChannel | ledChannel | ||
| ) |
Sets the LED Output.
| percentOutput | Output duty cycle expressed as percentage. |
| ledChannel | Channel to set the output of. |
| ErrorCode ctre::phoenix::CANifier::SetPWMOutput | ( | int | pwmChannel, |
| double | dutyCycle | ||
| ) |
Sets the PWM Output Currently supports PWM 0, PWM 1, and PWM 2.
| pwmChannel | Index of the PWM channel to output. |
| dutyCycle | Duty Cycle (0 to 1) to output. Default period of the signal is 4.2 ms. |
| ErrorCode ctre::phoenix::CANifier::SetQuadraturePosition | ( | int | newPosition, |
| int | timeoutMs = 0 |
||
| ) |
Sets the quadrature encoder's position.
| newPosition | Position to set |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| ErrorCode ctre::phoenix::CANifier::SetStatusFramePeriod | ( | CANifierStatusFrame | statusFrame, |
| uint8_t | periodMs, | ||
| int | timeoutMs = 0 |
||
| ) |
Sets the period of the given status frame.
| statusFrame | Frame whose period is to be changed. |
| periodMs | Period in ms for the given frame. |
| timeoutMs | Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed. |
| const int ctre::phoenix::CANifier::PWMChannelCount = 4 |
Number of PWM channels available to CANifier.