|
Open Model Railroad Network (OpenMRN)
|
Create a const structure like this to tell the spiflash driver how to talk to your spiflash device. More...
#include <SPIFlash.hxx>
Public Attributes | |
| uint32_t | speedHz_ {1000000} |
| Use this frequency to talk to SPI. | |
| uint32_t | sectorSize_ {4 * 1024} |
| How many bytes is an erase sector. | |
| uint32_t | pageSizeMask_ {~(256u - 1)} |
| A page program operation might wrap around a page. | |
| uint8_t | spiMode_ {SPI_MODE_0} |
| SPI mode to use. | |
| uint8_t | idCommand_ {0x9F} |
| Command to use for get identification bytes. | |
| uint8_t | readCommand_ {0x03} |
| Command to use for reads. | |
| uint8_t | writeEnableCommand_ {0x06} |
| Command sent out before each write/erase command. | |
| uint8_t | writeCommand_ {0x02} |
| Command to use for writes. | |
| uint8_t | eraseCommand_ {0x20} |
| Command to use for sector erases. | |
| uint8_t | chipEraseCommand_ {0x60} |
| Command to use for chip erase. | |
| uint8_t | statusReadCommand_ {0x05} |
| Command to use for status register read. | |
| uint8_t | statusWritePendingBit_ {0x01} |
| Which bit to check in the status register for write complete. | |
| uint8_t | readNeedsStuffing_: 1 |
| Set this to 1 if the read command needs a dummy byte after the address. | |
Create a const structure like this to tell the spiflash driver how to talk to your spiflash device.
Use it like this:
static const SPIFlashConfig cfg = { .speedHz_ = 2000000, .spiMode_ = 3, .writeCommand_ = 0xff, };
Definition at line 58 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::chipEraseCommand_ {0x60} |
Command to use for chip erase.
Definition at line 89 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::eraseCommand_ {0x20} |
Command to use for sector erases.
Definition at line 87 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::idCommand_ {0x9F} |
Command to use for get identification bytes.
Definition at line 79 of file SPIFlash.hxx.
| uint32_t SPIFlashConfig::pageSizeMask_ {~(256u - 1)} |
A page program operation might wrap around a page.
This will cause bytes to be written to the wrong place. There is a check that prevents this.
This variable is the mask on the address bits that define the page. Each write operation must start and finish within the same address & pageSizeMask_.
Definition at line 73 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::readCommand_ {0x03} |
Command to use for reads.
Definition at line 81 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::readNeedsStuffing_ |
Set this to 1 if the read command needs a dummy byte after the address.
Definition at line 98 of file SPIFlash.hxx.
| uint32_t SPIFlashConfig::sectorSize_ {4 * 1024} |
How many bytes is an erase sector.
Definition at line 64 of file SPIFlash.hxx.
| uint32_t SPIFlashConfig::speedHz_ {1000000} |
Use this frequency to talk to SPI.
Definition at line 61 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::spiMode_ {SPI_MODE_0} |
SPI mode to use.
Definition at line 76 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::statusReadCommand_ {0x05} |
Command to use for status register read.
Definition at line 92 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::statusWritePendingBit_ {0x01} |
Which bit to check in the status register for write complete.
(This is a mask, it should have exactly one bit set.)
Definition at line 95 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::writeCommand_ {0x02} |
Command to use for writes.
Definition at line 85 of file SPIFlash.hxx.
| uint8_t SPIFlashConfig::writeEnableCommand_ {0x06} |
Command sent out before each write/erase command.
Definition at line 83 of file SPIFlash.hxx.