Added high level clock reconfiguration capability to HAL.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14369 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
d72a5bf202
commit
8843d76fb6
|
@ -42,6 +42,10 @@
|
||||||
#define HAL_USE_CAN FALSE
|
#define HAL_USE_CAN FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAL_USE_CLK)
|
||||||
|
#define HAL_USE_CLK FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(HAL_USE_CRY)
|
#if !defined(HAL_USE_CRY)
|
||||||
#define HAL_USE_CRY FALSE
|
#define HAL_USE_CRY FALSE
|
||||||
#endif
|
#endif
|
||||||
|
@ -268,6 +272,41 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver inline functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#if defined(HAL_LLD_USE_CLOCK_MANAGEMENT) || defined(__DOXYGEN__)
|
||||||
|
/**
|
||||||
|
* @brief Switches to a different clock configuration
|
||||||
|
*
|
||||||
|
* @param[in] ccp pointer to clock a @p halclkcfg_t structure
|
||||||
|
* @return The clock switch result.
|
||||||
|
* @retval false if the clock switch succeeded
|
||||||
|
* @retval true if the clock switch failed
|
||||||
|
*
|
||||||
|
* @special
|
||||||
|
*/
|
||||||
|
static inline bool halClockSwitchMode(const halclkcfg_t *ccp) {
|
||||||
|
|
||||||
|
return hal_clock_switch_mode(ccp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the frequency of a clock point in Hz.
|
||||||
|
*
|
||||||
|
* @param[in] clkpt clock point to be returned
|
||||||
|
* @return The clock point frequency in Hz or zero if the
|
||||||
|
* frequency is unknown.
|
||||||
|
*
|
||||||
|
* @xclass
|
||||||
|
*/
|
||||||
|
static inline halfreq_t halClockGetPointX(halclkpoint_t clkpt) {
|
||||||
|
|
||||||
|
return hal_lld_get_clock_point(clkpt);
|
||||||
|
}
|
||||||
|
#endif /* defined(HAL_LLD_USE_CLOCK_MANAGEMENT) */
|
||||||
|
|
||||||
#endif /* HAL_H */
|
#endif /* HAL_H */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -32,6 +32,22 @@
|
||||||
/* Driver exported variables. */
|
/* Driver exported variables. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#if defined(HAL_LLD_USE_CLOCK_MANAGEMENT) && !defined(__DOXYGEN__)
|
||||||
|
/**
|
||||||
|
* @brief Post-reset configuration, must be implemented.
|
||||||
|
*/
|
||||||
|
const halclkcfg_t hal_clkcfg_reset = {
|
||||||
|
.dummy = 0U
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configuration from mcuconf.h, must be implemented.
|
||||||
|
*/
|
||||||
|
const halclkcfg_t hal_clkcfg_default = {
|
||||||
|
.dummy = 0U
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local variables and types. */
|
/* Driver local variables and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -57,4 +73,39 @@ void hal_lld_init(void) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAL_LLD_USE_CLOCK_MANAGEMENT) || defined(__DOXYGEN__)
|
||||||
|
/**
|
||||||
|
* @brief Switches to a different clock configuration
|
||||||
|
*
|
||||||
|
* @param[in] ccp pointer to clock a @p halclkcfg_t structure
|
||||||
|
* @return The clock switch result.
|
||||||
|
* @retval false if the clock switch succeeded
|
||||||
|
* @retval true if the clock switch failed
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
bool hal_clock_switch_mode(const halclkcfg_t *ccp) {
|
||||||
|
|
||||||
|
(void)ccp;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the frequency of a clock point in Hz.
|
||||||
|
*
|
||||||
|
* @param[in] clkpt clock point to be returned
|
||||||
|
* @return The clock point frequency in Hz or zero if the
|
||||||
|
* frequency is unknown.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
halfreq_t hal_lld_get_clock_point(halclkpoint_t clkpt) {
|
||||||
|
|
||||||
|
(void)clkpt;
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
#endif /* defined(HAL_LLD_USE_CLOCK_MANAGEMENT) */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -29,6 +29,11 @@
|
||||||
/* Driver constants. */
|
/* Driver constants. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Specifies implementation of dynamic clock management.
|
||||||
|
*/
|
||||||
|
#define HAL_LLD_USE_CLOCK_MANAGEMENT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Platform identification macros
|
* @name Platform identification macros
|
||||||
* @{
|
* @{
|
||||||
|
@ -61,6 +66,28 @@
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#if defined(HAL_LLD_USE_CLOCK_MANAGEMENT) || defined(__DOXYGEN__)
|
||||||
|
/**
|
||||||
|
* @brief Type of clock point names.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
clk_core = 0,
|
||||||
|
clk_peripherals = 1
|
||||||
|
} halclkpoint_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a clock point frequency in Hz.
|
||||||
|
*/
|
||||||
|
typedef uint32_t halfreq_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a clock configuration structure.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint32_t dummy;
|
||||||
|
} halclkcfg_t;
|
||||||
|
#endif /* defined(HAL_LLD_USE_CLOCK_MANAGEMENT) */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver macros. */
|
/* Driver macros. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -69,10 +96,19 @@
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#if defined(HAL_LLD_USE_CLOCK_MANAGEMENT) && !defined(__DOXYGEN__)
|
||||||
|
extern const halclkcfg_t hal_clkcfg_reset;
|
||||||
|
extern const halclkcfg_t hal_clkcfg_default;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void hal_lld_init(void);
|
void hal_lld_init(void);
|
||||||
|
#if defined(HAL_LLD_USE_CLOCK_MANAGEMENT) || defined(__DOXYGEN__)
|
||||||
|
bool hal_clock_switch_mode(const halclkcfg_t *ccp);
|
||||||
|
halfreq_t hal_lld_get_clock_point(halclkpoint_t clkpt);
|
||||||
|
#endif /* defined(HAL_LLD_USE_CLOCK_MANAGEMENT) */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue