/*
Connection to ARDUINO UNO:

ARDUINO  / Si5351C MODULE

GND - GND
5V - 5V
SDA - SDA
SCL - SCL
*/

#include "si5351.h"
#include "Wire.h"

Si5351 si5351;

void setup()
{

  // Initialize the Si5351 to use a 27 MHz clock on the XO input
  si5351.init(SI5351_CRYSTAL_LOAD_8PF, 27000000UL, 0);

    // Initialize the Si5351 to use a 25 MHz clock on the XO input
//  si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0);

  // Set the CLKIN reference frequency to 10 MHz
  si5351.set_ref_freq(10000000UL, SI5351_PLL_INPUT_CLKIN);

  // Apply a correction factor to CLKIN
  si5351.set_correction(0, SI5351_PLL_INPUT_CLKIN);

  // Set PLLA and PLLB to use the signal on CLKIN instead of the XTAL
  si5351.set_pll_input(SI5351_PLLA, SI5351_PLL_INPUT_CLKIN);
  si5351.set_pll_input(SI5351_PLLB, SI5351_PLL_INPUT_CLKIN);
  
  si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_8MA);
  si5351.drive_strength(SI5351_CLK6, SI5351_DRIVE_2MA);
  si5351.drive_strength(SI5351_CLK7, SI5351_DRIVE_2MA);
  si5351.output_enable(SI5351_CLK0, 1);                  //1 - Enable / 0 - Disable CLK
  si5351.output_enable(SI5351_CLK1, 0);
  si5351.output_enable(SI5351_CLK2, 0);
  si5351.output_enable(SI5351_CLK3, 0);
  si5351.output_enable(SI5351_CLK4, 0);
  si5351.output_enable(SI5351_CLK5, 0);                 
  si5351.output_enable(SI5351_CLK6, 0);
  si5351.output_enable(SI5351_CLK7, 0);

  
  // Set CLK0 to output 14 MHz
  si5351.set_freq(12345670900ULL, SI5351_CLK0);

  si5351.update_status();
  delay(500);
}

void loop()
{

}
