User Contributed Device Driver Code

A excellent source for drivers, peripherals and just learning Forth is the Mecrisp-Stellaris release itself, where contributors have shared their code. This is the very best way of finding help to use in your project, learning how to write peripheral code, learning about Mecrisp-Stellaris and so on.

This resource is the fastest way compared to wading thru a million pasted C code examples via Google looking for ways to make that STM32 Timer code work. Trust me on this ….

However, finding what you want can be a bit tedious as there are a LOT of sub-directories to search, so here they are, listed by name and showing where to find them.

Sharing Your Code

If you have device driver code to share, just email Matthias at “m-atthias@users.sf.net” with your code and ask him to include it in the next release. You’ll need to state the MCU it’s designed for and it will need to be released under the GPL. A suggested source code header is below. Be sure to include the peripheral name in your filename or my search script won’t find it for my next update.

Also check for any existing drivers of the same type (for your supported MCU) to avoid naming conflicts.

Suggested Source File Header

\ ------------------------------------------------------------
\ File Name: <your-program.txt or your-program.fs>
\ Date:
\ Copyright: GPL
\ For Mecrisp-Stellaris by Matthias Koch. http://mecrisp.sourceforge.net
\ MCU Model: <STM32F407>
\ Aim: This program does ....
\ Author: <you>
\ ------------------------------------------------------------

User Sources

Download the latest Mecrisp-Stellaris release here .

Example:

GPIO: ./mk20dx256/gpio.txt is  mecrisp-stellaris-2.6.2/mk20dx256/gpio.txt

Listed by Device

Source: mecrisp-stellaris-2.6.5
Peripherals listed alphabetically
Copyright 2024 by Terry Porter, MIT licensed.

ADC
./stm32f303k8/lib_adc1.txt
./stm32f407/adc-1msps-stm32f4.txt
./stm32f407/adc.txt
./stm32f407/lib_adc.txt
./tm4c1294/ether-adc.txt
./stm32f411/adc.txt
./kl25z128/adc.txt
./stm32f051/Examples by Andrew Palm/example-adc.fs
./lm4f120/adc-1msps.txt
./lm4f120/adc-1msps-2chan.txt
./stm32f303k8-ra/lib_adc1.txt

BLE

BLINKY
./stm32l073rz-ra/blinky.txt
./stm32l152/blinky.txt
./stm32g031j6-ra/blinky.txt
./stm32l432-ra/blinky.txt
./stm32g031f8-ra/blinky.txt
./msp432p401r/blinky.txt
./rp2040-ra/blinky.txt
./stm32l053c8/blinky.txt
./stm32l152rb/blinky.txt
./nuc123/blinky.fs
./stm32f042f6/blinky.txt
./cy8c4245axi/blinky.txt
./xmc1100/blinky.txt
./aducm4050-ra/blinky.txt
./mk64fn1m0/blinky.txt
./stm32f411/blinky.txt
./kl46z256/blinky.txt
./efm32gg990/blinky.txt
./stm32l073rz/blinky.txt
./atsame70-ra/blinky.txt
./stm32f401cd-ra/blinky.txt
./stm32f051/blinky.txt
./stm32f303-ra/blinky.txt
./efm32hg322/blinky.txt
./stm32g071rb-ra/blinky.txt
./stm32f401/blinky.txt
./microbit/blinky-multitask.txt
./microbit/blinky.txt
./microbit/calliope/blinky.txt
./stm32f103rb/blinky.fs
./lpc1114fn28/blinky.txt

BRESENHAM
common/circles.txt:\  Bresenham circle
common/graphics-8x12.txt:\  Bresenham line
common/graphics-8x12.txt:\  Bresenham ellipse
common/graphics-unicode-3x3.txt:\  Bresenham line
common/graphics-unicode-3x3.txt:\  Bresenham ellipse
common/graphics-unicode-4x6.txt:\  Bresenham line
common/graphics-unicode-4x6.txt:\  Bresenham ellipse
common/graphics-unicode-8x16.txt:\  Bresenham line
common/graphics-unicode-8x16.txt:\  Bresenham ellipse
common/graphics-unicode-8x8.txt:\  Bresenham line
common/graphics-unicode-8x8.txt:\  Bresenham ellipse
common/graphics.txt:\  Bresenham line
common/graphics.txt:\  Bresenham ellipse

BUTTON
./rp2040-ra/button.txt
./stm32f407/button.txt
./stm32f429/button.txt

CAN
./stm32f407/can.txt
./stm32f407/drv_can.txt

COMP
./numworks-ra/completesources.txt

CRC

CRYP

DAC
./mk20dx256/dac.txt
./stm32f407/dac.txt
./kl25z128/dac.txt

DELAY
./mk20dx256/delay.txt
./stm32l152rb/delaytim2.f
./stm32f407/delay.txt
./tm4c1294/delay.txt
./numworks-ra/delay.txt
./stm32f429/delaytim2.f
./stm32f411/delaytim2.fs
./kl25z128/delay.txt
./stm32f051/Examples by Andrew Palm/example-delay.fs
./lm4f120/delay.txt
./lm4f120/oscilloscope/delay.txt

DMA
./stm32f401cd-ra/drv_usart_DMA.txt

EPAPER
./stm32l053c8/epaper-hw.txt
./stm32l053c8/epaper-paint.txt
./stm32l053c8/epaper-32c3.txt

ESP8266
./stm32f401cd-ra/drv_ESP8266.txt

ETHERNET
./tm4c1294/ethernet.txt

EXTI

FLASH
./stm32f746-ra/clean-debug-flash-demo.txt
./stm32f407/drv_flash.txt
./stm32f407/flash.txt
./stm32f411-ra/flash.fs
./common/VIS/vis-wordlist-in-flash-ms.fs

FPU

GPIO
./mk20dx256/gpio.txt
./stm32f411-ra/gpio.fs
./stm32f407-ra/gpio.fs
./stm32f030r8-ra/gpio.fs
./common/experimental/vocs-0.7.0/examples/lm4f120/GPIO.txt

GPS
./stm32f303k8/drv_gps.txt
./stm32l432-ra/drv_gps.txt
./stm32f303k8-ra/drv_gps.txt

HASH

HTU21DF
./stm32l432-ra/drv_HTU21DF.txt

I2C
./stm32g031j6-ra/i2c.txt
./stm32l432-ra/drv_i2c1.txt
./stm32f051/Examples by Andrew Palm/example-nunchuk-i2c.fs
./lpc1114fn28/i2c.txt

IMU
./stm32f303/imu.txt

INTERRUPT
./rp2040-ra/interrupt.txt
./stm32l152rb/interrupts.f

LED
./stm32l152/Ledcomm-NucleoL152.txt
./stm32g031j6-ra/drv_LED_HT16K33_7Seg.txt
./stm32g031j6-ra/drv_LED_HT16K33.txt
./mk20dx256/led.txt
./msp432p401r/Ledcomm-MSP432.txt
./stm32f207zg/led.fs
./stm32f411-ra/led.fs
./stm32f407-ra/led.fs
./stm32f429/leds.txt
./efm32gg990/Ledcomm-Gecko.txt
./tm4c1294-ra/leds.txt
./tm4c1294-ra/leds-v2.2.txt
./lm4f120/Ledcomm-Stellaris.txt
./common/experimental/vocs-0.7.0/examples/lm4f120/RGB-LED.txt
./cy8c5888/led.txt
./lpc1114fn28/Ledcomm-LPC.txt

LCD
./stm32l432-ra/drv_lcd.txt
./stm32f051/Examples by Andrew Palm/glcdfont.fs
./stm32f103/lcd-ptinting.fs
./stm32f103/lcd-base.fs
./stm32f103/lcd-graphics.fs
./lpc1114fn28/lcd_164.txt

LORAN
./tm4c1294/loran.txt

MPU

NEOPIXEL

NUNCHUK
./stm32f051/Examples by Andrew Palm/example-nunchuk-i2c.fs

NVIC
./mk20dx256/nvic.txt
./nrf52832/lib/nvic.fs
./common/nvic.txt

ONE-WIRE
./stm32l152rb/1wire.f
./stm32f429/1w.fs
./stm32f411/1w.fs

OTG
./mk20dx256/usbotg.txt

PLL
./stm32f303k8/lib_pll.txt
./stm32l432-ra/lib_pll.txt
./stm32f207zg/pll.fs
./stm32f407/f407-pll-168MHz.txt
./stm32f407/pll-60mhz.txt
./stm32f407/pll-30mhz.txt
./stm32f407/pll-120mhz.txt
./tm4c1294/pll.txt
./stm32f407-ra/pll.fs
./stm32f429/pll-120mhz.txt
./stm32f411/pll-100mhz.fs
./stm32f100/f100-pll-48MHz-oc.txt
./stm32g431kb-ra/lib_pll.txt
./lm4f120/pll.txt
./lm4f120/pll-values.txt
./stm32f303k8-ra/lib_pll.txt
./lpc1114fn28/pll.txt

PWM
./stm32f407/lib_pwm.txt
./kl25z128/colourful-pwm.txt
./lm4f120/colourful-pwm.txt
./microbit/dual-pwm.fs
./lpc1114fn28/pwm-in.txt
./lpc1114fn28/pwm-out.txt

RCC
./stm32f411-ra/rcc.fs
./stm32f407-ra/def-rcc.fs
./common/svd2forth-v3/bitfields-rcc-screenshot.txt
./common/svd2forth-v3/equates-rcc-sample.txt

RNG
./nrf52832/lib/rng.fs
./stm32f407/rng.txt

RTC
./stm32l152rb/rtc.f
./nrf51822/nRF51_BLE_source/rtc.fth
./tm4c1294/rtc.txt
./stm32f429/rtc.fs
./stm32f411/rtc.fs
./stm32f051-ra/rtc/rtc-calib.fs
./stm32f051-ra/rtc/rtc-temp-cal.fs
./stm32f051-ra/rtc/rtc-init-set.fs
./stm32g431kb-ra/lib_rtc.txt
./lm4f120/rtc.txt

SERVO
./stm32f303k8/drv_servo.txt
./stm32f051/Examples by Andrew Palm/example-servo.fs
./stm32f303k8-ra/drv_servo.txt

SD
./stm32f411/sd.fs

SI4432
./stm32f411/si4432_spi.fs
./stm32f103/si4432_spi.fs

SINE
./mk20dx256/dac-examples/sine-wave.txt
./stm32f407-ra/sinewaves.txt
./common/sine.txt

SPI
./stm32f407/drv_spi2.txt
./stm32f411/si4432_spi.fs
./stm32f103/si4432_spi.fs

SSD1306
./stm32f051/Examples by Andrew Palm/example-ssd1306.fs
./stm32f030k6/example-ssd1306.fs

SSD3306

ST7735
./stm32f051/Examples by Andrew Palm/example-st7735.fs

STEPPER
./stm32f051/Examples by Andrew Palm/example-stepper.fs

SUNRISE
./common/sunrise-sunset.fs

SYSTICK
./stm32g031j6-ra/systick.txt
./stm32f303k8/lib_systick.txt
./stm32l432-ra/lib_systick.txt
./stm32f411/systick.fs
./stm32g431kb-ra/lib_systick.txt
./stm32f401cd-ra/lib_systick.txt
./stm32f303-ra/lib_systick.txt
./stm32f303k8-ra/lib_systick.txt

TFT
./stm32f429/tft.fs
./stm32f429/tft.txt
./stm32f411/tft-base.fs
./stm32f411/tft-printing.fs
./stm32f411/tft-graphics.fs
./stm32f411/tft-touch.fs

TIM
./mk20dx256/timer.txt
./nrf52832/lib/timer.fs
./stm32l152rb/delaytim2.f
./nrf51822/nRF51_BLE_source/timer.fth
./stm32f407/lib_timer.txt
./stm32f429/delaytim2.f
./stm32f411/delaytim2.fs
./lm4f120/timer-irq.txt
./common/date-time.fs
./common/date-time-tests.fs

TSC

UART
./mk20dx256/uart.txt

ULTRASONIC
./stm32f051/Examples by Andrew Palm/example-ultrasonic.fs

USART
./stm32f303k8/drv_usart1.txt
./stm32l432-ra/drv_usart1.txt
./stm32l152rb/usart1.f
./stm32f407/drv_usart6.txt
./stm32f429/usart3.f
./stm32f411/usart1.fs
./stm32f401cd-ra/drv_usart_DMA.txt
./stm32f303k8-ra/drv_usart1.txt

USB
./mk20dx256/usbotg.txt
./mk20dx256/usbdcd.txt
./stm32f407-ra/usb-f4.fs
./stm32f103-ra/usb-f1.txt
./stm32f303-ra/usb-f3.txt

WIFI
./stm32f407/drv_wifi.txt

WS2812
./stm32f303k8/drv_WS2812B.txt
./nrf52832/lib/ws2812.fs
./stm32f303k8-ra/drv_WS2812B.txt

Where are the Memory Maps ?

If the user source doesn’t contain the needed peripheral memory maps (it happens sometimes …) I recommend you read thru the CMSIS-SVD page and download the file at the end.

This has everything you need to generate a memory map for your particular MCU, tho you may need to download <your-mcu>.svd file. This is explained in the readme.

Note

SVD2FORTH is designed for STM32 SVD’s and may have issues with SVD files for other makes of MCU.

Notes for TP

  1. cp scripts/ms-release-examples.sh to the root dir of the latest mecrisp-Stellaris release

  2. ./ms-release-examples.sh in the root dir of the latest mecrisp-Stellaris release, this updates /home/tp/projects/programming-languages/forth/mecrisp-stellaris/mecrisp-unofficial-doc/txt/examples.txt

  3. compile the userdoc, check the local copy and if ok, update to the Sourceforge server