mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 16:55:58 +00:00
Add HAL clock helpers
This commit is contained in:
parent
0eac5fbf51
commit
e7d246a2e7
60
include/sta/hal/clocks.hpp
Normal file
60
include/sta/hal/clocks.hpp
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @brief Helper macros for HAL clock queries.
|
||||
*/
|
||||
#ifndef STA_HAL_CLOCKS_HPP
|
||||
#define STA_HAL_CLOCKS_HPP
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#include <sta/hal.hpp>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get function returning PCLK frequency.
|
||||
*
|
||||
* @param n Index of peripheral clock
|
||||
*/
|
||||
#define STA_HAL_GET_PCLK_FREQ_FN(n) HAL_RCC_GetPCLK ## n ## Freq
|
||||
|
||||
|
||||
// Internal helper for macro expansion
|
||||
#define _STA_HAL_GET_PCLK_FREQ_FN(n) STA_HAL_GET_PCLK_FREQ_FN(n)
|
||||
// Get instance to PCLK index map macro
|
||||
#define _STA_PCLK_IDX_MAP(type, idx) STA_ ## type ## _ ## idx ## _PCLK_IDX
|
||||
// Get HAL handle to PCLK index map macro
|
||||
#define _STA_HAL_PCLK_IDX_MAP(handle) STA_HAL_ ## handle ## _PCLK_IDX
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get function returning frequency of PCLK used by TIM.
|
||||
*
|
||||
* @param n TIM index
|
||||
*/
|
||||
#define STA_HAL_GET_TIM_PCLK_FREQ_FN(n) _STA_HAL_GET_PCLK_FREQ_FN(_STA_PCLK_IDX_MAP(TIM, n))
|
||||
/**
|
||||
* @brief Get function returning frequency of PCLK used by SPI interface.
|
||||
*
|
||||
* @param n SPI interface index
|
||||
*/
|
||||
#define STA_HAL_GET_SPI_PCLK_FREQ_FN(n) _STA_HAL_GET_PCLK_FREQ_FN(_STA_PCLK_IDX_MAP(SPI, n))
|
||||
/**
|
||||
* @brief Get function returning frequency of PCLK used by I2C interface.
|
||||
*
|
||||
* @param n I2C interface index
|
||||
*/
|
||||
#define STA_HAL_GET_I2C_PCLK_FREQ_FN(n) _STA_HAL_GET_PCLK_FREQ_FN(_STA_PCLK_IDX_MAP(I2C, n))
|
||||
/**
|
||||
* @brief Get function returning frequency of PCLK used by USART interface.
|
||||
*
|
||||
* @param n USART interface index
|
||||
*/
|
||||
#define STA_HAL_GET_USART_PCLK_FREQ_FN(n) _STA_HAL_GET_PCLK_FREQ_FN(_STA_PCLK_IDX_MAP(USART, n))
|
||||
|
||||
/**
|
||||
* @brief Get function returning frequency of PCLK used by HAL instance.
|
||||
*
|
||||
* @param handle Instance handle
|
||||
*/
|
||||
#define STA_HAL_GET_HANDLE_PCLK_FREQ_FN(handle) _STA_HAL_GET_PCLK_FREQ_FN(_STA_HAL_PCLK_IDX_MAP(handle))
|
||||
|
||||
|
||||
#endif // STA_HAL_CLOCKS_HPP
|
Loading…
x
Reference in New Issue
Block a user