mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 19:54:39 +00:00
C++14: const all the methods!
This commit is contained in:
parent
01cd8c7776
commit
0ea2f9650e
@ -168,7 +168,7 @@ struct Inputs {
|
||||
const uint32_t f_clkin;
|
||||
const uint32_t clkin_div;
|
||||
|
||||
constexpr uint32_t f_clkin_out() {
|
||||
constexpr uint32_t f_clkin_out() const {
|
||||
return f_clkin / clkin_div;
|
||||
}
|
||||
};
|
||||
@ -181,23 +181,23 @@ struct PLL {
|
||||
const uint32_t b;
|
||||
const uint32_t c;
|
||||
|
||||
constexpr uint32_t f_vco() {
|
||||
constexpr uint32_t f_vco() const {
|
||||
return f_in * (a + (float)b / (float)c);
|
||||
}
|
||||
|
||||
constexpr uint32_t p1() {
|
||||
constexpr uint32_t p1() const {
|
||||
return 128 * a + (uint32_t)(128 * (float)b / (float)c) - 512;
|
||||
}
|
||||
|
||||
constexpr uint32_t p2() {
|
||||
constexpr uint32_t p2() const {
|
||||
return 128 * b - c * (uint32_t)(128 * (float)b / (float)c);
|
||||
}
|
||||
|
||||
constexpr uint32_t p3() {
|
||||
constexpr uint32_t p3() const {
|
||||
return c;
|
||||
}
|
||||
|
||||
constexpr PLLReg reg(const uint8_t pll_n) {
|
||||
constexpr PLLReg reg(const uint8_t pll_n) const {
|
||||
return {
|
||||
uint8_t(26 + (pll_n * 8)),
|
||||
uint8_t((p3() >> 8) & 0xff),
|
||||
@ -224,23 +224,23 @@ struct MultisynthFractional {
|
||||
const uint32_t c;
|
||||
const uint32_t r_div;
|
||||
|
||||
constexpr uint32_t p1() {
|
||||
constexpr uint32_t p1() const {
|
||||
return 128 * a + (uint32_t)(128 * (float)b / (float)c) - 512;
|
||||
}
|
||||
|
||||
constexpr uint32_t p2() {
|
||||
constexpr uint32_t p2() const {
|
||||
return 128 * b - c * (uint32_t)(128 * (float)b / (float)c);
|
||||
}
|
||||
|
||||
constexpr uint32_t p3() {
|
||||
constexpr uint32_t p3() const {
|
||||
return c;
|
||||
}
|
||||
|
||||
constexpr uint32_t f_out() {
|
||||
constexpr uint32_t f_out() const {
|
||||
return f_src / (a + (float)b / (float)c) / (1 << r_div);
|
||||
}
|
||||
|
||||
constexpr MultisynthFractionalReg reg(const uint8_t multisynth_n) {
|
||||
constexpr MultisynthFractionalReg reg(const uint8_t multisynth_n) const {
|
||||
return {
|
||||
uint8_t(42 + (multisynth_n * 8)),
|
||||
uint8_t((p3() >> 8) & 0xFF),
|
||||
@ -260,11 +260,11 @@ struct MultisynthInteger {
|
||||
const uint32_t a;
|
||||
const uint32_t r_div;
|
||||
|
||||
constexpr uint8_t p1() {
|
||||
constexpr uint8_t p1() const {
|
||||
return a;
|
||||
}
|
||||
|
||||
constexpr uint32_t f_out() {
|
||||
constexpr uint32_t f_out() const {
|
||||
return f_src / a / (1 << r_div);
|
||||
}
|
||||
};
|
||||
|
@ -46,15 +46,15 @@ struct I2CClockConfig {
|
||||
return 1e9 / f;
|
||||
}
|
||||
|
||||
constexpr uint32_t i2c_period_count() {
|
||||
constexpr uint32_t i2c_period_count() const {
|
||||
return period_ns(bus_f) / period_ns(clock_source_f) + 0.5f;
|
||||
}
|
||||
|
||||
constexpr uint32_t i2c_high_count() {
|
||||
constexpr uint32_t i2c_high_count() const {
|
||||
return high_period_ns / period_ns(clock_source_f) + 0.5f;
|
||||
}
|
||||
|
||||
constexpr uint32_t i2c_low_count() {
|
||||
constexpr uint32_t i2c_low_count() const {
|
||||
return i2c_period_count() - i2c_high_count();
|
||||
}
|
||||
};
|
||||
|
@ -43,15 +43,15 @@ public:
|
||||
|
||||
}
|
||||
|
||||
constexpr uint32_t base() {
|
||||
constexpr uint32_t base() const {
|
||||
return base_;
|
||||
}
|
||||
|
||||
constexpr uint32_t end() {
|
||||
constexpr uint32_t end() const {
|
||||
return base_ + size_;
|
||||
}
|
||||
|
||||
constexpr size_t size() {
|
||||
constexpr size_t size() const {
|
||||
return size_;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ struct region_t {
|
||||
const size_t offset;
|
||||
const size_t size;
|
||||
|
||||
constexpr const void* base() {
|
||||
constexpr const void* base() const {
|
||||
return reinterpret_cast<void*>(portapack::memory::map::spifi_cached.base() + offset);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user