aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/appl/eval-pollin/blocks/hello-world.frt
blob: 94073b872631e6ddef7317c43bee65a8b5482d1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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!