Driver for AT25SF041 SPI Flash Memory, just basic operations
Embed:
(wiki syntax)
Show/hide line numbers
at25sf041.h
00001 #ifndef AT25SF041_H 00002 #define AT25SF041_H 00003 00004 #include "mbed.h" 00005 00006 #include "at25sf041_commands.h" 00007 00008 #define spi_transfer(data) _spi.write(data) 00009 00010 #define DF_CS_inactive _cs = 1 00011 #define DF_CS_active _cs = 0 00012 00013 #define READY_BUSY 0x01 00014 #define WRITE_ENABLE_LATCH 0x02 00015 00016 00017 class AT25SF041 00018 { 00019 public: 00020 00021 struct ID 00022 { 00023 uint8_t manufacturer; /**< Manufacturer id **/ 00024 uint8_t device[2]; /**< Device id **/ 00025 }; 00026 00027 public: 00028 /** CTOR **/ 00029 AT25SF041(PinName mosi, PinName miso, PinName sclk, PinName cs); 00030 AT25SF041(SPI &spi, PinName cs); 00031 /** DTOR **/ 00032 ~AT25SF041(); 00033 00034 /** Setup SPI and pinout **/ 00035 void Init(); 00036 00037 uint8_t ReadStatusRegister(int n); 00038 void WriteEnable(); 00039 void WriteDisable(); 00040 void ReadManufacturerAndDeviceID(struct AT25SF041::ID *id); 00041 void ReadArray(uint32_t address, uint32_t length, uint8_t *buffer); 00042 void WriteArray(uint32_t address, uint32_t length, uint8_t *buffer); 00043 void ChipErase(); 00044 void EndAndWait(); 00045 00046 private: 00047 SPI _spi; 00048 DigitalOut _cs; 00049 }; 00050 00051 #endif /* AT25SF041_H */
Generated on Fri Jul 15 2022 06:03:34 by 1.7.2