Adafruit SPI FRAM Library
Adafruit_FRAM_SPI.h
Go to the documentation of this file.
1 
21 #ifndef _ADAFRUIT_FRAM_SPI_H_
22 #define _ADAFRUIT_FRAM_SPI_H_
23 
24 #include <Adafruit_SPIDevice.h>
25 #include <Arduino.h>
26 #include <SPI.h>
27 
29 typedef enum opcodes_e {
30  OPCODE_WREN = 0b0110, /* Write Enable Latch */
31  OPCODE_WRDI = 0b0100, /* Reset Write Enable Latch */
32  OPCODE_RDSR = 0b0101, /* Read Status Register */
33  OPCODE_WRSR = 0b0001, /* Write Status Register */
34  OPCODE_READ = 0b0011, /* Read Memory */
35  OPCODE_WRITE = 0b0010, /* Write Memory */
36  OPCODE_RDID = 0b10011111 /* Read Device ID */
37 } opcodes_t;
38 
44 public:
45  Adafruit_FRAM_SPI(int8_t cs, SPIClass *theSPI = &SPI,
46  uint32_t freq = 1000000);
47  Adafruit_FRAM_SPI(int8_t clk, int8_t miso, int8_t mosi, int8_t cs);
48 
49  bool begin(uint8_t nAddressSizeBytes = 2);
50  bool writeEnable(bool enable);
51  bool write8(uint32_t addr, uint8_t value);
52  bool write(uint32_t addr, const uint8_t *values, size_t count);
53  uint8_t read8(uint32_t addr);
54  bool read(uint32_t addr, uint8_t *values, size_t count);
55  bool getDeviceID(uint8_t *manufacturerID, uint16_t *productID);
56  uint8_t getStatusRegister(void);
57  bool setStatusRegister(uint8_t value);
58  void setAddressSize(uint8_t nAddressSize);
59 
60 private:
61  Adafruit_SPIDevice *spi_dev = NULL;
62  uint8_t _nAddressSizeBytes;
63 };
64 
65 #endif
bool write8(uint32_t addr, uint8_t value)
Writes a byte at the specific FRAM address.
Definition: Adafruit_FRAM_SPI.cpp:185
bool write(uint32_t addr, const uint8_t *values, size_t count)
Writes count bytes starting at the specific FRAM address.
Definition: Adafruit_FRAM_SPI.cpp:211
bool writeEnable(bool enable)
Enables or disables writing to the SPI flash.
Definition: Adafruit_FRAM_SPI.cpp:166
bool getDeviceID(uint8_t *manufacturerID, uint16_t *productID)
Reads the Manufacturer ID and the Product ID from the IC.
Definition: Adafruit_FRAM_SPI.cpp:285
uint8_t read8(uint32_t addr)
Reads an 8 bit value from the specified FRAM address.
Definition: Adafruit_FRAM_SPI.cpp:233
bool setStatusRegister(uint8_t value)
Sets the status register.
Definition: Adafruit_FRAM_SPI.cpp:329
bool begin(uint8_t nAddressSizeBytes=2)
Initializes SPI and configures the chip (call this function before doing anything else) ...
Definition: Adafruit_FRAM_SPI.cpp:130
void setAddressSize(uint8_t nAddressSize)
Sets adress size to provided value.
Definition: Adafruit_FRAM_SPI.cpp:343
Adafruit_FRAM_SPI(int8_t cs, SPIClass *theSPI=&SPI, uint32_t freq=1000000)
Instantiates a new SPI FRAM class using hardware SPI.
Definition: Adafruit_FRAM_SPI.cpp:92
Class that stores state and functions for interacting with FRAM SPI.
Definition: Adafruit_FRAM_SPI.h:43
uint8_t getStatusRegister(void)
Reads the status register.
Definition: Adafruit_FRAM_SPI.cpp:313
enum opcodes_e opcodes_t
opcodes_e
Definition: Adafruit_FRAM_SPI.h:29
bool read(uint32_t addr, uint8_t *values, size_t count)
Read count bytes starting at the specific FRAM address.
Definition: Adafruit_FRAM_SPI.cpp:260