#include "stdio.h"
#include "OB90A64U1.h"
#include "gpio.h"
#include "uart.h"
#include "usb.h"
#include "usbcom.h"
#include "Bulk.h"
extern uint32_t g_usb_interrupt0 ;
extern uint32_t g_usb_interrupt1 ;

int main(void)
{
	uint32_t  TransferLength;
  SystemCoreClockUpdate();
	OB_GPIO1->DATA = 0;
	OB_GPIO1->MODE = 0;
  USB_Open(); 

	
	//------------------------------------------
    while(1)
    {
			while ( USB_WaitInterrupt(USB_CONTROL_POINT, USB_DIR_OUT, 1, &TransferLength) == USB_STATUS_OK )  //Control
			{
				if(TransferLength != 0x00)
				{
					while(1)
					{				 		  	
							USB_ProcCtrlPkg();			  			
							if((g_usb_interrupt1 & 0x01) == 0)
								break;
					}
				}	
				g_usb_interrupt1 = 0;
				USBSetReady( USB_CONTROL_POINT);			
			}	
 
    if ( USB_WaitInterrupt(USB_BULK_OUT_POINT,USB_DIR_OUT,  1, &TransferLength) == USB_STATUS_OK )//Bulk        {            
		{        
		  COM_ProcBulkPkg(); 
    }
	}
}
