2016-03-22 09:54:25 +01:00
|
|
|
/* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2016-03-22 11:16:47 +01:00
|
|
|
/** @file rtc_ds1307.h
|
|
|
|
* @author King Kévin <kingkevin@cuvoodoo.info>
|
|
|
|
* @date 2016
|
|
|
|
* @brief this library handles communication with the I2C RTC IC Maxim DS1307
|
2016-03-22 22:07:36 +01:00
|
|
|
* @todo control register and user RAM are not handled
|
2016-03-22 11:16:47 +01:00
|
|
|
* peripherals used: I2C @ref rtc_ds1307_i2c
|
|
|
|
*/
|
2016-03-22 09:54:25 +01:00
|
|
|
#pragma once
|
|
|
|
|
2016-03-22 11:16:47 +01:00
|
|
|
/** @brief setup communication with RTC IC
|
|
|
|
* configure the I2C port defined in the sources
|
|
|
|
*/
|
2016-03-22 09:54:25 +01:00
|
|
|
void rtc_setup(void);
|
2016-03-23 09:17:43 +01:00
|
|
|
/** @brief verify if oscillator is disabled
|
|
|
|
* @return if oscillator is disabled
|
|
|
|
*/
|
|
|
|
bool rtc_oscillator_disabled(void);
|
|
|
|
/** @brief read seconds from RTC IC
|
|
|
|
* @return the number of seconds (0-59) of the current time
|
2016-03-22 11:16:47 +01:00
|
|
|
*/
|
2016-03-22 09:54:25 +01:00
|
|
|
uint8_t rtc_read_seconds(void);
|
2016-03-23 09:17:43 +01:00
|
|
|
/** @brief read minutes from RTC IC
|
|
|
|
* @return the number of minutes (0-59) of the current time
|
2016-03-22 22:07:36 +01:00
|
|
|
*/
|
|
|
|
uint8_t rtc_read_minutes(void);
|
2016-03-23 09:17:43 +01:00
|
|
|
/** @brief read hours from RTC IC
|
|
|
|
* @return the number of hours (0-23) of the current time
|
2016-03-22 22:07:36 +01:00
|
|
|
*/
|
|
|
|
uint8_t rtc_read_hours(void);
|
2016-03-23 09:17:43 +01:00
|
|
|
/** @brief read day from RTC IC
|
|
|
|
* @return the day (1-7) of the current time, 1 being Sunday
|
2016-03-22 22:07:36 +01:00
|
|
|
*/
|
|
|
|
uint8_t rtc_read_day(void);
|
2016-03-23 09:17:43 +01:00
|
|
|
/** @brief read date from RTC IC
|
|
|
|
* @return the date (day of the month, 1-31) of the current time
|
2016-03-22 22:07:36 +01:00
|
|
|
*/
|
|
|
|
uint8_t rtc_read_date(void);
|
2016-03-23 09:17:43 +01:00
|
|
|
/** @brief read month from RTC IC
|
|
|
|
* @return the month (1-12) of the current time
|
2016-03-22 22:07:36 +01:00
|
|
|
*/
|
|
|
|
uint8_t rtc_read_month(void);
|
2016-03-23 09:17:43 +01:00
|
|
|
/** @brief read year from RTC IC
|
|
|
|
* @return the year (2000-2099) of the current time
|
2016-03-22 22:07:36 +01:00
|
|
|
*/
|
2016-03-23 08:09:52 +01:00
|
|
|
uint16_t rtc_read_year(void);
|
|
|
|
/** @brief read time from RTC IC
|
|
|
|
* @return array of {seconds, minutes, hours, day, date, month, year} as defined above
|
|
|
|
*/
|
|
|
|
uint16_t* rtc_read_time(void);
|
2016-03-23 09:17:43 +01:00
|
|
|
/** @brief disable RTC IC oscillator
|
|
|
|
*/
|
|
|
|
void rtc_oscillator_disable(void);
|
|
|
|
/** @brief enable RTC IC oscillator
|
|
|
|
*/
|
|
|
|
void rtc_oscillator_enable(void);
|
|
|
|
/** @brief write seconds into RTC IC
|
|
|
|
* @return the number of seconds (0-59)
|
|
|
|
*/
|
|
|
|
void rtc_write_seconds(uint8_t seconds);
|
|
|
|
|