]> Vexing Labs - forthdeck.git/commitdiff
baby steps w/ UART, start moving docs
authorAdam Shamblin <adam@vexingworkshop.com>
Sun, 26 Jun 2022 21:11:54 +0000 (15:11 -0600)
committerAdam Shamblin <adam@vexingworkshop.com>
Sun, 26 Jun 2022 21:11:54 +0000 (15:11 -0600)
README.md
doc/gpio.md [new file with mode: 0644]
doc/index.md [new file with mode: 0644]
src/sysinfo.fs
src/uart.fs

index 2a090367f9d14a1895f1cdcdf95990c203d94f2c..262677acac68d4aac88951ace818babda3fd1bb2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -12,77 +12,13 @@ keywords:
 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.
 
-## GPIO
+[Documentation](doc/index.md)
 
-*file: gpio.fs*
-
-### pin ( n -- addr )
-
-Given a pin number, return the pin's address on the IO bank.
-
-```forth
-13 pin
-```
-
-### funcsel@ ( addr -- n ) *funcsel fetch*
-
-Given a pin address, leave the number of the currently selected pin function on
-the stack.
-
-```forth
-13 pin funcsel@
-```
-
-### funcsel! ( addr n -- ) *funcsel set*
-
-Given a pin address and a function number (see GPIO pin constants), set the
-selected pin's function.
-
-```forth
-13 pin SIO funcsel!
-```
-
-### pins ( -- )
-
-Display a list of all GPIO pins and their currently selected function.
-
-```forth
-pins
-```
-
-### output-enable ( n -- ), output-disable ( n -- )
-
-Given a pin number, enable or disable that pin for output.
-
-```forth
-13 output-enable
-13 output-disable
-```
-
-### output-enabled? ( n -- flag )
-
-Given a pin number, leave a flag on the stack indicating whether or not output
-is enabled.
-
-```forth
-13 output-enabled?
-```
-
-### output-enabled. ( -- )
-
-Display a table of pins and their output status.
-
-```forth
-output-enabled.
-```
-
-## Terminal
-
-*file: terminal.fs*
 
 ## TODO
 
 * Timers
 * Blocks
+* UART
 * SPI
 * U2F image
diff --git a/doc/gpio.md b/doc/gpio.md
new file mode 100644 (file)
index 0000000..f9240dd
--- /dev/null
@@ -0,0 +1,74 @@
+---
+title: GPIO
+file: gpio.fs
+---
+
+The GPIO library provides a number of constants and words for working directly
+with the GPIO pins of the rp2040.
+
+## Function Selection
+
+The Raspberry Pi Pico has 30 programmable pins. Each of these pins may be used
+for a number of functions as defined the the rp2040 datasheet.
+
+### pin ( n -- addr )
+
+Given a pin number, return the pin's address on the IO bank.
+
+```forth
+13 pin
+```
+
+### funcsel@ ( addr -- n ) *funcsel fetch*
+
+Given a pin address, leave the number of the currently selected pin function on
+the stack.
+
+```forth
+13 pin funcsel@
+```
+
+### funcsel! ( addr n -- ) *funcsel set*
+
+Given a pin address and a function number (see GPIO pin constants), set the
+selected pin's function.
+
+```forth
+13 pin SIO funcsel!
+```
+
+### pins ( -- )
+
+Display a list of all GPIO pins and their currently selected function.
+
+```forth
+pins
+```
+
+## Output
+
+### output-enable ( n -- ), output-disable ( n -- )
+
+Given a pin number, enable or disable that pin for output.
+
+```forth
+13 output-enable
+13 output-disable
+```
+
+### output-enabled? ( n -- flag )
+
+Given a pin number, leave a flag on the stack indicating whether or not output
+is enabled.
+
+```forth
+13 output-enabled?
+```
+
+### output-enabled. ( -- )
+
+Display a table of pins and their output status.
+
+```forth
+output-enabled.
+```
diff --git a/doc/index.md b/doc/index.md
new file mode 100644 (file)
index 0000000..a50ead8
--- /dev/null
@@ -0,0 +1,5 @@
+---
+title: Documentation
+---
+
+* [GPIO](gpio.md)
index 9189cb3fc43a0b8f404b1c9f28a74974c37073d8..15aed85f7b962a08a0884a87104a2a930bf466b7 100644 (file)
@@ -4,3 +4,10 @@ $40000000          constant SYSINFO_BASE
 SYSINFO_BASE $00 + constant CHIP_ID
 SYSINFO_BASE $04 + constant PLATFORM
 SYSINFO_BASE $40 + constant GITREF_RP2040
+
+: fpga? ( -- ) PLATFORM @ 1 0 lshift AND 0 > ;
+: asic? ( -- ) PLATFORM @ 1 1 lshift AND 0 > ;
+: platform. ( -- ) fpga? IF ." FPGA" ELSE ." ASIC" THEN ;
+
+: chipid. ( -- ) CHIP_ID @ hex u. ;
+: gitref. ( -- ) GITREF_RP2040 @ hex u. ;
index 62b90f3dfeb60a24fbce80aaab07098568c2315b..5d6765ee5f6e9be3dfd3d6f224b3dfffb0b25bb5 100644 (file)
@@ -9,12 +9,16 @@ $030 constant UARTCR
 
 \ Addressed registers
 UART0_BASE UARTCR + constant UART0_CR
+UART1_BASE UARTCR + constant UART1_CR
 
-\ *NOTE* This is getting interesting enough
-\ to put on a slide presentation, perhaps for Denhac
+\ Determine if UART is enabled at this interface
+\ example: UART0_CR enabled?
+: enabled? ( addr -- flag ) @ 1 AND 0 > ;
+: transmit-enabled? ( addr -- flag ) @ 1 8 lshift AND 0 > ;
 
-\ ?? What is the difference between CTS and RTS?
-\ Clear to Send
-\ Ready to Send
+\ Hardware Flow Control
+: rts-enabled? ( addr -- flag ) @ 1 14 lshift AND 0 > ;
+: cts-enabled? ( addr -- flag ) @ 1 15 lshift AND 0 > ;
 
-: transfer-enabeled? ( n -- flag ) ; 
+: rts-toggle ( addr -- flag ) dup @ 1 14 lshift XOR swap ! ;
+: cts-toggle ( addr -- flag ) dup @ 1 15 lshift XOR swap ! ;