Skip to content

Commit 42f3599

Browse files
committed
[board] Add RTC clock source support to all BSPs
1 parent 5d8123f commit 42f3599

File tree

50 files changed

+215
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+215
-13
lines changed

src/modm/board/black_pill_f103/board.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ struct SystemClock
5858

5959
static constexpr uint32_t Usb = Ahb / 1.5;
6060
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
61+
static constexpr uint32_t Rtc = 32.768_kHz;
6162

6263
static bool inline
6364
enable()
6465
{
66+
Rcc::enableLowSpeedExternalCrystal();
67+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::LowSpeedExternalCrystal);
68+
6569
Rcc::enableExternalCrystal();
6670

6771
// external clock * 9 = 72MHz, => 72/1.5 = 48 => good for USB

src/modm/board/black_pill_f411/board.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ struct SystemClock
6060

6161
static constexpr uint32_t Usb = 48_MHz;
6262
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
63+
static constexpr uint32_t Rtc = 32.768_kHz;
6364

6465
static bool inline
6566
enable()
6667
{
68+
Rcc::enableLowSpeedExternalCrystal();
69+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::LowSpeedExternalCrystal);
70+
6771
Rcc::enableExternalCrystal();
6872
const Rcc::PllFactors pllFactors{
6973
.pllM = 25, // 25MHz / M=25 -> 1MHz

src/modm/board/blue_pill_f103/board.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ struct SystemClock
5858

5959
static constexpr uint32_t Usb = Ahb / 1.5;
6060
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
61+
static constexpr uint32_t Rtc = 32.768_kHz;
6162

6263
static bool inline
6364
enable()
6465
{
66+
Rcc::enableLowSpeedExternalCrystal();
67+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::LowSpeedExternalCrystal);
68+
6569
Rcc::enableExternalCrystal();
6670

6771
// external clock * 9 = 72MHz, => 72/1.5 = 48 => good for USB

src/modm/board/devebox_stm32f4xx/board.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,14 @@ struct SystemClock
7575
static constexpr uint32_t Timer13 = Apb1Timer;
7676
static constexpr uint32_t Timer14 = Apb1Timer;
7777
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
78+
static constexpr uint32_t Rtc = 32.768_kHz;
7879

7980
static bool inline
8081
enable()
8182
{
83+
Rcc::enableLowSpeedExternalCrystal();
84+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::LowSpeedExternalCrystal);
85+
8286
Rcc::enableExternalCrystal(); // 8MHz
8387
const Rcc::PllFactors pllFactors{
8488
.pllM = 4, // 8MHz / M=4 -> 2MHz

src/modm/board/devebox_stm32h750vb/board.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,14 @@ struct SystemClock
9595

9696
static constexpr uint32_t Usb = 48_MHz; // From PLL3Q
9797
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
98+
static constexpr uint32_t Rtc = 32.768_kHz;
9899

99100
static bool inline
100101
enable()
101102
{
103+
Rcc::enableLowSpeedExternalCrystal();
104+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::LowSpeedExternalCrystal);
105+
102106
Rcc::enableExternalCrystal(); // 25MHz
103107
Rcc::setVoltageScaling(Rcc::VoltageScaling::Scale0); // required for 400MHz/480MHz
104108
const Rcc::PllFactors pllFactors1{

src/modm/board/disco_f051r8/board.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,19 @@ using namespace modm::literals;
2828
/// STM32F0 running at 48MHz generated from the internal 8MHz with PLL.
2929
struct SystemClock
3030
{
31-
static constexpr int Frequency = 48_MHz;
32-
static constexpr int Usart1 = Frequency;
33-
static constexpr int Usart2 = Frequency;
34-
static constexpr int Spi2 = Frequency;
31+
static constexpr uint32_t Frequency = 48_MHz;
32+
static constexpr uint32_t Usart1 = Frequency;
33+
static constexpr uint32_t Usart2 = Frequency;
34+
static constexpr uint32_t Spi2 = Frequency;
3535
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
36+
static constexpr uint32_t Rtc = Rcc::LsiFrequency;
3637

3738
static bool inline
3839
enable()
3940
{
41+
Rcc::enableLowSpeedInternalClock();
42+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::Lsi);
43+
4044
// enable internal 8 MHz HSI RC clock
4145
Rcc::enableInternalClock();
4246
// (internal clock / 2) * 12 = 48MHz

src/modm/board/disco_f072rb/board.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using namespace modm::literals;
3030
/// STM32F072 running at 48MHz generated from the internal 48MHz clock
3131
struct SystemClock
3232
{
33-
static constexpr int Frequency = 48_MHz;
33+
static constexpr uint32_t Frequency = 48_MHz;
3434
static constexpr uint32_t Ahb = Frequency;
3535
static constexpr uint32_t Apb = Frequency;
3636

@@ -60,10 +60,14 @@ struct SystemClock
6060

6161
static constexpr uint32_t Usb = 48_MHz;
6262
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
63+
static constexpr uint32_t Rtc = Rcc::LsiFrequency;
6364

6465
static bool inline
6566
enable()
6667
{
68+
Rcc::enableLowSpeedInternalClock();
69+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::Lsi);
70+
6771
// Enable the internal 48MHz clock
6872
Rcc::enableInternalClockMHz48();
6973
// set flash latency for 48MHz

src/modm/board/disco_f100rb/board.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@ struct SystemClock
6868
static constexpr uint32_t Timer16 = Apb2Timer;
6969
static constexpr uint32_t Timer17 = Apb2Timer;
7070
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
71+
static constexpr uint32_t Rtc = 32.768_kHz;
7172

7273
static bool inline
7374
enable()
7475
{
76+
Rcc::enableLowSpeedExternalCrystal();
77+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::LowSpeedExternalCrystal);
78+
7579
Rcc::enableExternalCrystal(); // 8MHz
7680
const Rcc::PllFactors pllFactors{
7781
.pllMul = 3,

src/modm/board/disco_f303vc/board.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,14 @@ struct SystemClock
8585

8686
static constexpr uint32_t Usb = Ahb / 1.5;
8787
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
88+
static constexpr uint32_t Rtc = Rcc::LsiFrequency;
8889

8990
static bool inline
9091
enable()
9192
{
93+
Rcc::enableLowSpeedInternalClock();
94+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::Lsi);
95+
9296
Rcc::enableExternalClock(); // 8MHz
9397
const Rcc::PllFactors pllFactors{
9498
.pllMul = 9,

src/modm/board/disco_f401vc/board.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@ struct SystemClock
6868

6969
static constexpr uint32_t Usb = 48_MHz;
7070
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
71+
static constexpr uint32_t Rtc = Rcc::LsiFrequency;
7172

7273
static bool inline
7374
enable()
7475
{
76+
Rcc::enableLowSpeedInternalClock();
77+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::Lsi);
78+
7579
Rcc::enableExternalCrystal(); // 8MHz
7680
const Rcc::PllFactors pllFactors{
7781
.pllM = 4, // 8MHz / M=4 -> 2MHz

0 commit comments

Comments
 (0)