/* * WindowsInit - windows-specific initialization */ int WindowsInit( HANDLE inst, int showcmd ) { WNDCLASS wc; BOOL rc; WORD x,y; HGLOBAL handle; if( !SetTimer( MainWindowHandle, TIMER_ID, 32000, 0L) ) { return( FALSE ); } handle = GlobalAlloc( GMEM_FIXED | GMEM_ZEROINIT, MAX_SAMPLES * sizeof( samp_save ) ); if( handle == NULL ) { KillTimer( MainWindowHandle, TIMER_ID); return( FALSE ); } SampSave = MK_FP( handle, 0 ); wc.style = 0; wc.lpfnWndProc = MainDriver; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = inst; wc.hIcon = LoadIcon(inst, "ApplIcon" ); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = GetStockObject(GRAY_BRUSH); wc.lpszMenuName = ResName( "WSampMenu" ); wc.lpszClassName = sampleClass; rc = RegisterClass( &wc ); if( !rc ) { return( FALSE ); } x = GetSystemMetrics( SM_CXSCREEN ); y = GetSystemMetrics( SM_CYSCREEN ); InstanceHandle = inst; MainWindowHandle = CreateWindow( sampleClass, "Open Watcom Sampler for Windows", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, /* Window style. */ 0, /* Default horizontal position. */ 0, /* Default vertical position. */ x, /* width. */ y, /* height. */ NULL, /* Overlapped windows have no parent. */ NULL, /* Use the window class menu. */ inst, /* This instance owns this window. */ NULL /* Pointer not needed. */ ); if( !MainWindowHandle ) return( FALSE ); ShowWindow( MainWindowHandle, showcmd ); UpdateWindow( MainWindowHandle ); rc = StartOutput( x,y ); return( rc ); } /* WindowsInit */
void AT91_USBHS_Driver::Endpoint_ISR(UINT32 endpoint) { USB_CONTROLLER_STATE *State = g_AT91_USBHS_Driver.pUsbControllerState; UINT32 Status; struct AT91_UDPHS *pUdp = (struct AT91_UDPHS *) (AT91C_BASE_UDP); struct AT91_UDPHS_EPTFIFO *pFifo = (struct AT91_UDPHS_EPTFIFO *)AT91C_BASE_UDP_DMA; Status = pUdp->UDPHS_EPT[endpoint].UDPHS_EPTSTA; // Control Endpoint if(endpoint == 0) { // ugly if(Status & AT91C_UDPHS_RX_BK_RDY) { while(pUdp->UDPHS_EPT[0].UDPHS_EPTSTA & AT91C_UDPHS_RX_BK_RDY) pUdp->UDPHS_EPT[0].UDPHS_EPTCLRSTA &= ~AT91C_UDPHS_RX_BK_RDY; } // set up packet receive if(Status & AT91C_UDPHS_RX_SETUP) { #if 1 UINT8 len = (pUdp->UDPHS_EPT[0].UDPHS_EPTSTA >> 20) & 0x7F; (*(UINT32 *)(&g_AT91_USBHS_Driver.ControlPacketBuffer[0])) = pFifo->UDPHS_READEPT0[0]; (*(UINT32 *)(&g_AT91_USBHS_Driver.ControlPacketBuffer[4])) = pFifo->UDPHS_READEPT0[0]; #else UINT8 len = 8; #endif // UINT8 len = (EP_CSR >> 16) & 0x7F; // special handling for the very first SETUP command - Getdescriptor[DeviceType], the host looks for 8 bytes data only USB_SETUP_PACKET* Setup= (USB_SETUP_PACKET* )&g_AT91_USBHS_Driver.ControlPacketBuffer[0]; if((Setup->bRequest == USB_GET_DESCRIPTOR) && (((Setup->wValue & 0xFF00) >> 8) == USB_DEVICE_DESCRIPTOR_TYPE) && (Setup->wLength != 0x12)) g_AT91_USBHS_Driver.FirstDescriptorPacket = TRUE; else g_AT91_USBHS_Driver.FirstDescriptorPacket = FALSE; /* if(Setup->bmRequestType & 0x80) { while(!(pUdp->UDP_CSR[0] & AT91C_UDP_DIR)) pUdp->UDP_CSR[0] |= AT91C_UDP_DIR; } */ while(pUdp->UDPHS_EPT[0].UDPHS_EPTSTA & AT91C_UDPHS_RX_SETUP) pUdp->UDPHS_EPT[0].UDPHS_EPTCLRSTA = AT91C_UDPHS_RX_SETUP; /* send it to the upper layer */ State->Data = &g_AT91_USBHS_Driver.ControlPacketBuffer[0]; State->DataSize = len; pUdp->UDPHS_EPT[0].UDPHS_EPTCTLENB = AT91C_UDPHS_TX_PK_RDY; UINT8 result = USB_ControlCallback(State); switch(result) { case USB_STATE_DATA: /* setup packet was handled and the upper layer has data to send */ break; case USB_STATE_ADDRESS: /* upper layer needs us to change the address */ // address stage handles in hardware break; case USB_STATE_DONE: State->DataCallback = NULL; break; case USB_STATE_STALL: // since the setup command all handled in the hardware, should not have this state // // setup packet failed to process successfully // set stall condition on the default control // endpoint // break; case USB_STATE_STATUS: // handle by hardware break; case USB_STATE_CONFIGURATION: /* USB spec 9.4.5 SET_CONFIGURATION resets halt conditions, resets toggle bits */ break; case USB_STATE_REMOTE_WAKEUP: // It is not using currently as the device side won't go into SUSPEND mode unless // the PC is purposely to select it to SUSPEND, as there is always SOF in the bus // to keeping the device from SUSPEND. break; default: ASSERT(0); break; // the status change is only seen and taken care in hardware } if(result != USB_STATE_STALL) { ControlNext(); // If port is now configured, output any queued data if( result == USB_STATE_CONFIGURATION ) { for( int ep = 1; ep < c_Used_Endpoints; ep++ ) { if( State->Queues[ep] && State->IsTxQueue[ep] ) StartOutput( State, ep ); } } } }