This is the open source Pawn interpreter ported to mbed. See here: http://www.compuphase.com/pawn/pawn.htm and here: http://code.google.com/p/pawnscript/

Dependents:   Pawn4Test

Some instructions:

  • Put the attached include folder next to your source, so when you compile you get all the proper definitions
  • Use the attached main.p as a starting point if you wish
  • Compile your main.p into main.amx - Put your main.amx on the mbed 'drive'
  • Reset and be amazed.

Important Compile Notes:

  • You should use the -S# option to define a smaller default stack size. Start with -S64 and go up from there if needed.
  • To use on the Cortex-M0 version of the mbed (LPC11U24), you MUST include the TARGET=3 command-line option as well, so the pin names are properly defined. In the future this may be handled on the native code side.

Known Issues:

  • At the moment it appears the kbhit() function is not working right - at least on my mac. Will continue testing on Windows. Working fine.

Todo:

  • Add more wrappers for the mbed peripherals
  • Add Pawn overlay support, to allow much larger scripts to run (even on the LPC11U24)
Committer:
Lobo
Date:
Fri May 24 17:49:26 2013 +0000
Revision:
3:185fdbb7ccf0
Parent:
2:01588bd27169
Now includes AnalogIn and AnalogOut functions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tylerwilson 0:3ab1d2d14eb3 1 /*
tylerwilson 0:3ab1d2d14eb3 2 * Platform
tylerwilson 0:3ab1d2d14eb3 3 * __MSDOS__ set when compiling for DOS (not Windows)
tylerwilson 0:3ab1d2d14eb3 4 * _Windows set when compiling for any version of Microsoft Windows
tylerwilson 0:3ab1d2d14eb3 5 * __WIN32__ set when compiling for Windows95 or WindowsNT (32 bit mode)
tylerwilson 0:3ab1d2d14eb3 6 * __32BIT__ set when compiling in 32-bit "flat" mode (DOS, Windows, ARM)
tylerwilson 0:3ab1d2d14eb3 7 * __64BIT__ set when compiling in 64-bit mode
tylerwilson 0:3ab1d2d14eb3 8 * __ECOS__ set if Pawn was included with the eCos with configtool
tylerwilson 0:3ab1d2d14eb3 9 * __LINUX__ set when compiling for Linux
tylerwilson 0:3ab1d2d14eb3 10 *
tylerwilson 0:3ab1d2d14eb3 11 * Copyright 1998-2011, ITB CompuPhase, The Netherlands.
tylerwilson 0:3ab1d2d14eb3 12 * No usage restrictions, no warranties.
tylerwilson 0:3ab1d2d14eb3 13 */
tylerwilson 0:3ab1d2d14eb3 14
tylerwilson 0:3ab1d2d14eb3 15 #ifndef _OSDEFS_H
tylerwilson 0:3ab1d2d14eb3 16 #define _OSDEFS_H
tylerwilson 0:3ab1d2d14eb3 17
tylerwilson 0:3ab1d2d14eb3 18 /* Every compiler uses different "default" macros to indicate the mode
tylerwilson 0:3ab1d2d14eb3 19 * it is in. Throughout the source, we use the Borland C++ macros, so
tylerwilson 0:3ab1d2d14eb3 20 * the macros of Watcom C/C++ and Microsoft Visual C/C++ are mapped to
tylerwilson 0:3ab1d2d14eb3 21 * those of Borland C++.
tylerwilson 0:3ab1d2d14eb3 22 */
tylerwilson 0:3ab1d2d14eb3 23 #if defined(__WATCOMC__)
tylerwilson 0:3ab1d2d14eb3 24 #if defined(__WINDOWS__) || defined(__NT__)
tylerwilson 0:3ab1d2d14eb3 25 #define _Windows 1
tylerwilson 0:3ab1d2d14eb3 26 #endif
tylerwilson 0:3ab1d2d14eb3 27 #if defined(__386__) || defined(__NT__)
tylerwilson 0:3ab1d2d14eb3 28 #define __32BIT__ 1
tylerwilson 0:3ab1d2d14eb3 29 #endif
tylerwilson 0:3ab1d2d14eb3 30 #if defined(_Windows) && defined(__32BIT__)
tylerwilson 0:3ab1d2d14eb3 31 #define __WIN32__ 1
tylerwilson 0:3ab1d2d14eb3 32 #endif
tylerwilson 0:3ab1d2d14eb3 33 #elif defined(_MSC_VER)
tylerwilson 0:3ab1d2d14eb3 34 #if defined(_WINDOWS) || defined(_WIN32)
tylerwilson 0:3ab1d2d14eb3 35 #define _Windows 1
tylerwilson 0:3ab1d2d14eb3 36 #endif
tylerwilson 0:3ab1d2d14eb3 37 #if defined(_WIN32)
tylerwilson 0:3ab1d2d14eb3 38 #define __WIN32__ 1
tylerwilson 0:3ab1d2d14eb3 39 #define __32BIT__ 1
tylerwilson 0:3ab1d2d14eb3 40 #endif
tylerwilson 0:3ab1d2d14eb3 41 #elif defined __arm__
tylerwilson 0:3ab1d2d14eb3 42 #define __32BIT__ 1
tylerwilson 0:3ab1d2d14eb3 43 #elif defined __AVR__
tylerwilson 0:3ab1d2d14eb3 44 #define __16BIT__ 1
tylerwilson 0:3ab1d2d14eb3 45 #endif
tylerwilson 0:3ab1d2d14eb3 46 #if !defined __16BIT__ && !defined __32BIT__ && !defined __64BIT__
tylerwilson 0:3ab1d2d14eb3 47 #define __32BIT__ 1
tylerwilson 0:3ab1d2d14eb3 48 #endif
tylerwilson 0:3ab1d2d14eb3 49
tylerwilson 0:3ab1d2d14eb3 50 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC11U24)
tylerwilson 2:01588bd27169 51 // no Unicode support, so force only ANSI
tylerwilson 0:3ab1d2d14eb3 52 #define AMX_ANSIONLY 1
tylerwilson 2:01588bd27169 53 // No dynamically loaded module
tylerwilson 0:3ab1d2d14eb3 54 #define AMX_NODYNALOAD 1
tylerwilson 2:01588bd27169 55 // use the simplest Console I/O type - serial terminal
tylerwilson 0:3ab1d2d14eb3 56 #define AMX_TERMINAL 1
tylerwilson 2:01588bd27169 57 // If we get the core VM working with RVDS assember, this will speed things up
tylerwilson 1:cc719e522b5d 58 // #define AMX_ASM 1
tylerwilson 2:01588bd27169 59 // for the amxtime module. On Linux, stime is the standard set time call. On mbed,
tylerwilson 2:01588bd27169 60 // it is set_time. Fortunately, they both take the same param - seconds since 01/01/70
tylerwilson 2:01588bd27169 61 #define stime(x) set_time(x)
tylerwilson 0:3ab1d2d14eb3 62 #endif
tylerwilson 0:3ab1d2d14eb3 63
tylerwilson 0:3ab1d2d14eb3 64 #if (defined __linux || defined __linux__) && !defined __LINUX__
tylerwilson 0:3ab1d2d14eb3 65 #define __LINUX__
tylerwilson 0:3ab1d2d14eb3 66 #endif
tylerwilson 0:3ab1d2d14eb3 67 /* To be able to eventually set __ECOS__, we have to find a symbol
tylerwilson 0:3ab1d2d14eb3 68 * defined in a common place (so including the header file won't break
tylerwilson 0:3ab1d2d14eb3 69 * anything for other platforms). <sys/types.h> includes
tylerwilson 0:3ab1d2d14eb3 70 * <pkgconf/system.h> and in this later file we can find CYGPKG_PAWN
tylerwilson 0:3ab1d2d14eb3 71 * if the Pawn package was included with configtool and so we know
tylerwilson 0:3ab1d2d14eb3 72 * that we are compiling for eCos.
tylerwilson 0:3ab1d2d14eb3 73 */
tylerwilson 0:3ab1d2d14eb3 74 #if defined CCSINFO
tylerwilson 0:3ab1d2d14eb3 75 #include <sys/types.h>
tylerwilson 0:3ab1d2d14eb3 76 #endif
tylerwilson 0:3ab1d2d14eb3 77 #if defined CYGPKG_PAWN
tylerwilson 0:3ab1d2d14eb3 78 #define __ECOS__ 1
tylerwilson 0:3ab1d2d14eb3 79 #define HAVE_ALLOCA_H 0
tylerwilson 0:3ab1d2d14eb3 80 #endif
tylerwilson 0:3ab1d2d14eb3 81
tylerwilson 0:3ab1d2d14eb3 82
tylerwilson 0:3ab1d2d14eb3 83 #if defined __FreeBSD__
tylerwilson 0:3ab1d2d14eb3 84 #include <sys/endian.h>
tylerwilson 0:3ab1d2d14eb3 85 #elif defined __LINUX__
tylerwilson 0:3ab1d2d14eb3 86 #include <endian.h>
tylerwilson 0:3ab1d2d14eb3 87 #elif defined __ECOS__
tylerwilson 0:3ab1d2d14eb3 88 #include <cyg/hal/hal_endian.h>
tylerwilson 0:3ab1d2d14eb3 89 #define BIG_ENDIAN 4321
tylerwilson 0:3ab1d2d14eb3 90 #define LITTLE_ENDIAN 1234
tylerwilson 0:3ab1d2d14eb3 91 #if (CYG_BYTEORDER == CYG_LSBFIRST)
tylerwilson 0:3ab1d2d14eb3 92 #define BYTE_ORDER LITTLE_ENDIAN
tylerwilson 0:3ab1d2d14eb3 93 #else
tylerwilson 0:3ab1d2d14eb3 94 #define BYTE_ORDER BIG_ENDIAN
tylerwilson 0:3ab1d2d14eb3 95 #endif
tylerwilson 0:3ab1d2d14eb3 96 /*
tylerwilson 0:3ab1d2d14eb3 97 * eCos option management.
tylerwilson 0:3ab1d2d14eb3 98 */
tylerwilson 0:3ab1d2d14eb3 99 #include <pkgconf/pawn.h>
tylerwilson 0:3ab1d2d14eb3 100 #if CYGPKG_PAWN_AMX_ANSIONLY==1
tylerwilson 0:3ab1d2d14eb3 101 #define AMX_ANSIONLY
tylerwilson 0:3ab1d2d14eb3 102 #endif
tylerwilson 0:3ab1d2d14eb3 103 #define PAWN_CELL_SIZE CYGPKG_PAWN_AMX_CELLSIZE
tylerwilson 0:3ab1d2d14eb3 104 #if CYGPKG_PAWN_CORE_RANDOM==0
tylerwilson 0:3ab1d2d14eb3 105 #define AMX_NORANDOM
tylerwilson 0:3ab1d2d14eb3 106 #endif
tylerwilson 0:3ab1d2d14eb3 107 #if CYGPKG_PAWN_CORE_PROPERTY==0
tylerwilson 0:3ab1d2d14eb3 108 #define AMX_NOPROPLIST
tylerwilson 0:3ab1d2d14eb3 109 #endif
tylerwilson 0:3ab1d2d14eb3 110 #if CYGPKG_PAWN_AMX_CONS_FIXEDPOINT==1
tylerwilson 0:3ab1d2d14eb3 111 #define FIXEDPOINT
tylerwilson 0:3ab1d2d14eb3 112 #endif
tylerwilson 0:3ab1d2d14eb3 113 #if CYGPKG_PAWN_AMX_CONS_FLOATPOINT==1
tylerwilson 0:3ab1d2d14eb3 114 #define FLOATPOINT
tylerwilson 0:3ab1d2d14eb3 115 #endif
tylerwilson 0:3ab1d2d14eb3 116 #endif
tylerwilson 0:3ab1d2d14eb3 117
tylerwilson 0:3ab1d2d14eb3 118 /* Linux now has these */
tylerwilson 0:3ab1d2d14eb3 119 #if !defined BIG_ENDIAN
tylerwilson 0:3ab1d2d14eb3 120 #define BIG_ENDIAN 4321
tylerwilson 0:3ab1d2d14eb3 121 #endif
tylerwilson 0:3ab1d2d14eb3 122 #if !defined LITTLE_ENDIAN
tylerwilson 0:3ab1d2d14eb3 123 #define LITTLE_ENDIAN 1234
tylerwilson 0:3ab1d2d14eb3 124 #endif
tylerwilson 0:3ab1d2d14eb3 125
tylerwilson 0:3ab1d2d14eb3 126 /* educated guess, BYTE_ORDER is undefined, i386 is common => little endian */
tylerwilson 0:3ab1d2d14eb3 127 #if !defined BYTE_ORDER
tylerwilson 0:3ab1d2d14eb3 128 #if defined UCLINUX
tylerwilson 0:3ab1d2d14eb3 129 #define BYTE_ORDER BIG_ENDIAN
tylerwilson 0:3ab1d2d14eb3 130 #else
tylerwilson 0:3ab1d2d14eb3 131 #define BYTE_ORDER LITTLE_ENDIAN
tylerwilson 0:3ab1d2d14eb3 132 #endif
tylerwilson 0:3ab1d2d14eb3 133 #endif
tylerwilson 0:3ab1d2d14eb3 134
tylerwilson 0:3ab1d2d14eb3 135 #if defined __MSDOS__ || defined __WIN32__ || defined _Windows
tylerwilson 0:3ab1d2d14eb3 136 #define DIRSEP_CHAR '\\'
tylerwilson 0:3ab1d2d14eb3 137 #elif defined macintosh || defined __APPLE__
tylerwilson 0:3ab1d2d14eb3 138 #define DIRSEP_CHAR ':'
tylerwilson 0:3ab1d2d14eb3 139 #else
tylerwilson 0:3ab1d2d14eb3 140 #define DIRSEP_CHAR '/' /* directory separator character */
tylerwilson 0:3ab1d2d14eb3 141 #endif
tylerwilson 0:3ab1d2d14eb3 142
tylerwilson 0:3ab1d2d14eb3 143 /* _MAX_PATH is sometimes called differently and it may be in limits.h or
tylerwilson 0:3ab1d2d14eb3 144 * stdlib.h instead of stdio.h.
tylerwilson 0:3ab1d2d14eb3 145 */
tylerwilson 0:3ab1d2d14eb3 146 #if !defined _MAX_PATH
tylerwilson 0:3ab1d2d14eb3 147 /* not defined, perhaps stdio.h was not included */
tylerwilson 0:3ab1d2d14eb3 148 #if !defined PATH_MAX
tylerwilson 0:3ab1d2d14eb3 149 #include <stdio.h>
tylerwilson 0:3ab1d2d14eb3 150 #endif
tylerwilson 0:3ab1d2d14eb3 151 #if !defined _MAX_PATH && !defined PATH_MAX
tylerwilson 0:3ab1d2d14eb3 152 /* no _MAX_PATH and no MAX_PATH, perhaps it is in limits.h */
tylerwilson 0:3ab1d2d14eb3 153 #include <limits.h>
tylerwilson 0:3ab1d2d14eb3 154 #endif
tylerwilson 0:3ab1d2d14eb3 155 #if !defined _MAX_PATH && !defined PATH_MAX
tylerwilson 0:3ab1d2d14eb3 156 /* no _MAX_PATH and no MAX_PATH, perhaps it is in stdlib.h */
tylerwilson 0:3ab1d2d14eb3 157 #include <stdlib.h>
tylerwilson 0:3ab1d2d14eb3 158 #endif
tylerwilson 0:3ab1d2d14eb3 159 /* if _MAX_PATH is undefined, try common alternative names */
tylerwilson 0:3ab1d2d14eb3 160 #if !defined _MAX_PATH
tylerwilson 0:3ab1d2d14eb3 161 #if defined MAX_PATH
tylerwilson 0:3ab1d2d14eb3 162 #define _MAX_PATH MAX_PATH
tylerwilson 0:3ab1d2d14eb3 163 #elif defined _POSIX_PATH_MAX
tylerwilson 0:3ab1d2d14eb3 164 #define _MAX_PATH _POSIX_PATH_MAX
tylerwilson 0:3ab1d2d14eb3 165 #else
tylerwilson 0:3ab1d2d14eb3 166 /* everything failed, actually we have a problem here... */
tylerwilson 0:3ab1d2d14eb3 167 #define _MAX_PATH 1024
tylerwilson 0:3ab1d2d14eb3 168 #endif
tylerwilson 0:3ab1d2d14eb3 169 #endif
tylerwilson 0:3ab1d2d14eb3 170 #endif
tylerwilson 0:3ab1d2d14eb3 171
tylerwilson 0:3ab1d2d14eb3 172 #endif /* _OSDEFS_H */