So the microcontroller shouldn't need to know in advance how to "handle" these expansion boards, and shouldn't need "upgrade" when a new type of expansion board comes into existance. And therefor the idea is to have a Forth program sitting in an EEPROMon each expansion board, containing 4 words each;
BUT, I can not write to program that executes the Forth words that are in the eeprom, since that doesn't exist yet. Here was my first attempt at this;
: slot-powerup ( slot# -- ) Called on Colibri powerup for each slot, ONLY ONCE.
dup slot-on 1 delay Power up the slot, wait
dup slot-reset 1 delay RESET cycle
dup slot-select Select slot
1 block-read read the EEPROM
if .yellow< ." EEPROM not present in slot. " >.
2dup #1024 evaluate execute forth code from EEPROM. EEPROM should have been filled with SPACE at end.
if swap ." Error interpreting EEPROM in slot " . free exit then EEPROM program must have ( slot# c-addr len -- err? )
dup 1- cells
attach hooks
' (init) over cells slot-init + !
' (tick) over cells slot-tick + !
' (read) over cells slot-read + !
' (write) over cells slot-write + !
slot-init @ execute call "init" for slot
( slot# channels )
;
(Variant; MECRISP Forth for STM32)
Basically, (init), (tick), (read) and (write) are "not found", and even if I "pre-define" them, this snippet of code will be pointing to the old ones, not the words that were just read out from the EEPROM.
So, can someone think of any smarter way to do this, before I try to manually walk the dictionary to locate the word I am looking for?
Alternatively, the EEPROM could contain source code that leaves the
xts of the four words you want on the stack, in addition to the other
values. Then the code above would look like
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 475 |
Nodes: | 16 (2 / 14) |
Uptime: | 20:18:32 |
Calls: | 9,487 |
Calls today: | 6 |
Files: | 13,617 |
Messages: | 6,121,093 |