Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

9 anos atrás
9 anos atrás
9 anos atrás
9 anos atrás
9 anos atrás
9 anos atrás
9 anos atrás
9 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 W25Q128FV
  9. Micron N25Q512A
  10. Micron N25Q00AA
  11. Spansion S25FL127S
  12. SerialFlash automatically detects SPI Flash chip type and capacity to automatically handle differences between supported chips.
  13. ## Accessing Files
  14. ### Open A File
  15. SerialFlashFile file;
  16. file = SerialFlash.open("filename.bin");
  17. if (file) { // true if the file exists
  18. ### Read Data
  19. char buffer[256];
  20. file.read(buffer, 256);
  21. ### File Size & Positon
  22. file.size();
  23. file.position()
  24. file.seek(number);
  25. ### Write Data
  26. file.write(buffer, 256);
  27. 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.
  28. file.erase(); // not yet implemented
  29. Only files created for erasing can be erased. The entire file is erased to all 255 (0xFF) bytes.
  30. ## Managing Files
  31. ### Create New Files
  32. SerialFlash.create(filename, size);
  33. SerialFlash.createErasable(filename, size);
  34. 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.
  35. 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.
  36. 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.
  37. ### Directory Listing
  38. SerialFlash.opendir();
  39. SerialFlash.readdir(buffer, buflen, filelen);
  40. 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.
  41. ## Full Erase
  42. SerialFlash.erase();
  43. while (SerialFlash.ready() == false) {
  44. // wait, 30 seconds to 2 minutes for most chips
  45. }