function [LinModuleClockFrequencyInMHz, BaudRate] = calcLINBaudRate(SysclkoutInMHz, BaudRatePrescaler, FractionalPrescaler)
%CALCLINBAUDRATE Summary of this function goes here
%   Detailed explanation goes here

% Copyright 2013-2018 The MathWorks, Inc.

SysclkoutInMHz = convertStringsToChars(SysclkoutInMHz);
BaudRatePrescaler = convertStringsToChars(BaudRatePrescaler);
FractionalPrescaler = convertStringsToChars(FractionalPrescaler);

if ischar(SysclkoutInMHz)
    SysclkoutInMHz = str2double(SysclkoutInMHz);
end

if ischar(BaudRatePrescaler)
    BaudRatePrescaler = str2double(BaudRatePrescaler);
end

if ischar(FractionalPrescaler)
    FractionalPrescaler = str2double(FractionalPrescaler);
end

LinModuleClockFrequencyInMHz = SysclkoutInMHz / 2; 
LinModuleClockFrequency = (LinModuleClockFrequencyInMHz * 1e6); % MHz to Hz

if BaudRatePrescaler ~= 0
    BaudRate = LinModuleClockFrequency / (16 * (BaudRatePrescaler + 1 + FractionalPrescaler/16));
else
    BaudRate = LinModuleClockFrequency / 32;
end
BaudRate = round(BaudRate);
end

