This library aims to support the following MRAM memory chips from Everspin Technologies for Arduino core:
Name | Size | Datasheet | Tested |
---|---|---|---|
MR25H128 |
128 Kb | link | Yes (on Arduino Nano) |
MR25H256 |
256 Kb | link | No |
MR25H10 |
1 Mb | link | No |
MR25H40 |
4 Mb | link | No |
See examples/
folder.
Available classes are:
MR25H128
MR25H256
MR25H10
MR25H40
The first two chips only need two bytes (uint16_t
) to address all the memory on the chip. The last two require three bytes (uint32_t
). The following documentation uses addr_t
to describe the addressing datatype.
The MR25HXXX
family supports four different memory protection modes:
Mode | Info |
---|---|
MR25HXXX::ProtectionMode::PROT_NONE |
Every memory cell can be written |
MR25HXXX::ProtectionMode::PROT_UQ |
Only the first 3/4 of memory can be written |
MR25HXXX::ProtectionMode::PROT_UH |
Only the first 1/2 of memory can be written |
MR25HXXX::ProtectionMode::PROT_ALL |
No memory cell can be written |
Each class provides the following methods. Look into source code for more documentation.
Get total number of bytes in memory:
addr_t memorySize()
(Un-)Initialize the mram chip object:
void begin()
void end()
Methods for direct status register manipulation (not recommended to do manually):
StatusRegister readStatusRegister()
void writeStatusRegister(StatusRegister sr)
void enableWriteStatusRegister()
void disableWriteStatusRegister()
bool isStatusRegisterWritable(StatusRegister sr)
bool isStatusRegisterWritable()
bool isWriteEnabled()
Get/set memory protection mode:
ProtectionMode getProtectionMode(StatusRegister sr)
ProtectionMode getProtectionMode()
void setProtectionMode(ProtectionMode pmode)
Read/write methods:
void enableWrite()
: does not need to be called explicitly before write operation, but saves a few cpu cyclesvoid disableWrite()
bool readBytes(uint8_t *dst, addr_t address, addr_t n)
bool writeBytes(addr_t address, uint8_t *src, addr_t n)
Power saving:
void sleep()
void wake()
bool isSleeping()
: every command sent while sleeping will be ignored
Helper functions:
void eraseChip(uint8_t value = 0xff)
void eraseFullChip(uint8_t value = 0xff)