-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpinsDefinitions.txt
68 lines (54 loc) · 1.38 KB
/
pinsDefinitions.txt
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
\ *********************************************************************
\ ARDUINO pins definitions
\ Filename: pinsDefinitions.txt
\ author: Marc PETREMANN
\ Date: 04-june-2020
\ MCU: FlashForth Arduino all models
\ GNU General Public License
\ *********************************************************************
\ Use:
\ PORTD %10000000 defPIN: PD7 ( define portD pin #7)
: defPIN: ( PORTx mask --- <word> | <word> --- mask port)
create
c, c, \ compile PORT and pin mask
does>
dup c@ \ push pin mask
swap 1+ c@ \ push PORT
;
\ Turn a pin on, dont change others
: high ( pinmask portadr -- )
mset
;
\ Turn a pin off, dont change others
: low ( pinmask portadr -- )
mclr
;
\ Only for PORTx bits
\ address of DDRx is one less than address of PORTx
\ Set DDRx so its corresponding pin is output.
: output ( pinmask portadr -- )
1- high
;
\ Set DDRx so its corresponding pin is input.
: input ( pinmask portadr -- )
1- low
;
\ read the pins masked as input
: pin@ ( pinmask portaddr -- fl )
2- mtst \ select PINx register as input
if true
else false then
;
-testLED
marker -testLED
\ tests
\ PORTB
37 constant PORTB \ Port B Data Register
PORTB %10000000 defPIN: LED
: init.ports ( ---)
LED output
;
init.ports
LED high
500 ms
LED low