Driver for AT25SF041 SPI Flash Memory, just basic operations

Revision:
0:9225e2aef6b3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/at25sf041.h	Thu Sep 17 19:46:19 2015 +0000
@@ -0,0 +1,51 @@
+#ifndef AT25SF041_H
+#define AT25SF041_H
+
+#include "mbed.h"
+
+#include "at25sf041_commands.h"
+
+#define spi_transfer(data) _spi.write(data)
+
+#define DF_CS_inactive _cs = 1
+#define DF_CS_active _cs = 0
+
+#define READY_BUSY 0x01
+#define WRITE_ENABLE_LATCH 0x02
+
+
+class AT25SF041
+{
+    public:
+
+        struct ID
+        {
+            uint8_t manufacturer;       /**< Manufacturer id                           **/
+            uint8_t device[2];          /**< Device id                                 **/
+        };
+
+    public:
+        /** CTOR **/
+        AT25SF041(PinName mosi, PinName miso, PinName sclk, PinName cs);
+        AT25SF041(SPI &spi, PinName cs);
+        /** DTOR **/
+        ~AT25SF041();
+
+        /** Setup SPI and pinout **/
+        void Init();
+
+        uint8_t ReadStatusRegister(int n);
+        void WriteEnable();
+        void WriteDisable();
+        void ReadManufacturerAndDeviceID(struct AT25SF041::ID *id);
+        void ReadArray(uint32_t address, uint32_t length, uint8_t *buffer);
+        void WriteArray(uint32_t address, uint32_t length, uint8_t *buffer);
+        void ChipErase();
+        void EndAndWait();
+
+    private:
+        SPI _spi;
+        DigitalOut _cs;
+};
+
+#endif /* AT25SF041_H */