選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # SerialFlash
  2. SerialFlash provides low-latency, high performance access to SPI Flash memory with a filesystem-like interface for use with Arduino compatible boards. Familiar file-based functions, similar to the SD library, are used to access data.
  3. In-progress file write and erase operations do NOT block read access on other files. SerialFlash automatically allocates files with Flash page and sector awareness, and supports suspending in-progress write and erase operations, to minimize read latency even while the Flash memory is "busy" writing data.
  4. Performance oriented design does impose some usage limitations. Files are created with a fixed size which can never change or grow. Once created, files can not be renamed or deleted (except for erasing the entire chip). Files begin with all bytes erased (255). Each byte may be written only once. Files created as erasable may be fully erased, to allow new data to be written. Best performance is achieved by writing in 256 byte chunks, though individual bytes may be written.
  5. ## Hardware Compatibility
  6. ![W25Q128FV Chip](doc/w25q128fv.jpg)
  7. These chips have been tested with SerialFlash:
  8. Winbond W25Q80BV (http://www.adafruit.com/product/1564)
  9. Winbond W25Q64FV
  10. Winbond W25Q128FV
  11. Winbond W25Q256FV
  12. Micron N25Q512A
  13. Micron N25Q00AA
  14. Spansion S25FL127S
  15. Spansion S25FL256S
  16. Spansion S25FL512S
  17. SerialFlash automatically detects SPI Flash chip type and capacity to automatically handle differences between supported chips.
  18. ## Accessing Files
  19. ### Open A File
  20. SerialFlashFile file;
  21. file = SerialFlash.open("filename.bin");
  22. if (file) { // true if the file exists
  23. ### Read Data
  24. char buffer[256];
  25. file.read(buffer, 256);
  26. ### File Size & Positon
  27. file.size();
  28. file.position()
  29. file.seek(number);
  30. ### Write Data
  31. file.write(buffer, 256);
  32. Several limitations apply to writing. Only previously unwritten portions of the file may be written. File sizes can never change. Writes may only be done within the file's original size.
  33. ### Erase Data
  34. file.erase();
  35. Only files created for erasing can be erased. The entire file is erased to all 255 (0xFF) bytes, which allows the file to be written with new data.
  36. ## Managing Files
  37. ### Create New Files
  38. SerialFlash.create(filename, size);
  39. SerialFlash.createErasable(filename, size);
  40. New files must be created using these funtions. Each returns true if the file is successfully created, or false if not enough space is available.
  41. Once created, files can never be renamed or deleted. The file's size can never change. Writing additional data can NOT grow the size of file.
  42. Files created for erasing automatically increase in size to the nearest number of erasable blocks, resulting in a file that may be 4K to 128K larger than requested.
  43. ### Delete A File
  44. SerialFlash.remove(filename);
  45. The actual space used by the file is not reclaimed. However, a new file with this name may be created after the original is deleted.
  46. ### Check If A File Exists (without opening)
  47. SerialFlash.exists(filename);
  48. ### Directory Listing
  49. SerialFlash.opendir();
  50. SerialFlash.readdir(buffer, buflen, filelen);
  51. A list of files stored in the Flash can be accessed with readdir(), which returns true for each file, or false to indicate no more files.
  52. ## Full Erase
  53. SerialFlash.erase();
  54. while (SerialFlash.ready() == false) {
  55. // wait, 30 seconds to 2 minutes for most chips
  56. }