forked from ROMEO/obsw
included xilinx FAT and SD code
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user