ref: c7cbc8dfb9222d58bbc72413de606492120abfaa
parent: df6464ed444920bfbcbf22582547c562bebec026
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Sun Jan 14 05:56:07 EST 2024
Rename files for a particular board.
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
It uses combinators for the runtime execution.
The runtime system has minimal dependencies, and can be compiled even for micro-controllers.
-The STM32 directory contains some sample code for an STM32F407G-DISC1 board.
+The `boards/` directory contains some sample, e.g., some sample code for an STM32F407G-DISC1 board.
The compiler can compile itself.
--- a/STM32/.gitignore
+++ /dev/null
@@ -1,1 +1,0 @@
-blinky.c
--- a/STM32/Blinky.hs
+++ /dev/null
@@ -1,29 +1,0 @@
-module Blinky(main) where
-import Prelude
-
-main :: IO ()
-main = blinky (500::Int)
-
-blinky :: Int -> IO ()
-blinky n | n > 1000 = return ()
-blinky n = do
- oneByOne n True
- oneByOne n False
- blinky (n + 1)
-
-oneByOne :: Int -> Bool -> IO ()
-oneByOne n on = forM_ [0..3] $ \ led -> do
- setLed led on
- wait (n + led)
-
-foreign import ccall "set_led" set_led :: Int -> Int -> IO ()
-foreign import ccall "busy_wait" busy_wait :: Int -> IO ()
-
-setLed :: Int -> Bool -> IO ()
-setLed led on = set_led led $ if on then 1 else 0
-
-wait :: Int -> IO ()
-wait n = busy_wait (n*300)
-
-loop :: Int -> ()
-loop n = if n == 0 then () else loop (n - 1)
--- a/STM32/Makefile
+++ /dev/null
@@ -1,27 +1,0 @@
-MHSDIR=..
-BIN=../bin
-TOOLS=../Tools
-
-# Generate combinator file
-blinky.c: Blinky.hs $(BIN)/Addcombs $(BIN)/mhseval $(BIN)/mhs
- MHSDIR=$(MHSDIR) $(BIN)/mhs -i$(LIB) Blinky -oBlinky.comb
- $(BIN)/mhseval +RTS -rBlinky.comb -oBlinky-opt.comb
- $(BIN)/Addcombs Blinky-opt.comb blinky.c
-
-$(BIN)/Addcombs: $(TOOLS)/Addcombs.hs $(BIN)/mhs
- MHSDIR=$(MHSDIR) $(BIN)/mhs -i$(TOOLS) Addcombs -o$(BIN)/Addcombs
-
-# To compile for STM32 the following files are needed:
-# src/runtime/bfile.c
-# src/runtime/config-stm32f4.h
-# src/runtime/eval-stm32f.c
-# src/runtime/eval.c
-# blinky.c
-# The Keil project should include
-# eval-stm32f.c
-# blinky.c
-# To get enough memory I modified startup_stm32f407xx.s
-# Stack_Size EQU 0x00008000
-# Heap_Size EQU 0x0000E000
-# These values are not optimized, they just happen to work
-# for this project.
--- /dev/null
+++ b/boards/ESP32-C3-DevKitM-1/.gitignore
@@ -1,0 +1,1 @@
+blinky.c
--- /dev/null
+++ b/boards/STM32F407G-DISC1/.gitignore
@@ -1,0 +1,1 @@
+blinky.c
--- /dev/null
+++ b/boards/STM32F407G-DISC1/Blinky.hs
@@ -1,0 +1,29 @@
+module Blinky(main) where
+import Prelude
+
+main :: IO ()
+main = blinky (500::Int)
+
+blinky :: Int -> IO ()
+blinky n | n > 1000 = return ()
+blinky n = do
+ oneByOne n True
+ oneByOne n False
+ blinky (n + 1)
+
+oneByOne :: Int -> Bool -> IO ()
+oneByOne n on = forM_ [0..3] $ \ led -> do
+ setLed led on
+ wait (n + led)
+
+foreign import ccall "set_led" set_led :: Int -> Int -> IO ()
+foreign import ccall "busy_wait" busy_wait :: Int -> IO ()
+
+setLed :: Int -> Bool -> IO ()
+setLed led on = set_led led $ if on then 1 else 0
+
+wait :: Int -> IO ()
+wait n = busy_wait (n*300)
+
+loop :: Int -> ()
+loop n = if n == 0 then () else loop (n - 1)
--- /dev/null
+++ b/boards/STM32F407G-DISC1/Makefile
@@ -1,0 +1,27 @@
+MHSDIR=..
+BIN=../bin
+TOOLS=../Tools
+
+# Generate combinator file
+blinky.c: Blinky.hs $(BIN)/Addcombs $(BIN)/mhseval $(BIN)/mhs
+ MHSDIR=$(MHSDIR) $(BIN)/mhs -i$(LIB) Blinky -oBlinky.comb
+ $(BIN)/mhseval +RTS -rBlinky.comb -oBlinky-opt.comb
+ $(BIN)/Addcombs Blinky-opt.comb blinky.c
+
+$(BIN)/Addcombs: $(TOOLS)/Addcombs.hs $(BIN)/mhs
+ MHSDIR=$(MHSDIR) $(BIN)/mhs -i$(TOOLS) Addcombs -o$(BIN)/Addcombs
+
+# To compile for STM32 the following files are needed:
+# src/runtime/bfile.c
+# src/runtime/config-stm32f4.h
+# src/runtime/eval-stm32f.c
+# src/runtime/eval.c
+# blinky.c
+# The Keil project should include
+# eval-stm32f.c
+# blinky.c
+# To get enough memory I modified startup_stm32f407xx.s
+# Stack_Size EQU 0x00008000
+# Heap_Size EQU 0x0000E000
+# These values are not optimized, they just happen to work
+# for this project.
--
⑨