ds1307

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package ds1307 provides a driver for the DS1307 RTC

Datasheet: https://datasheets.maximintegrated.com/en/ds/DS1307.pdf

Index

Constants

View Source
const (
	I2CAddress = 0x68
	TimeDate   = 0x00
	Control    = 0x7
	//CH is oscillator halt bit
	CH              = 0x7
	SRAMBeginAddres = 0x8
	SRAMEndAddress  = 0x3F
)
View Source
const (
	SQW_OFF   = 0x0
	SQW_1HZ   = 0x10
	SQW_4KHZ  = 0x11
	SQW_8KHZ  = 0x12
	SQW_32KHZ = 0x13
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

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

Device wraps an I2C connection to a DS1307 device.

func New

func New(bus machine.I2C) Device

New creates a new DS1307 connection. I2C bus must be already configured.

func (*Device) IsOscillatorRunning

func (d *Device) IsOscillatorRunning() bool

IsOscillatorRunning returns if the oscillator is running

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) 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) SetOscillatorFrequency

func (d *Device) SetOscillatorFrequency(sqw uint8) error

SetOscillatorFrequency sets output oscillator frequency Available modes: SQW_OFF, SQW_1HZ, SQW_4KHZ, SQW_8KHZ, SQW_32KHZ

func (*Device) SetOscillatorRunning

func (d *Device) SetOscillatorRunning(running bool) error

SetOscillatorRunning starts/stops internal oscillator by toggling halt bit

func (*Device) SetTime

func (d *Device) SetTime(t time.Time) error

SetTime sets the time and date

func (*Device) Time

func (d *Device) Time() (time.Time, error)

Time returns the time and date

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

Jump to

Keyboard shortcuts

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