distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
getBusFrequency.hpp
Go to the documentation of this file.
1 
12 #ifndef SOURCE_CHIP_STM32_STM32F4_INCLUDE_DISTORTOS_CHIP_GETBUSFREQUENCY_HPP_
13 #define SOURCE_CHIP_STM32_STM32F4_INCLUDE_DISTORTOS_CHIP_GETBUSFREQUENCY_HPP_
14 
17 
18 namespace distortos
19 {
20 
21 namespace chip
22 {
23 
32 constexpr uint32_t getBusFrequency(const uintptr_t peripheralBase)
33 {
34  return peripheralBase >= AHB1PERIPH_BASE ? ahbFrequency :
35  peripheralBase >= APB2PERIPH_BASE ? apb2Frequency : apb1Frequency;
36 }
37 
38 } // namespace chip
39 
40 } // namespace distortos
41 
42 #endif // SOURCE_CHIP_STM32_STM32F4_INCLUDE_DISTORTOS_CHIP_GETBUSFREQUENCY_HPP_
CMSIS proxy header for STM32F4.
constexpr uint32_t getBusFrequency(const uintptr_t peripheralBase)
Returns frequency of the bus to which given peripheral is connected.
Definition: getBusFrequency.hpp:32
constexpr uint32_t apb1Frequency
APB1 frequency, Hz.
Definition: clocks.hpp:245
constexpr uint32_t apb2Frequency
APB2 frequency, Hz.
Definition: clocks.hpp:250
Top-level namespace of distortos project.
Definition: buttons.hpp:33
constexpr uint32_t ahbFrequency
AHB frequency, Hz.
Definition: clocks.hpp:242
Definitions of clocks for STM32F4.