ctre-sys 5.4.0

FFI bindings to CTR Electronics' Phoenix FRC libraries
Documentation
//! Enums and functions related to the CANifier.
#![allow(non_camel_case_types)]

use std::os::raw::{c_char, c_int};
use ErrorCode;

pub enum _Handle {}
pub type Handle = *mut _Handle;

/* automatically generated by rust-bindgen */

#[repr(i32)]
/// Enumerated type for status frame types.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum CANifierControlFrame {
    Control_1_General = 50593792,
    Control_2_PwmOutput = 50593856,
}
#[repr(i32)]
/// Enumerated type for status frame types.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum CANifierStatusFrame {
    Status_1_General = 267264,
    Status_2_General = 267328,
    Status_3_PwmInputs0 = 267392,
    Status_4_PwmInputs1 = 267456,
    Status_5_PwmInputs2 = 267520,
    Status_6_PwmInputs3 = 267584,
    Status_8_Misc = 267712,
}

#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum CANifierVelocityMeasPeriod {
    Period_1Ms = 1,
    Period_2Ms = 2,
    Period_5Ms = 5,
    Period_10Ms = 10,
    Period_20Ms = 20,
    Period_25Ms = 25,
    Period_50Ms = 50,
    Period_100Ms = 100,
}

#[repr(u32)]
/// General IO Pins on the CANifier
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub 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,
}

extern "C" {
    pub fn c_CANifier_Create1(deviceNumber: c_int) -> Handle;

    pub fn c_CANifier_GetDescription(
        handle: Handle,
        toFill: *mut c_char,
        toFillByteSz: c_int,
        numBytesFilled: *mut c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_SetLEDOutput(handle: Handle, dutyCycle: u32, ledChannel: u32) -> ErrorCode;

    pub fn c_CANifier_SetGeneralOutputs(
        handle: Handle,
        outputsBits: u32,
        isOutputBits: u32,
    ) -> ErrorCode;

    pub fn c_CANifier_SetGeneralOutput(
        handle: Handle,
        outputPin: u32,
        outputValue: bool,
        outputEnable: bool,
    ) -> ErrorCode;

    pub fn c_CANifier_SetPWMOutput(handle: Handle, pwmChannel: u32, dutyCycle: u32) -> ErrorCode;

    pub fn c_CANifier_EnablePWMOutput(handle: Handle, pwmChannel: u32, bEnable: bool) -> ErrorCode;

    pub fn c_CANifier_GetGeneralInputs(
        handle: Handle,
        allPins: *mut bool,
        capacity: u32,
    ) -> ErrorCode;

    pub fn c_CANifier_GetGeneralInput(
        handle: Handle,
        inputPin: u32,
        measuredInput: *mut bool,
    ) -> ErrorCode;

    /// dutyCycleAndPeriod takes an array of length 2
    pub fn c_CANifier_GetPWMInput(
        handle: Handle,
        pwmChannel: u32,
        dutyCycleAndPeriod: *mut f64,
    ) -> ErrorCode;

    pub fn c_CANifier_GetLastError(handle: Handle) -> ErrorCode;

    pub fn c_CANifier_GetBusVoltage(handle: Handle, batteryVoltage: *mut f64) -> ErrorCode;

    pub fn c_CANifier_GetQuadraturePosition(handle: Handle, pos: *mut c_int) -> ErrorCode;

    pub fn c_CANifier_SetQuadraturePosition(
        handle: Handle,
        pos: c_int,
        timeoutMs: c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_GetQuadratureVelocity(handle: Handle, vel: *mut c_int) -> ErrorCode;

    pub fn c_CANifier_GetQuadratureSensor(
        handle: Handle,
        pos: *mut c_int,
        vel: *mut c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_ConfigVelocityMeasurementPeriod(
        handle: Handle,
        period: c_int,
        timeoutMs: c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_ConfigVelocityMeasurementWindow(
        handle: Handle,
        window: c_int,
        timeoutMs: c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_SetLastError(handle: Handle, error: c_int);

    pub fn c_CANifier_ConfigSetParameter(
        handle: Handle,
        param: c_int,
        value: f64,
        subValue: c_int,
        ordinal: c_int,
        timeoutMs: c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_ConfigGetParameter(
        handle: Handle,
        param: c_int,
        value: *mut f64,
        ordinal: c_int,
        timeoutMs: c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_ConfigSetCustomParam(
        handle: Handle,
        newValue: c_int,
        paramIndex: c_int,
        timeoutMs: c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_ConfigGetCustomParam(
        handle: Handle,
        readValue: *mut c_int,
        paramIndex: c_int,
        timoutMs: c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_GetFaults(handle: Handle, param: *mut c_int) -> ErrorCode;

    pub fn c_CANifier_GetStickyFaults(handle: Handle, param: *mut c_int) -> ErrorCode;

    pub fn c_CANifier_ClearStickyFaults(handle: Handle, timeoutMs: c_int) -> ErrorCode;

    pub fn c_CANifier_GetFirmwareVersion(handle: Handle, firmwareVers: *mut c_int) -> ErrorCode;

    pub fn c_CANifier_HasResetOccurred(handle: Handle, hasReset: *mut bool) -> ErrorCode;

    pub fn c_CANifier_SetStatusFramePeriod(
        handle: Handle,
        frame: c_int,
        periodMs: c_int,
        timeoutMs: c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_GetStatusFramePeriod(
        handle: Handle,
        frame: c_int,
        periodMs: *mut c_int,
        timeoutMs: c_int,
    ) -> ErrorCode;

    pub fn c_CANifier_SetControlFramePeriod(
        handle: Handle,
        frame: c_int,
        periodMs: c_int,
    ) -> ErrorCode;
}