Skip to content

Commit

Permalink
added Fujitsu MB85RS4MT FRAM; added sleep mode
Browse files Browse the repository at this point in the history
  • Loading branch information
FUEL4EP committed Mar 26, 2024
1 parent 6615844 commit 3b1934e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
37 changes: 37 additions & 0 deletions Adafruit_FRAM_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const struct {
{0x04, 0x2503, 32 * 1024UL}, // MB85RS256TY
{0x04, 0x2703, 128 * 1024UL}, // MB85RS1MT
{0x04, 0x4803, 256 * 1024UL}, // MB85RS2MTA
{0x04, 0x2803, 256 * 1024UL}, // MB85RS2MT
{0x04, 0x4903, 512 * 1024UL}, // MB85RS4MT

// Cypress
Expand Down Expand Up @@ -343,3 +344,39 @@ bool Adafruit_FRAM_SPI::setStatusRegister(uint8_t value) {
void Adafruit_FRAM_SPI::setAddressSize(uint8_t nAddressSize) {
_nAddressSizeBytes = nAddressSize;
}

/*!
* @brief Enters the FRAM's low power sleep mode
* @return true if successful
*/
// WARNING: this method has not yet been validated
bool Adafruit_FRAM_SPI::enter_low_power_mode(void) {
uint8_t cmd;

cmd = OPCODE_SLEEP;

return spi_dev->write(&cmd, 1);
}


/*!
* @brief exits the FRAM's low power sleep mode
* @return true if successful
*/
// WARNING: this method has not yet been validated
bool Adafruit_FRAM_SPI::exit_low_power_mode(void) {
uint8_t cmd;

// Returning to an normal operation from the SLEEP mode is carried out after tREC (Max 400 μs)
// time from the falling edge of CS
spi_dev->beginTransactionWithAssertingCS();
delayMicroseconds(300);
// It is possible to return CS to H level before tREC time. However, it
// is prohibited to bring down CS to L level again during tREC period.
spi_dev->endTransactionWithDeassertingCS();
delayMicroseconds(100);

return spi_dev->write(&cmd, 1);
}


18 changes: 11 additions & 7 deletions Adafruit_FRAM_SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*
* BSD license, all text above must be included in any redistribution
*/

#ifndef _ADAFRUIT_FRAM_SPI_H_
#define _ADAFRUIT_FRAM_SPI_H_

Expand All @@ -27,13 +28,14 @@

/** Operation Codes **/
typedef enum opcodes_e {
OPCODE_WREN = 0b0110, /* Write Enable Latch */
OPCODE_WRDI = 0b0100, /* Reset Write Enable Latch */
OPCODE_RDSR = 0b0101, /* Read Status Register */
OPCODE_WRSR = 0b0001, /* Write Status Register */
OPCODE_READ = 0b0011, /* Read Memory */
OPCODE_WRITE = 0b0010, /* Write Memory */
OPCODE_RDID = 0b10011111 /* Read Device ID */
OPCODE_WREN = 0b0110, /* Write Enable Latch */
OPCODE_WRDI = 0b0100, /* Reset Write Enable Latch */
OPCODE_RDSR = 0b0101, /* Read Status Register */
OPCODE_WRSR = 0b0001, /* Write Status Register */
OPCODE_READ = 0b0011, /* Read Memory */
OPCODE_WRITE = 0b0010, /* Write Memory */
OPCODE_RDID = 0b10011111, /* Read Device ID */
OPCODE_SLEEP = 0b10111001 /* Sleep Mode */ // added by FUEL4EP
} opcodes_t;

/*!
Expand All @@ -56,6 +58,8 @@ class Adafruit_FRAM_SPI {
uint8_t getStatusRegister(void);
bool setStatusRegister(uint8_t value);
void setAddressSize(uint8_t nAddressSize);
bool enter_low_power_mode(void); // added by FUEL4EP
bool exit_low_power_mode(void); // added by FUEL4EP

private:
Adafruit_SPIDevice *spi_dev = NULL;
Expand Down

0 comments on commit 3b1934e

Please sign in to comment.