18 lines
407 B
Ada
18 lines
407 B
Ada
package body STM32.F4.USART is
|
|
|
|
function Baud_Rate (
|
|
Speed: Positive;
|
|
OVER8: Boolean;
|
|
Bus_Frequency: Positive)
|
|
return Baud_Rate_Register
|
|
is
|
|
Ratio : Natural := (Bus_Frequency + Speed / 2) / Speed;
|
|
Oversampling : Positive := (if OVER8 then 8 else 16);
|
|
begin
|
|
return (DIV_Mantissa => Ratio / Oversampling,
|
|
DIV_Fraction => Ratio mod Oversampling,
|
|
others => 0);
|
|
end;
|
|
|
|
end STM32.F4.USART;
|