#embedded-hal-driver #clock #ham-radio #no-std

no-std si5351

A platform agnostic driver for the Si5351 clock generator

5 releases

0.2.0 Jan 20, 2019
0.1.5 Mar 19, 2018
0.1.4 Mar 19, 2018
0.1.3 Mar 2, 2018
0.1.2 Mar 2, 2018

#1055 in Embedded development

MIT/Apache

21KB
496 lines

si5351

docs crates.io ci

Documentation

On docs.rs

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

A platform agnostic Rust driver for the Si5351, based on the embedded-hal traits.

The Device

The Silicon Labs Si5351 is an any-frequency CMOS clock generator.

The device has an I²C interface.

Usage

Import this crate and an embedded_hal implementation:

extern crate stm32f103xx_hal as hal;
extern crate si5351;

Initialize I²C bus (differs between embedded_hal implementations):

use hal::i2c::I2c;
type I2C = ...;

let i2c: I2C = initialize_i2c();

Then instantiate the device:

use si5351;
use si5351::{Si5351, Si5351Device};

let mut clock = Si5351Device<I2C>::new(i2c, false, 25_000_000);
clock.init(si5351::CrystalLoad::_10)?;

Or, if you have an Adafruit module, you can use shortcut functions to initializate it:

use si5351;
use si5351::{Si5351, Si5351Device};

let mut clock = Si5351Device<I2C>::new_adafruit_module(i2c);
clock.init_adafruit_module()?;

And set frequency on one of the outputs:

use si5351;

clock.set_frequency(si5351::PLL::A, si5351::ClockOutput::Clk0, 14_175_000)?;

Dependencies

~175KB