예제 #1
0
/*******************************************************************************
* 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)
  {	

  }
}
예제 #2
0
파일: main.c 프로젝트: Dzenik/QuadVolucer
/**
  * @brief   Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */     

  /* Initialize Leds mounted on STM3210X-EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  
  /* Enable the FSMC Clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
  
  /* FSMC Initialization */
  NAND_Init();

  /* NAND read ID command */
  NAND_ReadID(&NAND_ID);

  /* Verify the NAND ID */
  if((NAND_ID.Maker_ID == NAND_ST_MakerID) && (NAND_ID.Device_ID == NAND_ST_DeviceID))
  {

    /* NAND memory address to write to */
    WriteReadAddr.Zone = 0x00;
    WriteReadAddr.Block = 0x00;
    WriteReadAddr.Page = 0x00;

    /* Erase the NAND first Block */
    status = NAND_EraseBlock(WriteReadAddr);

    /* Write data to FSMC NAND memory */
    /* Fill the buffer to send */
    Fill_Buffer(TxBuffer, BUFFER_SIZE , 0x66);

    status = NAND_WriteSmallPage(TxBuffer, WriteReadAddr, PageNumber);

    /* Read back the written data */
    status = NAND_ReadSmallPage (RxBuffer, WriteReadAddr, PageNumber);
   
    /* Verify the written data */
    for(j = 0; j < BUFFER_SIZE; j++)
    {
      if(TxBuffer[j] != RxBuffer[j])
      {
        WriteReadStatus++;
      }
    }

    if (WriteReadStatus == 0)
    { 
      /* OK */
      /* Turn on LED1 */
      STM_EVAL_LEDOn(LED1);
    }
    else
    { 
      /* KO */
      /* Turn on LED2 */
      STM_EVAL_LEDOn(LED2);
    }
  }
  else
  {
    /* Turn on LED3 */
    STM_EVAL_LEDOn(LED3);
  }

  while(1)
  {
  }
}
예제 #3
0
파일: redbull.c 프로젝트: flodur1/redbull
void Redbull_Init()
{
  char buff[128] = { 0 };

  USART_STDIO_Init();
  Delay_Init();
  Button_GPIO_Config();

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

  STM3210E_LCD_Init();
  LCD_SetFont(&Font8x12);
  LCD_SetColors(LCD_COLOR_WHITE, LCD_COLOR_BLACK);

  LCD_WriteRAM_Prepare();

  for (int i = 0; i < (320 * 240); i++)
  {
    LCD_WriteRAM(LCD_COLOR_WHITE);
  }
  for (int i = 0; i < (320 * 240); i++)
  {
    LCD_WriteRAM(LCD_COLOR_BLACK);
  }

  LCD_DisplayStringLine(LINE(0), (uint8_t*) " initializing REDBULL");
  LCD_DisplayStringLine(LINE(1), (uint8_t*) " CPU ...............................");
  sprintf(buff, "ARM Cortex-M3 @ %dMHz", (int) SystemCoreClock / 1000000);
  printRight(1, buff);
  LCD_DisplayStringLine(LINE(2), (uint8_t*) " LCD ............................320x240");

  LCD_DisplayStringLine(LINE(3), (uint8_t*) " LED ..................................");

  LED_Init();
  toggleLED(LED1_PIN, 0);
  toggleLED(LED2_PIN, LED1_PIN);
  toggleLED(LED3_PIN, LED2_PIN);
  toggleLED(LED4_PIN, LED3_PIN);
  toggleLED(LED5_PIN, LED4_PIN);
  toggleLED(LED4_PIN, LED5_PIN);
  toggleLED(LED3_PIN, LED4_PIN);
  toggleLED(LED2_PIN, LED3_PIN);
  toggleLED(LED1_PIN, LED2_PIN);
  toggleLED(0, LED1_PIN);

  printRight(3, "5");

  LCD_DisplayStringLine(LINE(4), (uint8_t*) " RTC ................");
  RTC_Init();
  RTC_t rtc = { .year = 2011, .month = 12, .mday = 19, .hour = 21, .min = 00 };
  //RTC_SetTime(&rtc);
  RTC_GetTime(&rtc);
  sprintf(buff, "%04d/%02d/%02d %02d:%02d:%02d", rtc.year, rtc.month, rtc.mday, rtc.hour, rtc.min, rtc.sec);
  printRight(4, buff);

  LCD_DisplayStringLine(LINE(5), (uint8_t*) " USB .................................");
  Set_USBClock();
  Set_System();
  USB_Interrupts_Config();
  USB_Init();
  printRight(5, "ok");

  //IS61LV25616 (512KB)
  LCD_DisplayStringLine(LINE(6), (uint8_t*) " SRAM ................................");
  SRAM_Init();
  uint32_t* RAM = (uint32_t*) Bank1_SRAM3_ADDR;
  uint8_t TESTOK = 1;
  for (uint32_t i = 0; i < (512 * 1024) / 4; i++)
  {
    RAM[i] = i;
  }
  for (uint32_t i = 0; i < (512 * 1024) / 4; i++)
  {
    if (RAM[i] != i)
    {
      TESTOK = 0;
    }
    RAM[i] = 0;
  }

  if (TESTOK)
  {
    printRight(6, "IS61LV25616 512KB");
  }
  else
  {
    printRight(6, "fail");
  }

  //M29W128F (2MB)
  LCD_DisplayStringLine(LINE(7), (uint8_t*) " NOR .................................");
  NOR_Init();
  NOR_IDTypeDef norid;
  NOR_ReadID(&norid);
  printRight(7, "MX29LV160D 2MB");

  //HY27UF081G2A (128MB)
  LCD_DisplayStringLine(LINE(8), (uint8_t*) " NAND ................................");
  NAND_Init();
  NAND_IDTypeDef nandid;
  NAND_ReadID(&nandid);
  printRight(8, "HY27UF081G2A 128MB");

  LCD_DisplayStringLine(LINE(9), (uint8_t*) " SDIO ................................");
  SD_Init();
  SD_CardInfo cardinfo;
  SD_GetCardInfo(&cardinfo);
  printRight(9, "ok");

}