[Flashforth-devel] Pin words
Brought to you by:
oh2aun
From: Mikael N. <mik...@pp...> - 2014-03-25 19:08:39
|
I made some words for manipulating pins on pic18. Any comments or suggestions for the names and structure ? Is there any best practice for pin manipulation ? Would it be better to have pin-in: and pin-out: instead of pin-dir: ? BR Mike \ ********************************************************************* \ * \ Filename: pins.txt * \ Date: 25.03.2014 * \ FF Version: 5.0 * \ MCU: PIC18 * \ Copyright: Mikael Nordman * \ Author: Mikael Nordman * \ ********************************************************************* \ FlashForth is licensed acording to the GNU General Public License* \ ********************************************************************* \ Words for manipulating I/O pins -pins marker -pins \ Define a word that sets a pin direction ( tris bit dir "name" -- ) \ dir : 0 = output, 1 = input : pin-dir: : if a, bsf, else a, bcf, then $12 i, postpone [ ; \ Define a word that sets an output pin ( port bit "name" -- ) : pin-on: : a, bsf, $12 i, postpone [ ; \ Define a word that clears an output pin ( port bit "name" -- ) : pin-off: : a, bcf, $12 i, postpone [ ; \ Define a word that leaves a true flag if a bit is one \ and a false flag if a bit is zero. ( port bit "name" -- ) : pin-in: : ['] false in, a, btfss, $12 i, ['] invert in, $12 i, postpone [ ; $ff82 constant portc $ff94 constant trisc $0000 constant bit0 trisc bit0 0 pin-dir: pc0out trisc bit0 1 pin-dir: pc0in portc bit0 pin-on: pc0on portc bit0 pin-off: pc0off portc bit0 pin-in: pc0? |