naming convention for public/private words?
- From: Frank Buss <fb@xxxxxxxxxxxxx>
- Date: Sun, 27 Apr 2008 19:41:27 +0200
I'm implementing a system with multiple layers, e.g. two low-level words,
which are called from higher levels:
\ set the state of a digital output pin
\ state: 1 for high, 0 for low
\ n: digital output 1 or 2
: set-digital-output ( state n -- )
\ get the state of a digital input pin
\ n: digital input 1 or 2
\ return: 1, if high; 0, if low
: digital-input? ( n -- state )
These IO words are in one file, but need some more words to set the
registers of the microcontroller, which doesn't make sense to call from the
higher level, e.g. something like this (the code works, but looks a bit
ugly)
\ implementation for changing a GPIO
0 value gpio-control-regs
here to gpio-control-regs
0x30 , 0x34 , 0x120 ,
: gpio-write ( value reg -- )
ns9xxx-base-reg-pa-gpio memory-write
;
: get-control-reg ( pin -- reg )
32 / cells gpio-control-regs + @
;
: control-gpio ( state pin -- )
0 0 locals| reg shift pin state |
pin get-control-reg to reg
pin 32 mod to shift
reg gpio-read
1 shift lshift invert and
state shift lshift or
reg gpio-write
;
Is there a usual naming convention for such private words?
--
Frank Buss, fb@xxxxxxxxxxxxx
http://www.frank-buss.de, http://www.it4-systems.de
.
- Prev by Date: Re: Taylor series FSIN, FCOS, FTAN
- Next by Date: Re: Forth on Arduino?
- Previous by thread: Euler problem #22
- Next by thread: forth and virtual memory
- Index(es):
Relevant Pages
|