This module covers Peripheral Clock Control module functionality.
PCC HAL provides the API for reading and writing register bit-fields belonging to the PCC module. Clock selection for most modules is controlled by PCC. The clock to each module can be individually gated on and off using PCC.
The PCC hal component allows application to configure these peripheral clocking options:
- Clock gating
- Clock source selection
- Fractional clock divider values
This is an example to write a peripheral clock configuration:
Count of peripheral clock user configurations
#define NUM_OF_CONFIGURED_PERIPHERAL_CLOCKS_0 5U
Peripheral clocking configuration 0
{
.clkGate = true,
.frac = 0, N/A
.divider = 0, N/A
},
{
.clkGate = true,
},
{
.peripheral = PCC_SIM0_CLOCK,
.clkGate = true,
.clkSrc = 0, N/A
.frac = 0, N/A
.divider = 0, N/A
},
{
.clkGate = true,
.clkSrc = 0, N/A
.frac = 0, N/A
.divider = 0, N/A
},
{
.peripheral = PCC_SCG0_CLOCK,
.clkGate = true,
.clkSrc = 0, N/A
.frac = 0, N/A
.divider = 0, N/A
},
};
{
.
peripheralClocks = peripheralClockConfig0, Peripheral clock control configurations
.count = NUM_OF_CONFIGURED_PERIPHERAL_CLOCKS_0, Number of the peripheral clock control configurations
};
write peripheral clocking configuration
For higher-level functionality, use the Clock Manager driver.
|
enum | peripheral_clock_source_t {
CLK_SRC_OFF = 0x00U,
CLK_SRC_SOSC = 0x01U,
CLK_SRC_SIRC = 0x02U,
CLK_SRC_FIRC = 0x03U,
CLK_SRC_SPLL = 0x06U
} |
| PCC clock source select Implements peripheral_clock_source_t_Class. More...
|
|
enum | peripheral_clock_frac_t { MULTIPLY_BY_ONE = 0x00U,
MULTIPLY_BY_TWO = 0x01U
} |
| PCC fractional value select Implements peripheral_clock_frac_t_Class. More...
|
|
enum | peripheral_clock_divider_t {
DIVIDE_BY_ONE = 0x00U,
DIVIDE_BY_TWO = 0x01U,
DIVIDE_BY_THREE = 0x02U,
DIVIDE_BY_FOUR = 0x03U,
DIVIDE_BY_FIVE = 0x04U,
DIVIDE_BY_SIX = 0x05U,
DIVIDE_BY_SEVEN = 0x06U,
DIVIDE_BY_EIGTH = 0x07U
} |
| PCC divider value select Implements peripheral_clock_divider_t_Class. More...
|
|
|
const uint16_t | clockNameMappings [CLOCK_NAME_COUNT] |
| Clock name mappings Constant array storing the mappings between clock names and peripheral clock control indexes. If there is no peripheral clock control index for a clock name, then the corresponding value is PCC_INVALID_INDEX. More...
|
|
|
void | PCC_HAL_SetPeripheralClockConfig (PCC_Type *const base, const pcc_config_t *const config) |
| Set the peripheral clock configuration. More...
|
|
static void | PCC_HAL_SetClockMode (PCC_Type *const base, const clock_names_t clockName, const bool isClockEnabled) |
| Enables/disables the clock for a given peripheral. For example, to enable the ADC0 clock, use like this: More...
|
|
static void | PCC_HAL_SetClockSourceSel (PCC_Type *const base, const clock_names_t clockName, const peripheral_clock_source_t clockSource) |
| Selects the clock source for a given peripheral For example, to select the FIRC source for ADC clock, use like this: More...
|
|
static void | PCC_HAL_SetFracValueSel (PCC_Type *const base, const clock_names_t clockName, const peripheral_clock_frac_t fracValue) |
| Selects the fractional value for a given peripheral For example, to configure MULTIPLY_BY_ONE as fractional value for WDOG, use like this: More...
|
|
static void | PCC_HAL_SetDividerValueSel (PCC_Type *const base, const clock_names_t clockName, const peripheral_clock_divider_t divValue) |
| Selects the divider value for a given peripheral For example, to configure DIVIDE_BY_ONE as divider value for WDOG, use like this: More...
|
|
static bool | PCC_HAL_GetClockMode (const PCC_Type *const base, const clock_names_t clockName) |
| Gets the clock gate control mode. More...
|
|
static peripheral_clock_source_t | PCC_HAL_GetClockSourceSel (const PCC_Type *const base, const clock_names_t clockName) |
| Gets the selection of a clock source for a specific peripheral. More...
|
|
static peripheral_clock_frac_t | PCC_HAL_GetFracValueSel (const PCC_Type *const base, const clock_names_t clockName) |
| Gets the selection of the fractional value for a specific peripheral. More...
|
|
static peripheral_clock_divider_t | PCC_HAL_GetDividerSel (const PCC_Type *const base, const clock_names_t clockName) |
| Gets the selection of the divider value for a specific peripheral. More...
|
|
static bool | PCC_HAL_GetPeripheralMode (const PCC_Type *const base, const clock_names_t clockName) |
| Tells whether a given peripheral is present or not. More...
|
|
PCC divider value select Implements peripheral_clock_divider_t_Class.
Enumerator |
---|
DIVIDE_BY_ONE |
|
DIVIDE_BY_TWO |
|
DIVIDE_BY_THREE |
|
DIVIDE_BY_FOUR |
|
DIVIDE_BY_FIVE |
|
DIVIDE_BY_SIX |
|
DIVIDE_BY_SEVEN |
|
DIVIDE_BY_EIGTH |
|
Definition at line 141 of file pcc_hal.h.
PCC fractional value select Implements peripheral_clock_frac_t_Class.
Enumerator |
---|
MULTIPLY_BY_ONE |
|
MULTIPLY_BY_TWO |
|
Definition at line 131 of file pcc_hal.h.
PCC clock source select Implements peripheral_clock_source_t_Class.
Enumerator |
---|
CLK_SRC_OFF |
|
CLK_SRC_SOSC |
|
CLK_SRC_SIRC |
|
CLK_SRC_FIRC |
|
CLK_SRC_SPLL |
|
Definition at line 118 of file pcc_hal.h.
Gets the clock gate control mode.
- Parameters
-
[in] | base | pcc base pointer |
[in] | clockName | is the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK |
- Returns
- the clock gate control mode
- false : Clock is disabled
- true : Clock is enabled Implements PCC_HAL_GetClockMode_Activity
Definition at line 405 of file pcc_hal.h.
Gets the selection of a clock source for a specific peripheral.
- Parameters
-
[in] | base | pcc base pointer |
[in] | clockName | is the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK |
- Returns
- the clock gate control mode
- PCC_CLK_SRC_OFF : Clock is disabled
- PCC_CLK_SRC_SOSC : OSCCLK - System Oscillator Bus Clock
- PCC_CLK_SRC_SIRC : SCGIRCLK - Slow IRC Clock
- PCC_CLK_SRC_FIRC : SCGFIRCLK - Fast IRC Clock
- PCC_CLK_SRC_SPLL : SCGPCLK - System PLL clock Implements PCC_HAL_GetClockSourceSel_Activity
Definition at line 431 of file pcc_hal.h.
Gets the selection of the divider value for a specific peripheral.
- Parameters
-
[in] | base | pcc base pointer |
[in] | clockName | is the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK |
- Returns
- the divider value
- PCC_DIVIDE_BY_ONE : Divide by 1
- PCC_DIVIDE_BY_TWO : Divide by 2
- PCC_DIVIDE_BY_THREE : Divide by 3
- PCC_DIVIDE_BY_FOUR : Divide by 4
- PCC_DIVIDE_BY_FIVE : Divide by 5
- PCC_DIVIDE_BY_SIX : Divide by 6
- PCC_DIVIDE_BY_SEVEN : Divide by 7
- PCC_DIVIDE_BY_EIGTH : Divide by 8 Implements PCC_HAL_GetDividerSel_Activity
Definition at line 518 of file pcc_hal.h.
Gets the selection of the fractional value for a specific peripheral.
- Parameters
-
[in] | base | pcc base pointer |
[in] | clockName | is the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK |
- Returns
- the fractional value
- PCC_MULTPCCnLY_BY_ONE : Fractional value is zero
- PCC_MULTPCCnLY_BY_TWO : Fractional value is one Implements PCC_HAL_GetFracValueSel_Activity
Definition at line 476 of file pcc_hal.h.
Tells whether a given peripheral is present or not.
- Parameters
-
[in] | base | pcc base pointer |
[in] | clockName | is the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK |
- Returns
- is the value that tells whether the peripheral is present or not
- false : Peripheral is not present
- true : Peripheral is present Implements PCC_HAL_GetPeripheralMode_Activity
Definition at line 572 of file pcc_hal.h.
static void PCC_HAL_SetClockMode |
( |
PCC_Type *const |
base, |
|
|
const clock_names_t |
clockName, |
|
|
const bool |
isClockEnabled |
|
) |
| |
|
inlinestatic |
Enables/disables the clock for a given peripheral. For example, to enable the ADC0 clock, use like this:
1 PCC_HAL_SetClockMode(PCC, PCC_ADC0_CLOCK, true);
- Parameters
-
[in] | base | pcc base pointer |
[in] | clockName | is the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK |
[in] | isClockEnabled | is the value of the command that enables/disables the clock Implements PCC_HAL_SetClockMode_Activity |
Definition at line 230 of file pcc_hal.h.
Selects the clock source for a given peripheral For example, to select the FIRC source for ADC clock, use like this:
1 PCC_HAL_SetClockSourceSel(PCC, PCC_ADC0_CLOCK, CLK_SRC_FIRC);
- Parameters
-
[in] | base | pcc base pointer |
[in] | clockName | is the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK |
[in] | clockSource | is the clock source to use for a given peripheral Implements PCC_HAL_SetClockSourceSel_Activity |
Definition at line 257 of file pcc_hal.h.
Selects the divider value for a given peripheral For example, to configure DIVIDE_BY_ONE as divider value for WDOG, use like this:
1 PCC_HAL_SetDividerValueSel(PCC, PCC_WDOG_CLOCK, DIVIDE_BY_ONE);
- Parameters
-
[in] | base | pcc base pointer |
[in] | clockName | is the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK |
[in] | divValue | is the divider value to use for a given peripheral Implements PCC_HAL_SetDividerValueSel_Activity |
Definition at line 348 of file pcc_hal.h.
Selects the fractional value for a given peripheral For example, to configure MULTIPLY_BY_ONE as fractional value for WDOG, use like this:
1 PCC_HAL_SetFracValueSel(PCC, PCC_WDOG_CLOCK, MULTIPLY_BY_ONE);
- Parameters
-
[in] | base | pcc base pointer |
[in] | clockName | is the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK |
[in] | fracValue | is the fractional value to use for a given peripheral Implements PCC_HAL_SetFracValueSel_Activity |
Definition at line 307 of file pcc_hal.h.
Set the peripheral clock configuration.
This function sets the peripheral configuration.
- Parameters
-
[in] | base | Register base address for the PCC instance. |
[in] | config | Pointer to the configuration. |
Definition at line 56 of file pcc_hal.c.
Clock name mappings Constant array storing the mappings between clock names and peripheral clock control indexes. If there is no peripheral clock control index for a clock name, then the corresponding value is PCC_INVALID_INDEX.
Definition at line 43 of file pcc_hal.c.