included xilinx FAT and SD code

This commit is contained in:
2024-11-27 13:02:42 +01:00
parent 164b8ed6c2
commit a25c40b1d8
4 changed files with 46 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include "xscugic.h"
#include "xscutimer.h"
#include "xuartps_hw.h"
#include "ff.h"
/*
* Configure the hardware as necessary to run this demo.
@ -47,6 +48,8 @@ XScuGic xInterruptController;
extern SemaphoreHandle_t malloc_mutex;
FATFS fatfs;
int get_descriptor_rw() {
return 1;
}
@ -61,7 +64,33 @@ int main(void) {
/* Configure the hardware ready to run. */
prvSetupHardware();
mission();
FRESULT rc;
FIL fil;
TCHAR *path = "0:/"; /* Logical drive number is 0 */
uint8_t buffer[100];
buffer[0] = 'a';
buffer[1] = 'b';
buffer[2] = 'c';
buffer[3] = 'd';
UINT read_size;
/* Register volume work area, initialize device */
rc = f_mount(&fatfs, path, 0);
xil_printf("mount: %i\n", rc);
rc = f_open(&fil, "file.txt", FA_READ | FA_WRITE);
xil_printf("open: %i\n", rc);
rc = f_write(&fil, buffer, 1, &read_size );
xil_printf("write: %i\n", rc);
f_lseek(&fil, 0);
rc = f_read(&fil, buffer, sizeof(buffer), &read_size );
xil_printf("read: %i: ", rc);
for (int i = 0; i < read_size; i++) {
xil_printf("%c (%02x) ", buffer[i], buffer[i]);
}
xil_printf("\n");
f_close(&fil);
mission();
}
static void prvSetupHardware(void) {

View File

@ -3,8 +3,10 @@ add_subdirectory(libsrc/gpiops)
add_subdirectory(libsrc/scugic)
add_subdirectory(libsrc/scutimer)
add_subdirectory(libsrc/scuwdt)
add_subdirectory(libsrc/sdps)
add_subdirectory(libsrc/standalone)
add_subdirectory(libsrc/uartps)
add_subdirectory(libsrc/xilffs)
target_include_directories(
bsp PUBLIC include)

View File

@ -0,0 +1,10 @@
target_sources(bsp PRIVATE
src/xsdps_card.c
src/xsdps_g.c
src/xsdps_host.c
src/xsdps_options.c
src/xsdps_sinit.c
src/xsdps.c
)

View File

@ -0,0 +1,4 @@
target_sources(bsp PRIVATE
src/ff.c
src/diskio.c
)