libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
Clock Control System API

PAC5xx CCS Driver More...

Collaboration diagram for Clock Control System API:

Data Structures

struct  ccs_clk_config
 CCS Clock Configuration structure. More...
 

Functions

void ccs_frclkmux_select (uint32_t sel)
 Select the source for FRCLK. More...
 
void ccs_rosc_enable (void)
 Enable the 16MHz Ring oscillator. More...
 
void ccs_rosc_disable (void)
 Disable the 16MHz Ring oscillator. More...
 
void ccs_sclkmux_select_frclk (void)
 Select FRCLK for SCLK. More...
 
void ccs_sclkmux_select_pllclk (void)
 Select PLLCLK for SCLK. More...
 
void ccs_clkfail_enable (void)
 Enable Clock Fail Detection. More...
 
void ccs_clkfail_disable (void)
 Disable Clock Fail Detection. More...
 
void ccs_clkfailmux_select_frclk (void)
 Select FRCLK for Clock Fail Detection. More...
 
void ccs_clkfailmux_select_pllclk (void)
 Select PLLCLK for Clock Fail Detection. More...
 
void ccs_ldo_enable (void)
 Enable the LDO. More...
 
void ccs_ldo_disable (void)
 Disable the LDO. More...
 
void ccs_pclk_enable (void)
 Enable the Peripheral Clock. More...
 
void ccs_pclk_disable (void)
 Disable the Peripheral Clock. More...
 
void ccs_aclk_enable (void)
 Enable the Auxiliary Clock. More...
 
void ccs_aclk_disable (void)
 Disable the Auxiliary Clock. More...
 
void ccs_adcclk_enable (void)
 Enable the ADC Clock. More...
 
void ccs_adcclk_disable (void)
 Disable the ADC Clock. More...
 
void ccs_stclk_sleep_enable (void)
 Enable SysTick clock gating in deep sleep mode. More...
 
void ccs_stclk_sleep_disable (void)
 Disable SysTick clock gating in deep sleep mode. More...
 
void ccs_set_pclkdiv (uint32_t div)
 Set the divisor for the Peripheral Clock. More...
 
void ccs_set_aclkdiv (uint32_t div)
 Set the divisor for the Auxiliary Clock. More...
 
void ccs_set_hclkdiv (uint32_t div)
 Set the divisor for the AHB Clock. More...
 
void ccs_pll_enable (void)
 Enable the PLL. More...
 
void ccs_pll_disable (void)
 Disable the PLL. More...
 
bool ccs_pll_locked (void)
 Check if the PLL is locked. More...
 
void ccs_pll_bypass_enable (void)
 Enable the PLL bypass. More...
 
void ccs_pll_bypass_disable (void)
 Disable the PLL bypass. More...
 
void ccs_pll_set_outdiv (uint32_t div)
 Set the output divisor. More...
 
void ccs_pll_set_indiv (uint32_t div)
 Set the PLL input divisor. More...
 
void ccs_pll_set_fbdiv (uint32_t div)
 Set the PLL feedback divisor. More...
 
void css_pll_config_enable (uint32_t indiv, uint32_t fbdiv, uint32_t outdiv)
 Configure the CCS PLL, enable it, and wait for lock. More...
 
uint32_t ccs_get_peripheral_clk_freq (uint32_t periph, uint32_t select)
 Get the clock rate (in Hz) of the specified peripheral. More...
 
void ccs_reset_clocks (void)
 Restores CCSCTL and CCSPLLCTL registers to default/safe values. More...
 
void ccs_configure_clocks (const struct ccs_clk_config *config)
 Setup the PAC55xx clocks with the given struct. More...
 

Detailed Description

PAC5xx CCS Driver

Author
© 2020 Kevin Stefanik kevin.nosp@m.@all.nosp@m.ocor..nosp@m.tech
Date
March 7, 2020

This library supports the CCS module in the PAC55xx SoC from Qorvo.

LGPL License Terms libopencm3 License

Function Documentation

◆ ccs_aclk_disable()

void ccs_aclk_disable ( void  )

Disable the Auxiliary Clock.

Definition at line 81 of file ccs.c.

References CCSCTL.

◆ ccs_aclk_enable()

void ccs_aclk_enable ( void  )

Enable the Auxiliary Clock.

Definition at line 78 of file ccs.c.

References CCS_CTL_ACLKEN, and CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_adcclk_disable()

void ccs_adcclk_disable ( void  )

Disable the ADC Clock.

Definition at line 87 of file ccs.c.

References CCSCTL.

◆ ccs_adcclk_enable()

void ccs_adcclk_enable ( void  )

Enable the ADC Clock.

Definition at line 84 of file ccs.c.

References CCS_CTL_ADCCLKEN, and CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_clkfail_disable()

void ccs_clkfail_disable ( void  )

Disable Clock Fail Detection.

Definition at line 57 of file ccs.c.

References CCSCTL.

◆ ccs_clkfail_enable()

void ccs_clkfail_enable ( void  )

Enable Clock Fail Detection.

Definition at line 54 of file ccs.c.

References CCS_CTL_CLKFAILEN, and CCSCTL.

◆ ccs_clkfailmux_select_frclk()

void ccs_clkfailmux_select_frclk ( void  )

Select FRCLK for Clock Fail Detection.

Definition at line 60 of file ccs.c.

References CCSCTL.

◆ ccs_clkfailmux_select_pllclk()

void ccs_clkfailmux_select_pllclk ( void  )

Select PLLCLK for Clock Fail Detection.

Definition at line 63 of file ccs.c.

References CCS_CTL_CLKFAILMUXSEL, and CCSCTL.

◆ ccs_configure_clocks()

void ccs_configure_clocks ( const struct ccs_clk_config config)

◆ ccs_frclkmux_select()

void ccs_frclkmux_select ( uint32_t  sel)

Select the source for FRCLK.

Parameters
[in]selone of:
  • /ref CCS_CTL_FRCLKMUXSEL_ROSC - 16MHz ring oscillator
  • /ref CCS_CTL_FRCLKMUXSEL_CLKREF - trimmed 4MHz clock
  • /ref CCS_CTL_FRCLKMUXSEL_EXTCLK

Definition at line 39 of file ccs.c.

References CCS_CTL_FRCLKMUXSEL, CCS_CTL_FRCLKMUXSEL_MASK, and CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_get_peripheral_clk_freq()

uint32_t ccs_get_peripheral_clk_freq ( uint32_t  periph,
uint32_t  select 
)

Get the clock rate (in Hz) of the specified peripheral.

This will pull the proper sources out of the clock tree and calculate the clock for the peripheral for return to the user, based on current settings.

Parameters
[in]periphPeripheral base address to get the clock rate for.
[in]selectPeripheral-controlled clock select value. Set to 0 when not applicable.
Returns
Clock rate in Hz for the specified peripheral. 0 if undefined or error.

Definition at line 145 of file ccs.c.

References ADC_BASE, CAN_BASE, ccs_aclk_frequency, ccs_frclk_frequency, ccs_hclk_frequency, ccs_pclk_frequency, CCS_ROSC_FREQ, ccs_sclk_frequency, cm3_assert_not_reached, CRC_BASE, GPTIMERA_BASE, GPTIMERB_BASE, I2C_BASE, MEMCTL_BASE, RTC_BASE, SYS_TICK_BASE, TIMERA_BASE, TIMERB_BASE, TIMERC_BASE, TIMERD_BASE, USARTA_BASE, USARTB_BASE, USARTC_BASE, USARTD_BASE, and WWDT_BASE.

◆ ccs_ldo_disable()

void ccs_ldo_disable ( void  )

Disable the LDO.

Definition at line 69 of file ccs.c.

References CCSCTL.

◆ ccs_ldo_enable()

void ccs_ldo_enable ( void  )

Enable the LDO.

Definition at line 66 of file ccs.c.

References CCS_CTL_LDOEN, and CCSCTL.

◆ ccs_pclk_disable()

void ccs_pclk_disable ( void  )

Disable the Peripheral Clock.

Definition at line 75 of file ccs.c.

References CCSCTL.

◆ ccs_pclk_enable()

void ccs_pclk_enable ( void  )

Enable the Peripheral Clock.

Definition at line 72 of file ccs.c.

References CCS_CTL_PCLKEN, and CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_pll_bypass_disable()

void ccs_pll_bypass_disable ( void  )

Disable the PLL bypass.

Definition at line 117 of file ccs.c.

References CCSPLLCTL.

◆ ccs_pll_bypass_enable()

void ccs_pll_bypass_enable ( void  )

Enable the PLL bypass.

Definition at line 114 of file ccs.c.

References CCS_PLLCTL_PLLBP, and CCSPLLCTL.

◆ ccs_pll_disable()

void ccs_pll_disable ( void  )

Disable the PLL.

Definition at line 108 of file ccs.c.

References CCSPLLCTL.

Referenced by css_pll_config_enable().

Here is the caller graph for this function:

◆ ccs_pll_enable()

void ccs_pll_enable ( void  )

Enable the PLL.

Definition at line 105 of file ccs.c.

References CCS_PLLCTL_PLLEN, and CCSPLLCTL.

Referenced by css_pll_config_enable().

Here is the caller graph for this function:

◆ ccs_pll_locked()

bool ccs_pll_locked ( void  )

Check if the PLL is locked.

Returns
true if locked.

Definition at line 111 of file ccs.c.

References CCS_PLLCTL_PLLLOCK, and CCSPLLCTL.

Referenced by css_pll_config_enable().

Here is the caller graph for this function:

◆ ccs_pll_set_fbdiv()

void ccs_pll_set_fbdiv ( uint32_t  div)

Set the PLL feedback divisor.

Parameters
[in]divFeedback divisor, 4-16383.

Definition at line 130 of file ccs.c.

References CCS_PLLCTL_PLLFBDIV, CCS_PLLCTL_PLLFBDIV_MASK, CCSPLLCTL, and cm3_assert_not_reached.

Referenced by css_pll_config_enable().

Here is the caller graph for this function:

◆ ccs_pll_set_indiv()

void ccs_pll_set_indiv ( uint32_t  div)

Set the PLL input divisor.

Parameters
[in]divInput divisor, 1-15.

Definition at line 123 of file ccs.c.

References CCS_PLLCTL_PLLINDIV, CCS_PLLCTL_PLLINDIV_MASK, CCSPLLCTL, and cm3_assert_not_reached.

Referenced by css_pll_config_enable().

Here is the caller graph for this function:

◆ ccs_pll_set_outdiv()

void ccs_pll_set_outdiv ( uint32_t  div)

Set the output divisor.

Parameters
[in]divOutput divisor, one of:
  • /ref CCS_PLLCTL_PLLOUTDIV1
  • /ref CCS_PLLCTL_PLLOUTDIV2
  • /ref CCS_PLLCTL_PLLOUTDIV4
  • /ref CCS_PLLCTL_PLLOUTDIV8

Definition at line 120 of file ccs.c.

References CCS_PLLCTL_PLLOUTDIV, CCS_PLLCTL_PLLOUTDIV_MASK, and CCSPLLCTL.

Referenced by css_pll_config_enable().

Here is the caller graph for this function:

◆ ccs_reset_clocks()

void ccs_reset_clocks ( void  )

Restores CCSCTL and CCSPLLCTL registers to default/safe values.

Definition at line 177 of file ccs.c.

References CCS_CTL_ACLKEN, CCS_CTL_ADCCLKEN, CCS_CTL_LDOEN, CCS_CTL_PCLKEN, CCS_CTL_ROSCEN, CCS_CTL_STCLKSLPEN, CCSCTL, and CCSPLLCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_rosc_disable()

void ccs_rosc_disable ( void  )

Disable the 16MHz Ring oscillator.

Definition at line 45 of file ccs.c.

References CCSCTL.

◆ ccs_rosc_enable()

void ccs_rosc_enable ( void  )

Enable the 16MHz Ring oscillator.

Definition at line 42 of file ccs.c.

References CCS_CTL_ROSCEN, and CCSCTL.

◆ ccs_sclkmux_select_frclk()

void ccs_sclkmux_select_frclk ( void  )

Select FRCLK for SCLK.

Definition at line 48 of file ccs.c.

References CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_sclkmux_select_pllclk()

void ccs_sclkmux_select_pllclk ( void  )

Select PLLCLK for SCLK.

Definition at line 51 of file ccs.c.

References CCS_CTL_SCLKMUXSEL, and CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_set_aclkdiv()

void ccs_set_aclkdiv ( uint32_t  div)

Set the divisor for the Auxiliary Clock.

Parameters
[in]divACLK Divisor: 1-8.

Definition at line 99 of file ccs.c.

References CCS_CTL_ACLKDIV, and CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_set_hclkdiv()

void ccs_set_hclkdiv ( uint32_t  div)

Set the divisor for the AHB Clock.

Parameters
[in]divHCLK Divisor: 1-8.

Definition at line 102 of file ccs.c.

References CCS_CTL_HCLKDIV, and CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_set_pclkdiv()

void ccs_set_pclkdiv ( uint32_t  div)

Set the divisor for the Peripheral Clock.

Parameters
[in]divPCLK Divisor: 1-8.

Definition at line 96 of file ccs.c.

References CCS_CTL_PCLKDIV, and CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_stclk_sleep_disable()

void ccs_stclk_sleep_disable ( void  )

Disable SysTick clock gating in deep sleep mode.

Definition at line 93 of file ccs.c.

References CCSCTL.

Referenced by ccs_configure_clocks().

Here is the caller graph for this function:

◆ ccs_stclk_sleep_enable()

void ccs_stclk_sleep_enable ( void  )

Enable SysTick clock gating in deep sleep mode.

Definition at line 90 of file ccs.c.

References CCS_CTL_STCLKSLPEN, and CCSCTL.

◆ css_pll_config_enable()

void css_pll_config_enable ( uint32_t  indiv,
uint32_t  fbdiv,
uint32_t  outdiv 
)

Configure the CCS PLL, enable it, and wait for lock.

Parameters
[in]indivInput divisor, 1-15.
[in]fbdivFeedback divisor, 4-16383.
[in]outdivOutput divisor, one of:
  • /ref CCS_PLLCTL_PLLOUTDIV1
  • /ref CCS_PLLCTL_PLLOUTDIV2
  • /ref CCS_PLLCTL_PLLOUTDIV4
  • /ref CCS_PLLCTL_PLLOUTDIV8

Definition at line 137 of file ccs.c.

References ccs_pll_disable(), ccs_pll_enable(), ccs_pll_locked(), ccs_pll_set_fbdiv(), ccs_pll_set_indiv(), and ccs_pll_set_outdiv().

Referenced by ccs_configure_clocks().

Here is the call graph for this function:
Here is the caller graph for this function: