Documentation ¶
Overview ¶
Package eeprom provides an idiomatic interface to USB EEPROM programmers that conform to http://github.com/sstallion/usb-eeprom/wiki/Protocol. Due to the chip-agnostic nature of the protocol, constraints such as capacity and alignment must be enforced by the caller.
Example ¶
var start uint16 var data []byte // Program attached devices sequentially: eeprom.Walk(func(d *eeprom.Device) error { if err := d.Open(); err != nil { return err } defer d.Close() if err := d.Erase(); err != nil { return err } return d.WriteBytes(start, data) })
Output:
Index ¶
- Constants
- func Walk(fn func(*Device) error) error
- type Device
- func (d *Device) Close() error
- func (d *Device) Erase() error
- func (d *Device) ID() string
- func (d *Device) Open() error
- func (d *Device) Read(start uint16, data []byte) error
- func (d *Device) Reset() error
- func (d *Device) SetPageSize(pagesize int)
- func (d *Device) WriteBytes(start uint16, data []byte) error
- func (d *Device) WritePages(start uint16, data []byte) error
Examples ¶
Constants ¶
const (
// MaxBytes is the maximum amount of addressable data.
MaxBytes = 1 << 16
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents an attached USB EEPROM programmer.
func First ¶
First returns the first supported device attached to the host. Unlike Walk, the returned Device is opened automatically. This function exists primarily for testing.
func (*Device) Close ¶
Close releases the interface and closes the device. A device may not be opened again after calling this method. Returned errors may be safely ignored.
func (*Device) Open ¶
Open opens an attached device and claims the interface. To ensure proper reference counting, Open must be called within the context of a Walk.
func (*Device) Reset ¶
Reset issues a device reset. This method may be called after a failed transfer to reset the interface. Returned errors may be safely ignored.
func (*Device) SetPageSize ¶
SetPageSize sets the number of bytes written per page by WritePages. By default, the maximum packet size supported by the endpoint is used.
func (*Device) WriteBytes ¶
WriteBytes writes the given slice starting at the supplied starting address.