#rtc #i2c #driver #no-std-driver #embedded-hal-i2c #embedded-hal #no-std

no-std rv3028c7-rtc

RV-3028-C7 and similar Real Time Clock (RTC) no_std driver

9 releases (4 breaking)

0.5.2 Dec 8, 2023
0.5.1 Dec 8, 2023
0.4.1 Nov 25, 2023
0.3.1 Nov 19, 2023
0.1.0 Nov 4, 2023

#196 in Hardware support

Download history 5/week @ 2024-02-26 153/week @ 2024-03-04 1/week @ 2024-03-11 84/week @ 2024-04-01

93 downloads per month

BSD-3-Clause

1.5MB
748 lines

rv3028c7-rtc

Rust no_std driver for RV-3028-C7 and similar Real Time Clocks (RTC) manufactured by Micro Crystal AG, Switzerland. Based on the Application Manual downloaded November 2023.

This driver provides many methods for reading and writing the i2c registers of the RTC, but it does not fully exercise all the features of the RTC.

Running examples

All of the examples have been run and tested on a raspberry pi running linux, for example with the command line:

cargo run --example rpil

from the linux command line.

Single RTC examples

These examples all assume there is a single RTC connected directly to a raspberry pi-like linux host.

  • rpil demonstrates some basic interactions with the RTC attached to eg a Raspberry Pi host.
  • event_log shows how to configure and enable event logging (for example, detecting interrupt signals on the EVI pin)
  • alarm_int shows how to set and get the alarm, and check for alarm trigger
  • trickle shows how to enable and disable trickle charging, as well as enable Vbackup switchover
  • countdown demonstrates setting the Periodic Countdown Timer for repeating and one-shot modes.
  • set_alarm shows setting the alarm

Multiple RTC examples

These examples all assume that there are multiple RTCs connected to the host via an i2c mux (something like the TCA9548A)

  • muxit demonstrates talking to two RTCs (with the same i2c address) via TCA9548A-like i2c mux. See the high-level wiring diagram schematic.
  • comp_mux compares the output of four independent RTCs (two each of RV-3028-C7 and DS3231) and detects when they drift apart (usually after multiple days). See the associated quad RTC wiring diagram.
  • trickle_mux shows how to configure and confirm the backup voltage supply trickle charger.

Testing

RUST_BACKTRACE=1 cargo test --tests

This will build and run only the tests, on any host platform. These tests do not require a real hardware RTC to be connected to the host. Note that plain cargo test currently also builds all examples, and if you're testing on a non-linux platform the linux_embedded_hal-based examples will fail to build.

Funstuff

Here's a breadboard with four RTCs connected via an i2c mux (for the RTC comparison example)

Dependencies