Compare commits
2 Commits
a2256acd94
...
e616e22dd7
Author | SHA1 | Date |
---|---|---|
Mario Hüttel | e616e22dd7 | |
Mario Hüttel | bea543269e |
|
@ -373,9 +373,12 @@ static void sdio_init_hw()
|
|||
static int sdio_send_read_block_cmd17(uint32_t addr)
|
||||
{
|
||||
uint32_t response;
|
||||
|
||||
int retry;
|
||||
int ret;
|
||||
|
||||
sdio_send_cmd(17, addr, SHORT_ANS);
|
||||
return sdio_get_response(17, SHORT_ANS, &response);
|
||||
ret = sdio_get_response(17, SHORT_ANS, &response);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int sdio_send_all_send_cid_cmd2()
|
||||
|
@ -605,6 +608,7 @@ DRESULT sdio_disk_read(BYTE *buff, DWORD sector, UINT count){
|
|||
uint32_t sdio_status;
|
||||
uint32_t fifo;
|
||||
uint32_t counter;
|
||||
union sdio_status_conv status;
|
||||
|
||||
addr = (card_info.type == SD_V2_HC ? (sector) : (sector*512));
|
||||
for (; count > 0; count--) {
|
||||
|
@ -619,7 +623,13 @@ DRESULT sdio_disk_read(BYTE *buff, DWORD sector, UINT count){
|
|||
// DMASTREAM->CR = DMAP2M | DMA_SxCR_PL_1 | DMA_SxCR_PL_1;
|
||||
// DMASTREAM->CR |= DMA_SxCR_EN;
|
||||
|
||||
|
||||
do {
|
||||
sdio_check_status_register_cmd13(card_info.rca, &status.value);
|
||||
} while (status.statusstruct.CURRENT_STATE != CURRENT_STATE_TRAN);
|
||||
|
||||
SDIO->DLEN = (1 << BLOCKSIZE);
|
||||
SDIO->DTIMER = DTIMEOUT;
|
||||
|
||||
SDIO->ICR = SDIO_ICR_CCRCFAILC | SDIO_ICR_DCRCFAILC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_DTIMEOUTC |
|
||||
SDIO_ICR_TXUNDERRC | SDIO_ICR_RXOVERRC | SDIO_ICR_CMDRENDC | SDIO_ICR_CMDSENTC | SDIO_ICR_DATAENDC |
|
||||
|
@ -704,16 +714,6 @@ DRESULT sdio_disk_write(const BYTE *buff, DWORD sector, UINT count)
|
|||
addr = (card_info.type == SD_V2_HC ? (sector) : (sector * 512));
|
||||
|
||||
while (count) {
|
||||
do {
|
||||
sdio_check_status_register_cmd13(card_info.rca, &status.value);
|
||||
} while (status.statusstruct.CURRENT_STATE == CURRENT_STATE_PRG ||
|
||||
status.statusstruct.CURRENT_STATE == CURRENT_STATE_RCV);
|
||||
|
||||
if (status.statusstruct.CURRENT_STATE == CURRENT_STATE_STBY) {
|
||||
if (sdio_send_select_card_cmd7(card_info.rca))
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
do {
|
||||
sdio_check_status_register_cmd13(card_info.rca, &status.value);
|
||||
} while (status.statusstruct.READY_FOR_DATA != 1);
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
//Initial Transfer CLK (ca. 400kHz)
|
||||
#define INITCLK 130 //120
|
||||
//Working CLK (Maximum)
|
||||
#define WORKCLK 50 //0
|
||||
#define WORKCLK 8 //0
|
||||
//Data Timeout in CLK Cycles
|
||||
#define DTIMEOUT 0x3000 //150
|
||||
#define DTIMEOUT 0x8000 //150
|
||||
//DMA Stream used for TX and RX DMA2 Stream 3 or 6 possible
|
||||
// Currently not used due to possible misalignment of the data buffer.
|
||||
//#define DMASTREAM DMA2_Stream6
|
||||
|
|
33
main.c
33
main.c
|
@ -22,11 +22,15 @@ volatile uint32_t sdio_wait;
|
|||
|
||||
int initreq = 0xFF;
|
||||
|
||||
int main() {
|
||||
char buff[1024];
|
||||
//const char *write_string = "This is a write test. Okay... Writing seems to work. Let's close the file\n";
|
||||
|
||||
char buff[8192*6];
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
char *name;
|
||||
FILINFO fno;
|
||||
char *write_string = "This is a write test. Okay... Writing seems to work. Let's close the file\n";
|
||||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
|
||||
__DSB();
|
||||
|
@ -41,24 +45,17 @@ int main() {
|
|||
initreq = f_mount(&SDfs, "0:/", 1);
|
||||
while(initreq);
|
||||
|
||||
initreq = f_opendir(&root, "/");
|
||||
if (initreq == FR_OK) {
|
||||
if (!f_readdir(&root, &fno))
|
||||
{
|
||||
name = fno.fname;
|
||||
initreq = f_open(&file, name, FA_READ);
|
||||
if (initreq == FR_OK) {
|
||||
f_gets(buff, sizeof(buff), &file);
|
||||
printf("%s:\r\n%s\r\n",name, buff);
|
||||
f_close(&file);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 8192*6; i++)
|
||||
buff[i] = 'A';
|
||||
|
||||
initreq = f_open(&file, "foo.txt", FA_OPEN_APPEND | FA_WRITE);
|
||||
if (initreq == FR_OK) {
|
||||
initreq = f_write(&file, write_string, strlen(write_string), NULL);
|
||||
for (i = 0; i < 100; i++) {
|
||||
initreq = f_write(&file, buff, 8192*6, NULL);
|
||||
if (initreq) {
|
||||
initreq++;
|
||||
}
|
||||
}
|
||||
initreq = f_close(&file);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue