From d96c795564fa7ec1fa474c3ef7861164009b1023 Mon Sep 17 00:00:00 2001 From: Luc Chouinard Date: Mon, 27 Nov 2017 22:01:13 -0500 Subject: [PATCH 1/7] port to ESP32 --- .gitignore | 2 + src/{bitlash-api.c => bitlash-api.cpp} | 4 +- ...itlash-builtins.c => bitlash-builtins.cpp} | 4 +- ...{bitlash-cmdline.c => bitlash-cmdline.cpp} | 12 ++++-- src/{bitlash-eeprom.c => bitlash-eeprom.cpp} | 1 + src/{bitlash-error.c => bitlash-error.cpp} | 0 ...lash-functions.c => bitlash-functions.cpp} | 21 ++++++++- ...itlash-instream.c => bitlash-instream.cpp} | 0 ...-interpreter.c => bitlash-interpreter.cpp} | 16 +++++-- src/{bitlash-parser.c => bitlash-parser.cpp} | 21 ++++++--- src/{bitlash-serial.c => bitlash-serial.cpp} | 0 ...{bitlash-taskmgr.c => bitlash-taskmgr.cpp} | 0 ...lash-unix-file.c => bitlash-unix-file.cpp} | 0 src/{bitlash-unix.c => bitlash-unix.cpp} | 4 ++ src/bitlash.h | 43 +++++++++++++++++-- src/{eeprom.c => eeprom.cpp} | 33 +++++++++++++- src/{mygetch.c => mygetch.cpp} | 10 +++++ 17 files changed, 146 insertions(+), 25 deletions(-) rename src/{bitlash-api.c => bitlash-api.cpp} (93%) rename src/{bitlash-builtins.c => bitlash-builtins.cpp} (95%) rename src/{bitlash-cmdline.c => bitlash-cmdline.cpp} (94%) rename src/{bitlash-eeprom.c => bitlash-eeprom.cpp} (99%) rename src/{bitlash-error.c => bitlash-error.cpp} (100%) rename src/{bitlash-functions.c => bitlash-functions.cpp} (96%) rename src/{bitlash-instream.c => bitlash-instream.cpp} (100%) rename src/{bitlash-interpreter.c => bitlash-interpreter.cpp} (97%) rename src/{bitlash-parser.c => bitlash-parser.cpp} (98%) rename src/{bitlash-serial.c => bitlash-serial.cpp} (100%) rename src/{bitlash-taskmgr.c => bitlash-taskmgr.cpp} (100%) rename src/{bitlash-unix-file.c => bitlash-unix-file.cpp} (100%) rename src/{bitlash-unix.c => bitlash-unix.cpp} (99%) rename src/{eeprom.c => eeprom.cpp} (82%) rename src/{mygetch.c => mygetch.cpp} (93%) diff --git a/.gitignore b/.gitignore index 5321bb1..a355965 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ examples/.DS_Store bitlash.o .DS_Store Bitlash/ +.pioenvs +.piolibdeps diff --git a/src/bitlash-api.c b/src/bitlash-api.cpp similarity index 93% rename from src/bitlash-api.c rename to src/bitlash-api.cpp index da829e0..f69385b 100644 --- a/src/bitlash-api.c +++ b/src/bitlash-api.cpp @@ -46,7 +46,7 @@ jmp_buf env; // doCommand: main entry point to execute a bitlash command // numvar doCommand(char *cmd) { - return execscript(SCRIPT_RAM, (numvar) cmd, 0); + return execscript(SCRIPT_RAM, (numvar) cmd, 0); } @@ -55,7 +55,7 @@ void initBitlash(unsigned long baud) { #if defined(TINY_BUILD) beginSerial(9600); #else - beginSerial(baud); + beginSerial(baud); #endif #if defined(ARM_BUILD) diff --git a/src/bitlash-builtins.c b/src/bitlash-builtins.cpp similarity index 95% rename from src/bitlash-builtins.c rename to src/bitlash-builtins.cpp index 5c9c911..4891bb8 100644 --- a/src/bitlash-builtins.c +++ b/src/bitlash-builtins.cpp @@ -69,7 +69,7 @@ const prog_char builtin_table[] PROGMEM = { "print 2+2") // "while 1 {print millis;delay(999);}") #else - "print \"bitlash here! v2.0 (c) 2013 Bill Roy -type HELP-\",free,\"bytes free\"") + "print \"\nbitlash here! v2.0 (c) 2013 Bill Roy -type HELP-\",free,\"bytes free\"") #endif // Add user built-ins here. Some examples: @@ -114,5 +114,7 @@ const prog_char *wordlist = builtin_table; void displayBanner(void) { // print the banner and copyright notice // please note the license requires that you maintain this notice + execscript(SCRIPT_PROGMEM, (numvar) (builtin_table + strlen(builtin_table)+1), 0); + // Serial.println("\nbitlash here! v2.0 (c) 2013 Bill Roy -type HELP-\n"); } diff --git a/src/bitlash-cmdline.c b/src/bitlash-cmdline.cpp similarity index 94% rename from src/bitlash-cmdline.c rename to src/bitlash-cmdline.cpp index 45ac712..f1fe118 100644 --- a/src/bitlash-cmdline.c +++ b/src/bitlash-cmdline.cpp @@ -107,6 +107,7 @@ void initlbuf(void) { // flush any pending serial input while (serialAvailable()) serialRead(); + } @@ -149,7 +150,10 @@ void doCharacter(char c) { if ((c == '\r') || (c == '\n')) { speol(); *lbufptr = 0; - doCommand(lbuf); + // doCommand execute the typed command + // and return its value + // here that value is droped???? why? so not output for free for example + doCommand(lbuf); initlbuf(); } else if (c == 3) { // ^C break/stop @@ -176,9 +180,9 @@ void doCharacter(char c) { } #endif #if !defined(TINY_BUILD) - else if (c == 21) { // ^U to get last line - msgpl(M_ctrlu); - prompt(); + else if (c == 21 || c == 16) { // ^U to get last line + msgpl(M_ctrlu); + prompt(); sp(lbuf); lbufptr = lbuf + strlen(lbuf); } diff --git a/src/bitlash-eeprom.c b/src/bitlash-eeprom.cpp similarity index 99% rename from src/bitlash-eeprom.c rename to src/bitlash-eeprom.cpp index 0283f41..77dde90 100644 --- a/src/bitlash-eeprom.c +++ b/src/bitlash-eeprom.cpp @@ -199,6 +199,7 @@ char id[IDLEN+1]; // buffer for id eewrite(addr, 0); } + EEPROM.commit(); msgpl(M_saved); } diff --git a/src/bitlash-error.c b/src/bitlash-error.cpp similarity index 100% rename from src/bitlash-error.c rename to src/bitlash-error.cpp diff --git a/src/bitlash-functions.c b/src/bitlash-functions.cpp similarity index 96% rename from src/bitlash-functions.c rename to src/bitlash-functions.cpp index 6c2074f..c09913e 100644 --- a/src/bitlash-functions.c +++ b/src/bitlash-functions.cpp @@ -33,6 +33,14 @@ ***/ #include "bitlash.h" + + +#ifdef ESP32 + +// AS Of 2017-11 not analogWrite yet +void analogWrite(byte pin, int value) { sp("analogWrite() not supported yet!");oops('!'); } +#endif + // syntactic sugar for func_handlers() #if 0 // 15022 bytes #define arg1 getarg(1) @@ -86,10 +94,14 @@ numvar func_beep(void) { // unumvar pin, unumvar frequency, unumvar duration) #endif numvar func_free(void) { + #if defined(UNIX_BUILD) return 1000L; #elif defined(ARM_BUILD) return 1000L; +#elif defined(ESP32) + + return (numvar)esp_get_free_heap_size(); #else numvar ret; // from http://forum.pololu.com/viewtopic.php?f=10&t=989&view=unread#p4218 @@ -148,6 +160,8 @@ void dbseed(uint32_t x) { // >print inb(0x53) // 2 // + + numvar func_inb(void) { reqargs(1); return *(volatile byte *) arg1; } numvar func_outb(void) { reqargs(2); *(volatile byte *) arg1 = (byte) arg2; return 0;} numvar func_abs(void) { reqargs(1); return arg1 < 0 ? -arg1 : arg1; } @@ -167,6 +181,7 @@ numvar func_constrain(void) { } numvar func_ar(void) { reqargs(1); return analogRead(arg1); } numvar func_aw(void) { reqargs(2); analogWrite(arg1, arg2); return 0; } +//numvar func_aw(void) { reqargs(2); sigmaDeltaWrite(arg1, arg2); return 0; } numvar func_dr(void) { reqargs(1); return digitalRead(arg1); } numvar func_dw(void) { reqargs(2); digitalWrite(arg1, arg2); return 0; } numvar func_er(void) { reqargs(1); return eeread(arg1); } @@ -487,14 +502,16 @@ bitlash_function fp; else #endif // built-in function -#ifdef UNIX_BUILD +#if defined(UNIX_BUILD) or defined(ESP32) fp = function_table[entry]; #else fp = (bitlash_function) pgm_read_word(&function_table[entry]); #endif parsearglist(); // parse the arguments - numvar ret = (*fp)(); // call the function + + numvar ret = (*fp)(); // call the function + releaseargblock(); // peel off the arguments vpush(ret); // and push the return value } diff --git a/src/bitlash-instream.c b/src/bitlash-instream.cpp similarity index 100% rename from src/bitlash-instream.c rename to src/bitlash-instream.cpp diff --git a/src/bitlash-interpreter.c b/src/bitlash-interpreter.cpp similarity index 97% rename from src/bitlash-interpreter.c rename to src/bitlash-interpreter.cpp index 49abcbe..da3322f 100644 --- a/src/bitlash-interpreter.c +++ b/src/bitlash-interpreter.cpp @@ -62,7 +62,7 @@ void nukeeeprom(void) { } -#if defined(AVR_BUILD) +#if defined(AVR_BUILD) && !defined(ESP32) void cmd_boot(void) { // This is recommended but does not work on Arduino // Reset_AVR(); @@ -95,11 +95,17 @@ void cmd_boot(void) { SCB_AIRCR = 0x05FA0000 | SCB_AIRCR_SYSRESETREQ_MASK; while(1); } -#endif +#endif // if ARM_BUILD==1 +#elif defined(ESP32) + +void cmd_boot(void) {esp_restart();} + + #else void cmd_boot(void) {oops('boot');} #endif + void skipbyte(char c) {;} // Skip a statement without executing it @@ -381,8 +387,10 @@ numvar retval = 0; // numvar getstatementlist(void) { numvar retval = 0; - while ((sym != s_eof) && (sym != s_returning)) retval = getstatement(); - return retval; + while ((sym != s_eof) && (sym != s_returning)) { + retval = getstatement(); + } + return retval; } diff --git a/src/bitlash-parser.c b/src/bitlash-parser.cpp similarity index 98% rename from src/bitlash-parser.c rename to src/bitlash-parser.cpp index 30d20a5..6205069 100644 --- a/src/bitlash-parser.c +++ b/src/bitlash-parser.cpp @@ -35,9 +35,13 @@ ***/ #include "bitlash.h" -#if defined(AVR_BUILD) +#if defined(AVR_BUILD) && ! defined(ESP32) +#warning "AVRBUILD" , AVR_BUILD #include "avr/eeprom.h" #endif +#if defined(ESP32) +//#include +#endif // Interpreter globals byte fetchtype; // current script type @@ -421,7 +425,7 @@ byte pinnum(char id[]) { // > d13=1 ... and similarly for analog pinvars like a5 // // -//#define PIN_ALIASES 1 +#define PIN_ALIASES 1 #ifdef PIN_ALIASES @@ -430,18 +434,19 @@ byte pinnum(char id[]) { #define PV_MASK 0x3f const prog_char pinnames[] PROGMEM = { - "tx\0rx\0led\0vin\0zed\0" + "tx\0rx\0led\0vin\0zed\0therm1\0therm2\0" }; const prog_uchar pinvalues[] PROGMEM = { - 0, 1, 13, (PV_ANALOG | 1), (PV_VAR | 25) + 0, 1, 13, (PV_ANALOG | 1), (PV_VAR | 25), (PV_ANALOG |22), (PV_ANALOG |23) }; byte findpinname(char *alias) { - if (!findindex(alias, (const prog_char *) pinnames, 0)) return 0; // sets symval + if (!findindex(alias, (const prog_char *) pinnames, 0)) return 0; // sets symval byte pin = pgm_read_byte(pinvalues + symval); //sym = (pin & PV_ANALOG) ? s_apin : s_dpin; sym = (pin & PV_ANALOG) ? s_apin : ((pin & PV_VAR) ? s_nvar : s_dpin); symval = pin & PV_MASK; + return 1; } #endif @@ -736,7 +741,9 @@ byte thesym = sym; break; case s_nfunct: + dofunctioncall(thesymval); // get its value onto the stack + break; // Script-function-returning-value used as a factor @@ -767,7 +774,9 @@ byte thesym = sym; digitalWrite(thesymval, getnum()); vpush(expval); } - else vpush(digitalRead(thesymval)); + else { + vpush(digitalRead(thesymval)); + } break; case s_incr: diff --git a/src/bitlash-serial.c b/src/bitlash-serial.cpp similarity index 100% rename from src/bitlash-serial.c rename to src/bitlash-serial.cpp diff --git a/src/bitlash-taskmgr.c b/src/bitlash-taskmgr.cpp similarity index 100% rename from src/bitlash-taskmgr.c rename to src/bitlash-taskmgr.cpp diff --git a/src/bitlash-unix-file.c b/src/bitlash-unix-file.cpp similarity index 100% rename from src/bitlash-unix-file.c rename to src/bitlash-unix-file.cpp diff --git a/src/bitlash-unix.c b/src/bitlash-unix.cpp similarity index 99% rename from src/bitlash-unix.c rename to src/bitlash-unix.cpp index 4262e39..9004bd5 100644 --- a/src/bitlash-unix.c +++ b/src/bitlash-unix.cpp @@ -28,6 +28,8 @@ */ #include "bitlash.h" +#if ! defined( ESP32 ) + /* Build: @@ -365,3 +367,5 @@ int main () { #endif } + +#endif // if ! defined( ESP32 ) diff --git a/src/bitlash.h b/src/bitlash.h index 3616d23..c106454 100644 --- a/src/bitlash.h +++ b/src/bitlash.h @@ -45,12 +45,13 @@ #define ARM_BUILD 2 #elif defined(PART_LM4F120H5QR) //support Energia.nu - Stellaris Launchpad / Tiva C Series #define ARM_BUILD 4 //support Energia.nu - Stellaris Launchpad / Tiva C Series +#elif defined(ESP32) +#define XTENSA_BUILD 1 #else #define AVR_BUILD 1 #endif - -#if defined(AVR_BUILD) +#if defined(AVR_BUILD) && !defined(ESP32) #include "avr/io.h" #include "avr/pgmspace.h" #include "avr/interrupt.h" @@ -133,7 +134,8 @@ #define prog_char char PROGMEM #define prog_uchar char PROGMEM #else - #include "WProgram.h" + + #include "WProgram.h" #include "WConstants.h" #endif @@ -432,6 +434,39 @@ unsigned long millis(void); #endif +/////////////////////////////////// ESP32 +// +// ESP32 BUILD +#if defined(ESP32) +#include +#include +//#ifdef __cplusplus +#include +#include +//#endif + +extern void displayBanner(void); +extern void initlbuf(void); +extern void pointToError(void); +extern void cmd_function(void); +extern void eraseentry(char *id); +extern void cmd_ls(void); +extern void cmd_peep(void); +extern void cmd_help(void); +extern char find_user_function(char *id); +extern byte findbuiltin(char *name); +extern void analogWrite(byte pin, int value); +extern void oops(int errcode); + +#define NUMPINS 39 + +#define E2END SPI_FLASH_SEC_SIZE // 4096 + + +#endif // ESP32 + +////////////////////////////////// ESP32 END + // numvar is 32 bits on Arduino and 16 bits elsewhere #if (defined(ARDUINO_BUILD) || defined(UNIX_BUILD)) && !defined(TINY_BUILD) @@ -720,7 +755,7 @@ extern numvar symval; // value of current numeric expression #define USE_GPIORS defined(AVR_BUILD) -#ifndef GPIOR0 || GPIOR1 +#if !defined(GPIOR0) || !defined(GPIOR1) #undef USE_GPIORS #endif #if (defined USE_GPIORS) diff --git a/src/eeprom.c b/src/eeprom.cpp similarity index 82% rename from src/eeprom.c rename to src/eeprom.cpp index 4b43fa4..4de6b82 100644 --- a/src/eeprom.c +++ b/src/eeprom.cpp @@ -81,7 +81,7 @@ uint8_t eeread(int addr) { return cache_eeprom[addr]; } -#elif (defined(AVR_BUILD)) || ( (defined(ARM_BUILD)) && (ARM_BUILD==2)) +#elif ((defined(AVR_BUILD)) || ( (defined(ARM_BUILD)) && (ARM_BUILD==2))) && ! defined(ESP32) // AVR or Teensy 3 #include "avr/eeprom.h" void eewrite(int addr, uint8_t value) { eeprom_write_byte((unsigned char *) addr, value); } @@ -93,7 +93,7 @@ #elif defined(ARM_BUILD) #if ARM_BUILD!=2 // A little fake eeprom for ARM testing - char virtual_eeprom[E2END]; + char virtual_eeprom[E2END]; void eeinit(void) { for (int i=0; i #include #include @@ -6,7 +9,11 @@ #include "setjmp.h" #include #include +#ifndef (ESP32) #include +#else +#define __MAX_BAUD B4000000 +#endif int mygetch() { char ch; @@ -57,3 +64,6 @@ int mygetch() { return (error == 1 ? (int) ch : -1 ); } + + +#endif // if ! defined( ESP32 ) From 15b9b1b47f25d55afad595541b62cf00a412447d Mon Sep 17 00:00:00 2001 From: Luc Chouinard Date: Tue, 28 Nov 2017 16:03:19 -0500 Subject: [PATCH 2/7] esp32: now file reverted to .c; added library.json and bitlash.cpp --- bitlash.c | 67 +++++++++++++++++++ bitlash.cpp | 17 ++--- library.json | 23 +++++++ src/{bitlash-api.cpp => bitlash-api.c} | 4 ++ ...itlash-builtins.cpp => bitlash-builtins.c} | 0 ...{bitlash-cmdline.cpp => bitlash-cmdline.c} | 0 src/{bitlash-eeprom.cpp => bitlash-eeprom.c} | 0 src/{bitlash-error.cpp => bitlash-error.c} | 0 ...lash-functions.cpp => bitlash-functions.c} | 0 ...itlash-instream.cpp => bitlash-instream.c} | 0 ...-interpreter.cpp => bitlash-interpreter.c} | 0 src/{bitlash-parser.cpp => bitlash-parser.c} | 0 src/{bitlash-serial.cpp => bitlash-serial.c} | 0 ...{bitlash-taskmgr.cpp => bitlash-taskmgr.c} | 0 ...lash-unix-file.cpp => bitlash-unix-file.c} | 0 src/{bitlash-unix.cpp => bitlash-unix.c} | 4 -- src/bitlash.h | 3 +- src/{eeprom.cpp => eeprom.c} | 0 src/{mygetch.cpp => mygetch.c} | 6 -- 19 files changed, 101 insertions(+), 23 deletions(-) create mode 100644 bitlash.c create mode 100644 library.json rename src/{bitlash-api.cpp => bitlash-api.c} (94%) rename src/{bitlash-builtins.cpp => bitlash-builtins.c} (100%) rename src/{bitlash-cmdline.cpp => bitlash-cmdline.c} (100%) rename src/{bitlash-eeprom.cpp => bitlash-eeprom.c} (100%) rename src/{bitlash-error.cpp => bitlash-error.c} (100%) rename src/{bitlash-functions.cpp => bitlash-functions.c} (100%) rename src/{bitlash-instream.cpp => bitlash-instream.c} (100%) rename src/{bitlash-interpreter.cpp => bitlash-interpreter.c} (100%) rename src/{bitlash-parser.cpp => bitlash-parser.c} (100%) rename src/{bitlash-serial.cpp => bitlash-serial.c} (100%) rename src/{bitlash-taskmgr.cpp => bitlash-taskmgr.c} (100%) rename src/{bitlash-unix-file.cpp => bitlash-unix-file.c} (100%) rename src/{bitlash-unix.cpp => bitlash-unix.c} (99%) rename src/{eeprom.cpp => eeprom.c} (100%) rename src/{mygetch.cpp => mygetch.c} (96%) diff --git a/bitlash.c b/bitlash.c new file mode 100644 index 0000000..403bc9d --- /dev/null +++ b/bitlash.c @@ -0,0 +1,67 @@ +/*** + bitlash.cpp + + Bitlash is a tiny language interpreter that provides a serial port shell environment + for bit banging and hardware hacking. + + See the file README for documentation. + + Bitlash lives at: http://bitlash.net + The author can be reached at: bill@bitlash.net + + Copyright (C) 2008-2012 Bill Roy + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + + +***/ +#ifndef ESP32 + +#if defined(ARDUINO) && ARDUINO >= 100 + #include "Arduino.h" +#else + #include "WProgram.h" +#endif + +#ifdef UNIX_BUILD +#include "src/bitlash-unix.c" +//#else +//#include "src/bitlash-arduino.c" +#endif + + +#include "src/bitlash-cmdline.c" +#include "src/bitlash-eeprom.c" +#include "src/bitlash-error.c" +#include "src/bitlash-functions.c" +#include "src/bitlash-builtins.c" +#include "src/bitlash-interpreter.c" +#include "src/bitlash-instream.c" +#include "src/bitlash-parser.c" +#include "src/bitlash-serial.c" +#include "src/bitlash-taskmgr.c" +#include "src/bitlash-api.c" +#include "src/eeprom.c" + +#endif //ifndef ESP32 + + diff --git a/bitlash.cpp b/bitlash.cpp index a529a3f..9f066c3 100644 --- a/bitlash.cpp +++ b/bitlash.cpp @@ -34,17 +34,8 @@ ***/ -#if defined(ARDUINO) && ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - -#ifdef UNIX_BUILD -#include "src/bitlash-unix.c" -//#else -//#include "src/bitlash-arduino.c" -#endif + +#ifdef ESP32 #include "src/bitlash-cmdline.c" #include "src/bitlash-eeprom.c" @@ -58,3 +49,7 @@ #include "src/bitlash-taskmgr.c" #include "src/bitlash-api.c" #include "src/eeprom.c" + +#endif //ifdef ESP32 + + diff --git a/library.json b/library.json new file mode 100644 index 0000000..bff5364 --- /dev/null +++ b/library.json @@ -0,0 +1,23 @@ +{ + "name": "bitlash", + "keywords": "console cli shell bitlash", + "description": "Bitlash is a tiny language interpreter that provides a serial port shell environment for bit banging and hardware hacking.", + "build": { + "flags": "-xc++", + "srcFilter": "+ - - -" + }, + "repository": + { + "type": "git", + "url": "https://github.com/billroy/bitlash.git" + }, + "frameworks": + [ + "arduino-espressif32" + ], + "platforms": + [ + "atmelavr", + "espressif32" + ] +} diff --git a/src/bitlash-api.cpp b/src/bitlash-api.c similarity index 94% rename from src/bitlash-api.cpp rename to src/bitlash-api.c index f69385b..e931ced 100644 --- a/src/bitlash-api.cpp +++ b/src/bitlash-api.c @@ -62,6 +62,10 @@ void initBitlash(unsigned long baud) { eeinit(); #endif +#if defined(ESP32) + EEPROM.begin(E2END); +#endif + initTaskList(); vinit(); displayBanner(); diff --git a/src/bitlash-builtins.cpp b/src/bitlash-builtins.c similarity index 100% rename from src/bitlash-builtins.cpp rename to src/bitlash-builtins.c diff --git a/src/bitlash-cmdline.cpp b/src/bitlash-cmdline.c similarity index 100% rename from src/bitlash-cmdline.cpp rename to src/bitlash-cmdline.c diff --git a/src/bitlash-eeprom.cpp b/src/bitlash-eeprom.c similarity index 100% rename from src/bitlash-eeprom.cpp rename to src/bitlash-eeprom.c diff --git a/src/bitlash-error.cpp b/src/bitlash-error.c similarity index 100% rename from src/bitlash-error.cpp rename to src/bitlash-error.c diff --git a/src/bitlash-functions.cpp b/src/bitlash-functions.c similarity index 100% rename from src/bitlash-functions.cpp rename to src/bitlash-functions.c diff --git a/src/bitlash-instream.cpp b/src/bitlash-instream.c similarity index 100% rename from src/bitlash-instream.cpp rename to src/bitlash-instream.c diff --git a/src/bitlash-interpreter.cpp b/src/bitlash-interpreter.c similarity index 100% rename from src/bitlash-interpreter.cpp rename to src/bitlash-interpreter.c diff --git a/src/bitlash-parser.cpp b/src/bitlash-parser.c similarity index 100% rename from src/bitlash-parser.cpp rename to src/bitlash-parser.c diff --git a/src/bitlash-serial.cpp b/src/bitlash-serial.c similarity index 100% rename from src/bitlash-serial.cpp rename to src/bitlash-serial.c diff --git a/src/bitlash-taskmgr.cpp b/src/bitlash-taskmgr.c similarity index 100% rename from src/bitlash-taskmgr.cpp rename to src/bitlash-taskmgr.c diff --git a/src/bitlash-unix-file.cpp b/src/bitlash-unix-file.c similarity index 100% rename from src/bitlash-unix-file.cpp rename to src/bitlash-unix-file.c diff --git a/src/bitlash-unix.cpp b/src/bitlash-unix.c similarity index 99% rename from src/bitlash-unix.cpp rename to src/bitlash-unix.c index 9004bd5..4262e39 100644 --- a/src/bitlash-unix.cpp +++ b/src/bitlash-unix.c @@ -28,8 +28,6 @@ */ #include "bitlash.h" -#if ! defined( ESP32 ) - /* Build: @@ -367,5 +365,3 @@ int main () { #endif } - -#endif // if ! defined( ESP32 ) diff --git a/src/bitlash.h b/src/bitlash.h index c106454..a77aeef 100644 --- a/src/bitlash.h +++ b/src/bitlash.h @@ -438,12 +438,11 @@ unsigned long millis(void); // // ESP32 BUILD #if defined(ESP32) +#warning ESP32 #include #include -//#ifdef __cplusplus #include #include -//#endif extern void displayBanner(void); extern void initlbuf(void); diff --git a/src/eeprom.cpp b/src/eeprom.c similarity index 100% rename from src/eeprom.cpp rename to src/eeprom.c diff --git a/src/mygetch.cpp b/src/mygetch.c similarity index 96% rename from src/mygetch.cpp rename to src/mygetch.c index f75a53f..16aa8f9 100644 --- a/src/mygetch.cpp +++ b/src/mygetch.c @@ -1,7 +1,4 @@ // fromm http://pastebin.com/r6BRYDxV - -#if ! defined( ESP32 ) - #include #include #include @@ -64,6 +61,3 @@ int mygetch() { return (error == 1 ? (int) ch : -1 ); } - - -#endif // if ! defined( ESP32 ) From b2f9d38f4bed30dca0936a75ed80de41602831dc Mon Sep 17 00:00:00 2001 From: Luc Chouinard Date: Wed, 29 Nov 2017 01:05:05 -0500 Subject: [PATCH 3/7] some clean up and fix EEPROM.begin --- library.json | 16 +++++----------- library.properties | 10 ++++++++++ src/bitlash-api.c | 11 ++++------- src/bitlash-builtins.c | 17 ++++++++++++++--- src/bitlash-cmdline.c | 16 +++++++--------- src/bitlash-eeprom.c | 2 ++ src/bitlash-functions.c | 8 +------- src/bitlash-interpreter.c | 7 ++----- src/bitlash-parser.c | 15 +++------------ src/bitlash.h | 2 +- src/eeprom.c | 2 +- src/mygetch.c | 4 ---- 12 files changed, 50 insertions(+), 60 deletions(-) create mode 100644 library.properties diff --git a/library.json b/library.json index bff5364..9946beb 100644 --- a/library.json +++ b/library.json @@ -3,21 +3,15 @@ "keywords": "console cli shell bitlash", "description": "Bitlash is a tiny language interpreter that provides a serial port shell environment for bit banging and hardware hacking.", "build": { - "flags": "-xc++", - "srcFilter": "+ - - -" + "flags": "", + "srcFilter": "+<../*.cpp> - - - -" }, "repository": { "type": "git", "url": "https://github.com/billroy/bitlash.git" }, - "frameworks": - [ - "arduino-espressif32" - ], - "platforms": - [ - "atmelavr", - "espressif32" - ] + "frameworks": "arduino", + "platforms": "espressif32" + } diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..7e5dd74 --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=bitlash +version=2.1 +author=Bill Roy +maintainer=Bill Roy +sentence=Bitlash is a tiny CLI. +paragraph=With builtin language interpreter that provides a serial port shell environment for bit banging and hardware hacking. +category=Other +url=bitlash.net +architectures=* + diff --git a/src/bitlash-api.c b/src/bitlash-api.c index e931ced..46c11ec 100644 --- a/src/bitlash-api.c +++ b/src/bitlash-api.c @@ -46,26 +46,23 @@ jmp_buf env; // doCommand: main entry point to execute a bitlash command // numvar doCommand(char *cmd) { - return execscript(SCRIPT_RAM, (numvar) cmd, 0); + return execscript(SCRIPT_RAM, (numvar) cmd, 0); } void initBitlash(unsigned long baud) { - #if defined(TINY_BUILD) beginSerial(9600); #else - beginSerial(baud); + beginSerial(baud); #endif - #if defined(ARM_BUILD) eeinit(); #endif - #if defined(ESP32) EEPROM.begin(E2END); -#endif - +#endif + initTaskList(); vinit(); displayBanner(); diff --git a/src/bitlash-builtins.c b/src/bitlash-builtins.c index 4891bb8..ae6c435 100644 --- a/src/bitlash-builtins.c +++ b/src/bitlash-builtins.c @@ -69,7 +69,7 @@ const prog_char builtin_table[] PROGMEM = { "print 2+2") // "while 1 {print millis;delay(999);}") #else - "print \"\nbitlash here! v2.0 (c) 2013 Bill Roy -type HELP-\",free,\"bytes free\"") + "print \"bitlash here! v2.0 (c) 2013 Bill Roy -type HELP-\",free,\"bytes free\"") #endif // Add user built-ins here. Some examples: @@ -80,6 +80,19 @@ const prog_char builtin_table[] PROGMEM = { BUILT_IN("output", "return 1") BUILT_IN("digitalread", "return dr(arg(1))") #endif +#if defined(ESP32) + BUILT_IN("low", "return 0") + BUILT_IN("high", "return 1") + BUILT_IN("input", "return 1") + BUILT_IN("output", "return 2") + BUILT_IN("pullup", "return 4") + BUILT_IN("input_pullup","return 5") + BUILT_IN("pulldown", "return 8") + BUILT_IN("input_pulldown","return 9") + BUILT_IN("open_drain", "return 16") + BUILT_IN("output_open", "return 18") + BUILT_IN("analog", "return 12") +#endif // This sentinel must be last BUILT_IN("","") // guards end of table, must be last @@ -114,7 +127,5 @@ const prog_char *wordlist = builtin_table; void displayBanner(void) { // print the banner and copyright notice // please note the license requires that you maintain this notice - execscript(SCRIPT_PROGMEM, (numvar) (builtin_table + strlen(builtin_table)+1), 0); - // Serial.println("\nbitlash here! v2.0 (c) 2013 Bill Roy -type HELP-\n"); } diff --git a/src/bitlash-cmdline.c b/src/bitlash-cmdline.c index f1fe118..f22ad20 100644 --- a/src/bitlash-cmdline.c +++ b/src/bitlash-cmdline.c @@ -43,7 +43,9 @@ char lbuf[LBUFLEN]; // Help text // -#if !defined(TINY_BUILD) +#if defined(ESP32) +const prog_char helptext[] PROGMEM = { "http://bitlash.net\r\nSee LICENSE for license\r\nPins: d0-39,a0-39 Variables: a-z, 32 bit long integers\r\nOperators: + - * / ( ) < <= > >= == != << >> ! ^ & | ++ -- :=\r\nCommands: \0" }; +#elif !defined(TINY_BUILD) const prog_char helptext[] PROGMEM = { "http://bitlash.net\r\nSee LICENSE for license\r\nPins: d0-22,a0-22 Variables: a-z, 32 bit long integers\r\nOperators: + - * / ( ) < <= > >= == != << >> ! ^ & | ++ -- :=\r\nCommands: \0" }; #else const prog_char helptext[] PROGMEM = { "http://bitlash.net\r\n\0" }; @@ -107,7 +109,6 @@ void initlbuf(void) { // flush any pending serial input while (serialAvailable()) serialRead(); - } @@ -150,10 +151,7 @@ void doCharacter(char c) { if ((c == '\r') || (c == '\n')) { speol(); *lbufptr = 0; - // doCommand execute the typed command - // and return its value - // here that value is droped???? why? so not output for free for example - doCommand(lbuf); + doCommand(lbuf); initlbuf(); } else if (c == 3) { // ^C break/stop @@ -180,9 +178,9 @@ void doCharacter(char c) { } #endif #if !defined(TINY_BUILD) - else if (c == 21 || c == 16) { // ^U to get last line - msgpl(M_ctrlu); - prompt(); + else if (c == 21 || c == 16) { // ^U or ^P to get last line + msgpl(M_ctrlu); + prompt(); sp(lbuf); lbufptr = lbuf + strlen(lbuf); } diff --git a/src/bitlash-eeprom.c b/src/bitlash-eeprom.c index 77dde90..6ca8c4a 100644 --- a/src/bitlash-eeprom.c +++ b/src/bitlash-eeprom.c @@ -199,7 +199,9 @@ char id[IDLEN+1]; // buffer for id eewrite(addr, 0); } +#if defined(ESP32) EEPROM.commit(); +#endif msgpl(M_saved); } diff --git a/src/bitlash-functions.c b/src/bitlash-functions.c index c09913e..9a1cbbb 100644 --- a/src/bitlash-functions.c +++ b/src/bitlash-functions.c @@ -37,7 +37,7 @@ #ifdef ESP32 -// AS Of 2017-11 not analogWrite yet +// AS Of 2017-11 no analogWrite yet void analogWrite(byte pin, int value) { sp("analogWrite() not supported yet!");oops('!'); } #endif @@ -94,7 +94,6 @@ numvar func_beep(void) { // unumvar pin, unumvar frequency, unumvar duration) #endif numvar func_free(void) { - #if defined(UNIX_BUILD) return 1000L; #elif defined(ARM_BUILD) @@ -160,8 +159,6 @@ void dbseed(uint32_t x) { // >print inb(0x53) // 2 // - - numvar func_inb(void) { reqargs(1); return *(volatile byte *) arg1; } numvar func_outb(void) { reqargs(2); *(volatile byte *) arg1 = (byte) arg2; return 0;} numvar func_abs(void) { reqargs(1); return arg1 < 0 ? -arg1 : arg1; } @@ -181,7 +178,6 @@ numvar func_constrain(void) { } numvar func_ar(void) { reqargs(1); return analogRead(arg1); } numvar func_aw(void) { reqargs(2); analogWrite(arg1, arg2); return 0; } -//numvar func_aw(void) { reqargs(2); sigmaDeltaWrite(arg1, arg2); return 0; } numvar func_dr(void) { reqargs(1); return digitalRead(arg1); } numvar func_dw(void) { reqargs(2); digitalWrite(arg1, arg2); return 0; } numvar func_er(void) { reqargs(1); return eeread(arg1); } @@ -509,9 +505,7 @@ bitlash_function fp; #endif parsearglist(); // parse the arguments - numvar ret = (*fp)(); // call the function - releaseargblock(); // peel off the arguments vpush(ret); // and push the return value } diff --git a/src/bitlash-interpreter.c b/src/bitlash-interpreter.c index da3322f..7a3b911 100644 --- a/src/bitlash-interpreter.c +++ b/src/bitlash-interpreter.c @@ -105,7 +105,6 @@ void cmd_boot(void) {esp_restart();} void cmd_boot(void) {oops('boot');} #endif - void skipbyte(char c) {;} // Skip a statement without executing it @@ -387,10 +386,8 @@ numvar retval = 0; // numvar getstatementlist(void) { numvar retval = 0; - while ((sym != s_eof) && (sym != s_returning)) { - retval = getstatement(); - } - return retval; + while ((sym != s_eof) && (sym != s_returning)) retval = getstatement(); + return retval; } diff --git a/src/bitlash-parser.c b/src/bitlash-parser.c index 6205069..3bc6845 100644 --- a/src/bitlash-parser.c +++ b/src/bitlash-parser.c @@ -36,12 +36,8 @@ #include "bitlash.h" #if defined(AVR_BUILD) && ! defined(ESP32) -#warning "AVRBUILD" , AVR_BUILD #include "avr/eeprom.h" #endif -#if defined(ESP32) -//#include -#endif // Interpreter globals byte fetchtype; // current script type @@ -437,16 +433,15 @@ const prog_char pinnames[] PROGMEM = { "tx\0rx\0led\0vin\0zed\0therm1\0therm2\0" }; const prog_uchar pinvalues[] PROGMEM = { - 0, 1, 13, (PV_ANALOG | 1), (PV_VAR | 25), (PV_ANALOG |22), (PV_ANALOG |23) + 0, 1, 2, (PV_ANALOG | 1), (PV_VAR | 25), (PV_ANALOG |22), (PV_ANALOG |23) }; byte findpinname(char *alias) { - if (!findindex(alias, (const prog_char *) pinnames, 0)) return 0; // sets symval + if (!findindex(alias, (const prog_char *) pinnames, 0)) return 0; // sets symval byte pin = pgm_read_byte(pinvalues + symval); //sym = (pin & PV_ANALOG) ? s_apin : s_dpin; sym = (pin & PV_ANALOG) ? s_apin : ((pin & PV_VAR) ? s_nvar : s_dpin); symval = pin & PV_MASK; - return 1; } #endif @@ -741,9 +736,7 @@ byte thesym = sym; break; case s_nfunct: - dofunctioncall(thesymval); // get its value onto the stack - break; // Script-function-returning-value used as a factor @@ -774,9 +767,7 @@ byte thesym = sym; digitalWrite(thesymval, getnum()); vpush(expval); } - else { - vpush(digitalRead(thesymval)); - } + else vpush(digitalRead(thesymval)); break; case s_incr: diff --git a/src/bitlash.h b/src/bitlash.h index a77aeef..a40d2b9 100644 --- a/src/bitlash.h +++ b/src/bitlash.h @@ -438,7 +438,7 @@ unsigned long millis(void); // // ESP32 BUILD #if defined(ESP32) -#warning ESP32 + #include #include #include diff --git a/src/eeprom.c b/src/eeprom.c index 4de6b82..c11766d 100644 --- a/src/eeprom.c +++ b/src/eeprom.c @@ -93,7 +93,7 @@ #elif defined(ARM_BUILD) #if ARM_BUILD!=2 // A little fake eeprom for ARM testing - char virtual_eeprom[E2END]; + char virtual_eeprom[E2END]; void eeinit(void) { for (int i=0; i #include -#ifndef (ESP32) #include -#else -#define __MAX_BAUD B4000000 -#endif int mygetch() { char ch; From 1f58647af0dc7c1b905cb9f77d0b6db2f09a0d74 Mon Sep 17 00:00:00 2001 From: Luc Chouinard Date: Thu, 30 Nov 2017 00:51:17 -0500 Subject: [PATCH 4/7] added //#define ENDDB (E2END - xx) and comments --- src/bitlash.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bitlash.h b/src/bitlash.h index a40d2b9..130d56c 100644 --- a/src/bitlash.h +++ b/src/bitlash.h @@ -553,7 +553,8 @@ int findend(int); void eeputs(int); #define EMPTY ((uint8_t)255) -#define STARTDB 0 +#define STARTDB 0 // the space to reserve at the begining of EEPROM +//#define ENDDB (E2END - xx) // where xx is the space to reserve at the end of EEPROM #define FAIL ((int)-1) ///////////////////////////////////////////// From 255df23f7bac90850cd34cd238325c65aa0f94ec Mon Sep 17 00:00:00 2001 From: Luc Chouinard Date: Thu, 30 Nov 2017 00:52:38 -0500 Subject: [PATCH 5/7] added emacs backups files (*~) in .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a355965..c810e44 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ bitlash.o Bitlash/ .pioenvs .piolibdeps +*~ From b2254d53c0d0391c972a5d8df8cffc149e743cc8 Mon Sep 17 00:00:00 2001 From: Luc Chouinard Date: Thu, 30 Nov 2017 15:23:15 -0500 Subject: [PATCH 6/7] esp32: corrected substract of -1 to E2END peep was displaying an additionnal byte --- src/bitlash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitlash.h b/src/bitlash.h index 130d56c..cef9bcb 100644 --- a/src/bitlash.h +++ b/src/bitlash.h @@ -459,7 +459,7 @@ extern void oops(int errcode); #define NUMPINS 39 -#define E2END SPI_FLASH_SEC_SIZE // 4096 +#define E2END SPI_FLASH_SEC_SIZE - 1 // 4096 #endif // ESP32 From 8559a4ed036abe86a1f431f86d20f75b41dc73e5 Mon Sep 17 00:00:00 2001 From: Luc Chouinard Date: Sun, 10 Dec 2017 20:44:55 -0500 Subject: [PATCH 7/7] files renamed from .c to .cpp, so it can compile for arduino uno and teensy 3.2, because of HardwareSerial.h --- bitlash.cpp | 55 ------------------- library.json | 2 +- src/{bitlash-api.c => bitlash-api.cpp} | 0 ...itlash-builtins.c => bitlash-builtins.cpp} | 0 ...{bitlash-cmdline.c => bitlash-cmdline.cpp} | 0 src/{bitlash-eeprom.c => bitlash-eeprom.cpp} | 0 src/{bitlash-error.c => bitlash-error.cpp} | 0 ...lash-functions.c => bitlash-functions.cpp} | 0 ...itlash-instream.c => bitlash-instream.cpp} | 0 ...-interpreter.c => bitlash-interpreter.cpp} | 0 src/{bitlash-parser.c => bitlash-parser.cpp} | 0 src/{bitlash-serial.c => bitlash-serial.cpp} | 0 ...{bitlash-taskmgr.c => bitlash-taskmgr.cpp} | 0 ...lash-unix-file.c => bitlash-unix-file.cpp} | 0 src/{bitlash-unix.c => bitlash-unix.cpp} | 5 ++ src/bitlash.h | 30 ++++++++-- src/{eeprom.c => eeprom.cpp} | 0 src/{mygetch.c => mygetch.cpp} | 5 ++ 18 files changed, 35 insertions(+), 62 deletions(-) delete mode 100644 bitlash.cpp rename src/{bitlash-api.c => bitlash-api.cpp} (100%) rename src/{bitlash-builtins.c => bitlash-builtins.cpp} (100%) rename src/{bitlash-cmdline.c => bitlash-cmdline.cpp} (100%) rename src/{bitlash-eeprom.c => bitlash-eeprom.cpp} (100%) rename src/{bitlash-error.c => bitlash-error.cpp} (100%) rename src/{bitlash-functions.c => bitlash-functions.cpp} (100%) rename src/{bitlash-instream.c => bitlash-instream.cpp} (100%) rename src/{bitlash-interpreter.c => bitlash-interpreter.cpp} (100%) rename src/{bitlash-parser.c => bitlash-parser.cpp} (100%) rename src/{bitlash-serial.c => bitlash-serial.cpp} (100%) rename src/{bitlash-taskmgr.c => bitlash-taskmgr.cpp} (100%) rename src/{bitlash-unix-file.c => bitlash-unix-file.cpp} (100%) rename src/{bitlash-unix.c => bitlash-unix.cpp} (99%) rename src/{eeprom.c => eeprom.cpp} (100%) rename src/{mygetch.c => mygetch.cpp} (96%) diff --git a/bitlash.cpp b/bitlash.cpp deleted file mode 100644 index 9f066c3..0000000 --- a/bitlash.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/*** - bitlash.cpp - - Bitlash is a tiny language interpreter that provides a serial port shell environment - for bit banging and hardware hacking. - - See the file README for documentation. - - Bitlash lives at: http://bitlash.net - The author can be reached at: bill@bitlash.net - - Copyright (C) 2008-2012 Bill Roy - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation - files (the "Software"), to deal in the Software without - restriction, including without limitation the rights to use, - copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following - conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - - -***/ - -#ifdef ESP32 - -#include "src/bitlash-cmdline.c" -#include "src/bitlash-eeprom.c" -#include "src/bitlash-error.c" -#include "src/bitlash-functions.c" -#include "src/bitlash-builtins.c" -#include "src/bitlash-interpreter.c" -#include "src/bitlash-instream.c" -#include "src/bitlash-parser.c" -#include "src/bitlash-serial.c" -#include "src/bitlash-taskmgr.c" -#include "src/bitlash-api.c" -#include "src/eeprom.c" - -#endif //ifdef ESP32 - - diff --git a/library.json b/library.json index 9946beb..948f2b9 100644 --- a/library.json +++ b/library.json @@ -4,7 +4,7 @@ "description": "Bitlash is a tiny language interpreter that provides a serial port shell environment for bit banging and hardware hacking.", "build": { "flags": "", - "srcFilter": "+<../*.cpp> - - - -" + "srcFilter": "+<*.cpp> - - -" }, "repository": { diff --git a/src/bitlash-api.c b/src/bitlash-api.cpp similarity index 100% rename from src/bitlash-api.c rename to src/bitlash-api.cpp diff --git a/src/bitlash-builtins.c b/src/bitlash-builtins.cpp similarity index 100% rename from src/bitlash-builtins.c rename to src/bitlash-builtins.cpp diff --git a/src/bitlash-cmdline.c b/src/bitlash-cmdline.cpp similarity index 100% rename from src/bitlash-cmdline.c rename to src/bitlash-cmdline.cpp diff --git a/src/bitlash-eeprom.c b/src/bitlash-eeprom.cpp similarity index 100% rename from src/bitlash-eeprom.c rename to src/bitlash-eeprom.cpp diff --git a/src/bitlash-error.c b/src/bitlash-error.cpp similarity index 100% rename from src/bitlash-error.c rename to src/bitlash-error.cpp diff --git a/src/bitlash-functions.c b/src/bitlash-functions.cpp similarity index 100% rename from src/bitlash-functions.c rename to src/bitlash-functions.cpp diff --git a/src/bitlash-instream.c b/src/bitlash-instream.cpp similarity index 100% rename from src/bitlash-instream.c rename to src/bitlash-instream.cpp diff --git a/src/bitlash-interpreter.c b/src/bitlash-interpreter.cpp similarity index 100% rename from src/bitlash-interpreter.c rename to src/bitlash-interpreter.cpp diff --git a/src/bitlash-parser.c b/src/bitlash-parser.cpp similarity index 100% rename from src/bitlash-parser.c rename to src/bitlash-parser.cpp diff --git a/src/bitlash-serial.c b/src/bitlash-serial.cpp similarity index 100% rename from src/bitlash-serial.c rename to src/bitlash-serial.cpp diff --git a/src/bitlash-taskmgr.c b/src/bitlash-taskmgr.cpp similarity index 100% rename from src/bitlash-taskmgr.c rename to src/bitlash-taskmgr.cpp diff --git a/src/bitlash-unix-file.c b/src/bitlash-unix-file.cpp similarity index 100% rename from src/bitlash-unix-file.c rename to src/bitlash-unix-file.cpp diff --git a/src/bitlash-unix.c b/src/bitlash-unix.cpp similarity index 99% rename from src/bitlash-unix.c rename to src/bitlash-unix.cpp index 4262e39..3d22b15 100644 --- a/src/bitlash-unix.c +++ b/src/bitlash-unix.cpp @@ -26,6 +26,9 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#if defined (UNIX_BUILD) + #include "bitlash.h" /* @@ -365,3 +368,5 @@ int main () { #endif } + +#endif //if defined (UNIX_BUILD) diff --git a/src/bitlash.h b/src/bitlash.h index cef9bcb..107b8d1 100644 --- a/src/bitlash.h +++ b/src/bitlash.h @@ -36,11 +36,12 @@ #ifndef _BITLASH_H #define _BITLASH_H + #if defined(__x86_64__) || defined(__i386__) #define UNIX_BUILD 1 #elif defined(__SAM3X8E__) #define ARM_BUILD 1 -#elif (defined(__MK20DX128__) || defined(__MK20DX256__)) && defined (CORE_TEENSY) +#elif (defined(__MK20DX128__) || defined(__MK20DX256__)) && (defined (CORE_TEENSY) || defined (TEENSYDUINO)) // Teensy 3 #define ARM_BUILD 2 #elif defined(PART_LM4F120H5QR) //support Energia.nu - Stellaris Launchpad / Tiva C Series @@ -133,6 +134,7 @@ #include "Arduino.h" #define prog_char char PROGMEM #define prog_uchar char PROGMEM + #include #else #include "WProgram.h" @@ -426,14 +428,26 @@ unsigned long millis(void); #define strcmp_P strcmp #define strlen_P strlen #if ARM_BUILD==1 - #define E2END 4096 -#else - // Teensy 3 - #define E2END 2048 + #define E2END 4095 +#elif ARM_BUILD==2 // Teensy 3 // + #define E2END 2047 #endif #endif +extern void displayBanner(void); +extern void initlbuf(void); +extern void pointToError(void); +extern void cmd_function(void); +extern void eraseentry(char *id); +extern void cmd_ls(void); +extern void cmd_peep(void); +extern void cmd_help(void); +extern char find_user_function(char *id); +extern byte findbuiltin(char *name); +extern void analogWrite(byte pin, int value); +extern void oops(int errcode); + /////////////////////////////////// ESP32 // // ESP32 BUILD @@ -441,6 +455,7 @@ unsigned long millis(void); #include #include +#include #include #include @@ -457,10 +472,13 @@ extern byte findbuiltin(char *name); extern void analogWrite(byte pin, int value); extern void oops(int errcode); + #define NUMPINS 39 #define E2END SPI_FLASH_SEC_SIZE - 1 // 4096 - +extern void eeinit(void); +extern void eewrite(int addr, uint8_t value); +extern uint8_t eeread(int addr); #endif // ESP32 diff --git a/src/eeprom.c b/src/eeprom.cpp similarity index 100% rename from src/eeprom.c rename to src/eeprom.cpp diff --git a/src/mygetch.c b/src/mygetch.cpp similarity index 96% rename from src/mygetch.c rename to src/mygetch.cpp index 7e7b25e..5c7aa45 100644 --- a/src/mygetch.c +++ b/src/mygetch.cpp @@ -1,4 +1,6 @@ // fromm http://pastebin.com/r6BRYDxV +#if defined(UNIX_BUILD) + #include #include #include @@ -57,3 +59,6 @@ int mygetch() { return (error == 1 ? (int) ch : -1 ); } + + +#endif // #if defined(UNIX_BUILD)