-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from buzden/no-intermediate-c
Using Arduino's C-functions with no intermediate C lib
- Loading branch information
Showing
5 changed files
with
16 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.ibc | ||
*.o | ||
/build-* | ||
/[A-Z]*.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
module Main | ||
|
||
%include C "idris_arduino.h" | ||
%include C "Arduino.h" | ||
|
||
digitalWrite : Int -> Int -> IO () | ||
digitalWrite pin val = foreign FFI_C "idrard_digitalWrite" (Int -> Int -> IO ()) pin val | ||
digitalWrite pin val = foreign FFI_C "digitalWrite" (Int -> Int -> IO ()) pin val | ||
|
||
pinMode : Int -> Int -> IO () | ||
pinMode pin mode = foreign FFI_C "idrard_pinMode" (Int -> Int -> IO ()) pin mode | ||
pinMode pin mode = foreign FFI_C "pinMode" (Int -> Int -> IO ()) pin mode | ||
|
||
delay : Int -> IO () | ||
delay ms = foreign FFI_C "idrard_delay" (Int -> IO ()) ms | ||
delay ms = foreign FFI_C "delay" (Int -> IO ()) ms | ||
|
||
forever : Monad f => f a -> f b | ||
forever x = do x | ||
forever x | ||
|
||
blink : Int -> Int -> IO () | ||
blink pin ms = foreign FFI_C "idrard_blink" (Int -> Int -> IO ()) pin ms | ||
blink pin t = do digitalWrite pin 1 | ||
delay t | ||
digitalWrite pin 0 | ||
delay t | ||
|
||
main : IO () | ||
main = | ||
do pinMode 13 1 | ||
blink 13 30 | ||
forever $ blink 13 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.