Ejemplo n.º 1
0
/**
  * @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
     */     

  /* FSMC NOR configuration  **************************************************/
  /* Enable the FSMC Clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

  /* Configure FSMC Bank1 NOR/SRAM2 */
  NOR_Init();

  /* Jump to code loaded in NOR memory and execute it *************************/
  JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
  Jump_To_Application = (pFunction) JumpAddress;

  /* Initialize user application's Stack Pointer */
  __set_MSP(*(__IO uint32_t*) ApplicationAddress); 

  Jump_To_Application();

  while (1)
  {
  }
}
Ejemplo n.º 2
0
/* Function to find out where the Application is and copy to DRAM */
Uint32 NOR_Copy() {
	volatile NOR_BOOT	*hdr = 0;
	VUint32		*appStartAddr = 0;
	VUint32		count = 0;
	VUint32		*ramPtr = 0;
	Uint32      blkSize, blkAddress;

	UARTSendData((Uint8 *) "Starting NOR Copy...\r\n", FALSE);
	
	// Nor Initialization
	if (NOR_Init() != E_PASS)
	    return E_FAIL;
	    
	DiscoverBlockInfo( (gNorInfo.flashBase + UBL_IMAGE_SIZE), &blkSize, &blkAddress );
	
	hdr = (volatile NOR_BOOT *) (blkAddress + blkSize);

	/* Magic number found */
	if((hdr->magicNum & 0xFFFFFF00) != MAGIC_NUMBER_VALID)
	{
	 	return E_FAIL;/* Magic number not found */
	}

	/* Set the Start Address */
	appStartAddr = (Uint32 *)(((Uint8*)hdr) + sizeof(NOR_BOOT));

	if(hdr->magicNum == UBL_MAGIC_BIN_IMG)
	{
		ramPtr = (Uint32 *) hdr->ldAddress;

		/* Copy data to RAM */
		for(count = 0; count < ((hdr->appSize + 3)/4); count ++)
		{
			ramPtr[count] = appStartAddr[count];
		}
		gEntryPoint = hdr->entryPoint;
		/* Since our entry point is set, just return success */
		return E_PASS;
	}

	if(SRecDecode((Uint8 *)appStartAddr, hdr->appSize, (Uint32 *)&gEntryPoint, (Uint32 *)&count ) != E_PASS)
	{
		return E_FAIL;
	}
 	return E_PASS;
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------------------------------------*/
int main(void)
{
    uint32_t u32i;
    uint32_t u32NORIDInfo;
    uint8_t u8ReadOutData;

    /* Unlock protected registers */
    SYS_UnlockReg();

    /* Init System, peripheral clock and multi-function I/O */
    SYS_Init();

    /* Lock protected registers */
    SYS_LockReg();

    /* Init UART0 for printf */
    UART0_Init();

    printf("\n\nCPU @ %d Hz\n", SystemCoreClock);
    printf("+---------------------------------+\n");
    printf("|    EBI NOR Flash Sample Code    |\n");
    printf("+---------------------------------+\n\n");

    printf("************************************************************************\n");
    printf("* Please connect W39L040P to M051 Series EBI bus before EBI testing !! *\n");
    printf("************************************************************************\n\n");

    /* Enable EBI function and bus width to 8-bit, MCLK is HCLK/2 */
    EBI->EBICON = (EBI_MCLKDIV_2 << EBI_EBICON_MCLKDIV_Pos) | EBI_EBICON_ExtEN_Msk |
                  (0x3 << EBI_EBICON_ExttALE_Pos) ;
    EBI->EXTIME = 0x03003318;

    /* Initial NOR flash and check ID */
    NOR_Init();
    u32NORIDInfo = NOR_GetID();
    if(u32NORIDInfo == 0xDAB6)
    {
        printf("NOR W39L040P initial OK ! Manufacture ID:0x%X, Device ID:0x%X.\n", (u32NORIDInfo >> 8), (u32NORIDInfo & 0xFF));
    }
Ejemplo n.º 4
0
/**
  * @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_stm32l1xx_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32l1xx.c file
     */      

  /* Initialize Leds mounted on STM3210X-EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  
  /* Write/read to/from FSMC SRAM memory  *************************************/
  /* Enable the FSMC Clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

  /* Configure FSMC Bank1 NOR/SRAM2 */
  NOR_Init();
 
  /* Read NOR memory ID */
  NOR_ReadID(&NOR_ID);

  NOR_ReturnToReadMode();

  /* Erase the NOR memory block to write on */
  NOR_EraseBlock(WRITE_READ_ADDR);

  /* Write data to FSMC NOR memory */
  /* Fill the buffer to send */
  Fill_Buffer(TxBuffer, BUFFER_SIZE, 0x3210);
  NOR_WriteBuffer(TxBuffer, WRITE_READ_ADDR, BUFFER_SIZE);

  /* Read data from FSMC NOR memory */
  NOR_ReadBuffer(RxBuffer, WRITE_READ_ADDR, BUFFER_SIZE);  

  /* Read back NOR memory and check content correctness */   
  for (Index = 0x00; (Index < BUFFER_SIZE) && (WriteReadStatus == 0); Index++)
  {
    if (RxBuffer[Index] != TxBuffer[Index])
    {
      WriteReadStatus = Index + 1;
    }
  }

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

  while (1)
  {
  }
}
Ejemplo n.º 5
0
/*---------------------------------------------------------------------------------------------------------*/    
int main (void)
{
	uint8_t	u8Item = 0x0;
    uint32_t u32NORIDInfo;
    uint32_t u32i;
    uint8_t u8ReadOutData;

    /* Init System, IP clock and multi-function I/O */
    SYS_Init();     

    /* Init UART0 for printf */
    UART0_Init();

    printf("\n\nCPU @ %dHz\n", SystemCoreClock);

    printf("+------------------------------------+\n");
    printf("|    M05xx EBI Driver Sample Code    |\n");
    printf("+------------------------------------+\n");
	printf("\n");
	
	do {
		printf("*****************************************************************\n");
		printf("* Please connect BS616LV4017 or W39L010 to M051 Series EBI bus  *\n");
		printf("* before EBI testing!!                                          *\n");
		printf("*                                                               *\n");								
		printf("* The testing result will be FAILED, if there is no BS616LV4017 *\n");
		printf("* or W39L010 connecting to M051 sereis EBI bus!                 *\n");
		printf("*****************************************************************\n");
		printf("\n");
		printf("|   >>> Selese item to test <<<    |\n");
		printf("| [0] SRAM  --- BS616LV4017, 16bit |\n");
		printf("| [1] NOR   --- W39L010, 8bit      |\n");
		printf("| [ESC] Exit                       |\n");
		u8Item = getchar();

		printf("\n");
		switch (u8Item)
		{
			case '0':               
                /* Enable EBI function and data width 16-bit, MCLK is HCLK/4 */
                EBI->EBICON = EBI_EBICON_ExtEN_Msk | EBI_EBICON_ExtBW16_Msk | EBI_EBICON_MCLKDIV_4; 

                /* Start SRAM test */
                SRAM_BS616LV4017();

                /* Disable EBI function */
                EBI->EBICON = 0;
				break;
				
			case '1':		
                /* Enable EBI function and data width 8-bit, MCLK is HCLK/4 */
                EBI->EBICON = EBI_EBICON_ExtEN_Msk | EBI_EBICON_MCLKDIV_4; 

                /* Initial NOR flash and check ID */
				NOR_Init();
                u32NORIDInfo = NOR_GetID();
            	if (u32NORIDInfo == 0xDA31)
            	{
            		printf("NOR W39L010 initial OK ! ManufactureID:0x%X, DeviceID:0x%X. \n", (u32NORIDInfo>>8), (u32NORIDInfo&0xFF));
            	}else
            	{
            		printf("NOR W39L010 initial fail ! (ID:0x%X) \n\n", u32NORIDInfo);
            		break;
            	}

            	/* Erase flash */
            	NOR_Erase();	        		
        		for (u32i=0; u32i<EBI_MAX_SIZE; u32i++)
        		{
                    u8ReadOutData = NOR_ReadData(u32i);
        			if (u8ReadOutData != 0xFF)
        			{
        				printf("    >> Chip Erase Fail !! Addr:0x%X, Data:0x%X. \n\n", u32i, u8ReadOutData);
        				break;
        			}
        		}
        		printf("    >> Chip Erase OK !!! \n");

                /* Start to program NOR flash test */
                ProgramContinueDataTest();		

                /* Disable EBI function */
                EBI->EBICON = 0;
				break;
		}
Ejemplo n.º 6
0
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");

}