rtc.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. ******************************************************************************
  3. * @file rtc.c
  4. * @brief This file provides code for the configuration
  5. * of the RTC instances.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "rtc.h"
  21. /* USER CODE BEGIN 0 */
  22. /* USER CODE END 0 */
  23. RTC_HandleTypeDef hrtc;
  24. /* RTC init function */
  25. void MX_RTC_Init(void)
  26. {
  27. /** Initialize RTC Only
  28. */
  29. hrtc.Instance = RTC;
  30. hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
  31. hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM;
  32. if (HAL_RTC_Init(&hrtc) != HAL_OK)
  33. {
  34. Error_Handler();
  35. }
  36. }
  37. void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
  38. {
  39. if(rtcHandle->Instance==RTC)
  40. {
  41. /* USER CODE BEGIN RTC_MspInit 0 */
  42. /* USER CODE END RTC_MspInit 0 */
  43. HAL_PWR_EnableBkUpAccess();
  44. /* Enable BKP CLK enable for backup registers */
  45. __HAL_RCC_BKP_CLK_ENABLE();
  46. /* RTC clock enable */
  47. __HAL_RCC_RTC_ENABLE();
  48. /* USER CODE BEGIN RTC_MspInit 1 */
  49. /* USER CODE END RTC_MspInit 1 */
  50. }
  51. }
  52. void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle)
  53. {
  54. if(rtcHandle->Instance==RTC)
  55. {
  56. /* USER CODE BEGIN RTC_MspDeInit 0 */
  57. /* USER CODE END RTC_MspDeInit 0 */
  58. /* Peripheral clock disable */
  59. __HAL_RCC_RTC_DISABLE();
  60. /* USER CODE BEGIN RTC_MspDeInit 1 */
  61. /* USER CODE END RTC_MspDeInit 1 */
  62. }
  63. }
  64. /* USER CODE BEGIN 1 */
  65. /* USER CODE END 1 */
  66. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/