Exemplo n.º 1
0
/* ****************************************************************************  
 * short if_initInterface(hwInterface* file, char* fileName)
 * Description: This function should bring the hardware described in file in a
 * ready state to receive and retrieve data.
 * Return value: Return 0 on succes and -1 on failure.
*/
esint8 if_initInterface(hwInterface* file, eint8* fileName)
{
	MMCFG cfg;

	if (!mmc_init())
	    return (-1);

	if (!mmc_read_config (&cfg)) {
	    mmc_fini();
	    return (-1);
	}

	file->sectorCount = cfg.blocknr;
	file->readCount=file->writeCount=0;

	return(0);
}
Exemplo n.º 2
0
/*----------------------------------------------------------------------------
 *        Initialize a Flash Memory Card
 *---------------------------------------------------------------------------*/
static void init_card (void) {
  U32 retv;
  MMCFG SDCardCfg;
  char outBuf[26];

  GLCD_SetBackColor (White);
  GLCD_SetTextColor (Blue);
  GLCD_ClearLn (5);
  GLCD_ClearLn (6);
  GLCD_ClearLn (7);
  GLCD_ClearLn (8);

  while ((retv = finit ()) != 0) {            /* Wait until the Card is ready*/
    if (retv == 1) {
      printf ("\nSD/MMC Init Failed");
      printf ("\nInsert Memory card and press key...\n");
      getkey ();
    }
    else {
      printf ("\nSD/MMC Card is Unformatted");
      strcpy (&in_line[0], "KEIL\r\n");
      cmd_format (&in_line[0]);
    }
  }

  mmc_read_config (&SDCardCfg);

  outBuf[0] = 0;
  sprintf (&outBuf[0], " SerNr:  0x%08X", SDCardCfg.sernum);
  GLCD_DisplayString (5, 0, (unsigned char *)outBuf);
  sprintf (&outBuf[0], " BlockNr:0x%08X", SDCardCfg.blocknr);
  GLCD_DisplayString (6, 0, (unsigned char *)outBuf);
  sprintf (&outBuf[0], " RdLen:  0x%04X", SDCardCfg.read_blen);
  GLCD_DisplayString (7, 0, (unsigned char *)outBuf);
  sprintf(&outBuf[0], " WrLen:  0x%04X", SDCardCfg.write_blen);
  GLCD_DisplayString (8, 0, (unsigned char *)outBuf);
}