si-clock-0.1.3.1: An interface to the Silicon Labs Si5351 clock chip

Copyright(c) Marc Fontaine 2017
LicenseBSD3
MaintainerMarc.Fontaine@gmx.de
Stabilityexperimental
PortabilityGHC-only
Safe HaskellSafe
LanguageHaskell2010

Hardware.SiClock.Divider

Description

This module contains utility functions for fractional PLL divers. Most arduino Si5351 packages use dividers with a fixed large denominator, which seens to be against the spirit of the Si5351 design. I use continued fractions to compute the best fractional approximation. (This may be an overkill but why not.)

Synopsis

Documentation

dividerToPVal :: Rational -> (Word32, Word32, Word32) Source #

Compute the pvalues for a rational divider. Any denominator is pemissible here. The function uses the best approximation.

dividerToABC :: Rational -> (Integer, Integer, Integer) Source #

Approximate the a,b,c values of a divider.

approximations :: Rational -> [Rational] Source #

Compute a list of approximations of a rational number.

toContinuedFraction :: Rational -> (Integer, [Integer]) Source #

continued fraction stuff.

fromContinuedFraction :: (Integer, [Integer]) -> Rational Source #

continued fraction stuff.