etherkit / Si5351Arduino

Library for the Si5351 clock generator IC in the Arduino environment
GNU General Public License v3.0
233 stars 95 forks source link

set_clock_disable #19

Closed akadamson closed 8 years ago

akadamson commented 8 years ago

Jason, I think you may want to make these changes to the set_clock_disable routine. It looks like you copy & pasted and forgot to change some if, ifelse

void Si5351::set_clock_disable(enum si5351_clock clk, enum si5351_clock_disable dis_state) { uint8_t reg_val = 0, reg = 0;

if (clk >= SI5351_CLK0 && clk <= SI5351_CLK3)
{
    reg = SI5351_CLK3_0_DISABLE_STATE;
}
else if (clk >= SI5351_CLK4 && clk <= SI5351_CLK7)
{
    reg = SI5351_CLK7_4_DISABLE_STATE;
}

reg_val = si5351_read(reg);

if (clk >= SI5351_CLK0 && clk <= SI5351_CLK3)
{
    reg_val &= ~(0b11 << (clk * 2));
    reg_val |= dis_state << (clk * 2);
}
else if (clk >= SI5351_CLK4 && clk <= SI5351_CLK7)
{
    reg_val &= ~(0b11 << ((clk - 4) * 2));
    reg_val |= dis_state << ((clk - 4) * 2);
}

si5351_write(reg, reg_val);

}

NT7S commented 8 years ago

Always appreciate the extra eyes to catch bugs like these. Corrected in release v1.1.1.