├── Lua 5.3_STM32F10x ├── ArduinoAPI │ ├── Arduino.c │ ├── Arduino.h │ ├── HardwareSerial.cpp │ ├── HardwareSerial.h │ ├── Print.cpp │ ├── Print.h │ ├── Printable.h │ ├── SPI.cpp │ ├── SPI.h │ ├── Stream.cpp │ ├── Stream.h │ ├── WProgram.h │ ├── WString.cpp │ ├── WString.h │ ├── Wire.cpp │ ├── Wire.h │ ├── WireBase.cpp │ ├── WireBase.h │ ├── avr │ │ ├── dtostrf.c │ │ ├── dtostrf.h │ │ ├── interrupt.h │ │ └── pgmspace.h │ ├── binary.h │ ├── dtostrf.c │ ├── dtostrf.h │ ├── itoa.c │ ├── itoa.h │ ├── libmaple_types.h │ └── wirish_math.h ├── Core │ ├── adc.c │ ├── adc.h │ ├── delay.c │ ├── delay.h │ ├── exti.c │ ├── exti.h │ ├── gpio.c │ ├── gpio.h │ ├── pwm.c │ ├── pwm.h │ ├── time_exti.c │ ├── time_exti.h │ ├── usart.c │ └── usart.h ├── Libraries │ ├── Time │ │ ├── DateStrings.cpp │ │ ├── Readme.txt │ │ ├── Time.cpp │ │ ├── Time.h │ │ ├── TimeLib.h │ │ ├── examples │ │ │ ├── Processing │ │ │ │ └── SyncArduinoClock │ │ │ │ │ ├── SyncArduinoClock.pde │ │ │ │ │ └── readme.txt │ │ │ ├── TimeArduinoDue │ │ │ │ └── TimeArduinoDue.ino │ │ │ ├── TimeGPS │ │ │ │ └── TimeGPS.ino │ │ │ ├── TimeNTP │ │ │ │ └── TimeNTP.ino │ │ │ ├── TimeNTP_ESP8266WiFi │ │ │ │ └── TimeNTP_ESP8266WiFi.ino │ │ │ ├── TimeRTC │ │ │ │ └── TimeRTC.ino │ │ │ ├── TimeRTCLog │ │ │ │ └── TimeRTCLog.ino │ │ │ ├── TimeRTCSet │ │ │ │ └── TimeRTCSet.ino │ │ │ ├── TimeSerial │ │ │ │ └── TimeSerial.ino │ │ │ ├── TimeSerialDateStrings │ │ │ │ └── TimeSerialDateStrings.ino │ │ │ └── TimeTeensy3 │ │ │ │ └── TimeTeensy3.ino │ │ ├── keywords.txt │ │ ├── library.json │ │ └── library.properties │ └── lua-5.3.2 │ │ ├── Makefile │ │ ├── README │ │ ├── doc │ │ ├── contents.html │ │ ├── index.css │ │ ├── logo.gif │ │ ├── lua.1 │ │ ├── lua.css │ │ ├── luac.1 │ │ ├── manual.css │ │ ├── manual.html │ │ ├── osi-certified-72x60.png │ │ └── readme.html │ │ └── src │ │ ├── Makefile │ │ ├── lapi.c │ │ ├── lapi.h │ │ ├── lauxlib.c │ │ ├── lauxlib.h │ │ ├── lbaselib.c │ │ ├── lbitlib.c │ │ ├── lcode.c │ │ ├── lcode.h │ │ ├── lcorolib.c │ │ ├── lctype.c │ │ ├── lctype.h │ │ ├── ldblib.c │ │ ├── ldebug.c │ │ ├── ldebug.h │ │ ├── ldo.c │ │ ├── ldo.h │ │ ├── ldump.c │ │ ├── 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 │ │ ├── lprefix.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 │ │ ├── lua.hpp │ │ ├── luac.c │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.c │ │ ├── lundump.h │ │ ├── lutf8lib.c │ │ ├── lvm.c │ │ ├── lvm.h │ │ ├── lzio.c │ │ └── lzio.h ├── USER │ ├── C_call_CPP.h │ ├── DebugConfig │ │ ├── Arduino_For_Keil_STM32F103C8_1.0.0.dbgconf │ │ └── Project_STM32F103ZE_1.0.0.dbgconf │ ├── EventRecorderStub.scvd │ ├── FileGroup.h │ ├── Lua_Call.cpp │ ├── Pro.uvguix.FASTSHIFT │ ├── Pro.uvguix.lenovo │ ├── Pro.uvguix.linzh │ ├── Pro.uvoptx │ ├── Pro.uvprojx │ ├── RTE │ │ ├── Device │ │ │ ├── STM32F103C8 │ │ │ │ ├── RTE_Device.h │ │ │ │ ├── RTE_Device.h.0000 │ │ │ │ ├── RTE_Device.h.0001 │ │ │ │ ├── RTE_Device.h.0002 │ │ │ │ ├── RTE_Device.h.0003 │ │ │ │ ├── RTE_Device.h.0004 │ │ │ │ ├── RTE_Device.h.0005 │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ ├── startup_stm32f10x_md.s.0000 │ │ │ │ ├── startup_stm32f10x_md.s.0001 │ │ │ │ ├── startup_stm32f10x_md.s.0002 │ │ │ │ ├── startup_stm32f10x_md.s.0003 │ │ │ │ ├── startup_stm32f10x_md.s.0004 │ │ │ │ ├── startup_stm32f10x_md.s.0005 │ │ │ │ ├── stm32f10x_conf.h │ │ │ │ ├── stm32f10x_conf.h.0000 │ │ │ │ ├── stm32f10x_conf.h.0001 │ │ │ │ ├── stm32f10x_conf.h.0002 │ │ │ │ ├── stm32f10x_conf.h.0003 │ │ │ │ ├── stm32f10x_conf.h.0004 │ │ │ │ ├── stm32f10x_conf.h.0005 │ │ │ │ ├── system_stm32f10x.c │ │ │ │ ├── system_stm32f10x.c.0000 │ │ │ │ ├── system_stm32f10x.c.0001 │ │ │ │ ├── system_stm32f10x.c.0002 │ │ │ │ ├── system_stm32f10x.c.0003 │ │ │ │ ├── system_stm32f10x.c.0004 │ │ │ │ └── system_stm32f10x.c.0005 │ │ │ ├── STM32F103CB │ │ │ │ ├── RTE_Device.h │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ ├── stm32f10x_conf.h │ │ │ │ └── system_stm32f10x.c │ │ │ ├── STM32F103VE │ │ │ │ ├── RTE_Device.h │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ ├── stm32f10x_conf.h │ │ │ │ └── system_stm32f10x.c │ │ │ └── STM32F103ZE │ │ │ │ ├── RTE_Device.h │ │ │ │ ├── RTE_Device.h.0000 │ │ │ │ ├── RTE_Device.h.0001 │ │ │ │ ├── RTE_Device.h.0002 │ │ │ │ ├── RTE_Device.h.0003 │ │ │ │ ├── RTE_Device.h.0004 │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ ├── startup_stm32f10x_hd.s.0000 │ │ │ │ ├── startup_stm32f10x_hd.s.0001 │ │ │ │ ├── startup_stm32f10x_hd.s.0002 │ │ │ │ ├── startup_stm32f10x_hd.s.0003 │ │ │ │ ├── startup_stm32f10x_hd.s.0004 │ │ │ │ ├── stm32f10x_conf.h │ │ │ │ ├── stm32f10x_conf.h.0000 │ │ │ │ ├── stm32f10x_conf.h.0001 │ │ │ │ ├── stm32f10x_conf.h.0002 │ │ │ │ ├── stm32f10x_conf.h.0003 │ │ │ │ ├── stm32f10x_conf.h.0004 │ │ │ │ ├── system_stm32f10x.c │ │ │ │ ├── system_stm32f10x.c.0000 │ │ │ │ ├── system_stm32f10x.c.0001 │ │ │ │ ├── system_stm32f10x.c.0002 │ │ │ │ ├── system_stm32f10x.c.0003 │ │ │ │ └── system_stm32f10x.c.0004 │ │ └── _Project │ │ │ └── RTE_Components.h │ └── main.cpp └── desktop.ini └── Lua 5.3_STM32F4xx ├── ArduinoAPI ├── Arduino.c ├── Arduino.h ├── HardwareSerial.cpp ├── HardwareSerial.h ├── Print.cpp ├── Print.h ├── Printable.h ├── SPI.cpp ├── SPI.h ├── Stream.cpp ├── Stream.h ├── Tone.cpp ├── Tone.h ├── WMath.cpp ├── WMath.h ├── WProgram.h ├── WString.cpp ├── WString.h ├── Wire.cpp ├── Wire.h ├── WireBase.cpp ├── WireBase.h ├── avr │ ├── dtostrf.c │ ├── dtostrf.h │ ├── interrupt.h │ └── pgmspace.h ├── binary.h ├── dtostrf.c ├── dtostrf.h ├── itoa.c ├── itoa.h ├── libmaple_types.h └── wirish_math.h ├── Core ├── adc.c ├── adc.h ├── delay.c ├── delay.h ├── exti.c ├── exti.h ├── gpio.c ├── gpio.h ├── pwm.c ├── pwm.h ├── time_exti.c ├── time_exti.h ├── usart.c └── usart.h ├── Example ├── ADCRead_DMA.cpp ├── Basic.cpp ├── EXTI.cpp ├── PWM_Output.cpp ├── Timer_EXTI.cpp └── USART.cpp ├── Libraries ├── DS1302 │ ├── DS1302.cpp │ └── DS1302.h ├── DS1307RTC │ ├── DS1307RTC.cpp │ ├── DS1307RTC.h │ ├── examples │ │ ├── ReadTest │ │ │ └── ReadTest.ino │ │ └── SetTime │ │ │ └── SetTime.ino │ ├── keywords.txt │ ├── library.properties │ └── readme.txt ├── DS3231 │ ├── DS3231.cpp │ └── DS3231.h ├── I2Cdev │ ├── I2Cdev.cpp │ ├── I2Cdev.h │ ├── keywords.txt │ └── library.json ├── Kalman │ ├── Kalman.cpp │ └── Kalman.h ├── LTDC_Graphic │ ├── Common │ │ ├── Release_Notes.html │ │ ├── fonts.c │ │ ├── fonts.h │ │ ├── lcd_log.c │ │ ├── lcd_log.h │ │ ├── lcd_log_conf_template.h │ │ └── stm32_eval_legacy.h │ ├── LTDC_Graphic.cpp │ ├── LTDC_Graphic.h │ └── STM32F429I-Discovery │ │ ├── Release_Notes.html │ │ ├── stm32f429i_discovery.c │ │ ├── stm32f429i_discovery.h │ │ ├── stm32f429i_discovery_i2c_ee.c │ │ ├── stm32f429i_discovery_i2c_ee.h │ │ ├── stm32f429i_discovery_ioe.c │ │ ├── stm32f429i_discovery_ioe.h │ │ ├── stm32f429i_discovery_l3gd20.c │ │ ├── stm32f429i_discovery_l3gd20.h │ │ ├── stm32f429i_discovery_lcd.c │ │ ├── stm32f429i_discovery_lcd.h │ │ ├── stm32f429i_discovery_sdram.c │ │ └── stm32f429i_discovery_sdram.h ├── LiquidCrystal │ ├── LiquidCrystal.cpp │ └── LiquidCrystal.h ├── LiquidCrystal_I2C │ ├── LiquidCrystal_I2C.cpp │ └── LiquidCrystal_I2C.h ├── MPU6050 │ ├── Examples │ │ ├── MPU6050_DMP6 │ │ │ ├── MPU6050_DMP6.ino │ │ │ └── Processing │ │ │ │ └── MPUTeapot.pde │ │ └── MPU6050_raw │ │ │ └── MPU6050_raw.ino │ ├── MPU6050.cpp │ ├── MPU6050.h │ ├── MPU6050_6Axis_MotionApps20.h │ ├── MPU6050_9Axis_MotionApps41.h │ └── helper_3dmath.h ├── MillisTaskManager │ ├── MillisTaskManager.cpp │ └── MillisTaskManager.h ├── NRF │ ├── NRF.cpp │ └── NRF.h ├── SD │ ├── File.cpp │ ├── SD.cpp │ ├── SD.h │ └── utility │ │ ├── FatStructs.h │ │ ├── Sd2Card.cpp │ │ ├── Sd2Card.h │ │ ├── Sd2PinMap.h │ │ ├── SdFat.h │ │ ├── SdFatUtil.h │ │ ├── SdFatmainpage.h │ │ ├── SdFile.cpp │ │ ├── SdInfo.h │ │ └── SdVolume.cpp ├── SSD1306_I2C │ ├── SSD1306_I2C.cpp │ ├── SSD1306_I2C.h │ └── fonts │ │ └── font8x8.h ├── STM32F429_Discovery │ ├── Common │ │ ├── Release_Notes.html │ │ ├── fonts.c │ │ ├── fonts.h │ │ ├── lcd_log.c │ │ ├── lcd_log.h │ │ ├── lcd_log_conf_template.h │ │ └── stm32_eval_legacy.h │ ├── STM32F429I-Discovery │ │ ├── Release_Notes.html │ │ ├── stm32f429i_discovery.c │ │ ├── stm32f429i_discovery.h │ │ ├── stm32f429i_discovery_i2c_ee.c │ │ ├── stm32f429i_discovery_i2c_ee.h │ │ ├── stm32f429i_discovery_ioe.c │ │ ├── stm32f429i_discovery_ioe.h │ │ ├── stm32f429i_discovery_l3gd20.c │ │ ├── stm32f429i_discovery_l3gd20.h │ │ ├── stm32f429i_discovery_lcd.c │ │ ├── stm32f429i_discovery_lcd.h │ │ ├── stm32f429i_discovery_sdram.c │ │ └── stm32f429i_discovery_sdram.h │ └── Third_Party │ │ ├── FreeRTOS │ │ ├── License │ │ │ └── license.txt │ │ ├── Source │ │ │ ├── croutine.c │ │ │ ├── include │ │ │ │ ├── FreeRTOS.h │ │ │ │ ├── StackMacros.h │ │ │ │ ├── croutine.h │ │ │ │ ├── list.h │ │ │ │ ├── mpu_wrappers.h │ │ │ │ ├── portable.h │ │ │ │ ├── projdefs.h │ │ │ │ ├── queue.h │ │ │ │ ├── semphr.h │ │ │ │ ├── task.h │ │ │ │ └── timers.h │ │ │ ├── list.c │ │ │ ├── portable │ │ │ │ ├── GCC │ │ │ │ │ ├── ARM_CM0 │ │ │ │ │ │ ├── port_cm0.c │ │ │ │ │ │ └── portmacro.h │ │ │ │ │ ├── ARM_CM3 │ │ │ │ │ │ ├── port_cm3.c │ │ │ │ │ │ └── portmacro.h │ │ │ │ │ ├── ARM_CM3_MPU │ │ │ │ │ │ ├── port_cm3_mpu.c │ │ │ │ │ │ └── portmacro.h │ │ │ │ │ └── ARM_CM4F │ │ │ │ │ │ ├── port_cm4.c │ │ │ │ │ │ └── portmacro.h │ │ │ │ ├── IAR │ │ │ │ │ ├── ARM_CM0 │ │ │ │ │ │ ├── port_cm0.c │ │ │ │ │ │ ├── portasm_cm0.s │ │ │ │ │ │ └── portmacro.h │ │ │ │ │ ├── ARM_CM3 │ │ │ │ │ │ ├── port_cm3.c │ │ │ │ │ │ ├── portasm_cm3.s │ │ │ │ │ │ └── portmacro.h │ │ │ │ │ └── ARM_CM4F │ │ │ │ │ │ ├── port_cm4.c │ │ │ │ │ │ ├── portasm_cm4.s │ │ │ │ │ │ └── portmacro.h │ │ │ │ ├── Keil │ │ │ │ │ └── See-also-the-RVDS-directory.txt │ │ │ │ ├── MemMang │ │ │ │ │ ├── heap_1.c │ │ │ │ │ ├── heap_2.c │ │ │ │ │ └── heap_3.c │ │ │ │ ├── RVDS │ │ │ │ │ ├── ARM_CM3 │ │ │ │ │ │ ├── port_cm3.c │ │ │ │ │ │ └── portmacro.h │ │ │ │ │ └── ARM_CM4F │ │ │ │ │ │ ├── port_cm4.c │ │ │ │ │ │ └── portmacro.h │ │ │ │ ├── Tasking │ │ │ │ │ └── ARM_CM4F │ │ │ │ │ │ ├── port.c │ │ │ │ │ │ ├── port_asm.asm │ │ │ │ │ │ └── portmacro.h │ │ │ │ └── readme.txt │ │ │ ├── queue.c │ │ │ ├── readme.txt │ │ │ ├── tasks.c │ │ │ └── timers.c │ │ └── readme.txt │ │ └── fat_fs │ │ ├── inc │ │ ├── diskio.h │ │ ├── ff.h │ │ └── integer.h │ │ ├── readme.txt │ │ └── src │ │ ├── diskio.c │ │ ├── ff.c │ │ └── option │ │ ├── cc932.c │ │ ├── cc936.c │ │ ├── cc949.c │ │ ├── cc950.c │ │ ├── ccsbcs.c │ │ └── syscall.c ├── Servo │ ├── Servo.cpp │ └── Servo.h ├── Time │ ├── DateStrings.cpp │ ├── Readme.txt │ ├── Time.cpp │ ├── Time.h │ ├── TimeLib.h │ ├── examples │ │ ├── Processing │ │ │ └── SyncArduinoClock │ │ │ │ ├── SyncArduinoClock.pde │ │ │ │ └── readme.txt │ │ ├── TimeArduinoDue │ │ │ └── TimeArduinoDue.ino │ │ ├── TimeGPS │ │ │ └── TimeGPS.ino │ │ ├── TimeNTP │ │ │ └── TimeNTP.ino │ │ ├── TimeNTP_ESP8266WiFi │ │ │ └── TimeNTP_ESP8266WiFi.ino │ │ ├── TimeRTC │ │ │ └── TimeRTC.ino │ │ ├── TimeRTCLog │ │ │ └── TimeRTCLog.ino │ │ ├── TimeRTCSet │ │ │ └── TimeRTCSet.ino │ │ ├── TimeSerial │ │ │ └── TimeSerial.ino │ │ ├── TimeSerialDateStrings │ │ │ └── TimeSerialDateStrings.ino │ │ └── TimeTeensy3 │ │ │ └── TimeTeensy3.ino │ ├── keywords.txt │ ├── library.json │ └── library.properties ├── extEEPROM │ ├── extEEPROM.cpp │ └── extEEPROM.h └── lua-5.3.2 │ ├── Makefile │ ├── README │ ├── doc │ ├── contents.html │ ├── index.css │ ├── logo.gif │ ├── lua.1 │ ├── lua.css │ ├── luac.1 │ ├── manual.css │ ├── manual.html │ ├── osi-certified-72x60.png │ └── readme.html │ └── src │ ├── Makefile │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lbitlib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── 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 │ ├── lprefix.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 │ ├── lua.hpp │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lutf8lib.c │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h ├── OBJ ├── ArInp.Scr └── Pro.lib ├── README.txt ├── USER ├── C_call_CPP.h ├── DebugConfig │ └── Arduino_For_Keil_STM32F103C8_1.0.0.dbgconf ├── EventRecorderStub.scvd ├── FileGroup.h ├── Lua_Call.cpp ├── Pro.uvguix.FASTSHIFT ├── Pro.uvoptx ├── Pro.uvprojx ├── RTE │ ├── Device │ │ ├── STM32F103C8 │ │ │ ├── RTE_Device.h │ │ │ ├── RTE_Device.h.0000 │ │ │ ├── RTE_Device.h.0001 │ │ │ ├── RTE_Device.h.0002 │ │ │ ├── RTE_Device.h.0003 │ │ │ ├── RTE_Device.h.0004 │ │ │ ├── RTE_Device.h.0005 │ │ │ ├── startup_stm32f10x_md.s │ │ │ ├── startup_stm32f10x_md.s.0000 │ │ │ ├── startup_stm32f10x_md.s.0001 │ │ │ ├── startup_stm32f10x_md.s.0002 │ │ │ ├── startup_stm32f10x_md.s.0003 │ │ │ ├── startup_stm32f10x_md.s.0004 │ │ │ ├── startup_stm32f10x_md.s.0005 │ │ │ ├── stm32f10x_conf.h │ │ │ ├── stm32f10x_conf.h.0000 │ │ │ ├── stm32f10x_conf.h.0001 │ │ │ ├── stm32f10x_conf.h.0002 │ │ │ ├── stm32f10x_conf.h.0003 │ │ │ ├── stm32f10x_conf.h.0004 │ │ │ ├── stm32f10x_conf.h.0005 │ │ │ ├── system_stm32f10x.c │ │ │ ├── system_stm32f10x.c.0000 │ │ │ ├── system_stm32f10x.c.0001 │ │ │ ├── system_stm32f10x.c.0002 │ │ │ ├── system_stm32f10x.c.0003 │ │ │ ├── system_stm32f10x.c.0004 │ │ │ └── system_stm32f10x.c.0005 │ │ ├── STM32F103CB │ │ │ ├── RTE_Device.h │ │ │ ├── startup_stm32f10x_md.s │ │ │ ├── stm32f10x_conf.h │ │ │ └── system_stm32f10x.c │ │ ├── STM32F103VE │ │ │ ├── RTE_Device.h │ │ │ ├── startup_stm32f10x_hd.s │ │ │ ├── stm32f10x_conf.h │ │ │ └── system_stm32f10x.c │ │ ├── STM32F103ZE │ │ │ ├── RTE_Device.h │ │ │ ├── RTE_Device.h.0000 │ │ │ ├── RTE_Device.h.0001 │ │ │ ├── RTE_Device.h.0002 │ │ │ ├── RTE_Device.h.0003 │ │ │ ├── startup_stm32f10x_hd.s │ │ │ ├── startup_stm32f10x_hd.s.0000 │ │ │ ├── startup_stm32f10x_hd.s.0001 │ │ │ ├── startup_stm32f10x_hd.s.0002 │ │ │ ├── startup_stm32f10x_hd.s.0003 │ │ │ ├── stm32f10x_conf.h │ │ │ ├── stm32f10x_conf.h.0000 │ │ │ ├── stm32f10x_conf.h.0001 │ │ │ ├── stm32f10x_conf.h.0002 │ │ │ ├── stm32f10x_conf.h.0003 │ │ │ ├── system_stm32f10x.c │ │ │ ├── system_stm32f10x.c.0000 │ │ │ ├── system_stm32f10x.c.0001 │ │ │ ├── system_stm32f10x.c.0002 │ │ │ └── system_stm32f10x.c.0003 │ │ ├── STM32F429II │ │ │ ├── RTE_Device.h │ │ │ ├── startup_stm32f429_439xx.s │ │ │ ├── stm32f4xx_conf.h │ │ │ └── system_stm32f4xx.c │ │ ├── STM32F429ZG │ │ │ ├── RTE_Device.h │ │ │ ├── startup_stm32f429_439xx.s │ │ │ ├── stm32f4xx_conf.h │ │ │ └── system_stm32f4xx.c │ │ └── STM32F429ZI │ │ │ ├── RTE_Device.h │ │ │ ├── startup_stm32f429_439xx.s │ │ │ ├── stm32f4xx_conf.h │ │ │ └── system_stm32f4xx.c │ └── _Project │ │ └── RTE_Components.h └── main.cpp └── desktop.ini /Lua 5.3_STM32F10x/ArduinoAPI/HardwareSerial.cpp: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.h" 2 | 3 | HardwareSerial::HardwareSerial(USART_TypeDef *_USARTx) 4 | { 5 | USARTx = _USARTx; 6 | if(_USARTx==USART1)USART_Num=0; 7 | else if(_USARTx==USART2)USART_Num=1; 8 | else if(_USARTx==USART3)USART_Num=2; 9 | } 10 | 11 | void HardwareSerial::begin(uint32_t baud) 12 | { 13 | usart_init(USARTx,baud,1,3); 14 | } 15 | 16 | void HardwareSerial::end(void) 17 | { 18 | USART_Cmd(USARTx, DISABLE); 19 | } 20 | 21 | void HardwareSerial::attachInterrupt(void (*f)()) 22 | { 23 | usart_attachInterrupt(USART_Num,f); 24 | } 25 | 26 | int HardwareSerial::available(void) 27 | { 28 | return ((unsigned int)(SERIAL_RX_BUFFER_SIZE + _rx_buffer_head[USART_Num] - _rx_buffer_tail[USART_Num])) % SERIAL_RX_BUFFER_SIZE; 29 | } 30 | 31 | int HardwareSerial::read(void) 32 | { 33 | // if the head isn't ahead of the tail, we don't have any characters 34 | if (_rx_buffer_head[USART_Num] == _rx_buffer_tail[USART_Num]) 35 | { 36 | return -1; 37 | } 38 | else 39 | { 40 | unsigned char c = _rx_buffer[USART_Num][_rx_buffer_tail[USART_Num]]; 41 | _rx_buffer_tail[USART_Num] = (rx_buffer_index_t)(_rx_buffer_tail[USART_Num] + 1) % SERIAL_RX_BUFFER_SIZE; 42 | return c; 43 | } 44 | } 45 | 46 | int HardwareSerial::peek(void) 47 | { 48 | if (_rx_buffer_head[USART_Num] == _rx_buffer_tail[USART_Num]) 49 | { 50 | return -1; 51 | } 52 | else 53 | { 54 | return _rx_buffer[USART_Num][_rx_buffer_tail[USART_Num]]; 55 | } 56 | } 57 | 58 | void HardwareSerial::flush(void) 59 | { 60 | while(read()>=0); 61 | } 62 | 63 | size_t HardwareSerial::write(uint8_t n) 64 | { 65 | usart_putc(USARTx,n); 66 | return n; 67 | } 68 | 69 | //Creat Object For User 70 | HardwareSerial Serial(USART1);//TX-PA9 RX-PA10 71 | HardwareSerial Serial2(USART2);//TX-PA2 RX-PA3 72 | HardwareSerial Serial3(USART3);//TX-PB10 RX-PB11 73 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/HardwareSerial.h: -------------------------------------------------------------------------------- 1 | #ifndef HardwareSerial_h 2 | #define HardwareSerial_h 3 | 4 | extern "C"{ 5 | #include "usart.h" 6 | } 7 | #include "Print.h" 8 | #include "Stream.h" 9 | 10 | class HardwareSerial : public Stream 11 | { 12 | public: 13 | HardwareSerial(USART_TypeDef *USARTx); 14 | void begin(uint32_t baud); 15 | void end(void); 16 | void attachInterrupt(void (*f)()); 17 | virtual int available(void); 18 | virtual int peek(void); 19 | virtual int read(void); 20 | virtual void flush(void); 21 | 22 | virtual size_t write(uint8_t n); 23 | inline size_t write(unsigned long n) { return write((uint8_t)n); } 24 | inline size_t write(long n) { return write((uint8_t)n); } 25 | inline size_t write(unsigned int n) { return write((uint8_t)n); } 26 | inline size_t write(int n) { return write((uint8_t)n); } 27 | using Print::write; // pull in write(str) and write(buf, size) from Print 28 | 29 | private: 30 | USART_TypeDef *USARTx; 31 | uint8_t USART_Num; 32 | }; 33 | 34 | extern HardwareSerial Serial; 35 | extern HardwareSerial Serial2; 36 | extern HardwareSerial Serial3; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual size_t printTo(Print& p) const = 0; 37 | }; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/SPI.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F10x/ArduinoAPI/SPI.cpp -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/WProgram.h: -------------------------------------------------------------------------------- 1 | #ifndef __WPROGRAM_H 2 | #define __WPROGRAM_H 3 | 4 | #include "Arduino.h" 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/avr/dtostrf.c: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | 23 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { 24 | char fmt[20]; 25 | sprintf(fmt, "%%%d.%df", width, prec); 26 | sprintf(sout, fmt, val); 27 | return sout; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/avr/dtostrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/avr/interrupt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F10x/ArduinoAPI/avr/interrupt.h -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/avr/pgmspace.h: -------------------------------------------------------------------------------- 1 | #ifndef __PGMSPACE_H_ 2 | #define __PGMSPACE_H_ 1 3 | 4 | #include 5 | 6 | #define PROGMEM 7 | #define PGM_P const char * 8 | #define PSTR(str) (str) 9 | 10 | #define _SFR_BYTE(n) (n) 11 | 12 | typedef void prog_void; 13 | typedef char prog_char; 14 | typedef unsigned char prog_uchar; 15 | typedef int8_t prog_int8_t; 16 | typedef uint8_t prog_uint8_t; 17 | typedef int16_t prog_int16_t; 18 | typedef uint16_t prog_uint16_t; 19 | typedef int32_t prog_int32_t; 20 | typedef uint32_t prog_uint32_t; 21 | 22 | #define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) 23 | #define strcpy_P(dest, src) strcpy((dest), (src)) 24 | #define strcat_P(dest, src) strcat((dest), (src)) 25 | #define strcmp_P(a, b) strcmp((a), (b)) 26 | #define strstr_P(a, b) strstr((a), (b)) 27 | #define strlen_P(a) strlen((a)) 28 | #define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) 29 | 30 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 31 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) 32 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 33 | #define pgm_read_float(addr) (*(const float *)(addr)) 34 | 35 | #define pgm_read_byte_near(addr) pgm_read_byte(addr) 36 | #define pgm_read_word_near(addr) pgm_read_word(addr) 37 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 38 | #define pgm_read_float_near(addr) pgm_read_float(addr) 39 | #define pgm_read_byte_far(addr) pgm_read_byte(addr) 40 | #define pgm_read_word_far(addr) pgm_read_word(addr) 41 | #define pgm_read_dword_far(addr) pgm_read_dword(addr) 42 | #define pgm_read_float_far(addr) pgm_read_float(addr) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/dtostrf.c: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "dtostrf.h" 22 | 23 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { 24 | char fmt[20]; 25 | sprintf(fmt, "%%%d.%df", width, prec); 26 | sprintf(sout, fmt, val); 27 | return sout; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/dtostrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef __DTOSTRF_H 22 | #define __DTOSTRF_H 23 | #include "stdio.h" 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/itoa.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _ITOA_ 20 | #define _ITOA_ 21 | 22 | #include 23 | #ifdef __cplusplus 24 | extern "C"{ 25 | #endif // __cplusplus 26 | 27 | #if 0 28 | 29 | extern void itoa( int n, char s[] ) ; 30 | 31 | #else 32 | 33 | extern char* itoa( int value, char *string, int radix ) ; 34 | extern char* ltoa( long value, char *string, int radix ) ; 35 | #if 0/*__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \ 36 | (__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))*/ 37 | extern char* utoa( unsigned value, char *string, int radix ) ; 38 | #else 39 | extern char* utoa( unsigned long value, char *string, int radix ) ; 40 | #endif 41 | extern char* ultoa( unsigned long value, char *string, int radix ) ; 42 | #endif /* 0 */ 43 | 44 | #ifdef __cplusplus 45 | } // extern "C" 46 | #endif // __cplusplus 47 | 48 | #endif // _ITOA_ 49 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/ArduinoAPI/libmaple_types.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file libmaple/include/libmaple/libmaple_types.h 29 | * 30 | * @brief libmaple's types, and operations on types. 31 | */ 32 | 33 | #ifndef _LIBMAPLE_LIBMAPLE_TYPES_H_ 34 | #define _LIBMAPLE_LIBMAPLE_TYPES_H_ 35 | 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | typedef unsigned char uint8; 43 | typedef unsigned short uint16; 44 | typedef uint32_t uint32; 45 | typedef unsigned long long uint64; 46 | 47 | typedef signed char int8; 48 | typedef short int16; 49 | typedef int int32; 50 | typedef long long int64; 51 | 52 | typedef void (*voidFuncPtr)(void); 53 | typedef void (*voidArgumentFuncPtr)(void *); 54 | 55 | #define __io volatile 56 | #define __attr_flash __attribute__((section (".USER_FLASH"))) 57 | #define __packed __attribute__((__packed__)) 58 | #define __deprecated __attribute__((__deprecated__)) 59 | #define __weak __attribute__((weak)) 60 | #ifndef __always_inline 61 | #define __always_inline __attribute__((always_inline)) 62 | #endif 63 | #ifndef __unused 64 | #define __unused __attribute__((unused)) 65 | #endif 66 | 67 | #ifndef NULL 68 | #define NULL 0 69 | #endif 70 | 71 | #ifndef offsetof 72 | #define offsetof(type, member) __builtin_offsetof(type, member) 73 | #endif 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Core/adc.h: -------------------------------------------------------------------------------- 1 | #ifndef __ADC_H 2 | #define __ADC_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f10x.h" 9 | #include "Arduino.h" 10 | 11 | #define ADC_AverageTimes 8 //ADC求平均次数 12 | 13 | // 注意:用作ADC采集的IO必须没有复用,否则采集电压会有影响 14 | 15 | // 转换通道个数 16 | #define ADC_CHANNEL_NUM 8 17 | extern uint16_t ADC_ConvertedValue[ADC_CHANNEL_NUM];//ADC DMA Buffer 18 | 19 | // ADC1 对应 DMA1通道1,ADC3对应DMA2通道5,ADC2没有DMA功能 20 | 21 | void ADCx_DMA_Init(void); 22 | void ADCx_Init(ADC_TypeDef* ADCx); 23 | 24 | uint16_t Get_DMA_ADC(uint8_t Channel); 25 | uint16_t Get_ADC(ADC_TypeDef* ADCx,uint16_t ADC_Channel); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* __ADC_H */ 32 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Core/delay.c: -------------------------------------------------------------------------------- 1 | #include "delay.h" 2 | 3 | static uint32_t System_ms=0; 4 | 5 | void Delay_Init(void) 6 | { 7 | SysTick->LOAD=72000; 8 | SysTick->VAL =0x00; 9 | SysTick->CTRL|=0x04; 10 | SysTick->CTRL|=0x02; 11 | SysTick->CTRL|=0x01; 12 | } 13 | 14 | 15 | void SysTick_Handler(void) 16 | { 17 | System_ms++; 18 | } 19 | 20 | uint32_t millis(void) 21 | { 22 | return System_ms; 23 | } 24 | 25 | uint32_t micros(void) 26 | { 27 | return System_ms*1000 + (72000 - SysTick->VAL) / 72; 28 | } 29 | 30 | void delay_ms(uint32_t ms) 31 | { 32 | uint32_t start = System_ms; 33 | while((System_ms-start) <= ms); 34 | } 35 | 36 | void delay_us(uint32_t us) 37 | { 38 | uint32_t start = micros(); 39 | while((micros() - start) <= us); 40 | } 41 | 42 | /*********************************************END OF FILE**********************/ 43 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Core/delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f10x.h" 9 | 10 | void Delay_Init(void); 11 | uint32_t millis(void); 12 | uint32_t micros(void); 13 | void delay_ms(uint32_t ms); 14 | void delay_us(uint32_t us); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif /* __DELAY_H */ 21 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Core/exti.h: -------------------------------------------------------------------------------- 1 | #ifndef __EXTI_H 2 | #define __EXTI_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f10x.h" 9 | #include "stm32f10x_exti.h" 10 | #include "Arduino.h" 11 | 12 | void attach_EXTI(uint8_t Pin, void_func_point f, EXTITrigger_TypeDef Trigger_Mode, uint8_t PreemptionPriority, uint8_t SubPriority); 13 | void attachInterrupt(uint8_t Pin, void_func_point f, EXTITrigger_TypeDef Trigger_Mode); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Core/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef __GPIO_H 2 | #define __GPIO_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f10x.h" 9 | #include "stm32f10x_gpio.h" 10 | 11 | #ifndef NULL 12 | #define NULL 0 13 | #endif 14 | 15 | #define xADC 0xFF 16 | 17 | typedef enum{ 18 | PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, PA11, PA12, PA13, PA14, PA15, 19 | PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PB8, PB9, PB10, PB11, PB12, PB13, PB14, PB15, 20 | PC0, PC1, PC2, PC3, PC4, PC5, PC6, PC7, PC8, PC9, PC10, PC11, PC12, PC13, PC14, PC15, 21 | PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7, PD8, PD9, PD10, PD11, PD12, PD13, PD14, PD15, 22 | PE0, PE1, PE2, PE3, PE4, PE5, PE6, PE7, PE8, PE9, PE10, PE11, PE12, PE13, PE14, PE15, 23 | PF0, PF1, PF2, PF3, PF4, PF5, PF6, PF7, PF8, PF9, PF10, PF11, PF12, PF13, PF14, PF15, 24 | PG0, PG1, PG2, PG3, PG4, PG5, PG6, PG7, PG8, PG9, PG10, PG11, PG12, PG13, PG14, PG15 25 | }Pxx_TypeDef; 26 | 27 | typedef struct STM32_PinInfo{ 28 | GPIO_TypeDef* GPIOx; 29 | TIM_TypeDef* TIMx; 30 | ADC_TypeDef* ADCx; 31 | 32 | uint16_t GPIO_Pin_x; 33 | uint8_t TimerChannel; 34 | uint8_t ADC_Channel; 35 | }PinInfo_TypeDef; 36 | 37 | extern const PinInfo_TypeDef PIN_MAP[]; 38 | 39 | #define IS_ADC_PIN(Pin) (PIN_MAP[Pin].ADC_Channel != xADC) 40 | 41 | #define IS_PWM_PIN(Pin) (PIN_MAP[Pin].TIMx != NULL) 42 | 43 | void GPIO_Config(void); 44 | void GPIO_begin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin_x,GPIOMode_TypeDef GPIO_Mode_x,GPIOSpeed_TypeDef GPIO_Speed_x); 45 | void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin_x); 46 | uint8_t Get_GPIOx(uint8_t Pin); 47 | uint8_t Get_Pinx(uint8_t Pin); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Core/pwm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F10x/Core/pwm.c -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Core/pwm.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H 2 | #define __PWM_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f10x.h" 9 | #include "Arduino.h" 10 | 11 | uint8_t PWM_Init(uint8_t Pin, uint16_t PWM_DutyCycle, uint16_t PWM_Frequency); 12 | uint16_t pwmWrite(uint8_t Pin,uint16_t val); 13 | void TIMx_Init(TIM_TypeDef* TIMx,uint16_t arr,uint16_t psc,uint8_t CHx); 14 | 15 | uint16_t timer_get_compare(TIM_TypeDef* TIMx,u8 TimerChannel); 16 | void timer_set_prescaler(TIM_TypeDef* TIMx,uint16_t psc); 17 | void timer_set_reload(TIM_TypeDef* TIMx,uint16_t arr); 18 | void timer_generate_update(TIM_TypeDef* TIMx); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Core/time_exti.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H 2 | #define __TIMER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f10x.h" 9 | #include "Arduino.h" 10 | 11 | void TimerSet (TIM_TypeDef* TIMx,uint32_t InterruptTime_us,void_func_point f); 12 | void TimerSet_NVIC(TIM_TypeDef* TIMx,uint32_t InterruptTime_us,void_func_point f,uint8_t NVIC_IRQ_CPP, uint8_t NVIC_IRQ_CSP); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Core/usart.h: -------------------------------------------------------------------------------- 1 | #ifndef __USART_H 2 | #define __USART_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f10x.h" 9 | #include "Arduino.h" 10 | 11 | #define SERIAL_RX_BUFFER_SIZE 128 12 | #define SERIAL_NUM 3 13 | 14 | typedef uint16_t rx_buffer_index_t; 15 | extern volatile uint16_t _rx_buffer_head[SERIAL_NUM]; 16 | extern volatile uint16_t _rx_buffer_tail[SERIAL_NUM]; 17 | extern uint8_t _rx_buffer[SERIAL_NUM][SERIAL_RX_BUFFER_SIZE]; 18 | 19 | void usart_init(USART_TypeDef* USARTx,uint32_t bound,uint8_t PreemptionPriority,uint8_t SubPriority); 20 | void usart_putc(USART_TypeDef* USARTx,uint8_t ch); 21 | void usart_attachInterrupt(uint8_t USART_Num,void_func_point f); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/Time.h: -------------------------------------------------------------------------------- 1 | #include "TimeLib.h" 2 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde: -------------------------------------------------------------------------------- 1 | /** 2 | * SyncArduinoClock. 3 | * 4 | * portIndex must be set to the port connected to the Arduino 5 | * 6 | * The current time is sent in response to request message from Arduino 7 | * or by clicking the display window 8 | * 9 | * The time message is 11 ASCII text characters; a header (the letter 'T') 10 | * followed by the ten digit system time (unix time) 11 | */ 12 | 13 | 14 | import processing.serial.*; 15 | import java.util.Date; 16 | import java.util.Calendar; 17 | import java.util.GregorianCalendar; 18 | 19 | public static final short portIndex = 0; // select the com port, 0 is the first port 20 | public static final String TIME_HEADER = "T"; //header for arduino serial time message 21 | public static final char TIME_REQUEST = 7; // ASCII bell character 22 | public static final char LF = 10; // ASCII linefeed 23 | public static final char CR = 13; // ASCII linefeed 24 | Serial myPort; // Create object from Serial class 25 | 26 | void setup() { 27 | size(200, 200); 28 | println(Serial.list()); 29 | println(" Connecting to -> " + Serial.list()[portIndex]); 30 | myPort = new Serial(this,Serial.list()[portIndex], 9600); 31 | println(getTimeNow()); 32 | } 33 | 34 | void draw() 35 | { 36 | textSize(20); 37 | textAlign(CENTER); 38 | fill(0); 39 | text("Click to send\nTime Sync", 0, 75, 200, 175); 40 | if ( myPort.available() > 0) { // If data is available, 41 | char val = char(myPort.read()); // read it and store it in val 42 | if(val == TIME_REQUEST){ 43 | long t = getTimeNow(); 44 | sendTimeMessage(TIME_HEADER, t); 45 | } 46 | else 47 | { 48 | if(val == LF) 49 | ; //igonore 50 | else if(val == CR) 51 | println(); 52 | else 53 | print(val); // echo everying but time request 54 | } 55 | } 56 | } 57 | 58 | void mousePressed() { 59 | sendTimeMessage( TIME_HEADER, getTimeNow()); 60 | } 61 | 62 | 63 | void sendTimeMessage(String header, long time) { 64 | String timeStr = String.valueOf(time); 65 | myPort.write(header); // send header and time to arduino 66 | myPort.write(timeStr); 67 | myPort.write('\n'); 68 | } 69 | 70 | long getTimeNow(){ 71 | // java time is in ms, we want secs 72 | Date d = new Date(); 73 | Calendar cal = new GregorianCalendar(); 74 | long current = d.getTime()/1000; 75 | long timezone = cal.get(cal.ZONE_OFFSET)/1000; 76 | long daylight = cal.get(cal.DST_OFFSET)/1000; 77 | return current + timezone + daylight; 78 | } 79 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/examples/Processing/SyncArduinoClock/readme.txt: -------------------------------------------------------------------------------- 1 | SyncArduinoClock is a Processing sketch that responds to Arduino requests for 2 | time synchronization messages. 3 | 4 | The portIndex must be set the Serial port connected to Arduino. 5 | 6 | Download TimeSerial.pde onto Arduino and you should see the time 7 | message displayed when you run SyncArduinoClock in Processing. 8 | The Arduino time is set from the time on your computer through the 9 | Processing sketch. 10 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/examples/TimeArduinoDue/TimeArduinoDue.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTC.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | * This example requires Markus Lange's Arduino Due RTC Library 6 | * https://github.com/MarkusLange/Arduino-Due-RTC-Library 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | // Select the Slowclock source 13 | //RTC_clock rtc_clock(RC); 14 | RTC_clock rtc_clock(XTAL); 15 | 16 | void setup() { 17 | Serial.begin(9600); 18 | rtc_clock.init(); 19 | if (rtc_clock.date_already_set() == 0) { 20 | // Unfortunately, the Arduino Due hardware does not seem to 21 | // be designed to maintain the RTC clock state when the 22 | // board resets. Markus described it thusly: "Uhh the Due 23 | // does reset with the NRSTB pin. This resets the full chip 24 | // with all backup regions including RTC, RTT and SC. Only 25 | // if the reset is done with the NRST pin will these regions 26 | // stay with their old values." 27 | rtc_clock.set_time(__TIME__); 28 | rtc_clock.set_date(__DATE__); 29 | // However, this might work on other unofficial SAM3X boards 30 | // with different reset circuitry than Arduino Due? 31 | } 32 | setSyncProvider(getArduinoDueTime); 33 | if(timeStatus()!= timeSet) 34 | Serial.println("Unable to sync with the RTC"); 35 | else 36 | Serial.println("RTC has set the system time"); 37 | } 38 | 39 | time_t getArduinoDueTime() 40 | { 41 | return rtc_clock.unixtime(); 42 | } 43 | 44 | void loop() 45 | { 46 | digitalClockDisplay(); 47 | delay(1000); 48 | } 49 | 50 | void digitalClockDisplay(){ 51 | // digital clock display of the time 52 | Serial.print(hour()); 53 | printDigits(minute()); 54 | printDigits(second()); 55 | Serial.print(" "); 56 | Serial.print(day()); 57 | Serial.print(" "); 58 | Serial.print(month()); 59 | Serial.print(" "); 60 | Serial.print(year()); 61 | Serial.println(); 62 | } 63 | 64 | void printDigits(int digits){ 65 | // utility function for digital clock display: prints preceding colon and leading 0 66 | Serial.print(":"); 67 | if(digits < 10) 68 | Serial.print('0'); 69 | Serial.print(digits); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/examples/TimeGPS/TimeGPS.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeGPS.pde 3 | * example code illustrating time synced from a GPS 4 | * 5 | */ 6 | 7 | #include 8 | #include // http://arduiniana.org/libraries/TinyGPS/ 9 | #include 10 | // TinyGPS and SoftwareSerial libraries are the work of Mikal Hart 11 | 12 | SoftwareSerial SerialGPS = SoftwareSerial(10, 11); // receive on pin 10 13 | TinyGPS gps; 14 | 15 | // To use a hardware serial port, which is far more efficient than 16 | // SoftwareSerial, uncomment this line and remove SoftwareSerial 17 | //#define SerialGPS Serial1 18 | 19 | // Offset hours from gps time (UTC) 20 | const int offset = 1; // Central European Time 21 | //const int offset = -5; // Eastern Standard Time (USA) 22 | //const int offset = -4; // Eastern Daylight Time (USA) 23 | //const int offset = -8; // Pacific Standard Time (USA) 24 | //const int offset = -7; // Pacific Daylight Time (USA) 25 | 26 | // Ideally, it should be possible to learn the time zone 27 | // based on the GPS position data. However, that would 28 | // require a complex library, probably incorporating some 29 | // sort of database using Eric Muller's time zone shape 30 | // maps, at http://efele.net/maps/tz/ 31 | 32 | time_t prevDisplay = 0; // when the digital clock was displayed 33 | 34 | void setup() 35 | { 36 | Serial.begin(9600); 37 | while (!Serial) ; // Needed for Leonardo only 38 | SerialGPS.begin(4800); 39 | Serial.println("Waiting for GPS time ... "); 40 | } 41 | 42 | void loop() 43 | { 44 | while (SerialGPS.available()) { 45 | if (gps.encode(SerialGPS.read())) { // process gps messages 46 | // when TinyGPS reports new data... 47 | unsigned long age; 48 | int Year; 49 | byte Month, Day, Hour, Minute, Second; 50 | gps.crack_datetime(&Year, &Month, &Day, &Hour, &Minute, &Second, NULL, &age); 51 | if (age < 500) { 52 | // set the Time to the latest GPS reading 53 | setTime(Hour, Minute, Second, Day, Month, Year); 54 | adjustTime(offset * SECS_PER_HOUR); 55 | } 56 | } 57 | } 58 | if (timeStatus()!= timeNotSet) { 59 | if (now() != prevDisplay) { //update the display only if the time has changed 60 | prevDisplay = now(); 61 | digitalClockDisplay(); 62 | } 63 | } 64 | } 65 | 66 | void digitalClockDisplay(){ 67 | // digital clock display of the time 68 | Serial.print(hour()); 69 | printDigits(minute()); 70 | printDigits(second()); 71 | Serial.print(" "); 72 | Serial.print(day()); 73 | Serial.print(" "); 74 | Serial.print(month()); 75 | Serial.print(" "); 76 | Serial.print(year()); 77 | Serial.println(); 78 | } 79 | 80 | void printDigits(int digits) { 81 | // utility function for digital clock display: prints preceding colon and leading 0 82 | Serial.print(":"); 83 | if(digits < 10) 84 | Serial.print('0'); 85 | Serial.print(digits); 86 | } 87 | 88 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/examples/TimeRTC/TimeRTC.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTC.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | */ 6 | 7 | #include 8 | #include 9 | #include // a basic DS1307 library that returns time as a time_t 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | while (!Serial) ; // wait until Arduino Serial Monitor opens 14 | setSyncProvider(RTC.get); // the function to get the time from the RTC 15 | if(timeStatus()!= timeSet) 16 | Serial.println("Unable to sync with the RTC"); 17 | else 18 | Serial.println("RTC has set the system time"); 19 | } 20 | 21 | void loop() 22 | { 23 | if (timeStatus() == timeSet) { 24 | digitalClockDisplay(); 25 | } else { 26 | Serial.println("The time has not been set. Please run the Time"); 27 | Serial.println("TimeRTCSet example, or DS1307RTC SetTime example."); 28 | Serial.println(); 29 | delay(4000); 30 | } 31 | delay(1000); 32 | } 33 | 34 | void digitalClockDisplay(){ 35 | // digital clock display of the time 36 | Serial.print(hour()); 37 | printDigits(minute()); 38 | printDigits(second()); 39 | Serial.print(" "); 40 | Serial.print(day()); 41 | Serial.print(" "); 42 | Serial.print(month()); 43 | Serial.print(" "); 44 | Serial.print(year()); 45 | Serial.println(); 46 | } 47 | 48 | void printDigits(int digits){ 49 | // utility function for digital clock display: prints preceding colon and leading 0 50 | Serial.print(":"); 51 | if(digits < 10) 52 | Serial.print('0'); 53 | Serial.print(digits); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/examples/TimeRTCSet/TimeRTCSet.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTCSet.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | * RTC clock is set in response to serial port time message 6 | * A Processing example sketch to set the time is included in the download 7 | * On Linux, you can use "date +T%s > /dev/ttyACM0" (UTC time zone) 8 | */ 9 | 10 | #include 11 | #include 12 | #include // a basic DS1307 library that returns time as a time_t 13 | 14 | 15 | void setup() { 16 | Serial.begin(9600); 17 | while (!Serial) ; // Needed for Leonardo only 18 | setSyncProvider(RTC.get); // the function to get the time from the RTC 19 | if (timeStatus() != timeSet) 20 | Serial.println("Unable to sync with the RTC"); 21 | else 22 | Serial.println("RTC has set the system time"); 23 | } 24 | 25 | void loop() 26 | { 27 | if (Serial.available()) { 28 | time_t t = processSyncMessage(); 29 | if (t != 0) { 30 | RTC.set(t); // set the RTC and the system time to the received value 31 | setTime(t); 32 | } 33 | } 34 | digitalClockDisplay(); 35 | delay(1000); 36 | } 37 | 38 | void digitalClockDisplay(){ 39 | // digital clock display of the time 40 | Serial.print(hour()); 41 | printDigits(minute()); 42 | printDigits(second()); 43 | Serial.print(" "); 44 | Serial.print(day()); 45 | Serial.print(" "); 46 | Serial.print(month()); 47 | Serial.print(" "); 48 | Serial.print(year()); 49 | Serial.println(); 50 | } 51 | 52 | void printDigits(int digits){ 53 | // utility function for digital clock display: prints preceding colon and leading 0 54 | Serial.print(":"); 55 | if(digits < 10) 56 | Serial.print('0'); 57 | Serial.print(digits); 58 | } 59 | 60 | /* code to process time sync messages from the serial port */ 61 | #define TIME_HEADER "T" // Header tag for serial time sync message 62 | 63 | unsigned long processSyncMessage() { 64 | unsigned long pctime = 0L; 65 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 66 | 67 | if(Serial.find(TIME_HEADER)) { 68 | pctime = Serial.parseInt(); 69 | return pctime; 70 | if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater than Jan 1 2013) 71 | pctime = 0L; // return 0 to indicate that the time is not valid 72 | } 73 | } 74 | return pctime; 75 | } 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/examples/TimeSerial/TimeSerial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeSerial.pde 3 | * example code illustrating Time library set through serial port messages. 4 | * 5 | * Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970) 6 | * you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2013 7 | T1357041600 8 | * 9 | * A Processing example sketch to automatically send the messages is included in the download 10 | * On Linux, you can use "date +T%s\n > /dev/ttyACM0" (UTC time zone) 11 | */ 12 | 13 | #include 14 | 15 | #define TIME_HEADER "T" // Header tag for serial time sync message 16 | #define TIME_REQUEST 7 // ASCII bell character requests a time sync message 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | while (!Serial) ; // Needed for Leonardo only 21 | pinMode(13, OUTPUT); 22 | setSyncProvider( requestSync); //set function to call when sync required 23 | Serial.println("Waiting for sync message"); 24 | } 25 | 26 | void loop(){ 27 | if (Serial.available()) { 28 | processSyncMessage(); 29 | } 30 | if (timeStatus()!= timeNotSet) { 31 | digitalClockDisplay(); 32 | } 33 | if (timeStatus() == timeSet) { 34 | digitalWrite(13, HIGH); // LED on if synced 35 | } else { 36 | digitalWrite(13, LOW); // LED off if needs refresh 37 | } 38 | delay(1000); 39 | } 40 | 41 | void digitalClockDisplay(){ 42 | // digital clock display of the time 43 | Serial.print(hour()); 44 | printDigits(minute()); 45 | printDigits(second()); 46 | Serial.print(" "); 47 | Serial.print(day()); 48 | Serial.print(" "); 49 | Serial.print(month()); 50 | Serial.print(" "); 51 | Serial.print(year()); 52 | Serial.println(); 53 | } 54 | 55 | void printDigits(int digits){ 56 | // utility function for digital clock display: prints preceding colon and leading 0 57 | Serial.print(":"); 58 | if(digits < 10) 59 | Serial.print('0'); 60 | Serial.print(digits); 61 | } 62 | 63 | 64 | void processSyncMessage() { 65 | unsigned long pctime; 66 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 67 | 68 | if(Serial.find(TIME_HEADER)) { 69 | pctime = Serial.parseInt(); 70 | if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013) 71 | setTime(pctime); // Sync Arduino clock to the time received on the serial port 72 | } 73 | } 74 | } 75 | 76 | time_t requestSync() 77 | { 78 | Serial.write(TIME_REQUEST); 79 | return 0; // the time will be sent later in response to serial mesg 80 | } 81 | 82 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/examples/TimeTeensy3/TimeTeensy3.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTC.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | */ 6 | 7 | #include 8 | 9 | void setup() { 10 | // set the Time library to use Teensy 3.0's RTC to keep time 11 | setSyncProvider(getTeensy3Time); 12 | 13 | Serial.begin(115200); 14 | while (!Serial); // Wait for Arduino Serial Monitor to open 15 | delay(100); 16 | if (timeStatus()!= timeSet) { 17 | Serial.println("Unable to sync with the RTC"); 18 | } else { 19 | Serial.println("RTC has set the system time"); 20 | } 21 | } 22 | 23 | void loop() { 24 | if (Serial.available()) { 25 | time_t t = processSyncMessage(); 26 | if (t != 0) { 27 | Teensy3Clock.set(t); // set the RTC 28 | setTime(t); 29 | } 30 | } 31 | digitalClockDisplay(); 32 | delay(1000); 33 | } 34 | 35 | void digitalClockDisplay() { 36 | // digital clock display of the time 37 | Serial.print(hour()); 38 | printDigits(minute()); 39 | printDigits(second()); 40 | Serial.print(" "); 41 | Serial.print(day()); 42 | Serial.print(" "); 43 | Serial.print(month()); 44 | Serial.print(" "); 45 | Serial.print(year()); 46 | Serial.println(); 47 | } 48 | 49 | time_t getTeensy3Time() 50 | { 51 | return Teensy3Clock.get(); 52 | } 53 | 54 | /* code to process time sync messages from the serial port */ 55 | #define TIME_HEADER "T" // Header tag for serial time sync message 56 | 57 | unsigned long processSyncMessage() { 58 | unsigned long pctime = 0L; 59 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 60 | 61 | if(Serial.find(TIME_HEADER)) { 62 | pctime = Serial.parseInt(); 63 | return pctime; 64 | if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater than Jan 1 2013) 65 | pctime = 0L; // return 0 to indicate that the time is not valid 66 | } 67 | } 68 | return pctime; 69 | } 70 | 71 | void printDigits(int digits){ 72 | // utility function for digital clock display: prints preceding colon and leading 0 73 | Serial.print(":"); 74 | if(digits < 10) 75 | Serial.print('0'); 76 | Serial.print(digits); 77 | } 78 | 79 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Time 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | time_t KEYWORD1 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | now KEYWORD2 13 | second KEYWORD2 14 | minute KEYWORD2 15 | hour KEYWORD2 16 | day KEYWORD2 17 | month KEYWORD2 18 | year KEYWORD2 19 | isAM KEYWORD2 20 | isPM KEYWORD2 21 | weekday KEYWORD2 22 | setTime KEYWORD2 23 | adjustTime KEYWORD2 24 | setSyncProvider KEYWORD2 25 | setSyncInterval KEYWORD2 26 | timeStatus KEYWORD2 27 | TimeLib KEYWORD2 28 | ####################################### 29 | # Instances (KEYWORD2) 30 | ####################################### 31 | 32 | ####################################### 33 | # Constants (LITERAL1) 34 | ####################################### 35 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Time", 3 | "frameworks": "Arduino", 4 | "keywords": "Time, date, hour, minute, second, day, week, month, year, RTC", 5 | "description": "Time keeping library", 6 | "url": "http://playground.arduino.cc/Code/Time", 7 | "authors": 8 | [ 9 | { 10 | "name": "Michael Margolis" 11 | }, 12 | { 13 | "name": "Paul Stoffregen" 14 | } 15 | ], 16 | "repository": 17 | { 18 | "type": "git", 19 | "url": "https://github.com/PaulStoffregen/Time" 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/Time/library.properties: -------------------------------------------------------------------------------- 1 | name=Time 2 | version=1.5 3 | author=Michael Margolis 4 | maintainer=Paul Stoffregen 5 | sentence=Timekeeping functionality for Arduino 6 | paragraph=Date and Time functions, with provisions to synchronize to external time sources like GPS and NTP (Internet). This library is often used together with TimeAlarms and DS1307RTC. 7 | category=Timing 8 | url=http://playground.arduino.cc/code/time 9 | architectures=* 10 | 11 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.3.2, released on 25 Nov 2015. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/doc/index.css: -------------------------------------------------------------------------------- 1 | ul { 2 | list-style-type: none ; 3 | } 4 | 5 | ul.contents { 6 | padding: 0 ; 7 | } 8 | 9 | table { 10 | border: none ; 11 | border-spacing: 0 ; 12 | border-collapse: collapse ; 13 | } 14 | 15 | td { 16 | vertical-align: top ; 17 | padding: 0 ; 18 | text-align: left ; 19 | line-height: 1.25 ; 20 | width: 15% ; 21 | } 22 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F10x/Libraries/lua-5.3.2/doc/logo.gif -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/doc/lua.1: -------------------------------------------------------------------------------- 1 | .TH LUA 1 "$Date: 2014/12/10 15:55:45 $" 2 | .SH NAME 3 | lua \- Lua interpreter 4 | .SH SYNOPSIS 5 | .B lua 6 | [ 7 | .I options 8 | ] 9 | [ 10 | .I script 11 | [ 12 | .I args 13 | ] 14 | ] 15 | .SH DESCRIPTION 16 | .B lua 17 | is the standalone Lua interpreter. 18 | It loads and executes Lua programs, 19 | either in textual source form or 20 | in precompiled binary form. 21 | (Precompiled binaries are output by 22 | .BR luac , 23 | the Lua compiler.) 24 | .B lua 25 | can be used as a batch interpreter and also interactively. 26 | .LP 27 | The given 28 | .I options 29 | are handled in order and then 30 | the Lua program in file 31 | .I script 32 | is loaded and executed. 33 | The given 34 | .I args 35 | are available to 36 | .I script 37 | as strings in a global table named 38 | .BR arg . 39 | If no options or arguments are given, 40 | then 41 | .B "\-v \-i" 42 | is assumed when the standard input is a terminal; 43 | otherwise, 44 | .B "\-" 45 | is assumed. 46 | .LP 47 | In interactive mode, 48 | .B lua 49 | prompts the user, 50 | reads lines from the standard input, 51 | and executes them as they are read. 52 | If the line contains an expression or list of expressions, 53 | then the line is evaluated and the results are printed. 54 | If a line does not contain a complete statement, 55 | then a secondary prompt is displayed and 56 | lines are read until a complete statement is formed or 57 | a syntax error is found. 58 | .LP 59 | At the very start, 60 | before even handling the command line, 61 | .B lua 62 | checks the contents of the environment variables 63 | .B LUA_INIT_5_3 64 | or 65 | .BR LUA_INIT , 66 | in that order. 67 | If the contents is of the form 68 | .RI '@ filename ', 69 | then 70 | .I filename 71 | is executed. 72 | Otherwise, the string is assumed to be a Lua statement and is executed. 73 | .SH OPTIONS 74 | .TP 75 | .BI \-e " stat" 76 | execute statement 77 | .IR stat . 78 | .TP 79 | .B \-i 80 | enter interactive mode after executing 81 | .IR script . 82 | .TP 83 | .BI \-l " name" 84 | execute the equivalent of 85 | .IB name =require(' name ') 86 | before executing 87 | .IR script . 88 | .TP 89 | .B \-v 90 | show version information. 91 | .TP 92 | .B \-E 93 | ignore environment variables. 94 | .TP 95 | .B \-\- 96 | stop handling options. 97 | .TP 98 | .B \- 99 | stop handling options and execute the standard input as a file. 100 | .SH "SEE ALSO" 101 | .BR luac (1) 102 | .br 103 | The documentation at lua.org, 104 | especially section 7 of the reference manual. 105 | .SH DIAGNOSTICS 106 | Error messages should be self explanatory. 107 | .SH AUTHORS 108 | R. Ierusalimschy, 109 | L. H. de Figueiredo, 110 | W. Celes 111 | .\" EOF 112 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | color: gray ; 12 | float: right ; 13 | font-family: inherit ; 14 | font-style: normal ; 15 | font-size: small ; 16 | } 17 | 18 | h2:before { 19 | content: "" ; 20 | padding-right: 0em ; 21 | } 22 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F10x/Libraries/lua-5.3.2/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9 2015/03/06 19:49:50 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 "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 20 | 0x00, /* EOZ */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | }; 54 | 55 | #endif /* } */ 56 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 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 getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 36 | LUAI_FUNC void luaG_traceexec (lua_State *L); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.28 2015/11/23 11:29:43 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 21 | ** at every check. 22 | */ 23 | #define luaD_checkstackaux(L,n,pre,pos) \ 24 | if (L->stack_last - L->top <= (n)) \ 25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } 26 | 27 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,,) 29 | 30 | 31 | 32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 34 | 35 | 36 | /* type of protected functions, to be ran by 'runprotected' */ 37 | typedef void (*Pfunc) (lua_State *L, void *ud); 38 | 39 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 40 | const char *mode); 41 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 45 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 46 | ptrdiff_t oldtop, ptrdiff_t ef); 47 | LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, 48 | int nres); 49 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 50 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 51 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 52 | LUAI_FUNC void luaD_inctop (lua_State *L); 53 | 54 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 55 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 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 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | /* 33 | ** Upvalues for Lua closures 34 | */ 35 | struct UpVal { 36 | TValue *v; /* points to stack or to its own value */ 37 | lu_mem refcount; /* reference counter */ 38 | union { 39 | struct { /* (when open) */ 40 | UpVal *next; /* linked list */ 41 | int touched; /* mark to avoid cycles with dead threads */ 42 | } open; 43 | TValue value; /* the value (when closed) */ 44 | } u; 45 | }; 46 | 47 | #define upisopen(up) ((up)->v != &(up)->u.value) 48 | 49 | 50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 55 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 56 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 57 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 58 | int pc); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove _PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {"_G", luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | #if defined(LUA_COMPAT_BITLIB) 54 | {LUA_BITLIBNAME, luaopen_bit32}, 55 | #endif 56 | {NULL, NULL} 57 | }; 58 | 59 | 60 | LUALIB_API void luaL_openlibs (lua_State *L) { 61 | const luaL_Reg *lib; 62 | /* "require" functions from 'loadedlibs' and set results to global table */ 63 | for (lib = loadedlibs; lib->func; lib++) { 64 | luaL_requiref(L, lib->name, lib->func, 1); 65 | lua_pop(L, 1); /* remove lib */ 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.78 2014/10/29 15:38:24 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | #if !defined(LUA_ENV) 18 | #define LUA_ENV "_ENV" 19 | #endif 20 | 21 | 22 | /* 23 | * WARNING: if you change the order of this enumeration, 24 | * grep "ORDER RESERVED" 25 | */ 26 | enum RESERVED { 27 | /* terminal symbols denoted by reserved words */ 28 | TK_AND = FIRST_RESERVED, TK_BREAK, 29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 32 | /* other terminal symbols */ 33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 34 | TK_SHL, TK_SHR, 35 | TK_DBCOLON, TK_EOS, 36 | TK_FLT, TK_INT, TK_NAME, TK_STRING 37 | }; 38 | 39 | /* number of reserved words */ 40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | lua_Integer i; 46 | TString *ts; 47 | } SemInfo; /* semantics information */ 48 | 49 | 50 | typedef struct Token { 51 | int token; 52 | SemInfo seminfo; 53 | } Token; 54 | 55 | 56 | /* state of the lexer plus state of the parser when shared by all 57 | functions */ 58 | typedef struct LexState { 59 | int current; /* current character (charint) */ 60 | int linenumber; /* input line counter */ 61 | int lastline; /* line of last token 'consumed' */ 62 | Token t; /* current token */ 63 | Token lookahead; /* look ahead token */ 64 | struct FuncState *fs; /* current function (parser) */ 65 | struct lua_State *L; 66 | ZIO *z; /* input stream */ 67 | Mbuffer *buff; /* buffer for tokens */ 68 | Table *h; /* to avoid collection/reuse strings */ 69 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 70 | TString *source; /* current source name */ 71 | TString *envn; /* environment variable name */ 72 | char decpoint; /* locale decimal point */ 73 | } LexState; 74 | 75 | 76 | LUAI_FUNC void luaX_init (lua_State *L); 77 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 78 | TString *source, int firstchar); 79 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 80 | LUAI_FUNC void luaX_next (LexState *ls); 81 | LUAI_FUNC int luaX_lookahead (LexState *ls); 82 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 83 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 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 | 17 | /* 18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where 19 | ** each element has size 'e'. In case of arithmetic overflow of the 20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because 21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). 22 | ** 23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 24 | ** comparison avoids a runtime comparison when overflow cannot occur. 25 | ** The compiler should be able to optimize the real test by itself, but 26 | ** when it does it, it may give a warning about "comparison is always 27 | ** false due to limited range of data type"; the +1 tricks the compiler, 28 | ** avoiding this warning but also this optimization.) 29 | */ 30 | #define luaM_reallocv(L,b,on,n,e) \ 31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ 32 | ? luaM_toobig(L) : cast_void(0)) , \ 33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 34 | 35 | /* 36 | ** Arrays of chars do not need any test 37 | */ 38 | #define luaM_reallocvchar(L,b,on,n) \ 39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 40 | 41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 44 | 45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 47 | #define luaM_newvector(L,n,t) \ 48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 49 | 50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 51 | 52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 53 | if ((nelems)+1 > (size)) \ 54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 55 | 56 | #define luaM_reallocvector(L, v,oldn,n,t) \ 57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 58 | 59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 60 | 61 | /* not to be called directly */ 62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 63 | size_t size); 64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 65 | size_t size_elem, int limit, 66 | const char *what); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 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 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | 17 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 18 | #define sizeudata(u) sizeludata((u)->len) 19 | 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | 24 | /* 25 | ** test whether a string is a reserved word 26 | */ 27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 28 | 29 | 30 | /* 31 | ** equality for short strings, which are always internalized 32 | */ 33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 34 | 35 | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_clearcache (global_State *g); 41 | LUAI_FUNC void luaS_init (lua_State *L); 42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.21 2015/11/03 15:47:30 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 gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->i_key.nk.next) 16 | 17 | 18 | /* 'const' to avoid wrong writings that can mess up field 'next' */ 19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) 20 | 21 | /* 22 | ** writable version of 'gkey'; allows updates to individual fields, 23 | ** but not to the whole (which has incompatible type) 24 | */ 25 | #define wgkey(n) (&(n)->i_key.nk) 26 | 27 | #define invalidateTMcache(t) ((t)->flags = 0) 28 | 29 | 30 | /* returns the key, given the value of a table entry */ 31 | #define keyfromval(v) \ 32 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 33 | 34 | 35 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 36 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 37 | TValue *value); 38 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 39 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 40 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 41 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 42 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 43 | LUAI_FUNC Table *luaH_new (lua_State *L); 44 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 45 | unsigned int nhsize); 46 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 47 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 48 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 49 | LUAI_FUNC int luaH_getn (Table *t); 50 | 51 | 52 | #if defined(LUA_DEBUG) 53 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 54 | LUAI_FUNC int luaH_isdummy (Node *n); 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.21 2014/10/25 11:50:46 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" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_N /* number of elements in the enum */ 44 | } TMS; 45 | 46 | 47 | 48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 50 | 51 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 52 | 53 | #define ttypename(x) luaT_typenames_[(x) + 1] 54 | #define objtypename(x) ttypename(ttnov(x)) 55 | 56 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 57 | 58 | 59 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 60 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 61 | TMS event); 62 | LUAI_FUNC void luaT_init (lua_State *L); 63 | 64 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 65 | const TValue *p2, TValue *p3, int hasres); 66 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 67 | StkId res, TMS event); 68 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 69 | StkId res, TMS event); 70 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 71 | const TValue *p2, TMS event); 72 | 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 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 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_UTF8LIBNAME "utf8" 33 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 34 | 35 | #define LUA_BITLIBNAME "bit32" 36 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | 53 | #if !defined(lua_assert) 54 | #define lua_assert(x) ((void)0) 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/Libraries/lua-5.3.2/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/USER/C_call_CPP.h: -------------------------------------------------------------------------------- 1 | #ifndef __C_CALL_CPP 2 | #define __C_CALL_CPP 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | //Place "C" functions declaration 9 | 10 | void Serial_print(const char *s); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/USER/EventRecorderStub.scvd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/USER/FileGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef __FILEGROUP_H 2 | #define __FILEGROUP_H 3 | 4 | //*************C/C++ Library**************// 5 | 6 | #include "stm32f10x.h" 7 | #include "Arduino.h" 8 | #include "delay.h" 9 | #include "exti.h" 10 | #include "gpio.h" 11 | #include "adc.h" 12 | #include "pwm.h" 13 | #include "usart.h" 14 | #include "time_exti.h" 15 | #include "math.h" 16 | 17 | #include "HardwareSerial.h" 18 | #include "SPI.h" 19 | #include "Wire.h" 20 | #include "WString.h" 21 | #include "Stream.h" 22 | 23 | #include "C_call_CPP.h" 24 | #include "lua.hpp" 25 | 26 | int Lua_millis(lua_State *L); 27 | int Lua_delay(lua_State *L); 28 | int Lua_pinMode(lua_State *L); 29 | int Lua_digitalWrite(lua_State *L); 30 | int Lua_digitalRead(lua_State *L); 31 | int Lua_analogWrite(lua_State *L); 32 | int Lua_analogRead(lua_State *L); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/USER/RTE/_Project/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Component Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'Pro' 7 | * Target: 'Project' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "stm32f10x.h" 18 | 19 | #define RTE_DEVICE_STDPERIPH_ADC 20 | #define RTE_DEVICE_STDPERIPH_DMA 21 | #define RTE_DEVICE_STDPERIPH_EXTI 22 | #define RTE_DEVICE_STDPERIPH_FRAMEWORK 23 | #define RTE_DEVICE_STDPERIPH_GPIO 24 | #define RTE_DEVICE_STDPERIPH_RCC 25 | #define RTE_DEVICE_STDPERIPH_SPI 26 | #define RTE_DEVICE_STDPERIPH_TIM 27 | #define RTE_DEVICE_STDPERIPH_USART 28 | 29 | #endif /* RTE_COMPONENTS_H */ 30 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/USER/main.cpp: -------------------------------------------------------------------------------- 1 | #include "FileGroup.h" 2 | 3 | uint8_t LuaRunning=0; 4 | 5 | __asm void GenerateSystemReset(void) 6 | { 7 | MOV R0, #1 8 | MSR FAULTMASK, R0 9 | LDR R0, =0xE000ED0C 10 | LDR R1, =0x05FA0004 11 | STR R1, [R0] 12 | 13 | deadloop 14 | B deadloop 15 | } 16 | 17 | void Lua_Stop() 18 | { 19 | if(LuaRunning) 20 | { 21 | if(Serial.read()=='S') 22 | { 23 | GenerateSystemReset(); 24 | } 25 | else Serial.flush(); 26 | } 27 | } 28 | 29 | int main(void) 30 | { 31 | Delay_Init(); 32 | ADCx_Init(ADC1); 33 | 34 | Serial.begin(115200); 35 | Serial.println("\r\nInitializing..."); 36 | Serial.setTimeout(10); 37 | Serial.attachInterrupt(Lua_Stop); 38 | 39 | int error=0; 40 | lua_State *L = luaL_newstate(); 41 | luaL_openlibs(L); 42 | 43 | lua_register(L, "millis", Lua_millis); 44 | lua_register(L, "delay", Lua_delay); 45 | lua_register(L, "pinMode", Lua_pinMode); 46 | lua_register(L, "digitalWrite", Lua_digitalWrite); 47 | lua_register(L, "digitalRead", Lua_digitalRead); 48 | lua_register(L, "analogWrite", Lua_analogWrite); 49 | lua_register(L, "analogRead", Lua_analogRead); 50 | 51 | luaL_dostring(L,"print(\"> Version:\",_VERSION)"); 52 | while (1) 53 | { 54 | if(Serial.available()) 55 | { 56 | String rx=Serial.readString(); 57 | char *rx_buffer = new char[rx.length()+10]; 58 | 59 | Serial.println("\r\nCode:\r\n"); 60 | Serial.println(rx); 61 | Serial.printf("\r\n(Size: %d )\r\n",rx.length()); 62 | rx.toCharArray(rx_buffer,rx.length()+10); 63 | 64 | Serial.print("\r\n> "); 65 | LuaRunning = 1; 66 | error = luaL_loadbuffer(L, rx_buffer, strlen(rx_buffer), "line") || lua_pcall(L, 0, 0, 0); 67 | delete []rx_buffer; 68 | LuaRunning = 0; 69 | } 70 | if (error) 71 | { 72 | Serial.println(lua_tostring(L, -1)); 73 | error = 0; 74 | LuaRunning = 0; 75 | //lua_pop(L, 1); 76 | } 77 | } 78 | //lua_close(L); 79 | } 80 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F10x/desktop.ini: -------------------------------------------------------------------------------- 1 | [ViewState] 2 | Mode= 3 | Vid= 4 | FolderType=Generic 5 | [.ShellClassInfo] 6 | IconResource=C:\WINDOWS\System32\SHELL32.dll,306 7 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/HardwareSerial.cpp: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.h" 2 | 3 | HardwareSerial::HardwareSerial(USART_TypeDef *_USARTx) 4 | { 5 | USARTx = _USARTx; 6 | if(_USARTx==USART1)USART_Num=0; 7 | else if(_USARTx==USART2)USART_Num=1; 8 | else if(_USARTx==USART3)USART_Num=2; 9 | } 10 | 11 | void HardwareSerial::begin(uint32_t baud) 12 | { 13 | usart_init(USARTx,baud,1,3); 14 | } 15 | 16 | void HardwareSerial::end(void) 17 | { 18 | USART_Cmd(USARTx, DISABLE); 19 | } 20 | 21 | void HardwareSerial::attachInterrupt(void (*f)()) 22 | { 23 | usart_attachInterrupt(USART_Num,f); 24 | } 25 | 26 | int HardwareSerial::available(void) 27 | { 28 | return ((unsigned int)(SERIAL_RX_BUFFER_SIZE + _rx_buffer_head[USART_Num] - _rx_buffer_tail[USART_Num])) % SERIAL_RX_BUFFER_SIZE; 29 | } 30 | 31 | int HardwareSerial::read(void) 32 | { 33 | // if the head isn't ahead of the tail, we don't have any characters 34 | if (_rx_buffer_head[USART_Num] == _rx_buffer_tail[USART_Num]) 35 | { 36 | return -1; 37 | } 38 | else 39 | { 40 | unsigned char c = _rx_buffer[USART_Num][_rx_buffer_tail[USART_Num]]; 41 | _rx_buffer_tail[USART_Num] = (rx_buffer_index_t)(_rx_buffer_tail[USART_Num] + 1) % SERIAL_RX_BUFFER_SIZE; 42 | return c; 43 | } 44 | } 45 | 46 | int HardwareSerial::peek(void) 47 | { 48 | if (_rx_buffer_head[USART_Num] == _rx_buffer_tail[USART_Num]) 49 | { 50 | return -1; 51 | } 52 | else 53 | { 54 | return _rx_buffer[USART_Num][_rx_buffer_tail[USART_Num]]; 55 | } 56 | } 57 | 58 | void HardwareSerial::flush(void) 59 | { 60 | while(read()>=0); 61 | } 62 | 63 | size_t HardwareSerial::write(uint8_t n) 64 | { 65 | usart_putc(USARTx,n); 66 | return n; 67 | } 68 | 69 | //Creat Object For User 70 | HardwareSerial Serial(USART1);//TX-PA9 RX-PA10 71 | HardwareSerial Serial2(USART2);//TX-PA2 RX-PA3 72 | HardwareSerial Serial3(USART3);//TX-PB10 RX-PB11 73 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/HardwareSerial.h: -------------------------------------------------------------------------------- 1 | #ifndef HardwareSerial_h 2 | #define HardwareSerial_h 3 | 4 | #include "usart.h" 5 | #include "Print.h" 6 | #include "Stream.h" 7 | 8 | class HardwareSerial : public Stream 9 | { 10 | public: 11 | HardwareSerial(USART_TypeDef *USARTx); 12 | void begin(uint32_t baud); 13 | void end(void); 14 | void attachInterrupt(void (*f)()); 15 | virtual int available(void); 16 | virtual int peek(void); 17 | virtual int read(void); 18 | virtual void flush(void); 19 | 20 | virtual size_t write(uint8_t n); 21 | inline size_t write(unsigned long n) { return write((uint8_t)n); } 22 | inline size_t write(long n) { return write((uint8_t)n); } 23 | inline size_t write(unsigned int n) { return write((uint8_t)n); } 24 | inline size_t write(int n) { return write((uint8_t)n); } 25 | using Print::write; // pull in write(str) and write(buf, size) from Print 26 | 27 | private: 28 | USART_TypeDef *USARTx; 29 | uint8_t USART_Num; 30 | }; 31 | 32 | extern HardwareSerial Serial; 33 | extern HardwareSerial Serial2; 34 | extern HardwareSerial Serial3; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual size_t printTo(Print& p) const = 0; 37 | }; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/SPI.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/ArduinoAPI/SPI.cpp -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/Tone.cpp: -------------------------------------------------------------------------------- 1 | #include "Tone.h" 2 | 3 | uint8_t tone_State = On; 4 | uint8_t tone_Pin; 5 | uint32_t tone_StopTimePoint; 6 | 7 | void tone_Cmd(uint8_t State) 8 | { 9 | tone_State = State; 10 | } 11 | 12 | void tone_RingHandler() 13 | { 14 | togglePin(tone_Pin); 15 | } 16 | 17 | void tone_DelayHandler() 18 | { 19 | if(millis() > tone_StopTimePoint) 20 | { 21 | noTone(tone_Pin); 22 | } 23 | } 24 | 25 | void tone(uint8_t Pin, uint32_t freq,uint32_t Time_ms) 26 | { 27 | if(freq == 0 || Time_ms == 0) return; 28 | tone(Pin, freq); 29 | 30 | tone_StopTimePoint = millis() + Time_ms; 31 | TimerSet(ToneDelayTimer_Default, 1000, tone_DelayHandler); 32 | TIM_Cmd(ToneDelayTimer_Default,ENABLE); 33 | } 34 | 35 | void tone(uint8_t Pin, uint32_t freq) 36 | { 37 | if(freq == 0) return; 38 | tone_Pin = Pin; 39 | 40 | if(IS_PWM_PIN(tone_Pin)) 41 | { 42 | PWM_Init(tone_Pin, 101, freq); 43 | pwmWrite(tone_Pin, ToneVolumn_Default); 44 | } 45 | else 46 | { 47 | pinMode(tone_Pin, OUTPUT); 48 | uint32_t SetTime_us = 500000 / freq; 49 | TimerSet(ToneRingTimer_Default, SetTime_us, tone_RingHandler); 50 | TIM_Cmd(ToneRingTimer_Default, ENABLE); 51 | } 52 | } 53 | 54 | void noTone(uint8_t Pin) 55 | { 56 | if(IS_PWM_PIN(Pin)) 57 | { 58 | pwmWrite(Pin, 0); 59 | TIM_Cmd(PIN_MAP[Pin].TIMx, DISABLE); 60 | } 61 | else 62 | { 63 | TIM_Cmd(ToneRingTimer_Default,DISABLE); 64 | digitalWrite_LOW(Pin); 65 | } 66 | 67 | TIM_Cmd(ToneDelayTimer_Default,DISABLE); 68 | } 69 | 70 | void Block_tone(uint8_t Pin, uint32_t freq, uint32_t Time_ms) 71 | { 72 | uint32_t TimePoint = millis() + Time_ms; 73 | uint32_t dlyus = 500000 / freq; 74 | if(tone_State == Off)return; 75 | if(freq == 0)return; 76 | do 77 | { 78 | digitalWrite_HIGH(Pin); 79 | delayMicroseconds(dlyus); 80 | digitalWrite_LOW(Pin); 81 | delayMicroseconds(dlyus); 82 | }while(millis() < TimePoint); 83 | digitalWrite_LOW(Pin); 84 | } 85 | 86 | void Block_toneVolumn(uint8_t Pin,uint32_t freq,uint32_t Time_ms,uint32_t vol) 87 | { 88 | uint32_t TimePoint = millis() + Time_ms; 89 | uint32_t dlyus = 500000 / freq; 90 | uint32_t dlHigh = dlyus * vol / 100; 91 | uint32_t dlLow = 2 * dlyus - dlHigh; 92 | if(freq == 0)return; 93 | do 94 | { 95 | digitalWrite_HIGH(Pin); 96 | delayMicroseconds(dlHigh); 97 | digitalWrite_LOW(Pin); 98 | delayMicroseconds(dlLow); 99 | }while(millis() < TimePoint); 100 | digitalWrite_LOW(Pin); 101 | } 102 | 103 | void Block_toneVolumn_us(uint8_t Pin,uint32_t freq,uint32_t Time_us,uint32_t vol) 104 | { 105 | uint32_t TimePoint = micros() + Time_us; 106 | uint32_t dlyus = 500000 / freq; 107 | uint32_t dlHigh = dlyus * vol / 100; 108 | uint32_t dlLow = 2 * dlyus - dlHigh; 109 | if(freq == 0)return; 110 | do 111 | { 112 | digitalWrite_HIGH(Pin); 113 | delayMicroseconds(dlHigh); 114 | digitalWrite_LOW(Pin); 115 | delayMicroseconds(dlLow); 116 | }while(micros() < TimePoint); 117 | digitalWrite_LOW(Pin); 118 | } 119 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/Tone.h: -------------------------------------------------------------------------------- 1 | #ifndef __TONE_H 2 | #define __TONE_H 3 | 4 | #include "Arduino.h" 5 | #include "time_exti.h" 6 | 7 | #define ToneVolumn_Default 80 8 | #define ToneRingTimer_Default TIM1 9 | #define ToneDelayTimer_Default TIM2 10 | 11 | void tone_Cmd(uint8_t State); 12 | void tone(uint8_t Pin, uint32_t freq,uint32_t Time_ms); 13 | void tone(uint8_t Pin, uint32_t freq); 14 | void noTone(uint8_t Pin); 15 | 16 | void Block_tone(uint8_t Pin,uint32_t freq,uint32_t Time_ms); 17 | void Block_toneVolumn(uint8_t Pin,uint32_t freq,uint32_t Time_ms,uint32_t vol); 18 | void Block_toneVolumn_us(uint8_t Pin,uint32_t freq,uint32_t Time_us,uint32_t vol); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/WMath.cpp: -------------------------------------------------------------------------------- 1 | /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2 | 3 | /* 4 | Part of the Wiring project - http://wiring.org.co 5 | Copyright (c) 2004-06 Hernando Barragan 6 | Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/ 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General 19 | Public License along with this library; if not, write to the 20 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 21 | Boston, MA 02111-1307 USA 22 | */ 23 | #include "WMath.h" 24 | 25 | void randomSeed(unsigned long seed) 26 | { 27 | if (seed != 0) { 28 | srand(seed); 29 | } 30 | } 31 | 32 | long random(long howbig) 33 | { 34 | if (howbig == 0) { 35 | return 0; 36 | } 37 | return rand() % howbig; 38 | } 39 | 40 | long random(long howsmall, long howbig) 41 | { 42 | if (howsmall >= howbig) { 43 | return howsmall; 44 | } 45 | long diff = howbig - howsmall; 46 | return random(diff) + howsmall; 47 | } 48 | 49 | unsigned int makeWord(unsigned int w) { return w; } 50 | unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; } 51 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/WMath.h: -------------------------------------------------------------------------------- 1 | #ifndef __WMATH_H 2 | #define __WMATH_H 3 | 4 | extern "C" { 5 | #include "stdlib.h" 6 | } 7 | 8 | void randomSeed(unsigned long seed); 9 | long random(long howbig); 10 | long random(long howsmall, long howbig); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/WProgram.h: -------------------------------------------------------------------------------- 1 | #ifndef __WPROGRAM_H 2 | #define __WPROGRAM_H 3 | 4 | #include "Arduino.h" 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/avr/dtostrf.c: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | 23 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { 24 | char fmt[20]; 25 | sprintf(fmt, "%%%d.%df", width, prec); 26 | sprintf(sout, fmt, val); 27 | return sout; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/avr/dtostrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/avr/interrupt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/ArduinoAPI/avr/interrupt.h -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/avr/pgmspace.h: -------------------------------------------------------------------------------- 1 | #ifndef __PGMSPACE_H_ 2 | #define __PGMSPACE_H_ 1 3 | 4 | #include 5 | 6 | #define PROGMEM 7 | #define PGM_P const char * 8 | #define PSTR(str) (str) 9 | 10 | #define _SFR_BYTE(n) (n) 11 | 12 | typedef void prog_void; 13 | typedef char prog_char; 14 | typedef unsigned char prog_uchar; 15 | typedef int8_t prog_int8_t; 16 | typedef uint8_t prog_uint8_t; 17 | typedef int16_t prog_int16_t; 18 | typedef uint16_t prog_uint16_t; 19 | typedef int32_t prog_int32_t; 20 | typedef uint32_t prog_uint32_t; 21 | 22 | #define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) 23 | #define strcpy_P(dest, src) strcpy((dest), (src)) 24 | #define strcat_P(dest, src) strcat((dest), (src)) 25 | #define strcmp_P(a, b) strcmp((a), (b)) 26 | #define strstr_P(a, b) strstr((a), (b)) 27 | #define strlen_P(a) strlen((a)) 28 | #define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) 29 | 30 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 31 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) 32 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 33 | #define pgm_read_float(addr) (*(const float *)(addr)) 34 | 35 | #define pgm_read_byte_near(addr) pgm_read_byte(addr) 36 | #define pgm_read_word_near(addr) pgm_read_word(addr) 37 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 38 | #define pgm_read_float_near(addr) pgm_read_float(addr) 39 | #define pgm_read_byte_far(addr) pgm_read_byte(addr) 40 | #define pgm_read_word_far(addr) pgm_read_word(addr) 41 | #define pgm_read_dword_far(addr) pgm_read_dword(addr) 42 | #define pgm_read_float_far(addr) pgm_read_float(addr) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/dtostrf.c: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "dtostrf.h" 22 | 23 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { 24 | char fmt[20]; 25 | sprintf(fmt, "%%%d.%df", width, prec); 26 | sprintf(sout, fmt, val); 27 | return sout; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/dtostrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef __DTOSTRF_H 22 | #define __DTOSTRF_H 23 | #include "stdio.h" 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/itoa.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _ITOA_ 20 | #define _ITOA_ 21 | 22 | #include 23 | #ifdef __cplusplus 24 | extern "C"{ 25 | #endif // __cplusplus 26 | 27 | #if 0 28 | 29 | extern void itoa( int n, char s[] ) ; 30 | 31 | #else 32 | 33 | extern char* itoa( int value, char *string, int radix ) ; 34 | extern char* ltoa( long value, char *string, int radix ) ; 35 | #if 0/*__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \ 36 | (__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))*/ 37 | extern char* utoa( unsigned value, char *string, int radix ) ; 38 | #else 39 | extern char* utoa( unsigned long value, char *string, int radix ) ; 40 | #endif 41 | extern char* ultoa( unsigned long value, char *string, int radix ) ; 42 | #endif /* 0 */ 43 | 44 | #ifdef __cplusplus 45 | } // extern "C" 46 | #endif // __cplusplus 47 | 48 | #endif // _ITOA_ 49 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/ArduinoAPI/libmaple_types.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file libmaple/include/libmaple/libmaple_types.h 29 | * 30 | * @brief libmaple's types, and operations on types. 31 | */ 32 | 33 | #ifndef _LIBMAPLE_LIBMAPLE_TYPES_H_ 34 | #define _LIBMAPLE_LIBMAPLE_TYPES_H_ 35 | 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | typedef unsigned char uint8; 43 | typedef unsigned short uint16; 44 | typedef uint32_t uint32; 45 | typedef unsigned long long uint64; 46 | 47 | typedef signed char int8; 48 | typedef short int16; 49 | typedef int int32; 50 | typedef long long int64; 51 | 52 | typedef void (*voidFuncPtr)(void); 53 | typedef void (*voidArgumentFuncPtr)(void *); 54 | 55 | #define __io volatile 56 | #define __attr_flash __attribute__((section (".USER_FLASH"))) 57 | #define __packed __attribute__((__packed__)) 58 | #define __deprecated __attribute__((__deprecated__)) 59 | #define __weak __attribute__((weak)) 60 | #ifndef __always_inline 61 | #define __always_inline __attribute__((always_inline)) 62 | #endif 63 | #ifndef __unused 64 | #define __unused __attribute__((unused)) 65 | #endif 66 | 67 | #ifndef NULL 68 | #define NULL 0 69 | #endif 70 | 71 | #ifndef offsetof 72 | #define offsetof(type, member) __builtin_offsetof(type, member) 73 | #endif 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Core/adc.h: -------------------------------------------------------------------------------- 1 | #ifndef __ADC_H 2 | #define __ADC_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f4xx.h" 9 | 10 | #define ADC_AverageTimes 8 //ADC求平均次数 11 | 12 | // 注意:用作ADC采集的IO必须没有复用,否则采集电压会有影响 13 | 14 | // 转换通道个数 15 | #define ADC_CHANNEL_NUM 8 16 | extern uint16_t ADC_ConvertedValue[ADC_CHANNEL_NUM];//ADC DMA Buffer 17 | 18 | // ADC1 对应 DMA1通道1,ADC3对应DMA2通道5,ADC2没有DMA功能 19 | 20 | 21 | /**************************函数声明********************************/ 22 | void ADCx_DMA_Init(void); 23 | void ADCx_Init(ADC_TypeDef* ADCx); 24 | 25 | uint16_t Get_DMA_ADC(uint8_t Channel); 26 | uint16_t Get_ADC(ADC_TypeDef* ADCx,uint8_t ADC_Channel); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __ADC_H */ 33 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Core/delay.c: -------------------------------------------------------------------------------- 1 | #include "delay.h" 2 | #include "Arduino.h" 3 | 4 | #define SysTick_LoadValue (F_CPU / 1000U) 5 | 6 | volatile uint32_t System_ms=0; 7 | 8 | void Delay_Init(void) 9 | { 10 | // SysTick->LOAD = SysTick_LoadValue; 11 | // SysTick->VAL = 0x00; 12 | // SysTick->CTRL|= 0x04; 13 | // SysTick->CTRL|= 0x02; 14 | // SysTick->CTRL|= 0x01; 15 | SysTick_Config(SysTick_LoadValue); 16 | SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); 17 | } 18 | 19 | 20 | void SysTick_Handler(void) 21 | { 22 | System_ms++; 23 | } 24 | 25 | uint32_t millis(void) 26 | { 27 | return System_ms; 28 | } 29 | 30 | uint32_t micros(void) 31 | { 32 | return (System_ms*1000 + (SysTick_LoadValue - SysTick->VAL) / CYCLES_PER_MICROSECOND); 33 | } 34 | 35 | void delay_ms(uint32_t ms) 36 | { 37 | uint32_t Stop_TimePoint = System_ms + ms; 38 | while(System_ms < Stop_TimePoint); 39 | } 40 | 41 | void delay_us(uint32_t us) 42 | { 43 | uint32_t total = 0; 44 | uint32_t target = CYCLES_PER_MICROSECOND * us; 45 | int last = SysTick->VAL; 46 | int now = last; 47 | int diff = 0; 48 | start: 49 | now = SysTick->VAL; 50 | diff = last - now; 51 | if(diff > 0) 52 | { 53 | total += diff; 54 | } 55 | else 56 | { 57 | total += diff + SysTick_LoadValue; 58 | } 59 | if(total > target) 60 | { 61 | return; 62 | } 63 | last = now; 64 | goto start; 65 | } 66 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Core/delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f4xx.h" 9 | 10 | void Delay_Init(void); 11 | uint32_t millis(void); 12 | uint32_t micros(void); 13 | void delay_ms(uint32_t ms); 14 | void delay_us(uint32_t us); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif /* __DELAY_H */ 21 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Core/exti.h: -------------------------------------------------------------------------------- 1 | #ifndef __EXTI_H 2 | #define __EXTI_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f4xx.h" 9 | #include "stm32f4xx_exti.h" 10 | #include "Arduino.h" 11 | 12 | #define Get_EXTI_Linex(Pin) (1 << Pinx) 13 | #define Get_EXTI_PortSourceGPIOx(Pin) (Get_GPIOx(Pin)) 14 | #define Get_EXTI_PinSourcex(Pin) (Get_Pinx(Pin)) 15 | 16 | #define CHANGE EXTI_Trigger_Rising_Falling 17 | #define FALLING EXTI_Trigger_Falling 18 | #define RISING EXTI_Trigger_Rising 19 | 20 | void attach_EXTI(uint8_t Pin, void_func_point f, EXTITrigger_TypeDef Trigger_Mode, uint8_t PreemptionPriority, uint8_t SubPriority); 21 | void attachInterrupt(uint8_t Pin, void_func_point f, EXTITrigger_TypeDef Trigger_Mode); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Core/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef __GPIO_H 2 | #define __GPIO_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f4xx.h" 9 | #include "stm32f4xx_gpio.h" 10 | #include "stm32f4xx_rcc.h" 11 | 12 | #ifndef NULL 13 | #define NULL 0 14 | #endif 15 | 16 | #define ADC_Channel_X 0xFF 17 | 18 | typedef enum{ 19 | PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, PA11, PA12, PA13, PA14, PA15, 20 | PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PB8, PB9, PB10, PB11, PB12, PB13, PB14, PB15, 21 | PC0, PC1, PC2, PC3, PC4, PC5, PC6, PC7, PC8, PC9, PC10, PC11, PC12, PC13, PC14, PC15, 22 | PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7, PD8, PD9, PD10, PD11, PD12, PD13, PD14, PD15, 23 | PE0, PE1, PE2, PE3, PE4, PE5, PE6, PE7, PE8, PE9, PE10, PE11, PE12, PE13, PE14, PE15, 24 | PF0, PF1, PF2, PF3, PF4, PF5, PF6, PF7, PF8, PF9, PF10, PF11, PF12, PF13, PF14, PF15, 25 | PG0, PG1, PG2, PG3, PG4, PG5, PG6, PG7, PG8, PG9, PG10, PG11, PG12, PG13, PG14, PG15, 26 | PH0, PH1, PH2, PH3, PH4, PH5, PH6, PH7, PH8, PH9, PH10, PH11, PH12, PH13, PH14, PH15, 27 | PI0, PI1, PI2, PI3, PI4, PI5, PI6, PI7, PI8, PI9, PI10, PI11, PI12, PI13, PI14, PI15, 28 | PJ0, PJ1, PJ2, PJ3, PJ4, PJ5, PJ6, PJ7, PJ8, PJ9, PJ10, PJ11, PJ12, PJ13, PJ14, PJ15, 29 | PK0, PK1, PK2, PK3, PK4, PK5, PK6, PK7, PK8, PK9, PK10, PK11, PK12, PK13, PK14, PK15 30 | }Pxx_TypeDef; 31 | 32 | typedef struct STM32_PinInfo{ 33 | GPIO_TypeDef* GPIOx; 34 | TIM_TypeDef* TIMx; 35 | ADC_TypeDef* ADCx; 36 | 37 | uint16_t GPIO_Pin_x; 38 | uint8_t TimerChannel; 39 | uint8_t ADC_Channel; 40 | }PinInfo_TypeDef; 41 | 42 | typedef enum 43 | { 44 | INPUT, 45 | INPUT_PULLUP, 46 | INPUT_PULLDOWN, 47 | INPUT_ANALOG, 48 | OUTPUT, 49 | OUTPUT_OPEN_DRAIN, 50 | OUTPUT_AF, 51 | PWM 52 | }pinMode_TypeDef; 53 | 54 | 55 | extern const PinInfo_TypeDef PIN_MAP[]; 56 | 57 | #define IS_ADC_PIN(Pin) (PIN_MAP[Pin].ADC_Channel != ADC_Channel_X) 58 | #define IS_PWM_PIN(Pin) (PIN_MAP[Pin].TimerChannel != 0) 59 | 60 | void GPIO_begin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin_x, pinMode_TypeDef pinMode_x, GPIOSpeed_TypeDef GPIO_Speed_x); 61 | 62 | uint8_t Get_GPIOx(uint8_t Pin); 63 | uint8_t Get_Pinx(uint8_t Pin); 64 | uint8_t Get_GPIO_PinSource(uint16_t GPIO_Pin_x); 65 | 66 | #ifdef __cplusplus 67 | }// extern "C" 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Core/pwm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/Core/pwm.c -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Core/pwm.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H 2 | #define __PWM_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f4xx.h" 9 | 10 | #define Get_TIM_PinSourcex(Pin) Get_Pinx(Pin) 11 | 12 | uint8_t PWM_Init(uint8_t Pin, uint16_t PWM_DutyCycle, uint16_t PWM_Frequency); 13 | uint16_t pwmWrite(uint8_t Pin, uint16_t val); 14 | void TIMx_Init(TIM_TypeDef* TIMx, uint16_t arr, uint16_t psc, uint8_t CHx); 15 | uint8_t Get_TIMx_GPIO_AF_x(uint8_t Pin); 16 | 17 | uint16_t timer_get_compare(TIM_TypeDef* TIMx,u8 TimerChannel); 18 | void timer_set_prescaler(TIM_TypeDef* TIMx,uint16_t psc); 19 | void timer_set_reload(TIM_TypeDef* TIMx,uint16_t arr); 20 | void timer_generate_update(TIM_TypeDef* TIMx); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Core/time_exti.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H 2 | #define __TIMER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f4xx.h" 9 | #include "Arduino.h" 10 | 11 | 12 | void TimerSet (TIM_TypeDef* TIMx,uint32_t InterruptTime_us,void_func_point f); 13 | void TimerSet_NVIC(TIM_TypeDef* TIMx,uint32_t InterruptTime_us,void_func_point f,uint8_t NVIC_IRQ_CPP, uint8_t NVIC_IRQ_CSP); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Core/usart.h: -------------------------------------------------------------------------------- 1 | #ifndef __USART_H 2 | #define __USART_H 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "stm32f4xx.h" 9 | #include "stm32f4xx_usart.h" 10 | #include "Arduino.h" 11 | 12 | #define SERIAL_RX_BUFFER_SIZE 128 13 | #define SERIAL_NUM 3 14 | 15 | typedef uint16_t rx_buffer_index_t; 16 | extern volatile uint16_t _rx_buffer_head[SERIAL_NUM]; 17 | extern volatile uint16_t _rx_buffer_tail[SERIAL_NUM]; 18 | extern volatile uint8_t _rx_buffer[SERIAL_NUM][SERIAL_RX_BUFFER_SIZE]; 19 | 20 | void usart_init(USART_TypeDef* USARTx,uint32_t BaudRate,uint8_t PreemptionPriority,uint8_t SubPriority); 21 | void usart_putc(USART_TypeDef* USARTx,uint8_t ch); 22 | void usart_attachInterrupt(uint8_t USART_Num,void_func_point f); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Example/ADCRead_DMA.cpp: -------------------------------------------------------------------------------- 1 | #include "FileGroup.h" 2 | 3 | void setup() 4 | { 5 | Serial.begin(115200); 6 | } 7 | 8 | void loop() 9 | { 10 | int ADC_Val = analogRead_DMA(PA0); 11 | Serial.printf("PA0 ADC:%d\r\n",ADC_Val); 12 | } 13 | 14 | //*****************MAIN******************// 15 | int main(void) 16 | { 17 | Delay_Init(); 18 | // ADCx_Init(ADC1); 19 | ADCx_DMA_Init(); 20 | setup(); 21 | for(;;)loop(); 22 | } 23 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Example/Basic.cpp: -------------------------------------------------------------------------------- 1 | #include "FileGroup.h" 2 | 3 | void setup() 4 | { 5 | Serial.begin(115200); 6 | Serial.printf("C++ Version: %d\r\n",__cplusplus); 7 | Serial.printf("Compiling Time: %s %s\r\n",__DATE__,__TIME__); 8 | pinMode(PC13,OUTPUT); 9 | pinMode(PA0,PWM); 10 | } 11 | 12 | void loop() 13 | { 14 | Serial.println("STM32 Serial Test!"); 15 | delay(2000); 16 | 17 | Serial.println("Digital Write TEST:"); 18 | for(int i=0;i<5;i++) 19 | { 20 | digitalWrite(PC13,HIGH); 21 | delay(1000); 22 | digitalWrite(PC13,LOW); 23 | delay(1000); 24 | } 25 | 26 | Serial.println("Digital Read TEST:"); 27 | pinMode(PC13,INPUT); 28 | uint8_t State = digitalRead(PC13); 29 | Serial.printf("PC13 State is:%d\r\n",State); 30 | pinMode(PC13,OUTPUT); 31 | 32 | Serial.println("Analog Write TEST:"); 33 | for(int i=0;i<5;i++) 34 | { 35 | for(int j=0;j<=1000;j++) 36 | { 37 | analogWrite(PA0,j); 38 | delay(1); 39 | } 40 | for(int j=1000;j>0;j--) 41 | { 42 | analogWrite(PA0,j); 43 | delay(1); 44 | } 45 | } 46 | 47 | Serial.println("PA0 Analog Read TEST:"); 48 | pinMode(PA0,INPUT_ANALOG); 49 | uint16_t ADC_Val = analogRead(PA0); 50 | Serial.printf("PA0 ADC Val is:%d\r\n",ADC_Val); 51 | pinMode(PA0,PWM); 52 | } 53 | 54 | //*****************MAIN******************// 55 | int main(void) 56 | { 57 | Delay_Init(); 58 | ADCx_Init(ADC1); 59 | // ADCx_DMA_Init(); 60 | setup(); 61 | for(;;)loop(); 62 | } 63 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Example/EXTI.cpp: -------------------------------------------------------------------------------- 1 | #include "FileGroup.h" 2 | 3 | void LED() 4 | { 5 | Serial.println("PA1 FALLING!"); 6 | togglePin(PA0); 7 | } 8 | 9 | void setup() 10 | { 11 | Serial.begin(115200); 12 | pinMode(PA0,OUTPUT); 13 | attachInterrupt(PA1,LED,FALLING); 14 | } 15 | 16 | void loop() 17 | { 18 | } 19 | 20 | //*****************MAIN******************// 21 | int main(void) 22 | { 23 | Delay_Init(); 24 | ADCx_Init(ADC1); 25 | // ADCx_DMA_Init(); 26 | setup(); 27 | for(;;)loop(); 28 | } 29 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Example/PWM_Output.cpp: -------------------------------------------------------------------------------- 1 | #include "FileGroup.h" 2 | 3 | void setup() 4 | { 5 | PWM_Init(PA0,1000,10000);//PWM DutyCycle:0~1000 -> 0~100% , PWM Frequency: 10KHz 6 | } 7 | 8 | void loop() 9 | { 10 | for(int i = 0; i <= 1000; i++) 11 | { 12 | pwmWrite(PA0,i); 13 | //or use analogWrite(Pin,DutyCycle); 14 | delay(1); 15 | } 16 | } 17 | 18 | //*****************MAIN******************// 19 | int main(void) 20 | { 21 | Delay_Init(); 22 | ADCx_Init(ADC1); 23 | // ADCx_DMA_Init(); 24 | setup(); 25 | for(;;)loop(); 26 | } 27 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Example/Timer_EXTI.cpp: -------------------------------------------------------------------------------- 1 | #include "FileGroup.h" 2 | 3 | void LED1() 4 | { 5 | Serial.println("Timer 1 Interrupt!"); 6 | togglePin(PA0); 7 | } 8 | 9 | void LED2() 10 | { 11 | Serial.println("Timer 2 Interrupt!"); 12 | togglePin(PA1); 13 | } 14 | 15 | void setup() 16 | { 17 | Serial.begin(115200); 18 | pinMode(PA0,OUTPUT); 19 | pinMode(PA1,OUTPUT); 20 | TimerSet(TIM1,1000000,LED1); 21 | TimerSet(TIM2,100000,LED2); 22 | TIM_Cmd(TIM1,ENABLE); 23 | TIM_Cmd(TIM2,ENABLE); 24 | } 25 | 26 | void loop() 27 | { 28 | } 29 | 30 | //*****************MAIN******************// 31 | int main(void) 32 | { 33 | Delay_Init(); 34 | ADCx_Init(ADC1); 35 | // ADCx_DMA_Init(); 36 | setup(); 37 | for(;;)loop(); 38 | } 39 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Example/USART.cpp: -------------------------------------------------------------------------------- 1 | #include "FileGroup.h" 2 | 3 | void setup() 4 | { 5 | Serial.begin(115200); 6 | Serial2.begin(115200); 7 | Serial3.begin(115200); 8 | } 9 | 10 | void loop() 11 | { 12 | Serial.println("USART1 Print..."); 13 | Serial2.println("USART2 Print..."); 14 | Serial3.println("USART3 Print..."); 15 | } 16 | 17 | //*****************MAIN******************// 18 | int main(void) 19 | { 20 | Delay_Init(); 21 | ADCx_Init(ADC1); 22 | // ADCx_DMA_Init(); 23 | setup(); 24 | for(;;)loop(); 25 | } 26 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/DS1307RTC/DS1307RTC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DS1307RTC.h - library for DS1307 RTC 3 | * This library is intended to be uses with Arduino Time.h library functions 4 | */ 5 | 6 | #ifndef DS1307RTC_h 7 | #define DS1307RTC_h 8 | 9 | #include "Wire.h" 10 | #include "Time/TimeLib.h" 11 | 12 | // library interface description 13 | class DS1307RTC 14 | { 15 | // user-accessible "public" interface 16 | public: 17 | DS1307RTC(); 18 | static time_t get(); 19 | static bool set(time_t t); 20 | static bool read(tmElements_t &tm); 21 | static bool write(tmElements_t &tm); 22 | static bool chipPresent() { return exists; } 23 | 24 | private: 25 | static bool exists; 26 | static uint8_t dec2bcd(uint8_t num); 27 | static uint8_t bcd2dec(uint8_t num); 28 | }; 29 | 30 | #ifdef RTC 31 | #undef RTC // workaround for Arduino Due, which defines "RTC"... 32 | #endif 33 | 34 | extern DS1307RTC RTC; 35 | 36 | #endif 37 | 38 | 39 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/DS1307RTC/examples/ReadTest/ReadTest.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void setup() { 6 | Serial.begin(9600); 7 | while (!Serial) ; // wait for serial 8 | delay(200); 9 | Serial.println("DS1307RTC Read Test"); 10 | Serial.println("-------------------"); 11 | } 12 | 13 | void loop() { 14 | tmElements_t tm; 15 | 16 | if (RTC.read(tm)) { 17 | Serial.print("Ok, Time = "); 18 | print2digits(tm.Hour); 19 | Serial.write(':'); 20 | print2digits(tm.Minute); 21 | Serial.write(':'); 22 | print2digits(tm.Second); 23 | Serial.print(", Date (D/M/Y) = "); 24 | Serial.print(tm.Day); 25 | Serial.write('/'); 26 | Serial.print(tm.Month); 27 | Serial.write('/'); 28 | Serial.print(tmYearToCalendar(tm.Year)); 29 | Serial.println(); 30 | } else { 31 | if (RTC.chipPresent()) { 32 | Serial.println("The DS1307 is stopped. Please run the SetTime"); 33 | Serial.println("example to initialize the time and begin running."); 34 | Serial.println(); 35 | } else { 36 | Serial.println("DS1307 read error! Please check the circuitry."); 37 | Serial.println(); 38 | } 39 | delay(9000); 40 | } 41 | delay(1000); 42 | } 43 | 44 | void print2digits(int number) { 45 | if (number >= 0 && number < 10) { 46 | Serial.write('0'); 47 | } 48 | Serial.print(number); 49 | } 50 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/DS1307RTC/examples/SetTime/SetTime.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | const char *monthName[12] = { 6 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", 7 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" 8 | }; 9 | 10 | tmElements_t tm; 11 | 12 | void setup() { 13 | bool parse=false; 14 | bool config=false; 15 | 16 | // get the date and time the compiler was run 17 | if (getDate(__DATE__) && getTime(__TIME__)) { 18 | parse = true; 19 | // and configure the RTC with this info 20 | if (RTC.write(tm)) { 21 | config = true; 22 | } 23 | } 24 | 25 | Serial.begin(9600); 26 | while (!Serial) ; // wait for Arduino Serial Monitor 27 | delay(200); 28 | if (parse && config) { 29 | Serial.print("DS1307 configured Time="); 30 | Serial.print(__TIME__); 31 | Serial.print(", Date="); 32 | Serial.println(__DATE__); 33 | } else if (parse) { 34 | Serial.println("DS1307 Communication Error :-{"); 35 | Serial.println("Please check your circuitry"); 36 | } else { 37 | Serial.print("Could not parse info from the compiler, Time=\""); 38 | Serial.print(__TIME__); 39 | Serial.print("\", Date=\""); 40 | Serial.print(__DATE__); 41 | Serial.println("\""); 42 | } 43 | } 44 | 45 | void loop() { 46 | } 47 | 48 | bool getTime(const char *str) 49 | { 50 | int Hour, Min, Sec; 51 | 52 | if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false; 53 | tm.Hour = Hour; 54 | tm.Minute = Min; 55 | tm.Second = Sec; 56 | return true; 57 | } 58 | 59 | bool getDate(const char *str) 60 | { 61 | char Month[12]; 62 | int Day, Year; 63 | uint8_t monthIndex; 64 | 65 | if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false; 66 | for (monthIndex = 0; monthIndex < 12; monthIndex++) { 67 | if (strcmp(Month, monthName[monthIndex]) == 0) break; 68 | } 69 | if (monthIndex >= 12) return false; 70 | tm.Day = Day; 71 | tm.Month = monthIndex + 1; 72 | tm.Year = CalendarYrToTm(Year); 73 | return true; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/DS1307RTC/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For DS1307RTC 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | get KEYWORD2 13 | set KEYWORD2 14 | read KEYWORD2 15 | write KEYWORD2 16 | chipPresent KEYWORD2 17 | ####################################### 18 | # Instances (KEYWORD2) 19 | ####################################### 20 | RTC KEYWORD2 21 | ####################################### 22 | # Constants (LITERAL1) 23 | ####################################### 24 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/DS1307RTC/library.properties: -------------------------------------------------------------------------------- 1 | name=DS1307RTC 2 | version=1.4 3 | author=Michael Margolis 4 | maintainer=Paul Stoffregen 5 | sentence=Use a DS1307 Real Time Clock chip with the Time library 6 | paragraph= 7 | category=Timing 8 | url=http://playground.arduino.cc/code/time 9 | architectures=* 10 | 11 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/DS1307RTC/readme.txt: -------------------------------------------------------------------------------- 1 | Readme file for DS1307RTC Library 2 | 3 | The DS1307RTC library is provided to demonstrate the Arduino Time library. 4 | 5 | See the TimeRTC example sketches privided with the Time library download for usage 6 | 7 | 8 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/I2Cdev/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For I2Cdev 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | I2Cdev KEYWORD1 9 | 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | 14 | readBit KEYWORD2 15 | readBitW KEYWORD2 16 | readBits KEYWORD2 17 | readBitsW KEYWORD2 18 | readByte KEYWORD2 19 | readBytes KEYWORD2 20 | readWord KEYWORD2 21 | readWords KEYWORD2 22 | writeBit KEYWORD2 23 | writeBitW KEYWORD2 24 | writeBits KEYWORD2 25 | writeBitsW KEYWORD2 26 | writeByte KEYWORD2 27 | writeBytes KEYWORD2 28 | writeWord KEYWORD2 29 | writeWords KEYWORD2 30 | 31 | ####################################### 32 | # Instances (KEYWORD2) 33 | ####################################### 34 | 35 | ####################################### 36 | # Constants (LITERAL1) 37 | ####################################### 38 | 39 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/I2Cdev/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "I2Cdevlib-Core", 3 | "keywords": "i2cdevlib, i2c", 4 | "description": "The I2C Device Library (I2Cdevlib) is a collection of uniform and well-documented classes to provide simple and intuitive interfaces to I2C devices.", 5 | "include": "Arduino/I2Cdev", 6 | "repository": 7 | { 8 | "type": "git", 9 | "url": "https://github.com/jrowberg/i2cdevlib.git" 10 | }, 11 | "frameworks": "arduino", 12 | "platforms": "atmelavr" 13 | } 14 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Kalman/Kalman.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Kristian Lauszus, TKJ Electronics 14 | Web : http://www.tkjelectronics.com 15 | e-mail : kristianl@tkjelectronics.com 16 | */ 17 | 18 | #ifndef _Kalman_h_ 19 | #define _Kalman_h_ 20 | 21 | class Kalman { 22 | public: 23 | Kalman(); 24 | 25 | // The angle should be in degrees and the rate should be in degrees per second and the delta time in seconds 26 | float getAngle(float newAngle, float newRate, float dt); 27 | 28 | void setAngle(float angle); // Used to set angle, this should be set as the starting angle 29 | float getRate(); // Return the unbiased rate 30 | 31 | /* These are used to tune the Kalman filter */ 32 | void setQangle(float Q_angle); 33 | /** 34 | * setQbias(float Q_bias) 35 | * Default value (0.003f) is in Kalman.cpp. 36 | * Raise this to follow input more closely, 37 | * lower this to smooth result of kalman filter. 38 | */ 39 | void setQbias(float Q_bias); 40 | void setRmeasure(float R_measure); 41 | 42 | float getQangle(); 43 | float getQbias(); 44 | float getRmeasure(); 45 | 46 | private: 47 | /* Kalman filter variables */ 48 | float Q_angle; // Process noise variance for the accelerometer 49 | float Q_bias; // Process noise variance for the gyro bias 50 | float R_measure; // Measurement noise variance - this is actually the variance of the measurement noise 51 | 52 | float angle; // The angle calculated by the Kalman filter - part of the 2x1 state vector 53 | float bias; // The gyro bias calculated by the Kalman filter - part of the 2x1 state vector 54 | float rate; // Unbiased rate calculated from the rate and the calculated bias - you have to call getAngle to update the rate 55 | 56 | float P[2][2]; // Error covariance matrix - This is a 2x2 matrix 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/LTDC_Graphic/Common/fonts.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file fonts.h 4 | * @author MCD Application Team 5 | * @version V5.0.2 6 | * @date 05-March-2012 7 | * @brief Header for fonts.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __FONTS_H 30 | #define __FONTS_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include 38 | 39 | /** @addtogroup Utilities 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup STM32_EVAL 44 | * @{ 45 | */ 46 | 47 | /** @addtogroup Common 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup FONTS 52 | * @{ 53 | */ 54 | 55 | /** @defgroup FONTS_Exported_Types 56 | * @{ 57 | */ 58 | typedef struct _tFont 59 | { 60 | const uint16_t *table; 61 | uint16_t Width; 62 | uint16_t Height; 63 | 64 | } sFONT; 65 | 66 | extern sFONT Font16x24; 67 | extern sFONT Font12x12; 68 | extern sFONT Font8x12; 69 | extern sFONT Font8x8; 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup FONTS_Exported_Constants 76 | * @{ 77 | */ 78 | #define LINE(x) ((x) * (((sFONT *)LCD_GetFont())->Height)) 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup FONTS_Exported_Macros 85 | * @{ 86 | */ 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup FONTS_Exported_Functions 92 | * @{ 93 | */ 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __FONTS_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 125 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/LTDC_Graphic/STM32F429I-Discovery/Release_Notes.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/Libraries/LTDC_Graphic/STM32F429I-Discovery/Release_Notes.html -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/MillisTaskManager/MillisTaskManager.cpp: -------------------------------------------------------------------------------- 1 | #include "MillisTaskManager.h" 2 | 3 | void NullFunction()//空函数 4 | { 5 | } 6 | 7 | 8 | //用途:初始化任务列表 9 | //参数: (设定任务列表总长度) 10 | MillisTaskManager::MillisTaskManager(uint8_t TaskNum_MAX_Set) 11 | { 12 | if(TaskList != NULL) delete TaskList;//清空列表 13 | TaskList = new MillisTaskManager_TypeDef[TaskNum_MAX_Set];//为任务列表申请内存 14 | TaskNum_MAX = TaskNum_MAX_Set;//记录任务列表总长度 15 | 16 | for(uint8_t i = 0; i < TaskNum_MAX; i++)//初始化任务列表,清零 17 | { 18 | TaskClear(i); 19 | } 20 | } 21 | 22 | //用途:不带越界判断地清除一个任务,private权限 23 | //参数: (任务注册的位置) 24 | void MillisTaskManager::TaskClear(uint8_t FuncPos) 25 | { 26 | TaskList[FuncPos].Function = NullFunction; 27 | TaskList[FuncPos].State = 0; 28 | TaskList[FuncPos].IntervalTime = 0; 29 | TaskList[FuncPos].TimePoint = 0; 30 | } 31 | 32 | //用途:在任务列表内的一个位置注册一个任务,设定间隔执行时间 33 | //参数: (任务注册地址,任务函数指针,时间设定(毫秒)) 34 | int16_t MillisTaskManager::TaskRegister(uint8_t FuncPos, void_TaskFunction_t Function, uint32_t TimeSetMs, uint8_t TaskState) 35 | { 36 | if(FuncPos < TaskNum_MAX)//判断是否越界 37 | { 38 | TaskList[FuncPos].Function = Function;//注册函数指针 39 | TaskList[FuncPos].State = TaskState;//初始状态设定 40 | TaskList[FuncPos].IntervalTime = TimeSetMs;//注册时间 41 | return FuncPos;//如果注册成功,返回注册地址 42 | } 43 | return -1;//如果注册失败,返回-1 44 | } 45 | 46 | //用途:注销任务 47 | //参数: (任务函数指针) 48 | int16_t MillisTaskManager::TaskLogout(void_TaskFunction_t Function) 49 | { 50 | for(uint8_t i = 0; i < TaskNum_MAX; i++) 51 | { 52 | if(TaskList[i].Function == Function) 53 | { 54 | TaskClear(i); 55 | return i; 56 | } 57 | } 58 | return -1; 59 | } 60 | 61 | //用途:注销任务 62 | //参数: (任务注册的位置) 63 | int16_t MillisTaskManager::TaskLogout(uint8_t FuncPos) 64 | { 65 | if(FuncPos < TaskNum_MAX) 66 | { 67 | TaskClear(FuncPos); 68 | return FuncPos; 69 | } 70 | return -1; 71 | } 72 | 73 | //用途:任务状态控制 74 | //参数: (任务函数指针,任务状态) 75 | int16_t MillisTaskManager::TaskCtrl(void_TaskFunction_t Function, uint8_t TaskState) 76 | { 77 | for(uint8_t i = 0; i < TaskNum_MAX; i++) 78 | { 79 | if(TaskList[i].Function == Function) 80 | { 81 | TaskList[i].State = TaskState; 82 | return i; 83 | } 84 | } 85 | return -1; 86 | } 87 | 88 | //用途:任务状态控制 89 | //参数: (任务注册的位置,任务状态) 90 | int16_t MillisTaskManager::TaskCtrl(uint8_t FuncPos, uint8_t TaskState) 91 | { 92 | if(FuncPos < TaskNum_MAX) 93 | { 94 | TaskList[FuncPos].State = TaskState; 95 | return FuncPos; 96 | } 97 | return -1; 98 | } 99 | 100 | //用途:执行调度器 101 | //参数: (一个精确到毫秒的系统时钟) 102 | void MillisTaskManager::Running(uint32_t MillisSeed) 103 | { 104 | for(uint8_t i = 0; i < TaskNum_MAX; i++)//遍历任务列表 105 | { 106 | if(TaskList[i].Function != NullFunction)//判断是否为空函数 107 | { 108 | if(TaskList[i].State && MillisSeed >= TaskList[i].TimePoint)//判断是否运行任务,是否到达触发时间点 109 | { 110 | TaskList[i].TimePoint = MillisSeed + TaskList[i].IntervalTime;//标记下一个时间点 111 | TaskList[i].Function();//执行任务 112 | } 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/MillisTaskManager/MillisTaskManager.h: -------------------------------------------------------------------------------- 1 | //Designed By _VIFEXTech 2 | //Finished in 2018.7.26 V_1.0 可以替代旧的millis()循环判断的方案,不依赖ArduinoAPI 3 | 4 | #ifndef __MILLISTASKMANAGER_H 5 | #define __MILLISTASKMANAGER_H 6 | 7 | #include "stdint.h" 8 | 9 | #ifndef NULL 10 | #define NULL 0 11 | #endif 12 | 13 | typedef void(*void_TaskFunction_t)(void);//函数指针类型定义 14 | 15 | typedef struct{ 16 | void_TaskFunction_t Function; //任务函数指针 17 | uint8_t State; //任务状态 18 | uint32_t IntervalTime; //任务触发间隔时间 19 | uint32_t TimePoint; //任务触发时间点 20 | }MillisTaskManager_TypeDef;//任务类型定义 21 | 22 | class MillisTaskManager{ 23 | public: 24 | MillisTaskManager(uint8_t TaskNum_MAX_Set); 25 | int16_t TaskRegister(uint8_t FuncPos, void_TaskFunction_t Function, uint32_t TimeSetMs, uint8_t TaskState = 1); 26 | int16_t TaskLogout(void_TaskFunction_t Function); 27 | int16_t TaskLogout(uint8_t FuncPos); 28 | int16_t TaskCtrl(void_TaskFunction_t Function, uint8_t TaskState); 29 | int16_t TaskCtrl(uint8_t FuncPos, uint8_t TaskState); 30 | void Running(uint32_t MillisSeed); 31 | private: 32 | MillisTaskManager_TypeDef* TaskList;//任务列表 33 | uint8_t TaskNum_MAX;//任务列表长度 34 | void TaskClear(uint8_t FuncPos);//清除任务 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/SD/utility/SdFatUtil.h: -------------------------------------------------------------------------------- 1 | /* Arduino SdFat Library 2 | * Copyright (C) 2008 by William Greiman 3 | * 4 | * This file is part of the Arduino SdFat Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Arduino SdFat Library. If not, see 18 | * . 19 | */ 20 | #ifndef SdFatUtil_h 21 | #define SdFatUtil_h 22 | /** 23 | * \file 24 | * Useful utility functions. 25 | */ 26 | extern "C"{ 27 | #include 28 | } 29 | #ifdef __AVR__ 30 | #include 31 | /** Store and print a string in flash memory.*/ 32 | #define PgmPrint(x) SerialPrint_P(PSTR(x)) 33 | /** Store and print a string in flash memory followed by a CR/LF.*/ 34 | #define PgmPrintln(x) SerialPrintln_P(PSTR(x)) 35 | /** Defined so doxygen works for function definitions. */ 36 | #endif 37 | #define NOINLINE __attribute__((noinline,unused)) 38 | #define UNUSEDOK __attribute__((unused)) 39 | //------------------------------------------------------------------------------ 40 | /** Return the number of bytes currently free in RAM. */ 41 | static UNUSEDOK int FreeRam(void) { 42 | // extern int __bss_end;//*********************************************************** 43 | // extern int* __brkval; 44 | int __bss_end; 45 | int* __brkval; 46 | int free_memory; 47 | if (reinterpret_cast(__brkval) == 0) { 48 | // if no heap use from end of bss section 49 | free_memory = reinterpret_cast(&free_memory) 50 | - reinterpret_cast(&__bss_end); 51 | } else { 52 | // use from top of stack to heap 53 | free_memory = reinterpret_cast(&free_memory) 54 | - reinterpret_cast(__brkval); 55 | } 56 | return free_memory; 57 | } 58 | #ifdef __AVR__ 59 | //------------------------------------------------------------------------------ 60 | /** 61 | * %Print a string in flash memory to the serial port. 62 | * 63 | * \param[in] str Pointer to string stored in flash memory. 64 | */ 65 | static NOINLINE void SerialPrint_P(PGM_P str) { 66 | for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.write(c); 67 | } 68 | //------------------------------------------------------------------------------ 69 | /** 70 | * %Print a string in flash memory followed by a CR/LF. 71 | * 72 | * \param[in] str Pointer to string stored in flash memory. 73 | */ 74 | static NOINLINE void SerialPrintln_P(PGM_P str) { 75 | SerialPrint_P(str); 76 | Serial.println(); 77 | } 78 | #endif // __AVR__ 79 | #endif // #define SdFatUtil_h 80 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/SSD1306_I2C/SSD1306_I2C.h: -------------------------------------------------------------------------------- 1 | #ifndef SSD1306_I2C_H 2 | #define SSD1306_I2C_H 3 | 4 | #include "Arduino.h" 5 | #include "Wire.h" 6 | #include "Print.h" 7 | #include "fonts/font8x8.h" 8 | 9 | #define SSD1306_Max_X 127 //128 Pixels 10 | #define SSD1306_Max_Y 63 //64 Pixels 11 | 12 | #define PAGE_MODE 01 13 | #define HORIZONTAL_MODE 02 14 | 15 | //#define SSD1306_Address 0x3C 16 | #define SSD1306_Command_Mode 0x80 17 | #define SSD1306_Data_Mode 0x40 18 | #define SSD1306_Display_Off_Cmd 0xAE 19 | #define SSD1306_Display_On_Cmd 0xAF 20 | #define SSD1306_Normal_Display_Cmd 0xA6 21 | #define SSD1306_Inverse_Display_Cmd 0xA7 22 | #define SSD1306_Activate_Scroll_Cmd 0x2F 23 | #define SSD1306_Dectivate_Scroll_Cmd 0x2E 24 | #define SSD1306_Set_Brightness_Cmd 0x81 25 | 26 | #define Scroll_Left 0x00 27 | #define Scroll_Right 0x01 28 | 29 | #define Scroll_2Frames 0x7 30 | #define Scroll_3Frames 0x4 31 | #define Scroll_4Frames 0x5 32 | #define Scroll_5Frames 0x0 33 | #define Scroll_25Frames 0x6 34 | #define Scroll_64Frames 0x1 35 | #define Scroll_128Frames 0x2 36 | #define Scroll_256Frames 0x3 37 | 38 | #define MAX_bitmaparrayCache 20 39 | 40 | class SSD1306_I2C : public Print 41 | { 42 | public: 43 | 44 | char addressingMode; 45 | void init(unsigned char _Address = 0x3C); 46 | virtual size_t write(uint8_t); 47 | using Print::write; 48 | 49 | void setCacheMode(unsigned char chs); 50 | void CachePutChar(unsigned char C); 51 | void putCache(); 52 | 53 | void setNormalDisplay(); 54 | void setInverseDisplay(); 55 | 56 | void sendCommand(unsigned char command); 57 | void sendData(unsigned char Data); 58 | 59 | void setPageMode(); 60 | void setHorizontalMode(); 61 | 62 | void setCursor(unsigned char Column, unsigned char Row); 63 | void clear(); 64 | void setBrightness(unsigned char Brightness); 65 | void putChar(unsigned char c); 66 | 67 | void drawBitmap(unsigned char *bitmaparray); 68 | void drawFullScreen(const unsigned char *PictureArray,int bytes); 69 | 70 | void setHorizontalScrollProperties( 71 | bool direction, 72 | unsigned char startPage, 73 | unsigned char endPage, 74 | unsigned char scrollSpeed); 75 | void activateScroll(); 76 | void deactivateScroll(); 77 | 78 | private: 79 | 80 | unsigned char SSD1306_Address; 81 | unsigned char LastCache[16][8]; 82 | unsigned char Cache[16][8]; 83 | 84 | unsigned char UseCache; 85 | unsigned char Cache_X,Cache_Y; 86 | unsigned char Pos; 87 | unsigned char *bitmaparrayCache[MAX_bitmaparrayCache]; 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/STM32F429_Discovery/Common/fonts.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file fonts.h 4 | * @author MCD Application Team 5 | * @version V5.0.2 6 | * @date 05-March-2012 7 | * @brief Header for fonts.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __FONTS_H 30 | #define __FONTS_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include 38 | 39 | /** @addtogroup Utilities 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup STM32_EVAL 44 | * @{ 45 | */ 46 | 47 | /** @addtogroup Common 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup FONTS 52 | * @{ 53 | */ 54 | 55 | /** @defgroup FONTS_Exported_Types 56 | * @{ 57 | */ 58 | typedef struct _tFont 59 | { 60 | const uint16_t *table; 61 | uint16_t Width; 62 | uint16_t Height; 63 | 64 | } sFONT; 65 | 66 | extern sFONT Font16x24; 67 | extern sFONT Font12x12; 68 | extern sFONT Font8x12; 69 | extern sFONT Font8x8; 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup FONTS_Exported_Constants 76 | * @{ 77 | */ 78 | #define LINE(x) ((x) * (((sFONT *)LCD_GetFont())->Height)) 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup FONTS_Exported_Macros 85 | * @{ 86 | */ 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup FONTS_Exported_Functions 92 | * @{ 93 | */ 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __FONTS_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 125 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/STM32F429_Discovery/STM32F429I-Discovery/Release_Notes.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/Libraries/STM32F429_Discovery/STM32F429I-Discovery/Release_Notes.html -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/STM32F429_Discovery/Third_Party/FreeRTOS/Source/portable/Keil/See-also-the-RVDS-directory.txt: -------------------------------------------------------------------------------- 1 | Nothing to see here. -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/STM32F429_Discovery/Third_Party/FreeRTOS/Source/portable/readme.txt: -------------------------------------------------------------------------------- 1 | Each real time kernel port consists of three files that contain the core kernel 2 | components and are common to every port, and one or more files that are 3 | specific to a particular microcontroller and/or compiler. 4 | 5 | 6 | + The FreeRTOS/Source/Portable/MemMang directory contains the three sample 7 | memory allocators as described on the http://www.FreeRTOS.org WEB site. 8 | 9 | + The other directories each contain files specific to a particular 10 | microcontroller or compiler. 11 | 12 | 13 | 14 | For example, if you are interested in the GCC port for the ATMega323 15 | microcontroller then the port specific files are contained in 16 | FreeRTOS/Source/Portable/GCC/ATMega323 directory. If this is the only 17 | port you are interested in then all the other directories can be 18 | ignored. 19 | 20 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/STM32F429_Discovery/Third_Party/FreeRTOS/Source/readme.txt: -------------------------------------------------------------------------------- 1 | Each real time kernel port consists of three files that contain the core kernel 2 | components and are common to every port, and one or more files that are 3 | specific to a particular microcontroller and or compiler. 4 | 5 | + The FreeRTOS/Source directory contains the three files that are common to 6 | every port - list.c, queue.c and tasks.c. The kernel is contained within these 7 | three files. croutine.c implements the optional co-routine functionality - which 8 | is normally only used on very memory limited systems. 9 | 10 | + The FreeRTOS/Source/Portable directory contains the files that are specific to 11 | a particular microcontroller and or compiler. 12 | 13 | + The FreeRTOS/Source/include directory contains the real time kernel header 14 | files. 15 | 16 | See the readme file in the FreeRTOS/Source/Portable directory for more 17 | information. -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/STM32F429_Discovery/Third_Party/FreeRTOS/readme.txt: -------------------------------------------------------------------------------- 1 | The download includes the kernel source code, and a demo application for EVERY 2 | RTOS port. See http://www.freertos.org/a00017.html for full details of the 3 | directory structure and information on locating the files you require. 4 | 5 | The easiest way to use FreeRTOS is start start with one of the demo application 6 | projects. Once this is running the project can be modified to include your own 7 | source files. This way the correct files and compiler options will be 8 | automatically included in your application. 9 | 10 | + The Source directory contains the real time kernel source files for every 11 | port. The kernel itself is only 3 files. 12 | 13 | + The Demo directory contains the demo application source files for every 14 | port. 15 | 16 | + The TraceCon directory contains the trace visualisation exe file. 17 | 18 | See the readme files in the respective directories for further information. 19 | 20 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/STM32F429_Discovery/Third_Party/fat_fs/inc/diskio.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------- 2 | / Low level disk interface modlue include file (C)ChaN, 2013 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_DEFINED 6 | #define _DISKIO_DEFINED 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define _USE_WRITE 1 /* 1: Enable disk_write function */ 13 | #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ 14 | 15 | #include "integer.h" 16 | 17 | 18 | /* Status of Disk Functions */ 19 | typedef BYTE DSTATUS; 20 | 21 | /* Results of Disk Functions */ 22 | typedef enum { 23 | RES_OK = 0, /* 0: Successful */ 24 | RES_ERROR, /* 1: R/W Error */ 25 | RES_WRPRT, /* 2: Write Protected */ 26 | RES_NOTRDY, /* 3: Not Ready */ 27 | RES_PARERR /* 4: Invalid Parameter */ 28 | } DRESULT; 29 | 30 | 31 | /*---------------------------------------*/ 32 | /* Prototypes for disk control functions */ 33 | 34 | 35 | DSTATUS disk_initialize (BYTE pdrv); 36 | DSTATUS disk_status (BYTE pdrv); 37 | DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count); 38 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count); 39 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 40 | 41 | 42 | /* Disk Status Bits (DSTATUS) */ 43 | #define STA_NOINIT 0x01 /* Drive not initialized */ 44 | #define STA_NODISK 0x02 /* No medium in the drive */ 45 | #define STA_PROTECT 0x04 /* Write protected */ 46 | 47 | 48 | /* Command code for disk_ioctrl fucntion */ 49 | 50 | /* Generic command (used by FatFs) */ 51 | #define CTRL_SYNC 0 /* Flush disk cache (for write functions) */ 52 | #define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */ 53 | #define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ 54 | #define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */ 55 | #define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */ 56 | 57 | /* Generic command (not used by FatFs) */ 58 | #define CTRL_POWER 5 /* Get/Set power status */ 59 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 60 | #define CTRL_EJECT 7 /* Eject media */ 61 | #define CTRL_FORMAT 8 /* Create physical format on the media */ 62 | 63 | /* MMC/SDC specific ioctl command */ 64 | #define MMC_GET_TYPE 10 /* Get card type */ 65 | #define MMC_GET_CSD 11 /* Get CSD */ 66 | #define MMC_GET_CID 12 /* Get CID */ 67 | #define MMC_GET_OCR 13 /* Get OCR */ 68 | #define MMC_GET_SDSTAT 14 /* Get SD status */ 69 | 70 | /* ATA/CF specific ioctl command */ 71 | #define ATA_GET_REV 20 /* Get F/W revision */ 72 | #define ATA_GET_MODEL 21 /* Get model name */ 73 | #define ATA_GET_SN 22 /* Get serial number */ 74 | 75 | 76 | /* MMC card type flags (MMC_GET_TYPE) */ 77 | #define CT_MMC 0x01 /* MMC ver 3 */ 78 | #define CT_SD1 0x02 /* SD ver 1 */ 79 | #define CT_SD2 0x04 /* SD ver 2 */ 80 | #define CT_SDC (CT_SD1|CT_SD2) /* SD */ 81 | #define CT_BLOCK 0x08 /* Block addressing */ 82 | 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/STM32F429_Discovery/Third_Party/fat_fs/inc/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _INTEGER 6 | #define _INTEGER 7 | 8 | #ifdef _WIN32 /* FatFs development platform */ 9 | 10 | #include 11 | #include 12 | 13 | #else /* Embedded platform */ 14 | 15 | /* These types must be 16-bit, 32-bit or larger integer */ 16 | typedef int INT; 17 | typedef unsigned int UINT; 18 | 19 | /* These types must be 8-bit integer */ 20 | typedef char CHAR; 21 | typedef unsigned char UCHAR; 22 | typedef unsigned char BYTE; 23 | 24 | /* These types must be 16-bit integer */ 25 | typedef short SHORT; 26 | typedef unsigned short USHORT; 27 | typedef unsigned short WORD; 28 | typedef unsigned short WCHAR; 29 | 30 | /* These types must be 32-bit integer */ 31 | typedef long LONG; 32 | typedef unsigned long ULONG; 33 | typedef unsigned long DWORD; 34 | 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/Time.h: -------------------------------------------------------------------------------- 1 | #include "TimeLib.h" 2 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde: -------------------------------------------------------------------------------- 1 | /** 2 | * SyncArduinoClock. 3 | * 4 | * portIndex must be set to the port connected to the Arduino 5 | * 6 | * The current time is sent in response to request message from Arduino 7 | * or by clicking the display window 8 | * 9 | * The time message is 11 ASCII text characters; a header (the letter 'T') 10 | * followed by the ten digit system time (unix time) 11 | */ 12 | 13 | 14 | import processing.serial.*; 15 | import java.util.Date; 16 | import java.util.Calendar; 17 | import java.util.GregorianCalendar; 18 | 19 | public static final short portIndex = 0; // select the com port, 0 is the first port 20 | public static final String TIME_HEADER = "T"; //header for arduino serial time message 21 | public static final char TIME_REQUEST = 7; // ASCII bell character 22 | public static final char LF = 10; // ASCII linefeed 23 | public static final char CR = 13; // ASCII linefeed 24 | Serial myPort; // Create object from Serial class 25 | 26 | void setup() { 27 | size(200, 200); 28 | println(Serial.list()); 29 | println(" Connecting to -> " + Serial.list()[portIndex]); 30 | myPort = new Serial(this,Serial.list()[portIndex], 9600); 31 | println(getTimeNow()); 32 | } 33 | 34 | void draw() 35 | { 36 | textSize(20); 37 | textAlign(CENTER); 38 | fill(0); 39 | text("Click to send\nTime Sync", 0, 75, 200, 175); 40 | if ( myPort.available() > 0) { // If data is available, 41 | char val = char(myPort.read()); // read it and store it in val 42 | if(val == TIME_REQUEST){ 43 | long t = getTimeNow(); 44 | sendTimeMessage(TIME_HEADER, t); 45 | } 46 | else 47 | { 48 | if(val == LF) 49 | ; //igonore 50 | else if(val == CR) 51 | println(); 52 | else 53 | print(val); // echo everying but time request 54 | } 55 | } 56 | } 57 | 58 | void mousePressed() { 59 | sendTimeMessage( TIME_HEADER, getTimeNow()); 60 | } 61 | 62 | 63 | void sendTimeMessage(String header, long time) { 64 | String timeStr = String.valueOf(time); 65 | myPort.write(header); // send header and time to arduino 66 | myPort.write(timeStr); 67 | myPort.write('\n'); 68 | } 69 | 70 | long getTimeNow(){ 71 | // java time is in ms, we want secs 72 | Date d = new Date(); 73 | Calendar cal = new GregorianCalendar(); 74 | long current = d.getTime()/1000; 75 | long timezone = cal.get(cal.ZONE_OFFSET)/1000; 76 | long daylight = cal.get(cal.DST_OFFSET)/1000; 77 | return current + timezone + daylight; 78 | } 79 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/examples/Processing/SyncArduinoClock/readme.txt: -------------------------------------------------------------------------------- 1 | SyncArduinoClock is a Processing sketch that responds to Arduino requests for 2 | time synchronization messages. 3 | 4 | The portIndex must be set the Serial port connected to Arduino. 5 | 6 | Download TimeSerial.pde onto Arduino and you should see the time 7 | message displayed when you run SyncArduinoClock in Processing. 8 | The Arduino time is set from the time on your computer through the 9 | Processing sketch. 10 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/examples/TimeArduinoDue/TimeArduinoDue.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTC.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | * This example requires Markus Lange's Arduino Due RTC Library 6 | * https://github.com/MarkusLange/Arduino-Due-RTC-Library 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | // Select the Slowclock source 13 | //RTC_clock rtc_clock(RC); 14 | RTC_clock rtc_clock(XTAL); 15 | 16 | void setup() { 17 | Serial.begin(9600); 18 | rtc_clock.init(); 19 | if (rtc_clock.date_already_set() == 0) { 20 | // Unfortunately, the Arduino Due hardware does not seem to 21 | // be designed to maintain the RTC clock state when the 22 | // board resets. Markus described it thusly: "Uhh the Due 23 | // does reset with the NRSTB pin. This resets the full chip 24 | // with all backup regions including RTC, RTT and SC. Only 25 | // if the reset is done with the NRST pin will these regions 26 | // stay with their old values." 27 | rtc_clock.set_time(__TIME__); 28 | rtc_clock.set_date(__DATE__); 29 | // However, this might work on other unofficial SAM3X boards 30 | // with different reset circuitry than Arduino Due? 31 | } 32 | setSyncProvider(getArduinoDueTime); 33 | if(timeStatus()!= timeSet) 34 | Serial.println("Unable to sync with the RTC"); 35 | else 36 | Serial.println("RTC has set the system time"); 37 | } 38 | 39 | time_t getArduinoDueTime() 40 | { 41 | return rtc_clock.unixtime(); 42 | } 43 | 44 | void loop() 45 | { 46 | digitalClockDisplay(); 47 | delay(1000); 48 | } 49 | 50 | void digitalClockDisplay(){ 51 | // digital clock display of the time 52 | Serial.print(hour()); 53 | printDigits(minute()); 54 | printDigits(second()); 55 | Serial.print(" "); 56 | Serial.print(day()); 57 | Serial.print(" "); 58 | Serial.print(month()); 59 | Serial.print(" "); 60 | Serial.print(year()); 61 | Serial.println(); 62 | } 63 | 64 | void printDigits(int digits){ 65 | // utility function for digital clock display: prints preceding colon and leading 0 66 | Serial.print(":"); 67 | if(digits < 10) 68 | Serial.print('0'); 69 | Serial.print(digits); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/examples/TimeGPS/TimeGPS.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeGPS.pde 3 | * example code illustrating time synced from a GPS 4 | * 5 | */ 6 | 7 | #include 8 | #include // http://arduiniana.org/libraries/TinyGPS/ 9 | #include 10 | // TinyGPS and SoftwareSerial libraries are the work of Mikal Hart 11 | 12 | SoftwareSerial SerialGPS = SoftwareSerial(10, 11); // receive on pin 10 13 | TinyGPS gps; 14 | 15 | // To use a hardware serial port, which is far more efficient than 16 | // SoftwareSerial, uncomment this line and remove SoftwareSerial 17 | //#define SerialGPS Serial1 18 | 19 | // Offset hours from gps time (UTC) 20 | const int offset = 1; // Central European Time 21 | //const int offset = -5; // Eastern Standard Time (USA) 22 | //const int offset = -4; // Eastern Daylight Time (USA) 23 | //const int offset = -8; // Pacific Standard Time (USA) 24 | //const int offset = -7; // Pacific Daylight Time (USA) 25 | 26 | // Ideally, it should be possible to learn the time zone 27 | // based on the GPS position data. However, that would 28 | // require a complex library, probably incorporating some 29 | // sort of database using Eric Muller's time zone shape 30 | // maps, at http://efele.net/maps/tz/ 31 | 32 | time_t prevDisplay = 0; // when the digital clock was displayed 33 | 34 | void setup() 35 | { 36 | Serial.begin(9600); 37 | while (!Serial) ; // Needed for Leonardo only 38 | SerialGPS.begin(4800); 39 | Serial.println("Waiting for GPS time ... "); 40 | } 41 | 42 | void loop() 43 | { 44 | while (SerialGPS.available()) { 45 | if (gps.encode(SerialGPS.read())) { // process gps messages 46 | // when TinyGPS reports new data... 47 | unsigned long age; 48 | int Year; 49 | byte Month, Day, Hour, Minute, Second; 50 | gps.crack_datetime(&Year, &Month, &Day, &Hour, &Minute, &Second, NULL, &age); 51 | if (age < 500) { 52 | // set the Time to the latest GPS reading 53 | setTime(Hour, Minute, Second, Day, Month, Year); 54 | adjustTime(offset * SECS_PER_HOUR); 55 | } 56 | } 57 | } 58 | if (timeStatus()!= timeNotSet) { 59 | if (now() != prevDisplay) { //update the display only if the time has changed 60 | prevDisplay = now(); 61 | digitalClockDisplay(); 62 | } 63 | } 64 | } 65 | 66 | void digitalClockDisplay(){ 67 | // digital clock display of the time 68 | Serial.print(hour()); 69 | printDigits(minute()); 70 | printDigits(second()); 71 | Serial.print(" "); 72 | Serial.print(day()); 73 | Serial.print(" "); 74 | Serial.print(month()); 75 | Serial.print(" "); 76 | Serial.print(year()); 77 | Serial.println(); 78 | } 79 | 80 | void printDigits(int digits) { 81 | // utility function for digital clock display: prints preceding colon and leading 0 82 | Serial.print(":"); 83 | if(digits < 10) 84 | Serial.print('0'); 85 | Serial.print(digits); 86 | } 87 | 88 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/examples/TimeRTC/TimeRTC.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTC.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | */ 6 | 7 | #include 8 | #include 9 | #include // a basic DS1307 library that returns time as a time_t 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | while (!Serial) ; // wait until Arduino Serial Monitor opens 14 | setSyncProvider(RTC.get); // the function to get the time from the RTC 15 | if(timeStatus()!= timeSet) 16 | Serial.println("Unable to sync with the RTC"); 17 | else 18 | Serial.println("RTC has set the system time"); 19 | } 20 | 21 | void loop() 22 | { 23 | if (timeStatus() == timeSet) { 24 | digitalClockDisplay(); 25 | } else { 26 | Serial.println("The time has not been set. Please run the Time"); 27 | Serial.println("TimeRTCSet example, or DS1307RTC SetTime example."); 28 | Serial.println(); 29 | delay(4000); 30 | } 31 | delay(1000); 32 | } 33 | 34 | void digitalClockDisplay(){ 35 | // digital clock display of the time 36 | Serial.print(hour()); 37 | printDigits(minute()); 38 | printDigits(second()); 39 | Serial.print(" "); 40 | Serial.print(day()); 41 | Serial.print(" "); 42 | Serial.print(month()); 43 | Serial.print(" "); 44 | Serial.print(year()); 45 | Serial.println(); 46 | } 47 | 48 | void printDigits(int digits){ 49 | // utility function for digital clock display: prints preceding colon and leading 0 50 | Serial.print(":"); 51 | if(digits < 10) 52 | Serial.print('0'); 53 | Serial.print(digits); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/examples/TimeRTCSet/TimeRTCSet.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTCSet.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | * RTC clock is set in response to serial port time message 6 | * A Processing example sketch to set the time is included in the download 7 | * On Linux, you can use "date +T%s > /dev/ttyACM0" (UTC time zone) 8 | */ 9 | 10 | #include 11 | #include 12 | #include // a basic DS1307 library that returns time as a time_t 13 | 14 | 15 | void setup() { 16 | Serial.begin(9600); 17 | while (!Serial) ; // Needed for Leonardo only 18 | setSyncProvider(RTC.get); // the function to get the time from the RTC 19 | if (timeStatus() != timeSet) 20 | Serial.println("Unable to sync with the RTC"); 21 | else 22 | Serial.println("RTC has set the system time"); 23 | } 24 | 25 | void loop() 26 | { 27 | if (Serial.available()) { 28 | time_t t = processSyncMessage(); 29 | if (t != 0) { 30 | RTC.set(t); // set the RTC and the system time to the received value 31 | setTime(t); 32 | } 33 | } 34 | digitalClockDisplay(); 35 | delay(1000); 36 | } 37 | 38 | void digitalClockDisplay(){ 39 | // digital clock display of the time 40 | Serial.print(hour()); 41 | printDigits(minute()); 42 | printDigits(second()); 43 | Serial.print(" "); 44 | Serial.print(day()); 45 | Serial.print(" "); 46 | Serial.print(month()); 47 | Serial.print(" "); 48 | Serial.print(year()); 49 | Serial.println(); 50 | } 51 | 52 | void printDigits(int digits){ 53 | // utility function for digital clock display: prints preceding colon and leading 0 54 | Serial.print(":"); 55 | if(digits < 10) 56 | Serial.print('0'); 57 | Serial.print(digits); 58 | } 59 | 60 | /* code to process time sync messages from the serial port */ 61 | #define TIME_HEADER "T" // Header tag for serial time sync message 62 | 63 | unsigned long processSyncMessage() { 64 | unsigned long pctime = 0L; 65 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 66 | 67 | if(Serial.find(TIME_HEADER)) { 68 | pctime = Serial.parseInt(); 69 | return pctime; 70 | if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater than Jan 1 2013) 71 | pctime = 0L; // return 0 to indicate that the time is not valid 72 | } 73 | } 74 | return pctime; 75 | } 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/examples/TimeSerial/TimeSerial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeSerial.pde 3 | * example code illustrating Time library set through serial port messages. 4 | * 5 | * Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970) 6 | * you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2013 7 | T1357041600 8 | * 9 | * A Processing example sketch to automatically send the messages is included in the download 10 | * On Linux, you can use "date +T%s\n > /dev/ttyACM0" (UTC time zone) 11 | */ 12 | 13 | #include 14 | 15 | #define TIME_HEADER "T" // Header tag for serial time sync message 16 | #define TIME_REQUEST 7 // ASCII bell character requests a time sync message 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | while (!Serial) ; // Needed for Leonardo only 21 | pinMode(13, OUTPUT); 22 | setSyncProvider( requestSync); //set function to call when sync required 23 | Serial.println("Waiting for sync message"); 24 | } 25 | 26 | void loop(){ 27 | if (Serial.available()) { 28 | processSyncMessage(); 29 | } 30 | if (timeStatus()!= timeNotSet) { 31 | digitalClockDisplay(); 32 | } 33 | if (timeStatus() == timeSet) { 34 | digitalWrite(13, HIGH); // LED on if synced 35 | } else { 36 | digitalWrite(13, LOW); // LED off if needs refresh 37 | } 38 | delay(1000); 39 | } 40 | 41 | void digitalClockDisplay(){ 42 | // digital clock display of the time 43 | Serial.print(hour()); 44 | printDigits(minute()); 45 | printDigits(second()); 46 | Serial.print(" "); 47 | Serial.print(day()); 48 | Serial.print(" "); 49 | Serial.print(month()); 50 | Serial.print(" "); 51 | Serial.print(year()); 52 | Serial.println(); 53 | } 54 | 55 | void printDigits(int digits){ 56 | // utility function for digital clock display: prints preceding colon and leading 0 57 | Serial.print(":"); 58 | if(digits < 10) 59 | Serial.print('0'); 60 | Serial.print(digits); 61 | } 62 | 63 | 64 | void processSyncMessage() { 65 | unsigned long pctime; 66 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 67 | 68 | if(Serial.find(TIME_HEADER)) { 69 | pctime = Serial.parseInt(); 70 | if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013) 71 | setTime(pctime); // Sync Arduino clock to the time received on the serial port 72 | } 73 | } 74 | } 75 | 76 | time_t requestSync() 77 | { 78 | Serial.write(TIME_REQUEST); 79 | return 0; // the time will be sent later in response to serial mesg 80 | } 81 | 82 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/examples/TimeTeensy3/TimeTeensy3.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTC.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | */ 6 | 7 | #include 8 | 9 | void setup() { 10 | // set the Time library to use Teensy 3.0's RTC to keep time 11 | setSyncProvider(getTeensy3Time); 12 | 13 | Serial.begin(115200); 14 | while (!Serial); // Wait for Arduino Serial Monitor to open 15 | delay(100); 16 | if (timeStatus()!= timeSet) { 17 | Serial.println("Unable to sync with the RTC"); 18 | } else { 19 | Serial.println("RTC has set the system time"); 20 | } 21 | } 22 | 23 | void loop() { 24 | if (Serial.available()) { 25 | time_t t = processSyncMessage(); 26 | if (t != 0) { 27 | Teensy3Clock.set(t); // set the RTC 28 | setTime(t); 29 | } 30 | } 31 | digitalClockDisplay(); 32 | delay(1000); 33 | } 34 | 35 | void digitalClockDisplay() { 36 | // digital clock display of the time 37 | Serial.print(hour()); 38 | printDigits(minute()); 39 | printDigits(second()); 40 | Serial.print(" "); 41 | Serial.print(day()); 42 | Serial.print(" "); 43 | Serial.print(month()); 44 | Serial.print(" "); 45 | Serial.print(year()); 46 | Serial.println(); 47 | } 48 | 49 | time_t getTeensy3Time() 50 | { 51 | return Teensy3Clock.get(); 52 | } 53 | 54 | /* code to process time sync messages from the serial port */ 55 | #define TIME_HEADER "T" // Header tag for serial time sync message 56 | 57 | unsigned long processSyncMessage() { 58 | unsigned long pctime = 0L; 59 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 60 | 61 | if(Serial.find(TIME_HEADER)) { 62 | pctime = Serial.parseInt(); 63 | return pctime; 64 | if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater than Jan 1 2013) 65 | pctime = 0L; // return 0 to indicate that the time is not valid 66 | } 67 | } 68 | return pctime; 69 | } 70 | 71 | void printDigits(int digits){ 72 | // utility function for digital clock display: prints preceding colon and leading 0 73 | Serial.print(":"); 74 | if(digits < 10) 75 | Serial.print('0'); 76 | Serial.print(digits); 77 | } 78 | 79 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Time 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | time_t KEYWORD1 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | now KEYWORD2 13 | second KEYWORD2 14 | minute KEYWORD2 15 | hour KEYWORD2 16 | day KEYWORD2 17 | month KEYWORD2 18 | year KEYWORD2 19 | isAM KEYWORD2 20 | isPM KEYWORD2 21 | weekday KEYWORD2 22 | setTime KEYWORD2 23 | adjustTime KEYWORD2 24 | setSyncProvider KEYWORD2 25 | setSyncInterval KEYWORD2 26 | timeStatus KEYWORD2 27 | TimeLib KEYWORD2 28 | ####################################### 29 | # Instances (KEYWORD2) 30 | ####################################### 31 | 32 | ####################################### 33 | # Constants (LITERAL1) 34 | ####################################### 35 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Time", 3 | "frameworks": "Arduino", 4 | "keywords": "Time, date, hour, minute, second, day, week, month, year, RTC", 5 | "description": "Time keeping library", 6 | "url": "http://playground.arduino.cc/Code/Time", 7 | "authors": 8 | [ 9 | { 10 | "name": "Michael Margolis" 11 | }, 12 | { 13 | "name": "Paul Stoffregen" 14 | } 15 | ], 16 | "repository": 17 | { 18 | "type": "git", 19 | "url": "https://github.com/PaulStoffregen/Time" 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/Time/library.properties: -------------------------------------------------------------------------------- 1 | name=Time 2 | version=1.5 3 | author=Michael Margolis 4 | maintainer=Paul Stoffregen 5 | sentence=Timekeeping functionality for Arduino 6 | paragraph=Date and Time functions, with provisions to synchronize to external time sources like GPS and NTP (Internet). This library is often used together with TimeAlarms and DS1307RTC. 7 | category=Timing 8 | url=http://playground.arduino.cc/code/time 9 | architectures=* 10 | 11 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.3.2, released on 25 Nov 2015. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/doc/index.css: -------------------------------------------------------------------------------- 1 | ul { 2 | list-style-type: none ; 3 | } 4 | 5 | ul.contents { 6 | padding: 0 ; 7 | } 8 | 9 | table { 10 | border: none ; 11 | border-spacing: 0 ; 12 | border-collapse: collapse ; 13 | } 14 | 15 | td { 16 | vertical-align: top ; 17 | padding: 0 ; 18 | text-align: left ; 19 | line-height: 1.25 ; 20 | width: 15% ; 21 | } 22 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/doc/logo.gif -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/doc/lua.1: -------------------------------------------------------------------------------- 1 | .TH LUA 1 "$Date: 2014/12/10 15:55:45 $" 2 | .SH NAME 3 | lua \- Lua interpreter 4 | .SH SYNOPSIS 5 | .B lua 6 | [ 7 | .I options 8 | ] 9 | [ 10 | .I script 11 | [ 12 | .I args 13 | ] 14 | ] 15 | .SH DESCRIPTION 16 | .B lua 17 | is the standalone Lua interpreter. 18 | It loads and executes Lua programs, 19 | either in textual source form or 20 | in precompiled binary form. 21 | (Precompiled binaries are output by 22 | .BR luac , 23 | the Lua compiler.) 24 | .B lua 25 | can be used as a batch interpreter and also interactively. 26 | .LP 27 | The given 28 | .I options 29 | are handled in order and then 30 | the Lua program in file 31 | .I script 32 | is loaded and executed. 33 | The given 34 | .I args 35 | are available to 36 | .I script 37 | as strings in a global table named 38 | .BR arg . 39 | If no options or arguments are given, 40 | then 41 | .B "\-v \-i" 42 | is assumed when the standard input is a terminal; 43 | otherwise, 44 | .B "\-" 45 | is assumed. 46 | .LP 47 | In interactive mode, 48 | .B lua 49 | prompts the user, 50 | reads lines from the standard input, 51 | and executes them as they are read. 52 | If the line contains an expression or list of expressions, 53 | then the line is evaluated and the results are printed. 54 | If a line does not contain a complete statement, 55 | then a secondary prompt is displayed and 56 | lines are read until a complete statement is formed or 57 | a syntax error is found. 58 | .LP 59 | At the very start, 60 | before even handling the command line, 61 | .B lua 62 | checks the contents of the environment variables 63 | .B LUA_INIT_5_3 64 | or 65 | .BR LUA_INIT , 66 | in that order. 67 | If the contents is of the form 68 | .RI '@ filename ', 69 | then 70 | .I filename 71 | is executed. 72 | Otherwise, the string is assumed to be a Lua statement and is executed. 73 | .SH OPTIONS 74 | .TP 75 | .BI \-e " stat" 76 | execute statement 77 | .IR stat . 78 | .TP 79 | .B \-i 80 | enter interactive mode after executing 81 | .IR script . 82 | .TP 83 | .BI \-l " name" 84 | execute the equivalent of 85 | .IB name =require(' name ') 86 | before executing 87 | .IR script . 88 | .TP 89 | .B \-v 90 | show version information. 91 | .TP 92 | .B \-E 93 | ignore environment variables. 94 | .TP 95 | .B \-\- 96 | stop handling options. 97 | .TP 98 | .B \- 99 | stop handling options and execute the standard input as a file. 100 | .SH "SEE ALSO" 101 | .BR luac (1) 102 | .br 103 | The documentation at lua.org, 104 | especially section 7 of the reference manual. 105 | .SH DIAGNOSTICS 106 | Error messages should be self explanatory. 107 | .SH AUTHORS 108 | R. Ierusalimschy, 109 | L. H. de Figueiredo, 110 | W. Celes 111 | .\" EOF 112 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | color: gray ; 12 | float: right ; 13 | font-family: inherit ; 14 | font-style: normal ; 15 | font-size: small ; 16 | } 17 | 18 | h2:before { 19 | content: "" ; 20 | padding-right: 0em ; 21 | } 22 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9 2015/03/06 19:49:50 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 "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 20 | 0x00, /* EOZ */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | }; 54 | 55 | #endif /* } */ 56 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 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 getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 36 | LUAI_FUNC void luaG_traceexec (lua_State *L); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.28 2015/11/23 11:29:43 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 21 | ** at every check. 22 | */ 23 | #define luaD_checkstackaux(L,n,pre,pos) \ 24 | if (L->stack_last - L->top <= (n)) \ 25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } 26 | 27 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,,) 29 | 30 | 31 | 32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 34 | 35 | 36 | /* type of protected functions, to be ran by 'runprotected' */ 37 | typedef void (*Pfunc) (lua_State *L, void *ud); 38 | 39 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 40 | const char *mode); 41 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 45 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 46 | ptrdiff_t oldtop, ptrdiff_t ef); 47 | LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, 48 | int nres); 49 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 50 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 51 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 52 | LUAI_FUNC void luaD_inctop (lua_State *L); 53 | 54 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 55 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 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 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | /* 33 | ** Upvalues for Lua closures 34 | */ 35 | struct UpVal { 36 | TValue *v; /* points to stack or to its own value */ 37 | lu_mem refcount; /* reference counter */ 38 | union { 39 | struct { /* (when open) */ 40 | UpVal *next; /* linked list */ 41 | int touched; /* mark to avoid cycles with dead threads */ 42 | } open; 43 | TValue value; /* the value (when closed) */ 44 | } u; 45 | }; 46 | 47 | #define upisopen(up) ((up)->v != &(up)->u.value) 48 | 49 | 50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 55 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 56 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 57 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 58 | int pc); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove _PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {"_G", luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | #if defined(LUA_COMPAT_BITLIB) 54 | {LUA_BITLIBNAME, luaopen_bit32}, 55 | #endif 56 | {NULL, NULL} 57 | }; 58 | 59 | 60 | LUALIB_API void luaL_openlibs (lua_State *L) { 61 | const luaL_Reg *lib; 62 | /* "require" functions from 'loadedlibs' and set results to global table */ 63 | for (lib = loadedlibs; lib->func; lib++) { 64 | luaL_requiref(L, lib->name, lib->func, 1); 65 | lua_pop(L, 1); /* remove lib */ 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.78 2014/10/29 15:38:24 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | #if !defined(LUA_ENV) 18 | #define LUA_ENV "_ENV" 19 | #endif 20 | 21 | 22 | /* 23 | * WARNING: if you change the order of this enumeration, 24 | * grep "ORDER RESERVED" 25 | */ 26 | enum RESERVED { 27 | /* terminal symbols denoted by reserved words */ 28 | TK_AND = FIRST_RESERVED, TK_BREAK, 29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 32 | /* other terminal symbols */ 33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 34 | TK_SHL, TK_SHR, 35 | TK_DBCOLON, TK_EOS, 36 | TK_FLT, TK_INT, TK_NAME, TK_STRING 37 | }; 38 | 39 | /* number of reserved words */ 40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | lua_Integer i; 46 | TString *ts; 47 | } SemInfo; /* semantics information */ 48 | 49 | 50 | typedef struct Token { 51 | int token; 52 | SemInfo seminfo; 53 | } Token; 54 | 55 | 56 | /* state of the lexer plus state of the parser when shared by all 57 | functions */ 58 | typedef struct LexState { 59 | int current; /* current character (charint) */ 60 | int linenumber; /* input line counter */ 61 | int lastline; /* line of last token 'consumed' */ 62 | Token t; /* current token */ 63 | Token lookahead; /* look ahead token */ 64 | struct FuncState *fs; /* current function (parser) */ 65 | struct lua_State *L; 66 | ZIO *z; /* input stream */ 67 | Mbuffer *buff; /* buffer for tokens */ 68 | Table *h; /* to avoid collection/reuse strings */ 69 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 70 | TString *source; /* current source name */ 71 | TString *envn; /* environment variable name */ 72 | char decpoint; /* locale decimal point */ 73 | } LexState; 74 | 75 | 76 | LUAI_FUNC void luaX_init (lua_State *L); 77 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 78 | TString *source, int firstchar); 79 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 80 | LUAI_FUNC void luaX_next (LexState *ls); 81 | LUAI_FUNC int luaX_lookahead (LexState *ls); 82 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 83 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 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 | 17 | /* 18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where 19 | ** each element has size 'e'. In case of arithmetic overflow of the 20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because 21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). 22 | ** 23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 24 | ** comparison avoids a runtime comparison when overflow cannot occur. 25 | ** The compiler should be able to optimize the real test by itself, but 26 | ** when it does it, it may give a warning about "comparison is always 27 | ** false due to limited range of data type"; the +1 tricks the compiler, 28 | ** avoiding this warning but also this optimization.) 29 | */ 30 | #define luaM_reallocv(L,b,on,n,e) \ 31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ 32 | ? luaM_toobig(L) : cast_void(0)) , \ 33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 34 | 35 | /* 36 | ** Arrays of chars do not need any test 37 | */ 38 | #define luaM_reallocvchar(L,b,on,n) \ 39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 40 | 41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 44 | 45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 47 | #define luaM_newvector(L,n,t) \ 48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 49 | 50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 51 | 52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 53 | if ((nelems)+1 > (size)) \ 54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 55 | 56 | #define luaM_reallocvector(L, v,oldn,n,t) \ 57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 58 | 59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 60 | 61 | /* not to be called directly */ 62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 63 | size_t size); 64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 65 | size_t size_elem, int limit, 66 | const char *what); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 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 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | 17 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 18 | #define sizeudata(u) sizeludata((u)->len) 19 | 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | 24 | /* 25 | ** test whether a string is a reserved word 26 | */ 27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 28 | 29 | 30 | /* 31 | ** equality for short strings, which are always internalized 32 | */ 33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 34 | 35 | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_clearcache (global_State *g); 41 | LUAI_FUNC void luaS_init (lua_State *L); 42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.21 2015/11/03 15:47:30 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 gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->i_key.nk.next) 16 | 17 | 18 | /* 'const' to avoid wrong writings that can mess up field 'next' */ 19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) 20 | 21 | /* 22 | ** writable version of 'gkey'; allows updates to individual fields, 23 | ** but not to the whole (which has incompatible type) 24 | */ 25 | #define wgkey(n) (&(n)->i_key.nk) 26 | 27 | #define invalidateTMcache(t) ((t)->flags = 0) 28 | 29 | 30 | /* returns the key, given the value of a table entry */ 31 | #define keyfromval(v) \ 32 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 33 | 34 | 35 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 36 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 37 | TValue *value); 38 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 39 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 40 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 41 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 42 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 43 | LUAI_FUNC Table *luaH_new (lua_State *L); 44 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 45 | unsigned int nhsize); 46 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 47 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 48 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 49 | LUAI_FUNC int luaH_getn (Table *t); 50 | 51 | 52 | #if defined(LUA_DEBUG) 53 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 54 | LUAI_FUNC int luaH_isdummy (Node *n); 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.21 2014/10/25 11:50:46 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" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_N /* number of elements in the enum */ 44 | } TMS; 45 | 46 | 47 | 48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 50 | 51 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 52 | 53 | #define ttypename(x) luaT_typenames_[(x) + 1] 54 | #define objtypename(x) ttypename(ttnov(x)) 55 | 56 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 57 | 58 | 59 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 60 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 61 | TMS event); 62 | LUAI_FUNC void luaT_init (lua_State *L); 63 | 64 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 65 | const TValue *p2, TValue *p3, int hasres); 66 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 67 | StkId res, TMS event); 68 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 69 | StkId res, TMS event); 70 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 71 | const TValue *p2, TMS event); 72 | 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 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 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_UTF8LIBNAME "utf8" 33 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 34 | 35 | #define LUA_BITLIBNAME "bit32" 36 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | 53 | #if !defined(lua_assert) 54 | #define lua_assert(x) ((void)0) 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/Libraries/lua-5.3.2/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/OBJ/ArInp.Scr: -------------------------------------------------------------------------------- 1 | --create ..\OBJ\Pro.lib 2 | ..\obj\arduino.o 3 | ..\obj\dtostrf.o 4 | ..\obj\itoa.o 5 | ..\obj\print.o 6 | ..\obj\stream.o 7 | ..\obj\wstring.o 8 | ..\obj\wmath.o 9 | ..\obj\hardwareserial.o 10 | ..\obj\wirebase.o 11 | ..\obj\wire.o 12 | ..\obj\spi.o 13 | ..\obj\delay.o 14 | ..\obj\gpio.o 15 | ..\obj\usart.o 16 | ..\obj\pwm.o 17 | ..\obj\time_exti.o 18 | ..\obj\exti.o 19 | ..\obj\adc.o 20 | ..\obj\main.o 21 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/OBJ/Pro.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/OBJ/Pro.lib -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/README.txt -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/USER/C_call_CPP.h: -------------------------------------------------------------------------------- 1 | #ifndef __C_CALL_CPP 2 | #define __C_CALL_CPP 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | //Place "C" functions declaration 9 | 10 | void Lua_output(const char *s); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/USER/EventRecorderStub.scvd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/USER/FileGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef __FILEGROUP_H 2 | #define __FILEGROUP_H 3 | 4 | //*************C/C++ Library**************// 5 | 6 | #include "stm32f4xx.h" 7 | #include "Arduino.h" 8 | #include "delay.h" 9 | #include "exti.h" 10 | #include "gpio.h" 11 | #include "adc.h" 12 | #include "pwm.h" 13 | #include "usart.h" 14 | #include "time_exti.h" 15 | #include "math.h" 16 | #include "WMath.h" 17 | #include "Tone.h" 18 | 19 | #include "HardwareSerial.h" 20 | #include "SPI.h" 21 | #include "Wire.h" 22 | #include "WString.h" 23 | #include "Stream.h" 24 | 25 | #include "C_call_CPP.h" 26 | #include "lua.hpp" 27 | #include "LTDC_Graphic.h" 28 | 29 | int Lua_millis(lua_State *L); 30 | int Lua_delay(lua_State *L); 31 | int Lua_pinMode(lua_State *L); 32 | int Lua_togglePin(lua_State *L); 33 | int Lua_digitalWrite(lua_State *L); 34 | int Lua_digitalRead(lua_State *L); 35 | int Lua_analogWrite(lua_State *L); 36 | int Lua_analogRead(lua_State *L); 37 | 38 | extern LTDC_Graphic tft; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/USER/RTE/Device/STM32F429II/RTE_Device.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/USER/RTE/Device/STM32F429II/RTE_Device.h -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/USER/RTE/Device/STM32F429ZG/RTE_Device.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/USER/RTE/Device/STM32F429ZG/RTE_Device.h -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/USER/RTE/Device/STM32F429ZI/RTE_Device.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FASTSHIFT/Lua-For-STM32/f9fdc488b1aa0d3d2836e3ba0c415e78fb5aab7d/Lua 5.3_STM32F4xx/USER/RTE/Device/STM32F429ZI/RTE_Device.h -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/USER/RTE/_Project/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Component Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'Pro' 7 | * Target: 'Project' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "stm32f4xx.h" 18 | 19 | #define RTE_DEVICE_STARTUP_STM32F4xx /* Device Startup for STM32F4 */ 20 | #define RTE_DEVICE_STDPERIPH_ADC 21 | #define RTE_DEVICE_STDPERIPH_DCMI 22 | #define RTE_DEVICE_STDPERIPH_DMA 23 | #define RTE_DEVICE_STDPERIPH_DMA2D 24 | #define RTE_DEVICE_STDPERIPH_EXTI 25 | #define RTE_DEVICE_STDPERIPH_FLASH 26 | #define RTE_DEVICE_STDPERIPH_FMC 27 | #define RTE_DEVICE_STDPERIPH_FRAMEWORK 28 | #define RTE_DEVICE_STDPERIPH_GPIO 29 | #define RTE_DEVICE_STDPERIPH_I2C 30 | #define RTE_DEVICE_STDPERIPH_LTDC 31 | #define RTE_DEVICE_STDPERIPH_RCC 32 | #define RTE_DEVICE_STDPERIPH_SPI 33 | #define RTE_DEVICE_STDPERIPH_SYSCFG 34 | #define RTE_DEVICE_STDPERIPH_TIM 35 | #define RTE_DEVICE_STDPERIPH_USART 36 | 37 | #endif /* RTE_COMPONENTS_H */ 38 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/USER/main.cpp: -------------------------------------------------------------------------------- 1 | #include "FileGroup.h" 2 | 3 | LTDC_Graphic tft(320,240); 4 | 5 | uint8_t LuaRunning=0; 6 | 7 | void Lua_Stop() 8 | { 9 | if(LuaRunning) 10 | { 11 | if(Serial.read()=='C') 12 | { 13 | NVIC_SystemReset(); 14 | } 15 | else Serial.flush(); 16 | } 17 | } 18 | 19 | int main(void) 20 | { 21 | Delay_Init(); 22 | ADCx_Init(ADC1); 23 | tft.init(); 24 | tft.setBackColor(LCD_COLOR_BLACK); 25 | tft.setTextColor(LCD_COLOR_WHITE); 26 | tft.setFont(&Font8x12); 27 | tft.clear(); 28 | 29 | Serial.begin(115200); 30 | Serial.println("\r\nInitializing..."); 31 | tft.println("Initializing..."); 32 | Serial.setTimeout(10); 33 | Serial.attachInterrupt(Lua_Stop); 34 | 35 | int error=0; 36 | lua_State *L = luaL_newstate(); 37 | luaL_openlibs(L); 38 | 39 | lua_register(L, "millis", Lua_millis); 40 | lua_register(L, "delay", Lua_delay); 41 | lua_register(L, "pinMode", Lua_pinMode); 42 | lua_register(L, "togglePin", Lua_togglePin); 43 | lua_register(L, "digitalWrite", Lua_digitalWrite); 44 | lua_register(L, "digitalRead", Lua_digitalRead); 45 | lua_register(L, "analogWrite", Lua_analogWrite); 46 | lua_register(L, "analogRead", Lua_analogRead); 47 | 48 | luaL_dostring(L,"print(\"> Version:\",_VERSION)"); 49 | while (1) 50 | { 51 | if(Serial.available()) 52 | { 53 | String LuaCode = Serial.readString(); 54 | char *LuaCode_buffer = new char[LuaCode.length()+10]; 55 | 56 | // tft.clear(); 57 | // tft.println("\r\nCode:\r\n"); 58 | tft.setTextColor(LCD_COLOR_MAGENTA); 59 | tft << "\r\n" << LuaCode; 60 | tft.setTextColor(LCD_COLOR_WHITE); 61 | // tft.printf("\r\n(Size: %d )\r\n",LuaCode.length()); 62 | 63 | Serial.println("\r\nCode:\r\n"); 64 | Serial.println(LuaCode); 65 | Serial.printf("\r\n(Size: %d )\r\n",LuaCode.length()); 66 | LuaCode.toCharArray(LuaCode_buffer,LuaCode.length()+10); 67 | 68 | Serial.print("\r\n> "); 69 | tft.print("\r\n> "); 70 | LuaRunning = 1; 71 | error = luaL_loadbuffer(L, LuaCode_buffer, strlen(LuaCode_buffer), "line") || lua_pcall(L, 0, 0, 0); 72 | delete []LuaCode_buffer; 73 | LuaRunning = 0; 74 | } 75 | if (error) 76 | { 77 | Serial.println(lua_tostring(L, -1)); 78 | tft.setTextColor(LCD_COLOR_RED); 79 | tft << lua_tostring(L, -1); 80 | tft.setTextColor(LCD_COLOR_WHITE); 81 | error = 0; 82 | LuaRunning = 0; 83 | //lua_pop(L, 1); 84 | } 85 | } 86 | //lua_close(L); 87 | } 88 | -------------------------------------------------------------------------------- /Lua 5.3_STM32F4xx/desktop.ini: -------------------------------------------------------------------------------- 1 | [ViewState] 2 | Mode= 3 | Vid= 4 | FolderType=Generic 5 | [.ShellClassInfo] 6 | IconResource=C:\WINDOWS\System32\SHELL32.dll,306 7 | --------------------------------------------------------------------------------