Subversion Repositories idreammicro-avr

Rev

Rev 62 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/**************************************************************************//**
 * \brief DS1307 RTC library
 * \author Copyright (C) 2011  Julien Le Sech - www.idreammicro.com
 * \version 1.0
 * \date 20090501
 *
 * This file is part of the iDreamMicro library.
 *
 * This library is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This library 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 Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 ******************************************************************************/


/**************************************************************************//**
 * \headerfile ds1307.h
 ******************************************************************************/


#ifndef H__IDREAMMICRO__DS1307__H
#define H__IDREAMMICRO__DS1307__H

#ifdef _cplusplus
extern "C"{
#endif

/******************************************************************************
 * Header file inclusions.
 ******************************************************************************/


#include <useful/datetime.h>

/******************************************************************************
 * Public type definitions.
 ******************************************************************************/


/**************************************************************************//**
 * \typedef ds1307__hour_mode_t.
 * \bried RTC hour mode.
 ******************************************************************************/

/**************************************************************************//**
 * \enum ds1307__hour_modes.
 * \bried RTC hour modes.
 ******************************************************************************/

typedef enum ds1307__hour_modes
{
    DS1307__HOUR_MODE__24_HOUR = 0,     /*!< 24-hour mode. */
    DS1307__HOUR_MODE__12_HOUR = 1  /*!< 12-hour mode. */
} ds1307__hour_mode_t;

/******************************************************************************
 * Public function prototypes.
 ******************************************************************************/


/**************************************************************************//**
 * \fn void ds1307__initialize(void)
 *
 * \brief Initialize DS1307 RTC.
 ******************************************************************************/

void
ds1307__initialize
(
    void
);

/**************************************************************************//**
 * \fn void ds1307__get_time(
 * date_time__time_t*   p_time,
 * ds1307__hour_mode_t* p_hour_mode)
 *
 * \brief Get RTC time.
 *
 * \param p_time a pointer to fill with RTC time
 * \param p_hour_mode a pointer to fill with RTC hour mode
 ******************************************************************************/

void
ds1307__get_time
(
    datetime__time_t*      p_time,
    ds1307__hour_mode_t*    p_hour_mode
);

/**************************************************************************//**
 * \fn void ds1307__set_time(
 * date_time__time_t* p_time,
 * ds1307__hour_mode_t hour_mode)
 *
 * \brief Set RTC time.
 *
 * \param p_time time to set. p_time->meridiem isn't used in 12-hour mode.
 * \param hour_mode hour mode
 ******************************************************************************/

void
ds1307__set_time
(
    datetime__time_t*  p_time,
    ds1307__hour_mode_t hour_mode
);

/**************************************************************************//**
 * \fn void ds1307__get_date(date_time__date_t* p_date)
 *
 * \brief Get RTC date.
 *
 * \param p_date a pointer to fill with RTC date
 ******************************************************************************/

void
ds1307__get_date
(
    datetime__date_t* p_date
);

/**************************************************************************//**
 * \fn void ds1307__set_date(date_time__date_t* p_date)
 *
 * \brief Set RTC date.
 *
 * \param p_date date to set
 ******************************************************************************/

void
ds1307__set_date
(
    datetime__date_t* p_date
);

#ifdef _cplusplus
}
#endif

#endif /* H__IDREAMMICRO__DS1307__H */