The Squirrel interpreter for FRDM-K64F, extended with a set of classes that provide access to the mbed functionality (currently DigitalIn, DigitalInOut, DigitalOut, InterruptIn, PwmOut, Ticker, Timeout, Timer).

Dependencies:   SQUIRREL3 mbed sqbind-0_99

The Squirrel interpreter for FRDM-K64F.

NOTE: Currently of POC quality.

See http://www.squirrel-lang.org/ for information about the Squirrel language.

Currently the following (a subset of their functionality) mbed classes are available from within Squirrel:

  • DigitalIn
  • DigitalOut
  • DigitalInOut
  • PwmOut
  • Ticker
  • Timeout
  • Timer

In addition, InterruptIn is supported, but interrupts are noted when they occur, but only delivered from the main loop of the interpreter.

See also README.txt in the root of the project.

Committer:
jhnwkmn
Date:
Tue Dec 16 12:54:53 2014 +0000
Revision:
0:6f55c7651ccc
Added README.txt;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhnwkmn 0:6f55c7651ccc 1 Squirrel for FRDM-K64F
jhnwkmn 0:6f55c7651ccc 2 ======================
jhnwkmn 0:6f55c7651ccc 3 This is an *experimental* port of the Squirrel interpreter to the mbed
jhnwkmn 0:6f55c7651ccc 4 platform, in particular FRDM-K64F. Experimental means that that the port
jhnwkmn 0:6f55c7651ccc 5 is of POC quality, so don't expect to be able to switch over to Squirrel
jhnwkmn 0:6f55c7651ccc 6 just yet.
jhnwkmn 0:6f55c7651ccc 7
jhnwkmn 0:6f55c7651ccc 8 That said, it can already be used for trying things out interractively
jhnwkmn 0:6f55c7651ccc 9 from a prompt.
jhnwkmn 0:6f55c7651ccc 10
jhnwkmn 0:6f55c7651ccc 11 For more information about the Squirrel language, please consult the
jhnwkmn 0:6f55c7651ccc 12 official site http://www.squirrel-lang.org/. There is also useful
jhnwkmn 0:6f55c7651ccc 13 Squirrel information at the Electric Imp site
jhnwkmn 0:6f55c7651ccc 14 (https://electricimp.com/docs/squirrel/learningsquirrel/). Squirrel
jhnwkmn 0:6f55c7651ccc 15 is the "native" language of Electric Imp.
jhnwkmn 0:6f55c7651ccc 16
jhnwkmn 0:6f55c7651ccc 17 In addition to the interpreter itself, a few core components of mbed
jhnwkmn 0:6f55c7651ccc 18 has also been made available:
jhnwkmn 0:6f55c7651ccc 19
jhnwkmn 0:6f55c7651ccc 20 DigitalIn
jhnwkmn 0:6f55c7651ccc 21 DigitalOut
jhnwkmn 0:6f55c7651ccc 22 DigitalInOut
jhnwkmn 0:6f55c7651ccc 23 PwmOut
jhnwkmn 0:6f55c7651ccc 24 Ticker
jhnwkmn 0:6f55c7651ccc 25 Timeout
jhnwkmn 0:6f55c7651ccc 26 Timer
jhnwkmn 0:6f55c7651ccc 27
jhnwkmn 0:6f55c7651ccc 28 The provided functionality is a subset of the corresponding native
jhnwkmn 0:6f55c7651ccc 29 mbed components.
jhnwkmn 0:6f55c7651ccc 30
jhnwkmn 0:6f55c7651ccc 31 Examine the components in sqmbed/src to see what functionality is
jhnwkmn 0:6f55c7651ccc 32 available.
jhnwkmn 0:6f55c7651ccc 33
jhnwkmn 0:6f55c7651ccc 34
jhnwkmn 0:6f55c7651ccc 35 In addition, InterruptIn is also supported. However, interrupts are
jhnwkmn 0:6f55c7651ccc 36 *not* delivered as they occur, but they are queued and delivered when
jhnwkmn 0:6f55c7651ccc 37 it is safe to do so from the point of view of the Squirrel interpreter.
jhnwkmn 0:6f55c7651ccc 38 In practice this means that they are not delivered from interrupt
jhnwkmn 0:6f55c7651ccc 39 context and that there are no restrictions what can be done in the
jhnwkmn 0:6f55c7651ccc 40 handler.
jhnwkmn 0:6f55c7651ccc 41
jhnwkmn 0:6f55c7651ccc 42 Source structure
jhnwkmn 0:6f55c7651ccc 43 ----------------
jhnwkmn 0:6f55c7651ccc 44 +sqbind-0_099 Utility library that makes binding easier.
jhnwkmn 0:6f55c7651ccc 45 +sqk64f k64f-specific code (interrupt handling)
jhnwkmn 0:6f55c7651ccc 46 +sqmbed Generic mbed extensions for Squirrel.
jhnwkmn 0:6f55c7651ccc 47 +SQUIRREL3 The Squirrel virtual machine.
jhnwkmn 0:6f55c7651ccc 48
jhnwkmn 0:6f55c7651ccc 49 PuTTY Configuration
jhnwkmn 0:6f55c7651ccc 50 -------------------
jhnwkmn 0:6f55c7651ccc 51 Default terminal settings, but for
jhnwkmn 0:6f55c7651ccc 52 [X] Implicit CR in every LF
jhnwkmn 0:6f55c7651ccc 53
jhnwkmn 0:6f55c7651ccc 54 Local echo:
jhnwkmn 0:6f55c7651ccc 55 (o) Force on
jhnwkmn 0:6f55c7651ccc 56
jhnwkmn 0:6f55c7651ccc 57 Local line editing:
jhnwkmn 0:6f55c7651ccc 58 (o) Force on
jhnwkmn 0:6f55c7651ccc 59
jhnwkmn 0:6f55c7651ccc 60
jhnwkmn 0:6f55c7651ccc 61 Trying Out
jhnwkmn 0:6f55c7651ccc 62 ==========
jhnwkmn 0:6f55c7651ccc 63 - Build in the web-ide.
jhnwkmn 0:6f55c7651ccc 64 - Flash the .bin file.
jhnwkmn 0:6f55c7651ccc 65 - Start Putty.
jhnwkmn 0:6f55c7651ccc 66 - Press reset on the board.
jhnwkmn 0:6f55c7651ccc 67
jhnwkmn 0:6f55c7651ccc 68 You should be greeted with:
jhnwkmn 0:6f55c7651ccc 69
jhnwkmn 0:6f55c7651ccc 70 Squirrel 3.0.6 stable Copyright (C) 2003-2014 Alberto Demichelis (32 bits)
jhnwkmn 0:6f55c7651ccc 71
jhnwkmn 0:6f55c7651ccc 72 sq>
jhnwkmn 0:6f55c7651ccc 73
jhnwkmn 0:6f55c7651ccc 74 Then try the usual Hello World.
jhnwkmn 0:6f55c7651ccc 75
jhnwkmn 0:6f55c7651ccc 76 sq>print("Hello World\n");
jhnwkmn 0:6f55c7651ccc 77 Hello, World
jhnwkmn 0:6f55c7651ccc 78
jhnwkmn 0:6f55c7651ccc 79 sq>
jhnwkmn 0:6f55c7651ccc 80
jhnwkmn 0:6f55c7651ccc 81 Let's try turning the led on and off.
jhnwkmn 0:6f55c7651ccc 82
jhnwkmn 0:6f55c7651ccc 83 sq>::led<-DigitalOut(LED1);
jhnwkmn 0:6f55c7651ccc 84
jhnwkmn 0:6f55c7651ccc 85 sq>led.write(0);
jhnwkmn 0:6f55c7651ccc 86
jhnwkmn 0:6f55c7651ccc 87 sq>led.write(1);
jhnwkmn 0:6f55c7651ccc 88
jhnwkmn 0:6f55c7651ccc 89 sq>
jhnwkmn 0:6f55c7651ccc 90
jhnwkmn 0:6f55c7651ccc 91 Let's inform when button SW2 is pressed.
jhnwkmn 0:6f55c7651ccc 92
jhnwkmn 0:6f55c7651ccc 93 sq>::i<-InterruptIn(SW2);
jhnwkmn 0:6f55c7651ccc 94
jhnwkmn 0:6f55c7651ccc 95 sq>function buttonPressed() { print("Button pressed\n"); }
jhnwkmn 0:6f55c7651ccc 96
jhnwkmn 0:6f55c7651ccc 97 sq>buttonPressed();
jhnwkmn 0:6f55c7651ccc 98 Button pressed
jhnwkmn 0:6f55c7651ccc 99
jhnwkmn 0:6f55c7651ccc 100 sq>i.rise(buttonPressed);
jhnwkmn 0:6f55c7651ccc 101
jhnwkmn 0:6f55c7651ccc 102 sq>while (true) {}
jhnwkmn 0:6f55c7651ccc 103 Button pressed
jhnwkmn 0:6f55c7651ccc 104 Button pressed
jhnwkmn 0:6f55c7651ccc 105 Button pressed
jhnwkmn 0:6f55c7651ccc 106
jhnwkmn 0:6f55c7651ccc 107 Note that in order for the interrupts to work, the interpreter needs to be
jhnwkmn 0:6f55c7651ccc 108 running. That it won't be, while waiting for input at the prompt ("sq>").
jhnwkmn 0:6f55c7651ccc 109
jhnwkmn 0:6f55c7651ccc 110 Contact
jhnwkmn 0:6f55c7651ccc 111 =======
jhnwkmn 0:6f55c7651ccc 112 Feel free to contact me in case you have questions: johan.wikman@iki.fi
jhnwkmn 0:6f55c7651ccc 113
jhnwkmn 0:6f55c7651ccc 114