Example #1
0
void setup()
{
	ebox_init();
	uart1.begin(9600);
	ret = sd.begin();
	if(!ret)
		uart1.printf("\r\nsdcard init ok!");
	f_mount(0, &fs);

	w5500.begin(mac,lip,sub,gw);

	attachEthToSocket(&w5500);
	attachSDCardToFat(&sd);

  w5500.getMAC (ip);
  uart1.printf("\r\nmac : %02x.%02x.%02x.%02x.%02x.%02x\r\n", ip[0],ip[1],ip[2],ip[3],ip[4],ip[5]);
  w5500.getIP (ip);
  uart1.printf("IP : %d.%d.%d.%d\r\n", ip[0],ip[1],ip[2],ip[3]);
  w5500.getSubnet(ip);
  uart1.printf("mask : %d.%d.%d.%d\r\n", ip[0],ip[1],ip[2],ip[3]);
  w5500.getGateway(ip);
  uart1.printf("GW : %d.%d.%d.%d\r\n", ip[0],ip[1],ip[2],ip[3]);
  uart1.printf("Network is ready.\r\n");
	
	if(udp1.begin(0,30000) == 0)
		uart1.printf("\r\nudp1 server creat ok! listen on 30000");


	uart1.printf("\r\nret = %d",ret);
	ret = sd.getCID(buf);
	uart1.printf("\r\nret = %d",ret);
	uart1.printf((const char*)buf);

	ret = sd.getCSD(buf);
	uart1.printf("\r\nret = %d",ret);

	rl = sd.getCapacity();
	x = (float)rl;
	uart1.printf("\r\n容量 = %f",x/1024/1024);	
   
  res=f_getfree("/",&free_clust,&fss);
       uart1.printf("该分区所有扇区数为:%d\r\n",(fss->max_clust-2)*(fss->csize));
	if(res==FR_OK)
	{
		uart1.printf("该分区所有扇区数为:%d\r\n",(fss->max_clust-2)*(fss->csize));
		uart1.printf("该分区大小为:%dM\r\n",(fss->max_clust-2)*(fss->csize)/2048);
		uart1.printf("该分区空簇数为:%d\r\n",free_clust);
		uart1.printf("该分区空扇区数为:%d\r\n",free_clust*(fss->csize));
	}
	else
		uart1.printf("获取分区空簇失败\r\n,res = %d",res);
	uart1.printf("\r\n");

}
Example #2
0
void setup()
{
	eBoxInit();
	uart1.begin(9600);

	w5500.begin(mac,lip,sub,gw);
	w5500.attchInterruputEvent(ethEvent);
	attachEthToSocket(&w5500);
	
  w5500.getMAC (ip);
  uart1.printf("mac : %02x.%02x.%02x.%02x.%02x.%02x\r\n", ip[0],ip[1],ip[2],ip[3],ip[4],ip[5]);
  w5500.getIP (ip);
  uart1.printf("IP : %d.%d.%d.%d\r\n", ip[0],ip[1],ip[2],ip[3]);
  w5500.getSubnet(ip);
  uart1.printf("mask : %d.%d.%d.%d\r\n", ip[0],ip[1],ip[2],ip[3]);
  w5500.getGateway(ip);
  uart1.printf("GW : %d.%d.%d.%d\r\n", ip[0],ip[1],ip[2],ip[3]);
  uart1.printf("Network is ready.\r\n");
	
	if(udp.begin(0,30000) == 0)
		uart1.printf("\r\nudp1 server creat ok! listen on 30000");
	

}