GraspForth port for STM32 Primer 1 and 2
GraspForth (created by Bernard Mentink) stands for Gcc/Relocatable/fAst/Small/Portable Forth. This Forth system runs potentially on every 32-bit processor architecture with a corresponding GCC port. For those with special knowledge, it uses GCC's calculating labels to do the threading. The communication works over the VirtualCOM (Emulation of a serial port over USB).
Current version of the source code worked on Primer1, but should work on Primer2 almost without changes.
To use this Forth, install the resulting binary as usual and start the program GRSPFRTH. Connect to the newly registered serial port (of course, the port will be recognized only if you connect the USB cable between the application USB port on Primer and a USB port on your main computer) with the following settings: 115200 baud, 8 bits, no parity,1 stop bit, no flow control. Voila! You can exit the application with a press of a button.
(Remember though, that these settings work only for manual input; if you paste an entire source, it is possible, that because of too long compiling times some definitions will be dropped, and it is not what you want! Change the baud setting in src\hw_config.c if you desire to compile long sources automatically.)
The source code is structured as following:
Directory Forth contains the original GraspForth implementation together with the STM32 Primer-relevant include file stm32primer.h and the updated graspforth.c (the updates are basically the preprocessor-induced definitions for void GF_Task(void)).
Directory Software Driver has a driver for the serial-over-USB port.
Directory src has a main application source in the file Application.c; the rest is the USB library together with hardware abstraction library from STM. The file hw_config.c contains the USB descriptior.
The architecture is rather simple: The words of the Forth system are processed in a loop, 50000 words in one Application_Handler() call. If the output buffer is full or there is no (needed) input, the GF_Task() exits, hence the Forth system has to wait until the next Application_Handler() and through this the next GF_Task() call.