File tree Expand file tree Collapse file tree 6 files changed +22
-23
lines changed Expand file tree Collapse file tree 6 files changed +22
-23
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ using namespace modm::literals;
35
35
// / supplied by the on-board st-link
36
36
struct SystemClock
37
37
{
38
+ static constexpr uint32_t Hse = 8_MHz;
38
39
static constexpr uint32_t Frequency = 72_MHz;
39
40
static constexpr uint32_t Ahb = Frequency;
40
41
static constexpr uint32_t Apb1 = Frequency / 2 ;
@@ -89,13 +90,12 @@ struct SystemClock
89
90
90
91
static constexpr uint32_t Usb = Ahb / 1.5 ;
91
92
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
92
- static constexpr uint32_t Rtc = Rcc::LsiFrequency ;
93
+ static constexpr uint32_t Rtc = Hse / 32 ;
93
94
94
95
static bool inline
95
96
enable ()
96
97
{
97
- Rcc::enableLowSpeedInternalClock ();
98
- Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::Lsi);
98
+ Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::ExternalClock);
99
99
100
100
Rcc::enableExternalClock (); // 8MHz
101
101
const Rcc::PllFactors pllFactors{
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ using namespace modm::literals;
36
36
// / STM32F401 running at 168MHz generated from the external 8MHz crystal
37
37
struct SystemClock
38
38
{
39
+ static constexpr uint32_t Hse = 8_MHz;
39
40
static constexpr uint32_t Frequency = 84_MHz;
40
41
static constexpr uint32_t Ahb = Frequency;
41
42
static constexpr uint32_t Apb1 = Frequency / 4 ;
@@ -72,15 +73,14 @@ struct SystemClock
72
73
73
74
static constexpr uint32_t Usb = 48_MHz;
74
75
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
75
- static constexpr uint32_t Rtc = Rcc::LsiFrequency ;
76
+ static constexpr uint32_t Rtc = Hse / 25 ;
76
77
77
78
static bool inline
78
79
enable ()
79
80
{
80
- Rcc::enableLowSpeedInternalClock ();
81
- Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::Lsi);
82
-
83
81
Rcc::enableExternalCrystal (); // 8MHz
82
+ Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::ExternalClock, 25 );
83
+
84
84
const Rcc::PllFactors pllFactors{
85
85
.pllM = 4 , // 8MHz / M=4 -> 2MHz
86
86
.pllN = 168 , // 2MHz * N=168 -> 336MHz
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ using namespace modm::literals;
34
34
// / STM32F407 running at 168MHz generated from the external 8MHz crystal
35
35
struct SystemClock
36
36
{
37
+ static constexpr uint32_t Hse = 8_MHz;
37
38
static constexpr uint32_t Frequency = 168_MHz;
38
39
static constexpr uint32_t Ahb = Frequency;
39
40
static constexpr uint32_t Apb1 = Frequency / 4 ;
@@ -83,15 +84,14 @@ struct SystemClock
83
84
84
85
static constexpr uint32_t Usb = 48_MHz;
85
86
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
86
- static constexpr uint32_t Rtc = Rcc::LsiFrequency ;
87
+ static constexpr uint32_t Rtc = Hse / 25 ;
87
88
88
89
static bool inline
89
90
enable ()
90
91
{
91
- Rcc::enableLowSpeedInternalClock ();
92
- Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::Lsi);
93
-
94
92
Rcc::enableExternalCrystal (); // 8MHz
93
+ Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::ExternalClock, 25 );
94
+
95
95
const Rcc::PllFactors pllFactors{
96
96
.pllM = 4 , // 8MHz / M=4 -> 2MHz
97
97
.pllN = 168 , // 2MHz * N=168 -> 336MHz
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ using namespace modm::literals;
29
29
// / STM32F411 running at 96MHz generated from the external 8MHz crystal
30
30
struct SystemClock
31
31
{
32
+ static constexpr uint32_t Hse = 8_MHz;
32
33
static constexpr uint32_t Frequency = 96_MHz;
33
34
static constexpr uint32_t Ahb = Frequency;
34
35
static constexpr uint32_t Apb1 = Frequency / 2 ;
@@ -68,15 +69,14 @@ struct SystemClock
68
69
69
70
static constexpr uint32_t Usb = 48_MHz;
70
71
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
71
- static constexpr uint32_t Rtc = Rcc::LsiFrequency ;
72
+ static constexpr uint32_t Rtc = Hse / 25 ;
72
73
73
74
static bool inline
74
75
enable ()
75
76
{
76
- Rcc::enableLowSpeedInternalClock ();
77
- Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::Lsi);
78
-
79
77
Rcc::enableExternalCrystal (); // 8MHz
78
+ Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::ExternalClock, 25 );
79
+
80
80
const Rcc::PllFactors pllFactors{
81
81
.pllM = 7 , // 8MHz / M=7 -> ~1.14MHz
82
82
.pllN = 336 , // 1.14MHz * N=336 -> 384MHz
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ using namespace modm::literals;
32
32
// / STM32F429 running at 168MHz from the external 8MHz crystal
33
33
struct SystemClock
34
34
{
35
+ static constexpr uint32_t Hse = 8_MHz;
35
36
static constexpr uint32_t Frequency = 168_MHz;
36
37
static constexpr uint32_t Apb1 = Frequency / 4 ;
37
38
static constexpr uint32_t Apb2 = Frequency / 2 ;
@@ -80,15 +81,14 @@ struct SystemClock
80
81
81
82
static constexpr uint32_t Usb = 48_MHz;
82
83
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
83
- static constexpr uint32_t Rtc = Rcc::LsiFrequency ;
84
+ static constexpr uint32_t Rtc = Hse / 25 ;
84
85
85
86
static bool inline
86
87
enable ()
87
88
{
88
- Rcc::enableLowSpeedInternalClock ();
89
- Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::Lsi);
90
-
91
89
Rcc::enableExternalCrystal (); // 8 MHz
90
+ Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::ExternalClock, 25 );
91
+
92
92
const Rcc::PllFactors pllFactors{
93
93
.pllM = 4 , // 8MHz / M -> 2MHz
94
94
.pllN = 168 , // 2MHz * N -> 336MHz
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ using namespace modm::literals;
31
31
// / STM32F030 running at 48MHz generated from the external 8MHz crystal
32
32
struct SystemClock
33
33
{
34
+ static constexpr uint32_t Hse = 8_MHz;
34
35
static constexpr uint32_t Frequency = 48_MHz;
35
36
static constexpr uint32_t Ahb = Frequency;
36
37
static constexpr uint32_t Apb = Frequency;
@@ -52,15 +53,13 @@ struct SystemClock
52
53
static constexpr uint32_t Timer16 = Apb;
53
54
static constexpr uint32_t Timer17 = Apb;
54
55
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
55
- static constexpr uint32_t Rtc = Rcc::LsiFrequency ;
56
+ static constexpr uint32_t Rtc = Hse / 32 ;
56
57
57
58
static bool inline
58
59
enable ()
59
60
{
60
- Rcc::enableLowSpeedInternalClock ();
61
- Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::Lsi);
62
-
63
61
Rcc::enableExternalCrystal (); // 8MHz
62
+ Rcc::enableRealTimeClock (Rcc::RealTimeClockSource::ExternalClock);
64
63
65
64
// external clock / 1 * 6 = 48MHz
66
65
const Rcc::PllFactors pllFactors{
You can’t perform that action at this time.
0 commit comments