aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/appl/eval-pollin/blocks
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/appl/eval-pollin/blocks')
-rw-r--r--amforth-6.5/appl/eval-pollin/blocks/hd44780.frt115
-rw-r--r--amforth-6.5/appl/eval-pollin/blocks/hello-world.frt81
-rw-r--r--amforth-6.5/appl/eval-pollin/blocks/netio.frt32
3 files changed, 228 insertions, 0 deletions
diff --git a/amforth-6.5/appl/eval-pollin/blocks/hd44780.frt b/amforth-6.5/appl/eval-pollin/blocks/hd44780.frt
new file mode 100644
index 0000000..0524f5f
--- /dev/null
+++ b/amforth-6.5/appl/eval-pollin/blocks/hd44780.frt
@@ -0,0 +1,115 @@
+\
+\ Module: hd44780 routines
+\ use the hd44780 module in 8bit mode
+\ v 0.9
+
+\ needs marker.frt and bitnames.frt from lib
+
+marker _hd44780_
+
+
+hex
+
+\ for the pollin addon board 1.0
+1b 20 + constant hd44780-data \ PORTA
+18 20 + constant hd44780-ctrl \ PORTB
+
+hd44780-ctrl 1 portpin: hd44780-rw
+hd44780-ctrl 0 portpin: hd44780-en
+hd44780-ctrl 2 portpin: hd44780-rs
+
+2 constant hd44780-pulse-delay
+a constant hd44780-short-delay
+
+: hd44780-pulse-en
+ hd44780-en high
+ hd44780-pulse-delay ms
+ hd44780-en low
+ hd44780-pulse-delay ms
+;
+
+: hd44780-data-mode
+ hd44780-rs high
+;
+
+: hd44780-command-mode
+ hd44780-rs low
+;
+
+
+: hd44780-read-mode
+ 0 hd44780-data 1- c! \ input
+ hd44780-rw high
+;
+
+: hd44780-write-mode
+ ff hd44780-data 1- c! \ output
+ hd44780-rw low
+;
+
+: hd44780-read-data ( -- c )
+ hd44780-read-mode
+ hd44780-pulse-en
+ hd44780-short-delay ms
+ hd44780-data 1- 1- c@
+;
+
+: hd44780-wait
+ hd44780-read-mode
+ hd44780-rw high
+ hd44780-rs low
+ hd44780-pulse-en
+ begin
+ hd44780-data 1- 1- c@
+ 80 and
+ until
+;
+
+: hd44780-command ( n -- )
+ hd44780-wait
+ hd44780-write-mode
+ hd44780-command-mode
+ hd44780-data c!
+ hd44780-pulse-en
+;
+
+: hd44780-emit ( c -- )
+ hd44780-write-mode
+ hd44780-data-mode
+ hd44780-data c!
+ hd44780-pulse-en
+;
+
+: hd44780-init
+ hd44780-rw pin_output
+ hd44780-en pin_output
+ hd44780-rs pin_output
+;
+\ from tracker: hd44780.frt - added LCD initialization - ID: 2785157
+: hd44780-cmd-no-wait ( n -- )
+ hd44780-write-mode
+ hd44780-command-mode
+ hd44780-data c!
+ hd44780-pulse-en
+;
+
+: hd44780-start
+ hd44780-init
+ 15 ms
+ 30 hd44780-cmd-no-wait
+ 4 ms
+ 30 hd44780-cmd-no-wait
+ 1 ms
+ 30 hd44780-cmd-no-wait
+ 38 hd44780-command
+ 6 hd44780-command
+ c hd44780-command
+ 1 hd44780-command
+;
+
+
+: hd44780-page ( clear page )
+ 1 hd44780-command ( clear hd44780 )
+ 3 hd44780-command ( cursor home )
+;
+
diff --git a/amforth-6.5/appl/eval-pollin/blocks/hello-world.frt b/amforth-6.5/appl/eval-pollin/blocks/hello-world.frt
new file mode 100644
index 0000000..94073b8
--- /dev/null
+++ b/amforth-6.5/appl/eval-pollin/blocks/hello-world.frt
@@ -0,0 +1,81 @@
+\ test routines for the atmel evaluation
+\ boards from www.pollin.de
+\ needs the device register definitions loaded
+
+#require ms.frt
+
+marker _pollin_
+
+decimal
+
+\ wait some milliseconds
+: blinkdelay 250 ms ;
+
+PORTD 5 portpin: led1
+PORTD 6 portpin: led2
+
+PORTD 2 portpin: key1
+PORTD 3 portpin: key2
+PORTD 4 portpin: key3
+
+GICR 7 portpin: en_int1
+GICR 6 portpin: en_int0
+GICR 5 portpin: en_int2
+
+: +demoports
+ led1 pin_output
+ led2 pin_output
+ key1 pin_input
+ key2 pin_input
+ key3 pin_input
+
+ 05 MCUCR c! \ int0/1
+ en_int1 high
+ en_int0 high
+ en_int2 low
+;
+
+\ test runs until a terminal-key is pressed
+
+\ as long as a key on the board is pressed the
+\ corresponding led/buzzer is turned on
+: keys
+ begin
+ PIND c@
+ [ hex ] fc and
+ 3 lshift
+ PORTD c!
+ key? until
+ key drop \ we do not want to keep this key stroke
+;
+
+
+: blink ( -- )
+ led1 high blinkdelay
+ led2 high blinkdelay
+ led2 low blinkdelay
+ led1 low blinkdelay
+;
+
+: led1blink
+ led1 high
+ blinkdelay
+ led1 low
+;
+
+\ simple lights on/off
+: led
+ begin
+ blink
+ key?
+ until
+ key drop \ we do not want to keep this key stroke
+;
+
+\ interrupt processing takes a long time, do not
+\ press the key while it runs...
+\ ' led1blink 1 int!
+\ ' noop 2 int!
+
+\ autoconfig the i/o ports
+\ ' portinit 'turnkey e!
diff --git a/amforth-6.5/appl/eval-pollin/blocks/netio.frt b/amforth-6.5/appl/eval-pollin/blocks/netio.frt
new file mode 100644
index 0000000..6c1f62c
--- /dev/null
+++ b/amforth-6.5/appl/eval-pollin/blocks/netio.frt
@@ -0,0 +1,32 @@
+
+\ Definitions for the netio-addon board
+
+\ SPI communication pins
+ PORTB 4 portpin: /ss
+ PORTB 5 portpin: _mosi
+ PORTB 6 portpin: _miso
+ PORTB 7 portpin: _clk
+
+\ setup the SPI pins
+ : +spi ( -- )
+ /ss high \ activate pullup!
+ _mosi high _mosi pin_output
+ _clk low _clk pin_output
+ ;
+
+ : -spi 0 SPCR c! ;
+
+ \ transfer 1 cell
+ : ><spi ( x -- x' )
+ dup >< c!@spi
+ swap c!@spi
+ swap >< +
+ ;
+
+: +mmc
+ /ss low
+;
+: -mmc
+ /ss high
+;
+