#include <stdio.h>
#undef DIR
#include "diskio.h"
#include "ff.h"
#include "ff_compat.h"
char buffer[1024];
void main ()
{
unsigned int reset_flags;
unsigned long reset_causes;
int rv;
FATFS fso;
DIR dir_obj;
FILINFO finfo;
{
unsigned int sysrstiv;
reset_causes = 0;
reset_causes |= 1UL << (sysrstiv / 2);
}
}
cprintf(
"\nBUILD " __DATE__
" " __TIME__
"\n");
cprintf(
"FatFS Revision ID: %lu\n", (
unsigned long)_FATFS);
cprintf(
"System reset bitmask %lx; causes:\n", reset_causes);
{
int bit = 0;
while (bit < (8 * sizeof(reset_causes))) {
if (reset_causes & (1UL << bit)) {
}
++bit;
}
}
}
}
}
}
cprintf(
"Set core voltage gets %d\n", rv);
#if (FATFS_IS_PRE_R0_10 - 0)
rv = f_mount(0, &fso);
#else
rv = f_mount(&fso, "", 1);
#endif
if (FR_OK == rv) {
rv = f_opendir(&dir_obj, "/");
}
while (FR_OK == rv) {
rv = f_readdir(&dir_obj, &finfo);
if (FR_OK != rv) {
break;
}
if (0 == finfo.fname[0]) {
break;
}
cprintf(
"%s %lu %u %u %#x\n", finfo.fname, finfo.fsize, finfo.fdate, finfo.ftime, finfo.fattrib);
}
{
FIL fil_obj;
rv = f_open(&fil_obj, "0:BOOT.LOG", FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
cprintf(
"Boot log open returned %d\n", rv);
if (FR_OK == rv) {
UINT nbytes = -1;
rv = f_read(&fil_obj, buffer, sizeof(buffer), &nbytes);
cprintf(
"Read boot log %u got %d with %u read\n",
(unsigned int)sizeof(buffer), rv, nbytes);
if (0 == rv) {
buffer[nbytes] = 0;
}
rv = f_lseek(&fil_obj, f_size(&fil_obj));
cprintf(
"Seek to end got %d\n", rv);
if (FR_OK == rv) {
int nb = snprintf(buffer, sizeof(buffer), "Booted build " __DATE__ " " __TIME__ "\n");
UINT nw;
rv = f_write(&fil_obj, buffer, nb, &nw);
cprintf(
"write %u got %d nw %u\n", nb, rv, nw);
}
f_close(&fil_obj);
}
}
#if (FATFS_IS_PRE_R0_10 - 0)
f_mount(0, NULL);
#else
f_mount(NULL, NULL, 1);
#endif
}