Documentation ¶
Overview ¶
Package spimock provides a fake SPI flash part for unit testing. This simulates an MX66L51235F.
Index ¶
Constants ¶
View Source
const FakeSize = 64 * 1024 * 1024
FakeSize is the size of the mocked flash chip.
View Source
const WriteWaitStates = 5
WriteWaitStates is the number WritePending is set to after a write.
Variables ¶
View Source
var FakeSFDP = []byte{}/* 112 elements not displayed */
FakeSFDP is the SFDP from the MX66L51235F datasheet.
Functions ¶
This section is empty.
Types ¶
type MockSPI ¶
type MockSPI struct { // Data contains fake contents of the flash chip. Data []byte // SFDPData contains fake SFDP. SFDP []byte SpeedHz uint32 // Is4BA is set to true if the chip is currently in 4-byte addressing // mode. Is4BA bool // IsWriteEnabled is set to true if data can be written. IsWriteEnabled bool // WritePending is non-zero while a write is pending. It decreases on // every read of the status register. WritePending int // Transfers is a recording of the transfers. Transfers []spidev.Transfer // ForceTransferError is returned by Transfer when set. ForceTransferErr error // ForceSetSpeedHzError is returned by SetSpeedHz when set. ForceSetSpeedHzErr error // contains filtered or unexported fields }
MockSPI is an implementation of flash.SPI which records the transfers.
func NewFromFile ¶
NewFromFile returns a new MockSPI which is backed by a file. If the file does not exist, it will be created. Ideally, the file's size should match FlashSize.
func (*MockSPI) SetSpeedHz ¶
SetSpeedHz sets the SPI speed. The value set is recorded in the mock.
Click to show internal directories.
Click to hide internal directories.