Python pyb.usb_mode() Examples

The following are 1 code examples of pyb.usb_mode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyb , or try the search function .
Example #1
Source File: platform.py    From specter-diy with MIT License 6 votes vote down vote up
def set_usb_mode(dev=False, usb=False):
    if simulator:
        print("dev:", dev, ", usb:", usb)
    # now get correct mode
    if usb and not dev:
        pyb.usb_mode("VCP")
        if not simulator:
            os.dupterm(None,0)
            os.dupterm(None,1)
    elif usb and dev:
        pyb.usb_mode("VCP+MSC")
        if not simulator:
            # duplicate repl to stlink 
            # as usb is busy for communication
            os.dupterm(stlk,0)
            os.dupterm(None,1)
    elif not usb and dev:
        pyb.usb_mode("VCP+MSC")
        usb = pyb.USB_VCP()
        if not simulator:
            os.dupterm(None,0)
            os.dupterm(usb,1)
    else:
        pyb.usb_mode(None)
        if not simulator:
            os.dupterm(None,0)
            os.dupterm(None,1)