Skip to content

Commit

Permalink
Merge pull request #1 from buzden/master
Browse files Browse the repository at this point in the history
Update to the modern Idris 1 and several improvements
  • Loading branch information
stepcut authored May 12, 2020
2 parents 7338864 + c281465 commit a090364
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.ibc
*.o
/build-*
10 changes: 6 additions & 4 deletions Blink.idr
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
module Main

%include C "idris_arduino.h"

digitalWrite : Int -> Int -> IO ()
digitalWrite pin val = mkForeign (FFun "idrard_digitalWrite" [FInt, FInt] FUnit) pin val
digitalWrite pin val = foreign FFI_C "idrard_digitalWrite" (Int -> Int -> IO ()) pin val

pinMode : Int -> Int -> IO ()
pinMode pin mode = mkForeign (FFun "idrard_pinMode" [FInt, FInt] FUnit) pin mode
pinMode pin mode = foreign FFI_C "idrard_pinMode" (Int -> Int -> IO ()) pin mode

delay : Int -> IO ()
delay ms = mkForeign (FFun "idrard_delay" [FInt] FUnit) ms
delay ms = foreign FFI_C "idrard_delay" (Int -> IO ()) ms

blink : Int -> Int -> IO ()
blink pin ms = mkForeign (FFun "idrard_blink" [FInt, FInt] FUnit) pin ms
blink pin ms = foreign FFI_C "idrard_blink" (Int -> Int -> IO ()) pin ms

main : IO ()
main =
Expand Down
17 changes: 13 additions & 4 deletions Idris.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
IDRIS_CFLAGS += -I$(IDRIS_RTS_PATH) -I$(IDRIS_RTS_PATH)/arduino
EXTRA_FLAGS = $(IDRIS_CFLAGS) -DFORCE_ALIGNMENT -DIDRIS_TARGET_OS=\"none\" -DIDRIS_TARGET_TRIPLE=\"arduino\"
IDRIS_INCLUDES += -I$(IDRIS_RTS_PATH) -I$(IDRIS_RTS_PATH)/arduino
CFLAGS += $(IDRIS_INCLUDES)

IDRIS_RTS_CFLAGS = -DFORCE_ALIGNMENT -DIDRIS_TARGET_OS=\"none\" -DIDRIS_TARGET_TRIPLE=\"arduino\"

NO_CORE_MAIN_CPP := "true"

RTS_OBJS = $(OBJDIR)/rts/arduino/idris_main.o $(OBJDIR)/rts/idris_gc.o $(OBJDIR)/rts/idris_rts.o $(OBJDIR)/rts/idris_bitstring.o $(OBJDIR)/rts/idris_gmp.o $(OBJDIR)/rts/idris_heap.o $(OBJDIR)/rts/mini-gmp.o
RTS_OBJS = \
$(OBJDIR)/rts/arduino/idris_main.o \
$(OBJDIR)/rts/idris_gc.o \
$(OBJDIR)/rts/idris_rts.o \
$(OBJDIR)/rts/idris_bitstring.o \
$(OBJDIR)/rts/idris_gmp.o \
$(OBJDIR)/rts/idris_heap.o \
$(OBJDIR)/rts/mini-gmp.o

OTHER_OBJS += $(RTS_OBJS) $(IDRIS_MAIN:.idr=.o)

Expand All @@ -15,4 +24,4 @@ include $(ARDUINO_MAKEFILE_PATH)
# Idris rts files
$(OBJDIR)/rts/%.o: $(IDRIS_RTS_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR)
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $(IDRIS_C_FLAGS) $< -o $@
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $(IDRIS_RTS_CFLAGS) $< -o $@
12 changes: 12 additions & 0 deletions Makefile.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ADRUINO_DIR=/usr/share/arduino
AVR_TOOLS_DIR=/usr
AVRDUDE_CONF=/etc/avrdude.conf
IDRIS_RTS_PATH=rts
ARDUINO_MAKEFILE_PATH=/usr/share/arduino/Arduino.mk

IDRIS_MAIN=Blink.idr

BOARD_TAG=mega
BOARD_SUB=atmega2560

include Idris.mk
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Next you will need to update the `Makefile` in this directory.
You will need to set the following variables:

* `ARDUINO_DIR` = *where you unpacked the Arduino software*
* `BOARD_TAG` = *your board*
* `AVR_TOOLS_DIR` = *dir containing `bin/avr-gcc` unless it is shipped with the Arduino software*
* `AVRDUDE_CONF` = *path to `avrdude.conf` unless avrdude is shipped with the Arduino software*
* `BOARD_TAG` and `BOARD_SUB` = *your board name (e.g., uno, mega) and subname (if applicable, e.g. atmega2560 for mega)*
* `IDRIS_RTS_PATH` = *path to the source for the RTS. Could point to the git source or to the copy of the files installed by cabal*
* `ARDUINO_MAKEFILE_PATH` = *path to the `Arduino.mk` from step 2*

Expand Down

0 comments on commit a090364

Please sign in to comment.