Ejemplo n.º 1
0
/*******************************************************************************
* Function Name  : main
* Description    : Main program
* Input          : None
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
int main (void) {
	uint32_t n;
	uint32_t ret;

	SysTick_Config(SystemCoreClock / 1000);
	#ifdef CFG_SDCARD
  	/* Setup SD Card/FATFS */
  	SDInit();
	#endif
	debug_frmwrk_init();
	printf("\r\n hello");
	//for (n = 0; n < MSC_ImageSize; n++) {     /* Copy Initial Disk Image */
	//	Memory[n] = DiskImage[n];             /* from Flash to RAM */
	//}
	
	if(!KEY1_PIN)
	{
		UsbMode = 0;
		while(!KEY1_PIN);
		delay(100000);
		while(!KEY1_PIN);
		
	}
	if(UsbMode == 0){
		USB_Init();                               /* USB Initialization */
		USB_Connect(TRUE);                        /* USB Connect */
	}
	else{
		
	
	    Host_Init();               // Initialize the lpc17xx host controller                                    
	
		if( Host_EnumDev() == 0 )	/* Enumerate the device connected                                            */
	    {
		  printf("-- USB device detected OK \r\n");
	    }
	    else
	    {
	      printf("-- Please connect a USB device \r\n");
	      while( Host_EnumDev() == 0 );
	      printf("-- USB device connection detected \r\n");
		  Delay(0x00ffff);
	    }
	}

	while (1){
		if(!KEY1_PIN)
		{
			ret = Host_CtrlSend(0x40, 0x50, 0, 0, 0, NULL);
			printf("\r\n sent switch cmd,ret= %x ",ret);
			delay(100);
			NVIC_SystemReset();
		}
	}
}
Ejemplo n.º 2
0
int main()
{
    int32_t  rc;
    uint32_t  numBlks, blkSize;
    uint8_t  inquiryResult[INQUIRY_LENGTH];

    /* SystemClockUpdate() updates the SystemFrequency variable */
    SystemClockUpdate();

    UART_Init(57600);          /* Initialize the serial port to view the log messages                       */
    Host_Init();               /* Initialize the lpc17xx host controller                                    */
    rc = Host_EnumDev();       /* Enumerate the device connected                                            */
    if (rc == OK) {
		/* Initialize the mass storage and scsi interfaces */
        rc = MS_Init( &blkSize, &numBlks, inquiryResult );
        if (rc == OK) {
            rc = FAT_Init();   /* Initialize the FAT16 file system                                          */
            if (rc == OK) {
                Main_Copy();   /* Call the application                                                      */
            } else {
                return (0);
            }
        } else {
            return (0);
        }
    } else {							
        return (0);
    }
    while(1);
}
Ejemplo n.º 3
0
/*********************************************************************//**
 * @brief 			This function is the main function where the execution begins
 * @param[in]		None
 * @return 		    None
 **********************************************************************/
int main()
{
    int32_t  rc;
    uint32_t  numBlks, blkSize;	
		uint8_t buffer[30];
		UINT nun;
    uint8_t  inquiryResult[INQUIRY_LENGTH];
		FATFS fs;
	   FIL fsrc, fdst;
  
		const TCHAR  a=1;
  
		  SystemInit();
	  debug_frmwrk_init();
			print_menu();
		
    Host_Init();               /* Initialize the lpc17xx host controller                                    */

    PRINT_Log("Host Initialized\r\n");
    PRINT_Log("Connect a Mass Storage device\r\n");
    rc = Host_EnumDev();       /* Enumerate the device connected                                            */
		 PRINT_Log("Á¬½ÓÉ豸\r\n");
    if ((rc == USB_HOST_FUNC_OK) && (Host_GetDeviceType() == MASS_STORAGE_DEVICE))
			{
					
					PRINT_Log("Mass Storage device connected\r\n");

				rc = 	f_mount(&fs,"0:",1);  
				if(rc==0)
				{
					  rc = f_open(&fdst, "0:read.txt", FA_READ);
					if(rc==0)
					{
						PRINT_Log("open ok\r\n");
						f_read (&fdst,   buffer, 30, &nun );
						PRINT_Log(buffer);
						f_close(&fdst);
					}
				}
    
    } 
		else {
	    PRINT_Log("Not a Mass Storage device\n");							
        return (0);
    }


   return 0;
}
Ejemplo n.º 4
0
DSTATUS disk_initialize(BYTE drv /* Physical drive nmuber (0..) */
)
{
	DSTATUS stat;
	int result;

	(void) result;

	switch (drv)
	{
	case ATA:
		// result = ATA_disk_initialize();
		stat = STA_NOINIT;
		// translate the result code here
		return stat;

	case MMC:
		stat = MMC_disk_initialize();
		return stat;

	case USB:
#if WITH_USB_MS
		/* USB host init and enumeration */
		if ( usb_status & STA_NOINIT ) {
			Host_Init();
			if ( Host_EnumDev() == OK ) {
				/* mass-storage init */
				if ( MS_Init(&blkSize, &numBlks, inquiryResult) == OK ) {
					usb_status &= ~STA_NOINIT;
				} else {
					/* MS init fail */
				}
			} else {
				/* host init and/or enum fail */
			}
		}
		return usb_status;
#else
		stat = STA_NOINIT;
		return stat;
#endif
	}
	return STA_NOINIT;
}
Ejemplo n.º 5
0
int main()
{
    USB_INT32S  rc;
	USB_INT32U  numBlks, blkSize;
	USB_INT08U  inquiryResult[INQUIRY_LENGTH];

// Code Red - if CMSIS 1.3 setup is being used, then SystemInit() routine
// will be called by startup code rather than in application's main()
#ifndef __USE_CMSIS
	SystemInit();                               /* initialize clocks */
#endif

 

    UART_Init(115200);         /* Initialize the serial port to view the log messages                       */
    Host_Init();               /* Initialize the lpc17xx host controller                                    */
    rc = Host_EnumDev();       /* Enumerate the device connected                                            */
    if (rc == OK) {
		/* Initialize the mass storage and scsi interfaces */
        rc = MS_Init( &blkSize, &numBlks, inquiryResult );
        if (rc == OK) {
            rc = FAT_Init();   /* Initialize the FAT16 file system                                          */
            if (rc == OK) {
                Main_Copy();   /* Call the application                                                      */
            } else {
				while ( 1 );
                return (0);
            }
        } else {
			while ( 1 );
            return (0);
        }
    } else {							
		while ( 1 );
        return (0);
    }
    while(1);
}