ds1302

Crates.iods1302
lib.rsds1302
version4.0.0
sourcesrc
created_at2020-11-01 10:26:19.821372
updated_at2021-12-04 09:31:50.914185
descriptionA platform agnostic driver to interface with the DS1302 real time clock-calendar
homepage
repositoryhttps://github.com/Nekspire/ds1302-rs
max_upload_size
id307440
size57,205
(Nekspire)

documentation

https://docs.rs/ds1302

README

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!

Commit count: 33

cargo fmt