Skip to content

Commit ff77ff9

Browse files
committed
Use Ultra Low Power High (ULPH) density definition to factorize code
#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 Signed-off-by: Frederic.Pillon <[email protected]>
1 parent d8e15d9 commit ff77ff9

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

cores/arduino/stm32/rtc.c

+5-15
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,12 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
446446
} else {
447447
RTC_TimeStruct.TimeFormat = RTC_HOURFORMAT12_AM;
448448
}
449-
#if !defined(STM32F2xx) && !defined(STM32L1xx)
450-
RTC_TimeStruct.SubSeconds = subSeconds;
451-
RTC_TimeStruct.SecondFraction = 0;
452-
#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)
449+
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
453450
RTC_TimeStruct.SubSeconds = subSeconds;
454451
RTC_TimeStruct.SecondFraction = 0;
455452
#else
456453
UNUSED(subSeconds);
457-
#endif //!defined(STM32F2xx) && !defined(STM32L1xx)
454+
#endif //!defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
458455
RTC_TimeStruct.DayLightSaving = RTC_STOREOPERATION_RESET;
459456
RTC_TimeStruct.StoreOperation = RTC_DAYLIGHTSAVING_NONE;
460457
#else
@@ -490,9 +487,7 @@ void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *s
490487
} else {
491488
*format = AM;
492489
}
493-
#if !defined(STM32F2xx) && !defined(STM32L1xx)
494-
*subSeconds = RTC_TimeStruct.SubSeconds;
495-
#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)
490+
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
496491
*subSeconds = RTC_TimeStruct.SubSeconds;
497492
#endif
498493
#endif // !defined(STM32F1xx)
@@ -568,10 +563,7 @@ void RTC_StartAlarm(uint8_t date, uint8_t hours, uint8_t minutes, uint8_t second
568563
RTC_AlarmStructure.AlarmTime.Minutes = minutes;
569564
RTC_AlarmStructure.AlarmTime.Hours = hours;
570565
#if !defined(STM32F1xx)
571-
#if !defined(STM32F2xx) && !defined(STM32L1xx)
572-
RTC_AlarmStructure.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_SS14_10;
573-
RTC_AlarmStructure.AlarmTime.SubSeconds = subSeconds;
574-
#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)
566+
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
575567
RTC_AlarmStructure.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_SS14_10;
576568
RTC_AlarmStructure.AlarmTime.SubSeconds = subSeconds;
577569
#else
@@ -639,9 +631,7 @@ void RTC_GetAlarm(uint8_t *date, uint8_t *hours, uint8_t *minutes, uint8_t *seco
639631
} else {
640632
*format = AM;
641633
}
642-
#if !defined(STM32F2xx) && !defined(STM32L1xx)
643-
*subSeconds = RTC_AlarmStructure.AlarmTime.SubSeconds;
644-
#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)
634+
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
645635
*subSeconds = RTC_AlarmStructure.AlarmTime.SubSeconds;
646636
#endif
647637
#endif // !defined(STM32F1xx)

cores/arduino/stm32/rtc.h

+11
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ typedef enum {
6969
typedef void(*voidCallbackPtr)(void *);
7070

7171
/* Exported constants --------------------------------------------------------*/
72+
/* Ultra Low Power High (ULPH) density */
73+
#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) ||\
74+
defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) ||\
75+
defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) ||\
76+
defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) ||\
77+
defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) ||\
78+
defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) ||\
79+
defined (STM32L162xDX)
80+
#define STM32L1_ULPH
81+
#endif
82+
7283
#if defined(STM32F0xx) || defined(STM32L0xx)
7384
#define RTC_Alarm_IRQn RTC_IRQn
7485
#define RTC_Alarm_IRQHandler RTC_IRQHandler

0 commit comments

Comments
 (0)