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.
sqmbed/src/mbedsq.cpp@2:0df9688c9a11, 2014-12-16 (annotated)
- Committer:
- jhnwkmn
- Date:
- Tue Dec 16 13:32:06 2014 +0000
- Revision:
- 2:0df9688c9a11
- Parent:
- 1:540008bb92a2
Updated libraries.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhnwkmn | 0:6f55c7651ccc | 1 | /* |
jhnwkmn | 1:540008bb92a2 | 2 | Copyright 2014 Johan Wikman |
jhnwkmn | 1:540008bb92a2 | 3 | |
jhnwkmn | 1:540008bb92a2 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
jhnwkmn | 1:540008bb92a2 | 5 | you may not use this file except in compliance with the License. |
jhnwkmn | 1:540008bb92a2 | 6 | You may obtain a copy of the License at |
jhnwkmn | 1:540008bb92a2 | 7 | |
jhnwkmn | 1:540008bb92a2 | 8 | http://www.apache.org/licenses/LICENSE-2.0 |
jhnwkmn | 1:540008bb92a2 | 9 | |
jhnwkmn | 1:540008bb92a2 | 10 | Unless required by applicable law or agreed to in writing, software |
jhnwkmn | 1:540008bb92a2 | 11 | distributed under the License is distributed on an "AS IS" BASIS, |
jhnwkmn | 1:540008bb92a2 | 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
jhnwkmn | 1:540008bb92a2 | 13 | See the License for the specific language governing permissions and |
jhnwkmn | 1:540008bb92a2 | 14 | limitations under the License. |
jhnwkmn | 0:6f55c7651ccc | 15 | */ |
jhnwkmn | 0:6f55c7651ccc | 16 | |
jhnwkmn | 0:6f55c7651ccc | 17 | #include <mbed.h> |
jhnwkmn | 0:6f55c7651ccc | 18 | #include <sqmbed/digitalin.h> |
jhnwkmn | 0:6f55c7651ccc | 19 | #include <sqmbed/digitalinout.h> |
jhnwkmn | 0:6f55c7651ccc | 20 | #include <sqmbed/digitalout.h> |
jhnwkmn | 0:6f55c7651ccc | 21 | #include <sqmbed/interruptin.h> |
jhnwkmn | 0:6f55c7651ccc | 22 | #include <sqmbed/pwmout.h> |
jhnwkmn | 0:6f55c7651ccc | 23 | #include <sqmbed/ticker.h> |
jhnwkmn | 0:6f55c7651ccc | 24 | #include <sqmbed/timeout.h> |
jhnwkmn | 0:6f55c7651ccc | 25 | #include <sqmbed/timer.h> |
jhnwkmn | 0:6f55c7651ccc | 26 | |
jhnwkmn | 0:6f55c7651ccc | 27 | using namespace std; |
jhnwkmn | 0:6f55c7651ccc | 28 | |
jhnwkmn | 0:6f55c7651ccc | 29 | namespace |
jhnwkmn | 0:6f55c7651ccc | 30 | { |
jhnwkmn | 0:6f55c7651ccc | 31 | |
jhnwkmn | 0:6f55c7651ccc | 32 | void bindGlobals(HSQUIRRELVM vm) |
jhnwkmn | 0:6f55c7651ccc | 33 | { |
jhnwkmn | 0:6f55c7651ccc | 34 | sqbind_function(vm, "wait", wait); |
jhnwkmn | 0:6f55c7651ccc | 35 | sqbind_function(vm, "wait_ms", wait_ms); |
jhnwkmn | 0:6f55c7651ccc | 36 | sqbind_function(vm, "wait_us", wait_us); |
jhnwkmn | 0:6f55c7651ccc | 37 | } |
jhnwkmn | 0:6f55c7651ccc | 38 | |
jhnwkmn | 0:6f55c7651ccc | 39 | void bindMbed(HSQUIRRELVM vm) |
jhnwkmn | 0:6f55c7651ccc | 40 | { |
jhnwkmn | 0:6f55c7651ccc | 41 | SqMbed::DigitalIn::bind(vm); |
jhnwkmn | 0:6f55c7651ccc | 42 | SqMbed::DigitalInOut::bind(vm); |
jhnwkmn | 0:6f55c7651ccc | 43 | SqMbed::DigitalOut::bind(vm); |
jhnwkmn | 0:6f55c7651ccc | 44 | SqMbed::InterruptIn::bind(vm); |
jhnwkmn | 0:6f55c7651ccc | 45 | SqMbed::PwmOut::bind(vm); |
jhnwkmn | 0:6f55c7651ccc | 46 | SqMbed::Ticker::bind(vm); |
jhnwkmn | 0:6f55c7651ccc | 47 | SqMbed::Timeout::bind(vm); |
jhnwkmn | 0:6f55c7651ccc | 48 | SqMbed::Timer::bind(vm); |
jhnwkmn | 0:6f55c7651ccc | 49 | } |
jhnwkmn | 0:6f55c7651ccc | 50 | |
jhnwkmn | 0:6f55c7651ccc | 51 | } |
jhnwkmn | 0:6f55c7651ccc | 52 | |
jhnwkmn | 0:6f55c7651ccc | 53 | extern "C" void sq_bind_mbed(HSQUIRRELVM vm) |
jhnwkmn | 0:6f55c7651ccc | 54 | { |
jhnwkmn | 0:6f55c7651ccc | 55 | bindGlobals(vm); |
jhnwkmn | 0:6f55c7651ccc | 56 | bindMbed(vm); |
jhnwkmn | 0:6f55c7651ccc | 57 | |
jhnwkmn | 0:6f55c7651ccc | 58 | // Platform specific bindings. |
jhnwkmn | 0:6f55c7651ccc | 59 | SqMbed::bindPlatform(vm); |
jhnwkmn | 0:6f55c7651ccc | 60 | } |
jhnwkmn | 0:6f55c7651ccc | 61 | |
jhnwkmn | 0:6f55c7651ccc | 62 | extern "C" void mbed_execute_idle(HSQUIRRELVM vm) |
jhnwkmn | 0:6f55c7651ccc | 63 | { |
jhnwkmn | 0:6f55c7651ccc | 64 | SqMbed::InterruptIn::flushInterrupts(); |
jhnwkmn | 0:6f55c7651ccc | 65 | SqMbed::Trigger::flushTriggers(); |
jhnwkmn | 0:6f55c7651ccc | 66 | } |