2018-03-31 16:34:59 +03:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* @file stm32f1xx_hal_rtc.h
|
|
|
|
* @author MCD Application Team
|
|
|
|
* @brief Header file of RTC HAL module.
|
|
|
|
******************************************************************************
|
|
|
|
* @attention
|
|
|
|
*
|
2019-07-22 03:29:14 +03:00
|
|
|
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
|
|
* All rights reserved.</center></h2>
|
2018-03-31 16:34:59 +03:00
|
|
|
*
|
2019-07-22 03:29:14 +03:00
|
|
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
|
|
* the "License"; You may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at:
|
|
|
|
* opensource.org/licenses/BSD-3-Clause
|
2018-03-31 16:34:59 +03:00
|
|
|
*
|
2019-07-22 03:29:14 +03:00
|
|
|
******************************************************************************
|
2018-03-31 16:34:59 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
|
|
#ifndef __STM32F1xx_HAL_RTC_H
|
|
|
|
#define __STM32F1xx_HAL_RTC_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2019-07-22 03:29:14 +03:00
|
|
|
extern "C" {
|
2018-03-31 16:34:59 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
|
#include "stm32f1xx_hal_def.h"
|
|
|
|
|
|
|
|
/** @addtogroup STM32F1xx_HAL_Driver
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @addtogroup RTC
|
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
/** @addtogroup RTC_Private_Macros
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IS_RTC_ASYNCH_PREDIV(PREDIV) (((PREDIV) <= 0xFFFFFU) || ((PREDIV) == RTC_AUTO_1_SECOND))
|
|
|
|
#define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U)
|
|
|
|
#define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U)
|
|
|
|
#define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U)
|
|
|
|
#define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD))
|
|
|
|
#define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U)
|
|
|
|
#define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U))
|
|
|
|
#define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U))
|
|
|
|
#define IS_RTC_ALARM(ALARM) ((ALARM) == RTC_ALARM_A)
|
|
|
|
#define IS_RTC_CALIB_OUTPUT(__OUTPUT__) (((__OUTPUT__) == RTC_OUTPUTSOURCE_NONE) || \
|
|
|
|
((__OUTPUT__) == RTC_OUTPUTSOURCE_CALIBCLOCK) || \
|
|
|
|
((__OUTPUT__) == RTC_OUTPUTSOURCE_ALARM) || \
|
2019-07-22 03:29:14 +03:00
|
|
|
((__OUTPUT__) == RTC_OUTPUTSOURCE_SECOND))
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @addtogroup RTC_Private_Constants
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
/** @defgroup RTC_Timeout_Value Default Timeout Value
|
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
#define RTC_TIMEOUT_VALUE 1000U
|
|
|
|
/**
|
|
|
|
* @}
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
/** @defgroup RTC_EXTI_Line_Event RTC EXTI Line event
|
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
#define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)EXTI_IMR_MR17) /*!< External interrupt line 17 Connected to the RTC Alarm event */
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/* Exported types ------------------------------------------------------------*/
|
2018-03-31 16:34:59 +03:00
|
|
|
/** @defgroup RTC_Exported_Types RTC Exported Types
|
|
|
|
* @{
|
|
|
|
*/
|
2019-07-22 03:29:14 +03:00
|
|
|
/**
|
|
|
|
* @brief RTC Time structure definition
|
2018-03-31 16:34:59 +03:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint8_t Hours; /*!< Specifies the RTC Time Hour.
|
|
|
|
This parameter must be a number between Min_Data = 0 and Max_Data = 23 */
|
|
|
|
|
|
|
|
uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
|
|
|
|
This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
|
|
|
|
This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
} RTC_TimeTypeDef;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief RTC Alarm structure definition
|
2018-03-31 16:34:59 +03:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
uint32_t Alarm; /*!< Specifies the alarm ID (only 1 alarm ID for STM32F1).
|
|
|
|
This parameter can be a value of @ref RTC_Alarms_Definitions */
|
2019-07-22 03:29:14 +03:00
|
|
|
} RTC_AlarmTypeDef;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief HAL State structures definition
|
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */
|
|
|
|
HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */
|
2019-07-22 03:29:14 +03:00
|
|
|
HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */
|
|
|
|
HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */
|
|
|
|
HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */
|
|
|
|
|
|
|
|
} HAL_RTCStateTypeDef;
|
2018-03-31 16:34:59 +03:00
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/**
|
|
|
|
* @brief RTC Configuration Structure definition
|
2018-03-31 16:34:59 +03:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
|
2019-07-22 03:29:14 +03:00
|
|
|
This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF or RTC_AUTO_1_SECOND
|
2018-03-31 16:34:59 +03:00
|
|
|
If RTC_AUTO_1_SECOND is selected, AsynchPrediv will be set automatically to get 1sec timebase */
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC Tamper pin.
|
2019-07-22 03:29:14 +03:00
|
|
|
This parameter can be a value of @ref RTC_output_source_to_output_on_the_Tamper_pin */
|
|
|
|
|
|
|
|
} RTC_InitTypeDef;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief RTC Date structure definition
|
2018-03-31 16:34:59 +03:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay (not necessary for HAL_RTC_SetDate).
|
|
|
|
This parameter can be a value of @ref RTC_WeekDay_Definitions */
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
|
|
|
|
This parameter can be a value of @ref RTC_Month_Date_Definitions */
|
|
|
|
|
|
|
|
uint8_t Date; /*!< Specifies the RTC Date.
|
|
|
|
This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
uint8_t Year; /*!< Specifies the RTC Date Year.
|
|
|
|
This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
} RTC_DateTypeDef;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Time Handle Structure definition
|
|
|
|
*/
|
|
|
|
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
|
|
|
typedef struct __RTC_HandleTypeDef
|
|
|
|
#else
|
2018-03-31 16:34:59 +03:00
|
|
|
typedef struct
|
2019-07-22 03:29:14 +03:00
|
|
|
#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
|
2018-03-31 16:34:59 +03:00
|
|
|
{
|
|
|
|
RTC_TypeDef *Instance; /*!< Register base address */
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
RTC_InitTypeDef Init; /*!< RTC required parameters */
|
2018-03-31 16:34:59 +03:00
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
RTC_DateTypeDef DateToUpdate; /*!< Current date set by user and updated automatically */
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
HAL_LockTypeDef Lock; /*!< RTC locking object */
|
|
|
|
|
|
|
|
__IO HAL_RTCStateTypeDef State; /*!< Time communication state */
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
|
|
|
void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */
|
|
|
|
|
|
|
|
void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 1 Event callback */
|
|
|
|
|
|
|
|
void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */
|
|
|
|
|
|
|
|
void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */
|
|
|
|
|
|
|
|
#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
|
|
|
|
|
|
|
|
} RTC_HandleTypeDef;
|
|
|
|
|
|
|
|
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
|
|
|
/**
|
|
|
|
* @brief HAL RTC Callback ID enumeration definition
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00u, /*!< RTC Alarm A Event Callback ID */
|
|
|
|
HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04u, /*!< RTC Tamper 1 Callback ID */
|
|
|
|
HAL_RTC_MSPINIT_CB_ID = 0x0Eu, /*!< RTC Msp Init callback ID */
|
|
|
|
HAL_RTC_MSPDEINIT_CB_ID = 0x0Fu /*!< RTC Msp DeInit callback ID */
|
|
|
|
} HAL_RTC_CallbackIDTypeDef;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief HAL RTC Callback pointer definition
|
|
|
|
*/
|
|
|
|
typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */
|
|
|
|
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
/* Exported constants --------------------------------------------------------*/
|
|
|
|
/** @defgroup RTC_Exported_Constants RTC Exported Constants
|
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
/** @defgroup RTC_Automatic_Prediv_1_Second Automatic calculation of prediv for 1sec timebase
|
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
#define RTC_AUTO_1_SECOND 0xFFFFFFFFU
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @defgroup RTC_Input_parameter_format_definitions Input Parameter Format
|
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
#define RTC_FORMAT_BIN 0x000000000U
|
|
|
|
#define RTC_FORMAT_BCD 0x000000001U
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @defgroup RTC_Month_Date_Definitions Month Definitions
|
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
/* Coded in BCD format */
|
|
|
|
#define RTC_MONTH_JANUARY ((uint8_t)0x01)
|
|
|
|
#define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
|
|
|
|
#define RTC_MONTH_MARCH ((uint8_t)0x03)
|
|
|
|
#define RTC_MONTH_APRIL ((uint8_t)0x04)
|
|
|
|
#define RTC_MONTH_MAY ((uint8_t)0x05)
|
|
|
|
#define RTC_MONTH_JUNE ((uint8_t)0x06)
|
|
|
|
#define RTC_MONTH_JULY ((uint8_t)0x07)
|
|
|
|
#define RTC_MONTH_AUGUST ((uint8_t)0x08)
|
|
|
|
#define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
|
|
|
|
#define RTC_MONTH_OCTOBER ((uint8_t)0x10)
|
|
|
|
#define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
|
|
|
|
#define RTC_MONTH_DECEMBER ((uint8_t)0x12)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/** @defgroup RTC_WeekDay_Definitions WeekDay Definitions
|
2018-03-31 16:34:59 +03:00
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
#define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
|
|
|
|
#define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
|
|
|
|
#define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
|
|
|
|
#define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
|
|
|
|
#define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
|
|
|
|
#define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
|
|
|
|
#define RTC_WEEKDAY_SUNDAY ((uint8_t)0x00)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/** @defgroup RTC_Alarms_Definitions Alarms Definitions
|
2018-03-31 16:34:59 +03:00
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
#define RTC_ALARM_A 0U /*!< Specify alarm ID (mainly for legacy purposes) */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
|
|
|
|
/** @defgroup RTC_output_source_to_output_on_the_Tamper_pin Output source to output on the Tamper pin
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define RTC_OUTPUTSOURCE_NONE 0x00000000U /*!< No output on the TAMPER pin */
|
|
|
|
#define RTC_OUTPUTSOURCE_CALIBCLOCK BKP_RTCCR_CCO /*!< RTC clock with a frequency divided by 64 on the TAMPER pin */
|
|
|
|
#define RTC_OUTPUTSOURCE_ALARM BKP_RTCCR_ASOE /*!< Alarm pulse signal on the TAMPER pin */
|
|
|
|
#define RTC_OUTPUTSOURCE_SECOND (BKP_RTCCR_ASOS | BKP_RTCCR_ASOE) /*!< Second pulse signal on the TAMPER pin */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/** @defgroup RTC_Interrupts_Definitions Interrupts Definitions
|
2018-03-31 16:34:59 +03:00
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
#define RTC_IT_OW RTC_CRH_OWIE /*!< Overflow interrupt */
|
|
|
|
#define RTC_IT_ALRA RTC_CRH_ALRIE /*!< Alarm interrupt */
|
|
|
|
#define RTC_IT_SEC RTC_CRH_SECIE /*!< Second interrupt */
|
2019-07-22 03:29:14 +03:00
|
|
|
#define RTC_IT_TAMP1 BKP_CSR_TPIE /*!< TAMPER Pin interrupt enable */
|
2018-03-31 16:34:59 +03:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/** @defgroup RTC_Flags_Definitions Flags Definitions
|
2018-03-31 16:34:59 +03:00
|
|
|
* @{
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
#define RTC_FLAG_RTOFF RTC_CRL_RTOFF /*!< RTC Operation OFF flag */
|
|
|
|
#define RTC_FLAG_RSF RTC_CRL_RSF /*!< Registers Synchronized flag */
|
|
|
|
#define RTC_FLAG_OW RTC_CRL_OWF /*!< Overflow flag */
|
|
|
|
#define RTC_FLAG_ALRAF RTC_CRL_ALRF /*!< Alarm flag */
|
|
|
|
#define RTC_FLAG_SEC RTC_CRL_SECF /*!< Second flag */
|
|
|
|
#define RTC_FLAG_TAMP1F BKP_CSR_TEF /*!< Tamper Interrupt Flag */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
/* Exported macro ------------------------------------------------------------*/
|
|
|
|
/** @defgroup RTC_Exported_macros RTC Exported Macros
|
|
|
|
* @{
|
|
|
|
*/
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
/** @brief Reset RTC handle state
|
|
|
|
* @param __HANDLE__: RTC handle.
|
|
|
|
* @retval None
|
|
|
|
*/
|
2019-07-22 03:29:14 +03:00
|
|
|
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
|
|
|
#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\
|
|
|
|
(__HANDLE__)->State = HAL_RTC_STATE_RESET;\
|
|
|
|
(__HANDLE__)->MspInitCallback = NULL;\
|
|
|
|
(__HANDLE__)->MspDeInitCallback = NULL;\
|
|
|
|
}while(0u)
|
|
|
|
#else
|
|
|
|
#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
|
|
|
|
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
|
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
/**
|
|
|
|
* @brief Disable the write protection for RTC registers.
|
|
|
|
* @param __HANDLE__: specifies the RTC handle.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CRL, RTC_CRL_CNF)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable the write protection for RTC registers.
|
|
|
|
* @param __HANDLE__: specifies the RTC handle.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CRL, RTC_CRL_CNF)
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
/**
|
|
|
|
* @brief Enable the RTC Alarm interrupt.
|
|
|
|
* @param __HANDLE__: specifies the RTC handle.
|
2019-07-22 03:29:14 +03:00
|
|
|
* @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
|
2018-03-31 16:34:59 +03:00
|
|
|
* This parameter can be any combination of the following values:
|
|
|
|
* @arg RTC_IT_ALRA: Alarm A interrupt
|
|
|
|
* @retval None
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
#define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable the RTC Alarm interrupt.
|
|
|
|
* @param __HANDLE__: specifies the RTC handle.
|
2019-07-22 03:29:14 +03:00
|
|
|
* @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
|
2018-03-31 16:34:59 +03:00
|
|
|
* This parameter can be any combination of the following values:
|
|
|
|
* @arg RTC_IT_ALRA: Alarm A interrupt
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
|
|
|
|
* @param __HANDLE__: specifies the RTC handle.
|
|
|
|
* @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be checked
|
|
|
|
* This parameter can be:
|
|
|
|
* @arg RTC_IT_ALRA: Alarm A interrupt
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->CRH)& ((__INTERRUPT__)))) != RESET)? SET : RESET)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the selected RTC Alarm's flag status.
|
|
|
|
* @param __HANDLE__: specifies the RTC handle.
|
|
|
|
* @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
|
|
|
|
* This parameter can be:
|
|
|
|
* @arg RTC_FLAG_ALRAF
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->CRL) & (__FLAG__)) != RESET)? SET : RESET)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check whether the specified RTC Alarm interrupt has occurred or not.
|
|
|
|
* @param __HANDLE__: specifies the RTC handle.
|
|
|
|
* @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to check.
|
|
|
|
* This parameter can be:
|
|
|
|
* @arg RTC_IT_ALRA: Alarm A interrupt
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CRL) & (__INTERRUPT__)) != RESET)? SET : RESET)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clear the RTC Alarm's pending flags.
|
|
|
|
* @param __HANDLE__: specifies the RTC handle.
|
|
|
|
* @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
|
|
|
|
* This parameter can be:
|
|
|
|
* @arg RTC_FLAG_ALRAF
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CRL) = ~(__FLAG__)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable interrupt on ALARM Exti Line 17.
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, RTC_EXTI_LINE_ALARM_EVENT)
|
|
|
|
|
|
|
|
/**
|
2019-07-22 03:29:14 +03:00
|
|
|
* @brief Disable interrupt on ALARM Exti Line 17.
|
2018-03-31 16:34:59 +03:00
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, RTC_EXTI_LINE_ALARM_EVENT)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable event on ALARM Exti Line 17.
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, RTC_EXTI_LINE_ALARM_EVENT)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable event on ALARM Exti Line 17.
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, RTC_EXTI_LINE_ALARM_EVENT)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-22 03:29:14 +03:00
|
|
|
* @brief ALARM EXTI line configuration: set falling edge trigger.
|
2018-03-31 16:34:59 +03:00
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, RTC_EXTI_LINE_ALARM_EVENT)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable the ALARM Extended Interrupt Falling Trigger.
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, RTC_EXTI_LINE_ALARM_EVENT)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ALARM EXTI line configuration: set rising edge trigger.
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, RTC_EXTI_LINE_ALARM_EVENT)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable the ALARM Extended Interrupt Rising Trigger.
|
|
|
|
* This parameter can be:
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, RTC_EXTI_LINE_ALARM_EVENT)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ALARM EXTI line configuration: set rising & falling edge trigger.
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() \
|
|
|
|
do{ \
|
|
|
|
__HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \
|
|
|
|
__HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
|
|
|
|
} while(0U)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable the ALARM Extended Interrupt Rising & Falling Trigger.
|
|
|
|
* This parameter can be:
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() \
|
|
|
|
do{ \
|
|
|
|
__HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \
|
|
|
|
__HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
|
|
|
|
} while(0U)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check whether the specified ALARM EXTI interrupt flag is set or not.
|
|
|
|
* @retval EXTI ALARM Line Status.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & (RTC_EXTI_LINE_ALARM_EVENT))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clear the ALARM EXTI flag.
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = (RTC_EXTI_LINE_ALARM_EVENT))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Generate a Software interrupt on selected EXTI line.
|
|
|
|
* @retval None.
|
|
|
|
*/
|
|
|
|
#define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, RTC_EXTI_LINE_ALARM_EVENT)
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Include RTC HAL Extension module */
|
|
|
|
#include "stm32f1xx_hal_rtc_ex.h"
|
|
|
|
|
|
|
|
/* Exported functions --------------------------------------------------------*/
|
|
|
|
/** @addtogroup RTC_Exported_Functions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialization and de-initialization functions ****************************/
|
|
|
|
/** @addtogroup RTC_Exported_Functions_Group1
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
|
|
|
|
HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
|
|
|
|
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
|
|
|
|
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
|
2019-07-22 03:29:14 +03:00
|
|
|
|
|
|
|
/* Callbacks Register/UnRegister functions ***********************************/
|
|
|
|
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
|
|
|
HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
|
|
|
|
HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
|
|
|
|
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
|
2018-03-31 16:34:59 +03:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
/* RTC Time and Date functions ************************************************/
|
|
|
|
/** @addtogroup RTC_Exported_Functions_Group2
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
|
|
|
|
HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
|
|
|
|
HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
|
|
|
|
HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* RTC Alarm functions ********************************************************/
|
|
|
|
/** @addtogroup RTC_Exported_Functions_Group3
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
|
|
|
|
HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
|
|
|
|
HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
|
|
|
|
HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
|
|
|
|
void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
|
|
|
|
HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
|
|
|
|
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Peripheral State functions *************************************************/
|
|
|
|
/** @addtogroup RTC_Exported_Functions_Group4
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Peripheral Control functions ***********************************************/
|
|
|
|
/** @addtogroup RTC_Exported_Functions_Group5
|
|
|
|
* @{
|
|
|
|
*/
|
2019-07-22 03:29:14 +03:00
|
|
|
HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
|
2018-03-31 16:34:59 +03:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
2019-07-22 03:29:14 +03:00
|
|
|
*/
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __STM32F1xx_HAL_RTC_H */
|
|
|
|
|
|
|
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|