]> Vexing Labs - forthdeck.git/commitdiff
Further use of timers, probe at sysinfo and rtc.
authorAdam Shamblin <adam@vexingworkshop.com>
Mon, 30 May 2022 00:09:34 +0000 (18:09 -0600)
committerAdam Shamblin <adam@vexingworkshop.com>
Mon, 30 May 2022 00:09:34 +0000 (18:09 -0600)
README.md
rtc.fs [new file with mode: 0644]
sysinfo.fs [new file with mode: 0644]
timer.fs [new file with mode: 0644]

index aa9017853e24aa9066905e1813fef73c21ea5f55..2a090367f9d14a1895f1cdcdf95990c203d94f2c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ Given a pin number, return the pin's address on the IO bank.
 13 pin
 ```
 
-### funcsel@ ( addr -- n )
+### funcsel@ ( addr -- n ) *funcsel fetch*
 
 Given a pin address, leave the number of the currently selected pin function on
 the stack.
@@ -33,7 +33,7 @@ the stack.
 13 pin funcsel@
 ```
 
-### funcsel! ( addr n -- )
+### funcsel! ( addr n -- ) *funcsel set*
 
 Given a pin address and a function number (see GPIO pin constants), set the
 selected pin's function.
@@ -42,6 +42,40 @@ selected pin's function.
 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*
diff --git a/rtc.fs b/rtc.fs
new file mode 100644 (file)
index 0000000..bdbaaf5
--- /dev/null
+++ b/rtc.fs
@@ -0,0 +1,21 @@
+\ Words for interacting with RTC peripheral
+
+$4005c000       constant RTC_BASE
+RTC_BASE $00 +  constant RTC_CLKDIV_M1
+RTC_BASE $04 +  constant RTC_SETUP_0
+RTC_BASE $08 +  constant RTC_SETUP_1
+RTC_BASE $0c +  constant RTC_CTRL
+RTC_BASE $10 +  constant RTC_IRC_SETUP_0
+RTC_BASE $14 +  constant RTC_IRC_SETUP_1
+RTC_BASE $18 +  constant RTC_1
+RTC_BASE $1c +  constant RTC_0
+RTC_BASE $20 +  constant RTC_INTR
+RTC_BASE $24 +  constant RTC_INTE
+RTC_BASE $28 +  constant RTC_INTF
+RTC_BASE $2c +  constant RTC_INTS
+
+( Working with the onboard RTC
+  It would appear the the rpiPico does have an onboard RTC.)
+
+: rtc-active? ( -- flag ) RTC_CTRL %10 and ;
+: rtc-enable ( -- ) RTC_CTRL %1 or ;
diff --git a/sysinfo.fs b/sysinfo.fs
new file mode 100644 (file)
index 0000000..9189cb3
--- /dev/null
@@ -0,0 +1,6 @@
+\ Words for interacting with the sysinfo block
+
+$40000000          constant SYSINFO_BASE
+SYSINFO_BASE $00 + constant CHIP_ID
+SYSINFO_BASE $04 + constant PLATFORM
+SYSINFO_BASE $40 + constant GITREF_RP2040
diff --git a/timer.fs b/timer.fs
new file mode 100644 (file)
index 0000000..f738c95
--- /dev/null
+++ b/timer.fs
@@ -0,0 +1,22 @@
+\ Words for dealing with the system timer peripheral
+
+$40054000 constant TIMER_BASE
+TIMER_BASE $00 + constant TIMEHW
+TIMER_BASE $04 + constant TIMELW
+TIMER_BASE $08 + constant TIMEHR
+TIMER_BASE $0c + constant TIMELR
+
+TIMER_BASE $38 + constant TIMER_INTE
+
+
+\ Display the current system timer. "counter print"
+: counter. ( -- ) TIMELR @ TIMEHR @ swap D. ; 
+
+\ Enable or disable a specific alarm.
+\ example: 2 alarm-enable
+: alarm-enable ( n -- ) 1 swap lshift TIMER_INTE @ or TIMER_INTE ! ;
+: alarm-disable ( n -- ) 1 swap lshift TIMER_INTE @ and TIMER_INTE ! ;
+
+\ Check if an alarm is enabled.
+\ example: 2 alarm-enabled?
+: alarm-enabled? ( n -- flag ) 1 swap lshift TIMER_INTE @ and 0 > ;