├── .gitignore ├── .settings └── language.settings.xml ├── Documents ├── .gitignore ├── BitOp.pdf ├── ChangeLog.txt ├── FlashTools.pdf ├── Hardware │ ├── 2. Xadow GSM Breakout.rar │ ├── 3. Xadow 1.54'' Touchscreen.rar │ ├── 4. Xadow Audio.rar │ ├── 5. Xadow Duino.zip │ ├── 6. Xadow GPS v2.zip │ ├── 7. Xadow Basic Sensors.zip │ ├── 8. Xadow NFC v2.zip │ ├── 9. Xadow LED 5x7.zip │ ├── AT_DOCUMENT_full_V2.1.27.pdf │ ├── ILI9341.pdf │ ├── MT2502C SOC Processor Data Sheet v1.04 (pass=9272359884).pdf │ ├── MT2502_GPIO_Table_v1_0.pdf │ ├── MediaTek_LinkIt_Assist_2502_Developers_Guide_v1_1.pdf │ ├── MediaTek_MT2502A_SOC_Data_Sheet_v1_0.pdf │ ├── PCF8574.pdf │ ├── Protocols │ │ └── I2C-bus and how to use it.pdf │ ├── ST7789S.pdf │ ├── Sensors │ │ ├── BME280 DataSheet.pdf │ │ ├── DHT22.pdf │ │ ├── DS1822.pdf │ │ ├── DS18B20.pdf │ │ ├── DS18S20.pdf │ │ ├── DS28EA00.pdf │ │ └── dht11.pdf │ ├── Xadow - GSM Breakout v1.0.pdf │ ├── Xadow 1.54'' Touchscreen v1.0.pdf │ ├── Xadow Audio v1.0.pdf │ ├── Xadow GSM Breakout pinout.pdf │ ├── Xadow GSM+BLE v1.0.pdf │ └── Xadow GSM_BLE PINOUT.pdf ├── IoT │ ├── MQTT_V3.1_Protocol_Specific.pdf │ └── mqtt-adafruit-io-and-you.pdf ├── LCD Module.pdf ├── Lua CJSON 2.1.0 Manual.pdf ├── Lua on RePhone Manual.pdf ├── Lua struct module.pdf ├── Lua │ ├── ANoFrillsIntroToLua51VMInstructions.pdf │ ├── A_Quick_Start_Guide_On_Lua_For_C_C_Programme.pdf │ ├── Beginning Lua Programming.pdf │ ├── Lua 5.0 Reference Manual.pdf │ ├── Lua 5.1 Reference Manual.chm │ ├── Lua 5.1 Reference Manual.pdf │ ├── Lua 5.2 Reference Manual.pdf │ ├── Lua Introduction.pdf │ ├── Lua for beginners.pdf │ ├── Lua lessons.pdf │ ├── LuaShortReference_5.1.pdf │ ├── Programming In Lua 2nd Edition.pdf │ ├── Programming In Lua 3rd Edition.pdf │ ├── Quick Reference Guide.pdf │ ├── The Crash Course to Lua.pdf │ └── The Lua language.pdf └── RePhone on Linux.pdf ├── FirmwareUpdate ├── 20160407.log ├── FirmwareUpdater.exe ├── Firmware_update_Linux │ ├── .gitignore │ ├── Download_Agent │ │ └── 6261 │ │ │ ├── EXT_RAM │ │ │ ├── INT_SYSRAM │ │ │ └── NOR_FLASH_TABLE │ ├── Firmware_update_Linux.tar.gz │ ├── RePhone │ │ ├── EXT_BOOTLOADER │ │ ├── INT_BOOTLOADER │ │ ├── ROM │ │ ├── VIVA │ │ └── config_rephone.cfg │ ├── firmwareUploader.py │ └── readme.txt ├── FlashTool_v5.1516.00.zip ├── FlashTool_v5.1516.00 │ ├── BACKUP.INI │ ├── ConsoleMode_v1_0.xsd │ ├── ConsoleMode_v2_0.xsd │ ├── ConsoleMode_v3_0.xsd │ ├── ConsoleMode_v3_1.xsd │ ├── ConsoleMode_v3_2.xsd │ ├── ConsoleMode_v3_3.xsd │ ├── ConsoleMode_v3_4.xsd │ ├── ConsoleMode_v4_0.xsd │ ├── ConsoleMode_v5_0.xsd │ ├── DataLibrary.dll │ ├── DualTalkSwitchTool.exe │ ├── FlashToolLib.dll │ ├── Flash_tool.INI │ ├── Flash_tool.exe │ ├── FrameCommModule.dll │ ├── META_DLL.dll │ ├── MTK_AllInOne_DA.bin │ ├── RePhone │ │ ├── EXT_BOOTLOADER │ │ ├── FILE_01_mtk │ │ ├── FILE_02_mtk │ │ ├── INT_BOOTLOADER │ │ └── config_mtk.cfg │ ├── ReleaseNote.xls │ ├── SLA_Challenge.dll │ ├── SysUtility.dll │ ├── USBSwitchDLLibrary.dll │ ├── USBSwitchTool.exe │ ├── USBSwitchTool.ini │ ├── brom.dll │ ├── brom.ini │ ├── doc │ │ └── Memory_Validation_List_External.xlsx │ ├── gps_DA.bin │ ├── gps_brom.dll │ └── miodll.dll ├── PackTag.exe ├── PushTool.exe └── firmware │ ├── Download_Agent │ ├── 6261 │ │ ├── EXT_RAM │ │ ├── INT_SYSRAM │ │ ├── NAND_FLASH_TABLE │ │ └── NOR_FLASH_TABLE │ ├── Need DA version v5.1416 │ ├── Need DA version v5.1432.01 │ └── Need DA version v5.1504.0 │ ├── Downloader.exe │ └── LinkIt_Device │ └── RePhone │ └── W15.19.p2-uart │ ├── ALICE │ ├── ALICE.bin │ ├── EXT_BOOTLOADER │ ├── JTAG │ ├── LinkIt_bypass.cmm │ ├── LinkIt_debug_start.cmm │ ├── LinkIt_plugin.men │ └── LinkIt_reset.cmm │ ├── ROM │ ├── SEEED02A_DEMO_BB.cfg │ ├── SEEED02A_DEMO_BOOTLOADER_V005_MT2502_MAUI_11CW1418SP5_W15_19.bin │ ├── VIVA │ ├── VIVA.bin │ ├── database.db │ └── label.log ├── JS ├── .cproject ├── .project ├── .settings │ ├── language.settings.xml │ └── org.eclipse.cdt.codan.core.prefs ├── Makefile ├── README.md ├── audio.c ├── gccmain.c ├── gpio.c ├── gsm.c ├── main.c ├── retarget.c ├── shell.c ├── shell.h ├── sj_prompt.c ├── sj_prompt.h ├── v7.c └── v7.h ├── Lua ├── .cproject ├── .gitignore ├── .project ├── .settings │ ├── language.settings.xml │ ├── org.eclipse.cdt.codan.core.prefs │ └── org.eclipse.core.runtime.prefs ├── DefaultFont.c ├── Makefile ├── attributes.h ├── audio.c ├── bit.c ├── bme280.c ├── bme280.h ├── bt.c ├── email.c ├── fpconv.c ├── fpconv.h ├── ftp.c ├── gpio.c ├── gsm.c ├── https.c ├── i2c.c ├── integer.h ├── lcd.c ├── lua │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lcode.c │ ├── lcode.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── legc.c │ ├── legc.h │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linenoise.c │ ├── linenoise.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lrodefs.h │ ├── lrotable.c │ ├── lrotable.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.h │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ ├── lzio.h │ ├── print.c │ └── xlua.c ├── lua_cjson.c ├── main.c ├── md5.c ├── md5.h ├── mqtt.c ├── mqtt_client.c ├── mqtt_client.h ├── mqtt_packet.c ├── mqtt_packet.h ├── mqtt_socket.c ├── mqtt_socket.h ├── mqtt_types.h ├── mqttexample.h.xx ├── mqttnet.c ├── mqttnet.h ├── net.c ├── retarget.c ├── screen.c ├── sensor.c ├── sha1.c ├── sha1.h ├── sha2.c ├── sha2.h ├── shell.c ├── shell.h ├── sntp.c ├── sntp.h ├── spi.c ├── strbuf.c ├── strbuf.h ├── struct.c ├── term.c ├── term.h ├── term_mdl.c ├── timer.c ├── tjpgd.c ├── tjpgd.h ├── version.h └── visibility.h ├── Lua_Examples ├── @font │ ├── BigFont.c │ ├── BigFont.fon │ ├── DejaVuSans12.c │ ├── DejaVuSans12.fon │ ├── DejaVuSans18.c │ ├── DejaVuSans18.fon │ ├── DejaVuSans24.c │ ├── DejaVuSans24.fon │ ├── DotMatrix_M.c │ ├── DotMatrix_M.fon │ ├── Grotesk24x48.c │ ├── Grotesk24x48.fon │ ├── OCR_A_Extended_M.c │ ├── SmallFont.c │ ├── SmallFont.fon │ ├── Ubuntu.c │ ├── Ubuntu.fon │ ├── arial_bold.c │ ├── arial_bold.fon │ ├── swiss721_outline.c │ └── swiss721_outline.fon ├── bme280.lua ├── https-test-block.lua ├── https-test-noblock.lua ├── init.lua ├── lcddemo.lua ├── paint.lua └── tpcalib.lua ├── README.md ├── common ├── .gitignore ├── CheckSumUtils.c ├── CheckSumUtils.h ├── gccmain.c ├── lcd_sitronix_st7789s.c ├── lcd_sitronix_st7789s.h ├── tp_goodix_gt9xx.c ├── tp_goodix_gt9xx.h ├── tp_i2c.c ├── tp_i2c.h ├── ymodem.c └── ymodem.h ├── include ├── reg_base.h ├── rtc_hw.h ├── ts_drv_comm.h ├── vmalarm.h ├── vmaudio.h ├── vmaudio_play.h ├── vmaudio_record.h ├── vmaudio_stream_play.h ├── vmbearer.h ├── vmboard.h ├── vmbt_cm.h ├── vmbt_gatt.h ├── vmbt_ns.h ├── vmbt_spp.h ├── vmchset.h ├── vmcmd.h ├── vmdatetime.h ├── vmdcl.h ├── vmdcl_adc.h ├── vmdcl_eint.h ├── vmdcl_gpio.h ├── vmdcl_i2c.h ├── vmdcl_kbd.h ├── vmdcl_pmu.h ├── vmdcl_pwm.h ├── vmdcl_sio.h ├── vmdcl_spi.h ├── vmdns.h ├── vmdrv_lcd.h ├── vmdrv_tp.h ├── vmfirmware.h ├── vmfs.h ├── vmgps.h ├── vmgraphic.h ├── vmgraphic_font.h ├── vmgraphic_image.h ├── vmgsm.h ├── vmgsm_cell.h ├── vmgsm_gprs.h ├── vmgsm_sim.h ├── vmgsm_sms.h ├── vmgsm_tel.h ├── vmhttps.h ├── vmkeypad.h ├── vmlog.h ├── vmmemory.h ├── vmpwr.h ├── vmres.h ├── vmsock.h ├── vmssl.h ├── vmstdlib.h ├── vmsystem.h ├── vmtag.h ├── vmtcp.h ├── vmthread.h ├── vmtimer.h ├── vmtouch.h ├── vmtype.h ├── vmudp.h ├── vmusb.h ├── vmwdt.h ├── vmwlan.h ├── wdt_hw.h ├── wdt_sw.c.notused └── wdt_sw.h ├── lib └── LINKIT10 │ └── armgcc │ ├── libmtk.a │ ├── peraudio.a │ ├── perbitstream.a │ ├── perbt.a │ ├── percallout.a │ ├── percam.a │ ├── percommon.a │ ├── percontact.a │ ├── perda.a │ ├── perfile.a │ ├── perhttp.a │ ├── perlbs.a │ ├── permms.a │ ├── perpayment.a │ ├── perpn.a │ ├── perpro.a │ ├── perrecord.a │ ├── persec.a │ ├── persensor.a │ ├── persim.a │ ├── persmsmng.a │ ├── persmsper.a │ ├── persmssp.a │ ├── persso.a │ ├── persysfile.a │ ├── persysstorage.a │ ├── pertcp.a │ ├── perudp.a │ ├── pervideo.a │ ├── perxml.a │ └── scat.ld ├── tools ├── PackTag ├── PushTool ├── libiconv2.dll ├── libintl3.dll ├── make └── packtag.py └── vxp └── lua.vxp /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.elf 3 | *.lst 4 | *.map -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Documents/.gitignore: -------------------------------------------------------------------------------- 1 | /*.wps 2 | /*.odt 3 | /*.docx 4 | -------------------------------------------------------------------------------- /Documents/BitOp.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/BitOp.pdf -------------------------------------------------------------------------------- /Documents/ChangeLog.txt: -------------------------------------------------------------------------------- 1 | === Ver.: 1.0.11 17/09/2016 === 2 | - lcd module, touch functions for XCP2046 based touch pannels updated 3 | - lcd.gettouch() now returns calibrated coordinates 4 | - TP calibration program written in Lua added 5 | - Simple paint program written in Lua added to demonstrate touch panel usage 6 | - some minor bug fixes 7 | - documentation updated 8 | 9 | === Ver.: 1.0.10 13/09/2016 === 10 | - https module 11 | - bug fix in blocking get/post functions versions 12 | - fixed getstate() not returning value bug 13 | 14 | === Ver.: 1.0.9 12/09/2016 === 15 | - mqtt module, client ID can now be set 16 | - https module, added blocking get/post functions versions 17 | - lcd module, touch functions for XCP2046 based touch pannels 18 | - some minor bug fixes 19 | - documentation updated 20 | 21 | === Ver.: 1.0.8 03/09/2016 === 22 | - mqtt module, password max length is now 63 (was 31) 23 | - some bug fixes and improvements in spi module 24 | - initial support for resistive touch screen (XPT2046) 25 | - some minor bug fixes 26 | 27 | === Ver.: 1.0.7 27/08/2016 === 28 | - fixed bug in term.edit(), not saving under default name 29 | - advanced line input mode set as default 30 | - some minor bug fixes 31 | - documentation updated with more info on installation and usage, some errors corrected 32 | 33 | === Ver.: 1.0.6 26/08/2016 === 34 | - https module upgraded, new functionality added, some bugs fixed 35 | - documentation for https module updated 36 | 37 | === Ver.: 1.0.5 25/08/2016 === 38 | - BME280 sensor added to sensor module 39 | - documentation for sensor module updated 40 | - some minor bug fixes 41 | 42 | === Ver.: 1.0.4 21/08/2016 === 43 | - Fixes in audio module 44 | - audio: recording added 45 | - documentation for audio module updated 46 | 47 | === Ver.: 1.0.3 21/08/2016 === 48 | - Fix bugs in Xadow Touch panel handling (Lua callback function), fix touch in landscape mode 49 | -------------------------------------------------------------------------------- /Documents/FlashTools.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/FlashTools.pdf -------------------------------------------------------------------------------- /Documents/Hardware/2. Xadow GSM Breakout.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/2. Xadow GSM Breakout.rar -------------------------------------------------------------------------------- /Documents/Hardware/3. Xadow 1.54'' Touchscreen.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/3. Xadow 1.54'' Touchscreen.rar -------------------------------------------------------------------------------- /Documents/Hardware/4. Xadow Audio.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/4. Xadow Audio.rar -------------------------------------------------------------------------------- /Documents/Hardware/5. Xadow Duino.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/5. Xadow Duino.zip -------------------------------------------------------------------------------- /Documents/Hardware/6. Xadow GPS v2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/6. Xadow GPS v2.zip -------------------------------------------------------------------------------- /Documents/Hardware/7. Xadow Basic Sensors.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/7. Xadow Basic Sensors.zip -------------------------------------------------------------------------------- /Documents/Hardware/8. Xadow NFC v2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/8. Xadow NFC v2.zip -------------------------------------------------------------------------------- /Documents/Hardware/9. Xadow LED 5x7.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/9. Xadow LED 5x7.zip -------------------------------------------------------------------------------- /Documents/Hardware/AT_DOCUMENT_full_V2.1.27.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/AT_DOCUMENT_full_V2.1.27.pdf -------------------------------------------------------------------------------- /Documents/Hardware/ILI9341.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/ILI9341.pdf -------------------------------------------------------------------------------- /Documents/Hardware/MT2502C SOC Processor Data Sheet v1.04 (pass=9272359884).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/MT2502C SOC Processor Data Sheet v1.04 (pass=9272359884).pdf -------------------------------------------------------------------------------- /Documents/Hardware/MT2502_GPIO_Table_v1_0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/MT2502_GPIO_Table_v1_0.pdf -------------------------------------------------------------------------------- /Documents/Hardware/MediaTek_LinkIt_Assist_2502_Developers_Guide_v1_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/MediaTek_LinkIt_Assist_2502_Developers_Guide_v1_1.pdf -------------------------------------------------------------------------------- /Documents/Hardware/MediaTek_MT2502A_SOC_Data_Sheet_v1_0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/MediaTek_MT2502A_SOC_Data_Sheet_v1_0.pdf -------------------------------------------------------------------------------- /Documents/Hardware/PCF8574.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/PCF8574.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Protocols/I2C-bus and how to use it.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Protocols/I2C-bus and how to use it.pdf -------------------------------------------------------------------------------- /Documents/Hardware/ST7789S.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/ST7789S.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Sensors/BME280 DataSheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Sensors/BME280 DataSheet.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Sensors/DHT22.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Sensors/DHT22.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Sensors/DS1822.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Sensors/DS1822.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Sensors/DS18B20.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Sensors/DS18B20.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Sensors/DS18S20.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Sensors/DS18S20.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Sensors/DS28EA00.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Sensors/DS28EA00.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Sensors/dht11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Sensors/dht11.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Xadow - GSM Breakout v1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Xadow - GSM Breakout v1.0.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Xadow 1.54'' Touchscreen v1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Xadow 1.54'' Touchscreen v1.0.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Xadow Audio v1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Xadow Audio v1.0.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Xadow GSM Breakout pinout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Xadow GSM Breakout pinout.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Xadow GSM+BLE v1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Xadow GSM+BLE v1.0.pdf -------------------------------------------------------------------------------- /Documents/Hardware/Xadow GSM_BLE PINOUT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Hardware/Xadow GSM_BLE PINOUT.pdf -------------------------------------------------------------------------------- /Documents/IoT/MQTT_V3.1_Protocol_Specific.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/IoT/MQTT_V3.1_Protocol_Specific.pdf -------------------------------------------------------------------------------- /Documents/IoT/mqtt-adafruit-io-and-you.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/IoT/mqtt-adafruit-io-and-you.pdf -------------------------------------------------------------------------------- /Documents/LCD Module.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/LCD Module.pdf -------------------------------------------------------------------------------- /Documents/Lua CJSON 2.1.0 Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua CJSON 2.1.0 Manual.pdf -------------------------------------------------------------------------------- /Documents/Lua on RePhone Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua on RePhone Manual.pdf -------------------------------------------------------------------------------- /Documents/Lua struct module.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua struct module.pdf -------------------------------------------------------------------------------- /Documents/Lua/ANoFrillsIntroToLua51VMInstructions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/ANoFrillsIntroToLua51VMInstructions.pdf -------------------------------------------------------------------------------- /Documents/Lua/A_Quick_Start_Guide_On_Lua_For_C_C_Programme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/A_Quick_Start_Guide_On_Lua_For_C_C_Programme.pdf -------------------------------------------------------------------------------- /Documents/Lua/Beginning Lua Programming.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Beginning Lua Programming.pdf -------------------------------------------------------------------------------- /Documents/Lua/Lua 5.0 Reference Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Lua 5.0 Reference Manual.pdf -------------------------------------------------------------------------------- /Documents/Lua/Lua 5.1 Reference Manual.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Lua 5.1 Reference Manual.chm -------------------------------------------------------------------------------- /Documents/Lua/Lua 5.1 Reference Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Lua 5.1 Reference Manual.pdf -------------------------------------------------------------------------------- /Documents/Lua/Lua 5.2 Reference Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Lua 5.2 Reference Manual.pdf -------------------------------------------------------------------------------- /Documents/Lua/Lua Introduction.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Lua Introduction.pdf -------------------------------------------------------------------------------- /Documents/Lua/Lua for beginners.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Lua for beginners.pdf -------------------------------------------------------------------------------- /Documents/Lua/Lua lessons.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Lua lessons.pdf -------------------------------------------------------------------------------- /Documents/Lua/LuaShortReference_5.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/LuaShortReference_5.1.pdf -------------------------------------------------------------------------------- /Documents/Lua/Programming In Lua 2nd Edition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Programming In Lua 2nd Edition.pdf -------------------------------------------------------------------------------- /Documents/Lua/Programming In Lua 3rd Edition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Programming In Lua 3rd Edition.pdf -------------------------------------------------------------------------------- /Documents/Lua/Quick Reference Guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/Quick Reference Guide.pdf -------------------------------------------------------------------------------- /Documents/Lua/The Crash Course to Lua.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/The Crash Course to Lua.pdf -------------------------------------------------------------------------------- /Documents/Lua/The Lua language.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/Lua/The Lua language.pdf -------------------------------------------------------------------------------- /Documents/RePhone on Linux.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Documents/RePhone on Linux.pdf -------------------------------------------------------------------------------- /FirmwareUpdate/FirmwareUpdater.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FirmwareUpdater.exe -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/.gitignore: -------------------------------------------------------------------------------- 1 | test/** 2 | -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/Download_Agent/6261/EXT_RAM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/Firmware_update_Linux/Download_Agent/6261/EXT_RAM -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/Download_Agent/6261/INT_SYSRAM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/Firmware_update_Linux/Download_Agent/6261/INT_SYSRAM -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/Download_Agent/6261/NOR_FLASH_TABLE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/Firmware_update_Linux/Download_Agent/6261/NOR_FLASH_TABLE -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/Firmware_update_Linux.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/Firmware_update_Linux/Firmware_update_Linux.tar.gz -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/RePhone/EXT_BOOTLOADER: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/Firmware_update_Linux/RePhone/EXT_BOOTLOADER -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/RePhone/INT_BOOTLOADER: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/Firmware_update_Linux/RePhone/INT_BOOTLOADER -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/RePhone/ROM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/Firmware_update_Linux/RePhone/ROM -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/RePhone/VIVA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/Firmware_update_Linux/RePhone/VIVA -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/RePhone/config_rephone.cfg: -------------------------------------------------------------------------------- 1 | 2 | general: 3 | config_version : alpha # config file version (alpha, beta is used before SQC done.) 4 | # After SQC done, the version should be 1 for the first release version. 5 | platform: # It is used for tool to identify the right setting for specific target 6 | 7 | boot_region: 8 | alignment: block # block[default], page(NAND:2K/512B, NOR: 1KB, eMMC: 512B, SF: 256B) 9 | rom: 10 | - file: INT_BOOTLOADER 11 | - file: EXT_BOOTLOADER 12 | 13 | control_block_region: 14 | rom: 15 | 16 | main_region: 17 | alignment: block # block[default], page(NAND:2K/512B, NOR: 1KB, eMMC: 512B, SF: 256B) 18 | rom: 19 | - file: FILE_01_mtk 20 | - file: FILE_02_mtk 21 | 22 | file_system_region: 23 | rom: 24 | 25 | external_memory: 26 | parameters_version: v1 27 | parameters: 28 | # EMI 1 29 | - flash_info: 30 | flash_type: SF 31 | id_length: 3 32 | flash_id: [0xC2, 0x25, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00] 33 | memory_type: PSRAM_166MHz 34 | EMI_Setting: 35 | 36 | # EMI 2 37 | - flash_info: 38 | flash_type: SF 39 | id_length: 3 40 | flash_id: [0xEF, 0x60, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00] 41 | memory_type: PSRAM_166MHz 42 | EMI_Setting: 43 | 44 | -------------------------------------------------------------------------------- /FirmwareUpdate/Firmware_update_Linux/readme.txt: -------------------------------------------------------------------------------- 1 | # ############################################ 2 | # The beta version for a linux firmware upload 3 | # ############################################ 4 | 5 | # ############################################ 6 | # Thanks to: 7 | # Stefan.Mandl1@gmail.com 8 | # https://github.com/mandl/LinkIt_Assist_2502 9 | # ############################################ 10 | 11 | !!PYTHON3 must be installed!! 12 | 13 | udev rule 14 | ========= 15 | 16 | Since Rephone is based on a Mediatek chip, ModemManager will, by default, 17 | try to treat it as a modem and make it available for network connections. 18 | This is undesirable. 19 | 20 | To work around this problem, create a udev rule under /etc/udev/rules.d/ 21 | called 71-rephone.rules with the following contents: 22 | 23 | SUBSYSTEM=="tty", ATTRS{idVendor}=="0e8d",\ 24 | ATTRS{idProduct}=="0003",\ 25 | MODE="0660", SYMLINK+="rephone" 26 | 27 | ACTION=="add|change", SUBSYSTEM=="usb",\ 28 | ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="0e8d",\ 29 | ATTRS{idProduct}=="0003",\ 30 | ENV{ID_MM_DEVICE_IGNORE}="1" 31 | 32 | Upload process 33 | ============== 34 | 35 | 1. Install the udev rule "71-rephone.rules" 36 | 2. Disconnect the battery. 37 | 38 | 39 | We need in the same folder 40 | ========================== 41 | 42 | 1. Download_Agent/6261/NOR_FLASH_TABLE This is the data for the NOR flash detection. 43 | 2. Download_Agent/6261/EXT_RAM This is the download agent. 44 | 3. Download_Agent/6261/INT_SYSRAM This is the download agent. 45 | 4. RePhone/EXT_BOOTLOADER 46 | 5. RePhone/INT_BOOTLOADER This is the Rephone bootloader (SEEED02A_DEMO_BOOTLOADER_V005_MT2502_MAUI_11CW1418SP5_W15_19.bin). 47 | 6. RePhone/ROM (W15.19.p2-uart). 48 | 7. RePhone/VIVA (W15.19.p2-uart). 49 | 8. firmwareUploader.py Upload script 50 | 51 | ------------------------------------------------------ 52 | -- You can replace 5, 6 & 7 with different versions -- 53 | ------------------------------------------------------ 54 | 55 | 56 | Doing the upload 57 | ================ 58 | 59 | 1. Disconnect the battery and disconnect the device (USB) from PC 60 | 2. Start the *python3 firmwareUploader.py --nobattery* or *python3 firmwareUploader.py --nobattery --nofatformat* (to preserve the fat data) 61 | 3. Connect the device to USB 62 | 4. The upload is running. The red led goes on dimmed. 63 | 5. See progress info.... wait for **Update done !!!!!!!!**... 64 | 6. Disconnect the device from USB. 65 | 66 | -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00.zip -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/BACKUP.INI: -------------------------------------------------------------------------------- 1 | [Backup and Restore Calibration Data Basic Settings] 2 | ; only check for old load 3 | Backup NVRAM folder path=Z:\NVRAM\NVD_DATA\ 4 | Restore NVRAM folder path=Z:\NVRAM\NVD_DATA\ 5 | 6 | 7 | [Target NVRAM Backup and Restore List] 8 | ; only work for old load 9 | ; XXXLID = xxx_File_Prefix ( length = 4 ) 10 | 11 | 12 | [Target Backup and Restore List] 13 | ; ex: xxxfull path of old target = xxxfull path of new target 14 | 15 | 16 | [Upload PC files to Target List] 17 | ; ex: xxxfull path of PC side = xxxfull path of target 18 | ; Notice that the flash tool always overwites the files in FAT 19 | 20 | [Backup/Restore File Prefix-MORE] 21 | ; the file prefix length must = 4 22 | ; sample 23 | ;file_prefix1=abcd 24 | ;file_prefix2=efgh 25 | 26 | 27 | [Backup/Restore File Prefix-DELETE] 28 | ; the file prefix length must = 4 29 | ; can not define the same file prefix in SEC: Backup/Restore File Prefix-MORE 30 | ; sample 31 | ;file_prefix1=ijkl 32 | ;file_prefix2=mnop 33 | -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/DataLibrary.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/DataLibrary.dll -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/DualTalkSwitchTool.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/DualTalkSwitchTool.exe -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/FlashToolLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/FlashToolLib.dll -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/Flash_tool.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/Flash_tool.exe -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/FrameCommModule.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/FrameCommModule.dll -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/META_DLL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/META_DLL.dll -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/MTK_AllInOne_DA.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/MTK_AllInOne_DA.bin -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/RePhone/EXT_BOOTLOADER: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/RePhone/EXT_BOOTLOADER -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/RePhone/FILE_01_mtk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/RePhone/FILE_01_mtk -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/RePhone/FILE_02_mtk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/RePhone/FILE_02_mtk -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/RePhone/INT_BOOTLOADER: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/RePhone/INT_BOOTLOADER -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/RePhone/config_mtk.cfg: -------------------------------------------------------------------------------- 1 | 2 | general: 3 | config_version : alpha # config file version (alpha, beta is used before SQC done.) 4 | # After SQC done, the version should be 1 for the first release version. 5 | platform: # It is used for tool to identify the right setting for specific target 6 | 7 | boot_region: 8 | alignment: block # block[default], page(NAND:2K/512B, NOR: 1KB, eMMC: 512B, SF: 256B) 9 | rom: 10 | - file: INT_BOOTLOADER 11 | - file: EXT_BOOTLOADER 12 | 13 | control_block_region: 14 | rom: 15 | 16 | main_region: 17 | alignment: block # block[default], page(NAND:2K/512B, NOR: 1KB, eMMC: 512B, SF: 256B) 18 | rom: 19 | - file: FILE_01_mtk 20 | - file: FILE_02_mtk 21 | 22 | file_system_region: 23 | rom: 24 | 25 | external_memory: 26 | parameters_version: v1 27 | parameters: 28 | # EMI 1 29 | - flash_info: 30 | flash_type: SF 31 | id_length: 3 32 | flash_id: [0xC2, 0x25, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00] 33 | memory_type: PSRAM_166MHz 34 | EMI_Setting: 35 | 36 | # EMI 2 37 | - flash_info: 38 | flash_type: SF 39 | id_length: 3 40 | flash_id: [0xEF, 0x60, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00] 41 | memory_type: PSRAM_166MHz 42 | EMI_Setting: 43 | 44 | -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/ReleaseNote.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/ReleaseNote.xls -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/SLA_Challenge.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/SLA_Challenge.dll -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/SysUtility.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/SysUtility.dll -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/USBSwitchDLLibrary.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/USBSwitchDLLibrary.dll -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/USBSwitchTool.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/USBSwitchTool.exe -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/USBSwitchTool.ini: -------------------------------------------------------------------------------- 1 | [hardware] 2 | ;;CDROM_FriendlyName=MEDIATEK FLASH DISK USB Device 3 | 1 = "USBSTOR\CdRomMEDIATEK_FLASH_DISK________" 4 | 2 = "USBSTOR\CdRomMEDIATEK_FLASH_DISK____" 5 | 3 = "USBSTOR\CdRom&Ven_MEDIATEK&Prod__DRIVER_DISK" 6 | CTL_PATH=USB\Vid_0e8d&Pid_00A2&MI_01 7 | BaudRate=115200 8 | FlowCtrl=0 ; 0:none flowctrl, 1:hardware flowctrl 2:software flowctrl 9 | RNDIS_CTL_PATH=USB\Vid_0e8d&Pid_7111 10 | EnableRescueMode=false 11 | [software] 12 | ;; Scan devices periodically in milliseconds (default 1000 ms) 13 | ScanInterval=1000 14 | ;; Repeat times of scanning devices (default 10 times) 15 | ScanRepeat=10 16 | ;; Do NOT scan and send command to specific CDROM/com port/RNDIS device 17 | DisableCDROMScan=false 18 | DisableComPortScan=false 19 | DisableRNDISScan=false -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/brom.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/brom.dll -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/brom.ini: -------------------------------------------------------------------------------- 1 | [Resource Prefix] 2 | 0=LANG_PACK_ROM 3 | 1=CUSTPACK_ROM 4 | 5 | [NOR Device Name] 6 | 7 | [NAND Device Name] 8 | -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/doc/Memory_Validation_List_External.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/doc/Memory_Validation_List_External.xlsx -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/gps_DA.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/gps_DA.bin -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/gps_brom.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/gps_brom.dll -------------------------------------------------------------------------------- /FirmwareUpdate/FlashTool_v5.1516.00/miodll.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/FlashTool_v5.1516.00/miodll.dll -------------------------------------------------------------------------------- /FirmwareUpdate/PackTag.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/PackTag.exe -------------------------------------------------------------------------------- /FirmwareUpdate/PushTool.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/PushTool.exe -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/Download_Agent/6261/EXT_RAM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/Download_Agent/6261/EXT_RAM -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/Download_Agent/6261/INT_SYSRAM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/Download_Agent/6261/INT_SYSRAM -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/Download_Agent/6261/NAND_FLASH_TABLE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/Download_Agent/6261/NAND_FLASH_TABLE -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/Download_Agent/6261/NOR_FLASH_TABLE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/Download_Agent/6261/NOR_FLASH_TABLE -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/Download_Agent/Need DA version v5.1416: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/Download_Agent/Need DA version v5.1416 -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/Download_Agent/Need DA version v5.1432.01: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/Download_Agent/Need DA version v5.1432.01 -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/Download_Agent/Need DA version v5.1504.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/Download_Agent/Need DA version v5.1504.0 -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/Downloader.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/Downloader.exe -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/ALICE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/ALICE -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/ALICE.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/ALICE.bin -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/EXT_BOOTLOADER: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/EXT_BOOTLOADER -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/JTAG/LinkIt_bypass.cmm: -------------------------------------------------------------------------------- 1 | ; disable_watchdog 2 | D.S SD:0xA0030000 %LE %WORD 0x2200 3 | 4 | 5 | ; Avoiding assert at CTIRQ1/2 6 | D.S SD:0x83070008 %LE %WORD 0xABCD 7 | D.S SD:0x83070010 %LE %WORD 0x0003 ; bit0: disable CTIRQ1/2 timing check 8 | 9 | ;endup 10 | d.l 11 | enddo 12 | -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/JTAG/LinkIt_debug_start.cmm: -------------------------------------------------------------------------------- 1 | SYStem.RESet 2 | SYStem.CPU ARM9EJ 3 | SYStem.JtagClock RTCK. 4 | sys.o cflush on 5 | SYStem.Up 6 | 7 | setup.IMASKHLL ON 8 | setup.IMASKASM ON 9 | 10 | DO LinkIt_bypass.cmm 11 | 12 | ; specify_load_elf 13 | ; D.LOAD.ELF ..\ARM\*.dbg 0x00000000 /PATH ..\ /nocode 14 | 15 | menu.reprogram LinkIt_plugin 16 | 17 | ; setting attribute of breakpoints 18 | Break.Select Program OnChip 19 | Break.Select Hll OnChip 20 | Break.Select Spot OnChip 21 | Break.Select Read OnChip 22 | Break.Select Write OnChip 23 | 24 | ; clean_win 25 | winclear 26 | 27 | ; endup 28 | d.l 29 | enddo 30 | 31 | -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/JTAG/LinkIt_plugin.men: -------------------------------------------------------------------------------- 1 | ADD 2 | TOOLBAR 3 | ( 4 | SEPARATOR 5 | TOOLITEM "RESET" "DO LinkIt_reset.cmm" 6 | [ 7 | 8 | RRRR bbb ggggg 9 | R RR b g 10 | R R b g 11 | R RR b g 12 | RR b g 13 | RRR b g 14 | R R b g 15 | R R b g 16 | R R b g 17 | R R b g 18 | R R b g 19 | R R b g 20 | R R b g 21 | R R bbb g 22 | ] 23 | 24 | TOOLITEM "Assert bypass after BREAK" "DO LinkIt_bypass.cmm" 25 | [ 26 | RRRR gggg 27 | R RR gg g 28 | R R Y g 29 | RRRR YYY g 30 | R RR Y g ggg 31 | R R gg gg 32 | RRRRRR ggg g 33 | 34 | 35 | ccc ccc c c 36 | c c c cc c c 37 | c c c c cc 38 | cccc ccc ccc 39 | c c c c c c 40 | c c c c c c 41 | cccc c c c c 42 | ] 43 | 44 | SEPARATOR 45 | ) 46 | -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/JTAG/LinkIt_reset.cmm: -------------------------------------------------------------------------------- 1 | ; Auto Reset target with L1d assert disable 2 | 3 | ; In Target reset 4 | SYStem.Mode EmulExt 5 | Register.RESet 6 | 7 | DO LinkIt_bypass.cmm 8 | 9 | GO 10 | 11 | -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/ROM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/ROM -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/SEEED02A_DEMO_BB.cfg: -------------------------------------------------------------------------------- 1 | ############################################################################################################ 2 | # 3 | # General Setting 4 | # 5 | ############################################################################################################ 6 | 7 | general: 8 | config_version : alpha # config file version ("alpha", "beta" is used before SQC done.) 9 | # After SQC done, the version should be "1" for the first release version. 10 | platform: MT2502 # It is used for tool to identify the right setting for specific target 11 | 12 | ############################################################################################################ 13 | # 14 | # Boot Region Setting 15 | # 16 | ############################################################################################################ 17 | 18 | boot_region: 19 | alignment: block # block[default], page(NAND:2K/512B, NOR: 1KB, eMMC: 512B, SF: 256B) 20 | rom: 21 | - file: SEEED02A_DEMO_BOOTLOADER_V005_MT2502_MAUI_11CW1418SP5_W15_19.bin 22 | - file: EXT_BOOTLOADER 23 | 24 | ############################################################################################################ 25 | # 26 | # Control Block Region Setting 27 | # 28 | ############################################################################################################ 29 | 30 | control_block_region: 31 | rom: 32 | 33 | 34 | ############################################################################################################ 35 | # 36 | # Main Region Setting 37 | # 38 | ############################################################################################################ 39 | 40 | main_region: 41 | alignment: block # block[default], page(NAND:2K/512B, NOR: 1KB, eMMC: 512B, SF: 256B) 42 | rom: 43 | - file: ROM 44 | - file: VIVA 45 | 46 | ############################################################################################################ 47 | # 48 | # File System Region Setting 49 | # 50 | ############################################################################################################ 51 | 52 | file_system_region: 53 | rom: 54 | 55 | 56 | ############################################################################################################ 57 | # 58 | # External Memory Setting 59 | # 60 | ############################################################################################################ 61 | 62 | external_memory: 63 | parameters_version: v1 64 | parameters: 65 | # EMI 1 66 | - flash_info: 67 | flash_type: SF 68 | id_length: 3 69 | flash_id: [0xC2, 0x25, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00] 70 | memory_type: PSRAM_130MHz 71 | EMI_Setting: 72 | 73 | # EMI 2 74 | - flash_info: 75 | flash_type: SF 76 | id_length: 3 77 | flash_id: [0xEF, 0x60, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00] 78 | memory_type: PSRAM_130MHz 79 | EMI_Setting: 80 | 81 | 82 | -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/SEEED02A_DEMO_BOOTLOADER_V005_MT2502_MAUI_11CW1418SP5_W15_19.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/SEEED02A_DEMO_BOOTLOADER_V005_MT2502_MAUI_11CW1418SP5_W15_19.bin -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/VIVA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/VIVA -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/VIVA.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/VIVA.bin -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/database.db -------------------------------------------------------------------------------- /FirmwareUpdate/firmware/LinkIt_Device/RePhone/W15.19.p2-uart/label.log: -------------------------------------------------------------------------------- 1 | 11CW1418SP5.W15.19.p2 2 | -------------------------------------------------------------------------------- /JS/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | JS 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /JS/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /JS/Makefile: -------------------------------------------------------------------------------- 1 | 2 | WORKSPACE_PATH = ../ 3 | 4 | PROJECT = js 5 | 6 | OBJECTS += main.o retarget.o v7.o sj_prompt.o gpio.o audio.o gsm.o shell.o \ 7 | $(WORKSPACE_PATH)common/CheckSumUtils.o 8 | CC_SYMBOLS += -DNO_BSD_SOCKETS 9 | 10 | # =============================================================================== 11 | 12 | #PROJECT_PATH := $(patsubst %/Makefile,%,$(realpath $(lastword $(MAKEFILE_LIST)))) 13 | #PROJECT_PATH := $(patsubst %/makefile,%,$(PROJECT_PATH)) 14 | 15 | GCC_BIN ?= /usr/bin/ 16 | 17 | OBJECTS += $(WORKSPACE_PATH)common/lcd_sitronix_st7789s.o $(WORKSPACE_PATH)common/tp_goodix_gt9xx.o $(WORKSPACE_PATH)common/tp_i2c.o 18 | SYS_OBJECTS += gccmain.o 19 | INCLUDE_PATHS += -I. -I$(WORKSPACE_PATH)include -I$(WORKSPACE_PATH)common 20 | LIBRARY_PATHS += -L$(WORKSPACE_PATH)lib 21 | LIBRARIES += $(WORKSPACE_PATH)lib/LINKIT10/armgcc/percommon.a -lm 22 | LINKER_SCRIPT = $(WORKSPACE_PATH)lib/LINKIT10/armgcc/scat.ld 23 | 24 | ############################################################################### 25 | AS = $(GCC_BIN)arm-none-eabi-as 26 | CC = $(GCC_BIN)arm-none-eabi-gcc 27 | CPP = $(GCC_BIN)arm-none-eabi-g++ 28 | LD = $(GCC_BIN)arm-none-eabi-gcc 29 | OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy 30 | OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump 31 | SIZE = $(GCC_BIN)arm-none-eabi-size 32 | 33 | UNAME_S := $(shell uname -s) 34 | ifeq ($(UNAME_S),Linux) 35 | PACK = python $(WORKSPACE_PATH)tools/packtag.py 36 | PUSH = @echo "set RePhone into storage mode, put $(PROJECT).vxp into MRE directory and replace vxp file name with $(PROJECT).vxp" 37 | endif 38 | ifeq ($(UNAME_S),Darwin) 39 | PACK = python $(WORKSPACE_PATH)tools/packtag.py 40 | PUSH = @echo "set RePhone into storage mode, put $(PROJECT).vxp into MRE directory and replace vxp file name with $(PROJECT).vxp" 41 | endif 42 | 43 | CPU = -mcpu=arm7tdmi-s -mthumb -mlittle-endian 44 | CC_FLAGS = $(CPU) -c -fvisibility=hidden -fpic -O2 45 | #CC_SYMBOLS += -D__HDK_LINKIT_ASSIST_2502__ -D__COMPILER_GCC__ 46 | CC_SYMBOLS += -D__HDK_LINKIT_REPHONE__ -D__COMPILER_GCC__ 47 | 48 | LD_FLAGS = $(CPU) -O2 -Wl,--gc-sections --specs=nosys.specs -fpic -pie -Wl,-Map=$(PROJECT).map -Wl,--entry=gcc_entry -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-unresolved-symbols 49 | LD_SYS_LIBS = 50 | 51 | 52 | all: $(PROJECT).vxp size 53 | 54 | clean: 55 | rm -f $(PROJECT).vxp $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(SYS_OBJECTS) 56 | 57 | .s.o: 58 | $(AS) $(CPU) -o $@ $< 59 | 60 | .c.o: 61 | $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< 62 | 63 | .cpp.o: 64 | $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $< 65 | 66 | 67 | $(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) 68 | $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ -Wl,--start-group $^ $(LIBRARIES) $(LD_SYS_LIBS) -Wl,--end-group 69 | 70 | $(PROJECT).bin: $(PROJECT).elf 71 | @$(OBJCOPY) -O binary $< $@ 72 | 73 | $(PROJECT).hex: $(PROJECT).elf 74 | @$(OBJCOPY) -O ihex $< $@ 75 | 76 | $(PROJECT).vxp: $(PROJECT).elf 77 | @$(OBJCOPY) --strip-debug $< 78 | @$(PACK) $< $@ 79 | 80 | $(PROJECT).lst: $(PROJECT).elf 81 | @$(OBJDUMP) -Sdh $< > $@ 82 | 83 | lst: $(PROJECT).lst 84 | 85 | size: $(PROJECT).elf 86 | $(SIZE) $(PROJECT).elf 87 | 88 | flash: $(PROJECT).vxp 89 | $(PUSH) 90 | -------------------------------------------------------------------------------- /JS/README.md: -------------------------------------------------------------------------------- 1 | # 🔹 JavaScript on RePhone 🔹 2 | 3 | JavaScript implementation on RePhone (Xadow GSM+BLE). 4 | 5 | Only basic support for now. 6 | -------------------------------------------------------------------------------- /JS/gpio.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vmdcl.h" 3 | #include "vmdcl_gpio.h" 4 | 5 | #include "v7.h" 6 | 7 | #define INPUT 0 8 | #define OUTPUT 1 9 | #define INPUT_PULLUP 2 10 | #define HIGH 1 11 | #define LOW 0 12 | 13 | extern int gpio_get_handle(int pin, VM_DCL_HANDLE* handle); 14 | 15 | static v7_val_t gpio_mode(struct v7* v7) 16 | { 17 | VM_DCL_HANDLE handle; 18 | v7_val_t pinv = v7_arg(v7, 0); 19 | v7_val_t modev = v7_arg(v7, 1); 20 | 21 | int pin, mode; 22 | 23 | if(!v7_is_number(pinv) || !v7_is_number(modev)) { 24 | printf("Invalid arguments\n"); 25 | return v7_create_undefined(); 26 | } 27 | 28 | pin = v7_to_number(pinv); 29 | mode = v7_to_number(modev); 30 | 31 | if(gpio_get_handle(pin, &handle)) { 32 | printf("Can't get io handle\n"); 33 | return v7_create_undefined(); 34 | } 35 | 36 | vm_dcl_control(handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL); 37 | 38 | if(mode == INPUT) { 39 | vm_dcl_control(handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_IN, NULL); 40 | } else if(mode == OUTPUT) { 41 | vm_dcl_control(handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_OUT, NULL); 42 | } else { 43 | vm_dcl_control(handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_IN, NULL); 44 | vm_dcl_control(handle, VM_DCL_GPIO_COMMAND_ENABLE_PULL, NULL); 45 | vm_dcl_control(handle, VM_DCL_GPIO_COMMAND_SET_PULL_HIGH, NULL); 46 | } 47 | 48 | return v7_create_boolean(1); 49 | } 50 | 51 | static v7_val_t gpio_read(struct v7* v7) 52 | { 53 | VM_DCL_HANDLE handle; 54 | v7_val_t pinv = v7_arg(v7, 0); 55 | v7_val_t modev = v7_arg(v7, 1); 56 | 57 | int pin; 58 | vm_dcl_gpio_control_level_status_t data; 59 | 60 | if(!v7_is_number(pinv)) { 61 | printf("Invalid arguments\n"); 62 | return v7_create_undefined(); 63 | } 64 | 65 | pin = v7_to_number(pinv); 66 | 67 | gpio_get_handle(pin, &handle); 68 | vm_dcl_control(handle, VM_DCL_GPIO_COMMAND_READ, &data); 69 | 70 | return v7_create_number(data.level_status); 71 | } 72 | 73 | static v7_val_t gpio_write(struct v7* v7) 74 | { 75 | VM_DCL_HANDLE handle; 76 | v7_val_t pinv = v7_arg(v7, 0); 77 | v7_val_t valuev = v7_arg(v7, 1); 78 | 79 | int pin, value; 80 | 81 | if(!v7_is_number(pinv) || !v7_is_number(valuev)) { 82 | printf("Invalid arguments\n"); 83 | return v7_create_undefined(); 84 | ; 85 | } 86 | 87 | pin = v7_to_number(pinv); 88 | value = v7_to_number(valuev); 89 | 90 | gpio_get_handle(pin, &handle); 91 | if(value) { 92 | vm_dcl_control(handle, VM_DCL_GPIO_COMMAND_WRITE_HIGH, NULL); 93 | } else { 94 | vm_dcl_control(handle, VM_DCL_GPIO_COMMAND_WRITE_LOW, NULL); 95 | } 96 | 97 | return v7_create_boolean(1); 98 | } 99 | 100 | void js_init_gpio(struct v7* v7) 101 | { 102 | v7_val_t gpio = v7_create_object(v7); 103 | v7_set(v7, v7_get_global(v7), "gpio", 4, 0, gpio); 104 | v7_set_method(v7, gpio, "mode", gpio_mode); 105 | v7_set_method(v7, gpio, "read", gpio_read); 106 | v7_set_method(v7, gpio, "write", gpio_write); 107 | } 108 | -------------------------------------------------------------------------------- /JS/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "vmtype.h" 5 | #include "vmlog.h" 6 | #include "vmsystem.h" 7 | #include "vmtimer.h" 8 | #include "vmdcl.h" 9 | #include "vmdcl_kbd.h" 10 | #include "vmkeypad.h" 11 | #include "vmthread.h" 12 | 13 | #include "v7.h" 14 | #include "sj_prompt.h" 15 | 16 | struct v7* v7; 17 | 18 | VM_TIMER_ID_PRECISE sys_timer_id = 0; 19 | 20 | long timezone = 0; 21 | 22 | extern void retarget_setup(); 23 | extern void js_init_gpio(struct v7 *v7); 24 | extern void js_init_audio(struct v7 *v7); 25 | extern void js_init_gsm(struct v7 *v7); 26 | 27 | 28 | int sys_wdt_tmo = 13001; // ** HW WDT timeout in ticks: 13001 -> 59.999615 seconds ** 29 | int sys_wdt_rst = 10834; // time at which hw wdt is reset in ticks: 10834 -> 50 seconds, must be < 'sys_wdt_tmo' 30 | 31 | void key_init(void) 32 | { 33 | VM_DCL_HANDLE kbd_handle; 34 | vm_dcl_kbd_control_pin_t kbdmap; 35 | 36 | kbd_handle = vm_dcl_open(VM_DCL_KBD, 0); 37 | kbdmap.col_map = 0x09; 38 | kbdmap.row_map = 0x05; 39 | vm_dcl_control(kbd_handle, VM_DCL_KBD_COMMAND_CONFIG_PIN, (void*)(&kbdmap)); 40 | 41 | vm_dcl_close(kbd_handle); 42 | } 43 | 44 | void sys_timer_callback(VM_TIMER_ID_PRECISE sys_timer_id, void* user_data) 45 | { 46 | 47 | vm_log_debug("tick"); 48 | } 49 | 50 | VMINT handle_keypad_event(VM_KEYPAD_EVENT event, VMINT code) 51 | { 52 | /* output log to monitor or catcher */ 53 | vm_log_info("key event=%d,key code=%d", event, code); /* event value refer to VM_KEYPAD_EVENT */ 54 | 55 | if(code == 30) { 56 | if(event == 3) { // long pressed 57 | 58 | } else if(event == 2) { // down 59 | printf("key is pressed\n"); 60 | } else if(event == 1) { // up 61 | } 62 | } 63 | return 0; 64 | } 65 | 66 | void handle_sysevt(VMINT message, VMINT param) 67 | { 68 | switch(message) { 69 | case VM_EVENT_CREATE: 70 | // sys_timer_id = vm_timer_create_precise(1000, sys_timer_callback, NULL); 71 | break; 72 | case VM_EVENT_QUIT: 73 | break; 74 | } 75 | } 76 | 77 | /* Entry point */ 78 | void vm_main(void) 79 | { 80 | v7_val_t exec_result; 81 | 82 | v7 = v7_create(); 83 | retarget_setup(); 84 | 85 | js_init_gpio(v7); 86 | js_init_audio(v7); 87 | js_init_gsm(v7); 88 | 89 | v7_exec_file(v7, "init.js", &exec_result); 90 | 91 | sj_prompt_init(v7); 92 | 93 | 94 | 95 | key_init(); 96 | vm_keypad_register_event_callback(handle_keypad_event); 97 | 98 | /* register system events handler */ 99 | vm_pmng_register_system_event_callback(handle_sysevt); 100 | } 101 | -------------------------------------------------------------------------------- /JS/retarget.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "vmdcl.h" 4 | #include "vmdcl_sio.h" 5 | #include "vmboard.h" 6 | #include "vmthread.h" 7 | #include "vmlog.h" 8 | #include "sj_prompt.h" 9 | 10 | #define SERIAL_BUFFER_SIZE 64 11 | 12 | /* Module owner of APP */ 13 | static VM_DCL_OWNER_ID g_owner_id = 0; 14 | static VM_DCL_HANDLE retarget_device_handle = -1; 15 | 16 | void __retarget_irq_handler(void* parameter, VM_DCL_EVENT event, VM_DCL_HANDLE device_handle) 17 | { 18 | if(event == VM_DCL_SIO_UART_READY_TO_READ) 19 | { 20 | char data[SERIAL_BUFFER_SIZE]; 21 | int i; 22 | VM_DCL_STATUS status; 23 | VM_DCL_BUFFER_LENGTH returned_len = 0; 24 | 25 | status = vm_dcl_read(device_handle, 26 | (VM_DCL_BUFFER *)data, 27 | SERIAL_BUFFER_SIZE, 28 | &returned_len, 29 | g_owner_id); 30 | if(status < VM_DCL_STATUS_OK) 31 | { 32 | // vm_log_info((char*)"read failed"); 33 | } 34 | else if (returned_len) 35 | { 36 | for (i = 0; i < returned_len; i++) 37 | { 38 | sj_prompt_process_char(data[i]); 39 | } 40 | } 41 | 42 | } 43 | else 44 | { 45 | } 46 | } 47 | 48 | void retarget_setup(void) 49 | { 50 | VM_DCL_HANDLE uart_handle; 51 | vm_dcl_sio_control_dcb_t settings; 52 | 53 | 54 | g_owner_id = vm_dcl_get_owner_id(); 55 | 56 | if (retarget_device_handle != -1) 57 | { 58 | return; 59 | } 60 | 61 | /*vm_dcl_config_pin_mode(10, VM_DCL_PIN_MODE_UART); 62 | vm_dcl_config_pin_mode(11, VM_DCL_PIN_MODE_UART); 63 | uart_handle = vm_dcl_open(VM_DCL_SIO_UART_PORT1, g_owner_id);*/ 64 | uart_handle = vm_dcl_open(VM_DCL_SIO_USB_PORT1, g_owner_id); 65 | 66 | settings.owner_id = g_owner_id; 67 | settings.config.dsr_check = 0; 68 | settings.config.data_bits_per_char_length = VM_DCL_SIO_UART_BITS_PER_CHAR_LENGTH_8; 69 | settings.config.flow_control = VM_DCL_SIO_UART_FLOW_CONTROL_NONE; 70 | settings.config.parity = VM_DCL_SIO_UART_PARITY_NONE; 71 | settings.config.stop_bits = VM_DCL_SIO_UART_STOP_BITS_1; 72 | settings.config.baud_rate = VM_DCL_SIO_UART_BAUDRATE_115200; 73 | settings.config.sw_xoff_char = 0x13; 74 | settings.config.sw_xon_char = 0x11; 75 | vm_dcl_control(uart_handle, VM_DCL_SIO_COMMAND_SET_DCB_CONFIG, (void *)&settings); 76 | 77 | vm_dcl_register_callback(uart_handle, 78 | VM_DCL_SIO_UART_READY_TO_READ, 79 | (vm_dcl_callback)__retarget_irq_handler, 80 | (void*)NULL); 81 | 82 | retarget_device_handle = uart_handle; 83 | } 84 | 85 | void retarget_putc(char ch) 86 | { 87 | VM_DCL_BUFFER_LENGTH writen_len = 0; 88 | vm_dcl_write(retarget_device_handle, (VM_DCL_BUFFER *)&ch, 1, &writen_len, g_owner_id); 89 | } 90 | 91 | void retarget_puts(const char *str) 92 | { 93 | VM_DCL_BUFFER_LENGTH writen_len = 0; 94 | VM_DCL_BUFFER_LENGTH len = strlen(str); 95 | 96 | vm_dcl_write(retarget_device_handle, (VM_DCL_BUFFER *)str, len, &writen_len, g_owner_id); 97 | } 98 | 99 | int retarget_getc(void) 100 | { 101 | return -1; 102 | } 103 | -------------------------------------------------------------------------------- /JS/sj_prompt.h: -------------------------------------------------------------------------------- 1 | #ifndef __SMARTJS_PROMPT_H_ 2 | #define __SMARTJS_PROMPT_H_ 3 | 4 | struct v7; 5 | 6 | /* Initialize prompt. */ 7 | void sj_prompt_init(struct v7 *v7); 8 | 9 | /* Call this for each arriving char. */ 10 | void sj_prompt_process_char(char ch); 11 | 12 | /* 13 | * Hardware Abstraction Layer: 14 | * 15 | * Implement the following functions in each port 16 | */ 17 | 18 | /* initialize hooks that send chars to prompt handler */ 19 | void sj_prompt_init_hal(); 20 | 21 | #endif /* __SMARTJS_PROMPT_H_ */ 22 | -------------------------------------------------------------------------------- /Lua/.gitignore: -------------------------------------------------------------------------------- 1 | temp/** 2 | touch/** 3 | *.vxp 4 | -------------------------------------------------------------------------------- /Lua/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Lua 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | 29 | common 30 | 2 31 | /home/Boris/Programiranje/RePhone/common 32 | 33 | 34 | include 35 | 2 36 | /home/Boris/Programiranje/RePhone/include 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Lua/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Lua/.settings/org.eclipse.core.runtime.prefs: -------------------------------------------------------------------------------- 1 | content-types/enabled=false 2 | content-types/org.eclipse.cdt.core.cHeader/file-extensions=h 3 | content-types/org.eclipse.cdt.core.cSource/file-extensions=c 4 | content-types/org.eclipse.cdt.core.cSource/file-names=makefile 5 | eclipse.preferences.version=1 6 | -------------------------------------------------------------------------------- /Lua/Makefile: -------------------------------------------------------------------------------- 1 | 2 | WORKSPACE_PATH = ../ 3 | 4 | PROJECT = lua 5 | 6 | OBJECTS += main.o retarget.o shell.o audio.o bt.o gsm.o timer.o gpio.o i2c.o spi.o net.o https.o sntp.o struct.o sensor.o bme280.o 7 | OBJECTS += screen.o lua_cjson.o fpconv.o strbuf.o md5.o sha1.o sha2.o bit.o 8 | OBJECTS += mqtt.o mqtt_client.o mqtt_packet.o mqtt_socket.o mqttnet.o email.o ftp.o 9 | OBJECTS += lcd.o DefaultFont.o tjpgd.o term.o term_mdl.o 10 | 11 | OBJECTS += lua/lapi.o lua/lcode.o lua/ldebug.o lua/ldo.o lua/ldump.o lua/lfunc.o lua/lgc.o lua/llex.o \ 12 | lua/lmem.o lua/lobject.o lua/lopcodes.o lua/lparser.o lua/lstate.o lua/lstring.o lua/ltable.o lua/ltm.o \ 13 | lua/lundump.o lua/lvm.o lua/lzio.o lua/lrotable.o lua/lauxlib.o lua/lbaselib.o lua/ldblib.o lua/liolib.o \ 14 | lua/lmathlib.o lua/loslib.o lua/ltablib.o lua/lstrlib.o lua/loadlib.o lua/linit.o lua/print.o \ 15 | lua/linenoise.o lua/legc.o \ 16 | $(WORKSPACE_PATH)common/ymodem.o $(WORKSPACE_PATH)common/CheckSumUtils.o 17 | 18 | INCLUDE_PATHS += -I./lua 19 | 20 | # =============================================================================== 21 | 22 | #PROJECT_PATH := $(patsubst %/Makefile,%,$(realpath $(lastword $(MAKEFILE_LIST)))) 23 | #PROJECT_PATH := $(patsubst %/makefile,%,$(PROJECT_PATH)) 24 | 25 | GCC_BIN ?= /usr/bin/ 26 | OBJECTS += $(WORKSPACE_PATH)common/lcd_sitronix_st7789s.o $(WORKSPACE_PATH)common/tp_goodix_gt9xx.o $(WORKSPACE_PATH)common/tp_i2c.o 27 | SYS_OBJECTS += $(WORKSPACE_PATH)common/gccmain.o 28 | INCLUDE_PATHS += -I. -I$(WORKSPACE_PATH)include -I$(WORKSPACE_PATH)common 29 | LIBRARY_PATHS += -L$(WORKSPACE_PATH)lib 30 | LIBRARIES += $(WORKSPACE_PATH)lib/LINKIT10/armgcc/libmtk.a -lm 31 | #LIBRARIES += $(WORKSPACE_PATH)lib/LINKIT10/armgcc/percommon.a -lm 32 | LINKER_SCRIPT = $(WORKSPACE_PATH)lib/LINKIT10/armgcc/scat.ld 33 | 34 | ############################################################################### 35 | AS = $(GCC_BIN)arm-none-eabi-as 36 | CC = $(GCC_BIN)arm-none-eabi-gcc 37 | CPP = $(GCC_BIN)arm-none-eabi-g++ 38 | LD = $(GCC_BIN)arm-none-eabi-gcc 39 | OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy 40 | OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump 41 | SIZE = $(GCC_BIN)arm-none-eabi-size 42 | 43 | UNAME_S := $(shell uname -s) 44 | ifeq ($(UNAME_S),Linux) 45 | PACK = python $(WORKSPACE_PATH)tools/packtag.py 46 | PUSH = @echo "set RePhone into storage mode, put $(PROJECT).vxp into MRE directory and replace vxp file name with $(PROJECT).vxp" 47 | endif 48 | ifeq ($(UNAME_S),Darwin) 49 | PACK = python $(WORKSPACE_PATH)tools/packtag.py 50 | PUSH = @echo "set RePhone into storage mode, put $(PROJECT).vxp into MRE directory and replace vxp file name with $(PROJECT).vxp" 51 | endif 52 | 53 | CPU = -mcpu=arm7tdmi-s -mthumb -mlittle-endian 54 | #CC_FLAGS = $(CPU) -c -fvisibility=hidden -fpic -Os -Wa,-adhlns=$(PROJECT).lst -save-temps 55 | CC_FLAGS = $(CPU) -c -fvisibility=hidden -fpic -Os 56 | #CC_SYMBOLS += -D__HDK_LINKIT_ASSIST_2502__ -D__COMPILER_GCC__ 57 | CC_SYMBOLS += -D__HDK_LINKIT_REPHONE__ -D__COMPILER_GCC__ 58 | 59 | LD_FLAGS = $(CPU) -Os -Wl,--gc-sections --specs=nosys.specs -fpic -pie -Wl,-Map=$(PROJECT).map -Wl,--entry=gcc_entry -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-unresolved-symbols 60 | LD_SYS_LIBS = 61 | 62 | 63 | all: $(PROJECT).vxp size 64 | 65 | clean: 66 | rm -f $(PROJECT).vxp $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst *.o *.i *.s $(OBJECTS) $(SYS_OBJECTS) 67 | 68 | .s.o: 69 | $(AS) $(CPU) -o $@ $< 70 | 71 | .c.o: 72 | $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< 73 | 74 | .cpp.o: 75 | $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $< 76 | 77 | 78 | $(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) 79 | $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ -Wl,--start-group $^ $(LIBRARIES) $(LD_SYS_LIBS) -Wl,--end-group 80 | 81 | $(PROJECT).bin: $(PROJECT).elf 82 | @$(OBJCOPY) -O binary $< $@ 83 | 84 | $(PROJECT).hex: $(PROJECT).elf 85 | @$(OBJCOPY) -O ihex $< $@ 86 | 87 | $(PROJECT).vxp: $(PROJECT).elf 88 | # @$(OBJCOPY) --strip-debug $< 89 | @$(OBJCOPY) --strip-debug --strip-unneeded $< 90 | @$(PACK) $< $@ 91 | 92 | $(PROJECT).lst: $(PROJECT).elf 93 | @$(OBJDUMP) -Sdh $< > $@ 94 | 95 | lst: $(PROJECT).lst 96 | 97 | size: $(PROJECT).elf 98 | $(SIZE) $(PROJECT).elf 99 | 100 | flash: $(PROJECT).vxp 101 | $(PUSH) 102 | -------------------------------------------------------------------------------- /Lua/attributes.h: -------------------------------------------------------------------------------- 1 | /* attributes.h; some GCC extensions wrapped up so they do nothing elsewhere 2 | * Copyright 2009-2010 Rob Kendrick , distributed under MIT 3 | * 4 | * Of course, some compilers define __GNUC__ and a GCC version number, and 5 | * aren't GCC. If they choke when you use this file, report a bug to your 6 | * compiler vendor. 7 | */ 8 | 9 | #ifndef _GCC_ATTRIBUTES_ 10 | #define _GCC_ATTRIBUTES_ 11 | 12 | #ifdef __GNUC__ 13 | # define GCC_VERSION (__GNUC__ * 10000 \ 14 | + __GNUC_MINOR__ * 100 \ 15 | + __GNUC_PATCHLEVEL__) 16 | #else 17 | # define GCC_VERSION 0 18 | #endif 19 | 20 | /* Symbol behaviors *********************************************************/ 21 | 22 | #if GCC_VERSION >= 20500 23 | # define _NORETURN __attribute__ ((noreturn)) 24 | #else 25 | # define _NORETURN 26 | #endif 27 | 28 | #if GCC_VERSION >= 20700 29 | # define _CONSTRUCTOR __attribute__ ((constructor)) 30 | # define _DESTRUCTOR __attribute__ ((destructor)) 31 | # define _WEAK __attribute__ ((weak)) 32 | #else 33 | # define _CONSTRUCTOR 34 | # define _DESTRUCTOR 35 | # define _WEAK 36 | #endif 37 | 38 | #if GCC_VERSION >= 30000 39 | # define _MALLOC __attribute__ ((malloc)) 40 | #else 41 | # define _MALLOC 42 | #endif 43 | 44 | #if GCC_VERSION >= 30300 45 | # define _CLEANUP(x) __attribute__ ((cleanup(x))) 46 | #else 47 | # define _CLEANUP(x) 48 | #endif 49 | 50 | /* Parameter and call checking **********************************************/ 51 | 52 | #if GCC_VERSION >= 20300 53 | # define _FORMAT(...) __attribute__ ((format(__VA_ARGS__))) 54 | #else 55 | # define _FORMAT(...) 56 | #endif 57 | 58 | #if GCC_VERSION >= 20700 59 | # define _UNUSED __attribute__ ((unused)) 60 | #else 61 | # define _UNUSED 62 | #endif 63 | 64 | #if GCC_VERSION >= 20800 65 | # define _FORMAT_ARG(x) __attribute__ ((format_arg(x))) 66 | #else 67 | # define _FORMAT_ARG(x) 68 | #endif 69 | 70 | #if GCC_VERSION >= 30100 71 | # define _DEPRECATED __attribute__ ((deprecated)) 72 | # define _USED __attribute__ ((used)) 73 | #else 74 | # define _DEPRECATED 75 | # define _USED 76 | #endif 77 | 78 | #if GCC_VERSION >= 30300 79 | # define _NONNULL(...) __attribute__ ((nonnull(__VA_ARGS__))) 80 | # define _WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) 81 | #else 82 | # define _NONNULL(...) 83 | # define _WARN_UNUSED_RESULT 84 | #endif 85 | 86 | #if GCC_VERSION >= 40400 87 | # define _BOUNDED(...) __attribute ((__bounded__(__VAR_ARGS__))) 88 | #else 89 | # define _BOUNDED(...) 90 | #endif 91 | 92 | /* Performance and optimisation-related *************************************/ 93 | 94 | #if GCC_VERSION >= 20500 95 | # define _CONST __attribute__ ((const)) 96 | #else 97 | # define _CONST 98 | #endif 99 | 100 | #if GCC_VERSION >= 20700 101 | # define _ALIGNED(x) __attribute__ ((aligned(x))) 102 | # define _PACKED __attribute__ ((packed)) 103 | #else 104 | # define _ALIGNED(x) 105 | # define _PACKED 106 | #endif 107 | 108 | #if GCC_VERSION >= 30000 109 | # define _PURE __attribute__ ((pure)) 110 | #else 111 | # define _PURE 112 | #endif 113 | 114 | #if GCC_VERSION >= 30100 115 | # define _NO_INLINE __attribute__ ((noinline)) 116 | #else 117 | # define _NO_INLINE 118 | #endif 119 | 120 | #if GCC_VERSION >= 30200 121 | # define _NOTHROW __attribute__ ((nothrow)) 122 | #else 123 | # define _NOTHROW 124 | #endif 125 | 126 | #if GCC_VERSION >= 40300 127 | # define _HOT __attribute__ ((hot)) 128 | # define _COLD __attribute__ ((cold)) 129 | #else 130 | # define _HOT 131 | # define _COLD 132 | #endif 133 | 134 | #if GCC_VERSION >= 40400 135 | # define _OPTIMISE(x) __attribute__ ((optimize(x))) 136 | # define _TARGET(x) __attribute__ ((target(x))) 137 | # define _SSEREGPARM __attribute__ ((sseregparm)) 138 | #else 139 | # define _OPTIMISE(x) 140 | # define _TARGET(x) 141 | # define _SSEREGPARM 142 | #endif 143 | 144 | /* We don't have any version support information for these */ 145 | 146 | #if __GNUC__ 147 | # define _ALWAYS_INLINE __attribute__ ((always_inline)) 148 | # define _FLATTEN __attribute__ ((flatten)) 149 | #else 150 | # define _ALWAYS_INLINE 151 | # define _FLATTEN 152 | #endif 153 | 154 | /****************************************************************************/ 155 | 156 | #ifdef __GNUC__ 157 | # undef GCC_VERSION 158 | #endif 159 | 160 | #endif /* _GCC_ATTRIBUTES_ */ 161 | -------------------------------------------------------------------------------- /Lua/fpconv.h: -------------------------------------------------------------------------------- 1 | /* Lua CJSON floating point conversion routines */ 2 | 3 | /* Buffer required to store the largest string representation of a double. 4 | * 5 | * Longest double printed with %.14g is 21 characters long: 6 | * -1.7976931348623e+308 */ 7 | # define FPCONV_G_FMT_BUFSIZE 32 8 | 9 | #ifdef USE_INTERNAL_FPCONV 10 | static inline void fpconv_init() 11 | { 12 | /* Do nothing - not required */ 13 | } 14 | #else 15 | extern void fpconv_init(); 16 | #endif 17 | 18 | extern int fpconv_g_fmt(char*, double, int); 19 | extern double fpconv_strtod(const char*, char**); 20 | 21 | /* vi:ai et sw=4 ts=4: 22 | */ 23 | -------------------------------------------------------------------------------- /Lua/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _INTEGER 6 | #define _INTEGER 7 | 8 | #ifdef _WIN32 /* FatFs development platform */ 9 | 10 | #include 11 | #include 12 | 13 | #else /* Embedded platform */ 14 | 15 | /* These types must be 16-bit, 32-bit or larger integer */ 16 | typedef int INT; 17 | typedef unsigned int UINT; 18 | 19 | /* These types must be 8-bit integer */ 20 | typedef char CHAR; 21 | typedef unsigned char UCHAR; 22 | typedef unsigned char BYTE; 23 | 24 | /* These types must be 16-bit integer */ 25 | typedef short SHORT; 26 | typedef unsigned short USHORT; 27 | typedef unsigned short WORD; 28 | typedef unsigned short WCHAR; 29 | 30 | /* These types must be 32-bit integer */ 31 | typedef long LONG; 32 | typedef unsigned long ULONG; 33 | typedef unsigned long DWORD; 34 | 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Lua/lua/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Lua/lua/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, 28 | OPR_CONCAT, 29 | OPR_NE, OPR_EQ, 30 | OPR_LT, OPR_LE, OPR_GT, OPR_GE, 31 | OPR_AND, OPR_OR, 32 | OPR_NOBINOPR 33 | } BinOpr; 34 | 35 | 36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 37 | 38 | 39 | #define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) 40 | 41 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 42 | 43 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 44 | 45 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 46 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 47 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 48 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 49 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 50 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 51 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 52 | LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); 53 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 54 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 55 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 56 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 57 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 58 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 59 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 60 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 61 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 62 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 63 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 64 | LUAI_FUNC int luaK_jump (FuncState *fs); 65 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 66 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 67 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 68 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 69 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 70 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); 71 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 72 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); 73 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Lua/lua/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); 24 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, 25 | const TValue *p2); 26 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); 29 | LUAI_FUNC void luaG_errormsg (lua_State *L); 30 | LUAI_FUNC int luaG_checkcode (const Proto *pt); 31 | LUAI_FUNC int luaG_checkopenop (Instruction i); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Lua/lua/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | #define luaD_checkstack(L,n) \ 17 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ 18 | luaD_growstack(L, n); \ 19 | else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); 20 | 21 | 22 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;} 23 | 24 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 25 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 26 | 27 | #define saveci(L,p) ((char *)(p) - (char *)L->base_ci) 28 | #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) 29 | 30 | 31 | /* results from luaD_precall */ 32 | #define PCRLUA 0 /* initiated a call to a Lua function */ 33 | #define PCRC 1 /* did a call to a C function */ 34 | #define PCRYIELD 2 /* C funtion yielded */ 35 | 36 | 37 | /* type of protected functions, to be ran by `runprotected' */ 38 | typedef void (*Pfunc) (lua_State *L, void *ud); 39 | 40 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); 41 | LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 45 | ptrdiff_t oldtop, ptrdiff_t ef); 46 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); 47 | LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); 48 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 49 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 50 | 51 | LUAI_FUNC void luaD_throw (lua_State *L, int errcode); 52 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 53 | 54 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /Lua/lua/legc.c: -------------------------------------------------------------------------------- 1 | // Lua EGC (Emergeny Garbage Collector) interface 2 | 3 | #include "legc.h" 4 | #include "lstate.h" 5 | 6 | void legc_set_mode(lua_State *L, int mode, unsigned limit) { 7 | global_State *g = G(L); 8 | 9 | g->egcmode = mode; 10 | g->memlimit = limit; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Lua/lua/legc.h: -------------------------------------------------------------------------------- 1 | // Lua EGC (Emergeny Garbage Collector) interface 2 | 3 | #ifndef __LEGC_H__ 4 | #define __LEGC_H__ 5 | 6 | #include "lstate.h" 7 | 8 | // EGC operations modes 9 | #define EGC_NOT_ACTIVE 0 // EGC disabled 10 | #define EGC_ON_ALLOC_FAILURE 1 // run EGC on allocation failure 11 | #define EGC_ON_MEM_LIMIT 2 // run EGC when an upper memory limit is hit 12 | #define EGC_ALWAYS 4 // always run EGC before an allocation 13 | 14 | void legc_set_mode(lua_State *L, int mode, unsigned limit); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /Lua/lua/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | #include "lgc.h" 14 | 15 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 16 | cast(int, sizeof(TValue)*((n)-1))) 17 | 18 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 19 | cast(int, sizeof(TValue *)*((n)-1))) 20 | 21 | #define proto_readonly(p) l_setbit((p)->marked, READONLYBIT) 22 | #define proto_is_readonly(p) testbit((p)->marked, READONLYBIT) 23 | 24 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 25 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); 26 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); 27 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 28 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 29 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 30 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 31 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 32 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 33 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 34 | int pc); 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Lua/lua/linenoise.h: -------------------------------------------------------------------------------- 1 | /* linenoise.h -- guerrilla line editing library against the idea that a 2 | * line editing lib needs to be 20,000 lines of C code. 3 | * 4 | * See linenoise.c for more information. 5 | * 6 | * Copyright (c) 2010, Salvatore Sanfilippo 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * * Neither the name of Redis nor the names of its contributors may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef __LINENOISE_H 35 | #define __LINENOISE_H 36 | 37 | // Error codes 38 | #define LINENOISE_HISTORY_NOT_ENABLED ( -2 ) 39 | #define LINENOISE_HISTORY_EMPTY ( -3 ) 40 | 41 | // Components that use linenoise in Lua 42 | #define LINENOISE_ID_LUA 0 43 | #define LINENOISE_ID_SHELL 1 44 | #define LINENOISE_TOTAL_COMPONENTS 2 45 | #define LINENOISE_HISTORY_SIZE_LUA 20 46 | #define LINENOISE_HISTORY_SIZE_SHELL 10 47 | 48 | int linenoisePrompt(int id, char *buf, int buflen, const char *prompt); 49 | int linenoise_getline( int id, char* buffer, int maxinput, const char* prompt ); 50 | int linenoise_addhistory( int id, const char *line ); 51 | void linenoise_cleanup( int id ); 52 | int linenoise_savehistory( int id, const char* filename ); 53 | 54 | #endif /* __LINENOISE_H */ 55 | -------------------------------------------------------------------------------- /Lua/lua/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Initialization of libraries for lua.c 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | #include "lua.h" 12 | 13 | #include "lualib.h" 14 | #include "lauxlib.h" 15 | #include "lrotable.h" 16 | #include "luaconf.h" 17 | #ifndef LUA_CROSS_COMPILER 18 | #include "platform_conf.h" 19 | #endif 20 | 21 | #ifdef LUA_RPC 22 | #include "desktop_conf.h" 23 | #endif 24 | 25 | //LUALIB_API int luaopen_platform (lua_State *L); 26 | int luaopen_dummy(lua_State *L); 27 | 28 | // Declare table 29 | #if defined(LUA_PLATFORM_LIBS_ROM) && LUA_OPTIMIZE_MEMORY == 2 30 | #undef _ROM 31 | #define _ROM( name, openf, table ) extern const luaR_entry table[]; 32 | LUA_PLATFORM_LIBS_ROM; 33 | #endif 34 | 35 | // **************************************************************************** 36 | // Platform module handling 37 | // Automatically generate all the data required for platform modules 38 | 39 | #if defined( PLATFORM_MODULES_ENABLE ) 40 | 41 | #if LUA_OPTIMIZE_MEMORY == 2 42 | #undef _ROM 43 | #define _ROM( name, openf, table ) extern const luaR_entry table[]; 44 | PLATFORM_MODULES_LIBS_ROM 45 | #else // #if LUA_OPTIMIZE_MEMORY == 2 46 | #undef _ROM 47 | #define _ROM( name, openf, table ) extern const luaL_reg table[]; 48 | PLATFORM_MODULES_LIBS_ROM 49 | #endif // #if LUA_OPTIMIZE_MEMORY == 2 50 | 51 | #if LUA_OPTIMIZE_MEMORY == 2 52 | const luaR_entry platform_map[] = { 53 | #undef _ROM 54 | #define _ROM( name, openf, table ) { LRO_STRKEY( name ), LRO_ROVAL( table ) }, 55 | PLATFORM_MODULES_LIBS_ROM 56 | { LRO_NILKEY, LRO_NILVAL } 57 | }; 58 | #else // #if LUA_OPTIMIZE_MEMORY == 2 59 | typedef struct { 60 | const char *name; 61 | const luaL_reg *table; 62 | } PLATFORM_MODULE_ENTRY; 63 | 64 | static const PLATFORM_MODULE_ENTRY platform_map_tables[] = { 65 | #undef _ROM 66 | #define _ROM( name, openf, table ) { name, table }, 67 | PLATFORM_MODULES_LIBS_ROM 68 | { NULL, NULL } 69 | }; 70 | #endif // #if LUA_OPTIMIZE_MEMORY == 2 71 | 72 | #undef _ROM 73 | #define _ROM( name, openf, table ) int openf (lua_State*); 74 | PLATFORM_MODULES_LIBS_ROM 75 | static const lua_CFunction platform_open_funcs[] = { 76 | #undef _ROM 77 | #define _ROM( name, openf, table ) openf, 78 | PLATFORM_MODULES_LIBS_ROM 79 | luaopen_dummy 80 | }; 81 | 82 | LUALIB_API int luaopen_platform (lua_State *L) 83 | { 84 | #if LUA_OPTIMIZE_MEMORY == 0 85 | // Register the platform table first and each of the platform module's tables 86 | const PLATFORM_MODULE_ENTRY *plibs = platform_map_tables; 87 | 88 | lua_newtable(L); 89 | lua_pushvalue(L, -1); 90 | lua_setfield(L, LUA_GLOBALSINDEX, PS_LIB_TABLE_NAME); 91 | for(; plibs->name; plibs ++) { 92 | lua_newtable(L); 93 | luaL_register(L, NULL, plibs->table); 94 | lua_setfield(L, -2, plibs->name); 95 | } 96 | lua_pop(L, 1); 97 | #endif // #if LUA_OPTIMIZE_MEMORY == 0 98 | // In any case, call each platform module's initialization function if present 99 | unsigned i; 100 | for (i = 0; i < sizeof(platform_open_funcs) / sizeof(lua_CFunction); i++) { 101 | lua_pushcfunction(L, platform_open_funcs[i]); 102 | lua_call(L, 0, 0); 103 | } 104 | return 0; 105 | } 106 | #endif // #if defined( PLATFORM_MODULES_ENABLE ) 107 | 108 | // End of platform module section 109 | // **************************************************************************** 110 | 111 | 112 | // Dummy open function 113 | int luaopen_dummy(lua_State *L) 114 | { 115 | return 0; 116 | } 117 | 118 | #undef _ROM 119 | #define _ROM( name, openf, table ) { name, openf }, 120 | 121 | static const luaL_Reg lualibs[] = { 122 | {"", luaopen_base}, 123 | {LUA_LOADLIBNAME, luaopen_package}, 124 | {LUA_TABLIBNAME, luaopen_table}, 125 | {LUA_IOLIBNAME, luaopen_io}, 126 | {LUA_STRLIBNAME, luaopen_string}, 127 | {LUA_MATHLIBNAME, luaopen_math}, 128 | {LUA_OSLIBNAME, luaopen_os}, 129 | {LUA_DBLIBNAME, luaopen_debug}, 130 | #if defined(LUA_PLATFORM_LIBS_ROM) 131 | LUA_PLATFORM_LIBS_ROM 132 | #endif 133 | #if defined(LUA_LIBS_NOLTR) 134 | LUA_LIBS_NOLTR 135 | #endif 136 | {NULL, NULL} 137 | }; 138 | 139 | const luaR_table lua_rotable[] = 140 | { 141 | #if defined(LUA_PLATFORM_LIBS_ROM) && LUA_OPTIMIZE_MEMORY == 2 142 | #undef _ROM 143 | #define _ROM( name, openf, table ) { name, table }, 144 | LUA_PLATFORM_LIBS_ROM 145 | #endif 146 | {NULL, NULL} 147 | }; 148 | 149 | LUALIB_API void luaL_openlibs (lua_State *L) { 150 | const luaL_Reg *lib = lualibs; 151 | for (; lib->name; lib++) 152 | if (lib->func) { 153 | lua_pushcfunction(L, lib->func); 154 | lua_pushstring(L, lib->name); 155 | lua_call(L, 1, 0); 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /Lua/lua/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | /* maximum length of a reserved word */ 17 | #define TOKEN_LEN (sizeof("function")/sizeof(char)) 18 | 19 | 20 | /* 21 | * WARNING: if you change the order of this enumeration, 22 | * grep "ORDER RESERVED" 23 | */ 24 | enum RESERVED { 25 | /* terminal symbols denoted by reserved words */ 26 | TK_AND = FIRST_RESERVED, TK_BREAK, 27 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 28 | TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 29 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 30 | /* other terminal symbols */ 31 | TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, 32 | TK_NAME, TK_STRING, TK_EOS 33 | }; 34 | 35 | /* number of reserved words */ 36 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 37 | 38 | 39 | /* array with token `names' */ 40 | LUAI_DATA const char *const luaX_tokens []; 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | TString *ts; 46 | } SemInfo; /* semantics information */ 47 | 48 | 49 | typedef struct Token { 50 | int token; 51 | SemInfo seminfo; 52 | } Token; 53 | 54 | 55 | typedef struct LexState { 56 | int current; /* current character (charint) */ 57 | int linenumber; /* input line counter */ 58 | int lastline; /* line of last token `consumed' */ 59 | Token t; /* current token */ 60 | Token lookahead; /* look ahead token */ 61 | struct FuncState *fs; /* `FuncState' is private to the parser */ 62 | struct lua_State *L; 63 | ZIO *z; /* input stream */ 64 | Mbuffer *buff; /* buffer for tokens */ 65 | TString *source; /* current source name */ 66 | char decpoint; /* locale decimal point */ 67 | } LexState; 68 | 69 | 70 | LUAI_FUNC void luaX_init (lua_State *L); 71 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 72 | TString *source); 73 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 74 | LUAI_FUNC void luaX_next (LexState *ls); 75 | LUAI_FUNC void luaX_lookahead (LexState *ls); 76 | LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); 77 | LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); 78 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 79 | 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Lua/lua/llimits.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Limits, basic types, and some other `installation-dependent' definitions 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llimits_h 8 | #define llimits_h 9 | 10 | 11 | #include 12 | #include 13 | 14 | 15 | #include "lua.h" 16 | #include "shell.h" 17 | #include "vmthread.h" 18 | 19 | typedef LUAI_UINT32 lu_int32; 20 | 21 | typedef LUAI_UMEM lu_mem; 22 | 23 | typedef LUAI_MEM l_mem; 24 | 25 | 26 | 27 | /* chars used as small naturals (so that `char' is reserved for characters) */ 28 | typedef unsigned char lu_byte; 29 | 30 | 31 | #define MAX_SIZET ((size_t)(~(size_t)0)-2) 32 | 33 | #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) 34 | 35 | 36 | #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ 37 | 38 | /* 39 | ** conversion of pointer to integer 40 | ** this is for hashing only; there is no problem if the integer 41 | ** cannot hold the whole pointer value 42 | */ 43 | #define IntPoint(p) ((unsigned int)(lu_mem)(p)) 44 | 45 | 46 | 47 | /* type to ensure maximum alignment */ 48 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; 49 | 50 | 51 | /* result of a `usual argument conversion' over lua_Number */ 52 | typedef LUAI_UACNUMBER l_uacNumber; 53 | 54 | 55 | /* internal assertions for in-house debugging */ 56 | #ifdef lua_assert 57 | 58 | #define check_exp(c,e) (lua_assert(c), (e)) 59 | #define api_check(l,e) lua_assert(e) 60 | 61 | #else 62 | 63 | #define lua_assert(c) ((void)0) 64 | #define check_exp(c,e) (e) 65 | #define api_check luai_apicheck 66 | 67 | #endif 68 | 69 | 70 | #ifndef UNUSED 71 | #define UNUSED(x) ((void)(x)) /* to avoid warnings */ 72 | #endif 73 | 74 | 75 | #ifndef cast 76 | #define cast(t, exp) ((t)(exp)) 77 | #endif 78 | 79 | #define cast_byte(i) cast(lu_byte, (i)) 80 | #define cast_num(i) cast(lua_Number, (i)) 81 | #define cast_int(i) cast(int, (i)) 82 | 83 | 84 | 85 | /* 86 | ** type for virtual-machine instructions 87 | ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) 88 | */ 89 | typedef lu_int32 Instruction; 90 | 91 | 92 | 93 | /* maximum stack for a Lua function */ 94 | #define MAXSTACK 250 95 | 96 | 97 | 98 | /* minimum size for the string table (must be power of 2) */ 99 | #ifndef MINSTRTABSIZE 100 | #define MINSTRTABSIZE 32 101 | #endif 102 | 103 | 104 | /* minimum size for string buffer */ 105 | #ifndef LUA_MINBUFFER 106 | #define LUA_MINBUFFER 32 107 | #endif 108 | 109 | 110 | #ifndef lua_lock 111 | #define lua_lock(L) ((void) 0) 112 | #define lua_unlock(L) ((void) 0) 113 | //#define lua_lock(L) vm_mutex_lock(&lua_func_mutex) 114 | //#define lua_unlock(L) vm_mutex_unlock(&lua_func_mutex) 115 | #endif 116 | 117 | #ifndef luai_threadyield 118 | #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} 119 | #endif 120 | 121 | 122 | /* 123 | ** macro to control inclusion of some hard tests on stack reallocation 124 | */ 125 | #ifndef HARDSTACKTESTS 126 | #define condhardstacktests(x) ((void)0) 127 | #else 128 | #define condhardstacktests(x) x 129 | #endif 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /Lua/lua/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lmem_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "ldebug.h" 16 | #include "ldo.h" 17 | #include "lmem.h" 18 | #include "lobject.h" 19 | #include "lstate.h" 20 | 21 | 22 | 23 | /* 24 | ** About the realloc function: 25 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 26 | ** (`osize' is the old size, `nsize' is the new size) 27 | ** 28 | ** Lua ensures that (ptr == NULL) iff (osize == 0). 29 | ** 30 | ** * frealloc(ud, NULL, 0, x) creates a new block of size `x' 31 | ** 32 | ** * frealloc(ud, p, x, 0) frees the block `p' 33 | ** (in this specific case, frealloc must return NULL). 34 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 35 | ** (which is equivalent to free(NULL) in ANSI C) 36 | ** 37 | ** frealloc returns NULL if it cannot create or reallocate the area 38 | ** (any reallocation to an equal or smaller size cannot fail!) 39 | */ 40 | 41 | 42 | 43 | #define MINSIZEARRAY 4 44 | 45 | 46 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 47 | int limit, const char *errormsg) { 48 | void *newblock; 49 | int newsize; 50 | if (*size >= limit/2) { /* cannot double it? */ 51 | if (*size >= limit) /* cannot grow even a little? */ 52 | luaG_runerror(L, errormsg); 53 | newsize = limit; /* still have at least one free place */ 54 | } 55 | else { 56 | if (*size > 8192) newsize = (*size) + ((*size)/2); 57 | else newsize = (*size)*2; 58 | if (newsize < MINSIZEARRAY) 59 | newsize = MINSIZEARRAY; /* minimum size */ 60 | } 61 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 62 | *size = newsize; /* update only when everything else is OK */ 63 | return newblock; 64 | } 65 | 66 | 67 | void *luaM_toobig (lua_State *L) { 68 | luaG_runerror(L, "memory allocation error: block too big"); 69 | return NULL; /* to avoid warnings */ 70 | } 71 | 72 | 73 | 74 | /* 75 | ** generic allocation routine. 76 | */ 77 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 78 | global_State *g = G(L); 79 | lua_assert((osize == 0) == (block == NULL)); 80 | block = (*g->frealloc)(g->ud, block, osize, nsize); 81 | if (block == NULL && nsize > 0) 82 | luaD_throw(L, LUA_ERRMEM); 83 | lua_assert((nsize == 0) == (block == NULL)); 84 | g->totalbytes = (g->totalbytes - osize) + nsize; 85 | return block; 86 | } 87 | 88 | -------------------------------------------------------------------------------- /Lua/lua/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | #define MEMERRMSG "not enough memory" 17 | 18 | 19 | #define luaM_reallocv(L,b,on,n,e) \ 20 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 21 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 22 | luaM_toobig(L)) 23 | 24 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 25 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 26 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) 27 | 28 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) 29 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 30 | #define luaM_newvector(L,n,t) \ 31 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 32 | 33 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 34 | if ((nelems)+1 > (size)) \ 35 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 36 | 37 | #define luaM_reallocvector(L, v,oldn,n,t) \ 38 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 39 | 40 | 41 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 42 | size_t size); 43 | LUAI_FUNC void *luaM_toobig (lua_State *L); 44 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 45 | size_t size_elem, int limit, 46 | const char *errormsg); 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /Lua/lua/lopcodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** See Copyright Notice in lua.h 4 | */ 5 | 6 | 7 | #define lopcodes_c 8 | #define LUA_CORE 9 | 10 | 11 | #include "lopcodes.h" 12 | 13 | 14 | /* ORDER OP */ 15 | 16 | const char *const luaP_opnames[NUM_OPCODES+1] = { 17 | "MOVE", 18 | "LOADK", 19 | "LOADBOOL", 20 | "LOADNIL", 21 | "GETUPVAL", 22 | "GETGLOBAL", 23 | "GETTABLE", 24 | "SETGLOBAL", 25 | "SETUPVAL", 26 | "SETTABLE", 27 | "NEWTABLE", 28 | "SELF", 29 | "ADD", 30 | "SUB", 31 | "MUL", 32 | "DIV", 33 | "MOD", 34 | "POW", 35 | "UNM", 36 | "NOT", 37 | "LEN", 38 | "CONCAT", 39 | "JMP", 40 | "EQ", 41 | "LT", 42 | "LE", 43 | "TEST", 44 | "TESTSET", 45 | "CALL", 46 | "TAILCALL", 47 | "RETURN", 48 | "FORLOOP", 49 | "FORPREP", 50 | "TFORLOOP", 51 | "SETLIST", 52 | "CLOSE", 53 | "CLOSURE", 54 | "VARARG", 55 | NULL 56 | }; 57 | 58 | 59 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) 60 | 61 | const lu_byte luaP_opmodes[NUM_OPCODES] = { 62 | /* T A B C mode opcode */ 63 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ 64 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ 65 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ 66 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ 67 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ 68 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ 69 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ 70 | ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ 71 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ 72 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ 73 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ 74 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ 75 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ 76 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ 77 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ 78 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ 79 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ 80 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ 81 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ 82 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ 83 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ 84 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ 85 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ 86 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ 87 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ 88 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ 89 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ 90 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ 91 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ 92 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ 93 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ 94 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ 95 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ 96 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ 97 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ 98 | ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ 99 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ 100 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ 101 | }; 102 | 103 | -------------------------------------------------------------------------------- /Lua/lua/lparser.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua Parser 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lparser_h 8 | #define lparser_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* 16 | ** Expression descriptor 17 | */ 18 | 19 | typedef enum { 20 | VVOID, /* no value */ 21 | VNIL, 22 | VTRUE, 23 | VFALSE, 24 | VK, /* info = index of constant in `k' */ 25 | VKNUM, /* nval = numerical value */ 26 | VLOCAL, /* info = local register */ 27 | VUPVAL, /* info = index of upvalue in `upvalues' */ 28 | VGLOBAL, /* info = index of table; aux = index of global name in `k' */ 29 | VINDEXED, /* info = table register; aux = index register (or `k') */ 30 | VJMP, /* info = instruction pc */ 31 | VRELOCABLE, /* info = instruction pc */ 32 | VNONRELOC, /* info = result register */ 33 | VCALL, /* info = instruction pc */ 34 | VVARARG /* info = instruction pc */ 35 | } expkind; 36 | 37 | typedef struct expdesc { 38 | expkind k; 39 | union { 40 | struct { int info, aux; } s; 41 | lua_Number nval; 42 | } u; 43 | int t; /* patch list of `exit when true' */ 44 | int f; /* patch list of `exit when false' */ 45 | } expdesc; 46 | 47 | 48 | typedef struct upvaldesc { 49 | lu_byte k; 50 | lu_byte info; 51 | } upvaldesc; 52 | 53 | 54 | struct BlockCnt; /* defined in lparser.c */ 55 | 56 | 57 | /* state needed to generate code for a given function */ 58 | typedef struct FuncState { 59 | Proto *f; /* current function header */ 60 | Table *h; /* table to find (and reuse) elements in `k' */ 61 | struct FuncState *prev; /* enclosing function */ 62 | struct LexState *ls; /* lexical state */ 63 | struct lua_State *L; /* copy of the Lua state */ 64 | struct BlockCnt *bl; /* chain of current blocks */ 65 | int pc; /* next position to code (equivalent to `ncode') */ 66 | int lasttarget; /* `pc' of last `jump target' */ 67 | int jpc; /* list of pending jumps to `pc' */ 68 | int freereg; /* first free register */ 69 | int nk; /* number of elements in `k' */ 70 | int np; /* number of elements in `p' */ 71 | short nlocvars; /* number of elements in `locvars' */ 72 | lu_byte nactvar; /* number of active local variables */ 73 | upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ 74 | unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ 75 | } FuncState; 76 | 77 | 78 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, 79 | const char *name); 80 | 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /Lua/lua/lrodefs.h: -------------------------------------------------------------------------------- 1 | /* Read-only tables helper */ 2 | 3 | #undef LUA_REG_TYPE 4 | #undef LSTRKEY 5 | #undef LNILKEY 6 | #undef LNUMKEY 7 | #undef LFUNCVAL 8 | #undef LNUMVAL 9 | #undef LROVAL 10 | #undef LNILVAL 11 | #undef LREGISTER 12 | 13 | #if (MIN_OPT_LEVEL > 0) && (LUA_OPTIMIZE_MEMORY >= MIN_OPT_LEVEL) 14 | #define LUA_REG_TYPE luaR_entry 15 | #define LSTRKEY LRO_STRKEY 16 | #define LNUMKEY LRO_NUMKEY 17 | #define LNILKEY LRO_NILKEY 18 | #define LFUNCVAL LRO_FUNCVAL 19 | #define LNUMVAL LRO_NUMVAL 20 | #define LROVAL LRO_ROVAL 21 | #define LNILVAL LRO_NILVAL 22 | #define LREGISTER(L, name, table)\ 23 | return 0 24 | #else 25 | #define LUA_REG_TYPE luaL_reg 26 | #define LSTRKEY(x) x 27 | #define LNILKEY NULL 28 | #define LFUNCVAL(x) x 29 | #define LNILVAL NULL 30 | #define LREGISTER(L, name, table)\ 31 | luaL_register(L, name, table);\ 32 | return 1 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /Lua/lua/lrotable.c: -------------------------------------------------------------------------------- 1 | /* Read-only tables for Lua */ 2 | 3 | #include 4 | #include "lrotable.h" 5 | #include "lua.h" 6 | #include "lauxlib.h" 7 | #include "lstring.h" 8 | #include "lobject.h" 9 | #include "lapi.h" 10 | 11 | /* Local defines */ 12 | #define LUAR_FINDFUNCTION 0 13 | #define LUAR_FINDVALUE 1 14 | 15 | /* Externally defined read-only table array */ 16 | extern const luaR_table lua_rotable[]; 17 | 18 | /* Find a global "read only table" in the constant lua_rotable array */ 19 | void* luaR_findglobal(const char *name, unsigned len) { 20 | unsigned i; 21 | 22 | if (strlen(name) > LUA_MAX_ROTABLE_NAME) 23 | return NULL; 24 | for (i=0; lua_rotable[i].name; i ++) 25 | if (*lua_rotable[i].name != '\0' && strlen(lua_rotable[i].name) == len && !strncmp(lua_rotable[i].name, name, len)) { 26 | return (void*)(lua_rotable[i].pentries); 27 | } 28 | return NULL; 29 | } 30 | 31 | /* Find an entry in a rotable and return it */ 32 | static const TValue* luaR_auxfind(const luaR_entry *pentry, const char *strkey, luaR_numkey numkey, unsigned *ppos) { 33 | const TValue *res = NULL; 34 | unsigned i = 0; 35 | 36 | if (pentry == NULL) 37 | return NULL; 38 | while(pentry->key.type != LUA_TNIL) { 39 | if ((strkey && (pentry->key.type == LUA_TSTRING) && (!strcmp(pentry->key.id.strkey, strkey))) || 40 | (!strkey && (pentry->key.type == LUA_TNUMBER) && ((luaR_numkey)pentry->key.id.numkey == numkey))) { 41 | res = &pentry->value; 42 | break; 43 | } 44 | i ++; pentry ++; 45 | } 46 | if (res && ppos) 47 | *ppos = i; 48 | return res; 49 | } 50 | 51 | int luaR_findfunction(lua_State *L, const luaR_entry *ptable) { 52 | const TValue *res = NULL; 53 | const char *key = luaL_checkstring(L, 2); 54 | 55 | res = luaR_auxfind(ptable, key, 0, NULL); 56 | if (res && ttislightfunction(res)) { 57 | luaA_pushobject(L, res); 58 | return 1; 59 | } 60 | else 61 | return 0; 62 | } 63 | 64 | /* Find an entry in a rotable and return its type 65 | If "strkey" is not NULL, the function will look for a string key, 66 | otherwise it will look for a number key */ 67 | const TValue* luaR_findentry(void *data, const char *strkey, luaR_numkey numkey, unsigned *ppos) { 68 | return luaR_auxfind((const luaR_entry*)data, strkey, numkey, ppos); 69 | } 70 | 71 | /* Find the metatable of a given table */ 72 | void* luaR_getmeta(void *data) { 73 | #ifdef LUA_META_ROTABLES 74 | const TValue *res = luaR_auxfind((const luaR_entry*)data, "__metatable", 0, NULL); 75 | return res && ttisrotable(res) ? rvalue(res) : NULL; 76 | #else 77 | return NULL; 78 | #endif 79 | } 80 | 81 | static void luaR_next_helper(lua_State *L, const luaR_entry *pentries, int pos, TValue *key, TValue *val) { 82 | setnilvalue(key); 83 | setnilvalue(val); 84 | if (pentries[pos].key.type != LUA_TNIL) { 85 | /* Found an entry */ 86 | if (pentries[pos].key.type == LUA_TSTRING) 87 | setsvalue(L, key, luaS_newro(L, pentries[pos].key.id.strkey)) 88 | else 89 | setnvalue(key, (lua_Number)pentries[pos].key.id.numkey) 90 | setobj2s(L, val, &pentries[pos].value); 91 | } 92 | } 93 | /* next (used for iteration) */ 94 | void luaR_next(lua_State *L, void *data, TValue *key, TValue *val) { 95 | const luaR_entry* pentries = (const luaR_entry*)data; 96 | char strkey[LUA_MAX_ROTABLE_NAME + 1], *pstrkey = NULL; 97 | luaR_numkey numkey = 0; 98 | unsigned keypos; 99 | 100 | /* Special case: if key is nil, return the first element of the rotable */ 101 | if (ttisnil(key)) 102 | luaR_next_helper(L, pentries, 0, key, val); 103 | else if (ttisstring(key) || ttisnumber(key)) { 104 | /* Find the previoud key again */ 105 | if (ttisstring(key)) { 106 | luaR_getcstr(strkey, rawtsvalue(key), LUA_MAX_ROTABLE_NAME); 107 | pstrkey = strkey; 108 | } else 109 | numkey = (luaR_numkey)nvalue(key); 110 | luaR_findentry(data, pstrkey, numkey, &keypos); 111 | /* Advance to next key */ 112 | keypos ++; 113 | luaR_next_helper(L, pentries, keypos, key, val); 114 | } 115 | } 116 | 117 | /* Convert a Lua string to a C string */ 118 | void luaR_getcstr(char *dest, const TString *src, size_t maxsize) { 119 | if (src->tsv.len+1 > maxsize) 120 | dest[0] = '\0'; 121 | else { 122 | memcpy(dest, getstr(src), src->tsv.len); 123 | dest[src->tsv.len] = '\0'; 124 | } 125 | } 126 | 127 | /* Return 1 if the given pointer is a rotable */ 128 | #ifdef LUA_META_ROTABLES 129 | extern char stext; 130 | extern char etext; 131 | int luaR_isrotable(void *p) { 132 | return &stext <= ( char* )p && ( char* )p <= &etext; 133 | } 134 | #endif 135 | -------------------------------------------------------------------------------- /Lua/lua/lrotable.h: -------------------------------------------------------------------------------- 1 | /* Read-only tables for Lua */ 2 | 3 | #ifndef lrotable_h 4 | #define lrotable_h 5 | 6 | #include "lua.h" 7 | #include "llimits.h" 8 | #include "lobject.h" 9 | #include "luaconf.h" 10 | 11 | /* Macros one can use to define rotable entries */ 12 | #ifndef LUA_PACK_VALUE 13 | #define LRO_FUNCVAL(v) {{.p = v}, LUA_TLIGHTFUNCTION} 14 | #define LRO_NUMVAL(v) {{.n = v}, LUA_TNUMBER} 15 | #define LRO_ROVAL(v) {{.p = (void*)v}, LUA_TROTABLE} 16 | #define LRO_NILVAL {{.p = NULL}, LUA_TNIL} 17 | #else // #ifndef LUA_PACK_VALUE 18 | #define LRO_NUMVAL(v) {.value.n = v} 19 | #ifdef ELUA_ENDIAN_LITTLE 20 | #define LRO_FUNCVAL(v) {{(int)v, add_sig(LUA_TLIGHTFUNCTION)}} 21 | #define LRO_ROVAL(v) {{(int)v, add_sig(LUA_TROTABLE)}} 22 | #define LRO_NILVAL {{0, add_sig(LUA_TNIL)}} 23 | #else // #ifdef ELUA_ENDIAN_LITTLE 24 | #define LRO_FUNCVAL(v) {{add_sig(LUA_TLIGHTFUNCTION), (int)v}} 25 | #define LRO_ROVAL(v) {{add_sig(LUA_TROTABLE), (int)v}} 26 | #define LRO_NILVAL {{add_sig(LUA_TNIL), 0}} 27 | #endif // #ifdef ELUA_ENDIAN_LITTLE 28 | #endif // #ifndef LUA_PACK_VALUE 29 | 30 | #define LRO_STRKEY(k) {LUA_TSTRING, {.strkey = k}} 31 | #define LRO_NUMKEY(k) {LUA_TNUMBER, {.numkey = k}} 32 | #define LRO_NILKEY {LUA_TNIL, {.strkey=NULL}} 33 | 34 | /* Maximum length of a rotable name and of a string key*/ 35 | #define LUA_MAX_ROTABLE_NAME 32 36 | 37 | /* Type of a numeric key in a rotable */ 38 | typedef int luaR_numkey; 39 | 40 | /* The next structure defines the type of a key */ 41 | typedef struct 42 | { 43 | int type; 44 | union 45 | { 46 | const char* strkey; 47 | luaR_numkey numkey; 48 | } id; 49 | } luaR_key; 50 | 51 | /* An entry in the read only table */ 52 | typedef struct 53 | { 54 | const luaR_key key; 55 | const TValue value; 56 | } luaR_entry; 57 | 58 | /* A rotable */ 59 | typedef struct 60 | { 61 | const char *name; 62 | const luaR_entry *pentries; 63 | } luaR_table; 64 | 65 | void* luaR_findglobal(const char *key, unsigned len); 66 | int luaR_findfunction(lua_State *L, const luaR_entry *ptable); 67 | const TValue* luaR_findentry(void *data, const char *strkey, luaR_numkey numkey, unsigned *ppos); 68 | void luaR_getcstr(char *dest, const TString *src, size_t maxsize); 69 | void luaR_next(lua_State *L, void *data, TValue *key, TValue *val); 70 | void* luaR_getmeta(void *data); 71 | #ifdef LUA_META_ROTABLES 72 | int luaR_isrotable(void *p); 73 | #else 74 | #define luaR_isrotable(p) (0) 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /Lua/lua/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | 11 | #include "lgc.h" 12 | #include "lobject.h" 13 | #include "lstate.h" 14 | 15 | 16 | #define sizestring(s) (sizeof(union TString)+(luaS_isreadonly(s) ? sizeof(char **) : ((s)->len+1)*sizeof(char))) 17 | 18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 19 | 20 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 21 | #define luaS_newro(L, s) (luaS_newrolstr(L, s, strlen(s))) 22 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 23 | (sizeof(s)/sizeof(char))-1)) 24 | 25 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 26 | #define luaS_readonly(s) l_setbit((s)->tsv.marked, READONLYBIT) 27 | #define luaS_isreadonly(s) testbit((s)->marked, READONLYBIT) 28 | 29 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 30 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 31 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 32 | LUAI_FUNC TString *luaS_newrolstr (lua_State *L, const char *str, size_t l); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Lua/lua/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.tvk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define key2tval(n) (&(n)->i_key.tvk) 19 | 20 | 21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); 22 | LUAI_FUNC const TValue *luaH_getnum_ro (void *t, int key); 23 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); 24 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 25 | LUAI_FUNC const TValue *luaH_getstr_ro (void *t, TString *key); 26 | LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); 27 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 28 | LUAI_FUNC const TValue *luaH_get_ro (void *t, const TValue *key); 29 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 30 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); 31 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 32 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 33 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 34 | LUAI_FUNC int luaH_next_ro (lua_State *L, void *t, StkId key); 35 | LUAI_FUNC int luaH_getn (Table *t); 36 | LUAI_FUNC int luaH_getn_ro (void *t); 37 | 38 | #if defined(LUA_DEBUG) 39 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 40 | LUAI_FUNC int luaH_isdummy (Node *n); 41 | #endif 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Lua/lua/ltm.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define ltm_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "lobject.h" 16 | #include "lstate.h" 17 | #include "lstring.h" 18 | #include "ltable.h" 19 | #include "ltm.h" 20 | #include "lrotable.h" 21 | 22 | 23 | 24 | const char *const luaT_typenames[] = { 25 | "nil", "boolean", "romtable", "lightfunction", "userdata", "number", 26 | "string", "table", "function", "userdata", "thread", 27 | "proto", "upval" 28 | }; 29 | 30 | 31 | void luaT_init (lua_State *L) { 32 | static const char *const luaT_eventname[] = { /* ORDER TM */ 33 | "__index", "__newindex", 34 | "__gc", "__mode", "__eq", 35 | "__add", "__sub", "__mul", "__div", "__mod", 36 | "__pow", "__unm", "__len", "__lt", "__le", 37 | "__concat", "__call" 38 | }; 39 | int i; 40 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); 42 | luaS_fix(G(L)->tmname[i]); /* never collect these names */ 43 | } 44 | } 45 | 46 | 47 | /* 48 | ** function to be used with macro "fasttm": optimized for absence of 49 | ** tag methods 50 | */ 51 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 52 | const TValue *tm = luaR_isrotable(events) ? luaH_getstr_ro(events, ename) : luaH_getstr(events, ename); 53 | lua_assert(event <= TM_EQ); 54 | if (ttisnil(tm)) { /* no tag method? */ 55 | if (!luaR_isrotable(events)) 56 | events->flags |= cast_byte(1u<metatable; 68 | break; 69 | case LUA_TROTABLE: 70 | mt = (Table*)luaR_getmeta(rvalue(o)); 71 | break; 72 | case LUA_TUSERDATA: 73 | mt = uvalue(o)->metatable; 74 | break; 75 | default: 76 | mt = G(L)->mt[ttype(o)]; 77 | } 78 | if (!mt) 79 | return luaO_nilobject; 80 | else if (luaR_isrotable(mt)) 81 | return luaH_getstr_ro(mt, G(L)->tmname[event]); 82 | else 83 | return luaH_getstr(mt, G(L)->tmname[event]); 84 | } 85 | -------------------------------------------------------------------------------- /Lua/lua/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_EQ, /* last tag method with `fast' access */ 24 | TM_ADD, 25 | TM_SUB, 26 | TM_MUL, 27 | TM_DIV, 28 | TM_MOD, 29 | TM_POW, 30 | TM_UNM, 31 | TM_LEN, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | !luaR_isrotable(et) && ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | LUAI_DATA const char *const luaT_typenames[]; 47 | 48 | 49 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 50 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 51 | TMS event); 52 | LUAI_FUNC void luaT_init (lua_State *L); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /Lua/lua/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* Key to file-handle type */ 15 | #define LUA_FILEHANDLE "FILE*" 16 | 17 | 18 | #define LUA_COLIBNAME "coroutine" 19 | LUALIB_API int (luaopen_base) (lua_State *L); 20 | 21 | #define LUA_TABLIBNAME "table" 22 | LUALIB_API int (luaopen_table) (lua_State *L); 23 | 24 | #define LUA_IOLIBNAME "io" 25 | LUALIB_API int (luaopen_io) (lua_State *L); 26 | 27 | #define LUA_OSLIBNAME "os" 28 | LUALIB_API int (luaopen_os) (lua_State *L); 29 | 30 | #define LUA_STRLIBNAME "string" 31 | LUALIB_API int (luaopen_string) (lua_State *L); 32 | 33 | #define LUA_MATHLIBNAME "math" 34 | LUALIB_API int (luaopen_math) (lua_State *L); 35 | 36 | #define LUA_DBLIBNAME "debug" 37 | LUALIB_API int (luaopen_debug) (lua_State *L); 38 | 39 | #define LUA_LOADLIBNAME "package" 40 | LUALIB_API int (luaopen_package) (lua_State *L); 41 | 42 | 43 | /* open all previous libraries */ 44 | LUALIB_API void (luaL_openlibs) (lua_State *L); 45 | 46 | 47 | 48 | #ifndef lua_assert 49 | #define lua_assert(x) ((void)0) 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Lua/lua/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include 11 | 12 | #include "lobject.h" 13 | #include "lzio.h" 14 | 15 | typedef uint32_t strsize_t; 16 | 17 | /* info about target machine for cross-compilation */ 18 | typedef struct { 19 | int little_endian; 20 | int sizeof_int; 21 | int sizeof_strsize_t; 22 | int sizeof_lua_Number; 23 | int lua_Number_integral; 24 | int is_arm_fpa; 25 | } DumpTargetInfo; 26 | 27 | /* load one chunk; from lundump.c */ 28 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 29 | 30 | /* make header; from lundump.c */ 31 | LUAI_FUNC void luaU_header (char* h); 32 | 33 | /* dump one chunk to a different target; from ldump.c */ 34 | int luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target); 35 | 36 | /* dump one chunk; from ldump.c */ 37 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 38 | 39 | #ifdef luac_c 40 | /* print one chunk; from print.c */ 41 | LUAI_FUNC void luaU_print (const Proto* f, int full); 42 | #endif 43 | 44 | /* for header of binary files -- this is Lua 5.1 */ 45 | #define LUAC_VERSION 0x51 46 | 47 | /* for header of binary files -- this is the official format */ 48 | #define LUAC_FORMAT 0 49 | 50 | /* size of header of binary files */ 51 | #define LUAC_HEADERSIZE 12 52 | 53 | /* error codes from cross-compiler */ 54 | /* target integer is too small to hold a value */ 55 | #define LUA_ERR_CC_INTOVERFLOW 101 56 | 57 | /* target lua_Number is integral but a constant is non-integer */ 58 | #define LUA_ERR_CC_NOTINTEGER 102 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /Lua/lua/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ 19 | (((o) = luaV_tonumber(o,n)) != NULL)) 20 | 21 | #define equalobj(L,o1,o2) \ 22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) 23 | 24 | 25 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 26 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); 27 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 28 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 29 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 30 | StkId val); 31 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 32 | StkId val); 33 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); 34 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Lua/lua/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** a generic input stream interface 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lzio_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "llimits.h" 16 | #include "lmem.h" 17 | #include "lstate.h" 18 | #include "lzio.h" 19 | 20 | #include "shell.h" 21 | #include "vmthread.h" 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) return EOZ; 31 | z->n = size - 1; 32 | z->p = buff; 33 | return char2int(*(z->p++)); 34 | } 35 | 36 | 37 | int luaZ_lookahead (ZIO *z) { 38 | if (z->n == 0) { 39 | if (luaZ_fill(z) == EOZ) 40 | return EOZ; 41 | else { 42 | z->n++; /* luaZ_fill removed first byte; put back it */ 43 | z->p--; 44 | } 45 | } 46 | return char2int(*z->p); 47 | } 48 | 49 | 50 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 51 | z->L = L; 52 | z->reader = reader; 53 | z->data = data; 54 | z->n = z->i = 0; 55 | z->p = NULL; 56 | } 57 | 58 | 59 | /* --------------------------------------------------------------- read --- */ 60 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 61 | while (n) { 62 | size_t m; 63 | if (luaZ_lookahead(z) == EOZ) 64 | return n; /* return number of missing bytes */ 65 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 66 | if (b) 67 | memcpy(b, z->p, m); 68 | z->n -= m; 69 | z->i += m; 70 | z->p += m; 71 | if (b) 72 | b = (char *)b + m; 73 | n -= m; 74 | } 75 | return 0; 76 | } 77 | 78 | /* ------------------------------------------------------------------------ */ 79 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 80 | if (n > buff->buffsize) { 81 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 82 | luaZ_resizebuffer(L, buff, n); 83 | } 84 | return buff->buffer; 85 | } 86 | 87 | 88 | -------------------------------------------------------------------------------- /Lua/lua/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define char2int(c) cast(int, cast(unsigned char, (c))) 21 | 22 | #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) 23 | 24 | typedef struct Mbuffer { 25 | char *buffer; 26 | size_t n; 27 | size_t buffsize; 28 | } Mbuffer; 29 | 30 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->n = 0, (buff)->buffsize = 0) 31 | 32 | #define luaZ_buffer(buff) ((buff)->buffer) 33 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 34 | #define luaZ_bufflen(buff) ((buff)->n) 35 | 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 41 | (buff)->buffsize = size) 42 | 43 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 44 | 45 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 46 | #define luaZ_get_base_address(zio) ((const char *)((zio)->reader(NULL, (zio)->data, NULL))) 47 | #define luaZ_direct_mode(zio) (luaZ_get_base_address(zio) != NULL) 48 | #define luaZ_get_crt_address(zio) (luaZ_get_base_address(zio) + (zio)->i) 49 | 50 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 51 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 52 | void *data); 53 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 54 | LUAI_FUNC int luaZ_lookahead (ZIO *z); 55 | 56 | 57 | 58 | /* --------- Private Part ------------------ */ 59 | 60 | struct Zio { 61 | size_t n; /* bytes still unread */ 62 | size_t i; /* buffer offset */ 63 | const char *p; /* current position in buffer */ 64 | lua_Reader reader; 65 | void* data; /* additional data */ 66 | lua_State *L; /* Lua state (for reader) */ 67 | }; 68 | 69 | 70 | LUAI_FUNC int luaZ_fill (ZIO *z); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /Lua/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code implements the MD5 message-digest algorithm. 3 | * The algorithm is due to Ron Rivest. This code was 4 | * written by Colin Plumb in 1993, no copyright is claimed. 5 | * This code is in the public domain; do with it what you wish. 6 | * 7 | * Equivalent code is available from RSA Data Security, Inc. 8 | * This code has been tested against that, and is equivalent, 9 | * except that you don't need to include two pages of legalese 10 | * with every copy. 11 | */ 12 | 13 | #ifndef _MD5_H_ 14 | #define _MD5_H_ 15 | 16 | //#include "attributes.h" 17 | 18 | #define MD5_BLOCK_LENGTH 64 19 | #define MD5_DIGEST_LENGTH 16 20 | 21 | typedef struct MD5Context { 22 | uint32_t state[4]; /* state */ 23 | uint64_t count; /* number of bits, mod 2^64 */ 24 | uint8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */ 25 | } MD5_CTX; 26 | 27 | static void MD5Init(MD5_CTX *); 28 | static void MD5Update(MD5_CTX *, const uint8_t *, size_t); 29 | static void MD5Final(uint8_t [MD5_DIGEST_LENGTH], MD5_CTX *); 30 | static void MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]); 31 | 32 | #endif /* _MD5_H_ */ 33 | -------------------------------------------------------------------------------- /Lua/mqtt_socket.h: -------------------------------------------------------------------------------- 1 | /* mqtt_socket.h 2 | * 3 | * Copyright (C) 2006-2016 wolfSSL Inc. 4 | * 5 | * This file is part of wolfMQTT. 6 | * 7 | * wolfMQTT is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfMQTT is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | /* Implementation by: David Garske 23 | * Based on specification for MQTT v3.1.1 24 | * See http://mqtt.org/documentation for additional MQTT documentation. 25 | */ 26 | 27 | #ifndef WOLFMQTT_SOCKET_H 28 | #define WOLFMQTT_SOCKET_H 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Options */ 35 | /* Use without WolfSSL (on by default) */ 36 | //#define ENABLE_MQTT_TLS 37 | 38 | #include "mqtt_types.h" 39 | #ifdef ENABLE_MQTT_TLS 40 | #include 41 | #include 42 | #include 43 | #endif 44 | 45 | /* Default Port Numbers */ 46 | #define MQTT_DEFAULT_PORT 1883 47 | #define MQTT_SECURE_PORT 8883 48 | 49 | 50 | struct _MqttClient; 51 | 52 | /* Function callbacks */ 53 | typedef int (*MqttTlsCb)(struct _MqttClient* client); 54 | 55 | typedef int (*MqttNetConnectCb)(void *context, 56 | const char* host, word16 port, int timeout_ms); 57 | typedef int (*MqttNetWriteCb)(void *context, 58 | const byte* buf, int buf_len, int timeout_ms); 59 | typedef int (*MqttNetReadCb)(void *context, 60 | byte* buf, int buf_len, int timeout_ms); 61 | typedef int (*MqttNetDisconnectCb)(void *context); 62 | 63 | /* Strucutre for Network Security */ 64 | #ifdef ENABLE_MQTT_TLS 65 | typedef struct _MqttTls { 66 | WOLFSSL_CTX *ctx; 67 | WOLFSSL *ssl; 68 | } MqttTls; 69 | #endif 70 | 71 | /* Structure for Network callbacks */ 72 | typedef struct _MqttNet { 73 | void *context; 74 | MqttNetConnectCb connect; 75 | MqttNetReadCb read; 76 | MqttNetWriteCb write; 77 | MqttNetDisconnectCb disconnect; 78 | } MqttNet; 79 | 80 | 81 | /* MQTT SOCKET APPLICATION INTERFACE */ 82 | int MqttSocket_Init(struct _MqttClient *client, MqttNet* net); 83 | int MqttSocket_Write(struct _MqttClient *client, const byte* buf, int buf_len, 84 | int timeout_ms); 85 | int MqttSocket_Read(struct _MqttClient *client, byte* buf, int buf_len, 86 | int timeout_ms); 87 | 88 | int MqttSocket_Connect(struct _MqttClient *client, const char* host, 89 | word16 port, int timeout_ms, int use_tls, MqttTlsCb cb); 90 | int MqttSocket_Disconnect(struct _MqttClient *client); 91 | 92 | 93 | #ifdef __cplusplus 94 | } /* extern "C" */ 95 | #endif 96 | 97 | #endif /* WOLFMQTT_SOCKET_H */ 98 | -------------------------------------------------------------------------------- /Lua/mqtt_types.h: -------------------------------------------------------------------------------- 1 | /* mqtt_types.h 2 | * 3 | * Copyright (C) 2006-2016 wolfSSL Inc. 4 | * 5 | * This file is part of wolfMQTT. 6 | * 7 | * wolfMQTT is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfMQTT is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | /* Implementation by: David Garske 23 | * Based on specification for MQTT v3.1.1 24 | * See http://mqtt.org/documentation for additional MQTT documentation. 25 | */ 26 | 27 | #include "vmmemory.h" 28 | 29 | 30 | #ifndef WOLFMQTT_TYPES_H 31 | #define WOLFMQTT_TYPES_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #include "visibility.h" 38 | 39 | /* Endianess check */ 40 | #if defined(__BIG_ENDIAN__) || defined(BIG_ENDIAN_ORDER) 41 | #error Big Endian is not yet supported. Please contact us if \ 42 | you are interested in this feature. 43 | #endif 44 | 45 | #ifdef _WIN32 46 | #define USE_WINDOWS_API 47 | 48 | /* Make sure a level of Win compatibility is defined */ 49 | #ifndef _WIN32_WINNT 50 | #define _WIN32_WINNT 0x0501 51 | #endif 52 | #endif 53 | 54 | #ifndef WOLFMQTT_NO_STDIO 55 | #include 56 | #endif 57 | 58 | /* Allow custom override of data types */ 59 | #ifndef WOLFMQTT_CUSTOM_TYPES 60 | /* Basic Types */ 61 | #ifndef byte 62 | typedef unsigned char byte; 63 | #endif 64 | #ifndef word16 65 | typedef unsigned short word16; 66 | #endif 67 | #ifndef word32 68 | typedef unsigned int word32; 69 | #endif 70 | #endif 71 | 72 | /* Response Codes */ 73 | enum MqttPacketResponseCodes { 74 | MQTT_CODE_SUCCESS = 0, 75 | MQTT_CODE_ERROR_BAD_ARG = -1, 76 | MQTT_CODE_ERROR_OUT_OF_BUFFER = -2, 77 | MQTT_CODE_ERROR_MALFORMED_DATA = -3, /* Error (Malformed Remaining Len) */ 78 | MQTT_CODE_ERROR_PACKET_TYPE = -4, 79 | MQTT_CODE_ERROR_PACKET_ID = -5, 80 | MQTT_CODE_ERROR_TLS_CONNECT = -6, 81 | MQTT_CODE_ERROR_TIMEOUT = -7, 82 | MQTT_CODE_ERROR_NETWORK = -8, 83 | }; 84 | 85 | 86 | /* Standard wrappers */ 87 | #ifndef WOLFMQTT_CUSTOM_STRING 88 | #include 89 | #ifndef XSTRLEN 90 | #define XSTRLEN(s1) strlen((s1)) 91 | #endif 92 | #ifndef XSTRCHR 93 | #define XSTRCHR(s,c) strchr((s),(c)) 94 | #endif 95 | #ifndef XSTRCMP 96 | #define XSTRCMP(s1,s2) strcmp((s1),(s2)) 97 | #endif 98 | #ifndef XMEMCPY 99 | #define XMEMCPY(d,s,l) memcpy((d),(s),(l)) 100 | #endif 101 | #ifndef XMEMSET 102 | #define XMEMSET(b,c,l) memset((b),(c),(l)) 103 | #endif 104 | #ifndef XATOI 105 | #define XATOI(s) atoi((s)) 106 | #endif 107 | #endif 108 | 109 | #ifndef WOLFMQTT_CUSTOM_MALLOC 110 | #ifndef WOLFMQTT_MALLOC 111 | #define WOLFMQTT_MALLOC(s) vm_malloc((s)) 112 | #endif 113 | #ifndef WOLFMQTT_FREE 114 | #define WOLFMQTT_FREE(p) {void* xp = (p); if((xp)) vm_free((xp));} 115 | #endif 116 | #endif 117 | 118 | #ifndef WOLFMQTT_PACK 119 | #if defined(__GNUC__) 120 | #define WOLFMQTT_PACK __attribute__ ((packed)) 121 | #else 122 | #define WOLFMQTT_PACK 123 | #endif 124 | #endif 125 | 126 | /* use inlining if compiler allows */ 127 | #ifndef INLINE 128 | #ifndef NO_INLINE 129 | #if defined(__GNUC__) || defined(__MINGW32__) || defined(__IAR_SYSTEMS_ICC__) 130 | #define INLINE inline 131 | #elif defined(_MSC_VER) 132 | #define INLINE __inline 133 | #elif defined(THREADX) 134 | #define INLINE _Inline 135 | #else 136 | #define INLINE 137 | #endif 138 | #else 139 | #define INLINE 140 | #endif /* !NO_INLINE */ 141 | #endif /* !INLINE */ 142 | 143 | #ifdef __cplusplus 144 | } /* extern "C" */ 145 | #endif 146 | 147 | #endif /* WOLFMQTT_TYPES_H */ 148 | -------------------------------------------------------------------------------- /Lua/mqttexample.h.xx: -------------------------------------------------------------------------------- 1 | /* mqttexample.h 2 | * 3 | * Copyright (C) 2006-2016 wolfSSL Inc. 4 | * 5 | * This file is part of wolfMQTT. 6 | * 7 | * wolfMQTT is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfMQTT is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | #ifndef WOLFMQTT_EXAMPLE_H 23 | #define WOLFMQTT_EXAMPLE_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Compatibility Options */ 30 | #ifdef NO_EXIT 31 | #undef exit 32 | #define exit(rc) return rc 33 | #endif 34 | #ifndef LINE_END 35 | #define LINE_END "\n" 36 | #endif 37 | #ifndef PRINTF 38 | #define PRINTF(_f_, ...) printf( (_f_ LINE_END), ##__VA_ARGS__) 39 | #endif 40 | 41 | #ifndef WOLFMQTT_NO_STDIO 42 | #include 43 | #include 44 | #include 45 | #else 46 | #undef PRINTF 47 | #define PRINTF 48 | #endif 49 | 50 | /* Default Configurations */ 51 | #define WOLFMQTT_TOPIC_NAME "wolfMQTT/example/" 52 | #define DEFAULT_CMD_TIMEOUT_MS 30000 53 | #define DEFAULT_CON_TIMEOUT_MS 5000 54 | #define DEFAULT_MQTT_QOS MQTT_QOS_0 55 | #define DEFAULT_KEEP_ALIVE_SEC 60 56 | #define DEFAULT_TOPIC_NAME WOLFMQTT_TOPIC_NAME"testTopic" 57 | 58 | #define PRINT_BUFFER_SIZE 80 59 | #define MAX_PACKET_ID ((1 << 16) - 1) 60 | 61 | 62 | /* Argument Parsing */ 63 | typedef struct func_args { 64 | int argc; 65 | char** argv; 66 | int return_code; 67 | } func_args; 68 | 69 | #define MY_EX_USAGE 2 /* Exit reason code */ 70 | 71 | extern int myoptind; 72 | extern char* myoptarg; 73 | 74 | static INLINE int mygetopt(int argc, char** argv, const char* optstring) 75 | { 76 | static char* next = NULL; 77 | 78 | char c; 79 | char* cp; 80 | 81 | if (myoptind == 0) 82 | next = NULL; /* we're starting new/over */ 83 | 84 | if (next == NULL || *next == '\0') { 85 | if (myoptind == 0) 86 | myoptind++; 87 | 88 | if (myoptind >= argc || argv[myoptind][0] != '-' || 89 | argv[myoptind][1] == '\0') { 90 | myoptarg = NULL; 91 | if (myoptind < argc) 92 | myoptarg = argv[myoptind]; 93 | 94 | return -1; 95 | } 96 | 97 | if (XSTRCMP(argv[myoptind], "--") == 0) { 98 | myoptind++; 99 | myoptarg = NULL; 100 | 101 | if (myoptind < argc) 102 | myoptarg = argv[myoptind]; 103 | 104 | return -1; 105 | } 106 | 107 | next = argv[myoptind]; 108 | next++; /* skip - */ 109 | myoptind++; 110 | } 111 | 112 | c = *next++; 113 | /* The C++ strchr can return a different value */ 114 | cp = (char*)XSTRCHR(optstring, c); 115 | 116 | if (cp == NULL || c == ':') 117 | return '?'; 118 | 119 | cp++; 120 | 121 | if (*cp == ':') { 122 | if (*next != '\0') { 123 | myoptarg = next; 124 | next = NULL; 125 | } 126 | else if (myoptind < argc) { 127 | myoptarg = argv[myoptind]; 128 | myoptind++; 129 | } 130 | else 131 | return '?'; 132 | } 133 | 134 | return c; 135 | } 136 | 137 | static INLINE int err_sys(const char* msg) 138 | { 139 | if (msg) { 140 | PRINTF("wolfMQTT error: %s", msg); 141 | } 142 | exit(EXIT_FAILURE); 143 | } 144 | 145 | #ifdef __cplusplus 146 | } /* extern "C" */ 147 | #endif 148 | 149 | #endif /* WOLFMQTT_EXAMPLE_H */ 150 | -------------------------------------------------------------------------------- /Lua/mqttnet.h: -------------------------------------------------------------------------------- 1 | /* mqttnet.h 2 | * 3 | * Copyright (C) 2006-2016 wolfSSL Inc. 4 | * 5 | * This file is part of wolfMQTT. 6 | * 7 | * wolfMQTT is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfMQTT is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | #ifndef WOLFMQTT_NET_H 23 | #define WOLFMQTT_NET_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | 30 | /* Default MQTT host broker to use, when none is specified */ 31 | #define DEFAULT_MQTT_HOST "82.196.4.208" // "loboris.eu" 32 | 33 | 34 | /* Functions used to handle the MqttNet structure creation / destruction */ 35 | int MqttClientNet_Init(MqttNet* net); 36 | int MqttClientNet_DeInit(MqttNet* net); 37 | 38 | #ifdef __cplusplus 39 | } /* extern "C" */ 40 | #endif 41 | 42 | #endif /* WOLFMQTT_NET_H */ 43 | -------------------------------------------------------------------------------- /Lua/sha1.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: sha1.h,v 1.5 2007/09/10 22:19:42 henric Exp $ */ 2 | 3 | /* 4 | * SHA-1 in C 5 | * By Steve Reid 6 | * 100% Public Domain 7 | */ 8 | 9 | #ifndef _SHA1_H_ 10 | #define _SHA1_H_ 11 | 12 | #define SHA1_BLOCK_LENGTH 64 13 | #define SHA1_DIGEST_LENGTH 20 14 | 15 | typedef struct { 16 | uint32_t state[5]; 17 | uint64_t count; 18 | unsigned char buffer[SHA1_BLOCK_LENGTH]; 19 | } SHA1_CTX; 20 | 21 | static void SHA1Init(SHA1_CTX * context); 22 | static void SHA1Transform(uint32_t state[5], const unsigned char buffer[SHA1_BLOCK_LENGTH]); 23 | static void SHA1Update(SHA1_CTX *context, const unsigned char *data, unsigned int len); 24 | static void SHA1Final(unsigned char digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context); 25 | 26 | #endif /* _SHA1_H_ */ 27 | -------------------------------------------------------------------------------- /Lua/sha2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILE: sha2.h 3 | * AUTHOR: Aaron D. Gifford 4 | * 5 | * Copyright (c) 2000-2001, Aaron D. Gifford 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. Neither the name of the copyright holder nor the names of contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | * 32 | * $From: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $ 33 | */ 34 | 35 | #ifndef _SHA2_H 36 | #define _SHA2_H 37 | 38 | //#include "attributes.h" 39 | 40 | /*** SHA-256/384/512 Various Length Definitions ***********************/ 41 | #define SHA256_BLOCK_LENGTH 64 42 | #define SHA256_DIGEST_LENGTH 32 43 | #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) 44 | #define SHA384_BLOCK_LENGTH 128 45 | #define SHA384_DIGEST_LENGTH 48 46 | #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) 47 | #define SHA512_BLOCK_LENGTH 128 48 | #define SHA512_DIGEST_LENGTH 64 49 | #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) 50 | 51 | 52 | /*** SHA-256/384/512 Context Structure *******************************/ 53 | typedef struct _SHA2_CTX { 54 | union { 55 | uint32_t st32[8]; 56 | uint64_t st64[8]; 57 | } state; 58 | uint64_t bitcount[2]; 59 | uint8_t buffer[SHA512_BLOCK_LENGTH]; 60 | } SHA2_CTX; 61 | 62 | static void SHA256Init(SHA2_CTX *); 63 | static void SHA256Update(SHA2_CTX *, const uint8_t *, size_t); 64 | static void SHA256Final(uint8_t[SHA256_DIGEST_LENGTH], SHA2_CTX *); 65 | 66 | static void SHA384Init(SHA2_CTX *); 67 | static void SHA384Update(SHA2_CTX *, const uint8_t *, size_t); 68 | static void SHA384Final(uint8_t[SHA384_DIGEST_LENGTH], SHA2_CTX *); 69 | 70 | static void SHA512Init(SHA2_CTX *); 71 | static void SHA512Update(SHA2_CTX *, const uint8_t *, size_t); 72 | static void SHA512Final(uint8_t[SHA512_DIGEST_LENGTH], SHA2_CTX *); 73 | 74 | #endif /* _SHA2_H */ 75 | -------------------------------------------------------------------------------- /Lua/sntp.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | int ntp_cb_ref; 5 | 6 | void sntp_gettime(int tz, uint8_t showlog); 7 | -------------------------------------------------------------------------------- /Lua/term.h: -------------------------------------------------------------------------------- 1 | // Terminal functions 2 | 3 | #ifndef __TERM_H__ 4 | #define __TERM_H__ 5 | 6 | #include "shell.h" 7 | 8 | // **************************************************************************** 9 | // Data types 10 | 11 | // Terminal input mode (parameter of term_in and term_getch()) 12 | #define TERM_INPUT_DONT_WAIT 0 13 | #define TERM_INPUT_WAIT 1 14 | #define TERM_TIMEOUT 120 15 | #define TERM_TIMEOUT_NOWAIT 0 16 | 17 | // Maximum size on an ANSI sequence 18 | #define TERM_MAX_ANSI_SIZE 14 19 | 20 | // **************************************************************************** 21 | // Exported functions 22 | 23 | unsigned term_num_lines; 24 | unsigned term_num_cols; 25 | unsigned term_cx; 26 | unsigned term_cy; 27 | int use_term_input; 28 | 29 | // Terminal output functions 30 | void term_curs(int ctype); 31 | void term_clrscr(void); 32 | void term_clreol(void); 33 | void term_gotoxy( unsigned x, unsigned y ); 34 | void term_up( unsigned delta ); 35 | void term_down( unsigned delta ); 36 | void term_left( unsigned delta ); 37 | void term_right( unsigned delta ); 38 | unsigned term_get_lines(void); 39 | unsigned term_get_cols(void); 40 | void term_putch( uint8_t ch ); 41 | void term_putstr( const char* str, unsigned size ); 42 | unsigned term_get_cx(void); 43 | unsigned term_get_cy(void); 44 | int term_getstr(char *buf, int maxlen); 45 | 46 | #define TERM_KEYCODES\ 47 | _D( KC_UP ),\ 48 | _D( KC_DOWN ),\ 49 | _D( KC_LEFT ),\ 50 | _D( KC_RIGHT ),\ 51 | _D( KC_HOME ),\ 52 | _D( KC_END ),\ 53 | _D( KC_PAGEUP ),\ 54 | _D( KC_PAGEDOWN ),\ 55 | _D( KC_ENTER ),\ 56 | _D( KC_TAB ),\ 57 | _D( KC_BACKSPACE ),\ 58 | _D( KC_ESC ),\ 59 | _D( KC_CTRL_Z ),\ 60 | _D( KC_CTRL_A ),\ 61 | _D( KC_CTRL_E ),\ 62 | _D( KC_CTRL_C ),\ 63 | _D( KC_CTRL_T ),\ 64 | _D( KC_CTRL_U ),\ 65 | _D( KC_CTRL_K ),\ 66 | _D( KC_CTRL_D ),\ 67 | _D( KC_CTRL_L ),\ 68 | _D( KC_DEL ),\ 69 | _D( KC_INS ),\ 70 | _D( KC_UNKNOWN ) 71 | 72 | // Terminal input functions 73 | // Keyboard codes 74 | #define _D( x ) x 75 | 76 | enum 77 | { 78 | term_dummy = 255, 79 | TERM_KEYCODES, 80 | TERM_FIRST_KEY = KC_UP, 81 | TERM_LAST_KEY = KC_UNKNOWN 82 | }; 83 | 84 | int term_getch( int mode ); 85 | 86 | #endif // #ifndef __TERM_H__ 87 | -------------------------------------------------------------------------------- /Lua/tjpgd.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------/ 2 | / TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2012 3 | /----------------------------------------------------------------------------*/ 4 | #ifndef _TJPGDEC 5 | #define _TJPGDEC 6 | /*---------------------------------------------------------------------------*/ 7 | /* System Configurations */ 8 | 9 | #define JD_SZBUF 512 /* Size of stream input buffer */ 10 | #define JD_FORMAT 1 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */ 11 | #define JD_USE_SCALE 1 /* Use descaling feature for output */ 12 | #define JD_TBLCLIP 0 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */ 13 | 14 | /*---------------------------------------------------------------------------*/ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "integer.h" 21 | 22 | 23 | /* Error code */ 24 | typedef enum { 25 | JDR_OK = 0, /* 0: Succeeded */ 26 | JDR_INTR, /* 1: Interrupted by output function */ 27 | JDR_INP, /* 2: Device error or wrong termination of input stream */ 28 | JDR_MEM1, /* 3: Insufficient memory pool for the image */ 29 | JDR_MEM2, /* 4: Insufficient stream input buffer */ 30 | JDR_PAR, /* 5: Parameter error */ 31 | JDR_FMT1, /* 6: Data format error (may be damaged data) */ 32 | JDR_FMT2, /* 7: Right format but not supported */ 33 | JDR_FMT3 /* 8: Not supported JPEG standard */ 34 | } JRESULT; 35 | 36 | 37 | 38 | /* Rectangular structure */ 39 | typedef struct { 40 | WORD left, right, top, bottom; 41 | } JRECT; 42 | 43 | 44 | 45 | /* Decompressor object structure */ 46 | typedef struct JDEC JDEC; 47 | struct JDEC { 48 | UINT dctr; /* Number of bytes available in the input buffer */ 49 | BYTE* dptr; /* Current data read ptr */ 50 | BYTE* inbuf; /* Bit stream input buffer */ 51 | BYTE dmsk; /* Current bit in the current read byte */ 52 | BYTE scale; /* Output scaling ratio */ 53 | BYTE msx, msy; /* MCU size in unit of block (width, height) */ 54 | BYTE qtid[3]; /* Quantization table ID of each component */ 55 | SHORT dcv[3]; /* Previous DC element of each component */ 56 | WORD nrst; /* Restart inverval */ 57 | UINT width, height; /* Size of the input image (pixel) */ 58 | BYTE* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ 59 | WORD* huffcode[2][2]; /* Huffman code word tables [id][dcac] */ 60 | BYTE* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ 61 | LONG* qttbl[4]; /* Dequaitizer tables [id] */ 62 | void* workbuf; /* Working buffer for IDCT and RGB output */ 63 | BYTE* mcubuf; /* Working buffer for the MCU */ 64 | void* pool; /* Pointer to available memory pool */ 65 | UINT sz_pool; /* Size of momory pool (bytes available) */ 66 | UINT (*infunc)(JDEC*, BYTE*, UINT);/* Pointer to jpeg stream input function */ 67 | void* device; /* Pointer to I/O device identifiler for the session */ 68 | }; 69 | 70 | 71 | 72 | /* TJpgDec API functions */ 73 | JRESULT jd_prepare (JDEC*, UINT(*)(JDEC*,BYTE*,UINT), void*, UINT, void*); 74 | JRESULT jd_decomp (JDEC*, UINT(*)(JDEC*,void*,JRECT*), BYTE); 75 | 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* _TJPGDEC */ 82 | -------------------------------------------------------------------------------- /Lua/version.h: -------------------------------------------------------------------------------- 1 | /* version.h.in 2 | * 3 | * Copyright (C) 2006-2016 wolfSSL Inc. 4 | * 5 | * This file is part of wolfMQTT. 6 | * 7 | * wolfMQTT is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfMQTT is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | 23 | /* 24 | * The version header provides the current version number to the code 25 | * based and is updated automatically by the configure script. A copy 26 | * of the last generated copy of version.h is included with the 27 | * distribution for environments that do not use configure. 28 | */ 29 | 30 | 31 | #pragma once 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #define LIBWOLFMQTT_VERSION_STRING "0.6" 38 | #define LIBWOLFMQTT_VERSION_HEX 0x00006000 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /Lua/visibility.h: -------------------------------------------------------------------------------- 1 | /* visibility.h 2 | * 3 | * Copyright (C) 2006-2016 wolfSSL Inc. 4 | * 5 | * This file is part of wolfMQTT. 6 | * 7 | * wolfMQTT is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfMQTT is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | /* Visibility control macros */ 23 | 24 | #ifndef WOLFMQTT_VISIBILITY_H 25 | #define WOLFMQTT_VISIBILITY_H 26 | 27 | /* WOLFMQTT_API is used for the public API symbols. 28 | It either imports or exports (or does nothing for static builds) 29 | 30 | WOLFMQTT_LOCAL is used for non-API symbols (private). 31 | */ 32 | 33 | #if defined(BUILDING_WOLFMQTT) 34 | #if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY 35 | #define WOLFMQTT_API __attribute__ ((visibility("default"))) 36 | #define WOLFMQTT_LOCAL __attribute__ ((visibility("hidden"))) 37 | #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) 38 | #define WOLFMQTT_API __global 39 | #define WOLFMQTT_LOCAL __hidden 40 | #elif defined(_MSC_VER) 41 | #ifdef _WINDLL 42 | #define WOLFMQTT_API __declspec(dllexport) 43 | #else 44 | #define WOLFMQTT_API 45 | #endif 46 | #define WOLFMQTT_LOCAL 47 | #else 48 | #define WOLFMQTT_API 49 | #define WOLFMQTT_LOCAL 50 | #endif /* HAVE_VISIBILITY */ 51 | #else /* BUILDING_WOLFMQTT */ 52 | #if defined(_MSC_VER) 53 | #define WOLFMQTT_API __declspec(dllimport) 54 | #define WOLFMQTT_LOCAL 55 | #else 56 | #define WOLFMQTT_API 57 | #define WOLFMQTT_LOCAL 58 | #endif 59 | #endif /* BUILDING_WOLFMQTT */ 60 | 61 | #endif /* WOLFMQTT_VISIBILITY_H */ 62 | -------------------------------------------------------------------------------- /Lua_Examples/@font/BigFont.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/BigFont.fon -------------------------------------------------------------------------------- /Lua_Examples/@font/DejaVuSans12.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/DejaVuSans12.fon -------------------------------------------------------------------------------- /Lua_Examples/@font/DejaVuSans18.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/DejaVuSans18.fon -------------------------------------------------------------------------------- /Lua_Examples/@font/DejaVuSans24.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/DejaVuSans24.fon -------------------------------------------------------------------------------- /Lua_Examples/@font/DotMatrix_M.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/DotMatrix_M.fon -------------------------------------------------------------------------------- /Lua_Examples/@font/Grotesk24x48.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/Grotesk24x48.fon -------------------------------------------------------------------------------- /Lua_Examples/@font/SmallFont.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/SmallFont.fon -------------------------------------------------------------------------------- /Lua_Examples/@font/Ubuntu.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/Ubuntu.fon -------------------------------------------------------------------------------- /Lua_Examples/@font/arial_bold.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/arial_bold.fon -------------------------------------------------------------------------------- /Lua_Examples/@font/swiss721_outline.fon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/Lua_Examples/@font/swiss721_outline.fon -------------------------------------------------------------------------------- /Lua_Examples/https-test-block.lua: -------------------------------------------------------------------------------- 1 | -- no response cb function should be registered 2 | https.on("response") 3 | 4 | print("Http GET request 1") 5 | print(https.get("http://api.thingspeak.com/update?key=xxx&field1=8.0")) 6 | 7 | print("Http GET request 2") 8 | print(https.get("http://api.thingspeak.com/update?key=xxx&field1=9.0")) 9 | 10 | print("Http GET request 3") 11 | print(https.get("http://api.thingspeak.com/update?key=xxx&field1=10.0")) 12 | 13 | -------------------------------------------------------------------------------- /Lua_Examples/https-test-noblock.lua: -------------------------------------------------------------------------------- 1 | function dummy_h(hdr) 2 | print("HTTPS header") 3 | end 4 | 5 | https.on("header", dummy_h) 6 | 7 | function dummy_r(state, data, len, more) 8 | print("HTTPS response: "..state) 9 | end 10 | 11 | https.on("response", dummy_r) 12 | 13 | url_idx = 1 14 | 15 | my_urls = { 16 | "http://api.thingspeak.com/update?key=xxx&field1=8.0", 17 | "http://api.thingspeak.com/update?key=xxx&field1=9.0", 18 | "http://api.thingspeak.com/update?key=xxx&field1=10.0" 19 | } 20 | 21 | -- use timer cb function to initiate new request 22 | function tmr_cb(ht) 23 | if (url_idx <= 3) and (https.getstate() == 0) then 24 | print("Http GET request "..url_idx) 25 | print(https.get(my_urls[url_idx])) 26 | url_idx = url_idx + 1 27 | end 28 | end 29 | 30 | -- create and start timer 31 | https_tmr = timer.create(500, tmr_cb) 32 | 33 | -------------------------------------------------------------------------------- /Lua_Examples/init.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | init.lua runs on system startup before Lua shell is executed 3 | --]] 4 | 5 | -- === SET YOUR CORRECT APN FOR GPRS OPERATIONS === 6 | net.setapn({apn="my.apn"}) 7 | -- ================================================ 8 | 9 | -- === CHANGE THIS TO YOUR GSM NUMBER !! === 10 | smsnum = "123456789" 11 | -- ========================================= 12 | 13 | -- === Set you time zone (offset from GMT) === 14 | tmzn = 2 15 | -- =========================================== 16 | 17 | 18 | --[[ SNTP callback ------------------------------------- 19 | We will execute GSM related function in sntp callcack 20 | to allow the module to attach to network and be ready 21 | for sms operations 22 | --]] 23 | function sntp_cb(stat) 24 | print() 25 | print("==================================================") 26 | if stat ~= 0 then 27 | print("SNTP error\nCheck if your APN is set") 28 | else 29 | print("Time set from NTP server: "..os.date()) 30 | end 31 | print("==================================================") 32 | 33 | if sim_stat == 1 then 34 | -- Check total number of messages 35 | print("SIM card inserted, IMEI="..imei) 36 | local nsms = sms.numrec() 37 | print("You have "..nsms.." messages") 38 | if nsms > 0 then 39 | -- get list of unread messages 40 | local smsidx = sms.list(1) 41 | local smsfrom, smstime, smsmsg 42 | print("Unread messages: "..#smsidx) 43 | if #smsidx > 0 then 44 | print("Reading 1st message:") 45 | smsfrom, smstime, smsmsg = sms.read(smsidx[1]) 46 | print("----------") 47 | print("sms from: "..smsfrom) 48 | print("received: "..smstime) 49 | print("----------") 50 | print(smsmsg) 51 | print("----------") 52 | print() 53 | end 54 | end 55 | 56 | -- Send message 57 | print("Sending sms to "..smsnum.." ...") 58 | local smsres = sms.send(smsnum, "Hello from Rephone") 59 | if smsres ~= 1 then 60 | print("SMS send failed") 61 | else 62 | print("SMS sent") 63 | end 64 | else 65 | print("SIM card not inserted, or not working!") 66 | end 67 | -- enable all debug messages 68 | sys.showlog(LOG_ALL) 69 | end 70 | -- ---------------------------------------------------- 71 | 72 | print('=====================================================') 73 | print('Hello, this is Lua running on Xadow GSM+BLE (RePhone)') 74 | print('=====================================================') 75 | print() 76 | 77 | -- disable debug messages 78 | sys.showlog(LOG_NONE) 79 | 80 | -- Get system status 81 | sim_stat,imei,_ = sms.siminfo() 82 | tm = os.date("*t") 83 | version,_,_ = sys.ver() 84 | memused, memtot, heap = sys.mem() 85 | 86 | res = gpio.adc_config(0) 87 | if res == 0 then 88 | vbat = gpio.adc_start(0) 89 | vstr = string.format("%1.3f V", vbat) 90 | else 91 | vstr = "adc error" 92 | end 93 | 94 | if tm["year"] < 2016 then 95 | print("Your RTC time is set in the past !\nYou can use ntptime function to set the correct time.\n") 96 | else 97 | print("Current time is: "..tm.year.."/"..tm.month.."/"..tm.day.." "..tm.hour..":"..tm.min..":"..tm.sec) 98 | -- or you can directly format in os.date function 99 | -- print(os.date("Current time is %Y/%m/%d %H:%M:%S")) 100 | end 101 | 102 | print() 103 | print("Status:") 104 | print(" Lua version: "..version) 105 | print(" Used memory: "..memused) 106 | print(" Total memory: "..memtot) 107 | print(" C heap memory: "..heap) 108 | print("Battery voltage: "..vstr) 109 | print() 110 | print("After sntp result is ready, the rest of the code will be executed.") 111 | print() 112 | 113 | -- request time from ntp server 114 | net.ntptime(tmzn, sntp_cb) 115 | -------------------------------------------------------------------------------- /Lua_Examples/tpcalib.lua: -------------------------------------------------------------------------------- 1 | -- Touch pannel calibration for ILI9341 based displays 2 | 3 | if dispType == nil then 4 | dispType = lcd.ILI9341 5 | end 6 | 7 | -- === SELECT THE RIGHT CS&DC !! === 8 | lcd_OK = spi.setup({speed=10000, cs=1, dc=3}) 9 | if lcd_OK ~= 0 then 10 | print("SPI not initialized") 11 | return 12 | end 13 | 14 | lcd.init(dispType,lcd.LANDSCAPE) 15 | if lcd.gettype() < 0 then 16 | print("LCD not initialized") 17 | return 18 | end 19 | 20 | -- === SELECT THE RIGHT tp CS !! === 21 | lcd.set_touch_cs(2) 22 | 23 | local dispx, dispy 24 | dispx = 320 25 | dispy = 240 26 | 27 | local rx = {} 28 | local ry = {} 29 | 30 | -- ------------------------------------ 31 | local function drawCrossHair(x, y, clr) 32 | lcd.rect(x-10, y-10, 20, 20, clr) 33 | lcd.line(x-5, y, x+5, y, clr) 34 | lcd.line(x, y-5, x, y+5, clr) 35 | end 36 | 37 | -- ------------------------------ 38 | local function readCoordinates() 39 | local x = 0 40 | local y = 0 41 | local touch 42 | local sx = 0 43 | local sy = 0 44 | local n = 0 45 | 46 | lcd.setcolor(lcd.CYAN) 47 | 48 | while n < 8 do 49 | lcd.write(lcd.CENTER, 110, " PRESS ") 50 | -- wait for touch 51 | touch, x, y = lcd.getrawtouch() 52 | while touch <= 0 do 53 | touch, x, y = lcd.getrawtouch() 54 | end 55 | -- wait for release 56 | while touch > 0 do 57 | if n == 8 then 58 | lcd.write(lcd.CENTER, 110, "RELEASE") 59 | end 60 | touch, x, y = lcd.getrawtouch() 61 | if (touch > 0) and (n < 256) then 62 | sx = sx + x 63 | sy = sy + y 64 | n = n + 1 65 | end 66 | end 67 | end 68 | 69 | return (sx / n), (sy / n) 70 | end 71 | 72 | -- ------------------------------ 73 | local function calibrate(x, y, i) 74 | drawCrossHair(x,y, lcd.YELLOW) 75 | rx[i], ry[i] = readCoordinates() 76 | drawCrossHair(x,y,lcd.GREEN) 77 | end 78 | 79 | -- --------------------- 80 | local function tpcalib() 81 | local px,py,clx,crx,cty,cby,calx,caly 82 | 83 | lcd.setfont(lcd.FONT_DEFAULT) 84 | lcd.setfixed(0) 85 | lcd.setrot(0) 86 | lcd.write(lcd.CENTER,40,"Touch yellow point and release") 87 | lcd.write(lcd.CENTER,60,"Repeat for all 8 calibration points") 88 | 89 | lcd.setfixed(1) 90 | drawCrossHair(dispx-11, 10, lcd.WHITE) 91 | drawCrossHair(dispx/2, 10, lcd.WHITE) 92 | drawCrossHair(10, 10, lcd.WHITE) 93 | drawCrossHair(dispx-11, dispy/2, lcd.WHITE) 94 | drawCrossHair(10, dispy/2, lcd.WHITE) 95 | drawCrossHair(dispx-11, dispy-11, lcd.WHITE) 96 | drawCrossHair(dispx/2, dispy-11, lcd.WHITE) 97 | drawCrossHair(10, dispy-11, lcd.WHITE) 98 | 99 | calibrate(10, 10, 1) 100 | calibrate(10, dispy/2, 2) 101 | calibrate(10, dispy-11, 3) 102 | calibrate(dispx/2, 10, 4) 103 | calibrate(dispx/2, dispy-11, 5) 104 | calibrate(dispx-11, 10, 6) 105 | calibrate(dispx-11, dispy/2, 7) 106 | calibrate(dispx-11, dispy-11, 8) 107 | 108 | px = math.abs((((rx[4]+rx[5]+rx[8]) / 3) - ((rx[1]+rx[1]+rx[3]) / 3)) / (dispy-20)) -- LANDSCAPE 109 | clx = (((rx[1]+rx[2]+rx[3])/3)) -- LANDSCAPE 110 | crx = (((rx[6]+rx[7]+rx[8])/3)) -- LANDSCAPE 111 | 112 | if (clx < crx) then 113 | clx = clx - (px*10) 114 | crx = crx + (px*10) 115 | else 116 | clx = clx + (px*10) 117 | crx = crx - (px*10) 118 | end 119 | 120 | py = math.abs((((ry[1]+ry[4]+ry[6])/3) - ((ry[3]+ry[5]+ry[8])/3))/(dispx-20)) -- LANDSCAPE 121 | cty = (((ry[1]+ry[4]+ry[6])/3)) -- LANDSCAPE 122 | cby = (((ry[3]+ry[5]+ry[8])/3)) -- LANDSCAPE 123 | 124 | if (cty < cby) then 125 | cty = cty - (py*10) 126 | cby = cby + (py*10) 127 | else 128 | cty = cty + (py*10) 129 | cby = cby - (py*10) 130 | end 131 | 132 | calx = (math.ceil(clx) * 65536) + math.ceil(crx) 133 | caly = (math.ceil(cty) * 65536) + math.ceil(cby) 134 | 135 | lcd.setcal(calx, caly) 136 | __SYSPAR.calx = calx 137 | __SYSPAR.caly = caly 138 | local res sys.save_params() 139 | 140 | lcd.clear(0) 141 | lcd.write(lcd.CENTER,40,"Calibration completed") 142 | lcd.write(lcd.CENTER,60,"and saved to system parameters") 143 | print("Calibration completed and saved to system parameters") 144 | end 145 | 146 | -- run calibration function 147 | tpcalib() 148 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RePhone development on Linux 2 | 3 | This repository contains RePhone application projects configured for Eclipse. 4 | The main purpose of this repository is Lua implementation on RePhone (Xadow GSM+BLE). 5 | 6 | ### Guide for installation/configuration on Linux 7 | [RePhone on Linux guide](https://github.com/loboris/RePhone_on_Linux/raw/master/Documents/RePhone%20on%20Linux.pdf)
8 | 9 | ### Links: 10 | * [RePhone wiki](http://www.seeedstudio.com/wiki/Rephone) 11 | * [RePhone Forum](http://www.seeedstudio.com/forum/viewforum.php?f=71) 12 | * [LinkitAssist 2502 Forum](http://labs.mediatek.com/forums/forums/show/58.page) 13 | * [Xadow GSM+BLE](http://www.seeedstudio.com/wiki/Xadow_GSM%2BBLE) 14 | * [Linkit Assist SDK](http://download.labs.mediatek.com/MediaTek_LinkIt_Assist_2502_SDK_2_0_46.zip) 15 | * [Eclipse](https://www.eclipse.org/downloads/) 16 | 17 | # 🔹 Lua on RePhone 🔹 18 | 19 | Lua programming language implementation on RePhone (Xadow GSM+BLE). 20 | 21 | "Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description. 22 | 23 | Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. 24 | Lua is dynamically typed, runs by interpreting bytecode with a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping" 25 | 26 | This implementation is specially oriented to IoT applications building. 27 | 28 | 29 | #### Main features: 30 | 31 | * Complete Lua 5.1 implementation 32 | * Memory available to Lua programs 650~700 KB + heap for c functions ~64 KB 33 | * os module expanded with many new functions ( copy, mkdir, rmdir, list, compile ) 34 | * sys module added with many RePhone related functions, non-volatile system parameters & variables 35 | * Watchdog implemented for maximum security with variable timeout. 36 | * Full RTC support with scheduled shut down / wake up / alarm 37 | * Lua shell is available on USB port (/dev/ttyACM0), on RePhone hardware UART and over Bluetooth 38 | * Many new/RePhone specific modules (written in c) 39 | * gpio, with added fonctions for gpio toggle and EINT on any eint capable pin 40 | * pwm module (part of gpio module) 41 | * adc module (part of gpio module) 42 | * eint external interrupt; Lua callback function (part of gpio module) 43 | * wt2812 module; WT2812 - NeoPixel support (part of gpio module) 44 | * https, with added post mode (capable of sending file or params from table) 45 | * gsm module, with complete SMS functionality (read,write,list,delete,callbacks,...) 46 | * mqtt module, complete mqtt client 47 | * email module, only smtp client for now (send email) 48 | * ftp module, all basic ftp client commands available 49 | * audio module, playback and recording 50 | * timer module 51 | * i2c hw i2c module 52 | * spi hw spi module 53 | * net module, tcp & udp support, ntp support (set RTC time from NTP server) 54 | * bt Bluetooth module with possible Lua shell redirect 55 | * uart Hardware UART (two ports) module with possible Lua shell redirect 56 | * sensor module: DS18B20, DS18S20, DS1822 and DS28EA00, DHT-11, DHT-22, BME280 sensors 57 | * hash modules: md5, SHA1, SHA2 58 | * complete json module (cjson) 59 | * struct module (python struct library Lua implementation) 60 | * bit module, adds bitwise operations on numbers 61 | * lcd module; full support for Xadow 1.54" Touchscreen V0/V1 (with touch support) and ILI9341 & ST7735 based TFT modules in 4-wire SPI mode. Supported are many graphics elements, fixed width and proportional fonts (unlimited number of fonts, loaded from file), jpeg, bmp and raw bitmap images. Does not require frame buffer memory, very fast. 62 | * term module; operations for ansi/vt100 terminals; console file editior, ymodem file transfer 63 | -------------------------------------------------------------------------------- /common/.gitignore: -------------------------------------------------------------------------------- 1 | test/** 2 | -------------------------------------------------------------------------------- /common/CheckSumUtils.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file CheckSumUtils.c 4 | * @author William Xu 5 | * @version V1.0.0 6 | * @date 30-July-2015 7 | * @brief This file contains function that aid in checksum calculations. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, MXCHIP Inc. SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2014 MXCHIP Inc.

19 | ****************************************************************************** 20 | */ 21 | 22 | #include "CheckSumUtils.h" 23 | 24 | const unsigned char CRC8Table[]={ 25 | 0, 94, 188, 226, 97, 63, 221, 131, 194, 156, 126, 32, 163, 253, 31, 65, 26 | 157, 195, 33, 127, 252, 162, 64, 30, 95, 1, 227, 189, 62, 96, 130, 220, 27 | 35, 125, 159, 193, 66, 28, 254, 160, 225, 191, 93, 3, 128, 222, 60, 98, 28 | 190, 224, 2, 92, 223, 129, 99, 61, 124, 34, 192, 158, 29, 67, 161, 255, 29 | 70, 24, 250, 164, 39, 121, 155, 197, 132, 218, 56, 102, 229, 187, 89, 7, 30 | 219, 133, 103, 57, 186, 228, 6, 88, 25, 71, 165, 251, 120, 38, 196, 154, 31 | 101, 59, 217, 135, 4, 90, 184, 230, 167, 249, 27, 69, 198, 152, 122, 36, 32 | 248, 166, 68, 26, 153, 199, 37, 123, 58, 100, 134, 216, 91, 5, 231, 185, 33 | 140, 210, 48, 110, 237, 179, 81, 15, 78, 16, 242, 172, 47, 113, 147, 205, 34 | 17, 79, 173, 243, 112, 46, 204, 146, 211, 141, 111, 49, 178, 236, 14, 80, 35 | 175, 241, 19, 77, 206, 144, 114, 44, 109, 51, 209, 143, 12, 82, 176, 238, 36 | 50, 108, 142, 208, 83, 13, 239, 177, 240, 174, 76, 18, 145, 207, 45, 115, 37 | 202, 148, 118, 40, 171, 245, 23, 73, 8, 86, 180, 234, 105, 55, 213, 139, 38 | 87, 9, 235, 181, 54, 104, 138, 212, 149, 203, 41, 119, 244, 170, 72, 22, 39 | 233, 183, 85, 11, 136, 214, 52, 106, 43, 117, 151, 201, 74, 20, 246, 168, 40 | 116, 42, 200, 150, 21, 75, 169, 247, 182, 232, 10, 84, 215, 137, 107, 53 41 | }; 42 | 43 | uint8_t CRC8_Table(uint8_t crc8_ori, uint8_t *p, uint32_t counter) 44 | { 45 | uint8_t crc8 = crc8_ori; 46 | for( ; counter > 0; counter--){ 47 | crc8 = CRC8Table[crc8^*p]; 48 | p++; 49 | } 50 | return(crc8); 51 | } 52 | 53 | /** 54 | * @brief Update CRC16 for input byte 55 | * @param CRC input value 56 | * @param input byte 57 | * @retval None 58 | */ 59 | uint16_t UpdateCRC16(uint16_t crcIn, uint8_t byte) 60 | { 61 | uint32_t crc = crcIn; 62 | uint32_t in = byte | 0x100; 63 | 64 | do 65 | { 66 | crc <<= 1; 67 | in <<= 1; 68 | if(in & 0x100) 69 | ++crc; 70 | if(crc & 0x10000) 71 | crc ^= 0x1021; 72 | } 73 | 74 | while(!(in & 0x10000)); 75 | 76 | return crc & 0xffffu; 77 | } 78 | 79 | void CRC16_Init( CRC16_Context *inContext ) 80 | { 81 | inContext->crc = 0; 82 | } 83 | 84 | void CRC16_Update( CRC16_Context *inContext, const void *inSrc, int inLen ) 85 | { 86 | const uint8_t * src = (const uint8_t *) inSrc; 87 | const uint8_t* srcEnd = src + inLen; 88 | while( src < srcEnd ) 89 | inContext->crc = UpdateCRC16(inContext->crc, *src++); 90 | } 91 | 92 | void CRC16_Final( CRC16_Context *inContext, uint16_t *outResult ) 93 | { 94 | inContext->crc = UpdateCRC16(inContext->crc, 0); 95 | inContext->crc = UpdateCRC16(inContext->crc, 0); 96 | 97 | *outResult = inContext->crc&0xffffu; 98 | } 99 | -------------------------------------------------------------------------------- /common/CheckSumUtils.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file CheckSumUtils.h 4 | * @author William Xu 5 | * @version V1.0.0 6 | * @date 05-May-2014 7 | * @brief This header contains function prototypes which aid in checksum calculations. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, MXCHIP Inc. SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2014 MXCHIP Inc.

19 | ****************************************************************************** 20 | */ 21 | 22 | 23 | #ifndef __CheckSumUtils_h__ 24 | #define __CheckSumUtils_h__ 25 | 26 | #include 27 | 28 | typedef struct 29 | { 30 | uint16_t crc; 31 | } CRC16_Context; 32 | 33 | void CRC16_Init( CRC16_Context *inContext ); 34 | 35 | void CRC16_Update( CRC16_Context *inContext, const void *inSrc, int inLen ); 36 | 37 | void CRC16_Final( CRC16_Context *inContext, uint16_t *outResult ); 38 | 39 | uint8_t mico_CRC8_Table(uint8_t crc8_ori, uint8_t *p, uint32_t counter); 40 | 41 | 42 | 43 | #endif //__CheckSumUtils_h__ 44 | 45 | 46 | -------------------------------------------------------------------------------- /common/tp_i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef __TP_I2C_H__ 2 | #define __TP_I2C_H__ 3 | 4 | #include "vmtype.h" 5 | #include "vmdrv_tp.h" 6 | 7 | #define CTP_I2C_LOW 0 8 | #define CTP_I2C_HIGH 1 9 | #define CTP_I2C_ACK CTP_I2C_LOW 10 | #define CTP_I2C_NAK CTP_I2C_HIGH 11 | 12 | //delay 13 | //void ctp_i2c_udelay(VMUINT32 delay); 14 | 15 | //power on I2C 16 | //void ctp_i2c_power_on(VM_DRV_TP_BOOL ON, VMUINT32 ldo, VMUINT32 ldo_volt); 17 | 18 | //configure SW I2C or HW I2C parameters 19 | int ctp_i2c_configure(VMUINT32 slave_addr, VMUINT32 speed); 20 | 21 | // Start bit of I2C waveform 22 | //extern void ctp_i2c_start(void); 23 | 24 | // Stop bit of I2C waveform 25 | //extern void ctp_i2c_stop(void); 26 | 27 | // Send one byte from host to client 28 | //extern VM_DRV_TP_BOOL ctp_i2c_send_byte(VMUINT8 ucData); 29 | 30 | // Receive one byte form client to host 31 | //extern VMUINT8 ctp_i2c_receive_byte(VM_DRV_TP_BOOL bAck); 32 | 33 | // I2C send data fuction 34 | extern VM_DRV_TP_BOOL ctp_i2c_send(VMUINT8 ucDeviceAddr, VMUINT8 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 35 | 36 | // I2C receive data function 37 | extern VM_DRV_TP_BOOL ctp_i2c_receive(VMUINT8 ucDeviceAddr, VMUINT8 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 38 | 39 | // I2C send data for 16 bits address fuction 40 | extern VM_DRV_TP_BOOL ctp_i2c_send_ext(VMUINT8 ucDeviceAddr, VMUINT16 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 41 | 42 | // I2C receive data for 16 bits address function 43 | extern VM_DRV_TP_BOOL ctp_i2c_receive_ext(VMUINT8 ucDeviceAddr, VMUINT16 ucBufferIndex, VMUINT8* pucData, VMUINT32 unDataLength); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /common/ymodem.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __YMODEM_H__ 3 | #define __YMODEM_H__ 4 | 5 | // Y-MODEM defines 6 | #define PACKET_SEQNO_INDEX (1) 7 | #define PACKET_SEQNO_COMP_INDEX (2) 8 | 9 | #define PACKET_HEADER (3) 10 | #define PACKET_TRAILER (2) 11 | #define PACKET_OVERHEAD (PACKET_HEADER + PACKET_TRAILER) 12 | #define PACKET_SIZE (128) 13 | #define PACKET_1K_SIZE (1024) 14 | 15 | #define FILE_SIZE_LENGTH (16) 16 | 17 | #define SOH (0x01) /* start of 128-byte data packet */ 18 | #define STX (0x02) /* start of 1024-byte data packet */ 19 | #define EOT (0x04) /* end of transmission */ 20 | #define ACK (0x06) /* acknowledge */ 21 | #define NAK (0x15) /* negative acknowledge */ 22 | #define CA (0x18) /* two of these in succession aborts transfer */ 23 | #define CRC16 (0x43) /* 'C' == 0x43, request 16-bit CRC */ 24 | 25 | #define ABORT1 (0x41) /* 'A' == 0x41, abort by user */ 26 | #define ABORT2 (0x61) /* 'a' == 0x61, abort by user */ 27 | 28 | #define NAK_TIMEOUT (1000) 29 | #define MAX_ERRORS (45) 30 | 31 | int Ymodem_Receive ( char* FileName, unsigned int maxsize, unsigned char getname ); 32 | char Ymodem_Transmit (const char* sendFileName, unsigned int sizeFile, int ffd); 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/ts_drv_comm.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __TS_DRV_COMM_H__ 4 | #define __TS_DRV_COMM_H__ 5 | 6 | //#include"kal_release.h" 7 | 8 | #define DRV_WriteReg(addr,data) ((*(volatile kal_uint16 *)(addr)) = (kal_uint16)(data)) 9 | #define DRV_Reg(addr) (*(volatile kal_uint16 *)(addr)) 10 | #define DRV_WriteReg32(addr,data) ((*(volatile kal_uint32 *)(addr)) = (kal_uint32)(data)) 11 | #define DRV_Reg32(addr) (*(volatile kal_uint32 *)(addr)) 12 | #define DRV_WriteReg8(addr,data) ((*(volatile kal_uint8 *)(addr)) = (kal_uint8)(data)) 13 | #define DRV_Reg8(addr) (*(volatile kal_uint8 *)(addr)) 14 | 15 | #define DRV_ClearBits(addr,data) {\ 16 | kal_uint16 temp;\ 17 | temp = DRV_Reg(addr);\ 18 | temp &=~(data);\ 19 | DRV_WriteReg(addr,temp);\ 20 | } 21 | 22 | #define DRV_SetBits(addr,data) {\ 23 | kal_uint16 temp;\ 24 | temp = DRV_Reg(addr);\ 25 | temp |= (data);\ 26 | DRV_WriteReg(addr,temp);\ 27 | } 28 | 29 | #define DRV_SetData(addr, bitmask, value) {\ 30 | kal_uint16 temp;\ 31 | temp = (~(bitmask)) & DRV_Reg(addr);\ 32 | temp |= ((value) & (bitmask));\ 33 | DRV_WriteReg(addr,temp);\ 34 | } 35 | 36 | #define DRV_ClearBits32(addr,data) {\ 37 | kal_uint32 temp;\ 38 | temp = DRV_Reg32(addr);\ 39 | temp &=~(data);\ 40 | DRV_WriteReg32(addr,temp);\ 41 | } 42 | 43 | #define DRV_SetBits32(addr,data) {\ 44 | kal_uint32 temp;\ 45 | temp = DRV_Reg32(addr);\ 46 | temp |= (data);\ 47 | DRV_WriteReg32(addr,temp);\ 48 | } 49 | 50 | #define DRV_SetData32(addr, bitmask, value) {\ 51 | kal_uint32 temp;\ 52 | temp = (~(bitmask)) & DRV_Reg32(addr);\ 53 | temp |= ((value) & (bitmask));\ 54 | DRV_WriteReg32(addr,temp);\ 55 | } 56 | 57 | #define DRV_ClearBits8(addr,data) {\ 58 | kal_uint8 temp;\ 59 | temp = DRV_Reg8(addr);\ 60 | temp &=~(data);\ 61 | DRV_WriteReg8(addr,temp);\ 62 | } 63 | 64 | #define DRV_SetBits8(addr,data) {\ 65 | kal_uint8 temp;\ 66 | temp = DRV_Reg8(addr);\ 67 | temp |= (data);\ 68 | DRV_WriteReg8(addr,temp);\ 69 | } 70 | 71 | #define DRV_SetData8(addr, bitmask, value) {\ 72 | kal_uint8 temp;\ 73 | temp = (~(bitmask)) & DRV_Reg8(addr);\ 74 | temp |= ((value) & (bitmask));\ 75 | DRV_WriteReg8(addr,temp);\ 76 | } 77 | 78 | 79 | #ifdef __cplusplus 80 | extern "C" 81 | { 82 | #endif 83 | 84 | //extern kal_uint32 SaveAndSetIRQMask(void); 85 | //extern void RestoreIRQMask(kal_uint32); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | 92 | 93 | #ifdef DRV_DEBUG 94 | extern void dbg_print(char *fmt,...); 95 | extern void dbg_printWithTime(char *fmt,...); 96 | #endif /*DRV_DEBUG*/ 97 | 98 | 99 | 100 | // MoDIS parser skip end 101 | #endif /*__DRV_COMM_H__*/ 102 | 103 | -------------------------------------------------------------------------------- /include/vmalarm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of MediaTek Inc. (C) 2005-2015 8 | * 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. 21 | * 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 27 | * 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). 33 | * 34 | *****************************************************************************/ 35 | 36 | #ifndef VMALARM_SDK_H_ 37 | #define VMALARM_SDK_H_ 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #include "vmsys.h" 44 | 45 | 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* VMALARM_SDK_H_ */ 52 | -------------------------------------------------------------------------------- /include/vmboard.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of MediaTek Inc. (C) 2005-2015 8 | * 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. 21 | * 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 27 | * 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). 33 | * 34 | *****************************************************************************/ 35 | 36 | #ifndef _VMBOARD_SDK_H 37 | #define _VMBOARD_SDK_H 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #include "vmtype.h" 44 | 45 | /* pin mux mode */ 46 | 47 | typedef enum 48 | { 49 | VM_DCL_PIN_MODE_GPIO = 1, // gpio mode 50 | VM_DCL_PIN_MODE_ADC, // adc mode 51 | VM_DCL_PIN_MODE_PWM, // pwm mode 52 | VM_DCL_PIN_MODE_UART, // uart mode 53 | VM_DCL_PIN_MODE_EINT, // eint mode 54 | VM_DCL_PIN_MODE_SPI, // spi mode 55 | VM_DCL_PIN_MODE_I2C, // i2c mode 56 | VM_DCL_PIN_MODE_SDIO, // sdio mode 57 | VM_DCL_PIN_MODE_DBI_C, // dbi mode 58 | } VM_DCL_PIN_MODE; 59 | 60 | #define VM_PIN_P0 3 61 | #define VM_PIN_P1 27 62 | #define VM_PIN_P2 28 63 | #define VM_PIN_P3 29 64 | #define VM_PIN_P4 19 65 | #define VM_PIN_P5 43 66 | #define VM_PIN_P6 44 67 | #define VM_PIN_P7 10 68 | #define VM_PIN_P8 11 69 | #define VM_PIN_P9 1 70 | #define VM_PIN_P10 2 71 | #define VM_PIN_P11 25 72 | #define VM_PIN_P12 17 73 | #define VM_PIN_P13 15 74 | #define VM_PIN_P14 12 75 | #define VM_PIN_P15 13 76 | #define VM_PIN_P16 18 77 | #define VM_PIN_P17 47 78 | #define VM_PIN_P18 48 79 | #define VM_PIN_P19 49 80 | #define VM_PIN_P20 50 81 | #define VM_PIN_P21 46 82 | #define VM_PIN_P22 30 83 | #define VM_PIN_P23 38 84 | #define VM_PIN_P24 39 85 | #define VM_PIN_P25 52 86 | 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* _VMBOARD_SDK_H */ 93 | 94 | -------------------------------------------------------------------------------- /include/vmgsm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of MediaTek Inc. (C) 2005 8 | * 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. 21 | * 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 27 | * 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). 33 | * 34 | *****************************************************************************/ 35 | 36 | #ifndef VMGSM_SDK_H 37 | #define VMGSM_SDK_H 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #include "vmtype.h" 44 | 45 | typedef void (*vm_gsm_switch_mode_callback_t)(VMBOOL switched_successfully); 46 | 47 | /***************************************************************************** 48 | * FUNCTION 49 | * vm_gsm_switch_mode 50 | * DESCRIPTION 51 | * Switch the GSM on or off. 52 | * PARAMETERS 53 | * on: [IN] Switch on or not. 54 | * callback: [IN] Callback funtion when switching finished. 55 | * RETURNS 56 | * If return VM_FALSE means the mode is switching, please try again later. 57 | *****************************************************************************/ 58 | extern VMBOOL vm_gsm_switch_mode(VMBOOL on, vm_gsm_switch_mode_callback_t callback); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /* VMGSM_SDK_H */ 65 | -------------------------------------------------------------------------------- /include/vmusb.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of MediaTek Inc. (C) 2005-2015 8 | * 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. 21 | * 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 27 | * 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). 33 | * 34 | *****************************************************************************/ 35 | 36 | #ifndef VMUSB_SDK_H 37 | #define VMUSB_SDK_H 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #include "vmtype.h" 44 | 45 | /* The USB cable status. */ 46 | typedef enum 47 | { 48 | VM_USB_CABLE_PLUG_IN, /* The USB cable is in plug-in status. */ 49 | VM_USB_CABLE_PLUG_OUT, /* The USB cable is in plug-out status. */ 50 | } VM_USB_CABLE_STATUS; 51 | 52 | 53 | /******************************************************************************* 54 | * FUNCTION 55 | * vm_usb_get_cable_status 56 | * DESCRIPTION 57 | * Get the usb cable status. 58 | * RETURNS 59 | * Refer to VM_USB_CABLE_STATUS for details. 60 | * EXAMPLE 61 | * 62 | * usb_status = vm_usb_get_cable_status(); 63 | * 64 | *******************************************************************************/ 65 | VM_USB_CABLE_STATUS vm_usb_get_cable_status(void); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* VMUSB_SDK_H */ -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/libmtk.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/libmtk.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/peraudio.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/peraudio.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perbitstream.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perbitstream.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perbt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perbt.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/percallout.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/percallout.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/percam.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/percam.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/percommon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/percommon.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/percontact.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/percontact.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perda.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perda.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perfile.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perfile.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perhttp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perhttp.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perlbs.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perlbs.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/permms.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/permms.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perpayment.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perpayment.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perpn.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perpn.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perpro.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perpro.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perrecord.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perrecord.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/persec.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/persec.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/persensor.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/persensor.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/persim.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/persim.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/persmsmng.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/persmsmng.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/persmsper.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/persmsper.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/persmssp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/persmssp.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/persso.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/persso.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/persysfile.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/persysfile.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/persysstorage.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/persysstorage.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/pertcp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/pertcp.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perudp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perudp.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/pervideo.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/pervideo.a -------------------------------------------------------------------------------- /lib/LINKIT10/armgcc/perxml.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/lib/LINKIT10/armgcc/perxml.a -------------------------------------------------------------------------------- /tools/PackTag: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/tools/PackTag -------------------------------------------------------------------------------- /tools/PushTool: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/tools/PushTool -------------------------------------------------------------------------------- /tools/libiconv2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/tools/libiconv2.dll -------------------------------------------------------------------------------- /tools/libintl3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/tools/libintl3.dll -------------------------------------------------------------------------------- /tools/make: -------------------------------------------------------------------------------- 1 | /usr/bin/make -------------------------------------------------------------------------------- /tools/packtag.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | from struct import pack 5 | 6 | suffix = '\x04\x00\x00\x00\n\x00\x00\x00D\x00e\x00m\x00o\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\xff\xff\xff\xff\x03\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x04\x00\x00\x00\x00\x00\x01\x00\x16\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\x18\x00\x00\x00\xde\x07\x00\x00\x03\x00\x00\x00\x1c\x00\x00\x00\x0f\x00\x00\x00(\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x18\x00\x00\x00\xde\x07\x00\x00\x05\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x04\x00\x00\x00\x00\x04\x00\x00\x10\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x04\x00\x00\x00\x00\x00\xc4\t!\x00\x00\x00\x04\x00\x00\x00\x06\x00\x00\x00#\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00"\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x002\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00/\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x001\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00*\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00,\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00-\x00\x00\x00\x04\x00\x00\x00\xff\xff\xff\xff.\x00\x00\x00\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1c\x00\x00\x00M\x00e\x00d\x00i\x00a\x00T\x00e\x00k\x00 \x00I\x00n\x00c\x00.\x00\x00\x00%\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x003\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00\n\x00\x00\x001234567890\x17\x00\x00\x00\x10\x00\x00\x00c\x00o\x00n\x00t\x00e\x00n\x00t\x00\x00\x00\x19\x00\x00\x00>\x00\x00\x00\x01\x00\x00\x00\n\x00\x00\x00D\x00e\x00m\x00o\x00\x00\x00\x02\x00\x00\x00\n\x00\x00\x00D\x00e\x00m\x00o\x00\x00\x00\x03\x00\x00\x00\n\x00\x00\x00D\x00e\x00m\x00o\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x00\x00\x00\xd0\x00\x00\x00\x88\x13\x00\x00\x01\x00\x00\x00\x89\x13\x00\x00\x01\x00\x00\x00\x8a\x13\x00\x00\x01\x00\x00\x00\x8b\x13\x00\x00\x01\x00\x00\x00\x8c\x13\x00\x00\x01\x00\x00\x00\x8d\x13\x00\x00\x01\x00\x00\x00\x8e\x13\x00\x00\x01\x00\x00\x00\x8f\x13\x00\x00\x01\x00\x00\x00\x90\x13\x00\x00\x01\x00\x00\x00\x91\x13\x00\x00\x01\x00\x00\x00\x92\x13\x00\x00\x01\x00\x00\x00\x93\x13\x00\x00\x01\x00\x00\x00\x94\x13\x00\x00\x01\x00\x00\x00\x95\x13\x00\x00\x01\x00\x00\x00\x96\x13\x00\x00\x01\x00\x00\x00\x97\x13\x00\x00\x01\x00\x00\x00\x98\x13\x00\x00\x01\x00\x00\x00\x99\x13\x00\x00\x01\x00\x00\x00\x9a\x13\x00\x00\x01\x00\x00\x00\x9b\x13\x00\x00\x01\x00\x00\x00\x9c\x13\x00\x00\x01\x00\x00\x00\x9d\x13\x00\x00\x01\x00\x00\x00\x9e\x13\x00\x00\x01\x00\x00\x00\x9f\x13\x00\x00\x01\x00\x00\x00\xa0\x13\x00\x00\x01\x00\x00\x00\xa1\x13\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb4VDE10\x01\x00\x00\x00LV)\xfb\xed\xfe\xb6\xd0\x9e\xa6\xe0\xcb\xb3\x122\xa6\xff8\xdd\xf5\xfc\xb2i2X\xe1\x10\x9dw}\x19\xdd;0V*\x92\x9bo\xf8\x0f\xf0\xa0 "\xd9\x12$\x01f\xe3\x0f\xc1\n\xff\xa5\xae\x9a\xeb\xae4\x81\xed\xbb' 7 | 8 | 9 | if __name__ == '__main__': 10 | if len(sys.argv) < 2: 11 | print('Usage: %s input.elf output.vxp' % sys.argv[0]) 12 | sys.exit(-1) 13 | 14 | elfname = sys.argv[1] 15 | vxpname = elfname + '.vxp' 16 | if len(sys.argv) > 2: 17 | vxpname = sys.argv[2] 18 | 19 | elf = open(elfname, 'rb') 20 | if not elf: 21 | print('Can not open %s' % elfname) 22 | sys.exit(-2) 23 | 24 | vxp = open(vxpname, 'wb') 25 | if not vxp: 26 | print('Can not open %s' % vxp) 27 | sys.exit(-3) 28 | 29 | vxp.write(elf.read()) 30 | elf.close() 31 | 32 | # append 0xff 33 | vxp.write('\xff') 34 | size = vxp.tell() 35 | 36 | # align with 0x30 37 | while size & 0x3: 38 | vxp.write('\x30') 39 | size += 1 40 | 41 | vxp.write(suffix) 42 | 43 | # add elf file length information 44 | lengthinfo = pack('qi', size, 0) 45 | vxp.write(lengthinfo) 46 | vxp.close() 47 | 48 | -------------------------------------------------------------------------------- /vxp/lua.vxp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loboris/RePhone_on_Linux/c143291aa41a80c7c6ec88c4bbabcc26dfa7c1e2/vxp/lua.vxp --------------------------------------------------------------------------------