Skip to content

Commit

Permalink
Merge pull request #54 from etherkit/v2.0.7
Browse files Browse the repository at this point in the history
Change set_freq() for auto output enable on 1st call only
  • Loading branch information
NT7S committed Oct 1, 2017
2 parents bbbf0b3 + db16236 commit 252d1ee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -666,6 +666,10 @@ This library does not currently support the spread spectrum function of the Si53
Changelog
---------

* v2.0.7

* Change _set_freq()_ behavior so that the output is only automatically enabled the very first time that _set_freq()_ is called

* v2.0.6

* Call _set_pll()_ in _set_correction()_ to ensure that the new correction factor is applied
Expand Down
21 changes: 13 additions & 8 deletions src/si5351.cpp
Expand Up @@ -125,7 +125,6 @@ void Si5351::reset(void)
si5351_write(22, 0x80);
si5351_write(23, 0x80);


// Turn the clocks back on...
si5351_write(16, 0x0c);
si5351_write(17, 0x0c);
Expand Down Expand Up @@ -174,6 +173,7 @@ void Si5351::reset(void)
{
clk_freq[i] = 0;
output_enable((enum si5351_clock)i, 0);
clk_first_set[i] = false;
}
}

Expand Down Expand Up @@ -231,8 +231,12 @@ uint8_t Si5351::set_freq(uint64_t freq, enum si5351_clock clk)
}
}

// Enable the output
output_enable(clk, 1);
// Enable the output on first set_freq only
if(clk_first_set[(uint8_t)clk] == false)
{
output_enable(clk, 1);
clk_first_set[(uint8_t)clk] = true;
}

// Set the freq in memory
clk_freq[(uint8_t)clk] = freq;
Expand Down Expand Up @@ -284,8 +288,12 @@ uint8_t Si5351::set_freq(uint64_t freq, enum si5351_clock clk)
{
clk_freq[(uint8_t)clk] = freq;

// Enable the output
output_enable(clk, 1);
// Enable the output on first set_freq only
if(clk_first_set[(uint8_t)clk] == false)
{
output_enable(clk, 1);
clk_first_set[(uint8_t)clk] = true;
}

// Select the proper R div value
r_div = select_r_div(&freq);
Expand Down Expand Up @@ -416,9 +424,6 @@ uint8_t Si5351::set_freq(uint64_t freq, enum si5351_clock clk)
}
}

// Enable the output
output_enable(clk, 1);

div_by_4 = 0;
int_mode = 0;

Expand Down
1 change: 1 addition & 0 deletions src/si5351.h
Expand Up @@ -308,6 +308,7 @@ class Si5351
struct Si5351Status dev_status;
struct Si5351IntStatus dev_int_status;
enum si5351_pll pll_assignment[8];
bool clk_first_set[8];
uint64_t clk_freq[8];
uint64_t plla_freq;
uint64_t pllb_freq;
Expand Down

0 comments on commit 252d1ee

Please sign in to comment.