1 Values can be assigned to all expressions that have an
\CI{Upd
} role. Examples
2 of such expressions are
\glspl{SDS
} and
\gls{GPIO
} pins. Moreover, class
3 extensions can be created for specific peripherals such as built-in
4 \glspl{LED
}. The classes facilitating this are shown in
5 Listing~
\ref{lst:sdsio
}. In this way the assignment is the same for every
9 label=
{lst:sdsio
},caption=
{Input/Output classes
}]
10 :: DigitalPin = D0 | D1 | D2 | D3 | D4 | D5 |D6 | D7 | D8 | D9 | D10 | D11 | D12 | D13
11 :: AnalogPin = A0 | A1 | A2 | A3 | A4 | A5
12 :: UserLED = LED1 | LED2 | LED3
14 class dIO v where dIO :: DigitalPin -> v Bool Upd
15 class aIO v where aIO :: AnalogPin -> v Int Upd
16 class analogRead v where
17 analogRead :: AnalogPin -> v Int Expr
18 analogWrite :: AnalogPin (v Int p) -> v Int Expr
19 class digitalRead v where
20 digitalRead :: DigitalPin -> v Bin Expr
21 digitalWrite :: DigitalPin (v Bool p) -> v Int Expr
23 :: UserLED = LED1 | LED2 | LED3
25 ledOn :: (v UserLED q) -> (v () Stmt)
26 ledOff :: (v UserLED q) -> (v () Stmt)
29 (=.) infixr
2 :: (v t Upd) (v t p) -> v t Expr | ...
32 One way of storing data in
\gls{mTask
}-
\glspl{Task
} is using
\glspl{SDS
}.
33 \glspl{SDS
} serve as variables in
\gls{mTask
} and maintain their value across
34 executions.
\glspl{SDS
} can be used by multiple
\glspl{Task
} and can be used
35 to share data. The classes associated with
\glspl{SDS
} are listed in
36 Listing~
\ref{lst:sdsclass
}. The
\CI{Main
} type is introduced to box an
37 \gls{mTask
} and make it recognizable by the type system by separating programs
38 and decorations such as
\glspl{SDS
}.
41 label=
{lst:sdsclass
},caption=
{\glspl{SDS
} in
\gls{mTask
}}]
42 :: In a b = In infix
0 a b
43 :: Main a =
{main :: a
}
46 sds :: ((v t Upd)->In t (Main (v c s))) -> (Main (v c s)) | ...