at24cx

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: BSD-3-Clause Imports: 3 Imported by: 20

Documentation

Overview

Package at24cx provides a driver for the AT24C32/64/128/256/512 2-wire serial EEPROM

Datasheet: https://www.openimpulse.com/blog/wp-content/uploads/wpsc/downloadables/24C32-Datasheet.pdf

Index

Constants

View Source
const Address = 0x57

The I2C address which this device listens to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PageSize        uint16
	StartRAMAddress uint16
	EndRAMAddress   uint16
}

type Device

type Device struct {
	Address uint16
	// contains filtered or unexported fields
}

Device wraps an I2C connection to an AT24CX device.

func New

func New(bus drivers.I2C) Device

New creates a new AT24C32/64 connection. The I2C bus must already be configured.

This function only creates the Device object, it does not touch the device.

func (*Device) Configure

func (d *Device) Configure(cfg Config)

Configure sets up the device for communication

func (*Device) Read

func (d *Device) Read(data []uint8) (n int, err error)

Read reads len(data) from SRAM returns number of bytes written and error, if any

func (*Device) ReadAt

func (d *Device) ReadAt(data []byte, offset int64) (n int, err error)

ReadAt reads the bytes at the specified address

func (*Device) ReadByte

func (d *Device) ReadByte(eepromAddress uint16) (uint8, error)

ReadByte reads the byte at the specified address

func (*Device) Seek

func (d *Device) Seek(offset int64, whence int) (int64, error)

Seek sets the offset for the next Read or Write on SRAM to offset, interpreted according to whence: 0 means relative to the origin of the SRAM, 1 means relative to the current offset, and 2 means relative to the end. returns new offset and error, if any

func (*Device) Write

func (d *Device) Write(data []byte) (n int, err error)

Write writes len(data) bytes to SRAM returns number of bytes written and error, if any

func (*Device) WriteAt

func (d *Device) WriteAt(data []byte, offset int64) (n int, err error)

WriteAt writes a byte array at the specified address

func (*Device) WriteByte

func (d *Device) WriteByte(eepromAddress uint16, value uint8) error

WriteByte writes a byte at the specified address

Jump to

Keyboard shortcuts

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