-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
53 lines (40 loc) · 1 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module Main where
import Lib.Ccall as C
blink :: Port -> Pin -> IO ()
blink port pin = do
wait 100000
C.gpioClear port pin
wait 100000
C.gpioSet port pin
blink port pin
onOff :: Port -> Pin -> Port -> Pin -> IO ()
onOff inPort inPin outPort outPin = do
state <- C.gpioGet inPort inPin
if state == 0
then C.gpioClear outPort outPin
else C.gpioSet outPort outPin
main :: IO ()
main = do
C.rccPeriphClockEnableGpioA
C.rccPeriphClockEnableGpioB
C.rccPeriphClockEnableUsart2
gpioB <- C.gpioB
gpio12 <- C.gpio12
gpioA <- C.gpioA
gpio0 <- C.gpio0
gpioModeOutput2Mhz <- C.gpioModeOutput2Mhz
gpioCnfOutputPushpull <- C.gpioCnfOutputPushpull
gpioModeInput <- C.gpioModeInput
gpioCnfInputPullUpdown <- C.gpioCnfInputPullUpdown
C.gpioSetMode
gpioB
gpioModeOutput2Mhz
gpioCnfOutputPushpull
gpio12
C.gpioSetMode
gpioA
gpioModeInput
gpioCnfInputPullUpdown
gpio0
blink gpioB gpio12
-- onOff gpioA gpio0 gpioB gpio12