LibDriver DS1307
Loading...
Searching...
No Matches
driver_ds1307.c File Reference

driver ds1307 source file More...

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

Go to the source code of this file.

Macros

#define CHIP_NAME   "Maxim Integrated DS1307"
 chip information definition
#define MANUFACTURER_NAME   "Maxim Integrated"
#define SUPPLY_VOLTAGE_MIN   4.5f
#define SUPPLY_VOLTAGE_MAX   5.5f
#define MAX_CURRENT   1.50f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define DS1307_REG_SECOND   0x00
 chip register definition
#define DS1307_REG_MINUTE   0x01
#define DS1307_REG_HOUR   0x02
#define DS1307_REG_WEEK   0x03
#define DS1307_REG_DATE   0x04
#define DS1307_REG_MONTH   0x05
#define DS1307_REG_YEAR   0x06
#define DS1307_REG_CONTROL   0x07
#define DS1307_REG_RAM   0x08
#define DS1307_ADDRESS   0xD0
 chip address definition

Functions

uint8_t ds1307_set_time (ds1307_handle_t *handle, ds1307_time_t *t)
 set the current time
uint8_t ds1307_get_time (ds1307_handle_t *handle, ds1307_time_t *t)
 get the current time
uint8_t ds1307_set_oscillator (ds1307_handle_t *handle, ds1307_bool_t enable)
 enable or disable the oscillator
uint8_t ds1307_get_oscillator (ds1307_handle_t *handle, ds1307_bool_t *enable)
 get the chip oscillator status
uint8_t ds1307_set_output_level (ds1307_handle_t *handle, ds1307_output_level_t level)
 set the output level
uint8_t ds1307_get_output_level (ds1307_handle_t *handle, ds1307_output_level_t *level)
 get the output level
uint8_t ds1307_set_output_mode (ds1307_handle_t *handle, ds1307_output_mode_t mode)
 set the output mode
uint8_t ds1307_get_output_mode (ds1307_handle_t *handle, ds1307_output_mode_t *mode)
 get the output mode
uint8_t ds1307_set_square_wave_frequency (ds1307_handle_t *handle, ds1307_square_wave_frequency_t freq)
 set the square wave frequency
uint8_t ds1307_get_square_wave_frequency (ds1307_handle_t *handle, ds1307_square_wave_frequency_t *freq)
 get the square wave frequency
uint8_t ds1307_read_ram (ds1307_handle_t *handle, uint8_t addr, uint8_t *buf, uint8_t len)
 read ram
uint8_t ds1307_write_ram (ds1307_handle_t *handle, uint8_t addr, uint8_t *buf, uint8_t len)
 write ram
uint8_t ds1307_init (ds1307_handle_t *handle)
 initialize the chip
uint8_t ds1307_deinit (ds1307_handle_t *handle)
 close the chip
uint8_t ds1307_set_reg (ds1307_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t ds1307_get_reg (ds1307_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 get the chip register
uint8_t ds1307_info (ds1307_info_t *info)
 get chip's information

Detailed Description

driver ds1307 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
2023-05-31

history

Date Version Author Description
2023/05/31 1.0 Shifeng Li first upload

Definition in file driver_ds1307.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Maxim Integrated DS1307"

chip information definition

chip name

Definition at line 42 of file driver_ds1307.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_ds1307.c.

◆ DS1307_ADDRESS

#define DS1307_ADDRESS   0xD0

chip address definition

iic device address

Definition at line 67 of file driver_ds1307.c.

◆ DS1307_REG_CONTROL

#define DS1307_REG_CONTROL   0x07

control register

Definition at line 61 of file driver_ds1307.c.

◆ DS1307_REG_DATE

#define DS1307_REG_DATE   0x04

date register

Definition at line 58 of file driver_ds1307.c.

◆ DS1307_REG_HOUR

#define DS1307_REG_HOUR   0x02

hour register

Definition at line 56 of file driver_ds1307.c.

◆ DS1307_REG_MINUTE

#define DS1307_REG_MINUTE   0x01

minute register

Definition at line 55 of file driver_ds1307.c.

◆ DS1307_REG_MONTH

#define DS1307_REG_MONTH   0x05

month register

Definition at line 59 of file driver_ds1307.c.

◆ DS1307_REG_RAM

#define DS1307_REG_RAM   0x08

ram start register

Definition at line 62 of file driver_ds1307.c.

◆ DS1307_REG_SECOND

#define DS1307_REG_SECOND   0x00

chip register definition

second register

Definition at line 54 of file driver_ds1307.c.

◆ DS1307_REG_WEEK

#define DS1307_REG_WEEK   0x03

week register

Definition at line 57 of file driver_ds1307.c.

◆ DS1307_REG_YEAR

#define DS1307_REG_YEAR   0x06

year register

Definition at line 60 of file driver_ds1307.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Maxim Integrated"

manufacturer name

Definition at line 43 of file driver_ds1307.c.

◆ MAX_CURRENT

#define MAX_CURRENT   1.50f

chip max current

Definition at line 46 of file driver_ds1307.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   5.5f

chip max supply voltage

Definition at line 45 of file driver_ds1307.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   4.5f

chip min supply voltage

Definition at line 44 of file driver_ds1307.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 48 of file driver_ds1307.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 47 of file driver_ds1307.c.