Subversion Repositories FuelGauge

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 6
Line 54... Line 54...
54
  *** Callback registration ***
54
  *** Callback registration ***
55
  =============================================
55
  =============================================
56
 
56
 
57
  The compilation define  USE_RTC_REGISTER_CALLBACKS when set to 1
57
  The compilation define  USE_RTC_REGISTER_CALLBACKS when set to 1
58
  allows the user to configure dynamically the driver callbacks.
58
  allows the user to configure dynamically the driver callbacks.
59
  Use Function @ref HAL_RTC_RegisterCallback() to register an interrupt callback.
59
  Use Function HAL_RTC_RegisterCallback() to register an interrupt callback.
60
 
60
 
61
  Function @ref HAL_RTC_RegisterCallback() allows to register following callbacks:
61
  Function HAL_RTC_RegisterCallback() allows to register following callbacks:
62
    (+) AlarmAEventCallback          : RTC Alarm A Event callback.
62
    (+) AlarmAEventCallback          : RTC Alarm A Event callback.
63
    (+) TimeStampEventCallback       : RTC TimeStamp Event callback.
63
    (+) TimeStampEventCallback       : RTC TimeStamp Event callback.
64
    (+) WakeUpTimerEventCallback     : RTC WakeUpTimer Event callback.
64
    (+) WakeUpTimerEventCallback     : RTC WakeUpTimer Event callback.
65
    (+) Tamper1EventCallback         : RTC Tamper 1 Event callback.
65
    (+) Tamper1EventCallback         : RTC Tamper 1 Event callback.
66
    (+) Tamper2EventCallback         : RTC Tamper 2 Event callback.
66
    (+) Tamper2EventCallback         : RTC Tamper 2 Event callback.
Line 68... Line 68...
68
    (+) MspInitCallback              : RTC MspInit callback.
68
    (+) MspInitCallback              : RTC MspInit callback.
69
    (+) MspDeInitCallback            : RTC MspDeInit callback.
69
    (+) MspDeInitCallback            : RTC MspDeInit callback.
70
  This function takes as parameters the HAL peripheral handle, the Callback ID
70
  This function takes as parameters the HAL peripheral handle, the Callback ID
71
  and a pointer to the user callback function.
71
  and a pointer to the user callback function.
72
 
72
 
73
  Use function @ref HAL_RTC_UnRegisterCallback() to reset a callback to the default
73
  Use function HAL_RTC_UnRegisterCallback() to reset a callback to the default
74
  weak function.
74
  weak function.
75
  @ref HAL_RTC_UnRegisterCallback() takes as parameters the HAL peripheral handle,
75
  HAL_RTC_UnRegisterCallback() takes as parameters the HAL peripheral handle,
76
  and the Callback ID.
76
  and the Callback ID.
77
  This function allows to reset following callbacks:
77
  This function allows to reset following callbacks:
78
    (+) AlarmAEventCallback          : RTC Alarm A Event callback.
78
    (+) AlarmAEventCallback          : RTC Alarm A Event callback.
79
    (+) TimeStampEventCallback       : RTC TimeStamp Event callback.
79
    (+) TimeStampEventCallback       : RTC TimeStamp Event callback.
80
    (+) WakeUpTimerEventCallback     : RTC WakeUpTimer Event callback.
80
    (+) WakeUpTimerEventCallback     : RTC WakeUpTimer Event callback.
Line 82... Line 82...
82
    (+) Tamper2EventCallback         : RTC Tamper 2 Event callback.
82
    (+) Tamper2EventCallback         : RTC Tamper 2 Event callback.
83
    (+) Tamper3EventCallback         : RTC Tamper 3 Event callback.
83
    (+) Tamper3EventCallback         : RTC Tamper 3 Event callback.
84
    (+) MspInitCallback              : RTC MspInit callback.
84
    (+) MspInitCallback              : RTC MspInit callback.
85
    (+) MspDeInitCallback            : RTC MspDeInit callback.
85
    (+) MspDeInitCallback            : RTC MspDeInit callback.
86
 
86
 
87
  By default, after the @ref HAL_RTC_Init() and when the state is HAL_RTC_STATE_RESET,
87
  By default, after the HAL_RTC_Init() and when the state is HAL_RTC_STATE_RESET,
88
  all callbacks are set to the corresponding weak functions :
88
  all callbacks are set to the corresponding weak functions :
89
  examples @ref AlarmAEventCallback(), @ref WakeUpTimerEventCallback().
89
  examples AlarmAEventCallback(), WakeUpTimerEventCallback().
90
  Exception done for MspInit and MspDeInit callbacks that are reset to the legacy weak function
90
  Exception done for MspInit and MspDeInit callbacks that are reset to the legacy weak function
91
  in the @ref HAL_RTC_Init()/@ref HAL_RTC_DeInit() only when these callbacks are null
91
  in the HAL_RTC_Init()/HAL_RTC_DeInit() only when these callbacks are null
92
  (not registered beforehand).
92
  (not registered beforehand).
93
  If not, MspInit or MspDeInit are not null, @ref HAL_RTC_Init()/@ref HAL_RTC_DeInit()
93
  If not, MspInit or MspDeInit are not null, HAL_RTC_Init()/HAL_RTC_DeInit()
94
  keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
94
  keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
95
 
95
 
96
  Callbacks can be registered/unregistered in HAL_RTC_STATE_READY state only.
96
  Callbacks can be registered/unregistered in HAL_RTC_STATE_READY state only.
97
  Exception done MspInit/MspDeInit that can be registered/unregistered
97
  Exception done MspInit/MspDeInit that can be registered/unregistered
98
  in HAL_RTC_STATE_READY or HAL_RTC_STATE_RESET state,
98
  in HAL_RTC_STATE_READY or HAL_RTC_STATE_RESET state,
99
  thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
99
  thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
100
  In that case first register the MspInit/MspDeInit user callbacks
100
  In that case first register the MspInit/MspDeInit user callbacks
101
  using @ref HAL_RTC_RegisterCallback() before calling @ref HAL_RTC_DeInit()
101
  using HAL_RTC_RegisterCallback() before calling HAL_RTC_DeInit()
102
  or @ref HAL_RTC_Init() function.
102
  or HAL_RTC_Init() function.
103
 
103
 
104
  When The compilation define USE_HAL_RTC_REGISTER_CALLBACKS is set to 0 or
104
  When The compilation define USE_HAL_RTC_REGISTER_CALLBACKS is set to 0 or
105
  not defined, the callback registration feature is not available and all callbacks
105
  not defined, the callback registration feature is not available and all callbacks
106
  are set to the corresponding weak functions.
106
  are set to the corresponding weak functions.
107
  @endverbatim
107
  @endverbatim
Line 679... Line 679...
679
 
679
 
680
/**
680
/**
681
  * @brief  Set RTC current time.
681
  * @brief  Set RTC current time.
682
  * @param  hrtc RTC handle
682
  * @param  hrtc RTC handle
683
  * @param  sTime Pointer to Time structure
683
  * @param  sTime Pointer to Time structure
-
 
684
  * @note   DayLightSaving and StoreOperation interfaces are deprecated.
-
 
685
  *         To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions.
684
  * @param  Format Specifies the format of the entered parameters.
686
  * @param  Format Specifies the format of the entered parameters.
685
  *          This parameter can be one of the following values:
687
  *          This parameter can be one of the following values:
686
  *            @arg RTC_FORMAT_BIN: Binary data format
688
  *            @arg RTC_FORMAT_BIN: Binary data format
687
  *            @arg RTC_FORMAT_BCD: BCD data format
689
  *            @arg RTC_FORMAT_BCD: BCD data format
688
  * @retval HAL status
690
  * @retval HAL status
Line 761... Line 763...
761
  else
763
  else
762
  {
764
  {
763
    /* Set the RTC_TR register */
765
    /* Set the RTC_TR register */
764
    hrtc->Instance->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
766
    hrtc->Instance->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
765
 
767
 
766
    /* Clear the bits to be configured */
768
    /* Clear the bits to be configured (Deprecated. Use HAL_RTC_DST_xxx functions instead) */
767
    hrtc->Instance->CR &= ((uint32_t)~RTC_CR_BKP);
769
    hrtc->Instance->CR &= ((uint32_t)~RTC_CR_BKP);
768
 
770
 
769
    /* Configure the RTC_CR register */
771
    /* Configure the RTC_CR register (Deprecated. Use HAL_RTC_DST_xxx functions instead) */
770
    hrtc->Instance->CR |= (uint32_t)(sTime->DayLightSaving | sTime->StoreOperation);
772
    hrtc->Instance->CR |= (uint32_t)(sTime->DayLightSaving | sTime->StoreOperation);
771
 
773
 
772
    /* Exit Initialization mode */
774
    /* Exit Initialization mode */
773
    hrtc->Instance->ISR &= ((uint32_t)~RTC_ISR_INIT);
775
    hrtc->Instance->ISR &= ((uint32_t)~RTC_ISR_INIT);
774
 
776
 
Line 1000... Line 1002...
1000
  }
1002
  }
1001
  return HAL_OK;
1003
  return HAL_OK;
1002
}
1004
}
1003
 
1005
 
1004
/**
1006
/**
-
 
1007
  * @brief  Daylight Saving Time, adda one hour to the calendar in one
-
 
1008
  *         single operation without going through the initialization procedure.
-
 
1009
  * @param  hrtc pointer to a RTC_HandleTypeDef structure that contains
-
 
1010
  *                the configuration information for RTC.
-
 
1011
  * @retval None
-
 
1012
  */
-
 
1013
void HAL_RTC_DST_Add1Hour(RTC_HandleTypeDef *hrtc)
-
 
1014
{
-
 
1015
  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
 
1016
  SET_BIT(hrtc->Instance->CR, RTC_CR_ADD1H);
-
 
1017
  __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
 
1018
}
-
 
1019
 
-
 
1020
/**
-
 
1021
  * @brief  Daylight Saving Time, subtracts one hour from the calendar in one
-
 
1022
  *         single operation without going through the initialization procedure.
-
 
1023
  * @param  hrtc pointer to a RTC_HandleTypeDef structure that contains
-
 
1024
  *                the configuration information for RTC.
-
 
1025
  * @retval None
-
 
1026
  */
-
 
1027
void HAL_RTC_DST_Sub1Hour(RTC_HandleTypeDef *hrtc)
-
 
1028
{
-
 
1029
  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
 
1030
  SET_BIT(hrtc->Instance->CR, RTC_CR_SUB1H);
-
 
1031
  __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
 
1032
}
-
 
1033
 
-
 
1034
/**
-
 
1035
  * @brief  Daylight Saving Time, sets the store operation bit.
-
 
1036
  * @note   It can be used by the software in order to memorize the DST status.
-
 
1037
  * @param  hrtc pointer to a RTC_HandleTypeDef structure that contains
-
 
1038
  *                the configuration information for RTC.
-
 
1039
  * @retval None
-
 
1040
  */
-
 
1041
void HAL_RTC_DST_SetStoreOperation(RTC_HandleTypeDef *hrtc)
-
 
1042
{
-
 
1043
  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
 
1044
  SET_BIT(hrtc->Instance->CR, RTC_CR_BKP);
-
 
1045
  __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
 
1046
}
-
 
1047
 
-
 
1048
/**
-
 
1049
  * @brief  Daylight Saving Time, clears the store operation bit.
-
 
1050
  * @param  hrtc pointer to a RTC_HandleTypeDef structure that contains
-
 
1051
  *                the configuration information for RTC.
-
 
1052
  * @retval None
-
 
1053
  */
-
 
1054
void HAL_RTC_DST_ClearStoreOperation(RTC_HandleTypeDef *hrtc)
-
 
1055
{
-
 
1056
  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
 
1057
  CLEAR_BIT(hrtc->Instance->CR, RTC_CR_BKP);
-
 
1058
  __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
 
1059
}
-
 
1060
 
-
 
1061
/**
-
 
1062
  * @brief  Daylight Saving Time, reads the store operation bit.
-
 
1063
  * @param  hrtc RTC handle
-
 
1064
  * @retval operation see RTC_StoreOperation_Definitions
-
 
1065
  */
-
 
1066
uint32_t HAL_RTC_DST_ReadStoreOperation(RTC_HandleTypeDef *hrtc)
-
 
1067
{
-
 
1068
  return READ_BIT(hrtc->Instance->CR, RTC_CR_BKP);
-
 
1069
}
-
 
1070
 
-
 
1071
/**
1005
  * @}
1072
  * @}
1006
  */
1073
  */
1007
 
1074
 
1008
/** @addtogroup RTC_Exported_Functions_Group3
1075
/** @addtogroup RTC_Exported_Functions_Group3
1009
 *  @brief   RTC Alarm functions
1076
 *  @brief   RTC Alarm functions