ds1302 - Driver for DS1302 RTC module

group ds1302

ESP-IDF driver for DS1302 RTC.

Ported from esp-open-rtos

Copyright (C) 2016, 2019 Ruslan V. Uss unclerus@gmail.com

Copyright (C) 2016 Pavel Merzlyakov

merzlyakovpavel@gmail.com

BSD Licensed as described in the file LICENSE

Defines

DS1302_RAM_SIZE

Functions

esp_err_t ds1302_init(ds1302_t *dev)

Init device.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

esp_err_t ds1302_start(ds1302_t *dev, bool start)

Start/stop clock.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • start: Start clock if true

esp_err_t ds1302_is_running(ds1302_t *dev, bool *running)

Get current clock state.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • running: true if clock running

esp_err_t ds1302_set_write_protect(ds1302_t *dev, bool wp)

Enable/disable write protection.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • wp: Set RTC write-protected if true

esp_err_t ds1302_get_write_protect(ds1302_t *dev, bool *wp)

Get write protection status.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • wp: true if RTC write-protected

esp_err_t ds1302_get_time(ds1302_t *dev, struct tm *time)

Get current time.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • time: Pointer to the time struct to fill

esp_err_t ds1302_set_time(ds1302_t *dev, const struct tm *time)

Set time to RTC.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • time: Pointer to the time struct

esp_err_t ds1302_read_sram(ds1302_t *dev, uint8_t offset, void *buf, uint8_t len)

Read RAM contents into the buffer.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • offset: Start byte, 0..55

  • buf: Buffer

  • len: Bytes to read, 1..56

esp_err_t ds1302_write_sram(ds1302_t *dev, uint8_t offset, void *buf, uint8_t len)

Write buffer to RTC RAM.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • offset: Start byte, 0..55

  • buf: Buffer

  • len: Bytes to write, 1..56

struct ds1302_t
#include <ds1302.h>

Device descriptor.