git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3412 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
8ce9365e00
commit
d2fa0e3fde
|
@ -26,12 +26,9 @@
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _RTC_H_
|
#ifndef _RTC_H_
|
||||||
#define _RTC_H_
|
#define _RTC_H_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if HAL_USE_RTC || defined(__DOXYGEN__)
|
#if HAL_USE_RTC || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -50,8 +47,14 @@
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a structure representing an RTC driver.
|
||||||
|
*/
|
||||||
typedef struct RTCDriver RTCDriver;
|
typedef struct RTCDriver RTCDriver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of an RTC callback.
|
||||||
|
*/
|
||||||
typedef void (*rtccb_t)(RTCDriver *rtcp);
|
typedef void (*rtccb_t)(RTCDriver *rtcp);
|
||||||
|
|
||||||
#include "rtc_lld.h"
|
#include "rtc_lld.h"
|
||||||
|
@ -68,26 +71,14 @@ typedef void (*rtccb_t)(RTCDriver *rtcp);
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void rtcInit(void);
|
void rtcInit(void);
|
||||||
|
#if RTC_SUPPORTS_CALLBACKS
|
||||||
#if RTC_SUPPORTS_CALLBACKS
|
void rtcSetCallback(RTCDriver *rtcp, rtccb_t overflowcb,
|
||||||
void rtcSetCallback(RTCDriver *rtcp, rtccb_t overflowcb,
|
rtccb_t secondcb, rtccb_t alarmcb);
|
||||||
rtccb_t secondcb, rtccb_t alarmcb);
|
#endif /* RTC_SUPPORTS_CALLBACKS */
|
||||||
#endif /* RTC_SUPPORTS_CALLBACKS */
|
|
||||||
|
|
||||||
void rtcSetTime(RTCDateTime *timespec);
|
void rtcSetTime(RTCDateTime *timespec);
|
||||||
void rtcGetTime(RTCDateTime *timespec);
|
void rtcGetTime(RTCDateTime *timespec);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void rtcSetAlarm(RTCDateTime *timespec);
|
void rtcSetAlarm(RTCDateTime *timespec);
|
||||||
void rtcGetAlarm(RTCDateTime *timespec);
|
void rtcGetAlarm(RTCDateTime *timespec);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file rtc.c
|
* @file rtc.c
|
||||||
* @brief Real Time Clock Abstraction Layer code.
|
* @brief RTC Driver code.
|
||||||
*
|
*
|
||||||
* @addtogroup RTC
|
* @addtogroup RTC
|
||||||
* @{
|
* @{
|
||||||
|
@ -50,74 +50,85 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver exported functions. */
|
/* Driver exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable access to registers and initialize RTC if BKP doamin
|
* @brief Enable access to registers and initialize RTC if BKP domain
|
||||||
* was previously reseted.
|
* was previously reset.
|
||||||
*
|
|
||||||
* @note This function is implicitly invoked by @p halInit(), there is
|
* @note This function is implicitly invoked by @p halInit(), there is
|
||||||
* no need to explicitly initialize the driver.
|
* no need to explicitly initialize the driver.
|
||||||
|
*
|
||||||
|
* @init
|
||||||
*/
|
*/
|
||||||
void rtcInit(void){
|
void rtcInit(void) {
|
||||||
rtc_lld_init();
|
rtc_lld_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if RTC_SUPPORTS_CALLBACKS
|
#if RTC_SUPPORTS_CALLBACKS || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief Enables and disables callbacks on the fly.
|
* @brief Enables or disables callbacks.
|
||||||
* @details Pass callback function(s) in argument(s) to enable callback(s).
|
* @details This function enables or disables callbacks, use a @p NULL pointer
|
||||||
* Pass NULL to disable callback.
|
* in order to disable a callback.
|
||||||
* @pre To use this function you must set @p RTC_SUPPORTS_CALLBACKS
|
* @pre To use this function you must set @p RTC_SUPPORTS_CALLBACKS
|
||||||
* to @p TRUE.
|
* to @p TRUE.
|
||||||
*
|
*
|
||||||
* @param[in] rtcp - pointer to RTC driver structure.
|
* @param[in] rtcp pointer to RTC driver structure
|
||||||
* @param[in] overflowcb - overflow callback function.
|
* @param[in] overflowcb overflow callback function
|
||||||
* @param[in] secondcb - every second callback function.
|
* @param[in] secondcb every second callback function
|
||||||
* @param[in] alarmcb - alarm callback function.
|
* @param[in] alarmcb alarm callback function
|
||||||
*/
|
*/
|
||||||
void rtcSetCallback(RTCDriver *rtcp, rtccb_t overflowcb,
|
void rtcSetCallback(RTCDriver *rtcp, rtccb_t overflowcb,
|
||||||
rtccb_t secondcb, rtccb_t alarmcb){
|
rtccb_t secondcb, rtccb_t alarmcb) {
|
||||||
|
|
||||||
chDbgCheck((rtcp != NULL), "rtcSetCallback");
|
chDbgCheck((rtcp != NULL), "rtcSetCallback");
|
||||||
|
|
||||||
rtc_lld_set_callback(rtcp, overflowcb, secondcb, alarmcb);
|
rtc_lld_set_callback(rtcp, overflowcb, secondcb, alarmcb);
|
||||||
}
|
}
|
||||||
#endif /* RTC_SUPPORTS_CALLBACKS */
|
#endif /* RTC_SUPPORTS_CALLBACKS */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set current time.
|
* @brief Set current time.
|
||||||
*
|
*
|
||||||
* @param[in] timespec pointer to variable storing time.
|
* @param[in] timespec pointer to a @p RTCDateTime structure
|
||||||
*/
|
*/
|
||||||
void rtcSetTime(RTCDateTime *timespec){
|
void rtcSetTime(RTCDateTime *timespec) {
|
||||||
|
|
||||||
chDbgCheck((timespec != NULL), "rtcSetTime");
|
chDbgCheck((timespec != NULL), "rtcSetTime");
|
||||||
|
|
||||||
rtc_lld_set_time(timespec);
|
rtc_lld_set_time(timespec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get current time.
|
* @brief Get current time.
|
||||||
*
|
*
|
||||||
* @param[in] timespec pointer to variable storing time.
|
* @param[in] timespec pointer to a @p RTCDateTime structure
|
||||||
*/
|
*/
|
||||||
void rtcGetTime(RTCDateTime *timespec){
|
void rtcGetTime(RTCDateTime *timespec) {
|
||||||
|
|
||||||
chDbgCheck((timespec != NULL), "rtcGetTime");
|
chDbgCheck((timespec != NULL), "rtcGetTime");
|
||||||
rtc_lld_get_time(timespec);
|
rtc_lld_get_time(timespec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set alarm time.
|
* @brief Set alarm time.
|
||||||
*
|
*
|
||||||
* @param[in] timespec pointer to variable storing time of alarm.
|
* @param[in] timespec pointer to a @p RTCDateTime structure
|
||||||
*/
|
*/
|
||||||
void rtcSetAlarm(RTCDateTime *timespec){
|
void rtcSetAlarm(RTCDateTime *timespec) {
|
||||||
|
|
||||||
chDbgCheck((timespec != NULL), "rtcSetAlarm");
|
chDbgCheck((timespec != NULL), "rtcSetAlarm");
|
||||||
|
|
||||||
rtc_lld_set_alarm(timespec);
|
rtc_lld_set_alarm(timespec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get current alarm.
|
* @brief Get current alarm.
|
||||||
*
|
*
|
||||||
* @param[in] timespec pointer to variable to store alarm time.
|
* @param[in] timespec pointer to a @p RTCDateTime structure
|
||||||
*/
|
*/
|
||||||
void rtcGetAlarm(RTCDateTime *timespec){
|
void rtcGetAlarm(RTCDateTime *timespec){
|
||||||
|
|
||||||
chDbgCheck((timespec != NULL), "rtcGetAlarm");
|
chDbgCheck((timespec != NULL), "rtcGetAlarm");
|
||||||
|
|
||||||
rtc_lld_get_alarm(timespec);
|
rtc_lld_get_alarm(timespec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue