Ejemplo n.º 1
0
    /*=====================================================================
     | COMPLEX MATCH CONFIGURATION
     | ====================================================================*/
    static void usbConfigComplexMatch()
    {
        int features = BeagleApi.bg_usb5000_features(beagle);

        if (features < 0)
        {
            Console.Write("error: could not retrieve features\n");
            Environment.Exit(1);
        }

        bool adv = (features & BeagleApi.BG_USB5000_FEATURE_CMP_TRIG) != 0;

        // Setup the first state.
        // Do a capture trigger on seeing a SET ADDRESS setup packet.

        // Match on a SET ADDRESS request.  We also construct a data
        // valid mask which masks out the device address from the
        // request as that is variable.
        byte[] setup_data = new byte[] { 0x00, 0x05, 0x00, 0x00,
                                         0x00, 0x00, 0x00, 0x00 };
        byte[] setup_data_valid = new byte[] { 0xff, 0xff, 0x00, 0xff,
                                               0xff, 0xff, 0xff, 0xff };

        // Configure the data match properties.  Since SET ADDRESS only comes
        // on device 0 and ep 0, we can match only on those parameters.
        BeagleApi.BeagleUsb5000DataProperties prop =
            new BeagleApi.BeagleUsb5000DataProperties();
        prop.source_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_EQUAL;
        prop.source_match_val =
            BeagleUsb5000Source.BG_USB5000_SOURCE_TX;
        prop.ep_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_EQUAL;
        prop.ep_match_val   = 0;
        prop.dev_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_EQUAL;
        prop.dev_match_val        = 0;
        prop.stream_id_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_DISABLED;
        prop.data_len_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_EQUAL;
        prop.data_len_match_val = 8;

        // Setup the struct for the Data Match Unit
        BeagleApi.BeagleUsb5000DataMatchUnit match0 =
            new BeagleApi.BeagleUsb5000DataMatchUnit();
        match0.packet_type =
            BeagleUsb5000PacketType.BG_USB5000_MATCH_PACKET_SHP_SDP;
        match0.match_other_packets = 0;   // Only match a qualified SDP.
        match0.data       = setup_data;
        match0.data_not   = 0;            // Match this data only.
        match0.data_valid = setup_data_valid;
        match0.err_match  =
            BeagleUsb5000ErrorType.BG_USB5000_MATCH_CRC_BOTH_VALID;
        match0.data_properties_valid = 1;
        match0.data_properties       = prop;
        match0.repeat_count          = 0; // Match just once.
        match0.sticky_action         = 0; // Match just once.
        match0.action_mask           =
            BeagleApi.BG_USB5000_COMPLEX_MATCH_ACTION_TRIGGER;

        if (adv)
        {
            // Configure state0's data match to goto state1
            // on it's match of the SET ADDRESS.
            match0.goto_selector = 0; // Use the first goto selector.
            match0.action_mask  |= BeagleApi.BG_USB5000_COMPLEX_MATCH_ACTION_GOTO;
        }

        // Configure the State 0 struct.
        BeagleApi.BeagleUsb5000ComplexMatchState state0 =
            new BeagleApi.BeagleUsb5000ComplexMatchState();
        state0.tx_data_0_valid = 1;
        state0.tx_data_0       = match0;
        state0.tx_data_1_valid = 0;
        state0.tx_data_2_valid = 0;
        state0.rx_data_0_valid = 0;
        state0.rx_data_1_valid = 0;
        state0.rx_data_2_valid = 0;
        state0.timer_valid     = 0;
        state0.async_valid     = 0;
        // For units licensed for advanced complex trigger, go to state 1.
        state0.goto_0 = 1;

        // Setup state 2 to filter out all link layer packets on both streams.
        BeagleApi.BeagleUsb5000DataMatchUnit match_slc =
            new BeagleApi.BeagleUsb5000DataMatchUnit();

        match_slc.packet_type =
            BeagleUsb5000PacketType.BG_USB5000_MATCH_PACKET_SLC;
        match_slc.match_other_packets = 0;   // Only match a SLC packet.
        match_slc.data       = null;         // Match all SLCs.
        match_slc.data_not   = 0;
        match_slc.data_valid = null;
        match_slc.err_match  =
            BeagleUsb5000ErrorType.BG_USB5000_MATCH_CRC_BOTH_VALID;
        match_slc.data_properties_valid = 0;
        match_slc.repeat_count          = 0;
        match_slc.sticky_action         = 0;
        match_slc.action_mask           =
            BeagleApi.BG_USB5000_COMPLEX_MATCH_ACTION_FILTER;

        BeagleApi.BeagleUsb5000ComplexMatchState state1 =
            new BeagleApi.BeagleUsb5000ComplexMatchState();
        state1.tx_data_0_valid = 1;
        state1.tx_data_0       = match_slc;
        state1.tx_data_1_valid = 0;
        state1.tx_data_2_valid = 0;
        state1.rx_data_0_valid = 1;
        state1.rx_data_0       = match_slc;
        state1.rx_data_1_valid = 0;
        state1.rx_data_2_valid = 0;
        state1.timer_valid     = 0;
        state1.async_valid     = 0;

        int ret = 0;

        if (adv)
        {
            // Passing null BeagleUsb5000ComplexMatchState objects
            // into bg_usb5000_usb3_complex_match_config is not
            // allowed so unconfigured match state objects are
            // used instead.
            BeagleApi.BeagleUsb5000ComplexMatchState empty = new
                                                             BeagleApi.BeagleUsb5000ComplexMatchState();

            ret = BeagleApi.bg_usb5000_usb3_complex_match_config(
                beagle,
                0, // Validate and program it into the Beagle 5000.
                0, // Not using extout.
                state0, state1, empty, empty, empty, empty, empty, empty);
        }
        else
        {
            ret = BeagleApi.bg_usb5000_usb3_complex_match_config_single(
                beagle,
                0, // Validate and program it into the Beagle 5000.
                0, // Not using extout.
                state0);
        }


        if (ret != (int)BeagleStatus.BG_OK)
        {
            Console.Write("error: could not configure complex match\n");
            Environment.Exit(1);
        }

        if (BeagleApi.bg_usb5000_usb3_complex_match_enable(beagle) !=
            (int)BeagleStatus.BG_OK)
        {
            Console.Write("error: could not enable complex match\n");
            Environment.Exit(1);
        }
    }
Ejemplo n.º 2
0
    /*=====================================================================
    | COMPLEX MATCH CONFIGURATION
     ====================================================================*/
    static void usbConfigComplexMatch()
    {
        int features = BeagleApi.bg_usb5000_features(beagle);
        if (features < 0) {
            Console.Write("error: could not retrieve features\n");
            Environment.Exit(1);
        }

        bool adv = (features & BeagleApi.BG_USB5000_FEATURE_CMP_TRIG) != 0;

        // Setup the first state.
        // Do a capture trigger on seeing a SET ADDRESS setup packet.

        // Match on a SET ADDRESS request.  We also construct a data
        // valid mask which masks out the device address from the
        // request as that is variable.
        byte[] setup_data       = new byte[] {0x00, 0x05, 0x00, 0x00,
                                              0x00, 0x00, 0x00, 0x00};
        byte[] setup_data_valid = new byte[] {0xff, 0xff, 0x00, 0xff,
                                              0xff, 0xff, 0xff, 0xff};

        // Configure the data match properties.  Since SET ADDRESS only comes
        // on device 0 and ep 0, we can match only on those parameters.
        BeagleApi.BeagleUsb5000DataProperties prop =
            new BeagleApi.BeagleUsb5000DataProperties();
        prop.source_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_EQUAL;
        prop.source_match_val =
            BeagleUsb5000Source.BG_USB5000_SOURCE_TX;
        prop.ep_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_EQUAL;
        prop.ep_match_val = 0;
        prop.dev_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_EQUAL;
        prop.dev_match_val = 0;
        prop.stream_id_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_DISABLED;
        prop.data_len_match_type =
            BeagleUsb5000MatchType.BG_USB5000_MATCH_TYPE_EQUAL;
        prop.data_len_match_val = 8;

        // Setup the struct for the Data Match Unit
        BeagleApi.BeagleUsb5000DataMatchUnit match0 =
            new BeagleApi.BeagleUsb5000DataMatchUnit();
        match0.packet_type =
            BeagleUsb5000PacketType.BG_USB5000_MATCH_PACKET_SHP_SDP;
        match0.match_other_packets   = 0; // Only match a qualified SDP.
        match0.data                  = setup_data;
        match0.data_not              = 0; // Match this data only.
        match0.data_valid            = setup_data_valid;
        match0.err_match             =
            BeagleUsb5000ErrorType.BG_USB5000_MATCH_CRC_BOTH_VALID;
        match0.data_properties_valid = 1;
        match0.data_properties       = prop;
        match0.repeat_count          = 0; // Match just once.
        match0.sticky_action         = 0; // Match just once.
        match0.action_mask           =
            BeagleApi.BG_USB5000_COMPLEX_MATCH_ACTION_TRIGGER;

        if (adv) {
            // Configure state0's data match to goto state1
            // on it's match of the SET ADDRESS.
            match0.goto_selector = 0; // Use the first goto selector.
            match0.action_mask  |= BeagleApi.BG_USB5000_COMPLEX_MATCH_ACTION_GOTO;
        }

        // Configure the State 0 struct.
        BeagleApi.BeagleUsb5000ComplexMatchState state0 =
            new BeagleApi.BeagleUsb5000ComplexMatchState();
        state0.tx_data_0_valid = 1;
        state0.tx_data_0       = match0;
        state0.tx_data_1_valid = 0;
        state0.tx_data_2_valid = 0;
        state0.rx_data_0_valid = 0;
        state0.rx_data_1_valid = 0;
        state0.rx_data_2_valid = 0;
        state0.timer_valid     = 0;
        state0.async_valid     = 0;
        // For units licensed for advanced complex trigger, go to state 1.
        state0.goto_0          = 1;

        // Setup state 2 to filter out all link layer packets on both streams.
        BeagleApi.BeagleUsb5000DataMatchUnit match_slc =
            new BeagleApi.BeagleUsb5000DataMatchUnit();

        match_slc.packet_type =
            BeagleUsb5000PacketType.BG_USB5000_MATCH_PACKET_SLC;
        match_slc.match_other_packets   = 0; // Only match a SLC packet.
        match_slc.data                  = null; // Match all SLCs.
        match_slc.data_not              = 0;
        match_slc.data_valid            = null;
        match_slc.err_match             =
            BeagleUsb5000ErrorType.BG_USB5000_MATCH_CRC_BOTH_VALID;
        match_slc.data_properties_valid = 0;
        match_slc.repeat_count          = 0;
        match_slc.sticky_action         = 0;
        match_slc.action_mask           =
            BeagleApi.BG_USB5000_COMPLEX_MATCH_ACTION_FILTER;

        BeagleApi.BeagleUsb5000ComplexMatchState state1 =
            new BeagleApi.BeagleUsb5000ComplexMatchState();
        state1.tx_data_0_valid = 1;
        state1.tx_data_0       = match_slc;
        state1.tx_data_1_valid = 0;
        state1.tx_data_2_valid = 0;
        state1.rx_data_0_valid = 1;
        state1.rx_data_0       = match_slc;
        state1.rx_data_1_valid = 0;
        state1.rx_data_2_valid = 0;
        state1.timer_valid     = 0;
        state1.async_valid     = 0;

        int ret = 0;
        if (adv) {
            // Passing null BeagleUsb5000ComplexMatchState objects
            // into bg_usb5000_usb3_complex_match_config is not
            // allowed so unconfigured match state objects are
            // used instead.
            BeagleApi.BeagleUsb5000ComplexMatchState empty = new
                BeagleApi.BeagleUsb5000ComplexMatchState();

            ret = BeagleApi.bg_usb5000_usb3_complex_match_config(
                beagle,
                0, // Validate and program it into the Beagle 5000.
                0, // Not using extout.
                state0, state1, empty, empty, empty, empty, empty, empty);
        }
        else {
            ret = BeagleApi.bg_usb5000_usb3_complex_match_config_single(
                beagle,
                0, // Validate and program it into the Beagle 5000.
                0, // Not using extout.
                state0);
        }

        if (ret != (int) BeagleStatus.BG_OK) {
            Console.Write("error: could not configure complex match\n");
            Environment.Exit(1);
        }

        if (BeagleApi.bg_usb5000_usb3_complex_match_enable(beagle) !=
            (int) BeagleStatus.BG_OK)
        {
            Console.Write("error: could not enable complex match\n");
            Environment.Exit(1);
        }
    }