From 666af47976ef74df740dc7df58fc31fa6e3fc65b Mon Sep 17 00:00:00 2001 From: asterix Date: Tue, 6 Sep 2011 13:41:48 +0000 Subject: [PATCH] Move some define in sam3x sd implementaion. Define sd speeds macro to clarify the code. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5034 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/cortex-m3/drv/hsmci_sam3.c | 2 +- bertos/cpu/cortex-m3/drv/hsmci_sam3.h | 28 +++------------------------ bertos/cpu/cortex-m3/drv/sd_sam3.c | 28 ++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/bertos/cpu/cortex-m3/drv/hsmci_sam3.c b/bertos/cpu/cortex-m3/drv/hsmci_sam3.c index 51b79d9c..d09723fc 100644 --- a/bertos/cpu/cortex-m3/drv/hsmci_sam3.c +++ b/bertos/cpu/cortex-m3/drv/hsmci_sam3.c @@ -179,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); diff --git a/bertos/cpu/cortex-m3/drv/hsmci_sam3.h b/bertos/cpu/cortex-m3/drv/hsmci_sam3.h index 71cdd99b..82bf668e 100644 --- a/bertos/cpu/cortex-m3/drv/hsmci_sam3.h +++ b/bertos/cpu/cortex-m3/drv/hsmci_sam3.h @@ -43,31 +43,6 @@ #include -#define CMD8_V_RANGE_CHECK_PAT 0xAA -#define CMD8_V_RANGE_27V_36V (0x100 | CMD8_V_RANGE_CHECK_PAT) -#define CMD8_V_RANGE_LOW (0x1000 | CMD8_V_RANGE_CHECK_PAT) -#define CMD8_V_ECHO_REPLY 0xFF -#define CMD8_SUPP_V_RANGE_REPLY 0xFF00 - - -#define SD_OCR_CCS BV(30) /**< SD Card Capacity Status (CCS) */ -#define SD_OCR_BUSY BV(31) /**< SD/MMC Card power up status bit (busy) */ - -#define SD_OCR_VDD_27_28 BV(15) -#define SD_OCR_VDD_28_29 BV(16) -#define SD_OCR_VDD_29_30 BV(17) -#define SD_OCR_VDD_30_31 BV(18) -#define SD_OCR_VDD_31_32 BV(19) -#define SD_OCR_VDD_32_33 BV(20) - - -#define SD_HOST_VOLTAGE_RANGE (SD_OCR_VDD_27_28 | \ - SD_OCR_VDD_28_29 | \ - SD_OCR_VDD_29_30 | \ - SD_OCR_VDD_30_31 | \ - SD_OCR_VDD_31_32 | \ - SD_OCR_VDD_32_33) - #define HSMCI_CHECK_BUSY() \ do { \ cpu_relax(); \ @@ -75,6 +50,9 @@ #define HSMCI_INIT_SPEED 400000 +#define HSMCI_HIGH_SPEED 2100000 + +#define HSMCI_HS_MODE BV(0) typedef struct Hsmci { diff --git a/bertos/cpu/cortex-m3/drv/sd_sam3.c b/bertos/cpu/cortex-m3/drv/sd_sam3.c index 8718f075..de5a9821 100644 --- a/bertos/cpu/cortex-m3/drv/sd_sam3.c +++ b/bertos/cpu/cortex-m3/drv/sd_sam3.c @@ -60,6 +60,32 @@ #define SD_STATUS_READY BV(8) #define SD_CARD_IS_LOCKED BV(25) +#define SD_OCR_CCS BV(30) /**< SD Card Capacity Status (CCS) */ +#define SD_OCR_BUSY BV(31) /**< SD/MMC Card power up status bit (busy) */ + +#define SD_OCR_VDD_27_28 BV(15) +#define SD_OCR_VDD_28_29 BV(16) +#define SD_OCR_VDD_29_30 BV(17) +#define SD_OCR_VDD_30_31 BV(18) +#define SD_OCR_VDD_31_32 BV(19) +#define SD_OCR_VDD_32_33 BV(20) + + +#define SD_HOST_VOLTAGE_RANGE (SD_OCR_VDD_27_28 | \ + SD_OCR_VDD_28_29 | \ + SD_OCR_VDD_29_30 | \ + SD_OCR_VDD_30_31 | \ + SD_OCR_VDD_31_32 | \ + SD_OCR_VDD_32_33) + + +#define CMD8_V_RANGE_CHECK_PAT 0xAA +#define CMD8_V_RANGE_27V_36V (0x100 | CMD8_V_RANGE_CHECK_PAT) +#define CMD8_V_RANGE_LOW (0x1000 | CMD8_V_RANGE_CHECK_PAT) +#define CMD8_V_ECHO_REPLY 0xFF +#define CMD8_SUPP_V_RANGE_REPLY 0xFF00 + + #define SD_GET_ERRORS(status) ((status) & 0xFFF80000) #define SD_ADDR_TO_RCA(addr) (uint32_t)(((addr) << 16) & 0xFFFF0000) #define SD_GET_STATE(status) (uint8_t)(((status) & 0x1E00) >> 9) @@ -595,7 +621,7 @@ int sd_getStatus(Sd *sd, SdSSR *ssr, uint32_t *buf, size_t words) void sd_setHightSpeed(Sd *sd) { (void)sd; - hsmci_setSpeed(2100000, true); + hsmci_setSpeed(HSMCI_HIGH_SPEED, HSMCI_HS_MODE); } -- 2.25.1