├── .gitignore ├── CHANGELOG ├── LICENSE ├── LICENSE.fatfs ├── LICENSE.luarpc ├── README.asciidoc ├── SConstruct ├── build_elua.lua ├── cross-lua.lua ├── cross-lua.py ├── doc ├── README.TXT ├── buildall.lua ├── ddlevelsfiles │ └── arrow-right.gif ├── docdata.lua ├── eluadoc.lua ├── eluadoc │ ├── arch_platform_adc.lua │ ├── arch_platform_can.lua │ ├── arch_platform_cpu.lua │ ├── arch_platform_eth.lua │ ├── arch_platform_i2c.lua │ ├── arch_platform_ll.lua │ ├── arch_platform_pio.lua │ ├── arch_platform_pwm.lua │ ├── arch_platform_spi.lua │ ├── arch_platform_timers.lua │ ├── arch_platform_uart.lua │ ├── refman_gen_adc.lua │ ├── refman_gen_bit.lua │ ├── refman_gen_can.lua │ ├── refman_gen_cpu.lua │ ├── refman_gen_elua.lua │ ├── refman_gen_i2c.lua │ ├── refman_gen_net.lua │ ├── refman_gen_nrf.lua │ ├── refman_gen_pack.lua │ ├── refman_gen_pd.lua │ ├── refman_gen_pio.lua │ ├── refman_gen_pwm.lua │ ├── refman_gen_rpc.lua │ ├── refman_gen_spi.lua │ ├── refman_gen_term.lua │ ├── refman_gen_tmr.lua │ ├── refman_gen_uart.lua │ ├── refman_ps_lm3s_disp.lua │ ├── refman_ps_mbed_pio.lua │ ├── refman_ps_mizar32_lcd.lua │ ├── refman_ps_stm32_snd.lua │ ├── refman_ps_str9_pio.lua │ ├── refman_ps_str9_rtc.lua │ └── template.lua ├── en │ ├── arch.html │ ├── arch_coding.txt │ ├── arch_con_term.html │ ├── arch_ints.txt │ ├── arch_ltr.html │ ├── arch_newport.html │ ├── arch_overview.html │ ├── arch_rfs.txt │ ├── arch_romfs.html │ ├── arch_tcpip.html │ ├── asciidoc.conf │ ├── building.txt │ ├── building_unix.html │ ├── building_win.html │ ├── comunity.txt │ ├── dl_old.html │ ├── doc.html │ ├── downloads.txt │ ├── elua_egc.html │ ├── examples.html │ ├── faq.html │ ├── fatfs.html │ ├── filesystems.html │ ├── forum.html │ ├── genericmodules.html │ ├── installing.html │ ├── installing_at91sam7x.html │ ├── installing_avr32.txt │ ├── installing_i386.html │ ├── installing_lm3s.html │ ├── installing_lpc2468.html │ ├── installing_lpc2888.html │ ├── installing_stm32.html │ ├── installing_str7.html │ ├── installing_str9.html │ ├── inthandlers.txt │ ├── linenoise.txt │ ├── media.txt │ ├── modules_lm3s.html │ ├── modules_mbed.txt │ ├── modules_mizar32.txt │ ├── modules_str9.html │ ├── news.txt │ ├── overview.txt │ ├── refman.html │ ├── refman_dep.html │ ├── refman_gen.html │ ├── sermux.txt │ ├── status.txt │ ├── tc_386.html │ ├── tc_arm.html │ ├── tc_cortex.html │ ├── tchainbuild.html │ ├── tmr_ref.html │ ├── toolchains.html │ ├── tut_bootpc.html │ ├── tut_bootstick.html │ ├── tut_openocd.html │ ├── tutorials.html │ ├── using.html │ ├── versionhistory.html │ └── xhtml11.conf ├── images │ ├── En.jpg │ ├── Pt.jpg │ ├── barlineleft.png │ ├── barlineright.png │ ├── blank.png │ ├── eLuaLogo.png │ ├── eLuaLogo.svg │ ├── eLua_16x16.ico │ ├── elua_arch.png │ ├── flashmagic.png │ ├── ft_prog_power.png │ ├── ft_prog_strings.png │ ├── google.gif │ ├── hideall.png │ ├── hideall_over.png │ ├── icons │ │ ├── caution.png │ │ ├── example.png │ │ ├── home.png │ │ ├── important.png │ │ ├── next.png │ │ ├── note.png │ │ ├── prev.png │ │ ├── tip.png │ │ ├── up.png │ │ └── warning.png │ ├── lng_en.png │ ├── lng_en_over.png │ ├── lng_es.png │ ├── lng_es_over.png │ ├── lng_pt.png │ ├── lng_pt_over.png │ ├── minusnode.png │ ├── minusnodelast.png │ ├── next.png │ ├── next_over.png │ ├── node.png │ ├── nodelast.png │ ├── plusnode.png │ ├── plusnodelast.png │ ├── previous.png │ ├── previous_over.png │ ├── sepblank.png │ ├── sepnode.png │ ├── sepvertline.png │ ├── showall.png │ ├── showall_over.png │ ├── stat_not_applicable.png │ ├── stat_not_implemented.png │ ├── stat_not_tested.png │ ├── stat_ok.png │ ├── sync.png │ ├── sync_over.png │ ├── terminalreneseas.jpg │ ├── title_background.png │ ├── vertline.png │ ├── volta-small.jpg │ ├── webbook.png │ └── webbook_over.png ├── menu.css ├── pt │ ├── arch.html │ ├── arch_coding.html │ ├── arch_con_term.html │ ├── arch_ltr.html │ ├── arch_newport.html │ ├── arch_overview.html │ ├── arch_platform.html │ ├── arch_romfs.html │ ├── arch_tcpip.html │ ├── bit_ref.html │ ├── building.html │ ├── building_unix.html │ ├── building_win.html │ ├── comunity.html │ ├── cpu_ref.html │ ├── disp_ref.html │ ├── dl_old.html │ ├── doc.html │ ├── downloads.html │ ├── elua_egc.html │ ├── eluaapi.html │ ├── examples.html │ ├── faq.html │ ├── fatfs.html │ ├── filesystems.html │ ├── forum.html │ ├── genericmodules.html │ ├── gpio_ref.html │ ├── installing.html │ ├── installing_at91sam7x.html │ ├── installing_avr32.html │ ├── installing_i386.html │ ├── installing_lm3s.html │ ├── installing_lpc2468.html │ ├── installing_lpc2888.html │ ├── installing_stm32.html │ ├── installing_str7.html │ ├── installing_str9.html │ ├── modules_lm3s.html │ ├── modules_str9.html │ ├── net_ref.html │ ├── news.html │ ├── overview.html │ ├── platdependentmodules.html │ ├── platdepmodules.html │ ├── pwm_ref.html │ ├── refman.html │ ├── refman_dep.html │ ├── refman_gen.html │ ├── spi_ref.html │ ├── status.html │ ├── sys_ref.html │ ├── tc_386.html │ ├── tc_arm.html │ ├── tc_cortex.html │ ├── tchainbuild.html │ ├── term_ref.html │ ├── tmr_ref.html │ ├── toolchains.html │ ├── tut_bootpc.html │ ├── tut_bootstick.html │ ├── tut_openocd.html │ ├── tutorials.html │ ├── uart_ref.html │ ├── using.html │ └── versionhistory.html └── style1.css ├── entry00138 ├── abstract.doc ├── enc28j60_module_schematic.jpg ├── lights.jpg ├── lights.sch ├── network_ps2_audio_extension.jpg ├── network_ps2_audio_extension.sch ├── radio_module_schematic.jpg ├── stmbrain_diagram.jpg ├── stmbrain_diagram.vsd ├── video_radio.jpg └── video_radio.sch ├── inc ├── buf.h ├── cexcept.h ├── common.h ├── desktop │ ├── platform_conf.h │ └── type.h ├── dlmalloc.h ├── editor │ ├── edalloc.h │ ├── ededit.h │ ├── edhw.h │ ├── editor.h │ ├── edmove.h │ ├── edutils.h │ └── edvars.h ├── elua_adc.h ├── elua_int.h ├── elua_net.h ├── elua_rfs.h ├── elua_uip.h ├── eluarpc.h ├── enc28j60.h ├── help.h ├── linenoise.h ├── linenoise_posix.h ├── luarpc_rpc.h ├── mmcfs.h ├── newlib │ ├── devman.h │ ├── genstd.h │ └── ioctl.h ├── nrf │ ├── nrf.h │ └── nrf_ll.h ├── platform.h ├── ps2.h ├── remotefs │ ├── client.h │ ├── os_io.h │ └── remotefs.h ├── romfs.h ├── rtype.h ├── salloc.h ├── semifs.h ├── serial.h ├── sermux.h ├── shell.h ├── swi.h ├── term.h ├── utils.h ├── validate.h ├── version.h ├── vram.h └── xmodem.h ├── luasrcdiet.lua ├── mkfs.py ├── mux.lua ├── mux.py ├── mux_src ├── config.h ├── main.c ├── mux.vcxproj └── mux.vcxproj.filters ├── others ├── bdf2img │ ├── bdf2img.py │ ├── bdflib.py │ ├── cp437-8x12.bdf │ └── font.py ├── connections.txt ├── getfntdata │ ├── font.py │ └── fontdata.png ├── interrupts.txt ├── lights │ ├── SConstruct │ ├── avr_nrf.c │ ├── i2cee.c │ ├── inc │ │ ├── i2cee.h │ │ ├── ledvm.h │ │ ├── machine.h │ │ ├── nrf_conf.h │ │ ├── pwm.h │ │ ├── type.h │ │ └── uart.h │ ├── ledvm.c │ ├── main.c │ ├── pwm.c │ └── uart.c ├── vgademo-0.0.3 │ ├── connections.txt │ ├── vgacolour.spin │ ├── vgademo.spin │ └── vram.spin └── videov2 │ ├── serial.spin │ ├── spi_asmfast.spin │ ├── vgacolour.spin │ ├── vgademo.spin │ └── vram.spin ├── rfs_server.lua ├── rfs_server.py ├── rfs_server_src ├── deskutils.c ├── deskutils.h ├── log.c ├── log.h ├── main.c ├── main_sim.c ├── net.h ├── net_posix.c ├── net_win32.c ├── os_io_posix.c ├── os_io_win32.c ├── rfs.h ├── rfs_server.vcxproj ├── rfs_server.vcxproj.filters ├── rfs_transports.c ├── rfs_transports.h ├── serial.h ├── serial_posix.c ├── serial_win32.c ├── server.c ├── server.h └── type.h ├── romfs └── .gitignore ├── rpc-lua.py ├── run_elua_sim.sh ├── src ├── buf.c ├── common.c ├── common_tmr.c ├── common_uart.c ├── dlmalloc.c ├── editor │ ├── edalloc.c │ ├── edalloc_zones.c │ ├── ededit.c │ ├── edhw.c │ ├── editor.c │ ├── edmove.c │ └── edutils.c ├── elua_adc.c ├── elua_int.c ├── elua_mmc.c ├── elua_nrf.c ├── elua_uip.c ├── eluarpc.c ├── enc28j60.c ├── fatfs │ ├── ccsbcs.c │ ├── diskio.h │ ├── ff.c │ ├── ff.h │ ├── ffconf.h │ └── integer.h ├── help.c ├── linenoise.c ├── linenoise_posix.c ├── lua │ ├── Makefile │ ├── 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 │ ├── 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.c │ ├── lua.h │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ ├── lzio.h │ └── print.c ├── luarpc_desktop_serial.c ├── luarpc_elua_uart.c ├── main.c ├── mmcfs.c ├── modules │ ├── adc.c │ ├── auxmods.h │ ├── bit.c │ ├── bitarray.c │ ├── can.c │ ├── cpu.c │ ├── elua.c │ ├── i2c.c │ ├── lpack.c │ ├── luarpc.c │ ├── modcommon.h │ ├── net.c │ ├── nrf.c │ ├── pd.c │ ├── pio.c │ ├── pwm.c │ ├── spi.c │ ├── term.c │ ├── tmr.c │ └── uart.c ├── newlib │ ├── devman.c │ ├── genstd.c │ ├── stdtcp.c │ └── stubs.c ├── nrf │ └── nrf.c ├── patches │ ├── README │ └── strings_and_protos_in_rom.patch ├── platform │ ├── arm_constants.h │ ├── arm_cortex_interrupts.c │ ├── arm_utils.s │ ├── at91sam7x │ │ ├── aic.c │ │ ├── aic.h │ │ ├── assert.h │ │ ├── at91sam7x256 │ │ │ └── AT91SAM7X256.h │ │ ├── at91sam7x512 │ │ │ └── AT91SAM7X512.h │ │ ├── board.h │ │ ├── board_cstartup.s │ │ ├── board_lowlevel.c │ │ ├── board_memories.c │ │ ├── board_memories.h │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── flash256.lds │ │ ├── flash512.lds │ │ ├── pio.c │ │ ├── pio.h │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── platform_int.c │ │ ├── pmc.c │ │ ├── pmc.h │ │ ├── pwmc.c │ │ ├── pwmc.h │ │ ├── stacks.h │ │ ├── tc.c │ │ ├── tc.h │ │ ├── trace.h │ │ ├── type.h │ │ ├── usart.c │ │ └── usart.h │ ├── avr32 │ │ ├── EVK1100 │ │ │ ├── evk1100.h │ │ │ ├── evk1100_conf.h │ │ │ └── evk1100_revA.h │ │ ├── EVK1101 │ │ │ ├── evk1101.h │ │ │ └── evk1101_conf.h │ │ ├── MIZAR32 │ │ │ ├── mizar32.h │ │ │ └── mizar32_conf.h │ │ ├── MT48LC16M16A2TG7E │ │ │ └── mt48lc16m16a2tg7e.h │ │ ├── adc.c │ │ ├── adc.h │ │ ├── at32uc3a0128.ld │ │ ├── at32uc3a0128_emblod.ld │ │ ├── at32uc3a0256.ld │ │ ├── at32uc3a0512.ld │ │ ├── at32uc3b0256.ld │ │ ├── board.h │ │ ├── compiler.h │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── conf_isp.h │ │ ├── crt0.s │ │ ├── ethernet.c │ │ ├── ethernet.h │ │ ├── exception.s │ │ ├── flashc.c │ │ ├── flashc.h │ │ ├── gpio.c │ │ ├── gpio.h │ │ ├── i2c.c │ │ ├── i2c.h │ │ ├── intc.c │ │ ├── intc.h │ │ ├── lcd.c │ │ ├── lcd.h │ │ ├── mrepeat.h │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── platform_int.c │ │ ├── pm.c │ │ ├── pm.h │ │ ├── pm_conf_clocks.c │ │ ├── preprocessor.h │ │ ├── pwm.c │ │ ├── pwm.h │ │ ├── sdramc.c │ │ ├── sdramc.h │ │ ├── spi.c │ │ ├── spi.h │ │ ├── stacks.h │ │ ├── stringz.h │ │ ├── tc.c │ │ ├── tc.h │ │ ├── tpaste.h │ │ ├── trampoline.s │ │ ├── type.h │ │ ├── uip-conf.h │ │ ├── usart.c │ │ └── usart.h │ ├── cortex_constants.h │ ├── cortex_utils.s │ ├── i386 │ │ ├── boot.s │ │ ├── common.c │ │ ├── common.h │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── descriptor_tables.c │ │ ├── descriptor_tables.h │ │ ├── gdt.s │ │ ├── i386.ld │ │ ├── interrupt.s │ │ ├── isr.c │ │ ├── isr.h │ │ ├── kb.c │ │ ├── kb.h │ │ ├── main.c │ │ ├── monitor.c │ │ ├── monitor.h │ │ ├── multiboot.h │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── stacks.h │ │ ├── timer.c │ │ ├── timer.h │ │ └── type.h │ ├── lm3s │ │ ├── adc.c │ │ ├── adc.h │ │ ├── can.c │ │ ├── can.h │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── cpu.c │ │ ├── cpu.h │ │ ├── debug.h │ │ ├── disp.c │ │ ├── disp.h │ │ ├── ethernet.c │ │ ├── ethernet.h │ │ ├── flash.c │ │ ├── flash.h │ │ ├── gpio.c │ │ ├── gpio.h │ │ ├── hw_adc.h │ │ ├── hw_can.h │ │ ├── hw_comp.h │ │ ├── hw_epi.h │ │ ├── hw_ethernet.h │ │ ├── hw_flash.h │ │ ├── hw_gpio.h │ │ ├── hw_hibernate.h │ │ ├── hw_i2c.h │ │ ├── hw_i2s.h │ │ ├── hw_ints.h │ │ ├── hw_memmap.h │ │ ├── hw_nvic.h │ │ ├── hw_pwm.h │ │ ├── hw_qei.h │ │ ├── hw_ssi.h │ │ ├── hw_sysctl.h │ │ ├── hw_timer.h │ │ ├── hw_types.h │ │ ├── hw_uart.h │ │ ├── hw_udma.h │ │ ├── hw_usb.h │ │ ├── hw_watchdog.h │ │ ├── interrupt.c │ │ ├── interrupt.h │ │ ├── lm3s-9b92.ld │ │ ├── lm3s-9d92.ld │ │ ├── lm3s.ld │ │ ├── lm3s6918.h │ │ ├── lm3s6965.h │ │ ├── lm3s8962.h │ │ ├── lm3s9b92.h │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── platform_int.c │ │ ├── pwm.c │ │ ├── pwm.h │ │ ├── rit128x96x4.c │ │ ├── rit128x96x4.h │ │ ├── rom.h │ │ ├── rom_map.h │ │ ├── ssi.c │ │ ├── ssi.h │ │ ├── stacks.h │ │ ├── startup_gcc.c │ │ ├── sysctl.c │ │ ├── sysctl.h │ │ ├── systick.c │ │ ├── systick.h │ │ ├── timer.c │ │ ├── timer.h │ │ ├── type.h │ │ ├── uart.c │ │ ├── uart.h │ │ └── uip-conf.h │ ├── lpc17xx │ │ ├── LPC17xx.h │ │ ├── LPC17xx.ld │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── core_cm3.c │ │ ├── core_cm3.h │ │ ├── drivers │ │ │ ├── inc │ │ │ │ ├── lpc17xx_adc.h │ │ │ │ ├── lpc17xx_can.h │ │ │ │ ├── lpc17xx_clkpwr.h │ │ │ │ ├── lpc17xx_dac.h │ │ │ │ ├── lpc17xx_emac.h │ │ │ │ ├── lpc17xx_gpdma.h │ │ │ │ ├── lpc17xx_gpio.h │ │ │ │ ├── lpc17xx_i2c.h │ │ │ │ ├── lpc17xx_i2s.h │ │ │ │ ├── lpc17xx_libcfg_default.h │ │ │ │ ├── lpc17xx_mcpwm.h │ │ │ │ ├── lpc17xx_nvic.h │ │ │ │ ├── lpc17xx_pinsel.h │ │ │ │ ├── lpc17xx_pwm.h │ │ │ │ ├── lpc17xx_qei.h │ │ │ │ ├── lpc17xx_rit.h │ │ │ │ ├── lpc17xx_rtc.h │ │ │ │ ├── lpc17xx_spi.h │ │ │ │ ├── lpc17xx_ssp.h │ │ │ │ ├── lpc17xx_timer.h │ │ │ │ ├── lpc17xx_uart.h │ │ │ │ ├── lpc17xx_wdt.h │ │ │ │ └── lpc_types.h │ │ │ └── src │ │ │ │ ├── lpc17xx_adc.c │ │ │ │ ├── lpc17xx_can.c │ │ │ │ ├── lpc17xx_clkpwr.c │ │ │ │ ├── lpc17xx_dac.c │ │ │ │ ├── lpc17xx_emac.c │ │ │ │ ├── lpc17xx_gpdma.c │ │ │ │ ├── lpc17xx_gpio.c │ │ │ │ ├── lpc17xx_i2c.c │ │ │ │ ├── lpc17xx_i2s.c │ │ │ │ ├── lpc17xx_libcfg_default.c │ │ │ │ ├── lpc17xx_mcpwm.c │ │ │ │ ├── lpc17xx_nvic.c │ │ │ │ ├── lpc17xx_pinsel.c │ │ │ │ ├── lpc17xx_pwm.c │ │ │ │ ├── lpc17xx_qei.c │ │ │ │ ├── lpc17xx_rit.c │ │ │ │ ├── lpc17xx_rtc.c │ │ │ │ ├── lpc17xx_spi.c │ │ │ │ ├── lpc17xx_ssp.c │ │ │ │ ├── lpc17xx_timer.c │ │ │ │ ├── lpc17xx_uart.c │ │ │ │ └── lpc17xx_wdt.c │ │ ├── lpc17xx_libcfg.h │ │ ├── mbed_pio.c │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── stacks.h │ │ ├── startup_LPC17xx.c │ │ ├── system_LPC17xx.c │ │ ├── system_LPC17xx.h │ │ └── type.h │ ├── lpc24xx │ │ ├── LPC23xx.h │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── irq.c │ │ ├── irq.h │ │ ├── lpc2468.lds │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── platform_int.c │ │ ├── stacks.h │ │ ├── startup.s │ │ ├── target.c │ │ ├── target.h │ │ ├── type.h │ │ └── uart.h │ ├── lpc288x │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── lpc2888.lds │ │ ├── lpc288x.h │ │ ├── lpc28xx.s │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── sdram_lpc.h │ │ ├── stacks.h │ │ ├── target.c │ │ ├── target.h │ │ ├── type.h │ │ ├── uart.c │ │ └── uart.h │ ├── sim │ │ ├── boot.s │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── host.c │ │ ├── host.h │ │ ├── hostif.h │ │ ├── hostif_linux.c │ │ ├── i386.ld │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── stacks.h │ │ ├── type.h │ │ └── utils.s │ ├── stm32 │ │ ├── FWLib │ │ │ └── library │ │ │ │ ├── inc │ │ │ │ ├── misc.h │ │ │ │ ├── stm32f10x_adc.h │ │ │ │ ├── stm32f10x_bkp.h │ │ │ │ ├── stm32f10x_can.h │ │ │ │ ├── stm32f10x_crc.h │ │ │ │ ├── stm32f10x_dac.h │ │ │ │ ├── stm32f10x_dbgmcu.h │ │ │ │ ├── stm32f10x_dma.h │ │ │ │ ├── stm32f10x_exti.h │ │ │ │ ├── stm32f10x_flash.h │ │ │ │ ├── stm32f10x_fsmc.h │ │ │ │ ├── stm32f10x_gpio.h │ │ │ │ ├── stm32f10x_i2c.h │ │ │ │ ├── stm32f10x_iwdg.h │ │ │ │ ├── stm32f10x_pwr.h │ │ │ │ ├── stm32f10x_rcc.h │ │ │ │ ├── stm32f10x_rtc.h │ │ │ │ ├── stm32f10x_sdio.h │ │ │ │ ├── stm32f10x_spi.h │ │ │ │ ├── stm32f10x_tim.h │ │ │ │ ├── stm32f10x_usart.h │ │ │ │ └── stm32f10x_wwdg.h │ │ │ │ └── src │ │ │ │ ├── misc.c │ │ │ │ ├── stm32f10x_adc.c │ │ │ │ ├── stm32f10x_bkp.c │ │ │ │ ├── stm32f10x_can.c │ │ │ │ ├── stm32f10x_crc.c │ │ │ │ ├── stm32f10x_dac.c │ │ │ │ ├── stm32f10x_dbgmcu.c │ │ │ │ ├── stm32f10x_dma.c │ │ │ │ ├── stm32f10x_exti.c │ │ │ │ ├── stm32f10x_flash.c │ │ │ │ ├── stm32f10x_fsmc.c │ │ │ │ ├── stm32f10x_gpio.c │ │ │ │ ├── stm32f10x_i2c.c │ │ │ │ ├── stm32f10x_iwdg.c │ │ │ │ ├── stm32f10x_pwr.c │ │ │ │ ├── stm32f10x_rcc.c │ │ │ │ ├── stm32f10x_rtc.c │ │ │ │ ├── stm32f10x_sdio.c │ │ │ │ ├── stm32f10x_spi.c │ │ │ │ ├── stm32f10x_tim.c │ │ │ │ ├── stm32f10x_usart.c │ │ │ │ └── stm32f10x_wwdg.c │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── core_cm3.c │ │ ├── core_cm3.h │ │ ├── cortexm3_macro.s │ │ ├── diskio_sdio_stm32.c │ │ ├── enc.c │ │ ├── enc.h │ │ ├── fonts.h │ │ ├── fsmc_nand.c │ │ ├── fsmc_nand.h │ │ ├── fsmc_sram.c │ │ ├── fsmc_sram.h │ │ ├── lstm32_mod.c │ │ ├── lua_lcd.c │ │ ├── nand_if.c │ │ ├── nand_if.h │ │ ├── nrf_conf.h │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── platform_int.c │ │ ├── sdcard.c │ │ ├── sdcard.h │ │ ├── snd.c │ │ ├── stacks.h │ │ ├── startup_stm32f10x_hd.s │ │ ├── stm32.ld │ │ ├── stm32f10x.h │ │ ├── stm32f10x_conf.h │ │ ├── stm32f10x_it.c │ │ ├── stm32f10x_it.h │ │ ├── system_stm32f10x.c │ │ ├── system_stm32f10x.h │ │ ├── type.h │ │ └── uip-conf.h │ ├── str7 │ │ ├── 71x_apb.c │ │ ├── 71x_apb.h │ │ ├── 71x_conf.h │ │ ├── 71x_gpio.c │ │ ├── 71x_gpio.h │ │ ├── 71x_lib.h │ │ ├── 71x_map.h │ │ ├── 71x_rccu.c │ │ ├── 71x_rccu.h │ │ ├── 71x_tim.c │ │ ├── 71x_tim.h │ │ ├── 71x_type.h │ │ ├── 71x_uart.c │ │ ├── 71x_uart.h │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── crt0.s │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── stacks.h │ │ ├── str711fr2.lds │ │ └── type.h │ └── str9 │ │ ├── 91x_adc.c │ │ ├── 91x_adc.h │ │ ├── 91x_conf.h │ │ ├── 91x_fmi.c │ │ ├── 91x_fmi.h │ │ ├── 91x_gpio.c │ │ ├── 91x_gpio.h │ │ ├── 91x_i2c.c │ │ ├── 91x_i2c.h │ │ ├── 91x_it.h │ │ ├── 91x_map.h │ │ ├── 91x_scu.c │ │ ├── 91x_scu.h │ │ ├── 91x_ssp.c │ │ ├── 91x_ssp.h │ │ ├── 91x_tim.c │ │ ├── 91x_tim.h │ │ ├── 91x_type.h │ │ ├── 91x_uart.c │ │ ├── 91x_uart.h │ │ ├── 91x_vic.c │ │ ├── 91x_vic.h │ │ ├── 91x_wiu.c │ │ ├── 91x_wiu.h │ │ ├── conf.lua │ │ ├── conf.py │ │ ├── interrupt.c │ │ ├── platform.c │ │ ├── platform_conf.h │ │ ├── platform_int.c │ │ ├── stacks.h │ │ ├── startup912.s │ │ ├── startup_generic.s │ │ ├── str912fw44.lds │ │ ├── str9_pio.c │ │ └── type.h ├── ps2.c ├── remotefs │ ├── client.c │ ├── elua_os_io.c │ ├── elua_rfs.c │ └── remotefs.c ├── romfs.c ├── salloc.c ├── semifs.c ├── serial │ ├── serial_posix.c │ └── serial_win32.c ├── shell.c ├── term.c ├── term_vram.c ├── uip │ ├── clock.h │ ├── dhcpc.c │ ├── dhcpc.h │ ├── lc-addrlabels.h │ ├── lc-switch.h │ ├── lc.h │ ├── psock.c │ ├── psock.h │ ├── pt.h │ ├── resolv.c │ ├── resolv.h │ ├── timer.c │ ├── timer.h │ ├── uip-fw.c │ ├── uip-fw.h │ ├── uip-neighbor.c │ ├── uip-neighbor.h │ ├── uip-split.c │ ├── uip-split.h │ ├── uip.c │ ├── uip.h │ ├── uip_arch.h │ ├── uip_arp.c │ ├── uip_arp.h │ ├── uiplib.c │ ├── uiplib.h │ └── uipopt.h ├── vram.c └── xmodem.c ├── test └── test-rpc.lua └── utils ├── build.lua ├── build_release.lua ├── mkfs.lua └── utils.lua /.gitignore: -------------------------------------------------------------------------------- 1 | .build/ 2 | *.hex 3 | *.elf 4 | *.o 5 | *.obj 6 | *.exe 7 | *.bin 8 | *.pyc 9 | inc/romfiles.h 10 | *.swp 11 | .sconf_temp/ 12 | .sconsign.dblite 13 | config.log 14 | mux* 15 | rfs_server* 16 | doc/dist 17 | doc/cache 18 | luarpc 19 | *.binary 20 | *.eeprom 21 | *~ 22 | *.*~ 23 | luac.cross* 24 | *.s#* 25 | ~*.doc 26 | 27 | -------------------------------------------------------------------------------- /LICENSE.fatfs: -------------------------------------------------------------------------------- 1 | FatFs module is an open source software to implement FAT file system to 2 | small embedded systems. This is a free software and is opened for education, 3 | research and commercial developments under license policy of following trems. 4 | 5 | Copyright (C) 2009, ChaN, all right reserved. 6 | 7 | * The FatFs module is a free software and there is NO WARRANTY. 8 | * No restriction on use. You can use, modify and redistribute it for 9 | personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY. 10 | * Redistributions of source code must retain the above copyright notice. 11 | 12 | -------------------------------------------------------------------------------- /LICENSE.luarpc: -------------------------------------------------------------------------------- 1 | Lua-RPC library, Copyright (C) 2001 Russell L. Smith. All rights reserved. 2 | Email: russ@q12.org Web: www.q12.org 3 | For documentation, see http://www.q12.org/lua 4 | 5 | Permission is hereby granted, without written agreement and without 6 | license or royalty fees, to use, copy, modify, and distribute this 7 | software and its documentation for any purpose, including commercial 8 | applications, subject to the following conditions: 9 | 10 | - The above copyright notice and this permission notice shall appear 11 | in all copies or substantial portions of this software. 12 | 13 | - The origin of this software must not be misrepresented; you must 14 | not claim that you wrote the original software. If you use this 15 | software in a product, an acknowledgment in the product 16 | documentation would be greatly appreciated (but it is not 17 | required). 18 | 19 | - Altered source versions must be plainly marked as such, and must 20 | not be misrepresented as being the original software. 21 | 22 | The authors specifically disclaim any warranties, including, but not 23 | limited to, the implied warranties of merchantability and fitness for 24 | a particular purpose. The software provided hereunder is on an "as is" 25 | basis, and the authors have no obligation to provide maintenance, 26 | support, updates, enhancements, or modifications. In no event shall 27 | the authors be held liable to any party for direct, indirect, special, 28 | incidental, or consequential damages arising out of the use of this 29 | software and its documentation. 30 | 31 | This implementation contains no third-party code. 32 | 33 | -------------------------------------------------------------------------------- /cross-lua.lua: -------------------------------------------------------------------------------- 1 | local args = { ... } 2 | local b = require "utils.build" 3 | local builder = b.new_builder( ".build/cross-lua" ) 4 | local utils = b.utils 5 | local sf = string.format 6 | builder:init( args ) 7 | builder:set_build_mode( builder.BUILD_DIR ) 8 | 9 | local output = 'luac.cross' 10 | local cdefs = '-DLUA_CROSS_COMPILER' 11 | 12 | -- Lua source files and include path 13 | local lua_files = [[lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c 14 | lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c 15 | ldblib.c liolib.c lmathlib.c loslib.c ltablib.c lstrlib.c loadlib.c linit.c luac.c print.c lrotable.c]] 16 | lua_files = lua_files:gsub( "\n" , "" ) 17 | local lua_full_files = utils.prepend_path( lua_files, "src/lua" ) 18 | local local_include = "-Isrc/lua -Iinc/desktop -Iinc" 19 | 20 | -- Compiler/linker options 21 | builder:set_compile_cmd( sf( "gcc -O2 %s -Wall %s -c $(FIRST) -o $(TARGET)", local_include, cdefs ) ) 22 | builder:set_link_cmd( "gcc -o $(TARGET) $(DEPENDS) -lm" ) 23 | 24 | -- Build everything 25 | builder:make_exe_target( output, lua_full_files ) 26 | builder:build() 27 | 28 | -------------------------------------------------------------------------------- /cross-lua.py: -------------------------------------------------------------------------------- 1 | import os, sys 2 | 3 | output = 'luac.cross' 4 | cdefs = '-DLUA_CROSS_COMPILER' 5 | 6 | # Lua source files and include path 7 | lua_files = """lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c 8 | lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c 9 | ldblib.c liolib.c lmathlib.c loslib.c ltablib.c lstrlib.c loadlib.c linit.c luac.c print.c lrotable.c""" 10 | lua_full_files = " " + " ".join( [ "src/lua/%s" % name for name in lua_files.split() ] ) 11 | local_include = "-Isrc/lua -Iinc/desktop -Iinc" 12 | 13 | # Compiler/linker options 14 | cccom = "gcc -O2 %s -Wall %s -c $SOURCE -o $TARGET" % ( local_include, cdefs ) 15 | linkcom = "gcc -o $TARGET $SOURCES -lm" 16 | 17 | # Env for building the program 18 | comp = Environment( CCCOM = cccom, 19 | LINKCOM = linkcom, 20 | ENV = os.environ ) 21 | if comp['PLATFORM'] == 'win32': 22 | suffix = ".exe" 23 | else: 24 | suffix = "" 25 | Decider( 'MD5' ) 26 | Default( comp.Program( output + suffix, Split( lua_full_files ) ) ) 27 | -------------------------------------------------------------------------------- /doc/ddlevelsfiles/arrow-right.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/ddlevelsfiles/arrow-right.gif -------------------------------------------------------------------------------- /doc/eluadoc/refman_gen_pd.lua: -------------------------------------------------------------------------------- 1 | -- eLua reference manual - platform data 2 | 3 | data_en = 4 | { 5 | 6 | -- Title 7 | title = "eLua reference manual - platform data", 8 | 9 | -- Menu name 10 | menu_name = "pd", 11 | 12 | desc = "Platform data", 13 | 14 | -- Overview 15 | overview = [[This module contains functions that access specific platform data. Useful if the code needs to know on which platform it runs.]], 16 | 17 | -- Functions 18 | funcs = 19 | { 20 | { sig = "platform = #pd.platform#()", 21 | desc = "Get platform name.", 22 | ret = "$platform$ - the name of the platform on which eLua is running.", 23 | }, 24 | 25 | { sig = "cpu = #pd.cpu#()", 26 | desc = "Get CPU name.", 27 | ret = "$cpu$ - the name of the CPU of the platform on which eLua is running.", 28 | }, 29 | 30 | { sig = "board = #pd.board#()", 31 | desc = "Get board name.", 32 | ret = "$board$ - the name of the board on which eLua is running.", 33 | } 34 | }, 35 | } 36 | 37 | data_pt = data_en 38 | -------------------------------------------------------------------------------- /doc/eluadoc/refman_ps_stm32_snd.lua: -------------------------------------------------------------------------------- 1 | -- eLua platform interface - stm32.snd module 2 | 3 | data_en = 4 | { 5 | 6 | -- Title 7 | title = "eLua reference manual - STM32 snd module", 8 | 9 | -- Menu name 10 | menu_name = "snd", 11 | mod_name = "stm32.snd", 12 | desc = "STM32 PWM based sound generator", 13 | 14 | -- Overview 15 | overview = "This module implements PWM based sound generation with a simple syntax.", 16 | 17 | -- Functions 18 | funcs = 19 | { 20 | { sig = "#stm32.snd.play#( song )", 21 | desc = [[Plays the specified song. The song is described with a simple syntax detailed below. This function is blocking (it doesn't return until the song finished playing).]], 22 | args = [[$song$ - the song to be played. The song is given in a string which contains notes and indications about their duration. Notes are specified like below: 23 | 30 |

Notes durations and tempo are specified like below:

31 | ]] 40 | }, 41 | 42 | }, 43 | 44 | } 45 | 46 | data_pt = data_en 47 | 48 | -------------------------------------------------------------------------------- /doc/eluadoc/template.lua: -------------------------------------------------------------------------------- 1 | -- eLua platform interface - name 2 | 3 | data_en = 4 | { 5 | 6 | -- Title 7 | title = "eLua platform interface - name", 8 | 9 | -- Menu name 10 | menu_name = "name" 11 | 12 | -- Overview 13 | overview = [[ 14 | ]], 15 | 16 | -- Data structures, constants and types 17 | structures = 18 | { 19 | { text = [[ ]], 20 | name = "", 21 | desc = [[ ]] 22 | }, 23 | }, 24 | 25 | -- Functions 26 | funcs = 27 | { 28 | { sig = "void #functionname#( void )", 29 | desc = [[ ]], 30 | args = 31 | { 32 | "$name$ - desc", 33 | "$name$ - desc", 34 | }, 35 | ret = 36 | { 37 | "", 38 | [[ ]], 39 | }, 40 | }, 41 | 42 | }, 43 | 44 | -- Aux data 45 | auxdata = 46 | { 47 | { title = "", 48 | desc = [[]] 49 | } 50 | } 51 | } 52 | 53 | data_pt = data_en 54 | -------------------------------------------------------------------------------- /doc/en/arch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | eLua architecture 5 | 6 | 7 | 8 |

The eLua architecture

9 |

This section presents in-depth details about the design and implementation of eLua. It's meant as a guide mainly for eLua developers, 10 | but it contains information that can be also valuable for eLua users. An example is the ROM file system chapter. 11 | Also, by reading the overview of the eLua architecture you'll get a good view of the overall structure of eLua, 12 | which will help no matter if you're a developer or not.

13 |

Before diving into this, go to the downloads section and download the source code of eLua, it's much easier to 14 | follow this section if you look at the source code.

15 | 16 | -------------------------------------------------------------------------------- /doc/en/doc.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

eLua documentation

3 |

This section contains the complete eLua documentation for both users and developers, including (but not limited to):

4 | 10 |

People who want to contribute to the eLua source code will find a lot of important information here:

11 | 16 | $$FOOTER$$ 17 | 18 | -------------------------------------------------------------------------------- /doc/en/examples.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

eLua Code Examples

3 |

4 | Previous to v0.8, official eLua distributions included some games, demos and code examples in 5 | the ROM File System. 6 |

7 |

8 | These examples grew to independent projects and are now maintained by the 9 | community in dedicated pages on the eLua 10 | Wiki projects section. 11 |

12 |

13 | There you will also find some tutorials on how to use them on your kits 14 | and many others. 15 |

16 |

The wiki is maintained by eLua users and you are very welcomed to 17 | register and add your own tutorial contribution or to comment on any other. 18 |

19 |
20 | 21 | $$FOOTER$$ 22 | 23 | -------------------------------------------------------------------------------- /doc/en/faq.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

eLua Frequently Asked Questions

3 |
4 | eLua has a list of frequently asked questions maintained by the 5 | community in the eLua Wiki at wiki.eluaproject.net/FAQ 6 | $$FOOTER$$ 7 | 8 | -------------------------------------------------------------------------------- /doc/en/filesystems.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

eLua file systems

3 |

You can compile and use more than one file system in eLua, as listed below:

4 | 11 | $$FOOTER$$ 12 | -------------------------------------------------------------------------------- /doc/en/forum.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 | eLua Development 3 | 4 | $$FOOTER$$ 5 | 6 | -------------------------------------------------------------------------------- /doc/en/genericmodules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Product 5 | 6 | 7 | 8 | 9 |

eLua Generic Modules

10 |
11 |
12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /doc/en/installing.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Installing eLua

3 |

To use eLua in one of the 4 | supported 5 | platforms, you need to install 6 | it in your target kit/device or, more precisely, to flash the eLua 7 | image into the platform of your choice.
8 | This section shows specific installation instructions and tips, for all the 9 | CPU/boards supported by eLua.
10 |
11 | First, you need to have a suitable eLua image for your target.
12 | You can either download one of our ready to use 13 | binary images or build 14 | eLua to have custom image for your needs.
15 |
16 | Please choose the platform of your interest from the "Platform Info" submenu 17 | for more instructions.

18 |
19 |
20 |
21 | $$FOOTER$$ 22 | 23 | -------------------------------------------------------------------------------- /doc/en/installing_i386.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Using eLua with Intel i386 (or better) CPUs

3 |

Since the i386 platform was implemented as a proof of concept only, the only things you can do with it are:

4 | 8 |

If you want to do this, build your eLua image or download a precompiled image, as explained in the download page.

9 |

However, most of the features that you'd find on an embedded platform won't work. You won't be able to upload programs to your i386 eLua box using the 10 | XMODEM protocol (not because it's impossible, but simply because this doesn't make sense at all on a desktop PC). Also, you won't be able to control the peripherals that you'd normally find in an 11 | embedded CPU (SPI, I2C, PIO and all the others), because they are not present on the i386 platform (they can be emulated via different means, but this is way beyond 12 | the scope of eLua). So, until further notice, i386 will be nothing more than a spectacular demo platform for eLua. If you think that you can make something 13 | more out of it, please feel free to contact us. I'm actually very interested in this, but I lack the necessary resources to continue it.

14 | $$FOOTER$$ 15 | 16 | -------------------------------------------------------------------------------- /doc/en/modules_lm3s.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Reference manual - LM3S platform dependent modules

3 |

This paragraph presents all the modules specific to the LM3S platform.

4 | $$FOOTER$$ 5 | 6 | -------------------------------------------------------------------------------- /doc/en/modules_mbed.txt: -------------------------------------------------------------------------------- 1 | // $$HEADER$$ 2 | Reference manual - MBED platform dependent modules 3 | -------------------------------------------------- 4 | 5 | This paragraph presents all the modules specific to the link:status.html[lpc17xx] (mbed) platform. 6 | 7 | // $$FOOTER$$ 8 | -------------------------------------------------------------------------------- /doc/en/modules_mizar32.txt: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Reference manual - Mizar32 platform dependent modules

3 |

This paragraph presents all the modules specific to the Mizar32 platform.

4 | $$FOOTER$$ 5 | 6 | -------------------------------------------------------------------------------- /doc/en/modules_str9.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Reference manual - STR9 platform dependent modules

3 |

This paragraph presents all the modules specific to the STR9 platform.

4 | $$FOOTER$$ 5 | 6 | -------------------------------------------------------------------------------- /doc/en/refman.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | eLua reference manual 5 | 6 | 7 | 8 |

The reference manual

9 |

The eLua reference manual presents in details all the modules that can be used from a Lua program running inside eLua. It doesn't cover the 10 | standard Lua libraries, as the Lua reference manual already does a very good job at this. 11 | Instead, it covers eLua-specific modules (most of which are linked with the platform interface) and some generic 12 | "3rd party" modules that are included in eLua by default. There are two types of modules in eLua, both of which are presented 13 | in this section: 14 |

19 |

Remember that in order to use a module (generic or not) in eLua you must first include it in your eLua binary image, check 20 | here for instructions on how to do this.

21 |

22 | 23 | -------------------------------------------------------------------------------- /doc/en/refman_dep.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Reference manual - platform dependent modules

3 |

This part of the reference manual presents the platform specifics in eLua (see here for more information about platform 4 | specific modules).

5 | $$FOOTER$$ 6 | 7 | -------------------------------------------------------------------------------- /doc/en/refman_gen.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Reference manual - generic modules

3 |

This part of the reference manual presents the generic modules in 4 | eLua. Please check the available modules and all its functions, in the 5 | Generic Modules sub-menu options of the main menu. For more information on 6 | what a Generic Module is, see here.

7 | $$FOOTER$$ 8 | 9 | -------------------------------------------------------------------------------- /doc/en/tchainbuild.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Toolchain building tutorials

3 |

Although not strictly required, you can roll your own toolchain that can be used to build eLua. As explained here, eLua can generally be built with 4 | ready-made toolchains (with the exception of the i386 port), but you might still want to build your own toolchain for various reasons:

5 | 11 |

Three separate tutorials explain the procedure of building a regular ARM toolchain, a Cortex-M3 toolchain and an i386 toolchain, respectively.

12 | $$FOOTER$$ 13 | 14 | -------------------------------------------------------------------------------- /doc/en/tutorials.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Tutorials

3 |

This section contains information about different tools and procedures related to eLua:

4 | 9 | $$FOOTER$$ 10 | 11 | -------------------------------------------------------------------------------- /doc/en/xhtml11.conf: -------------------------------------------------------------------------------- 1 | # Document sections. 2 | [sect0] 3 | {title} 4 | | 5 | 6 | [sect1] 7 | {numbered?{sectnum} }{title} 8 |
9 | | 10 |
11 | 12 | [sect2] 13 | {numbered?{sectnum} }{title} 14 | | 15 | 16 | [sect3] 17 | {numbered?{sectnum} }{title} 18 | | 19 | 20 | [sect4] 21 | {title} 22 | 23 | -------------------------------------------------------------------------------- /doc/images/En.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/En.jpg -------------------------------------------------------------------------------- /doc/images/Pt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/Pt.jpg -------------------------------------------------------------------------------- /doc/images/barlineleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/barlineleft.png -------------------------------------------------------------------------------- /doc/images/barlineright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/barlineright.png -------------------------------------------------------------------------------- /doc/images/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/blank.png -------------------------------------------------------------------------------- /doc/images/eLuaLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/eLuaLogo.png -------------------------------------------------------------------------------- /doc/images/eLua_16x16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/eLua_16x16.ico -------------------------------------------------------------------------------- /doc/images/elua_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/elua_arch.png -------------------------------------------------------------------------------- /doc/images/flashmagic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/flashmagic.png -------------------------------------------------------------------------------- /doc/images/ft_prog_power.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/ft_prog_power.png -------------------------------------------------------------------------------- /doc/images/ft_prog_strings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/ft_prog_strings.png -------------------------------------------------------------------------------- /doc/images/google.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/google.gif -------------------------------------------------------------------------------- /doc/images/hideall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/hideall.png -------------------------------------------------------------------------------- /doc/images/hideall_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/hideall_over.png -------------------------------------------------------------------------------- /doc/images/icons/caution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/caution.png -------------------------------------------------------------------------------- /doc/images/icons/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/example.png -------------------------------------------------------------------------------- /doc/images/icons/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/home.png -------------------------------------------------------------------------------- /doc/images/icons/important.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/important.png -------------------------------------------------------------------------------- /doc/images/icons/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/next.png -------------------------------------------------------------------------------- /doc/images/icons/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/note.png -------------------------------------------------------------------------------- /doc/images/icons/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/prev.png -------------------------------------------------------------------------------- /doc/images/icons/tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/tip.png -------------------------------------------------------------------------------- /doc/images/icons/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/up.png -------------------------------------------------------------------------------- /doc/images/icons/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/icons/warning.png -------------------------------------------------------------------------------- /doc/images/lng_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/lng_en.png -------------------------------------------------------------------------------- /doc/images/lng_en_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/lng_en_over.png -------------------------------------------------------------------------------- /doc/images/lng_es.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/lng_es.png -------------------------------------------------------------------------------- /doc/images/lng_es_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/lng_es_over.png -------------------------------------------------------------------------------- /doc/images/lng_pt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/lng_pt.png -------------------------------------------------------------------------------- /doc/images/lng_pt_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/lng_pt_over.png -------------------------------------------------------------------------------- /doc/images/minusnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/minusnode.png -------------------------------------------------------------------------------- /doc/images/minusnodelast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/minusnodelast.png -------------------------------------------------------------------------------- /doc/images/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/next.png -------------------------------------------------------------------------------- /doc/images/next_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/next_over.png -------------------------------------------------------------------------------- /doc/images/node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/node.png -------------------------------------------------------------------------------- /doc/images/nodelast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/nodelast.png -------------------------------------------------------------------------------- /doc/images/plusnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/plusnode.png -------------------------------------------------------------------------------- /doc/images/plusnodelast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/plusnodelast.png -------------------------------------------------------------------------------- /doc/images/previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/previous.png -------------------------------------------------------------------------------- /doc/images/previous_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/previous_over.png -------------------------------------------------------------------------------- /doc/images/sepblank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/sepblank.png -------------------------------------------------------------------------------- /doc/images/sepnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/sepnode.png -------------------------------------------------------------------------------- /doc/images/sepvertline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/sepvertline.png -------------------------------------------------------------------------------- /doc/images/showall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/showall.png -------------------------------------------------------------------------------- /doc/images/showall_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/showall_over.png -------------------------------------------------------------------------------- /doc/images/stat_not_applicable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/stat_not_applicable.png -------------------------------------------------------------------------------- /doc/images/stat_not_implemented.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/stat_not_implemented.png -------------------------------------------------------------------------------- /doc/images/stat_not_tested.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/stat_not_tested.png -------------------------------------------------------------------------------- /doc/images/stat_ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/stat_ok.png -------------------------------------------------------------------------------- /doc/images/sync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/sync.png -------------------------------------------------------------------------------- /doc/images/sync_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/sync_over.png -------------------------------------------------------------------------------- /doc/images/terminalreneseas.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/terminalreneseas.jpg -------------------------------------------------------------------------------- /doc/images/title_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/title_background.png -------------------------------------------------------------------------------- /doc/images/vertline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/vertline.png -------------------------------------------------------------------------------- /doc/images/volta-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/volta-small.jpg -------------------------------------------------------------------------------- /doc/images/webbook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/webbook.png -------------------------------------------------------------------------------- /doc/images/webbook_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/doc/images/webbook_over.png -------------------------------------------------------------------------------- /doc/pt/arch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

A arquitetura eLua

4 |

Esta seção apresenta em detalhes, a concepção e implementação de eLua. Foi concebida como um guia, principalmente para os desenvolvedores eLua, 5 | mas contém informação que pode ser também útil também para usuários de eLua. Um exemplo é o capítulo sobre o sistema de arquivos ROM. 6 | Além disso, ao ler a visão geral da arquitetura eLua você vai ter uma boa visão da estrutura geral de eLua, 7 | que irá ajudar, não importa se você é um desenvolvedor ou não.

8 |

Antes de nos aprofundarmos nisso, vá para a seção de downloads e baixe o código fonte do eLua, é muito mais fácil seguir esta seção acompanhando pelo código-fonte.

9 | 10 | -------------------------------------------------------------------------------- /doc/pt/disp_ref.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

disp

7 |
8 |

9 | disp.init

10 |


11 |

12 |

13 | disp.enable

14 |


15 |

16 |

17 | disp.disable

18 |


19 |

20 |

disp.on 21 |

22 |


23 |

24 |

25 | disp.off
26 |

27 |

28 |
29 |

30 |    disp.print
31 |
32 |

33 | disp.draw

34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | 65 |   66 |

67 |
68 | 69 | -------------------------------------------------------------------------------- /doc/pt/doc.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Documentação

3 |

Nesta seção você encontrará; a documentação completa de eLua tanto para usuá;rios quanto para desenvolvedores, incluindo (mas não se limitando a): 4 |

    5 |
  • como fazer um build de eLua
  • 6 |
  • como compilar e instalar os toolchains necessá;rios para um 7 | build de eLua
  • 8 |
  • como utilizar eLua
  • 9 |
  • descrição de exemplos de programas-fontes de eLua
  • 10 |

11 |

Aquele que desejar contribuir com o código fonte de eLua encontrará; aqui muita informação importante:

    12 |
  • descrição da arquitetura de eLua
  • 13 |
  • as regras de codificação padrão de eLua
  • 14 |
  • como portar eLua para uma nova plataforma
  • 15 |
16 |

17 | $$FOOTER$$ 18 | -------------------------------------------------------------------------------- /doc/pt/eluaapi.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

API eLua

5 |
6 |
7 |
8 |
9 |
10 | 11 | -------------------------------------------------------------------------------- /doc/pt/filesystems.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

eLua file systems

3 |

You can compile and use more than one file system in eLua, as listed below:

4 |
    5 |
  • the ROM file system: a very simple, very low footprint read-only file system that can be included in the eLua binary image. Check here for details.
  • 6 |
  • the FAT file system: a read-write FAT filesystem implementation (platform independent) that can currently be used with SD/MMC memory cards. Check here for 7 | details. (new in 0.7)
  • 8 |
9 | $$FOOTER$$ 10 | 11 | -------------------------------------------------------------------------------- /doc/pt/forum.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 | eLua Development 3 | 4 | $$FOOTER$$ 5 | 6 | -------------------------------------------------------------------------------- /doc/pt/genericmodules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

eLua Generic Modules

5 |
6 |
7 |
8 |
9 |
10 | -------------------------------------------------------------------------------- /doc/pt/installing.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Instalando eLua

3 |

Para utilizar eLua em sua plataforma preferida, será preciso "instalar" no seu dispositivo/kit ou, mais precisamente, gravar a 4 | imagem de eLua na memória Flash. Nesta seção apresentamos instruções específicas para a instalação em todas as plataformas por eLua. 5 | Certifique-se que você já possui uma imagem de eLua gerada para funcionar no seu hardware (tanto baixando uma 6 | já pronta ou gerando você mesmo), então escolha a plataforma que lhe interessa a partir das 7 | opções menu "Instalando" aqui ao lado.

8 |

Para obter o arquivo binário necessário no formato necessário para a 9 | programação de sua CPU durante a geraçãoo de eLua, lembre-se de especificar o 10 | parâmetro "prog" na linha do comando do scons.

11 | $$FOOTER$$ 12 | -------------------------------------------------------------------------------- /doc/pt/installing_i386.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Usando eLua com as CPUs Intel i386 (ou mais recentes)

3 |

Como a plataforma i386 foi implementada somente como uma prova de conceito, as únicas coisas que você pode fazer com ela são:

4 | 8 |

Se você quiser fazer isso, construa sua imagem de eLua ou faça o download de uma imagem pré-compilada, como explicado na página de download.

9 |

No entanto, a maioria dos recursos que você encontraria em uma plataforma embutida não funciona aqui. 10 | Você não será capaz de carregar programas para o seu hardware eLua i386 usando o protocolo XMODEM (não porque é impossível, mas simplesmente porque isso não faz sentido algum em um PC). Além disso, você não será capaz de controlar os periféricos que normalmente encontram-se embutidos em uma CPU (SPI, I2C, PIO e todos os outros), porque eles não estão presentes na plataforma i386 (que podem ser emulados através de diferentes meios, mas este é um assunto que vai além do escopo de eLua). Assim, até novo aviso, i386 será nada mais do que uma plataforma de demonstração para eLua. Se você acha que pode fazer algo além disso, não hesite em contactar-nos. Estou realmente muito interessado nisso, mas me faltam recursos necessários para dar continuidade.

11 | $$FOOTER$$ 12 | 13 | -------------------------------------------------------------------------------- /doc/pt/modules_lm3s.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Reference manual - LM3S platform dependent modules

3 |

This paragraph presents all the modules specific to the LM3S platform.

4 | $$FOOTER$$ 5 | 6 | -------------------------------------------------------------------------------- /doc/pt/modules_str9.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Reference manual - STR9 platform dependent modules

3 |

This paragraph presents all the modules specific to the STR9 platform.

4 | $$FOOTER$$ 5 | 6 | -------------------------------------------------------------------------------- /doc/pt/net_ref.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

rede

5 |
6 | 7 | -------------------------------------------------------------------------------- /doc/pt/platdependentmodules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Módulos Dependentes da Plataforma eLua

7 |
8 |
9 |
10 |
11 |
12 |
13 | 14 | -------------------------------------------------------------------------------- /doc/pt/platdepmodules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Módulos Dependentes da Plataforma eLua

5 |
6 |
7 |
8 |
9 |
10 |
11 | 12 | -------------------------------------------------------------------------------- /doc/pt/refman.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

The reference manual

5 |

The eLua reference manual presents in details all the modules that can be used from a Lua program running inside eLua. It doesn't cover the 6 | standard Lua libraries, as the Lua reference manual already does a very good job at this. 7 | Instead, it covers eLua-specific modules (most of which are linked with the platform interface) and some generic 8 | "3rd party" modules that are included in eLua by default. There are two types of modules in eLua, both of which are presented 9 | in this section: 10 |

    11 |
  • generic modules: they are available on all platforms and should behave the same on all platforms.
  • 12 |
  • platform-depedent modules: they can be found only on specific platforms. Using them sacrifices portability, but gives access to platform 13 | internals that aren't covered by the generic modules (for example specific hardware features). 14 |

15 |

Remember that in order to use a module (generic or not) in eLua you must first include it in your eLua binary image, check 16 | here for instructions on how to do this.

17 |

18 | 19 | -------------------------------------------------------------------------------- /doc/pt/refman_dep.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Reference manual - platform dependent modules

3 |

This part of the reference manual presents the platform specifics in eLua (see here for more information about platform 4 | specific modules).

5 | $$FOOTER$$ 6 | 7 | -------------------------------------------------------------------------------- /doc/pt/refman_gen.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Reference manual - generic modules

3 |

This part of the reference manual presents the generic modules in eLua (see here for more information about generic 4 | modules).

5 | $$FOOTER$$ 6 | 7 | -------------------------------------------------------------------------------- /doc/pt/tchainbuild.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Geração do Toolchain

eLua pode ser gerado com o toolchain GCC.

.....................

3 | $$FOOTER$$ 4 | -------------------------------------------------------------------------------- /doc/pt/tutorials.html: -------------------------------------------------------------------------------- 1 | $$HEADER$$ 2 |

Tutoriais

3 |

Esta sessão contêm informação sobre diferentes ferramentas e procedimentos relacionados com eLua: 4 |

    5 |
  • construindo toolchains que podem ser utilizados para construir o próprio eLua.
  • 6 |
  • rodando eLua (i386) na versão standalone utilizando diferentes cenários.
  • 7 |
  • usando OpenOCD para programar em eLua em diferentes plataformas.
  • 8 |

9 | $$FOOTER$$ 10 | -------------------------------------------------------------------------------- /entry00138/abstract.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/abstract.doc -------------------------------------------------------------------------------- /entry00138/enc28j60_module_schematic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/enc28j60_module_schematic.jpg -------------------------------------------------------------------------------- /entry00138/lights.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/lights.jpg -------------------------------------------------------------------------------- /entry00138/lights.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/lights.sch -------------------------------------------------------------------------------- /entry00138/network_ps2_audio_extension.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/network_ps2_audio_extension.jpg -------------------------------------------------------------------------------- /entry00138/network_ps2_audio_extension.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/network_ps2_audio_extension.sch -------------------------------------------------------------------------------- /entry00138/radio_module_schematic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/radio_module_schematic.jpg -------------------------------------------------------------------------------- /entry00138/stmbrain_diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/stmbrain_diagram.jpg -------------------------------------------------------------------------------- /entry00138/stmbrain_diagram.vsd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/stmbrain_diagram.vsd -------------------------------------------------------------------------------- /entry00138/video_radio.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/video_radio.jpg -------------------------------------------------------------------------------- /entry00138/video_radio.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/entry00138/video_radio.sch -------------------------------------------------------------------------------- /inc/buf.h: -------------------------------------------------------------------------------- 1 | // eLua "char device" buffering system 2 | 3 | #ifndef __BUF_H__ 4 | #define __BUF_H__ 5 | 6 | #include "type.h" 7 | 8 | // [TODO] the buffer data type is currently u8, is this OK? 9 | typedef u8 t_buf_data; 10 | 11 | // IDs of "bufferable" devices 12 | enum 13 | { 14 | BUF_ID_UART = 0, 15 | BUF_ID_ADC = 1, 16 | BUF_ID_FIRST = BUF_ID_UART, 17 | BUF_ID_LAST = BUF_ID_ADC, 18 | BUF_ID_TOTAL = BUF_ID_LAST - BUF_ID_FIRST + 1 19 | }; 20 | 21 | // This structure describes a buffer 22 | typedef struct 23 | { 24 | u8 logsize; 25 | volatile u16 wptr, rptr, count; 26 | t_buf_data *buf; 27 | u8 logdsize; 28 | } buf_desc; 29 | 30 | // Buffer sizes (there are power of 2 to speed up modulo operations) 31 | enum 32 | { 33 | BUF_SIZE_NONE = 0, 34 | BUF_SIZE_2, 35 | BUF_SIZE_4, 36 | BUF_SIZE_8, 37 | BUF_SIZE_16, 38 | BUF_SIZE_32, 39 | BUF_SIZE_64, 40 | BUF_SIZE_128, 41 | BUF_SIZE_256, 42 | BUF_SIZE_512, 43 | BUF_SIZE_1024, 44 | BUF_SIZE_2048, 45 | BUF_SIZE_4096, 46 | BUF_SIZE_8192, 47 | BUF_SIZE_16384, 48 | BUF_SIZE_32768 49 | }; 50 | 51 | enum 52 | { 53 | BUF_DSIZE_U8 = 0, 54 | BUF_DSIZE_U16, 55 | BUF_DSIZE_U32 56 | }; 57 | 58 | 59 | 60 | // Buffer API 61 | int buf_set(unsigned resid, unsigned resnum, u8 logsize, u8 logdsize); 62 | int buf_is_enabled( unsigned resid, unsigned resnum ); 63 | unsigned buf_get_size( unsigned resid, unsigned resnum ); 64 | unsigned buf_get_count( unsigned resid, unsigned resnum ); 65 | int buf_write( unsigned resid, unsigned resnum, t_buf_data *data ); 66 | int buf_read( unsigned resid, unsigned resnum, t_buf_data *data ); 67 | void buf_flush( unsigned resid, unsigned resnum ); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /inc/common.h: -------------------------------------------------------------------------------- 1 | // Common platform functions 2 | 3 | #ifndef __COMMON_H__ 4 | #define __COMMON_H__ 5 | 6 | #include "elua_int.h" 7 | 8 | // Virtual timers data 9 | #define VTMR_FIRST_ID ( 32 ) 10 | #define VTMR_GET_ID( x ) ( ( x ) - VTMR_FIRST_ID ) 11 | #define TIMER_IS_VIRTUAL( x ) ( ( VTMR_NUM_TIMERS > 0 ) && ( ( x ) >= VTMR_FIRST_ID ) && ( ( x ) < VTMR_NUM_TIMERS + VTMR_FIRST_ID ) ) 12 | 13 | // Path types 14 | #define PATH_TYPE_INVALID 0 15 | #define PATH_TYPE_FS 1 16 | #define PATH_TYPE_FILE 2 17 | #define PATH_TYPE_WC 3 // wildcards 18 | 19 | // Functions exported by the common platform layer 20 | void cmn_platform_init(); 21 | void cmn_virtual_timer_cb(); 22 | void cmn_int_handler( elua_int_id id, elua_int_resnum resnum ); 23 | // Timer-specific functions 24 | int cmn_tmr_int_set_status( elua_int_resnum resnum, int status ); 25 | int cmn_tmr_int_get_status( elua_int_resnum resnum ); 26 | int cmn_tmr_int_get_flag( elua_int_resnum resnum, int clear ); 27 | void cmn_uart_setup_sermux(); 28 | 29 | unsigned int intlog2( unsigned int v ); 30 | int cmn_match_fname( const char *fname, const char *pattern ); 31 | int cmn_get_path_type( const char *path, const char **pname ); 32 | 33 | #endif // #ifndef __COMMON_H__ 34 | 35 | -------------------------------------------------------------------------------- /inc/desktop/platform_conf.h: -------------------------------------------------------------------------------- 1 | // eLua platform configuration 2 | 3 | #ifndef __PLATFORM_CONF_H__ 4 | #define __PLATFORM_CONF_H__ 5 | 6 | #ifdef LUA_RPC 7 | #include "auxmods.h" 8 | 9 | #define BUILD_RPC 10 | #define LUARPC_ENABLE_SERIAL 11 | 12 | #define LUA_PLATFORM_LIBS_REG \ 13 | {LUA_OSLIBNAME, luaopen_os} 14 | 15 | #define LUA_PLATFORM_LIBS_ROM \ 16 | _ROM( AUXLIB_RPC, luaopen_rpc, rpc_map )\ 17 | _ROM( AUXLIB_BITARRAY, luaopen_bitarray, bitarray_map )\ 18 | _ROM( AUXLIB_PACK, luaopen_pack, pack_map )\ 19 | _ROM( AUXLIB_BIT, luaopen_bit, bit_map ) 20 | #endif 21 | 22 | 23 | #endif // #ifndef __PLATFORM_CONF_H__ 24 | 25 | -------------------------------------------------------------------------------- /inc/desktop/type.h: -------------------------------------------------------------------------------- 1 | // Type definitions for desktop platform 2 | #ifndef __TYPE_H__ 3 | #define __TYPE_H__ 4 | 5 | #include 6 | 7 | // signed and unsigned 8, 16 and 32 bit types 8 | typedef uint8_t u8; 9 | typedef uint16_t u16; 10 | typedef uint32_t u32; 11 | typedef int8_t s8; 12 | typedef int16_t s16; 13 | typedef int32_t s32; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /inc/editor/edalloc.h: -------------------------------------------------------------------------------- 1 | // Editor allocator 2 | 3 | #ifndef __EDALLOC_H__ 4 | #define __EDALLOC_H__ 5 | 6 | #include "type.h" 7 | #include "editor.h" 8 | 9 | // Static editor line configuration 10 | // The next constant used to be 20 for the zones allocator 11 | #define LINE_ALLOCATOR_ZONE_SIZE 24 // the "zone" is the minimal (and fixed) unit of allocatoin 12 | #define LINE_ALLOCATOR_ZONES 500 // size of allocator in zones 13 | #define BUFFER_ALLOCATOR_EXTRA_LINES 10 // how many more lines to allocate on each request 14 | #define FILE_ESTIMATED_LINE_SIZE 40 // estimated medium size (in chars) of an editor line 15 | #define LINE_BUFFER_SIZE 500 // size of the line buffer (gives the maximum length of a line in the file) 16 | 17 | // Editor line allocator 18 | int edalloc_init(); 19 | void edalloc_deinit(); 20 | EDITOR_BUFFER* edalloc_buffer_new( const char *fname ); 21 | void edalloc_free_buffer( EDITOR_BUFFER *b ); 22 | int edalloc_buffer_change_lines( EDITOR_BUFFER* b, int delta ); 23 | void* edalloc_line_malloc( unsigned size ); 24 | void edalloc_line_free( void* ptr ); 25 | void* edalloc_line_realloc( void* ptr, unsigned size ); 26 | void edalloc_line_set_extra_space( int size ); 27 | void edalloc_buffer_remove_line( EDITOR_BUFFER* b, int line ); 28 | int edalloc_buffer_add_line( EDITOR_BUFFER* b, int line, char* pline ); 29 | int edalloc_set_fname( EDITOR_BUFFER *b, const char *name ); 30 | void edalloc_clear_selection( EDITOR_BUFFER *b ); 31 | void edalloc_reset_used_selection( EDITOR_BUFFER *b ); 32 | int edalloc_fill_selection( EDITOR_BUFFER *b ); 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /inc/editor/ededit.h: -------------------------------------------------------------------------------- 1 | // Actual text editing functionality 2 | // (yes, I know, very bad name for a file) 3 | 4 | #ifndef __EDEDIT_H__ 5 | #define __EDEDIT_H__ 6 | 7 | #include "type.h" 8 | #include "editor.h" 9 | 10 | int ededit_handle_key( int c ); 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /inc/editor/edhw.h: -------------------------------------------------------------------------------- 1 | // Editor hardware related functions 2 | 3 | #ifndef __EDHW_H__ 4 | #define __EDHW_H__ 5 | 6 | #include "type.h" 7 | #include "editor.h" 8 | 9 | // Message types 10 | #define EDHW_MSG_ERROR 0 11 | #define EDHW_MSG_INFO 1 12 | #define EDHW_MSG_WARNING 2 13 | 14 | // Dialog button 15 | #define EDHW_DLG_YES 1 16 | #define EDHW_DLG_NO 2 17 | #define EDHW_DLG_CANCEL 4 18 | #define EDHW_DLG_OK 8 19 | #define EDHW_DLG_TOTAL 4 20 | 21 | // Input validator function 22 | typedef int ( *p_ed_validate )( const char *crt, int c ); 23 | 24 | // Return value from validator meaning "exit now" 25 | #define EDHW_VALIDATE_EXIT 0xFF 26 | 27 | // Editor HW interface 28 | int edhw_init(); 29 | int edhw_getkey( void ); 30 | void edhw_clrscr(); 31 | void edhw_clearline( int line ); 32 | void edhw_writechar( char c ); 33 | void edhw_writetext( const char* text ); 34 | //void edhw_setcolors( int fgcol, int bgcol ); 35 | void edhw_invertcols( int flag ); 36 | void edhw_gotoxy( int x, int y ); 37 | void edhw_setcursor( int type ); 38 | void edhw_longline( int enable ); 39 | void edhw_selectedline( int y, int enable ); 40 | void edhw_markselected( int enable ); 41 | void edhw_msg( const char *text, int type, const char *title ); 42 | char* edhw_read( const char *title, const char *text, unsigned maxlen, p_ed_validate validator ); 43 | int edhw_dlg( const char *text, int type, const char *title ); 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /inc/editor/edmove.h: -------------------------------------------------------------------------------- 1 | // Editor movement functions 2 | 3 | #ifndef __EDMOVE_H__ 4 | #define __EDMOVE_H__ 5 | 6 | #include "type.h" 7 | #include "editor.h" 8 | 9 | int edmove_handle_key( int c ); 10 | void edmove_key_end(); 11 | void edmove_set_cursorx( int x ); 12 | void edmove_set_cursory( int y ); 13 | void edmove_goto_line( int y ); 14 | void edmove_save_cursorx(); 15 | void edmove_restore_cursor(); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /inc/editor/edutils.h: -------------------------------------------------------------------------------- 1 | // General utilities 2 | 3 | #ifndef __EDUTILS_H__ 4 | #define __EDUTILS_H__ 5 | 6 | #include "type.h" 7 | #include "editor.h" 8 | 9 | char* edutils_line_get( int id ); 10 | void edutils_line_set( int id, char* pline ); 11 | int edutils_get_actsize( const char* pdata ); 12 | int edutils_is_flag_set( EDITOR_BUFFER* b, int flag ); 13 | void edutils_set_flag( EDITOR_BUFFER* b, int flag, int value ); 14 | void edutils_display_status(); 15 | void edutils_line_display( int scrline, int id ); 16 | void edutils_show_screen(); 17 | int edutils_number_validator( const char *input, int c ); 18 | int edutils_fname_validator( const char *input, int c ); 19 | void edutils_update_selection(); 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /inc/editor/edvars.h: -------------------------------------------------------------------------------- 1 | // Editor variables 2 | 3 | #ifndef __EDVARS_H__ 4 | #define __EDVARS_H__ 5 | 6 | #ifndef EDITOR_MAIN_FILE 7 | #define EDSPEC 8 | #else 9 | #define EDSPEC extern 10 | #endif 11 | 12 | EDSPEC EDITOR_BUFFER *ed_crt_buffer; // current editor file data 13 | 14 | #define ed_startx ed_crt_buffer->startx 15 | #define ed_startline ed_crt_buffer->startline 16 | #define ed_cursorx ed_crt_buffer->cursorx 17 | #define ed_cursory ed_crt_buffer->cursory 18 | #define ed_nlines ed_crt_buffer->nlines 19 | #define ed_userstartx ed_crt_buffer->userstartx 20 | #define ed_userx ed_crt_buffer->userx 21 | #define ed_firstsel ed_crt_buffer->firstsel 22 | #define ed_lastsel ed_crt_buffer->lastsel 23 | #define ed_sellines ed_crt_buffer->sellines 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /inc/elua_rfs.h: -------------------------------------------------------------------------------- 1 | // eLua remote file system 2 | 3 | #ifndef __ELUA_RFS_H__ 4 | #define __ELUA_RFS_H__ 5 | 6 | #include "devman.h" 7 | 8 | DM_DEVICE* remotefs_init(); 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /inc/elua_uip.h: -------------------------------------------------------------------------------- 1 | // UIP "helper" for eLua 2 | // Implements the eLua specific UIP application 3 | 4 | #ifndef __ELUA_UIP_H__ 5 | #define __ELUA_UIP_H__ 6 | 7 | #include "type.h" 8 | #include "elua_net.h" 9 | 10 | // eLua UIP application states 11 | enum 12 | { 13 | ELUA_UIP_STATE_IDLE = 0, 14 | ELUA_UIP_STATE_SEND, 15 | ELUA_UIP_STATE_RECV, 16 | ELUA_UIP_STATE_CONNECT, 17 | ELUA_UIP_STATE_CLOSE, 18 | ELUA_UIP_STATE_CLOSE_ACK, 19 | ELUA_UIP_STATE_RETRY 20 | }; 21 | 22 | #define ELUA_UIP_UDP_FIRST_ID 16384 23 | #define ELUA_UIP_IS_UDP( s ) ( ( s ) >= ELUA_UIP_UDP_FIRST_ID ) 24 | #define ELUA_UIP_TO_UDP( s ) ( ( s ) >= 0 ? ( s ) + ELUA_UIP_UDP_FIRST_ID : ( s ) ) 25 | #define ELUA_UIP_FROM_UDP( s ) ( ( s ) >= ELUA_UIP_UDP_FIRST_ID ? ( s ) - ELUA_UIP_UDP_FIRST_ID : -1 ) 26 | 27 | // eLua UIP state 28 | struct elua_uip_state 29 | { 30 | u8 state, res; 31 | char *ptr, *buf; 32 | elua_net_size len; 33 | s16 split; 34 | elua_net_size buf_total, buf_crt, buf_ridx, buf_widx; 35 | p_elua_net_recv_cb recv_cb; 36 | }; 37 | 38 | struct uip_eth_addr; 39 | 40 | // Helper functions 41 | void elua_uip_appcall(); 42 | void elua_uip_udp_appcall(); 43 | void elua_uip_init( const struct uip_eth_addr* paddr ); 44 | void elua_uip_mainloop(); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /inc/help.h: -------------------------------------------------------------------------------- 1 | // Online help reader 2 | 3 | #ifndef __HELP_H__ 4 | #define __HELP_H__ 5 | 6 | #define HELP_COLOR_SUPPORT 7 | #define HELP_FILE_NAME "/rom/eluadoc.bin" 8 | 9 | #include "type.h" 10 | 11 | // This defines a module 12 | typedef struct 13 | { 14 | const char *name; 15 | const char *desc; 16 | u16 nfuncs; 17 | const char **pfuncs; 18 | } HELP_MOD_DATA; 19 | 20 | int help_init( const char *fname ); 21 | void help_close(); 22 | int help_get_num_modules(); 23 | const char* help_get_module_name_at( int index ); 24 | const char* help_get_module_overview_at( int index ); 25 | HELP_MOD_DATA* help_load_module_idx( int index ); 26 | HELP_MOD_DATA* help_load_module_name( const char *name ); 27 | void help_unload_module(); 28 | void help_help( const char *topic ); 29 | 30 | #ifdef HELP_COLOR_SUPPORT 31 | #define HRESET "\xFF" 32 | #define HBLACK "\x80" 33 | #define HDBLUE "\x81" 34 | #define HDGREEN "\x82" 35 | #define HDCYAN "\x83" 36 | #define HDRED "\x84" 37 | #define HDMAGENTA "\x85" 38 | #define HDBROWN "\x86" 39 | #define HLGRAY "\x87" 40 | #define HDGRAY "\x88" 41 | #define HLBLUE "\x89" 42 | #define HLGREEN "\x8A" 43 | #define HLCYAN "\x8B" 44 | #define HLRED "\x8C" 45 | #define HLMAGENTA "\x8D" 46 | #define HLYELLOW "\x8E" 47 | #define HWHITE "\x8F" 48 | #else // #ifdef HELP_COLOR_SUPPORT 49 | #define HRESET "" 50 | #define HBLACK "" 51 | #define HDBLUE "" 52 | #define HDGREEN "" 53 | #define HDCYAN "" 54 | #define HDRED "" 55 | #define HDMAGENTA "" 56 | #define HDBROWN "" 57 | #define HLGRAY "" 58 | #define HDGRAY "" 59 | #define HLBLUE "" 60 | #define HLGREEN "" 61 | #define HLCYAN "" 62 | #define HLRED "" 63 | #define HLMAGENTA "" 64 | #define HLYELLOW "" 65 | #define HWHITE "" 66 | #endif // #ifdef HELP_COLOR_SUPPORT 67 | 68 | #endif // #ifndef __HELP_H__ 69 | 70 | -------------------------------------------------------------------------------- /inc/mmcfs.h: -------------------------------------------------------------------------------- 1 | // MMC filesystem 2 | 3 | #ifndef __MMCFS_H__ 4 | #define __MMCFS_H__ 5 | 6 | #include "type.h" 7 | #include "devman.h" 8 | 9 | // FS functions 10 | const DM_DEVICE* mmcfs_init(); 11 | void mmcfs_int_handler(); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /inc/newlib/genstd.h: -------------------------------------------------------------------------------- 1 | // stdio/stdout/stderr and generic console support 2 | 3 | #ifndef __GENSTD_H__ 4 | #define __GENSTD_H__ 5 | 6 | #include "type.h" 7 | #include "devman.h" 8 | #include "platform.h" 9 | 10 | // STD device name (for devman) 11 | #define STD_DEV_NAME "/std" 12 | 13 | #define STD_INFINITE_TIMEOUT PLATFORM_UART_INFINITE_TIMEOUT 14 | #define STD_INTER_CHAR_TIMEOUT 10000 15 | 16 | // Send/receive function types 17 | typedef void ( *p_std_send_char )( int fd, char c ); 18 | typedef int ( *p_std_get_char )( s32 to ); 19 | 20 | // STD functions 21 | void std_set_send_func( p_std_send_char pfunc ); 22 | void std_set_get_func( p_std_get_char pfunc ); 23 | const DM_DEVICE* std_get_desc(); 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /inc/newlib/ioctl.h: -------------------------------------------------------------------------------- 1 | // Just a declaration of the "ioctl" function, as it does not appear in the Newlib headers 2 | 3 | #ifndef __IOCTL_H__ 4 | #define __IOCTL_H__ 5 | 6 | #include 7 | 8 | // ************************** Generic IOCTL calls ***************************** 9 | 10 | // Seek 11 | #define FDSEEK 0x01 12 | struct fd_seek 13 | { 14 | _off_t off; 15 | int dir; 16 | }; 17 | 18 | // ***************** Base IOCTRL numbers for other devices ********************* 19 | #define IOCTL_BASE_UART 0x100 20 | 21 | // Function prototype 22 | int ioctl( int file, unsigned long request, void *ptr ); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /inc/nrf/nrf_ll.h: -------------------------------------------------------------------------------- 1 | // Low level nRF operations (must be implemented by host) 2 | 3 | #ifndef __NRF_LL_H__ 4 | #define __NRF_LL_H__ 5 | 6 | #include "type.h" 7 | 8 | void nrf_ll_init( void ); 9 | void nrf_ll_set_ce( int state ); 10 | void nrf_ll_set_csn( int state ); 11 | int nrf_ll_get_irq( void ); 12 | void nrf_ll_send_packet( const u8 *packet, u16 len ); 13 | void nrf_ll_read_packet( u8 *packet, u16 len ); 14 | void nrf_ll_flush( u16 len ); 15 | void nrf_ll_delay_us( u32 delay ); 16 | 17 | #define nrf_ll_ce_low() nrf_ll_set_ce( 0 ) 18 | #define nrf_ll_ce_high() nrf_ll_set_ce( 1 ) 19 | #define nrf_ll_csn_low() nrf_ll_set_csn( 0 ) 20 | #define nrf_ll_csn_high() nrf_ll_set_csn( 1 ) 21 | 22 | #endif // #ifndef __NRF_LL_H__ 23 | 24 | -------------------------------------------------------------------------------- /inc/ps2.h: -------------------------------------------------------------------------------- 1 | // PS/2 keyboard decoder 2 | 3 | #ifndef __PS2_H__ 4 | #define __PS2_H__ 5 | 6 | #include "type.h" 7 | 8 | #define PS2_SHIFT 0x0001 9 | #define PS2_CTRL 0x0002 10 | #define PS2_ALT 0x0004 11 | #define PS2_BASEF_MASK ( PS2_SHIFT | PS2_CTRL | PS2_ALT ) 12 | #define PS2_BASEF_SHIFT 13 13 | #define PS2_RAW_TO_CODE( x ) ( ( x ) & ~( PS2_BASEF_MASK << PS2_BASEF_SHIFT ) ) 14 | #define PS2_RAW_TO_MODS( x ) ( ( ( x ) >> PS2_BASEF_SHIFT ) & PS2_BASEF_MASK ) 15 | 16 | void ps2_init(); 17 | int ps2_term_translate(); 18 | int ps2_get_rawkey( s32 timeout ); 19 | int ps2_std_get( s32 timeout ); 20 | int ps2_term_get( int mode ); 21 | int ps2_term_translate( int code ); 22 | 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /inc/remotefs/client.h: -------------------------------------------------------------------------------- 1 | // Remote filesystem client 2 | 3 | #ifndef __CLIENT_H__ 4 | #define __CLIENT_H__ 5 | 6 | #include "type.h" 7 | 8 | // Error codes 9 | #define CLIENT_OK 0 10 | #define CLIENT_ERR 1 11 | 12 | // RFS client send/receive functions 13 | typedef u32 ( *p_rfsc_send )( const u8 *p, u32 size ); 14 | typedef u32 ( *p_rfsc_recv )( u8 *p, u32 size, s32 timeout ); 15 | 16 | // Public interface 17 | void rfsc_setup( u8 *pbuf, p_rfsc_send rfsc_send_func, p_rfsc_recv rfsc_recv_func, u32 timeout ); 18 | void rfsc_set_timeout( u32 timeout ); 19 | int rfsc_open( const char* pathname, int flags, int mode ); 20 | s32 rfsc_write( int fd, const void *buf, u32 count ); 21 | s32 rfsc_read( int fd, void *buf, u32 count ); 22 | s32 rfsc_lseek( int fd, s32 offset, int whence ); 23 | int rfsc_close( int fd ); 24 | u32 rfsc_opendir( const char* name ); 25 | void rfsc_readdir( u32 d, const char **pname, u32 *psize, u32 *ptime ); 26 | int rfsc_closedir( u32 d ); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /inc/remotefs/os_io.h: -------------------------------------------------------------------------------- 1 | // OS interface for file I/O manipulation 2 | 3 | #ifndef __OS_IO_H__ 4 | #define __OS_IO_H__ 5 | 6 | #include "type.h" 7 | 8 | #ifdef WIN32_BUILD 9 | #define PLATFORM_PATH_SEPARATOR '\\' 10 | #define PLATFORM_MAX_FNAME_LEN 2048 11 | #else 12 | #define PLATFORM_PATH_SEPARATOR '/' 13 | #define PLATFORM_MAX_FNAME_LEN 2048 14 | #endif 15 | 16 | int os_open( const char *pathname, int flags, int mode ); 17 | u32 os_open_sys_flags_to_rfs_flags( int sysflags ); 18 | s32 os_write( int fd, const void *buf, u32 count ); 19 | s32 os_read( int fd, void *buf, u32 count ); 20 | int os_close( int fd ); 21 | s32 os_lseek( int fd, s32 offset, int whence ); 22 | u32 os_lseek_sys_whence_to_rfs_whence( int syswhence ); 23 | int os_isdir( const char *name ); 24 | u32 os_opendir( const char* name ); 25 | void os_readdir( u32 d, const char **pname ); 26 | int os_closedir( u32 d ); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /inc/romfs.h: -------------------------------------------------------------------------------- 1 | // Read-only ROM filesystem 2 | 3 | #ifndef __FS_H__ 4 | #define __FS_H__ 5 | 6 | #include "type.h" 7 | #include "devman.h" 8 | 9 | /******************************************************************************* 10 | The Read-Only "filesystem" resides in a contiguous zone of memory, with the 11 | following structure, repeated for each file: 12 | 13 | Filename: ASCIIZ, max length is DM_MAX_FNAME_LENGTH defined here, empty if last file 14 | File size: (2 bytes) 15 | File data: (file size bytes) 16 | 17 | *******************************************************************************/ 18 | 19 | enum 20 | { 21 | FS_FILE_NOT_FOUND, 22 | FS_FILE_OK 23 | }; 24 | 25 | // This is the function used to read a byte at the given address from the file 26 | // system 27 | typedef u8 ( *p_read_fs_byte )( u32 ); 28 | 29 | // A small "FILE" structure 30 | typedef struct 31 | { 32 | u32 baseaddr; 33 | u32 offset; 34 | u32 size; 35 | p_read_fs_byte p_read_func; 36 | } FS; 37 | 38 | // FS functions 39 | const DM_DEVICE* romfs_init(); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /inc/rtype.h: -------------------------------------------------------------------------------- 1 | // Type definitions for the remote file system 2 | 3 | #ifndef __RTYPE_H__ 4 | #define __RTYPE_H__ 5 | 6 | // Type codes 7 | #define TYPE_INT_8 0x01 8 | #define TYPE_INT_16 0x02 9 | #define TYPE_INT_32 0x03 10 | #define TYPE_PTR 0x04 11 | #define TYPE_START 0x05 12 | #define TYPE_END 0x06 13 | #define TYPE_OP_ID 0x07 14 | #define TYPE_SMALL_PTR 0x08 15 | #define TYPE_PKT_SIZE 0xA5 16 | #define TYPE_DISCOVER 0xC8 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /inc/salloc.h: -------------------------------------------------------------------------------- 1 | // A very simple, quite inneficient, yet very small memory allocator 2 | 3 | #ifndef __SALLOC_H__ 4 | #define __SALLOC_H__ 5 | 6 | #include 7 | 8 | void* smalloc( size_t size ); 9 | void sfree( void* ptr ); 10 | void* scalloc( size_t nmemb, size_t size ); 11 | void* srealloc( void* ptr, size_t size ); 12 | 13 | #endif // #ifndef __SALLOC_H__ 14 | 15 | -------------------------------------------------------------------------------- /inc/semifs.h: -------------------------------------------------------------------------------- 1 | // Semihosting filesystem 2 | 3 | #ifndef __SEMIFS_H__ 4 | #define __SEMIFS_H__ 5 | 6 | #include "type.h" 7 | #include "devman.h" 8 | #include 9 | 10 | // ARM Semihosting Commands 11 | #define SYS_OPEN (0x1) 12 | #define SYS_CLOSE (0x2) 13 | #define SYS_WRITE (0x5) 14 | #define SYS_READ (0x6) 15 | #define SYS_ISTTY (0x9) 16 | #define SYS_SEEK (0xa) 17 | #define SYS_ENSURE (0xb) 18 | #define SYS_FLEN (0xc) 19 | 20 | // Required Structures 21 | // These structures provided by Simon Ford of mbed 22 | typedef struct { 23 | uint8_t hr; /* Hours [0..23] */ 24 | uint8_t min; /* Minutes [0..59] */ 25 | uint8_t sec; /* Seconds [0..59] */ 26 | uint8_t day; /* Day [1..31] */ 27 | uint8_t mon; /* Month [1..12] */ 28 | uint16_t year; /* Year [1980..2107] */ 29 | } FTIME; // 7 bytes 30 | 31 | typedef struct { // File Search info record 32 | char name[32]; // File - 32-bytes 33 | uint32_t size; // File size in bytes - 4-bytes 34 | uint16_t fileID; // System File Identification - 2-bytes 35 | FTIME create_time; // Date & time file was created 36 | FTIME write_time; // Date & time of last write 37 | } XFINFO; 38 | 39 | typedef struct { 40 | char *pattern; 41 | XFINFO file_info; 42 | } SEARCHINFO; 43 | 44 | 45 | // FS functions 46 | const DM_DEVICE* semifs_init(); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /inc/serial.h: -------------------------------------------------------------------------------- 1 | // Generic serial interface 2 | 3 | #ifndef __SERIAL_H__ 4 | #define __SERIAL_H__ 5 | 6 | #include "type.h" 7 | 8 | #define SER_INF_TIMEOUT 0xFFFFFFFF 9 | #define SER_NO_TIMEOUT 0 10 | #define SER_OK 0 11 | #define SER_ERR 1 12 | 13 | // Serial interface modes (blocking or non blocking) 14 | #define SER_MODE_BLOCKING 0 15 | #define SER_MODE_NONBLOCKING 1 16 | 17 | // Setup constants 18 | #define SER_PARITY_NONE 0 19 | #define SER_PARITY_EVEN 1 20 | #define SER_PARITY_ODD 2 21 | 22 | #define SER_STOPBITS_1 0 23 | #define SER_STOPBITS_1_5 1 24 | #define SER_STOPBITS_2 2 25 | 26 | #define SER_DATABITS_5 5 27 | #define SER_DATABITS_6 6 28 | #define SER_DATABITS_7 7 29 | #define SER_DATABITS_8 8 30 | 31 | // Define serial port "handle" type for each platform 32 | #ifdef WIN32_BUILD 33 | #include 34 | typedef HANDLE ser_handler; 35 | #else // assume POSIX here 36 | typedef int ser_handler; 37 | #endif 38 | 39 | // Serial access functions (to be implemented by each platform) 40 | ser_handler ser_open( const char *sername ); 41 | void ser_close( ser_handler id ); 42 | int ser_setup( ser_handler id, u32 baud, int databits, int parity, int stopbits ); 43 | u32 ser_read( ser_handler id, u8* dest, u32 maxsize ); 44 | int ser_read_byte( ser_handler id ); 45 | u32 ser_write( ser_handler id, const u8 *src, u32 size ); 46 | u32 ser_write_byte( ser_handler id, u8 data ); 47 | void ser_set_timeout_ms( ser_handler id, u32 timeout ); 48 | int ser_readable( ser_handler id ); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /inc/sermux.h: -------------------------------------------------------------------------------- 1 | // Serial multiplexer definitions 2 | 3 | #ifndef __SERMUX_H__ 4 | #define __SERMUX_H__ 5 | 6 | #define SERMUX_SERVICE_ID_FIRST 0xD0 7 | #define SERMUX_SERVICE_ID_LAST 0xD7 8 | #define SERMUX_SERVICE_MAX ( SERMUX_SERVICE_ID_LAST - SERMUX_SERVICE_ID_FIRST + 1 ) 9 | 10 | #define SERMUX_ESCAPE_CHAR 0xC0 11 | #define SERMUX_FORCE_SID_CHAR 0xFF 12 | 13 | #define SERMUX_ESCAPE_XOR_MASK 0x20 14 | #define SERMUX_ESC_MASK 0x100 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /inc/shell.h: -------------------------------------------------------------------------------- 1 | // eLua shell 2 | 3 | #ifndef __SHELL_H__ 4 | #define __SHELL_H__ 5 | 6 | #include "term.h" 7 | 8 | #define SHELL_WELCOMEMSG "\neLua %s (STMBrain version) Copyright (C) 2007-2011 www.eluaproject.net\n" 9 | #define SHELL_PROMPT "brain> " 10 | #define SHELL_PROMPT_COLOR TERM_FGCOL_LIGHT_RED 11 | #define SHELL_COMMAND_COLOR TERM_FGCOL_LIGHT_GREEN 12 | #define SHELL_ERRMSG "Invalid command, type 'help' for help\n" 13 | #define SHELL_MAXSIZE 50 14 | #define SHELL_MAX_LUA_ARGS 8 15 | 16 | int shell_init(); 17 | void shell_start(); 18 | 19 | #endif // #ifndef __SHELL_H__ 20 | -------------------------------------------------------------------------------- /inc/utils.h: -------------------------------------------------------------------------------- 1 | // General purpose function/macros 2 | 3 | #ifndef __UTILS_H__ 4 | #define __UTILS_H__ 5 | 6 | #define ABSDIFF( x, y ) ( ( x ) >= ( y ) ? ( x ) - ( y ) : ( y ) - ( x ) ) 7 | #define UMIN( x, y ) ( ( x ) <= ( y ) ? ( x ) : ( y ) ) 8 | #define UMAX( x, y ) ( ( x ) >= ( y ) ? ( x ) : ( y ) ) 9 | #define UABS( x ) ( ( x ) >= 0 ? ( x ) : -( x ) ) 10 | 11 | // Implement a very simple try-catch ike mechanism using setmp/longjmp, 12 | // mostly to avoid goto's :) 13 | #define EXC_DECLARE static jmp_buf exception_buf 14 | #define EXC_TRY if( setjmp( exception_buf ) == 0 ) 15 | #define EXC_CATCH else 16 | #define EXC_THROW() longjmp( exception_buf, 1 ) 17 | 18 | // Macro version of Duff's device found in 19 | // "A Reusable Duff Device" by Ralf Holly 20 | // Dr Dobb's Journal, August 1, 2005 21 | 22 | #define DUFF_DEVICE_8(count, action) \ 23 | do { \ 24 | int _count = ( count ); \ 25 | int _times = ( _count + 7 ) >> 3; \ 26 | switch ( _count & 7 ){ \ 27 | case 0: do { action; \ 28 | case 7: action; \ 29 | case 6: action; \ 30 | case 5: action; \ 31 | case 4: action; \ 32 | case 3: action; \ 33 | case 2: action; \ 34 | case 1: action; \ 35 | } while (--_times > 0); \ 36 | } \ 37 | } while (0) 38 | 39 | #define STD_CTRLZ_CODE 26 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /inc/version.h: -------------------------------------------------------------------------------- 1 | // eLua version information 2 | 3 | #ifndef __VERSION_H__ 4 | #define __VERSION_H__ 5 | 6 | #define ELUA_VERSION v0.8 7 | #define ELUA_STR_VERSION "v0.8" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /inc/xmodem.h: -------------------------------------------------------------------------------- 1 | // XMODEM for eLua 2 | 3 | #ifndef __XMODEM_H__ 4 | #define __XMODEM_H__ 5 | 6 | #include "type.h" 7 | 8 | // XMODEM constants 9 | #define XMODEM_INITIAL_BUFFER_SIZE 1024 10 | #define XMODEM_INCREMENT_AMMOUNT 512 11 | 12 | // xmodem timeout/retry parameters 13 | #define XMODEM_TIMEOUT 1000000 14 | #define XMODEM_RETRY_LIMIT 20 15 | 16 | // error return codes 17 | #define XMODEM_ERROR_REMOTECANCEL (-1) 18 | #define XMODEM_ERROR_OUTOFSYNC (-2) 19 | #define XMODEM_ERROR_RETRYEXCEED (-3) 20 | #define XMODEM_ERROR_OUTOFMEM (-4) 21 | 22 | typedef void ( *p_xm_send_func )( u8 ); 23 | typedef int ( *p_xm_recv_func )( u32 ); 24 | long xmodem_receive( char** dest ); 25 | void xmodem_init( p_xm_send_func send_func, p_xm_recv_func recv_func ); 26 | 27 | #endif // #ifndef __XMODEM_H__ 28 | -------------------------------------------------------------------------------- /mux.lua: -------------------------------------------------------------------------------- 1 | local args = { ... } 2 | local b = require "utils.build" 3 | local builder = b.new_builder( ".build/mux" ) 4 | local utils = b.utils 5 | builder:init( args ) 6 | builder:set_build_mode( builder.BUILD_DIR_LINEARIZED ) 7 | 8 | local flist = "main.c" 9 | local rfs_flist = "main.c server.c log.c deskutils.c rfs_transports.c" 10 | local cdefs = "RFS_UDP_TRANSPORT RFS_INSIDE_MUX_MODE" 11 | local socklib 12 | if utils.is_windows() then 13 | cdefs = cdefs .. " WIN32_BUILD" 14 | rfs_flist = rfs_flist .. " os_io_win32.c serial_win32.c net_win32.c" 15 | exeprefix = ".exe" 16 | socklib = "ws2_32" 17 | else 18 | rfs_flist = rfs_flist .. " os_io_posix.c serial_posix.c net_posix.c" 19 | exeprefix = "" 20 | end 21 | 22 | local full_files = utils.prepend_path( flist, "mux_src" ) .. utils.prepend_path( rfs_flist, "rfs_server_src" ) .. "src/remotefs/remotefs.c src/eluarpc.c" 23 | local local_include = "mux_src rfs_server_src inc inc/remotefs" 24 | local compcmd = builder:compile_cmd{ flags = "-m32 -O0 -Wall -g", defines = cdefs, includes = local_include } 25 | local linkcmd = builder:link_cmd{ flags = "-m32", libraries = socklib } 26 | builder:set_compile_cmd( compcmd ) 27 | builder:set_link_cmd( linkcmd ) 28 | builder:set_exe_extension( exeprefix ) 29 | 30 | -- Build everyting 31 | builder:make_exe_target( "mux", full_files ) 32 | builder:build() 33 | 34 | -------------------------------------------------------------------------------- /mux.py: -------------------------------------------------------------------------------- 1 | import os, sys, platform 2 | 3 | flist = "main.c" 4 | rfs_flist = "main.c server.c log.c deskutils.c rfs_transports.c" 5 | cdefs = "-DRFS_UDP_TRANSPORT -DRFS_INSIDE_MUX_MODE" 6 | socklib = '' 7 | ptlib = '' 8 | if platform.system() == "Windows": 9 | cdefs = cdefs + " -DWIN32_BUILD" 10 | rfs_flist = rfs_flist + " os_io_win32.c serial_win32.c net_win32.c" 11 | exeprefix = ".exe" 12 | socklib = '-lws2_32' 13 | else: 14 | rfs_flist = rfs_flist + " os_io_posix.c serial_posix.c net_posix.c" 15 | exeprefix = "" 16 | socklib = '' 17 | 18 | output = "mux%s" % exeprefix 19 | 20 | rfs_full_files = " " + " ".join( [ "rfs_server_src/%s" % name for name in rfs_flist.split() ] ) 21 | full_files = " " + " ".join( [ "mux_src/%s" % name for name in flist.split() ] ) + rfs_full_files + " src/remotefs/remotefs.c src/eluarpc.c" 22 | local_include = "-Imux_src -Irfs_server_src -Iinc -Iinc/remotefs" 23 | 24 | # Compiler/linker options 25 | cccom = "gcc -m32 -O0 -g %s -Wall %s -c $SOURCE -o $TARGET" % ( local_include, cdefs ) 26 | linkcom = "gcc -m32 -o $TARGET $SOURCES %s" % socklib 27 | 28 | # Env for building the program 29 | comp = Environment( CCCOM = cccom, 30 | LINKCOM = linkcom, 31 | ENV = os.environ ) 32 | Decider( 'MD5' ) 33 | Default( comp.Program( output, Split( full_files ) ) ) 34 | -------------------------------------------------------------------------------- /mux_src/config.h: -------------------------------------------------------------------------------- 1 | // Service multiplexer configurator 2 | 3 | #ifndef __CONFIG_H__ 4 | #define __CONFIG_H__ 5 | 6 | #include "sermux.h" 7 | 8 | #define SER_TIMEOUT_MS 100 9 | #define NET_TIMEOUT_MS 100 10 | #define MEM_BUF_SIZE ( 6 * 1024 ) 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /others/bdf2img/bdf2img.py: -------------------------------------------------------------------------------- 1 | # Script for converting a bdf file to a C source 2 | 3 | import os, sys 4 | import getopt, math 5 | from bdflib import BDF, BDFChar 6 | from PIL import Image 7 | 8 | chars = None 9 | charno = 0 10 | x = 0 11 | y = 0 12 | 13 | def printchar( font, code, im ): 14 | ch = font.getchar( code ) 15 | if ch is None: 16 | print "ERROR: cannot get data for char %d" % code 17 | return 18 | 19 | # Generate char data 20 | for line in xrange( 0, 12 ): 21 | data = ch.bitmap[ line ] 22 | mask = 1 << ( 8 - 1 ) 23 | bitno = 0 24 | while mask != 0: 25 | if data & mask: 26 | sys.stdout.write( 'X' ) 27 | im.putpixel( ( x + bitno, y + line ), 1 ) 28 | else: 29 | sys.stdout.write(' ') 30 | mask = mask >> 1 31 | bitno = bitno + 1 32 | print 33 | 34 | ################################################################################ 35 | # The program starts here 36 | 37 | font = BDF("cp437-8x12.bdf") 38 | if not font.open(): 39 | print "Cannot open %s" % args_proper[0] 40 | sys.exit(0) 41 | res, a1, a2 = font.readallchars() 42 | if not res: 43 | print "Error %s at line %d" % (a1, a2) 44 | sys.exit(0) 45 | 46 | chars = range( 0, 256 ) 47 | 48 | im = Image.new( "1", ( 128, 192 ), 0 ) 49 | 50 | # Process all chars 51 | for ch in chars: 52 | printchar( font, ch, im ) 53 | charno = charno + 1 54 | if charno == 16: 55 | y = y + 12 56 | x = 0 57 | charno = 0 58 | else: 59 | x = x + 8 60 | 61 | im.save( "fontdata.png" ) 62 | 63 | -------------------------------------------------------------------------------- /others/bdf2img/font.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import sys 3 | 4 | cheight = 12 5 | sects = cheight / 4 6 | 7 | def outdigit( x ): 8 | if x < 10: 9 | sys.stdout.write( chr( x + ord( "0" ) ) ) 10 | else: 11 | sys.stdout.write( chr( x - 10 + ord( "a" ) ) ) 12 | 13 | def outhex( x ): 14 | outdigit( ( x & 0xF0 ) >> 4 ) 15 | outdigit( x & 0x0F ) 16 | 17 | im = Image.open( "fontdata.png" ) 18 | chars = [ 0 ] * 256 * cheight 19 | for ch in xrange( 0, 256 ): 20 | line = ( ch / 16 ) * cheight 21 | col = ( ch % 16 ) * 8 22 | for i in xrange( 0, cheight ): 23 | ldata = 0 24 | mask = 1 25 | for j in xrange( 0, 8 ): 26 | p = im.getpixel( ( col + j, line + i ) ) 27 | if p != 0: 28 | ldata = ldata | mask 29 | mask = mask << 1 30 | chars[ ch * cheight + i ] = ldata 31 | 32 | for section in xrange( 0, sects ): 33 | longcnt = 0 34 | sys.stdout.write( " long "); 35 | for ch in xrange( 0, 256 ): 36 | start = ch * cheight + section * 4 37 | sys.stdout.write( "$" ) 38 | outhex( chars[ start + 3 ]) 39 | outhex( chars[ start + 2 ]) 40 | outhex( chars[ start + 1 ]) 41 | outhex( chars[ start ] ) 42 | longcnt = longcnt + 1 43 | if longcnt == 8: 44 | longcnt = 0 45 | print 46 | if start != 255 * cheight + section * 4: 47 | sys.stdout.write( " long "); 48 | else: 49 | sys.stdout.write( "," ) 50 | print 51 | -------------------------------------------------------------------------------- /others/getfntdata/font.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import sys 3 | 4 | def outdigit( x ): 5 | if x < 10: 6 | sys.stdout.write( chr( x + ord( "0" ) ) ) 7 | else: 8 | sys.stdout.write( chr( x - 10 + ord( "a" ) ) ) 9 | 10 | def outhex( x ): 11 | outdigit( ( x & 0xF0 ) >> 4 ) 12 | outdigit( x & 0x0F ) 13 | 14 | im = Image.open( "fontdata.png" ) 15 | chars = [ 0 ] * 256 * 16 16 | for ch in xrange( 0, 256 ): 17 | line = ( ch / 16 ) * 16 18 | col = ( ch % 16 ) * 8 19 | for i in xrange( 0, 16 ): 20 | ldata = 0 21 | mask = 1 22 | for j in xrange( 0, 8 ): 23 | p = im.getpixel( ( col + j, line + i ) ) 24 | if p != 0: 25 | ldata = ldata | mask 26 | mask = mask << 1 27 | chars[ ch * 16 + i ] = ldata 28 | 29 | for section in xrange( 0, 4 ): 30 | longcnt = 0 31 | sys.stdout.write( " long "); 32 | for ch in xrange( 0, 256 ): 33 | start = ch * 16 + section * 4 34 | sys.stdout.write( "$" ) 35 | outhex( chars[ start + 3 ]) 36 | outhex( chars[ start + 2 ]) 37 | outhex( chars[ start + 1 ]) 38 | outhex( chars[ start ] ) 39 | longcnt = longcnt + 1 40 | if longcnt == 8: 41 | longcnt = 0 42 | print 43 | if start != 255 * 16 + section * 4: 44 | sys.stdout.write( " long "); 45 | else: 46 | sys.stdout.write( "," ) 47 | print 48 | -------------------------------------------------------------------------------- /others/getfntdata/fontdata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/others/getfntdata/fontdata.png -------------------------------------------------------------------------------- /others/interrupts.txt: -------------------------------------------------------------------------------- 1 | Configuration: 2 | 3 bit(s) -> group 3 | 1 bit(s) -> subpriority 4 | 5 | Brain32 interrupts and their priorities 6 | ======================================= 7 | Group Sub 8 | SysTick 3 0 9 | Keyboard 0 0 10 | Ethernet 2 0 11 | UARTs 1 0 12 | Other GPIOs 5 0 13 | SD/MMC 4 0 14 | -------------------------------------------------------------------------------- /others/lights/inc/i2cee.h: -------------------------------------------------------------------------------- 1 | // 24LCxxx EEROM access routines 2 | 3 | #ifndef __I2CEE_H__ 4 | #define __I2CEE_H__ 5 | 6 | #include "type.h" 7 | 8 | void i2cee_init( void ); 9 | u16 i2cee_write_byte( u16 address, u8 data ); 10 | int i2cee_is_write_finished(); 11 | int i2cee_read_byte( u16 address ); 12 | u16 i2cee_write_block( u16 address, const u8 *pdata, u16 size ); 13 | u16 i2cee_read_block( u16 address, u8 *pdata, u16 size ); 14 | 15 | #endif // #ifndef __I2CEE_H__ 16 | 17 | -------------------------------------------------------------------------------- /others/lights/inc/ledvm.h: -------------------------------------------------------------------------------- 1 | // LED virtual machine 2 | 3 | #ifndef __LEDVM_H__ 4 | #define __LEDVM_H_ 5 | 6 | #include "type.h" 7 | 8 | #define LEDVM_REP_COUNTERS 8 9 | #define LEDVM_MAX_VAL 32 10 | #define LEDVM_MAX_CALLS 8 11 | #define LEDVM_EMPTY_MARK 0xAA55AA 12 | #define LEDVM_NUM_RAND 0xFF 13 | #define LEDVM_MASKNEW_BIT 0x08 14 | #define LEDVM_MASKR_BIT 0x04 15 | #define LEDVM_MASKG_BIT 0x02 16 | #define LEDVM_MASKB_BIT 0x01 17 | #define LEDVM_CNT_LIM 0 18 | #define LEDVM_DELTA_MASK 0x40 19 | #define LEDVM_NUM_MASK 0x3F 20 | 21 | // Errors 22 | enum 23 | { 24 | LEDVM_ERR_OK = 0, 25 | LEDVM_ERR_INVALID_OPCODE, 26 | LEDVM_ERR_INVALID_INSTRUCTION, 27 | LEDVM_ERR_TOO_MANY_CALLS, 28 | LEDVM_ERR_INVALID_PC, 29 | LEDVM_ERR_FINISHED 30 | }; 31 | 32 | void ledvm_init(); 33 | int ledvm_run(); 34 | u16 ledvm_get_pc(); 35 | 36 | // Low-level interface (to be implemented by host) 37 | void ledvm_ll_setrgb( s8 r, s8 g, s8 b ); 38 | void ledvm_ll_delayms_start( u32 ms ); 39 | int ledvm_ll_delay_elapsed(); 40 | int ledvm_ll_getinst( u16 pc, u8 *pinst ); 41 | int ledvm_ll_rand(); 42 | 43 | #endif // #ifndef __LEDVM_H_ 44 | 45 | -------------------------------------------------------------------------------- /others/lights/inc/nrf_conf.h: -------------------------------------------------------------------------------- 1 | // nRF configuration 2 | 3 | #ifndef __NRF_CONF_H__ 4 | #define __NRF_CONF_H__ 5 | 6 | #include "nrf.h" 7 | 8 | // Profile (server or client) 9 | #define NRF_CFG_PROFILE_CLIENT 10 | // RF channel 11 | #define NRF_CFG_RF_CHANNEL 2 12 | // TX power (0 is the highest, see NRF_RF_SETUP_PWR_xxx in nrf.h for more values) 13 | #define NRF_CFG_TX_POWER NRF_RF_SETUP_PWR_0 14 | // Data rate (1Mbps or 2Mbps) 15 | #define NRF_CFG_DATA_RATE NRF_RF_SETUP_DR_1MBPS 16 | // Client address pool (only for clients) 17 | #define NRF_CLIENT_ADDR_POOL { 0xC0, 0xBF, 0, 0, 0 } 18 | // Debugging on 19 | //#define NRF_DEBUG 20 | 21 | #endif // #ifndef __NRF_CONF_H__ 22 | 23 | -------------------------------------------------------------------------------- /others/lights/inc/pwm.h: -------------------------------------------------------------------------------- 1 | // PWM functions 2 | 3 | #ifndef __PWM_H__ 4 | #define __PWM_H__ 5 | 6 | #include "machine.h" 7 | 8 | void pwm_init(); 9 | void pwm_start(); 10 | void pwm_stop(); 11 | void pwm_set_frequency( u32 freq ); 12 | void pwm_set_duty( int duty ); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /others/lights/inc/type.h: -------------------------------------------------------------------------------- 1 | // Machine independent types 2 | 3 | #ifndef __TYPE_H__ 4 | #define __TYPE_H__ 5 | 6 | typedef char s8; 7 | typedef unsigned char u8; 8 | typedef int s16; 9 | typedef unsigned int u16; 10 | typedef long s32; 11 | typedef unsigned long u32; 12 | typedef long long s64; 13 | typedef unsigned long long u64; 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /others/lights/inc/uart.h: -------------------------------------------------------------------------------- 1 | // Asynchronous USART driver 2 | 3 | #ifndef __UART_H__ 4 | #define __UART_H__ 5 | 6 | #include "machine.h" 7 | 8 | void uart_init(); 9 | void uart_putchar( u8 c ); 10 | s16 uart_nb_getchar(); 11 | u8 uart_getchar(); 12 | u8 uart_getchar_to( u8 *, u16 ); 13 | void uart_empty_rx_buffer(); 14 | void uart_empty_tx_buffer(); 15 | u8 uart_bytes_received(); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /others/lights/pwm.c: -------------------------------------------------------------------------------- 1 | #include "pwm.h" 2 | #include "machine.h" 3 | #include 4 | 5 | //****************************************************************************** 6 | // Timer definitions 7 | #define start_timer() TCCR1B = ( TCCR1B & ( u8 )~0x07 ) | PWM_PRESCALER 8 | #define stop_timer() TCCR1B &= ~0x07 9 | 10 | // ***************************************************************************** 11 | // PWM functions 12 | 13 | // Initialize PWM 14 | // Output will be on OC1A (PB1) 15 | void pwm_init() 16 | { 17 | stop_timer(); 18 | // Mode = 1110 (fast PWM with TOP in ICR1) 19 | // OC1A: clear on compare match, set on BOTTOM (non-inverting mode) 20 | TCCR1B |= _BV( WGM13 ) | _BV( WGM12 ); 21 | TCCR1A |= _BV( WGM11 ) | _BV( COM1A1 ); 22 | // Set OCR1A (PB1) as output 23 | PORTB &= ~_BV( PB1 ); 24 | DDRB |= _BV( PB1 ); 25 | } 26 | 27 | // Start PWM 28 | void pwm_start() 29 | { 30 | start_timer(); 31 | } 32 | 33 | // Stop PWM 34 | void pwm_stop() 35 | { 36 | stop_timer(); 37 | TCNT1 = 0; 38 | } 39 | 40 | // Set PWM frequency 41 | void pwm_set_frequency( u32 freq ) 42 | { 43 | ICR1 = ( PWM_CLOCK / freq ) - 1; 44 | } 45 | 46 | // Setup PWM duty cycle (from 0% to 100%) 47 | void pwm_set_duty( int duty ) 48 | { 49 | OCR1A = ( ICR1 * duty ) / 100; 50 | } 51 | -------------------------------------------------------------------------------- /others/vgademo-0.0.3/connections.txt: -------------------------------------------------------------------------------- 1 | REQ GND 2 | MISO MOSI 3 | CS SCK 4 | 5 | Memory 6 | 1 - CS (PB12) 7 | 2 - MISO (PB14) 8 | 3 - NC 9 | 4 - VSS 10 | 5 - MOSI (PB15) 11 | 6 - CLK (PB13) 12 | 7 - /HOLD 13 | 8 - VCC 14 | 15 | REQ -> PC5 -------------------------------------------------------------------------------- /others/vgademo-0.0.3/vgademo.spin: -------------------------------------------------------------------------------- 1 | CON 2 | _xinfreq = 5_000_000 ' Quartz is 5MHz 3 | _clkmode = xtal1 + pll16x ' System clock is 80MHz 4 | 5 | CHAR_W = 80 6 | CHAR_H = 30 7 | 8 | OBJ 9 | vga : "vgacolour" 10 | vram : "vram" 11 | 12 | PUB main|tmp, ramcnt, i 13 | 14 | ' Start components 15 | vga.start(16, @screen, @screen2, @cursor, @sync) 16 | vram.start(@sync, @screen, @screen2, @cursor) 17 | 18 | repeat 19 | waitcnt(10) 20 | 21 | 22 | DAT 23 | screen word $0720[CHAR_W*CHAR_H] 24 | screen2 word $0720[CHAR_W*CHAR_H] 25 | cursor byte 40,0,%010,0 26 | sync long 0 -------------------------------------------------------------------------------- /others/vgademo-0.0.3/vram.spin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/others/vgademo-0.0.3/vram.spin -------------------------------------------------------------------------------- /others/videov2/serial.spin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/others/videov2/serial.spin -------------------------------------------------------------------------------- /others/videov2/vgademo.spin: -------------------------------------------------------------------------------- 1 | CON 2 | _xinfreq = 5_000_000 ' Quartz is 5MHz 3 | _clkmode = xtal1 + pll16x ' System clock is 80MHz 4 | 5 | CHAR_W = 80 6 | CHAR_H = 30 7 | 8 | OBJ 9 | vga : "vgacolour" 10 | vram : "vram" 11 | serial : "serial" 12 | spi : "spi_asmfast" 13 | 14 | PUB main|tmp 15 | 16 | ' Start components 17 | vga.start(16, @screen, @screen2, @cursor, @sync) 18 | vram.start(@sync, @screen, @screen2, @cursor) 19 | serial.start(115200) 20 | spi.start 21 | 22 | repeat 23 | tmp := serial.rx 24 | outa[ serial#RTS_PIN] := 1 25 | tmp := spi.rw( tmp ) 26 | serial.tx( tmp ) 27 | outa[ serial#RTS_PIN] := 0 28 | 29 | 30 | DAT 31 | screen word $0720[CHAR_W*CHAR_H] 32 | screen2 word $0720[CHAR_W*CHAR_H] 33 | cursor byte 0,0,%010,0 34 | sync long 0 -------------------------------------------------------------------------------- /rfs_server.lua: -------------------------------------------------------------------------------- 1 | local args = { ... } 2 | local b = require "utils.build" 3 | local builder = b.new_builder( ".build/rfs_server" ) 4 | local utils = b.utils 5 | 6 | -- Set builder options BEFORE calling builder:init 7 | builder:add_option( 'sim', 'run under the eLua simulator', false ) 8 | builder:init( args ) 9 | builder:set_build_mode( builder.BUILD_DIR_LINEARIZED ) 10 | 11 | local sim = builder:get_option( 'sim' ) 12 | sim = sim and 1 or 0 13 | 14 | local flist, socklib 15 | local cdefs = "RFS_STANDALONE_MODE" 16 | local mainname = sim == 0 and 'main.c' or 'main_sim.c' 17 | local exeprefix = "" 18 | if utils.is_windows() then 19 | if sim == 1 then 20 | print "SIM target not supported under Windows" 21 | os.exit( 1 ) 22 | end 23 | flist = "main.c server.c os_io_win32.c log.c net_win32.c serial_win32.c deskutils.c rfs_transports.c" 24 | cdefs = cdefs .. " WIN32_BUILD" 25 | exeprefix = ".exe" 26 | socklib = 'ws2_32' 27 | else 28 | flist = mainname .. " server.c os_io_posix.c log.c net_posix.c serial_posix.c deskutils.c rfs_transports.c" 29 | end 30 | 31 | local output = sim == 0 and 'rfs_server' or 'rfs_sim_server' 32 | local local_include = "rfs_server_src inc/remotefs inc" 33 | local full_files = utils.prepend_path( flist, 'rfs_server_src' ) .. " src/remotefs/remotefs.c src/eluarpc.c" 34 | local compcmd = builder:compile_cmd{ flags = "-m32 -O0 -Wall -g", defines = cdefs, includes = local_include } 35 | local linkcmd = builder:link_cmd{ flags = "-m32", libraries = socklib } 36 | builder:set_compile_cmd( compcmd ) 37 | builder:set_link_cmd( linkcmd ) 38 | builder:set_exe_extension( exeprefix ) 39 | 40 | -- Build everything 41 | builder:make_exe_target( output, full_files ) 42 | builder:build() 43 | 44 | -------------------------------------------------------------------------------- /rfs_server.py: -------------------------------------------------------------------------------- 1 | import os, sys, platform 2 | 3 | sim = ARGUMENTS.get( 'sim', '0' ) 4 | 5 | flist = "" 6 | cdefs = "-DRFS_STANDALONE_MODE" 7 | socklib = '' 8 | if sim == '0': 9 | mainname = "main.c" 10 | else: 11 | mainname = 'main_sim.c' 12 | if platform.system() == "Windows": 13 | if sim == '1': 14 | print "SIM target not supported under Windows" 15 | os.exit( 1 ) 16 | flist = "main.c server.c os_io_win32.c log.c net_win32.c serial_win32.c deskutils.c rfs_transports.c" 17 | cdefs = cdefs + " -DWIN32_BUILD" 18 | exeprefix = ".exe" 19 | socklib = '-lws2_32' 20 | else: 21 | flist = "%s server.c os_io_posix.c log.c net_posix.c serial_posix.c deskutils.c rfs_transports.c" % mainname 22 | exeprefix = "" 23 | 24 | if sim == '0': 25 | output = 'rfs_server%s' % exeprefix 26 | else: 27 | output = 'rfs_sim_server%s' % exeprefix 28 | #endif 29 | 30 | full_files = " " + " ".join( [ "rfs_server_src/%s" % name for name in flist.split() ] ) 31 | full_files = full_files + " src/remotefs/remotefs.c src/eluarpc.c" 32 | local_include = "-Irfs_server_src -Iinc/remotefs -Iinc" 33 | 34 | # Compiler/linker options 35 | cccom = "gcc -m32 -O0 -g %s -Wall %s -c $SOURCE -o $TARGET" % ( local_include, cdefs ) 36 | linkcom = "gcc -m32 -o $TARGET $SOURCES %s" % socklib 37 | 38 | # Env for building the program 39 | comp = Environment( CCCOM = cccom, 40 | LINKCOM = linkcom, 41 | ENV = os.environ ) 42 | Decider( 'MD5' ) 43 | Default( comp.Program( output, Split( full_files ) ) ) 44 | 45 | -------------------------------------------------------------------------------- /rfs_server_src/deskutils.c: -------------------------------------------------------------------------------- 1 | // Utility functions for desktop programs 2 | 3 | #include "deskutils.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // Secure atoi 11 | int secure_atoi( const char *str, long *pres ) 12 | { 13 | char *end_ptr; 14 | long s1; 15 | 16 | errno = 0; 17 | s1 = strtol( str, &end_ptr, 10 ); 18 | if( ( s1 == LONG_MIN || s1 == LONG_MAX ) && errno != 0 ) 19 | return 0; 20 | else if( end_ptr == str ) 21 | return 0; 22 | else if( s1 > INT_MAX || s1 < INT_MIN ) 23 | return 0; 24 | else if( '\0' != *end_ptr ) 25 | return 0; 26 | *pres = s1; 27 | return 1; 28 | } 29 | 30 | // Local strndup function to compensate the lack of strndup in Windows 31 | char* l_strndup( const char* s, size_t n ) 32 | { 33 | char* p; 34 | 35 | if( ( p = ( char* )malloc( n + 1 ) ) == NULL ) 36 | return NULL; 37 | p [ 0 ] = p[ n ] = '\0'; 38 | strncpy( p, s, n ); 39 | return p; 40 | } 41 | -------------------------------------------------------------------------------- /rfs_server_src/deskutils.h: -------------------------------------------------------------------------------- 1 | // Utility functions for desktop programs 2 | 3 | #ifndef __DESKUTILS_H__ 4 | #define __DESKUTILS_H__ 5 | 6 | #include "type.h" 7 | #include 8 | 9 | int secure_atoi( const char *str, long *pres ); 10 | char* l_strndup( const char* s, size_t n ); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /rfs_server_src/log.c: -------------------------------------------------------------------------------- 1 | // Simple logging functions for the RFS server 2 | 3 | #include "log.h" 4 | #include 5 | #include 6 | 7 | static int log_level; 8 | 9 | void log_init( int level ) 10 | { 11 | log_level = level; 12 | } 13 | 14 | void log_msg( const char *msg, ... ) 15 | { 16 | va_list va; 17 | 18 | if( log_level == LOG_ALL ) 19 | { 20 | va_start( va, msg ); 21 | vprintf( msg, va ); 22 | va_end( va ); 23 | } 24 | } 25 | 26 | void log_err( const char *msg, ... ) 27 | { 28 | va_list va; 29 | 30 | va_start( va, msg ); 31 | vfprintf( stderr, msg, va ); 32 | va_end( va ); 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /rfs_server_src/log.h: -------------------------------------------------------------------------------- 1 | // Simple logging functions for the RFS server 2 | 3 | #ifndef __LOG_H__ 4 | #define __LOG_H__ 5 | 6 | // Logging levels 7 | #define LOG_NONE 0 8 | #define LOG_ALL 1 9 | 10 | void log_init( int level ); 11 | void log_msg( const char *msg, ... ); 12 | void log_err( const char* msg, ... ); 13 | 14 | #define LOG_SET_MODULE 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /rfs_server_src/main.c: -------------------------------------------------------------------------------- 1 | // Remote FS server 2 | 3 | #include "net.h" 4 | #include "remotefs.h" 5 | #include "eluarpc.h" 6 | #include "serial.h" 7 | #include "server.h" 8 | #include "type.h" 9 | #include "log.h" 10 | #include "os_io.h" 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "rfs.h" 17 | #include "deskutils.h" 18 | #include "rfs_transports.h" 19 | 20 | #ifdef RFS_STANDALONE_MODE 21 | int main( int argc, const char **argv ) 22 | { 23 | // Initialize data 24 | if( rfs_init( argc, argv ) != 0 ) 25 | return 1; 26 | 27 | // 'mem' transport doesn't work in this mode 28 | if( p_transport_data == &mem_transport_data ) 29 | { 30 | log_err( "Invalid transport in standalone mode.\n" ); 31 | return 1; 32 | } 33 | 34 | // Enter the server endless loop 35 | while( 1 ) 36 | { 37 | p_transport_data->f_read_request(); 38 | server_execute_request( rfs_buffer ); 39 | p_transport_data->f_send_response(); 40 | } 41 | 42 | p_transport_data->f_cleanup(); 43 | return 0; 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /rfs_server_src/net.h: -------------------------------------------------------------------------------- 1 | // Network functions 2 | 3 | #ifndef __NETINIT_H__ 4 | #define __NETINIT_H__ 5 | 6 | typedef int net_ssize_t; 7 | 8 | #ifdef WIN32_BUILD 9 | 10 | #include 11 | #include 12 | typedef int socklen_t; 13 | #define INVALID_SOCKET_VALUE NULL 14 | typedef struct 15 | { 16 | SOCKET s; 17 | OVERLAPPED o; 18 | } NET_DATA; 19 | typedef NET_DATA* NET_SOCKET; 20 | #define net_socket( d ) ( d )->s 21 | typedef HANDLE net_sync_object; 22 | 23 | #else // #ifdef WIN32_BUILD 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | typedef int NET_SOCKET; 31 | #define INVALID_SOCKET_VALUE ( -1 ) 32 | #define net_socket( s ) s 33 | typedef int net_sync_object; 34 | #endif // #ifdef WIN32_BUILD 35 | 36 | #define NET_INF_TIMEOUT ( -1 ) 37 | 38 | int net_init(); 39 | NET_SOCKET net_create_socket( int domain, int type, int protocol ); 40 | net_ssize_t net_recvfrom( NET_SOCKET s, void *buf, size_t len, int flags, struct sockaddr* from, socklen_t *fromlen, int timeout ); 41 | net_ssize_t net_sendto( NET_SOCKET s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen ); 42 | int net_close( NET_SOCKET s ); 43 | net_sync_object net_get_sync_object( NET_SOCKET s ); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /rfs_server_src/net_posix.c: -------------------------------------------------------------------------------- 1 | // Network functions (POSIX) 2 | 3 | #include "net.h" 4 | #include "log.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int net_init() 14 | { 15 | return 1; 16 | } 17 | 18 | NET_SOCKET net_create_socket( int domain, int type, int protocol ) 19 | { 20 | return socket( domain, type, protocol ); 21 | } 22 | 23 | net_ssize_t net_recvfrom( NET_SOCKET s, void *buf, size_t len, int flags, struct sockaddr* from, socklen_t *fromlen, int timeout ) 24 | { 25 | fd_set fds; 26 | struct timeval tv; 27 | 28 | FD_ZERO( &fds ); 29 | FD_SET( s, &fds ); 30 | tv.tv_sec = timeout / 1000000; 31 | tv.tv_usec = ( timeout % 1000000 ) * 1000; 32 | if( select( s + 1, &fds, NULL, NULL, timeout == NET_INF_TIMEOUT ? NULL : &tv ) <= 0 ) 33 | return 0; 34 | return recvfrom( s, buf, len, flags, from, fromlen ); 35 | } 36 | 37 | net_ssize_t net_sendto( NET_SOCKET s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen ) 38 | { 39 | return sendto( s, buf, len, flags, to, tolen ); 40 | } 41 | 42 | int net_close( NET_SOCKET s ) 43 | { 44 | return close( s ); 45 | } 46 | 47 | net_sync_object net_get_sync_object( NET_SOCKET s ) 48 | { 49 | return s; 50 | } 51 | -------------------------------------------------------------------------------- /rfs_server_src/rfs.h: -------------------------------------------------------------------------------- 1 | // RFS public interface (used by mux) 2 | 3 | #ifndef __RFS_H__ 4 | #define __RFS_H__ 5 | 6 | int rfs_init( int argc, const char **argv ); 7 | void rfs_mem_start_request(); 8 | int rfs_mem_read_request_packet( int c ); 9 | int rfs_mem_has_response(); 10 | void rfs_mem_write_response( u16 *plen, u8 **pdata ); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /rfs_server_src/rfs_transports.h: -------------------------------------------------------------------------------- 1 | #ifndef _RFS_TRANSPORTS_H 2 | #define _RFS_TRANSPORTS_H 3 | 4 | typedef void ( *p_read_request )( void ); 5 | typedef void ( *p_send_response )( void ); 6 | typedef void ( *p_cleanup )( void ); 7 | typedef struct 8 | { 9 | p_read_request f_read_request; 10 | p_send_response f_send_response; 11 | p_cleanup f_cleanup; 12 | } RFS_TRANSPORT_DATA; 13 | 14 | #define MAX_PACKET_SIZE 4096 15 | 16 | extern const RFS_TRANSPORT_DATA *p_transport_data; 17 | extern const RFS_TRANSPORT_DATA mem_transport_data; 18 | extern const RFS_TRANSPORT_DATA udp_transport_data; 19 | extern const RFS_TRANSPORT_DATA ser_transport_data; 20 | extern u8 rfs_buffer[ MAX_PACKET_SIZE + ELUARPC_WRITE_REQUEST_EXTRA ]; 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /rfs_server_src/serial.h: -------------------------------------------------------------------------------- 1 | // STM32 loader serial interface 2 | 3 | #ifndef __SERIAL_H__ 4 | #define __SERIAL_H__ 5 | 6 | #include "type.h" 7 | 8 | #define SER_INF_TIMEOUT 0xFFFFFFFF 9 | #define SER_NO_TIMEOUT 0 10 | #define SER_OK 0 11 | #define SER_ERR 1 12 | 13 | // Serial interface modes (blocking or non blocking) 14 | #define SER_MODE_BLOCKING 0 15 | #define SER_MODE_NONBLOCKING 1 16 | 17 | // Setup constants 18 | #define SER_PARITY_NONE 0 19 | #define SER_PARITY_EVEN 1 20 | #define SER_PARITY_ODD 2 21 | 22 | #define SER_STOPBITS_1 0 23 | #define SER_STOPBITS_1_5 1 24 | #define SER_STOPBITS_2 2 25 | 26 | #define SER_DATABITS_5 5 27 | #define SER_DATABITS_6 6 28 | #define SER_DATABITS_7 7 29 | #define SER_DATABITS_8 8 30 | 31 | #define SER_FLOW_NONE 0 32 | #define SER_FLOW_RTSCTS 1 33 | 34 | // Serial access functions (to be implemented by each platform) 35 | ser_handler ser_open( const char *sername ); 36 | void ser_close( ser_handler id ); 37 | int ser_setup( ser_handler id, u32 baud, int databits, int parity, int stopbits, int flow ); 38 | u32 ser_read( ser_handler id, u8* dest, u32 maxsize, u32 timeout ); 39 | int ser_read_byte( ser_handler id, u32 timeout ); 40 | u32 ser_write( ser_handler id, const u8 *src, u32 size ); 41 | u32 ser_write_byte( ser_handler id, u8 data ); 42 | int ser_select_byte( ser_handler *pobjects, unsigned nobjects, int timeout ); 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /rfs_server_src/server.h: -------------------------------------------------------------------------------- 1 | // Remote filesystem server implementation 2 | 3 | #ifndef __SERVER_H__ 4 | #define __SERVER_H__ 5 | 6 | #include "type.h" 7 | 8 | // Error codes 9 | #define SERVER_OK 0 10 | #define SERVER_ERR 1 11 | 12 | // Server function 13 | void server_setup( const char *basedir ); 14 | void server_cleanup(); 15 | int server_execute_request( u8 *pdata ); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /rfs_server_src/type.h: -------------------------------------------------------------------------------- 1 | // Type definitions for the remote file system 2 | 3 | #ifndef __TYPE_H__ 4 | #define __TYPE_H__ 5 | 6 | typedef char s8; 7 | typedef unsigned char u8; 8 | typedef short s16; 9 | typedef unsigned short u16; 10 | typedef long s32; 11 | typedef unsigned long u32; 12 | typedef long long s64; 13 | typedef unsigned long long u64; 14 | 15 | #ifdef WIN32_BUILD 16 | 17 | #include 18 | typedef struct 19 | { 20 | HANDLE hnd; 21 | OVERLAPPED o; 22 | OVERLAPPED o_wr; 23 | BOOL fWaitingOnRead; 24 | u8 databuf; 25 | } SERIAL_DATA; 26 | typedef SERIAL_DATA* ser_handler; 27 | #define SER_HANDLER_INVALID ( NULL ) 28 | typedef HANDLE sync_object; 29 | 30 | #else // #ifdef WIN32_BUILD 31 | 32 | // Assume POSIX here 33 | 34 | typedef int ser_handler; 35 | #define SER_HANDLER_INVALID ( -1 ) 36 | typedef int sync_object; 37 | 38 | #endif // #ifdef WIN32_BUILD 39 | 40 | #endif // #ifndef __TYPE_H__ 41 | -------------------------------------------------------------------------------- /romfs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | 4 | -------------------------------------------------------------------------------- /rpc-lua.py: -------------------------------------------------------------------------------- 1 | import os, sys, platform 2 | 3 | output = 'luarpc' 4 | cdefs = "-DLUA_CROSS_COMPILER -DLUA_RPC" 5 | 6 | # Lua source files and include path 7 | lua_files = """lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c 8 | lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c 9 | ldblib.c liolib.c lmathlib.c loslib.c ltablib.c lstrlib.c loadlib.c linit.c lua.c print.c lrotable.c""" 10 | lua_full_files = " " + " ".join( [ "src/lua/%s" % name for name in lua_files.split() ] ) 11 | lua_full_files += " src/modules/luarpc.c src/modules/lpack.c src/modules/bitarray.c src/modules/bit.c src/luarpc_desktop_serial.c " 12 | 13 | external_libs = '-lm' 14 | 15 | if platform.system() == "Windows": 16 | lua_full_files += " src/serial/serial_win32.c" 17 | cdefs += " -DWIN32_BUILD" 18 | else: 19 | lua_full_files += " src/serial/serial_posix.c src/linenoise_posix.c" 20 | cdefs += " -DLUA_USE_LINENOISE " 21 | 22 | local_include = "-Isrc/lua -Iinc -Isrc/modules -Iinc/desktop" 23 | 24 | # Compiler/linker options 25 | cccom = "gcc -O2 -g %s -Wall %s -c $SOURCE -o $TARGET" % ( local_include, cdefs ) 26 | linkcom = "gcc -o $TARGET $SOURCES %s" % external_libs 27 | 28 | # Env for building the program 29 | comp = Environment( CCCOM = cccom, 30 | LINKCOM = linkcom, 31 | ENV = os.environ ) 32 | # Debug 33 | Decider( 'MD5-timestamp' ) 34 | Default( comp.Program( output, Split( lua_full_files ) ) ) 35 | -------------------------------------------------------------------------------- /run_elua_sim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Setup terminal 4 | stty -echo raw -igncr 5 | 6 | # Run simulator 7 | ./elua_lua_linux.elf 8 | 9 | # Restore terminal to default settings 10 | stty echo cooked 11 | 12 | -------------------------------------------------------------------------------- /src/fatfs/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #include "type.h" 6 | 7 | #ifndef _INTEGER 8 | 9 | typedef signed int INT; 10 | typedef unsigned int UINT; 11 | 12 | #ifndef __TYPE_H__ 13 | /* These types are assumed as 8-bit integer */ 14 | typedef signed char CHAR; 15 | typedef unsigned char UCHAR; 16 | typedef unsigned char BYTE; 17 | 18 | /* These types are assumed as 16-bit integer */ 19 | typedef signed short SHORT; 20 | typedef unsigned short USHORT; 21 | typedef unsigned short WORD; 22 | typedef unsigned short WCHAR; 23 | 24 | /* These types are assumed as 32-bit integer */ 25 | typedef signed long LONG; 26 | typedef unsigned long ULONG; 27 | typedef unsigned long DWORD; 28 | 29 | /* Boolean type */ 30 | typedef enum { FALSE = 0, TRUE } BOOL; 31 | #else 32 | /* Only define types not in type.h */ 33 | typedef signed char CHAR; 34 | typedef unsigned short WCHAR; 35 | typedef unsigned char UCHAR; 36 | typedef signed short SHORT; 37 | typedef unsigned short USHORT; 38 | typedef signed long LONG; 39 | typedef unsigned long ULONG; 40 | #endif 41 | 42 | #define _INTEGER 43 | #endif 44 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | #if defined (LUA_BITWISE_OPERATORS) 34 | LUAI_FUNC void luaG_logicerror (lua_State *L, const TValue *p1, 35 | const TValue *p2); 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | #include "lgc.h" 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | #define proto_readonly(p) l_setbit((p)->marked, READONLYBIT) 21 | #define proto_is_readonly(p) testbit((p)->marked, READONLYBIT) 22 | 23 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 24 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); 25 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); 26 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 27 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 28 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 29 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 30 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 31 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 32 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 33 | int pc); 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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_newrolstr(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 | -------------------------------------------------------------------------------- /src/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.nk) 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 | -------------------------------------------------------------------------------- /src/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 | #if defined(LUA_BITWISE_OPERATORS) 37 | TM_BOR, 38 | TM_BAND, 39 | TM_BXOR, 40 | TM_BLSHFT, 41 | TM_BRSHFT, 42 | TM_BNOT, 43 | TM_INTDIV, 44 | #endif 45 | TM_N /* number of elements in the enum */ 46 | } TMS; 47 | 48 | 49 | 50 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 51 | !luaR_isrotable(et) && ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 52 | 53 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 54 | 55 | LUAI_DATA const char *const luaT_typenames[]; 56 | 57 | 58 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 59 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 60 | TMS event); 61 | LUAI_FUNC void luaT_init (lua_State *L); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/modules/modcommon.h: -------------------------------------------------------------------------------- 1 | #ifndef __MODCOMMON_H__ 2 | #define __MODCOMMON_H__ // Sentinel 3 | 4 | // Const Table Entry 5 | #define _ELUA_CTE(x) { #x, x } 6 | 7 | // Const table typedef 8 | typedef struct 9 | { 10 | const char* name; 11 | u32 val; 12 | } eLua_const_userdata_t; 13 | 14 | #define _ELUA_MODTAB luaL_reg mod_##__COUNTER__[] __attribute__((section (".lua_init"))) 15 | 16 | // Register eLua module 17 | int eLua_register(lua_State * l, const char * name, const luaL_Reg * t); 18 | // Register const table 19 | int eLua_register_const(lua_State * l, const eLua_const_userdata_t * ct); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/modules/pd.c: -------------------------------------------------------------------------------- 1 | // Module for interfacing with platform data 2 | 3 | #include "lua.h" 4 | #include "lualib.h" 5 | #include "lauxlib.h" 6 | #include "platform.h" 7 | #include "auxmods.h" 8 | #include "lrotable.h" 9 | 10 | #define MACRO_NAME( x ) MACRO_AGAIN( x ) 11 | #define MACRO_AGAIN( x ) #x 12 | 13 | // Lua: platform = platform() 14 | static int pd_platform( lua_State* L ) 15 | { 16 | lua_pushstring( L, MACRO_NAME( ELUA_PLATFORM ) ); 17 | return 1; 18 | } 19 | 20 | // Lua: cpuname = cpu() 21 | static int pd_cpu( lua_State* L ) 22 | { 23 | lua_pushstring( L, MACRO_NAME( ELUA_CPU ) ); 24 | return 1; 25 | } 26 | 27 | // Lua: boardname = board() 28 | static int pd_board( lua_State* L ) 29 | { 30 | lua_pushstring( L, MACRO_NAME( ELUA_BOARD ) ); 31 | return 1; 32 | } 33 | 34 | // Module function map 35 | #define MIN_OPT_LEVEL 2 36 | #include "lrodefs.h" 37 | const LUA_REG_TYPE pd_map[] = 38 | { 39 | { LSTRKEY( "platform" ), LFUNCVAL( pd_platform ) }, 40 | { LSTRKEY( "cpu" ), LFUNCVAL( pd_cpu ) }, 41 | { LSTRKEY( "board" ), LFUNCVAL( pd_board ) }, 42 | { LNILKEY, LNILVAL } 43 | }; 44 | 45 | LUALIB_API int luaopen_pd( lua_State* L ) 46 | { 47 | LREGISTER( L, AUXLIB_PD, pd_map ); 48 | } 49 | -------------------------------------------------------------------------------- /src/patches/README: -------------------------------------------------------------------------------- 1 | This directory contains some of the patches that were applied to stock Lua inside the 2 | eLua distribution. 3 | 4 | strings_and_protos_in_rom_v1.patch 5 | ================================== 6 | DESCRIPTION: 7 | - Adds the "dm_getaddr" operation which lets a filesystem return the base address 8 | of a file (an actual memory address where the file can be found and accessed via 9 | regular memory read/write operations). Only filesystems that reside in a memory 10 | that is directly accesible to the CPU (for example the ROM filesystem inside the 11 | MPU Flash memory) can return a non-NULL result for this function and only for files 12 | that are contigous in memory (no chained blocks). NULL shuold be returned in all the 13 | other cases. 14 | - When loading bytecode from a file that has a base address (dm_getaddr() returns 15 | a non-NULL result) it keeps the data part of a TString (the string itself) in ROM 16 | and prevents it from being loaded to RAM. Also keeps the instructions and line size 17 | information array of a 'Proto' (function prototype structure) in ROM and prevents 18 | them from being loaded to RAM. 19 | - When loading Lua code from a file that has a base address (dm_getaddr() returns 20 | a non-NULL result) it lets the parser read the Lua code directly from ROM. 21 | APPLIES TO: 22 | Stock Lua 5.1.4 source tree 23 | AUTHOR: 24 | Bogdan Marinescu 25 | DATE: 26 | August 1st, 2011 27 | SOURCE: 28 | eLua source repository (http://github.com/elua/elua) 29 | 30 | -------------------------------------------------------------------------------- /src/platform/arm_constants.h: -------------------------------------------------------------------------------- 1 | // ARM/Thumb constants 2 | 3 | #ifndef __ARM_CONSTANTS_H__ 4 | #define __ARM_CONSTANTS_H__ 5 | 6 | #define I_BIT 0x80 7 | #define F_BIT 0x40 8 | 9 | #ifndef CORTEX_M3 10 | #define INTERRUPT_MASK_BIT ( I_BIT ) 11 | // Define next constant as 0 if the interrupt flag is active on logic 0, or as INTERRUPT_MASK_BIT otherwise 12 | #define INTERRUPT_ACTIVE ( 0 ) 13 | #endif // #ifndef CORTEX_M3 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/platform/arm_cortex_interrupts.c: -------------------------------------------------------------------------------- 1 | // Generic functions for ARM CPUs 2 | 3 | #include "arm_constants.h" 4 | #include "cortex_constants.h" 5 | #include "type.h" 6 | #include "platform.h" 7 | 8 | extern void arm_enable_ints(); 9 | extern void arm_disable_ints(); 10 | extern u32 arm_get_int_status(); 11 | 12 | int platform_cpu_set_global_interrupts( int status ) 13 | { 14 | u32 crt_status = arm_get_int_status(); 15 | 16 | if( status == PLATFORM_CPU_ENABLE ) 17 | arm_enable_ints(); 18 | else 19 | arm_disable_ints(); 20 | return ( crt_status & INTERRUPT_MASK_BIT ) == INTERRUPT_ACTIVE; 21 | } 22 | 23 | int platform_cpu_get_global_interrupts() 24 | { 25 | return ( arm_get_int_status() & INTERRUPT_MASK_BIT ) == INTERRUPT_ACTIVE; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/platform/arm_utils.s: -------------------------------------------------------------------------------- 1 | #include "arm_constants.h" 2 | 3 | .section .text 4 | .align 4 5 | 6 | .macro prologue 7 | #ifdef CPUMODE_THUMB 8 | mov r1, pc 9 | bx r1 10 | .arm 11 | #endif 12 | .endm 13 | 14 | .macro functype 15 | #ifdef CPUMODE_THUMB 16 | .thumb 17 | .thumb_func 18 | #else 19 | .arm 20 | #endif 21 | .endm 22 | 23 | # enable interrupts 24 | .global arm_enable_ints 25 | functype 26 | arm_enable_ints: 27 | prologue 28 | mrs r0, CPSR 29 | bic r0, r0, #I_BIT 30 | msr CPSR_c, r0 31 | bx lr 32 | 33 | # disable interrupts 34 | .global arm_disable_ints 35 | functype 36 | arm_disable_ints: 37 | prologue 38 | mrs r0, CPSR 39 | orr r0, r0, #I_BIT 40 | msr CPSR_c, r0 41 | bx lr 42 | 43 | # Get interrupt status 44 | .global arm_get_int_status 45 | functype 46 | arm_get_int_status: 47 | prologue 48 | mrs r0, CPSR 49 | bx lr 50 | 51 | .end 52 | 53 | -------------------------------------------------------------------------------- /src/platform/at91sam7x/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE_USR 2048 7 | #define STACK_SIZE_IRQ 64 8 | #define STACK_SIZE_TOTAL ( STACK_SIZE_USR + STACK_SIZE_IRQ ) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/platform/at91sam7x/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | #ifndef NULL 5 | #define NULL ((void *)0) 6 | #endif 7 | 8 | #ifndef FALSE 9 | #define FALSE (0) 10 | #endif 11 | 12 | #ifndef TRUE 13 | #define TRUE (1) 14 | #endif 15 | 16 | typedef unsigned char BYTE; 17 | typedef unsigned short WORD; 18 | typedef unsigned long DWORD; 19 | typedef unsigned int BOOL; 20 | 21 | typedef unsigned char u8; 22 | typedef signed char s8; 23 | typedef unsigned short u16; 24 | typedef signed short s16; 25 | typedef unsigned long u32; 26 | typedef signed long s32; 27 | typedef unsigned long long u64; 28 | typedef signed long long s64; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/platform/avr32/at32uc3a0128.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | sram (W!RX) : ORIGIN = 0x00000004, LENGTH = 0x00007FFC 4 | flash (RX) : ORIGIN = 0x80002000, LENGTH = 0x00020000 - 0x2000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : 10 | { 11 | . = ALIGN(4); 12 | _stext = .; 13 | PROVIDE(stext = .); 14 | KEEP(*(.start)) 15 | *(.text .text.*) 16 | *(.rodata .rodata.*) 17 | *(.gnu.linkonce.t.*) 18 | *(.glue_7) 19 | *(.glue_7t) 20 | *(.gcc_except_table) 21 | *(.gnu.linkonce.r.*) 22 | *(.exception .exception.*) 23 | . = ALIGN(4); 24 | _etext = .; 25 | PROVIDE(etext = .); 26 | } >flash 27 | 28 | .data : AT (_etext) 29 | { 30 | . = ALIGN(4); 31 | _data = .; 32 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 33 | *(.data .data.*) 34 | *(.gnu.linkonce.d.*) 35 | . = ALIGN(4); 36 | _edata = .; 37 | } >sram 38 | 39 | .bss (NOLOAD) : { 40 | _bss = .; 41 | *(.bss .bss.*) 42 | *(.gnu.linkonce.b.*) 43 | *(COMMON) 44 | . = ALIGN(4); 45 | _ebss = .; 46 | } >sram 47 | 48 | end = .; 49 | _sstack = 0x00008000; 50 | } 51 | -------------------------------------------------------------------------------- /src/platform/avr32/at32uc3a0128_emblod.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | sram (W!RX) : ORIGIN = 0x00000004, LENGTH = 0x00007FFC 4 | sdram (WRX) : ORIGIN = 0xd0000000, LENGTH = 0x02000000 5 | flash (RX) : ORIGIN = 0x80002000, LENGTH = 0x00020000 - 0x2000 6 | } 7 | 8 | SECTIONS 9 | { 10 | .text : 11 | { 12 | . = ALIGN(4); 13 | _stext = .; 14 | PROVIDE(stext = .); 15 | KEEP(*(.start)) 16 | *(.text .text.*) 17 | *(.rodata .rodata.*) 18 | *(.gnu.linkonce.t.*) 19 | *(.glue_7) 20 | *(.glue_7t) 21 | *(.gcc_except_table) 22 | *(.gnu.linkonce.r.*) 23 | *(.exception .exception.*) 24 | . = ALIGN(4); 25 | _etext = .; 26 | PROVIDE(etext = .); 27 | } >sdram 28 | 29 | .data : AT (_etext) 30 | { 31 | . = ALIGN(4); 32 | _data = .; 33 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 34 | *(.data .data.*) 35 | *(.gnu.linkonce.d.*) 36 | . = ALIGN(4); 37 | _edata = .; 38 | } >sram 39 | 40 | .bss (NOLOAD) : { 41 | _bss = .; 42 | *(.bss .bss.*) 43 | *(.gnu.linkonce.b.*) 44 | *(COMMON) 45 | . = ALIGN(4); 46 | _ebss = .; 47 | } >sram 48 | 49 | end = .; 50 | _sstack = 0x00008000; 51 | } 52 | -------------------------------------------------------------------------------- /src/platform/avr32/at32uc3a0256.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | sram (W!RX) : ORIGIN = 0x00000004, LENGTH = 0x0000FFFC 4 | flash (RX) : ORIGIN = 0x80002000, LENGTH = 0x00040000 - 0x2000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : 10 | { 11 | . = ALIGN(4); 12 | _stext = .; 13 | PROVIDE(stext = .); 14 | KEEP(*(.start)) 15 | *(.text .text.*) 16 | *(.rodata .rodata.*) 17 | *(.gnu.linkonce.t.*) 18 | *(.glue_7) 19 | *(.glue_7t) 20 | *(.gcc_except_table) 21 | *(.gnu.linkonce.r.*) 22 | *(.exception .exception.*) 23 | . = ALIGN(4); 24 | _etext = .; 25 | PROVIDE(etext = .); 26 | } >flash 27 | 28 | .data : AT (_etext) 29 | { 30 | . = ALIGN(4); 31 | _data = .; 32 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 33 | *(.data .data.*) 34 | *(.gnu.linkonce.d.*) 35 | . = ALIGN(4); 36 | _edata = .; 37 | } >sram 38 | 39 | .bss (NOLOAD) : { 40 | _bss = .; 41 | *(.bss .bss.*) 42 | *(.gnu.linkonce.b.*) 43 | *(COMMON) 44 | . = ALIGN(4); 45 | _ebss = .; 46 | } >sram 47 | 48 | end = .; 49 | _sstack = 0x00010000; 50 | } 51 | -------------------------------------------------------------------------------- /src/platform/avr32/at32uc3a0512.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | sram (W!RX) : ORIGIN = 0x00000004, LENGTH = 0x0000FFFC 4 | flash (RX) : ORIGIN = 0x80002000, LENGTH = 0x00080000 - 0x2000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : 10 | { 11 | . = ALIGN(4); 12 | _stext = .; 13 | PROVIDE(stext = .); 14 | KEEP(*(.start)) 15 | *(.text .text.*) 16 | *(.rodata .rodata.*) 17 | *(.gnu.linkonce.t.*) 18 | *(.glue_7) 19 | *(.glue_7t) 20 | *(.gcc_except_table) 21 | *(.gnu.linkonce.r.*) 22 | *(.exception .exception.*) 23 | . = ALIGN(4); 24 | _etext = .; 25 | PROVIDE(etext = .); 26 | } >flash 27 | 28 | .data : AT (_etext) 29 | { 30 | . = ALIGN(4); 31 | _data = .; 32 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 33 | *(.data .data.*) 34 | *(.gnu.linkonce.d.*) 35 | . = ALIGN(4); 36 | _edata = .; 37 | } >sram 38 | 39 | .bss (NOLOAD) : { 40 | _bss = .; 41 | *(.bss .bss.*) 42 | *(.gnu.linkonce.b.*) 43 | *(COMMON) 44 | . = ALIGN(4); 45 | _ebss = .; 46 | } >sram 47 | 48 | end = .; 49 | _sstack = 0x00010000; 50 | } 51 | -------------------------------------------------------------------------------- /src/platform/avr32/at32uc3b0256.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | sram (W!RX) : ORIGIN = 0x00000004, LENGTH = 0x00007FFC 4 | flash (RX) : ORIGIN = 0x80002000, LENGTH = 0x00040000 - 0x2000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : 10 | { 11 | . = ALIGN(4); 12 | _stext = .; 13 | PROVIDE(stext = .); 14 | KEEP(*(.start)) 15 | *(.text .text.*) 16 | *(.rodata .rodata.*) 17 | *(.gnu.linkonce.t.*) 18 | *(.glue_7) 19 | *(.glue_7t) 20 | *(.gcc_except_table) 21 | *(.gnu.linkonce.r.*) 22 | *(.exception .exception.*) 23 | . = ALIGN(4); 24 | _etext = .; 25 | PROVIDE(etext = .); 26 | } >flash 27 | 28 | .data : AT (_etext) 29 | { 30 | . = ALIGN(4); 31 | _data = .; 32 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 33 | *(.data .data.*) 34 | *(.gnu.linkonce.d.*) 35 | . = ALIGN(4); 36 | _edata = .; 37 | } >sram 38 | 39 | .bss (NOLOAD) : { 40 | _bss = .; 41 | *(.bss .bss.*) 42 | *(.gnu.linkonce.b.*) 43 | *(COMMON) 44 | . = ALIGN(4); 45 | _ebss = .; 46 | } >sram 47 | 48 | end = .; 49 | _sstack = 0x0008000; 50 | } 51 | -------------------------------------------------------------------------------- /src/platform/avr32/i2c.h: -------------------------------------------------------------------------------- 1 | // Declarations for the low-level AVR32 I2C driver for eLua 2 | 3 | #include "type.h" // for u32 4 | 5 | u32 i2c_setup( u32 speed ); // speed is in Hz 6 | void i2c_start_cond( void ); 7 | void i2c_stop_cond( void ); 8 | int i2c_write_byte( unsigned char byte ); // returns 0 if acked by slave 9 | unsigned char i2c_read_byte( int nack ); 10 | -------------------------------------------------------------------------------- /src/platform/avr32/platform_conf.h: -------------------------------------------------------------------------------- 1 | // eLua platform configuration 2 | 3 | #ifndef __PLATFORM_CONF_H__ 4 | #define __PLATFORM_CONF_H__ 5 | 6 | #include "auxmods.h" 7 | #include "board.h" 8 | #include "stacks.h" 9 | 10 | #if BOARD == EVK1100 11 | #include "EVK1100/evk1100_conf.h" 12 | #elif BOARD == EVK1101 13 | #include "EVK1101/evk1101_conf.h" 14 | #elif BOARD == MIZAR32 15 | #include "MIZAR32/mizar32_conf.h" 16 | #else 17 | #error No known AVR32 board defined 18 | #endif 19 | 20 | #endif // #ifndef __PLATFORM_CONF_H__ 21 | -------------------------------------------------------------------------------- /src/platform/avr32/pwm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pwm.h: Declarations for low-level part of the AVR32 PWM driver for eLua. 3 | * 4 | * Martin Guy , March 2011 5 | */ 6 | 7 | #include "platform.h" // for u32 8 | 9 | // Initialize the PWM system, called at startup 10 | void pwm_init( void ); 11 | 12 | // Set the frequencies of the two linear dividers A and B 13 | void pwm_set_linear_divider( unsigned prea, unsigned diva ); 14 | 15 | // Return the actual clock frequency obtained. 16 | u32 pwm_get_clock_freq( void ); 17 | 18 | // Set the parameters determining period and duty cycle for a channel 19 | void pwm_channel_set_period_and_duty_cycle( unsigned id, u32 period, u32 duty ); 20 | 21 | // Enable a PWM channel (set it running) 22 | void pwm_channel_start( int id ); 23 | 24 | // Disable a PWM channel (stop it) 25 | void pwm_channel_stop( int id ); 26 | -------------------------------------------------------------------------------- /src/platform/avr32/spi.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPI_H_ 2 | #define _SPI_H_ 3 | 4 | #include 5 | 6 | #ifndef AVR32_SPI0 7 | #define AVR32_SPI0 AVR32_SPI 8 | #define AVR32_SPI0_ADDRESS AVR32_SPI_ADDRESS 9 | #endif 10 | 11 | typedef enum { 12 | SPI_MODE_0 = 0, 13 | SPI_MODE_1, 14 | SPI_MODE_2, 15 | SPI_MODE_3 16 | } spi_mode_t; 17 | 18 | //! Option structure for SPI channels. 19 | typedef struct 20 | { 21 | //! Preferred baudrate for the SPI. 22 | unsigned int baudrate; 23 | 24 | //! Number of bits in each character (8 to 16). 25 | unsigned char bits; 26 | 27 | //! Delay before first clock pulse after selecting slave (in microseconds). 28 | unsigned int spck_delay; 29 | 30 | //! Delay between each transfer/character (in microseconds). 31 | unsigned int trans_delay; 32 | 33 | //! Which SPI mode to use when transmitting. 34 | spi_mode_t mode; 35 | 36 | } spi_options_t; 37 | 38 | typedef struct 39 | { 40 | //! Mode fault detection disable 41 | Bool modfdis; 42 | //! Chip select decoding 43 | Bool pcs_decode; 44 | //! delay before chip select (in microseconds) 45 | unsigned int delay; 46 | } spi_master_options_t; 47 | 48 | 49 | extern void spi_reset(volatile avr32_spi_t *spi); 50 | 51 | extern int spi_initMaster(volatile avr32_spi_t *spi, const spi_master_options_t *, U32 pba_hz); 52 | extern int spi_setupChipReg(volatile avr32_spi_t *spi, unsigned char chip, const spi_options_t *, U32 pba_hz); 53 | 54 | extern int spi_selectChip(volatile avr32_spi_t *spi, unsigned char chip); 55 | extern int spi_unselectChip(volatile avr32_spi_t *spi, unsigned char chip); 56 | 57 | extern U16 spi_single_transfer(volatile avr32_spi_t *spi, U16 txdata); 58 | 59 | #endif // _SPI_H_ 60 | -------------------------------------------------------------------------------- /src/platform/avr32/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE 4096 7 | #define STACK_SIZE_TOTAL ( STACK_SIZE ) 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/platform/avr32/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | #ifndef NULL 5 | #define NULL ((void *)0) 6 | #endif 7 | 8 | typedef unsigned char BYTE; 9 | typedef unsigned short WORD; 10 | typedef unsigned long DWORD; 11 | typedef unsigned int BOOL; 12 | 13 | typedef unsigned char u8; 14 | typedef signed char s8; 15 | typedef unsigned short u16; 16 | typedef signed short s16; 17 | typedef unsigned long u32; 18 | typedef signed long s32; 19 | typedef unsigned long long u64; 20 | typedef signed long long s64; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/platform/cortex_constants.h: -------------------------------------------------------------------------------- 1 | // ARM/Thumb constants 2 | 3 | #ifndef __CORTEX_CONSTANTS_H__ 4 | #define __CORTEX_CONSTANTS_H__ 5 | 6 | #define PM_BIT 0x01 7 | 8 | #ifdef CORTEX_M3 9 | #define INTERRUPT_MASK_BIT ( PM_BIT ) 10 | // Define next constant as 0 if the interrupt flag is active on logic 0, or as INTERRUPT_MASK_BIT otherwise 11 | #define INTERRUPT_ACTIVE ( 0 ) 12 | #endif // #ifdef CORTEX_M3 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /src/platform/cortex_utils.s: -------------------------------------------------------------------------------- 1 | #include "cortex_constants.h" 2 | 3 | .section .text 4 | .align 2 5 | 6 | # enable interrupts 7 | .global arm_enable_ints 8 | .thumb 9 | .thumb_func 10 | arm_enable_ints: 11 | cpsie i 12 | bx lr 13 | 14 | # disable interrupts 15 | .global arm_disable_ints 16 | .thumb 17 | .thumb_func 18 | arm_disable_ints: 19 | cpsid i 20 | bx lr 21 | 22 | # Get interrupt status 23 | .global arm_get_int_status 24 | .thumb 25 | .thumb_func 26 | arm_get_int_status: 27 | mrs r0, PRIMASK 28 | bx lr 29 | 30 | .end 31 | 32 | -------------------------------------------------------------------------------- /src/platform/i386/common.c: -------------------------------------------------------------------------------- 1 | // common.c -- Defines some global functions. 2 | // From JamesM's kernel development tutorials. 3 | 4 | #include "common.h" 5 | 6 | // Write a byte out to the specified port. 7 | void outb(u16int port, u8int value) 8 | { 9 | asm volatile ("outb %1, %0" : : "dN" (port), "a" (value)); 10 | } 11 | 12 | u8int inb(u16int port) 13 | { 14 | u8int ret; 15 | asm volatile("inb %1, %0" : "=a" (ret) : "dN" (port)); 16 | return ret; 17 | } 18 | 19 | u16int inw(u16int port) 20 | { 21 | u16int ret; 22 | asm volatile ("inw %1, %0" : "=a" (ret) : "dN" (port)); 23 | return ret; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/platform/i386/common.h: -------------------------------------------------------------------------------- 1 | // common.h -- Defines typedefs and some global functions. 2 | // From JamesM's kernel development tutorials. 3 | 4 | #ifndef COMMON_H 5 | #define COMMON_H 6 | 7 | #include "multiboot.h" 8 | 9 | // Some nice typedefs, to standardise sizes across platforms. 10 | // These typedefs are written for 32-bit X86. 11 | typedef unsigned int u32int; 12 | typedef int s32int; 13 | typedef unsigned short u16int; 14 | typedef short s16int; 15 | typedef unsigned char u8int; 16 | typedef char s8int; 17 | 18 | void outb(u16int port, u8int value); 19 | u8int inb(u16int port); 20 | u16int inw(u16int port); 21 | 22 | #endif // COMMON_H 23 | -------------------------------------------------------------------------------- /src/platform/i386/conf.lua: -------------------------------------------------------------------------------- 1 | -- Configuration file for the i386 backend 2 | 3 | specific_files = "boot.s common.c descriptor_tables.c gdt.s interrupt.s isr.c kb.c monitor.c timer.c platform.c" 4 | local ldscript = "i386.ld" 5 | 6 | -- Prepend with path 7 | specific_files = utils.prepend_path( specific_files, sf( "src/platform/%s", platform ) ) 8 | ldscript = sf( "src/platform/%s/%s", platform, ldscript ) 9 | 10 | -- Standard GCC Flags 11 | addcf{ '-ffunction-sections', '-fdata-sections', '-fno-strict-aliasing', '-Wall' } 12 | addlf{ '-nostartfiles', '-nostdlib', '-T', ldscript, '-Wl,--gc-sections', '-Wl,--allow-multiple-definition' } 13 | addlib{ 'c','gcc','m' } 14 | 15 | local target_flags = { '-march=i386','-mfpmath=387', '-m32' } 16 | 17 | addcf{ target_flags, '-fno-builtin', '-fno-stack-protector' } 18 | addlf{ target_flags, '-Wl,-e,start' } 19 | addaf{ '-felf' } 20 | 21 | -- Need to force the assembler command as we're using nasm 22 | ascmd = "nasm -felf -o $(TARGET) $(FIRST)" 23 | -- Also tell the builder that we don't need dependency checks for assembler files 24 | builder:set_asm_dep_cmd( false ) 25 | 26 | -- Toolset data 27 | tools.i386 = {} 28 | 29 | -- Programming function for i386 (not needed, empty function) 30 | tools.i386.progfunc = function( target, deps ) 31 | local outname = deps[ 1 ]:target_name() 32 | os.execute( sf( "%s %s", toolset.size, outname ) ) 33 | print "Visit http://www.eluaproject.net for instructions on how to use your eLua ELF file" 34 | return 0 35 | end 36 | 37 | -- Add the programming function explicitly for this target 38 | tools.i386.pre_build = function() 39 | local t = builder:target( "#phony:prog", { exetarget }, tools.i386.progfunc ) 40 | builder:add_target( t, "build eLua firmware image", { "prog" } ) 41 | end 42 | 43 | -------------------------------------------------------------------------------- /src/platform/i386/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the i386 backend 2 | 3 | specific_files = "boot.s common.c descriptor_tables.c gdt.s interrupt.s isr.c kb.c monitor.c timer.c platform.c" 4 | ldscript = "i386.ld" 5 | 6 | # Prepend with path 7 | specific_files = " ".join( [ "src/platform/%s/%s" % ( platform, f ) for f in specific_files.split() ] ) 8 | ldscript = "src/platform/%s/%s" % ( platform, ldscript ) 9 | 10 | 11 | # Standard GCC Flags 12 | comp.Append(CCFLAGS = ['-ffunction-sections','-fdata-sections','-fno-strict-aliasing','-Wall']) 13 | comp.Append(LINKFLAGS = ['-nostartfiles','-nostdlib','-T',ldscript,'-Wl,--gc-sections','-Wl,--allow-multiple-definition']) 14 | #comp.Append(ASFLAGS = ['-x','assembler-with-cpp','-c','-Wall','$_CPPDEFFLAGS']) 15 | comp.Append(LIBS = ['c','gcc','m']) 16 | 17 | TARGET_FLAGS = ['-march=i386','-mfpmath=387','-m32'] 18 | 19 | comp.Prepend(CCFLAGS = [TARGET_FLAGS,'-fno-builtin','-fno-stack-protector']) 20 | comp.Prepend(LINKFLAGS = [TARGET_FLAGS,'-Wl,-e,start']) 21 | comp['AS'] = toolset[ 'asm' ] # Need to force toolset 22 | comp.Prepend(ASFLAGS = ['-felf']) 23 | 24 | # Toolset data 25 | tools[ 'i386' ] = {} 26 | 27 | # Programming function for i386 (not needed, empty function) 28 | def progfunc_i386( target, source, env ): 29 | outname = output + ".elf" 30 | os.system( "%s %s" % ( toolset[ 'size' ], outname ) ) 31 | print "Visit http://www.eluaproject.net for instructions on how to use your eLua ELF file" 32 | 33 | tools[ 'i386' ][ 'progfunc' ] = progfunc_i386 34 | -------------------------------------------------------------------------------- /src/platform/i386/gdt.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Gdt.s -- contains global descriptor table and interrupt descriptor table 3 | ; setup code. 4 | ; Based on code from Bran's kernel development tutorials. 5 | ; Rewritten for JamesM's kernel development tutorials. 6 | 7 | [GLOBAL gdt_flush] ; Allows the C code to call gdt_flush(). 8 | 9 | gdt_flush: 10 | mov eax, [esp+4] ; Get the pointer to the GDT, passed as a parameter. 11 | lgdt [eax] ; Load the new GDT pointer 12 | 13 | mov ax, 0x10 ; 0x10 is the offset in the GDT to our data segment 14 | mov ds, ax ; Load all data segment selectors 15 | mov es, ax 16 | mov fs, ax 17 | mov gs, ax 18 | mov ss, ax 19 | jmp 0x08:.flush ; 0x08 is the offset to our code segment: Far jump! 20 | .flush: 21 | ret 22 | 23 | [GLOBAL idt_flush] ; Allows the C code to call idt_flush(). 24 | 25 | idt_flush: 26 | mov eax, [esp+4] ; Get the pointer to the IDT, passed as a parameter. 27 | lidt [eax] ; Load the IDT pointer. 28 | ret 29 | -------------------------------------------------------------------------------- /src/platform/i386/i386.ld: -------------------------------------------------------------------------------- 1 | /* Link.ld -- Linker script for the kernel - ensure everything goes in the */ 2 | /* Correct place. */ 3 | /* Original file taken from Bran's Kernel Development */ 4 | /* tutorials: http://www.osdever.net/bkerndev/index.php. */ 5 | 6 | SECTIONS 7 | { 8 | 9 | .text 0x100000 : 10 | { 11 | KEEP(*(.header)) 12 | code = .; _code = .; __code = .; 13 | PROVIDE(stext = .); 14 | *(.text .text.*) 15 | *(.rodata .rodata.*) 16 | *(.gnu.linkonce.r.*) 17 | *(.gnu.linkonce.t.*) 18 | . = ALIGN(4096); 19 | PROVIDE(etext = .); 20 | } 21 | 22 | .data : 23 | { 24 | data = .; _data = .; __data = .; 25 | *(.data .data.*) 26 | *(.gnu.linkonce.d.*) 27 | . = ALIGN(4096); 28 | } 29 | 30 | .bss : 31 | { 32 | bss = .; _bss = .; __bss = .; 33 | *(.bss .bss.*) 34 | *(.gnu.linkonce.b.*) 35 | *(COMMON) 36 | . = ALIGN(4096); 37 | } 38 | 39 | end = .; _end = .; __end = .; 40 | } 41 | -------------------------------------------------------------------------------- /src/platform/i386/isr.c: -------------------------------------------------------------------------------- 1 | // 2 | // isr.c -- High level interrupt service routines and interrupt request handlers. 3 | // Part of this code is modified from Bran's kernel development tutorials. 4 | // Rewritten for JamesM's kernel development tutorials. 5 | // 6 | 7 | #include "common.h" 8 | #include "isr.h" 9 | #include "monitor.h" 10 | 11 | isr_t interrupt_handlers[256]; 12 | extern void monitor_write_dec(u32int n); 13 | 14 | void register_interrupt_handler(u8int n, isr_t handler) 15 | { 16 | interrupt_handlers[n] = handler; 17 | } 18 | 19 | // This gets called from our ASM interrupt handler stub. 20 | void isr_handler(registers_t regs) 21 | { 22 | monitor_write("recieved interrupt: "); 23 | monitor_write_dec(regs.int_no); 24 | monitor_put('\n'); 25 | 26 | if (interrupt_handlers[regs.int_no] != 0) 27 | { 28 | isr_t handler = interrupt_handlers[regs.int_no]; 29 | handler(regs); 30 | } 31 | } 32 | 33 | // This gets called from our ASM interrupt handler stub. 34 | void irq_handler(registers_t regs) 35 | { 36 | // Send an EOI (end of interrupt) signal to the PICs. 37 | // If this interrupt involved the slave. 38 | if (regs.int_no >= 40) 39 | { 40 | // Send reset signal to slave. 41 | outb(0xA0, 0x20); 42 | } 43 | // Send reset signal to master. (As well as slave, if necessary). 44 | outb(0x20, 0x20); 45 | 46 | if (interrupt_handlers[regs.int_no] != 0) 47 | { 48 | isr_t handler = interrupt_handlers[regs.int_no]; 49 | handler(regs); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/platform/i386/isr.h: -------------------------------------------------------------------------------- 1 | // 2 | // isr.h -- Interface and structures for high level interrupt service routines. 3 | // Part of this code is modified from Bran's kernel development tutorials. 4 | // Rewritten for JamesM's kernel development tutorials. 5 | // 6 | 7 | #include "common.h" 8 | 9 | // A few defines to make life a little easier 10 | #define IRQ0 32 11 | #define IRQ1 33 12 | #define IRQ2 34 13 | #define IRQ3 35 14 | #define IRQ4 36 15 | #define IRQ5 37 16 | #define IRQ6 38 17 | #define IRQ7 39 18 | #define IRQ8 40 19 | #define IRQ9 41 20 | #define IRQ10 42 21 | #define IRQ11 43 22 | #define IRQ12 44 23 | #define IRQ13 45 24 | #define IRQ14 46 25 | #define IRQ15 47 26 | 27 | typedef struct registers 28 | { 29 | u32int ds; // Data segment selector 30 | u32int edi, esi, ebp, esp, ebx, edx, ecx, eax; // Pushed by pusha. 31 | u32int int_no, err_code; // Interrupt number and error code (if applicable) 32 | u32int eip, cs, eflags, useresp, ss; // Pushed by the processor automatically. 33 | } registers_t; 34 | 35 | // Enables registration of callbacks for interrupts or IRQs. 36 | // For IRQs, to ease confusion, use the #defines above as the 37 | // first parameter. 38 | typedef void (*isr_t)(registers_t); 39 | void register_interrupt_handler(u8int n, isr_t handler); 40 | -------------------------------------------------------------------------------- /src/platform/i386/kb.h: -------------------------------------------------------------------------------- 1 | // Keyboard handler 2 | 3 | #ifndef __KB_H__ 4 | #define __KB_H__ 5 | 6 | void keyboard_install(); 7 | int keyboard_getch(); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/platform/i386/monitor.h: -------------------------------------------------------------------------------- 1 | // monitor.h -- Defines the interface for monitor.h 2 | // From JamesM's kernel development tutorials. 3 | 4 | #ifndef MONITOR_H 5 | #define MONITOR_H 6 | 7 | #include "common.h" 8 | 9 | // Write a single character out to the screen. 10 | void monitor_put(char c); 11 | 12 | // Clear the screen to all black. 13 | void monitor_clear(); 14 | 15 | // Output a null-terminated ASCII string to the monitor. 16 | void monitor_write(char *c); 17 | 18 | #endif // MONITOR_H 19 | -------------------------------------------------------------------------------- /src/platform/i386/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE_TOTAL 32768 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /src/platform/i386/timer.c: -------------------------------------------------------------------------------- 1 | // timer.c -- Initialises the PIT, and handles clock updates. 2 | // Written for JamesM's kernel development tutorials. 3 | 4 | #include "timer.h" 5 | #include "isr.h" 6 | #include "monitor.h" 7 | 8 | u32int tick = 0; 9 | 10 | static void timer_callback(registers_t regs) 11 | { 12 | tick++; 13 | monitor_write("Tick: "); 14 | monitor_write_dec(tick); 15 | monitor_write("\n"); 16 | } 17 | 18 | void init_timer(u32int frequency) 19 | { 20 | // Firstly, register our timer callback. 21 | register_interrupt_handler(IRQ0, &timer_callback); 22 | 23 | // The value we send to the PIT is the value to divide it's input clock 24 | // (1193180 Hz) by, to get our required frequency. Important to note is 25 | // that the divisor must be small enough to fit into 16-bits. 26 | u32int divisor = 1193180 / frequency; 27 | 28 | // Send the command byte. 29 | outb(0x43, 0x36); 30 | 31 | // Divisor has to be sent byte-wise, so split here into upper/lower bytes. 32 | u8int l = (u8int)(divisor & 0xFF); 33 | u8int h = (u8int)( (divisor>>8) & 0xFF ); 34 | 35 | // Send the frequency divisor. 36 | outb(0x40, l); 37 | outb(0x40, h); 38 | } 39 | -------------------------------------------------------------------------------- /src/platform/i386/timer.h: -------------------------------------------------------------------------------- 1 | // timer.h -- Defines the interface for all PIT-related functions. 2 | // Written for JamesM's kernel development tutorials. 3 | 4 | #ifndef TIMER_H 5 | #define TIMER_H 6 | 7 | #include "common.h" 8 | 9 | void init_timer(u32int frequency); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/platform/i386/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | #ifndef NULL 5 | #define NULL ((void *)0) 6 | #endif 7 | 8 | #ifndef FALSE 9 | #define FALSE (0) 10 | #endif 11 | 12 | #ifndef TRUE 13 | #define TRUE (1) 14 | #endif 15 | 16 | typedef unsigned char BYTE; 17 | typedef unsigned short WORD; 18 | typedef unsigned long DWORD; 19 | typedef unsigned int BOOL; 20 | 21 | typedef unsigned char u8; 22 | typedef signed char s8; 23 | typedef unsigned short u16; 24 | typedef signed short s16; 25 | typedef unsigned long u32; 26 | typedef signed long s32; 27 | typedef unsigned long long u64; 28 | typedef signed long long s64; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/platform/lm3s/disp.h: -------------------------------------------------------------------------------- 1 | // LM3S OLED display support 2 | 3 | #ifndef __DISP_H__ 4 | #define __DISP_H__ 5 | 6 | void lm3s_disp_init( unsigned long freq ); 7 | void lm3s_disp_clear( void ); 8 | void lm3s_disp_stringDraw( const char *str, unsigned long x, unsigned long y, unsigned char level ); 9 | void lm3s_disp_imageDraw( const unsigned char *img, unsigned long x, unsigned long y, 10 | unsigned long width, unsigned long height ); 11 | void lm3s_disp_enable( unsigned long freq ); 12 | void lm3s_disp_disable( void ); 13 | void lm3s_disp_displayOn( void ); 14 | void lm3s_disp_displayOff( void ); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/platform/lm3s/lm3s-9b92.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00018000 4 | flash (RX) : ORIGIN = 0x00000000, LENGTH = 0x00040000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : 10 | { 11 | . = ALIGN(4); 12 | _text = .; 13 | PROVIDE(stext = .); 14 | KEEP(*(.isr_vector)) 15 | KEEP(*(.init)) 16 | *(.text .text.*) 17 | *(.rodata .rodata.*) 18 | *(.gnu.linkonce.t.*) 19 | *(.glue_7) 20 | *(.glue_7t) 21 | *(.gcc_except_table) 22 | *(.gnu.linkonce.r.*) 23 | . = ALIGN(4); 24 | _etext = .; 25 | PROVIDE(etext = .); 26 | _fini = . ; 27 | *(.fini) 28 | 29 | } >flash 30 | 31 | .data : AT (_etext) 32 | { 33 | . = ALIGN(4); 34 | _data = .; 35 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 36 | *(.data .data.*) 37 | *(.gnu.linkonce.d.*) 38 | . = ALIGN(4); 39 | _edata = .; 40 | } >sram 41 | 42 | .ARM.extab : 43 | { 44 | *(.ARM.extab*) 45 | } >sram 46 | 47 | __exidx_start = .; 48 | .ARM.exidx : 49 | { 50 | *(.ARM.exidx*) 51 | } >sram 52 | __exidx_end = .; 53 | 54 | .bss (NOLOAD) : { 55 | _bss = .; 56 | *(.bss .bss.*) 57 | *(.gnu.linkonce.b.*) 58 | *(COMMON) 59 | . = ALIGN(4); 60 | _ebss = .; 61 | } >sram 62 | 63 | end = .; 64 | } 65 | -------------------------------------------------------------------------------- /src/platform/lm3s/lm3s-9d92.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00018000 4 | flash (RX) : ORIGIN = 0x00000000, LENGTH = 0x00080000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : 10 | { 11 | . = ALIGN(4); 12 | _text = .; 13 | PROVIDE(stext = .); 14 | KEEP(*(.isr_vector)) 15 | KEEP(*(.init)) 16 | *(.text .text.*) 17 | *(.rodata .rodata.*) 18 | *(.gnu.linkonce.t.*) 19 | *(.glue_7) 20 | *(.glue_7t) 21 | *(.gcc_except_table) 22 | *(.gnu.linkonce.r.*) 23 | . = ALIGN(4); 24 | _etext = .; 25 | PROVIDE(etext = .); 26 | _fini = . ; 27 | *(.fini) 28 | 29 | } >flash 30 | 31 | .data : AT (_etext) 32 | { 33 | . = ALIGN(4); 34 | _data = .; 35 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 36 | *(.data .data.*) 37 | *(.gnu.linkonce.d.*) 38 | . = ALIGN(4); 39 | _edata = .; 40 | } >sram 41 | 42 | .ARM.extab : 43 | { 44 | *(.ARM.extab*) 45 | } >sram 46 | 47 | __exidx_start = .; 48 | .ARM.exidx : 49 | { 50 | *(.ARM.exidx*) 51 | } >sram 52 | __exidx_end = .; 53 | 54 | .bss (NOLOAD) : { 55 | _bss = .; 56 | *(.bss .bss.*) 57 | *(.gnu.linkonce.b.*) 58 | *(COMMON) 59 | . = ALIGN(4); 60 | _ebss = .; 61 | } >sram 62 | 63 | end = .; 64 | } 65 | -------------------------------------------------------------------------------- /src/platform/lm3s/lm3s.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00010000 4 | flash (RX) : ORIGIN = 0x00000000, LENGTH = 0x00040000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : 10 | { 11 | . = ALIGN(4); 12 | _text = .; 13 | PROVIDE(stext = .); 14 | KEEP(*(.isr_vector)) 15 | KEEP(*(.init)) 16 | *(.text .text.*) 17 | *(.rodata .rodata.*) 18 | *(.gnu.linkonce.t.*) 19 | *(.glue_7) 20 | *(.glue_7t) 21 | *(.gcc_except_table) 22 | *(.gnu.linkonce.r.*) 23 | . = ALIGN(4); 24 | _etext = .; 25 | PROVIDE(etext = .); 26 | _fini = . ; 27 | *(.fini) 28 | 29 | } >flash 30 | 31 | .data : AT (_etext) 32 | { 33 | . = ALIGN(4); 34 | _data = .; 35 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 36 | *(.data .data.*) 37 | *(.gnu.linkonce.d.*) 38 | . = ALIGN(4); 39 | _edata = .; 40 | } >sram 41 | 42 | .ARM.extab : 43 | { 44 | *(.ARM.extab*) 45 | } >sram 46 | 47 | __exidx_start = .; 48 | .ARM.exidx : 49 | { 50 | *(.ARM.exidx*) 51 | } >sram 52 | __exidx_end = .; 53 | 54 | .bss (NOLOAD) : { 55 | _bss = .; 56 | *(.bss .bss.*) 57 | *(.gnu.linkonce.b.*) 58 | *(COMMON) 59 | . = ALIGN(4); 60 | _ebss = .; 61 | } >sram 62 | 63 | end = .; 64 | } 65 | -------------------------------------------------------------------------------- /src/platform/lm3s/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE 2048 7 | #define STACK_SIZE_TOTAL ( STACK_SIZE ) 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/platform/lm3s/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | #ifndef NULL 5 | #define NULL ((void *)0) 6 | #endif 7 | 8 | #ifndef FALSE 9 | #define FALSE (0) 10 | #endif 11 | 12 | #ifndef TRUE 13 | #define TRUE (1) 14 | #endif 15 | 16 | typedef unsigned char BYTE; 17 | typedef unsigned short WORD; 18 | typedef unsigned long DWORD; 19 | typedef unsigned int BOOL; 20 | 21 | typedef unsigned char u8; 22 | typedef signed char s8; 23 | typedef unsigned short u16; 24 | typedef signed short s16; 25 | typedef unsigned long u32; 26 | typedef signed long s32; 27 | typedef unsigned long long u64; 28 | typedef signed long long s64; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/platform/lpc17xx/conf.lua: -------------------------------------------------------------------------------- 1 | -- Configuration file for the LPC17xx backend 2 | 3 | addi( sf( 'src/platform/%s/drivers/inc', platform ) ) 4 | 5 | local fwlib_files = utils.get_files( sf( "src/platform/%s/drivers/src", platform ), ".*%.c$" ) 6 | specific_files = "startup_LPC17xx.c system_LPC17xx.c core_cm3.c platform.c mbed_pio.c" 7 | 8 | local ldscript = "LPC17xx.ld" 9 | 10 | -- Prepend with path 11 | specific_files = fwlib_files .. " " .. utils.prepend_path( specific_files, sf( "src/platform/%s", platform ) ) 12 | specific_files = specific_files .. " src/platform/cortex_utils.s src/platform/arm_cortex_interrupts.c" 13 | ldscript = sf( "src/platform/%s/%s", platform, ldscript ) 14 | 15 | addm{ "FOR" .. comp.cpu:upper(), 'gcc', 'CORTEX_M3' } 16 | 17 | -- Standard GCC flags 18 | addcf{ '-ffunction-sections', '-fdata-sections', '-fno-strict-aliasing', '-Wall' } 19 | addlf{ '-nostartfiles', '-nostdlib', '-T', ldscript, '-Wl,--gc-sections', '-Wl,--allow-multiple-definition' } 20 | addaf{ '-x', 'assembler-with-cpp', '-Wall' } 21 | addlib{ 'c','gcc','m' } 22 | 23 | local target_flags = { '-mcpu=cortex-m3','-mthumb' } 24 | 25 | -- Configure general flags for target 26 | addcf{ target_flags, '-mlittle-endian' } 27 | addlf{ target_flags, '-Wl,-e,Reset_Handler', '-Wl,-static' } 28 | addaf{ target_flags } 29 | 30 | -- Toolset data 31 | tools.lpc17xx = {} 32 | 33 | -- Array of file names that will be checked against the 'prog' target; their absence will force a rebuild 34 | tools.lpc17xx.prog_flist = { output .. ".bin" } 35 | 36 | -- We use 'gcc' as the assembler 37 | toolset.asm = toolset.compile 38 | 39 | -------------------------------------------------------------------------------- /src/platform/lpc17xx/drivers/inc/lpc17xx_clkpwr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/lpc17xx/drivers/inc/lpc17xx_clkpwr.h -------------------------------------------------------------------------------- /src/platform/lpc17xx/drivers/inc/lpc17xx_dac.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/lpc17xx/drivers/inc/lpc17xx_dac.h -------------------------------------------------------------------------------- /src/platform/lpc17xx/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE 2048 7 | #define STACK_SIZE_TOTAL ( STACK_SIZE ) 8 | 9 | #endif -------------------------------------------------------------------------------- /src/platform/lpc17xx/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | typedef unsigned char u8; 5 | typedef signed char s8; 6 | typedef unsigned short u16; 7 | typedef signed short s16; 8 | typedef unsigned long u32; 9 | typedef signed long s32; 10 | typedef unsigned long long u64; 11 | typedef signed long long s64; 12 | 13 | 14 | 15 | typedef unsigned char BYTE; 16 | typedef unsigned short WORD; 17 | typedef unsigned long DWORD; 18 | typedef unsigned int BOOL; 19 | 20 | typedef volatile unsigned long* PREG; 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /src/platform/lpc24xx/conf.lua: -------------------------------------------------------------------------------- 1 | -- Configuration file for the LPC24xx backend 2 | 3 | local cpumode = ( builder:get_option( 'cpumode' ) or 'arm' ):lower() 4 | 5 | specific_files = "startup.s irq.c target.c platform.c platform_int.c" 6 | 7 | local ldscript = "lpc2468.lds" 8 | 9 | -- Prepend with path 10 | specific_files = utils.prepend_path( specific_files, sf( "src/platform/%s", platform ) ) 11 | specific_files = specific_files .. " src/platform/arm_utils.s src/platform/arm_cortex_interrupts.c" 12 | ldscript = sf( "src/platform/%s/%s", platform, ldscript ) 13 | 14 | addm{ "FOR" .. comp.cpu:upper(), 'gcc' } 15 | 16 | -- Standard GCC Flags 17 | addcf{ '-ffunction-sections', '-fdata-sections', '-fno-strict-aliasing', '-Wall' } 18 | addlf{ '-nostartfiles', '-nostdlib', '-T', ldscript, '-Wl,--gc-sections', '-Wl,--allow-multiple-definition' } 19 | addaf{ '-x', 'assembler-with-cpp', '-Wall' } 20 | addlib{ 'c','gcc','m' } 21 | 22 | -- Specific target configuration 23 | local target_flags = '-mcpu=arm7tdmi' 24 | if cpumode == 'thumb' then 25 | target_flags = { target_flags, '-mthumb' } 26 | addm( 'CPUMODE_THUMB' ) 27 | else 28 | addm( 'CPUMODE_ARM' ) 29 | end 30 | 31 | addcf( target_flags ) 32 | addlf{ target_flags, '-Wl,-e,entry' } 33 | addaf{ target_flags, '-D___ASSEMBLY__' } 34 | 35 | -- Toolset data 36 | tools.lpc24xx = {} 37 | 38 | -- Array of file names that will be checked against the 'prog' target; their absence will force a rebuild 39 | tools.lpc24xx.prog_flist = { output .. ".hex" } 40 | 41 | -- We use 'gcc' as the assembler 42 | toolset.asm = toolset.compile 43 | 44 | -------------------------------------------------------------------------------- /src/platform/lpc24xx/lpc2468.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") 2 | OUTPUT_ARCH(arm) 3 | 4 | MEMORY 5 | { 6 | sram (W!RX) : ORIGIN = 0x40000000, LENGTH = 96k 7 | flash (RX) : ORIGIN = 0x0, LENGTH = 512k 8 | } 9 | 10 | SECTIONS 11 | { 12 | .fixed : 13 | { 14 | . = ALIGN(4); 15 | _sfixed = .; 16 | PROVIDE(stext = .); 17 | KEEP(*(.vectors)) 18 | *(.text .text.*) 19 | *(.rodata .rodata.*) 20 | *(.gnu.linkonce.t.*) 21 | *(.glue_7) 22 | *(.glue_7t) 23 | *(.gcc_except_table) 24 | *(.gnu.linkonce.r.*) 25 | . = ALIGN(4); 26 | _efixed = .; 27 | PROVIDE(etext = .); 28 | _fini = .; 29 | *(.fini) 30 | } >flash 31 | 32 | .relocate : AT (_efixed) 33 | { 34 | . = ALIGN(4); 35 | _srelocate = .; 36 | *(.data .data.*) 37 | *(.gnu.linkonce.d.*) 38 | . = ALIGN(4); 39 | _erelocate = .; 40 | } >sram 41 | 42 | .ARM.extab : 43 | { 44 | *(.ARM.extab*) 45 | } >sram 46 | 47 | __exidx_start = .; 48 | .ARM.exidx : 49 | { 50 | *(.ARM.exidx*) 51 | } >sram 52 | __exidx_end = .; 53 | 54 | .bss (NOLOAD) : { 55 | _szero = .; 56 | *(.bss .bss.*) 57 | *(.gnu.linkonce.b.*) 58 | *(COMMON) 59 | _ezero = .; 60 | } >sram 61 | 62 | end = .; 63 | } 64 | -------------------------------------------------------------------------------- /src/platform/lpc24xx/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE_USR 8192 7 | #define STACK_SIZE_IRQ 128 8 | #define STACK_SIZE_TOTAL ( STACK_SIZE_USR + STACK_SIZE_IRQ ) 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /src/platform/lpc24xx/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | typedef unsigned char u8; 5 | typedef signed char s8; 6 | typedef unsigned short u16; 7 | typedef signed short s16; 8 | typedef unsigned long u32; 9 | typedef signed long s32; 10 | typedef unsigned long long u64; 11 | typedef signed long long s64; 12 | 13 | #ifndef FALSE 14 | #define FALSE (0) 15 | #endif 16 | 17 | #ifndef TRUE 18 | #define TRUE (1) 19 | #endif 20 | 21 | typedef unsigned char BYTE; 22 | typedef unsigned short WORD; 23 | typedef unsigned long DWORD; 24 | typedef unsigned int BOOL; 25 | 26 | typedef volatile unsigned long* PREG; 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /src/platform/lpc24xx/uart.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * uart.h: Header file for NXP LPC23xx Family Microprocessors 3 | * 4 | * Copyright(C) 2006, NXP Semiconductor 5 | * All rights reserved. 6 | * 7 | * History 8 | * 2006.09.01 ver 1.00 Prelimnary version, first Release 9 | * 10 | * Modified by BogdanM for eLua 11 | ******************************************************************************/ 12 | 13 | #ifndef __UART_H 14 | #define __UART_H 15 | 16 | #include "type.h" 17 | 18 | #define IER_RBR 0x01 19 | #define IER_THRE 0x02 20 | #define IER_RLS 0x04 21 | 22 | #define IIR_PEND 0x01 23 | #define IIR_RLS 0x03 24 | #define IIR_RDA 0x02 25 | #define IIR_CTI 0x06 26 | #define IIR_THRE 0x01 27 | 28 | #define LSR_RDR 0x01 29 | #define LSR_OE 0x02 30 | #define LSR_PE 0x04 31 | #define LSR_FE 0x08 32 | #define LSR_BI 0x10 33 | #define LSR_THRE 0x20 34 | #define LSR_TEMT 0x40 35 | #define LSR_RXFE 0x80 36 | 37 | // UART setup constants 38 | enum 39 | { 40 | UART_DATABITS_5 = 0, 41 | UART_DATABITS_6 = 1, 42 | UART_DATABITS_7 = 2, 43 | UART_DATABITS_8 = 3, 44 | UART_STOPBITS_1 = 0, 45 | UART_STOPBITS_2 = 4, 46 | UART_PARITY_ENABLE = 8, 47 | UART_PARITY_ODD = 0, 48 | UART_PARITY_EVEN = 1 << 4, 49 | UART_DLAB_ENABLE = 1 << 7, 50 | UART_FIFO_ENABLE = 1, 51 | UART_RXFIFO_RESET = 2, 52 | UART_TXFIFO_RESET = 4 53 | }; 54 | 55 | #endif /* end __UART_H */ 56 | /***************************************************************************** 57 | ** End Of File 58 | ******************************************************************************/ 59 | 60 | -------------------------------------------------------------------------------- /src/platform/lpc288x/conf.lua: -------------------------------------------------------------------------------- 1 | -- Configuration file for the LPC288x backend 2 | 3 | local cpumode = ( builder:get_option( 'cpumode' ) or 'arm' ):lower() 4 | 5 | specific_files = "lpc28xx.s platform.c target.c uart.c" 6 | 7 | local ldscript = "lpc2888.lds" 8 | 9 | if cpumode == 'thumb' then 10 | print "ERROR: due to a hardware limitation, it is not possible to run Thumb code from the LPC2888 internal flash." 11 | print "Compile again, this time with cpumode=arm (or without specifying 'cpumode')" 12 | os.exit( -1 ) 13 | end 14 | 15 | -- Prepend with path 16 | specific_files = utils.prepend_path( specific_files, sf( "src/platform/%s", platform ) ) 17 | specific_files = specific_files .. " src/platform/arm_utils.s src/platform/arm_cortex_interrupts.c" 18 | ldscript = sf( "src/platform/%s/%s", platform, ldscript ) 19 | 20 | addm{ "FOR" .. comp.cpu:upper(), 'gcc' } 21 | 22 | -- Standard GCC flags 23 | addcf{ '-ffunction-sections', '-fdata-sections', '-fno-strict-aliasing', '-Wall' } 24 | addlf{ '-nostartfiles', '-nostdlib', '-T', ldscript, '-Wl,--gc-sections', '-Wl,--allow-multiple-definition' } 25 | addaf{ '-x', 'assembler-with-cpp', '-Wall' } 26 | addlib{ 'c','gcc','m' } 27 | 28 | -- Special target configuration 29 | local target_flags = { '-mcpu=arm7tdmi' } 30 | addm( 'CPUMODE_ARM' ) 31 | 32 | addcf( target_flags ) 33 | addlf{ target_flags, '-Wl,-e,HardReset' } 34 | addaf{ target_flags,'-D__ASSEMBLY__' } 35 | 36 | -- Toolset data 37 | tools.lpc288x = {} 38 | 39 | -- Array of file names that will be checked against the 'prog' target; their absence will force a rebuild 40 | tools.lpc288x.prog_flist = { output .. ".bin" } 41 | 42 | -- We use 'gcc' as the assembler 43 | toolset.asm = toolset.compile 44 | 45 | -------------------------------------------------------------------------------- /src/platform/lpc288x/lpc2888.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") 2 | OUTPUT_ARCH(arm) 3 | 4 | MEMORY 5 | { 6 | sram (W!RX) : ORIGIN = 0x00400000, LENGTH = 64k 7 | flash (RX) : ORIGIN = 0x10400000, LENGTH = (1M - 8k) 8 | } 9 | 10 | SECTIONS 11 | { 12 | .fixed : 13 | { 14 | . = ALIGN(4); 15 | _sfixed = .; 16 | PROVIDE(stext = .); 17 | KEEP(*(.vectors)) 18 | *(.text .text.*) 19 | *(.rodata .rodata.*) 20 | *(.gnu.linkonce.t.*) 21 | *(.glue_7) 22 | *(.glue_7t) 23 | *(.gcc_except_table) 24 | *(.gnu.linkonce.r.*) 25 | . = ALIGN(4); 26 | _efixed = .; 27 | PROVIDE(etext = .); 28 | _fini = .; 29 | *(.fini) 30 | } >flash 31 | 32 | .relocate : AT (_efixed) 33 | { 34 | . = ALIGN(4); 35 | _srelocate = .; 36 | *(.data .data.*) 37 | *(.gnu.linkonce.d.*) 38 | . = ALIGN(4); 39 | _erelocate = .; 40 | } >sram 41 | 42 | .ARM.extab : 43 | { 44 | *(.ARM.extab*) 45 | } >sram 46 | 47 | __exidx_start = .; 48 | .ARM.exidx : 49 | { 50 | *(.ARM.exidx*) 51 | } >sram 52 | __exidx_end = .; 53 | 54 | .bss (NOLOAD) : { 55 | _szero = .; 56 | *(.bss .bss.*) 57 | *(.gnu.linkonce.b.*) 58 | *(COMMON) 59 | _ezero = .; 60 | } >sram 61 | 62 | end = .; 63 | } 64 | -------------------------------------------------------------------------------- /src/platform/lpc288x/sdram_lpc.h: -------------------------------------------------------------------------------- 1 | #ifndef __SDRAM_LPC 2 | #define __SDRAM_LPC 3 | 4 | #include "type.h" 5 | 6 | #define SDRAM_PERIOD 16.6 // 60MHz 7 | #define P2C(Period) (((Period 7 | #include 8 | 9 | extern int host_errno; 10 | 11 | ssize_t host_read( int fd, void * buf, size_t count ); 12 | ssize_t host_write( int fd, const void * buf, size_t count ); 13 | int host_open( const char *name, int flags, mode_t mode ); 14 | int host_close( int fd ); 15 | 16 | #define PROT_READ 0x1 /* Page can be read. */ 17 | #define PROT_WRITE 0x2 /* Page can be written. */ 18 | #define PROT_EXEC 0x4 /* Page can be executed. */ 19 | #define PROT_NONE 0x0 /* Page can not be accessed. */ 20 | 21 | #define MAP_SHARED 0x01 /* Share changes. */ 22 | #define MAP_PRIVATE 0x02 /* Changes are private. */ 23 | #define MAP_FIXED 0x10 /* Interpret addr exactly. */ 24 | #define MAP_ANONYMOUS 0x20 /* Don't use a file. */ 25 | 26 | // Flags for "open" 27 | #define O_RDONLY 00 28 | #define O_WRONLY 01 29 | 30 | #define MAP_FAILED (void *)(-1) 31 | 32 | void *host_mmap2(void *addr, size_t length, int prot, int flags, int fd, off_t pgoffset); 33 | void host_exit(int status); 34 | 35 | #endif // _HOST_H 36 | 37 | -------------------------------------------------------------------------------- /src/platform/sim/hostif.h: -------------------------------------------------------------------------------- 1 | // Host I/O operations for eLua 'simulator' 2 | 3 | #ifndef __HOSTIO_H__ 4 | #define __HOSTIO_H__ 5 | 6 | // Write a single character out to the screen. 7 | void hostif_putc(char c); 8 | 9 | // Output a null-terminated ASCII string to the monitor. 10 | void hostif_putstr(const char *c); 11 | 12 | // Get a char from keyboard 13 | int hostif_getch(); 14 | 15 | // Get memory 16 | void *hostif_getmem( unsigned size ); 17 | 18 | // Terminate the simulator (exit program) 19 | void hostif_exit(); 20 | 21 | // Open 22 | int hostif_open( const char* name, int flags, unsigned mode ); 23 | 24 | // Read 25 | int hostif_read( int fd, void *buf, unsigned count ); 26 | 27 | // Write 28 | int hostif_write( int fd, const void *buf, unsigned count ); 29 | 30 | // Close 31 | int hostif_close( int fd ); 32 | 33 | #endif // __HOSTIO_H__ 34 | 35 | -------------------------------------------------------------------------------- /src/platform/sim/hostif_linux.c: -------------------------------------------------------------------------------- 1 | // Host I/O operations for eLua 'simulator' 2 | 3 | #include 4 | #include 5 | #include 6 | #include "term.h" 7 | #include "host.h" 8 | #include "hostif.h" 9 | 10 | #define EOF (-1) 11 | #define STDIN_FILENO 0 12 | #define STDOUT_FILENO 1 13 | 14 | void hostif_putc(char c) 15 | { 16 | host_write(STDOUT_FILENO, &c, 1); 17 | } 18 | 19 | void hostif_putstr(const char *c) 20 | { 21 | int i = 0; 22 | while( c[ i ] ) 23 | hostif_putc( c[ i++ ] ); 24 | } 25 | 26 | int hostif_getch() 27 | { 28 | unsigned char ch = 0; 29 | if(host_read(STDIN_FILENO, &ch, 1) != 1) { 30 | return EOF; 31 | } 32 | return (int)ch; 33 | 34 | } 35 | 36 | void* hostif_getmem( unsigned size ) 37 | { 38 | void *pmem = host_mmap2( 0, size, (PROT_READ|PROT_WRITE), (MAP_PRIVATE|MAP_ANONYMOUS), -1, 0 ); 39 | return pmem == MAP_FAILED ? NULL : pmem; 40 | } 41 | 42 | void hostif_exit() 43 | { 44 | host_exit( 0 ); 45 | } 46 | 47 | int hostif_open( const char* name, int flags, unsigned mode ) 48 | { 49 | return host_open( name, flags, ( mode_t )mode ); 50 | } 51 | 52 | int hostif_read( int fd, void *buf, unsigned count ) 53 | { 54 | return ( int )host_read( fd, buf, ( size_t )count ); 55 | } 56 | 57 | int hostif_write( int fd, const void *buf, unsigned count ) 58 | { 59 | return ( int )host_write( fd, buf, ( size_t )count ); 60 | } 61 | 62 | int hostif_close( int fd ) 63 | { 64 | return host_close( fd ); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/platform/sim/i386.ld: -------------------------------------------------------------------------------- 1 | /* Link.ld -- Linker script for the kernel - ensure everything goes in the */ 2 | /* Correct place. */ 3 | /* Original file taken from Bran's Kernel Development */ 4 | /* tutorials: http://www.osdever.net/bkerndev/index.php. */ 5 | 6 | SECTIONS 7 | { 8 | 9 | .text 0x100000 : 10 | { 11 | KEEP(*(.header)) 12 | code = .; _code = .; __code = .; 13 | PROVIDE(stext = .); 14 | *(.text .text.*) 15 | *(.rodata .rodata.*) 16 | *(.gnu.linkonce.r.*) 17 | *(.gnu.linkonce.t.*) 18 | . = ALIGN(4096); 19 | PROVIDE(etext = .); 20 | } 21 | 22 | .data : 23 | { 24 | data = .; _data = .; __data = .; 25 | *(.data .data.*) 26 | *(.gnu.linkonce.d.*) 27 | . = ALIGN(4096); 28 | } 29 | 30 | .bss : 31 | { 32 | bss = .; _bss = .; __bss = .; 33 | *(.bss .bss.*) 34 | *(.gnu.linkonce.b.*) 35 | *(COMMON) 36 | . = ALIGN(4096); 37 | } 38 | 39 | end = .; _end = .; __end = .; 40 | } 41 | -------------------------------------------------------------------------------- /src/platform/sim/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE_TOTAL 32768 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /src/platform/sim/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | #ifndef NULL 5 | #define NULL ((void *)0) 6 | #endif 7 | 8 | #ifndef FALSE 9 | #define FALSE (0) 10 | #endif 11 | 12 | #ifndef TRUE 13 | #define TRUE (1) 14 | #endif 15 | 16 | typedef unsigned char BYTE; 17 | typedef unsigned short WORD; 18 | typedef unsigned long DWORD; 19 | typedef unsigned int BOOL; 20 | 21 | typedef unsigned char u8; 22 | typedef signed char s8; 23 | typedef unsigned short u16; 24 | typedef signed short s16; 25 | typedef unsigned long u32; 26 | typedef signed long s32; 27 | typedef unsigned long long u64; 28 | typedef signed long long s64; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/platform/sim/utils.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; boot.s -- Kernel start location. Also defines multiboot header. 3 | ; Based on Bran's kernel development tutorial file start.asm 4 | ; 5 | 6 | [BITS 32] ; All instructions should be 32-bit. 7 | 8 | [GLOBAL longjmp] 9 | [SECTION .text] 10 | 11 | longjmp: 12 | push ebp 13 | mov ebp, esp 14 | 15 | mov edi, [ebp+8] ; get jump buffer 16 | mov eax, [ebp+12] ; store retval in j->eax 17 | mov [edi], eax 18 | 19 | mov ebp, [edi+24] 20 | 21 | mov esp, [edi+28] 22 | 23 | push dword [edi+32] 24 | 25 | mov eax, [edi] 26 | mov ebx, [edi+4] 27 | mov ecx, [edi+8] 28 | mov edx, [edi+12] 29 | mov esi, [edi+16] 30 | mov edi, [edi+20] 31 | 32 | ret 33 | 34 | -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/inc/stm32f10x_fsmc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/inc/stm32f10x_fsmc.h -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_adc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_adc.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_can.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_can.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_dma.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_dma.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_exti.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_exti.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_flash.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_fsmc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_fsmc.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_i2c.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_rcc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_rcc.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_rtc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_rtc.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_sdio.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_sdio.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_tim.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_tim.c -------------------------------------------------------------------------------- /src/platform/stm32/FWLib/library/src/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/stm32/FWLib/library/src/stm32f10x_usart.c -------------------------------------------------------------------------------- /src/platform/stm32/enc.h: -------------------------------------------------------------------------------- 1 | // STM32 encoder support 2 | 3 | #ifndef __ENC_H__ 4 | #define __ENC_H__ 5 | 6 | void stm32_enc_init( unsigned id ); 7 | void stm32_enc_set_counter( unsigned id, unsigned count ); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/platform/stm32/fsmc_sram.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** 2 | * File Name : fsmc_sram.h 3 | * Author : MCD Application Team 4 | * Version : V2.0.3 5 | * Date : 09/22/2008 6 | * Description : Header for fsmc_sram.c file. 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __FSMC_SRAM_H 18 | #define __FSMC_SRAM_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | //#include "stm32f10x_lib.h" 22 | #include "type.h" 23 | 24 | /* Exported types ------------------------------------------------------------*/ 25 | /* Exported constants --------------------------------------------------------*/ 26 | /* Exported macro ------------------------------------------------------------*/ 27 | /* Exported functions ------------------------------------------------------- */ 28 | void FSMC_SRAM_Init(void); 29 | 30 | #endif /* __FSMC_SRAM_H */ 31 | 32 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ 33 | -------------------------------------------------------------------------------- /src/platform/stm32/lstm32_mod.c: -------------------------------------------------------------------------------- 1 | // Example module that shows how to use the rom-loader in modcommon.c 2 | 3 | #include "lua.h" 4 | #include "lualib.h" 5 | #include "lauxlib.h" 6 | #include "platform.h" 7 | #include "auxmods.h" 8 | #include "modcommon.h" 9 | #include 10 | #include 11 | #include 12 | 13 | #define THENUMBERONE 1 // Example constant to demo _ELUA_CTE macro use 14 | 15 | static int afunc(lua_State * L) 16 | { 17 | lua_pushliteral(L, "afunc() called!"); 18 | 19 | return 1; 20 | } 21 | 22 | static const eLua_const_userdata_t consts[] = 23 | { 24 | _ELUA_CTE(THENUMBERONE), 25 | { NULL, 0 } 26 | }; 27 | 28 | static const luaL_reg funcs[] = 29 | { 30 | { "afunc", afunc }, 31 | { NULL, NULL } 32 | }; // Pretty boring module ... 33 | 34 | // Function that gets called when lua registers the module 35 | LUALIB_API int luaopen_stm32(lua_State * L) 36 | { 37 | eLua_register(L, "stm32", funcs); // Register module methods first 38 | eLua_register_const(L, consts); // Then register constants, if any. 39 | 40 | return 1; 41 | } 42 | 43 | // Add the module to the module table. Do *NOT* terminate this with a NULL entry 44 | // The linker script does it for you. 45 | _ELUA_MODTAB = { 46 | { "stm32", luaopen_stm32 } 47 | }; 48 | 49 | -------------------------------------------------------------------------------- /src/platform/stm32/nrf_conf.h: -------------------------------------------------------------------------------- 1 | // nRF configuration 2 | 3 | #ifndef __NRF_CONF_H__ 4 | #define __NRF_CONF_H__ 5 | 6 | #include "nrf.h" 7 | 8 | // RF channel 9 | #define NRF_CFG_RF_CHANNEL 2 10 | // TX power (0 is the highest, see NRF_RF_SETUP_PWR_xxx in nrf.h for more values) 11 | #define NRF_CFG_TX_POWER NRF_RF_SETUP_PWR_0 12 | // Data rate (1Mbps or 2Mbps) 13 | #define NRF_CFG_DATA_RATE NRF_RF_SETUP_DR_1MBPS 14 | // Debugging on 15 | //#define NRF_DEBUG 16 | 17 | #endif // #ifndef __NRF_CONF_H__ 18 | 19 | -------------------------------------------------------------------------------- /src/platform/stm32/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE 8192 7 | #define STACK_SIZE_TOTAL ( STACK_SIZE ) 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/platform/stm32/stm32.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 64k 4 | flash (RX) : ORIGIN = 0x08000000, LENGTH = 512k 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : 10 | { 11 | . = ALIGN(4); 12 | _text = .; 13 | PROVIDE(stext = .); 14 | KEEP(*(.isr_vector)) 15 | KEEP(*(.init)) 16 | *(.text .text.*) 17 | *(.rodata .rodata.*) 18 | *(.gnu.linkonce.t.*) 19 | *(.glue_7) 20 | *(.glue_7t) 21 | *(.gcc_except_table) 22 | *(.gnu.linkonce.r.*) 23 | . = ALIGN(4); 24 | _etext = .; 25 | _sidata = _etext; 26 | PROVIDE(etext = .); 27 | _fini = . ; 28 | *(.fini) 29 | 30 | } >flash 31 | 32 | .data : AT (_etext) 33 | { 34 | . = ALIGN(4); 35 | _sdata = .; 36 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 37 | *(.data .data.*) 38 | *(.gnu.linkonce.d.*) 39 | . = ALIGN(4); 40 | _edata = .; 41 | } >sram 42 | 43 | .ARM.extab : 44 | { 45 | *(.ARM.extab*) 46 | } >sram 47 | 48 | __exidx_start = .; 49 | .ARM.exidx : 50 | { 51 | *(.ARM.exidx*) 52 | } >sram 53 | __exidx_end = .; 54 | 55 | .bss (NOLOAD) : { 56 | . = ALIGN(4); 57 | /* This is used by the startup in order to initialize the .bss secion */ 58 | _sbss = .; 59 | *(.bss .bss.*) 60 | *(.gnu.linkonce.b.*) 61 | *(COMMON) 62 | . = ALIGN(4); 63 | _ebss = .; 64 | } >sram 65 | 66 | end = .; 67 | PROVIDE( _estack = 0x20010000 ); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /src/platform/stm32/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | #include "stm32f10x.h" 5 | 6 | #ifndef NULL 7 | #define NULL ((void *)0) 8 | #endif 9 | 10 | #ifndef FALSE 11 | #define FALSE (0) 12 | #endif 13 | 14 | #ifndef TRUE 15 | #define TRUE (1) 16 | #endif 17 | 18 | typedef unsigned char BYTE; 19 | typedef unsigned short WORD; 20 | typedef unsigned long DWORD; 21 | typedef unsigned int BOOL; 22 | 23 | typedef unsigned long long u64; 24 | typedef signed long long s64; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/platform/str7/71x_conf.h: -------------------------------------------------------------------------------- 1 | // Configuration for STR7 2 | 3 | #ifndef __71X_CONF_H__ 4 | #define __71X_CONF_H__ 5 | 6 | #define _APB 7 | #define _GPIO 8 | #define _RCCU 9 | #define _UART 10 | #define _TIM 11 | 12 | #define RCCU_Main_Osc 4000000 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/platform/str7/conf.lua: -------------------------------------------------------------------------------- 1 | -- Configuration file for the STR7 backend 2 | 3 | local cpumode = ( builder:get_option( 'cpumode' ) or 'thumb' ):lower() 4 | specific_files = "platform.c crt0.s 71x_rccu.c 71x_uart.c 71x_apb.c 71x_gpio.c 71x_tim.c" 5 | local ldscript = 'str711fr2.lds' 6 | 7 | -- Prepend with path 8 | specific_files = utils.prepend_path( specific_files, sf( "src/platform/%s", platform ) ) 9 | specific_files = specific_files .. " src/platform/arm_utils.s src/platform/arm_cortex_interrupts.c" 10 | ldscript = sf( "src/platform/%s/%s", platform, ldscript ) 11 | 12 | addm{ "FOR" .. comp.cpu:upper(), 'gcc' } 13 | 14 | -- Standard GCC flags 15 | addcf{ '-ffunction-sections', '-fdata-sections', '-fno-strict-aliasing','-Wall' } 16 | addlf{ '-nostartfiles', '-nostdlib', '-T', ldscript, '-Wl,--gc-sections', '-Wl,--allow-multiple-definition' } 17 | addaf{ '-x', 'assembler-with-cpp', '-Wall' } 18 | addlib{ 'c','gcc','m' } 19 | 20 | -- Special target configuration 21 | local target_flasg = '-mcpu=arm7tdmi' 22 | if cpumode == 'thumb' then 23 | target_flags = { target_flags, '-mthumb' } 24 | addm( 'CPUMODE_THUMB' ) 25 | else 26 | addm( 'CPUMODE_ARM' ) 27 | end 28 | 29 | addcf( target_flags ) 30 | addlf{ target_flags, '-Wl,-e,entry' } 31 | addaf( target_flags ) 32 | 33 | -- Toolset data 34 | tools.str7 = {} 35 | 36 | -- Array of file names that will be checked against the 'prog' target; their absence will force a rebuild 37 | tools.str7.prog_flist = { output .. ".bin" } 38 | 39 | -- We use 'gcc' as the assembler 40 | toolset.asm = toolset.compile 41 | 42 | -------------------------------------------------------------------------------- /src/platform/str7/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE_USR 2048 7 | #define STACK_SIZE_TOTAL ( STACK_SIZE_USR ) 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/platform/str7/str711fr2.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") 2 | OUTPUT_ARCH(arm) 3 | ENTRY(entry) 4 | 5 | MEMORY 6 | { 7 | sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x10000 8 | flash (RX) : ORIGIN = 0x0, LENGTH = 0x40000 9 | } 10 | 11 | SECTIONS 12 | { 13 | .fixed : 14 | { 15 | . = ALIGN(4); 16 | _sfixed = .; 17 | PROVIDE(stext = .); 18 | KEEP(*(.vectors)) 19 | KEEP(*(.init)) 20 | *(.text .text.*) 21 | *(.rodata .rodata.*) 22 | *(.gnu.linkonce.t.*) 23 | *(.glue_7) 24 | *(.glue_7t) 25 | *(.gcc_except_table) 26 | *(.gnu.linkonce.r.*) 27 | . = ALIGN(4); 28 | _efixed = .; 29 | PROVIDE(etext = .); 30 | _fini = .; 31 | *(.fini) 32 | } >flash 33 | 34 | .relocate : AT (_efixed) 35 | { 36 | . = ALIGN(4); 37 | _srelocate = .; 38 | *(.ramfunc .ramfunc.* .fastrun .fastrun.*) 39 | *(.data .data.*) 40 | *(.gnu.linkonce.d.*) 41 | . = ALIGN(4); 42 | _erelocate = .; 43 | } >sram 44 | 45 | .ARM.extab : 46 | { 47 | *(.ARM.extab*) 48 | } >sram 49 | 50 | __exidx_start = .; 51 | .ARM.exidx : 52 | { 53 | *(.ARM.exidx*) 54 | } >sram 55 | __exidx_end = .; 56 | 57 | .bss (NOLOAD) : { 58 | _szero = .; 59 | *(.bss .bss.*) 60 | *(.gnu.linkonce.b.*) 61 | *(COMMON) 62 | _ezero = .; 63 | } >sram 64 | 65 | end = .; 66 | _sstack = 0x20010000; 67 | } 68 | -------------------------------------------------------------------------------- /src/platform/str7/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | typedef unsigned char BYTE; 4 | typedef unsigned short WORD; 5 | typedef unsigned long DWORD; 6 | typedef unsigned int BOOL; 7 | 8 | typedef unsigned char u8; 9 | typedef signed char s8; 10 | typedef unsigned short u16; 11 | typedef signed short s16; 12 | typedef unsigned long u32; 13 | typedef signed long s32; 14 | typedef unsigned long long u64; 15 | typedef signed long long s64; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/platform/str9/91x_wiu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bogdanm/eLuaBrain/35176be6e4e82fb4e7dadf5cd2379c0a4ea2314c/src/platform/str9/91x_wiu.c -------------------------------------------------------------------------------- /src/platform/str9/stacks.h: -------------------------------------------------------------------------------- 1 | // Stack size definitions 2 | 3 | #ifndef __STACKS_H__ 4 | #define __STACKS_H__ 5 | 6 | #define STACK_SIZE_SVC 2048 7 | #define STACK_SIZE_IRQ 96 8 | #define STACK_SIZE_TOTAL ( STACK_SIZE_SVC + STACK_SIZE_IRQ ) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/platform/str9/str912fw44.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") 2 | OUTPUT_ARCH(arm) 3 | 4 | MEMORY 5 | { 6 | sram (W!RX) : ORIGIN = 0x40000000, LENGTH = 96k 7 | flash (RX) : ORIGIN = 0x0, LENGTH = 512k 8 | } 9 | 10 | SECTIONS 11 | { 12 | .fixed : 13 | { 14 | . = ALIGN(4); 15 | _sfixed = .; 16 | PROVIDE(stext = .); 17 | KEEP(*(.vectors)) 18 | *(.text .text.*) 19 | *(.rodata .rodata.*) 20 | *(.gnu.linkonce.t.*) 21 | *(.glue_7) 22 | *(.glue_7t) 23 | *(.gcc_except_table) 24 | *(.gnu.linkonce.r.*) 25 | . = ALIGN(4); 26 | _efixed = .; 27 | PROVIDE(etext = .); 28 | _fini = .; 29 | *(.fini) 30 | } >flash 31 | 32 | .relocate : AT (_efixed) 33 | { 34 | . = ALIGN(4); 35 | _srelocate = .; 36 | *(.data .data.*) 37 | *(.gnu.linkonce.d.*) 38 | . = ALIGN(4); 39 | _erelocate = .; 40 | } >sram 41 | 42 | .ARM.extab : 43 | { 44 | *(.ARM.extab*) 45 | } >sram 46 | 47 | __exidx_start = .; 48 | .ARM.exidx : 49 | { 50 | *(.ARM.exidx*) 51 | } >sram 52 | __exidx_end = .; 53 | 54 | .bss (NOLOAD) : { 55 | _szero = .; 56 | *(.bss .bss.*) 57 | *(.gnu.linkonce.b.*) 58 | *(COMMON) 59 | _ezero = .; 60 | } >sram 61 | 62 | end = .; 63 | } 64 | -------------------------------------------------------------------------------- /src/platform/str9/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | typedef unsigned char BYTE; 5 | typedef unsigned short WORD; 6 | typedef unsigned long DWORD; 7 | typedef unsigned int BOOL; 8 | 9 | typedef unsigned char u8; 10 | typedef signed char s8; 11 | typedef unsigned short u16; 12 | typedef signed short s16; 13 | typedef unsigned long u32; 14 | typedef signed long s32; 15 | typedef unsigned long long u64; 16 | typedef signed long long s64; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/remotefs/elua_os_io.c: -------------------------------------------------------------------------------- 1 | // Remote FS IO adapter for eLua 2 | 3 | #include 4 | #include 5 | #include 6 | #include "os_io.h" 7 | #include "remotefs.h" 8 | #include "eluarpc.h" 9 | 10 | u32 os_open_sys_flags_to_rfs_flags( int sysflags ) 11 | { 12 | int rfsflags = 0; 13 | 14 | // Translate RFS flags to POSIX flags 15 | rfsflags = eluarpc_replace_flag( sysflags, O_APPEND, RFS_OPEN_FLAG_APPEND ); 16 | rfsflags |= eluarpc_replace_flag( sysflags, O_CREAT, RFS_OPEN_FLAG_CREAT ); 17 | rfsflags |= eluarpc_replace_flag( sysflags, O_EXCL, RFS_OPEN_FLAG_EXCL ); 18 | rfsflags |= eluarpc_replace_flag( sysflags, O_TRUNC, RFS_OPEN_FLAG_TRUNC ); 19 | rfsflags |= eluarpc_replace_flag( sysflags, O_SYNC, RFS_OPEN_FLAG_SYNC ); 20 | rfsflags |= eluarpc_replace_flag( sysflags, O_RDONLY, RFS_OPEN_FLAG_RDONLY ); 21 | rfsflags |= eluarpc_replace_flag( sysflags, O_WRONLY, RFS_OPEN_FLAG_WRONLY ); 22 | rfsflags |= eluarpc_replace_flag( sysflags, O_RDWR, RFS_OPEN_FLAG_RDWR ); 23 | return rfsflags; 24 | } 25 | 26 | u32 os_lseek_sys_whence_to_rfs_whence( int syswhence ) 27 | { 28 | switch( syswhence ) 29 | { 30 | case SEEK_SET: 31 | return RFS_LSEEK_SET; 32 | 33 | case SEEK_CUR: 34 | return RFS_LSEEK_CUR; 35 | 36 | case SEEK_END: 37 | return RFS_LSEEK_END; 38 | } 39 | return 0; 40 | } 41 | 42 | --------------------------------------------------------------------------------