Basic ExampleΒΆ

This simple example shows briefly how instantiate, connect to, disable and re-enable a port on the USBHub3c. There are multiple examples shipped with the BrainStem Development Kit (BDK) download.

#include <iostream>
#include "BrainStem2/BrainStem-all.h"

static const uint8_t PORT = 5;

int main(int argc, const char * argv[]) {

    //Create an instance of the USBHub3c
    aUSBHub3c device;

    //Connect to USBHub3c
    aErr err = device.discoverAndConnect(USB);
    if(err == aErrNone) {
        printf("Connected\r\n");
    }
    else {
        printf("Unable to discover device\r\n");
        return 1;
    }

    //Disable PORT
    device.hub.port[PORT].setEnabled(0);

    ////////////
    //Do Stuff
    ////////////

    //Enable PORT
    device.hub.port[PORT].setEnabled(1);

    //Disconnect
    device.disconnect();

    return 0
}