CuVoodoo STM32F1 firmware template
Functions
rtc_ds1307.h File Reference

library to communicate with the Maxim DS1307 I2C RTC IC (API) More...

Go to the source code of this file.

Functions

void rtc_ds1307_setup (void)
 setup communication with RTC IC configure the I2C port defined in the sources
 
bool rtc_ds1307_oscillator_disabled (void)
 verify if oscillator is disabled More...
 
uint16_t rtc_ds1307_read_square_wave (void)
 read square wave output frequency (in Hz) More...
 
uint8_t rtc_ds1307_read_seconds (void)
 read seconds from RTC IC More...
 
uint8_t rtc_ds1307_read_minutes (void)
 read minutes from RTC IC More...
 
uint8_t rtc_ds1307_read_hours (void)
 read hours from RTC IC More...
 
uint8_t rtc_ds1307_read_day (void)
 read day from RTC IC More...
 
uint8_t rtc_ds1307_read_date (void)
 read date from RTC IC More...
 
uint8_t rtc_ds1307_read_month (void)
 read month from RTC IC More...
 
uint8_t rtc_ds1307_read_year (void)
 read year from RTC IC More...
 
uint8_t * rtc_ds1307_read_time (void)
 read time from RTC IC More...
 
bool rtc_ds1307_read_ram (uint8_t *data, uint8_t start, uint8_t length)
 read user RAM from RTC IC More...
 
bool rtc_ds1307_oscillator_disable (void)
 disable RTC IC oscillator More...
 
bool rtc_ds1307_oscillator_enable (void)
 enable RTC IC oscillator More...
 
bool rtc_ds1307_write_square_wave (uint16_t frequency)
 write square wave output frequency (in Hz) More...
 
bool rtc_ds1307_write_seconds (uint8_t seconds)
 write seconds into RTC IC More...
 
bool rtc_ds1307_write_minutes (uint8_t minutes)
 write minutes into RTC IC More...
 
bool rtc_ds1307_write_hours (uint8_t hours)
 write hours into RTC IC More...
 
bool rtc_ds1307_write_day (uint8_t day)
 write day into RTC IC More...
 
bool rtc_ds1307_write_date (uint8_t date)
 write date into RTC IC More...
 
bool rtc_ds1307_write_month (uint8_t month)
 write month into RTC IC More...
 
bool rtc_ds1307_write_year (uint8_t year)
 write year into RTC IC More...
 
bool rtc_ds1307_write_time (uint8_t seconds, uint8_t minutes, uint8_t hours, uint8_t day, uint8_t date, uint8_t month, uint8_t year)
 write time into RTC IC More...
 
bool rtc_ds1307_write_ram (uint8_t *data, uint8_t start, uint8_t length)
 write user RAM from RTC IC More...
 

Detailed Description

library to communicate with the Maxim DS1307 I2C RTC IC (API)

Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2016-2017
Note
peripherals used: I2C I2C peripheral used to communicate

Definition in file rtc_ds1307.h.

Function Documentation

◆ rtc_ds1307_oscillator_disable()

bool rtc_ds1307_oscillator_disable ( void  )

disable RTC IC oscillator

Returns
if disabling oscillator succeeded

Definition at line 203 of file rtc_ds1307.c.

◆ rtc_ds1307_oscillator_disabled()

bool rtc_ds1307_oscillator_disabled ( void  )

verify if oscillator is disabled

Returns
if oscillator is disabled (or if communication error occurred)

Definition at line 44 of file rtc_ds1307.c.

◆ rtc_ds1307_oscillator_enable()

bool rtc_ds1307_oscillator_enable ( void  )

enable RTC IC oscillator

Returns
if enabling oscillator succeeded

Definition at line 214 of file rtc_ds1307.c.

◆ rtc_ds1307_read_date()

uint8_t rtc_ds1307_read_date ( void  )

read date from RTC IC

Returns
day of the month (1-31) of the current time (0xff if communication error occurred)

Definition at line 127 of file rtc_ds1307.c.

◆ rtc_ds1307_read_day()

uint8_t rtc_ds1307_read_day ( void  )

read day from RTC IC

Returns
day of the week (1-7, 1 is Sunday) of the current time, 1 being Sunday (0xff if communication error occurred)

Definition at line 115 of file rtc_ds1307.c.

◆ rtc_ds1307_read_hours()

uint8_t rtc_ds1307_read_hours ( void  )

read hours from RTC IC

Returns
number of hours (0-23) of the current time (0xff if communication error occurred)

Definition at line 95 of file rtc_ds1307.c.

◆ rtc_ds1307_read_minutes()

uint8_t rtc_ds1307_read_minutes ( void  )

read minutes from RTC IC

Returns
number of minutes (0-59) of the current time (0xff if communication error occurred)

Definition at line 83 of file rtc_ds1307.c.

◆ rtc_ds1307_read_month()

uint8_t rtc_ds1307_read_month ( void  )

read month from RTC IC

Returns
month of the year (1-12) of the current time (0xff if communication error occurred)

Definition at line 139 of file rtc_ds1307.c.

◆ rtc_ds1307_read_ram()

bool rtc_ds1307_read_ram ( uint8_t *  data,
uint8_t  start,
uint8_t  length 
)

read user RAM from RTC IC

Parameters
[out]dataarray to store the RAM read
[in]startstart of the user RAM to read (0-55)
[in]lengthnumber of user RAM bytes to read (0-55)
Returns
if read succeeded

Definition at line 189 of file rtc_ds1307.c.

◆ rtc_ds1307_read_seconds()

uint8_t rtc_ds1307_read_seconds ( void  )

read seconds from RTC IC

Returns
number of seconds (0-59) of the current time (0xff if communication error occurred)

Definition at line 71 of file rtc_ds1307.c.

◆ rtc_ds1307_read_square_wave()

uint16_t rtc_ds1307_read_square_wave ( void  )

read square wave output frequency (in Hz)

Returns
square wave output frequency in Hz, 0 if disabled (0xffff if communication error occurred)

Definition at line 54 of file rtc_ds1307.c.

◆ rtc_ds1307_read_time()

uint8_t* rtc_ds1307_read_time ( void  )

read time from RTC IC

Returns
array of {seconds, minutes, hours, day, date, month, year} as defined above (NULL if communication error occurred)

Definition at line 162 of file rtc_ds1307.c.

◆ rtc_ds1307_read_year()

uint8_t rtc_ds1307_read_year ( void  )

read year from RTC IC

Returns
year of the century (00-99) of the current time (0xff if communication error occurred)

Definition at line 151 of file rtc_ds1307.c.

◆ rtc_ds1307_write_date()

bool rtc_ds1307_write_date ( uint8_t  date)

write date into RTC IC

Parameters
[in]dateday of the month (1-31)
Returns
if write succeeded

Definition at line 303 of file rtc_ds1307.c.

◆ rtc_ds1307_write_day()

bool rtc_ds1307_write_day ( uint8_t  day)

write day into RTC IC

Parameters
[in]dayday of the week (1-7, 1 is Sunday)
Returns
if write succeeded

Definition at line 291 of file rtc_ds1307.c.

◆ rtc_ds1307_write_hours()

bool rtc_ds1307_write_hours ( uint8_t  hours)

write hours into RTC IC

Parameters
[in]hoursnumber of hours (0-23)
Returns
if write succeeded

Definition at line 279 of file rtc_ds1307.c.

◆ rtc_ds1307_write_minutes()

bool rtc_ds1307_write_minutes ( uint8_t  minutes)

write minutes into RTC IC

Parameters
[in]minutesnumber of minutes (0-59)
Returns
if write succeeded

Definition at line 267 of file rtc_ds1307.c.

◆ rtc_ds1307_write_month()

bool rtc_ds1307_write_month ( uint8_t  month)

write month into RTC IC

Parameters
[in]monthmonth of the year (1-12)
Returns
if write succeeded

Definition at line 315 of file rtc_ds1307.c.

◆ rtc_ds1307_write_ram()

bool rtc_ds1307_write_ram ( uint8_t *  data,
uint8_t  start,
uint8_t  length 
)

write user RAM from RTC IC

Parameters
[in]dataarray of byte to write in RAM
[in]startstart of the user RAM to write (0-55)
[in]lengthnumber of user RAM bytes to write (0-55)
Returns
if write succeeded

Definition at line 386 of file rtc_ds1307.c.

◆ rtc_ds1307_write_seconds()

bool rtc_ds1307_write_seconds ( uint8_t  seconds)

write seconds into RTC IC

Parameters
[in]secondsnumber of seconds (0-59)
Returns
if write succeeded

Definition at line 251 of file rtc_ds1307.c.

◆ rtc_ds1307_write_square_wave()

bool rtc_ds1307_write_square_wave ( uint16_t  frequency)

write square wave output frequency (in Hz)

Parameters
[in]frequencysquare wave output frequency in Hz (0 to disable, 1, 4096, 8192, 32768)
Returns
if write succeeded

Definition at line 225 of file rtc_ds1307.c.

◆ rtc_ds1307_write_time()

bool rtc_ds1307_write_time ( uint8_t  seconds,
uint8_t  minutes,
uint8_t  hours,
uint8_t  day,
uint8_t  date,
uint8_t  month,
uint8_t  year 
)

write time into RTC IC

Parameters
[in]secondsnumber of seconds (0-59)
[in]minutesnumber of minutes (0-59)
[in]hoursnumber of hours (0-23)
[in]dayday of the week (1-7, 1 is Sunday)
[in]dateday of the month (1-31)
[in]monthmonth of the year (1-12)
[in]yearyear of the century (00-99)
Returns
if write succeeded

Definition at line 339 of file rtc_ds1307.c.

◆ rtc_ds1307_write_year()

bool rtc_ds1307_write_year ( uint8_t  year)

write year into RTC IC

Parameters
[in]yearyear of the century (00-99)
Returns
if write succeeded

Definition at line 327 of file rtc_ds1307.c.