This page presents examples of: 1) changing the prompt, 2) reading and writing files, 3) using files on an attached SD-card, 4) using r6rs-style libraries, 5) the Runge-Kutta example of r5rs, 6) the library-based Runge-Kutta example of r6rs, 7) Fast Fourier Transforms (FFT), 8) an expert system, 9) the game of life (Conway), and 10) an ARMSchembler and compiler for Armpit Scheme. Examples that differ from prior releases are presented in full while those that are the same are linked to the appropriate web page (possibly via multiple links). Examples may not work out-of-the-box on small MCUs (NXP LPC-1343, 2103, 2131, 4357 (non-flash)) due to the absence of macros and of the r5rs library on these chips (eg. let, string-append). It is left as an exercise to the reader to modifiy them for this purpose, if desired. Examples of GPIO, Threads, ADC, PWM and other hardware-oriented processes (if available) are presented in a separate page of MCU-specific examples.
This example is the same as in version 060
This example is the same as in version 060
This example is the same as in version 060
This example is the same as in version 060
This example is the same as in version 060
This example is the same as in version 060
This example is the same as in version 060
This example is the same as in version 060
This example is the same as in version 060
The ARMSchembler presented here is a an updated version of that in 050. It is designed to be loaded from an SD card and to be used with the linker that is in the 070 core.
After copying the ARMSchembler source file to a SD card on your development system, place the card in an ArmPit Scheme system, reset it (if desired or needed), initialize the SD sub-system (if needed) and install the ARMSchembler:ap> (sd-init) ; check for #t or #vu8(...), redo if #f (not needed on OMAP3x,OMAP4x,AM335x) ap> (load "asarL070.scm" SDFT) ; for ARM (omit SDFT on OMAP3x,OMAP4x,AM335x Live-SD) ap> (libs) ; check for (as) ... to verify installation OR: ap> (sd-init) ; check for #t or #vu8(...), redo if #f (not needed on OMAP3530) ap> (load "asT2L070.scm" SDFT) ; for Cortex-M3 (Thumb2) ap> (libs) ; check for (as) ... to verify installationThe Compiler for ArmPit Scheme (caps) library is also an update of the compiler for 050:
ap> (load "capsL070.scm" SDFT) ; all architectures (omit SDFT on OMAP3x,OMAP4x,AM335x Live-SD) ap> (libs) ; check for (caps) ... to verify installationARMSchembler and Compiler initialization and tests are presented here:
This version (070) includes a Parks-Miller linear congruential pseudo-random number sequence generator, named RNG, that takes a 4-octet bytevector as input and returns a 4-octet bytevector representing the next value in the pseudo-random sequence. It can be used in functions that return integer or float pseudo-random number generators, with uniform distribution, as in this example:
;; integer (0 to 536870911) (define (make-irndu seed) (lambda () (bytevector-s32-native-ref (ash (RNG seed) -2) 0))) ;; float (0.0 to 1.0) (define (make-frndu seed) (lambda () (/ (bytevector-s32-native-ref (ash (RNG seed) -2) 0) 5.36870911e8)))These pseudo-random generators can then be used as follows:
ap> (define q (make-irndu #vu8(1 0 0 0))) ap> (q) ;; output is pseudo-random integer (call repeatedly for sequence) ap> (define r (make-frndu #vu8(1 0 0 0))) ap> (r) ;; output is pseudo-random float (call repeatedly for sequence)