コード例 #1
0
ファイル: board.c プロジェクト: jionfull/lon_uboot
static int init_baudrate (void)
{
    UartPuts("init_baudrate_run");
	char tmp[64];	/* long enough for environment variables */
	int i = getenv_r ("baudrate", tmp, sizeof (tmp));
	gd->bd->bi_baudrate = gd->baudrate = (i > 0)
			? (int) simple_strtoul (tmp, NULL, 10)
			: CONFIG_BAUDRATE;

	return (0);
}
コード例 #2
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void ModemResetTimerCallback(void)
{
	if (g_modemResetStage == 0)
	{
		// If for some reason this executes, make sure the timer is disabled
		ClearSoftTimer(MODEM_RESET_TIMER_NUM);
	}
	else if (g_modemResetStage == 1)
	{
		SET_DTR;

		AssignSoftTimer(MODEM_RESET_TIMER_NUM, (uint32)(3 * TICKS_PER_SEC), ModemResetTimerCallback);
		g_modemResetStage = 2;
	}
	else if (g_modemResetStage == 2)
	{
		UartPuts((char*)(CMDMODE_CMD_STRING), CRAFT_COM_PORT);
		AssignSoftTimer(MODEM_RESET_TIMER_NUM, (uint32)(3 * TICKS_PER_SEC), ModemResetTimerCallback);
		g_modemResetStage = 3;
	}
	else if (g_modemResetStage == 3)
	{
		UartPuts((char*)(CMDMODE_CMD_STRING), CRAFT_COM_PORT);
		AssignSoftTimer(MODEM_RESET_TIMER_NUM, (uint32)(3 * TICKS_PER_SEC), ModemResetTimerCallback);
		g_modemResetStage = 4;
	}
	else if (g_modemResetStage == 4)
	{
		UartPuts((char*)(ATH_CMD_STRING), CRAFT_COM_PORT);
		UartPuts((char*)&g_CRLF, CRAFT_COM_PORT);
		AssignSoftTimer(MODEM_RESET_TIMER_NUM, (uint32)(3 * TICKS_PER_SEC), ModemResetTimerCallback);
		g_modemResetStage = 5;
	}
	else if (g_modemResetStage == 5)
	{
		ModemInitProcess();
		g_modemResetStage = 0;
	}
}
コード例 #3
0
ファイル: main.c プロジェクト: edwin-oetelaar/W7500P
int main()
{
    /*System clock configuration*/
	SystemInit();    
    /* UART0 and UART1 configuration*/
    UART_StructInit(&UART_InitStructure);
    /* Configure UART0 */
    UART_Init(UART1,&UART_InitStructure);
  	S_UART_Init(115200);
    /* Retarget functions for GNU Tools for ARM Embedded Processors*/
    UartPuts(UART1,"UART 1 Test(#1)\r\n");
    printf("UART 2 Test(#2)\r\n"); 
}
コード例 #4
0
ファイル: main.c プロジェクト: embeddist/W7500
int main()
{

    /*System clock configuration*/
    SystemInit();
	
    /* UART configuration */
    UART_Configuration();
   
    UartPuts(UART1,"*****W7500 RNG TEST*****\r\n");

	  // Read Power up random value
	  rng_data = RNG_ReadRandomNumber();
	  printf("Initial random number = %d\r\n", rng_data);
	
	  // RNG Initialize : Change RNG mode to manual RUN
	  RNG_Init ();
	  
	  // RNG RUN & STOP
	  RNG_Run(ENABLE);
		__NOP();
		__NOP();
		RNG_Run(DISABLE);
		
		// Read Manual RUN RNG Data
		rng_data = RNG_ReadRandomNumber();
	  printf("manual run & stop random number = %d\r\n", rng_data);
	
	  // Change Seed value & polynimials
    RNG_SetSeedvalue(0x30002001);
	  RNG_SetPolynomial(0x90001011);
		
		// RNG RUN & STOP again
		RNG_Run(ENABLE);
		__NOP();
		__NOP();
		RNG_Run(DISABLE);
		
		// Read 2nd Manual RUN RNG data
		rng_data = RNG_ReadRandomNumber();
		printf("updated polynomial & seed value\r\n");
	  printf("manual run & stop random number = %d\r\n", rng_data);
	  printf("\r\n");
}
コード例 #5
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void AutoDialoutStateMachine(void)
{
	static uint32 timer = 0;
	CMD_BUFFER_STRUCT msg;

	switch (g_autoDialoutState)
	{
		//----------------------------------------------------------------
		// Send Dial string
		//----------------------------------------------------------------
		case AUTO_DIAL_INIT:
			// Issue dial command and dial string
			if ((g_modemSetupRecord.dial[0] >= '0') && (g_modemSetupRecord.dial[0] <= '9'))
			{
				UartPuts((char *)"ATDT", CRAFT_COM_PORT);
			}
			UartPuts((char *)(g_modemSetupRecord.dial), CRAFT_COM_PORT);
			UartPuts((char *)&g_CRLF, CRAFT_COM_PORT);

			// Update timer to current tick count
			timer = g_lifetimeHalfSecondTickCount;

			// Advance to Connecting state
			g_autoDialoutState = AUTO_DIAL_CONNECTING;
		break;

		//----------------------------------------------------------------
		// Look for DCD
		//----------------------------------------------------------------
		case AUTO_DIAL_CONNECTING:
			// Check if a remote connection has been established
			if (READ_DCD == CONNECTION_ESTABLISHED)
			{
				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;

				// Advance to Connected state
				g_autoDialoutState = AUTO_DIAL_CONNECTED;
			}
			// Check if the timer has surpassed 1 minute
			else if ((g_lifetimeHalfSecondTickCount - timer) > (1 * TICKS_PER_MIN))
			{
				// Couldn't establish a connection, give up and retry later

				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;

				// Advance to Retry state
				g_autoDialoutState = AUTO_DIAL_RETRY;
			}
		break;

		//----------------------------------------------------------------
		// Send out GAD command
		//----------------------------------------------------------------
		case AUTO_DIAL_CONNECTED:
			// Check if the current connection has been established for 5 seconds
			if ((g_lifetimeHalfSecondTickCount - timer) > (5 * TICKS_PER_SEC))
			{
				// Make sure transfer flag is set to ascii
				g_binaryXferFlag = NO_CONVERSION;

				// Send out GAD command (includes serial number and auto dialout parameters)
				handleGAD(&msg);

				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;

				// Advance to Response state
				g_autoDialoutState = AUTO_DIAL_RESPONSE;
			}
			// Check if we lose the remote connection
			else if (READ_DCD == NO_CONNECTION)
			{
				// Advance to Retry state
				g_autoDialoutState = AUTO_DIAL_RETRY;
			}
		break;

		//----------------------------------------------------------------
		// Look for system to be unlocked
		//----------------------------------------------------------------
		case AUTO_DIAL_RESPONSE:
			// Check if the system has been unlocked (thus successful receipt of an unlock command)
			if (g_modemStatus.systemIsLockedFlag == NO)
			{
				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;

				// Advance to Active state
				g_autoDialoutState = AUTO_DIAL_ACTIVE;
			}
			// Check if more than 30 seconds have elapsed without a successful unlock command
			else if ((g_lifetimeHalfSecondTickCount - timer) > (30 * TICKS_PER_SEC))
			{
				// Send out GAD command again
				handleGAD(&msg);

				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;

				// Advance to Wait state
				g_autoDialoutState = AUTO_DIAL_WAIT;
			}
			// Check if we lose the remote connection
			else if (READ_DCD == NO_CONNECTION)
			{
				// Advance to Retry state
				g_autoDialoutState = AUTO_DIAL_RETRY;
			}
		break;

		//----------------------------------------------------------------
		// Wait for system to be unlocked (2nd attempt)
		//----------------------------------------------------------------
		case AUTO_DIAL_WAIT:
			// Check if the system has been unlocked (thus successful receipt of an unlock command)
			if (g_modemStatus.systemIsLockedFlag == NO)
			{
				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;

				// Advance to Active state
				g_autoDialoutState = AUTO_DIAL_ACTIVE;
			}
			// Check if more than 30 seconds have elapsed without a successful unlock command (again, 2nd attempt)
			else if ((g_lifetimeHalfSecondTickCount - timer) > (30 * TICKS_PER_SEC))
			{
				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;

				// Advance to Retry state
				g_autoDialoutState = AUTO_DIAL_RETRY;
			}
			// Check if we lose the remote connection
			else if (READ_DCD == NO_CONNECTION)
			{
				// Advance to Retry state
				g_autoDialoutState = AUTO_DIAL_RETRY;
			}
		break;

		//----------------------------------------------------------------
		// Start retry handling
		//----------------------------------------------------------------
		case AUTO_DIAL_RETRY:
			// Check if retries have been exhausted
			if (g_autoRetries == 0)
			{
				// Advance to Finish state
				g_autoDialoutState = AUTO_DIAL_FINISH;
			}
			else // Keep trying
			{
				// Decrement retry count
				g_autoRetries--;

				// Unable to successfully connect to remote end, start retry with modem reset
				ModemResetProcess();

				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;

				// Advance to Sleep state
				g_autoDialoutState = AUTO_DIAL_SLEEP;
			}
		break;

		//----------------------------------------------------------------
		// Sleep for variable retry time
		//----------------------------------------------------------------
		case AUTO_DIAL_SLEEP:
			// Check if the retry time has expired
			if ((g_lifetimeHalfSecondTickCount - timer) > (g_modemSetupRecord.retryTime * TICKS_PER_MIN))
			{
				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;

				// Start back at Init state
				g_autoDialoutState = AUTO_DIAL_INIT;
			}
		break;

		//----------------------------------------------------------------
		// Active connection
		//----------------------------------------------------------------
		case AUTO_DIAL_ACTIVE:
			// Check if modem data has been transfered (either sent or successful receipt of a message)
			if (g_modemDataTransfered == YES)
			{
				// Toggle the flag off
				g_modemDataTransfered = NO;

				// Update timer to current tick count
				timer = g_lifetimeHalfSecondTickCount;
			}
			// Check if data has not been transmitted in the last 5 minutes
			else if ((g_lifetimeHalfSecondTickCount - timer) > (5 * TICKS_PER_MIN))
			{
				// No data has been transfered in 5 minutes, tear down connection

				// Advance to Finish state
				g_autoDialoutState = AUTO_DIAL_FINISH;
			}
			// Check if we lose the remote connection
			else if (READ_DCD == NO_CONNECTION)
			{
				// Advance to Finish state
				g_autoDialoutState = AUTO_DIAL_FINISH;
			}
		break;

		//----------------------------------------------------------------
		// Finished with Auto dialout (either successful connection of failed retries)
		//----------------------------------------------------------------
		case AUTO_DIAL_FINISH:
			// Done with Auto Dialout processing, issue a modem reset
			ModemResetProcess();

			// Place in Idle state
			g_autoDialoutState = AUTO_DIAL_IDLE;
		break;

		//----------------------------------------------------------------
		// Idle
		//----------------------------------------------------------------
		case AUTO_DIAL_IDLE:
			// Do nothing
		break;
	}
}
コード例 #6
0
ファイル: board.c プロジェクト: jionfull/lon_uboot
void start_armboot (void)
{
	init_fnc_t **init_fnc_ptr;
	char *s;
#if defined(CONFIG_VFD) || defined(CONFIG_LCD)
	unsigned long addr;
#endif

	/* Pointer is writable since we allocated a register for it */
	gd = (gd_t*)(_armboot_start - CONFIG_SYS_MALLOC_LEN - sizeof(gd_t));
	/* compiler optimization barrier needed for GCC >= 3.4 */
	__asm__ __volatile__("": : :"memory");

	memset ((void*)gd, 0, sizeof (gd_t));
	gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));
	memset (gd->bd, 0, sizeof (bd_t));

	gd->flags |= GD_FLG_RELOC;

	monitor_flash_len = _bss_start - _armboot_start;

	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
		if ((*init_fnc_ptr)() != 0) {
            UartPuts("system init err");
			hang ();
		}
	}

	/* armboot_start is defined in the board-specific linker script */
	mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN,
			CONFIG_SYS_MALLOC_LEN);

#ifndef CONFIG_SYS_NO_FLASH
	/* configure available FLASH banks */
	display_flash_config (flash_init ());
#endif /* CONFIG_SYS_NO_FLASH */

#ifdef CONFIG_VFD
#	ifndef PAGE_SIZE
#	  define PAGE_SIZE 4096
#	endif
	/*
	 * reserve memory for VFD display (always full pages)
	 */
	/* bss_end is defined in the board-specific linker script */
	addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
	vfd_setmem (addr);
	gd->fb_base = addr;
#endif /* CONFIG_VFD */

#ifdef CONFIG_LCD
	/* board init may have inited fb_base */
	if (!gd->fb_base) {
#		ifndef PAGE_SIZE
#		  define PAGE_SIZE 4096
#		endif
		/*
		 * reserve memory for LCD display (always full pages)
		 */
		/* bss_end is defined in the board-specific linker script */
		addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
		lcd_setmem (addr);
		gd->fb_base = addr;
	}
#endif /* CONFIG_LCD */

#if defined(CONFIG_CMD_NAND)
	puts ("NAND:  ");
	nand_init();		/* go init the NAND */
#endif



	/* initialize environment */
	env_relocate ();

#ifdef CONFIG_VFD
	/* must do this after the framebuffer is allocated */
	drv_vfd_init();
#endif /* CONFIG_VFD */

#ifdef CONFIG_SERIAL_MULTI
	serial_initialize();
#endif

	/* IP Address */
	gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");

	stdio_init ();	/* get the devices list going. */

	jumptable_init ();

#if defined(CONFIG_API)
	/* Initialize API */
	api_init ();
#endif

	console_init_r ();	/* fully init console as a device */

#if defined(CONFIG_ARCH_MISC_INIT)
	/* miscellaneous arch dependent initialisations */
	arch_misc_init ();
#endif
#if defined(CONFIG_MISC_INIT_R)
	/* miscellaneous platform dependent initialisations */
	misc_init_r ();
#endif

	/* enable exceptions */
	enable_interrupts ();

	/* Perform network card initialisation if necessary */


	/* Initialize from environment */
	if ((s = getenv ("loadaddr")) != NULL) {
		load_addr = simple_strtoul (s, NULL, 16);
	}
#if defined(CONFIG_CMD_NET)
	if ((s = getenv ("bootfile")) != NULL) {
		copy_filename (BootFile, s, sizeof (BootFile));
	}
#endif

#ifdef BOARD_LATE_INIT
	board_late_init ();
#endif

#ifdef CONFIG_GENERIC_MMC
	puts ("MMC:   ");
	mmc_initialize (gd->bd);
#endif

#ifdef CONFIG_BITBANGMII
	bb_miiphy_init();
#endif
#if defined(CONFIG_CMD_NET)
#if defined(CONFIG_NET_MULTI)
	puts ("Net:   ");
#endif
	eth_initialize(gd->bd);
#if defined(CONFIG_RESET_PHY_R)
	debug ("Reset Ethernet PHY\n");
	reset_phy();
#endif
#endif
	/* main_loop() can return to retry autoboot, if so just run it again. */
	for (;;) {
		main_loop ();
	}

	/* NOTREACHED - no way out of command loop except booting */
}
コード例 #7
0
ファイル: main.c プロジェクト: wanglehui/W7500
/**
  * @brief  Main Function
  */
int main()
{
    uint32_t i,result;

	SystemInit();
//    *(volatile uint32_t *)(0x41001014) = 0x0060100; //clock setting 48MHz
    
    /* CLK OUT Set */
//    PAD_AFConfig(PAD_PA,GPIO_Pin_2, PAD_AF2); // PAD Config - CLKOUT used 3nd Function
#ifdef __DEBUG
    UART_StructInit(&UART_InitStructure);
    UART_Init(USING_UART,&UART_InitStructure);
    UartPuts(USING_UART,"Test Start\r\n");
#endif


    // Make Dummy Data for Flash Write Test
    for(i=0;i<SECT_SIZE;i++)
    {
        save_buff[i] = i;
    }

    // Step 1 DATA0 Erase, Read, Write Test
    DO_IAP(IAP_ERAS_DAT0,0,0,0);
    DO_IAP(IAP_PROG,DAT0_START_ADDR,save_buff,SECT_SIZE);
    result = Buffercmp((uint8_t*)save_buff,((uint8_t *)(DAT0_START_ADDR)),SECT_SIZE);
#ifdef __DEBUG
    if(result == PASSED)
        UartPuts(USING_UART,"Step1 Test Passed\r\n");
    else
        UartPuts(USING_UART,"Step1 Test Falied\r\n");
#endif


    // Step 2 DATA1 Erase, Read, Write Test
    DO_IAP(IAP_ERAS_DAT1,0,0,0);
    DO_IAP(IAP_PROG,DAT1_START_ADDR,save_buff,SECT_SIZE);
    result = Buffercmp((uint8_t*)save_buff,((uint8_t *)(DAT1_START_ADDR)),SECT_SIZE);
#ifdef __DEBUG
    if(result == PASSED)
        UartPuts(USING_UART,"Step2 Test Passed\r\n");
    else
        UartPuts(USING_UART,"Step2 Test Falied\r\n");
#endif

    // Step 3 Code Flash Block Erase, Read, Write Test
    for(i=0;i<BLOCK_SIZE;i++)
    {
        save_buff[i] = i;
    }

    DO_IAP(IAP_ERAS_BLCK,CODE_TEST_ADDR,0,0);
    DO_IAP(IAP_PROG, CODE_TEST_ADDR,save_buff,BLOCK_SIZE);
    result = Buffercmp((uint8_t*)save_buff,((uint8_t *)(CODE_TEST_ADDR)),BLOCK_SIZE);
#ifdef __DEBUG
    if(result == PASSED)
        UartPuts(USING_UART,"Step3 Test Passed\r\n");
    else
        UartPuts(USING_UART,"Step3 Test Falied\r\n");
#endif
}