【概述】
S32K3 系列的芯片的 RTD 驱动库对时钟系统进行了抽象,按照面向对象的思想将时钟系统的初始化抽成 Clock_Ip_ClockConfigType 结构体,对应的结构体定义如下:
/*!
* @brief Clock configuration structure.
* Implements Clock_Ip_ClockConfigType_Class
*/
typedef struct
{
uint32 ClkConfigId; /**< The ID for Clock configuration */
const Clock_Ip_RegisterValueType (*RegValues)[]; /**< Pointer to register values array */
uint8 IrcoscsCount; /**< IRCOSCs count */
uint8 XoscsCount; /**< XOSCs count */
uint8 PllsCount; /**< PLLs count */
uint8 SelectorsCount; /**< Selectors count */
uint8 DividersCount; /**< Dividers count */
uint8 DividerTriggersCount; /**< Divider triggers count */
uint8 FracDivsCount; /**< Fractional dividers count */
uint8 ExtClksCount; /**< External clocks count */
uint8 GatesCount; /**< Clock gates count */
uint8 PcfsCount; /**< Clock pcfs count */
uint8 CmusCount; /**< Clock cmus count */
uint8 ConfigureFrequenciesCount; /**< Configured frequencies count */
Clock_Ip_IrcoscConfigType Ircoscs[CLOCK_IP_IRCOSCS_NO]; /**< IRCOSCs */
Clock_Ip_XoscConfigType Xoscs[CLOCK_IP_XOSCS_NO]; /**< XOSCs */
Clock_Ip_PllConfigType Plls[CLOCK_IP_PLLS_NO]; /**< PLLs */
Clock_Ip_SelectorConfigType Selectors[CLOCK_IP_SELECTORS_NO];/**< Selectors */
Clock_Ip_DividerConfigType Dividers[CLOCK_IP_DIVIDERS_NO]; /**< Dividers */
Clock_Ip_DividerTriggerConfigType DividerTriggers[CLOCK_IP_DIVIDER_TRIGGERS_NO];/**< Divider triggers */
Clock_Ip_FracDivConfigType FracDivs[CLOCK_IP_FRACTIONAL_DIVIDERS_NO];/**< Fractional dividers */
Clock_Ip_ExtClkConfigType ExtClks[CLOCK_IP_EXT_CLKS_NO]; /**< External clocks */
Clock_Ip_GateConfigType Gates[CLOCK_IP_GATES_NO]; /**< Clock gates */
Clock_Ip_PcfsConfigType Pcfs[CLOCK_IP_PCFS_NO]; /**< Progressive clock switching */
Clock_Ip_CmuConfigType Cmus[CLOCK_IP_CMUS_NO]; /**< Clock cmus */
Clock_IP_SpecificPeriphConfigType SpecificPeriphalConfiguration; /**< Clock specific peripheral configuration */
Clock_Ip_ConfiguredFrequencyType ConfiguredFrequencies[CLOCK_IP_CONFIGURED_FREQUENCIES_NO]; /**< Configured frequency values */
} Clock_Ip_ClockConfigType;上述配置结构体对时钟系统的 xosc/pll/divider 进行了抽每一个对象有对应的counter 对于小面的配置数组进行描述。

本地的生成的 clock 结构如下:

本地以PLL的配置流程来了解时钟系统初始化的过程,PLL 的配置结构如下:
*/
typedef struct
{
Clock_Ip_NameType Name; /**< Clock name associated to pll */
uint16 Enable; /**< Enable pll. */
Clock_Ip_NameType InputReference; /**< Input reference. */
uint8 Bypass; /**< Bypass pll. */
uint8 Predivider; /**< Input clock predivider. */
uint16 Multiplier; /**< Clock multiplier. */
uint8 Postdivider; /**< Clock postidivder.*/
uint16 NumeratorFracLoopDiv; /**< Numerator of fractional loop division factor (MFN) */
uint8 MulFactorDiv; /**< Multiplication factor divider (MFD) */
uint8 ModulationFrequency; /**< Enable/disable modulation */
uint8 ModulationType; /**< Modulation type */
uint16 ModulationPeriod; /**< Stepsize - modulation period */
uint16 IncrementStep; /**< Stepno - step no */
uint8 SigmaDelta; /**< Sigma Delta Modulation Enable */
uint8 DitherControl; /**< Dither control enable */
uint8 DitherControlValue; /**< Dither control value */
uint8 Monitor; /**< Monitor type */
uint16 Dividers[3U]; /**< Dividers values */
} Clock_Ip_PllConfigType;代码中通过配置的回调函数传入上述的配置完成PLL 的配置,其他的结构配置也是通过该方式来完成。

从上述代码可以大致理解S32K3 clk 驱动的配置方法。
我要赚赏金
