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

driver ds1302 header file More...

#include <stdio.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for driver_ds1302.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ds1302_time_s
 ds1302 time structure definition More...
struct  ds1302_handle_s
 ds1302 handle structure definition More...
struct  ds1302_info_s
 ds1302 information structure definition More...

Macros

#define DRIVER_DS1302_LINK_INIT(HANDLE, STRUCTURE)
 initialize ds1302_handle_t structure
#define DRIVER_DS1302_LINK_CE_GPIO_INIT(HANDLE, FUC)
 link ce_gpio_init function
#define DRIVER_DS1302_LINK_CE_GPIO_DEINIT(HANDLE, FUC)
 link ce_gpio_deinit function
#define DRIVER_DS1302_LINK_CE_GPIO_WRITE(HANDLE, FUC)
 link ce_gpio_write function
#define DRIVER_DS1302_LINK_SCLK_GPIO_INIT(HANDLE, FUC)
 link sclk_gpio_init function
#define DRIVER_DS1302_LINK_SCLK_GPIO_DEINIT(HANDLE, FUC)
 link sclk_gpio_deinit function
#define DRIVER_DS1302_LINK_SCLK_GPIO_WRITE(HANDLE, FUC)
 link sclk_gpio_write function
#define DRIVER_DS1302_LINK_IO_GPIO_INIT(HANDLE, FUC)
 link io_gpio_init function
#define DRIVER_DS1302_LINK_IO_GPIO_DEINIT(HANDLE, FUC)
 link io_gpio_deinit function
#define DRIVER_DS1302_LINK_CS_GPIO_WRITE(HANDLE, FUC)
 link ce_gpio_write function
#define DRIVER_DS1302_LINK_CS_GPIO_READ(HANDLE, FUC)
 link ce_gpio_read function
#define DRIVER_DS1302_LINK_DEBUG_PRINT(HANDLE, FUC)
 link debug_print function
#define DRIVER_DS1302_LINK_DELAY_MS(HANDLE, FUC)
 link delay_ms function
#define DRIVER_DS1302_LINK_DELAY_US(HANDLE, FUC)
 link delay_us function

Typedefs

typedef struct ds1302_time_s ds1302_time_t
 ds1302 time structure definition
typedef struct ds1302_handle_s ds1302_handle_t
 ds1302 handle structure definition
typedef struct ds1302_info_s ds1302_info_t
 ds1302 information structure definition

Enumerations

enum  ds1302_bool_t { DS1302_BOOL_FALSE = 0x00 , DS1302_BOOL_TRUE = 0x01 }
 ds1302 bool enumeration definition More...
enum  ds1302_am_pm_t { DS1302_AM = 0x00 , DS1302_PM = 0x01 }
 ds1302 am pm enumeration definition More...
enum  ds1302_format_t { DS1302_FORMAT_12H = 0x01 , DS1302_FORMAT_24H = 0x00 }
 ds1302 format enumeration definition More...
enum  ds1302_charge_t {
  DS1302_CHARGE_ENABLE = (0xA << 4) , DS1302_CHARGE_DISABLE = (0x0 << 0) , DS1302_CHARGE_1_DIODE = (1 << 2) , DS1302_CHARGE_2_DIODE = (2 << 2) ,
  DS1302_CHARGE_2K = (1 << 0) , DS1302_CHARGE_4K = (2 << 0) , DS1302_CHARGE_8K = (3 << 0)
}
 ds1302 charge enumeration definition More...

Functions

uint8_t ds1302_info (ds1302_info_t *info)
 get chip's information
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_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_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

Detailed Description

driver ds1302 header 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.h.