From 493400a3426c0e496afcdc0ebdf43cdf07e7745e Mon Sep 17 00:00:00 2001 From: MPETREMANN11 <57889978+MPETREMANN11@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:45:07 +0200 Subject: [PATCH] ARDUINO pins definitions --- pinsDefinitions.txt | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 pinsDefinitions.txt diff --git a/pinsDefinitions.txt b/pinsDefinitions.txt new file mode 100644 index 0000000..2991bba --- /dev/null +++ b/pinsDefinitions.txt @@ -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 --- | --- 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 + +