LibDriver DS1302
Loading...
Searching...
No Matches
driver_ds1302.c File Reference

driver ds1302 source file More...

#include "driver_ds1302.h"
Include dependency graph for driver_ds1302.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "Maxim Integrated DS1302"
 chip information definition
#define MANUFACTURER_NAME   "Maxim Integrated"
#define SUPPLY_VOLTAGE_MIN   2.0f
#define SUPPLY_VOLTAGE_MAX   5.5f
#define MAX_CURRENT   1.28f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define DS1302_REG_SECOND   (0 << 1)
 chip register definition
#define DS1302_REG_MINUTE   (1 << 1)
#define DS1302_REG_HOUR   (2 << 1)
#define DS1302_REG_DATE   (3 << 1)
#define DS1302_REG_MONTH   (4 << 1)
#define DS1302_REG_WEEK   (5 << 1)
#define DS1302_REG_YEAR   (6 << 1)
#define DS1302_REG_CONTROL   (7 << 1)
#define DS1302_REG_CHARGE   (8 << 1)
#define DS1302_COMMAND_RTC   (0 << 6)
 chip command definition
#define DS1302_COMMAND_RAM   (1 << 6)
#define DS1302_COMMAND_BURST   (0x1F << 1)

Functions

uint8_t ds1302_set_time (ds1302_handle_t *handle, ds1302_time_t *t)
 set the current time
uint8_t ds1302_get_time (ds1302_handle_t *handle, ds1302_time_t *t)
 get the current time
uint8_t ds1302_set_oscillator (ds1302_handle_t *handle, ds1302_bool_t enable)
 enable or disable the oscillator
uint8_t ds1302_get_oscillator (ds1302_handle_t *handle, ds1302_bool_t *enable)
 get the chip oscillator status
uint8_t ds1302_set_write_protect (ds1302_handle_t *handle, ds1302_bool_t enable)
 enable or disable write protect
uint8_t ds1302_get_write_protect (ds1302_handle_t *handle, ds1302_bool_t *enable)
 get write protect status
uint8_t ds1302_set_charge (ds1302_handle_t *handle, uint8_t charge)
 set charge
uint8_t ds1302_get_charge (ds1302_handle_t *handle, uint8_t *charge)
 get charge
uint8_t ds1302_read_ram (ds1302_handle_t *handle, uint8_t addr, uint8_t *buf, uint8_t len)
 read ram
uint8_t ds1302_write_ram (ds1302_handle_t *handle, uint8_t addr, uint8_t *buf, uint8_t len)
 write ram
uint8_t ds1302_init (ds1302_handle_t *handle)
 initialize the chip
uint8_t ds1302_deinit (ds1302_handle_t *handle)
 close the chip
uint8_t ds1302_clock_burst_write (ds1302_handle_t *handle, uint8_t *buf, uint8_t len)
 clock burst write
uint8_t ds1302_clock_burst_read (ds1302_handle_t *handle, uint8_t *buf, uint8_t len)
 clock burst read
uint8_t ds1302_ram_burst_write (ds1302_handle_t *handle, uint8_t *buf, uint8_t len)
 ram burst write
uint8_t ds1302_ram_burst_read (ds1302_handle_t *handle, uint8_t *buf, uint8_t len)
 ram burst read
uint8_t ds1302_set_reg (ds1302_handle_t *handle, uint8_t reg, uint8_t *buf, uint8_t len)
 set the chip register
uint8_t ds1302_get_reg (ds1302_handle_t *handle, uint8_t reg, uint8_t *buf, uint8_t len)
 get the chip register
uint8_t ds1302_info (ds1302_info_t *info)
 get chip's information

Detailed Description

driver ds1302 source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2024-02-15

history

Date Version Author Description
2024/02/15 1.0 Shifeng Li first upload

Definition in file driver_ds1302.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Maxim Integrated DS1302"

chip information definition

chip name

Definition at line 42 of file driver_ds1302.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_ds1302.c.

◆ DS1302_COMMAND_BURST

#define DS1302_COMMAND_BURST   (0x1F << 1)

burst command

Definition at line 69 of file driver_ds1302.c.

◆ DS1302_COMMAND_RAM

#define DS1302_COMMAND_RAM   (1 << 6)

ram command

Definition at line 68 of file driver_ds1302.c.

◆ DS1302_COMMAND_RTC

#define DS1302_COMMAND_RTC   (0 << 6)

chip command definition

rtc command

Definition at line 67 of file driver_ds1302.c.

◆ DS1302_REG_CHARGE

#define DS1302_REG_CHARGE   (8 << 1)

charge register

Definition at line 62 of file driver_ds1302.c.

◆ DS1302_REG_CONTROL

#define DS1302_REG_CONTROL   (7 << 1)

control register

Definition at line 61 of file driver_ds1302.c.

◆ DS1302_REG_DATE

#define DS1302_REG_DATE   (3 << 1)

date register

Definition at line 57 of file driver_ds1302.c.

◆ DS1302_REG_HOUR

#define DS1302_REG_HOUR   (2 << 1)

hour register

Definition at line 56 of file driver_ds1302.c.

◆ DS1302_REG_MINUTE

#define DS1302_REG_MINUTE   (1 << 1)

minute register

Definition at line 55 of file driver_ds1302.c.

◆ DS1302_REG_MONTH

#define DS1302_REG_MONTH   (4 << 1)

month register

Definition at line 58 of file driver_ds1302.c.

◆ DS1302_REG_SECOND

#define DS1302_REG_SECOND   (0 << 1)

chip register definition

second register

Definition at line 54 of file driver_ds1302.c.

◆ DS1302_REG_WEEK

#define DS1302_REG_WEEK   (5 << 1)

week register

Definition at line 59 of file driver_ds1302.c.

◆ DS1302_REG_YEAR

#define DS1302_REG_YEAR   (6 << 1)

year register

Definition at line 60 of file driver_ds1302.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Maxim Integrated"

manufacturer name

Definition at line 43 of file driver_ds1302.c.

◆ MAX_CURRENT

#define MAX_CURRENT   1.28f

chip max current

Definition at line 46 of file driver_ds1302.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   5.5f

chip max supply voltage

Definition at line 45 of file driver_ds1302.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   2.0f

chip min supply voltage

Definition at line 44 of file driver_ds1302.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 48 of file driver_ds1302.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 47 of file driver_ds1302.c.