38 int res =
twi.
write(pos, regs, size);
40 return (res < 0 ? res : res - 1);
44 DS3231::get(
void* alarm, uint8_t size, uint8_t offset, uint8_t& mask)
46 int res =
read(alarm, size, offset);
47 if (
UNLIKELY(res != size))
return (
false);
49 uint8_t* buf = (uint8_t*) alarm;
50 for (uint8_t i = 0; i < size; i++) {
60 DS3231::set(
void* alarm, uint8_t size, uint8_t offset, uint8_t mask)
62 uint8_t* buf = (uint8_t*) alarm;
63 for (uint8_t i = 0; i < size; i++) {
64 if (mask & (1 << i)) {
68 int res =
write(alarm, size, offset);
77 return (
swap(temp) >> 6);
86 if (res !=
sizeof(control))
return (
false);
88 control.
intcn = !flag;
91 return (res ==
sizeof(control));
115 outs << t.
clock <<
' ' 121 << (temp >> 2) <<
'.' << (25 * (temp & 0x3));
int write(void *regs, uint8_t size, uint8_t pos=0)
IOStream & bcd(IOStream &outs)
time_t clock
Current time.
bool square_wave(bool flag)
status_t status
Device status register.
control_t control
Device control register.
IOStream & bin(IOStream &outs)
int read(void *regs, uint8_t size, uint8_t pos=0)
int16_t temp
Device temperature.
int8_t aging
Crystal adjustment.
IOStream & operator<<(IOStream &outs, DS3231::alarm1_t &t)
int read(void *buf, size_t size)
alarm2_t alarm2
Alarm 2 setting.
int write(void *buf, size_t size)
void acquire(TWI::Driver *dev)
alarm1_t alarm1
Alarm 1 setting.
uint8_t intcn
Interrupt Control.
uint8_t bbsqw
Battery-Backup Square-Wave Enable.