Beispiel #1
0
esint8 if_initInterface(hwInterface* file, eint8* opts)
{
  euint32 sc;
  //初始化硬件SPI 并且唤醒SD卡
  if_spiInit(file); /* init at low speed */
	//初始化SD卡并判断是1.X还是2.X打上标记。
  if (sd_Init(file) < 0)
  {
    DBG((TXT("Card failed to init, breaking up...\n")));
    return(-1);
  }
  //判断SD卡状态无实际意义
  if (sd_State(file) < 0)
  {
    DBG((TXT("Card didn't return the ready state, breaking up...\n")));
    return(-2);
  }
	
  sd_getDriveSize(file, &sc);//取得SD卡的扇区总字节数,
  file->sectorCount = sc / 512;	 //计算扇区总数,只要把字节总数除以512就好
  if ( (sc % 512) != 0)
  {
    file->sectorCount--;  //对不非整数个的扇区处理舍去一个凑够整数
  }

  DBG((TXT("Drive Size is %lu Bytes (%lu Sectors)\n"), sc, file->sectorCount));
  DBG((TXT("Init done...\n")));

  return(0);
}
Beispiel #2
0
esint8
if_initInterface(hwInterface* file, eint8* opts)
{
  euint32 sc;
  if_spiInit(file);
  if(sd_Init(file)<0)     {
    DBG((TXT("Card failed to init, breaking up...\n")));
    return(-1);
  }
  
  if(sd_State(file)<0){
    DBG((TXT("Card didn't return the ready state, breaking up...\n")
	 ));
    return(-2);
  }
  

  
  sd_getDriveSize(file, &sc);
  file->sectorCount = sc/512;
  DBG((TXT("Card Capacity is %lu Bytes (%lu Sectors)\n"), sc, file->sectorCount));
  
  
  return(0);
}
Beispiel #3
0
esint8 if_initInterface(hwInterface* file, eint8* opts)
{
	euint32 sc;

	if_spiInit(file);
	
	if_spiSelectDevice(file);
	
	if(sd_Init(file)<0)	{
		DBG((TXT("Card failed to init, breaking up...\n")));
		if_spiUnselectDevice(file);
		return(-1);
	}
	if(sd_State(file)<0){
		DBG((TXT("Card didn't return the ready state, breaking up...\n")));
		if_spiUnselectDevice(file);
		return(-2);
	}
	
	if_spiUnselectDevice(file);
	
	/* get file->sectorCount (do not use hardcoded = 4 ) */
	if_getDriveSize(file, &sc);
	file->sectorCount = sc/512;
	if( (sc%512) != 0) {
		file->sectorCount--;
	}
	DBG((TXT("Card Capacity is %lu Bytes (%lu Sectors)\n"), sc, file->sectorCount));
	
	DBG((TXT("Init done...\n")));
	
	return(0);
}
esint8 if_initInterface(hwInterface* file, eint8* opts)
{
	euint32 sc;

	if_spiInit(file); /* init at low speed */

	if(sd_Init(file)<0)	{
		DBG((TXT("Card failed to init, breaking up...\n")));
		return(-1);
	}
	if(sd_State(file)<0){
		DBG((TXT("Card didn't return the ready state, breaking up...\n")));
		return(-2);
	}

	// file->sectorCount=4; /* FIXME ASAP!! */

	sd_getDriveSize(file, &sc);
	file->sectorCount = sc/512;
	if( (sc%512) != 0) {
		file->sectorCount--;
	}
	DBG((TXT("Drive Size is %lu Bytes (%lu Sectors)\n"), sc, file->sectorCount));

	 /* increase speed after init */
#if ( HW_ENDPOINT_LPC2000_SPINUM == 1 )
	SSPCR0 = ((8-1)<<0) | (0<<CPOL);
#endif
	if_spiSetSpeed(SPI_PRESCALE_MIN);
	// if_spiSetSpeed(100); /* debug - slower */

	DBG((TXT("Init done...\n")));
	return(0);
}
Beispiel #5
0
int8_t init_interface()
{
	uint32_t sc;
	
	if_spiInit(file); /* init at low speed */
	
	if(sd_Init(file)<0)	{
		printf("Card failed to init, breaking up...\n\r");
		return(-1);
	}
	if(sd_State(file)<0){
		printf("Card didn't return the ready state, breaking up...\n\r");
		return(-2);
	}
	// file->sectorCount=4; /* FIXME ASAP!! */
	
	sd_getDriveSize(file, &sc);
	file->sectorCount = sc/512;
	if( (sc%512) != 0) {
		file->sectorCount--;
	}
	printf("Drive Size is %d Bytes (%d sectors)\n\r ", sc, file->sectorCount); 	
	if_spiSetSpeed(SPI_PRESCALE_MIN);
	// if_spiSetSpeed(100); /* debug - slower */
	
	printf("Init done...\n\r");
	return 0;
}
Beispiel #6
0
esint8 if_initInterface(hwInterface* file, eint8* opts)
{
	if_spiInit(file);
	if(sd_Init(file)<0)	{
		DBG((TXT("Card failed to init, breaking up...\n")));
		return(-1);
	}
	if(sd_State(file)<0){
		DBG((TXT("Card didn't return the ready state, breaking up...\n")));
		return(-2);
	}
	file->sectorCount=4; /* FIXME ASAP!! */
	DBG((TXT("Init done...\n")));
	return(0);
}
esint8 if_initInterface(hwInterface* file, eint8* opts)
{
euint32 size;
	if_spiInit(file);
	if(sd_Init(file)<0)	{
		DBG((TXT("Card failed to init, breaking up...\n")));
		return(-1);
	}
	if(sd_State(file)<0){
		DBG((TXT("Card didn't return the ready state, breaking up...\n")));
		return(-2);
	}
    
    sd_getDriveSize(file,&size);

	file->sectorCount=size>>9; /* FIXME ASAP!! */
    DBG(TXT(("Card size:%d\n",size)));
	DBG((TXT("Init done...\n")));
	return(0);
}
Beispiel #8
0
esint8 if_initInterface(hwInterface* file, eint8* opts)
{
	euint32 sc;
	
	if_spiInit(file); 
	
	if(sd_Init(file)<0)	{
		return(-1);
	}
	if(sd_State(file)<0){
		
		return(-2);
	}

	sd_getDriveSize(file, &sc);
	file->sectorCount = sc/512;
	if( (sc%512) != 0) {
		file->sectorCount--;
	}

	return(0);
}
Beispiel #9
0
short if_initInterface(hwInterface* file, char* opts)
{
    file->sectorCount=0;
    return(if_spiInit(file));
}