mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 16:55:58 +00:00
83 lines
2.2 KiB
C++
83 lines
2.2 KiB
C++
/**
|
|
* @file
|
|
* @brief Helper macros for STM32 clock queries.
|
|
*/
|
|
#ifndef STA_STM32_CLOCKS_HPP
|
|
#define STA_STM32_CLOCKS_HPP
|
|
|
|
/**
|
|
* @defgroup stm32 STM32
|
|
* @brief Modules implemented for STM32 MCUs.
|
|
*/
|
|
|
|
/**
|
|
* @defgroup stm32BuildConfig Build config
|
|
* @ingroup stm32
|
|
* @brief Build configuration options.
|
|
*/
|
|
|
|
/**
|
|
* @defgroup stm32Clocks Clocks
|
|
* @ingroup stm32
|
|
* @brief STM32 clock queries.
|
|
* @{
|
|
*/
|
|
|
|
#include <sta/config.hpp>
|
|
|
|
#include <sta/stm32/hal.hpp>
|
|
|
|
|
|
/**
|
|
* @brief Get function returning PCLK frequency.
|
|
*
|
|
* @param n Index of peripheral clock
|
|
*/
|
|
#define STA_STM32_GET_PCLK_FREQ_FN(n) HAL_RCC_GetPCLK ## n ## Freq
|
|
|
|
|
|
// Internal helper for macro expansion
|
|
#define _STA_STM32_GET_PCLK_FREQ_FN(n) STA_STM32_GET_PCLK_FREQ_FN(n)
|
|
// Get instance to PCLK index map macro
|
|
#define _STA_STM32_PCLK_IDX_MAP(type, idx) STA_STM32_ ## type ## _ ## idx ## _PCLK_IDX
|
|
// Get HAL handle to PCLK index map macro
|
|
#define _STA_STM32_HANDLE_PCLK_IDX_MAP(handle) STA_STM32_ ## handle ## _PCLK_IDX
|
|
|
|
|
|
/**
|
|
* @brief Get function returning frequency of PCLK used by TIM.
|
|
*
|
|
* @param n TIM index
|
|
*/
|
|
#define STA_STM32_GET_TIM_PCLK_FREQ_FN(n) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_PCLK_IDX_MAP(TIM, n))
|
|
/**
|
|
* @brief Get function returning frequency of PCLK used by SPI interface.
|
|
*
|
|
* @param n SPI interface index
|
|
*/
|
|
#define STA_STM32_GET_SPI_PCLK_FREQ_FN(n) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_PCLK_IDX_MAP(SPI, n))
|
|
/**
|
|
* @brief Get function returning frequency of PCLK used by I2C interface.
|
|
*
|
|
* @param n I2C interface index
|
|
*/
|
|
#define STA_STM32_GET_I2C_PCLK_FREQ_FN(n) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_PCLK_IDX_MAP(I2C, n))
|
|
/**
|
|
* @brief Get function returning frequency of PCLK used by USART interface.
|
|
*
|
|
* @param n USART interface index
|
|
*/
|
|
#define STA_STM32_GET_USART_PCLK_FREQ_FN(n) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_PCLK_IDX_MAP(USART, n))
|
|
|
|
/**
|
|
* @brief Get function returning frequency of PCLK used by HAL instance.
|
|
*
|
|
* @param handle Instance handle
|
|
*/
|
|
#define STA_STM32_GET_HANDLE_PCLK_FREQ_FN(handle) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_HANDLE_PCLK_IDX_MAP(handle))
|
|
|
|
|
|
/** @} */
|
|
|
|
#endif // STA_STM32_CLOCKS_HPP
|