52 template<BOARD::pin_t CS_PIN, BOARD::pin_t SDA_PIN, BOARD::pin_t CLK_PIN>
83 uint8_t* rp = (uint8_t*) &rtc;
84 for (
size_t i = 0; i <
sizeof(
rtc); i++, rp++)
121 uint8_t* rp = (uint8_t*) &rtc;
122 for (
size_t i = 0; i <
sizeof(
rtc); i++, rp++)
131 __attribute__((always_inline))
140 __attribute__((always_inline))
150 __attribute__((always_inline))
162 __attribute__((always_inline))
175 if (size == 0)
return;
176 uint8_t* bp = (uint8_t*) buf;
177 if (size > RAM_MAX) size =
RAM_MAX;
181 do *bp++ =
read();
while (--size);
195 if (size == 0)
return;
196 uint8_t* bp = (uint8_t*) buf;
197 if (size > RAM_MAX) size =
RAM_MAX;
201 do write(*bp++);
while (--size);
211 static const uint8_t
WP = 0x07;
220 } __attribute__((packed));
234 } __attribute__((packed));
248 addr = ((addr << 1) |
READ);
265 void write(uint8_t addr, uint8_t data)
267 addr = ((addr << 1) |
WRITE);
285 res |= (m_sda ? mask : 0x00);
287 __asm__ __volatile__(
"nop");
290 __asm__ __volatile__(
"nop");
305 __asm__ __volatile__(
"nop");
307 __asm__ __volatile__(
"nop");
int8_t tm_mday
Day in Month [1-31].
int8_t tm_min
Minutes [0-59].
bcd_t seconds
00-59 Seconds.
Read/write bit in write mode.
RTC register burst transfer.
void get_time(struct tm &now)
uint8_t read(uint8_t addr)
bcd_t minutes
00-59 Minutes.
void read_ram(void *buf, size_t size)
void write_ram(uint8_t addr, uint8_t data)
GPIO< SDA_PIN > m_sda
Serial data, bidirectional.
static const size_t RAM_MAX
int16_t tm_year
Years since 1900.
int8_t tm_sec
Seconds [0-60].
DS1302< BOARD::D11, BOARD::D12, BOARD::D13 > rtc
void set_time(struct tm &now)
uint8_t wp
Write protect register.
int8_t tm_hour
Hours [0-23].
uint8_t read_ram(uint8_t addr)
int8_t tm_wday
Days since Sunday [0-6].
void write_ram(void *buf, size_t size)
GPIO< CLK_PIN > m_clk
Clock for synchronized data.
Read/write bit in read mode.
static const uint8_t RAM_START
GPIO< CS_PIN > m_cs
Chip select, asserted high.
int8_t tm_mon
0-11 Months since January [0-11].
void write(uint8_t addr, uint8_t data)