fileops.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* sd2snes - SD card based universal cartridge for the SNES
  2. Copyright (C) 2009-2010 Maximilian Rehkopf <otakon@gmx.net>
  3. AVR firmware portion
  4. Inspired by and based on code from sd2iec, written by Ingo Korb et al.
  5. See sdcard.c|h, config.h.
  6. FAT file system access based on code by ChaN, Jim Brain, Ingo Korb,
  7. see ff.c|h.
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; version 2 of the License only.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. fileops.h: simple file access functions
  19. */
  20. #ifndef FILEOPS_H
  21. #define FILEOPS_H
  22. #include <arm/NXP/LPC17xx/LPC17xx.h>
  23. #include "ff.h"
  24. enum filestates { FILE_OK=0, FILE_ERR, FILE_EOF };
  25. #define GCC_ALIGN_WORKAROUND __attribute__ ((aligned(4)))
  26. BYTE file_buf[512] GCC_ALIGN_WORKAROUND;
  27. FATFS fatfs;
  28. FIL file_handle;
  29. FRESULT file_res;
  30. uint8_t file_lfn[258];
  31. uint16_t file_block_off, file_block_max;
  32. enum filestates file_status;
  33. void file_init(void);
  34. void file_open(uint8_t* filename, BYTE flags);
  35. void file_open_by_filinfo(FILINFO* fno);
  36. void file_close(void);
  37. UINT file_read(void);
  38. UINT file_write(void);
  39. UINT file_readblock(void* buf, uint32_t addr, uint16_t size);
  40. UINT file_writeblock(void* buf, uint32_t addr, uint16_t size);
  41. uint8_t file_getc(void);
  42. #endif