comparison fatfs_sd.c @ 51:590886732da9

Return correct error defines.
author Daniel O'Connor <darius@dons.net.au>
date Sun, 07 Apr 2013 22:31:05 +0930
parents d7207a9d3c3b
children 9521be9b391e
comparison
equal deleted inserted replaced
50:d7207a9d3c3b 51:590886732da9
87 SD_Error err; 87 SD_Error err;
88 88
89 DEBUG("disk_read(%d, 0x%08x, %d, %d)\n", pdrv, buff, sector, count); 89 DEBUG("disk_read(%d, 0x%08x, %d, %d)\n", pdrv, buff, sector, count);
90 90
91 if (pdrv != 0) 91 if (pdrv != 0)
92 return STA_NOINIT; 92 return RES_ERROR;
93 93
94 if (count == 1) 94 if (count == 1)
95 err = SD_ReadBlock(buff, sector * SD_BLOCK_SIZE, SD_BLOCK_SIZE); 95 err = SD_ReadBlock(buff, sector * SD_BLOCK_SIZE, SD_BLOCK_SIZE);
96 else 96 else
97 err = SD_ReadMultiBlocks(buff, sector * SD_BLOCK_SIZE, SD_BLOCK_SIZE, count); 97 err = SD_ReadMultiBlocks(buff, sector * SD_BLOCK_SIZE, SD_BLOCK_SIZE, count);
98 98
99 #ifdef SD_DMA_MODE 99 #ifdef SD_DMA_MODE
100 if ((err = SD_WaitReadOperation()) != SD_OK) { 100 if ((err = SD_WaitReadOperation()) != SD_OK) {
101 printf("Wait returned %s\n", sderr2str(err)); 101 printf("Wait returned %s\n", sderr2str(err));
102 goto read_exit; 102 return RES_ERROR;
103 } 103 }
104 #endif 104 #endif
105 if (err != SD_OK) { 105 if (err != SD_OK) {
106 printf("Read failed: %s\n", sderr2str(err)); 106 printf("Read failed: %s\n", sderr2str(err));
107 return STA_NOINIT; 107 return RES_ERROR;
108 } 108 }
109 109
110 while(SD_GetStatus() != SD_TRANSFER_OK) 110 while(SD_GetStatus() != SD_TRANSFER_OK)
111 ; 111 ;
112 112
117 disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, BYTE count) { 117 disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, BYTE count) {
118 SD_Error err; 118 SD_Error err;
119 119
120 DEBUG("disk_write(%d, 0x%08x, %d, %d)\n", pdrv, buff, sector, count); 120 DEBUG("disk_write(%d, 0x%08x, %d, %d)\n", pdrv, buff, sector, count);
121 if (pdrv != 0) 121 if (pdrv != 0)
122 return RES_NOTRDY; 122 return RES_ERROR;
123 123
124 if (count == 1) 124 if (count == 1)
125 err = SD_WriteBlock(buff, sector * SD_BLOCK_SIZE, SD_BLOCK_SIZE); 125 err = SD_WriteBlock(buff, sector * SD_BLOCK_SIZE, SD_BLOCK_SIZE);
126 else 126 else
127 err = SD_WriteMultiBlocks(buff, sector * SD_BLOCK_SIZE, SD_BLOCK_SIZE, count); 127 err = SD_WriteMultiBlocks(buff, sector * SD_BLOCK_SIZE, SD_BLOCK_SIZE, count);
128 128
129 #ifdef SD_DMA_MODE 129 #ifdef SD_DMA_MODE
130 if ((err = SD_WaitReadOperation()) != SD_OK) { 130 if ((err = SD_WaitReadOperation()) != SD_OK) {
131 printf("Wait returned %s\n", sderr2str(err)); 131 printf("Wait returned %s\n", sderr2str(err));
132 goto read_exit; 132 return RES_ERROR;
133 } 133 }
134 #endif 134 #endif
135 if (err != SD_OK) { 135 if (err != SD_OK) {
136 printf("Write failed: %s\n", sderr2str(err)); 136 printf("Write failed: %s\n", sderr2str(err));
137 return RES_ERROR; 137 return RES_ERROR;