LibDriver DS3231
Loading...
Searching...
No Matches
driver_ds3231.h File Reference

driver ds3231 header file More...

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

Go to the source code of this file.

Data Structures

struct  ds3231_time_s
 ds3231 time structure definition More...
struct  ds3231_handle_s
 ds3231 handle structure definition More...
struct  ds3231_info_s
 ds3231 information structure definition More...

Macros

#define DRIVER_DS3231_LINK_INIT(HANDLE, STRUCTURE)
 initialize ds3231_handle_t structure
#define DRIVER_DS3231_LINK_IIC_INIT(HANDLE, FUC)
 link iic_init function
#define DRIVER_DS3231_LINK_IIC_DEINIT(HANDLE, FUC)
 link iic_deinit function
#define DRIVER_DS3231_LINK_IIC_READ(HANDLE, FUC)
 link iic_read function
#define DRIVER_DS3231_LINK_IIC_WRITE(HANDLE, FUC)
 link iic_write function
#define DRIVER_DS3231_LINK_DELAY_MS(HANDLE, FUC)
 link delay_ms function
#define DRIVER_DS3231_LINK_DEBUG_PRINT(HANDLE, FUC)
 link debug_print function
#define DRIVER_DS3231_LINK_RECEIVE_CALLBACK(HANDLE, FUC)
 link receive_callback function

Typedefs

typedef struct ds3231_time_s ds3231_time_t
 ds3231 time structure definition
typedef struct ds3231_handle_s ds3231_handle_t
 ds3231 handle structure definition
typedef struct ds3231_info_s ds3231_info_t
 ds3231 information structure definition

Enumerations

enum  ds3231_bool_t { DS3231_BOOL_FALSE = 0x00 , DS3231_BOOL_TRUE = 0x01 }
 ds3231 bool enumeration definition More...
enum  ds3231_alarm_t { DS3231_ALARM_1 = 0x00 , DS3231_ALARM_2 = 0x01 }
 ds3231 alarm enumeration definition More...
enum  ds3231_am_pm_t { DS3231_AM = 0x00 , DS3231_PM = 0x01 }
 ds3231 am pm enumeration definition More...
enum  ds3231_pin_t { DS3231_PIN_SQUARE_WAVE = 0x00 , DS3231_PIN_INTERRUPT = 0x01 }
 ds3231 pin enumeration definition More...
enum  ds3231_format_t { DS3231_FORMAT_12H = 0x01 , DS3231_FORMAT_24H = 0x00 }
 ds3231 format enumeration definition More...
enum  ds3231_status_t { DS3231_STATUS_ALARM_2 = (1 << 1) , DS3231_STATUS_ALARM_1 = (1 << 0) }
 ds3231 alarm1 enumeration definition More...
enum  ds3231_alarm1_mode_t {
  DS3231_ALARM1_MODE_ONCE_A_SECOND = 0x0F , DS3231_ALARM1_MODE_SECOND_MATCH = 0x0E , DS3231_ALARM1_MODE_MINUTE_SECOND_MATCH = 0x0C , DS3231_ALARM1_MODE_HOUR_MINUTE_SECOND_MATCH = 0x08 ,
  DS3231_ALARM1_MODE_DATE_HOUR_MINUTE_SECOND_MATCH = 0x00 , DS3231_ALARM1_MODE_WEEK_HOUR_MINUTE_SECOND_MATCH = 0x10
}
 ds3231 alarm1 enumeration definition More...
enum  ds3231_alarm2_mode_t {
  DS3231_ALARM2_MODE_ONCE_A_MINUTE = 0x07 , DS3231_ALARM2_MODE_MINUTE_MATCH = 0x06 , DS3231_ALARM2_MODE_HOUR_MINUTE_MATCH = 0x04 , DS3231_ALARM2_MODE_DATE_HOUR_MINUTE_MATCH = 0x00 ,
  DS3231_ALARM2_MODE_WEEK_HOUR_MINUTE_MATCH = 0x10
}
 ds3231 alarm2 enumeration definition More...

Functions

uint8_t ds3231_info (ds3231_info_t *info)
 get chip's information
uint8_t ds3231_init (ds3231_handle_t *handle)
 initialize the chip
uint8_t ds3231_deinit (ds3231_handle_t *handle)
 close the chip
uint8_t ds3231_irq_handler (ds3231_handle_t *handle)
 irq handler
uint8_t ds3231_set_time (ds3231_handle_t *handle, ds3231_time_t *t)
 set the current time
uint8_t ds3231_get_time (ds3231_handle_t *handle, ds3231_time_t *t)
 get the current time
uint8_t ds3231_set_oscillator (ds3231_handle_t *handle, ds3231_bool_t enable)
 enable or disable the oscillator
uint8_t ds3231_get_oscillator (ds3231_handle_t *handle, ds3231_bool_t *enable)
 get the chip oscillator status
uint8_t ds3231_get_status (ds3231_handle_t *handle, uint8_t *status)
 get the chip status
uint8_t ds3231_set_pin (ds3231_handle_t *handle, ds3231_pin_t pin)
 set the chip pin function
uint8_t ds3231_get_pin (ds3231_handle_t *handle, ds3231_pin_t *pin)
 get the chip pin function
uint8_t ds3231_set_square_wave (ds3231_handle_t *handle, ds3231_bool_t enable)
 enable or disable the square wave output
uint8_t ds3231_get_square_wave (ds3231_handle_t *handle, ds3231_bool_t *enable)
 get the square wave output status
uint8_t ds3231_set_32khz_output (ds3231_handle_t *handle, ds3231_bool_t enable)
 enable or disable the 32KHz output
uint8_t ds3231_get_32khz_output (ds3231_handle_t *handle, ds3231_bool_t *enable)
 get the 32KHz output status
uint8_t ds3231_get_temperature (ds3231_handle_t *handle, int16_t *raw, float *s)
 get the chip temperature
uint8_t ds3231_set_aging_offset (ds3231_handle_t *handle, int8_t offset)
 set the chip aging offset
uint8_t ds3231_get_aging_offset (ds3231_handle_t *handle, int8_t *offset)
 get the chip aging offset
uint8_t ds3231_aging_offset_convert_to_register (ds3231_handle_t *handle, float offset, int8_t *reg)
 convert a aging offset value to a register raw data
uint8_t ds3231_aging_offset_convert_to_data (ds3231_handle_t *handle, int8_t reg, float *offset)
 convert a register raw data to a converted aging offset data
uint8_t ds3231_set_alarm_interrupt (ds3231_handle_t *handle, ds3231_alarm_t alarm, ds3231_bool_t enable)
 enable or disable the alarm interrupt
uint8_t ds3231_get_alarm_interrupt (ds3231_handle_t *handle, ds3231_alarm_t alarm, ds3231_bool_t *enable)
 get the alarm interrupt status
uint8_t ds3231_set_alarm1 (ds3231_handle_t *handle, ds3231_time_t *t, ds3231_alarm1_mode_t mode)
 set the alarm1 time
uint8_t ds3231_get_alarm1 (ds3231_handle_t *handle, ds3231_time_t *t, ds3231_alarm1_mode_t *mode)
 get the alarm1 time
uint8_t ds3231_set_alarm2 (ds3231_handle_t *handle, ds3231_time_t *t, ds3231_alarm2_mode_t mode)
 set the alarm2 time
uint8_t ds3231_get_alarm2 (ds3231_handle_t *handle, ds3231_time_t *t, ds3231_alarm2_mode_t *mode)
 get the alarm2 time
uint8_t ds3231_alarm_clear (ds3231_handle_t *handle, ds3231_alarm_t alarm)
 clear the alarm flag
uint8_t ds3231_set_reg (ds3231_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t ds3231_get_reg (ds3231_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 get the chip register

Detailed Description

driver ds3231 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
2.0.0
Author
Shifeng Li
Date
2021-03-15

history

Date Version Author Description
2021/03/15 2.0 Shifeng Li format the code
2020/11/30 1.0 Shifeng Li first upload

Definition in file driver_ds3231.h.