X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Fcortex-m3%2Fdrv%2Fhsmci_sam3.c;h=b0c0ad0af522693a3afc08a548ee997352e4298d;hb=d603ad8d35758a54f6cb08a7f8c16f6327ea86e0;hp=d0b0c39675e5f47d33bad56f5d3f5eaf523f9a08;hpb=5bb1f1a99a0ac8e07b5591779416cff925f4b2af;p=bertos.git diff --git a/bertos/cpu/cortex-m3/drv/hsmci_sam3.c b/bertos/cpu/cortex-m3/drv/hsmci_sam3.c index d0b0c396..b0c0ad0a 100644 --- a/bertos/cpu/cortex-m3/drv/hsmci_sam3.c +++ b/bertos/cpu/cortex-m3/drv/hsmci_sam3.c @@ -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);