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

Description

This is the main API.

Synopsis

Documentation

defaultConfig :: Config Source #

The defaultConfig if no environment variables are set.

defaultConfigEnv :: HasCallStack => IO Config Source #

Check that defaultConfigEnv matches your hardware before you use it. Do not run any SiPLL code on a wrong i2c-bus, i.e. an internal I2C bus of your PC. (it might confuse and or wreck) your hardware. You can overwrite config values with the following ENV variables: SI_CLOCK_I2C_DEVICE SI_CLOCK_I2C_ADDRESS SI_CLOCK_XTAL_FREQUENCY SI_CLOCK_MAX_PLL_FREQUENCY

testIO :: IO () Source #

Quick test for the I2C connection (with default config).

type Synth a = forall m. MonadIO m => SynthT Config m a Source #

runSynth :: HasCallStack => SynthT Config IO a -> IO a Source #

Run the Synth monad with the config from defaultConfigEnv. | .i.e. reading Env

runSynthWith :: HasCallStack => Config -> SynthT Config IO a -> IO a Source #

Run the Synth monad with a custom configuration.

data PLL Source #

An IC has PLL_A and PLL_B.

Constructors

PLL_A 
PLL_B 

Instances

Eq PLL Source # 

Methods

(==) :: PLL -> PLL -> Bool #

(/=) :: PLL -> PLL -> Bool #

Show PLL Source # 

Methods

showsPrec :: Int -> PLL -> ShowS #

show :: PLL -> String #

showList :: [PLL] -> ShowS #

DividerAddr PLL Source #

Address of a PLL divider.

data CLK Source #

An IC has up to 8 clocks. (CLK_0..CLK_7).

Constructors

CLK_0 
CLK_1 
CLK_2 
CLK_3 
CLK_4 
CLK_5 
CLK_6 
CLK_7 

Instances

Enum CLK Source # 

Methods

succ :: CLK -> CLK #

pred :: CLK -> CLK #

toEnum :: Int -> CLK #

fromEnum :: CLK -> Int #

enumFrom :: CLK -> [CLK] #

enumFromThen :: CLK -> CLK -> [CLK] #

enumFromTo :: CLK -> CLK -> [CLK] #

enumFromThenTo :: CLK -> CLK -> CLK -> [CLK] #

Eq CLK Source # 

Methods

(==) :: CLK -> CLK -> Bool #

(/=) :: CLK -> CLK -> Bool #

Ord CLK Source # 

Methods

compare :: CLK -> CLK -> Ordering #

(<) :: CLK -> CLK -> Bool #

(<=) :: CLK -> CLK -> Bool #

(>) :: CLK -> CLK -> Bool #

(>=) :: CLK -> CLK -> Bool #

max :: CLK -> CLK -> CLK #

min :: CLK -> CLK -> CLK #

Show CLK Source # 

Methods

showsPrec :: Int -> CLK -> ShowS #

show :: CLK -> String #

showList :: [CLK] -> ShowS #

DividerAddr CLK Source #

Address of a Clock divider.

pllReset :: Synth () Source #

Reset (both?) PLLs

clk0_On :: Synth () Source #

Turn on CLK_0 output.

clk0_Off :: Synth () Source #

Turn off CLK_0 output.

setDividers :: PLL -> CLK -> Frequency -> Synth DividerPair Source #

Set PLL and Clock dividers for a frequency.

defaultDividers :: Frequency -> Synth DividerPair Source #

Compute a pair of good default pll and clk dividers. (clk divider is an integer)

setPLLDivider :: PLL -> Divider -> Synth () Source #

Set a PLL fractional divider

setPLLDivider_A :: Divider -> Synth () Source #

Short for setPLLDivider PLL_A

setPLLDivider_B :: Divider -> Synth () Source #

Short for setPLLDivider PLL_B

setCLKDivider :: CLK -> Word8 -> Divider -> Synth () Source #

Setup a Clock divider. The rfield is passed as a plain Word8. (ToDo high level API for rfields).

newtype DividerConf Source #

A DividerConf is basically the bytestring that configures a fractional divider.

Constructors

DividerConf 

toDividerConf :: Word8 -> Divider -> DividerConf Source #

Mangle a Divider and a rval into a DividerConf. This can be used to pre-compute all the math and to get the bits that define a divider.

setDividerRaw :: DividerAddr hw => hw -> DividerConf -> Synth () Source #

Setup some fractional divider with a pre-computed config. Using a pre-computed config might be faster or more convenient.

class DividerAddr a where Source #

Get address of the fractional divider.

Minimal complete definition

toDividerAddr

Methods

toDividerAddr :: a -> Word8 Source #

Instances

DividerAddr Word8 Source #

Generic Address of fractional divider.

DividerAddr CLK Source #

Address of a Clock divider.

DividerAddr PLL Source #

Address of a PLL divider.