You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.3KB

9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
9 vuotta sitten
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # SerialFlash
  2. SerialFlash provides low-latency, high performance access to SPI Flash memory with a filesystem-like interface. 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 W25Q128FV
  10. Winbond W25Q256FV
  11. Micron N25Q512A
  12. Micron N25Q00AA
  13. Spansion S25FL127S
  14. Spansion S25FL256S
  15. Spansion S25FL512S
  16. SerialFlash automatically detects SPI Flash chip type and capacity to automatically handle differences between supported chips.
  17. ## Accessing Files
  18. ### Open A File
  19. SerialFlashFile file;
  20. file = SerialFlash.open("filename.bin");
  21. if (file) { // true if the file exists
  22. ### Read Data
  23. char buffer[256];
  24. file.read(buffer, 256);
  25. ### File Size & Positon
  26. file.size();
  27. file.position()
  28. file.seek(number);
  29. ### Write Data
  30. file.write(buffer, 256);
  31. Several limitations apply to writing. Only previously unwritten portions of the file may be written. Files sizes can never change. Writes may only be done within the file's original size.
  32. file.erase(); // not yet implemented
  33. Only files created for erasing can be erased. The entire file is erased to all 255 (0xFF) bytes.
  34. ## Managing Files
  35. ### Create New Files
  36. SerialFlash.create(filename, size);
  37. SerialFlash.createErasable(filename, size);
  38. 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.
  39. 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.
  40. 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.
  41. ### Delete A File
  42. SerialFlash.remove(filename);
  43. 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.
  44. ### Check If A File Exists (without opening)
  45. SerialFlash.exists(filename);
  46. ### Directory Listing
  47. SerialFlash.opendir();
  48. SerialFlash.readdir(buffer, buflen, filelen);
  49. 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.
  50. ## Full Erase
  51. SerialFlash.erase();
  52. while (SerialFlash.ready() == false) {
  53. // wait, 30 seconds to 2 minutes for most chips
  54. }