Dmitry wrote:
> 
> hm...
> any code snippet?
> ~d
Sure, let me know if you need more.
Thanks,
  Garst

#ifdef _MMC_TEST
int main(void)
{
        unsigned int i;
        union reg16b_t reg16b;
        mcu_init();
        spi_init();
        lcd_init();
        clear_display();
        lcd_set_pos(0,0);
        get_register(MMC_SEND_CSD,&reg16b);
        print_register(&reg16b);
        print_response(0xEE);
        print_response(reg16b.csd.READ_BL_LEN);
        SPI_NONE;
}
#endif


int get_register( unsigned char reg_cmd, union reg16b_t *reg16)
{
        unsigned char arguments[4];
        unsigned char temp25;
        int i;

        arguments[0]=0x00;
        arguments[1]=0x00;
        arguments[2]=0x00;
        arguments[3]=0x00;
        temp25=mmc_sendcmd(reg_cmd,arguments);
        if(temp25)
        {
                SPI_NONE;
                SPI_LCD_EN;
                lcd_write_string("GETREG");
                print_response(temp25);
                BREAKPNT;
                return FALSE;
        }
        mmc_get_data((unsigned char*) reg16);
        return TRUE;
}


int mmc_get_data(unsigned char* data)
{
        unsigned char temp25;
        int i ;

        while((temp25=mmc_get_response())==0); //if card is busy
        if(temp25!=0xFE)
        {
                BREAKPNT;
                return FALSE;
        }

        /*read the data*/
        for(i=0;i<16;i++)
        {
                data[i]=spi_read();
        }

        //CRC TOKENs
        spi_read();
        spi_read();

        return TRUE;
}

Reply via email to