RCC
Introduction
RCC (Reset and Clock Control) is responsible for managing various clock sources and clock dividers, providing clock enablement to various peripherals.
Function List
Supports enabling and disabling clocks for other modules, such as I2C, UART, SPI, DMA, etc.
Supports resetting clocks of other modules.
Supports frequency settings for CPU/WLAN/Peripheral, etc.
Features Supported by RCC HW
Function Descriptions
Clock Enable/Disable
Relevant Sequence API:
Call
wm_drv_clock_init
to initialize the clock. If the device is already initialized, obtain the device pointer through thewm_dt_get_device_by_name
function.Call
wm_drv_clock_enable
to enable the clock for the corresponding module.Call
wm_drv_clock_disable
to disable the clock for the corresponding module.
Clock modules that support enable/disable:
I2C, UART, SPI, DMA, RF, TIMER, GPIO, SD_ADC, PWM, LCD, I2S, RSA,
GPSEC, SDIOM, QSRAM, BT, TOUCH
Clock Reset
Relevant Sequence API:
Call
wm_drv_clock_init
to initialize the clock. If the device is already initialized, obtain the device pointer through thewm_dt_get_device_by_name
function.Call
wm_drv_clock_reset
to reset the module clock.
Result:
After the reset is successful, the corresponding module returns to the initialized state. For example, if the SPI module is reset, the SPI module will return to its initialized state.
Modules that can be reset:
BBP, MAC, SEC, SDIO_AHB, DMA, MEM_MNG, APB, I2C, UART, SPIM, SPIS
RF, GPIO, TIMER, SAR_ADC, PWM, LCD, I2S, RSA, QPSEC, SDIOM, BT, FLASH, TOUCH
Warning
After the system is running, certain modules cannot be reset. Forcing a reset may cause the system to malfunction.
Clock Frequency Setting
Set the clock for the corresponding module.
Relevant Sequence API:
Call
wm_drv_clock_init
to initialize the clock. If the device is already initialized, obtain the device pointer through thewm_dt_get_device_by_name
function.Call
wm_drv_rcc_config_clock
to set the frequency for the specified clock module.Call
wm_drv_rcc_get_config_clock
to query the current clock frequency of the specified module.
Modules with configurable clocks:
CPU, WLAN, SD_ADC, QFLASH, GPSEC, RSA, PERIPHERAL
Warning
Arbitrarily setting the clock may cause the system to malfunction. It is recommended to only configure the CPU clock, and the configured clock should be divisible by 480.
Application Example
wm_drv_clock_init();
wm_drv_clock_disable(WM_RCC_CLOCK_ALL);
wm_drv_clock_enable(WM_RCC_UART0_GATE_EN | WM_RCC_UART1_GATE_EN |
WM_RCC_RF_CFG_GATE_EN | WM_RCC_GPIO_GATE_EN |
WM_RCC_SD_ADC_GATE_EN | WM_RCC_TOUCH_GATE_EN); //enable UART, RF, GPIO, SD_ADC, TOUCH clocks
wm_drv_rcc_config_clock(WM_RCC_TYPE_CPU, 240); //Configure CPU clock to 240MHz