From 0403d4e20b0d43efad9b17bb9f51d53559aad738 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Wed, 17 May 2017 13:16:20 +0200 Subject: [PATCH] Add assignments to pins --- Tasks/Examples.dcl | 2 +- Tasks/Examples.icl | 17 ++++++----------- mTaskInterpret.dcl | 2 ++ mTaskInterpret.icl | 8 ++++++++ 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Tasks/Examples.dcl b/Tasks/Examples.dcl index 57f0c85..e689081 100644 --- a/Tasks/Examples.dcl +++ b/Tasks/Examples.dcl @@ -3,8 +3,8 @@ definition module Tasks.Examples from Data.Map import :: Map import mTask +pinShare :: Main (ByteCode () Stmt) faculty :: Int -> Main (ByteCode () Stmt) -countTo5 :: Main (ByteCode () Stmt) countAndLed :: Main (ByteCode () Stmt) blink :: UserLED -> Main (ByteCode () Stmt) count :: Main (ByteCode () Stmt) diff --git a/Tasks/Examples.icl b/Tasks/Examples.icl index 2e2a973..4ca051d 100644 --- a/Tasks/Examples.icl +++ b/Tasks/Examples.icl @@ -6,6 +6,11 @@ import mTask import Devices.mTaskDevice import iTasks._Framework.Serialization +pinShare :: Main (ByteCode () Stmt) +pinShare = sds \p=True In {main = + d0 =. p :. noOp + } + faculty :: Int -> Main (ByteCode () Stmt) faculty i = sds \y=i In sds \x=1 In {main = IF (y <=. lit 1) ( @@ -15,16 +20,6 @@ faculty i = sds \y=i In sds \x=1 In {main = y =. y -. lit 1 )} -countTo5 :: Main (ByteCode () Stmt) -countTo5 = sds \x=0 In {main = - x =. x +. lit 1 :. - pub x :. - IF ( x >. lit 5) ( - retrn - ) ( - noOp - )} - count :: Main (ByteCode () Stmt) count = sds \x=0 In {main = x =. x +. lit 1 :. pub x :. noOp} @@ -86,6 +81,6 @@ allmTasks = 'DM'.fromList ,("blink", ledSelection @ blink) ,("blinkShare", treturn blinkShare) ,("count", treturn count) - ,("countTo5", treturn countTo5) ,("faculty", enterInformation "Faculty" [] @ faculty) + ,("pinShare", treturn pinShare) ] diff --git a/mTaskInterpret.dcl b/mTaskInterpret.dcl index 5065585..99a3533 100644 --- a/mTaskInterpret.dcl +++ b/mTaskInterpret.dcl @@ -138,6 +138,8 @@ instance arith ByteCode instance boolExpr ByteCode instance analogIO ByteCode instance digitalIO ByteCode +instance aIO ByteCode +instance dIO ByteCode instance userLed ByteCode instance If ByteCode Stmt Stmt Stmt instance If ByteCode e Stmt Stmt diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index df59c28..80d458a 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -230,6 +230,12 @@ instance digitalIO ByteCode where digitalRead p = tell` [BCDigitalRead $ pin p] digitalWrite p b = op b (BCDigitalWrite $ pin p) +instance aIO ByteCode where + aIO p = undef + +instance dIO ByteCode where + dIO p = tell` [BCDigitalRead $ pin p] + instance If ByteCode Stmt Stmt Stmt where If b t e = BCIfStmt b t e instance If ByteCode e Stmt Stmt where If b t e = BCIfStmt b t e instance If ByteCode Stmt e Stmt where If b t e = BCIfStmt b t e @@ -267,6 +273,8 @@ instance assign ByteCode where where //This is going to include pins as well, as variables makeStore [BCSdsFetch i] = [BCSdsStore i] + makeStore [BCDigitalRead i] = [BCDigitalWrite i] + makeStore [BCAnalogRead i] = [BCAnalogWrite i] instance seq ByteCode where (>>=.) _ _ = abort "undef on >>=." -- 2.20.1