OpenMPTL - STM32F4
C++ Microprocessor Template Library
pwr.hpp
Go to the documentation of this file.
1 /*
2  * OpenMPTL - C++ Microprocessor Template Library
3  *
4  * Copyright (C) 2012-2017 Axel Burri <axel@tty0.ch>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef ARCH_PWR_HPP_INCLUDED
22 #define ARCH_PWR_HPP_INCLUDED
23 
24 #include <arch/reg/pwr.hpp>
25 #include <voltage.hpp>
26 
27 namespace mptl {
28 
29 template< voltage_t _system_voltage = volt(3.3) >
30 class pwr
31 {
32  static_assert(_system_voltage >= volt(1.8) && _system_voltage <= volt(3.6), "unsupported system voltage");
33 
34  template< typename system_clock_type >
35  struct power_save_enable_impl {
36  static_assert(system_clock_type::hclk_freq <= mhz(144), "system clock frequency too high for power save feature");
37  using type = regval< PWR::CR::VOS, 0 >;
38  };
39 
40 public:
41 
42  static constexpr voltage_t system_voltage = _system_voltage;
43 
44 public: /* ------ configuration traits ------ */
45 
46  /** disable high performance mode */
47  template< typename system_clock_type >
49 
50 public: /* ------ static member functions ------ */
51 
54  }
55 };
56 
57 } // namespace mptl
58 
59 #endif // ARCH_PWR_HPP_INCLUDED
static constexpr voltage_t system_voltage
Definition: pwr.hpp:42
static void disable_backup_domain_write_protection(void)
Definition: pwr.hpp:52
static constexpr voltage_t volt(long double x)
static constexpr freq_t mhz(unsigned long long x)
Definition: pwr.hpp:30
unsigned int voltage_t
typename power_save_enable_impl< system_clock_type >::type power_save_enable
disable high performance mode
Definition: pwr.hpp:48