Exemplo n.º 1
0
Arquivo: mmc.c Projeto: MaxGekk/ZigZag
// Initialize MMC card
unsigned char initMMC (void)
{

  //raise SS and MOSI for 80 clock cycles
  //SendByte(0xff) 10 times with SS high
  //RAISE SS
  int i;

  // Port 5 Function           Dir       On/Off
  //         5.1-Dout          Out       0 - off    1 - On -> init in SPI_Init
  //         5.2-Din           Inp       0 - off    1 - On -> init in SPI_Init
  //         5.3-Clk           Out       -                 -> init in SPI_Init
  //         5.0-mmcCS         Out       0 - Active 1 - none Active
/*
  P5SEL |= 0x0E;
  P5SEL &= ~0x11;
  P5OUT |= 0x11;
  P5DIR |= 0x1B;
*/
  /*
  PIN_SET(port5_attr.sel, 0x0e, PIN_HI);
  PIN_CLEAR(port5_attr.sel, 0x01);
  PIN_SET(port5_attr.dir, 0x0B, PIN_HI);
  PIN_CLEAR(port5_attr.dir, 0x04);
  port_set_attr(5, 0x0f, &port5_attr);
  port_write(5, 0x01, PIN_HI);
  */
//  PIN_SET(port5_attr.sel, 0x0e, PIN_HI);
#ifndef PORT_WRITE
  mmcPower(MMC_ON);
  MMC_PWR_PDIR |=  MMC_CARD_PWR;
  MMC_PWR_PSEL &= ~MMC_CARD_PWR;
//  MMC_POUT |=  MMC_CS;
  CS_HIGH();
  MMC_PDIR |=  MMC_CS;
  MMC_PSEL &= ~MMC_CS;
#else  // !PORT_WRITE
  PIN_SET  (mmc_pwr_port_attr.dir, MMC_CARD_PWR, PIN_HI);
  PIN_CLEAR(mmc_pwr_port_attr.sel, MMC_CARD_PWR);
  port_set_attr(MMC_PWR_PORT, MMC_CARD_PWR, &mmc_pwr_port_attr);
  mmcPower(MMC_ON);
  PIN_CLEAR(mmc_port_attr.sel, MMC_CS);
  PIN_SET  (mmc_port_attr.dir, MMC_CS, PIN_HI);
  port_set_attr(MMC_PORT, MMC_CS, &mmc_port_attr);
  CS_HIGH();
  //port_write(5, 0x01, PIN_HI);
#endif // !PORT_WRITE

//  initSPI();
//  SPI_init();
  //initialization sequence on PowerUp
//  CS_HIGH();
  for(i=0;i<=9;i++)
    spiSendByte(0xff);

  mmc_error = MMC_SUCCESS;

  return (mmc_GoIdle());
}
Exemplo n.º 2
0
// Initialize MMC card
//set DI and CS high and apply more than 74 pulses to SCLK
char initMMC (void){
  int i;

  CS_HIGH(); //sey CS high
  for(i=0;i<11;i++)
    spiSendByte(0xff);//set DI high with ff (10 times)

  return (mmc_GoIdle());
}