IJFW - IchigoJamのBASICプログラムをメモリカード(MMCまたは互換カード)に保存したり読み出したりできるプログラム。メモリカードにファームウェアのファイルを置くだけで、電源ON時に自動的に書き換える機能も搭載(一応こちらがメイン)。LPC1114FN28専用。
FatfsIJFW.h
00001 #ifndef FATFS_IJFW_H 00002 #define FATFS_IJFW_H 00003 00004 #include "mbed.h" 00005 #include "diskio.h" 00006 #include "ff.h" 00007 00008 enum FileMode { 00009 MODE_WR, 00010 MODE_RO, 00011 MODE_APPEND, 00012 MODE_OVERWRITE, 00013 }; 00014 00015 class FatfsIJFW { 00016 public: 00017 00018 FatfsIJFW(SPI* _spi, DigitalOut* _cs); 00019 00020 int mount(); 00021 int open(const char* name, const FileMode mode); 00022 int close(); 00023 int remove(const char* filename); 00024 int mkdir(const char* name); 00025 int read(char* buf, const int length); 00026 int write(const char* buf, const int length); 00027 int lseek(int pos); 00028 int filesize(); 00029 void timerproc(); 00030 00031 DSTATUS disk_initialize(BYTE drv); 00032 DSTATUS disk_status(BYTE drv); 00033 DRESULT disk_read(BYTE drv, BYTE* buff, DWORD sector, UINT count); 00034 DRESULT disk_write(BYTE drv, const BYTE* buff, DWORD sector, UINT count); 00035 DRESULT disk_ioctl(BYTE drv, BYTE cmd, void* buff); 00036 00037 protected: 00038 00039 SPI* spi; 00040 DigitalOut* cs; 00041 FATFS fs; 00042 FIL file; 00043 00044 int timerCount; 00045 DSTATUS Stat; 00046 00047 int select(void); 00048 void deselect(void); 00049 int waitReady(int wait); 00050 char sendCommand(BYTE cmd, DWORD arg); 00051 int rcvDataBlock(BYTE *buff, UINT btr); 00052 int sendDataBlock(const BYTE *buff, BYTE token); 00053 00054 }; 00055 00056 #endif
Generated on Sat Jul 16 2022 19:47:26 by 1.7.2