Reformar get name funtion. Add test.
[bertos.git] / bertos / cpu / cortex-m3 / drv / hsmci_sam3.c
index d0b0c39675e5f47d33bad56f5d3f5eaf523f9a08..b0c0ad0af522693a3afc08a548ee997352e4298d 100644 (file)
@@ -88,16 +88,16 @@ bool hsmci_sendCmd(uint8_t index, uint32_t argument, uint32_t reply_type)
        HSMCI_ARGR = argument;
        HSMCI_CMDR = index | reply_type | BV(HSMCI_CMDR_MAXLAT);
 
-       uint32_t status = HSMCI_SR;
-       while (!(status & BV(HSMCI_SR_CMDRDY)))
-       {
+       uint32_t status;
+       do {
+               status = HSMCI_SR;
+
                if (status & HSMCI_RESP_ERROR_MASK)
                        return status;
 
                cpu_relax();
 
-               status = HSMCI_SR;
-       }
+       } while (!(status & BV(HSMCI_SR_CMDRDY)));
 
        return 0;
 }
@@ -161,9 +161,7 @@ void hsmci_setSpeed(uint32_t data_rate, int flag)
        else
                HSMCI_CFG &= ~BV(HSMCI_CFG_HSMODE);
 
-       HSMCI_DTOR = 0xF8 | HSMCI_DTOR_DTOMUL_1;
-       HSMCI_CSTOR = 0xF8 | HSMCI_CSTOR_CSTOMUL_1;
-       HSMCI_MR = HSMCI_CLK_DIV(data_rate) | BV(HSMCI_MR_RDPROOF) | BV(HSMCI_MR_WRPROOF);
+       HSMCI_MR = HSMCI_CLK_DIV(data_rate);
 
        timer_delay(10);
 }
@@ -181,7 +179,7 @@ void hsmci_init(Hsmci *hsmci)
 
        HSMCI_DTOR = 0xFF | HSMCI_DTOR_DTOMUL_1048576;
        HSMCI_CSTOR = 0xFF | HSMCI_CSTOR_CSTOMUL_1048576;
-       HSMCI_MR = HSMCI_CLK_DIV(HSMCI_INIT_SPEED) | BV(HSMCI_MR_RDPROOF) | BV(HSMCI_MR_WRPROOF);
+       HSMCI_MR = HSMCI_CLK_DIV(HSMCI_INIT_SPEED);
        HSMCI_CFG = BV(HSMCI_CFG_FIFOMODE) | BV(HSMCI_CFG_FERRCTRL);
 
        HSMCI_CR = BV(HSMCI_CR_MCIEN);