From 04d0ba6187c4a66552afe3f47b2fe21c3721895d Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 9 Jun 2020 17:58:43 +0200 Subject: [PATCH] software/liblitesdcard/sdcard: add FatFs disk functions. --- litex/soc/software/liblitesdcard/sdcard.c | 41 ++++++++++++++++++----- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/litex/soc/software/liblitesdcard/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c index fac22e89..92edf8e6 100644 --- a/litex/soc/software/liblitesdcard/sdcard.c +++ b/litex/soc/software/liblitesdcard/sdcard.c @@ -12,6 +12,8 @@ #include #include +#include "fat/ff.h" +#include "fat/diskio.h" #include "sdcard.h" #define SDCARD_DEBUG @@ -560,9 +562,9 @@ int sdcard_sddatareader_wait(void) { /* user */ int sdcard_init(void) { - unsigned short rca; + unsigned short rca; - /* initialize SD driver parameters */ + /* initialize SD driver parameters */ sdcore_cmdtimeout_write(1<<19); sdcore_datatimeout_write(1<<19); @@ -713,15 +715,36 @@ int sdcard_test(unsigned int blocks) return 0; } -uint8_t sdcard_read_block(uint32_t addr, uint8_t *buf) { - int n; +/*-----------------------------------------------------------------------*/ +/* SDCard FatFs disk functions */ +/*-----------------------------------------------------------------------*/ - // FIXME: handle errors, avoid recopy. +static DSTATUS spisdcardstatus = STA_NOINIT; - sdcard_read(addr, 1); - for(n=0; n