Documentation ¶
Overview ¶
Package ds1307 provides a driver for the DS1307 RTC
Datasheet: https://datasheets.maximintegrated.com/en/ds/DS1307.pdf
Index ¶
- Constants
- type Device
- func (d *Device) IsOscillatorRunning() bool
- func (d *Device) Read(data []uint8) (n int, err error)
- func (d *Device) Seek(offset int64, whence int) (int64, error)
- func (d *Device) SetOscillatorFrequency(sqw uint8) error
- func (d *Device) SetOscillatorRunning(running bool) error
- func (d *Device) SetTime(t time.Time) error
- func (d *Device) Time() (time.Time, error)
- func (d *Device) Write(data []byte) (n int, err error)
Constants ¶
const ( I2CAddress = 0x68 TimeDate = 0x00 Control = 0x7 //CH is oscillator halt bit CH = 0x7 SRAMBeginAddres = 0x8 SRAMEndAddress = 0x3F )
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 ¶
Device wraps an I2C connection to a DS1307 device.
func (*Device) IsOscillatorRunning ¶
IsOscillatorRunning returns if the oscillator is running
func (*Device) Read ¶
Read reads len(data) from SRAM returns number of bytes written and error, if any
func (*Device) Seek ¶
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 ¶
SetOscillatorFrequency sets output oscillator frequency Available modes: SQW_OFF, SQW_1HZ, SQW_4KHZ, SQW_8KHZ, SQW_32KHZ
func (*Device) SetOscillatorRunning ¶
SetOscillatorRunning starts/stops internal oscillator by toggling halt bit