Skip to content
Snippets Groups Projects
Commit e1d63a1a authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Added func_i2c_calculate_clk_cnt with bit_rate_in_kHz argument.

parent 4bfb1f42
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,7 @@ PACKAGE i2c_pkg IS ...@@ -56,6 +56,7 @@ PACKAGE i2c_pkg IS
CONSTANT c_i2c_phy_sim : t_c_i2c_phy := (1, c_i2c_comma_w_dis); CONSTANT c_i2c_phy_sim : t_c_i2c_phy := (1, c_i2c_comma_w_dis);
-- Calculate clk_cnt from system_clock_freq_in_MHz -- Calculate clk_cnt from system_clock_freq_in_MHz
FUNCTION func_i2c_calculate_clk_cnt(system_clock_freq_in_MHz, bit_rate_in_kHz : NATURAL) RETURN NATURAL;
FUNCTION func_i2c_calculate_clk_cnt(system_clock_freq_in_MHz : NATURAL) RETURN NATURAL; FUNCTION func_i2c_calculate_clk_cnt(system_clock_freq_in_MHz : NATURAL) RETURN NATURAL;
-- Calculate (clk_cnt, comma_w) from system_clock_freq_in_MHz -- Calculate (clk_cnt, comma_w) from system_clock_freq_in_MHz
...@@ -70,6 +71,14 @@ END i2c_pkg; ...@@ -70,6 +71,14 @@ END i2c_pkg;
PACKAGE BODY i2c_pkg IS PACKAGE BODY i2c_pkg IS
FUNCTION func_i2c_calculate_clk_cnt(system_clock_freq_in_MHz, bit_rate_in_kHz : NATURAL) RETURN NATURAL IS
-- . Adapt c_i2c_clk_freq and c_i2c_bit_rate and c_i2c_clk_cnt will be set appropriately
-- . Default no comma time is needed, it appeared necessary for the uP based I2C slave in the LOFAR HBA client
CONSTANT c_clk_cnt_factor : NATURAL := 5;
BEGIN
RETURN system_clock_freq_in_MHz * 1000 / bit_rate_in_kHz / c_clk_cnt_factor - 1;
END;
FUNCTION func_i2c_calculate_clk_cnt(system_clock_freq_in_MHz : NATURAL) RETURN NATURAL IS FUNCTION func_i2c_calculate_clk_cnt(system_clock_freq_in_MHz : NATURAL) RETURN NATURAL IS
-- . Adapt c_i2c_clk_freq and c_i2c_bit_rate and c_i2c_clk_cnt will be set appropriately -- . Adapt c_i2c_clk_freq and c_i2c_bit_rate and c_i2c_clk_cnt will be set appropriately
-- . Default no comma time is needed, it appeared necessary for the uP based I2C slave in the LOFAR HBA client -- . Default no comma time is needed, it appeared necessary for the uP based I2C slave in the LOFAR HBA client
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment