Move some define in sam3x sd implementaion. Define sd speeds macro to clarify the...
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 6 Sep 2011 13:41:48 +0000 (13:41 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 6 Sep 2011 13:41:48 +0000 (13:41 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5034 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/cortex-m3/drv/hsmci_sam3.c
bertos/cpu/cortex-m3/drv/hsmci_sam3.h
bertos/cpu/cortex-m3/drv/sd_sam3.c

index 51b79d9cd4723b11a411cdd782c5d8f9dea28734..d09723fc146601be8a16b8a01ab61a949299e0a8 100644 (file)
@@ -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);
index 71cdd99bc19f0c43b8f5e8b6001be624a68be887..82bf668e56b555ad3a1fffb3c1a65fee6a61bd5e 100644 (file)
 
 #include <io/cm3.h>
 
-#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
 {
index 8718f0757795a030db85a37938225a2d4bcb020b..de5a9821a6bc64cc0920ab3d0dc868633e09f60e 100644 (file)
 #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);
 }