int main( int argc, char *argv[] )
{
	FILE *stream;
	char *url;
	int loops,i,j;

	char method[URL_SIZE];
	char server[URL_SIZE];
	char path[URL_SIZE];
	char buffer[BUFFER_SIZE];

	if(argc!=3) {
		printf("Use: %s <url> <loops>\n",argv[0]);
		return EXIT_FAILURE;
	}

	url = argv[1]; 
	loops = atoi(argv[2]);

	printf("url:   %s\n",url);
	printf("loops: %d\n",loops);

	sscanf(url,"%[^:]://%[^/]%s",method,server,path);

	printf("method: %s\n",method);
	printf("server: %s\n",server);
	printf("path:   %s\n",path);

	for(i=0; i<loops; i++) {

		printf("Making connection...\n");

		stream = fopen_http(server,path);
		if(!stream) {
			printf("FAILURE: fopen_http(): %s\n",strerror(errno));
			return -1;
		}

		printf("Getting data...\n");

		for(j=0; j<5; j++) {
			fgets(buffer,BUFFER_SIZE,stream);
			if(ferror(stream)) {
				printf("FAILURE: stream has an error: %s\n",strerror(errno));
				return -1;
			}
			printf(">>> %s",buffer);
			loop_delay(1);
		}

		printf("Closing connection...\n");
		fclose(stream);

		loop_delay(1);
	}

	printf("SUCCESS\n");

	return EXIT_SUCCESS;
}
示例#2
0
void entry(void)
{
	for(;;) {
		
		LED_TOGGLE
		loop_delay(10000000);
		
		/* Or */
		/*
		GPIO0_TOGGLE_BIT(16)
		loop_delay(10000000);
		*/
		
		/* Or */
		/*
		GPIO0_SET_LOW(16)
		loop_delay(10000000);
		GPIO0_SET_HIGH(16)
		loop_delay(10000000);
		*/
		
		/* Or */
		/*
		iomem(GPCLR0) |= (1<<16);
		loop_delay(10000000);
		iomem(GPSET0) |= (1<<16);
		loop_delay(10000000);
		*/
	}
}
示例#3
0
文件: panic.c 项目: gepp88/Meiji
static inline void panic(int l1)
{
	leds_mask(l1 & 0xf);
	for (;;) {
		loop_delay(3000000u);
		leds_toggle_mask(0xf);
	}
}
示例#4
0
文件: board_init.c 项目: awe00/boards
void bl_blink(void) {
    LED_RED_ON;
    LED_GREEN_ON;
    
    loop_delay();

    LED_RED_OFF;
    LED_GREEN_OFF;
}
示例#5
0
void entry(void)
{
	/* Init GPIO 16 (wired to LED ACT) as Output */
	gpio[GPFSEL1/4] |= (1<<18);
	
	/* Alternativelly: */
	//gpio[GPFSEL1/4] &= ~((1<<20)|(1<<19)|(1<<18));
	//gpio[GPFSEL1/4] |= ((0<<20)|(0<<19)|(1<<18));
	
	/* Set bit related to GPIO 16 low */
	//gpio[GPCLR0/4] |= (1<<16);
	
	for(;;) {
		gpio[GPCLR0/4] |= (1<<16);
		loop_delay(10000000);
		gpio[GPSET0/4] |= (1<<16);
		loop_delay(10000000);
	}
}
示例#6
0
文件: main.c 项目: rijn/HardwareWorks
int main()
{
    GPIO_InitTypeDef gpio;
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

    GPIO_StructInit(&gpio);
    gpio.GPIO_Pin = LED_PIN;
    gpio.GPIO_Mode = GPIO_Mode_OUT;
    gpio.GPIO_Speed = GPIO_Speed_Level_3;
    gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
    gpio.GPIO_OType = GPIO_OType_PP;
    GPIO_Init(GPIOA, &gpio);
	while ( 1 )
	{
        GPIO_SetBits(GPIOA, LED_PIN);
        loop_delay(LED_BLINKING_PERIOD * 1250);
        GPIO_ResetBits(GPIOA, LED_PIN);
        loop_delay(LED_BLINKING_PERIOD * 1250);
	}

	return 0;
}
示例#7
0
static void panic(unsigned int type) {
	puts("\r\n****PANIC = ");
	putunsigned(type);
	puts("****\r\n");
	
	//spegni tutti i led
	leds_off(ALL_LED);
	
	//maschera dei led da accendere
	u32 ledmask = 0;
	
	u32 mask = 0x8;
	while(mask != 0) {
		switch(type & mask) {
			case 0x8:
				ledmask |= LED4;
				break;
			case 0x4:
				ledmask |= LED3;
				break;
			case 0x2:
				ledmask |= LED2;
				break;
			case 0x1:
				ledmask |= LED1;
				break;
		}		
		mask >>= 1;
	}
	
	leds_on(ledmask);
	
	for(;;) {
		loop_delay(3000000u);	//buona frequenza di lampeggiamento
		leds_toggle(ledmask);
	}
}
int do_mdcp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	ulong start, size, memsize = 0, banksize = 0;
	uint32_t loop, idle, cpufreq;
	uint32_t i = 0;
	uint32_t total, data, busy;
	uint32_t dump = 0, showup = 0;

	if (argc != 6) {
		mdcp_help();
		return 0;
	}

	start = conv_hex((char *)argv[1]);
	size = conv_dec((char *)argv[2]);
	loop = conv_dec((char *)argv[3]);
	idle = conv_dec((char *)argv[4]);
	cpufreq = conv_dec((char *)argv[5]);

	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
		MCK5_sdram_size(i, &banksize);
		memsize += banksize;
	}

	if ((start + size * 2048) > memsize) {
		printf("memcpy size exceeds the total memory size: 0x%lx\n",
			memsize);
		return 0;
	}

	printf("memcpy %lu KB at 0x%lx for %d loop,", size, start, loop);
	if (idle > 0)
		printf("then idle for %d ms ", idle);
	else
		printf("without idle ");
	printf("at cpu %dMhz\n", cpufreq);

	while (1) {
		dump++;

		if ((dump % 300) == 0) {
			/* init DDR performance counter */
			MCK5_perf_cnt_clear(0x7);
			MCK5_perf_cnt_init();
		}

		/* do memcpy */
		for (i = 0; i < size * 1024; i = i + 4)
			*(u32 *)(start + size * 1024 + i)
				= *(u32 *)(start + i);

		/* sleep */
		if (idle > 0)
			loop_delay(idle * 1000 * cpufreq);

		if ((dump % 300) == 0) {
			/* calculate data_ratio/busy_ratio */
			MCK5_perf_cnt_stop();
			MCK5_perf_cnt_get(&total, &busy, &data);
			data = data * 4;

			if (showup < loop) {
				showup++;
				printf("%d.%d\t %d.%d\n", busy*100/total,
					((busy*100)%total)*100/total,
					data*100/total,
					((data*100)%total)*100/total);
			} else {
				printf("end\n");
				break;
			}
		}
	}

	return 1;
}