Skip to content

Commit 252d1ee

Browse files
authored
Merge pull request #54 from etherkit/v2.0.7
Change set_freq() for auto output enable on 1st call only
2 parents bbbf0b3 + db16236 commit 252d1ee

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ This library does not currently support the spread spectrum function of the Si53
666666
Changelog
667667
---------
668668

669+
* v2.0.7
670+
671+
* Change _set_freq()_ behavior so that the output is only automatically enabled the very first time that _set_freq()_ is called
672+
669673
* v2.0.6
670674

671675
* Call _set_pll()_ in _set_correction()_ to ensure that the new correction factor is applied

src/si5351.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ void Si5351::reset(void)
125125
si5351_write(22, 0x80);
126126
si5351_write(23, 0x80);
127127

128-
129128
// Turn the clocks back on...
130129
si5351_write(16, 0x0c);
131130
si5351_write(17, 0x0c);
@@ -174,6 +173,7 @@ void Si5351::reset(void)
174173
{
175174
clk_freq[i] = 0;
176175
output_enable((enum si5351_clock)i, 0);
176+
clk_first_set[i] = false;
177177
}
178178
}
179179

@@ -231,8 +231,12 @@ uint8_t Si5351::set_freq(uint64_t freq, enum si5351_clock clk)
231231
}
232232
}
233233

234-
// Enable the output
235-
output_enable(clk, 1);
234+
// Enable the output on first set_freq only
235+
if(clk_first_set[(uint8_t)clk] == false)
236+
{
237+
output_enable(clk, 1);
238+
clk_first_set[(uint8_t)clk] = true;
239+
}
236240

237241
// Set the freq in memory
238242
clk_freq[(uint8_t)clk] = freq;
@@ -284,8 +288,12 @@ uint8_t Si5351::set_freq(uint64_t freq, enum si5351_clock clk)
284288
{
285289
clk_freq[(uint8_t)clk] = freq;
286290

287-
// Enable the output
288-
output_enable(clk, 1);
291+
// Enable the output on first set_freq only
292+
if(clk_first_set[(uint8_t)clk] == false)
293+
{
294+
output_enable(clk, 1);
295+
clk_first_set[(uint8_t)clk] = true;
296+
}
289297

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

419-
// Enable the output
420-
output_enable(clk, 1);
421-
422427
div_by_4 = 0;
423428
int_mode = 0;
424429

src/si5351.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ class Si5351
308308
struct Si5351Status dev_status;
309309
struct Si5351IntStatus dev_int_status;
310310
enum si5351_pll pll_assignment[8];
311+
bool clk_first_set[8];
311312
uint64_t clk_freq[8];
312313
uint64_t plla_freq;
313314
uint64_t pllb_freq;

0 commit comments

Comments
 (0)