general
This commit is contained in:
parent
3d99c89bb1
commit
b2c26b7096
@ -27,7 +27,8 @@
|
|||||||
RTC_HandleTypeDef hrtc;
|
RTC_HandleTypeDef hrtc;
|
||||||
|
|
||||||
/* RTC init function */
|
/* RTC init function */
|
||||||
void MX_RTC_Init(void) {
|
void MX_RTC_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN RTC_Init 0 */
|
/* USER CODE BEGIN RTC_Init 0 */
|
||||||
|
|
||||||
@ -45,8 +46,9 @@ void MX_RTC_Init(void) {
|
|||||||
hrtc.Instance = RTC;
|
hrtc.Instance = RTC;
|
||||||
hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
|
hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
|
||||||
hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM;
|
hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM;
|
||||||
if (HAL_RTC_Init(&hrtc) != HAL_OK) {
|
if (HAL_RTC_Init(&hrtc) != HAL_OK)
|
||||||
Error_Handler();
|
{
|
||||||
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN Check_RTC_BKUP */
|
/* USER CODE BEGIN Check_RTC_BKUP */
|
||||||
@ -69,16 +71,18 @@ void MX_RTC_Init(void) {
|
|||||||
sTime.Minutes = 0;
|
sTime.Minutes = 0;
|
||||||
sTime.Seconds = 0;
|
sTime.Seconds = 0;
|
||||||
|
|
||||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK) {
|
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
|
||||||
Error_Handler();
|
{
|
||||||
|
Error_Handler();
|
||||||
}
|
}
|
||||||
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
|
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
|
||||||
DateToUpdate.Month = RTC_MONTH_JANUARY;
|
DateToUpdate.Month = RTC_MONTH_JANUARY;
|
||||||
DateToUpdate.Date = 1;
|
DateToUpdate.Date = 1;
|
||||||
DateToUpdate.Year = 0;
|
DateToUpdate.Year = 0;
|
||||||
|
|
||||||
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BIN) != HAL_OK) {
|
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BIN) != HAL_OK)
|
||||||
Error_Handler();
|
{
|
||||||
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN RTC_Init 2 */
|
/* USER CODE BEGIN RTC_Init 2 */
|
||||||
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR1,0x1234);
|
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR1,0x1234);
|
||||||
@ -86,44 +90,48 @@ void MX_RTC_Init(void) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_RTC_MspInit(RTC_HandleTypeDef *rtcHandle) {
|
void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
if (rtcHandle->Instance == RTC) {
|
if(rtcHandle->Instance==RTC)
|
||||||
/* USER CODE BEGIN RTC_MspInit 0 */
|
{
|
||||||
|
/* USER CODE BEGIN RTC_MspInit 0 */
|
||||||
|
|
||||||
/* USER CODE END RTC_MspInit 0 */
|
/* USER CODE END RTC_MspInit 0 */
|
||||||
HAL_PWR_EnableBkUpAccess();
|
HAL_PWR_EnableBkUpAccess();
|
||||||
/* Enable BKP CLK enable for backup registers */
|
/* Enable BKP CLK enable for backup registers */
|
||||||
__HAL_RCC_BKP_CLK_ENABLE();
|
__HAL_RCC_BKP_CLK_ENABLE();
|
||||||
/* RTC clock enable */
|
/* RTC clock enable */
|
||||||
__HAL_RCC_RTC_ENABLE();
|
__HAL_RCC_RTC_ENABLE();
|
||||||
|
|
||||||
/* RTC interrupt Init */
|
/* RTC interrupt Init */
|
||||||
HAL_NVIC_SetPriority(RTC_IRQn, 3, 0);
|
HAL_NVIC_SetPriority(RTC_IRQn, 3, 0);
|
||||||
HAL_NVIC_EnableIRQ(RTC_IRQn);
|
HAL_NVIC_EnableIRQ(RTC_IRQn);
|
||||||
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 3, 0);
|
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 3, 0);
|
||||||
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
|
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
|
||||||
/* USER CODE BEGIN RTC_MspInit 1 */
|
/* USER CODE BEGIN RTC_MspInit 1 */
|
||||||
|
|
||||||
/* USER CODE END RTC_MspInit 1 */
|
/* USER CODE END RTC_MspInit 1 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *rtcHandle) {
|
void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
if (rtcHandle->Instance == RTC) {
|
if(rtcHandle->Instance==RTC)
|
||||||
/* USER CODE BEGIN RTC_MspDeInit 0 */
|
{
|
||||||
|
/* USER CODE BEGIN RTC_MspDeInit 0 */
|
||||||
|
|
||||||
/* USER CODE END RTC_MspDeInit 0 */
|
/* USER CODE END RTC_MspDeInit 0 */
|
||||||
/* Peripheral clock disable */
|
/* Peripheral clock disable */
|
||||||
__HAL_RCC_RTC_DISABLE();
|
__HAL_RCC_RTC_DISABLE();
|
||||||
|
|
||||||
/* RTC interrupt Deinit */
|
/* RTC interrupt Deinit */
|
||||||
HAL_NVIC_DisableIRQ(RTC_IRQn);
|
HAL_NVIC_DisableIRQ(RTC_IRQn);
|
||||||
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
|
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
|
||||||
/* USER CODE BEGIN RTC_MspDeInit 1 */
|
/* USER CODE BEGIN RTC_MspDeInit 1 */
|
||||||
|
|
||||||
/* USER CODE END RTC_MspDeInit 1 */
|
/* USER CODE END RTC_MspDeInit 1 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user