#real-time-clock #rtc #embedded-hal-driver #hardware-interface #no-std

no-std ds1302

A platform agnostic driver to interface with the DS1302 real time clock-calendar

4 releases (major breaking)

4.0.0 Dec 4, 2021
3.0.0 Nov 25, 2021
2.0.0 Nov 20, 2021
0.1.1 Nov 1, 2020

#531 in Embedded development

MIT/Apache

26KB
468 lines

ds1302-rs

crates.io badge docs.rs badge

DS1302 real time clock-calendar platform agnostic driver

About

The DS1302 trickle-charge timekeeping chip contains a real-time clock/calendar and 31 bytes of static RAM. It communicates with a microprocessor via a simple serial interface. The real-time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator. The chip driver is based on embedded-hal traits.

Datasheet: DS1302

DS1302 RTC Board - Waveshare

Hardware requirements

  • Serial Peripheral Interface (SPI)
  • SPI speed less than 2 MHz
  • SPI frame format with LSB transmitted first!
  • Default 8-bit data frame format is selected for transmission/reception
  • Default CPOL: CK to 0 when idle, CPHA: the first clock transition is the first data capture edge

Driver features:

  • Reading/setting clock/calendar data

  • 12-hour (AM/PM) or 24-hour format

  • Changing the time format while the chip is working

    NEW (4.0.0 release):

  • Programmable Trickle Charger configuration

  • 31 x 8 Battery-Backed General-Purpose RAM operations

Examples

https://github.com/Nekspire/ds1302-rs/tree/master/examples

This crate uses probe-run to run the examples.

To build examples type:

cargo build --examples or cargo build --examples --release

To run examples type:

cargo run --example <example name> or cargo run --example <example name> --release

The output should be like this:

Running `probe-run --chip STM32F103C8 target/thumbv7m-none-eabi/debug/examples/bluepill_ssd1306`
(HOST) INFO  flashing program (36.32 KiB)
(HOST) INFO  success!

License

Copyright © 2021 Nekspire

Dual licensed under your choice of either of:

Thanks for contribution!

Dependencies

~235KB