]> Vexing Labs - forthdeck.git/commitdiff
move rng function to its own file, update Makefile and README for hwfc
authorAdam Shamblin <adam@vexingworkshop.com>
Tue, 19 Jul 2022 01:48:34 +0000 (19:48 -0600)
committerAdam Shamblin <adam@vexingworkshop.com>
Tue, 19 Jul 2022 01:48:34 +0000 (19:48 -0600)
.gitignore [new file with mode: 0644]
Makefile
README.md
src/rng.fs [new file with mode: 0644]
src/uart.fs
src/wordle.fs

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..c10d187
--- /dev/null
@@ -0,0 +1 @@
+project/
index f5f0db4dd218787165c6297482cf91a4322dbf09..ec57a30256ce65acf324dda2014b8b29194400c6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,15 @@
 # As recommended by the Mecrisp-Stellaris unofficial docs
 # @ https://mecrisp-stellaris-folkdoc.sourceforge.io/serial-terminals.html
+
+HW_FLOW_CONTROL ?= 1
+LINESPEED = ""
+
+ifeq ($(HW_FLOW_CONTROL), 0)
+       LINESPEED = "-l200"
+endif
+
 connect:
        picocom -b 115200 -f h /dev/ttyUSB0 \
                --imap lfcrlf,crcrlf \
                --omap delbs,crlf \
-               --send-cmd "ascii-xfr -s"
+               --send-cmd "ascii-xfr -s $(LINESPEED)"
index 45b621c155466c77dfaa86aea9c05e8396797bf8..170b95d7e59a29b55fe414a8cad5d11c05e1ae83 100644 (file)
--- a/README.md
+++ b/README.md
@@ -14,6 +14,22 @@ out of an rp2040, while learning practical programming using the Forth language.
 
 [Documentation](doc/README.md)
 
+## Connecting
+
+To connect to the system relying on hardware flow control:
+
+```shell
+make connect
+```
+
+Or, when hardware flow control may not be present:
+
+```shell
+HW_FLOW_CONTROL=0 make connect
+```
+
+This will add a 200ms end-of-line delay. Enabling hardware flow control comes
+highly recommended, as developer workflow improves tremendously.
 
 ## TODO
 
diff --git a/src/rng.fs b/src/rng.fs
new file mode 100644 (file)
index 0000000..78ee204
--- /dev/null
@@ -0,0 +1,11 @@
+\ Random number generation words
+\ Relies upon the rp2040 ring oscillator
+
+$40060000       constant ROSC_BASE
+ROSC_BASE $1c + constant RANDOMBIT
+
+\ Given a size in bits, return a random number
+: random ( bits -- n )
+  0 SWAP 0 DO
+    RANDOMBIT @ I lshift OR
+  LOOP ;
index 36078f7b08f228721e5d7730cdd1c0014c22b279..1b8cd9c117809c13d2215c96175e2d1b7d855edd 100644 (file)
@@ -22,12 +22,18 @@ UART1_BASE UARTCR + constant UART1_CR
 : transmit-enabled? ( addr -- flag ) @ 1 8 lshift AND 0 > ;
 
 \ Hardware Flow Control
+\ Given the address of a UART control register, check if rts or cts is enabled
+\ example: UART0 rts-enabled?
 : rts-enabled? ( addr -- flag ) @ 1 14 lshift AND 0 > ;
 : cts-enabled? ( addr -- flag ) @ 1 15 lshift AND 0 > ;
 
+\ Given the address of a UART control register, toggle rts or cts
+\ example: UART0 rts-toggle
 : rts-toggle ( addr -- ) DUP @ 1 14 lshift XOR SWAP ! ;
 : cts-toggle ( addr -- ) DUP @ 1 15 lshift XOR SWAP ! ;
 
+\ Given the address of a UART control register, enable rts or cts
+\ example: UART0 rts-enable
 : rts-enable ( addr -- ) DUP @ 1 14 lshift OR SWAP ! ;
 : cts-enable ( addr -- ) DUP @ 1 15 lshift OR SWAP ! ;
 
index b0dccc560c6bce1c726ea1f9d9ab1c757d36ee30..a148d016bfbbcc699c34748c67bd86968d059f03 100644 (file)
@@ -1,20 +1,11 @@
 \ The hit game, Wordle
 
+\ requires rng.fs, terminal.fs
+
 \ QOL words
 : ? @ . ;
 : R? R@ . ;
 
-\ Random number generator
-\ relies on the rp2040 Ring Oscillator
-$40060000       constant ROSC_BASE
-ROSC_BASE $1c + constant RANDOMBIT
-
-\ Given a size in bits, return a random number
-: random ( bits -- n )
-  0 SWAP 0 DO
-    RANDOMBIT @ I lshift OR
-  LOOP ;
-
 \ Lexicon
 5 constant WORDSIZE
 20 WORDSIZE * constant SIZE