LibDriver DS1302
Loading...
Searching...
No Matches
ds1302 basic driver function

ds1302 basic driver modules More...

Collaboration diagram for ds1302 basic driver function:

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...

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

Detailed Description

ds1302 basic driver modules

Typedef Documentation

◆ ds1302_handle_t

ds1302 handle structure definition

◆ ds1302_info_t

typedef struct ds1302_info_s ds1302_info_t

ds1302 information structure definition

◆ ds1302_time_t

typedef struct ds1302_time_s ds1302_time_t

ds1302 time structure definition

Enumeration Type Documentation

◆ ds1302_am_pm_t

ds1302 am pm enumeration definition

Enumerator
DS1302_AM 

am

DS1302_PM 

pm

Definition at line 71 of file driver_ds1302.h.

◆ ds1302_bool_t

ds1302 bool enumeration definition

Enumerator
DS1302_BOOL_FALSE 

disable function

DS1302_BOOL_TRUE 

enable function

Definition at line 62 of file driver_ds1302.h.

◆ ds1302_charge_t

ds1302 charge enumeration definition

Enumerator
DS1302_CHARGE_ENABLE 

enable charge

DS1302_CHARGE_DISABLE 

disable charge

DS1302_CHARGE_1_DIODE 

1 diode

DS1302_CHARGE_2_DIODE 

2 diode

DS1302_CHARGE_2K 

2k

DS1302_CHARGE_4K 

4k

DS1302_CHARGE_8K 

8k

Definition at line 89 of file driver_ds1302.h.

◆ ds1302_format_t

ds1302 format enumeration definition

Enumerator
DS1302_FORMAT_12H 

12h format

DS1302_FORMAT_24H 

24h format

Definition at line 80 of file driver_ds1302.h.

Function Documentation

◆ ds1302_deinit()

uint8_t ds1302_deinit ( ds1302_handle_t * handle)

close the chip

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

Definition at line 1297 of file driver_ds1302.c.

◆ ds1302_get_charge()

uint8_t ds1302_get_charge ( ds1302_handle_t * handle,
uint8_t * charge )

get charge

Parameters
[in]*handlepointer to a ds1302 handle structure
[out]*chargepointer to a charge buffer
Returns
status code
  • 0 success
  • 1 get charge failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1046 of file driver_ds1302.c.

◆ ds1302_get_oscillator()

uint8_t ds1302_get_oscillator ( ds1302_handle_t * handle,
ds1302_bool_t * enable )

get the chip oscillator status

Parameters
[in]*handlepointer to a ds1302 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 889 of file driver_ds1302.c.

◆ ds1302_get_time()

uint8_t ds1302_get_time ( ds1302_handle_t * handle,
ds1302_time_t * t )

get the current time

Parameters
[in]*handlepointer to a ds1302 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 782 of file driver_ds1302.c.

◆ ds1302_get_write_protect()

uint8_t ds1302_get_write_protect ( ds1302_handle_t * handle,
ds1302_bool_t * enable )

get write protect status

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

Definition at line 973 of file driver_ds1302.c.

◆ ds1302_info()

uint8_t ds1302_info ( ds1302_info_t * info)

get chip's information

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

Definition at line 1555 of file driver_ds1302.c.

◆ ds1302_init()

uint8_t ds1302_init ( ds1302_handle_t * handle)

initialize the chip

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

Definition at line 1184 of file driver_ds1302.c.

◆ ds1302_read_ram()

uint8_t ds1302_read_ram ( ds1302_handle_t * handle,
uint8_t addr,
uint8_t * buf,
uint8_t len )

read ram

Parameters
[in]*handlepointer to a ds1302 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 > 30
  • 5 len is invalid
Note
none

Definition at line 1085 of file driver_ds1302.c.

◆ ds1302_set_charge()

uint8_t ds1302_set_charge ( ds1302_handle_t * handle,
uint8_t charge )

set charge

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

Definition at line 1011 of file driver_ds1302.c.

◆ ds1302_set_oscillator()

uint8_t ds1302_set_oscillator ( ds1302_handle_t * handle,
ds1302_bool_t enable )

enable or disable the oscillator

Parameters
[in]*handlepointer to a ds1302 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 842 of file driver_ds1302.c.

◆ ds1302_set_time()

uint8_t ds1302_set_time ( ds1302_handle_t * handle,
ds1302_time_t * t )

set the current time

Parameters
[in]*handlepointer to a ds1302 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 584 of file driver_ds1302.c.

◆ ds1302_set_write_protect()

uint8_t ds1302_set_write_protect ( ds1302_handle_t * handle,
ds1302_bool_t enable )

enable or disable write protect

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

Definition at line 927 of file driver_ds1302.c.

◆ ds1302_write_ram()

uint8_t ds1302_write_ram ( ds1302_handle_t * handle,
uint8_t addr,
uint8_t * buf,
uint8_t len )

write ram

Parameters
[in]*handlepointer to a ds1302 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 > 30
  • 5 len is invalid
Note
none

Definition at line 1137 of file driver_ds1302.c.