atom-1.0.13: An EDSL for embedded hard realtime applications.

Copyright(c) 2013 Tom Hawkins & Lee Pike
Safe HaskellNone
LanguageHaskell98

Language.Atom.Common

Contents

Description

Common Atom functions

Synopsis

Timers

data Timer Source

A Timer.

timer :: Name -> Atom Timer Source

Creates a new timer.

startTimer Source

Arguments

:: Timer

Timer to start

-> E Word64

Number of clock ticks the timer shall run

-> Atom () 

Starts a Timer. A timer can be restarted at any time.

startTimerIf Source

Arguments

:: Timer

Timer to start conditionally

-> E Bool

Condition for starting the timer

-> E Word64

Number of ticks the timer shall run

-> Atom () 

Conditionally start a Timer.

timerDone :: Timer -> E Bool Source

True when a timer has completed. Note that this remains True until the timer is restarted.

One Shots

oneShotRise :: E Bool -> Atom (E Bool) Source

One-shot on a rising transition.

oneShotFall :: E Bool -> Atom (E Bool) Source

One-shot on a falling transition.

Debouncing

debounce Source

Arguments

:: Name

Name of the resulting atom

-> E Word64

On time in ticks

-> E Word64

Off time in ticks

-> Bool

Initial value

-> E Bool

The boolean to debounce

-> Atom (E Bool)

Resulting debounced boolean

Debounces a boolean given an on and off time (ticks) and an initial state.

Lookup Tables

lookupTable Source

Arguments

:: FloatingE a 
=> [(E a, E a)]

(x, y) lookup table

-> E a

Input x value

-> E a

Output y value

1-D lookup table. x values out of table range are clipped at end y values. Input table must be monotonically increasing in x.

linear Source

Arguments

:: FloatingE a 
=> (E a, E a)

First point, (x1, y1)

-> (E a, E a)

Second point, (x2, y2)

-> E a

Input x value

-> E a

Interpolated/extrapolated y value

Linear extrapolation and interpolation on a line with 2 points. The two x points must be different to prevent a divide-by-zero.

Hysteresis

hysteresis Source

Arguments

:: OrdE a 
=> E a

min

-> E a

max

-> E a

Input

-> Atom (E Bool) 

Hysteresis returns True when the input exceeds max and False when the input is less than min. The state is held when the input is between min and max.

Channels

data Channel a Source

A channel is a uni-directional communication link that ensures one read for every write.

Constructors

Channel a (V Bool) 

channel :: a -> Atom (Channel a) Source

Creates a new channel, with a given name and data.

writeChannel :: Channel a -> Atom () Source

Write data to a Channel. A write will only suceed if the Channel is empty.

readChannel :: Channel a -> Atom a Source

Read data from a Channel. A read will only suceed if the Channel has data to be read.