X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Fcortex-m3%2Fdrv%2Fhsmci_sam3.c;h=d09723fc146601be8a16b8a01ab61a949299e0a8;hb=666af47976ef74df740dc7df58fc31fa6e3fc65b;hp=134a972c490d3c88992249562d9d586a21e3b0e6;hpb=e8d055eeb9e26e36df916ea05969f34163a6c488;p=bertos.git diff --git a/bertos/cpu/cortex-m3/drv/hsmci_sam3.c b/bertos/cpu/cortex-m3/drv/hsmci_sam3.c index 134a972c..d09723fc 100644 --- a/bertos/cpu/cortex-m3/drv/hsmci_sam3.c +++ b/bertos/cpu/cortex-m3/drv/hsmci_sam3.c @@ -36,11 +36,13 @@ #include "hsmci_sam3.h" +#include "hw/hw_sd.h" #include -#include #include +#include + #include /** DMA Transfer Descriptor as well as Linked List Item */ @@ -53,9 +55,6 @@ typedef struct DmacDesc uint32_t dsc_addr; /**< Next descriptor address */ } DmacDesc; - - - #define HSMCI_CLK_DIV(RATE) ((CPU_FREQ / (RATE << 1)) - 1) @@ -76,21 +75,6 @@ typedef struct DmacDesc cpu_relax(); \ } while (!(HSMCI_SR & BV(HSMCI_SR_RXRDY))) -#define HSMCI_HW_INIT() \ -do { \ - PIOA_PDR = BV(19) | BV(20) | BV(21) | BV(22) | BV(23) | BV(24); \ - PIO_PERIPH_SEL(PIOA_BASE, BV(19) | BV(20) | BV(21) | BV(22) | BV(23) | BV(24), PIO_PERIPH_A); \ -} while (0) - - -#define STROBE_ON() PIOB_SODR = BV(13) -#define STROBE_OFF() PIOB_CODR = BV(13) -#define STROBE_INIT() \ - do { \ - PIOB_OER = BV(13); \ - PIOB_PER = BV(13); \ - } while(0) - static DECLARE_ISR(hsmci_irq) { uint32_t status = HSMCI_SR; @@ -99,7 +83,6 @@ static DECLARE_ISR(hsmci_irq) } } - static DECLARE_ISR(dmac_irq) { uint32_t stat = DMAC_EBCISR; @@ -120,7 +103,6 @@ void hsmci_readResp(uint32_t *resp, size_t len) bool hsmci_sendCmd(uint8_t index, uint32_t argument, uint32_t reply_type) { - STROBE_ON(); HSMCI_WAIT(); HSMCI_ARGR = argument; @@ -137,7 +119,6 @@ bool hsmci_sendCmd(uint8_t index, uint32_t argument, uint32_t reply_type) status = HSMCI_SR; } - STROBE_OFF(); return 0; } @@ -198,7 +179,7 @@ void hsmci_waitTransfer(void) void hsmci_setSpeed(uint32_t data_rate, int flag) { - if (flag) + if (flag & HSMCI_HS_MODE) HSMCI_CFG |= BV(HSMCI_CFG_HSMODE); else HSMCI_CFG &= ~BV(HSMCI_CFG_HSMODE); @@ -212,8 +193,7 @@ void hsmci_init(Hsmci *hsmci) { (void)hsmci; - HSMCI_HW_INIT(); - STROBE_INIT(); + SD_PIN_INIT(); pmc_periphEnable(HSMCI_ID); HSMCI_CR = BV(HSMCI_CR_SWRST); @@ -233,7 +213,6 @@ void hsmci_init(Hsmci *hsmci) DMAC_EBCIDR = 0x3FFFFF; DMAC_CHDR = 0x1F; - pmc_periphEnable(DMAC_ID); DMAC_EN = BV(DMAC_EN_ENABLE); sysirq_setHandler(INT_DMAC, dmac_irq);