The purpose of this project is to build a general purpose, interactive computer
out of an rp2040, while learning practical programming using the Forth language.
-[Documentation](doc/index.md)
+[Documentation](doc/README.md)
## TODO
--- /dev/null
+---
+title: Documentation
+---
+
+# Documentation
+
+Here may be found the documentation for the words and capabilities made
+available using the `forthdeck` project.
+
+* [GPIO](gpio.md)
+* [Terminal](terminal.md)
+* [UART](uart.md)
+* [Wordle](wordle.fs)
+++ /dev/null
----
-title: Documentation
----
-
-* [GPIO](gpio.md)
--- /dev/null
+---
+title: Terminal
+file: terminal.fs
+---
+
+# Terminal
+
+The Terminal library provides words for working with serial input and output,
+including screen management and color display.
+
+## Escape Characters & Color Codes
+
+### ESC[ ( -- )
+
+Send an ANSI escape character to the terminal. This is intended to precede ANSI
+escape codes.
+
+## Terminal UI
+
+### TI ( -- ), TE ( -- )
+
+Enter or exit TUI mode.
+
+### at-xy ( column, row )
+
+Place the cursor at the specified column and row on screen.
+
+```forth
+5 5 at-xy
+```
+
+### \[home\] ( -- )
+
+Place the cursor at the 1,1 position on screen.
+
+### page ( -- )
+
+Clear the screen and place the cursor at the 1,1 position on screen.
+
+### hide-cursor ( -- ), show-cursor (--)
+
+Hide or show the cursor.
+
+### cleanup ( -- )
+
+After completing a TUI application, clear the screen, exit TUI mode and display
+the cursor.
+
+## Colors
+
+Terminal text may be formatted using typical ANSI color and formatting codes.
+
+```forth
+[black][red/bg]Black on red text[reset]
+```
+
+Further "true color" words may be created using `ESC[` and extended ANSI color
+codes.
--- /dev/null
+---
+title: UART
+file: uart.fs
+---
+
+# UART
+
+The UART library provides words for working with the rp2040's two UART serial
+interfaces. This includes matters of hardware flow control.
+
+The rp2040 has two UART serial interfaces, referred to by the constants UART0
+and UART1.
+
+## Diagram
+
+**TODO** Put ASCII diagram connecting FTDI module and Pico here
+
+## Enabling & Disabling Interfaces
+
+### enabled? ( addr -- flag )
+
+Determine if a UART interface is enabled.
+
+```forth
+UART0 enabled?
+```
+
+### transmit-enabled? ( addr -- flag )
+
+Determine if a UART interface has transmit enabled.
+
+```forth
+UART0 transmit-enabled?
+```
+
+### rts-enabled? ( addr -- flag ), cts-enabled? ( addr -- flag )
+
+Determine if RTS or CTS are enabled for the given interface.
+
+```forth
+UART0 rts-enabled?
+```
+
+### rts-toggle ( addr -- ), cts-toggle ( addr -- )
+
+Enable or disable RTS or CTS for the given interface.
+
+```forth
+UART0 rts-toggle
+```
UART0_BASE UARTCR + constant UART0_CR
UART1_BASE UARTCR + constant UART1_CR
+\ Convenience words for referencing control registers
+: UART0 ( -- addr ) UART0_CR ;
+: UART1 ( -- addr ) UART1_CR ;
+
\ Determine if UART is enabled at this interface
-\ example: UART0_CR enabled?
+\ example: UART0 enabled?
: enabled? ( addr -- flag ) @ 1 AND 0 > ;
: transmit-enabled? ( addr -- flag ) @ 1 8 lshift AND 0 > ;
: rts-enabled? ( addr -- flag ) @ 1 14 lshift AND 0 > ;
: cts-enabled? ( addr -- flag ) @ 1 15 lshift AND 0 > ;
-: rts-toggle ( addr -- flag ) dup @ 1 14 lshift XOR swap ! ;
-: cts-toggle ( addr -- flag ) dup @ 1 15 lshift XOR swap ! ;
+: rts-toggle ( addr -- ) dup @ 1 14 lshift XOR swap ! ;
+: cts-toggle ( addr -- ) dup @ 1 15 lshift XOR swap ! ;