-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proto for blue_pill_f103, board/disco_f411ve
- Loading branch information
Showing
4 changed files
with
225 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#pragma once | ||
|
||
#include <modm/architecture/interface/clock.hpp> | ||
|
||
namespace modm::platform | ||
{ | ||
|
||
// @todo integrate with /platform/clock/stm32/rcc.hpp.in | ||
class RccProto | ||
{ | ||
public: | ||
template<Rcc::AhbPrescaler Prescaler> | ||
static consteval int | ||
prescalerToValue() | ||
{ | ||
switch (Prescaler) | ||
{ | ||
case Rcc::AhbPrescaler::Div1: return 1; | ||
case Rcc::AhbPrescaler::Div2: return 2; | ||
case Rcc::AhbPrescaler::Div4: return 4; | ||
case Rcc::AhbPrescaler::Div8: return 8; | ||
case Rcc::AhbPrescaler::Div16: return 16; | ||
case Rcc::AhbPrescaler::Div64: return 64; | ||
case Rcc::AhbPrescaler::Div128: return 128; | ||
case Rcc::AhbPrescaler::Div256: return 256; | ||
case Rcc::AhbPrescaler::Div512: return 512; | ||
}; | ||
} | ||
|
||
template<Rcc::Apb1Prescaler Prescaler> | ||
static consteval int | ||
prescalerToValue() | ||
{ | ||
switch (Prescaler) | ||
{ | ||
case Rcc::Apb1Prescaler::Div1: return 1; | ||
case Rcc::Apb1Prescaler::Div2: return 2; | ||
case Rcc::Apb1Prescaler::Div4: return 4; | ||
case Rcc::Apb1Prescaler::Div8: return 8; | ||
case Rcc::Apb1Prescaler::Div16: return 16; | ||
}; | ||
} | ||
|
||
template<Rcc::Apb2Prescaler Prescaler> | ||
static consteval int | ||
prescalerToValue() | ||
{ | ||
switch (Prescaler) | ||
{ | ||
case Rcc::Apb2Prescaler::Div1: return 1; | ||
case Rcc::Apb2Prescaler::Div2: return 2; | ||
case Rcc::Apb2Prescaler::Div4: return 4; | ||
case Rcc::Apb2Prescaler::Div8: return 8; | ||
case Rcc::Apb2Prescaler::Div16: return 16; | ||
} | ||
} | ||
|
||
template<Rcc::UsbPrescaler Prescaler> | ||
static consteval float | ||
prescalerToValue() | ||
{ | ||
switch (Prescaler) | ||
{ | ||
case Rcc::UsbPrescaler::Div1: return 1; | ||
case Rcc::UsbPrescaler::Div1_5: return 1.5; | ||
} | ||
} | ||
}; | ||
|
||
} // namespace modm::platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#pragma once | ||
|
||
#include <modm/architecture/interface/clock.hpp> | ||
|
||
namespace modm::platform | ||
{ | ||
|
||
// @todo integrate with /platform/clock/stm32/rcc.hpp.in | ||
class RccProto | ||
{ | ||
public: | ||
template<Rcc::AhbPrescaler Prescaler> | ||
static consteval int | ||
prescalerToValue() | ||
{ | ||
switch (Prescaler) | ||
{ | ||
case Rcc::AhbPrescaler::Div1: return 1; | ||
case Rcc::AhbPrescaler::Div2: return 2; | ||
case Rcc::AhbPrescaler::Div4: return 4; | ||
case Rcc::AhbPrescaler::Div8: return 8; | ||
case Rcc::AhbPrescaler::Div16: return 16; | ||
case Rcc::AhbPrescaler::Div64: return 64; | ||
case Rcc::AhbPrescaler::Div128: return 128; | ||
case Rcc::AhbPrescaler::Div256: return 256; | ||
case Rcc::AhbPrescaler::Div512: return 512; | ||
}; | ||
} | ||
|
||
template<Rcc::Apb1Prescaler Prescaler> | ||
static consteval int | ||
prescalerToValue() | ||
{ | ||
switch (Prescaler) | ||
{ | ||
case Rcc::Apb1Prescaler::Div1: return 1; | ||
case Rcc::Apb1Prescaler::Div2: return 2; | ||
case Rcc::Apb1Prescaler::Div4: return 4; | ||
case Rcc::Apb1Prescaler::Div8: return 8; | ||
case Rcc::Apb1Prescaler::Div16: return 16; | ||
}; | ||
} | ||
|
||
template<Rcc::Apb2Prescaler Prescaler> | ||
static consteval int | ||
prescalerToValue() | ||
{ | ||
switch (Prescaler) | ||
{ | ||
case Rcc::Apb2Prescaler::Div1: return 1; | ||
case Rcc::Apb2Prescaler::Div2: return 2; | ||
case Rcc::Apb2Prescaler::Div4: return 4; | ||
case Rcc::Apb2Prescaler::Div8: return 8; | ||
case Rcc::Apb2Prescaler::Div16: return 16; | ||
} | ||
} | ||
}; | ||
} // namespace modm::platform |