ds3231

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package ds3231 provides a driver for the DS3231 RTC forked from tinygo.org/x/drivers/ds3231 to add alarm functions Datasheet: https://datasheets.maximintegrated.com/en/ds/DS3231.pdf

Index

Constants

View Source
const (
	REG_TIMEDATE = 0x00
	REG_ALARMONE = 0x07
	REG_ALARMTWO = 0x0B

	REG_CONTROL = 0x0E
	REG_STATUS  = 0x0F
	REG_AGING   = 0x10

	REG_TEMP = 0x11

	REG_ALARMONE_SIZE = 4
	REG_ALARMTWO_SIZE = 3

	// DS3231 Control Register Bits
	A1IE  = 0
	A2IE  = 1
	INTCN = 2
	RS1   = 3
	RS2   = 4
	CONV  = 5
	BBSQW = 6
	EOSC  = 7

	// DS3231 Status Register Bits
	A1F     = 0
	A2F     = 1
	BSY     = 2
	EN32KHZ = 3
	OSF     = 7

	AlarmFlag_Alarm1    = 0x01
	AlarmFlag_Alarm2    = 0x02
	AlarmFlag_AlarmBoth = 0x03

	None          Mode = 0
	BatteryBackup Mode = 1
	Clock         Mode = 2
	AlarmOne      Mode = 3
	AlarmTwo      Mode = 4
	ModeAlarmBoth Mode = 5
)

Registers

View Source
const Address = 0x68

The I2C address which this device listens to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

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

Device wraps an I2C connection to a DS3231 device.

func New

func New(bus drivers.I2C) Device

New creates a new DS3231 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() bool

Configure sets up the device for communication

func (*Device) IsRunning

func (d *Device) IsRunning() bool

IsRunning returns if the oscillator is running

func (*Device) IsTimeValid

func (d *Device) IsTimeValid() bool

IsTimeValid return true/false is the time in the device is valid

func (*Device) ReadTemperature

func (d *Device) ReadTemperature() (int32, error)

ReadTemperature returns the temperature in millicelsius (mC)

func (*Device) ReadTime

func (d *Device) ReadTime() (dt time.Time, err error)

ReadTime returns the date and time

func (*Device) SetRunning

func (d *Device) SetRunning(isRunning bool) error

SetRunning starts the internal oscillator

func (*Device) SetTime

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

SetTime sets the date and time in the DS3231

type Mode

type Mode uint8

Jump to

Keyboard shortcuts

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