function [cpu_clock_speed, lspclk, hspclk] = calcCpuClockSpeed(osc_freq, pllcr, clkin_div, pllclk_div, lspclk_div, hspclk_div)
%

% Copyright 2013-2018 The MathWorks, Inc.

    osc_freq = convertStringsToChars(osc_freq);
    pllcr = convertStringsToChars(pllcr);
    clkin_div = convertStringsToChars(clkin_div);
    pllclk_div = convertStringsToChars(pllclk_div);
    lspclk_div = convertStringsToChars(lspclk_div);
    hspclk_div = convertStringsToChars(hspclk_div);
    % Get the numeric value
    if ischar(osc_freq)
        osc_freq = str2double(osc_freq);
    end
    
    % Get the numeric value
    if ischar(pllcr)
        pllcr = str2double(pllcr);
    end
    
    % Get the numeric value
    if ischar(clkin_div)
        clkin_div = str2double(clkin_div);
    end
    
    % Get the numeric value
    if ischar(pllclk_div)
        pllclk_div = str2double(pllclk_div);
    end
    
    % Get the numeric value
    if ischar(lspclk_div)
        lspclk_div = str2double(lspclk_div);
    end
    
    % Get the numeric value
    if ischar(hspclk_div)
        hspclk_div = str2double(hspclk_div);
    end
    
    % The pll is bypasses. Under this case oscillator clock is used
    if pllcr == 0
        pllcr = pllcr + 1;
    end
    
    % Raw pll calculation
    if pllclk_div ~= 0
        raw_pll_clock_speed = (osc_freq * pllcr) / pllclk_div;
    else
        raw_pll_clock_speed = (osc_freq * pllcr);
    end
    
    % CPU Clock calculation
    if clkin_div ~= 0
        cpu_clock_speed = raw_pll_clock_speed / clkin_div;
    else
        cpu_clock_speed = raw_pll_clock_speed;
    end
    
    % LSPCLK
    if lspclk_div ~= 0
        lspclk = cpu_clock_speed / lspclk_div;
    else
        lspclk = cpu_clock_speed;
    end
    
    % HSPCLK
    if hspclk_div ~= 0
        hspclk = cpu_clock_speed / hspclk_div;
    else
        hspclk = cpu_clock_speed;
    end