TURNKEY
turnkey ( -- addr )
Specific Flash Forth
Vector for user start-up word. EEPROM value mirrored in SRAM.
When the application is ready, the application word address can be stored in the turnkey vector, and your autonomous embedded application has been set up.
When FlashForth starts (or resets), it can be configured to run any word from the dictionary by mapping that word to the turnkey word. This is particularly useful if you have created an embedded application that you want to run automatically whenever your Arduino is turned on.
In this example, myWord
is made to launch at start up:
' myWord is turnkey
The tick word '
searches the dictionary for the name of the word
(specified by the string of characters immediately after ' ), and places the
address of myWord on the stack. The word is then stores the address to
the dictionary entry for turnkey
.
On restart, if turnkey
is 0 (false), FlashForth starts normally.
If turnkey
is not zero, it is treated as a token (pointer) to a
word to be run. You can use RESET to bypass turnkey
, if you need to
disable it or change it. Other sources of restart (such as power-on, brown-out
reset, warm etc) will execute turnkey
immediately.