Basic ExampleΒΆ

#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 USBHub3p
    aUSBHub3p hub;

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

    //Disable PORT
    hub.usb.setPortEnable(PORT);

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

    //Enable PORT
    hub.usb.setPortDisable(PORT);

    //Disconnect
    hub.disconnect();

    return 0
}