/* Get current HCLK frequency, calculated from hw setting.  */
uint32_t sys_hclk_calc(void)
/* Get current HCLK frequency, calculated from hw setting.  */
uint32_t sys_hclk_calc(void)
{
    volatile struct sys_registers *sys = (void *)SYS_REG_BASE;
    uint8_t plldiv = sys->CLK_PLL_DIV.pll_div;
    if (sys->CLK_CFG_CTRL.sel_pll == CLK_SEL_PLL_USB_480M)
    {
        hclk_freq = plldiv ? 480000000 / plldiv : 30000000;
    }
    else
    {
        hclk_freq = plldiv ?  30000000 / plldiv : 2000000;
    }
    return hclk_freq;
}