SD native mode bitbanging (4-bit). No write support yet

This commit is contained in:
ikari
2010-11-22 00:46:56 +01:00
parent 254b602529
commit c5ff79a9d2
21 changed files with 1780 additions and 486 deletions

View File

@@ -33,7 +33,6 @@
WCHAR ff_convert(WCHAR w, UINT dir) {
return w;
}*/
void file_init() {
file_res=f_mount(0, &fatfs);
}
@@ -44,6 +43,9 @@ void file_open_by_filinfo(FILINFO* fno) {
void file_open(uint8_t* filename, BYTE flags) {
file_res = f_open(&file_handle, (TCHAR*)filename, flags);
file_block_off = sizeof(file_buf);
file_block_max = sizeof(file_buf);
file_status = file_res ? FILE_ERR : FILE_OK;
}
void file_close() {
@@ -79,3 +81,12 @@ UINT file_writeblock(void* buf, uint32_t addr, uint16_t size) {
file_res = f_write(&file_handle, buf, size, &bytes_written);
return bytes_written;
}
uint8_t file_getc() {
if(file_block_off == file_block_max) {
file_block_max = file_read();
if(file_block_max == 0) file_status = FILE_EOF;
file_block_off = 0;
}
return file_buf[file_block_off++];
}