-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e2e9f9
commit 493400a
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
\ ********************************************************************* | ||
\ 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 | ||
|
||
|