| 34 | class SerialFlashFile; |
| 35 | |
| 36 | class SerialFlashChip |
| 37 | { |
| 38 | public: |
| 39 | static bool begin(SPIClass& device, uint8_t pin = 6); |
| 40 | static bool begin(uint8_t pin = 6); |
| 41 | static uint32_t capacity(const uint8_t *id); |
| 42 | static uint32_t blockSize(); |
| 43 | static void sleep(); |
| 44 | static void wakeup(); |
| 45 | static void readID(uint8_t *buf); |
| 46 | static void readSerialNumber(uint8_t *buf); |
| 47 | static void read(uint32_t addr, void *buf, uint32_t len); |
| 48 | static bool ready(); |
| 49 | static void wait(); |
| 50 | static void write(uint32_t addr, const void *buf, uint32_t len); |
| 51 | static void eraseAll(); |
| 52 | static void eraseBlock(uint32_t addr); |
| 53 | |
| 54 | static SerialFlashFile open(const char *filename); |
| 55 | static bool create(const char *filename, uint32_t length, uint32_t align = 0); |
| 56 | static bool createErasable(const char *filename, uint32_t length) { |
| 57 | return create(filename, length, blockSize()); |
| 58 | } |
| 59 | static bool exists(const char *filename); |
| 60 | static bool remove(const char *filename); |
| 61 | static bool remove(SerialFlashFile &file); |
| 62 | static void opendir() { dirindex = 0; } |
| 63 | static bool readdir(char *filename, uint32_t strsize, uint32_t &filesize); |
| 64 | private: |
| 65 | static uint16_t dirindex; // current position for readdir() |
| 66 | static uint8_t flags; // chip features |
| 67 | static uint8_t busy; // 0 = ready |
| 68 | // 1 = suspendable program operation |
| 69 | // 2 = suspendable erase operation |
| 70 | // 3 = busy for realz!! |
| 71 | }; |
| 72 | |
| 73 | extern SerialFlashChip SerialFlash; |
| 74 |
nothing calls this directly
no outgoing calls
no test coverage detected