Prusa MINI Firmware overview
fs_custom.c File Reference
#include "ff.h"
#include "lwip/apps/fs.h"

Functions

int fs_open_custom (struct fs_file *file, const char *name)
 
void fs_close_custom (struct fs_file *file)
 
int fs_read_custom (struct fs_file *file, char *buffer, int count)
 

Variables

static FIL webFile
 

Function Documentation

◆ fs_open_custom()

int fs_open_custom ( struct fs_file file,
const char *  name 
)
13  {
14  //FRESULT res;
15 
16  // res = f_opendir(&dir, "/");
17  // if (res != FR_OK) {
18  // return 0;
19  // }
20 
21  if (f_open(&webFile, (const TCHAR *)name, FA_READ) != FR_OK) {
22  return 0;
23  }
24  file->data = NULL;
25  FSIZE_t fileSize = f_size(&webFile);
26  file->len = fileSize;
27  file->index = 0;
28  file->pextension = NULL;
29  return 1;
30 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fs_close_custom()

void fs_close_custom ( struct fs_file file)
32  {
33  f_close(&webFile);
34  // f_closedir(&dir);
35 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fs_read_custom()

int fs_read_custom ( struct fs_file file,
char *  buffer,
int  count 
)
37  {
38 
39  FRESULT res;
40  uint32_t bytesRead = 0;
41 
42  if (f_eof(&webFile)) {
43  return FS_READ_EOF;
44  }
45  //char testbuff[1000];
46  res = f_read(&webFile, buffer, count, (void *)&bytesRead);
47  //memcpy(buffer, testbuff, bytesRead);
48  file->index += bytesRead;
49  if (res != FR_OK) {
50  return 0;
51  }
52 
53  return bytesRead;
54 }
Here is the call graph for this function:

Variable Documentation

◆ webFile

FIL webFile
static
fs_file::pextension
void * pextension
Definition: fs.h:60
TCHAR
char TCHAR
Definition: ff.h:62
fs_file::len
int len
Definition: fs.h:58
FS_READ_EOF
#define FS_READ_EOF
Definition: fs.h:42
f_open
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
Definition: ff.c:3296
webFile
static FIL webFile
Definition: fs_custom.c:10
FSIZE_t
DWORD FSIZE_t
Definition: ff.h:78
NULL
#define NULL
Definition: usbd_def.h:53
FA_READ
#define FA_READ
Definition: ff.h:326
f_size
#define f_size(fp)
Definition: ff.h:280
fs_file::index
int index
Definition: fs.h:59
netif::name
char name[2]
Definition: netif.h:307
fs_file::data
const char * data
Definition: fs.h:57
f_eof
#define f_eof(fp)
Definition: ff.h:277
FRESULT
FRESULT
Definition: ff.h:214
FR_OK
Definition: ff.h:215
f_read
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
Definition: ff.c:3499
f_close
FRESULT f_close(FIL *fp)
Definition: ff.c:3801