mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-06 02:27:33 +00:00
Added I2C support for raspi & first rework of debugging
This commit is contained in:
107
include/sta/devices/stm32/clocks.hpp
Normal file
107
include/sta/devices/stm32/clocks.hpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Helper macros for STM32 clock queries.
|
||||
*/
|
||||
#ifndef STA_CORE_STM32_CLOCKS_HPP
|
||||
#define STA_CORE_STM32_CLOCKS_HPP
|
||||
|
||||
|
||||
// Only enable module on STM32 platform
|
||||
#include <sta/config.hpp>
|
||||
|
||||
|
||||
#if defined(STA_PLATFORM_STM32) || defined(DOXYGEN)
|
||||
|
||||
#include <sta/stm32/hal.hpp>
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup sta_core_stm32_clocks Clocks
|
||||
* @ingroup sta_core_stm32
|
||||
* @brief STM32 Clock queries.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Get peripheral clock frequency.
|
||||
*
|
||||
* @return Clock frequency
|
||||
*/
|
||||
using PCLKFreqFn = uint32_t (*)();
|
||||
} // namespace sta
|
||||
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
||||
|
||||
/**
|
||||
* @brief Internal helper for macro expansion.
|
||||
*
|
||||
* @param n PCLK index
|
||||
* @return Function returning PCLK frequency
|
||||
*/
|
||||
#define _STA_STM32_GET_PCLK_FREQ_FN(n) STA_STM32_GET_PCLK_FREQ_FN(n)
|
||||
/**
|
||||
* @brief Map instance name to PCLK index.
|
||||
*
|
||||
* @param type Hardware type
|
||||
* @param idx Instance index
|
||||
* @return PCLK index
|
||||
*/
|
||||
#define _STA_STM32_PCLK_IDX_MAP(type, idx) STA_STM32_ ## type ## _ ## idx ## _PCLK_IDX
|
||||
// Get HAL handle to PCLK index map macro
|
||||
/**
|
||||
* @brief Map instance handle to PCLK index.
|
||||
*
|
||||
* @param handle HAL handle
|
||||
* @return PCLK index
|
||||
*/
|
||||
#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_PLATFORM_STM32
|
||||
|
||||
#endif // STA_CORE_STM32_CLOCKS_HPP
|
Reference in New Issue
Block a user