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

no-std ds1302

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

3 releases (stable)

3.0.0 Nov 25, 2021
2.0.0 Nov 20, 2021
0.1.1 Nov 1, 2020

#104 in Embedded development

42 downloads per month

MIT/Apache

20KB
319 lines

ds1302-rs

crates.io badge docs.rs badge

DS1302 real time clock-calendar platform agnostic driver

About

DS1302 is a real time clock/calendar chip, which communicates via SPI interface. The device provides seconds, minutes, hours, day, date, month, and year information. The driver is based on embedded-hal traits.

Datasheet: DS1302

DS1302 RTC Board - Waveshare

Hardware requirements

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

Features:

  • Reading/setting clock and calendar data in 12-hour or 24-hour format.
  • Changing hour format without resetting it. set_clock_mode()

TODO:

  • RAM support.

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

~185KB