pcf8563

package
v0.0.0-...-7691dab Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PCF8563_ADDR = 0x51 // R:A3 W:A2

	I2C_SPEED_STANDARD = 100000
	I2C_SPEED_DOUBLE   = 200000

	RTC_CTRL_STOP = 0x20
	RTC_CTRL_TITP = 0x10
	RTC_CTRL_AF   = 0x08
	RTC_CTRL_TF   = 0x04
	RTC_CTRL_AIE  = 0x02
	RTC_CTRL_TIE  = 0x01

	RTC_COT_DISABLE = 0x00
	RTC_COT_32KHZ   = 0x80
	RTC_COT_1KHZ    = 0x81
	RTC_COT_32HZ    = 0x82
	RTC_COT_1HZ     = 0x83

	RTC_TIMER_DISABLE = 0x00
	RTC_TIMER_4KHZ    = 0x80
	RTC_TIMER_64HZ    = 0x81
	RTC_TIMER_1S      = 0x82
	RTC_TIMER_60S     = 0x83

	RTC_ALARM_DISABLE = 0x80
	RTC_ALARM_ENABLE  = 0x00
)

Registers

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 PCF8563 device.

func New

func New(i2c drivers.I2C) Device

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

func (*Device) AlarmTriggered

func (d *Device) AlarmTriggered() bool

AlarmTriggered returns whether or not an Alarm has been triggered.

func (*Device) ClearAlarm

func (d *Device) ClearAlarm() error

ClearAlarm disables alarm.

func (*Device) ClearTimer

func (d *Device) ClearTimer() error

ClearTimer disables timer.

func (*Device) DisableAlarmInterrupt

func (d *Device) DisableAlarmInterrupt() error

DisableAlarmInterrupt disable alarm interrupt.

func (*Device) DisableTimerInterrupt

func (d *Device) DisableTimerInterrupt() error

DisableTimerInterrupt disable timer interrupt.

func (*Device) EnableAlarmInterrupt

func (d *Device) EnableAlarmInterrupt() error

EnableAlarmInterrupt enables alarm interrupt. When triggered, INT pin (3) goes low.

func (*Device) EnableTimerInterrupt

func (d *Device) EnableTimerInterrupt() error

EnableTimerInterrupt enables timer interrupt. When triggered, INT pin (3) goes low.

func (*Device) ReadTime

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

ReadTime returns the date and time

func (*Device) Reset

func (d *Device) Reset() (err error)

Reset resets the `control and status registers`. When this method is called, it writes `0x00` to the `control and status registers`. This will cause `Alarm` and `Timer` to become Inactive. Please refer to the datasheet for details.

func (*Device) SetAlarm

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

SetAlarm sets the alarm

func (*Device) SetOscillatorFrequency

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

SetOscillatorFrequency sets output oscillator frequency Available modes: RTC_COT_DISABLE, RTC_COT_32KHZ, RTC_COT_1KHZ, RTC_COT_32Hz, RTC_COT_1HZ.

func (*Device) SetTime

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

SetTime sets the time and date

func (*Device) SetTimer

func (d *Device) SetTimer(dur time.Duration) error

SetTimer sets timer. The available durations are 1 to 127 seconds. If any other value is specified, it will be truncated.

func (*Device) TimerTriggered

func (d *Device) TimerTriggered() bool

TimerTriggered returns whether or not an Alarm has been triggered.

Jump to

Keyboard shortcuts

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