/*******************************************************************************
* Function Name  : main.
* Description    : main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
	NAND_IDTypeDef NAND_Id;
	NAND_ADDRESS NAND_Address;
	int i=0;
#ifdef DEBUG
  debug();
#endif

  Set_System();
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
  
  Serial_Init();

    NAND_Init();
		NAND_Reset();
  NAND_ReadID(&NAND_Id);

  Get_Medium_Characteristics();
  Set_USBClock();
  USB_Interrupts_Config(); 
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  USB_Init();
	
  while (1)
  {	

  }
}
/*******************************************************************************
* Function Name  : Mass_Storage_Start
* Description    : Starts the mass storage demo.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Mass_Storage_Start (void)
{
  /* Disble the JoyStick interrupts */
  IntExtOnOffConfig(DISABLE);

  /* Clear the LCD screen */
  LCD_Clear(White);

  LCD_SetDisplayWindow(160, 223, 128, 128);
 
  LCD_DrawBMP(0x00647C00);

  /* Disable LCD Window mode */
  LCD_WindowModeDisable();
  
  /* Set the Back Color */
  LCD_SetBackColor(Blue);
  /* Set the Text Color */
  LCD_SetTextColor(White); 

  if(MSD_Init() != 0x00)
  {
    LCD_DisplayStringLine(Line8, " No MSD Card Present");
    LCD_DisplayStringLine(Line9, "  To exit Press SEL ");

    /* Loop until SEL key pressed */
    while(ReadKey() != SEL)
    {
    }
  }
  else
  {
    Get_Medium_Characteristics();

    /* Display the "  Plug the USB   " message */
    LCD_DisplayStringLine(Line8, " Plug the USB Cable ");
    LCD_DisplayStringLine(Line9, "Exit:  Push JoyStick");
    
    /* Intialize the USB cell */
    USB_Init();
  
    LCD_ClearLine(Line9);
    /* Display the "To stop Press SEL" message */
    LCD_DisplayStringLine(Line8, "  To stop Press SEL ");

    /* Loop until SEL key pressed */
    while(ReadKey() != SEL)
    {
    }

    PowerOff();
  }
  LCD_Clear(White);
  DisplayMenu();
  IntExtOnOffConfig(ENABLE);
  /* Flush SPI1 Data Register */
  SPI_I2S_ReceiveData(SPI1);
}
示例#3
0
/*******************************************************************************
* Function Name  : main.
* Description    : main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
#ifdef DEBUG
  debug();
#endif

  Set_System();
  
  
  Serial_Init();
  
  /////////////////////////////////////////////////////////////////////
  //////// SDCARD Initialisation //////////////////////////////////////
  /////////////////Section adapted from ST example/////////////////////
  
  /*-------------------------- SD Init ----------------------------- */
  Status = SD_Init();

  
  if (Status == SD_OK)
  {	
     
	 Status = SD_GetCardInfo(&SDCardInfo);	   
  }
 
  if (Status == SD_OK)
  {	
    /*----------------- Select Card --------------------------------*/
    Status = SD_SelectDeselect((uint32_t) (SDCardInfo.RCA << 16));  
  }

 
  if (Status == SD_OK)
  {  
    Status = SD_SetDeviceMode(SD_DMA_MODE);	 
	//Status = SD_SetDeviceMode(SD_INTERRUPT_MODE);	
	//Status = SD_SetDeviceMode(SD_POLLING_MODE);  
  }
  
  if (Status == SD_OK)
  {	 
     
	  //Status = SD_ReadBlock(0x00, Buffer_Block_Rx, BlockSize);  
	  //Status = SD_WriteBlock(0x00, Buffer_Block_Tx, BlockSize);   
      Status = SD_ReadMultiBlocks(0x00, Buffer_MultiBlock_Rx, BlockSize, NumberOfBlocks);	
	 
  }
  
 
  if (Status == SD_OK)
  {	
    /* Read block of 512 bytes from address 0 */
    Status = SD_ReadBlock(0x00, Buffer_Block_Rx, BlockSize);  
  }

 
  
  if (Status == SD_OK)
  {
    /* Read block of many bytes from address 0 */
    Status = SD_ReadMultiBlocks(0x00, Buffer_MultiBlock_Rx, BlockSize, NumberOfBlocks);	 
  }

  if (Status == SD_OK)
  {	 
    /* Check the corectness of written dada */
    

	printf("\r\nSD SDIO-1bit模式 测试TF卡读写成功! \n ");
  }  


   
  Get_Medium_Characteristics();
  Set_USBClock();
  USB_Interrupts_Config(); 
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  USB_Init();

  
  
  while (1)
  {	
    //printf("\nTEST OK!\n");
    //if (JoyState() != 0)
    //{
    //  Joystick_Send(JoyState());
    //}
  }
}