The Mecrisp REPL

Terminal handlers

emit, emit?, key and key? are the UART handlers.

If you wish to use blocking IO, you can set hook-emit? and hook-key? statically to true.

Repl Maximum Character Length

You can change the accepted length in forth-core.s for “Maximaleeingabe” which is currently set to 200 characters.

Ledcomm Example from Matthias

https://sourceforge.net/p/mecrisp/discussion/general/thread/e29549a8d5/?limit=25#4afd/6b1e [matthias.koch]

key? ( -- ? ) is giving you a flag meaning if there is (at least) one character in the receive buffer.
key ( -- c ) is waiting until a character is received (it calls key? internally in a loop) and gives back that character.

The hooks are just vectors, accepting a pointer to a definition.

hook-key takes a definition which works as "key" and hook-key? takes a definition which works as "key?"

Look at this snipplet:

0 variable tx-puffer
0 variable rx-puffer

Communication is done from/to buffer variables driven by timers/interrupts

Then wire the buffers in accordingly:

: ledcomm-key? ( -- ? ) rx-puffer @ 0<> ;
: ledcomm-key ( -- c ) begin ledcomm-key? until rx-puffer @ 0 rx-puffer ! ;
: ledcomm-emit? ( -- ? ) tx-puffer @ 0= ;
: ledcomm-emit ( c -- ) begin ledcomm-emit? until tx-puffer ! ;

Switch terminal to new definitions:

['] ledcomm-key? hook-key? !
['] ledcomm-key hook-key !
['] ledcomm-emit? hook-emit? !
['] ledcomm-emit hook-emit !

Table Of Contents

Previous topic

CMSIS-SVD

Next topic

Serial Terminal: Software

This Page