Skip to content

Add STM32RTC library source files #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from Apr 25, 2018
Merged

Add STM32RTC library source files #1

merged 5 commits into from Apr 25, 2018

Conversation

ghost
Copy link

@ghost ghost commented Dec 13, 2017

Source files of the RTC library.

This library is based on the RTCZero library.
We tried to keep the compatibility as far as possible.

Tested on NUCLEO-L476RG and NUCLEO-L053R8.
Compilation test OK on all variant boards.

Requires the validation of this PR.

@ghost ghost requested review from LMESTM, fpistm and VVESTM December 13, 2017 10:14
@LMESTM
Copy link
Member

LMESTM commented Dec 13, 2017

@fprwi6labs
thanks for the PR.
Please edit and update the Pull Request title to something more precise than "Add source files"

@ghost ghost changed the title Add source files Add STM32RTC library source files Dec 13, 2017
@LMESTM
Copy link
Member

LMESTM commented Dec 13, 2017

@fpistm just told me there is a dependency to stm32duino/Arduino_Core_STM32#177
Would be good to mention it in the PR description here, I was looking for services like RTC_Init and was not finding them ...

Copy link
Member

@LMESTM LMESTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few questions and comments

@@ -0,0 +1,814 @@
/**
******************************************************************************
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please edit the commit title to something specific => Like STM32 RTC library

******************************************************************************
*/

#include <time.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is being used from time.h ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Epoch conversion needs time functions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thx

#define EPOCH_TIME_YEAR_OFF 100 // years since 1900

// Initialize static variable
bool STM32RTC::_configured = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't this be initialized in the STM32RTC::STM32RTC(void) constructor?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it couldn't because we use a static variable to avoid the overwrite of a previous RTC configuration in case the user create is own object and a library call another. It is the case with the future low power library.

src/STM32RTC.cpp Outdated
* @retval None
*/
void STM32RTC::begin(hourFormat_t format)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hourFormat_t is a type of the core - it would be easier to read to have a type defined in the library that will map to the one of the core.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

src/STM32RTC.h Outdated
#endif

typedef void(*voidFuncPtr)(void);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as proposed in the RTC PR of the core, could make sense to add a (void* data) parameter to the callback.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

RTC_StopAlarm();
break;
case MATCH_YYMMDDHHMMSS://kept for compatibility
case MATCH_MMDDHHMMSS: //kept for compatibility
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the limitation about year / months described ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside the header file.

src/STM32RTC.cpp Outdated
// Kept for compatibility.
void STM32RTC::setAlarmMonth(uint8_t month)
{
UNUSED(month);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain and document the implication of not using / supporting the month

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

src/STM32RTC.cpp Outdated
// Kept for compatibility.
void STM32RTC::setAlarmYear(uint8_t year)
{
UNUSED(year);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain and document the implication of not using / supporting the year

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

src/STM32RTC.cpp Outdated

// Kept for compatibility.
void STM32RTC::setAlarmDate(uint8_t day, uint8_t month, uint8_t year)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not setting the day ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

src/STM32RTC.h Outdated
#define HOUR_24 HOUR_FORMAT_24

//Hour AM/PM definition
#define HOUR_AM AM //AM or 24 hours
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean that hourAM_PM_t will always be HOUR_AM when hourFormat_t is HOUR_24 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. It is documented in board datasheet:

Bit 22 PM: AM/PM notation
0: AM or 24-hour format
1: PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least I would like to have all information in this file so if you can add better comments of each type definition in this header file that would help users. Otherwise they don't know which define corresponds to which type.

README.md Outdated
The following functions have been added to support specific STM32 RTC features:

_RTC hours mode (12 or 24)_
* **`void begin(hourFormat_t format)`**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be RTCHourFormats_t ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

README.md Outdated

_Hour format (AM or PM)_
* **`uint8_t getHours(hourAM_PM_t *format)`**
* **`void setHours(uint8_t hours, hourAM_PM_t format)`**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be Hour12_AM_PM_t now ?
same in below functions ?

LMESTM
LMESTM previously approved these changes Dec 14, 2017
Copy link
Member

@LMESTM LMESTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fprwi6labs Looks all good to me now - thanks for all the quick changes ! Approved from my side.

* @param format: hour format: HOUR_12 or HOUR_24(default)
* @retval None
*/
void STM32RTC::begin(RTCHourFormats_t format)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should provide a way to select RTC clock source (HSE, LSI, LSE)
Even if all LP is not reachable depending of the clock source.
Not All Nucleo board provide LSE by default.

@fpistm fpistm dismissed LMESTM’s stale review January 23, 2018 16:14

Need to handle RTC clock config. Currently fixed config.

fpr added 2 commits January 24, 2018 14:08
@ghost
Copy link
Author

ghost commented Jan 24, 2018

Library updated.
The RTC clock source can be selected.
By default, LSI is used as RTC clock source.

@ghost ghost requested a review from fpistm January 24, 2018 13:18
Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fine to add one example with clock source selection.

@@ -0,0 +1,107 @@
/**
******************************************************************************
* @file simpleRTC.ino
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: sSimpleRTC.ino

@@ -0,0 +1,77 @@
/**
******************************************************************************
* @file Epoch.ino
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simpleRTCAlarm.ino

README.md Outdated
This library is based on the Arduino RTCZero library.
You can take control of the internal RTC of the STM32 boards.

The following functions are not supported:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the reason why not supported

README.md Outdated
# API

This library is based on the Arduino RTCZero library.
You can take control of the internal RTC of the STM32 boards.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use passive form to avoid use of 'you'

README.md Outdated
* **`void setWeekDay(uint8_t weekDay)`**
* **`void setDate(uint8_t weekDay, uint8_t day, uint8_t month, uint8_t year)`**

Refer you to the Arduino RTC documentation for the other functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove 'you'

README.md Outdated

## Source

You can find the source files at
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passive form:

Source file available at:


#include <STM32RTC.h>

/* Create an rtc object */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a rtc

fpr added 2 commits March 15, 2018 09:53
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
@ghost
Copy link
Author

ghost commented Mar 15, 2018

@fpistm
Fix done.
Example with clock selection added.

@ghost ghost requested review from LMESTM and fpistm March 15, 2018 08:56
@fpistm fpistm assigned ghost Apr 24, 2018
@fpistm
Copy link
Member

fpistm commented Apr 24, 2018

This PR is corrected and extended by #2

@fpistm fpistm merged commit 6cb058c into stm32duino:master Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants