Esempio n. 1
0
    /*=========================================================================
     | DIGITAL INPIT/OUTPUT CONFIG
     | ========================================================================*/
    static void setupDigitalLines()
    {
        // Digital input mask
        byte input_enable_mask =
            BeagleApi.BG_USB2_DIGITAL_IN_ENABLE_PIN1 |
            BeagleApi.BG_USB2_DIGITAL_IN_ENABLE_PIN2 |
            BeagleApi.BG_USB2_DIGITAL_IN_ENABLE_PIN3 |
            BeagleApi.BG_USB2_DIGITAL_IN_ENABLE_PIN4;

        // Define the packet and data match structures.  By using 'new'
        // to define these structures, their value type elements are
        // initialized to 0 and the reference type elements (including
        // the arrays) are set to null.
        BeagleApi.BeagleUsb2PacketMatch packet_match =
            new BeagleApi.BeagleUsb2PacketMatch();
        BeagleApi.BeagleUsb2DataMatch data_match =
            new BeagleApi.BeagleUsb2DataMatch();

        // Enable digital input pins
        BeagleApi.bg_usb480_digital_in_config(beagle, input_enable_mask);
        Console.Write("Configuring digital input with {0:x}\n",
                      input_enable_mask);

        // Configure digital out pins.  Only those fields that we want
        // enabled need to be set here since everything was initialized
        // above.
        packet_match.pid_match_type =
            BeagleUsb2MatchType.BG_USB2_MATCH_TYPE_EQUAL;
        packet_match.pid_match_val = BeagleApi.BG_USB_PID_PING;

        // Enable digital output pin 4
        BeagleApi.bg_usb480_digital_out_config(beagle,
                                               BeagleApi.BG_USB2_DIGITAL_OUT_ENABLE_PIN4,
                                               BeagleApi.BG_USB2_DIGITAL_OUT_PIN4_ACTIVE_HIGH);

        // Configure digital output pin 4 match pattern
        BeagleApi.bg_usb480_digital_out_match(beagle,
                                              BeagleUsb2DigitalOutMatchPins.BG_USB2_DIGITAL_OUT_MATCH_PIN4,
                                              packet_match, data_match);

        Console.Write("Configuring digital output pin 4.\n");
    }