LibDriver DS1307
Loading...
Searching...
No Matches
ds1307 base driver function

ds1307 base driver modules More...

Collaboration diagram for ds1307 base driver function:

Data Structures

struct  ds1307_time_s
 ds1307 time structure definition More...
struct  ds1307_handle_s
 ds1307 handle structure definition More...
struct  ds1307_info_s
 ds1307 information structure definition More...

Typedefs

typedef struct ds1307_time_s ds1307_time_t
 ds1307 time structure definition
typedef struct ds1307_handle_s ds1307_handle_t
 ds1307 handle structure definition
typedef struct ds1307_info_s ds1307_info_t
 ds1307 information structure definition

Enumerations

enum  ds1307_bool_t { DS1307_BOOL_FALSE = 0x00 , DS1307_BOOL_TRUE = 0x01 }
 ds1307 bool enumeration definition More...
enum  ds1307_am_pm_t { DS1307_AM = 0x00 , DS1307_PM = 0x01 }
 ds1307 am pm enumeration definition More...
enum  ds1307_format_t { DS1307_FORMAT_12H = 0x01 , DS1307_FORMAT_24H = 0x00 }
 ds1307 format enumeration definition More...
enum  ds1307_output_level_t { DS1307_OUTPUT_LEVEL_LOW = 0x00 , DS1307_OUTPUT_LEVEL_HIGH = 0x01 }
 ds1307 output level enumeration definition More...
enum  ds1307_output_mode_t { DS1307_OUTPUT_MODE_LEVEL = 0x00 , DS1307_OUTPUT_MODE_SQUARE_WAVE = 0x01 }
 ds1307 output mode enumeration definition More...
enum  ds1307_square_wave_frequency_t { DS1307_SQUARE_WAVE_FREQUENCY_1_HZ = 0x00 , DS1307_SQUARE_WAVE_FREQUENCY_4096_HZ = 0x01 , DS1307_SQUARE_WAVE_FREQUENCY_8192_HZ = 0x02 , DS1307_SQUARE_WAVE_FREQUENCY_32768_HZ = 0x03 }
 ds1307 square wave frequency enumeration definition More...

Functions

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

Detailed Description

ds1307 base driver modules

Typedef Documentation

◆ ds1307_handle_t

ds1307 handle structure definition

◆ ds1307_info_t

typedef struct ds1307_info_s ds1307_info_t

ds1307 information structure definition

◆ ds1307_time_t

typedef struct ds1307_time_s ds1307_time_t

ds1307 time structure definition

Enumeration Type Documentation

◆ ds1307_am_pm_t

ds1307 am pm enumeration definition

Enumerator
DS1307_AM 

am

DS1307_PM 

pm

Definition at line 71 of file driver_ds1307.h.

◆ ds1307_bool_t

ds1307 bool enumeration definition

Enumerator
DS1307_BOOL_FALSE 

disable function

DS1307_BOOL_TRUE 

enable function

Definition at line 62 of file driver_ds1307.h.

◆ ds1307_format_t

ds1307 format enumeration definition

Enumerator
DS1307_FORMAT_12H 

12h format

DS1307_FORMAT_24H 

24h format

Definition at line 80 of file driver_ds1307.h.

◆ ds1307_output_level_t

ds1307 output level enumeration definition

Enumerator
DS1307_OUTPUT_LEVEL_LOW 

low level

DS1307_OUTPUT_LEVEL_HIGH 

high level

Definition at line 89 of file driver_ds1307.h.

◆ ds1307_output_mode_t

ds1307 output mode enumeration definition

Enumerator
DS1307_OUTPUT_MODE_LEVEL 

level mode

DS1307_OUTPUT_MODE_SQUARE_WAVE 

square wave mode

Definition at line 98 of file driver_ds1307.h.

◆ ds1307_square_wave_frequency_t

ds1307 square wave frequency enumeration definition

Enumerator
DS1307_SQUARE_WAVE_FREQUENCY_1_HZ 

1Hz

DS1307_SQUARE_WAVE_FREQUENCY_4096_HZ 

4.096kHz

DS1307_SQUARE_WAVE_FREQUENCY_8192_HZ 

8.192kHz

DS1307_SQUARE_WAVE_FREQUENCY_32768_HZ 

32.768kHz

Definition at line 107 of file driver_ds1307.h.

Function Documentation

◆ ds1307_deinit()

uint8_t ds1307_deinit ( ds1307_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to a ds1307 handle structure
Returns
status code
  • 0 success
  • 1 iic deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 933 of file driver_ds1307.c.

◆ ds1307_get_oscillator()

uint8_t ds1307_get_oscillator ( ds1307_handle_t * handle,
ds1307_bool_t * enable )

get the chip oscillator status

Parameters
[in]*handlepointer to a ds1307 handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 get oscillator failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 485 of file driver_ds1307.c.

◆ ds1307_get_output_level()

uint8_t ds1307_get_output_level ( ds1307_handle_t * handle,
ds1307_output_level_t * level )

get the output level

Parameters
[in]*handlepointer to a ds1307 handle structure
[out]*levelpointer to an output level buffer
Returns
status code
  • 0 success
  • 1 get output level failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 567 of file driver_ds1307.c.

◆ ds1307_get_output_mode()

uint8_t ds1307_get_output_mode ( ds1307_handle_t * handle,
ds1307_output_mode_t * mode )

get the output mode

Parameters
[in]*handlepointer to a ds1307 handle structure
[out]*modepointer to an output mode buffer
Returns
status code
  • 0 success
  • 1 get output mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 649 of file driver_ds1307.c.

◆ ds1307_get_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

Parameters
[in]*handlepointer to a ds1307 handle structure
[out]*freqpointer to a square wave frequency buffer
Returns
status code
  • 0 success
  • 1 get square wave frequency failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 731 of file driver_ds1307.c.

◆ ds1307_get_time()

uint8_t ds1307_get_time ( ds1307_handle_t * handle,
ds1307_time_t * t )

get the current time

Parameters
[in]*handlepointer to a ds1307 handle structure
[out]*tpointer to a time structure
Returns
status code
  • 0 success
  • 1 get time failed
  • 2 handle or time is NULL
  • 3 handle is not initialized
Note
none

Definition at line 381 of file driver_ds1307.c.

◆ ds1307_info()

uint8_t ds1307_info ( ds1307_info_t * info)

get chip's information

Parameters
[out]*infopointer to a ds1307 info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 1031 of file driver_ds1307.c.

◆ ds1307_init()

uint8_t ds1307_init ( ds1307_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to a ds1307 handle structure
Returns
status code
  • 0 success
  • 1 iic initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
Note
none

Definition at line 871 of file driver_ds1307.c.

◆ ds1307_read_ram()

uint8_t ds1307_read_ram ( ds1307_handle_t * handle,
uint8_t addr,
uint8_t * buf,
uint8_t len )

read ram

Parameters
[in]*handlepointer to a ds1307 handle structure
[in]addrram address
[out]*bufpointer to a data buffer
[in]lenbuffer length
Returns
status code
  • 0 success
  • 1 read ram failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 addr > 55
  • 5 len is invalid
Note
none

Definition at line 772 of file driver_ds1307.c.

◆ ds1307_set_oscillator()

uint8_t ds1307_set_oscillator ( ds1307_handle_t * handle,
ds1307_bool_t enable )

enable or disable the oscillator

Parameters
[in]*handlepointer to a ds1307 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set oscillator failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 440 of file driver_ds1307.c.

◆ ds1307_set_output_level()

uint8_t ds1307_set_output_level ( ds1307_handle_t * handle,
ds1307_output_level_t level )

set the output level

Parameters
[in]*handlepointer to a ds1307 handle structure
[in]leveloutput level
Returns
status code
  • 0 success
  • 1 set output level failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 522 of file driver_ds1307.c.

◆ ds1307_set_output_mode()

uint8_t ds1307_set_output_mode ( ds1307_handle_t * handle,
ds1307_output_mode_t mode )

set the output mode

Parameters
[in]*handlepointer to a ds1307 handle structure
[in]modeoutput mode
Returns
status code
  • 0 success
  • 1 set output mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 604 of file driver_ds1307.c.

◆ ds1307_set_square_wave_frequency()

uint8_t ds1307_set_square_wave_frequency ( ds1307_handle_t * handle,
ds1307_square_wave_frequency_t freq )

set the square wave frequency

Parameters
[in]*handlepointer to a ds1307 handle structure
[in]freqsquare wave frequency
Returns
status code
  • 0 success
  • 1 set square wave frequency failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 686 of file driver_ds1307.c.

◆ ds1307_set_time()

uint8_t ds1307_set_time ( ds1307_handle_t * handle,
ds1307_time_t * t )

set the current time

Parameters
[in]*handlepointer to a ds1307 handle structure
[in]*tpointer to a time structure
Returns
status code
  • 0 success
  • 1 set time failed
  • 2 handle or time is NULL
  • 3 handle is not initialized
  • 4 time is invalid
Note
none

Definition at line 184 of file driver_ds1307.c.

◆ ds1307_write_ram()

uint8_t ds1307_write_ram ( ds1307_handle_t * handle,
uint8_t addr,
uint8_t * buf,
uint8_t len )

write ram

Parameters
[in]*handlepointer to a ds1307 handle structure
[in]addrram address
[in]*bufpointer to a data buffer
[in]lenbuffer length
Returns
status code
  • 0 success
  • 1 write ram failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 addr > 55
  • 5 len is invalid
Note
none

Definition at line 824 of file driver_ds1307.c.