Skip to content

PR 177 review: Add RTC driver #235

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 8 commits into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions cores/arduino/stm32/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,12 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
} else {
RTC_TimeStruct.TimeFormat = RTC_HOURFORMAT12_AM;
}
#if !defined(STM32F2xx) && !defined(STM32L1xx)
RTC_TimeStruct.SubSeconds = subSeconds;
RTC_TimeStruct.SecondFraction = 0;
#elif defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
RTC_TimeStruct.SubSeconds = subSeconds;
RTC_TimeStruct.SecondFraction = 0;
#else
UNUSED(subSeconds);
#endif //!defined(STM32F2xx) && !defined(STM32L1xx)
#endif //!defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
RTC_TimeStruct.DayLightSaving = RTC_STOREOPERATION_RESET;
RTC_TimeStruct.StoreOperation = RTC_DAYLIGHTSAVING_NONE;
#else
Expand Down Expand Up @@ -490,9 +487,7 @@ void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *s
} else {
*format = AM;
}
#if !defined(STM32F2xx) && !defined(STM32L1xx)
*subSeconds = RTC_TimeStruct.SubSeconds;
#elif defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
*subSeconds = RTC_TimeStruct.SubSeconds;
#endif
#endif // !defined(STM32F1xx)
Expand Down Expand Up @@ -568,10 +563,7 @@ void RTC_StartAlarm(uint8_t date, uint8_t hours, uint8_t minutes, uint8_t second
RTC_AlarmStructure.AlarmTime.Minutes = minutes;
RTC_AlarmStructure.AlarmTime.Hours = hours;
#if !defined(STM32F1xx)
#if !defined(STM32F2xx) && !defined(STM32L1xx)
RTC_AlarmStructure.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_SS14_10;
RTC_AlarmStructure.AlarmTime.SubSeconds = subSeconds;
#elif defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
RTC_AlarmStructure.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_SS14_10;
RTC_AlarmStructure.AlarmTime.SubSeconds = subSeconds;
#else
Expand Down Expand Up @@ -639,9 +631,7 @@ void RTC_GetAlarm(uint8_t *date, uint8_t *hours, uint8_t *minutes, uint8_t *seco
} else {
*format = AM;
}
#if !defined(STM32F2xx) && !defined(STM32L1xx)
*subSeconds = RTC_AlarmStructure.AlarmTime.SubSeconds;
#elif defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
*subSeconds = RTC_AlarmStructure.AlarmTime.SubSeconds;
#endif
#endif // !defined(STM32F1xx)
Expand Down
11 changes: 11 additions & 0 deletions cores/arduino/stm32/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ typedef enum {
typedef void(*voidCallbackPtr)(void *);

/* Exported constants --------------------------------------------------------*/
/* Ultra Low Power High (ULPH) density */
#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) ||\
defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) ||\
defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) ||\
defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) ||\
defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) ||\
defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) ||\
defined (STM32L162xDX)
#define STM32L1_ULPH
#endif

#if defined(STM32F0xx) || defined(STM32L0xx)
#define RTC_Alarm_IRQn RTC_IRQn
#define RTC_Alarm_IRQHandler RTC_IRQHandler
Expand Down