Exemplo n.º 1
0
void MidiOutPort_visual::close(void) {
   if (getPort() == -1) {
      return;
   }

   if (getPortStatus() == 1 && device[getPort()] != NULL) {

      // The following function, midiOutClose, is not what I like.
      // It will send note offs to any note which it thinks is
      // on when the port is closed.  Uncomment the line if
      // you want this feature.
      // midiOutReset(device[getPort()]);

      midiOutClose(device[getPort()]);
      setPortStatus(0);
   }
}
Exemplo n.º 2
0
void USBHostHub::portReset(uint8_t port) {
    // reset port
    uint32_t status;
    USB_DBG("reset port %d on hub: %p [this: %p]", port, dev, this)
    setPortFeature(PORT_RESET_FEATURE, port);
    while(1) {
        status = getPortStatus(port);
        if (status & (PORT_ENABLE | PORT_RESET))
            break;
        if (status & PORT_OVER_CURRENT) {
            USB_ERR("OVER CURRENT DETECTED\r\n");
            clearPortFeature(PORT_OVER_CURRENT, port);
            host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
            break;
        }
        Thread::wait(10);
    }
}
Exemplo n.º 3
0
int MidiOutPort_visual::open(void) {
   if (getPort() == -1) {
      return 2;
   }

   if (getPortStatus() == 0) {
      int flag;
      flag = midiOutOpen(&device[getPort()], getPort(), 0, 0, CALLBACK_NULL);
      if (flag == MMSYSERR_NOERROR) {
         openQ[getPort()] = 1;
         return 1;
      } else { // faied to open
         openQ[getPort()] = 0;
         device[getPort()] = NULL;
         return 0;
      }
   } else { // already open
      return 1;
   }
}
Exemplo n.º 4
0
void USBHostHub::rxHandler() {
    uint32_t status;
    if (int_in) {
        if (int_in->getState() == USB_TYPE_IDLE) {
            for (int port = 1; port <= nb_port; port++) {
                status = getPortStatus(port);
                USB_DBG("[hub handler hub: %d] status port %d [hub: %p]: 0x%X", dev->getHub(), port, dev, status);

                // if connection status has changed
                if (status & C_PORT_CONNECTION) {
                    if (status & PORT_CONNECTION) {
                        USB_DBG("[hub handler hub: %d - port: %d] new device connected", dev->getHub(), port);
                        host->deviceConnected(dev->getHub() + 1, port, status & PORT_LOW_SPEED, this);
                    } else {
                        USB_DBG("[hub handler hub: %d - port: %d] device disconnected", dev->getHub(), port);
                        host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
                    }

                    clearPortFeature(C_PORT_CONNECTION_FEATURE, port);
                }

                if (status & C_PORT_RESET) {
                    clearPortFeature(C_PORT_RESET_FEATURE, port);
                }

                if (status & C_PORT_ENABLE) {
                    clearPortFeature(C_PORT_ENABLE_FEATURE, port);
                }

                if ((status & PORT_OVER_CURRENT)) {
                    USB_ERR("OVER CURRENT DETECTED\r\n");
                    clearPortFeature(PORT_OVER_CURRENT, port);
                    host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
                }
            }
        }
        host->interruptRead(dev, int_in, buf, 1, false);
    }
}
Exemplo n.º 5
0
void MidiInPort_unsupported::close(void) {
   if (getPortStatus() == 1) {
      openQ[getPort()] = 0;
   }
}
Exemplo n.º 6
0
int MidiInPort_unsupported::open(void) {
   if (getPortStatus() == 0) {
      openQ[getPort()] = 1;
   }
   return openQ[getPort()];
}