From 22d2162db773e677c900b8b397889b7087470248 Mon Sep 17 00:00:00 2001 From: barthess Date: Tue, 30 Aug 2011 22:52:11 +0000 Subject: RTC. Initial commit. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rtc_dev@3269 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/hal.h | 1 + os/hal/include/rtc.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 os/hal/include/rtc.h (limited to 'os/hal/include') diff --git a/os/hal/include/hal.h b/os/hal/include/hal.h index 1ed893aab..b92789b02 100644 --- a/os/hal/include/hal.h +++ b/os/hal/include/hal.h @@ -49,6 +49,7 @@ #include "usb.h" #include "mmc_spi.h" #include "serial_usb.h" +#include "rtc.h" /*===========================================================================*/ /* External declarations. */ diff --git a/os/hal/include/rtc.h b/os/hal/include/rtc.h new file mode 100644 index 000000000..4a36f4317 --- /dev/null +++ b/os/hal/include/rtc.h @@ -0,0 +1,77 @@ +/** + * @file rtc.h + * @brief RTC Driver macros and structures. + * + * @addtogroup RTC + * @{ + */ + + +#ifndef _RTC_H_ +#define _RTC_H_ + + + +#if HAL_USE_RTC || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ +/* TODO: move this to hal_lld_f103.h & mcuconf.h */ +#define STM32_LSECLK 32768 /**< Low speed external clock. */ + + +/* RCC_CFGR register bits definitions.*/ +#define STM32_RTC_NONE (0 << 8) /**< */ +#define STM32_RTC_LSE (1 << 8) /**< LSE oscillator clock used as RTC clock */ +#define STM32_RTC_LSI (2 << 8) /**< LSI oscillator clock used as RTC clock */ +#define STM32_RTC_HSE (3 << 8) /**< HSE oscillator clock divided by 128 used as RTC clock */ + + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +typedef struct RTCDriver RTCDriver; + +typedef void (*rtccb_t)(RTCDriver *rtcp); + +#include "rtc_lld.h" + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void rtcInit(void); +#if RTC_SUPPORTS_CALLBACKS + void rtcStart(RTCDriver *rtcp, RTCConfig *rtccfgp); + void rtcStop(void); +#endif /* RTC_SUPPORTS_CALLBACKS */ + void rtcSetTime(uint32_t tv_sec); + uint32_t rtcGetSec(void); + uint16_t rtcGetMsec(void); + void rtcSetAlarm(uint32_t tv_alarm); + uint32_t rtcGetAlarm(void); +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_RTC */ +#endif /* _RTC_H_ */ + +/** @} */ -- cgit v1.2.3