flash

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2022 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Overview

Package flash provides higher-level functions such as reading, erasing, writing and programming the flash chip.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flash

type Flash struct {
	// contains filtered or unexported fields
}

Flash provides operations for SPI flash chips.

func New

func New(spi SPI) (*Flash, error)

New creates a new flash device from a SPI interface.

func (*Flash) EraseAt

func (f *Flash) EraseAt(n int64, off int64) (int64, error)

EraseAt erases n bytes from offset off. Both parameters must be aligned to sectorSize.

func (*Flash) ProgramAt

func (f *Flash) ProgramAt(p []byte, off int64) (int, error)

func (*Flash) ReadAt

func (f *Flash) ReadAt(p []byte, off int64) (int, error)

ReadAt reads from the flash chip.

func (*Flash) ReadJEDECID

func (f *Flash) ReadJEDECID() (uint32, error)

ReadJEDECID reads the flash chip's JEDEC ID.

func (*Flash) SFDP

func (f *Flash) SFDP() *sfdp.SFDP

SFDP returns all the SFDP tables from the flash chip. The value is cached.

func (*Flash) SFDPReader

func (f *Flash) SFDPReader() *SFDPReader

SFDPReader is used to read from the SFDP address space.

func (*Flash) Size

func (f *Flash) Size() int64

Size returns the size of the flash chip in bytes.

func (*Flash) WriteAt

func (f *Flash) WriteAt(p []byte, off int64) (int, error)

WriteAt writes to the flash chip.

For optimal performance, call this function on boundaries of pageSize.

NOTE: This will not erase before writing! The ProgramAt function is probably what you want instead!

type SFDPReader

type SFDPReader Flash

SFDPReader is a wrapper around Flash where the ReadAt function reads from the SFDP address space.

func (*SFDPReader) ReadAt

func (f *SFDPReader) ReadAt(p []byte, off int64) (int, error)

ReadAt reads from the given offset in the SFDP address space.

type SPI

type SPI interface {
	Transfer(transfers []spidev.Transfer) error
}

SPI interface for the underlying calls to the SPI driver.

Directories

Path Synopsis
Package op contains available SPI opcodes.
Package op contains available SPI opcodes.
Package sfdp reads the SFDP (Serial Flash Discoverable Parameters) from a flash chip where supported.
Package sfdp reads the SFDP (Serial Flash Discoverable Parameters) from a flash chip where supported.
Package spimock provides a fake SPI flash part for unit testing.
Package spimock provides a fake SPI flash part for unit testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL