-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58e8709
commit 81acbe6
Showing
18 changed files
with
12,395 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef APPLICATION_INC_RTC | ||
#define APPLICATION_INC_RTC | ||
|
||
#include "array" | ||
#include "main.h" | ||
|
||
class CustomRTC { | ||
public: | ||
CustomRTC(); | ||
~CustomRTC(); | ||
void setPort(RTC_HandleTypeDef *port); | ||
|
||
void setTime(uint8_t hour, uint8_t minute, uint8_t second); | ||
void setDate(uint8_t day, uint8_t month, uint8_t year); | ||
std::array<uint8_t, 3> getDate(); | ||
std::array<uint8_t, 3> getTime(); | ||
|
||
private: | ||
RTC_HandleTypeDef m_port; | ||
RTC_TimeTypeDef m_time; | ||
RTC_DateTypeDef m_date; | ||
}; | ||
|
||
#endif /* APPLICATION_INC_RTC */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
// fill all functions in this file | ||
|
||
#include "RTC.hpp" | ||
|
||
#include "instances.hpp" | ||
|
||
CustomRTC::CustomRTC() {} | ||
|
||
CustomRTC::~CustomRTC() {} | ||
|
||
void CustomRTC::setPort(RTC_HandleTypeDef *port) { m_port = *port; } | ||
|
||
void CustomRTC::setTime(uint8_t hour, uint8_t minute, uint8_t second) { | ||
m_time.Hours = hour; | ||
m_time.Minutes = minute; | ||
m_time.Seconds = second; | ||
if (HAL_RTC_SetTime(&m_port, &m_time, RTC_FORMAT_BIN) != HAL_OK) { | ||
serialCOM.sendString("RTC Set Time Error\n"); | ||
} | ||
} | ||
|
||
void CustomRTC::setDate(uint8_t day, uint8_t month, uint8_t year) { | ||
m_date.Date = day; | ||
m_date.Month = month; | ||
m_date.Year = year; | ||
if (HAL_RTC_SetDate(&m_port, &m_date, RTC_FORMAT_BIN) != HAL_OK) { | ||
serialCOM.sendString("RTC Set Date Error\n"); | ||
} | ||
} | ||
|
||
std::array<uint8_t, 3> CustomRTC::getDate() { | ||
if (HAL_RTC_GetDate(&m_port, &m_date, RTC_FORMAT_BIN) != HAL_OK) { | ||
serialCOM.sendString("RTC Get Date Error\n"); | ||
} | ||
return {m_date.Date, m_date.Month, m_date.Year}; | ||
} | ||
|
||
std::array<uint8_t, 3> CustomRTC::getTime() { | ||
if (HAL_RTC_GetTime(&m_port, &m_time, RTC_FORMAT_BIN) != HAL_OK) { | ||
serialCOM.sendString("RTC Get Time Error\n"); | ||
} | ||
return {m_time.Hours, m_time.Minutes, m_time.Seconds}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* USER CODE BEGIN Header */ | ||
/** | ||
****************************************************************************** | ||
* @file rtc.h | ||
* @brief This file contains all the function prototypes for | ||
* the rtc.c file | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* Copyright (c) 2023 STMicroelectronics. | ||
* All rights reserved. | ||
* | ||
* This software is licensed under terms that can be found in the LICENSE file | ||
* in the root directory of this software component. | ||
* If no LICENSE file comes with this software, it is provided AS-IS. | ||
* | ||
****************************************************************************** | ||
*/ | ||
/* USER CODE END Header */ | ||
/* Define to prevent recursive inclusion -------------------------------------*/ | ||
#ifndef __RTC_H__ | ||
#define __RTC_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Includes ------------------------------------------------------------------*/ | ||
#include "main.h" | ||
|
||
/* USER CODE BEGIN Includes */ | ||
|
||
/* USER CODE END Includes */ | ||
|
||
extern RTC_HandleTypeDef hrtc; | ||
|
||
/* USER CODE BEGIN Private defines */ | ||
|
||
/* USER CODE END Private defines */ | ||
|
||
void MX_RTC_Init(void); | ||
|
||
/* USER CODE BEGIN Prototypes */ | ||
|
||
/* USER CODE END Prototypes */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __RTC_H__ */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.