Library for the Si5351 clock generator IC in the Arduino environment
Repo etherkit/Si5351Arduino, read from GitHub 1 min ago. etherkit has not joined Take My Repo.
init()/reset() output loops. On an Uno (arduino-cli 1.5.1, arduino:avr 1.8.6) the minimal init() + set_freq() sketch is 10,140 bytes for a constant CLK0 (was 10,830) and 10,868 bytes for a runtime clock index (was 11,558)#define SI5351_NO_CLK67 before #include <si5351.h>, or -DSI5351_NO_CLK67. set_freq() and set_freq_manual() return 1 for CLK6 and CLK7 and write nothing, and set_ms() writes nothing for those outputs. The si5351_clock enumerators stay, and reset() still initializes all eight clock-control registers. About 1 KB less flash on that Uno runtime-clock sketch (9,870 bytes with the sketch define, 9,836 with the compiler flag)SI5351_NO_VCXO, alone or with SI5351_NO_CLK67. set_vcxo() returns 1 and writes nothing, and later PLL updates use the non-VCXO denominator. reset() still clears the VCXO parameter registers. On that same sketch the define saves 440 bytes (10,428) and the compiler flag saves 472 bytes (10,396). Both defines together are 9,390 bytesset_vcxo() returns uint8_t: 0 when the PLL and VCXO registers are written, 1 when nothing is written (reference not usable, or SI5351_NO_VCXO). Sketches that ignore the return still compile. Without the macro, register writes match v2.4.2select_r_div() with a regression test. Divide-by-64 is only the [2F, 4F) band; the next band is divide-by-32. CLK6/CLK7 edges are what set_freq() writes to register 92 (#89)SI5351_CRYSTAL_LOAD_0PF: AN619 Register 183 says XTAL_CL 00b is reserved, and init() keeps the 10 pF defaultreset_freq() to set one CLK output back to 0 Hz, disable it, and clear its first-set flag so the next set_freq() enables it again, the same as the first call. Pass a valid si5351_clock value (SI5351_CLK0..SI5351_CLK7); out-of-range values are not supported. Other outputs are left unchanged. Thanks to KT315AM (#104)Bug-fix release. Hardware-verified on Si5351B (VCXO) and Si5351C boards.
*_MAX_FREQ macros still say 225 MHz)set_freq_manual() now validates the Multisynth ratio; an invalid ratio returns 1 and writes nothingset_freq(), like CLK0-CLK5; set_phase() and set_int() are no-ops for CLK6/CLK7set_pll_input() instead of ORing itreset(), which init() calls (#82, #86)dev_status.LOS now reports crystal loss of signal (LOS_XTAL, register 0 bit 3). New LOS_CLKIN and LOS_XTAL fields plus matching sticky fields, and SI5351_STATUS_LOS is now bit 3 (#85)get_i2c_error(), which records I2C errors from register reads and writes and from a failed init(). A read that returns no data reports SI5351_I2C_ERR_NO_DATA (0xFF) (#74)set_freq()/set_freq_manual() take 0.01 Hz units, and the range comment is fixed (#97, #60)Si5351(TwoWire *wire = &Wire, uint8_t i2c_addr = SI5351_BUS_BASE_ADDR) so the Si5351 can be on Wire1 or any other TwoWire bus (closes #103, #106). Si5351() and Si5351(addr) (any integer type, including a literal 0 or NULL) behave as before. No new C++11 features are requirednullptr or (TwoWire *)0 to the bus constructor selects Wire; NULL or 0 still mean I2C address 0get_correction() now called with SI5351_PLL_INPUT_XO)Flash on ATmega328P (Arduino Uno, arduino-cli): a basic CLK0/CLK1 sketch went from 12138 to 9684 bytes, and a sketch using every public method from 13268 to 12692 bytes. A larger test program went from 15464 to 13516 bytes with the size refactor alone.
All changes were verified on hardware. See #105 for full details, verification, and known limitations.